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

Z3 set default value of array to zero

I am trying to solve models for array expressions, where default values for array is equal to 0. For example, I am trying to solve this example, but I get unknown results all the time (declare-const arr (Array Int Int)) (declare-const arr2 (Array…
4
votes
2 answers

What does "quantifier free logic" mean in SMT context?

Even for simplest arithmetic SMT problems the existential quantifier is required to declare symbolic variables. And ∀ quantifier can be turned into ∃ by inverting the constraint. So, I can use both of them in QF_* logics and it works. I take it,…
arrowd
  • 33,231
  • 8
  • 79
  • 110
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

Unsatisfiable Assumptions in Z3?

According to the SMTLib doc here, we can check sat using check-sat-assuming and then one can determine the unsatisfiable assumptions using get-unsat-assumptions. Reflecting that on Z3 in JavaAPI, I can see checkAssuming API doing the same thing as…
S. Nabil
  • 319
  • 1
  • 10
4
votes
1 answer

Z3 support for exponentials

I'm new to Z3 and I'm trying to understand how it works, and what it can and cannot do. I know that Z3 has at least some support for exponentials through the power (^) operator (see Z3py returns unknown for equation using pow() function, How to…
4
votes
1 answer

Negation in z3 datalog for expressing optimality

I use Z3 with :fixedpoint.engine set to datalog. I have an enumerated filter relation (f pos min max). Let us say that we have (f #x10 #x100000 #x200000), (f #x20 #x150000 #x200000) and (f #x20 #x300000 #x500000). For a given x, I search the…
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
3 answers

How do you extract an element as the base type from a Seq type in Z3?

How do I extract an element in a Sequence to the base type, so that the following will work? (define-sort ISeq () (Seq Int)) (define-const x ISeq (seq.unit 5)) (define-const y ISeq (seq.unit 6)) (assert (>= (seq.at x 0) (seq.at y 0)))
Adam
  • 406
  • 3
  • 6
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
4
votes
1 answer

Workaround for z3 not supporting injectivity

I want to represent a hash function in z3, something like SHA(x). After doing some research, it appears z3 doesn't support injectivity very well, so I can't have a constraint like (and while I realise this isn't strictly speaking true because of…
4
votes
1 answer

Turning Haskell Int values into Constants for SBV constraints

I see lots of examples of the SBV library being used like so: f :: IO SatResult f = sat $ do x <- sInteger "x" constraint $ x .< 200 For a function that takes in a Haskell Int, I would like to use that Int in my constraint formulas…
Matt Ahrens
  • 129
  • 7
4
votes
0 answers

Fixpoint with PDR and muZ answers unknown

I created this file which is supposed to represent Dekker's algorithm Given a variable Turn of type proc and two arrays want and crit mapping proc to bools The initial state is want[p] = false and crit[p] = false for all proc p I can non…
Lhooq
  • 4,281
  • 1
  • 18
  • 37