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 (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)
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
Outline Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } postcondition B ( c , d )
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) }
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } 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 ′ ) → ⊥
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } 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 ′ ) → ⊥
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } 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 .
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } 0 < c ′ = 1 ∧ C [ 0 ] = D [ 0 ] I ( c ′ , d ′ ) ≡ 0 < c ′′ = 2 ∧ C [ 0 ] = D [ 0 ] ∧ C [ 1 ] = D [ 1 ] I ( c ′′ , d ′′ ) ≡ Taks: Compute interpolant I ( c ′ , d ′ ) by eliminating symbols c , d .
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } 0 < c ′ = 1 ∧ C [ 0 ] = D [ 0 ] I ( c ′ , d ′ ) ≡ 0 < c ′′ = 2 ∧ C [ 0 ] = D [ 0 ] ∧ C [ 1 ] = D [ 1 ] I ( c ′′ , d ′′ ) ≡ Taks: Compute interpolant I ( c ′′ , d ′′ ) by eliminating symbols c , d , c ′ , d ′ .
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 < N ∧ C [ c ] = D [ d ] ∧ c ′ = c + 1 ∧ d ′ = d + 1 ∧ c ′ ≥ N C [ c ] := D [ d ] ; � �� � T ( c , d , c ′ , d ′ ) c := c + 1 ; d := d + 1 end do postcondition B ( c ′ , d ′ ) { ( ∀ k )( 0 ≤ k < N → C [ k ] = 0 ) } ( ∀ k ) 0 ≤ k < c ′ → C [ k ] = D [ k ] I ( c ′ , d ′ ) ≡ ( ∀ k ) 0 ≤ k < c ′′ → C [ k ] = D [ k ] I ( c ′′ , d ′′ ) ≡ Taks: Compute interpolant I ( c ′′ , d ′′ ) implying invariant in any state.
Outline Invariants, Interpolants and Symbol Elimination Interpolants from Proofs Interpolation in Vampire Quality of Interpolants Conclusions
Symbol Elimination and Interpolation What is an Interpolant? Computing Interpolants ◮ Local Derivations ◮ Symbol Eliminations ◮ Building Interpolants from Proof Summary: Invariants, Symbol Elimination, Interpolants
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. ◮ L A : the language of A : the set of all formulas built from the symbols occurring in A .
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 ∈ L A ∩ L B 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.
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 ∈ L A ∩ L B 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 → ⊥ .
Interpolation with Theories ◮ Theory T : any set of closed formulas. ◮ C 1 , . . . , C n → T C means that the formula C 1 ∧ . . . ∧ C 1 → 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.
Recommend
More recommend