correctness of program transformations as a termination
play

Correctness of Program Transformations as a Termination Problem - PowerPoint PPT Presentation

Correctness of Program Transformations as a Termination Problem Conrad Rau, David Sabel and Manfred Schmidt-Schau Goethe-University, Frankfurt am Main, Germany IJCAR 2012, Manchester, UK 1 Introduction & Motivation Automate correctness


  1. Correctness of Program Transformations as a Termination Problem Conrad Rau, David Sabel and Manfred Schmidt-Schauß Goethe-University, Frankfurt am Main, Germany IJCAR 2012, Manchester, UK 1

  2. Introduction & Motivation Automate correctness proofs of program transformations Approach to correctness proofs: Diagram based e.g. Wells, Plump and Kamareddine, 2003 Schmidt-Schauß, Sch¨ utz, Sabel, 2008 Sabel, Schmidt-Schauß, 2011 R., Schmidt-Schauß, 2011 Problem: Correctness proofs carried out by hand (tedious) Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 2/13

  3. Program Calculus & Contextual Equivalence Definition (Program calculus ( E , C , sr = ⇒ , A , L ) ) E : Set of expressions C : Set of contexts L : Set of labels (finite) A ⊆ E : Set of answers sr ,l = = ⇒⊆ E × E × L : Labeled reduction relation sr , ∗ Convergence : s ⇓ iff s = = ⇒ a where a ∈ A Definition Contextual approximation : s ≤ c t iff ∀ C ∈ C : C [ s ] ⇓ ⇒ C [ t ] ⇓ Contextual equivalence : s ∼ c t iff s ≤ c t ∧ t ≤ c s Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 3/13

  4. Program Transformations, Correctness Definition (Program Transformation, Correctness) T A program transformation : = ⇒ ⊆ ( E × E ) is correct iff s T = ⇒ t = ⇒ s ∼ c t Example (Program Transformations from LR) lbeta (( λx.s ) t ) = = ⇒ letrec x = t in s llet letrec x = s in ( letrec y = t in r ) = ⇒ letrec x = s, y = t in r silly = = ⇒ False True Simplifications: Focus on ≤ c , since ∼ c = ≤ c ∩ ≥ c Assume T = ⇒ is CP-sufficient: ( ∀ s, t with s T T ⇒ t : s ⇓ = = ⇒ t ⇓ ) implies = ⇒ ⊆ ≤ c � �� � T = ⇒ is convergence preserving Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 4/13

  5. Proving Correctness: Diagram Based Approach Prove convergence preservation for T ⇒ , i.e. s T = = ⇒ t ∧ s ⇓ = ⇒ t ⇓ ∀ s, t ∈ E with s T ⇒ t = T s t sr ,l i = s T 1 Determine all overlaps s 1 ⇐ = ⇒ t and join = sr, l 1 sr, l ′ 1 them into: Sets of diagrams (already automated) s 1 t 1 2 Construct converging reduction sequence inductively for t using the diagram sets sr, l 2 sr, l ′ 2 . . . . Example: Diagram Set . . s n t m T T T T · · · · · · A A sr, l n sr, l ′ m sr, l sr, l sr, l sr, l sr, l, + sr, l, + a 1 a 2 T T · · · · · Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/13

  6. Proving Correctness: Diagram Based Approach Prove convergence preservation for T ⇒ , i.e. s T = = ⇒ t ∧ s ⇓ = ⇒ t ⇓ ∀ s, t ∈ E with s T ⇒ t = T a 1 a 2 sr ,l i = s T 1 Determine all overlaps s 1 ⇐ = ⇒ t and join = sr, l ′ sr, l 1 1 them into: Sets of diagrams (already automated) s 1 t 1 2 Construct converging reduction sequence inductively for t using the diagram sets sr, l 2 sr, l ′ 2 . . . . Example: Diagram Set . . s n t m T T T T · · · · · · A A sr, l n sr, l ′ m sr, l sr, l sr, l sr, l sr, l, + sr, l, + a 1 a 2 T T · · · · · Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/13

  7. Proving Correctness: Diagram Based Approach Prove convergence preservation for T ⇒ , i.e. s T = = ⇒ t ∧ s ⇓ = ⇒ t ⇓ ∀ s, t ∈ E with s T ⇒ t = T s t sr ,l i = s T 1 Determine all overlaps s 1 ⇐ = ⇒ t and join = sr, l 1 sr, l 1 them into: Sets of diagrams (already automated) s 1 t 1 2 Construct converging reduction sequence inductively for t using the diagram sets sr, l 2 sr, l ′ 2 . . . . Example: Diagram Set . . s n t m T T T T · · · · · · A A sr, l n sr, l ′ m sr, l sr, l sr, l sr, l sr, l, + sr, l, + a 1 a 2 T T · · · · · Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/13

  8. Proving Correctness: Diagram Based Approach Prove convergence preservation for T ⇒ , i.e. s T = = ⇒ t ∧ s ⇓ = ⇒ t ⇓ ∀ s, t ∈ E with s T ⇒ t = T s t sr ,l i = s T 1 Determine all overlaps s 1 ⇐ = = ⇒ t and join sr, l 1 sr, l 1 them into: Sets of diagrams (already automated) T s 1 t 1 2 Construct converging reduction sequence inductively for t using the diagram sets sr, l 2 . . Example: Diagram Set . s n T T T T · · · · · · A A sr, l n sr, l sr, l sr, l sr, l sr, l, + sr, l, + a 1 a 2 T T · · · · · Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/13

  9. Proving Correctness: Diagram Based Approach Prove convergence preservation for T ⇒ , i.e. s T = = ⇒ t ∧ s ⇓ = ⇒ t ⇓ ∀ s, t ∈ E with s T ⇒ t = T s t sr ,l i = s T 1 Determine all overlaps s 1 ⇐ = ⇒ t and join = sr, l 1 sr, l 1 them into: Sets of diagrams (already automated) . . . . 2 Construct converging reduction sequence . . inductively for t using the diagram sets sr, l 1 sr, l 1 T s n t m Example: Diagram Set . . . T T T T · · · · · · A A sr, l k sr, l sr, l sr, l sr, l sr, l, + sr, l, + a 1 a 2 T T · · · · · Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/13

  10. Proving Correctness: Diagram Based Approach Prove convergence preservation for T ⇒ , i.e. s T = = ⇒ t ∧ s ⇓ = ⇒ t ⇓ ∀ s, t ∈ E with s T ⇒ t = T s t sr ,l i = s T 1 Determine all overlaps s 1 ⇐ = ⇒ t and join = sr, l 1 sr, l 1 them into: Sets of diagrams (already automated) . . . . 2 Construct converging reduction sequence . . inductively for t using the diagram sets sr, l 1 sr, l 1 T s n t m Example: Diagram Set . . . T T T T · · · · · · A A sr, l k sr, l sr, l sr, l sr, l sr, l, + sr, l, + a 1 a 2 T T · · · · · Rewriting by diagrams, termination by induction Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/13

  11. Abstract Reduction Sequences & Diagrams T Definition (Diagram for = ⇒ ) Rewrite rule S L � S R on abstract reduction sequences sr, l n sr, l n − 1 sr, l 2 sr, l 1 T . . . Concrete (cRS): s n s 1 a s t sr, l n − 1 sr, l n sr, l 2 sr, l 1 T . . . Abstract (cARS): A T · · sr, x sr, l 1 sr, l k , + sr, l 1 T . . . . . . . . . Forking sr, l ′ T 1 , + T m sr, x . . . . . . n � sr, l k , + sr, l ′ n T 1 , + T m . . . · · T 1 T m sr, l n sr, l 1 T . . . . . . Answer A � Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 6/13

  12. Overview: Involved Rewrite Systems Forking/Answer Diagrams Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 7/13

  13. Overview: Involved Rewrite Systems Rewrite Systems on simple ARS (SRSARS) simple Abstract Reduction Sequences (cARS) translated into (by J ) SRSARS (String Rewrite System) Forking/Answer Diagrams D := { S L � S R } over simple ARS D ( simple cARS ( D ) , − ⇀ ) Translation J Replace variables by labels Expand transitive closures: ∀ k, k ′ ∈ N T i , + T i T i − − → to − → . . . − → � �� � k times sr ,l, + sr ,l sr ,l ← − − − to ← − − . . . ← − − � �� � k ′ times Result: Infinite SRS over simple ARS Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 7/13

  14. Overview: Involved Rewrite Systems Rewrite Systems on RS (CRSRS) Rewrite Systems on simple ARS (SRSARS) interpreted as (by I ) Concrete Reduction Sequences (cRS) simple Abstract Reduction Sequences (cARS) translated into (by J ) CRSRS (String Rewrite System) Forking/Answer Diagrams D := { S L � S R } over RS D ( all cRS ( D ) , − ⇀ ) Interpretation I Interpret ARS as set of concrete RS sr ,l sr ,l sr ,l I ( ← − − ) := { e 1 ⇐ = e 2 | e 2 = ⇒ e 1 } T i T i T i I ( − → ) := { e 1 = ⇒ e 2 | e 1 = ⇒ e 2 } . . . Result: SRS over concrete RS Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 7/13

  15. Overview: Involved Rewrite Systems Rewrite Systems on RS (CRSRS) Rewrite Systems on simple ARS (SRSARS) interpreted as (by I ) Concrete Reduction Sequences (cRS) simple Abstract Reduction Sequences (cARS) Semantics translated into (by J ) Forking/Answer Diagrams Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 7/13

  16. Complete Diagram Sets Definition (Completeness of Diagram Sets ) DF ( T = ⇒ ) is complete iff any concrete sequence sr, l n sr, l n − 1 sr, l 2 sr, l 1 T . . . s n s 1 a s t is rewritable by a rule in I ( J ( DF ( T ⇒ ))) = DA ( T = ⇒ ) is complete iff for any concrete sequence T a t is rewritable by a rule in I ( J ( DA ( T = ⇒ ))) Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 8/13

  17. Overview: Involved Rewrite Systems Rewrite Systems on RS (CRSRS) Rewrite Systems on simple ARS (SRSARS) interpreted as (by I ) Concrete Reduction Sequences (cRS) simple Abstract Reduction Sequences (cARS) Semantics translated into (by J ) Forking/Answer Diagrams Correctness of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/13

Recommend


More recommend