Symbolic Computation and Theorem Proving in Program Analysis Laura - - PowerPoint PPT Presentation

symbolic computation and theorem proving in program
SMART_READER_LITE
LIVE PREVIEW

Symbolic Computation and Theorem Proving in Program Analysis Laura - - PowerPoint PPT Presentation

Symbolic Computation and Theorem Proving in Program Analysis Laura Kov acs Chalmers Outline Part 1: Weakest Precondition for Program Analysis and Verification Part 2: Polynomial Invariant Generation (TACAS08, LPAR10) Part 3:


slide-1
SLIDE 1

Symbolic Computation and Theorem Proving in Program Analysis

Laura Kov´ acs

Chalmers

slide-2
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
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
SLIDE 4

Outline

Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions

slide-5
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

  • T(c,d,c′,d′)

c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c, d)

slide-6
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

  • T(c,d,c′,d′)

c := c + 1; d := d + 1 end do {(∀k)(0 ≤ k < N → C[k] = 0)} postcondition B(c′, d′)

slide-7
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

  • T(c,d,c′,d′)

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

  • T(c,d,c′,d′)

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

  • T(c,d,c′,d′)

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

  • T(c,d,c′,d′)

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

  • T(c,d,c′,d′)

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

  • T(c,d,c′,d′)

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
SLIDE 13

Outline

Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions

slide-14
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
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
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
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
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
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
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
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
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
SLIDE 23

Shape of local derivations for A → B

slide-24
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
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
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
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
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
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
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
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
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
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
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
SLIDE 35

Formulas Coloring Reverse Interpolant L : z < 0 ∧ x ≤ z ∧ y ≤ x R : y ≤ 0 ∧ x + y ≥ 0 left: z right:

  • y ≤ x ∧ x < 0

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
SLIDE 36

Symbol Elimination and Interpolation

Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions

slide-37
SLIDE 37

Interpolation Through Colors in Vampire

◮ There are three colors: blue, red and green.

slide-38
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
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
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

  • 1. → A → I;
  • 2. → I → B.
slide-41
SLIDE 41

Interpolation Example in Vampire

fof(fA,axiom, q(f(a)) & ˜q(f(b)) ). fof(fB,conjecture, ?[V]: V != c).

slide-42
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
SLIDE 43

Symbol Elimination and Interpolation

Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions

slide-44
SLIDE 44

Given: a problem (an interpolation problem) Generate: a formula (an interpolant)

  • 1 + a + -a = -1 ∧

∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧

  • (-1 + -1 + a) = -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) ∧

  • a + -1 + a = -1 ∧

∀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
SLIDE 45

Given: a problem (an interpolation problem) Generate: a formula (an interpolant)

  • 1 + a + -a = -1 ∧

∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧

  • (-1 + -1 + a) = -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) ∧

  • a + -1 + a = -1 ∧

∀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

  • r

¬(a ≤ 6) ∧

  • a ≤ -1 ∧

¬(-1 ≤ -a) ∧ a = 3 ∧ 1 ≤ -1 + a ∧ ¬(2 + a ≤ 6) ∧ ¬(-1 + a ≤ 1) ∧ (a = 6 ∨ ¬(b ≤ 6))

slide-46
SLIDE 46

Given: a problem (an interpolation problem) Generate: a formula (an interpolant) which is small

  • 1 + a + -a = -1 ∧

∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧

  • (-1 + -1 + a) = -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) ∧

  • a + -1 + a = -1 ∧

∀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

  • r

¬(a ≤ 6) ∧

  • a ≤ -1 ∧

¬(-1 ≤ -a) ∧ a = 3 ∧ 1 ≤ -1 + a ∧ ¬(2 + a ≤ 6) ∧ ¬(-1 + a ≤ 1) ∧ (a = 6 ∨ ¬(b ≤ 6))

slide-47
SLIDE 47

Given: a problem (an interpolation problem) Generate: a formula (an interpolant) which is small

  • 1 + a + -a = -1 ∧

∀x(¬(x ≤ 5) ∨ -6 + x ≤ -1) ∧

  • (-1 + -1 + a) = -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) ∧

  • a + -1 + a = -1 ∧

∀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

  • r

¬(a ≤ 6) ∧

  • a ≤ -1 ∧

¬(-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
SLIDE 48

How to Make Interpolants Smaller/Nicer?

◮ in size; ◮ in weight; ◮ in the number of quantifiers; ◮ . . .

slide-49
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
SLIDE 50

Extracting Interpolants from Local Proofs

slide-51
SLIDE 51

Extracting Interpolants from Local Proofs

G1 G2 G3 G4

Interpolant: boolean combination of {G1, . . . , G4}

[McMillan05, KV09]

slide-52
SLIDE 52

Extracting Interpolants from Local Proofs

G1 G2 G3 G4

Digest Interpolant: boolean combination of {G1, . . . , G4}

slide-53
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
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
SLIDE 55

How to Make Interpolants Smaller/Nicer?

Task: minimise interpolants = minimise digest

slide-56
SLIDE 56

How to Make Interpolants Smaller/Nicer?

Task: minimise interpolants = minimise digest

Idea: Change the green areas of the local proof

slide-57
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
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
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
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
SLIDE 61

How to Make Interpolants Smaller/Nicer?

R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥

slide-62
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
SLIDE 63

How to Make Interpolants Smaller/Nicer?

R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥

slide-64
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
SLIDE 65

How to Make Interpolants Smaller/Nicer?

R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥

slide-66
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
SLIDE 67

How to Make Interpolants Smaller/Nicer?

R3 R1 G1 G3 B1 G2 G4 G5 G6 R4 G7 ⊥

slide-68
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
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
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
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
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
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
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
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
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

  • ff;

◮ 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
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

  • ff;

◮ 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
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

  • ff;

◮ 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
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

  • ff;

◮ 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
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

  • ff;

◮ 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
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
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
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
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
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
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
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
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
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)

  • min{Gi1,...,Gin }

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
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)

  • min{Gi1,...,Gin }

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
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)

  • min{Gi1,...,Gin }

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

  • f 5;

◮ for 6 examples the size of the interpolant has decreased by a factor

  • f 500.
slide-95
SLIDE 95

Symbol Elimination and Interpolation

Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions

slide-96
SLIDE 96

Summary: Invariant Generation, Interpolation, Symbol Elimination

Given the proof obligation A → B:

  • 1. Run a theorem prover and

eliminate extra symbols;

  • 2. Generate a (reverse)

interpolant from a refutation;

  • 3. Interpolant is a boolean

combination of consequences

  • f symbol-eliminating

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
SLIDE 97

Summary: Invariant Generation, Interpolation, Symbol Elimination

Given the proof obligation A → B:

  • 1. Run a theorem prover and

eliminate extra symbols;

  • 2. Generate a (reverse)

interpolant from a refutation;

  • 3. Interpolant is a boolean

combination of consequences

  • f symbol-eliminating

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
SLIDE 98

End of Session 4

Slides for session 4 ended here . . .