This document discusses a theory solver for linear rational arithmetic (LRA). It begins with an overview of the basic solving process, including preprocessing to separate formulas into equations and bounds, and storing equations in a tableau data structure. It then describes how bounds are asserted on variables, which may tighten bounds or require updating the model if a bound conflicts with the current value assigned to a variable. Asserting a bound on a non-basic variable in particular may cause the values of basic variables to be adjusted. The document provides examples to illustrate these concepts.
1. Satisfiability Modulo Theories
Lecture 6 - A Theory Solver for LRA
(slides revision: Saturday 14th
March, 2015, 11:47)
Roberto Bruttomesso
Seminario di Logica Matematica
(Corso Prof. Silvio Ghilardi)
24 Novembre 2011
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 1 / 21
3. Simplex Algorithm
Invented by Tobias Dantzig around 1950
Used to solve optimization problems in linear programming
Greg Nelson was the first to employ it for constraint solving, AFAIK,
around 1980
Difference is that in linear programming input problem is feasible and
one looks for optimum. In constraint solving problem can be infeasible,
and we are interested in finding any solution
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 3 / 21
4. Introduction
Linear Rational Arithmetic LRA consists in solving Boolean
combinations of atoms of the form
n
j=1
ajxj ≤ b
n
j=1
ajxj ≥ b
where aj are constants (coefficients), xj are variables, and b is a
constant (bound). The domain of aj, xj, b is that of rationals.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 4 / 21
5. Introduction
Linear Rational Arithmetic LRA consists in solving Boolean
combinations of atoms of the form
n
j=1
ajxj ≤ b
n
j=1
ajxj ≥ b
where aj are constants (coefficients), xj are variables, and b is a
constant (bound). The domain of aj, xj, b is that of rationals.
Notice that the following translations hold
n
j=1 ajxj = b =⇒ ( n
j=1 ajxj ≤ b) ∧ ( n
j=1 ajxj ≥ b)
n
j=1 ajxj < b =⇒ see later
n
j=1 ajxj > b =⇒ see later
n
j=1 ajxj = b =⇒ ( n
j=1 ajxj < b) ∨ ( n
j=1 ajxj > b)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 4 / 21
6. Preprocessing
In the SMT setting, we are given a formula ϕ like
(x ≥ 0) ∧ ((x + y ≤ 2) ∨ (x + 2y − z ≥ 6)) ∧ ((x + y ≥ 2) ∨ (2y − z ≤ 4))
We perform a preprocessing step, in order to separate the formula
into a set of equations and a set of simple bounds. This is done by
introducing fresh variables.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 5 / 21
7. Preprocessing
In the SMT setting, we are given a formula ϕ like
(x ≥ 0) ∧ ((x + y ≤ 2) ∨ (x + 2y − z ≥ 6)) ∧ ((x + y ≥ 2) ∨ (2y − z ≤ 4))
We perform a preprocessing step, in order to separate the formula
into a set of equations and a set of simple bounds. This is done by
introducing fresh variables.
The formula above ϕ is equivalent to (the conjunction of)
(x ≥ 0) ∧ ((s1 ≤ 2) ∨ (s2 ≥ 6)) ∧ ((s1 ≥ 2) ∨ (s3 ≤ 4))
(s1 = x + y)
(s2 = x + 2y − z)
(s3 = 2y − z)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 5 / 21
8. Preprocessing
In the SMT setting, we are given a formula ϕ like
(x ≥ 0) ∧ ((x + y ≤ 2) ∨ (x + 2y − z ≥ 6)) ∧ ((x + y ≥ 2) ∨ (2y − z ≤ 4))
We perform a preprocessing step, in order to separate the formula
into a set of equations and a set of simple bounds. This is done by
introducing fresh variables.
The formula above ϕ is equivalent to (the conjunction of)
(x ≥ 0) ∧ ((s1 ≤ 2) ∨ (s2 ≥ 6)) ∧ ((s1 ≥ 2) ∨ (s3 ≤ 4)) ϕ
(s1 = x + y)
(s2 = x + 2y − z) Ax = 0
(s3 = 2y − z)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 5 / 21
9. Preprocessing
In general, from a formula ϕ, we end up in a rewritten formula of the
kind
ϕ ∧ Ax = 0
where ϕ is a Boolean combination of bounds, while Ax = 0 is a
system of equations of the form
a11x1 + . . . + a1nxn = 0
a21x1 + . . . + a2nxn = 0
. . .
ai1x1 + . . . + ainxn = 0
. . .
am1x1 + . . . + amnxn = 0
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 6 / 21
10. Preprocessing
In general, from a formula ϕ, we end up in a rewritten formula of the
kind
ϕ ∧ Ax = 0
where ϕ is a Boolean combination of bounds, while Ax = 0 is a
system of equations of the form
a11x1 + . . . + a1nxn = 0
a21x1 + . . . + a2nxn = 0
. . .
ai1x1 + . . . + ainxn = 0
. . .
am1x1 + . . . + amnxn = 0
Now we detach Ax = 0 from the formula, and we store it into the
T -solver permanently. The SAT-solver will work only on ϕ . Therefore
the constraints that are pushed into and popped from the
T -solver are just bounds
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 6 / 21
11. The Tableau
The equations Ax = 0 are kept in a tableau, the most important structure of the Simplex
The variables are partitioned into the set of non-basic N and basic B variables
E.g., B = {x1, x3, x4}, N = {x2, x5, x6}
x1 = 4x2 + x5
x3 = 5x2 + 3x6
x4 = x5 − x6
non-basic variables can be considered as independent, while basic variables assume values
forced by the non-basic ones. E.g., in the row
x1 = 4x2 + x5
suppose that x2 = 2, x5 = 1, then we set x1 = 9
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 7 / 21
12. Solving
The T -solver stores
the Tableau (does not grow/shrink)
the active bounds on variables (initially none)
the current model µ (initially all 0, but could be chosen differently)
Tableau
x1 = a11xm+1 . . . + a1nxn
x2 = a21xm+1 . . . + a2nxn
. . .
xi = ai1xm+1 . . . + ainxn
. . .
xm = am1xm+1 . . . + amnxn
lb Bounds ub
−∞ ≤ x1 ≤ ∞
−∞ ≤ x2 ≤ ∞
. . .
−∞ ≤ xi ≤ ∞
. . .
−∞ ≤ xm ≤ ∞
. . .
−∞ ≤ xn ≤ ∞
µ
x1 → 0
x2 → 0
. . .
xi → 0
. . .
xm → 0
. . .
xn → 0
The T -solver is in a consistent state if the model (i) respects the tableau and (ii) satisfies
the bounds (for all x, lb(x) ≤ µ(x) ≤ ub(x))
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 8 / 21
13. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
14. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
15. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
16. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
17. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
18. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
The last case is “problematic” because we need to
(i) adjust µ(x): µ(x) is set to c
(ii) adjust the values of basic variables
We assume we have a function Update(x, c) that implements (i) − (ii)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
19. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
The last case is “problematic” because we need to
(i) adjust µ(x): µ(x) is set to c
(ii) adjust the values of basic variables
We assume we have a function Update(x, c) that implements (i) − (ii)
Tableau
x1 = −x3 + x4
x2 = x3 + x4
lb Bounds ub
−∞ ≤ x1 ≤ ∞
−∞ ≤ x2 ≤ ∞
− ∞ ≤ x3 ≤ ∞
−∞ ≤ x4 ≤ ∞
µ
x1 → 0
x2 → 0
x3 → 0
x4 → 0
T -solver stack:
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
20. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
The last case is “problematic” because we need to
(i) adjust µ(x): µ(x) is set to c
(ii) adjust the values of basic variables
We assume we have a function Update(x, c) that implements (i) − (ii)
Tableau
x1 = −x3 + x4
x2 = x3 + x4
lb Bounds ub
−∞ ≤ x1 ≤ ∞
−∞ ≤ x2 ≤ ∞
− ∞ ≤ x3 ≤ − 4
−∞ ≤ x4 ≤ ∞
µ
x1 → 0
x2 → 0
x3 → 0
x4 → 0
T -solver stack:
x3 ≤ −4 (tighten ub(x3), affects other values)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
21. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
The last case is “problematic” because we need to
(i) adjust µ(x): µ(x) is set to c
(ii) adjust the values of basic variables
We assume we have a function Update(x, c) that implements (i) − (ii)
Tableau
x1 = −x3 + x4
x2 = x3 + x4
lb Bounds ub
−∞ ≤ x1 ≤ ∞
−∞ ≤ x2 ≤ ∞
− ∞ ≤ x3 ≤ − 4
−∞ ≤ x4 ≤ ∞
µ
x1 → 4
x2 → − 4
x3 → − 4
x4 → 0
T -solver stack:
x3 ≤ −4 (tighten ub(x3), affects other values)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
22. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
The last case is “problematic” because we need to
(i) adjust µ(x): µ(x) is set to c
(ii) adjust the values of basic variables
We assume we have a function Update(x, c) that implements (i) − (ii)
Tableau
x1 = −x3 + x4
x2 = x3 + x4
lb Bounds ub
−∞ ≤ x1 ≤ ∞
−∞ ≤ x2 ≤ ∞
− 8 ≤ x3 ≤ − 4
−∞ ≤ x4 ≤ ∞
µ
x1 → 4
x2 → − 4
x3 → − 4
x4 → 0
T -solver stack:
x3 ≤ −4 (tighten ub(x3), affects other values)
x3 ≥ −8 (tighten lb(x3), does not affect other values)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
23. Asserting a bound on a non-basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ N may result in
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
The last case is “problematic” because we need to
(i) adjust µ(x): µ(x) is set to c
(ii) adjust the values of basic variables
We assume we have a function Update(x, c) that implements (i) − (ii)
Tableau
x1 = −x3 + x4
x2 = x3 + x4
lb Bounds ub
−∞ ≤ x1 ≤ ∞
−∞ ≤ x2 ≤ ∞
− 8 ≤ x3 ≤ − 4
−∞ ≤ x4 ≤ ∞
µ
x1 → 4
x2 → − 4
x3 → − 4
x4 → 0
T -solver stack:
x3 ≤ −4 (tighten ub(x3), affects other values)
x3 ≥ −8 (tighten lb(x3), does not affect other values)
x3 ≤ 0 (does not tighten ub(x3))
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 9 / 21
24. Asserting a bound on a basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ B may result in the same 4 cases as before
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
however, since a basic variable is dependent from non-basic variables in the tableau, we
cannot use function Update directly. Before we need to turn x into a non-basic variables.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 10 / 21
25. Asserting a bound on a basic variable
Asserting a bound x ≤ c (resp. x ≥ c), x ∈ B may result in the same 4 cases as before
unsatisfiability, if c < lb(x) (resp. c > ub(x))
nothing, if c > ub(x) (resp. c < lb(x))
bound tightening, model not affected if µ(x) ≤ c (resp. µ(x) ≥ c)
bound tightening, model affected if µ(x) > c (resp. µ(x) < c)
however, since a basic variable is dependent from non-basic variables in the tableau, we
cannot use function Update directly. Before we need to turn x into a non-basic variables.
So if µ(x) > c or µ(x) < c we have to
(i) turn x into non-basic (another non-basic variable will become basic instead)
(ii) adjust µ(x): µ(x) is set to c
(iii) adjust the values of basic variables
Step (i) is performed by a function Pivot(x, y) (see next slide). Therefore asserting a bound
on a basic variable x consists in executing Pivot(x, y) and then Update(x, c)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 10 / 21
26. Pivoting
Pivot(x, y) is the operation of swapping a basic variable x with a non-basic variable y (how
to choose y ? See next slide)
It consists of the following steps:
1 Take the row x = ay + R in the tableau (R = rest of the polynome)
2 Rewrite it as y = x−R
a
3 Substitute y with x−R
a
in all the other rows of the tableau (and simplify)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 11 / 21
27. Pivoting
Pivot(x, y) is the operation of swapping a basic variable x with a non-basic variable y (how
to choose y ? See next slide)
It consists of the following steps:
1 Take the row x = ay + R in the tableau (R = rest of the polynome)
2 Rewrite it as y = x−R
a
3 Substitute y with x−R
a
in all the other rows of the tableau (and simplify)
Example for Pivot(x1, x3)
Step 1
x1 = 3x2 + 4x3 − 5x4
x5 = −x2 − x3
x6 = 10x2 + 5x4
Step 2
x3 = −3
4
x2 + 1
4
x1 + 5
4
x4
x5 = −x2 − x3
x6 = 10x2 + 5x4
Step 3
x3 = −3
4
x2 + 1
4
x1 + 5
4
x4
x5 = −1
4
x2 − 1
4
x1 − 5
4
x4
x6 = 10x2 + 5x4
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 11 / 21
28. Pivoting
Pivot(x, y) is the operation of swapping a basic variable x with a non-basic variable y (how
to choose y ? See next slide)
It consists of the following steps:
1 Take the row x = ay + R in the tableau (R = rest of the polynome)
2 Rewrite it as y = x−R
a
3 Substitute y with x−R
a
in all the other rows of the tableau (and simplify)
Example for Pivot(x1, x3)
Step 1
x1 = 3x2 + 4x3 − 5x4
x5 = −x2 − x3
x6 = 10x2 + 5x4
Step 2
x3 = −3
4
x2 + 1
4
x1 + 5
4
x4
x5 = −x2 − x3
x6 = 10x2 + 5x4
Step 3
x3 = −3
4
x2 + 1
4
x1 + 5
4
x4
x5 = −1
4
x2 − 1
4
x1 − 5
4
x4
x6 = 10x2 + 5x4
we moved from B = {x1, x5, x6} to B = {x3, x5, x6}
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 11 / 21
29. Choosing Pivoting Variable
Consider the following situation
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 10
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
1 ≤ x4 ≤ 2
−1 ≤ x5 ≤ 10
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
which among N = {x2, x3, x4} do I choose for pivoting ? Clearly, the value of µ(x1) is too
high, I have to decrease it by playing with the values of N:
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 12 / 21
30. Choosing Pivoting Variable
Consider the following situation
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 10
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
1 ≤ x4 ≤ 2
−1 ≤ x5 ≤ 10
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
which among N = {x2, x3, x4} do I choose for pivoting ? Clearly, the value of µ(x1) is too
high, I have to decrease it by playing with the values of N:
3x2 cannot decrease, as µ(x2) = lb(x2) and cannot be moved down
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 12 / 21
31. Choosing Pivoting Variable
Consider the following situation
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 10
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
1 ≤ x4 ≤ 2
−1 ≤ x5 ≤ 10
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
which among N = {x2, x3, x4} do I choose for pivoting ? Clearly, the value of µ(x1) is too
high, I have to decrease it by playing with the values of N:
3x2 cannot decrease, as µ(x2) = lb(x2) and cannot be moved down
−4x3 cannot decrease, as µ(x3) = ub(x3) and cannot be moved up
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 12 / 21
32. Choosing Pivoting Variable
Consider the following situation
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 10
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
1 ≤ x4 ≤ 2
−1 ≤ x5 ≤ 10
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
which among N = {x2, x3, x4} do I choose for pivoting ? Clearly, the value of µ(x1) is too
high, I have to decrease it by playing with the values of N:
3x2 cannot decrease, as µ(x2) = lb(x2) and cannot be moved down
−4x3 cannot decrease, as µ(x3) = ub(x3) and cannot be moved up
2x4 can decrease, as µ(x4) = ub(x4), and can be moved down
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 12 / 21
33. Choosing Pivoting Variable
Consider the following situation
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 10
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
1 ≤ x4 ≤ 2
−1 ≤ x5 ≤ 10
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
which among N = {x2, x3, x4} do I choose for pivoting ? Clearly, the value of µ(x1) is too
high, I have to decrease it by playing with the values of N:
3x2 cannot decrease, as µ(x2) = lb(x2) and cannot be moved down
−4x3 cannot decrease, as µ(x3) = ub(x3) and cannot be moved up
2x4 can decrease, as µ(x4) = ub(x4), and can be moved down
−x5 can decrease, as µ(x5) = lb(x5), and can be moved up
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 12 / 21
34. Choosing Pivoting Variable
Consider the following situation
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 10
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
1 ≤ x4 ≤ 2
−1 ≤ x5 ≤ 10
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
which among N = {x2, x3, x4} do I choose for pivoting ? Clearly, the value of µ(x1) is too
high, I have to decrease it by playing with the values of N:
3x2 cannot decrease, as µ(x2) = lb(x2) and cannot be moved down
−4x3 cannot decrease, as µ(x3) = ub(x3) and cannot be moved up
2x4 can decrease, as µ(x4) = ub(x4), and can be moved down
−x5 can decrease, as µ(x5) = lb(x5), and can be moved up
both x4 and x5 are therefore good candidates for pivoting. To avoid loops, choose variable
with smallest subscript (Bland’s Rule). This rule is not necessarily efficient, though
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 12 / 21
35. Detect Unsatisfiability
There might be cases in which no suitable variable for pivoting can be found. This
indicates unsatisfiability.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 13 / 21
36. Detect Unsatisfiability
There might be cases in which no suitable variable for pivoting can be found. This
indicates unsatisfiability. Consider the following where we have just asserted x1 ≤ 9
Tableau
. . .
x1 = 3x2 − 4x3 + 2x4 − x5
. . .
lb Bounds ub
−4 ≤ x1 ≤ 9
1 ≤ x2 ≤ 3
−4 ≤ x3 ≤ −1
2 ≤ x4 ≤ 2
−1 ≤ x5 ≤ −1
µ
x1 → 12
x2 → 1
x3 → −1
x4 → 2
x5 → −1
no variable among N = {x2, x3, x4} can be chosen for pivoting. This is because (due to
tableau)
x2 ≥ 3 ∧ x3 ≤ −1 ∧ x4 ≥ 4 ∧ x5 ≤ −1 ⇒ x1 ≥ 12 ⇒ ¬(x1 ≤ 9)
Therefore
{x2 ≥ 3, x3 ≤ −1, x4 ≥ 4, x5 ≤ −1, ¬(x1 ≤ 9)}
is a T -conflict (modulo the tableau)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 13 / 21
37. Solving
1 while( true )
2 pick first xi ∈ B such that µ(xi) < lb(xi) or µ(xi) > ub(xi)
3 if ( there is no such xi ) return sat
4 xj = ChoosePivot(xi)
5 if ( xj == undef ) return unsat
6 Pivot(xi, xj)
7 if ( µ(xi) < lb(xi) )
8 Update(xi, lb(xi))
9 if ( µ(xi) > ub(xi) )
10 Update(xi, ub(xi))
11 end
xj = ChoosePivot(xi): returns variable to use for pivoting with xi, or undef if conflict
pick first xi . . . : it’s again Bland’s rule
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 14 / 21
38. An Example
Consider the following problem
x1 − x2 ≤ 8 ∧ x2 − x3 ≤ −1 ∧ x3 − x4 ≤ 2 ∧ x4 − x1 ≤ −10
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 15 / 21
49. T -solver features
Incrementality: it comes for free, as we keep µ updated
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 17 / 21
50. T -solver features
Incrementality: it comes for free, as we keep µ updated
Backtrackability: use the same trick as for BF: update a model µ ,
if satisfiable set µ = µ , otherwise forget µ . When backtracking
don’t change µ
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 17 / 21
51. T -solver features
Incrementality: it comes for free, as we keep µ updated
Backtrackability: use the same trick as for BF: update a model µ ,
if satisfiable set µ = µ , otherwise forget µ . When backtracking
don’t change µ
Minimal T -conflicts: seen already
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 17 / 21
52. T -solver features
Incrementality: it comes for free, as we keep µ updated
Backtrackability: use the same trick as for BF: update a model µ ,
if satisfiable set µ = µ , otherwise forget µ . When backtracking
don’t change µ
Minimal T -conflicts: seen already
Theory Propagation:
Bound propagation (cheap): if x ≤ c has been asserted, then all
other inactive x ≤ c with c ≤ c are implied (similar for ≥)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 17 / 21
53. T -solver features
Incrementality: it comes for free, as we keep µ updated
Backtrackability: use the same trick as for BF: update a model µ ,
if satisfiable set µ = µ , otherwise forget µ . When backtracking
don’t change µ
Minimal T -conflicts: seen already
Theory Propagation:
Bound propagation (cheap): if x ≤ c has been asserted, then all
other inactive x ≤ c with c ≤ c are implied (similar for ≥)
Tableau+Bound propagation: use a row x1 = a2x2 + a3x3 + . . . and
bounds on x2, x3, . . . to derive bounds on x1 (similar idea as to find
conflicts)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 17 / 21
54. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
55. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
Since we are on the rationals x < 3 is same as x ≤ (3 − δ), where δ is a
symbolic positive parameter (δ > 0)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
56. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
Since we are on the rationals x < 3 is same as x ≤ (3 − δ), where δ is a
symbolic positive parameter (δ > 0)
We do the following: instead of using Q numbers of form n, we use Qδ
numbers of form (n, k) to be intended as n + kδ
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
57. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
Since we are on the rationals x < 3 is same as x ≤ (3 − δ), where δ is a
symbolic positive parameter (δ > 0)
We do the following: instead of using Q numbers of form n, we use Qδ
numbers of form (n, k) to be intended as n + kδ
Addition in Qδ: (n1, k1) + (n2, k2) = (n1 + n2, k1 + k2)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
58. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
Since we are on the rationals x < 3 is same as x ≤ (3 − δ), where δ is a
symbolic positive parameter (δ > 0)
We do the following: instead of using Q numbers of form n, we use Qδ
numbers of form (n, k) to be intended as n + kδ
Addition in Qδ: (n1, k1) + (n2, k2) = (n1 + n2, k1 + k2)
Scalar multiplication in Qδ: c(n, k) = (cn, ck)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
59. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
Since we are on the rationals x < 3 is same as x ≤ (3 − δ), where δ is a
symbolic positive parameter (δ > 0)
We do the following: instead of using Q numbers of form n, we use Qδ
numbers of form (n, k) to be intended as n + kδ
Addition in Qδ: (n1, k1) + (n2, k2) = (n1 + n2, k1 + k2)
Scalar multiplication in Qδ: c(n, k) = (cn, ck)
Comparison in Qδ: (n1, k1) ≤ (n2, k2) iff (n1 < n2) or (n1 = n2 and
k1 ≤ k2)
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
60. Strict inequalities
So far we have used bounds like x ≤ 3, but never strict ones like x < 3
Since we are on the rationals x < 3 is same as x ≤ (3 − δ), where δ is a
symbolic positive parameter (δ > 0)
We do the following: instead of using Q numbers of form n, we use Qδ
numbers of form (n, k) to be intended as n + kδ
Addition in Qδ: (n1, k1) + (n2, k2) = (n1 + n2, k1 + k2)
Scalar multiplication in Qδ: c(n, k) = (cn, ck)
Comparison in Qδ: (n1, k1) ≤ (n2, k2) iff (n1 < n2) or (n1 = n2 and
k1 ≤ k2)
If constraints are satisfiable, it is always possible to compute a rational
value for δ to translate Qδ numbers into Q numbers
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 18 / 21
62. Solving LIA with LRA
The Simplex can be used also to reason (in a complete way) about the
integers (LIA), e.g., using known techniques in linear programming
Given a set of LIA constraints S
If S is unsatisfiable on LRA1 then it is also unsatisfiable on LIA
If S is satisfiable on LRA, then we have to check if there is an
integer solution
1
This means that we allow variables to assume values in Q instead of Z.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 20 / 21
63. Solving LIA with LRA
The Simplex can be used also to reason (in a complete way) about the
integers (LIA), e.g., using known techniques in linear programming
Given a set of LIA constraints S
If S is unsatisfiable on LRA1 then it is also unsatisfiable on LIA
If S is satisfiable on LRA, then we have to check if there is an
integer solution
For the latter case the convex polytope on Q is explored sistematically.
However, in general, search is necessary: LIA is NP-Complete, like
SAT
in SAT we split a and ¬a, in LIA we split x ≤ c and x ≥ c + 1
in SAT we learn clauses, in LIA we learn new tableau rows (new
constraints)
1
This means that we allow variables to assume values in Q instead of Z.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 20 / 21
64. Solving LIA with LRA
The Simplex can be used also to reason (in a complete way) about the
integers (LIA), e.g., using known techniques in linear programming
Given a set of LIA constraints S
If S is unsatisfiable on LRA1 then it is also unsatisfiable on LIA
If S is satisfiable on LRA, then we have to check if there is an
integer solution
For the latter case the convex polytope on Q is explored sistematically.
However, in general, search is necessary: LIA is NP-Complete, like
SAT
in SAT we split a and ¬a, in LIA we split x ≤ c and x ≥ c + 1
in SAT we learn clauses, in LIA we learn new tableau rows (new
constraints)
When on the integers, δ is set to 1 (Qδ numbers are not used)
1
This means that we allow variables to assume values in Q instead of Z.
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 20 / 21
65. Exercizes
1 Show that the T -conflicts generated by the Simplex are minimal
2 Suppose that (0, 1) ≤ x ≤ (1, −1). Compute the biggest possible
value for δ
3 Find the candidate for pivoting in this row (for simplicity we use
normal numbers)
x1 = 3x2 − 9x3 − 7x4
given these bounds −∞ ≤ x1 ≤ 1, 0 ≤ x2 ≤ ∞, −∞ ≤ x3 ≤ −1,
1 ≤ x4 ≤ 2 and this assignment
µ = {x1 → 2, x2 → 0, x3 → −1, x4 → 1}
4 Using the row of previous exercize, change the bounds so that the
only candidate for pivoting becomes x2
5 Now change the bounds so that no pivoting is possible. Compute
the conflict
R. Bruttomesso (SMT) T -solver for LRA 24 Novembre 2011 21 / 21