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
4
votes
2 answers

z3py examples do not to work on macOS

I can not get any of the z3py examples to work. I was able to install it successful using the instructions from the README on github. I successfully updated my python path to point to the appropriate directory. Furthermore, I was able to…
4
votes
0 answers

Xor parity constraint with more than two variables

I am using the following Python function to model Xor constraints with an arbitrary number of variables for Microsoft's Z3 solver with Python API: # parity function # break up long input lists in two smaller lists def odd(solver, lits): length…
Axel Kemper
  • 10,544
  • 2
  • 31
  • 54
4
votes
2 answers

z3py: how to represent an array of integers or characters in z3py

I am new to z3py and SMT and I haven't found a good tutorial about z3py. Here is my problem setting: Given an input integer array I=[1,2,3,4,5], and an output integer array O=[1,2,4,5]. I want to infer k for the operator Delete, which deletes the…
Mark Jin
  • 2,616
  • 3
  • 25
  • 37
4
votes
2 answers

How do I create a constraint in Z3py to check if a list if a permutation of another?

I am a beginner in Z3py and I've been struggling with this for almost a week now... I don't find enough information to help me in tutorials out there neither a good example (of the function Exists) that can help me.
Ewerton
  • 470
  • 7
  • 20
4
votes
2 answers

River crossing puzzle in z3

I've just start learning z3 solver. I've seen some puzzles solved by z3 i.e sudoku and Eight Queens. I'm just wondering if any one solved River crossing problem in z3. z3 seems very good in problem solving. Regards
Moody
  • 137
  • 1
  • 9
4
votes
1 answer

Why does z3.check() slow when it is immediately preceded by z3.push()?

The below Python snippet illustrates a strage performance behavior of Z3. Without push() call, the z3 checks the formula in 0.1s. With push() (and no extra assertions), z3 takes 0.8s. A similar outcome occurs even after swapping s.append(f) and…
4
votes
1 answer

Why is z3.And() slow?

I am using Z3 Python bindings to create an And expression via z3.And(exprs) where exprs is a python list of 48000 equality constraints over boolean variables. This operation takes 2 seconds on a MBP with 2.6GHz processor. What could I be doing…
4
votes
2 answers

How to loop over array in Z3Py

As part of a reverse engineering exercise, I'm trying to write a Z3 solver to find a username and password that satisfy the program below. This is especially tough because the z3py tutorial that everyone refers to (rise4fun) is down. #include…
gsgx
  • 12,020
  • 25
  • 98
  • 149
4
votes
1 answer

how to convert z3py expression to smtlib 2 format

My question is related to: Z3: convert Z3py expression to SMT-LIB2? I am trying to convert z3py expression from to smtlib2 format. using following script, but after conversion when I am feeding the result to z3 or any other SMT, I get: "Syntax…
user3196876
  • 187
  • 1
  • 12
4
votes
2 answers

z3 bitvector overflow checking from python?

The C API for z3 has functions such as Z3_mk_bvadd_no_overflow, but these do not seem to be available from the Python API. Before I start hacking to solve this I'd just like to verify that this is the case and also request that these be added to…
John Regehr
  • 123
  • 1
  • 6
4
votes
1 answer

How can I solve minimizing constraint in Z3?

Could any one can tell me how I can implement minimizing integer problem like the below one by Z3py? How can I define for all statement? Here all variables are int sort. Is there any dedicated solver within Z3 is available to solve such kind of…
user1770051
  • 131
  • 1
  • 7
4
votes
3 answers

How to perform quantifier elimination using Python API of Z3

How can I perform quantifier elimination using the Python API of Z3? Although I checked the tutorial and API, couldn't manage to do it. I have a formula that has an existential quantifier and I want Z3 to give me a new formula, such that this…
blurium
  • 43
  • 5
4
votes
1 answer

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

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] >>>…
Vu Nguyen
  • 987
  • 1
  • 9
  • 20
4
votes
1 answer

z3py: got an error when parsing small real numbers

I'm trying to integrate z3py into my application. There are assertions that involve small real numbers, such as solver.add(x <= 1e-6) Then I got the following error: File "~/src/solver/z3.py", line 2001, in __le__ a, b = _coerce_exprs(self,…
Yan
  • 55
  • 1
  • 7
3
votes
1 answer

How to get the model with minimum variables to satisfy the assertion using Z3

An Example: from z3 import * p1,p2, p3 = Reals('p1 p2 p3') s = Optimize() s.add(And(Or(p1>=0, p2>0),Or(p1<=10,p3>0))) print(s.check()) print(s.model()) run the code,and get output: sat [p3 = 1, p1 = 11, p2 = 1] it's right. However, it's valuable…
Lucent
  • 33
  • 7
1 2
3
55 56