I was trying some basic FOL formula satisfiability problems using Z3. I am not able to understand why the below code snippet returns Unsat. Please help.
If possible if anyone has tried with some example for which FOL with quantifiers gives "Sat" and with some small minor changes gives "Unsat" as an output, will be very helpful
Are there exist some simple FOL formula code snippets to study, other than provided on the rise4fun tutorial page.
(set-option :smt.mbqi true)
(declare-fun f (Real Real) Bool)
(declare-const a Real)
(declare-const b Real)
(assert (forall ((x Real)) (and (f a x) (> x 6))))
(assert (and (f a b) (> b 6) ))
(check-sat)
Your input is unsat
because of this assert
:
(assert (forall ((x Real)) (and (f a x) (> x 6))))
The right hand side is a conjunction. So this is saying that all real valued x
values are greater than 6, which is clearly not true. In fact, you can simplify your whole input to:
(assert (forall ((x Real)) (> x 6)))
(check-sat)
and it would still be unsat
for precisely the same reason.
Perhaps what you meant is something like this:
(set-option :smt.mbqi true)
(declare-fun f (Real Real) Bool)
(declare-const a Real)
(declare-const b Real)
(assert (forall ((x Real)) (=> (> x 6) (f a x))))
(assert (and (f a b) (> b 6) ))
(check-sat)
(get-value (f a b))
That is, f a x
is true
if x
is greater than 6? For this input z3 says:
sat
((f (lambda ((x!1 Real) (x!2 Real)) (= x!2 0.0)))
(a 0.0)
(b 7.0))
And you can see that this is indeed a satisfying model, though not a particularly interesting one.
Hope that helps!