Z3中的排序名称问题

Z3中的排序名称问题,z3,Z3,在前一篇文章中,使用名为S的排序来表示组,证明了一些组公理。请运行代码,但现在当排序名称更改为G时,代码不起作用。请在线查看问题,是否需要使用名称S进行排序,或者是Z3问题?请让我知道。请让我知道以下名为G的排序代码是否正确。非常感谢 (declare-sort G) (declare-fun f (G G) G) (declare-const a G) (declare-const b G) (declare-const c G) (assert (forall ((x G) (y G))

在前一篇文章中,使用名为S的排序来表示组,证明了一些组公理。请运行代码,但现在当排序名称更改为G时,代码不起作用。请在线查看问题,是否需要使用名称S进行排序,或者是Z3问题?请让我知道。

请让我知道以下名为G的排序代码是否正确。非常感谢

(declare-sort G)
(declare-fun f (G G) G)
(declare-const a G)
(declare-const b G)
(declare-const c G)
(assert (forall ((x G) (y G))
            (= (f x y)  (f y x))))
(assert (forall ((x G))
            (= (f x a) x)))
(assert (= (f b b) c))
(assert (= (f b c) a))
(assert (= (f c c) b))
(check-sat)
(get-model)

(push)
;; prove the left-module axiom
(assert (not (forall ((x G)) (= (f a x) x ))) )
(check-sat)
(pop)

(push)
;; prove the right-module axiom
(assert (not (forall ((x G)) (= (f x a) x ))) )
(check-sat)
(pop)


(declare-fun x () G)
(declare-fun y () G)
(declare-fun z () G)

(push)
;; prove the right-inverse axiom
(assert (not (=> (and  (or (= x a) (= x b) (= x c)))   (exists ((y G)) (= (f x y) a)))))
(check-sat)                
(pop)

(push)
;; prove the left-inverse axiom
(assert (not (=> (and  (or (= x a) (= x b) (= x c)))   (exists ((y G)) (= (f y x  ) a)))))
(check-sat)                
(pop)

(push)
;; prove the associativity axiom
(assert (not (=> (and (or (= x a) (= x b) (= x c)) (or (= y a) (= y b) (= y c)) 
                  (or (= z a) (= z b) (= z c))) 
            (=  (f x (f y z)) (f (f x y) z)))))

(check-sat)  
(pop)    

(push)
;; prove the commutative property
(assert (not (=> (and (or (= x a) (= x b) (= x c)) (or (= y a) (= y b) (= y c))) 

            (=  (f x y ) (f y x )))))

(check-sat)  
(pop) 
相应的输出是预期的

sat unsat unsat unsat unsat unsat unsat

请联机运行此代码

此问题的简化版本

$ z3 -version
Z3 version 4.3.1
使用名称S:

$ cat S.smt 
(declare-sort S)
(declare-fun f (S S) S)
(declare-const a S)
(declare-const b S)
(assert (= (f a a) a))
(assert (= (f a b) b))
(assert (= (f b a) b))
(assert (= (f b b) a))
(check-sat)

;; Restrict the search to models of size at most 2.
(assert (forall ((x S)) (or (= x a) (= x b))))

;; Associativity
(assert (not (forall ((x S) (y S) (z S)) (= (f x (f y z)) (f (f x y) z)))))
(check-sat)

$ z3 -smt2 S.smt
sat
unsat
使用名称G:

$ cat G.smt
(declare-sort G)
(declare-fun f (G G) G)
(declare-const a G)
(declare-const b G)
(assert (= (f a a) a))
(assert (= (f a b) b))
(assert (= (f b a) b))
(assert (= (f b b) a))
(check-sat)

;; Restrict the search to models of size at most 2
(assert (forall ((x G)) (or (= x a) (= x b))))

;; Associativity
(assert (not (forall ((x G) (y G) (z G)) (= (f x (f y z)) (f (f x y) z)))))
(check-sat)

$ z3 -smt2 G.smt
sat
unknown

奇怪,但这似乎是本地的网络版本和我们强加的超时。在本地运行示例不会带来任何问题。我正在尝试在本地运行示例:排序名为S的示例运行得非常快,并生成正确的输出;但是,当排序名为G时,该示例运行得非常慢,并且不会停止。你能告诉我发生了什么吗?在我使用Z3版本4.3.1的Ubuntu框中,我可以在4秒内运行名为S的代码,但使用名为G的代码在15分钟后没有产生任何结果。使用Z3不稳定版本(提交d548c51a984ea3baf173c55dd57418bccb327b7c)我无法重现这个问题。这非常有趣,值得注意的是,没有必要为了证明公理而生成模型。如果这是您当前使用的代码,请将其添加到问题本身,而不是作为答案。非常感谢。