我正在尝试使用Z3求解器定义一个抽象的半环,但是,每当我尝试使用该环执行任何操作时,求解器似乎就会永远运行。
目前,我有以下Z3 smt代码:
; declare the ring elements
(declare-sort R)
(declare-fun add (R R) R)
(declare-fun mul (R R) R)
(declare-fun one () R)
(declare-fun zero () R)
; the add properties
(assert (forall ((a R)) (= (add a zero) a)))
(assert (forall ((a R) (b R)) (= (add a b) (add b a))))
(assert (forall ((a R) (b R) (c R)) (= (add (add a b) c) (add a (add b c)))))
; the multiply properties
(assert (forall ((a R)) (= (mul a one) a)))
(assert (forall ((a R)) (= (mul a zero) zero)))
(assert (forall ((a R) (b R)) (= (mul a b) (mul b a))))
(assert (forall ((a R) (b R) (c R)) (= (mul (mul a b) c) (mul a (mul b c)))))
; distributive
(assert (forall ((a R) (b R) (c R)) (= (mul a (add b c)) (add (mul a b) (mul a c)))))
; different elements
(assert (distinct zero one))
; Either of the following blocks on their own cause the solver to run seemingly forever
(declare-fun fubar () R)
(assert (= fubar (mul fubar one)))
(assert (= zero (mul zero one)))
(set-option :timeout 100000)
(check-sat)
(get-model)
答案 0 :(得分:0)
由于大量使用量词,我非常怀疑Z3是否适合此类问题。有限的模型查找和电子匹配并不容易。好的旧定理证明也许在这里是更好的选择,或者至少对基数非常明确,因此可以删除量化。 (诚然,这仅适用于小型域。)