-
Notifications
You must be signed in to change notification settings - Fork 77
Remove 'rewritingSharedContext' and related code. #2684
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
Conversation
|
Not looking super promising :-( |
6a38e31 to
3e21b62
Compare
|
I just force-pushed to 3e21b62: Instead of removing everything all at once, I'm now going to try removing a few rules at a time. I'm starting with the rules to remove |
3e21b62 to
3f428c2
Compare
Both of the rewriter conversions `remove_coerce` and `remove_unsafeCoerce` were blatantly type-unsafe. Fortunately neither was ever used.
Neither of the conversions `remove_ident_coerce` and `remove_ident_unsafeCoerce` needed to be a conversion: Both of these are expressible as ordinary rewrite rules, so we don't need either of them as conversions.
Such reductions can cause types on Pi binders to be rewritten, so that they no longer match the types annotated on occurrences of the bound variable. This in turn can cause type checking to fail, as one of the enforced invariants is that all 'Variable' subterms in the scope of a lambda or Pi should have a type that matches exactly.
4a7252f to
c138999
Compare
08050c7 to
5854c65
Compare
|
Removing |
Rewriting with basic_ss includes bvConversions.
|
Remove The test expects it to print out |
Now it will immediately return the list of elements instead of applying the SAWCore 'at' function to the whole list. Previously this relied on a rewritingSharedContext with vecConversions to simplify; this is no longer necessary.
|
Woo, it ran! |
|
Removing the EDIT: It turns out |
This is an adaptation to the removal of rewritingSharedContext, which used to perform tuple and record reductions as terms were built.
01c6aa6 to
66ef819
Compare
| case nameInfo (defName d) of | ||
| ModuleIdentifier ident -> ident `elem` excludedNames | ||
| ImportedName{} -> True | ||
| idents = ["Prelude.coerce_same", "Prelude.unsafeCoerce_same"] |
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.
I know that cryptol_ss is already a bit ad hoc, but it is interesting that we need to specifically add identifiers from the SAWCore prelude, not cryptol-saw-core's prelude, in order to make things work. This raises a number of questions when I read it:
- What determines which identifiers to add to
cryptol_ss? The SAW user manual entry gives the impression that it contains primarily Cryptol-specific rules, but clearly there's more to it than that. - Would these be better suited for
basic_ssthancryptol_ss? I'm not actually sure ifcryptol_ssis a superset ofbasic_ss, however. - Would it be worth documenting in more detail what
cryptol_ss/basic_sscontain in the SAW user manual?
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.
The purpose of cryptol_ss is to be able to take a SAWCore term translated from Cryptol, and reduce it down to basic SAWCore operations and types from the SAWCore prelude. One of the things that cryptol-saw-core does is to insert coercions to handle situations where e.g. symbolic array size types are equal (according to the Cryptol type checker) but not syntactically identical. We rely on coerce_same and unsafeCoerce_same to eliminate such coercions once the size types have been instantiated and reduced to literals.
I'll add some comments to that effect.
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.
See d035e7c.
| let sc = rewritingSharedContext sc0 ss | ||
| natType <- scNatType sc0 | ||
| ss <- scSimpset sc [] eqs [] :: IO (Simpset ()) | ||
| -- let sc = rewritingSharedContext sc0 ss |
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.
Remove this comment?
saw-core/src/SAWCore/SharedTerm.hs
Outdated
| emptyAppCache :: AppCache | ||
| emptyAppCache = emptyTFM | ||
|
|
||
| -- | Return term for application using existing term in cache if it is available. |
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 isn't your fault (the comment was like this before the PR), but I have a hard time parsing this sentence. I think some extra speech articles would help. Should this say something like "Return a term for an application, using an existing term in the cache if it is available"?
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.
See new haddocks in a1aa91c.
This makes it so that client code can't break the SharedContext abstraction by updating the 'scTermF' field.
81a605e to
4bce8d3
Compare
Fixes #2676.