Z3

Use Z3 and SMT-LIB to define sqrt function with a real number

蹲街弑〆低调 提交于 2019-12-20 04:38:06
问题 How I can write sqrt function in smt-libv2 format. Note: To get a maximum of two values, i found a useful link here: Use Z3 and SMT-LIB to get a maximum of two values. 回答1: Suppose that your formula is quantifier free, then you can define square-roots implicitly by introducing fresh variables and adding constraints. For example you can write: (define-fun is_sqrt ((x Real) (y Real)) Bool (= y (* x x))) Then 'x' is a square root of 'y'; and if you just want the non-negative square roots, then:

z3/python reals

天涯浪子 提交于 2019-12-20 04:23:49
问题 With the z3/python web interface, if I ask: x = Real ('x') solve(x * x == 2, show=True) I nicely get: Problem: [x·x = 2] Solution: [x = -1.4142135623?] I thought the following smt-lib2 script would have the same solution: (set-option :produce-models true) (declare-fun s0 () Real) (assert (= 2.0 (* s0 s0))) (check-sat) Alas, I get unknown with z3 (v3.2). I suspect the problem is with the non-linear term (* s0 s0) , which the python interface somehow doesn't suffer from. Is there a way to code

Why does Z3 return “unknown” on this simple input?

旧时模样 提交于 2019-12-20 04:14:10
问题 Here is the input: (set-option :auto-config false) (set-option :mbqi false) (declare-sort T6) (declare-sort T7) (declare-fun set23 (T7 T7) Bool) (assert (forall ((bv1 T7) (bv0 T7)) (= (set23 bv0 bv1) (= bv0 bv1)))) (check-sat) Note that Z3 does not timeout. It returns unknown almost instantaneously. 回答1: This returns unknown because you've disabled the quantifier handling mechanism (e.g., you disabled the model based quantifier instantiation module, MBQI), and it appears that with the options

Using Z3Py With Python 3.3

筅森魡賤 提交于 2019-12-20 04:11:47
问题 My Situation I've installed Microsoft Z3 ( Z3 [version 4.3.0 - 64 bit]. (C) 2006 ) and it's pyc binaries for Python2. I've written an Python3 package which needs access to z3 functionality. In order to be able to use the pyc binaries with my Python3 package, I decompyle the z3 binaries and applied 2to3 . My Problem Int('string') doesn't work because Z3Py isn't able to handle the new <class 'str'> used as 'string' argument: >>> import z3; z3.Int('abc') Traceback (most recent call last): File "

Z3 returns model not available

雨燕双飞 提交于 2019-12-20 03:56:09
问题 If possible I'd like a second opinion on my code. The constraints of the problem are: a,b,c,d,e,f are non-zero integers s1 = [a,b,c] and s2 = [d,e,f] are sets The sum s1_i + s2_j for i,j = 0..2 has to be a perfect square I don't understand why but my code returns model not available. Moreover, when commenting out the following lines: (assert (and (> sqrtx4 1) (= x4 (* sqrtx4 sqrtx4)))) (assert (and (> sqrtx5 1) (= x5 (* sqrtx5 sqrtx5)))) (assert (and (> sqrtx6 1) (= x6 (* sqrtx6 sqrtx6))))

z3 existential theory of the reals

橙三吉。 提交于 2019-12-20 03:54:10
问题 Does Z3 decide the existential fragment of nonlinear real arithmetic? That is, can I use it as a decision procedure for testing whether a quantifier-free formula with + and x has a solution over the reals? 回答1: Yes, Z3 has a decision procedure for the existential fragment of nonlinear polynomial real arithmetic. Of course, the procedure is complete modulo available resources. The procedure is quite expensive. This article describes the procedure implemented in Z3. Here is a small example

bv-enable-int2bv-propagation option

情到浓时终转凉″ 提交于 2019-12-20 03:31:25
问题 (set-option :bv-enable-int2bv-propagation true) works online. But, my local version complaints about it, saying: (error "line 1 column 43: unknown parameter 'bv_enable_int2bv_propagation', this is an old parameter name, invoke 'z3 -p' to obtain the new parameter list") What's the new parameter name? I tried to find it in the output of z3 -p , but I'm not sure. 回答1: I'm assuming you are using the unstable (working-in-progress) branch, or one of the nightly builds. The nightly builds are

z3 fails with this system of equations

╄→гoц情女王★ 提交于 2019-12-20 03:25:08
问题 Over the years I keep track of solving technology - and I maintain a blog post about applying them to a specific puzzle - the "crossing ladders". To get to the point, I accidentally found out about z3, and tried putting it to use in the specific problem. I used the Python bindings, and wrote this: $ cat laddersZ3.py #!/usr/bin/env python from z3 import * a = Int('a') b = Int('b') c = Int('c') d = Int('d') e = Int('e') f = Int('f') solve( a>0, a<200, b>0, b<200, c>0, c<200, d>0, d<200, e>0, e

Surprising behaviour when trying to prove a forall

北慕城南 提交于 2019-12-20 02:45:10
问题 Consider the following SMT-LIB code: (set-option :auto_config false) (set-option :smt.mbqi false) ; (set-option :smt.case_split 3) (set-option :smt.qi.profile true) (declare-const x Int) (declare-fun trigF (Int Int Int) Bool) (declare-fun trigF$ (Int Int Int) Bool) (declare-fun trigG (Int) Bool) (declare-fun trigG$ (Int) Bool) ; Essentially noise (declare-const y Int) (assert (! (not (= x y)) :named foo )) ; Essentially noise (assert (forall ((x Int) (y Int) (z Int)) (! (= (trigF$ x y z)

Which statistics indicate an efficient run of Z3?

北战南征 提交于 2019-12-20 02:34:31
问题 The SMTLib2 directive (get-info all-statistics) displays several numbers, e.g. num. conflicts: 4 num. propagations: 0 (binary: 0) num. qa. inst: 23 In order to test different axiomatisations and encodings I'd like to know which of those numbers are appropriate to declare that one Z3 run is better/more efficient than another. Guessing from the names I'd say that num. qa. inst - the number of quantifier instantiations - is a good indicator (lower = better), but what about the others? 回答1: