问题
I'm a total newbie with Z3 (started today). So far liking it a lot. Great tool. Unfortunately the syntax confuses me a bit.
I want to prove that if:
a^3 = xyz = m ( with a, x, y, z, m (0..1) )
then:
3a <= (x+y+z)
I do so by trying to find a model satisfying that:
3a > (x+y+z)
Here is the Z3 code:
(declare-const a Real)
(declare-const x Real)
(declare-const y Real)
(declare-const z Real)
(declare-const m Real)
(assert (> a 0))
(assert (< a 1))
(assert (> x 0))
(assert (< x 1))
(assert (> y 0))
(assert (< y 1))
(assert (> z 0))
(assert (< z 1))
(assert (> m 0))
(assert (< m 1))
(assert (= (* (* a a) a) m))
(assert (= (* (* x y) z) m))
(assert (> (* 3.0 a) (+ (+ z y) x) ))
(check-sat)
The model is unsatisfied.
Have I successfully proved what I wanted? As I said, the syntax confuses me since I'm a total newbie.
回答1:
Your solution is correct.
Explanation: What you wrote is equivalent to:
0 < x < 1
0 < y < 1
0 < z < 1
0 < m < 1
a * a * a = m
x * y * z = m
3 * a > x + y + z
Z3 says this is unsatisfiable. Thus, if
a^3 = xyz = m ( with a, x, y, z, m (0..1) )
then it cannot be the case that:
3a > (x+y+z)
because, if this did occur, then the SMT problem you posed would be satisfiable, which would be a contradiction with the claim by Z3 that the SMT problem is unsatisfiable. If it cannot be the case that 3a > (x+y+z)
, then it must be the case that 3a <= (x+y+z)
, which is the statement you originally wanted to prove.
回答2:
I think that your solution is correct. Let me explain a bit about using Z3 to prove validity of a statement A
. The key idea is that, in the classical logic, e.g., propositional logic and predicate logic:
A
is Valid iffnegation(A)
is Unsatisfiable.
This is a pretty well-known result. You can find it in many textbooks and materials, for example, in page 4 of this slide. So, validity of P -> Q
can be proved via checking for unsatisfiability of its negation: P /\ negation(Q)
.
In particular, for your example,
(a^3 = x*y*z = m) -> (3a <= x+y+z)
is Valid,
iff
(a^3 = m) /\ (x*y*z = m) /\ (3a > x+y+z)
is Unsatifiable.
来源:https://stackoverflow.com/questions/39039922/z3-to-show-that-if-a3-xyz-then-3a-xyz