typechecking in the calculus modulo theory and practice
play

Typechecking in the -Calculus Modulo: Theory and Practice PhD - PowerPoint PPT Presentation

Introduction -Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Typechecking in the -Calculus Modulo: Theory and Practice PhD thesis defense Ronan SAILLARD MINES ParisTech,


  1. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Typechecking in the λ Π-Calculus Modulo: Theory and Practice PhD thesis defense Ronan SAILLARD MINES ParisTech, PSL Research University INRIA, Deducteam September 25, 2015 1/39

  2. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Formal Proving Computers can help mathematicians and engineers prove theorems. • Theorem provers. • Proof checkers. Examples: The Kepler Conjecture Operating System of Driverless Subway (Paris, Line 14) 2/39

  3. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Logical Frameworks There exist many tools for proving/checking Agda, Beluga, Coq, . . . and Dedukti . Dedukti : a Logical Framework A tool to implement logical systems. • Prototyping of proof systems. • Independent proof checking. 3/39

  4. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion A Universal Proof Checker Coq Zenon M. HOL iProver M. Dedukti FoCaLiZe ??? Matita Long-Term Goal : allowing these programs to cooperate thanks to a unique proof format. 4/39

  5. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion The Curry-Howard Correspondence [Curry 1958 and Howard 1969] Observation Γ ⊢ A = ⇒ B Γ ⊢ A Γ ⊢ f : A → B Γ ⊢ u : A ≅ Γ ⊢ B Γ ⊢ f u : B (Modus Ponens) (Typing Rule for Application) Consequence Proof checking can be reduced to Type checking Dedukti is at the same time a proof checker and a type checker. 5/39

  6. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion The Curry-Howard Correspondence [Curry 1958 and Howard 1969] Observation Γ ⊢ A = ⇒ B Γ ⊢ A Γ ⊢ f : A → B Γ ⊢ u : A ≅ Γ ⊢ B Γ ⊢ f u : B (Modus Ponens) (Typing Rule for Application) Consequence Proof checking can be reduced to Type checking Dedukti is at the same time a proof checker and a type checker. 5/39

  7. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion The λ Π-Calculus Modulo [Cousineau and Dowek, 2007] The λ Π -Calculus Modulo is a typed calculus based on two features: • Dependent Types. • Rewrite Rules. 6/39

  8. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Dependent Types The λ -Calculus with Dependent Types is called λ Π-Calculus or LF. Idea Types can be parameterized by terms. Functions can return values whose types depend on their input. Lists Parameterized by their Size nil : Vector 0 cons : Π n : Nat . Elt − → Vector n − → Vector ( S n ) Typing Rules Γ ⊢ t : Π x : A . B Γ ⊢ u : A (Application) Γ ⊢ t u : B [ x ← u ] Γ ⊢ t : A Γ ⊢ B : Type A ≡ β B (Conversion) Γ ⊢ t : B 7/39

  9. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Rewrite Rules λ Π-Calculus Modulo • β -reduction, • A set R of rewrite rules ( f � → r ). l ֒ Example → n plus n 0 ֒ plus n ( S m ) ֒ → S ( plus n m ) Extended Conversion Rule Γ ⊢ t : A Γ ⊢ B : Type A ≡ β R B Γ ⊢ t : B Benefits • Allows the design of small encodings of proof systems. • Allows encoding more systems. 8/39

  10. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Encoding Propositional Logic In the λ Π -Calculus : prop : Type . prf : prop − → Type . = ⇒ : prop − ˙ → prop − → prop . elim : Π A : prop . Π B : prop . prf ( A = ˙ ⇒ B ) − → prf A − → prf B . intro : Π A : prop . Π B : prop . ( prf A − → prf B ) − → prf ( A = ⇒ B ). ˙ In the λ Π -Calculus Modulo : ⇒ B ) ֒ → ( prf A − → prf B ). prf ( A = ˙ Meta-Theorem (in both cases) Σ ⊢ P iff ∃ t (Γ; ˙ Σ ⊢ t : prf ˙ P ). In the λ Π-Calculus Modulo, proof terms are usually smaller and can be checked faster. 9/39

  11. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion General Contribution: More Safety Previous versions of Dedukti could give incorrect results if the input problem did not verify the subject reduction property (preservation of types by reduction). And Dedukti did not check subject reduction compromising its soundness. More Safety • I studied the subject reduction property and showed how it can be checked. • I implemented the verification in Dedukti . 10/39

  12. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion General Contribution: More Expressiveness From Algebraic Rewrite Rules • Left-hand sides are algebraic terms (built from constant applications and variables only). • Example: plus n 0 ֒ → n → S ( plus n m ) plus n ( S m ) ֒ To Higher-Order Rewrite Rules • Left-hand sides may contain abstractions. • Example: • D ( λ x : R . Exp ( f x )) ֒ → ( D ( λ x : R . f x )) × ( λ x : R . Exp ( f x )). • Encoding of Coq’s universes [Assaf, 2014]. 11/39

  13. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion 1 A λ Π-Calculus Modulo with Global Contexts 2 Product Compatibility and Higher-Order Rewrite Rules 3 Typing Rewrite Rules 4 Conclusion 12/39

  14. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion λ Π-Calculus Modulo vs Dedukti λ Π-Calculus Modulo • The set of rewrite rules R is fixed. • Rewrite rules are typed outside the system. Dedukti • Rewrite rules can be added at any time. • Rewrite rules are typed iteratively. • More rules can be checked. 13/39

  15. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion λ Π-Calculus Modulo with Global Contexts Global Contexts and Local Contexts () | Γ( c : A ) | Γ( f � Γ ::= l ֒ → r ) ∆ ::= () | ∆( x : A ) Conversion Rule Γ; ∆ ⊢ t : A Γ; ∆ ⊢ B : s A ≡ β Γ B Γ; ∆ ⊢ t : B Improvements • Allows typing more rewrite rules. • Eases the reasoning about Dedukti (soundness/completeness proofs). Publication: Towards Explicit Rewrite Rules in the λ Π-Calculus Modulo, R. Saillard in IWIL, 2013. 14/39

  16. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion A Fundamental Property Subject Reduction Γ; ∆ ⊢ t 1 : T ∧ t 1 → β Γ t 2 = ⇒ Γ; ∆ ⊢ t 2 : T Subject Reduction is necessary for proving any non-trivial property about the type system and in particular • the soundness/completeness of proof embeddings. • the soundness/completeness of typechecking algorithms. • termination. Subject reduction may not hold! 15/39

  17. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Product Compatibility and Well-Typedness of Rewrite Rules The proof of subject reduction can be reduced to the proof of two simpler properties. Product Compatibility [Geuvers, 1992] If Π x : A 1 . B 1 ≡ β Γ Π x : A 2 . B 2 , then A 1 ≡ β Γ A 2 and B 1 ≡ β Γ B 2 . Well-Typed Rewrite Rules [Blanqui, 2005] For all ( l ֒ → r ) ∈ Γ and substitution σ , if Γ; ∆ ⊢ σ ( l ) : T , then Γ; ∆ ⊢ σ ( r ) : T . Remark These properties are undecidable. To check them in Dedukti , we need to find decidable criteria. 16/39

  18. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion 1 A λ Π-Calculus Modulo with Global Contexts 2 Product Compatibility and Higher-Order Rewrite Rules 3 Typing Rewrite Rules 4 Conclusion 17/39

  19. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Product Compatibility Product Compatibility (PC) If Π x : A 1 . B 1 ≡ β Γ Π x : A 2 . B 2 , then A 1 ≡ β Γ A 2 and B 1 ≡ β Γ B 2 . Theorem: PC for Object-Level Systems [Barbanera et al,1994] Product Compatibility holds when there are no type-level rewrite rules. Theorem: PC by Confluence Product Compatibility follows from the confluence of → β Γ . 18/39

  20. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Higher-Order Rewrite Rules Derivation Operation ( e f ) ′ = f ′ × e f D ( λ x : R . Exp ( f x )) ֒ → ( D ( λ x : R . f x )) × ( λ x : R . Exp ( f x )). Critical Pair D ( λ x : R . Exp (( λ y : R . y ) x )) β D ( λ x : R . Exp x ) D ( D ( λ x : R . ( λ y : R . y ) x )) × ( λ x : R . ( Exp (( λ y : R . y ) x ))) The critical peak cannot be joined; confluence is lost . Remark In the λ Π-Calculus Modulo, matching is syntactic. 19/39

  21. Introduction λ Π-Calculus Modulo with Contexts Product Compatibility & Higher-Order Rules Typing Rewrite Rules Conclusion Two Problems • How to prove product compatibility? • How to decide the congruence ≡ β Γ ? 20/39

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend