towards unification for dependent types
play

Towards Unification for Dependent Types Ningning Xie , Bruno C. d. S. - PowerPoint PPT Presentation

Towards Unification for Dependent Types Ningning Xie , Bruno C. d. S. Oliveira The University of Hong Kong June 2017 N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 1 / 26 Outline Motivation and Background 1


  1. Towards Unification for Dependent Types Ningning Xie , Bruno C. d. S. Oliveira The University of Hong Kong June 2017 N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 1 / 26

  2. Outline Motivation and Background 1 Unification Algorithm 2 Extension: Implicit polymorphism 3 Conclusion 4 N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 2 / 26

  3. Outline Motivation and Background 1 Unification Algorithm 2 Extension: Implicit polymorphism 3 Conclusion 4 N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 3 / 26

  4. Motivation Developments on type unification techniques for sophisticated dependent type systems. Features: higher-order, polymorphism, subtyping, etc. powerful, but complicated, complex, and hard to reason. 1 1 Ziliani, Beta, and Matthieu Sozeau. ”A unification algorithm for Coq featuring universe polymorphism and overloading.” ACM SIGPLAN Notices. Vol. 50. No. 9. ACM, 2015. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 4 / 26

  5. Motivation Developments on type unification techniques for sophisticated dependent type systems. Features: higher-order, polymorphism, subtyping, etc. powerful, but complicated, complex, and hard to reason. Developments on dependent type systems that give programmers more control. 1 2 3 4 Manage type-level computations using explicit casts. Decidable type checking based on alpha-equality. Easy to combine recursive types. 1 Yang, Yanpeng, Xuan Bi, and Bruno C. D. S. Oliveira. ”Unified Syntax with Iso-types.” Asian Symposium on Programming Languages and Systems. Springer International Publishing, 2016. 2 van Doorn, Floris, Herman Geuvers, and Freek Wiedijk. ”Explicit convertibility proofs in pure type systems.” Proceedings of the Eighth ACM SIGPLAN international workshop on Logical frameworks & meta-languages: theory & practice. ACM, 2013. 3 Kimmell, Garrin, et al. ”Equational reasoning about programs with general recursion and call-by-value semantics.” Proceedings of the sixth workshop on Programming languages meets program verification. ACM, 2012. 4 Sjberg, Vilhelm, and Stephanie Weirich. ”Programming up to congruence.” ACM SIGPLAN Notices. Vol. 50. No. 1. ACM, 2015. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 4 / 26

  6. Motivation Developments on type unification techniques for sophisticated dependent type systems. Features: higher-order, polymorphism, subtyping, etc. powerful, but complicated, complex, and hard to reason. Developments on dependent type systems that give programmers more control. Manage type-level computations using explicit casts. Decidable type checking based on alpha-equality. Easy to combine recursive types. Question: can we get rid of the complication of the algorithms in those systems? N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 4 / 26

  7. Goals Our goal is to present a simple and complete unification algorithm for first-order dependent type systems with alpha-equality based type checking fill the gap between delicate unification algorithms for simple types and sophisticated unification algorithms for dependent types. We do not intend to solve more problems than existing unification algorithms. serve for beta-equality based dependent type systems. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 5 / 26

  8. Contributions Strategy: type sanitization that resolves the dependency between types. Algorithm: an alpha-equality based unification algorithm for first-order dependent types. Extension: subtyping in implicit polymorphism. Meta-theory Study: undergoing. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 6 / 26

  9. Background: Dependent Types Types depends on terms. Vector of integers definition without dependent types: data Vect = Nil | Cons Int Vect N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 7 / 26

  10. Background: Dependent Types Types depends on terms. Vector of integers definition without dependent types: data Vect = Nil | Cons Int Vect one definition that could cause run-time error head :: Vect → Int N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 7 / 26

  11. Background: Dependent Types Types depends on terms. Vector of integers definition without dependent types: data Vect = Nil | Cons Int Vect one definition that could cause run-time error head :: Vect → Int make it total head :: Vect → Maybe Int N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 7 / 26

  12. Background: Dependent Types Types depends on terms. Vector of integers definition without dependent types: data Vect = Nil | Cons Int Vect one definition that could cause run-time error head :: Vect → Int make it total head :: Vect → Maybe Int definition with dependent type: sized Vector data Vect :: Nat → Type = | Nil :: Vect Z | Cons :: Int → Vect k → Vect ( S k ) N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 7 / 26

  13. Background: Dependent Types Types depends on terms. Vector of integers definition without dependent types: data Vect = Nil | Cons Int Vect one definition that could cause run-time error head :: Vect → Int make it total head :: Vect → Maybe Int definition with dependent type: sized Vector data Vect :: Nat → Type = | Nil :: Vect Z | Cons :: Int → Vect k → Vect ( S k ) head :: Vect ( S k ) → Int N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 7 / 26

  14. Background: Unification Problem Unification Given two terms containing some unification variables, find the substitution which makes two terms equal. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 8 / 26

  15. Background: Unification Problem Unification Given two terms containing some unification variables, find the substitution which makes two terms equal. α → Int � Bool → Int N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 8 / 26

  16. Background: Unification Problem Unification Given two terms containing some unification variables, find the substitution which makes two terms equal. α → Int � Bool → Int Solution: � α = Bool . N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 8 / 26

  17. Outline Motivation and Background 1 Unification Algorithm 2 Extension: Implicit polymorphism 3 Conclusion 4 N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 9 / 26

  18. Language Unified syntax based on λ C Syntax Type σ, τ ::= � α | e Expr e ::= x | ⋆ | e 1 e 2 | λ x : σ. e | Π x : σ 1 . σ 2 λ x . e ≡ λ x : � α. e Example: ( λ x : ⋆. λ y : x . y ) :: Π x : ⋆. Π y : x . x A → B for Π x : A . B if x does not appear in B . N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 10 / 26

  19. Unification Algorithm Key ideas: 1 : ordered typing context Algorithmic typing context Contexts Γ , Θ , ∆ ::= ∅ | Γ , x : σ | Γ , � α | Γ , � α = τ scope constraint α. λ y : � λ x : � β. y α = y invalid � � β = x valid 1 Dunfield, Joshua, and Neelakantan R. Krishnaswami. ”Complete and easy bidirectional typechecking for higher-rank polymorphism.” ACM SIGPLAN Notices. Vol. 48. No. 9. ACM, 2013. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 11 / 26

  20. Unification Algorithm Key ideas: 1 : ordered typing context Algorithmic typing context Contexts Γ , Θ , ∆ ::= ∅ | Γ , x : σ | Γ , � α | Γ , � α = τ scope constraint α. λ y : � λ x : � β. y α = y invalid � � β = x valid judgment: Γ ⊢ τ 1 ≃ τ 2 ⊣ Θ 1 Dunfield, Joshua, and Neelakantan R. Krishnaswami. ”Complete and easy bidirectional typechecking for higher-rank polymorphism.” ACM SIGPLAN Notices. Vol. 48. No. 9. ACM, 2013. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 11 / 26

  21. Unification Algorithm Key ideas: 1 : ordered typing context Algorithmic typing context Contexts Γ , Θ , ∆ ::= ∅ | Γ , x : σ | Γ , � α | Γ , � α = τ scope constraint α. λ y : � λ x : � β. y α = y invalid � � β = x valid judgment: Γ ⊢ τ 1 ≃ τ 2 ⊣ Θ invariant: inputs are already fully substituted under current context. α = Int ⊢ � � α ≃ Bool invalid α = Int ⊢ Int ≃ Bool valid � 1 Dunfield, Joshua, and Neelakantan R. Krishnaswami. ”Complete and easy bidirectional typechecking for higher-rank polymorphism.” ACM SIGPLAN Notices. Vol. 48. No. 9. ACM, 2013. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 11 / 26

  22. Problem The case when we have a unification variable on one side: Γ , � α, ∆ ⊢ � α ≃ τ 2 Dunfield, Joshua, and Neelakantan R. Krishnaswami. ”Complete and easy bidirectional typechecking for higher-rank polymorphism.” ACM SIGPLAN Notices. Vol. 48. No. 9. ACM, 2013. N. Xie, B.C.d.S. Oliveira Towards Unification for Dependent Types TFP 2017 12 / 26

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