5

Say I have

t1<x and x<t2

is it possible to hide variable x so that t1<t2 in Z3?

william007
  • 17,375
  • 25
  • 118
  • 194

2 Answers2

6

You can use quantifier elimination for doing that. Here is an example:

(declare-const t1 Int)
(declare-const t2 Int)

(elim-quantifiers (exists ((x Int)) (and (< t1 x) (< x t2))))

You can try this example online at: http://rise4fun.com/Z3/kp0X

Leonardo de Moura
  • 21,065
  • 2
  • 47
  • 53
  • Thanks but why the result is t1-t2<=-2? and not t1-t2<0? – william007 Jul 26 '12 at 07:44
  • 1
    Because, `t1`, `t2` and `x` are integers. For integers we have that if `a < b` then `a <= b - 1`. Thus, combining the inequalities `t1 <= x - 1` and `x <= t2 - 1`, we get `t1 - t2 <= -2`. If we replace `Int` with `Real`, we will get a formula that is equivalent to `t1 - t2 < 0`. – Leonardo de Moura Jul 26 '12 at 14:42
  • 1
    This answer seems to be outdated, as it yields "unsupported" as a result (also on rise4fun) – DCTLib Nov 28 '16 at 20:26
2

Possible solution using Redlog of Reduce:

enter image description here

Juan Ospina
  • 1,317
  • 1
  • 7
  • 15