-
Notifications
You must be signed in to change notification settings - Fork 18
Description
When dealing with program refinement (or really any domain with the notion of a meta-variable), capturing substitution is required. For example, consider the language and judgements below.
e ::= x (variables)
| \x.e (abstraction)
| e e (application)
| ?x (meta-variable)
| ?x.e (hole)
| ?x ~ e.e (guess)
pure e = b pure e1 = l pure e2 = r
----------------- ------------------ ----------------------------- -------------------
pure x = true pure \x.e = b pure e1 e2 = l ^ r pure ?x = true
-------------------- -----------------------------
pure ?x.e = false pure ?x ~ e1.e2 = false
pure e1
--------------------------------
solve ?x ~ e1.e2 = [e1/x]e2
Informally speaking, you can solve a hole if and only if the guess does not contain holes itself. However, the meta-variable substitution must capture variables. As a concrete example:
solve ?x ~ y. \y.?x = \y.y
.
As it currently stands, the only way to implement capturing substitutions (and metavariables) that I have come upon is pretty hacky, and any other way would require support in unbound itself.
In my mind, there are 2 options:
- Add
substCapturing :: AlphaCtx -> Name b -> b -> a -> a
as a method onSubst
- Add support for meta-variables directly
Seeing as the only reasonable use that I can think of for substCapturing
would be for implementing
meta-variables, I think that option 2 would be the best approach, but it has its downsides as well.
Either way, I can write up a PR to implement this if it seems like something that would be a useful addition.