-
Notifications
You must be signed in to change notification settings - Fork 274
Incorrect (hard-coded) logic for SMT backend #5977
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
Comments
In my experience, just If performance hit is a concern, I can create a draft PR once we have Z3 running on the CI [#5949] and check how long the |
cc: @mww-aws Also adding Mike to this discussion. |
|
I've had a quick look into this and am updating with some preliminary information (and welcome to guidance/feedback if there is anything you can recommend). A look at the documentation for SMT2 logics here indicates that there is no SMT2 theory that supports quantifiers over bitvectors. This is unfortunate and may cause some issues, but more details below on what happens. I tried modifying I took the example (from above):
and tried running it in cbmc with
|
( Note that the list of logics on the website is somewhat out of date and the list of benchmark collections http://smtlib.cs.uiowa.edu/benchmarks.shtml is probably a better view of the state-of-the-art, although most people have adopted the 'automata' approach to the naming of logics and it will all change in a month or so with the release of SMT-LIB 3.0. |
Sadly Some data from trying
|
Some more updates for possible logics to try with
So of the ones listed on the website only
Nothing unusual in the above, but when I tried to run it in
Killed with I tried within
No big time problem or kill, but still failing (kind of expectedly). I also checked the
Seems there are no other possible quantifier free (not At least for now, this might be a problem. |
Thank you so much for taking a look at this PR, and for the detailed logs, @TGWDB! Regarding,
Yes indeed. It looks like Z3 is having a hard time with these verification constraints! I extracted the SMT output from CBMC, reduced it to the core verification problem, and changed the logic to (set-logic ALL)
; find_symbols
(declare-fun |main::1::i!0@1#1| () (_ BitVec 32))
; set_to true
(assert (= (bvsrem |main::1::i!0@1#1| (_ bv2 32)) (_ bv0 32)))
; set_to false
(assert (not (exists ((|main::1::2::1::j!0#0| (_ BitVec 32))) (= |main::1::i!0@1#1| (bvadd |main::1::2::1::j!0#0| |main::1::2::1::j!0#0|)))))
; convert
(define-fun |B2| () Bool (not false))
; set_to true
(assert |B2|)
(check-sat) Z3 seems to run forever and I eventually had to killed it. But CVC4 generates an I noticed the same behavior with |
Further update with better usage of When the
The above generates a new output SMT2 file with the
Observe that the Now we can run this through
This is similar to what @martin-cs (apologies for the @, let me know if you prefer less of them) predicted, with an Also for the sake of completeness of the data, I tried the same steps with the version of
Again observe that the SMT2 output file generated with the
Also as expected the outcome from
|
So currently:
Would it be possible to specify another logic for CVC4 (and other SMT encodings, including the generic one) to allow quantifiers (at least when they are used in the C program)? |
Actually I tried running With
No
With the
No
AnalysisThe above results show that Return to testing First using
and now with the logic set to
This suggests that maybe |
The linked PR number 14 above is a provisional fix that appears to work for the examples above. Output from that version of
|
On Tue, 2021-06-22 at 07:14 -0700, Saswat Padhi wrote:
So currently:
- Z3 returns `unknown`, so is unreliable, on BV problems with
quantifiers
This is semi-expected. It can be improved by instantiation patterns
but TBH avoiding quantifiers is a better route.
- CVC4 is given QF_AUFBV, so it throws errors.
If the problem includes quantifiers then this is the expected and
correct behaviour.
Would it be possible to specify another logic for CVC4 to allow
quantifiers (at least when they are used in the C program)?
I would suggest switching the logic based on what you are actually
using. You might want FP or DT in there as well, for example.
( From elsewhere, it is fine to @ me and I will do what I can to help
when I have a moment. )
|
This fixes the sort mismatch that can occur when CVC4 expects an Array of Bool but cbmc translation produces an Array of (_ BitVec 1). Partial fix for diffblue#5970 and diffblue#5977
CVC4 allows ALL logic to be specified which in turn allows for quantifiers in forumulas. Fixes diffblue#5977
Returning to examine this issue now that various related bugs/limitations of the To summarise the current state of
The above already leads to problems such as unexpected quantifiers in Aside: Similar problems to To progress there are a some possible changes to Hard Code Different LogicsThis might be the lightest approach, which would be to change the hard coded logic for each solver to the most permissible for what Note that this would add (although perhaps it is already possible for Not Outputting QuantifiersThis would require a bit more effort, but to remove the output of quantifiers in most/all of the SMT paths. Since the combination of quantifiers and bitvectors are not well/widely supported, this would make SMT output more usable for multiple solvers. The potential problem here is that this may reduce the performance advantage of using SMT and quantifiers. Also, if it is not done for all solvers, then we have more inconsistency in the SMT (although this may already be an issue). Handling
|
Tiny update, we already see |
Some updates. The The There is also #6270 that may solve some of this issue in a different way (or for other solvers), mentioned for relation rather than dependence upon this PR. |
Just merged #6248 , please let us know if this (along with other fixes) resolves the issue as expected from your perspective. (I'm aware that this reports a different error for |
Closing as this appears to be resolved by various fixes and notes above. Please reopen if you believe this is erroneous. |
Uh oh!
There was an error while loading. Please reload this page.
CBMC version:
develop
Operating system: Mac OS 10.15.7
Test case:
Exact command line resulting in the issue:
cbmc --z3 test.c
orcbmc --cvc4 test.c
What behaviour did you expect:
CBMC would verify the assertion and report success.
What happened instead:
Additional context:
CBMC also fails to verify this program with the SAT backend, but a similar issue has already been reported in #5395.
The text was updated successfully, but these errors were encountered: