8.16.0.1
Redex Parameters🔗ℹ
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.
As expected, we can see what happens when we
step with r0-bad.
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.
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*.
We’ve replaced the non-starred variants from earlier,
with their starred counterparts.
Using the starred form gets you two things:
Here we introduce a parameter lang-number
that is bound to L0-number.
For L0 there is no difference between
r0 and r0-bad.
However if we do the extension as before,
the parameter’s default value will be
lifted to the current language.
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.
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.
|
|
parameters | | = | | | | | | | | #:parameters ([parameter default] ...) |
|
Defines
id
as a parameterized reduction relation.
Aside from parameters,
the syntax is the same as in
reduction-relation.
|
|
parameters | | = | | | | | | | | #:parameters ([parameter default] ...) |
|
Defines
id
as a parameterized reduction relation
that extends an existing one.
Aside from parameters,
the syntax is the same as in
extend-reduction-relation.
|
|
parameters | | = | | | | | | | | #:parameters ([parameter default] ...) |
|
Defines a parameterized metafunction.
Aside from parameters,
the syntax is the same as in
define-metafunction.
Parameterized metafunctions must have a contract.
|
|
parameters | | = | | | | | | | | #:parameters ([parameter default] ...) |
|
Defines a parameterized metafunction
that extends
metafunction-id.
Aside from parameters,
the syntax is the same as in
define-metafunction/extension.
Parameterized metafunctions must have a contract.
|
|
parameters | | = | | | | | | | | #:parameters ([parameter default] ...) |
|
Defines a parameterized judgment form.
Aside from parameters,
the syntax is the same as in
define-judgment-form.
Parameterized judgments may not be modeless.
(define-extended-judgment* judgment-id language | parameters | mode-spec | contract-spec | invariant-spec | rule ...) |
|
|
parameters | | = | | | | | | | | #:parameters ([parameter default] ...) |
|
Defines a parameterized judgment form
that extends
judgment-id.
Aside from parameters,
the syntax is the same as in
define-extended-judgment-form.
Parameterized judgments may not be modeless.
These are non-parameterized variants of the above
starred variants;
they are provided only for consistency.