smt

Can Z3 check the satisfiability of formulas that contain recursive functions?

安稳与你 提交于 2019-11-29 11:13:13
I'm trying out some of the examples of a Z3 tutorial that involve recursive functions. I've tried out the following example. Fibonacci (Section 8.3) IsNat (Section 8.3) Inductive (Section 10.5) Z3 times out on all of the above examples. But, the tutorial seems to imply that only Inductive is non-terminating. Can Z3 check the satisfiability of formulas that contain recursive functions or it cannot handle any inductive facts? Leonardo de Moura These examples from the Z3 tutorial are there to illustrate limitations of the technology behind Z3. Z3 fails on these examples for two reasons: The

printing internal solver formulas in z3

旧巷老猫 提交于 2019-11-29 10:26:53
The theorem proving tool z3 is taking a lot of time to solve a formula, which I believe it should be able to handle easily. To understand this better and possibly optimize my input to z3, I wanted to see the internal constraints that z3 generates as part of its solving process. How do I print the formula that z3 produces for its back-end solvers, when using z3 from the command line? Leonardo de Moura Z3 command line tool does not have such option. Moreover, Z3 contains several solvers and pre-processing steps. It is unclear which step would be useful for you. The Z3 source code is available at

y=1/x, x=0 satisfiable in the reals?

£可爱£侵袭症+ 提交于 2019-11-28 09:35:20
问题 In SMT-LIB: (declare-fun y () Real) (declare-fun x () Real) (assert (= 0.0 x)) (assert (= y (/ 1.0 x))) (check-sat) Should this model be SAT or UNSAT? 回答1: In SMT-LIB 2.0 and 2.5, all functions are total, so this example is SAT in SMT-LIB. Both Z3 and CVC4 do indeed return SAT for the example in the question. I found this counter-intuitive. I think it would be mathematically more well justified to say that y=1/x, x=0 is unsatisfiable in the reals. In Mathematica, the equivalent code returns

Z3: Extracting existential model-values

若如初见. 提交于 2019-11-28 09:28:46
问题 I'm playing around with Z3's QBVF solver, and wondering if it's possible to extract values from an existential assertion. To wit, let's say I have the following: (assert (exists ((x (_ BitVec 16))) (forall ((y (_ BitVec 16))) (bvuge y x)))) This basically says that there is a "least" 16-bit unsigned value. Then, I can say: (check-sat) (get-model) And Z3-3.0 happily responds: sat (model (define-fun x!0 () (_ BitVec 16) #x0000) ) Which is really cool. But what I want to do is to be able to

How to optimize a piece of code in Z3? (PI_NON_NESTED_ARITH_WEIGHT related)

痴心易碎 提交于 2019-11-28 06:25:24
问题 I have a code in z3 which aims to solve an optimization problem for a boolean formula (set-option :PI_NON_NESTED_ARITH_WEIGHT 1000000000) (declare-const a0 Int) (assert (= a0 2)) (declare-const b0 Int) (assert (= b0 2)) (declare-const c0 Int) (assert (= c0 (- 99999))) (declare-const d0 Int) (assert (= d0 99999)) (declare-const e0 Int) (assert (= e0 49)) (declare-const f0 Int) (assert (= f0 49)) (declare-const a1 Int) (assert (= a1 3)) (declare-const b1 Int) (assert (= b1 3)) (declare-const c1

Z3 : Questions About Z3 int2bv?

百般思念 提交于 2019-11-28 05:46:19
问题 I'm a little confused with the Z3 (smt2 format ) operation int2bv . I wrote a such smt2 expression : (declare-const t1 Int) (assert (= ((_ int2bv 2) t1) #b11)) (check-sat) (get-model) when I solve it with Z3 ,it got: sat (model (define-fun t1 () Int 0) ) Is that correct? Shouldn't t1 be 3? I thought the int2bv operation just transform the int value to the equivalent bitvector value. But it seems not! Thanks! 回答1: The int2bv function is essentially handled as uninterpreted (as stated in the

Read func interp of a z3 array from the z3 model

一世执手 提交于 2019-11-27 15:39:06
Suppose I have 2 arrays in a formula whose satisfiability I want to check using z3. If z3 returns sat, I want to read in the first array in the z3 model and pretty print it as a key, value pair and a default value. Later I want to convert it to a map and do further analysis on it. Here's the example I run: void find_model_example_arr() { std::cout << "find_model_example_involving_array\n"; context c; sort arr_sort = c.array_sort(c.int_sort(), c.int_sort()); expr some_array_1 = c.constant("some_array_1", arr_sort); expr some_array_2 = c.constant("some_array_2", arr_sort); solver s(c); s.add

SAT solving with haskell SBV library: how to generate a predicate from a parsed string?

自作多情 提交于 2019-11-27 14:08:28
问题 I want to parse a String that depicts a propositional formula and then find all models of the propositional formula with a SAT solver. Now I can parse a propositional formula with the hatt package; see the testParse function below. I can also run a SAT solver call with the SBV library; see the testParse function below. Question: How do I, at runtime, generate a value of type Predicate like myPredicate within the SBV library that represents the propositional formula I just parsed from a String

Z3: finding all satisfying models

☆樱花仙子☆ 提交于 2019-11-26 10:41:47
I am trying to retrieve all possible models for some first-order theory using Z3, an SMT solver developed by Microsoft Research. Here is a minimal working example: (declare-const f Bool) (assert (or (= f true) (= f false))) In this propositional case there are two satisfying assignments: f->true and f->false . Because Z3 (and SMT solvers in general) will only try to find one satisfying model, finding all solutions is not directly possible. Here I found a useful command called (next-sat) , but it seems that the latest version of Z3 no longer supports this. This is bit unfortunate for me, and in

Z3: finding all satisfying models

风流意气都作罢 提交于 2019-11-26 02:01:05
问题 I am trying to retrieve all possible models for some first-order theory using Z3, an SMT solver developed by Microsoft Research. Here is a minimal working example: (declare-const f Bool) (assert (or (= f true) (= f false))) In this propositional case there are two satisfying assignments: f->true and f->false . Because Z3 (and SMT solvers in general) will only try to find one satisfying model, finding all solutions is not directly possible. Here I found a useful command called (next-sat) , but