In Z3-Py, I am performing quantifier elimination (QE) over the following formulae:
Exists y. Forall x. (x>=2) => ((y>1) /\ (y<=x))
Forall x. Exists y. (x>=2) => ((y>1) /\ (y<=x))
,
where both x
and y
are Integers. I did QE in the following way:
x, y = Ints('x, y')
t = Tactic("qe")
negS0= (x >= 2)
s1 = (y > 1)
s2 = (y <= x)
#EA
ea = Goal()
ea.add(Exists([y],Implies(negS0, (ForAll([x], And(s1,s2))))))
ea_qe = t(ea)
print(ea_qe)
#AE
ae = Goal()
ae.add(ForAll([x],Implies(negS0, (Exists([y], And(s1,s2))))))
ae_qe = t(ae)
print(ae_qe)
Result QE for ae
is as expected: [[]]
(i.e., True
). However, as for ea
, QE outputs: [[Not(x, >= 2)]]
, which is a results that I do not know how to interpret since (1) it has not really performed QE (note the resulting formula still contains x
and indeed does not contain y
which is the outermost quantified variable) and (2) I do not understand the meaning of the comma in x, >=
. I cannot get the model either:
phi = Exists([y],Implies(negS0, (ForAll([x], And(s1,s2)))))
s_def = Solver()
s_def.add(phi)
print(s_def.model())
This results in the error Z3Exception: model is not available
.
I think the point is as follows: since (x>=2)
is an implication, there are two ways to satisfy the formula; by making the antecedent False
or by satisfying the consequent. In the second case, the model would be y=2
. But in the first case, the result of QE would be True
, thus we cannot get a single model (as it happens with a universal model):
phi = ForAll([x],Implies(negS0, (Exists([y], And(s1,s2)))))
s_def = Solver()
s_def.add(phi)
print(s_def.model())
In any case, I cannot 'philosophically' understand the meaning of a QE of x
where x
is part of the (quantifier-eliminated) answer.
Any help?