![Page 1: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/1.jpg)
Computational (Higher) Type Theory
Robert Harper and Carlo Angiuli
Computer Science DepartmentCarnegie Mellon University
ACM PoPL Tutorial Session January 2018
![Page 2: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/2.jpg)
Vladimir Voevodsky 1966-2017Photo credit: Wikipedia
![Page 3: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/3.jpg)
Acknowledgements
Thanks to many, including
• Collaborators: Evan Cavallo, Kuen-Bang Hou (Favonia), Daniel R. Licata,Jonathan Sterling, Todd Wilson.
• Colleagues: Steve Awodey, Marc Bezem, Guillaume Brunerie, Thierry Coquand,Simon Huber, Anders Mortberg.
• Inspiration: Robert Constable, Per Martin-Lof, Dana Scott, Vladimir Voevodsky.
Supported by AFOSR MURI FA9550-15-1-0053.
![Page 4: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/4.jpg)
References
Primary sources for these lectures:
• Carlo Angiuli and Robert Harper. “Meaning Explanations at Higher Dimension.”Indagationes Mathematicae 29 (2018), pages 135–149. Special Issue: L.E.J. Brouwerafter 50 years.
• Carlo Angiuli, Kuen-Bang Hou (Favonia), and Robert Harper. “Computational HigherType Theory III: Univalent Universes and Exact Equality.”https://arxiv.org/abs/1712.01800.
• Evan Cavallo and Robert Harper. “Computational Higher Type Theory IV: InductiveTypes.” https://arxiv.org/abs/1801.01568.
See also:
• Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mortberg. “Cubical typetheory: a constructive interpretation of the univalence axiom.” To appear, 2018.
• Carlo Angiuli, Guillaume Brunerie, Thierry Coquand, Kuen-Bang Hou (Favonia), RobertHarper, and Daniel R. Licata. “Cartesian Cubical Type Theory.” To appear, 2018.
![Page 5: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/5.jpg)
Formal Type TheoryMartin-Lof; Coquand; HoTT
A formal type theory is inductively defined by rules:
• Formation: Γ ` A type, Γ ` M : A.
• Definitional equivalence: Γ ` A ≡ B, Γ ` M ≡ N : A.
Axioms and rules are chosen to ensure:
• Not non-constructive, eg no unrestricted LEM.
• Formal correspondence to logics, eg HA, IHOL.
• Decidability of all assertions.
Ought to admit a computational interpretation as programs.
![Page 6: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/6.jpg)
Formal Type TheoryMartin-Lof; Coquand; HoTT
A formal type theory is inductively defined by rules:
• Formation: Γ ` A type, Γ ` M : A.
• Definitional equivalence: Γ ` A ≡ B, Γ ` M ≡ N : A.
Axioms and rules are chosen to ensure:
• Not non-constructive, eg no unrestricted LEM.
• Formal correspondence to logics, eg HA, IHOL.
• Decidability of all assertions.
Ought to admit a computational interpretation as programs.
![Page 7: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/7.jpg)
Formal Type TheoryMartin-Lof; Coquand; HoTT
A formal type theory is inductively defined by rules:
• Formation: Γ ` A type, Γ ` M : A.
• Definitional equivalence: Γ ` A ≡ B, Γ ` M ≡ N : A.
Axioms and rules are chosen to ensure:
• Not non-constructive, eg no unrestricted LEM.
• Formal correspondence to logics, eg HA, IHOL.
• Decidability of all assertions.
Ought to admit a computational interpretation as programs.
![Page 8: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/8.jpg)
Intensional Type TheoryMartin-Lof
The canonical formal dependent type theory: ITT.
• Inductive types: nat, bool, sums, well-founded trees.
• Dependent function and product types: Πx :A.B, Σx :A.B.
• Identity type: IdA(M,N).
Identity type is the least reflexive relation:
• Reflexivity: reflA(M) : IdA(M,M).
• Induction: if P : IdA(M,N) and u:A ` Q : C [M,M, reflA(M)],then J(u.Q;P) : C [M,N,P].
![Page 9: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/9.jpg)
Intensional Type TheoryMartin-Lof
The canonical formal dependent type theory: ITT.
• Inductive types: nat, bool, sums, well-founded trees.
• Dependent function and product types: Πx :A.B, Σx :A.B.
• Identity type: IdA(M,N).
Identity type is the least reflexive relation:
• Reflexivity: reflA(M) : IdA(M,M).
• Induction: if P : IdA(M,N) and u:A ` Q : C [M,M, reflA(M)],then J(u.Q;P) : C [M,N,P].
![Page 10: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/10.jpg)
Computational Meaning of ITTMartin-Lof
Normalization: reduction of open terms.
• Variables are indeterminates, obey substitution.
• Canonicity via characterization of closed normal forms.
Meaning explanations: evaluation of closed terms.
• Variables range over closed terms, obey functionality.
• Canonicity by definition of observable values.
![Page 11: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/11.jpg)
Computational Meaning of ITTMartin-Lof
Normalization: reduction of open terms.
• Variables are indeterminates, obey substitution.
• Canonicity via characterization of closed normal forms.
Meaning explanations: evaluation of closed terms.
• Variables range over closed terms, obey functionality.
• Canonicity by definition of observable values.
![Page 12: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/12.jpg)
Identity Type in ITT
Equational reasoning is handled by the identity type:
x : nat, y : nat ` P(x , y) : Idnat(x + y , y + x)
The proof P(x , y) is non-trivial: induction on x and y .
Type families respect identity proofs:
x , y : nat ` Vec†(P(x , y)) : IdU (Vec(x + y),Vec(y + x)).
![Page 13: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/13.jpg)
Identity Type in ITT
Equational reasoning is handled by the identity type:
x : nat, y : nat ` P(x , y) : Idnat(x + y , y + x)
The proof P(x , y) is non-trivial: induction on x and y .
Type families respect identity proofs:
x , y : nat ` Vec†(P(x , y)) : IdU (Vec(x + y),Vec(y + x)).
![Page 14: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/14.jpg)
Identity Type in ITT
Identity proofs in IdU (A,B) induce coercions:
a, b : U , p : IdU (a, b) ` coerce(p) : a→ b
In particular, for any M,N : nat,
coerce(Vec†(P(M,N))) : Vec(M + N)→ Vec(N + M)
But for closed M and N these types are definitionally equal!
Thus, no coercion is needed at run-time!
![Page 15: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/15.jpg)
Identity Type in ITT
Identity proofs in IdU (A,B) induce coercions:
a, b : U , p : IdU (a, b) ` coerce(p) : a→ b
In particular, for any M,N : nat,
coerce(Vec†(P(M,N))) : Vec(M + N)→ Vec(N + M)
But for closed M and N these types are definitionally equal!
Thus, no coercion is needed at run-time!
![Page 16: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/16.jpg)
Program Extraction for ITTCoq
Program extraction exploits irrelevance of identity proofs.
• Evaluate only closed terms of observable type.
• Erase uses of identity elimination.
Meaning explanation emphasizes extraction and execution.
• No transport operations to erase.
• Exact equality: x , y : nat� x + y.
= y + x ∈ nat.
![Page 17: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/17.jpg)
Program Extraction for ITTCoq
Program extraction exploits irrelevance of identity proofs.
• Evaluate only closed terms of observable type.
• Erase uses of identity elimination.
Meaning explanation emphasizes extraction and execution.
• No transport operations to erase.
• Exact equality: x , y : nat� x + y.
= y + x ∈ nat.
![Page 18: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/18.jpg)
Homotopy Type TheoryHofmann & Streicher; Awodey & Warren; Voevodsky
IdA(M,N) may be considered as type of paths.
Univalence: if E : Equiv(A,B) is an equivalence, then
ua(E ) : IdU (A,B).
Higher inductive types, such as the “circle”, C:
base : Cloop : IdC(base, base).
![Page 19: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/19.jpg)
Homotopy Type TheoryHofmann & Streicher; Awodey & Warren; Voevodsky
IdA(M,N) may be considered as type of paths.
Univalence: if E : Equiv(A,B) is an equivalence, then
ua(E ) : IdU (A,B).
Higher inductive types, such as the “circle”, C:
base : Cloop : IdC(base, base).
![Page 20: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/20.jpg)
Homotopy Type Theory
Coercions are no longer erasable!
coerce(ua(. . . )) : nat + nat→ bool× nat
(Even for closed terms.)
What is the computational content of HoTT?
coerce(ua(. . . )) 7−→ ???
Identity elimination does not eliminate identifications!
![Page 21: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/21.jpg)
Homotopy Type Theory
Coercions are no longer erasable!
coerce(ua(. . . )) : nat + nat→ bool× nat
(Even for closed terms.)
What is the computational content of HoTT?
coerce(ua(. . . )) 7−→ ???
Identity elimination does not eliminate identifications!
![Page 22: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/22.jpg)
Higher Meaning Explanations
Judgmental account of higher structure of types:
• What is a path in a type?
• Define the action of a path.
• Ensure that paths can be composed.
Identity type splits into two concepts:
• Exact equality: M.
= N ∈ A.
• Path type: Pathx .A(M,N).
![Page 23: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/23.jpg)
Higher Meaning Explanations
Judgmental account of higher structure of types:
• What is a path in a type?
• Define the action of a path.
• Ensure that paths can be composed.
Identity type splits into two concepts:
• Exact equality: M.
= N ∈ A.
• Path type: Pathx .A(M,N).
![Page 24: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/24.jpg)
Computational Meaning ExplanationsMartin-Lof; Constable; Allen
Start with a programming language:
• Programs are closed terms.
• Evaluation M ⇓ V to a canonical form aka value.
Types are programs that name specifications of programs.
• A type means A ⇓ V and V names a specification.
• if A type, then M.
= M ′ ∈ A means M ⇓ V and M ′ ⇓ V ′ and V and V ′ behavethe same in the sense of A.
What matters is behavior, not form!
![Page 25: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/25.jpg)
Computational Meaning ExplanationsMartin-Lof; Constable; Allen
Start with a programming language:
• Programs are closed terms.
• Evaluation M ⇓ V to a canonical form aka value.
Types are programs that name specifications of programs.
• A type means A ⇓ V and V names a specification.
• if A type, then M.
= M ′ ∈ A means M ⇓ V and M ′ ⇓ V ′ and V and V ′ behavethe same in the sense of A.
What matters is behavior, not form!
![Page 26: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/26.jpg)
Computational Meaning ExplanationsMartin-Lof; Constable; Allen
Start with a programming language:
• Programs are closed terms.
• Evaluation M ⇓ V to a canonical form aka value.
Types are programs that name specifications of programs.
• A type means A ⇓ V and V names a specification.
• if A type, then M.
= M ′ ∈ A means M ⇓ V and M ′ ⇓ V ′ and V and V ′ behavethe same in the sense of A.
What matters is behavior, not form!
![Page 27: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/27.jpg)
Computational Meaning Explanations
Variables are interpreted semantically.
• Range over closed terms satisfying a type.
• Respect equality at that type.
Functionality: a : A� N ∈ B means
M.
= M ′ ∈ A implies N[M/a].
= N[M ′/a] ∈ B[M/a].
Extensionality: a : A� N.
= N ′ ∈ B means
M.
= M ′ ∈ A implies N[M/a].
= N ′[M ′/a] ∈ B[M/a].
![Page 28: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/28.jpg)
Computational Meaning Explanations
Variables are interpreted semantically.
• Range over closed terms satisfying a type.
• Respect equality at that type.
Functionality: a : A� N ∈ B means
M.
= M ′ ∈ A implies N[M/a].
= N[M ′/a] ∈ B[M/a].
Extensionality: a : A� N.
= N ′ ∈ B means
M.
= M ′ ∈ A implies N[M/a].
= N ′[M ′/a] ∈ B[M/a].
![Page 29: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/29.jpg)
Computational Meaning Explanations
Proof theories are secondary, a matter of pragmatics.
• No privileged proof theory. (Down with C-H!).
• No requirement of decidability of judgments.
RedPRL proof theory is a refinement logic.
• Inspired by NuPRL.
• Emphasizes program extraction.
Inverts the conceptual order in ITT and related formalisms!
![Page 30: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/30.jpg)
Computational Meaning Explanations
Proof theories are secondary, a matter of pragmatics.
• No privileged proof theory. (Down with C-H!).
• No requirement of decidability of judgments.
RedPRL proof theory is a refinement logic.
• Inspired by NuPRL.
• Emphasizes program extraction.
Inverts the conceptual order in ITT and related formalisms!
![Page 31: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/31.jpg)
Computational Meaning Explanations
Proof theories are secondary, a matter of pragmatics.
• No privileged proof theory. (Down with C-H!).
• No requirement of decidability of judgments.
RedPRL proof theory is a refinement logic.
• Inspired by NuPRL.
• Emphasizes program extraction.
Inverts the conceptual order in ITT and related formalisms!
![Page 32: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/32.jpg)
Computational Meaning Explanations
A specification is a symmetric, transitive relation on closed values.
Equal specifications must specify the same behavior,i.e., be interchangeable as classifiers.
The construction of a type system ensures that specifications satisfy these conditions.
![Page 33: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/33.jpg)
Booleans
Programs:
• bool, true, false are canonical.
• if (true;P;Q) 7−→ P.
• if (false;P;Q) 7−→ Q.
• if M 7−→ M ′ then if (M;P;Q) 7−→ if (M ′;P;Q).
The type bool specifies that true and false are equal only to themselves.
bool is an inductive type.
![Page 34: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/34.jpg)
Booleans
Programs:
• bool, true, false are canonical.
• if (true;P;Q) 7−→ P.
• if (false;P;Q) 7−→ Q.
• if M 7−→ M ′ then if (M;P;Q) 7−→ if (M ′;P;Q).
The type bool specifies that true and false are equal only to themselves.
bool is an inductive type.
![Page 35: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/35.jpg)
Booleans
Theorem (Dependent Elimination)
If M ∈ bool and P ∈ A[true/a] and Q ∈ A[false/a], then if (M;P;Q) ∈ A[M/a].
Theorem (Behavioral Typing)
If M.
= true ∈ bool and P ∈ A[true/a], then if (M;P;Q) ∈ A[M/a].
Theorem (Shannon Expansion)
If a : bool� M ∈ A, then
a : bool� M.
= if(a;M[true/a];M[false/a]) ∈ A.
![Page 36: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/36.jpg)
Booleans
Theorem (Dependent Elimination)
If M ∈ bool and P ∈ A[true/a] and Q ∈ A[false/a], then if (M;P;Q) ∈ A[M/a].
Theorem (Behavioral Typing)
If M.
= true ∈ bool and P ∈ A[true/a], then if (M;P;Q) ∈ A[M/a].
Theorem (Shannon Expansion)
If a : bool� M ∈ A, then
a : bool� M.
= if(a;M[true/a];M[false/a]) ∈ A.
![Page 37: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/37.jpg)
Booleans
Theorem (Dependent Elimination)
If M ∈ bool and P ∈ A[true/a] and Q ∈ A[false/a], then if (M;P;Q) ∈ A[M/a].
Theorem (Behavioral Typing)
If M.
= true ∈ bool and P ∈ A[true/a], then if (M;P;Q) ∈ A[M/a].
Theorem (Shannon Expansion)
If a : bool� M ∈ A, then
a : bool� M.
= if(a;M[true/a];M[false/a]) ∈ A.
![Page 38: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/38.jpg)
Functions
Programs:
• (a:A)→ B and λa.M are canonical.
• app(λa.P,N) 7−→ P[N/a].
• if M 7−→ M ′, then app(M,N) 7−→ app(M ′,N).
The value λa.M satisfies the spec. (a:A)→ B iff
a : A� M ∈ B.
Values λa.M and λa.M ′ are equal in (a:A)→ B iff
a : A� M.
= M ′ ∈ B [Ψ].
![Page 39: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/39.jpg)
Functions
Programs:
• (a:A)→ B and λa.M are canonical.
• app(λa.P,N) 7−→ P[N/a].
• if M 7−→ M ′, then app(M,N) 7−→ app(M ′,N).
The value λa.M satisfies the spec. (a:A)→ B iff
a : A� M ∈ B.
Values λa.M and λa.M ′ are equal in (a:A)→ B iff
a : A� M.
= M ′ ∈ B [Ψ].
![Page 40: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/40.jpg)
Functions
Programs:
• (a:A)→ B and λa.M are canonical.
• app(λa.P,N) 7−→ P[N/a].
• if M 7−→ M ′, then app(M,N) 7−→ app(M ′,N).
The value λa.M satisfies the spec. (a:A)→ B iff
a : A� M ∈ B.
Values λa.M and λa.M ′ are equal in (a:A)→ B iff
a : A� M.
= M ′ ∈ B [Ψ].
![Page 41: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/41.jpg)
Functions
Theorem (Dependent Elim)
If M ∈ (a:A)→ B, and N ∈ A, then app(M,N) ∈ B[N/a].
Theorem (β Equality)
If λa.P ∈ (a:A)→ B and N ∈ A, then
app(λa.P,N).
= P[N/a] ∈ B[N/a].
Theorem (Extensionality)
If a : A� app(M, a).
= app(N, a) ∈ B, then
M.
= N ∈ (a:A)→ B.
![Page 42: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/42.jpg)
Functions
Theorem (Dependent Elim)
If M ∈ (a:A)→ B, and N ∈ A, then app(M,N) ∈ B[N/a].
Theorem (β Equality)
If λa.P ∈ (a:A)→ B and N ∈ A, then
app(λa.P,N).
= P[N/a] ∈ B[N/a].
Theorem (Extensionality)
If a : A� app(M, a).
= app(N, a) ∈ B, then
M.
= N ∈ (a:A)→ B.
![Page 43: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/43.jpg)
Functions
Theorem (Dependent Elim)
If M ∈ (a:A)→ B, and N ∈ A, then app(M,N) ∈ B[N/a].
Theorem (β Equality)
If λa.P ∈ (a:A)→ B and N ∈ A, then
app(λa.P,N).
= P[N/a] ∈ B[N/a].
Theorem (Extensionality)
If a : A� app(M, a).
= app(N, a) ∈ B, then
M.
= N ∈ (a:A)→ B.
![Page 44: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/44.jpg)
Exact EqualityMartin-Lof
Programs:
• EqA(M,N) and ? are canonical.
• No elimination form needed!
The value ? satisfies spec. EqA(M,N) iff M.
= N ∈ A.
The value ? is equal only to itself whenever it satisfies EqA(M,N).
![Page 45: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/45.jpg)
Exact EqualityMartin-Lof
TheoremIf M ∈ A, then ? ∈ EqA(M,M).
TheoremIf P ∈ EqA(M,N), then M
.= N ∈ A.
![Page 46: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/46.jpg)
Exact EqualityMartin-Lof
TheoremIf M ∈ A, then ? ∈ EqA(M,M).
TheoremIf P ∈ EqA(M,N), then M
.= N ∈ A.
![Page 47: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/47.jpg)
Demonstration
Please enjoy Carlo’s demo of RedPRL!
![Page 48: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/48.jpg)
Obligatory Cat PhotoThanks to Tran Ma
![Page 49: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/49.jpg)
Higher Meaning Explanations
HoTT encodes path structure in identification types:
A, IdA(M,N), IdIdA(M,N)(P,Q), . . .
Paths re-expressed using the interval I = [0, 1]:
• Points: A.
• Lines btw points: I A,
• Squares, lines btw lines: I (I A) ∼= I2 ; A,
• Cubes, lines btw squares: I3 A, . . .
• n-cubes: In A
![Page 50: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/50.jpg)
Higher Meaning Explanations
HoTT encodes path structure in identification types:
A, IdA(M,N), IdIdA(M,N)(P,Q), . . .
Paths re-expressed using the interval I = [0, 1]:
• Points: A.
• Lines btw points: I A,
• Squares, lines btw lines: I (I A) ∼= I2 ; A,
• Cubes, lines btw squares: I3 A, . . .
• n-cubes: In A
![Page 51: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/51.jpg)
Cubical Programming LanguageLicata, Brunerie; Coquand, et al.
Cubical syntax:
• Dimensions r := 0 | 1 | x .
• Contexts Ψ = x1, . . . , xn.
• Substitutions ψ = 〈r1/x1, . . . rn/xn〉 : Ψ′ → Ψ.
• Action on terms: M ψ
Cartesian cubes = substitutions are structural:
• Faces: 0/x , 1/x .
• Re-indexing: y/x .
• Weakening aka degeneracy: silent.
• Exchange aka symmetry: y , x/x , y .
• Contraction aka diagonal: z , z/x , y .
![Page 52: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/52.jpg)
Cubical Programming LanguageLicata, Brunerie; Coquand, et al.
Cubical syntax:
• Dimensions r := 0 | 1 | x .
• Contexts Ψ = x1, . . . , xn.
• Substitutions ψ = 〈r1/x1, . . . rn/xn〉 : Ψ′ → Ψ.
• Action on terms: M ψ
Cartesian cubes = substitutions are structural:
• Faces: 0/x , 1/x .
• Re-indexing: y/x .
• Weakening aka degeneracy: silent.
• Exchange aka symmetry: y , x/x , y .
• Contraction aka diagonal: z , z/x , y .
![Page 53: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/53.jpg)
Cubical Programming Language
Substitutions act on cubes:
• Faces: M〈0/x〉, M〈1/x〉• Diagonals: M〈x/y〉
y
x
M〈1/x〉〈1/y〉.
= M〈1/y〉〈1/x〉.
= M〈x/y〉〈1/x〉
M〈0/x〉 M〈1/x〉
M〈0/y〉
M〈1/y〉
M
![Page 54: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/54.jpg)
Cubical Programming Language
Substitutions act on cubes:
• Faces: M〈0/x〉, M〈1/x〉
• Diagonals: M〈x/y〉
y
x
M〈1/x〉〈1/y〉.
= M〈1/y〉〈1/x〉.
= M〈x/y〉〈1/x〉
M〈0/x〉 M〈1/x〉
M〈0/y〉
M〈1/y〉
M
![Page 55: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/55.jpg)
Cubical Programming Language
Substitutions act on cubes:
• Faces: M〈0/x〉, M〈1/x〉• Diagonals: M〈x/y〉
y
x
M〈1/x〉〈1/y〉.
= M〈1/y〉〈1/x〉.
= M〈x/y〉〈1/x〉
M〈0/x〉 M〈1/x〉
M〈0/y〉
M〈1/y〉
M〈x/y〉
![Page 56: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/56.jpg)
Cubical Programming Language
Substitutions act on cubes:
• Faces: M〈0/x〉, M〈1/x〉• Diagonals: M〈x/y〉
y
x
M〈1/x〉〈1/y〉.
= M〈1/y〉〈1/x〉.
= M〈x/y〉〈1/x〉
M〈0/x〉 M〈1/x〉
M〈0/y〉
M〈1/y〉
M〈x/y〉
![Page 57: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/57.jpg)
Cubical Programming Language
Any cube can be seen as a degenerate cube of higher dimension:
y
xN〈0/x〉 N〈1/x〉
N
N〈0/x〉 N〈1/x〉
N〈0/x〉 N〈1/x〉
N
N
![Page 58: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/58.jpg)
Cubical Programming Language
Any cube can be seen as a degenerate cube of higher dimension:
y
xN〈0/x〉 N〈1/x〉
N
N〈0/x〉 N〈1/x〉
N〈0/x〉 N〈1/x〉
N
N
![Page 59: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/59.jpg)
Cubical Programming LanguageLicata, Brunerie; Coquand, et al.
Evaluation: M ⇓ V [Ψ].
Conventional functional programming constructs:
• Booleans, pairs, functions.
• Lazy dynamics (weak head reduction).
Unconventional functional programming constructs:
• Circle: C, base, loopx ,C-elima.A(M;N, x .P).
• Kan operations: coe, hcom.
![Page 60: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/60.jpg)
Cubical Programming LanguageLicata, Brunerie; Coquand, et al.
Evaluation: M ⇓ V [Ψ].
Conventional functional programming constructs:
• Booleans, pairs, functions.
• Lazy dynamics (weak head reduction).
Unconventional functional programming constructs:
• Circle: C, base, loopx ,C-elima.A(M;N, x .P).
• Kan operations: coe, hcom.
![Page 61: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/61.jpg)
Cubical Programming LanguageLicata, Brunerie; Coquand, et al.
Evaluation: M ⇓ V [Ψ].
Conventional functional programming constructs:
• Booleans, pairs, functions.
• Lazy dynamics (weak head reduction).
Unconventional functional programming constructs:
• Circle: C, base, loopx ,C-elima.A(M;N, x .P).
• Kan operations: coe, hcom.
![Page 62: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/62.jpg)
Cubical Programming Language
Evaluation is sensitive to dimensions:
loop0 7−→ base
loop1 7−→ base
C-elima.A(base;N, x .P) 7−→ N
C-elima.A(loopy ;N, x .P) 7−→ P〈y/x〉.
base.
= loopx〈0/x〉 loopx〈1/x〉.
= baseloopx
![Page 63: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/63.jpg)
Higher Meaning Explanations
If A type [Ψ], then all faces of A evaluate to specifications:
• Aψ ⇓ V [Ψ′] for all ψ : Ψ′ → Ψ, and
• Value V names a specification of values.
If M ∈ A [Ψ], then all faces of M satisfy the spec given by A.
That is, for every ψ : Ψ′ → Ψ,
• M ψ ⇓ V , and
• V satisfies the specification given by Aψ.
(Actually, we must define equal types and equal members.)
![Page 64: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/64.jpg)
Higher Meaning Explanations
If A type [Ψ], then all faces of A evaluate to specifications:
• Aψ ⇓ V [Ψ′] for all ψ : Ψ′ → Ψ, and
• Value V names a specification of values.
If M ∈ A [Ψ], then all faces of M satisfy the spec given by A.
That is, for every ψ : Ψ′ → Ψ,
• M ψ ⇓ V , and
• V satisfies the specification given by Aψ.
(Actually, we must define equal types and equal members.)
![Page 65: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/65.jpg)
Higher Meaning Explanations
If A type [Ψ], then all faces of A evaluate to specifications:
• Aψ ⇓ V [Ψ′] for all ψ : Ψ′ → Ψ, and
• Value V names a specification of values.
If M ∈ A [Ψ], then all faces of M satisfy the spec given by A.
That is, for every ψ : Ψ′ → Ψ,
• M ψ ⇓ V , and
• V satisfies the specification given by Aψ.
(Actually, we must define equal types and equal members.)
![Page 66: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/66.jpg)
Cubical Specifications
Specifications are cubical symmetric, and transitive binary relations.
If V is a canonical type, then all of its faces must be types:
for all ψ : Ψ′ → Ψ, Vψ type [Ψ′].
If W is canonical of type V , then its faces must be elements:
for all ψ : Ψ′ → Ψ, Wψ ∈ Vψ [Ψ′].
![Page 67: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/67.jpg)
Cubical Specifications
Specifications are cubical symmetric, and transitive binary relations.
If V is a canonical type, then all of its faces must be types:
for all ψ : Ψ′ → Ψ, Vψ type [Ψ′].
If W is canonical of type V , then its faces must be elements:
for all ψ : Ψ′ → Ψ, Wψ ∈ Vψ [Ψ′].
![Page 68: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/68.jpg)
Cubical Specifications
Specifications are cubical symmetric, and transitive binary relations.
If V is a canonical type, then all of its faces must be types:
for all ψ : Ψ′ → Ψ, Vψ type [Ψ′].
If W is canonical of type V , then its faces must be elements:
for all ψ : Ψ′ → Ψ, Wψ ∈ Vψ [Ψ′].
![Page 69: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/69.jpg)
Coherence
An ambiguity arises for A type [Ψ]:
• Aψ1 ⇓ V1 and V1ψ2 ⇓ V2.
• A(ψ1 · ψ2) ⇓ V12.
But are V2 and V12 the same canonical type?
• Not necessarily the same program.
• But should have the same elements and equality.
Coherence demands that they determine the same specification.
![Page 70: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/70.jpg)
Coherence
An ambiguity arises for A type [Ψ]:
• Aψ1 ⇓ V1 and V1ψ2 ⇓ V2.
• A(ψ1 · ψ2) ⇓ V12.
But are V2 and V12 the same canonical type?
• Not necessarily the same program.
• But should have the same elements and equality.
Coherence demands that they determine the same specification.
![Page 71: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/71.jpg)
Meaning of Variables
Term variables express functional dependence on closed values at all dimensions.
Thus a : A� B type [Ψ] means for all ψ : Ψ′ → Ψ,
if M.
= N ∈ A [Ψ′], then Bψ[M/a].
= Bψ[N/a] type [Ψ′].
In particular, type families transform lines into lines:
if M ∈ A [Ψ, x ]︸ ︷︷ ︸line in A
, then B[M/a] type [Ψ, x ]︸ ︷︷ ︸line of types
.
![Page 72: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/72.jpg)
Meaning of Variables
Term variables express functional dependence on closed values at all dimensions.
Thus a : A� B type [Ψ] means for all ψ : Ψ′ → Ψ,
if M.
= N ∈ A [Ψ′], then Bψ[M/a].
= Bψ[N/a] type [Ψ′].
In particular, type families transform lines into lines:
if M ∈ A [Ψ, x ]︸ ︷︷ ︸line in A
, then B[M/a] type [Ψ, x ]︸ ︷︷ ︸line of types
.
![Page 73: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/73.jpg)
Pre- and Kan TypesVoevodsky (HTS)
These conditions define cubical pre-types
• From zero- to higher-dimensional types.
• Not sufficient for HoTT.
A full-fledged type must satisfy the Kan conditions:
• Type lines induce coercions between types.
• Paths must be closed under Kan composition.
![Page 74: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/74.jpg)
Pre- and Kan TypesVoevodsky (HTS)
These conditions define cubical pre-types
• From zero- to higher-dimensional types.
• Not sufficient for HoTT.
A full-fledged type must satisfy the Kan conditions:
• Type lines induce coercions between types.
• Paths must be closed under Kan composition.
![Page 75: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/75.jpg)
Coercion along a Line of Types
Type lines A type [Ψ, x ] induce coercions:
coer r ′x .A (M) ∈ A〈r ′/x〉 [Ψ] when M ∈ A〈r/x〉 [Ψ].
Coercion along A type [Ψ, x ] is trivial when r = r ′:
coer rx .A (M)
.= M ∈ A〈r/x〉 [Ψ].
Each type defines the meaning of coercion along lines!
![Page 76: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/76.jpg)
Coercion along a Line of Types
Type lines A type [Ψ, x ] induce coercions:
coer r ′x .A (M) ∈ A〈r ′/x〉 [Ψ] when M ∈ A〈r/x〉 [Ψ].
Coercion along A type [Ψ, x ] is trivial when r = r ′:
coer rx .A (M)
.= M ∈ A〈r/x〉 [Ψ].
Each type defines the meaning of coercion along lines!
![Page 77: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/77.jpg)
Coercion along a Line of Types
Type lines A type [Ψ, x ] induce coercions:
coer r ′x .A (M) ∈ A〈r ′/x〉 [Ψ] when M ∈ A〈r/x〉 [Ψ].
Coercion along A type [Ψ, x ] is trivial when r = r ′:
coer rx .A (M)
.= M ∈ A〈r/x〉 [Ψ].
Each type defines the meaning of coercion along lines!
![Page 78: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/78.jpg)
Coercion along a Line of Types
Diagrammatically,
A〈0/x〉 A〈1/x〉A
Mcoe0 0x .A (M)
.=
∈
coe0 1x .A (M)
∈
![Page 79: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/79.jpg)
Coercion along a Line of Types
Diagrammatically,
A〈0/x〉 A〈1/x〉A
Mcoe0 0x .A (M)
.=
∈
coe0 1x .A (M)
∈
![Page 80: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/80.jpg)
Coercion along a Line of Types
Diagrammatically,
A〈0/x〉 A〈1/x〉A
Mcoe0 0x .A (M)
.=
∈
coe0 1x .A (M)
∈coe0 x
x .A (M)
∈
![Page 81: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/81.jpg)
Coercion along a Line of Types
Diagrammatically,
A〈0/x〉 A〈1/x〉A
Mcoe0 0x .A (M)
.=
∈
coe0 1x .A (M)
∈coe0 x
x .A (M)
∈
![Page 82: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/82.jpg)
Kan Composition
P〈0/x〉 P〈1/x〉 Q〈0/x〉 Q〈1/x〉
.=
P Q
P · Q
Paths in a type must compose.
• if P ∈ A [Ψ, x ], and Q ∈ A [Ψ, x ],
and
• P〈1/x〉 .= Q〈0/x〉 ∈ A [Ψ],
then
• there exists P · Q ∈ A [Ψ, x ],
• satisfying composition and identity laws up to higher paths.
Miraculously, there is a simple way to capture the full meaning!
![Page 83: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/83.jpg)
Kan Composition
P〈0/x〉 P〈1/x〉 Q〈0/x〉 Q〈1/x〉.=
P Q
P · Q
Paths in a type must compose.
• if P ∈ A [Ψ, x ], and Q ∈ A [Ψ, x ], and
• P〈1/x〉 .= Q〈0/x〉 ∈ A [Ψ],
then
• there exists P · Q ∈ A [Ψ, x ],
• satisfying composition and identity laws up to higher paths.
Miraculously, there is a simple way to capture the full meaning!
![Page 84: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/84.jpg)
Kan Composition
P〈0/x〉 P〈1/x〉 Q〈0/x〉 Q〈1/x〉.=
P Q
P · Q
Paths in a type must compose.
• if P ∈ A [Ψ, x ], and Q ∈ A [Ψ, x ], and
• P〈1/x〉 .= Q〈0/x〉 ∈ A [Ψ], then
• there exists P · Q ∈ A [Ψ, x ],
• satisfying composition and identity laws up to higher paths.
Miraculously, there is a simple way to capture the full meaning!
![Page 85: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/85.jpg)
Kan Composition
P〈0/x〉 P〈1/x〉 Q〈0/x〉 Q〈1/x〉.=
P Q
P · Q
Paths in a type must compose.
• if P ∈ A [Ψ, x ], and Q ∈ A [Ψ, x ], and
• P〈1/x〉 .= Q〈0/x〉 ∈ A [Ψ], then
• there exists P · Q ∈ A [Ψ, x ],
• satisfying composition and identity laws up to higher paths.
Miraculously, there is a simple way to capture the full meaning!
![Page 86: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/86.jpg)
Kan Composition
P〈0/x〉 P〈1/x〉 Q〈0/x〉 Q〈1/x〉.=
P Q
P · Q
Paths in a type must compose.
• if P ∈ A [Ψ, x ], and Q ∈ A [Ψ, x ], and
• P〈1/x〉 .= Q〈0/x〉 ∈ A [Ψ], then
• there exists P · Q ∈ A [Ψ, x ],
• satisfying composition and identity laws up to higher paths.
Miraculously, there is a simple way to capture the full meaning!
![Page 87: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/87.jpg)
The HCom Diagram
Pictorially,x
yM0
.= N0 M1
.= P0
N1 P1
M.
= hcom0 0A (M; ~T )
N P
hcom0 1A (M; ~T )
hcom0 yA (M; ~T )
Symbolically,
hcom0 yA ( M︸︷︷︸
cap
; x = 0 ↪→ y .N, x = 1 ↪→ y .P︸ ︷︷ ︸tube ~T
) ∈ A [Ψ, x , y ].
![Page 88: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/88.jpg)
Composition and Inversion from HCom
Concatenation and reversal are definable:
P0
P0
P1
Q1
P0 Q
P
P · Q
P0
P1
P0
P0
P P0
P0
P−1
Kan composition suffices to derive composition laws.
![Page 89: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/89.jpg)
Strict Booleans
The type bool is defined such that for all M and Ψ,
M ∈ bool [Ψ] iff M ⇓ true or M ⇓ false.
Therefore, we can make bool Kan:
• coer r ′.bool(M) 7−→ M for any M, r , r ′.
• hcomr r ′bool (M; ~T ) 7−→ M for any M, ~T , r , r ′.
The properties of bool stated earlier carry over directly.
• Same proofs, using equality pre-type for equations.
• e.g., Shannon expansion.
![Page 90: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/90.jpg)
Strict Booleans
The type bool is defined such that for all M and Ψ,
M ∈ bool [Ψ] iff M ⇓ true or M ⇓ false.
Therefore, we can make bool Kan:
• coer r ′.bool(M) 7−→ M for any M, r , r ′.
• hcomr r ′bool (M; ~T ) 7−→ M for any M, ~T , r , r ′.
The properties of bool stated earlier carry over directly.
• Same proofs, using equality pre-type for equations.
• e.g., Shannon expansion.
![Page 91: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/91.jpg)
Weak Booleans
Canonical:
• wbool, true, and false as before.
• fcomr r ′(M; ~T ), where r 6= r ′.
Fcom = formal composition of booleans:
N
M
N ′
![Page 92: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/92.jpg)
Weak Booleans
Canonical:
• wbool, true, and false as before.
• fcomr r ′(M; ~T ), where r 6= r ′.
Fcom = formal composition of booleans:
N
M
N ′
![Page 93: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/93.jpg)
Weak Booleans
Conditional offloads composition to the motive at higher dims!
ifa.A(true;P;Q) 7−→ P
ifa.A(false;P;Q) 7−→ Q
ifa.A( N
M
N ′ ;P;Q) 7−→
ifa.A(N;P;Q)
ifa.A(M;P;Q)
ifa.A(N′;P;Q)
Result composition is heterogeneous.
![Page 94: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/94.jpg)
Weak Booleans
The motive of the conditional on wbool must be Kan!
a : wbool� A typeKan [Ψ].
Theorem (Dependent Elimination)
If M ∈ bool [Ψ] and P ∈ A[true/a] [Ψ] and Q ∈ A[false/a] [Ψ], then
ifa.A(M;P;Q) ∈ A[M/a] [Ψ].
Looks unremarkable, but is not trivial because of higher dim’s.
![Page 95: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/95.jpg)
Weak Booleans
The motive of the conditional on wbool must be Kan!
a : wbool� A typeKan [Ψ].
Theorem (Dependent Elimination)
If M ∈ bool [Ψ] and P ∈ A[true/a] [Ψ] and Q ∈ A[false/a] [Ψ], then
ifa.A(M;P;Q) ∈ A[M/a] [Ψ].
Looks unremarkable, but is not trivial because of higher dim’s.
![Page 96: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/96.jpg)
Weak Booleans
The motive of the conditional on wbool must be Kan!
a : wbool� A typeKan [Ψ].
Theorem (Dependent Elimination)
If M ∈ bool [Ψ] and P ∈ A[true/a] [Ψ] and Q ∈ A[false/a] [Ψ], then
ifa.A(M;P;Q) ∈ A[M/a] [Ψ].
Looks unremarkable, but is not trivial because of higher dim’s.
![Page 97: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/97.jpg)
Circle
The circle C is like wbool.
C-elima.A(base;N, x .P) 7−→ N
C-elima.A(loopy ;N, x .P) 7−→ P〈y/x〉
C-elima.A( M
M ′
M ′′ ;N, x .P) 7−→
C-elima.A(M;N, x .P)
C-elima.A(M′;N, x .P)
C-elima.A(M′′;N, x .P)
Iterations of loop defined using formal composition.
![Page 98: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/98.jpg)
Circle
The circle C is like wbool.
C-elima.A(base;N, x .P) 7−→ N
C-elima.A(loopy ;N, x .P) 7−→ P〈y/x〉
C-elima.A( M
M ′
M ′′ ;N, x .P) 7−→
C-elima.A(M;N, x .P)
C-elima.A(M′;N, x .P)
C-elima.A(M′′;N, x .P)
Iterations of loop defined using formal composition.
![Page 99: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/99.jpg)
Functions
Abstraction and application as before:
• Canonical: (a:A)→ B, λa.M.
• Non-canonical: app(M,N).
• Computation: app(λa.P,N) 7−→ P[N/a].
Coercion co- and contra-variantly:
coer r ′
x .(a:A)→B(M) 7−→ λa.coer r ′x .B (app(M, coer
′ rx .A (a))).
Kan composition by extensionality:
hcomr r ′
(a:A)→B(M; ~T ) 7−→ λa.hcomr r ′B (app(M, a); app( ~T , a)).
![Page 100: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/100.jpg)
Functions
Abstraction and application as before:
• Canonical: (a:A)→ B, λa.M.
• Non-canonical: app(M,N).
• Computation: app(λa.P,N) 7−→ P[N/a].
Coercion co- and contra-variantly:
coer r ′
x .(a:A)→B(M) 7−→ λa.coer r ′x .B (app(M, coer
′ rx .A (a))).
Kan composition by extensionality:
hcomr r ′
(a:A)→B(M; ~T ) 7−→ λa.hcomr r ′B (app(M, a); app( ~T , a)).
![Page 101: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/101.jpg)
Functions
Abstraction and application as before:
• Canonical: (a:A)→ B, λa.M.
• Non-canonical: app(M,N).
• Computation: app(λa.P,N) 7−→ P[N/a].
Coercion co- and contra-variantly:
coer r ′
x .(a:A)→B(M) 7−→ λa.coer r ′x .B (app(M, coer
′ rx .A (a))).
Kan composition by extensionality:
hcomr r ′
(a:A)→B(M; ~T ) 7−→ λa.hcomr r ′B (app(M, a); app( ~T , a)).
![Page 102: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/102.jpg)
Paths
The type Pathx .A(P0,P1) specifies paths in A with end points P0 and P1.
Dimension abstraction and application:
• Pathx .A(P0,P1), 〈x〉M are canonical.
• (〈x〉M)@r 7−→ M〈r/x〉.
Paths are Kan, provided that A is Kan.
![Page 103: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/103.jpg)
Paths
Coercion: coe0 1y .Pathx.A(P0,P1)(M) 7−→
〈x〉com0 1y .A (M@x ; x = 0 ↪→ y .P0, x = 1 ↪→ y .P1).
y
xP0〈0/y〉
.= M@0 M@1
.= P1〈1/y〉
M@x
P0〈1/y〉 P1〈1/y〉
P0 P1
![Page 104: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/104.jpg)
HoTT, Revisited
HoTT identity type splits into two concepts:
• Exact equality: extensional, evidence-free.
• Paths of arbitrary dimension.
Both may be internalized:
• Equality pre-type, may or may not be Kan.
• Path type, always Kan.
Equality proofs are irrelevant and erasable.
Coercion and composition express the computational content of paths in each type.
![Page 105: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/105.jpg)
HoTT, Revisited
HoTT identity type splits into two concepts:
• Exact equality: extensional, evidence-free.
• Paths of arbitrary dimension.
Both may be internalized:
• Equality pre-type, may or may not be Kan.
• Path type, always Kan.
Equality proofs are irrelevant and erasable.
Coercion and composition express the computational content of paths in each type.
![Page 106: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/106.jpg)
HoTT, Revisited
HoTT identity type splits into two concepts:
• Exact equality: extensional, evidence-free.
• Paths of arbitrary dimension.
Both may be internalized:
• Equality pre-type, may or may not be Kan.
• Path type, always Kan.
Equality proofs are irrelevant and erasable.
Coercion and composition express the computational content of paths in each type.
![Page 107: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/107.jpg)
HoTT, Revisited
Path type admits structure of identity type.
• Intro: reflA(M) ∈ Path .A(M,M).
• Elim: J(u.Q;P) with P ∈ Path .A(M,N).
Does not validate β law, because reflexivity is not special.
![Page 108: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/108.jpg)
HoTT, RevisitedAwodey; Cavallo
Jdentity type is definable as free Kan type on reflexivity:
• Validates β law for J.
• Elimination commutes with free Kan structure.
Admits computation: J is never “stuck.”
But does not validate type-directed path laws!
It seems that we cannot have it both ways!
![Page 109: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/109.jpg)
HoTT, RevisitedAwodey; Cavallo
Jdentity type is definable as free Kan type on reflexivity:
• Validates β law for J.
• Elimination commutes with free Kan structure.
Admits computation: J is never “stuck.”
But does not validate type-directed path laws!
It seems that we cannot have it both ways!
![Page 110: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/110.jpg)
RedPRL: Proof Refinement LogicSterling, Hou, Angiuli
notation meaning
Ψ | Γ =⇒ A true ; e There exists a term e such that if Γ ctx [Ψ], thenΓ� A typepre [Ψ] and Γ� e ∈ A [Ψ].
Ψ | Γ =⇒ A.
= B typek If Γ ctx [Ψ], then Γ� A.
= B typek [Ψ].
Ψ | Γ =⇒ e synth ; A There exists a term A such that if Γ ctx [Ψ],then Γ� A typepre [Ψ] and Γ� e ∈ A [Ψ].
Ψ | Γ =⇒ A v B If Γ ctx [Ψ], then Γ � A typepre [Ψ] and Γ �B typepre [Ψ], and Γ, a : A� a ∈ B [Ψ].
Ψ | Γ =⇒ A v Ukω If Γ ctx [Ψ], then there exists some level i and
kind k ′ ≤ k such that Γ� A.
= Uk′
i typepre [Ψ].
![Page 111: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/111.jpg)
Demonstration
Please enjoy Carlo’s demonstration of RedPRL!
![Page 112: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/112.jpg)
References I
Stuart F Allen, Mark Bickford, Robert L Constable, Richard Eaton, Christoph Kreitz, Lori Lorigo, and Evan Moran. Innovations in computationaltype theory using Nuprl. Journal of Applied Logic, 4(4):428–469, 2006.
Carlo Angiuli and Robert Harper. Meaning explanations at higher dimension. Indagationes Mathematicae, 29:135–149, 2018. Virtual Special Issue –L.E.J. Brouwer after 50 years.
Carlo Angiuli, Guillaume Brunerie, Thierry Coquand, Kuen-Bang Hou (Favonia), Robert Harper, and Daniel R. Licata. Cartesian cubical type theory.(Unpublished manuscript), December 2017a.
Carlo Angiuli, Kuen-Bang Hou (Favonia), and Robert Harper. Computational higher type theory III: Univalent universes and exact equality. Preprint,December 2017b. URL https://arxiv.org/abs/1712.01800.
Marc Bezem, Thierry Coquand, and Simon Huber. A model of type theory in cubical sets. In 19th International Conference on Types for Proofs andPrograms (TYPES 2013), volume 26, pages 107–128, 2014.
Evan Cavallo and Robert Harper. Computational higher type theory IV: Inductive types. Preprint, January 2018. URLhttps://arxiv.org/abs/1801.01568.
Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mortberg. Cubical type theory: a constructive interpretation of the univalence axiom. toappear in the proceedings of TYPES 2015, 2015.
Simon Huber. Canonicity for cubical type theory. Preprint arXiv:1607.04156v1 [cs.LO], July 2016.
Jonathan Sterling, Kuen-Bang Hou (Favonia), Evan Cavallo, Carlo Angiuli, James Wilcox, Eugene Akentyev, David Christiansen, Daniel Gratzer, andDarin Morrison. RedPRL – the People’s Refinement Logic. http://www.redprl.org/, 2017.
Vladimir Voevodsky. A simple type system with two identity types. Lecture notes, February 2013. URLhttps://www.math.ias.edu/vladimir/sites/math.ias.edu.vladimir/files/HTS.pdf.
![Page 113: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/113.jpg)
InvRefl
(path [_] (path [_] ty a a) ($ PathInv ty a a (abs [_] a)) (abs [_] a))
abs x => abs y =>
yx
z
· ·
· ·a
a
a(@ ($ PathInv ty a a (abs [ ] a)) y)
·
·
·
·
a
a
a
·
·
![Page 114: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/114.jpg)
InvRefl
(path [_] (path [_] ty a a) ($ PathInv ty a a (abs [_] a)) (abs [_] a))
abs x => abs y =>
yx
z
· ·
· ·a
a
a
(@ ($ PathInv ty a a (abs [ ] a)) y)
·
·
·
·
a
a
a
·
·
![Page 115: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/115.jpg)
InvRefl
(path [_] (path [_] ty a a) ($ PathInv ty a a (abs [_] a)) (abs [_] a))
abs x => abs y =>
yx
z
· ·
· ·a
a
a
(@ ($ PathInv ty a a (abs [ ] a)) y)
·
·
·
·
a
a
a
·
·
![Page 116: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/116.jpg)
The Univalence TypeFavonia; CCHM
M
N0 N1N
Vinx(M,N)E
∈
A
B0 B1B
Vx(A,B,E )E ∼
![Page 117: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/117.jpg)
The Univalence TypeFavonia; CCHM
M N1
N0 N1N
Vinx(M,N)
E
∈
A B1
B0 B1B
Vx(A,B,E )
E ∼
![Page 118: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/118.jpg)
The Coe Diagram
Given M ∈ A [Ψ, x ]:
M0 M1M
∈ A0 A1A
Then coex yx .Ax
(Mx) ∈ Ay [Ψ, x , y ]:
xy
M0 coe1 0x .Ax
(M1)
coe0 1x .Ax
(M0) M1
coex 0x .Ax
(Mx) ∈ A0
coe0 yx .Ax
(M0) ∈ Ay coe1 yx .Ax
(M1) ∈ Ay
coex 1x .Ax
(Mx) ∈ A1
coex yx .Ax
(Mx)
![Page 119: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/119.jpg)
The Coe Diagram
Given M ∈ A [Ψ, x ]:
M0 M1M
∈ A0 A1A
Then coex yx .Ax
(Mx) ∈ Ay [Ψ, x , y ]:
xy
M0 coe1 0x .Ax
(M1)
coe0 1x .Ax
(M0) M1
coex 0x .Ax
(Mx) ∈ A0
coe0 yx .Ax
(M0) ∈ Ay coe1 yx .Ax
(M1) ∈ Ay
coex 1x .Ax
(Mx) ∈ A1
M
![Page 120: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/120.jpg)
The Com Diagram
com0 1y .A (M; x = 0 ↪→ y .N0, x = 1 ↪→ y .N1) ∈ A〈1/y〉 [Ψ, x ]
yx
∈ A〈1/y〉
· ·
· ·
M ∈ A〈0/y〉
A〈0/x〉 3 N0 N1 ∈ A〈1/x〉
· ·
coey 1y .A〈0/x〉(N0)
coey 1y .A〈1/x〉(N1)
coe0 1y .A (M)
![Page 121: Computational (Higher) Type Theoryrwh/talks/POPL18-Tutorial.pdf · Computational (Higher) Type Theory Robert Harper and Carlo Angiuli Computer Science Department Carnegie Mellon University](https://reader033.vdocuments.us/reader033/viewer/2022050312/5f74ebf202adf345b36cfd56/html5/thumbnails/121.jpg)
The Com Diagram
com0 1y .A (M; x = 0 ↪→ y .N0, x = 1 ↪→ y .N1) ∈ A〈1/y〉 [Ψ, x ]
yx
∈ A〈1/y〉
· ·
· ·
M ∈ A〈0/y〉
A〈0/x〉 3 N0 N1 ∈ A〈1/x〉
· ·
coey 1y .A〈0/x〉(N0)
coey 1y .A〈1/x〉(N1)
coe0 1y .A (M)