(get-unsat-core)在Z3中返回空

时间:2013-08-08 17:25:29

标签: z3 core smt sat-solvers

我正在使用Z3来提取不可满足的配方的不饱和核心。我正在使用Z3 @Rise界面(基于Web)编写以下代码,

(set-logic QF_LIA)
(set-option :produce-unsat-cores true)

(declare-fun ph1 () Int)
(declare-fun ph1p () Int)
(declare-fun ph3 () Int)
(declare-fun ph3p () Int)
(declare-fun ph4 () Int)
(declare-fun ph4p () Int)

(define-fun one () Bool (= ph3p (+ ph1 1)))
(define-fun two () Bool (= ph3 (+ ph1 1)))
(define-fun three () Bool (= ph1p (+ ph1 1)))
(define-fun four () Bool (= ph4p (+ ph1p 1)))
(define-fun five () Bool (>= ph1 0))
(define-fun six () Bool (>= ph4 0))

(define-fun secondpartA () Bool (or (= ph4 0) (<= ph3 ph4) ))
(define-fun secondpartB () Bool (or (= ph3p 0) (<= ph4p ph3p) ))


(assert one)
(assert two)
(assert three)
(assert four)
(assert five)
(assert six)
(assert secondpartA)
(assert secondpartB)
(check-sat)
(get-unsat-core)

check-sat正确地返回&'39;不满&#39;但是(get-unsat-core)返回空。我错过了一些配置/选项吗?或者我让这个例子变得复杂了吗?

1 个答案:

答案 0 :(得分:9)

您需要在断言中添加名称标签,以便get-unsat-core在不良核心输出中使用标签。写下你的断言:

(assert (! one :named a1))
(assert (! two :named a2))
(assert (! three :named a3))
(assert (! four :named a4))
(assert (! five :named a5))
(assert (! six :named a6))
(assert (! secondpartA :named spA))
(assert (! secondpartB :named spB))

和get-unsat-core将打印出一个不满核心。

此语法的文档可在SMTLIB tutorial(PDF文件)中找到。