algebraic simple type theory
play

Algebraic simple type theory A polynomial approach Nathanael Arkor - PowerPoint PPT Presentation

Algebraic simple type theory A polynomial approach Nathanael Arkor & Marcelo Fiore Department of Computer Science and Technology University of Cambridge Category Theory 2019 What is a type theory? What is a type theory? system of


  1. Algebraic simple type theory A polynomial approach Nathanael Arkor & Marcelo Fiore Department of Computer Science and Technology University of Cambridge Category Theory 2019

  2. What is a type theory?

  3. What is a type theory? system of mathematical proof

  4. What is a type theory? specification system of for a mathematical programming proof language

  5. What is a type theory? specification system of internal for a mathematical language of a programming proof category language

  6. Algebraic type theory typing / sorting binding categorical algebra polymorphism dependency

  7. Algebraic simple type theory typing / sorting binding categorical algebra polymorphism dependency e.g. λ-calculus, computational λ-calculus, predicate logic

  8. Typing judgements x 1 : τ 1 , …, x n : τ n ⊢ t : τ Examples Monoid action x : M, a : A ⊢ x • a : A Integration f : R → R ⊢ ∫ x f(x) dx : R

  9. x 1 : τ 1 , …, x n : τ n ⊢ t : τ contexts terms and types

  10. x 1 : τ 1 , …, x n : τ n ⊢ t : τ contexts terms and types

  11. Cartesian context structures S ∈ Set the sorts , or types ∈ Cat 𝒟 the variable contexts ε (terminal) ∈ 𝒟 the empty context : S → 𝒟 ⟨ – ⟩ types as contexts : 𝒟 × S → 𝒟 – × ⟨ = ⟩ context extension e.g. any cartesian category

  12. Cartesian context structures S ∈ Set the sorts , or types ∈ Cat 𝒟 the variable contexts ε (terminal) ∈ 𝒟 the empty context : S → 𝒟 ⟨ – ⟩ types as contexts : 𝒟 × S → 𝒟 – × ⟨ = ⟩ context extension e.g. any cartesian category

  13. Cartesian context structures S ∈ Set the sorts , or types ∈ Cat 𝒟 the variable contexts ε (terminal) ∈ 𝒟 the empty context : S → 𝒟 ⟨ – ⟩ types as contexts : 𝒟 × S → 𝒟 – × ⟨ = ⟩ context extension e.g. any cartesian category

  14. Cartesian context structures S ∈ Set the sorts , or types ∈ Cat 𝒟 the variable contexts ε (terminal) ∈ 𝒟 the empty context : S → 𝒟 ⟨ – ⟩ types as contexts : 𝒟 × S → 𝒟 – × ⟨ = ⟩ context extension e.g. any cartesian category

  15. Cartesian context structures S ∈ Set the sorts , or types ∈ Cat 𝒟 the variable contexts ε (terminal) ∈ 𝒟 the empty context : S → 𝒟 ⟨ – ⟩ types as contexts : 𝒟 × S → 𝒟 – × ⟨ = ⟩ context extension e.g. any cartesian category

  16. x 1 : τ 1 , …, x n : τ n ⊢ t : τ contexts terms and types

  17. Term-typing structure We consider presheaves 𝒟 op → Set on a cartesian context structure ( 𝒟 , S), fibred over S. T(Γ) presheaf of terms (in context Γ) τ Γ assignment of types to terms S(Γ) presheaf of types (in context Γ)

  18. Term-typing structure We consider presheaves 𝒟 op → Set on a cartesian context structure ( 𝒟 , S), fibred over S. T(Γ) presheaf of terms (in context Γ) τ Γ assignment of types to terms S constant presheaf of types

  19. Terms with a specified type NB. The fibre T σ is the set of terms with type σ. T T σ τ pb 1 S σ

  20. Presheaf of variables For any context Γ ∈ 𝒟 , V(Γ) is the set of variables in Γ. V = ⨿ y ⟨ σ ⟩ def σ ∈ S ν S

  21. Models of simple type theory x 1 : τ 1 , …, x n : τ n ⊢ t : τ contexts terms and types

  22. Models of simple type theory x 1 : τ 1 , …, x n : τ n ⊢ t : τ contexts terms and types algebraic structure

  23. Models of simple type theory Γ ⊢ op( t ) : Op( τ ) term operators type operators τ → σ | τ × σ | T(τ) | ... (t 1 , t 2 ) | π 1 t | t 1 t 2 | λ(x) t | ...

  24. Algebraic structure on types Type structure is as in universal algebra. For instance, the following operators τ → σ | τ × σ | T(τ) | U induce a signature endofunctor on Set Σ ty = X ↦ X 2 + X 2 + X + 1 the algebras for which are sets S with the appropriate structure [ ⟦ → ⟧ , ⟦ × ⟧ , ⟦ T ⟧ , ⟦ U ⟧ ] : Σ ty S → S (NB. These signature functors are polynomial.)

  25. How should we define the algebraic structure on terms? Natural deduction rules present algebraic structure Polynomials present natural deduction rules

  26. How should we define the algebraic structure on terms? Natural deduction rules present algebraic structure Polynomials present natural deduction rules

  27. How should we define the algebraic structure on terms? Natural deduction rules present algebraic structure Polynomials present natural deduction rules

  28. Polynomials & polynomial functors In a locally cartesian-closed category ℰ , a polynomial is a diagram: g f h A ⟵ B ⟶ C ⟶ D The polynomial functor associated to the polynomial is given by: Σ h Π g f* : ℰ /A ⟶ ℰ /D

  29. Polynomials & polynomial functors We will consider polynomials in Psh( 𝒟 ), inducing polynomial functors Psh( 𝒟 )/S → Psh( 𝒟 )/S, where ( 𝒟 , S) is a cartesian context structure with algebraic structure Σ ty S → S. Let P be a polynomial in Psh( 𝒟 ). Algebras for the corresponding polynomial functor are bundles τ : T → S together with morphisms as in the following. T T ⟦ P ⟧ F P ( ) ⟶ ( ) τ τ S S

  30. Algebraic structure & natural deduction Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B)

  31. Algebraic structure & natural deduction two type metavariables Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B) S ⟵ S × S + S × S ⟶ S × S ⟶ S A B in Psh( 𝒟 )

  32. Algebraic structure & natural deduction Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B) output sort ⟦ Prod ⟧ S ⟵ S × S + S × S ⟶ S × S ⟶ S in Psh( 𝒟 )

  33. Algebraic structure & natural deduction two hypotheses Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B) ⟦ Prod ⟧ S ⟵ S × S + S × S ⟶ S × S ⟶ S Γ ⊢ a : A Γ ⊢ b : B in Psh( 𝒟 )

  34. Algebraic structure & natural deduction Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B) A B ⟦ Prod ⟧ ∇ 2 S ⟵ S × S + S × S ⟶ S × S ⟶ S A' B' in Psh( 𝒟 )

  35. Algebraic structure & natural deduction Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B) [π 1 , π 2 ] ⟦ Prod ⟧ ∇ 2 S ⟵ S × S + S × S ⟶ S × S ⟶ S A B in Psh( 𝒟 )

  36. Algebraic structure & natural deduction Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ Γ ⊢ pair(a, b) : Prod(A, B) [π 1 , π 2 ] ⟦ Prod ⟧ ∇ 2 S ⟵ S × S + S × S ⟶ S × S ⟶ S A B in Psh( 𝒟 )

  37. Algebraic structure & natural deduction Γ ⊢ a : A Γ ⊢ b : B Prod- ɪɴᴛʀᴏ introduction rule Γ ⊢ pair(a, b) : Prod(A, B) [π 1 , π 2 ] ⟦ Prod ⟧ ∇ 2 S ⟵ S × S + S × S ⟶ S × S ⟶ S polynomial ⟦ pair ⟧ T × T T functor algebra τ × τ τ S × S S in Psh( 𝒟 ) ⟦ Prod ⟧

  38. Binding algebraic structure & natural deduction Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ Γ ⊢ abs(x : A . t) : Fun(A, B)

  39. Binding algebraic structure & natural deduction two type metavariables Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ Γ ⊢ abs(x : A . t) : Fun(A, B) S ⟵ V × S ⟶ S × S ⟶ S A B in Psh( 𝒟 )

  40. Binding algebraic structure & natural deduction Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ Γ ⊢ abs(x : A . t) : Fun(A, B) output sort ⟦ Fun ⟧ S ⟵ V × S ⟶ S × S ⟶ S in Psh( 𝒟 )

  41. Binding algebraic structure & natural deduction one term one variable Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ Γ ⊢ abs(x : A . t) : Fun(A, B) ⟦ Fun ⟧ S ⟵ V × S ⟶ S × S ⟶ S A B in Psh( 𝒟 )

  42. Binding algebraic structure & natural deduction Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ Γ ⊢ abs(x : A . t) : Fun(A, B) types of variables ν × id ⟦ Fun ⟧ S ⟵ V × S ⟶ S × S ⟶ S in Psh( 𝒟 )

  43. Binding algebraic structure & natural deduction term sort Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ Γ ⊢ abs(x : A . t) : Fun(A, B) ν × id π 2 ⟦ Fun ⟧ S ⟵ V × S ⟶ S × S ⟶ S A B in Psh( 𝒟 )

  44. Binding algebraic structure & natural deduction Γ, x : A ⊢ t : B Fun- ɪɴᴛʀᴏ introduction rule Γ ⊢ abs(x : A . t) : Fun(A, B) π 2 ν × id ⟦ Fun ⟧ S ⟵ V × S ⟶ S × S ⟶ S polynomial ⟦ abs ⟧ Γ ⨿ T B (Γ · A) T(Γ) functor algebra A, B ∈ S π τ Γ S × S S in Psh( 𝒟 ) ⟦ Fun ⟧ Γ

  45. Algebraic structure & natural deduction The natural deduction rules corresponding to introduction/elimination can be described by a second-order arity (describing the typing and binding data for each argument). Each second-order arity induces a polynomial in Psh( 𝒟 ). The algebras for their associated polynomial functors are presheaves with the corresponding (typed & binding) term structure. We can collect the arities into a term signature Σ tm , which itself induces a polynomial. (NB. We're using the same notation for a signature and the polynomial functor it induces.)

  46. Models of simple type theory x 1 : τ 1 , …, x n : τ n ⊢ t : τ contexts terms and types algebraic structure

Recommend


More recommend