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

Z3Py Fixedpoint computation too weak

I am using z3py APIs to compute a set of inductive annotations. I am mapping my constraints to a conjuction of generalized Horn clauses. Among the constraints, there are a couple of relations (l6 and iwc1) which need to be inferred. The variables…
0
votes
1 answer

Why is * with numeral argument not flattened by simplify?

I would expect simplify with :flat to evaluate 3 * x * y * z to (* 3 x y z). Instead, the result is (* 3 (* x y z)). Why? Example w = Int('w') x = Int('x') y = Int('y') z = Int('z') print simplify(w * x * y * z, flat=True).num_args() # 4, which we…
thpani
  • 403
  • 6
  • 15
0
votes
1 answer

How to use Z3Py online to compute Ro in a population with heterogeneity in sexual acitivity and proportionate miximg

To solve the problem we use the following code: R_H, R_L, g_H, g_L, x, R_0 = Reals('R_H R_L g_H g_L x R_0') R_HH = R_H*g_H R_HL = R_L*g_H R_LH = R_H*g_L R_LL = R_L*g_L eq1 = R_HH*x+R_HL*(1-x) eq2 = R_LH*x+R_LL*(1-x) equations = [ eq1 ==…
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
0
votes
2 answers

It is possible to compute the Kauffman bracket using Z3py?

I am trying to compute the Kauffman bracket of the trefoil knot using Z3py. Until now I have the following code: a, b, c, d, e, f, A, B = Ints('a b c d e f A B') delta = Function('delta', IntSort(), IntSort(), IntSort()) def X(a,b,c,d): return…
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
0
votes
1 answer

How to solve a 2-SAT instance with 60 boolean variables and 99 clauses using Z3Py

I am using the following code: X = BoolVector('x', 60) M = [[21, 34],[-49, -12],[7, 18], [-5, -1],[28, 17], [3, 55],[36, 33], [-6, -50],[44, -41], [-55, 3],[14, -54],[-30, 13], [-13, 60],[54, -16],[-48, 41], [3, 6],[49,…
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
0
votes
1 answer

How can we use xor operation on integers in z3 using python?

from z3 import * x = Int('x') #declaration y = Int('y') #declaration solve((x ^ y)==2) #solving i was unable to perform xor operation in z3 using python.please help tell what is the correct way of writing if i am doing it wrong else suggest some…
user2534232
  • 15
  • 2
  • 4
0
votes
1 answer

Why this code returns Unsat (formula using ForAll & Implies)?

Given 2 equations c == a + 4 and t == c + b, if a == -4, then t == b. I am trying to do the opposite, meaning given the above 2 equations, and t == b, I try to find value of a. I have below code to do this with ForAll and Implies: from z3 import…
user311703
  • 1,113
  • 2
  • 14
  • 25
0
votes
1 answer

Z3py polish notation output

The default output for z3py expression is in infix notation. Is there a option to set the output format to polish notation? I assume there may be an option similar to set_option(html_mode=False) But haven't been able to find any supporting…
bettsmatt
  • 33
  • 5
0
votes
1 answer

Z3Python: ForAll causes my code hangup, or returns Unsat, why?

I am still struggling with the problem of findiong a value so that a * b == b with all value of b. The expected result is a == 1. I have two solutions below. (A) I implemented this with ForAll quantifier in below code (correct me if there is a…
user311703
  • 1,113
  • 2
  • 14
  • 25
0
votes
1 answer

Retrieve the bounds of an Extract node in z3py

I am using z3py. My question is, how do I retrieve the bounds of an Extract node? I thought Extract would be a function with arity three, but it isn't: >>> x = BitVecVal(3, 32) >>> e = Extract(15, 0, x) >>> e.decl() Extract >>>…
EfForEffort
  • 55,816
  • 4
  • 36
  • 41
0
votes
2 answers

How to solve a liars/truth-tellers instance using Z3Py and Z3 SMT-LIB

Example Problem: Suppose that liars always speak what is false, and truth-tellers always speak what is true. Further suppose that Amy, Bob, Cal, Dan, Erny and Francis are each either a liar or truth-teller. Amy says, “Bob is a liar.” Bob says,…
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
0
votes
1 answer

Find logical conditions for 2 formulas to be equivalent?

I posted a related question, but then I think it was not very clear. I would like to rephrase the problem like this: Two formulas a1 == a + b (1) and a1 == b (2) are equivalent if a == 0. Given these formulas (1) and (2), how can I use Z3 python to…
user311703
  • 1,113
  • 2
  • 14
  • 25
-1
votes
1 answer

How to get result from z3py calculation?

I want to use z3py to illustrate the following genealogy exercise (pa is “parent” and grpa is “grand-parent) pa(Rob,Kev) ∧ pa(Rob,Sama) ∧ pa(Sama,Tho) ∧ pa(Dor,Jim) ∧ pa(Bor,Jim) ∧ pa(Bor,Eli) ∧ pa(Jim,Tho) ∧ pa(Sama,Samu) ∧ pa(Jim,Samu) ∧…
yannis
  • 819
  • 1
  • 9
  • 26
-1
votes
1 answer

Error when using remainder operation in z3py

Doing a remainder operation gives an error in z3py code Following is my code x = Real("x") solve( x%2 == 3 ) The Code gives the following Error : z3.z3types.Z3Exception: Z3 integer expression expected whereas when I am doing division…
infiNity9819
  • 536
  • 2
  • 7
  • 19
-1
votes
1 answer

Labeling constraints in Z3 Python API

Question 1: How could I use Z3 Python API in order to add constraints with unique labels? I was trying something like: ... self.solver.add(self.vm[i] >= 0, 'labelIdx'+str(self.idx)) ... where self.idx is an integer number which increases for each i,…
1 2 3
55
56