Cameron Moy
This package implements forms for parameterized Redex objects (i.e. metafunctions, judgment forms, and reduction relations). When objects depend on one another, for example a reduction relation is defined using a metafunction, parameters can automatically lift dependencies from the lower language to a higher one.
Suppose we define a language L0, a metafunction L0-number-bad, and a reduction relation r0-bad. We will rely on this metafunction, defined for L0, in our reduction relation.
L0-number-bad:m->m[(L0-number-badm)0])L0
As expected, we can see what happens when we step with r0-bad.
'(0)
Why is r0-bad named as such? We’ve defined a reduction relation that depends on a language-specific metafunction. Unfortunately, extended reduction relations will break under these conditions. An extended reduction relation will lift all rules to the new language, but metafunction and judgment form dependencies will not be reinterpreted.
Here we’ve added to the m non-terminal. Since r1-bad extends r0-bad, every rule will be reinterpreted. The only case we have will match, but the metafunction L0-number-bad is undefined for strings. This will yield an error.
L0-number-bad: (L0-number-bad hi) is not in my domain
This package solve the problem by introducing parameters. We’ll instead define r0 with define-reduction-relation* and parameterize it by the metafunction defined with define-metafunction* .
L0-number:m->m[(L0-numberm)0])L0#:parameters([lang-numberL0-number])
Liftable. You can use the object as the value of a parameter.
Parameters. You can introduce parameters that will lift their values appropriately.
Here we introduce a parameter lang-number that is bound to L0-number. For L0 there is no difference between r0 and r0-bad.
'(0)
However if we do the extension as before, the parameter’s default value will be lifted to the current language.
'(0)
Now suppose instead of giving back a language level of 0, we’d like it to give back 1. One way to do this is to extend the original metafunction.
'(1)
As we just saw, if no metafunction extends the original parameter value, in our case L0-number, then it is lifted. However, if a metafunction does extend it, in this case L1-number, that will be used instead.
Parameters are not limited to just reduction relations. You can, for example, parameterize a judgment form by a metafunction or parameterize a metafunction by a reduction relation.
syntax
languageparametersdomaincodomainbase-arrowreduction-case...shortcuts)parameters =| #:parameters([parameterdefault]...)
syntax
reduction-relationlanguageparametersdomaincodomainbase-arrowreduction-case...shortcuts)parameters =| #:parameters([parameterdefault]...)
syntax
parametersmetafunction-contractmetafunction-case...)parameters =| #:parameters([parameterdefault]...)
syntax
parametersmetafunction-contractmetafunction-case...)parameters =| #:parameters([parameterdefault]...)
syntax
parametersmode-speccontract-specinvariant-specrule...)parameters =| #:parameters([parameterdefault]...)
syntax
parametersmode-speccontract-specinvariant-specrule...)parameters =| #:parameters([parameterdefault]...)
syntax
languagedomaincodomainbase-arrowreduction-case...shortcuts)syntax
reduction-relationlanguagedomaincodomainbase-arrowreduction-case...shortcuts)syntax
metafunction-contractmetafunction-case...)