3

我想知道,SMT-LIB 2.0 脚本中是否有可能访问求解器的最后一个可满足性决策(sat、unsat、...)。例如,下面的代码:

(set-option :produce-unsat-cores true)
(set-option :produce-models true)
(set-logic QF_UF)
(declare-fun p () Bool)
(declare-fun q () Bool)
(declare-fun r () Bool)

(assert (! (=> p q) :named PQ))
(assert (! (=> q r) :named QR))
(assert (! (not (=> p r)) :named nPR))

(check-sat)
(get-model)
(get-unsat-core)

在 Z3 中运行返回:

unsat
(error "line 15 column 10: model is not available")
(PQ QR nPR)

并在 MathSAT 中运行返回:

unsat
(error "model generation not enabled")

在 MathSAT 5 中,它只是中断(get-model),甚至没有达到(get-unsat-core)。如果决定是 SAT,SMT-LIB 2.0 语言中是否有任何方法可以获取模型,如果决定是 UNSAT,则为 unsat-core?例如,解决方案可能如下所示:

(check-sat)
(ite (= (was-sat) true) (get-model) (get-unsat-core))

我搜索了 SMT-LIB 2.0 语言文档,但没有找到任何提示。

编辑:我也尝试了下面的代码,不幸的是它没有工作。

(ite (= (check-sat) "sat") (get-model) (get-unsat-core))
4

2 回答 2

3

SMT 语言不允许您编写这样的命令。诸如 Boogie 之类的工具处理此问题的方式是使用双向文本管道:它从 (check-sat) 读回结果。如果结果字符串是“unsat”,则模型不可用,但如果检查使用假设,核心将是可用的。如果结果字符串是“sat”,则该工具可以预期 (get-model) 命令成功。

于 2016-08-25T23:04:03.503 回答
3

正如 Nikolaj 在他的回答中所说,正确的方法是解析求解器输出并有条件地生成 a(get-model)(get-unsat-core)语句。

但是,使用 mathsat 您可以使用不带(get-model)语句的代码,并mathsat使用-model选项调用。例如:

$ cat demo_sat.smt2 
(set-option :produce-unsat-cores true)
(set-option :produce-models true)
(set-logic QF_UF)
(declare-fun p () Bool)
(declare-fun q () Bool)
(declare-fun r () Bool)

(assert (! (=> p q) :named PQ))
(assert (! (=> q r) :named QR))
; (assert (! (not (=> p r)) :named nPR))

(check-sat)
(get-unsat-core)

$ mathsat -model demo_sat.smt2 
sat
( (p false)
  (q false)
  (r false) )
(error "no unsatisfiability proof, impossible to compute unsat core")

在不满意的情况下:

$ cat demo_unsat.smt2 
(set-option :produce-unsat-cores true)
(set-option :produce-models true)
(set-logic QF_UF)
(declare-fun p () Bool)
(declare-fun q () Bool)
(declare-fun r () Bool)

(assert (! (=> p q) :named PQ))
(assert (! (=> q r) :named QR))
(assert (! (not (=> p r)) :named nPR))

(check-sat)
(get-unsat-core)

$ mathsat -model demo_unsat.smt2 
unsat
( PQ
  QR
  nPR )

不幸的是,似乎不存在像-model生产未饱和核心这样的选择。因此,如果您想将其用于增量问题,则此 hack 将不起作用,除非您对求解器在第一个sat结果后终止感到满意。(因为在第一个sat结果中,求解器会因 . 的错误而退出(get-unsat-core)。)

于 2016-09-11T11:13:39.127 回答