-
Notifications
You must be signed in to change notification settings - Fork 237
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
Changing the SteelCore semantics and the Steel libraries to use tokens for invariants #2817
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
…l_witnessed_tokens
This reverts commit 11c85c8.
Thanks Nik for merging. |
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.
In response to issue #2814 , this PR revises the monotonic state effect in FStar.MST and MSTTotal to use an explicit token for the witnessed predicate.
This change bubbles up through to Steel as an explicit token for invariants too.
Recapping the changes here, as discussed also on #2814
The main change is that inv p is now also an explicit token of type Type0 and the
i >--> p
prop is no longer visible in the Steel.Memory interface.Additionally, the libraries that provide monotonic references are changed to provide their own witnessed tokens, rather than just providing prop-based witnesses.
The new_invariant, with_invariant and with_invariant_g operations are no longer ghost, since this would allow them to reveal an erased (witnessed p) as a witnessed p and break the abstraction. Instead, with_invariant_g is now classified as SteelAtomic unobservable and with_invariariant is parametric in the observability flag of computation it takes as argument.
All the Steel files (except one, noted below) in the F* repo work again without significant change. Also, the Zeta project is also not significantly impacted.
However, the this change results in a loss of expressiveness since it is no longer possible to turn an invariant into an slprop/vprop. That is,
pure (i >--> p)
is no longer expressible in the Steel---you need an explicit invariant token inv p. This results in a change to the style used in specifying the invariant of a lock-coupling list in Steel.LockCoupling.fsti. That invariants is now phrased using a combination of a inductive type that simultaneously specifies the type of a list cell and the invariant that the lock protects, combined with a recursive predicate on that structure, where the two interact via the use of fractional permissions.We also have extraction support for invariant-related constructs in F*. It is important from the F* type checker's perspective that witnessed and hence inv is not an erasable type. However, for concrete executions, these tokens have no information content (since they are only eliminated by recall, an axiom). So, in FStar.Extraction.ML.Term, applying to extracting Steel to both OCaml and C, we now
With these changes, the extraction behavior is mostly unchanged:
For example,
is extracted to ML as
and via krml (which does unit elimination) to C as