0
集團Z3已經款項如何使用Z3 SMT-LIB獲得團體表示Z3和Z4
使用下面的Z3 SMT-LIB代碼下表是可以得到Z3的表示:
(set-option :mbqi true)
(declare-sort S)
(declare-fun f (S S) S)
(declare-const a S)
(declare-const b S)
(declare-const c S)
(assert (forall ((x S) (y S))
(= (f x y) (f y x))))
(assert (forall ((x S))
(= (f x a) x)))
(assert (= (f b b) c))
(assert (= (f b c) a))
(assert (= (f c c) b))
(check-sat)
(get-model)
相應的輸出是
sat
(model
;; universe for S:
;; S!val!1 S!val!0 S!val!2
;; -----------
;; definitions for universe elements:
(declare-fun S!val!1() 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!0) (= x S!val!2)))
;; -----------
(define-fun b() S S!val!0)
(define-fun c() S S!val!1)
(define-fun a() S 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!1) (= x!2 S!val!1)) S!val!0
(ite (and (= x!1 S!val!1) (= x!2 S!val!0)) S!val!2
(ite (and (= x!1 S!val!0) (= x!2 S!val!2)) S!val!0
(ite (and (= x!1 S!val!2) (= x!2 S!val!0)) S!val!0
(ite (and (= x!1 S!val!2) (= x!2 S!val!1)) S!val!1
(ite (and (= x!1 S!val!1) (= x!2 S!val!2)) S!val!1
x!1)))))))))
)
運行該代碼的在線here
組Z4具有和的下表:
採用下述Z3 SMT-LIB代碼可以獲得Z4的表示:
(set-option :mbqi true)
(declare-sort S)
(declare-fun f (S S) S)
(declare-const a S)
(declare-const b S)
(declare-const c S)
(declare-const d S)
(assert (forall ((x S) (y S))
(= (f x y) (f y x))))
(assert (forall ((x S))
(= (f x a) x)))
(assert (= (f b b) c))
(assert (= (f b c) d))
(assert (= (f b d) a))
(assert (= (f c c) a))
(assert (= (f c d) b))
(assert (= (f d d) c))
(check-sat)
(get-model)
相應的輸出是:
sat
(model
;; universe for S: ;; S!val!1 S!val!3 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!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!0) (= x S!val!2)))
;; -----------
(define-fun b() S S!val!0)
(define-fun c() S S!val!1)
(define-fun d() S S!val!2)
(define-fun a() S S!val!3)
(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!2)) S!val!3
(ite (and (= x!1 S!val!1) (= x!2 S!val!1)) S!val!3
(ite (and (= x!1 S!val!1) (= x!2 S!val!2)) S!val!0
(ite (and (= x!1 S!val!2) (= x!2 S!val!2)) S!val!1
(ite (and (= x!1 S!val!1) (= x!2 S!val!0)) S!val!2
(ite (and (= x!1 S!val!2) (= x!2 S!val!0)) S!val!3
(ite (and (= x!1 S!val!2) (= x!2 S!val!1)) S!val!0
(ite (and (= x!1 S!val!2) (= x!2 S!val!3)) S!val!2
(ite (and (= x!1 S!val!3) (= x!2 S!val!2)) S!val!2
(ite (and (= x!1 S!val!3) (= x!2 S!val!1)) S!val!1
(ite (and (= x!1 S!val!1) (= x!2 S!val!3)) S!val!1
(ite (and (= x!1 S!val!3) (= x!2 S!val!0)) S!val!0
(ite (and (= x!1 S!val!0) (= x!2 S!val!3)) S!val!0
x!1))))))))))))))))
)
運行這段代碼在線here
的問題是,如何在原有的代碼插入與Z3和Z4可以使組計算這樣的方式由Z3生成的函數f
。非常感謝。
您的回答非常好,說明性和實用性。非常感謝。 –