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.
This PR simplifies somewhat the handling of delta_depths throughout the compiler. Currently, we have an
fv_delta : option delta_depth
field in everyfv
, which is mostly set by desugaring (which is a first problem, variables created by tactics usually have this depth wrong). Also, there is a way to compute the delta_depth dynamically from the environment inEnv.delta_depth_of_fv
, which actually looks at the definition of the variable. But, for some identifiers, it still falls back to thefv_delta
field, the reason being that using the legit delta_depth brings many regressions in the form of badly generated VCs (connectives get unfolded) or checking errors (connectives do not get unfolded when it matters, likelet f : ~p = return_squash ()
).The desugarer also had a big table of assumed delta_depths, most of which were not right, but which kept the thing working. For some connectives like
/\
, the desugarer would set the depth toDelta_constant_at_level 1
, but a conjunction created by the unifier (e.g. when meeting refinements), would useDelta_constant_at_level 0
, so we were in fact mixing different depths for a same given symbol.--
This PR removes the
fv_delta
field altogether, and centralizes the definition of what a delta_depth is in the typechecker (as a memoized function). Since the field is gone, the desugarer (and tactics) need not have a clue about delta_depths, so the magic tables are also now gone. This did require a patch in the unifier to handle cases like/\
above gracefully, though: when we're matching types, we do want to unfold/\
(it has a definition, we want to use it for constructive logic); but when matching propositions, such as refinement formulas, we do not. So the unifier now sets an extra flag for each problem stating whether the problem is logical or not, preventing unfolding connectives when so.The whole thing is still not very pretty, and there are some dubious transformations like this snippet, but it's definitely cleaner and getting a consistent state that passes everest was pretty tricky, so I'd like to merge this as it is.