当我问check-sat
(我认为是)一个相当简单的SMT2代码我试图在Z3中运行时,我完全不知道为什么我会出现分段错误。
(declare-const A Int)
(declare-const B Int)
(declare-const C Int)
(declare-const D Int)
(assert (= A (or 2 3 5 7)))
(define-fun W ((In1 Int)) Int
(ite (= In1 2) (or 3 5)
(ite (= In1 3) (or 5 7)
(ite (= In1 5) 7
(ite (= In1 7) 3 11)
)
)
)
)
(assert (= B (W A)))
(assert (= C (W B)))
(assert (= D (W C)))
(declare-const MULT Int)
(assert (= MULT (* A B C D)))
; 210 because 210 = 2*3*5*7
(declare-const MODULUS Int)
(assert (= 0 (rem MULT 210)))
(assert (= MODULUS 0))
(echo "Check 1")
(check-sat)
(echo "Check 2")
(get-model)
如果我删除代码的MODULUS
位,模型似乎很高兴返回非数值模型,但我期待的是一个数值解,其中A = 2,B = 3,C = 5 ,D = 7(和MODULUS
位工作)。
(model
(define-fun D () Int
(let ((a!1 (ite (= (or 2 3 5 7) 5) 7 (ite (= (or 2 3 5 7) 7) 3 11))))
(let ((a!2 (ite (= (or 2 3 5 7) 2) (or 3 5)
(ite (= (or 2 3 5 7) 3) (or 5 7) a!1))))
(let ((a!3 (ite (= a!2 3) (or 5 7) (ite (= a!2 5) 7 (ite (= a!2 7) 3 11)))))
(let ((a!4 (ite (= (ite (= a!2 2) (or 3 5) a!3) 7) 3 11)))
(let ((a!5 (ite (= (ite (= a!2 2) (or 3 5) a!3) 5) 7 a!4)))
(let ((a!6 (ite (= (ite (= a!2 2) (or 3 5) a!3) 3) (or 5 7) a!5)))
(ite (= (ite (= a!2 2) (or 3 5) a!3) 2) (or 3 5) a!6))))))))
(define-fun C () Int
(let ((a!1 (ite (= (or 2 3 5 7) 5) 7 (ite (= (or 2 3 5 7) 7) 3 11))))
(let ((a!2 (ite (= (or 2 3 5 7) 2)(or 3 5)
(ite (= (or 2 3 5 7) 3) (or 5 7) a!1))))
(let ((a!3 (ite (= a!2 3) (or 5 7) (ite (= a!2 5) 7 (ite (= a!2 7) 3 11)))))
(ite (= a!2 2) (or 3 5) a!3)))))
(define-fun B () Int
(let ((a!1 (ite (= (or 2 3 5 7) 5) 7 (ite (= (or 2 3 5 7) 7) 3 11))))
(ite (= (or 2 3 5 7) 2) (or 3 5) (ite (= (or 2 3 5 7) 3) (or 5 7) a!1))))
(define-fun A () Int
(or 2 3 5 7))
)
我尝试过使用不同的解算器,我尝试过使用Reals,我尝试摆弄model_evaluator
和model
的设置,但我真的不确定自己在做什么。 ...
有没有其他人有类似的困难或运气更好调试seg故障(分段错误:11,如果它有帮助?!),或者我是否超出了Z3的限制?
非常感谢
答案 0 :(得分:1)
这可能是由最近修复的类型检查功能中的错误引起的,因此在最新的不稳定版本中不会重现。原因是
(assert (= A (or 2 3 5 7)))
断言A
(Int
)应该等于(or ...)
Bool
,所以在最新的不稳定版本中我得到
(error "line 5 column 25: Sorts Int and Bool are incompatible")
(之后会出现更多错误)。