如何使用Z3 SMT-LIB来证明D3组的定理

时间:2013-11-22 01:39:31

标签: z3

D3组的产品表是:

enter image description here

使用以下Z3 SMT-LIB代码可以获得表示:

(set-option :mbqi true)
(declare-sort S)
(declare-fun f (S S) S)
(declare-fun g (S) S)
(declare-const E S)
(declare-const R1 S)
(declare-const R2 S)
(declare-const R3 S)
(declare-const R4 S)
(declare-const R5 S)
(assert (forall ((x S))
            (= (f x E) x)))
(assert (forall ((x S))
            (= (f E x) x)))               
(assert (= (f R1 R1) R2))
(assert (= (f R1 R2) E))
(assert (= (f R1 R3) R4))
(assert (= (f R1 R4) R5))
(assert (= (f R1 R5) R3))
(assert (= (f R2 R1) E))
(assert (= (f R2 R2) R1))
(assert (= (f R2 R3) R5))
(assert (= (f R2 R4) R3))
(assert (= (f R2 R5) R4))
(assert (= (f R3 R1) R5))
(assert (= (f R3 R2) R4))
(assert (= (f R3 R3) E))
(assert (= (f R3 R4) R2))
(assert (= (f R3 R5) R1))
(assert (= (f R4 R1) R3))
(assert (= (f R4 R2) R5))
(assert (= (f R4 R3) R1))
(assert (= (f R4 R4) E))
(assert (= (f R4 R5) R2))
(assert (= (f R5 R1) R4))
(assert (= (f R5 R2) R3))
(assert (= (f R5 R3) R2))
(assert (= (f R5 R4) R1))
(assert (= (f R5 R5) E))
(assert (= (g E) E))
(assert (= (g R1) R2))
(assert (= (g R2) R1))
(assert (= (g R3) R3))
(assert (= (g R4) R4))
(assert (= (g R5) R5))
(check-sat)
(get-model)

在此代码中,函数f给出了产品,函数g给出了反函数。相应的输出是:

sat 
(model 
;; universe for S: 
;; S!val!1 S!val!3 S!val!5 S!val!4 S!val!0 S!val!2 
;; -----------
;; definitions for universe elements: 
(declare-fun S!val!1 () S) 
(declare-fun S!val!3 () S) 
(declare-fun S!val!5 () S) 
(declare-fun S!val!4 () S) 
(declare-fun S!val!0 () S) 
(declare-fun S!val!2 () S) 
;; cardinality constraint: 
(forall ((x S)) (or (= x S!val!1) (= x
  S!val!3) (= x S!val!5) (= x S!val!4) (= x S!val!0) (= x S!val!2)))
;; ----------- 
(define-fun R1 () S S!val!0) 
(define-fun R3 () S S!val!3) 
(define-fun R2 () S S!val!1) 
(define-fun R4 () S S!val!4) 
(define-fun R5 () S S!val!5) 
(define-fun E () S S!val!2) 
(define-fun g ((x!1 S)) S 
 (ite (= x!1 S!val!0) S!val!1 
 (ite (= x!1 S!val!1) S!val!0 
 (ite (= x!1 S!val!3) S!val!3 
 (ite (= x!1 S!val!4) S!val!4 
 (ite (= x!1 S!val!5) S!val!5 S!val!2)))))) 
(define-fun f ((x!1 S) (x!2 S)) S 
 (ite (and (= x!1 S!val!0) (= x!2 S!val!0)) S!val!1 
 (ite (and (= x!1 S!val!0) (= x!2 S!val!1)) S!val!2 
 (ite (and (= x!1 S!val!0) (= x!2 S!val!3)) S!val!4 
 (ite (and (= x!1 S!val!0) (= x!2 S!val!4)) S!val!5 
 (ite (and (= x!1 S!val!0) (= x!2 S!val!5)) S!val!3 
 (ite (and (= x!1 S!val!1) (= x!2 S!val!0)) S!val!2 
 (ite (and (= x!1 S!val!1) (= x!2 S!val!1)) S!val!0 
 (ite (and (= x!1 S!val!1) (= x!2 S!val!3)) S!val!5 
 (ite (and (= x!1 S!val!1) (= x!2 S!val!4)) S!val!3 
 (ite (and (= x!1 S!val!1) (= x!2 S!val!5)) S!val!4 
 (ite (and (= x!1 S!val!3) (= x!2 S!val!0)) S!val!5 
 (ite (and (= x!1 S!val!3) (= x!2 S!val!1)) S!val!4 
 (ite (and (= x!1 S!val!3) (= x!2 S!val!3)) S!val!2 
 (ite (and (= x!1 S!val!3) (= x!2 S!val!4)) S!val!1 
 (ite (and (= x!1 S!val!3) (= x!2 S!val!5)) S!val!0 
 (ite (and (= x!1 S!val!4) (= x!2 S!val!0)) S!val!3 
 (ite (and (= x!1 S!val!4) (= x!2 S!val!1)) S!val!5 
 (ite (and (= x!1 S!val!4) (= x!2 S!val!3)) S!val!0 
 (ite (and (= x!1 S!val!4) (= x!2 S!val!4)) S!val!2 
 (ite (and (= x!1 S!val!4) (= x!2 S!val!5)) S!val!1 
 (ite (and (= x!1 S!val!5) (= x!2 S!val!0)) S!val!4 
 (ite (and (= x!1 S!val!5) (= x!2 S!val!1)) S!val!3 
 (ite (and (= x!1 S!val!5) (= x!2 S!val!3)) S!val!1 
 (ite (and (= x!1 S!val!5) (= x!2 S!val!4)) S!val!0 
 (ite (and (= x!1 S!val!5) (= x!2 S!val!5)) S!val!2 
 (ite (= x!1 S!val!2) x!2 x!1))))))))))))))))))))))))))) 
 )

使用这种表示可以证明以下定理:

enter image description here

证据是:

(eval (f (f R3 R1) (g R3)))
(eval R2)

输出

S!val!1 
S!val!1

运行完整代码here

问题是:有可能更准确地证明这个定理吗?

1 个答案:

答案 0 :(得分:1)

您想要检查断言是否暗示(f (f R3 R1) (g R3))R2相等。您可以通过显示上面的断言加上断言

来实现这一点
    (assert (not (= (f (f R3 R1) (g R3)) R2)))

不可满足。 您可以在(check-sat)之前添加以下附加断言。 Here是更新后的示例。

您可以在原始断言集之后使用以下命令序列

    (check-sat) ; check if the set of assertions is consistent
    (get-model) ; display the model
    ; assert the negation of the conjecture
    (assert (not (= (f (f R3 R1) (g R3)) R2))) 
    (check-sat) 

Here是使用此命令序列的更新示例。