-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing inconsistencies in inspect_ln #2882
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A correction: it requires a small patch to HACL* to change some |
10 tasks
mtzguido
approved these changes
Apr 12, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me. I'm just adding a test for it and relocating collect_app
into Tactics.SyntaxHelpers
. Fine with merging as soon as HACL takes the fix.
mtzguido
approved these changes
Apr 13, 2023
tahina-pro
added a commit
to FStarLang/steel
that referenced
this pull request
Apr 15, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Gabriel Ebner (@gebner) noticed that the reflection
inspect_ln
API compresses unification variables using the union-find graph in the typechecker. This means it is not a total function, and indeed can be used to prove assertions that are not valid at runtime:@nikswamy suggested that
inspect_ln
should not do this compression of uvars.While working on this, I noticed another quirk. The
Tv_Uvar
node in the reflection AST has anint
index. Ininspect_ln
we useSyntax.Unionfind.uvar_id
to fill in this field. However,uvar_id
returns the id of the root of the union-find tree that the uvar belongs to. This can evolve as the union-find graph evolves, and indeed we can write examples to exploit it:This PR has the following fixes:
inspect_ln
. However, we still need to push down delayed substitutions. So, the PR adds a new APIcompress_subst
toFStar.Syntax.Subst
.Tv_UVar
.collect_app
API inFStar.Tactics.Derived
that usesinspect
internally.The second change is done for both
inspect_ln
andinspect
. Otherwise,inspect
is unchanged.Impact on clients
This change breaks some code patterns in the existing code. For example, the steel tactic was doing something like this:
Where
R.collect_app
internally calls intoR.inspect_ln
to get the head constructor oft
.When
t
is a uvar, this is problematic, sinceT.inspect
will compress the uvar and may returnTv_App
, whileR.inspect_ln
will returnTv_UVar
.To sort out this confusion, the PR renames
R.collect_app
toR.collect_app_ln
and introduces aT.collect_app
that usesinspect
internally.Changing
R.collect_app
in the steel tactic toT.collect_app
restored it.The other changes were just related to renaming of
R.collect_app
toR.collect_app_ln
. If the client code was inTac
already, I changedR.collect_app
toT.collect_app
, else toR.collect_app_ln
.No changes are required in Everest, outside of F*.