SlideShare a Scribd company logo
Satisfiability Modulo Theories
Lezione 5 - A Theory Solver for IDL
(slides revision: Saturday 14th
March, 2015, 11:47)
Roberto Bruttomesso
Seminario di Logica Matematica
(Corso Prof. Silvio Ghilardi)
17 Novembre 2011
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 1 / 24
Recall from last lecture
The Lazy Approach for a theory T is based on the tight integration of
a CDCL SAT-solver
a T -solver, a decision procedure for T
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 2 / 24
Recall from last lecture
The Lazy Approach for a theory T is based on the tight integration of
a CDCL SAT-solver
a T -solver, a decision procedure for T
The SAT-solver enumerates Boolean models µB
The T -solver checks the consistency of µB in T
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 2 / 24
Recall from last lecture
The Lazy Approach for a theory T is based on the tight integration of
a CDCL SAT-solver
a T -solver, a decision procedure for T
The SAT-solver enumerates Boolean models µB
The T -solver checks the consistency of µB in T
For efficiency, it is desirable that the T -solver
Reasons incrementally (does not compute everything from scratch
everytime)
Backtracks efficiently
Returns minimal conflicts
Performs Theory-Propagation
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 2 / 24
Outline
1 Integer Difference Logic
Introduction
Translation into a Graph
Solving
2 Improvement for T -solver
Minimal Conflicts
Incrementality
Backtrackability
Theory Propagation
3 Final Remarks
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 3 / 24
Integer Difference Logics (IDL)
The T -atoms of IDL consists of arithmetic constraints of the form
x − y ≤ c
where x, y are variables and c is a numerical constant. The domain of
x, y, c is that of the integers
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 4 / 24
Integer Difference Logics (IDL)
The T -atoms of IDL consists of arithmetic constraints of the form
x − y ≤ c
where x, y are variables and c is a numerical constant. The domain of
x, y, c is that of the integers
Notice that the following translations hold
x − y ≥ c =⇒ y − x ≤ −c
x − y < c =⇒ x − y ≤ c − 1
x − y > c =⇒ y − x ≤ −c − 1
x − y = c =⇒ (x − y ≤ c) ∧ (x − y ≥ c)
x − y = c =⇒ (x − y < c) ∨ (x − y > c)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 4 / 24
Integer Difference Logic (IDL)
RDL is similar to IDL, but it is defined on the rationals. However an
RDL formula can be reduced to an equisatisfiable IDL formula
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 5 / 24
Integer Difference Logic (IDL)
RDL is similar to IDL, but it is defined on the rationals. However an
RDL formula can be reduced to an equisatisfiable IDL formula
IDL/RDL can be used to encode a large variety of verification
probems
scheduling
TSP
ASP
timed-automata
sorting algorithms
Also, the worst-case complexity of solving a conjunction of IDL
constraints is O(m + n log n)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 5 / 24
Translation into a Graph
The constraint x − y ≤ c says that
“the distance between x and y is at most c”
This can be encoded as (x, y; c)
x y
c
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 6 / 24
Translation into a Graph
The constraint x − y ≤ c says that
“the distance between x and y is at most c”
This can be encoded as (x, y; c)
x y
c
So, a set µB can be encoded as a graph. Concrete example:
x − y ≤ 8
y − z ≤ −1
z − x ≤ −6
z − w ≤ 2
w − x ≤ −10
w − t ≤ 0
t − x ≤ 3
x y
z
wt
8
−1
−6
2
−10
0
3
G(V, E): V = {x, y, z, w, t}, E = {(x, y; 8), (y, z; −1), (z, x; −6), (z, w; 2), (w, x; −10), . . .}
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 6 / 24
Translation into a Graph
Theorem (Translation)
µB is IDL-unsatisfiable
iff
there is a negative cycle in the corresponging graph G(V, E)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 7 / 24
Translation into a Graph
Theorem (Translation)
µB is IDL-unsatisfiable
iff
there is a negative cycle in the corresponging graph G(V, E)
E.g.:
x − y ≤ 8
y − z ≤ − 1
z − x ≤ − 6
z − w ≤ 2
w − x ≤ − 10
w − t ≤ 0
t − x ≤ 3
x y
z
wt
8
−1
−6
2
−10
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 7 / 24
Translation into a Graph
Theorem (Translation)
µB is IDL-unsatisfiable
iff
there is a negative cycle in the corresponging graph G(V, E)
E.g.:
x − y ≤ 8
y − z ≤ − 1
z − x ≤ − 6
z − w ≤ 2
w − x ≤ − 10
w − t ≤ 0
t − x ≤ 3
x y
z
wt
8
−1
−6
2
−10
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 7 / 24
Translation into a Graph
We use the following lemma to aid the proof
Lemma (Farka’s Lemma for IDL)
µB is unsatisfiable iff there exists a subset
νB = { x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn − x1 ≤ cn } of µB such that
c1 + . . . + cn < 0
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 8 / 24
Translation into a Graph
We use the following lemma to aid the proof
Lemma (Farka’s Lemma for IDL)
µB is unsatisfiable iff there exists a subset
νB = { x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn − x1 ≤ cn } of µB such that
c1 + . . . + cn < 0
The proof of Theorem is now trivial
Proof.
µB is unsatisfiable iff by Farka’s Lemma for IDL
there exists νB ⊆ µB with c1 + . . . + cn < 0 iff by our translation
there exists a negative cycle in G(V, E)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 8 / 24
Solving
Suppose that no negative cycle exists in G(V, E) for µB, how do we
find a model µ for the integer variables ?
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 9 / 24
Solving
Suppose that no negative cycle exists in G(V, E) for µB, how do we
find a model µ for the integer variables ?
State-of-the-art methods employ SSSP (Single Source Shortest Paths)
algorithms, such as the Bellman-Ford algorithm (or its variations), as
follows:
we add an artificial vertex I to V , and add
{(I, x1; 0), . . . , (I, xn; 0)} to E (notice that this never creates
negative cycles)
Compute the shortest paths from source I (run Bellman-Ford).
Let π(x) be the shortest path from I to x, for all x ∈ V
The model µ can be computed as µ(x) = −π(x) for all x ∈ V (see
later why)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 9 / 24
Bellman-Ford
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
1 π(x) = ∞ for all x ∈ V, x = I
2 π(I) = 0
3 TBV.pushBack(I)
4 while ( TBV.size( ) > 0 )
5 s = TBV.popFront( )
6 foreach (s, t; w) ∈ E // for each outgoing edge
7 if ( π(t) − π(s) > w ) // is too far ?
8 π(t) = π(s) + w // relax (decrease π(t))
9 if ( TBV.has(t) == false )
10 TBV.pushBack(t) // enqueue t if not there
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 10 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ ]
Current vertex:
Current edge:
x y
z
wt
I
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ ]
Current vertex:
Current edge:
x y
z
wt
I
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ I ]
Current vertex:
Current edge:
x
∞
y
∞
z
∞
w
∞
t
∞
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ ]
Current vertex: I
Current edge:
x
∞
y
∞
z
∞
w
∞
t
∞
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ x ]
Current vertex: I
Current edge: (I, x; 0)
x
0
y
∞
z
∞
w
∞
t
∞
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ x, y,z, w, t ]
Current vertex:
Current edge:
x
0
y
0
z
0
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ y,z, w, t ]
Current vertex: x
Current edge:
x
0
y
0
z
0
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ y,z, w, t ]
Current vertex: x
Current edge:
x
0
y
0
z
0
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ y,z, w, t ]
Current vertex:
Current edge:
x
0
y
0
z
0
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ z, w, t ]
Current vertex: y
Current edge:
x
0
y
0
z
0
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ z, w, t ]
Current vertex: y
Current edge: (y, z; −1)
x
0
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ z, w, t ]
Current vertex:
Current edge:
x
0
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ ]
Current vertex:
Current edge:
x
−9
y
−1
z
−2
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, Example
π(x): current distance of x from I
TBV : queue of vertexes To Be Visited
π(x) = ∞ for all x ∈ V, x = I
π(I) = 0
TBV.pushBack(I)
while ( TBV.size( ) > 0 )
s = TBV.popFront( )
foreach (s, t; w) ∈ E
if ( π(t) − π(s) > w )
π(t) = π(s) + w
if ( TBV.has(t) == false )
TBV.pushBack(t)
TBV = [ ]
Current vertex:
Current edge:
x
−9
y
−1
z
−2
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
shortest paths
(spanning tree)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
Bellman-Ford, consideration
Invariant
At the end of BF, π(x) holds the shortest distance from I to x, for all x ∈ V
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 12 / 24
Bellman-Ford, consideration
Invariant
At the end of BF, π(x) holds the shortest distance from I to x, for all x ∈ V
Lemma (Shortest Path)
At the end of BF, π(y) − π(x) ≤ c holds for all (x, y; c) ∈ E
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 12 / 24
Bellman-Ford, consideration
Invariant
At the end of BF, π(x) holds the shortest distance from I to x, for all x ∈ V
Lemma (Shortest Path)
At the end of BF, π(y) − π(x) ≤ c holds for all (x, y; c) ∈ E
Proof.
Suppose, for the sake of contradiction, that for an edge (x, y; c), we have π(y) − π(x) > c
x
π(x)
y
π(y)
I
0
. . . . . .c
shortest paths
π(x) is the shortest dist. from I to x (by Invariant). But since π(y) > π(x) + c, the shortest
path from I to y is π(x) + c. So π(y) is not the shortest dist. Contradiction.
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 12 / 24
Finding a model µ
Because of the previous lemma we have that
π(y) − π(x) ≤ c holds for all (x, y; c) ∈ E
So, if we take µ(x) = −π(x) we have that
µ(x) − µ(y) ≤ c holds for all constraints in µB
and therefore µ is a model
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 13 / 24
Outline
1 Integer Difference Logic
Introduction
Translation into a Graph
Solving
2 Improvement for T -solver
Minimal Conflicts
Incrementality
Backtrackability
Theory Propagation
3 Final Remarks
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 14 / 24
T -solver Compliance
So far we have seen that BF can be used to compute a model of a given
consistent set of IDL constraints
Recall that to have an efficient T -solver the following features should
be supported
Minimal Conflicts
Incrementality
Backtrackability
Theory Propagation
Let’s see how to improve the current algorithm to support them
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 15 / 24
Minimal Conflicts
So far we assumed that G(V, E) did not contain negative cycles.
However it is not difficult to tweak the BF to recognize them
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 16 / 24
Minimal Conflicts
So far we assumed that G(V, E) did not contain negative cycles.
However it is not difficult to tweak the BF to recognize them
Recall the spanning tree: the tree that holds shortest paths
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 16 / 24
Minimal Conflicts
So far we assumed that G(V, E) did not contain negative cycles.
However it is not difficult to tweak the BF to recognize them
Recall the spanning tree: the tree that holds shortest paths
It is easy to keep the spanning tree:
each node t keeps two fields fatherVertex and fatherEdge that
stores its father in the spanning tree
when a relax is done on t (line 8 of BF) through an edge
e = (s, t; c), t.fatherV ertex is set to s and t.fatherEdge is set to e
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 16 / 24
Minimal Conflicts
When a negative cycle exists, the spanning tree tends to become cyclic (trees are acyclic
instead). It is easy to recognize this situation and report the negative cycle
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 17 / 24
Minimal Conflicts
When a negative cycle exists, the spanning tree tends to become cyclic (trees are acyclic
instead). It is easy to recognize this situation and report the negative cycle
TBV = [ ]
Current vetex: z
Current edge: (z, w; 2)
x
−10
y
−2
z
−3
w
0
t
0
I
0
8
−1
2
−10
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 17 / 24
Minimal Conflicts
When a negative cycle exists, the spanning tree tends to become cyclic (trees are acyclic
instead). It is easy to recognize this situation and report the negative cycle
TBV = [ ]
Current vetex: z
Current edge: (z, w; 2)
x
−10
y
−2
z
−3
w
0
t
0
I
0
8
−1
2
−10
checkNegativeCycle( s, t )
νB = { }
while ( s = t && s = I )
s = s.fatherV ertex
νB = νB ∪ {s.fatherEdge}
if ( s == t ) return conflict // Neg. Cycle detected
return OK // I reached
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 17 / 24
Minimal Conflicts
Bellman-Ford with negative cycle detection
1 π(x) = ∞ for all x ∈ V, x = I
2 π(I) = 0
3 TBV.pushBack(I)
4 while ( TBV.size( ) > 0 )
5 s = TBV.popFront( )
6 foreach (s, t; w) ∈ E // for each outgoing edge
7 if ( π(t) − π(s) > w ) // is too far ?
8 if ( checkNegativeCycle( s, t ) == conflict )
9 return νB
10 s.fatherV ertex = t
11 s.fatherEdge = (s, t; w)
12 π(t) = π(s) + w // relax (decrease π(t))
13 if ( TBV.has(t) == false )
14 TBV.pushBack(t) // enqueue t if not there
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 18 / 24
Incrementality
Incrementality comes almost for free !
we always keep the π function “alive”, and only update it slightly
G(V, E) keeps track of active and inactive edges: active edges are those on µB
when a new T -atom x − y ≤ c is added to µB, the corresponding edge (x, y; c)
becomes active in the graph
we add x to TBV , and run BF from line 4
x − y ≤ 8 ∈ µB
x
−9
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 19 / 24
Incrementality
Incrementality comes almost for free !
we always keep the π function “alive”, and only update it slightly
G(V, E) keeps track of active and inactive edges: active edges are those on µB
when a new T -atom x − y ≤ c is added to µB, the corresponding edge (x, y; c)
becomes active in the graph
we add x to TBV , and run BF from line 4
x − y ≤ 8 ∈ µB
x
−9
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
x − y ≤ 8 pushed to µB
x
−9
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 19 / 24
Incrementality
Incrementality comes almost for free !
we always keep the π function “alive”, and only update it slightly
G(V, E) keeps track of active and inactive edges: active edges are those on µB
when a new T -atom x − y ≤ c is added to µB, the corresponding edge (x, y; c)
becomes active in the graph
we add x to TBV , and run BF from line 4
x − y ≤ 8 ∈ µB
x
−9
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
x − y ≤ 8 pushed to µB
x
−9
y
0
z
−1
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
After BF
x
−9
y
−1
z
−2
w
0
t
0
I
0
8
−1
−6
2
−9
0
3
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 19 / 24
Backtrackability
Backtracking can be done efficiently
First of all, recall that µ(x) = −π(x). Second obeserve that
Observation 1
Let µ be a model for a set µB of constraints. Then µ is also a model for
any subset of µB
Observation 1 implies that when backtracking we just have to turn
some edges into inactive, and keep the last π intact
This is done as follows: BF will always work on a temporary π, called
π . If satisfiable, π is replaced by π , otherwise we keep π
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 20 / 24
Theory Propagation
Theory Propagation is the process of activating some edges in the
graph that are implied by the current µB
Observation 2
A set of constraints
{ x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn−1 − xn ≤ cn−1 }
implies x1 − xn ≤ cn iff c1 + c2 + . . . cn−1 ≤ cn
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 21 / 24
Theory Propagation
Theory Propagation is the process of activating some edges in the
graph that are implied by the current µB
Observation 2
A set of constraints
{ x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn−1 − xn ≤ cn−1 }
implies x1 − xn ≤ cn iff c1 + c2 + . . . cn−1 ≤ cn
Example:
x y z. . . . . .4 2
10
x − z ≤ 10, currently inactive, can be theory-propagated
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 21 / 24
Final Remarks
We did not say how to handle negative T -atoms, such as ¬(x − y ≤ c).
However it is easy to see that ¬(x − y ≤ c) iff y − x ≤ −c − 1
Each T -atom is associated to two edges (x, y; c), (y, x; −c − 1).
However at most only one of the two is activated (depending if T -atom
is pushed positively or negatively)
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 22 / 24
Final Remarks
We did not say how to handle negative T -atoms, such as ¬(x − y ≤ c).
However it is easy to see that ¬(x − y ≤ c) iff y − x ≤ −c − 1
Each T -atom is associated to two edges (x, y; c), (y, x; −c − 1).
However at most only one of the two is activated (depending if T -atom
is pushed positively or negatively)
Simple bounds, such as x ≤ c or −x ≤ c can also be handled.
It is sufficient to add a “fake” (and fresh) variable Z (stands for
“zero”), and use x − Z ≤ c and Z − x ≤ c instead of the above
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 22 / 24
Floyd-Warshall
Another algorithm that can be used instead of BF is the
Floyd-Warshall
FW has a complexity of θ(n3), while BF of O(nm) (variations of BF
have complexity O(m + n log n))
FW however is useful as it is trivial to compute all theory
propagations. In BF, theory propagations are tricky to discover
FW is independent of m, the numeber of edges. FW is good for dense
problems, while is likely to be bad for sparse ones
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 23 / 24
Exercizes
1 Prove that adding {(I, x1; 0), . . . , (I, xn; 0)} to a graph free of
negative cycles, does not introduce any negative cycle
2 Let G(V, E) be a graph, let x, y ∈ V , and suppose that a path
y → . . . → x exists in G. Are the following true or false ? (if false,
show counterexamples)
(a) Adding an edge (x, y; 100) to G never causes the creation of a
negative cycle
(b) Adding an edge (x, y; −100) to G always causes the creation of a
negative cycle
3 Let µB be a set of constraints of the form x − y ≤ c. Let µ be a
model. Let ζ(x) = {µ(x) + }, for some ∈ Z. Show that ζ is also
a model
4 Show that conflicts returned discovered with checkNegativeCycle
are always minimal
5 Prove Observation 2 using Farka’s Lemma
R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 24 / 24

More Related Content

What's hot

Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Introduction to modern Variational Inference.
Introduction to modern Variational Inference.
Tomasz Kusmierczyk
 
DSP System Assignment Help
DSP System Assignment HelpDSP System Assignment Help
DSP System Assignment Help
Matlab Assignment Experts
 
Kolmogorov complexity and topological arguments
Kolmogorov complexity and topological argumentsKolmogorov complexity and topological arguments
Kolmogorov complexity and topological arguments
shenmontpellier
 
A Generalization of QN-Maps
A Generalization of QN-MapsA Generalization of QN-Maps
A Generalization of QN-Maps
IOSR Journals
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
Absorbing Random Walk Centrality
Absorbing Random Walk CentralityAbsorbing Random Walk Centrality
Absorbing Random Walk Centrality
Michael Mathioudakis
 
Richard Everitt's slides
Richard Everitt's slidesRichard Everitt's slides
Richard Everitt's slides
Christian Robert
 
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 
Multicasting in Linear Deterministic Relay Network by Matrix Completion
Multicasting in Linear Deterministic Relay Network by Matrix CompletionMulticasting in Linear Deterministic Relay Network by Matrix Completion
Multicasting in Linear Deterministic Relay Network by Matrix Completion
Tasuku Soma
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
Dr Shashikant Athawale
 
Signals Processing Assignment Help
Signals Processing Assignment HelpSignals Processing Assignment Help
Signals Processing Assignment Help
Matlab Assignment Experts
 
Justesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesJustesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codes
Madhumita Tamhane
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
sohelranasweet
 
The low-rank basis problem for a matrix subspace
The low-rank basis problem for a matrix subspaceThe low-rank basis problem for a matrix subspace
The low-rank basis problem for a matrix subspace
Tasuku Soma
 
QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...
QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...
QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...
The Statistical and Applied Mathematical Sciences Institute
 
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmOptimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Tasuku Soma
 
Mark Girolami's Read Paper 2010
Mark Girolami's Read Paper 2010Mark Girolami's Read Paper 2010
Mark Girolami's Read Paper 2010
Christian Robert
 
Jere Koskela slides
Jere Koskela slidesJere Koskela slides
Jere Koskela slides
Christian Robert
 
Nonconvex Compressed Sensing with the Sum-of-Squares Method
Nonconvex Compressed Sensing with the Sum-of-Squares MethodNonconvex Compressed Sensing with the Sum-of-Squares Method
Nonconvex Compressed Sensing with the Sum-of-Squares Method
Tasuku Soma
 

What's hot (20)

Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Introduction to modern Variational Inference.
Introduction to modern Variational Inference.
 
DSP System Assignment Help
DSP System Assignment HelpDSP System Assignment Help
DSP System Assignment Help
 
Kolmogorov complexity and topological arguments
Kolmogorov complexity and topological argumentsKolmogorov complexity and topological arguments
Kolmogorov complexity and topological arguments
 
A Generalization of QN-Maps
A Generalization of QN-MapsA Generalization of QN-Maps
A Generalization of QN-Maps
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 
Absorbing Random Walk Centrality
Absorbing Random Walk CentralityAbsorbing Random Walk Centrality
Absorbing Random Walk Centrality
 
Richard Everitt's slides
Richard Everitt's slidesRichard Everitt's slides
Richard Everitt's slides
 
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
 
Multicasting in Linear Deterministic Relay Network by Matrix Completion
Multicasting in Linear Deterministic Relay Network by Matrix CompletionMulticasting in Linear Deterministic Relay Network by Matrix Completion
Multicasting in Linear Deterministic Relay Network by Matrix Completion
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Signals Processing Assignment Help
Signals Processing Assignment HelpSignals Processing Assignment Help
Signals Processing Assignment Help
 
Justesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesJustesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codes
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
The low-rank basis problem for a matrix subspace
The low-rank basis problem for a matrix subspaceThe low-rank basis problem for a matrix subspace
The low-rank basis problem for a matrix subspace
 
QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...
QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...
QMC: Operator Splitting Workshop, Proximal Algorithms in Probability Spaces -...
 
Algorithum Analysis
Algorithum AnalysisAlgorithum Analysis
Algorithum Analysis
 
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmOptimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
 
Mark Girolami's Read Paper 2010
Mark Girolami's Read Paper 2010Mark Girolami's Read Paper 2010
Mark Girolami's Read Paper 2010
 
Jere Koskela slides
Jere Koskela slidesJere Koskela slides
Jere Koskela slides
 
Nonconvex Compressed Sensing with the Sum-of-Squares Method
Nonconvex Compressed Sensing with the Sum-of-Squares MethodNonconvex Compressed Sensing with the Sum-of-Squares Method
Nonconvex Compressed Sensing with the Sum-of-Squares Method
 

Viewers also liked

Balanç 100 dies nou govern Ajuntament de Manresa
Balanç 100 dies nou govern Ajuntament de ManresaBalanç 100 dies nou govern Ajuntament de Manresa
Balanç 100 dies nou govern Ajuntament de Manresa
Ajuntament de Manresa
 
Memorial de Greuges 1760, 1885 i Bases de Manresa 1892
Memorial de Greuges 1760, 1885 i Bases de Manresa 1892Memorial de Greuges 1760, 1885 i Bases de Manresa 1892
Memorial de Greuges 1760, 1885 i Bases de Manresa 1892
Miqui Mel
 
Power historia bases de manresa by Oriol Alicarte i Marc Pérez
Power historia bases de manresa by Oriol Alicarte i Marc PérezPower historia bases de manresa by Oriol Alicarte i Marc Pérez
Power historia bases de manresa by Oriol Alicarte i Marc PérezToni Guirao
 
Bases de manresa
Bases de manresaBases de manresa
Bases de manresa
mariaeulaliacs
 
El Catalanisme polític (1833-1898). Primera part.
El Catalanisme polític (1833-1898). Primera part.El Catalanisme polític (1833-1898). Primera part.
El Catalanisme polític (1833-1898). Primera part.Marcel Duran
 

Viewers also liked (7)

Bases
BasesBases
Bases
 
Balanç 100 dies nou govern Ajuntament de Manresa
Balanç 100 dies nou govern Ajuntament de ManresaBalanç 100 dies nou govern Ajuntament de Manresa
Balanç 100 dies nou govern Ajuntament de Manresa
 
Memorial de Greuges 1760, 1885 i Bases de Manresa 1892
Memorial de Greuges 1760, 1885 i Bases de Manresa 1892Memorial de Greuges 1760, 1885 i Bases de Manresa 1892
Memorial de Greuges 1760, 1885 i Bases de Manresa 1892
 
Power historia bases de manresa by Oriol Alicarte i Marc Pérez
Power historia bases de manresa by Oriol Alicarte i Marc PérezPower historia bases de manresa by Oriol Alicarte i Marc Pérez
Power historia bases de manresa by Oriol Alicarte i Marc Pérez
 
3 catalanisme xix
3 catalanisme xix3 catalanisme xix
3 catalanisme xix
 
Bases de manresa
Bases de manresaBases de manresa
Bases de manresa
 
El Catalanisme polític (1833-1898). Primera part.
El Catalanisme polític (1833-1898). Primera part.El Catalanisme polític (1833-1898). Primera part.
El Catalanisme polític (1833-1898). Primera part.
 

Similar to smtlecture.5

smtlecture.6
smtlecture.6smtlecture.6
smtlecture.6
Roberto Bruttomesso
 
Online Signals and Systems Assignment Help
Online Signals and Systems Assignment HelpOnline Signals and Systems Assignment Help
Online Signals and Systems Assignment Help
Matlab Assignment Experts
 
Congrès SMAI 2019
Congrès SMAI 2019Congrès SMAI 2019
Congrès SMAI 2019
Hamed Zakerzadeh
 
Affine Yield Curves: Flexibility versus Incompleteness
Affine Yield Curves: Flexibility versus IncompletenessAffine Yield Curves: Flexibility versus Incompleteness
Affine Yield Curves: Flexibility versus Incompleteness
Dhia Eddine Barbouche
 
Graph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph AlgorithmsGraph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph Algorithms
htttuneti
 
smtlectures.1
smtlectures.1smtlectures.1
smtlectures.1
Roberto Bruttomesso
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
Dilum Bandara
 
Signal Processing Homework Help
Signal Processing Homework HelpSignal Processing Homework Help
Signal Processing Homework Help
Matlab Assignment Experts
 
Unit 3
Unit 3Unit 3
Unit 3
guna287176
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
台灣資料科學年會
 
smtlecture.7
smtlecture.7smtlecture.7
smtlecture.7
Roberto Bruttomesso
 
Eece 301 note set 14 fourier transform
Eece 301 note set 14 fourier transformEece 301 note set 14 fourier transform
Eece 301 note set 14 fourier transform
Sandilya Sridhara
 
20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilersComputer Science Club
 
Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)
Haruki Nishimura
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Codemotion
 
MVPA with SpaceNet: sparse structured priors
MVPA with SpaceNet: sparse structured priorsMVPA with SpaceNet: sparse structured priors
MVPA with SpaceNet: sparse structured priors
Elvis DOHMATOB
 
Wide sense stationary process in digital communication
Wide sense stationary process in digital communicationWide sense stationary process in digital communication
Wide sense stationary process in digital communication
VitthalGavhane1
 
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
Marco Benini
 

Similar to smtlecture.5 (20)

smtlecture.6
smtlecture.6smtlecture.6
smtlecture.6
 
Online Signals and Systems Assignment Help
Online Signals and Systems Assignment HelpOnline Signals and Systems Assignment Help
Online Signals and Systems Assignment Help
 
Congrès SMAI 2019
Congrès SMAI 2019Congrès SMAI 2019
Congrès SMAI 2019
 
Affine Yield Curves: Flexibility versus Incompleteness
Affine Yield Curves: Flexibility versus IncompletenessAffine Yield Curves: Flexibility versus Incompleteness
Affine Yield Curves: Flexibility versus Incompleteness
 
Graph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph AlgorithmsGraph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph Algorithms
 
smtlectures.1
smtlectures.1smtlectures.1
smtlectures.1
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Signal Processing Homework Help
Signal Processing Homework HelpSignal Processing Homework Help
Signal Processing Homework Help
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
residue
residueresidue
residue
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
 
smtlecture.7
smtlecture.7smtlecture.7
smtlecture.7
 
Eece 301 note set 14 fourier transform
Eece 301 note set 14 fourier transformEece 301 note set 14 fourier transform
Eece 301 note set 14 fourier transform
 
20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers
 
Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)Stochastic Control and Information Theoretic Dualities (Complete Version)
Stochastic Control and Information Theoretic Dualities (Complete Version)
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
 
MVPA with SpaceNet: sparse structured priors
MVPA with SpaceNet: sparse structured priorsMVPA with SpaceNet: sparse structured priors
MVPA with SpaceNet: sparse structured priors
 
Wide sense stationary process in digital communication
Wide sense stationary process in digital communicationWide sense stationary process in digital communication
Wide sense stationary process in digital communication
 
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
Intuitionistic First-Order Logic: Categorical semantics via the Curry-Howard ...
 

More from Roberto Bruttomesso

smtlecture.10
smtlecture.10smtlecture.10
smtlecture.10
Roberto Bruttomesso
 
smtlecture.9
smtlecture.9smtlecture.9
smtlecture.9
Roberto Bruttomesso
 
smtlecture.8
smtlecture.8smtlecture.8
smtlecture.8
Roberto Bruttomesso
 
smtlecture.4
smtlecture.4smtlecture.4
smtlecture.4
Roberto Bruttomesso
 
smtlecture.3
smtlecture.3smtlecture.3
smtlecture.3
Roberto Bruttomesso
 
smtlectures.2
smtlectures.2smtlectures.2
smtlectures.2
Roberto Bruttomesso
 
satandsmt.stpetersburg
satandsmt.stpetersburgsatandsmt.stpetersburg
satandsmt.stpetersburg
Roberto Bruttomesso
 

More from Roberto Bruttomesso (7)

smtlecture.10
smtlecture.10smtlecture.10
smtlecture.10
 
smtlecture.9
smtlecture.9smtlecture.9
smtlecture.9
 
smtlecture.8
smtlecture.8smtlecture.8
smtlecture.8
 
smtlecture.4
smtlecture.4smtlecture.4
smtlecture.4
 
smtlecture.3
smtlecture.3smtlecture.3
smtlecture.3
 
smtlectures.2
smtlectures.2smtlectures.2
smtlectures.2
 
satandsmt.stpetersburg
satandsmt.stpetersburgsatandsmt.stpetersburg
satandsmt.stpetersburg
 

Recently uploaded

Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

smtlecture.5

  • 1. Satisfiability Modulo Theories Lezione 5 - A Theory Solver for IDL (slides revision: Saturday 14th March, 2015, 11:47) Roberto Bruttomesso Seminario di Logica Matematica (Corso Prof. Silvio Ghilardi) 17 Novembre 2011 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 1 / 24
  • 2. Recall from last lecture The Lazy Approach for a theory T is based on the tight integration of a CDCL SAT-solver a T -solver, a decision procedure for T R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 2 / 24
  • 3. Recall from last lecture The Lazy Approach for a theory T is based on the tight integration of a CDCL SAT-solver a T -solver, a decision procedure for T The SAT-solver enumerates Boolean models µB The T -solver checks the consistency of µB in T R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 2 / 24
  • 4. Recall from last lecture The Lazy Approach for a theory T is based on the tight integration of a CDCL SAT-solver a T -solver, a decision procedure for T The SAT-solver enumerates Boolean models µB The T -solver checks the consistency of µB in T For efficiency, it is desirable that the T -solver Reasons incrementally (does not compute everything from scratch everytime) Backtracks efficiently Returns minimal conflicts Performs Theory-Propagation R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 2 / 24
  • 5. Outline 1 Integer Difference Logic Introduction Translation into a Graph Solving 2 Improvement for T -solver Minimal Conflicts Incrementality Backtrackability Theory Propagation 3 Final Remarks R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 3 / 24
  • 6. Integer Difference Logics (IDL) The T -atoms of IDL consists of arithmetic constraints of the form x − y ≤ c where x, y are variables and c is a numerical constant. The domain of x, y, c is that of the integers R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 4 / 24
  • 7. Integer Difference Logics (IDL) The T -atoms of IDL consists of arithmetic constraints of the form x − y ≤ c where x, y are variables and c is a numerical constant. The domain of x, y, c is that of the integers Notice that the following translations hold x − y ≥ c =⇒ y − x ≤ −c x − y < c =⇒ x − y ≤ c − 1 x − y > c =⇒ y − x ≤ −c − 1 x − y = c =⇒ (x − y ≤ c) ∧ (x − y ≥ c) x − y = c =⇒ (x − y < c) ∨ (x − y > c) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 4 / 24
  • 8. Integer Difference Logic (IDL) RDL is similar to IDL, but it is defined on the rationals. However an RDL formula can be reduced to an equisatisfiable IDL formula R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 5 / 24
  • 9. Integer Difference Logic (IDL) RDL is similar to IDL, but it is defined on the rationals. However an RDL formula can be reduced to an equisatisfiable IDL formula IDL/RDL can be used to encode a large variety of verification probems scheduling TSP ASP timed-automata sorting algorithms Also, the worst-case complexity of solving a conjunction of IDL constraints is O(m + n log n) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 5 / 24
  • 10. Translation into a Graph The constraint x − y ≤ c says that “the distance between x and y is at most c” This can be encoded as (x, y; c) x y c R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 6 / 24
  • 11. Translation into a Graph The constraint x − y ≤ c says that “the distance between x and y is at most c” This can be encoded as (x, y; c) x y c So, a set µB can be encoded as a graph. Concrete example: x − y ≤ 8 y − z ≤ −1 z − x ≤ −6 z − w ≤ 2 w − x ≤ −10 w − t ≤ 0 t − x ≤ 3 x y z wt 8 −1 −6 2 −10 0 3 G(V, E): V = {x, y, z, w, t}, E = {(x, y; 8), (y, z; −1), (z, x; −6), (z, w; 2), (w, x; −10), . . .} R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 6 / 24
  • 12. Translation into a Graph Theorem (Translation) µB is IDL-unsatisfiable iff there is a negative cycle in the corresponging graph G(V, E) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 7 / 24
  • 13. Translation into a Graph Theorem (Translation) µB is IDL-unsatisfiable iff there is a negative cycle in the corresponging graph G(V, E) E.g.: x − y ≤ 8 y − z ≤ − 1 z − x ≤ − 6 z − w ≤ 2 w − x ≤ − 10 w − t ≤ 0 t − x ≤ 3 x y z wt 8 −1 −6 2 −10 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 7 / 24
  • 14. Translation into a Graph Theorem (Translation) µB is IDL-unsatisfiable iff there is a negative cycle in the corresponging graph G(V, E) E.g.: x − y ≤ 8 y − z ≤ − 1 z − x ≤ − 6 z − w ≤ 2 w − x ≤ − 10 w − t ≤ 0 t − x ≤ 3 x y z wt 8 −1 −6 2 −10 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 7 / 24
  • 15. Translation into a Graph We use the following lemma to aid the proof Lemma (Farka’s Lemma for IDL) µB is unsatisfiable iff there exists a subset νB = { x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn − x1 ≤ cn } of µB such that c1 + . . . + cn < 0 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 8 / 24
  • 16. Translation into a Graph We use the following lemma to aid the proof Lemma (Farka’s Lemma for IDL) µB is unsatisfiable iff there exists a subset νB = { x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn − x1 ≤ cn } of µB such that c1 + . . . + cn < 0 The proof of Theorem is now trivial Proof. µB is unsatisfiable iff by Farka’s Lemma for IDL there exists νB ⊆ µB with c1 + . . . + cn < 0 iff by our translation there exists a negative cycle in G(V, E) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 8 / 24
  • 17. Solving Suppose that no negative cycle exists in G(V, E) for µB, how do we find a model µ for the integer variables ? R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 9 / 24
  • 18. Solving Suppose that no negative cycle exists in G(V, E) for µB, how do we find a model µ for the integer variables ? State-of-the-art methods employ SSSP (Single Source Shortest Paths) algorithms, such as the Bellman-Ford algorithm (or its variations), as follows: we add an artificial vertex I to V , and add {(I, x1; 0), . . . , (I, xn; 0)} to E (notice that this never creates negative cycles) Compute the shortest paths from source I (run Bellman-Ford). Let π(x) be the shortest path from I to x, for all x ∈ V The model µ can be computed as µ(x) = −π(x) for all x ∈ V (see later why) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 9 / 24
  • 19. Bellman-Ford π(x): current distance of x from I TBV : queue of vertexes To Be Visited 1 π(x) = ∞ for all x ∈ V, x = I 2 π(I) = 0 3 TBV.pushBack(I) 4 while ( TBV.size( ) > 0 ) 5 s = TBV.popFront( ) 6 foreach (s, t; w) ∈ E // for each outgoing edge 7 if ( π(t) − π(s) > w ) // is too far ? 8 π(t) = π(s) + w // relax (decrease π(t)) 9 if ( TBV.has(t) == false ) 10 TBV.pushBack(t) // enqueue t if not there R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 10 / 24
  • 20. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ ] Current vertex: Current edge: x y z wt I 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 21. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ ] Current vertex: Current edge: x y z wt I 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 22. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ I ] Current vertex: Current edge: x ∞ y ∞ z ∞ w ∞ t ∞ I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 23. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ ] Current vertex: I Current edge: x ∞ y ∞ z ∞ w ∞ t ∞ I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 24. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ x ] Current vertex: I Current edge: (I, x; 0) x 0 y ∞ z ∞ w ∞ t ∞ I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 25. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ x, y,z, w, t ] Current vertex: Current edge: x 0 y 0 z 0 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 26. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ y,z, w, t ] Current vertex: x Current edge: x 0 y 0 z 0 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 27. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ y,z, w, t ] Current vertex: x Current edge: x 0 y 0 z 0 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 28. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ y,z, w, t ] Current vertex: Current edge: x 0 y 0 z 0 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 29. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ z, w, t ] Current vertex: y Current edge: x 0 y 0 z 0 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 30. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ z, w, t ] Current vertex: y Current edge: (y, z; −1) x 0 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 31. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ z, w, t ] Current vertex: Current edge: x 0 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 32. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ ] Current vertex: Current edge: x −9 y −1 z −2 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 33. Bellman-Ford, Example π(x): current distance of x from I TBV : queue of vertexes To Be Visited π(x) = ∞ for all x ∈ V, x = I π(I) = 0 TBV.pushBack(I) while ( TBV.size( ) > 0 ) s = TBV.popFront( ) foreach (s, t; w) ∈ E if ( π(t) − π(s) > w ) π(t) = π(s) + w if ( TBV.has(t) == false ) TBV.pushBack(t) TBV = [ ] Current vertex: Current edge: x −9 y −1 z −2 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 shortest paths (spanning tree) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 11 / 24
  • 34. Bellman-Ford, consideration Invariant At the end of BF, π(x) holds the shortest distance from I to x, for all x ∈ V R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 12 / 24
  • 35. Bellman-Ford, consideration Invariant At the end of BF, π(x) holds the shortest distance from I to x, for all x ∈ V Lemma (Shortest Path) At the end of BF, π(y) − π(x) ≤ c holds for all (x, y; c) ∈ E R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 12 / 24
  • 36. Bellman-Ford, consideration Invariant At the end of BF, π(x) holds the shortest distance from I to x, for all x ∈ V Lemma (Shortest Path) At the end of BF, π(y) − π(x) ≤ c holds for all (x, y; c) ∈ E Proof. Suppose, for the sake of contradiction, that for an edge (x, y; c), we have π(y) − π(x) > c x π(x) y π(y) I 0 . . . . . .c shortest paths π(x) is the shortest dist. from I to x (by Invariant). But since π(y) > π(x) + c, the shortest path from I to y is π(x) + c. So π(y) is not the shortest dist. Contradiction. R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 12 / 24
  • 37. Finding a model µ Because of the previous lemma we have that π(y) − π(x) ≤ c holds for all (x, y; c) ∈ E So, if we take µ(x) = −π(x) we have that µ(x) − µ(y) ≤ c holds for all constraints in µB and therefore µ is a model R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 13 / 24
  • 38. Outline 1 Integer Difference Logic Introduction Translation into a Graph Solving 2 Improvement for T -solver Minimal Conflicts Incrementality Backtrackability Theory Propagation 3 Final Remarks R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 14 / 24
  • 39. T -solver Compliance So far we have seen that BF can be used to compute a model of a given consistent set of IDL constraints Recall that to have an efficient T -solver the following features should be supported Minimal Conflicts Incrementality Backtrackability Theory Propagation Let’s see how to improve the current algorithm to support them R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 15 / 24
  • 40. Minimal Conflicts So far we assumed that G(V, E) did not contain negative cycles. However it is not difficult to tweak the BF to recognize them R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 16 / 24
  • 41. Minimal Conflicts So far we assumed that G(V, E) did not contain negative cycles. However it is not difficult to tweak the BF to recognize them Recall the spanning tree: the tree that holds shortest paths R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 16 / 24
  • 42. Minimal Conflicts So far we assumed that G(V, E) did not contain negative cycles. However it is not difficult to tweak the BF to recognize them Recall the spanning tree: the tree that holds shortest paths It is easy to keep the spanning tree: each node t keeps two fields fatherVertex and fatherEdge that stores its father in the spanning tree when a relax is done on t (line 8 of BF) through an edge e = (s, t; c), t.fatherV ertex is set to s and t.fatherEdge is set to e R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 16 / 24
  • 43. Minimal Conflicts When a negative cycle exists, the spanning tree tends to become cyclic (trees are acyclic instead). It is easy to recognize this situation and report the negative cycle R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 17 / 24
  • 44. Minimal Conflicts When a negative cycle exists, the spanning tree tends to become cyclic (trees are acyclic instead). It is easy to recognize this situation and report the negative cycle TBV = [ ] Current vetex: z Current edge: (z, w; 2) x −10 y −2 z −3 w 0 t 0 I 0 8 −1 2 −10 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 17 / 24
  • 45. Minimal Conflicts When a negative cycle exists, the spanning tree tends to become cyclic (trees are acyclic instead). It is easy to recognize this situation and report the negative cycle TBV = [ ] Current vetex: z Current edge: (z, w; 2) x −10 y −2 z −3 w 0 t 0 I 0 8 −1 2 −10 checkNegativeCycle( s, t ) νB = { } while ( s = t && s = I ) s = s.fatherV ertex νB = νB ∪ {s.fatherEdge} if ( s == t ) return conflict // Neg. Cycle detected return OK // I reached R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 17 / 24
  • 46. Minimal Conflicts Bellman-Ford with negative cycle detection 1 π(x) = ∞ for all x ∈ V, x = I 2 π(I) = 0 3 TBV.pushBack(I) 4 while ( TBV.size( ) > 0 ) 5 s = TBV.popFront( ) 6 foreach (s, t; w) ∈ E // for each outgoing edge 7 if ( π(t) − π(s) > w ) // is too far ? 8 if ( checkNegativeCycle( s, t ) == conflict ) 9 return νB 10 s.fatherV ertex = t 11 s.fatherEdge = (s, t; w) 12 π(t) = π(s) + w // relax (decrease π(t)) 13 if ( TBV.has(t) == false ) 14 TBV.pushBack(t) // enqueue t if not there R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 18 / 24
  • 47. Incrementality Incrementality comes almost for free ! we always keep the π function “alive”, and only update it slightly G(V, E) keeps track of active and inactive edges: active edges are those on µB when a new T -atom x − y ≤ c is added to µB, the corresponding edge (x, y; c) becomes active in the graph we add x to TBV , and run BF from line 4 x − y ≤ 8 ∈ µB x −9 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 19 / 24
  • 48. Incrementality Incrementality comes almost for free ! we always keep the π function “alive”, and only update it slightly G(V, E) keeps track of active and inactive edges: active edges are those on µB when a new T -atom x − y ≤ c is added to µB, the corresponding edge (x, y; c) becomes active in the graph we add x to TBV , and run BF from line 4 x − y ≤ 8 ∈ µB x −9 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 x − y ≤ 8 pushed to µB x −9 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 19 / 24
  • 49. Incrementality Incrementality comes almost for free ! we always keep the π function “alive”, and only update it slightly G(V, E) keeps track of active and inactive edges: active edges are those on µB when a new T -atom x − y ≤ c is added to µB, the corresponding edge (x, y; c) becomes active in the graph we add x to TBV , and run BF from line 4 x − y ≤ 8 ∈ µB x −9 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 x − y ≤ 8 pushed to µB x −9 y 0 z −1 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 After BF x −9 y −1 z −2 w 0 t 0 I 0 8 −1 −6 2 −9 0 3 R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 19 / 24
  • 50. Backtrackability Backtracking can be done efficiently First of all, recall that µ(x) = −π(x). Second obeserve that Observation 1 Let µ be a model for a set µB of constraints. Then µ is also a model for any subset of µB Observation 1 implies that when backtracking we just have to turn some edges into inactive, and keep the last π intact This is done as follows: BF will always work on a temporary π, called π . If satisfiable, π is replaced by π , otherwise we keep π R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 20 / 24
  • 51. Theory Propagation Theory Propagation is the process of activating some edges in the graph that are implied by the current µB Observation 2 A set of constraints { x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn−1 − xn ≤ cn−1 } implies x1 − xn ≤ cn iff c1 + c2 + . . . cn−1 ≤ cn R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 21 / 24
  • 52. Theory Propagation Theory Propagation is the process of activating some edges in the graph that are implied by the current µB Observation 2 A set of constraints { x1 − x2 ≤ c1, x2 − x3 ≤ c2, . . . , xn−1 − xn ≤ cn−1 } implies x1 − xn ≤ cn iff c1 + c2 + . . . cn−1 ≤ cn Example: x y z. . . . . .4 2 10 x − z ≤ 10, currently inactive, can be theory-propagated R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 21 / 24
  • 53. Final Remarks We did not say how to handle negative T -atoms, such as ¬(x − y ≤ c). However it is easy to see that ¬(x − y ≤ c) iff y − x ≤ −c − 1 Each T -atom is associated to two edges (x, y; c), (y, x; −c − 1). However at most only one of the two is activated (depending if T -atom is pushed positively or negatively) R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 22 / 24
  • 54. Final Remarks We did not say how to handle negative T -atoms, such as ¬(x − y ≤ c). However it is easy to see that ¬(x − y ≤ c) iff y − x ≤ −c − 1 Each T -atom is associated to two edges (x, y; c), (y, x; −c − 1). However at most only one of the two is activated (depending if T -atom is pushed positively or negatively) Simple bounds, such as x ≤ c or −x ≤ c can also be handled. It is sufficient to add a “fake” (and fresh) variable Z (stands for “zero”), and use x − Z ≤ c and Z − x ≤ c instead of the above R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 22 / 24
  • 55. Floyd-Warshall Another algorithm that can be used instead of BF is the Floyd-Warshall FW has a complexity of θ(n3), while BF of O(nm) (variations of BF have complexity O(m + n log n)) FW however is useful as it is trivial to compute all theory propagations. In BF, theory propagations are tricky to discover FW is independent of m, the numeber of edges. FW is good for dense problems, while is likely to be bad for sparse ones R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 23 / 24
  • 56. Exercizes 1 Prove that adding {(I, x1; 0), . . . , (I, xn; 0)} to a graph free of negative cycles, does not introduce any negative cycle 2 Let G(V, E) be a graph, let x, y ∈ V , and suppose that a path y → . . . → x exists in G. Are the following true or false ? (if false, show counterexamples) (a) Adding an edge (x, y; 100) to G never causes the creation of a negative cycle (b) Adding an edge (x, y; −100) to G always causes the creation of a negative cycle 3 Let µB be a set of constraints of the form x − y ≤ c. Let µ be a model. Let ζ(x) = {µ(x) + }, for some ∈ Z. Show that ζ is also a model 4 Show that conflicts returned discovered with checkNegativeCycle are always minimal 5 Prove Observation 2 using Farka’s Lemma R. Bruttomesso (SMT) T -solver for IDL 17 Novembre 2011 24 / 24