Questions tagged [z3]

Z3 is a high-performance theorem prover being developed at Microsoft Research.

Z3 is a high-performance theorem prover being developed at Microsoft Research. Z3 supports linear real and integer arithmetic, fixed-size bit-vectors, extensional arrays, uninterpreted functions, and quantifiers.

Some key features of Z3 are:

  • High-performance theorem prover
  • Integrating efficient constraint solving technologies
  • Checking satisfiability of logical formulas with quantifiers
  • Highly customizable with an extensive API
  • Including support for custom theories

For more information about Z3, visit the Z3 homepage or try Z3 in your browser.

See also Z3 tutorial guide for more in-depth introduction about Z3.

2824 questions
5
votes
2 answers

Encoding "at-most-k / at-least-k booleans are true" constraints in Z3

What's a good way to encode "at least k / at most k of these boolean variables must be true" constraints in Z3, for arbitrary k and number of boolean variables? I'm thinking of casting "at least k" as a pseudo-boolean problem by introducing new PB…
Josh Rosen
  • 13,511
  • 6
  • 58
  • 70
5
votes
1 answer

Most efficient way to represent memory buffers in Z3

I would like to model fixed-size memory buffers and their access operations in Z3. The size of the buffers can be anywhere from a couple of bytes to hundreds of bytes. The standard way employed by several existing tools (e.g., KLEE) is to create…
5
votes
1 answer

What are the benefits of incremental solving?

If "pop" completely destroys context (i.e., learned lemmas) in incremental constraint solving what is the purpose of using "stack mode"? Rationale: I imagine that if I have just 1 constraint (several conjuncts) it would be preferable to make a…
Tianhai Liu
  • 795
  • 5
  • 10
5
votes
1 answer

DPLL(T) algorithm used in Z3 (linear arithmetic)

The arithmetic solver of Z3 is developed based on DPLL(T) and Simplex (described in this paper). And I do not understand how Z3 perform the backtrack when a conflict explanation is generated. I give an example: The linear arithmetic formula…
ClePIR
  • 51
  • 1
5
votes
3 answers

Sum array in z3 solver

I am trying to express the sum of the range of an unbounded Array in z3. For instance in Python: IntArray = ArraySort(IntSort(), IntSort()) sum = Function('sum', IntArray, IntSort()) ........ Is there any way to complete the definition of 'sum'?…
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
1 answer

HORN Clause Z3 Documentation

I am trying to encode some imperative program using HORN logic of Z3 (set-logic HORN) but getting some difficulties of defining clause (using SMT2). Could anyone tell me where can I find a good source of documentations for this feature of Z3?
5
votes
2 answers

Haskell: binding to fast and simple SAT solver

Today I wanted too look into options on SAT solving in haskell. First I tought about writing my own interface to the picosat solver. Then I found out there is the SBV library. It's interfaces to Z3, Yices, CVC4 and Boolector. Also, I did a google…
mrsteve
  • 4,082
  • 1
  • 26
  • 63
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
2 answers

Defining injective functions in Z3

My goal is to define an injective function f: Int -> Term, where Term is some new sort. Having referred to the definition of the injective function, I wrote the following: (declare-sort Term) (declare-fun f (Int) Term) (assert (forall ((x Int) (y…
Pavel Zaichenkov
  • 835
  • 5
  • 12
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
5
votes
2 answers

Z3: how to encode If-the-else in Z3 python?

I want to encode If-the-else in Z3 python, but cannot find any docs or sample on how to do that. I have a sample code like below. F = True tmp = BitVec('tmp', 1) tmp1 = BitVec('tmp1', 8) Now how can I encode this condition into F: if tmp == 1,…
user311703
  • 1,113
  • 2
  • 14
  • 25
5
votes
1 answer

Z3 timing variation

Since upgrading to the open source release of Z3 (latest git master), I've noticed a significant timing variation between repeated runs of nearly-identical SMT queries using the C API (anywhere from 2-122s). The only difference between the queries…
ramosbugs
  • 53
  • 4