いいえ、ステートメントは異なります。Z3の定数はnullary(0 arity)関数であるため、(declare-const a Int)
の構文上の砂糖であるため(declare-fun a () Int)
、これら2つのステートメントは同一です。2番目のステートメント(assert (>= (f x x) (+ x a))))
は、最初のステートメントのようにすべてのxに対してではなく、xの存在を暗黙的に表明します(assert (forall ((x Int)) (>= (f x x) (+ x a))))
。明確にするために、2番目のステートメントでは、xの単一の割り当てのみがアサーションを満たす必要があり、すべての可能な割り当てではないことに注意してください(関数fの違いにも注意してください。また、次のZ3 @riseスクリプトを参照してください:http:// rise4fun .com / Z3 / 4cif)。
そのスクリプトのテキストは次のとおりです。
(set-option :mbqi true)
(declare-fun f (Int Int) Int)
(declare-const a Int)
(declare-fun af () Int)
(declare-const b Int)
(declare-fun bf () Int)
(push)
(declare-const x Int)
(assert (>= (f x x) (+ x a)))
(check-sat) ; note the explicit model value for x: this only checks a single value of x, not all of them
(get-model)
(pop)
(push)
(assert (forall ((x Int)) (>= (f x x) (+ x a))))
(check-sat)
(get-model) ; no model for x since any model must satisfy assertion
(pop)
また、Z3 SMTガイド(http://rise4fun.com/z3/tutorial/guideの「未解釈の関数と定数」のセクション)の例を次に示します。
(declare-fun f (Int) Int)
(declare-fun a () Int) ; a is a constant
(declare-const b Int) ; syntax sugar for (declare-fun b () Int)
(assert (> a 20))
(assert (> b a))
(assert (= (f 10) 1))
(check-sat)
(get-model)