How about <br><br> #:mode (sum I I O)<br><br>for the mode spec where the #:mode keyword is optional but, if present must be followed by what looks like a use of the relation but with a<br>Mode?<br><br>Robby<br><br>On Friday, August 5, 2011, Casey Klein <<a href="mailto:clklein@eecs.northwestern.edu">clklein@eecs.northwestern.edu</a>> wrote:<br>
> On Fri, Aug 5, 2011 at 8:13 AM, <<a href="mailto:clklein@racket-lang.org">clklein@racket-lang.org</a>> wrote:<br>>> clklein has updated `master' from 1a65678924 to 576272362b.<br>>> <a href="http://git.racket-lang.org/plt/1a65678924..576272362b">http://git.racket-lang.org/plt/1a65678924..576272362b</a><br>
>><br>><br>> This push adds a more general way to define relations in Redex,<br>> currently under the name define-judgment-form. For those of you<br>> familiar with the existing define-relation form, this new form lifts<br>
> the restriction that relations have no outputs when executed. In<br>> particular, it lets you specify which positions are inputs and which<br>> are outputs, and it statically checks that the outputs can be computed<br>
> from the inputs without "guessing" any intermediate values.<br>><br>> Here's a simple example:<br>><br>> (define-language nats<br>> (n z (s n)))<br>><br>> (define-judgment-form nats<br>
> mode : O O I<br>> sum ⊆ n × n × n<br>> [(sum z n n)]<br>> [(sum (s n_1) n_2 (s n_3))<br>> (sum n_1 n_2 n_3)])<br>><br>>> (judgment-holds (sum (s (s z)) (s z) (s (s (s z)))))<br>> true<br>
>> (judgment-holds (sum (s (s z)) (s z) (s (s z))))<br>> false<br>>> (judgment-holds (sum (s z) n (s (s z))) n)<br>> `((s z))<br>>> (judgment-holds (sum n_1 n_2 (s (s z))) (n_1 n_2))<br>> `(((s (s z)) z) ((s z) (s z)) (z (s (s z))))<br>
><br>> I see three use cases:<br>><br>> 1. Defining type systems in a way that supports mechanized<br>> typesetting. Here's an example:<br>><br>> <a href="https://gist.github.com/1128672">https://gist.github.com/1128672</a><br>
><br>> There are still plenty of type systems Redex can't express, but the<br>> new form gets a lot of low-hanging fruit.<br>><br>> 2. Defining structural operational semantics in a way that supports<br>
> mechanized typesetting. Here's an example:<br>><br>> <a href="https://gist.github.com/1128685">https://gist.github.com/1128685</a><br>><br>> Relations defined in this way don't work directly with traces. You can<br>
> embed them in reduction-relation, as the example demonstrates, but you<br>> lose out on edge labels. It shouldn't be too difficult to rig up<br>> something better, if this turns out to be important.<br>><br>
> 3. Defining relations using something like multi-valued metafunctions.<br>> Here's an example in which (add1 e) may reduce to 0.<br>><br>> <a href="https://gist.github.com/1128692">https://gist.github.com/1128692</a><br>
><br>> Any feedback is welcome, but I'm especially interested in opinions on<br>> two points:<br>><br>> 1. Is there a better name than define-judgment-form? I would have<br>> liked the name define-relation, if it weren't already taken. Is it OK<br>
> to overload it?<br>><br>> 2. Should mode declarations use a different syntax? I tried to do<br>> something in the paren-free style of define-relation contracts, but I<br>> don't like the result -- partially because I personally like parens,<br>
> partially because it makes it harder to give good error messages.<br>><br>> _________________________________________________<br>> For list-related administrative tasks:<br>> <a href="http://lists.racket-lang.org/listinfo/dev">http://lists.racket-lang.org/listinfo/dev</a>