z3py

Z3 String/Char xor?

跟風遠走 提交于 2019-12-11 11:12:33
问题 I'm working with Z3 in Python and am trying to figure out how to do String operations. In general, I've played around with z3.String as the object, doing things like str1 + str2 == 'hello world' . However, I have been unable to accomplish the following behavior: solver.add(str1[1] ^ str1[2] == 12) # -- or -- solver.add(str1[1] ^ str1[2] == str2[1]) So basically add the constraint that character 1 xor character 2 equals 12. My understanding is that the string is defined as a sequence of 8-bit

timeout for z3 solver in python

人盡茶涼 提交于 2019-12-11 10:37:21
问题 I have problems setting a timeout for my solver: s = Solver() encoding = parse_smt2_file("ex.smt2") s.add(encoding) s.set("timeout", 600) solution = s.check() but I get the following error Traceback (most recent call last): File "/Users/X/Documents/encode.py", line 145, in parse_polyedra("file") File "/Users/X/Documents/encode.py", line 108, in parse_polyedra s.set("timeout",1) File "/Users/X/z3/build/z3.py", line 5765, in set Z3_solver_set_params(self.ctx.ref(), self.solver, p.params) File "

Scalability of z3

混江龙づ霸主 提交于 2019-12-11 07:48:42
问题 I would like to improve the scalability of SMT solving. I have actually implemented the incremental solving. But I would like to improve more. Any other general methods to improve it without the knowledge of the problem itself? 回答1: There's no single "trick" that can make z3 scale better for an arbitrary problem. It really depends on what the actual problem is and what sort of constraints you have. Of course, this goes for any general computing problem, but it really applies in the context of

Z3 BitVec extraction using symbolic high and low

断了今生、忘了曾经 提交于 2019-12-11 07:02:21
问题 I've been playing around with proving certain SIMD vectorizations using Z3 and I'm running into a problem trying to model SIMD operations that conditionally move around bits or lanes (such as Intel _mm_shuffle_epi8 for example) The problem occurs when I try to use symbolic high and low with Extract which does not seem supported: assert a.sort() == BitVecSort(128) assert b.sort() == BitVecSort(128) Extract( Extract(i+3,i,b)*8+7, Extract(i+3,i,b)*8, a) results in z3.z3types.Z3Exception:

Bit Vector tactic leads to exit code 139 in Z3Py

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 04:36:56
问题 This is a simple bit vector problem: import z3 s = z3.Tactic('bv').solver() m = z3.Function('m', z3.BitVecSort(32), z3.BitVecSort(32)) a, b = z3.BitVecs('a b', 32) axioms = [ a == m(12432), z3.Not(a == b) ] s.add(axioms) print(s.check()) Python crashes with error code 139. Please note that, this is not my real problem, so I must use bit vector tactic in my project, though it doesn't have any problem with smt tactic or even qfbv tactic. 回答1: It seems to be a bug in 4.4.0. With 4.4.0 and Ubuntu

z3, z3py: Is it possible to intrinsically reduce the search space of Function?

谁说胖子不能爱 提交于 2019-12-11 03:41:43
问题 I am inferring a Function(var1) and I only care about the values of this function when 0 <= var1 <= 10 and I know, when 0 <= var <= 10, 0 <= Function(var1) <= 10. A common way (I guess) to constrain the search space of the Function is something like asserting constraints like (in z3py): for i in range(11): solver.add(And(Function(i)>=0,Function(i)<=10)) My question is that: is there a better way so that I can constrain the search space of Function? Something like setting upperbound/lowerbound

Retrieve a value in Z3Py yields unexpected result

*爱你&永不变心* 提交于 2019-12-11 01:49:59
问题 I want to find a maximal interval in which an expression e is true for all x . A way to write such a formula should be: Exists d : ForAll x in (-d,d) . e and ForAll x not in (-d,d) . !e . To get such a d , the formula f in Z3 (looking at the one above) could be the following: from z3 import * x = Real('x') delta = Real('d') s = Solver() e = And(1/10000*x**2 > 0, 1/5000*x**3 + -1/5000*x**2 < 0) f = ForAll(x, And(Implies(And(delta > 0, -delta < x, x < delta, x != 0), e), Implies(And(delta > 0,

Why is Z3 slow for tiny search space?

纵饮孤独 提交于 2019-12-10 19:34:42
问题 I'm trying to make a Z3 program (in Python) that generates boolean circuits that do certain tasks (e.g. adding two n-bit numbers) but the performance is terrible to the point where a brute-force search of the entire solution space would be faster. This is my first time using Z3 so I could be doing something that impacts my performance, but my code seems fine. The following is copied from my code here: from z3 import * BITLEN = 1 # Number of bits in input STEPS = 1 # How many steps to take (e

Z3 python treats x**2 different than x*x?

本小妞迷上赌 提交于 2019-12-10 15:55:40
问题 It seems that Z3 Python interface doesn't like the ** operator , it can deal with x*x but not x**2 as shown in the example below >>> x,y = x,y=Reals('x y') >>> z3.prove(Implies(x -6 == 0,x**2 -36 == 0)) failed to prove [x = 6] >>> z3.prove(Implies(x -6 == 0,x*x -36 == 0)) proved 回答1: You are probably using version 4.3.0 on Linux or OSX. Version 4.3.0 has a configuration problem on these platforms. If that is the case, I suggest you download version 4.3.1. Version 4.3.1 will prove both queries

Why Z3Py does not provide all possible solutions

半腔热情 提交于 2019-12-10 11:14:23
问题 I ran into a problem where Z3Py does not enumerate all possible solutions for the given Boolean clauses. I was wondering if anyone knows why this is happening. Here is the code I use for the Z3Py. There are 5 booleans: 1 2 3 4 and 5. from z3 import * a,b,c,d,e = Bools('1 2 3 4 5') solver = Solver() solver.add(Or(Not(a), Not(b))) solver.add(Or(Not(b), Not(c))) solver.add(Or(Not(c), Not(d))) solver.add(Or(Not(d), Not(e))) while solver.check() == sat: model = solver.model() block = [] for