tactics: ctrl_rewrite: perform rewrite under arrows; fix rewrite under dependent binders #3104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wanted to perform rewrites on the environment, but when I reverted the environment it wouldn't rewrite. It looks like ctrl_rewrite was missing part of the implementation.
Additionally, I believe that the handling of dependent binders in ctrl_rewrite was incorrect. For a function abstraction
fun (a: Type) (x: a) -> x
it was taking the binders[a: Type; x: a]
and computing a close substitution[a := bv@1; x := bv@0]
. But we can't apply that substitution to the binders, because the binderx: a
needs to refer to a with de bruijn index 0, not 1.At least, this is what I think was causing the rewriting problem that I saw. I suspect that this may not have come up often in the past because functions with dependent binders will occur more often in the environment than in the goal.
To rewrite under arrows, I only implemented rewrite for Total and GTotal computations. It wasn't clear to me what to do for effectful computations. (I assume that they won't occur in reverts, anyway.) How often does this case occur - should it perhaps print a warning?
While debugging, I also made some of the "Impossible" errors a little more searchable. (Is there an easier way to track down what threw the impossible?)