naturality for free
play

Naturality for Free The category interpretation of directed type - PowerPoint PPT Presentation

Naturality for Free The category interpretation of directed type theory Thorsten Altenkirch jww Filippo Sestini Functional Programming Laboratory School of Computer Science University of Nottingham March 28, 2019 Thorsten Altenkirch jww


  1. Naturality for Free The category interpretation of directed type theory Thorsten Altenkirch jww Filippo Sestini Functional Programming Laboratory School of Computer Science University of Nottingham March 28, 2019 Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 1 / 24

  2. The first commandment of Type Theory Thou shalt not inspect a type! Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 2 / 24

  3. Consequences of the 1st commandment Parametricity Polymorphic functions preserve all logical relations. Univalence Isomorphic types are equal. How are these related? Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 3 / 24

  4. reverse is natural List : Set → Set rev : Π A : Set List A → List A f : A → B rev A List A List A List f List f List B List B rev B Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 4 / 24

  5. Proof by . . . -induction List f [ a 0 , a 1 , . . . , a n − 1 ] = [ f a 0 , f a 1 , . . . , f a n − 1 ] rev A [ a 0 , a 1 , . . . , a n − 1 ] = [ a n − 1 , . . . , a 1 , a 0 ] ( rev B ◦ List f ) [ a 0 , a 1 , . . . , a n − 1 ] = rev B ( List f [ a 0 , a 1 , . . . , a n − 1 ]) = rev B [ f a 0 , f a 1 , . . . , f a n − 1 ]) = [ f a n − 1 , . . . , f a 1 , f a 0 ]) = List f [ a n − 1 , . . . , a 1 , a 0 ] = List f ( rev A [ a 0 , a 1 , . . . , a n − 1 ]) = ( List f ◦ rev A ) [ a 0 , a 1 , . . . , a n − 1 ] Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 5 / 24

  6. Everything is natural . . . F , G : Set → Set α : Π A : Set F A → G A f : A → B α A F A G A F f G f F B G B α B Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 6 / 24

  7. . . . but we can’t prove it. We know that all families of functions are natural. But we cannot prove it. It should be a free theorem . Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 7 / 24

  8. The hint (HoTT) F , G : Set → Set α : Π A : Set F A ≃ G A f : A ≃ B α A F A G A F f G f F B G B α B A ≃ B means isomorphism (for sets). This is provable in HoTT. It follows from univalence + J. Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 8 / 24

  9. Summary The set-level fragment of HoTT can be interpreted using the groupoid model (Hofmann & Streicher). This interpretation also gives rise to a univalent, truncated universe of sets (but it doesn’t classify hsets). Can we replace groupoids by categories? Yes, but we need to take care of polarities. And some places we do need groupoids, hence we need an operation calculating the groupoid associated to a category (the core). I am going to derive a type theory guided by the semantics. Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 9 / 24

  10. The category with families of categories Contexts Con : Set Γ : Con [[Γ]] : Cat Types Ty : Con → Set A : Ty Γ [[ A ]] : [[Γ]] → Cat Terms Tm : (Γ : Con ) → Ty Γ → Set a : Tm Γ A [[ a ]] : . . . Subst Tms : Con → Con → Set γ : Tms Γ ∆ [[ γ ]] : [[Γ]] → [[∆]] [[Γ . A ]] � [ [ a ] ] [ [ A ] ] [[Γ]] We write � [[ A ]] for the associated opfibration. Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 10 / 24

  11. Operations on contexts A : Ty Γ • : Con Γ . A : Con | [[ • ]] | = 1 [[ • ]]( x , y ) = 1 | [[Γ . A ]] | = ( x : | [[Γ]] | ) × | [[ A ]] x | [[Γ . A ]](( x , a ) , ( y , b )) = ( f : [[Γ]]( x , y )) × ([[ A ]] y )([[ A ]] f a , b ) Grothendieck construction Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 11 / 24

  12. Opposites A : Ty Γ Γ : Con Γ op : Con A op : Ty Γ [[Γ op ]] = [[Γ]] op [[ A op ]] x = ([[ A ]] x ) op op : Cat → Cat is covariant! Note that But what is (Γ . A ) op ? It cannot be Γ op . A op Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 12 / 24

  13. Fibrations A : Ty Γ op Γ . op A : Con | [[Γ . op A ]] | = ( x : | [[Γ | ]]) × | [[ A ]] x | [[Γ . op A ]](( x , a ) , ( y , b )) = ( f : [[Γ]]( x , y )) × ([[ A ]] x )( a , [[ A ]] f b ) (Γ . A ) op = Γ op . op A op Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 13 / 24

  14. Σ-types, undirected A : Ty Γ B : Ty Γ . A Σ A B : Ty Γ Γ . A . B ∼ = Γ . (Σ A B ) On objects: (Σ A B ) x = ( A x ) . ( B x ) Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 14 / 24

  15. Σ-types with polarities B : Ty Γ . A s A : Ty Γ Σ s A B : Ty Γ = Γ . (Σ s A B ) Γ . A s . B ∼ On objects: (Σ s A B ) x = ( A x ) . s ( B x ) (Σ s A B ) op = Σ s op A op B op Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 15 / 24

  16. Π-types, undirected A : Ty Γ B : Ty Γ . A Π A B : Ty Γ Tm Γ . A B ∼ = Tm Γ (Π A B ) On objects: | [[Π A B ]] x | = Tm ( A x ) ( B x ) Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 16 / 24

  17. Π-types with polarities B : Ty Γ . op A s A : Ty Γ op Π s A B : Ty Γ Tm Γ . op A s B ∼ = Tm Γ (Π s A B ) (Π A B ) op = Π op A op B op On objects: | (Π s A B ) x | = Tm s ( A x ) ( B x ) = Tm ( A x ) s ( B x ) s Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 17 / 24

  18. The universe of sets a : Tm Γ U U : Ty Γ El a : Ty Γ | [[ U ]] x | = Set ([[ U ]] x )( A , B ) = A → B | [[ El a ]] x | = [[ a ]] x ([[ El a ]] x )( y , z ) = ( y = z ) Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 18 / 24

  19. The hom type a : Tm Γ A op b : Tm Γ A a ⊑ A b : Ty Γ [[ a ⊑ A b ]] x = A x ( a x , b x ) But what about id (aka refl)? We would like to say a : Tm Γ A id a : a ⊑ A a but this doesn’t type check! Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 19 / 24

  20. The core type A : Ty Γ a : Tm Γ ¯ A ¯ a : Tm Γ A s A : Ty Γ a : Tm Γ ¯ A id a : a ⊑ A a a , b : Tm Γ ¯ A f : Tm Γ ( a ⊑ A b ) f op : Tm Γ ( b ⊑ A a ) l : Tm Γ ( f ◦ f op ⊑ id a ) r : Tm Γ ( f op ◦ f ⊑ id a ) f , f op , l , r : Tm Γ a ⊑ ¯ A b ) Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 20 / 24

  21. Directed Path induction ( J ) A : Ty Γ a : Tm Γ ¯ A M : Ty Γ , x : A , p : a ⊑ A s x m : Tm Γ M [ x = a , p = id a ] b : Tm Γ A q : Tm Γ a ⊑ A s b J s a M m x p : M [ x = b , p = q ] Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 21 / 24

  22. The homtypes of sets Homtypes of sets are symmetric a : Tm Γ A El a ≃ El a Homtypes of sets are proof irrelevant a : Tm Γ A K a : Tm Γ (Π a : ¯ A , p : a ⊑ A a . p ⊑ id a ) Directed univalence a ⊑ A b ≡ El a → El b Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 22 / 24

  23. Everything is natural, provably! F , G : Set → Set α : Π A : Set F A → G A f : A → B α A F A G A F f G f F B G B α B It follows from directed univalence + directed J. Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 23 / 24

  24. Further work Filippo is formalising the calculus and its semantics in Agda. What is the relation to logical relations? Can we do higher categories (full directed HoTT)? Thorsten Altenkirch jww Filippo Sestini (Nottingham) Naturality for Free March 28, 2019 24 / 24

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