SLIDE 1 Symbolic Computation and Theorem Proving in Program Analysis
Laura Kov´ acs
Chalmers
SLIDE 2
Outline
Part 1: Weakest Precondition for Program Analysis and Verification Part 2: Polynomial Invariant Generation (TACAS’08, LPAR’10) Part 3: Quantified Invariant Generation (FASE’09, MICAI’11) Part 4: Invariants, Interpolants and Symbol Elimination
(CADE’09, POPL ’12, APLAS’12)
SLIDE 3
Part 4: Invariants, Interpolants and Symbol Eliminatio
Symbol Elimination by First-Order Theorem Proving
Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
SLIDE 4
Outline
Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
SLIDE 5 Invariants, Symbol Elimination, and Interpolation
Reachability of B in ONE iteration: A(c, d) ∧ T(c, d, c′, d′) → B(c′, d′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c, d)
SLIDE 6 Invariants, Symbol Elimination, and Interpolation
Reachability of B in ONE iteration: A(c, d) ∧ T(c, d, c′, d′) → B(c′, d′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′)
SLIDE 7 Invariants, Symbol Elimination, and Interpolation
Reachability of B in ONE iteration: A(c, d) ∧ T(c, d, c′, d′) → B(c′, d′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′)
Refutation: A(c, d) ∧ T(c, d, c′, d′) ∧ ¬B(c′, d′)
- The formula is of 2 states (c, d, c′, d′).
- Need a state formula I(c′, d′) such that:
(Jhala and McMillan) A(c, d) ∧ T(c, d, c′, d′) → I(c′, d′) and I(c′, d′) ∧ ¬B(c′, d′) → ⊥
SLIDE 8 Invariants, Symbol Elimination, and Interpolation
Reachability of B in ONE iteration: A(c, d) ∧ T(c, d, c′, d′) → B(c′, d′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′)
Refutation: A(c, d) ∧ T(c, d, c′, d′) ∧ ¬B(c′, d′)
- The formula is of 2 states (c, d, c′, d′).
- Need a state formula I(c′, d′) such that:
(Jhala and McMillan) A(c, d) ∧ T(c, d, c′, d′) → I(c′, d′) and I(c′, d′) ∧ ¬B(c′, d′) → ⊥
SLIDE 9 Invariants, Symbol Elimination, and Interpolation
Reachability of B in ONE iteration: A(c, d) ∧ T(c, d, c′, d′) → B(c′, d′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′)
Refutation: A(c, d) ∧ T(c, d, c′, d′) ∧ ¬B(c′, d′)
- The formula is of 2 states (c, d, c′, d′).
- Need a state formula I(c′, d′) such that:
(Jhala and McMillan) A(c, d) ∧ T(c, d, c′, d′) → I(c′, d′) and I(c′, d′) ∧ ¬B(c′, d′) → ⊥ Taks: Compute interpolant I(c′, d′) by eliminating symbols c, d.
SLIDE 10 Invariants, Symbol Elimination, and Interpolation
Reachability of B in ONE iteration: A(c, d) ∧ T(c, d, c′, d′) → B(c′, d′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′) I(c′, d′) ≡ 0 < c′ = 1 ∧ C[0] = D[0] I(c′′, d′′) ≡ 0 < c′′ = 2 ∧ C[0] = D[0] ∧ C[1] = D[1]
Taks: Compute interpolant I(c′, d′) by eliminating symbols c, d.
SLIDE 11 Invariants, Symbol Elimination, and Interpolation
Reachability of B in TWO iterations: A(c, d)∧T(c, d, c′, d′)∧T(c′, d′, c′′, d′′)→B(c′′, d′′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′) I(c′, d′) ≡ 0 < c′ = 1 ∧ C[0] = D[0] I(c′′, d′′) ≡ 0 < c′′ = 2 ∧ C[0] = D[0] ∧ C[1] = D[1]
Taks: Compute interpolant I(c′′, d′′) by eliminating symbols c, d, c′, d′.
SLIDE 12 Invariants, Symbol Elimination, and Interpolation
Reachability of B in TWO iterations: A(c, d)∧T(c, d, c′, d′)∧T(c′, d′, c′′, d′′)→B(c′′, d′′)
{c = d = 0 ∧ N > 0 ∧ (∀k) (0 ≤ k < N → D[k] = 0)} precondition A(c, d) while (c < N) do C[c] := D[d];
c < N ∧ C[c] = D[d] ∧ c′ = c + 1 ∧ d′ = d + 1 ∧ c′ ≥ N
c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′) I(c′, d′) ≡ (∀k)0 ≤ k < c′ → C[k] = D[k] I(c′′, d′′) ≡ (∀k)0 ≤ k < c′′ → C[k] = D[k]
Taks: Compute interpolant I(c′′, d′′) implying invariant in any state.
SLIDE 13
Outline
Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
SLIDE 14 Symbol Elimination and Interpolation
What is an Interpolant? Computing Interpolants
◮ Local Derivations ◮ Symbol Eliminations ◮ Building Interpolants from Proof
Summary: Invariants, Symbol Elimination, Interpolants
SLIDE 15 Notation
◮ First-order predicate logic with equality. ◮ ⊤: always true,
⊥: always false.
◮ ∀A: universal closure of A. ◮ Symbols:
◮ predicate symbols; ◮ function symbols; ◮ constants.
Equality is part of the language → equality is not a symbol.
◮ LA: the language of A: the set of all formulas built from the
symbols occurring in A.
SLIDE 16
What is an Interpolant?
Let A, B be closed formulas such that A → B.
Theorem (Craig’s Interpolation Theorem)
There exists a closed formula I ∈ LA ∩ LB such that A → I and I → B.
I is an interpolant of A and B. Note: if A and B are ground, they also have a ground interpolant.
SLIDE 17
What is an Interpolant?
Let A, B be closed formulas such that A → B.
Theorem (Craig’s Interpolation Theorem)
There exists a closed formula I ∈ LA ∩ LB such that A → I and I → B.
I is an interpolant of A and B. Reverse interpolant of A and B: any formula I such that A → I and I, ¬B → ⊥.
SLIDE 18 Interpolation with Theories
◮ Theory T: any set of closed formulas. ◮ C1, . . . , Cn →T C means that the formula C1 ∧ . . . ∧ C1 → C holds in all
models of T.
◮ Interpreted symbols: symbols occurring in T. ◮ Uninterpreted symbols: all other symbols.
Theorem
Let A, B be formulas and let A →T B. Then there exists a formula I such that
- 1. A →T I and I → B;
- 2. every uninterpreted symbol of I occurs both in A and B;
- 3. every interpreted symbol of I occurs in B.
Likewise, there exists a formula I such that 1. A → I and I →T B; 2. every uninterpreted symbol of I occurs both in A and B; 3. every interpreted symbol of I occurs in A.
SLIDE 19 Interpolation with Theories
◮ Theory T: any set of closed formulas. ◮ C1, . . . , Cn →T C means that the formula C1 ∧ . . . ∧ C1 → C holds in all
models of T.
◮ Interpreted symbols: symbols occurring in T. ◮ Uninterpreted symbols: all other symbols.
Theorem
Let A, B be formulas and let A →T B. Then there exists a formula I such that
- 1. A →T I and I → B;
- 2. every uninterpreted symbol of I occurs both in A and B;
- 3. every interpreted symbol of I occurs in B.
Likewise, there exists a formula I such that 1. A → I and I →T B; 2. every uninterpreted symbol of I occurs both in A and B; 3. every interpreted symbol of I occurs in A.
SLIDE 20 Computing Interpolants using Inference Systems
◮ Inference Rule:
A1 . . . An A
◮ Inference system: a set of inference rules. ◮ Axiom: an inference rule with 0 premises. ◮ Derivation of A: tree with the root A built from inferences.
SLIDE 21 Interpolants and Local AB-Derivations
AB-derivation
Let L = LA ∩ LB. A derivation Π is an AB-derivation if (AB1) For every leaf C of Π one of following conditions holds:
- 1. A →T ∀C and C ∈ LA or
- 2. B →T ∀C and C ∈ LB.
(AB2) For every inference C1 . . . Cn C
- f Π we have ∀C1, . . . , ∀Cn →T ∀C.
We will refer to property (AB2) as soundness.
SLIDE 22
Interpolants and Local AB-Derivations
C1 . . . Cn C This inference is local if the following two conditions hold: (L1) Either {C1, . . . , Cn, C} ⊆ LA or {C1, . . . , Cn, C} ⊆ LB. (L2) If all of the formulas C1, . . . , Cn are colorless, then C is colorless, too. A derivation is called local if so is every inference of this derivation.
SLIDE 23
Shape of local derivations for A → B
SLIDE 24 Local Derivations: Example A → B
[demo]
◮ A := ∀x(x = c) ◮ B := a = b ◮ Universal interpolant I: ∀x∀y(x = y)
A local refutation of in the superposition calculus: x = c y = c x = y a = b y = b ⊥
SLIDE 25 Local Derivations: Example A → B
[demo]
◮ A := ∀x(x = c) ◮ B := a = b ◮ Universal interpolant I: ∀x∀y(x = y)
A local refutation of in the superposition calculus: x = c y = c x = y a = b y = b ⊥
SLIDE 26 Interpolants and Symbol Eliminating Inference
◮ At least one of the premises colored. ◮ The conclusion is not colored.
x = c y = c x = y a = b y = b ⊥
Interpolant ∀x∀y(x = y): conclusion of a symbol-eliminating inference.
SLIDE 27 Interpolants and Symbol Eliminating Inference
◮ At least one of the premises colored. ◮ The conclusion is not colored.
x = c y = c x = y a = b y = b ⊥
Interpolant ∀x∀y(x = y): conclusion of a symbol-eliminating inference.
SLIDE 28 Extracting Interpolants from Local Proofs
Theorem (CADE’09)
Let Π be a closed local AB-refutation. Then:
◮ A reverse interpolant I of A and B can be extracted from Π in linear time. ◮ I is ground if all formulas in Π are ground. ◮ I is a boolean combination of conclusions of symbol-eliminating
inferences of Π.
NOTE:
◮ No restriction on the calculus (only soundness required)
– can be used with theories.
◮ Can generate interpolants in theories where no good interpolation
algorithms exist.
◮ Shift of interest: what matters are symbol-eliminating inferences.
SLIDE 29 Extracting Interpolants from Local Proofs
Theorem (CADE’09)
Let Π be a closed local AB-refutation. Then:
◮ A reverse interpolant I of A and B can be extracted from Π in linear time. ◮ I is ground if all formulas in Π are ground. ◮ I is a boolean combination of conclusions of symbol-eliminating
inferences of Π.
NOTE:
◮ No restriction on the calculus (only soundness required)
– can be used with theories.
◮ Can generate interpolants in theories where no good interpolation
algorithms exist.
◮ Shift of interest: what matters are symbol-eliminating inferences.
SLIDE 30 Extracting Interpolants from Local Proofs
Theorem (CADE’09)
Let Π be a closed local AB-refutation. Then:
◮ A reverse interpolant I of A and B can be extracted from Π in linear time. ◮ I is ground if all formulas in Π are ground. ◮ I is a boolean combination of conclusions of symbol-eliminating
inferences of Π.
NOTE:
◮ No restriction on the calculus (only soundness required)
– can be used with theories.
◮ Can generate interpolants in theories where no good interpolation
algorithms exist.
◮ Shift of interest: what matters are symbol-eliminating inferences.
SLIDE 31 Building Interpolants from Proofs
◮ Problem: generation of proofs giving interpolants.
◮ Idea 1: look for local refutations only; ◮ Idea 2: find calculi that guarantee that local proofs exist. ◮ LASCA: Superposition + Linear Arithmetic; ◮ Separating orderings (colored symbols are the greatest).
Theorem (CADE’09)
If ≻ is separating, then every AB-derivation in LASCA is local. First-order interpolation implemented in Vampire.
SLIDE 32 Building Interpolants from Proofs
◮ Problem: generation of proofs giving interpolants.
◮ Idea 1: look for local refutations only; ◮ Idea 2: find calculi that guarantee that local proofs exist. ◮ LASCA: Superposition + Linear Arithmetic; ◮ Separating orderings (colored symbols are the greatest).
Theorem (CADE’09)
If ≻ is separating, then every AB-derivation in LASCA is local. First-order interpolation implemented in Vampire.
SLIDE 33 Building Interpolants from Proofs
◮ Problem: generation of proofs giving interpolants.
◮ Idea 1: look for local refutations only; ◮ Idea 2: find calculi that guarantee that local proofs exist. ◮ LASCA: Superposition + Linear Arithmetic; ◮ Separating orderings (colored symbols are the greatest).
Theorem (CADE’09)
If ≻ is separating, then every AB-derivation in LASCA is local. First-order interpolation implemented in Vampire.
SLIDE 34 Building Interpolants from Proofs
◮ Problem: generation of proofs giving interpolants.
◮ Idea 1: look for local refutations only; ◮ Idea 2: find calculi that guarantee that local proofs exist. ◮ LASCA: Superposition + Linear Arithmetic; ◮ Separating orderings (colored symbols are the greatest).
Theorem (CADE’09)
If ≻ is separating, then every AB-derivation in LASCA is local. First-order interpolation implemented in Vampire.
SLIDE 35 Formulas Coloring Reverse Interpolant L : z < 0 ∧ x ≤ z ∧ y ≤ x R : y ≤ 0 ∧ x + y ≥ 0 left: z right:
L : g(a) = c + 5 ∧ f(g(a)) ≥ c + 1 R : h(b) = d + 4 ∧ d = c + 1 ∧ f(h(b)) < c + 1 left: g, a right: h, b c + 1 ≤ f(c + 5) L : p ≤ c ∧ c ≤ q ∧ f(c) = 1 R : q ≤ d ∧ d ≤ p ∧ f(d) = 0 left: c right: d p ≤ q ∧ (q > p ∨ f(p) = 1) L : f(x1) + x2 = x3 ∧ f(y1) + y2 = y3 ∧ y1 ≤ x1 R : x2 = g(b) ∧ y2 = g(b) ∧ x1 ≤ y1 ∧ x3 < y3 left: f right: g, b x1 > y1 ∨ x2 = y2 ∨ x3 = y3 L : c2 = car(c1) ∧ c3 = cdr(c1) ∧ ¬(atom(c1)) R : c1 = cons(c2, c3) left: car, cons right:
- ¬atom(c1) ∧ c1 = cons(c2, c3)
L : Q(f(a))∧ = Q(f(b)) R : f(V) = c left: Q, a, b right: c ∃x, y : f(x) = f(y) L : a = c ∧ f(c) = a R : c = b∧ = (b = f(c)) left: a right: b c = f(c) L : True ∧ a′[x′] = y ∧ x′ = x ∧ y′ = y + 1 ∧ z′ = x′ R : ¬(y′ = a′[z′] + 1) left: x, y right:
- 1 + a′[x′] = y′ ∧ x′ = z′
Table : Interpolation with Vampire, within 1 second time limit.
SLIDE 36
Symbol Elimination and Interpolation
Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
SLIDE 37 Interpolation Through Colors in Vampire
◮ There are three colors: blue, red and green.
SLIDE 38 Interpolation Through Colors in Vampire
◮ There are three colors: blue, red and green. ◮ Each symbol (function or predicate) is colored in exactly one of
these colors.
SLIDE 39 Interpolation Through Colors in Vampire
◮ There are three colors: blue, red and green. ◮ Each symbol (function or predicate) is colored in exactly one of
these colors.
◮ We have two formulas: A and B. ◮ Each symbol in A is either blue or green. ◮ Each symbol in B is either red or green.
SLIDE 40 Interpolation Through Colors in Vampire
◮ There are three colors: blue, red and green. ◮ Each symbol (function or predicate) is colored in exactly one of
these colors.
◮ We have two formulas: A and B. ◮ Each symbol in A is either blue or green. ◮ Each symbol in B is either red or green. ◮ We know that → A → B. ◮ Our goal is to find a green formula I such that
SLIDE 41
Interpolation Example in Vampire
fof(fA,axiom, q(f(a)) & ˜q(f(b)) ). fof(fB,conjecture, ?[V]: V != c).
SLIDE 42
Interpolation Example in Vampire
% request to generate an interpolant vampire(option,show_interpolant,on). % symbol coloring vampire(symbol,predicate,q,1,left). vampire(symbol,function,f,1,left). vampire(symbol,function,a,0,left). vampire(symbol,function,b,0,left). vampire(symbol,function,c,0,right). % formula L vampire(left_formula). fof(fA,axiom, q(f(a)) & ˜q(f(b)) ). vampire(end_formula). % formula R vampire(right_formula). fof(fB,conjecture, ?[V]: V != c). vampire(end_formula).
SLIDE 43
Symbol Elimination and Interpolation
Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
SLIDE 44 Given: a problem (an interpolation problem) Generate: a formula (an interpolant)
∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧
∀x((1 ≤ x + --(-1 + a) ∨ ¬(-1 ≤ x))) ∧ (a ≤ 6 ∨ 1 ≤ a + -1) ∧ ∀x(¬(-1 ≤ x) ∨ ¬(x ≤ -2)) ∧ ∀x(-1 ≤ x + -a ∨ ¬(-1 + a ≤ x)) ∧ ∀x(-1 + x = 1 + -2 + x) ∧
∀x(¬(--(-1 + a) ≤ x) ∨ 1 ≤ x + -1) ∧ ∀x((¬(x ≤ 4) ∨ -5 + x ≤ -1)) ∧ ∀x(x + -3 ≤ -1 ∨ ¬(x ≤ 2)) ∧ ∀x(¬(x ≤ 3) ∨ -4 + x ≤ -1) ∧ ∀x(x + -a ≤ -1 ∨ ¬(x ≤ -1 + a)) ∧ ∀x(-1 + x = -1 + -1 + a + -(-1 + a) + x) ∧ 6 ≤ b
SLIDE 45 Given: a problem (an interpolation problem) Generate: a formula (an interpolant)
∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧
∀x((1 ≤ x + --(-1 + a) ∨ ¬(-1 ≤ x))) ∧ (a ≤ 6 ∨ 1 ≤ a + -1) ∧ ∀x(¬(-1 ≤ x) ∨ ¬(x ≤ -2)) ∧ ∀x(-1 ≤ x + -a ∨ ¬(-1 + a ≤ x)) ∧ ∀x(-1 + x = 1 + -2 + x) ∧
∀x(¬(--(-1 + a) ≤ x) ∨ 1 ≤ x + -1) ∧ ∀x((¬(x ≤ 4) ∨ -5 + x ≤ -1)) ∧ ∀x(x + -3 ≤ -1 ∨ ¬(x ≤ 2)) ∧ ∀x(¬(x ≤ 3) ∨ -4 + x ≤ -1) ∧ ∀x(x + -a ≤ -1 ∨ ¬(x ≤ -1 + a)) ∧ ∀x(-1 + x = -1 + -1 + a + -(-1 + a) + x) ∧ 6 ≤ b
¬(a ≤ 6) ∧
¬(-1 ≤ -a) ∧ a = 3 ∧ 1 ≤ -1 + a ∧ ¬(2 + a ≤ 6) ∧ ¬(-1 + a ≤ 1) ∧ (a = 6 ∨ ¬(b ≤ 6))
SLIDE 46 Given: a problem (an interpolation problem) Generate: a formula (an interpolant) which is small
∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧
∀x((1 ≤ x + --(-1 + a) ∨ ¬(-1 ≤ x))) ∧ (a ≤ 6 ∨ 1 ≤ a + -1) ∧ ∀x(¬(-1 ≤ x) ∨ ¬(x ≤ -2)) ∧ ∀x(-1 ≤ x + -a ∨ ¬(-1 + a ≤ x)) ∧ ∀x(-1 + x = 1 + -2 + x) ∧
∀x(¬(--(-1 + a) ≤ x) ∨ 1 ≤ x + -1) ∧ ∀x((¬(x ≤ 4) ∨ -5 + x ≤ -1)) ∧ ∀x(x + -3 ≤ -1 ∨ ¬(x ≤ 2)) ∧ ∀x(¬(x ≤ 3) ∨ -4 + x ≤ -1) ∧ ∀x(x + -a ≤ -1 ∨ ¬(x ≤ -1 + a)) ∧ ∀x(-1 + x = -1 + -1 + a + -(-1 + a) + x) ∧ 6 ≤ b
¬(a ≤ 6) ∧
¬(-1 ≤ -a) ∧ a = 3 ∧ 1 ≤ -1 + a ∧ ¬(2 + a ≤ 6) ∧ ¬(-1 + a ≤ 1) ∧ (a = 6 ∨ ¬(b ≤ 6))
SLIDE 47 Given: a problem (an interpolation problem) Generate: a formula (an interpolant) which is small
∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧
∀x((1 ≤ x + --(-1 + a) ∨ ¬(-1 ≤ x))) ∧ (a ≤ 6 ∨ 1 ≤ a + -1) ∧ ∀x(¬(-1 ≤ x) ∨ ¬(x ≤ -2)) ∧ ∀x(-1 ≤ x + -a ∨ ¬(-1 + a ≤ x)) ∧ ∀x(-1 + x = 1 + -2 + x) ∧
∀x(¬(--(-1 + a) ≤ x) ∨ 1 ≤ x + -1) ∧ ∀x((¬(x ≤ 4) ∨ -5 + x ≤ -1)) ∧ ∀x(x + -3 ≤ -1 ∨ ¬(x ≤ 2)) ∧ ∀x(¬(x ≤ 3) ∨ -4 + x ≤ -1) ∧ ∀x(x + -a ≤ -1 ∨ ¬(x ≤ -1 + a)) ∧ ∀x(-1 + x = -1 + -1 + a + -(-1 + a) + x) ∧ 6 ≤ b
¬(a ≤ 6) ∧
¬(-1 ≤ -a) ∧ a = 3 ∧ 1 ≤ -1 + a ∧ ¬(2 + a ≤ 6) ∧ ¬(-1 + a ≤ 1) ∧ (a = 6 ∨ ¬(b ≤ 6)) What is a good interpolant?
◮ logical strength [Jhala07, D’Silva09, McMillan08]; ◮ small size [Kroening10, Brillout11, Griggio11].
SLIDE 48 How to Make Interpolants Smaller/Nicer?
◮ in size; ◮ in weight; ◮ in the number of quantifiers; ◮ . . .
SLIDE 49 How to Make Interpolants Smaller/Nicer?
◮ in size; ◮ in weight; ◮ in the number of quantifiers; ◮ . . .
Revised Interpolation Problem:
Given → R → B, find a green formula I: → R → I; → I → B; I is small.
SLIDE 50
Extracting Interpolants from Local Proofs
SLIDE 51 Extracting Interpolants from Local Proofs
G1 G2 G3 G4
Interpolant: boolean combination of {G1, . . . , G4}
[McMillan05, KV09]
SLIDE 52 Extracting Interpolants from Local Proofs
G1 G2 G3 G4
Digest Interpolant: boolean combination of {G1, . . . , G4}
SLIDE 53 Extracting Interpolants from Local Proofs
G is in the digest:
- comes from a red block
- followed by a blue or green block
G1 G2 G3 G4
Digest Interpolant: boolean combination of {G1, . . . , G4}
SLIDE 54 Extracting Interpolants from Local Proofs
G is in the digest:
- comes from a red block
- followed by a blue or green block
- r
- comes from a blue block
- followed by a red
G1 G2 G3 G4
Digest Interpolant: boolean combination of {G1, . . . , G4}
SLIDE 55
How to Make Interpolants Smaller/Nicer?
Task: minimise interpolants = minimise digest
SLIDE 56
How to Make Interpolants Smaller/Nicer?
Task: minimise interpolants = minimise digest
Idea: Change the green areas of the local proof
SLIDE 57 How to Make Interpolants Smaller/Nicer?
Task: minimise interpolants = minimise digest
Idea: Change the green areas of the local proof Slicing off formulas
A1 · · · An An+1 · · · Am A A0
− → slicing off A
A1 · · · An An+1 · · · Am A0
SLIDE 58 How to Make Interpolants Smaller/Nicer?
Task: minimise interpolants = minimise digest
Idea: Change the green areas of the local proof Slicing off formulas
A1 · · · An An+1 · · · Am A A0
− → slicing off A
A1 · · · An An+1 · · · Am A0 If A is green: Green slicing
SLIDE 59 How to Make Interpolants Smaller/Nicer?
Task: minimise interpolants = minimise digest
Idea: Change the green areas of the local proof Slicing off formulas
B0 R0 G1 G0
− → slicing off G1
B0 R0 G0 If A is green: Green slicing
SLIDE 60 How to Make Interpolants Smaller/Nicer?
Task: minimise interpolants = minimise digest
Idea: Change the green areas of the local proof, but preserve locality! Slicing off formulas
B0 R0 G1 G0
− → slicing off G1
B0 R0 G0 If A is green: Green slicing
SLIDE 61
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥
SLIDE 62
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥ Digest: {G4, G7} Reverse interpolant: G4 → G7
SLIDE 63
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥
SLIDE 64
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥ Digest: {G5, G7} Reverse interpolant: G5 → G7
SLIDE 65
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥
SLIDE 66
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥ Digest: {G6, G7} Reverse interpolant: G6 → G7
SLIDE 67
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥
SLIDE 68
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥ Digest: {G6} Reverse interpolant: ¬G6
SLIDE 69
How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥ Note that the interpolant has changed from G4 → G7 to ¬G6.
SLIDE 70 How to Make Interpolants Smaller/Nicer?
R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥ Note that the interpolant has changed from G4 → G7 to ¬G6.
◮ There is no obvious logical relation between G4 → G7 and ¬G6,
for example none of these formulas implies the other one;
◮ These formulas may even have no common atoms or no
common symbols.
SLIDE 71
How to Make Interpolants Smaller/Nicer?
If green slicing gives us very different interpolants, we can use it for finding small interpolants. Problem: if the proof contains n green formulas, the number of possible different slicing off transformations is 2n.
SLIDE 72
How to Make Interpolants Smaller/Nicer?
If green slicing gives us very different interpolants, we can use it for finding small interpolants. Problem: if the proof contains n green formulas, the number of possible different slicing off transformations is 2n.
SLIDE 73 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
SLIDE 74 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3
SLIDE 75 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 G3, and at most one of G1, G2 can be sliced off.
SLIDE 76 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Some predicates on green for- mulas:
◮ sliced(G): G was sliced
◮ red(G): the trace of G
contains a red formula;
◮ blue(G): the trace of G
contains a blue formula;
◮ green(G): the trace of G
contains only green formulas;
◮ digest(G): G belongs to
the digest.
SLIDE 77 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Some predicates on green for- mulas:
◮ sliced(G): G was sliced
◮ red(G): the trace of G
contains a red formula;
◮ blue(G): the trace of G
contains a blue formula;
◮ green(G): the trace of G
contains only green formulas;
◮ digest(G): G belongs to
the digest. ¬sliced(G1) → Green(G1) sliced(G1) → red(G1)
SLIDE 78 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Some predicates on green for- mulas:
◮ sliced(G): G was sliced
◮ red(G): the trace of G
contains a red formula;
◮ blue(G): the trace of G
contains a blue formula;
◮ green(G): the trace of G
contains only green formulas;
◮ digest(G): G belongs to
the digest. ¬sliced(G3) → Green(G3) sliced(G3) → (Green(G3) ↔ Green(G1) ∧ Green(G2)) sliced(G3) → (red(G3) ↔ red(G1) ∨ red(G2)) sliced(G3) → (blue(G3) ↔ blue(G1) ∨ blue(G2))
SLIDE 79 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Some predicates on green for- mulas:
◮ sliced(G): G was sliced
◮ red(G): the trace of G
contains a red formula;
◮ blue(G): the trace of G
contains a blue formula;
◮ green(G): the trace of G
contains only green formulas;
◮ digest(G): G belongs to
the digest. digest(G1) → ¬sliced(G1)
SLIDE 80 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Some predicates on green for- mulas:
◮ sliced(G): G was sliced
◮ red(G): the trace of G
contains a red formula;
◮ blue(G): the trace of G
contains a blue formula;
◮ green(G): the trace of G
contains only green formulas;
◮ digest(G): G belongs to
the digest. ¬sliced(G1) → Green(G1) sliced(G1) → red(G1) ¬sliced(G3) → Green(G3) sliced(G3) → (Green(G3) ↔ Green(G1) ∧ Green(G2)) sliced(G3) → (red(G3) ↔ red(G1) ∨ red(G2)) sliced(G3) → (blue(G3) ↔ blue(G1) ∨ blue(G2)) digest(G1) → ¬sliced(G1) · · ·
SLIDE 81 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Express digest(G)
SLIDE 82 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Express digest(G) by considering the possibilities:
◮ G comes from a
red/ blue/green formula
◮ G is followed by a
red/ blue/green formula
SLIDE 83 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Express digest(G) by considering the possibilities:
◮ G comes from a
red/ blue/green formula
rc(G)/bc(G)
◮ G is followed by a
red/ blue/green formula
bf(G)/rf(G)
SLIDE 84 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Express digest(G) by considering the possibilities:
◮ G comes from a
red/ blue/green formula
rc(G)/bc(G)
◮ G is followed by a
red/ blue/green formula
bf(G)/rf(G)
digest(G3) ↔ (rc(G3) ∧ rf(G3)) ∨ (bc(G3) ∧ bf(G3)) rc(G3) ↔ (¬sliced(G3) ∧ (red(G1) ∨ red(G2))
SLIDE 85 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Express digest(G) by considering the possibilities:
◮ G comes from a
red/ blue/green formula
rc(G)/bc(G)
◮ G is followed by a
red/ blue/green formula
bf(G)/rf(G)
¬sliced(G1) → Green(G1) sliced(G1) → red(G1) ¬sliced(G3) → Green(G3) sliced(G3) → (Green(G3) ↔ Green(G1) ∧ Green(G2)) sliced(G3) → (red(G3) ↔ red(G1) ∨ red(G2)) sliced(G3) → (blue(G3) ↔ blue(G1) ∨ blue(G2)) digest(G1) → ¬sliced(G1) digest(G3) ↔ (rc(G3) ∧ rf(G3)) ∨ (bc(G3) ∧ bf(G3)) rc(G3) ↔ (¬sliced(G3) ∧ (red(G1) ∨ red(G2)) · · ·
SLIDE 86 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT ◮ solutions encode all slicing off transformations
R G1 B G2 G3 Express digest(G) by considering the possibilities:
◮ G comes from a
red/ blue/green formula
rc(G)/bc(G)
◮ G is followed by a
red/ blue/green formula
bf(G)/rf(G)
¬sliced(G1) → Green(G1) sliced(G1) → red(G1) ¬sliced(G3) → Green(G3) sliced(G3) → (Green(G3) ↔ Green(G1) ∧ Green(G2)) sliced(G3) → (red(G3) ↔ red(G1) ∨ red(G2)) sliced(G3) → (blue(G3) ↔ blue(G1) ∨ blue(G2)) digest(G1) → ¬sliced(G1) digest(G3) ↔ (rc(G3) ∧ rf(G3)) ∨ (bc(G3) ∧ bf(G3)) rc(G3) ↔ (¬sliced(G3) ∧ (red(G1) ∨ red(G2)) · · ·
SLIDE 87 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT; ◮ solutions encode all slicing off transformations; ◮ compute small interpolants: smallest digest of green formulas;
min{Gi1,...,Gin }
Gi
digest(Gi)
- ◮ use a pseudo-boolean optimisation tool or an SMT solver to
minimise interpolants;
◮ minimising interpolants is an NP-complete problem.
SLIDE 88 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT; ◮ solutions encode all slicing off transformations; ◮ compute small interpolants: smallest digest of green formulas;
min{Gi1,...,Gin }
Gi
digest(Gi)
- ◮ use a pseudo-boolean optimisation tool or an SMT solver to
minimise interpolants;
◮ minimising interpolants is an NP-complete problem.
SLIDE 89 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT; ◮ solutions encode all slicing off transformations; ◮ compute small interpolants: smallest digest of green formulas;
min{Gi1,...,Gin }
Gi
digest(Gi)
Gi
quantifier number(Gi) digest(Gi)
- ◮ use a pseudo-boolean optimisation tool or an SMT solver to
minimise interpolants;
◮ minimising interpolants is an NP-complete problem.
SLIDE 90 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT; ◮ solutions encode all slicing off transformations; ◮ compute small interpolants: smallest digest of green formulas;
min{Gi1,...,Gin }
Gi
digest(Gi)
Gi
quantifier number(Gi) digest(Gi)
- ◮ use a pseudo-boolean optimisation tool or an SMT solver to
minimise interpolants;
◮ minimising interpolants is an NP-complete problem.
SLIDE 91 How to Make Interpolants Smaller/Nicer?
Solution:
◮ encode all sequences of transformations as an instance of SAT; ◮ solutions encode all slicing off transformations; ◮ compute small interpolants: smallest digest of green formulas;
min{Gi1,...,Gin }
Gi
digest(Gi)
Gi
quantifier number(Gi) digest(Gi)
- ◮ use a pseudo-boolean optimisation tool or an SMT solver to
minimise interpolants;
◮ minimising interpolants is an NP-complete problem.
SLIDE 92 Experiments with Minimising Interpolants
◮ Experimental results:
◮ 9632 first-order examples from the TPTP library:
for example, for 2000 problems the size of the interpolants became 20-49 times smaller;
◮ 4347 SMT examples: ◮ we used Z3 for proving SMT examples; ◮ Z3 proofs were localised in Vampire; ◮ minimal interpolants were generated for 2123 SMT examples.
SLIDE 93 Experiments with Minimising Interpolants
◮ Experimental results:
◮ 9632 first-order examples from the TPTP library:
for example, for 2000 problems the size of the interpolants became 20-49 times smaller;
◮ 4347 SMT examples: ◮ we used Z3 for proving SMT examples; ◮ Z3 proofs were localised in Vampire; ◮ minimal interpolants were generated for 2123 SMT examples.
SLIDE 94 Experiments with Minimising Interpolants
◮ More realistic benchmarks:
◮ 4048 problems coming from CPAchecker; ◮ we used Vampire to generate local proofs; ◮ minimal interpolants were generated for 1903 CPAchecker
examples:
◮ for 296 examples the size of the interpolant has decreased by a factor
◮ for 6 examples the size of the interpolant has decreased by a factor
SLIDE 95
Symbol Elimination and Interpolation
Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
SLIDE 96 Summary: Invariant Generation, Interpolation, Symbol Elimination
Given the proof obligation A → B:
- 1. Run a theorem prover and
eliminate extra symbols;
interpolant from a refutation;
- 3. Interpolant is a boolean
combination of consequences
inferences. Given a loop:
- 1. Express loop properties in a
language containing extra symbols;
- 2. Every logical consequence of these
properties is a valid loop property, but not an invariant;
- 3. Run a theorem prover for eliminating
extra symbols;
- 4. Every derived formula in the language
- f the loop is a loop invariant;
- 5. Invariants are consequences of
symbol-eliminating inferences.
SLIDE 97 Summary: Invariant Generation, Interpolation, Symbol Elimination
Given the proof obligation A → B:
- 1. Run a theorem prover and
eliminate extra symbols;
interpolant from a refutation;
- 3. Interpolant is a boolean
combination of consequences
inferences. Given a loop:
- 1. Express loop properties in a
language containing extra symbols;
- 2. Every logical consequence of these
properties is a valid loop property, but not an invariant;
- 3. Run a theorem prover for eliminating
extra symbols;
- 4. Every derived formula in the language
- f the loop is a loop invariant;
- 5. Invariants are consequences of
symbol-eliminating inferences.
SLIDE 98
End of Session 4
Slides for session 4 ended here . . .