hottpsztxa/talks/mgs-xmas14.pdf · hott christmas thorsten altenkirch! functional programming...
TRANSCRIPT
![Page 1: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/1.jpg)
HoTT Christmas
Thorsten Altenkirch Functional Programming Laboratory
School of Computer Science
![Page 2: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/2.jpg)
How do we teach Mathematics?
Use informal set theory?
Definition
But what is ?
N \ B
A \B := {x | x 2 A ^ x 2 B}
![Page 3: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/3.jpg)
More stupid questions
A ! B ✓ P(A⇥B)?
A⇥B ✓ P(P(A [B))?
![Page 4: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/4.jpg)
What is the problem?
In set theory we can ask questions about the intensional properties of constructions like
Also their definitions seem quite arbitrary.
This is a consequence of the idea that elements of sets exist independently of the set they inhabit.
N,B,⇥,!
![Page 5: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/5.jpg)
The alternative
+
Per Martin-Löf Vladimir Voevodsky
= Homotopy Type Theory (HoTT)
![Page 6: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/6.jpg)
Types come first!
In Type Theory elements of a type do not exist in isolation of the type they inhabit!
In Set Theory is a proposition in Type Theory is a judgment.
We cannot define on arbitrary types.
a 2 A
a : A
A \B,A [B,A ✓ B
![Page 7: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/7.jpg)
Univalence
Because we cannot talk about intensional properties of constructions …
… all constructions are invariant under extensional equivalence.
This is expressed formally by Voevodsky’s univalence principle.
![Page 8: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/8.jpg)
Type Theory for dummies
![Page 9: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/9.jpg)
Constructions in Type Theory
A ! B
A⇥B
B
N
a =A b
Typei
Functions special case of types
Tuples special case of types
Bool,
special case of a finite typenatural numbers
special case of a tree type
equality types
universes
⇧
⌃
![Page 10: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/10.jpg)
Anatomy of a type
Formation How to form a type?
Introduction How to form elements?
Non-dependent elimination How to define non-dependent functions from a type?
Dependent elimination How to define dependent functions from a type?
Computation How to compute?
![Page 11: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/11.jpg)
Anatomy of a type
Formation How to form a type?
Introduction How to form elements?
Dependent elimination How to define dependent functions from a type?
Computation How to compute?
![Page 12: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/12.jpg)
Example : tuples
Formation
If !!
thenA,B : Type
A⇥B : Type
![Page 13: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/13.jpg)
Example : tuples
Introduction
If !!
thena : A, b : B
(a, b) : A⇥B
![Page 14: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/14.jpg)
Example : tuples
Non-dependent elimination
To define !!
we need
Computation
f : A⇥B ! C
g : A ! B ! C
f (a, b) ⌘ g a b
![Page 15: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/15.jpg)
Example : tuples
Dependent elimination
To define !!
we need
Computation f (a, b) ⌘ g a b
f : ⇧p : A⇥B.C p
g : ⇧a : A.⇧b : B.C (a, b)C : A⇥B ! Type
![Page 16: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/16.jpg)
Eliminator
The dependent elimination principle can also be expressed by an eliminator
with the computation ruleEA⇥B : ⇧C:A⇥B!Type⇧g:⇧a:A⇧b:B.C (a,b)⇧p : A⇥B.C p
EA⇥B C g (a, b) ⌘ g a b
![Page 17: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/17.jpg)
Propositions as types
Using the idea to identify a proposition with the type of its proofs
we can use dependent elimination to prove things.
E.g.
where can be defined using non-dependent elimination
⇧p : A⇥B.(⇡1 p,⇡2 p) = p.
⇡i : A1 ⇥A2 ! Ai
![Page 18: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/18.jpg)
Canonicity
The elimination principle makes sure that all functions applied to canonical elements can be eliminated.
All closed terms of a type are computationally equal ( ) to a term built from constructors.
⌘
![Page 19: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/19.jpg)
Equality for beginners
![Page 20: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/20.jpg)
Example : equality
Formation
If !!
thena, b : A
a =A b : Type
![Page 21: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/21.jpg)
Introduction
If !!
then
Example : equality
a : A
refl a : a =A a
![Page 22: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/22.jpg)
Non-dependent elimination
To define !!
we need
Computation
Example : equality
f : ⇧x : A, a = x ! P x
g : P a
f a (refl a) ⌘ g
![Page 23: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/23.jpg)
Dependent elimination
To define !!
we need
Computation
Example : equality
f a (refl a) ⌘ g
f : ⇧x : A,⇧p : a = x ! P xp
g : P a (refl a)P : ⇧x : A.a = x ! Type
![Page 24: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/24.jpg)
The structure of equality types
refl : ⇧a : A, a = a
(�)�1 : ⇧a,b:A, a = b ! b = a
� � � : ⇧a,b,c:Ab = c ! a = b ! a = c
Using the elimination principle we can show that all types have the structure of a groupoid.
� : ⇧a,b:A⇧p : a = b, p � (refl a) = p
⇢ : ⇧a,b:A⇧p : a = b, (refl b) � p = p
......
...
Each function gives rise to a functor: for we have f : A ! B
f= : ⇧a.a0:Aa =A a0 ! f a = f a0
![Page 25: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/25.jpg)
The structure of equality types
refl : ⇧a : A, a = a
(�)�1 : ⇧a,b:A, a = b ! b = a
� � � : ⇧a,b,c:Ab = c ! a = b ! a = c
Using the elimination principle we can show that all types have the structure of an -groupoid.
� : ⇧a,b:A⇧p : a = b, p � (refl a) = p
⇢ : ⇧a,b:A⇧p : a = b, (refl b) � p = p
......
...
Each function gives rise to an -functor: for we have f : A ! B
f= : ⇧a.a0:Aa =A a0 ! f a = f a0
!
!
![Page 26: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/26.jpg)
Univalence for cat lovers
![Page 27: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/27.jpg)
Propositions
We say that a type is a proposition (or a (-1)-type) if all elements are equal.
Hence the only observable property of this type is wether it is inhabited.
![Page 28: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/28.jpg)
Sets
We say that a type is a set (or a 0-type) if all its equalities are propositions.
In general we say that a type is an (n+1)-type if all its equalities are n-types
![Page 29: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/29.jpg)
Univalence for propositionsWe define logical equivalence having functions in both directions.
Univalence for propositions implies that equality for propositions is logically equivalent to logical equivalence.
A () B := ⌃f : A ! B
g : B ! A
(A = B) () (A () B)
![Page 30: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/30.jpg)
Univalence for setsIsomorphism is a refinement of logical equivalence:
Univalence for sets implies that equality for sets is isomorphic to isomorphism:
A ' B :=
⌃f : A ! B
g : B ! A
⌘ : ⇧a : A, g (f a) = a
✏ : ⇧b : B, f (g b) = b
(A = B) ' (A ' B)
![Page 31: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/31.jpg)
Univalence for typesEquivalence is a refinement of isomorphism:
Univalence implies that equality for types is equivalent to equivalence: (A = B) ⇠= (A ⇠= B)
A ⇠= B :=
⌃f : A ! B
g : B ! A
⌘ : ⇧a : A, g (f a) = a
✏ : ⇧b : B, f (g b) = b
� : ⇧a : A, f= (⌘ a) = ✏ (f a)
![Page 32: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/32.jpg)
Canonicity ?
We add univalence as a constant :
However, this destroys the computational symmetry of introduction and elimination for equality types.
f : A = B ! A ⇠= B
uval : isEquivalence f
![Page 33: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/33.jpg)
What I would have talked about to a more sophisticated
audience
![Page 34: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/34.jpg)
Cubical Type TheoryWe consider an alternative presentation of equality types where equality is defined as a logical relation.
Since we have to deal with dependent types this we have to use heterogenous equality.
This is related to internal parametricity ala Bernardy and Moulin…
…and Coquand & Huber’s work on the constructive cubical set model.
![Page 35: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/35.jpg)
Back to the future
![Page 36: hottpsztxa/talks/mgs-xmas14.pdf · HoTT Christmas Thorsten Altenkirch! Functional Programming Laboratory! School of Computer Science!](https://reader030.vdocument.in/reader030/viewer/2022040910/5e83f4a5aae3144d7c04cadd/html5/thumbnails/36.jpg)
How should we teach Mathematics?
Use informal Type Theory!
Encourages sensible use of Mathematics!
Given define
A,B : X ! Prop
A \B : X ! Prop
(A \B)x = Ax ^B x