-
Notifications
You must be signed in to change notification settings - Fork 62
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
Updates to Cryptol Monadification (+ add qsort
to saw-core)
#1844
Conversation
…ed into their pure type instead of their monadic type
…lM.sawcore to a Coq file
My initial thought is that I don't think we want an exponential explosion of different kinds of |
@eddywestbrook Oh, sorry for misunderstanding you! The worry I have with always bundling |
@m-yac I see your concern, and we certainly wouldn't want to |
Update: We realized what we really want here is some sort of typeclass system in saw-core (#1845). At least, that was the best solution we could think of that was equally as easy to use as the current solution of having special |
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 mostly looks great! Please perform the small doc changes I requested. I'll mark as "approve" assuming that you'll make those changes and merge yourself.
This PR mainly makes the following changes to Cryptol Monadification:
write_coq_cryptol_module_monadic
command which monadifies all definitions in a Cryptol module and writes them to a Coq fileCryptolM.sawcore
to a Coq file ingenerate_scaffolding.saw
FIXME
s inCryptolM.sawcore
. This mostly involved the mostly mechanical task of translating theCryptol.sawcore
definitions into theSpecM
monad (which I did while waiting for things to compile) but also involved adding anuncurryMacro
and generalizing thefinMacro
inMonadify.hs
However, it also adds a new type of sort,
qsort
, to saw-core. Like the existingisort
, it is ignored during saw-core typechecking, but when translated to Coq adds an implicit typeclass argument. Forisort
this is theInhabited
typeclass, but forqsort
this is theQuantType
typeclass (needed for theexistsS
combinator and theCryptolM
functions that use it, such asvecMapM
and the number functions that in turn use that). This involved:Bool
in theSort
constructor ofFlatTermF
(which differentiatedsort
vs.isort
) with a new record typeSortFlags
, which has twoBool
s:flagInhabited
andflagQuantType
.Bool
with this new typeqsort
andqisort
keywordsFalse
value for the oldBool
flag was used with the newnoFlags
value of the record where all fields areFalse
An advantage of making a new
SortFlags
type instead of just adding anotherBool
flag is that in the future if we want to add another such flag, it should only involve adding a new field toSortFlags
, updating the Coq translation, and updating the Lexer and Grammar. The changes to the external format as well as the many placesFalse
was replaced withnoFlags
should not need to happen again.