sequence types for hereditary permutators
play

Sequence Types for Hereditary Permutators Pierre VIAL Equipe - PowerPoint PPT Presentation

Sequence Types for Hereditary Permutators Pierre VIAL Equipe Gallinette Inria - LS2N June 25, 2019 Sequence types for hereditary permutators P. Vial 0 1 /22 In a nutshell TLCA Problem # 20 Characterization of a set of terms with an


  1. Intuitions (syntax) Naively, A ∧ B stands for A ∩ B : t is of type A ∧ B if t can be typed with A as well as B . I : A → A I : ( A → B ) → ( A → B ) ∧ − intro (with I = λx.x ) I : ( A → A ) ∧ (( A → B ) → ( A → B )) Intersection = kind of finite polymorphism . ( A → A ) ∧ (( A → B ) → ( A → B )) = double instance of ∀ X.X → X (with X = A and X = A → B ) But less constrained : assigning x : o ∧ ( o → o ′ ) ∧ ( o → o ) → o is legal. ( not an instance of a polymorphic type except ∀ X.X := False !) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 8 /22

  2. Subject Reduction and Subject Expansion A good intersection type system should enjoy: Subject Expansion (SE) : Subject Reduction (SR) : Typing is stable under anti- Typing is stable under reduction. reduction. SE is usually not verified by simple or polymorphic type systems Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 9 /22

  3. Subject Reduction and Subject Expansion A good intersection type system should enjoy: Subject Expansion (SE) : Subject Reduction (SR) : Typing is stable under anti- Typing is stable under reduction. reduction. SE is usually not verified by simple or polymorphic type systems t is typable SR + extra arg. Some reduction strategy normalizes t Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 9 /22

  4. Subject Reduction and Subject Expansion A good intersection type system should enjoy: Subject Expansion (SE) : Subject Reduction (SR) : Typing is stable under anti- Typing is stable under reduction. reduction. SE is usually not verified by simple or polymorphic type systems t is typable SR + extra arg. t can reach a Some reduction strategy normal form normalizes t obvious Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 9 /22

  5. Subject Reduction and Subject Expansion A good intersection type system should enjoy: Subject Expansion (SE) : Subject Reduction (SR) : Typing is stable under anti- Typing is stable under reduction. reduction. SE is usually not verified by simple or polymorphic type systems t is typable typing the NF + SE SR + extra arg. t can reach a Some reduction strategy normal form normalizes t obvious Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 9 /22

  6. Subject Reduction and Subject Expansion A good intersection type system should enjoy: Subject Expansion (SE) : Subject Reduction (SR) : Typing is stable under anti- Typing is stable under reduction. reduction. SE is usually not verified by simple or polymorphic type systems t is typable typing the NF + SE SR + extra arg. t can reach a Some reduction strategy normal form normalizes t obvious reducibility cand. non-trivial well-founded order. non-idem. inter types: trivial size of derivation decreases during red. Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 9 /22

  7. Intersection types (Coppo-Dezani 80) Type constructors: o ∈ O , → and ∧ (intersection). Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 10 /22

  8. Intersection types (Coppo-Dezani 80) Type constructors: o ∈ O , → and ∧ (intersection). Strict types : no inter. on the right h.s. of → , e.g. , ( A ∧ B ) → A , not A → ( B ∧ C ) � no intro/elim. rules for ∧ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 10 /22

  9. Intersection types (Coppo-Dezani 80) Type constructors: o ∈ O , → and ∧ (intersection). Strict types : no inter. on the right h.s. of → , e.g. , ( A ∧ B ) → A , not A → ( B ∧ C ) � no intro/elim. rules for ∧ Assoc.: ( A ∧ B ) ∧ C ∼ A ∧ ( B ∧ C ) Comm.: A ∧ B ∼ B ∧ A i.e. Γ ⊢ t : ( A ∧ B ) ∧ C iff Γ ⊢ t : A ∧ ( B ∧ C ) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 10 /22

  10. Intersection types (Coppo-Dezani 80) Type constructors: o ∈ O , → and ∧ (intersection). Strict types : no inter. on the right h.s. of → , e.g. , ( A ∧ B ) → A , not A → ( B ∧ C ) � no intro/elim. rules for ∧ Assoc.: ( A ∧ B ) ∧ C ∼ A ∧ ( B ∧ C ) Comm.: A ∧ B ∼ B ∧ A i.e. Γ ⊢ t : ( A ∧ B ) ∧ C iff Γ ⊢ t : A ∧ ( B ∧ C ) Idempotency? A ∧ A ∼ A Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 10 /22

  11. Intersection types (Coppo-Dezani 80) Type constructors: o ∈ O , → and ∧ (intersection). Strict types : no inter. on the right h.s. of → , e.g. , ( A ∧ B ) → A , not A → ( B ∧ C ) � no intro/elim. rules for ∧ Assoc.: ( A ∧ B ) ∧ C ∼ A ∧ ( B ∧ C ) Comm.: A ∧ B ∼ B ∧ A i.e. Γ ⊢ t : ( A ∧ B ) ∧ C iff Γ ⊢ t : A ∧ ( B ∧ C ) Idempotency? A ∧ A ∼ A Yes No Coppo-Dezani 80 Gardner 94 - de Carvalho 07 Typing= qualitative info. Typing= quantitative info. Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 10 /22

  12. Intersection types (Coppo-Dezani 80) Type constructors: o ∈ O , → and ∧ (intersection). Strict types : no inter. on the right h.s. of → , e.g. , ( A ∧ B ) → A , not A → ( B ∧ C ) � no intro/elim. rules for ∧ Assoc.: ( A ∧ B ) ∧ C ∼ A ∧ ( B ∧ C ) Comm.: A ∧ B ∼ B ∧ A i.e. Γ ⊢ t : ( A ∧ B ) ∧ C iff Γ ⊢ t : A ∧ ( B ∧ C ) Idempotency? A ∧ A ∼ A Yes No Coppo-Dezani 80 Gardner 94 - de Carvalho 07 Typing= qualitative info. Typing= quantitative info. Collapsing A ∧ B ∧ C into [ A, B, C ] ( multiset ) � no need for perm rules etc. A ∧ B ∧ A := [ A, B, A ] = [ A, A, B ] � = [ A, B ] [ A, B, A ] = [ A, B ] + [ A ] Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 10 /22

  13. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  14. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  15. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Remark Relevant system (no weakening, cf. ax -rule) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  16. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Remark Relevant system (no weakening, cf. ax -rule) Non-idempotency ( σ ∧ σ � = σ ): in app -rule, pointwise multiset sum e.g. , ( x : [ σ ]; y : [ τ ]) + ( x : [ σ, τ ]) = x : [ σ, σ, τ ]; y : [ τ ] Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  17. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Example ax ax f : [ o ] → o x : o ax app f : [ o ] → o f x : o app f ( f x ) : o Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  18. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Example ax ax f : [ o ] → o x : o ax app f : [ o ] → o f x : o app f : [[ o ] → o, [ o ] → o ] , x : [ o ] ⊢ f ( f x ) : o Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  19. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  20. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Head redexes always typed! Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  21. System R 0 (Gardner 94-de Carvalho 07) Types: τ, σ ::= o | [ σ i ] i ∈ I → τ intersection = multiset of types [ σ i ] i ∈ I only on the left-h.s of → ( strictness ) Γ; x : [ σ i ] i ∈ I ⊢ t : τ ax abs x : [ τ ] ⊢ x : τ Γ ⊢ λx.t : [ σ i ] i ∈ I → τ Γ ⊢ t : [ σ i ] i ∈ I → τ (Γ i ⊢ u : σ i ) i ∈ I app Γ + i ∈ I Γ i ⊢ t u : τ Head redexes always typed! but an arg. may be typed 0 time Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 11 /22

  22. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  23. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  24. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  25. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  26. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 By relevance and non-idempotency! ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  27. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  28. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 1 ] ⊢ x : σ 1 ax x :[ σ 2 ] ⊢ x : σ 2 Π a Π b Π 2 1 1 Γ; x :[ σ 1 , σ 2 , σ 1 ] ⊢ r : τ abs ∆ a Γ ⊢ λx.r : [ σ 1 , σ 2 , σ 1 ] → τ 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 ∆ b 1 ⊢ s : σ 1 app Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ ( λx.r ) s : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  29. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] Π b 1 Π a 1 ∆ b 1 ⊢ s : σ 1 Π 2 ∆ a 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ r [ s/x ] : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  30. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] Π b 1 Π a 1 ∆ b 1 ⊢ s : σ 1 Non-determinism of SR Π 2 ∆ a 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ r [ s/x ] : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  31. Subject reduction and expansion in R 0 From a typing of ( λx.r ) s . . . to a typing of r [ s/x ] Π a 1 Π b 1 ∆ a 1 ⊢ s : σ 1 Non-determinism of SR Π 2 ∆ b 1 ⊢ s : σ 1 ∆ 2 ⊢ s : σ 2 Γ + ∆ a 1 + ∆ b 1 + ∆ 2 ⊢ r [ s/x ] : τ Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 12 /22

  32. System S and sequence types [V., Lics’17] Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  33. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  34. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) (3 · σ, 5 · τ, 9 · σ ) vs . [ σ, τ, σ ] Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  35. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Tracking: (3 · σ, 5 · τ, 9 · σ ) = (3 · σ, 5 · τ ) ⊎ (9 · σ ) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  36. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Tracking: (3 · σ, 5 · τ, 9 · σ ) = (3 · σ, 5 · τ ) ⊎ (9 · σ ) vs. [ σ, τ, σ ] = [ σ ? , τ ] + [ σ ? ] Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  37. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Tracking: (3 · σ, 5 · τ, 9 · σ ) = (3 · σ, 5 · τ ) ⊎ (9 · σ ) vs. [ σ, τ, σ ] = [ σ ? , τ ] + [ σ ? ] Why system S ? Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  38. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Tracking: (3 · σ, 5 · τ, 9 · σ ) = (3 · σ, 5 · τ ) ⊎ (9 · σ ) vs. [ σ, τ, σ ] = [ σ ? , τ ] + [ σ ? ] Why system S ? Coinduction necessary to fully type infinite NF Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  39. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Tracking: (3 · σ, 5 · τ, 9 · σ ) = (3 · σ, 5 · τ ) ⊎ (9 · σ ) vs. [ σ, τ, σ ] = [ σ ? , τ ] + [ σ ? ] Why system S ? Coinduction necessary to fully type infinite NF Coinductive type grammar � Ω is typable (unsoundness) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  40. System S and sequence types [V., Lics’17] System S - coinductive type grammar - replace [ σ i ] i ∈ I with ( k · σ k ) k ∈ K sequence type (new intersection) Tracking: (3 · σ, 5 · τ, 9 · σ ) = (3 · σ, 5 · τ ) ⊎ (9 · σ ) vs. [ σ, τ, σ ] = [ σ ? , τ ] + [ σ ? ] Why system S ? Coinduction necessary to fully type infinite NF Coinductive type grammar � Ω is typable (unsoundness) Tracking necessary to recover soundness � approximability (= validity criterion, next slide) System S allows characterizing infinitary weak normalization Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 13 /22

  41. Approximability (intuitions) Order � on the set derivations based on truncation x : [[ ] → o ] ⊢ x : [ ] → o x : [[ o ] → o ] ⊢ x y : o Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  42. Approximability (intuitions) Order � on the set derivations based on truncation x : [[ o ] → o ] ⊢ x : [ o ] → o y : [ o ] ⊢ y : o x : [[ o ] → o ]; y : [ o ] ⊢ x y : o Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  43. Approximability (intuitions) Order � on the set derivations based on truncation (black � black+red) x : [[ o ] → o ] ⊢ x : [ o ] → o y : [ o ] ⊢ y : o x : [[ o ] → o ]; y : [ o ] ⊢ x y : o Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  44. Approximability (intuitions) Order � on the set derivations based on truncation (black � black+red) x : [[ o ] → o ] ⊢ x : [ o ] → o y : [ o ] ⊢ y : o x : [[ o ] → o ]; y : [ o ] ⊢ x y : o P 1 � P 2 � P 1 approximates P 2 Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  45. Approximability (intuitions) Order � on the set derivations based on truncation (black � black+red) x : [[ o ] → o ] ⊢ x : [ o ] → o y : [ o ] ⊢ y : o x : [[ o ] → o ]; y : [ o ] ⊢ x y : o P 1 � P 2 � P 1 approximates P 2 Approximability (def.): a S -derivation P is approximable if it is the supremum of its finite approximations Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  46. Approximability (intuitions) Order � on the set derivations based on truncation (black � black+red) x : [[ o ] → o ] ⊢ x : [ o ] → o y : [ o ] ⊢ y : o x : [[ o ] → o ]; y : [ o ] ⊢ x y : o P 1 � P 2 � P 1 approximates P 2 Approximability (def.): a S -derivation P is approximable if it is the supremum of its finite approximations Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  47. Approximability (intuitions) Order � on the set derivations based on truncation (black � black+red) x : [[ o ] → o ] ⊢ x : [ o ] → o y : [ o ] ⊢ y : o x : [[ o ] → o ]; y : [ o ] ⊢ x y : o P 1 � P 2 � P 1 approximates P 2 Approximability (def.): a S -derivation P is approximable if it is the supremum of its finite approximations Some derivations do not have finite approximations ( e.g. , typings of Ω) Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 14 /22

  48. Properties of system S Sequence types for hereditary permutators P. Vial 1 Intersection types and sequences 15 /22

  49. Plan 1 Intersection types and sequences 2 Characterizing hereditary permutators Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 16 /22

  50. Typing normal h.p. with permutator pairs Goal: Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. Tracks are ignored above! (ok for NF) Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  51. Typing normal h.p. with permutator pairs Goal: h σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x Tracks are ignored above! (ok for NF) h σ ( 1) n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ @ : o λx n λx 1 h Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  52. Typing normal h.p. with permutator pairs Goal: h σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x Tracks are ignored above! (ok for NF) h σ ( 1) n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ we want x : S ⊢ h : T and x 1 : S 1 ⊢ h 1 : T 1 ,. . . , x n : S n ⊢ h n T n @ : o λx n λx 1 h Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  53. Typing normal h.p. with permutator pairs S Goal: h σ (1) : T σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x 1) : T Tracks are ignored above! (ok for NF) h σ ( σ ( 1) n − n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) : T σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ we want x : S ⊢ h : T and x 1 : S 1 ⊢ h 1 : T 1 ,. . . , x n : S n ⊢ h n T n @ : o λx n λx 1 h : T Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  54. Typing normal h.p. with permutator pairs S Goal: h σ (1) : T σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x 1) : T Tracks are ignored above! (ok for NF) h σ ( σ ( 1) n − n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) : T σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ we want x : S ⊢ h : T and x 1 : S 1 ⊢ h 1 : T 1 ,. . . , x n : S n ⊢ h n T n @ : o λx n S n → o λx 1 h : T Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  55. Typing normal h.p. with permutator pairs S Goal: h σ (1) : T σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x 1) : T Tracks are ignored above! (ok for NF) h σ ( σ ( 1) n − n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) : T σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ we want x : S ⊢ h : T and x 1 : S 1 ⊢ h 1 : T 1 ,. . . , x n : S n ⊢ h n T n @ : o λx n S n → o λx 1 h : T = S 1 → . . . → S n → o Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  56. Typing normal h.p. with permutator pairs S = T σ (1) → . . . → T σ ( n ) → o Goal: h σ (1) : T σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x 1) : T Tracks are ignored above! (ok for NF) h σ ( σ ( 1) n − n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) : T σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ we want x : S ⊢ h : T and x 1 : S 1 ⊢ h 1 : T 1 ,. . . , x n : S n ⊢ h n T n @ : o λx n S n → o λx 1 h : T = S 1 → . . . → S n → o Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  57. Typing normal h.p. with permutator pairs S = T σ (1) → . . . → T σ ( n ) → o Goal: h σ (1) : T σ (1) Finding a set of pairs of types ( S, T ) s.t. x : S ⊢ h : T when h is x -h.p. x 1) : T Tracks are ignored above! (ok for NF) h σ ( σ ( 1) n − n − @ h = λx 1 . . . x n .x h σ (1) . . . h σ ( n ) h σ ( n ) : T σ ( n ) h 1 , . . . , h n headed by x 1 , . . . , x n @ we want x : S ⊢ h : T and x 1 : S 1 ⊢ h 1 : T 1 ,. . . , x n : S n ⊢ h n T n @ : o We obtain: λx n S n → o S = T σ (1) → . . . → T σ ( n ) → o and T = S 1 → . . . → S n → o λx 1 h : T = S 1 → . . . → S n → o Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  58. Typing normal h.p. with permutator pairs We obtain: S = T σ (1) → . . . → T σ ( n ) → o and T = S 1 → . . . → S n → o Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  59. Typing normal h.p. with permutator pairs Permutator pairs When o ranges over O (the set of type atoms), the set PP ( o ) of o -permutator pairs ( S, T ), where S and T are S -types, is defined by mutual coinduction: ( S 1 , T 1 ) ∈ PP ( o 1 ) , . . . , ( S n , T n ) ∈ PP ( o n ) σ ∈ S n ((2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o, (2 · S 1 ) → . . . (2 · S n ) → o ) ∈ PP ( o ) We obtain: S = T σ (1) → . . . → T σ ( n ) → o and T = S 1 → . . . → S n → o Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  60. Typing normal h.p. with permutator pairs Permutator pairs When o ranges over O (the set of type atoms), the set PP ( o ) of o -permutator pairs ( S, T ), where S and T are S -types, is defined by mutual coinduction: ( S 1 , T 1 ) ∈ PP ( o 1 ) , . . . , ( S n , T n ) ∈ PP ( o n ) σ ∈ S n ((2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o, (2 · S 1 ) → . . . (2 · S n ) → o ) ∈ PP ( o ) Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  61. Typing normal h.p. with permutator pairs Permutator pairs When o ranges over O (the set of type atoms), the set PP ( o ) of o -permutator pairs ( S, T ), where S and T are S -types, is defined by mutual coinduction: ( S 1 , T 1 ) ∈ PP ( o 1 ) , . . . , ( S n , T n ) ∈ PP ( o n ) σ ∈ S n ((2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o, (2 · S 1 ) → . . . (2 · S n ) → o ) ∈ PP ( o ) A pair ( S, T ) ∈ PP ( o ) is said to be proper , if, for all o ′ ∈ O , o ′ occurs at most once in S and in T . The set of proper o -permutator pairs is denoted PPP ( o ). Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  62. Typing normal h.p. with permutator pairs Permutator pairs When o ranges over O (the set of type atoms), the set PP ( o ) of o -permutator pairs ( S, T ), where S and T are S -types, is defined by mutual coinduction: ( S 1 , T 1 ) ∈ PP ( o 1 ) , . . . , ( S n , T n ) ∈ PP ( o n ) σ ∈ S n ((2 · T σ (1) ) → . . . → (2 · T σ ( n ) ) → o, (2 · S 1 ) → . . . (2 · S n ) → o ) ∈ PP ( o ) A pair ( S, T ) ∈ PP ( o ) is said to be proper , if, for all o ′ ∈ O , o ′ occurs at most once in S and in T . The set of proper o -permutator pairs is denoted PPP ( o ). Characterization of h.p. in system S t is a x -h.p. iff x : (2 · S ) ⊢ t : T for some ( S, T ) ∈ PPP t is a h.p. iff ⊢ t : (2 · S ) → T for some ( S, T ) ∈ PPP . - For ∞ -NF: ⇒ (animation) ⇐ : use properness - non-NF: use ∞ -subj. reduction and expansion Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 17 /22

  63. Towards quotienting Characterization in system S - t is a x -h.p. iff x : (2 · S ) ⊢ t : T (with ( S, T ) perm. pair) - t is a h.p. iff ⊢ t : (2 · S ) → T Proof. NF case: previous slide Use infinitary subject reduction and expansion Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 18 /22

  64. Towards quotienting Characterization in system S - t is a x -h.p. iff x : (2 · S ) ⊢ t : T (with ( S, T ) perm. pair) - t is a h.p. iff ⊢ t : (2 · S ) → T Proof. NF case: previous slide Use infinitary subject reduction and expansion Question: how to give a unique type to all h.p.? Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 18 /22

  65. Towards quotienting Characterization in system S - t is a x -h.p. iff x : (2 · S ) ⊢ t : T (with ( S, T ) perm. pair) - t is a h.p. iff ⊢ t : (2 · S ) → T Proof. NF case: previous slide Use infinitary subject reduction and expansion Question: how to give a unique type to all h.p.? Idea: “collapse” the (2 · S ) → T Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 18 /22

  66. Towards quotienting Characterization in system S - t is a x -h.p. iff x : (2 · S ) ⊢ t : T (with ( S, T ) perm. pair) - t is a h.p. iff ⊢ t : (2 · S ) → T Proof. NF case: previous slide Use infinitary subject reduction and expansion Question: how to give a unique type to all h.p.? Idea: “collapse” the (2 · S ) → T Does this preserve type soundness/completeness? Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 18 /22

  67. Truncation Permutator schemes of degree d Let d ∈ N . A x - permutator scheme of degree d is a term t whose B¨ ohm tree is equal to that of a x -h.p. for applicative depth < d . Applicative depth: number of nestings inside arguments. Any term t is a 0-p.s. h = λx x 1 x 2 . ( x ( λx 1 , 1 x 1 , 2 .x 2 t 1 t 2 ))( λx 2 , 1 .x 1 t 3 ) is a 2-p.s. ( t 1 , 2 , 3 :terms) Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 19 /22

  68. Truncation Permutator schemes of degree d Let d ∈ N . A x - permutator scheme of degree d is a term t whose B¨ ohm tree is equal to that of a x -h.p. for applicative depth < d . Applicative depth: number of nestings inside arguments. Any term t is a 0-p.s. h = λx x 1 x 2 . ( x ( λx 1 , 1 x 1 , 2 .x 2 t 1 t 2 ))( λx 2 , 1 .x 1 t 3 ) is a 2-p.s. ( t 1 , 2 , 3 :terms) Proper permutator pairs of degree d PPP d : truncations (( S ) � d , ( T ) � d ) of a proper permutator pair at domain depth < d (finite types!) Domain depth: number of nestings inside left-hand sides of arrows Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 19 /22

  69. Truncation Permutator schemes of degree d Let d ∈ N . A x - permutator scheme of degree d is a term t whose B¨ ohm tree is equal to that of a x -h.p. for applicative depth < d . Applicative depth: number of nestings inside arguments. Any term t is a 0-p.s. h = λx x 1 x 2 . ( x ( λx 1 , 1 x 1 , 2 .x 2 t 1 t 2 ))( λx 2 , 1 .x 1 t 3 ) is a 2-p.s. ( t 1 , 2 , 3 :terms) Proper permutator pairs of degree d PPP d : truncations (( S ) � d , ( T ) � d ) of a proper permutator pair at domain depth < d (finite types!) Domain depth: number of nestings inside left-hand sides of arrows Characterization in system S t is a d -p.s. headed by x iff x : (2 · S ) ⊢ t : T (with ( S, T ) ∈ PPP d ) Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 19 /22

  70. Truncation Permutator schemes of degree d Let d ∈ N . A x - permutator scheme of degree d is a term t whose B¨ ohm tree is equal to that of a x -h.p. for applicative depth < d . Applicative depth: number of nestings inside arguments. Any term t is a 0-p.s. h = λx x 1 x 2 . ( x ( λx 1 , 1 x 1 , 2 .x 2 t 1 t 2 ))( λx 2 , 1 .x 1 t 3 ) is a 2-p.s. ( t 1 , 2 , 3 :terms) Proper permutator pairs of degree d PPP d : truncations (( S ) � d , ( T ) � d ) of a proper permutator pair at domain depth < d (finite types!) Domain depth: number of nestings inside left-hand sides of arrows Characterization in system S t is a d -p.s. headed by x iff x : (2 · S ) ⊢ t : T (with ( S, T ) ∈ PPP d ) Compatible truncation x : (2 · S ) ⊢ t : T iff, for all d ∈ N , x : (2 · ( S ) � d ) ⊢ t : ( T ) � d Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 19 /22

  71. System S hp System S hp = System S + “Infinitary rule”: “Finitary” rule (level d for all d ): x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP d hp d hp ⊢ λx.t : ptyp ⊢ λx.t : ptyp d Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 20 /22

  72. System S hp System S hp = System S + “Infinitary rule”: “Finitary” rule (level d for all d ): x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP d hp d hp ⊢ λx.t : ptyp ⊢ λx.t : ptyp d Approximability extended with the rule ptyp d � ptyp for all d Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 20 /22

  73. System S hp System S hp = System S + “Infinitary rule”: “Finitary” rule (level d for all d ): x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP d hp d hp ⊢ λx.t : ptyp ⊢ λx.t : ptyp d Approximability extended with the rule ptyp d � ptyp for all d Lemma (inversion for normal forms) Let t be a (finite or not) normal form. Then ⊢ t : ptyp iff t is a hereditary permutator. Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 20 /22

  74. System S hp System S hp = System S + “Infinitary rule”: “Finitary” rule (level d for all d ): x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP x : (2 · S ) ⊢ t : T ( S, T ) ∈ PPP d hp d hp ⊢ λx.t : ptyp ⊢ λx.t : ptyp d Approximability extended with the rule ptyp d � ptyp for all d Lemma (inversion for normal forms) Let t be a (finite or not) normal form. Then ⊢ t : ptyp iff t is a hereditary permutator. Lemma (compatible truncation in S hp ) Let t be a (finite or not) normal form. Then ⊢ t : ptyp iff t ⊢ t : ptyp d . Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 20 /22

  75. Dynamic properties and final characterization Finitary soundness If P proves C ⊢ t : T in S hp and P is finite, then t is HN. Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 21 /22

  76. Dynamic properties and final characterization Finitary soundness If P proves C ⊢ t : T in S hp and P is finite, then t is HN. Infinitary subject reduction in S hp If t → ∞ t ′ and C ⊢ t : T then C ⊢ t ′ : T . t → ∞ t ′ : ∞ -productive reduction path, possibly computing the B¨ ohm tree of t Sequence types for hereditary permutators P. Vial 2 Characterizing hereditary permutators 21 /22

Recommend


More recommend