Nikolaj Bjørner
Microsoft Research
nbjorner@microsoft.com |
(Moura and Bjørner, 2007) E-matching
(Ge and Moura, 2009; Moura and Bjørner, 2010; Bonacina et al., 2011; Wintersteiger et al., 2013) Model-based Quantifier Instantiation (MBQI)
(Bjørner, 2010; Phan et al., 2012; Bjørner and Janota, 2015) Quantifier Elimination and Satifiability
(Hoder and Bjørner, 2012; Bjørner et al., 2013) Horn Clauses
Deprecated: (Piskac et al., 2010) EPR using relational algebra, (Moura and Bjørner, 2008) Superposition, see also VampireZ3
Formulas are ground unsatisfiable.
Takes
Let be a set of terms and set of equalities over .
A congruence closure over modulo is the finest a partition of , cc, such that:
if , then are in the same partition in cc.
for ,
Convention: , maps term to its equivalence class.
def match(pattern, term, , cc):
pattern = pattern
if pattern == term:
yield
elif is_var(pattern):
yield pattern term
else:
f(patterns) = pattern
for f(terms) in cc(term):
# e.g., with same head function symbol f
for in matches(patterns, terms, , cc):
yield
def matches(patterns, terms, , cc):
if not patterns:
yield
return
for in match(patterns[0], terms[0], , cc):
for in matches(patterns[1:], terms[1:], , cc):
yield
PC | Instruction | |
---|---|---|
init(f, ) | add arguments of to registers 1-4 | |
check(4,,) | check if is congruent to | |
bind(2, , 5, ) | bind terms in with to | |
compare(1, 5, ) | check if equals | |
check(6, , ) | check if is congruent to | |
bind(3, , 7, ) | bind terms in with to | |
yield(1,7) | output binding from | |
PC | Instruction | ||
---|---|---|---|
init(f, ) | |||
check(4,,) | |||
bind(2, , 5, ) | |||
compare(1, 5, ) | |||
check(6, , ) | |||
bind(3, , 7, ) | |||
yield(1,7) | |||
PC | Instruction | ||
---|---|---|---|
init(f, ) | |||
check(4,,) | |||
bind(2, , 5, ) | |||
compare(1, 5, ) | |||
check(6, , ) | |||
bind(3, , 7, ) | |||
yield(1,7) | |||
Patterns that share common (top-down) term structure can share code sequences.
This saves on common work.
Use the choice instruction to branch when patterns end up having different sub-terms.
Other instructions are possible,
forward pruning: lookahead multiple function symbols in immediate subterms before diving into any subterm.
to deal with multi-patterns, when maching more than one pattern at a time.
During search, congruence classes are merged.
Q: Which merges could enable pattern to be matched?
A: When pattern contains term , and
a node is in in the same class as a node labeled by ,
a node is an argument of in the same position as ,
, are merged
Idea: Build an index of all pairs from patterns.
Check
while is SAT with model :
if is UNSAT return SAT
model for
find , such that .
return UNSAT
where is partially evaluated using interpretation .
Example:
Quite powerful when search space for instantiation terms is finite
Also known as Bernays-Schoenfinkel-Ramsey class.
Same complexity as DQBF.
(declare-sort T)
(declare-fun subtype (T T) Bool)
;; subtype is reflexive
(assert (forall ((x T)) (subtype x x)))
;; subtype is antisymmetric
(assert (forall ((x T) (y T)) (=> (and (subtype x y) (subtype y x)) (= x y))))
;; subtype is transitive
; ...
;; subtype has the tree-property
(assert (forall ((x T) (y T) (z T))
(=> (and (subtype x z) (subtype y z)) (or (subtype x y) (subtype y x)))))
;; we have an additional axiom: every type is a subtype of obj-type
(declare-const obj-type T) ....
(assert (forall ((x T)) (subtype x obj-type)))
(assert (subtype int-type real-type))
(assert (subtype real-type complex-type))
(assert (not (subtype string-type real-type)))
Skolemize
Models for bind variables to free constants
The number of possible such models is bounded by .
(set-option :smt.mbqi true)
(define-sort Char () (_ BitVec 8))
(declare-fun f (Char) Char)
(declare-fun f1 (Char) Char)
(declare-const a Char)
(assert (bvugt a #x00))
(assert (= (f1 (bvadd a #x01)) #x00))
(assert (forall ((x Char)) (or (= x (bvadd a #x01)) (= (f1 x) (f x)))))
(check-sat)
(get-model)
All variables range over finite domains.
Quantifier-free fragment is not only NP hard, it is NEXPTIME hard.
Quantified fragment is another complexity jump.
BV - quantifier elimination (John and Chakraborty, 2016, 2013, 2011)
UFBV using MBQI (Wintersteiger et al., 2013)
is equal to except at index .
can only have two values, or .
(set-option :smt.mbqi true)
(set-option :model.compact true)
;; A0, A1, A2, A3, A4 are "arrays" from Integers to Integers.
(declare-fun A0 (Int) Int) (declare-fun A1 (Int) Int)
(declare-fun A2 (Int) Int) (declare-fun A3 (Int) Int)
(declare-fun A4 (Int) Int)
(declare-const n Int) (declare-const l Int)
(declare-const k Int) (declare-const x Int)
(declare-const y Int) (declare-const w Int)
(declare-const z Int)
;; A1 = A0[k <- w]
(assert (= (A1 k) w))
(assert (forall ((x Int)) (or (= x k) (= (A1 x) (A0 x)))))
;; A2 = A1[l <- x] = A0[k <- w][l <- x]
(assert (= (A2 l) x))
(assert (forall ((x Int)) (or (= x l) (= (A2 x) (A1 x)))))
;; A3 = A0[k <- y]
(assert (= (A3 k) y))
(assert (forall ((x Int)) (or (= x k) (= (A3 x) (A0 x)))))
;; A4 = A3[l <- z] = A0[k <- y][l <- z]
(assert (= (A3 l) z))
(assert (forall ((x Int)) (or (= x l) (= (A4 x) (A3 x)))))
(assert (and (< w x) (< x y) (< y z)))
(assert (and (< 0 k) (< k l) (< l n)))
(assert (> (- l k) 1))
;; A2 is sorted in the interval [0,n-1]
(assert (forall ((i Int) (j Int))
(=> (and (<= 0 i) (<= i j) (<= j (- n 1)))
(<= (A2 i) (A2 j)))))
(check-sat)
(get-model)
;; A4 is sorted in the interval [0,n-1]
(assert (forall ((i Int) (j Int))
(=> (and (<= 0 i) (<= i j) (<= j (- n 1)))
(<= (A4 i) (A4 j)))))
(check-sat)
Given formula with free.
Let be set of a set of from .
Definition 1.
The set is a sufficient set of instances for , if
Proposition 1.
If admits a finite sufficient set of instances , it can be evaluated using those.
Proposition 2.
Formulas in the array and map property fragments admit a sufficient set of instantiations.
Proposition 3.
MBQI is a decision procedure the array and map property fragments by using the
instantiation sets computed from the formulas.
Synthesize generalized instantiation sets using grammar rules.
Applies to winder range of formulas than the syntactic array property fragment.
(set-option :smt.mbqi true)
;; f an g are "streams"
(declare-fun f (Int) Int)
(declare-fun g (Int) Int)
;; the segment [a, n + a] of stream f is equal to the segment [0, n] of stream g.
(declare-const n Int)
(declare-const a Int)
(assert (forall ((x Int)) (=> (and (<= 0 x) (<= x n))
(= (f (+ x a)) (g x)))))
;; adding some constraints to a
(assert (> a 10))
(assert (>= (f a) 2))
(assert (<= (g 3) (- 10)))
(check-sat)
(get-model)
As pursued in (Reynolds et al., 2017)
The notion of instantiation set can be extended along a different dimension of virtual substitutions.
Several theories admit quantifier elimination by virtual substitutions.
Example .
Tricky part: ensure that set of virtual substitutions does not grow unbounded.
Goal: To find a quantifier free , such that
Tool: project that eliminates from a conjunction
that is, project() .
Initialize:
Repeatedly: find conjunctions that imply
Update: project().
def qe():
e, a = Solver(), Solver()
e.add()
a.add()
= False
while sat == e.check():
= e.model()
= # assume is in negation normal form
assert unsat == a.check()
= a.unsat_core()
= project(, )
=
e.add()
return
The approach we illustrated was used by Monniaux'08 (Monniaux, 2008).
QESTO (Janota and Marques-Silva, 2015) generalizes to nested QBF.
We generalize QESTO to SMT; improving (Monniaux, 2008, 2010; Phan et al., 2012)
Two players try to find values
Players control their variables
Some player loses at round .
Projections are added to learn from mistakes.
Strategies prune moves from opponent.
Player has lost at round
Player found a model at round , .
induces an evaluation on a subset of literals in , such that .
is an unsatisfiable core for .
Model Based Projection
Find a , such that .
Then can block .
Idea: Use to find a sufficient .
def level(j,a): return max level of bound variable in atom a of parity j
def strategy(M,j): return
def tailv(j): return
j = 1
M = null
while True:
if strategy(M, j) is unsat:
if j == 1:
return F is unsat
if j == 2:
return F is sat
C = Core(, strategy(M, j))
J = Mbp(tailv(j), C)
j = index of max variable in J of same parity as j
= J
M = null
else:
M = current model
j = j + 1
Projections learn from mistakes, avoids similar mistakes in future rounds.
Strategies prune moves from opponent.
Want to compute small .
Note
Say
So
Eliminate from conjunction of literals :
Trick: Use to turn into .
Can now assume occurs only as upper or lower bounds:
def sign(M,a): if M(a) return a else return a
For LIA, cannot just assume equalities are of the form or .
Generally, has a coefficient, that we cannot remove.
Example: .
What could go wrong if we just reduce to ?
Suppose , . So .
Cross-multiplying gives , which is feasible, but is infeasible.
Solution: Combine inequalities using resolution
if
else if
otherwise,
satisfies , and …
Resolution introduced divisibility constraints.
So now we also have to eliminate under divisions.
where
S-expressions: A generic term algebra
An s-expression is either a nil or a cons.
Access arguments of cons using car and cdr.
Test terms using cons?(), or nil?()
amounts to unification
Case for is symmetric.
Since there is an infinite number of cons-terms.
New terms are created during
but they are of the form following shape of original constructor terms.
and they occur in conjunctions with .
so produces finite set of projections.
Theory: Non-linear polynomial arithmetic
Partial CAD - model-based projection (Jovanovic and Moura, 2012)
CAD decomposes into sign-invariant cylinders.
Choose the cylinder where is a member.
Sat based MBP (Komuravelli et al., 2014):
Given:
Find: , free for
Such that:
Contrast this with Core-based MBP (Moura and Jovanovic, 2013):
Given: .
Find: , free for
Such that:
Claim: (Roughly) The same projection operator can be used in both cases if occurs in all literals and the operator is stable under changes to the value of .
Other main ingredient of QSAT is option for players to narrow options of opponents by revealing a strategy
Developing practical strategies is work in progress
For QBF can use Q-resolution proofs as guide (Bjørner et al., 2015)
Method by Markus Rabe can be seen as a strategy.
|
|
are state variables.
is a monome (a conjunction of literals).
is a clause (a disjunction of literals).
Convention: is a monome over variables , is a renaming of the same monome to variables .
repeat until ∞
Candidate If for some , , then add to .
Unfold If , then set .
repeat until ∞
Unreachable For , if , return Unreachable.
Reachable If , return Reachable.
repeat until ∞
repeat until ∞
Conflict Let : given a candidate model and clause , such that
Leaf If , and is unsatisfiable,
then add to .
repeat until ∞
Decide Add to if , .