encoding induction in correctness proofs of program
play

Encoding Induction in Correctness Proofs of Program Transformations - PowerPoint PPT Presentation

Encoding Induction in Correctness Proofs of Program Transformations as a Termination Problem Conrad Rau, David Sabel and Manfred Schmidt-Schau Goethe-University, Frankfurt am Main, Germany WST 2012, Obergurgl, Austria 1 Introduction


  1. Encoding Induction in Correctness Proofs of Program Transformations as a Termination Problem Conrad Rau, David Sabel and Manfred Schmidt-Schauß Goethe-University, Frankfurt am Main, Germany WST 2012, Obergurgl, Austria 1

  2. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Introduction and Motivation Motivation: Automate correctness proofs of program transformations Programming language: Core language, modelled as extended λ -calculus Correctness of program transformations: Based on contextual equivalence Correctness proof uses: Diagrams (already automated) Induction (automate through a termination proof ) David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 2/14

  3. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Related and Own Work Schmidt-Schauß, Sch¨ utz, Sabel, 2008 Extended λ -calculus LR and correctness of program transformations via diagrams; manual proofs Wells, Plump and Kamareddine, 2003 Diagrams to show meaning preservation R., Schmidt-Schauß, 2010, 2011 Compute diagrams in extended λ -calculi Fuhs, Giesl, Pl¨ ucker, Schneider-Kamp, Falke, 2009 Termination of integer term rewriting David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 3/14

  4. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Program Calculus, Contextual Equivalence Definition (Program calculus ( E , C , sr − → , A ) ) E : Set of expressions C : Set of contexts sr ,l sr − →⊆ E × E : Reduction relation, usually labeled − − → A ⊆ E : Set of answers Example (Extended λ -calculus: LR) call-by-need λ -calculus, core language of pure Haskell sr , ∗ Convergence : e ⇓ iff e − − → a where a ∈ A (also called termination) Definition (Contextual Equivalence for ( E , C , sr − → , A ) ) Contextual approximation : e 1 ≤ c e 0 ⇐ ⇒ ∀ C ∈ C : C [ e 1 ] ⇓ = ⇒ C [ e 0 ] ⇓ Contextual equivalence : e 1 ∼ c e 0 ⇐ ⇒ e 1 ≤ c e 0 ∧ e 0 ≤ c e 1 David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 4/14

  5. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Program Transformations Definition (Program Transformation, Correctness) T A Program transformation : − → ⊆ ( E × E ) is correct iff T − → e 0 = ⇒ e 1 ∼ c e 0 e 1 Focus on ≤ c , since ∼ c = ≤ c ∩ ≥ c T − → is called T convergence preserving iff e 1 − → e 0 ∧ e 1 ⇓ = ⇒ e 0 ⇓ context-closed for T ′ → iff convergence preservation of T − − → implies T ′ − → ⊆ ≤ c R ( T ) T (e.g. − − − → := { ( R [ e 1 ] , R [ e 0 ]) | e 1 − → e 0 , R ∈ R} ) Focus on c. p., since T − → can easily be context-closed David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 5/14

  6. � � � � � � � � � � � � � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Convergence Preservation Prove convergence preservation for T T − → , i.e. e 1 − → e 0 ∧ e 1 ⇓ = ⇒ e 0 ⇓ : T � e 0 e 1 sr ,l 1 sr ,l ′ 1 T Outline of Convergence Preservation Proof for − → e 2 e ′ T 2 ∀ e 1 , e 0 ∈ E with e 1 − → e 0 sr ,l T sr ,l ′ 1 Determine all overlaps e 2 sr ,l 2 ← − − e 1 − → e 0 and join 2 them into: Sets of diagrams . . . . . . 2 Construct converging reduction sequence for e 0 using the diagram sets sr ,l ′ sr ,l n m a 1 a 0 David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 6/14

  7. � � � � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Forking and Answer Diagrams T Diagram for − → : Rewrite rule S L � S R on abstract reduction sequences (ARSs) sr ,l n sr ,l n − 1 sr ,l 1 T . . . � e 0 e n e 1 concrete sequence: a sr ,l n sr ,l n − 1 sr ,l 1 T � e 0 . . . e n e 1 abstract sequence: A “ + ” denotes transitive closure of reductions sr ,l ′ sr ,l ′ sr ,l n sr ,l 1 − T → � T → . . . T 1 Forking diagram : ← − − − . . . ← − − − − − → ← − − − . . . ← − − − m Finite representation of overlaps and joining sequences Represent set of rewrite rules on concrete sequences Answer diagram : A T sr ,l n sr ,l 1 − → � A ← − − − . . . ← − − − DF ( T → ) , DA ( T − − → ) : Sets of diagrams (i.e. rewriting systems) David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 7/14

  8. � � � � � � � � � � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Complete Sets of Diagrams i S ,llet Example (Diagrams for − − − − → ) i S ,llet � i S ,llet � i S ,llet � i S ,llet � i S ,llet � DF · · · · · · · · · · � � � � � � � � � � � � � � � � sr ,a � sr ,a sr ,lll, + sr ,a sr ,a sr ,lll, + sr ,lll, + · sr ,a sr ,lll, + sr ,a i S ,llet � i S ,llet � · · sr ,llet � · · · · · � � � � � � i S ,llet DF A − − − − → � A T Definition (Complete Diagram Set for → ) − DF ( T − → ) is complete , if every ARS of the form sr ,l n sr ,l 1 − T → is rewritable by a diagram in DF ( T ← − − − . . . ← − − − − → ) A DA ( T → ) is complete , if every sequence A T − − → is rewritable by a diagram in DA ( T − → ) David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 8/14

  9. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

  10. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction i S ,llet � e 0 a 1 David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

  11. Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction i S ,llet � e 0 a 1 i S ,llet A − − − − → � A David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

  12. � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction i S ,llet � e 0 i S ,llet � e 0 a 1 e 1 i S ,llet sr ,l 1 A − − − − → � A e 2 sr ,l 2 . . . sr ,l n a 1 David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

  13. � � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction i S ,llet � e 0 i S ,llet � e 0 a 1 e 1 i S ,llet sr ,l 1 A − − − − → � A e 2 sr ,l 2 . . . sr ,l n a 1 i S ,llet � · · � � � � � sr ,a sr ,a · David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

  14. � � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction i S ,llet � e 0 i S ,llet � e 0 a 1 e 1 � ����� i S ,llet sr ,l 1 A − − − − → � A sr ,l 1 e 2 sr ,l 2 . . . sr ,l n a 1 i S ,llet � · · � � � � � sr ,a sr ,a · David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

  15. � � � � � � � Introduction Calculus & Program Transformations Proving Correctness Encoding Conclusion Proving Correctness through Induction Construct an evaluation through diagram application and induction i S ,llet � e 0 i S ,llet � e 0 i S ,llet � e 0 a 1 e 1 e 1 � ����� i S ,llet sr ,l 1 sr ,l 1 A − − − − → � A sr ,l 1 e 2 e 2 sr ,l 2 sr ,l 2 . . . . . . sr ,l n sr ,l n a 1 a 1 i S ,llet � · · � � � � � sr ,a sr ,a · David Sabel Correctness Proofs of Program Transformations as a Termination Problem C. Rau, D. Sabel, M. Schmidt-Schauß 9/14

Recommend


More recommend