Z3 分段错误和非数值结果
Z3 segmentation fault and non-numerical results
当我向 check-sat
询问(我认为是)我试图 运行 在 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
位,该模型似乎足以 return 一个非数值模型,但我期待的是一个数值解,其中 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))
)
我试过使用不同的求解器,我试过使用实数,我试过摆弄 model_evaluator
和 model
的设置,但我真的不确定我在做什么做....
有没有其他人有任何类似的困难或运气更好地调试段错误(段错误:11,如果它有帮助?!),或者我在这里超出了 Z3 的限制?
非常感谢
这可能是由最近修复的类型检查功能中的错误引起的,因此在最新的不稳定版本中不会重现。原因是
(assert (= A (or 2 3 5 7)))
断言 A
(这是一个 Int
)应该等于 (or ...)
这是一个 Bool
,所以在最新的不稳定版本中我得到
(error "line 5 column 25: Sorts Int and Bool are incompatible")
(之后还有更多错误)。
当我向 check-sat
询问(我认为是)我试图 运行 在 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
位,该模型似乎足以 return 一个非数值模型,但我期待的是一个数值解,其中 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))
)
我试过使用不同的求解器,我试过使用实数,我试过摆弄 model_evaluator
和 model
的设置,但我真的不确定我在做什么做....
有没有其他人有任何类似的困难或运气更好地调试段错误(段错误:11,如果它有帮助?!),或者我在这里超出了 Z3 的限制?
非常感谢
这可能是由最近修复的类型检查功能中的错误引起的,因此在最新的不稳定版本中不会重现。原因是
(assert (= A (or 2 3 5 7)))
断言 A
(这是一个 Int
)应该等于 (or ...)
这是一个 Bool
,所以在最新的不稳定版本中我得到
(error "line 5 column 25: Sorts Int and Bool are incompatible")
(之后还有更多错误)。