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
3
votes
1 answer

How to convert Z3 String Expression into Python String

I'm using Z3py and Strings to generate some new constraints from a recursive data type (list). In order to construct related constraints in Z3 engine, I used Z3 String to store it. For example, if we have a list (a,b,c), then we produce x1==1,…
Kun
  • 101
  • 3
3
votes
2 answers

Converting Z3 QBF formula directly to pcnf

I'm using Z3 theorem prover (using Z3Py: the Z3 API in Python) to create QBF (Quantified Boolean formula). Is there any way in Z3 to directly convert your qbf formula into Prenex normal form ?
Pushpa
  • 448
  • 3
  • 10
3
votes
2 answers

z3py compare Datatype / Enum to string

Following this example in (found here: z3py) I can compare c to e.g. Color.green. Color = Datatype('Color') Color.declare('red') Color.declare('green') Color.declare('blue') Color = Color.create() # Let c be a constant of sort Color c = Const('c',…
stklik
  • 834
  • 1
  • 8
  • 19
3
votes
2 answers

What additional axioms do we need to add so that Z3 can verify the satisfiability of programs with recurrences?

As we know Z3 has limitations with recurrences. Is there any way get the result for the following program? what will additional equation help z3 get the result? from z3 import * ackermann=Function('ackermann',IntSort(),IntSort(),IntSort()) …
Tom
  • 904
  • 1
  • 7
  • 21
3
votes
2 answers

Use different back-end solvers in Z3

I'm using Z3 Python interface to create formulas for my experiments. I'm then sending that formula to a Z3 solver. If I'm correct Z3 uses its own solver! How to use a different SAT/SMT solver with Z3py? The way I use to do it in CBMC (C bounded…
user2754673
  • 439
  • 3
  • 13
3
votes
1 answer

Invariant induction over horn-clauses with Z3py

I am currently using Z3py to to deduce some invariants which are encoded as a conjunction of horn-clauses whilst also providing a template for the invariant. I'm starting with a simple example first if you see the code snippet below. x = 0; while(x…
wrahman
  • 123
  • 1
  • 10
3
votes
0 answers

Backtracking using push/pop operation on z3 fixedpoint solver

When I try to use push and pop operations for backtracking on z3's fixedpoint solver via python api, "operation is not supported by engine" exception is thrown by the solver. b = Bool('b') a = Bool('a') s =…
3
votes
1 answer

Signed division not working in z3py

I was trying to work with z3py. I came across a strange problem. I read that the operation / is treated as signed division for bit vectors in z3py. I was trying to give the following commands: a = z3.BitVec('a',2) b = z3.BitVec('b',2) solver =…
siddhant
  • 837
  • 9
  • 13
3
votes
0 answers

Linear extension of partial orders with Z3

I'm trying to write a script that, given a partial order over a (small) set of constants, finds a total order that can be built as an extension of the given partial ordering constrains (i.e. a linear extension). As an example, if given a,b,c,d as…
paolo_
  • 301
  • 1
  • 3
  • 9
3
votes
0 answers

z3 Python API: Optimize() + timeout = segmentation fault

I'm using the z3 Python API (version 4.4.2) for an optimization problem using z3.Optimize(). I get a segmentation fault problem when setting a timeout. The problem disappears once I remove the timeout of set a soft-timeout; however, in both cases,…
3
votes
1 answer

z3py: how to make constraints for "else" value when inferring a function

I am inferring a function using z3py as follows f = Function('f',IntSort(),IntSort(),IntSort()) After asserting a set of constraints like: s.add(f(a1,b1)==c1) s.add(f(a2,b2)==c2) s.add(f(a3,b3)==c3)... The function is inferred as [(a1,b1) ->…
Mark Jin
  • 2,616
  • 3
  • 25
  • 37
3
votes
1 answer

Simplifying Z3 expressions

I am using z3 in Python to simplify some logic expressions and I have question. When I execute the following code x = BitVec('x', 8) e = ULT(x - 5, 10) Then('simplify', 'propagate-values', 'ctx-solver-simplify')(e).as_expr() I get the…
db_bin
  • 61
  • 1
  • 4
3
votes
1 answer

Distinct in z3 SMT and python

My question is that Does "Distinct" works in z3 python?. I've compared the following code and it seem not giving the same results: (declare-const x Int) (declare-const y Int) (assert (distinct x y)) (check-sat) (get-model) The result was: sat …
Moody
  • 137
  • 1
  • 9
3
votes
1 answer

Is it a bug in Z3? Incorrect answer on Real and ForAll applied

I'm trying to find the minimal value of the Parabola y=(x+2)**2-3, apparently, the answer should be y==-3, when x ==-2. But z3 gives the answer [x = 0, y = 1], which doesn't meet the ForAll assertion. Am I assuming wrongly with something? Here is…
wsysuper
  • 146
  • 6
3
votes
1 answer

About constraints on arrays in Z3

I have two questions about how Z3 operates with regards to arrays. 1) In models, arrays have an "else" element along with a corresponding value. Is there a way to specify constraints on the "else" element on an array in the formula? For example,…