I have some constraints involving Bitvectors that I believe should be sat even though Z3 produces the verdict unsat. I have managed to reduce them to a small example.
I tried tracing the solver by running z3 -tr:sat test.smt but did not get any traces (it just says unsat). Any ideas why this doesn't work, or an alternative to debugging this type of situation?
You might want to label your constraints and then ask for an unsat core. This will allow you to see which (hopefully a small) set of constraints are found conflicting and debug from there. If you post your example, we can help with setting it up for unsat-core production.
Related
I am trying to use z3 from the command line as a SAT solver, but I can't figure out how to make it generate a proof of unsatisfiability. No matter what I do, it just prints "unsat" with no explanation, and nothing I can find online has helped. I tried passing proof=true on the command line, but nothing changed.
../z3-4.8.6-x64-ubuntu-16.04/bin/z3 proof=true unsat_core=true test_tx.cnf
unsat
z3 can generate proofs in SMTLib mode (though the proof format is rather unspecified.) I'm not sure if it can even generate proofs in the CNF mode at all, though it certainly should be possible. Your best bet might be to file an issue at https://github.com/Z3Prover/z3/issues and see if this is supported.
Here x and k are integers
and the formula is: (50<=x+k Ʌ x+k<51)
Can it get simplified to "x+k=50"
I want the right set of tactics to solve this conjunction of inequalities.
Z3 is not a general purpose symbolic engine to simplify such expressions. Even if you got a good combination of tactics to give you what you need today, the results might change in further releases of the tool. You should look at other systems. Even a symbolic-engine like wolfram-alpha may not produce what you exactly want; but it might give you some alternative forms that might be easier to work with. See here: http://www.wolframalpha.com/input/?i=50%3C%3Dx%2Bk+%26%26+x%2Bk%3C51
I notice that the Z3 C++ (and C) API allows you to supply the logic to be used.
I have two questions about this that I couldn't answer by looking online:
Are these supposed to be the standard SMT-LIB logics i.e. QF_LRA
When are these worth supplying i.e. when will Z3 actually use this information
My context is mainly QF no BV but everything else possible, I am using the SMT solver incrementally and I can always work out what logic I will be in at the start.
Z3 will also try to figure out what the logic is (when run with default options), but it doesn't have custom tactics for all combinations of theories (see default_tactic.cpp and smt_strategic_solver.cpp). When you are not sure what Z3 will decide to do, then it's best to set the tactic right up front, so that you will get errors if you try to use things that are not in that logic. It will also use that information to set up the smt kernel, e.g., enabling various preprocessors, various solver features, and chosing heuristics (see e.g., smt_setup.cpp).
Try it out and see!
Usually it does make a big difference. Setting the logic means the solver will use a specialized tactic to solve the formula, instead of going through the generic loop. Z3 will also try to guess the logic, but it's usually better to just provide it upfront.
I am using Z3 with the Python-API.
I am setting up a quite big set of linear arithmetic constraints.
However, push/pop is causing the check() to run infinite.
If I dont't use any push/pop, everthing works fine. But when I just insert a
s.push()
s.pop()
somewhere before the s.check(), then the s.check() runs endless.
Only using the push without pop works fine.
Is there any known Issue and workaround about this?
I am using Z3 [version 4.3.1 - 64 bit] on MacOS 10.7.5.
Thanks a lot & regards,
Klaus
Z3 is a collection of solvers. However, only one of them is incremental.
The non-incremental solvers are much more efficient for your problem.
When you use s.push(), Z3 "guesses" you want to solve problems incrementally, and switches to the incremental (general purpose) solver.
If we add the following command in the beginning of the file, Z3 will display several messages. Note that the messages are completely different when we use s.push().
set_option(verbose=10)
We can force Z3 to use a particular solver. For example, if we replace
s = Solver()
with
s = Tactic('qflia').solver()
Then, Z3 will use the efficient solver even when s.push() is used.
However, it will start every check() command from scratch. I don't think this is a problem in your problem because the different in performance between the non-incremental and incremental is very big.
I have a simple set of constraints that Z3 is not able to cope with:
http://pastebin.com/3eaLQ9wx
Is there a way to tweak the constraints in order to get the result ?
This is a simple example of a bigger set of constraints (thousands) but
I am somehow troubled that it doesn't work even on such simple example
Thanks in advance !!
Your problem has non-linear constraints. While Z3 can deal with them in most cases, the mixing of Ints and Real's seem to be putting it beyond its current capabilities. If you simply use Reals for your s_0_1, s_0_2 etc. variables, I trust Z3 will be able to solve the problem. (You seem to have enough value constraints, so I trust there won't be a modeling issue.)
I think Leonardo expressed several times that the upcoming releases will have better support for combined theories in the presence of non-linear constraints.