这是我的程序,当图中有一个循环时返回SAT,而在没有循环时返回UNSAT:
(set-option :fixedpoint.engine datalog)
(define-sort s () Int)
(declare-rel edge (s s))
(declare-rel path (s s))
(declare-var a s)
(declare-var b s)
(declare-var c s)
(rule (=> (edge a b) (path a b)))
(rule (=> (and (path a b) (path b c)) (path a c)))
(rule (edge 1 2))
(rule (edge 2 3))
(declare-rel cycle (s))
(rule (=> (path a a) (cycle a)))
(query cycle :print-answer true)
我想在没有周期的情况下获得模型(UNSAT)。我意识到我应该使用命令(get-unsat-core)并将选项设置为(set-option:produce-unsat-cores true):
(set-option :fixedpoint.engine datalog)
(set-option :produce-unsat-cores true)
(define-sort s () Int)
(declare-rel edge (s s))
(declare-rel path (s s))
(declare-var a s)
(declare-var b s)
(declare-var c s)
(rule (=> (edge a b) (path a b)) P-1)
(rule (=> (and (path a b) (path b c)) (path a c)) P-2)
(rule (edge 1 2) E-1)
(rule (edge 2 3) E-2)
(rule (edge 3 1) E-3)
(declare-rel cycle (s))
(rule (=> (path a a) (cycle a)))
(query cycle :print-answer true)
(get-unsat-core)
我收到此错误:
unsat
(error "line 24 column 15: unsat core is not available")
答案 0 :(得分:3)
在unsat
情况下获取模型没有任何意义。从字面上无法满足意味着没有模型可以满足您的约束。请针对您要实现的目标发布一个更明确的问题。
unsat核心是有冲突的断言的子集。根据定义,此集合是不能令人满意的,并且不构成您要寻找的模型。此外,我非常怀疑定点引擎是否支持unsat-core,因此,您收到的错误消息只是意味着它们没有被计算。
答案 1 :(得分:1)
如果我可能要入侵,则 AFAIK 可能需要命名,以限制要检索unsat core
的约束。
smtlib网站提供以下示例:
; Getting unsatisfiable cores
(set-option :produce-unsat-cores true)
(set-logic QF_UF)
(declare-const p Bool) (declare-const q Bool) (declare-const r Bool)
(declare-const s Bool) (declare-const t Bool)
(assert (! (=> p q) :named PQ))
(assert (! (=> q r) :named QR))
(assert (! (=> r s) :named RS))
(assert (! (=> s t) :named ST))
(assert (! (not (=> q s)) :named NQS))
(check-sat)
; unsat
(get-unsat-core)
; (QR RS NQS)
(exit)
@LeventErkok指出,仅当公式为sat
时模型可用,而unsat core
仅当公式为unsat
时可用。