-
Notifications
You must be signed in to change notification settings - Fork 34
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
Unexpected prove
/forSome
interaction
#623
Comments
Unfortunately prop1 = forSome_ $ \ (n :: SInteger) -> sNot (n .== 0) which is, of course, a theorem. The "flipping" of the quantifier is not done, and indeed there is no way to really handle this within SBV, under the current design. (That is, a different design could've handled it; but long-ago made design choices on how quantifiers are handled in SBV does not allow for this sort of manipulation.) So, strictly speaking this is a "usability" bug, because what looks like should be an obvious translation isn't what actually happens. Meaning: SBV as it stands will never support the kind of transformation you want, though I wish it was smart enough to detect it and reject it instead of silently going and doing the most confusing thing. You'll also find that this is true for any sort of quantifier manipulation in SBV. It has a very limited understanding of them. In particular, it assumes all the given formulae has all the quantifiers pulled to the top (i.e., in prenex form), and also there are no "outside" operations done, i.e., you start with the quantifiers and the formula is completely done after them. (Your call to While this is not something that will be fixed in SBV, I'll keep this ticket open as a "usability bug," and perhaps one day SBV will be smart enough to detect these cases and reject them properly as they are not really supported. |
Also see #256 for a related issue. Note that the documentation does mention this, but I'd agree that unless you know exactly what it's saying it might be hard to decipher: https://hackage.haskell.org/package/sbv-8.17/docs/Data-SBV.html#g:40, replicated below:
|
Thank you for the reply (and for SBV which is a great library). I had just found the note on quantifiers in the documentation. Perhaps an interim usability patch could be to link to the above mentioned note in the documentation for |
Sure.. Please file a PR and I'd be happy to merge! |
Not sure if this is still relevant to you. But the latest release of SBV has proper support for quantifiers. The old way of dealing with quantifiers is completely removed. The current implementation (I hope!) is much easier to use and much more expressive. For instance, your example is now coded like this: Prelude Data.SBV> prop1 = qNot $ \(Exists n) -> n .== (0 :: SInteger)
Prelude Data.SBV> prop2 = \(Forall n) -> sNot (n .== (0 :: SInteger))
Prelude Data.SBV> prove prop1
Falsifiable
Prelude Data.SBV> prove prop2
Falsifiable and as you'd expect, these are both not theorems. Prelude Data.SBV> :set -XDataKinds
Prelude Data.SBV> let q = \(Forall @"x" x) (Exists @"y" y) -> y .== (x+1::SInteger)
Prelude Data.SBV> sat q
Satisfiable
Prelude Data.SBV> sat $ skolemize q
Satisfiable. Model:
y :: Integer -> Integer
y x = 1 + x There are some further examples in https://hackage.haskell.org/package/sbv-10.1/docs/Documentation-SBV-Examples-Misc-FirstOrderLogic.html Let me know if you give this a try and have any feedback regarding usage/further examples etc. |
It seem that
forSome
is behaving strangely with respect toprove
.For instance, I'd expect the following
prop1
andprop2
to be equivalent:However, when I try to prove them I get:
Why is it possible to prove
prop1
? The documentation doesn't seem to offer any clues.The text was updated successfully, but these errors were encountered: