Skip to content
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

[MRSolver] Changes to Mr. Solver to get zero_array working #1624

Merged
merged 20 commits into from
Mar 28, 2022

Conversation

m-yac
Copy link
Contributor

@m-yac m-yac commented Mar 23, 2022

This PR gets an example of exponential explosion (exp_explosion_mr_solver.saw) and a Cryptol refinement proof of zero_array (arrays_mr_solver.saw) working with Mr. Solver.

The main changes needed to get these working were:

  • Make refinement heterogeneous, specifically a function with argument type Vec n Bool can now refine a function with corresponding argument type Num (or vice versa) by introducing the former and substituting TCNum of bvToNat n of the former for the latter
  • Define seqMapM in terms of multiFixM with a loop invariant (so that Mr. Solver can do co-induction on list comprehensions) and special-case it if its length argument is bvToNat of some bitvector (so that we can easily translate to SMT)
  • Add monadification for ecUpdate and tweak the monadification of ecAt to better work with Mr. Solver
  • Add a monadification macro for invariantHint to ensure an application of invariantHint remains top-level (i.e. so that invariantHint a cond comp monadifies to invariantHint (CompM a) cond comp and not comp >>= \x -> returnM a (invariantHint a cond x))
  • Add a monadification macro for asserting and assuming (for the same reason as the above) and add special cases for them to Mr. Solver (for better error reporting)
  • If there is an existing monadification macro for y, calling set_monadification x y will now add the same macro for x. This is needed so that in specPrims.saw, set_monadification "invariantHint" "Prelude.invariantHint" does the macro described above instead of just monadifying it to Prelude.invariantHint and stopping there - the same goes for assuming and asserting. (This could probably also be solved by recursing in monadifyTerm, but this seemed simpler.)
  • Make bvNat w (bvToNat w' n) reduce to n in the SAW core simulator

@m-yac m-yac added the subsystem: MRSolver Issues related to the Mr. Solver monadic-recursive solver in Heapster label Mar 23, 2022
Copy link
Contributor

@eddywestbrook eddywestbrook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks Matt!

@eddywestbrook eddywestbrook added the PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run label Mar 28, 2022
@eddywestbrook eddywestbrook merged commit 4ecdc83 into master Mar 28, 2022
@mergify mergify bot deleted the mr-solver/heterogeneous branch March 28, 2022 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run subsystem: MRSolver Issues related to the Mr. Solver monadic-recursive solver in Heapster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants