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

Use of "for all" with Uninterpreted sorts JAVA API

I am trying to learn Z3 using the java API, since there is not documentation I've been looking at the C API documentation but until now I can't find a clear example of how to use some basic functions. I am trying to encode this Z3 code (which works…
user3723800
  • 145
  • 7
3
votes
1 answer

Z3Py: randomized results (phase-selection) not random?

I tried to use bit vectors to get randomized results in model values like suggested by de Moura here but then with Z3Py instead of SMTLIB. I translated his example to: from z3 import * s = Solver() x = BitVec('x', 16) set_option('auto_config',…
3
votes
1 answer

Z3 randomness of generated model values

I'm trying to influence the randomness of results for model values generated by Z3. As far as I understand, the options for this are very limited: in case of linear arithmetic, the simplex solver does not allow for random results that still satisfy…
3
votes
0 answers

Z3 Python API seems to be slow on linear formulae

I am trying to use Z3 through its Python interface to infer the satisfiability of simple linear formulae. It seems to be quite slow even on simple formulae such as the following (composed of 10 clauses with 10 terms each) which I write down in the…
3
votes
2 answers

(set-option :macro-finder true): does not work in a theorem of group theory

I am trying to prove the right-cancellation property in group theory using the following code (set-option :macro-finder true) (declare-sort S) (declare-fun e () S) (declare-fun mult (S S) S) (declare-fun inv (S) S) (assert (forall ((x S) (y S) (z…
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
3
votes
1 answer

How do you set number of cores in z3py

According to http://research.microsoft.com/en-us/um/people/leonardo/z3_doc/parallel.html I can set CC_NUM_THREADS=4 from the z3 command line if I'm using a .smt file. How do I do this if I'm using the z3py api?
3
votes
2 answers

Z3 is not able to prove the right-cancellation property in group theory?

I am trying to prove some general properties in group theory. For example the left-cancellation property : ( x y = x z ) => (y = z) it proved using the following code (declare-sort S) (declare-fun e () S) (declare-fun mult (S S) S) (declare-fun…
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
3
votes
0 answers

Is it possible to force a Z3 model to evaluate boolean expressions involving arrays?

Sometimes, evaluating a boolean expression in a model doesn't return a concrete boolean value even when the expression clearly has a concrete value. I've been able to reduce this to cases involving array expressions such as this test case: from z3…
3
votes
1 answer

Can get final CNF formula from Z3?

Here is my simple encoding. I would like to get the final Boolean CNF that presents all these constrains. Is there any option in Z3 solver to get the final Boolean CNF ? x = Int('x') y = Int('y') c1 = And(x >= 1, x <= 10) c2 = And(y >= 1, y <=…
user1770051
  • 131
  • 1
  • 7
3
votes
1 answer

Prove 2 formulas equivalent under some conditions?

Two formulas a1 == a + b and a1 == b are equivalent if a == 0. I want to find this required condition (a == 0) with Z3 python. I wrote the code below: from z3 import * def equivalence(F, G): s = Solver() s.add(Not(F == G)) r =…
user311703
  • 1,113
  • 2
  • 14
  • 25
3
votes
1 answer

Is there a way to obtain the default context in Z3?

I am using the z3py API (4.3.0). I can easily translate an expression expr from the default context to a new context target_ctx, using expr.translate(target_ctx). But how can I translate from a given context ctx into the default Z3 context? Is there…
EfForEffort
  • 55,816
  • 4
  • 36
  • 41
3
votes
1 answer

Unsatisfiable Cores in Z3 Python

I am working with the Python API of Z3 in an attempt to include support for it in a research tool that I am writing. I have a question regarding extracting the unsatisfiable core using the Python interface. I have the following simple…
Jon Kotker
  • 199
  • 2
  • 10
3
votes
1 answer

Error in Z3Py code

Whats wrong with the following script http://rise4fun.com/Z3Py/Cbl? Adding the last two lines gives me the following error 'instancemethod' object is not #subscriptable x,t,t1,t2,x_next=Reals ('x t t1 t2…
hafizul asad
  • 527
  • 2
  • 5
  • 11
2
votes
1 answer

What does a model mean in a universally quantified formula? Is it a function?

Consider these two formulae: Exists y. Forall x. (y>x), which is unsat. Forall x. Exists y. (y>x), which is sat. Note that we cannot find “models” for the sat formula, e.g., using Z3 it outputs Z3Exception: model is not available for the following…
Theo Deep
  • 666
  • 4
  • 15
2
votes
1 answer

Without unwinding, translate a simple while loop iteration into SMT-LIB formula to prove correctness

Consider proving correctness of the following while loop, i.e. I want show that given the loop condition holds to start with, it will eventually terminate and result in the final assertion being true. int x = 0; while(x>=0 && x<10){ x = x +…
newlogic
  • 807
  • 8
  • 25