Z3

Z3 FP logic: produces unexpected model

我只是一个虾纸丫 提交于 2019-12-24 12:41:32
问题 For this problem: http://rise4fun.com/Z3/YNBG Z3 produces the model: sat ((s0 FP!val!0)) I was expecting to see a true number as the model. It's almost as if it's treating FP as an uninterpreted sort for this case. Is there a way to get Z3 to produce a real number here? 回答1: Thanks for reporting this. Indeed, there was a bug in the model completion for FPA. The fix is already available in the unstable branch at Codeplex. Note that == (floating point equal) with NaN is always false, i.e., in

Randomness in Z3 Results

点点圈 提交于 2019-12-24 11:44:32
问题 I am using the Z3 Python interface as part of a research tool that I am writing, and I noticed some pretty odd behavior when I run the Z3 solver repeatedly on the same query: In particular, I seem to not get the same results each time, even though I explicitly reset the solver before running. For reference, here's my code: import z3 with open("query.smt", "r") as smt_reader: query_lines = "".join(smt_reader.readlines()) for i in xrange(3): solver = z3.Solver() solver.reset() queryExpr = z3

Model-based Quantifier Instantiation and the Stratified Sorts Fragment

走远了吗. 提交于 2019-12-24 07:59:48
问题 the documentation of Z3 says for the Model-based Quantifier Instantiation (MBQI): Stratified Sorts Fragment The statified sorts fragment is another decidable fragment of many sorted first-order logic formulas. It corresponds to formulas which, when written in prenex normal form, there is a function level from sorts to naturals, and for every function (declare-fun f (S_1 ... S_n) R) level(R) < level(S_i). Does Z3 support any formula that is in prenex normal form, or only universal ones where

Extracting just one value from a z3 model

…衆ロ難τιáo~ 提交于 2019-12-24 07:28:27
问题 I'm looking for the z3 source API equivalent of get-value . For example, when I have the following query, I can easily specify which values I want to be seen: (declare-const s1 String) (declare-const s2 String) (assert (= 8 (str.len s1 ))) (assert (= 3 (str.indexof s1 "M" 0))) (assert (= 3 (str.len s2 ))) (assert (= -1 (str.indexof s2 "\x00" 0))) (check-sat) ;(get-value (s1)) (get-value (s1 s2)) I manage to do the same thing with the (C) source API, but then I only get the entire model (s1

Why this z3 equation is failing?

点点圈 提交于 2019-12-24 06:58:32
问题 I need to solve this code (the code in C) if ( ((0xAAAAAAAAAAAAAAABLL * len_input_serial >> 64) >> 1)+ len_input_serial- 3 * ((0xAAAAAAAAAAAAAAABLL * len_input_serial >> 64) >> 1) != 14) return 0xFFFFFFFFLL; that's my python script from z3 import * len_input_serial = BitVec("serial_len",64) solve(LShR(LShR(0xAAAAAAAAAAAAAAABL * len_input_serial,64),1) + len_input_serial - 3 * LShR(LShR(0xAAAAAAAAAAAAAAABL * len_input_serial,64),1) == 14) However this gives me [serial_len = 14] I know the

Different check-sat answers when asserting same property in between

╄→гoц情女王★ 提交于 2019-12-24 05:33:52
问题 Given the following input (set-option :auto_config false) (set-option :smt.mbqi false) (declare-fun len (Int) Int) (declare-fun idx (Int Int) Int) (declare-const x Int) (define-fun FOO () Bool (forall ((i Int)) (! (implies (and (<= 0 i) (< i (len x))) (exists ((j Int)) (! (implies (and (<= 0 j) (< j (len x))) (> (idx x j) 0)))))))) (assert FOO) ; (push) (assert (not FOO)) (check-sat) ; (pop) ; (push) (assert (not FOO)) (check-sat) ; (pop) Z3 4.3.2 x64 reports unsat for the first check-sat (as

Which is better practice in SMT: to add multiple assertions or single and?

此生再无相见时 提交于 2019-12-24 05:04:33
问题 Lets say I have two clauses that I want to model in SMT, is it better to add them as separate assertions like (assert (> x y)) (assert (< y 2)) or to add one assertion with and operator like this (assert (and (> x y) (< y 2) )) Does this matter for large scale problems in terms of SMT solver performance. I am using Z3. 回答1: The conjunction gets split into multiple assertions, so it doesn't really matter too much. If you introduce a large conjunction, Z3's parser will create a term that

Z3 int2bv operation

回眸只為那壹抹淺笑 提交于 2019-12-24 04:59:14
问题 I am experiencing some issues with the bitvector operations. In particular, given the following model. I was expecting var0 to be 11 . (declare-const var1 Int) (declare-const var0 Int) (assert (= var1 10)) (assert (= var0 ((_ bv2int 32) (bvor ((_ int2bv 32) var1) ((_ int2bv 32) 1))))) (check-sat) (get-model) (exit) However, the solution given by Z3 for fun was: sat (model (define-fun var1 () Int 10) (define-fun var0 () Int (- 1)) ) This means, -1 instead of 10. Am I doing something wrong? 回答1

Z3 Python bindings: init(Z3_LIBRARY_PATH) must be invoked before using Z3-python

前提是你 提交于 2019-12-24 04:26:07
问题 I installed the Z3 theorem prover on Linux, and am using its Python bindings (Z3Py). I tried to test a minimal example, but I immediately got the following error: z3.z3types.Z3Exception: init(Z3_LIBRARY_PATH) must be invoked before using Z3-python How do I fix this and get up and running with Z3? I'm not quite sure what that error message means. The Z3 documentation and tutorials don't seem to say anything about this or about init() , and the Z3-Python docs don't list any function called init

Support of trigonometric functions ( e.g.: cos, tan) in Z3

喜你入骨 提交于 2019-12-24 03:48:19
问题 I would like to use Z3 to optimize a set of equations. The problem hereby is my equations are non-linear but most importantly they do have trigonometric functions. Is there a way to deal with that in z3? I am using the z3py API. 回答1: Transcendental numbers and trigonometric functions are usually not supported by SMT solvers. As Christopher pointed out (thanks!), Z3 does have support for trigonometric functions and transcendentals; but the support is rather quite limited. (In practice, this