smt

Using SMT-LIB to count the number of modules using a formula

↘锁芯ラ 提交于 2019-12-08 04:10:28
I am not sure that this is possible using SMT-LIB, if it is not possible does an alternative solver exist that can do it? Consider the equations a < 10 and a > 5 b < 5 and b > 0 b < c < a with a , b and c integers The values for a and b where the maximum number of model exist that satisfy the equations when a=9 and b=1 . Do SMT-LIB support the following: For each values of a and b count the number of models that satisfy the formulas and give the value for a and b that maximize the count. Let's break down your goals: You want to enumerate all possible ways in which a and b (...and more) can be

How to deal with recursive function in Z3?

不想你离开。 提交于 2019-12-08 02:32:22
问题 (set-option :smt.mbqi true) (declare-fun R(Int) Int) (declare-const a Int) (assert (= (R 0) 0)) (assert (forall ((n Int)) (=> (> n 0) (= (R n ) (+ (R (- n 1)) 1))))) (assert (not (= a 5))) (assert (not (= (R a) 5))) (check-sat) I have tried the above code in Z3,But Z3 unable to answer.Can you please guide me where i have made the mistake ? 回答1: As a general pattern don't expect MBQI to produce models involving functions that only have an infinite range of different values. If you really must,

Solving formulas in parallel with z3

陌路散爱 提交于 2019-12-07 06:09:17
问题 Let's say I have a z3 solver with a certain number of asserted constraints that are satisfiable. Let S be a set of constraints, I would like to verify for every constraint in S whether the formula is still satisfiable when adding the constraint to the solver. This can be easily done sequentially in such a fashion: results = [] for constraint in S: solver.push() solver.add(constraint) results.append(solver.check() == z3.sat) solver.pop() print all(results) Now, I would like to parallelize this

retrieve the matched model in Z3py?

匆匆过客 提交于 2019-12-06 15:07:40
问题 In the following working example , How to retrieve the matched model? S, (cl_3,cl_39,cl_11, me_32,m_59,m_81) = EnumSort('S', ['cl_3','cl_39','cl_11','me_32','me_59','me_81']) h1, h2 = Consts('h1 h2', S) def fun(h1 , h2): conds = [ (cl_3, me_32), (cl_39, me_59), (cl_11, me_81), # ... ] and_conds = (And(h1==a, h2==b) for a,b in conds) return Or(*and_conds) For Example: as the following solver s = Solver() x1 = Const('x1', S) x2 = Const('x2', S) s.add(fun(x1,x2)) print s.check() print s.model()

Z3 Time Restricted Optimization

吃可爱长大的小学妹 提交于 2019-12-06 14:55:56
问题 I have seen that Z3 supports optimization via e.g. assert-soft. From what I understood, if given sufficient time, Z3 will report the optimal solution for a given SMT formula. However, I am interested if it is possible to run Z3 for a limited amount of time and have it report the best solution it can find (which does not necessarily mean it is the optimal solution). If I run Z3 on a SMT formula and restrict the time (via parameter -T), it will just report 'timeout' if it did not solve it

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

SMT solver with custom theories?

心不动则不痛 提交于 2019-12-05 17:48:57
I'm looking at doing some verification work where I've got regular tree grammars as an underlying theory. Z3 lets you define your own stuff with uninterpreted functions, but that doesn't tend to work well any time your decision procedures are recursive. They used to allow for plugins but that has been depricated, I think. I'm wondering, does anybody have a recommendation of a decent SMT solver that allows you to write decision procedures for custom theories? There are several options given that most reasonable SMT solvers are open source you can integrate theory solvers in any detail depending

Solving formulas in parallel with z3

怎甘沉沦 提交于 2019-12-05 10:52:32
Let's say I have a z3 solver with a certain number of asserted constraints that are satisfiable. Let S be a set of constraints, I would like to verify for every constraint in S whether the formula is still satisfiable when adding the constraint to the solver. This can be easily done sequentially in such a fashion: results = [] for constraint in S: solver.push() solver.add(constraint) results.append(solver.check() == z3.sat) solver.pop() print all(results) Now, I would like to parallelize this to speed things up, but I'm not sure how to do it properly with z3. Here is an attempt. Consider the

Avoiding quantifiers in Z3

狂风中的少年 提交于 2019-12-05 03:58:26
I am experimenting with Z3 where I combine the theories of arithmetic, quantifiers and equality. This does not seem to be very efficient, in fact it seems to be more efficient to replace the quantifiers with all instantiated ground instances when possible. Consider the following example, in which I have encoded the unique names axiom for a function f that takes two arguments of sort Obj and returns an interpreted sort S . This axiom states that each unique list of arguments to f returns a unique object: (declare-datatypes () ((Obj o1 o2 o3 o4 o5 o6 o7 o8))) (declare-sort S 0) (declare-fun f