I'm trying to define a theory of sets (union, intersection etc.) for Z3 using the SMTLIB interface. Unfortunately, my current definition hangs z3 for a trivial query, so I guess I'm missing some simple option/flags.
here's the permalink: http://rise4fun.com/Z3/JomY
(declare-sort Set)
(declare-fun emp () Set)
(declare-fun add (Set Int) Set)
(declare-fun cup (Set Set) Set)
(declare-fun cap (Set Set) Set)
(declare-fun dif (Set Set) Set)
(declare-fun sub (Set Set) Bool)
(declare-fun mem (Int Set) Bool)
(assert (forall ((x Int)) (not (mem x emp))))
(assert (forall ((x Int) (s1 Set) (s2 Set))
(= (mem x (cup s1 s2)) (or (mem x s1) (mem x s2)))))
(assert (forall ((x Int) (s1 Set) (s2 Set))
(= (mem x (cap s1 s2)) (and (mem x s1) (mem x s2)))))
(assert (forall ((x Int) (s1 Set) (s2 Set))
(= (mem x (dif s1 s2)) (and (mem x s1) (not (mem x s2))))))
(assert (forall ((x Int) (s Set) (y Int))
(= (mem x (add s y)) (or (mem x s) (= x y)))))
(declare-fun z3v8 () Bool)
(assert (not z3v8))
(check-sat)
Any hint as to what I'm missing?
Also, from what I can tell there is no standard SMT-LIB2
encoding of the set operations e.g. Z3.mk_set_{add,del,empty,...}
(which is why I'm trying to get that functionality via quantifiers.)
Is that correct? Or is there another route?
Thanks!
Ranjit.