Assumptions are available in the SMT 2.0 interface. They are used to extract unsatisfactory nuclei. They can also be used to “reverse” assumptions. Note that assumptions are not really “soft constraints”, but they can be used to implement them. See the example maxsat (subdir maxsat) in the Z3 distribution. Here is an example of how to use assumptions in the Z3 SMT 2.0 interface.
;; Must enable unsat core generation (set-option :produce-unsat-cores true) (set-option :produce-models true) ;; Declare three Boolean constants to "assumptions" (declare-const p1 Bool) (declare-const p2 Bool) (declare-const p3 Bool) ;; We assert (=> p C) to track C using p (declare-const x Int) (declare-const y Int) (assert (=> p1 (> x 10))) ;; An Boolean constant may track more than one formula (assert (=> p1 (> yx))) (assert (=> p2 (< y 5))) (assert (=> p3 (> y 0))) (check-sat p1 p2 p3) (get-unsat-core) ;; produce core (p1 p2) (check-sat p1 p3) ;; "retrack" p2 (get-model)
Leonardo de Moura Dec 09 '11 at 6:20 2011-12-09 06:20
source share