(Why are not the math formulae showing correctly?)
I am performing a test over the Z3 library in Python (Collab) to see whether it knows to distinguish formulae.
The test is the following: (1) I make a quantifier elimination over a formula $phi_1$, (2) I change the formula in a way it remains semantically equivalent: for instance, $phi_1 \equiv (a<b+1)$ to $\phi_2 \equiv (a<1+b)$, (3) I test whether $phi_1=phi_2$.
To see whether $phi_1=phi_2$, I perform the following query: for all the variables, I see whether formulae imply each other. Like $\forall * . (\phi_1 \rightleftarrow \phi_2)$ Is this correct?
So, imagine I apply this on my machine:
x, t1, t2 = Reals('x t1 t2')
g = Goal()
g.add(Exists(x, And(t1 < x, x < t2)))
t = Tactic('qe')
res = t(g)
The result res
is [[Not(0 <= t1 + -1*t2)]]
, so a semantically equivalent formula is: [[Not(0 <= -1*t2 + t1)]]
Am I right?
Let us check whether [[Not(0 <= t1 + -1*t2)]] = [[Not(0 <= -1*t2 + t1)]]
. So I apply the universal double-implication formula above:
w = Goal()
w.add(ForAll(t1, (ForAll(t2, And(
Implies(Not(0 <= -1*t2 + t1), Not(0 <= t1 + -1*t2)),
Implies(Not(0 <= t1 + -1*t2), Not(0 <= -1*t2 + t1)),
)))))
tt = Tactic('qe')
areThey = tt(w)
print (areThey)
And the result is.. [[]]
I do not know how to interpret this. An optimistic approach is to think that it returns emptyness, since quantifier elimination has been capable to eliminate both quantifiers successfully (i.e. with true result).
I think this can be a problem of using a wrong tactic, or maybe Z3 does not deal OK with universal quantifiers.
However, the most probable situation is that I am probably missing something key and Z3 is clever enough to distinguish.
Any help?