下面是一個試圖回答問題1-4的例子(帶有評論)。它也可以在線here。
(declare-const x Int)
(declare-const y Int)
;; 1. and 2.
;; The simplifier will map strict inequalities (<, >) into non-strict ones (>=, <=)
;; Example: x < y ===> not x >= y
;; As suggested by you, for integer inequalities, we can also use
;; x < y ==> x <= y - 1
;; This choice was made because it is convenient for solvers implemented in Z3
;; Other normal forms can be used.
;; It is possible to map everything to a single inequality. This is a straightforward modificiation
;; in the Z3 simplifier. The relevant files are src/ast/rewriter/arith_rewriter.* and src/ast/rewriter/poly_rewriter.*
(simplify (<= x y))
(simplify (< x y))
(simplify (>= x y))
(simplify (> x y))
;; 3.
;; :som stands for sum-of-monomials. It is a normal form for polynomials.
;; It is essentially a big sum of products.
;; The simplifier applies distributivity to put a polynomial into this form.
(simplify (<= (* (+ y 2) (+ x 2)) (+ (* y y) 2)))
(simplify (<= (* (+ y 2) (+ x 2)) (+ (* y y) 2)) :som true)
;; Another relevant option is :arith-lhs. It will move all non-constant monomials to the left-hand-side.
(simplify (<= (* (+ y 2) (+ x 2)) (+ (* y y) 2)) :som true :arith-lhs true)
;; 4. Yes, you are correct.
;; The polynomials are encoded using just * and +.
(simplify (- x y))
5)CTX-求解器簡化文件src/SMT /策略/ CTX-求解器簡化。* 的代碼非常可讀被實現。我們可以添加跟蹤消息來了解它是如何在特定示例上運行的。
6)目前還沒有關於如何寫策略的教程。但是,代碼庫有很多例子。 目錄src/tactic/core
有基本的。
謝謝。所以,就我所知,som似乎隻影響非線性項,因爲線性算術被簡化爲單項式的總和。那是對的嗎? – Egbert 2013-04-09 09:31:25
你在1號工作嗎? – toebs 2016-07-28 10:43:45