After applying quantifier elimination in Z3 to a linear arithmetic formula h, I'm getting a 30-line or so formula. It turns out this formula is equivalent to h2=And(n>2, i>=0, i<=n-2), which I would much prefer as an output.
I tried ctx-solver-simplify; I'm getting:
And(Not(n <= 2), Or(Not(i >= 1), Not(n + -1*i <= 1)), i >= 0)
Now, Not(n<=2) can be more succinctly expressed as n>=3, Not(n + -1*i <= 1) as n-i>=2, and in this formula i >= 1 is not needed.
Repeat(Then('nnf','ctx-solver-simplify')) does a little better (by getting rid of i>=1).
Is there a better simplification tactic?
Similarly, is there a tactic that would transform Or(x==0, x==1, x==2, x==3) into And(x>=0,x<=3)?
h2(hcomes from a program analysis problem and I had some intuition about what the final result should be like), which I checked with Z3 (h⇒h2andh2⇒h), but in general the formula may be more complex. Your idea is interesting, I could, say, conjecture that the formula consists only in a few disjuncts... - David Monniaux