【发布时间】:2020-07-31 12:33:52
【问题描述】:
我有一个运行 Z3 版本 4.8.8 - 64 位的程序,带有增量输入:程序启动 Z3 一次,对 Z3 执行多轮输入输出,然后停止 Z3。出于性能原因,在没有增量输入的情况下运行 Z3 不是一种选择。
每一轮,程序向Z3输入一些(assert ...)语句,向Z3输入(check-sat),然后从Z3获取(check-sat)的输出。
我有两轮输入输出:第一轮输入如z3.sat:
(declare-fun f () Int)
(declare-fun n () Int)
(assert (< 1 n))
(assert (<= 2 f))
(assert (= (+ (+ 1 f) 1) (+ n n)))
(assert (not false))
(check-sat)
这意味着:f 是偶数 Int 大于或等于 2。
第二轮输入如z3.unsat:
(declare-fun f () Int)
(declare-fun n () Int)
(assert (< 1 n))
(assert (<= 2 f))
(assert (= (+ (+ 1 f) 1) (+ n n)))
(assert (not (exists ((alpha Int)) (= (* 2 alpha) f))))
(check-sat)
这意味着:如果f 是偶数Int 大于或等于2,则存在alpha 其中alpha=f/2。
我假设使用增量输入运行 Z3 类似于将两轮输入 z3.sat 和 z3.unsat 连接到一个输入中,如 z3.combined:
(declare-fun f () Int)
(declare-fun n () Int)
(assert (< 1 n))
(assert (<= 2 f))
(assert (= (+ (+ 1 f) 1) (+ n n)))
(assert (not false))
(check-sat)
(declare-fun f () Int)
(declare-fun n () Int)
(assert (< 1 n))
(assert (<= 2 f))
(assert (= (+ (+ 1 f) 1) (+ n n)))
(assert (not (exists ((alpha Int)) (= (* 2 alpha) f))))
(check-sat)
跑步:
-
z3 -smt2 z3.sat输出sat -
z3 -smt2 z3.unsat输出unsat -
z3 -smt2 z3.combined输出错误,因为第一轮的(assert ...)语句不会消失:sat (error "line 8 column 21: invalid declaration, constant 'f' (with the given signature) already declared") (error "line 9 column 21: invalid declaration, constant 'n' (with the given signature) already declared") unknown
所以Z3似乎需要(push 1)和(pop 1)语句来忘记之前的断言集,所以我在z3.sat和z3.unsat的开头和结尾添加了这些语句,并重新连接了z3.pushpop.sat和z3.pushpop.unsat 得到z3.pushpop.combined。
-
z3.pushpop.sat:(push 1) (declare-fun f () Int) (declare-fun n () Int) (assert (< 1 n)) (assert (<= 2 f)) (assert (= (+ (+ 1 f) 1) (+ n n))) (assert (not false)) (check-sat) (pop 1) -
z3.pushpop.unsat:(push 1) (declare-fun f () Int) (declare-fun n () Int) (assert (< 1 n)) (assert (<= 2 f)) (assert (= (+ (+ 1 f) 1) (+ n n))) (assert (not (exists ((alpha Int)) (= (* 2 alpha) f)))) (check-sat) (pop 1) -
z3.pushpop.combined:(push 1) (declare-fun f () Int) (declare-fun n () Int) (assert (< 1 n)) (assert (<= 2 f)) (assert (= (+ (+ 1 f) 1) (+ n n))) (assert (not false)) (check-sat) (pop 1) (push 1) (declare-fun f () Int) (declare-fun n () Int) (assert (< 1 n)) (assert (<= 2 f)) (assert (= (+ (+ 1 f) 1) (+ n n))) (assert (not (exists ((alpha Int)) (= (* 2 alpha) f)))) (check-sat) (pop 1)
但是,现在正在运行:
-
z3 -smt2 z3.pushpop.sat输出sat -
z3 -smt2 z3.pushpop.unsat输出unknown -
z3 -smt2 z3.pushpop.combined输出:sat unknown
为什么z3 -smt2 z3.pushpop.unsat 输出unknown?
【问题讨论】:
标签: z3 smt theorem-proving