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

SBV multi-SAT queries interact poorly with rationals #897

Open
robdockins opened this issue Sep 18, 2020 · 2 comments
Open

SBV multi-SAT queries interact poorly with rationals #897

robdockins opened this issue Sep 18, 2020 · 2 comments
Labels
prover Issues related to :sat and :prove

Comments

@robdockins
Copy link
Contributor

Because the SBV multi-SAT procedure doesn't understand the semantics of a pair of integers as a rational number, it will enumerate different representatives of the same equivalence class of pairs of integers when asked a multi-SAT query involving rational numbers. These are normalized before being presented to the user, and it appears the solver is repeatedly returning the same assignment.

Cryptol> :set satNum=10
Cryptol> :set prover=sbv-z3
Cryptol> :sat (\x -> x == ratio 1 2)
Satisfiable
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(\x -> x == ratio 1 2) (ratio 1 2) = True
(Total Elapsed Time: 0.025s, using "Z3")
Cryptol> :set prover=w4-z3
Cryptol> :sat (\x -> x == ratio 1 2)
Satisfiable
(\x -> x == ratio 1 2) (ratio 1 2) = True
(Total Elapsed Time: 0.036s, using "z3")

The What4 backend controls its own loop for finding multiple assignments and computes its own blocking predicates using the equivalence relation for rationals, and thus will avoid other representatives of the same class. We should do the same for SBV.

@yav yav added the prover Issues related to :sat and :prove label Sep 22, 2020
@LeventErkok
Copy link
Contributor

The newly released SBV 8.13 (https://hackage.haskell.org/package/sbv-8.13) has native support for SRational:

Prelude Data.SBV Data.SBV.Rational> allSat $ \x -> x .== 1 .% 2
Solution #1:
  s0 = 1 % 2 :: Rational
This is the only solution.

If you move to 8.13; you can map Cryptol's rationals to SBV's, and automatically handle this problem without lifting a finger!

@robdockins
Copy link
Contributor Author

Neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prover Issues related to :sat and :prove
Projects
None yet
Development

No branches or pull requests

3 participants