Z3

How do I get Z3 to return minimal model?

ε祈祈猫儿з 提交于 2019-12-06 11:33:53
问题 If I give Z3 a formula like p | q, I would expect Z3 to return p=true, q=don't care (or with p and q switched) but instead it seems to insist on assigning values to both p and q (even though I don't have completion turned on when calling Eval() ). Besides being surprised at this, my question then is what if p and q are not simple prop. vars but expensive expressions and I know that typically either p or q will be true. Is there an easy way to ask Z3 to return a "minimal" model and not waste

z3python: using math library

我们两清 提交于 2019-12-06 11:01:53
问题 I was trying to use python's math library with z3python, what I did was import z3 import math a,b = z3.Reals('a b') solve(b == math.factorial(a), b == 6) The error message it returns is AttributeError: ArithRef instance has no attribute ' float '. My purpose is not really using the factorial function in Z3, rather I am curious if the functions from the math library can be used with Z3 in general. Any suggestion is appreciated. 回答1: In general, no, this is not possible. The reason is that

ld linking error while compiling z3

假如想象 提交于 2019-12-06 09:19:20
问题 I met the following error while compiling z3. It seems to be an error for ld. I wonder what I can do to make it compile. It is a problem from the opt branch in git. I am on iMac with OS X 10.9.2 (13C1021) I am with xcode Version 5.1.1 (5B1008) with xcode-select tools installed to version 2333. I use port with version 2.2.1 with ld installed. The problem seems to be a linking problem. I am using link loader as: ld64 @136_2+llvm33 (active) My gcc is gcc (MacPorts gcc48 4.8.2_0) 4.8.2 Thank you

Z3 Enumerating all satisfying assignments

元气小坏坏 提交于 2019-12-06 08:00:48
I am trying to solve a problem similar to the one here ( Z3: finding all satisfying models ) where I need to find all satisfying assignments of SMT formulae that contain set variables. I understand the idea in the link since it is similar to what some SAT solvers do to iterate through solutions: add the negation of the solution to obtain a different solution. However, when I use the set variables (which are implemented as arrays in Z3) the things get a little complicated or perhaps I miss something. Assume that I have two constraints added to the solver as follows: EnumSort rSort = ctx

Display declarations parsed from an SMT-LIB2 file

荒凉一梦 提交于 2019-12-06 06:55:57
I'm using Z3 with Java API. In my SMT-LIB2 file, there are several variables: (declare-fun x0 () Int) (declare-fun x1 () Bool) ; alot more I want to get all these variables, and store them in an array of Expr . From the example distributed with z3, I find the API SMTLIBDecls that get declarations parsed from an SMT-LIB1 file, but there is no similar API for SMT-LIB2. How can I get the declarations? Thanks. Christoph Wintersteiger There is currently no function for this purpose, but it is easy to get the declarations by traversing the expressions. This has previously been asked for C/C++, but

Performance issues about Z3 for Java

限于喜欢 提交于 2019-12-06 04:34:50
I am running into some performance issues in my current project with Z3 for Java: Basically most of my current constraints are pretty simple: e.g: (f(x) = 2 && f(y) <= 3) || f(x) <=5 I am using static context and solver instances shared by the whole project: public class ConstraintManager { static Context ctx; static Solver solver; ... } If I generate expr by the same instance of ctx for billions of times, is that going to an issue? When is the best time to invoke ctx.Dispose() , or, what's the best way to manage ctx? I invoked expr.Simplify() to simplify some constraints like: f(x)=3 && f(x)<

Array select and store using the C++ API

自作多情 提交于 2019-12-06 03:34:32
I am using z3 v 4.1. I am using the C++ API and I am trying to add some array constraints in the context. I dont see the select and sort functions in the C++ API. I tried mixing of the C and C++ API. In the example array_example1() provided with the C API if I change the context variable from Z3_Context (i.e. C API) to context (i.e. C++ API) I get a segmentation fault at the "create antecedent" statement void array_example1(){ context ctx; //Z3_context ctx; Z3_sort int_sort, array_sort; Z3_ast a1, a2, i1, v1, i2, v2, i3; Z3_ast st1, st2, sel1, sel2; Z3_ast antecedent, consequent; Z3_ast ds[3];

Using theory plugins with solvers

纵饮孤独 提交于 2019-12-06 03:33:32
Recent versions of Z3 have decoupled the notions of Z3_context and Z3_solver . The API mostly reflects these changes; for instance push is deprecated on contexts and respecified as taking a solver as an extra argument. The interface for theories has not been updated, however. Theories are still created from contexts, and as far as I can tell, never explicitly attached to solvers. One could think that a theory created from a context will always be attached to all solvers created from the context, but it seems from our experience that this is not the case. Instead, user-defined theories seem to

How to convert a formula to Disjunctive Normal Form?

守給你的承諾、 提交于 2019-12-06 03:29:33
问题 Say given a formula (t1>=2 or t2>=3) and (t3>=1) I wish to get its disjunctive normal form (t1>=2 and t3>=1) or (t2>=3 and t3>=1) How to achieve this in Z3? 回答1: Z3 does not have an API or tactic for converting formulas into DNF. However, it has support for breaking a goal into many subgoals using the tactic split-clause . Given an input formula in CNF, if we apply this tactic exhaustively, each output subgoal can be viewed as a big conjunction. Here is an example on how to do it. http:/

Does z3 support rational arithmetic for its input constraints?

笑着哭i 提交于 2019-12-06 03:17:16
In fact, does the SMT-LIB standard have a rational (not just real) sort? Going by its website , it does not. If x is a rational and we have a constraint x^2 = 2, then we should get back ``unsatisfiable''. The closest I could get to encoding that constraint is the following: ;;(set-logic QF_NRA) ;; intentionally commented out (declare-const x Real) (assert (= (* x x) 2.0)) (check-sat) (get-model) for which z3 returns a solution, as there is a solution (irrational) in the reals. I do understand that z3 has its own rational library, which it uses, for instance, when solving QF_LRA constraints