a machine checked model of mgu axioms applications of
play

A Machine-Checked Model of MGU Axioms: Applications of Finite Maps - PowerPoint PPT Presentation

A Machine-Checked Model of MGU Axioms: Applications of Finite Maps and Functional Induction Presented by Sunil Kothari Joint work with Prof. James Caldwell Department of Computer Science, University of Wyoming, USA 23rd International Workshop


  1. A Machine-Checked Model of MGU Axioms: Applications of Finite Maps and Functional Induction Presented by Sunil Kothari Joint work with Prof. James Caldwell Department of Computer Science, University of Wyoming, USA 23rd International Workshop on Unification August 2, 2009

  2. Outline Overview 1 Type Reconstruction Algorithms Introduction 2 Substitution Coq First-order unification algorithm 3 Specification in Coq Termination A model for MGU axioms 4 Axiom iii Axiom iv Conclusions and Future Work 5 Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 2 / 31

  3. Outline Overview 1 Type Reconstruction Algorithms Introduction 2 Substitution Coq First-order unification algorithm 3 Specification in Coq Termination 4 A model for MGU axioms Axiom iii Axiom iv Conclusions and Future Work 5

  4. Overview Type Reconstruction Algorithms Highlights Essential feature of many functional programming languages (ML, Haskell, OCaml, etc.). Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 3 / 31

  5. Overview Type Reconstruction Algorithms Highlights Essential feature of many functional programming languages (ML, Haskell, OCaml, etc.). Automated type reconstruction is possible. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 3 / 31

  6. Overview Type Reconstruction Algorithms Highlights Essential feature of many functional programming languages (ML, Haskell, OCaml, etc.). Automated type reconstruction is possible. Substitution-based algorithms. Intermittent constraint generation and constraint solving. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 3 / 31

  7. Overview Type Reconstruction Algorithms Highlights Essential feature of many functional programming languages (ML, Haskell, OCaml, etc.). Automated type reconstruction is possible. Substitution-based algorithms. Intermittent constraint generation and constraint solving. Constraint-based algorithms. Two distinct phases: constraint generation and constraint solving. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 3 / 31

  8. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms...contd Substitution-based Algorithm W, J by Milner, 1978. Algorithm M by Leroy, 1993. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 4 / 31

  9. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms...contd Substitution-based Algorithm W, J by Milner, 1978. Algorithm M by Leroy, 1993. Constraint-based Frameworks/Algorithms Wand’s algorithm [Wan87]. Qualified types [Jon95]. HM(X) [SOW97] by Sulzmann et al. 1999, Pottier and Rémy 2005 [PR05]. Top quality error messages [Hee05]. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 4 / 31

  10. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms... Contd Machine-Certified Correctness Proof Algorithm W in Coq, Isabelle/HOL [DM99, NN99a, NN99b, NN96]. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 5 / 31

  11. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms... Contd Machine-Certified Correctness Proof Algorithm W in Coq, Isabelle/HOL [DM99, NN99a, NN99b, NN96]. Nominal verification of Algorithm W [UN09]. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 5 / 31

  12. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms... Contd Machine-Certified Correctness Proof Algorithm W in Coq, Isabelle/HOL [DM99, NN99a, NN99b, NN96]. Nominal verification of Algorithm W [UN09]. We want to formalize multi-phase unification algorithm needed to handle polymorphic let. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 5 / 31

  13. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms... Contd Machine-Certified Correctness Proof Algorithm W in Coq, Isabelle/HOL [DM99, NN99a, NN99b, NN96]. Nominal verification of Algorithm W [UN09]. We want to formalize multi-phase unification algorithm needed to handle polymorphic let. POPLMark challenge also aims at mechanizing meta-theory. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 5 / 31

  14. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms... Contd Modeling MGU The most general unifier (MGU) is often a first-order unification algorithm over simple type terms. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 6 / 31

  15. Overview Type Reconstruction Algorithms Type Reconstruction Algorithms... Contd Modeling MGU The most general unifier (MGU) is often a first-order unification algorithm over simple type terms. In machine checked correctness proofs, the MGU is modeled as a set of four axioms: c ( i ) mgu σ ( τ 1 = τ 2 ) ⇒ σ ( τ 1 ) = σ ( τ 2 ) = τ 2 ) ∧ σ ′ ( τ 1 ) = σ ′ ( τ 2 ) ⇒ ∃ σ ′′ .σ ′ ≈ σ ◦ σ ′′ c ( ii ) mgu σ ( τ 1 c c ( iii ) mgu σ ( τ 1 = τ 2 ) ⇒ FTVS ( σ ) ⊆ FVC ( τ 1 = τ 2 ) c ( iv ) σ ( τ 1 ) = σ ( τ 2 ) ⇒ ∃ σ ′ . mgu σ ′ ( τ 1 = τ 2 ) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 6 / 31

  16. Outline Overview 1 Type Reconstruction Algorithms Introduction 2 Substitution Coq First-order unification algorithm 3 Specification in Coq Termination 4 A model for MGU axioms Axiom iii Axiom iv Conclusions and Future Work 5

  17. Introduction Terms and Constraint Syntax Terms τ ::= TyVar ( x ) | τ ′ → τ ′′ Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 7 / 31

  18. Introduction Terms and Constraint Syntax Terms τ ::= TyVar ( x ) | τ ′ → τ ′′ Atomic types (of the form TyVar x ) are denoted by α, β, α ′ etc. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 7 / 31

  19. Introduction Terms and Constraint Syntax Terms τ ::= TyVar ( x ) | τ ′ → τ ′′ Atomic types (of the form TyVar x ) are denoted by α, β, α ′ etc. Constraints Constraint are of the form τ c = τ ′ . Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 7 / 31

  20. Introduction Terms and Constraint Syntax Terms τ ::= TyVar ( x ) | τ ′ → τ ′′ Atomic types (of the form TyVar x ) are denoted by α, β, α ′ etc. Constraints Constraint are of the form τ c = τ ′ . A list of constraint is given as: = τ ′ :: C ′ c C ::= [ ] | τ Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 7 / 31

  21. Introduction FTV and FVC Free type variable (FTV) de f FTV ( TyVar x ) = [ x ] de f FTV ( τ → τ ′ ) = FTV ( τ ) ++ FTV ( τ ′ ) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 8 / 31

  22. Introduction FTV and FVC Free type variable (FTV) de f FTV ( TyVar x ) = [ x ] de f FTV ( τ → τ ′ ) = FTV ( τ ) ++ FTV ( τ ′ ) Free variables of a constraint list (FVC) de f FVC [ ] = [ ] de f c FVC (( τ 1 = τ 2 ) :: C ) = FTV ( τ 1 ) ++ FTV ( τ 2 ) ++ FVC ( C ) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 8 / 31

  23. Introduction Substitution Substitution Related Concepts A substitution (denoted by ρ ) maps type variables to types. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 9 / 31

  24. Introduction Substitution Substitution Related Concepts A substitution (denoted by ρ ) maps type variables to types. Denoted by σ, σ ′ , σ 1 etc. Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 9 / 31

  25. Introduction Substitution Substitution Related Concepts A substitution (denoted by ρ ) maps type variables to types. Denoted by σ, σ ′ , σ 1 etc. Substitution application to a type τ is defined as: de f σ ( TyVar ( x )) = if � x , τ � ∈ σ then τ else TyVar ( x ) de f σ ( τ 1 → τ 2 ) = σ ( τ 1 ) → σ ( τ 2 ) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 9 / 31

  26. Introduction Substitution Substitution Related Concepts A substitution (denoted by ρ ) maps type variables to types. Denoted by σ, σ ′ , σ 1 etc. Substitution application to a type τ is defined as: de f σ ( TyVar ( x )) = if � x , τ � ∈ σ then τ else TyVar ( x ) de f σ ( τ 1 → τ 2 ) = σ ( τ 1 ) → σ ( τ 2 ) Application of a substitution to a constraint is defined similarly: de f c c σ ( τ 1 = τ 2 ) = σ ( τ 1 ) = σ ( τ 2 ) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 9 / 31

  27. Introduction Substitution Substitution Substitution Composition Substitution composition definition using Coq’s finite maps is complicated. But the following theorem holds Theorem 1 (Composition apply) ∀ σ, σ ′ . ∀ τ. ( σ ◦ σ ′ ) τ = σ ′ ( σ ( τ )) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 10 / 31

  28. Introduction Substitution Substitution Substitution Composition Substitution composition definition using Coq’s finite maps is complicated. But the following theorem holds Theorem 1 (Composition apply) ∀ σ, σ ′ . ∀ τ. ( σ ◦ σ ′ ) τ = σ ′ ( σ ( τ )) Kothari Caldwell (U. of Wyoming) A Machine-Checked Model of MGU Axioms UNIF’09 10 / 31

Recommend


More recommend