Questions tagged [z3py]

Python interface for the Z3 Theorem Prover

z3py - Python interface for the Z3 Theorem Prover. Z3 is a high-performance theorem prover. Z3 supports arithmetic, fixed-size bit-vectors, extensional arrays, datatypes, uninterpreted functions, and quantifiers.

834 questions
5
votes
2 answers

How can I access the variable mapping used when bit-blasting?

I'm modifying a tool which uses Z3 (specifically the Python API) to solve bitvector constraints. I need to use a particular external SAT solver instead of the internal Z3 one, so I'm first bit-blasting using the tactic Then('simplify', 'bit-blast',…
Daniel
  • 55
  • 2
5
votes
3 answers

How to calculate Absolute value in z3 or z3py

I have been trying to solve a small problem which includes absolute value of some terms. In z3 there is no support for abs() function. In python there is, but I eventually i have to pass it to z3py. Is there any way through which I can pass terms…
user3196876
  • 187
  • 1
  • 12
5
votes
3 answers

Where can i get z3py tutorials

rise4fun z3py is unavailable from several weeks due to some security issues. I tried to find out some resources for learning z3py but ended in vain. Please suggest some resources to learn z3py
svKris
  • 783
  • 1
  • 7
  • 21
5
votes
1 answer

Z3py: Convert a Z3 formula to clauses used by picosat

LINKS: Z3 theorem prover picosat with pyhton bindings I've used Z3 as a SAT-solver. For larger formulae there seem to be performance issues which is why I wanted to check out picosat to see whether it's a faster alternative. My existing python code…
mrsteve
  • 4,082
  • 1
  • 26
  • 63
5
votes
1 answer

Incremental solving in Z3 using push command

I am using Z3's python api to do some kind of incremental solving. I push constraints to the solver iteratively while checking for unsatisfiability at each step using solver.push() command. I want to understand whether Z3 would use the learned…
Garvit Juniwal
  • 195
  • 1
  • 6
5
votes
2 answers

How to model signed integer with BitVector?

Suppose that a is an integer of 8-bit of value 254. If a is a signed integer, it is actually considered -2. In contrary, if a is unsigned, it remains 254. I am trying to model this signed/unsigned integer problem with BitVector theory with Z3, but…
user311703
  • 1,113
  • 2
  • 14
  • 25
4
votes
1 answer

How to get median constraint with z3 solver in python

I got different vectors where I want to set constraints for different medians. Where some medians are calculated for different subsets of the vector. Eg, I want a constraint for age = IntVector('age', 10) male = BoolVector('male', 10) …
mojado
  • 370
  • 1
  • 12
4
votes
2 answers

Timeout for Z3 Optimize

How do you set a timeout for the z3 optimizer such that it will give you the best known solution when it runs out of time? from z3 import * s = Optimize() # Hard Problem print(s.check()) print(s.model()) Follow-up question, can you set z3 to…
HiDefender
  • 2,088
  • 2
  • 14
  • 31
4
votes
1 answer

Scalability of z3

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?
4
votes
1 answer

Optimize() in z3py not finding optimal solutions

I'm trying to use z3py as an optimization solver to maximise the volume of a cuboid cut out from a piece of paper. The python API provides the Optimize() object but using it seems to be unreliable, giving me solutions that are obviously inaccurate.…
isaacngym
  • 43
  • 5
4
votes
1 answer

Save and reload z3py solver constraints

Can I save the constraints I created for a z3 solver and later reload them to continue looking for more solutions? I have learned there is the SMT-LIB2 format for such things and that z3 and z3py have an API for saving and loading in that format.…
Marian Aldenhövel
  • 677
  • 1
  • 6
  • 24
4
votes
2 answers

Is it possible to get a legit range info when using a SMT constraint with Z3

So basically I am trying to solve the following SMT constraint with a generic constraint solver like Z3: >>> from z3 import * >>> a = BitVec("a", 32) >>> b = BitVec("b", 32) >>> c1 = (a + 32) & (b & 0xff) >>> c2 = (b & 0xff) >>> s = Solver() >>>…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
4
votes
1 answer

Understanding quantifier traversing in Z3

I'm trying to understand traversing quantified formula in z3 (i'm using z3py). Have no idea how to pickup the quantified variables. For example in code shown below i'm trying to print the same formula and getting error. from z3 import * def…
Pushpa
  • 448
  • 3
  • 10
4
votes
1 answer

How to solve this using z3?

I have just recently started scripting using z3 , only for CTF challenges. for ( i = 0; i <= 7; ++i ) { s2[i] += s2[i] % 10; if ( s2[i] > 123 ) s2[i] = -100 - s2[i]; } strcmp("H0Tf00D:<", s2) This is quite simple logic , that can even be…
jame
  • 328
  • 3
  • 11
4
votes
2 answers

Z3 Prover returns wrong solution

I'm trying to solve an equation with Z3 Thoerem Prover in Python. But the solution I get is wrong. from z3 import * solv = Solver() x = Int("x") y = Int("y") z = Int("z") s = Solver() s.add(x/(y+z)+y/(x+z)+z/(x+y)==10, x>0, y>0,…
Peter234
  • 1,052
  • 7
  • 24
1
2
3
55 56