cumulative types systems and levels
play

Cumulative Types Systems and Levels Franois Thir June 22, 2019 - PowerPoint PPT Presentation

Cumulative Types Systems and Levels Franois Thir June 22, 2019 LSV, CNRS, Inria, ENS Paris-Saclay 1 Logipedia (http://logipedia.science) Matita HOL D[STT ] D[CiC] Agda Coq D[MLTT] D[CiC] Dedukti 2 Logipedia


  1. Cumulative Types Systems and Levels François Thiré June 22, 2019 LSV, CNRS, Inria, ENS Paris-Saclay 1

  2. Logipedia (http://logipedia.science) Matita HOL D[STT ∀ ] D[CiC] Agda Coq D[MLTT] D[CiC] Dedukti 2

  3. Logipedia (http://logipedia.science) Matita HOL D[ C M + . . . ] D[ C H + . . . ] Agda Coq D[ C A + . . . ] D[ C C + . . . ] Dedukti 2

  4. Cumulative Type Systems C = ( S , A , R , C ) Sorts Cumul. Axioms Rules Syntax t , u , A , B ::= s ∈ S | x | t u | λ x : A . t | ( x : A ) → B Γ ⊢ C A : s 1 Γ , x : A ⊢ C B : s 2 ( s 1 , s 2 , s 3 ) ∈ R Π Γ ⊢ C ( x : A ) → B : s 3 Γ ⊢ o ( s 1 , s 2 ) ∈ A C wf C sort Γ ⊢ o C s 1 : s 2 A � C Γ ⊢ C t : A Γ ⊢ C B : s C B Conv ( CTS ) 3 Γ ⊢ C t : B

  5. Cumulative Type Systems C = ( S , A , R , ∅ ) Sorts Cumul. Axioms Rules Syntax t , u , A , B ::= s ∈ S | x | t u | λ x : A . t | ( x : A ) → B Γ ⊢ C A : s 1 Γ , x : A ⊢ C B : s 2 ( s 1 , s 2 , s 3 ) ∈ R Π Γ ⊢ C ( x : A ) → B : s 3 Γ ⊢ o ( s 1 , s 2 ) ∈ A C wf C sort Γ ⊢ o C s 1 : s 2 Γ ⊢ C t : A Γ ⊢ C B : s A ≡ β B Conv ( PTS ) 3 Γ ⊢ C t : B

  6. Translations Matita HOL D[ C M + . . . ] D[ C H + . . . ] Agda Coq D[ C A + . . . ] D[ C C + . . . ] Dedukti 4

  7. Strange loop 1 Correctness of the translation: Γ ⊢ C t : A ⇒ � Γ � ⊢ D [ t ] : � A � 5

  8. Strange loop 1 Correctness of the translation: Γ ⊢ C t : A ⇒ � Γ � ⊢ D [ t ] : � A � Main lemma: 1. A ≡ β B ⇒ � A � ≡ β � B � 5

  9. Strange loop 1 Correctness of the translation: Γ ⊢ C t : A ⇒ � Γ � ⊢ D [ t ] : � A � Main lemma: 1. A ≡ β B ⇒ � A � ≡ β � B � 2. [ t ] { x ← [ N ] } = [ t { x ← N } ] Dependencies: • 1 → 2 5

  10. Strange loop 1 Correctness of the translation: Γ ⊢ C t : A ⇒ � Γ � ⊢ D [ t ] : � A � Main lemma: 1. A ≡ β B ⇒ � A � ≡ β � B � 2. [ t ] { x ← [ N ] } = [ t { x ← N } ] Dependencies: Γ ⊢ C t : A • 1 → 2 Γ ⊢ C B : s A ≡ β B Conv • 2 → 1 Γ ⊢ C t : B 5

  11. Strange loop 1 Correctness of the translation: Γ ⊢ C t : A ⇒ � Γ � ⊢ D [ t ] : � A � Main lemma: 1. A ≡ β B ⇒ � A � ≡ β � B � 2. [ t ] { x ← [ N ] } = [ t { x ← N } ] Dependencies: Γ ⊢ C t : A • 1 → 2 Γ ⊢ C B : s A ≡ β B Conv • 2 → 1 but for the type Γ ⊢ C t : B 5

  12. Expansion Postponement Γ ⊢ C t : A A ≡ β B Conv Γ ⊢ C t : B ⇒ ⇒ → ∗ ֓ ∗ Γ ⊢ C t : A A ֒ β B Γ ⊢ C t : A A ← β B Red Exp Γ ⊢ C t : B Γ ⊢ C t : B Expansion postponement β A ′ ∧ Γ ⊢ r Γ ⊢ C t : A ⇔ ∃ A ′ , A ֒ → ∗ C t : A ′ 6

  13. Expansion Postponement Γ ⊢ C t : A A ≡ β B Conv Γ ⊢ C t : B ⇒ Γ ⊢ r → ∗ C t : A A ֒ β B Red Γ ⊢ r C t : B Expansion postponement β A ′ ∧ Γ ⊢ r Γ ⊢ C t : A ⇔ ∃ A ′ , A ֒ → ∗ C t : A ′ 6

  14. Strange Loop 2 Let’s try to prove Expansion Postponement (abstraction case): Γ , x : A ⊢ C t : B Γ ⊢ C ( x : A ) → B : s λ Γ ⊢ C λ x : A . t : ( x : A ) → B ? 7

  15. Strange Loop 2 Let’s try to prove Expansion Postponement (abstraction case): Γ , x : A ⊢ C t : B Γ ⊢ r Γ ⊢ C ( x : A ) → B : s C ( x : A ) → B : s λ Γ ⊢ C λ x : A . t : ( x : A ) → B ? 7

  16. Strange Loop 2 Let’s try to prove Expansion Postponement (abstraction case): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B Γ ⊢ r Γ ⊢ C ( x : A ) → B : s C ( x : A ) → B : s λ Γ ⊢ C λ x : A . t : ( x : A ) → B ? 7

  17. Strange Loop 2 Let’s try to prove Expansion Postponement (abstraction case): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B Γ ⊢ r Γ ⊢ C ( x : A ) → B : s C ( x : A ) → B : s λ r λ Γ ⊢ C λ x : A . t : ( x : A ) → B ? You need subject reduction for Γ ⊢ r C t : ( x : A ) → B ! But... 7

  18. Strange Loop 2 Let’s try to prove Expansion Postponement (abstraction case): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B Γ ⊢ r Γ ⊢ C ( x : A ) → B : s C ( x : A ) → B : s λ r λ Γ ⊢ C λ x : A . t : ( x : A ) → B ? You need subject reduction for Γ ⊢ r C t : ( x : A ) → B ! But... 1. Subject Reduction needs the substitution lemma 2. The substitution lemma needs subject reduction (for the same reason as above) on the type 7

  19. Explicit conversion Γ ⊢ C t : A A ≡ β B Conv Γ ⊢ C t : B ⇓ Γ ⊢ e Γ ⊢ e C A ≡ β B : s C t : A Red Γ ⊢ e C t : B 8

  20. Explicit conversion Γ ⊢ C t : A A ≡ β B Conv Γ ⊢ C t : B Γ ⊢ e Γ ⊢ e C A : s 1 C B : s 2 ⇓ Γ ⊢ e Γ , x : A ⊢ e C N : A C M : B ( s 1 , s 2 , s 3 ) ∈ R C Γ ⊢ e Γ ⊢ e C A ≡ β B : s C ≡ β C t : A beta Γ ⊢ e C ( λ x : A . M ) N ≡ β M { x ← N } : B { x ← N } Red Γ ⊢ e C t : B . . . 8

  21. Explicit conversion Γ ⊢ C t : A A ≡ β B Conv Γ ⊢ C t : B ⇓ Γ ⊢ e Γ ⊢ e C A ≡ β B : s C t : A Red Γ ⊢ e C t : B Equivalence from implicit to explicit conversion Γ ⊢ C t : A ⇔ Γ ⊢ e C t : A 8

  22. Strange Loop 3 Let’s try to prove the equivalence (conversion case): Γ ⊢ C t : A Γ ⊢ C B : s A ≡ β B Conv Γ ⊢ C t : B 9

  23. Strange Loop 3 Let’s try to prove the equivalence (conversion case): Γ ⊢ e C t : A Γ ⊢ e C B : s Γ ⊢ C t : A Γ ⊢ C B : s A ≡ β B Conv Γ ⊢ C t : B 9

  24. Strange Loop 3 Let’s try to prove the equivalence (conversion case): Γ ⊢ e C t : A Γ ⊢ e C B : s Γ ⊢ C t : A Γ ⊢ C B : s A ≡ β B We cannot use subject reduction on Γ ⊢ C B : s Conv Γ ⊢ C t : B 9

  25. Strange Loop 3 Let’s try to prove the equivalence (conversion case): Γ ⊢ e C t : A Γ ⊢ e C B : s Γ ⊢ C t : A Γ ⊢ e C A ≡ β B : s Γ ⊢ C B : s A ≡ β B Conv e Conv Γ ⊢ e C t : B Γ ⊢ C t : B Instead, it would be easy if we had already proved the equivalence for the types ( Γ ⊢ e C A : s and Γ ⊢ e C B : s ) thanks to subject reduction. 9

  26. Strange Loop 3 Let’s try to prove the equivalence (conversion case): Γ ⊢ e C t : A Γ ⊢ e C B : s Γ ⊢ C t : A Γ ⊢ e C A ≡ β B : s Γ ⊢ C B : s A ≡ β B Conv e Conv Γ ⊢ e C t : B Γ ⊢ C t : B 9

  27. Levels We are looking for a measure which is: 1. strictly decreasing from a term t to its type A 2. stable by β 3. stable by subtree 10

  28. Levels Lets denote > D : D → D → P , a relation on derivation trees such that Π ′ Π 1. ( A �∈ S ) > D Γ ⊢ C t : A Γ ⊢ C A : s Π ′ Π → β t ′ ) ≥ D 2. (if t ֒ Γ ⊢ C t ′ : A Γ ⊢ C t : A Π ′ Π (if Π ′ is a subtree of Π ) ≥ D 3. Γ ′ ⊢ C u : B Γ ⊢ C t : A Theorem The existence of > D implies a measure function L : D → O where O is a well-ordered set. 11

  29. Levels are nice Theorem If > D exists, then we have the correctness of the CTS encoding into Dedukti Theorem If > D exists, then we have expansion postponement Theorem If > D exists, then we have the equivalence between the implicit and the explicit conversion 12

  30. Proof of expansion postponement with levels Theorem The existence of > D implies expansion postponement: β A ′ ∧ Γ ⊢ r Γ ⊢ C t : A ⇔ ∃ A ′ , A ֒ → ∗ C t : A ′ Proof. By induction given by the measure function L . • Base case is trivial (though an induction on the derivation tree is needed). • Inductive case is proved by induction on the derivation tree. 13

  31. Proving the inductive case Assuming expansion postponement at level o ′ , we want to prove expansion postponement at level o (where o > D o ′ ): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B Γ ⊢ C ( x : A ) → B : s λ r λ Γ ⊢ r Γ ⊢ C λ x : A . t : ( x : A ) → B C λ x : A . t : ( x : A ) → B 14

  32. Proving the inductive case Assuming expansion postponement at level o ′ , we want to prove expansion postponement at level o (where o > D o ′ ): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B Γ ⊢ C ( x : A ) → B : s λ r λ Γ ⊢ r Γ ⊢ C λ x : A . t : ( x : A ) → B C λ x : A . t : ( x : A ) → B • L (Γ ⊢ C ( x : A ) → B : s ) = o 1 with o > D o 1 14

  33. Proving the inductive case Assuming expansion postponement at level o ′ , we want to prove expansion postponement at level o (where o > D o ′ ): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B Γ ⊢ C ( x : A ) → B : s λ r λ Γ ⊢ r Γ ⊢ C λ x : A . t : ( x : A ) → B C λ x : A . t : ( x : A ) → B • L (Γ ⊢ C ( x : A ) → B : s ) = o 1 with o > D o 1 • L (Γ ⊢ C ( x : A ) → B ′ : s ) ≤ D o 1 from second condition of > D 14

  34. Proving the inductive case Assuming expansion postponement at level o ′ , we want to prove expansion postponement at level o (where o > D o ′ ): Γ , x : A ⊢ r C t : B ′ Γ , x : A ⊢ C t : B C ( x : A ) → B ′ : s Γ ⊢ r Γ ⊢ C ( x : A ) → B : s λ r λ Γ ⊢ r Γ ⊢ C λ x : A . t : ( x : A ) → B C λ x : A . t : ( x : A ) → B • L (Γ ⊢ C ( x : A ) → B : s ) = o 1 with o > D o 1 • L (Γ ⊢ C ( x : A ) → B ′ : s ) ≤ D o 1 from second condition of > D C ( x : A ) → B ′ : s by EP • Γ ⊢ r 14

  35. The big question Is it possible to find an order > D ? 15

Recommend


More recommend