Nikolaj Bjørner
Microsoft Research
nbjorner@microsoft.com http://theory.stanford.edu/~nikolaj/atva.html |
SAT | SAT + Theories | |
Theories | Theories + Theories | |
Programmability |
SAT: Search Techniques
Theories: Solving Constraints over a theory
Theories + Theories: Integration of Theories
SAT + Theories: Integration of Theory Solvers with Search
Programmability: Programming Z3
Current pre-release 4.8.0.0, July 3
A parallel cube & conquer mode
binding support
SAT solver with XOR, Cardinality and PB theories
SAT solver in-processing (ATE, ALA, ACCE, HBCA)
Model preservation across search resumption
SPACER/Horn engine by Arie Gurfinkel
New ILP engine by Lev Nachmanson
from z3 import *
Tie, Shirt = Bools('Tie Shirt')
s = Solver()
s.add(Or(Tie, Shirt),
Or(Not(Tie), Shirt),
Or(Not(Tie), Not(Shirt)))
print(s.check())
print(s.model())
Z = IntSort()
f = Function('f', Z, Z)
x, y, z = Ints('x y z')
A = Array('A',Z,Z)
fml = Implies(x + 2 == y, f(Store(A, x, 3)[y - 2]) == f(y - x + 1))
solve(Not(fml))
(set-logic QF_LIA)
(declare-const x Int)
(declare-const y Int)
(assert (> (+ (mod x 4) (* 3 (div y 2))) (- x y)))
(check-sat)
Python version:
solve((x % 4) + 3 * (y / 2) > x - y)
It is also possible to extract an SMT-LIB2 representation of a solver state.
from z3 import *
x, y = Ints('x y')
s = Solver()
s.add((x % 4) + 3 * (y / 2) > x - y)
print(s.sexpr())
produces the output
(declare-fun y () Int)
(declare-fun x () Int)
(assert (> (+ (mod x 4) (* 3 (div y 2))) (- x y)))
x = Int('x')
y = Int('y')
n = x + y >= 3
print("num args: ", n.num_args())
print("children: ", n.children())
print("1st child:", n.arg(0))
print("2nd child:", n.arg(1))
print("operator: ", n.decl())
print("op name: ", n.decl().name())
('num args: ', 2)
('children: ', [x + y, 3])
('1st child:', x + y)
('2nd child:', 3)
('operator: ', >=)
('op name: ', '>=')
solve(y == x + 1, ForAll([y], Implies(y <= 0, x < y)))
m, m1 = Array('m', Z, Z), Array('m1', Z, Z)
def memset(lo,hi,y,m):
return Lambda([x], If(And(lo <= x, x <= hi), y, Select(m, x)))
solve([m1 == memset(1, 700, z, m), Select(m1, 6) != z])
Q = Array('Q', Z, B)
prove(Implies(ForAll(Q, Implies(Select(Q, x), Select(Q, y))), x == y))
Mainstream SMT solver architecture based on co-processor architecture to CDCL.
Alternatives: