I need a theorem prover for some simple linear arithmetic problems. However, I can’t get Z3 to work even on simple problems. I’m aware that it is incomplete, however it should be able to handle this simple example:
(assert (forall ((t Int)) (= t 5)))
(check-sat)
I’m not sure if i’m overlooking something, but this should be trivial to disprove. I even tried this simpler example:
(assert (forall ((t Bool)) (= t true)))
(check-sat)
That should be solvable by making an exhaustive search, since boot only contains two values.
In both cases z3 answers with unknown. I’d like to know if i’m doing something wrong here or if not if you can recommend a theorem prover for these types of formulas.
For handling this kind of quantifiers, you should use the quantifier elimination module available in Z3. Here is an example on how to use it (try online at http://rise4fun.com/Z3/3C3):
The command
check-sat-usingallows us to specify an strategy to solve the problem. In the example above, I’m just usingqe(quantifier elimination) and then invoking a general purpose SMT solver.Note that, for these examples,
qeis sufficient.Here is a more complicated example, where we really need to combine
qeandsmt(try online at: http://rise4fun.com/Z3/l3Rl )EDIT
Here is the same example using the C/C++ API: