SlideShare une entreprise Scribd logo
1  sur  56
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Introduction to modern Variational Inference.
Introduction to modern Variational Inference.Tomasz Kusmierczyk
 
Kolmogorov complexity and topological arguments
Kolmogorov complexity and topological argumentsKolmogorov complexity and topological arguments
Kolmogorov complexity and topological argumentsshenmontpellier
 
A Generalization of QN-Maps
A Generalization of QN-MapsA Generalization of QN-Maps
A Generalization of QN-MapsIOSR 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
 
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 ReviewRoman 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 CompletionTasuku Soma
 
Justesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesJustesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesMadhumita Tamhane
 
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 subspaceTasuku Soma
 
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 AlgorithmTasuku Soma
 
Mark Girolami's Read Paper 2010
Mark Girolami's Read Paper 2010Mark Girolami's Read Paper 2010
Mark Girolami's Read Paper 2010Christian 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 MethodTasuku Soma
 

Tendances (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
 

En vedette

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 ManresaAjuntament 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 1892Miqui 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
 
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
 

En vedette (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.
 

Similaire à smtlecture.5

Affine Yield Curves: Flexibility versus Incompleteness
Affine Yield Curves: Flexibility versus IncompletenessAffine Yield Curves: Flexibility versus Incompleteness
Affine Yield Curves: Flexibility versus IncompletenessDhia Eddine Barbouche
 
Graph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph AlgorithmsGraph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph Algorithmshtttuneti
 
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 transformSandilya 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 priorsElvis DOHMATOB
 
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
 
Linear transformation.ppt
Linear transformation.pptLinear transformation.ppt
Linear transformation.pptRaj Parekh
 

Similaire à 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
 
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 ...
 
Linear transformation.ppt
Linear transformation.pptLinear transformation.ppt
Linear transformation.ppt
 

Plus de 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
 

Dernier

Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...Nguyen Thanh Tu Collection
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Osopher
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineCeline George
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxMadhavi Dharankar
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxAvaniJani1
 

Dernier (20)

Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command Line
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptx
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptx
 

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