Programming and Proving with Higher Inductive Types Dan Licata Wesleyan University Department of Mathematics and Computer Science
Constructive Type Theory Three senses of constructivity: [Martin-Löf] 2
Constructive Type Theory [Martin-Löf] Three senses of constructivity: Non-affirmation of certain classical principles provides axiomatic freedom 2
Synthetic geometry Euclid s postulates 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously in a straight line. 3. To describe a circle with any center and distance. 4. That all right angles are equal to one another. 5. That, if a straight line falling on two straight lines make the interior angles on the same side less than to right angles,the two straight lines, if produced indefinitely, meet on that side on which are the angles less than the to right angles. 3
Synthetic geometry Euclid s postulates 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously in a straight line. 3. To describe a circle with any center and distance. 4. That all right angles are equal to one another. 5. That, if a straight line falling on two straight lines make the interior angles on the same side less than to right angles,the two straight lines, if produced indefinitely, meet on that side on which are the angles less than the to right angles. Cartesian 3
Synthetic geometry Euclid s postulates 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously in a straight line. 3. To describe a circle with any center and distance. 4. That all right angles are equal to one another. 5. That, if a straight line falling on two straight lines make the interior angles on the same side less than to right angles,the two straight lines, if produced indefinitely, meet on that side on which are the angles less than the to right angles. models Cartesian 3
Synthetic geometry Euclid s postulates 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously in a straight line. 3. To describe a circle with any center and distance. 4. That all right angles are equal to one another. models Cartesian 3
Synthetic geometry Euclid s postulates 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously in a straight line. 3. To describe a circle with any center and distance. 4. That all right angles are equal to one another. models Cartesian Spherical 3
Synthetic geometry Euclid s postulates 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously in a straight line. 3. To describe a circle with any center and distance. 4. That all right angles are equal to one another. 5. Two distinct lines meet at two antipodal points. models Cartesian Spherical 3
Synthetic mathematics Type theory 1.τ ::= b τ 1 τ 2 2.e ::= x e 1 e 2 λx.e 3.(λx.e)e 2 = e[e 2 /x] 4
Synthetic mathematics Type theory 1.τ ::= b τ 1 τ 2 2.e ::= x e 1 e 2 λx.e 3.(λx.e)e 2 = e[e 2 /x] Set-theoretic functions 4
Synthetic mathematics Type theory 1.τ ::= b τ 1 τ 2 2.e ::= x e 1 e 2 λx.e 3.(λx.e)e 2 = e[e 2 /x] Set-theoretic functions Domain-theoretic functions 4
Synthetic mathematics Type theory Set-theoretic functions 1.τ ::= b τ 1 τ 2 2.e ::= x e 1 e 2 λx.e 3.(λx.e)e 2 = e[e 2 /x] 4.Y(f) = f(y(f)) Domain-theoretic functions 4
Constructive Type Theory Three senses of constructivity: 5
Constructive Type Theory Three senses of constructivity: Non-affirmation of certain classical principles provides axiomatic freedom 5
Constructive Type Theory Three senses of constructivity: Non-affirmation of certain classical principles provides axiomatic freedom Computational interpretation supports software verification and proof automation 5
Computational Interpretation There is an algorithm that, given a closed program e : bool, computes either an equality e = true, or an equality e = false. 6
Computational Interpretation There is an algorithm that, given a closed program e : bool, computes either an equality e = true, or an equality e = false. Requires functions with arbitrary domain/ range to be computable, but stating theorem for bool offers some flexibility 6
Computational Interpretation There is an algorithm that, given a closed program e : bool, computes either an equality e = true, or an equality e = false. Requires functions with arbitrary domain/ range to be computable, but stating theorem for bool offers some flexibility Basis for software verification and proof automation 6
Constructive Type Theory Three senses of constructivity: Non-affirmation of certain classical principles provides axiomatic freedom Computational interpretation supports software verification and proof automation 7
Constructive Type Theory Three senses of constructivity: Non-affirmation of certain classical principles provides axiomatic freedom Computational interpretation supports software verification and proof automation Props-as-types allows proof-relevant mathematics 7
Proof relevance x : A 8
Proof relevance x : A x =A y equality type 8
Proof relevance x : A p : x =A y equality type 8
Proof relevance x : A p : x =A y equality type Any structure or property C can be transported along an equality 8
Proof relevance x : A p : x =A y equality type Any structure or property C can be transported along an equality transport C (p) : C(x)! C(y) 8
Proof relevance x : A p : x =A y equality type Any structure or property C can be transported along an equality transport C (p) : C(x)! C(y) Leibniz s indiscernability of identicals 8
Proof relevance x : A p : x =A y equality type Any structure or property C can be transported along an equality transport C (p) : C(x)! C(y) Leibniz s indiscernability of identicals by a function: can it do real work? 8
Proof relevance x : A p : x =A y equality type 9
Proof relevance x : A p : x =A y equality type p1 = x=y p2 9
Proof relevance x : A p : x =A y equality type q : p1 = x=y p2 9
Proof relevance x : A p : x =A y equality type q : p1 = x=y p2 q1 = p1=p2 q2 9
Proof relevance x : A p : x =A y equality type q : p1 = x=y p2 r : q1 = p1=p2 q2 9
... Proof relevance x : A p : x =A y equality type q : p1 = x=y p2 r : q1 = p1=p2 q2 higher equalities radically expand the kind of math that can be done synthetically 9
Homotopy Type Theory type theory category theory homotopy theory [Hofmann,Streicher,Awodey,Warren,Voevodsky Lumsdaine,Gambino,Garner,van den Berg] 10
Types as spaces α M N 11
Types as spaces type A is a space α M N 11
Types as spaces type A is a space α M N programs M:A are points 11
Types as spaces type A is a space α M N programs M:A are points proofs of equality α : M =A N are paths 11
Types as spaces type A is a space α path operations M N programs M:A are points proofs of equality α : M =A N are paths 11
Types as spaces type A is a space id α N M path operations id : M = M (refl) programs M:A are points proofs of equality α : M =A N are paths 11
Types as spaces type A is a space id α α -1 N M path operations id : M = M (refl) α -1 : N = M (sym) programs M:A are points proofs of equality α : M =A N are paths 11
Types as spaces type A is a space id α α -1 N M β P path operations id : M = M (refl) α -1 : N = M (sym) β o α : M = P (trans) programs M:A are points proofs of equality α : M =A N are paths 11
Homotopy Deformation of one path into another α β 12
Homotopy Deformation of one path into another α β 12
Homotopy Deformation of one path into another α = 2-dimensional path between paths β 12
Homotopy Deformation of one path into another α β = 2-dimensional path between paths δ : α =x=y β 12
Homotopy Deformation of one path into another α β = 2-dimensional path between paths δ : α =x=y β Then homotopies between homotopies. 12
Types as spaces type A is a space id α α -1 N M β path operations id : M = M (refl) α -1 : N = M (sym) β o α : M = P (trans) programs M:A are points P proofs of equality α : M =A N are paths homotopies ul : id o α = M=N α il : α -1 o α = M=M id asc : γ o (β o α) =M=P (γ o β) o α 13
Homotopy Type Theory type theory category theory homotopy theory [Hofmann,Streicher,Awodey,Warren,Voevodsky Lumsdaine,Gambino,Garner,van den Berg] 14
Types as -groupoids type A is an -groupoid infinite-dimensional algebraic structure, with morphisms, morphisms between morphisms,... each level has a groupoid structure, and they interact morphisms id : M = M (refl) α -1 : N = M (sym) β o α : M = P (trans) morphisms between morphisms ul : id o α = M=N α il : α -1 o α = M=M id asc : γ o (β o α) =M=P (γ o β) o α 15
Path induction Type of paths from a to somewhere y2 p2 y1 y3 p1 p3 a is inductively generated by id a 16
Path induction Type of paths from a to somewhere y2 p2 y1 y3 p1 p3 a is inductively generated by id a Fix a type A with element a:a. For a family of types C(y:A, p:a=y), to give an element of C(y,p) for all y and p:a=y, suffices to give an element of C(a,id) 16
Type theory is a synthetic theory of spaces/ -groupoids 17
Homotopy Type Theory type theory new programs and types category theory homotopy theory 18
Univalence [Voevodsky] 19
Univalence [Voevodsky] Equivalence of types is a generalization to spaces of bijection of sets 19
Univalence [Voevodsky] Equivalence of types is a generalization to spaces of bijection of sets Univalence axiom: equality of types (A =Type B) is (equivalent to) equivalence of types (Equiv A B) 19
Univalence [Voevodsky] Equivalence of types is a generalization to spaces of bijection of sets Univalence axiom: equality of types (A =Type B) is (equivalent to) equivalence of types (Equiv A B) all structures/properties respect equivalence 19
Univalence [Voevodsky] Equivalence of types is a generalization to spaces of bijection of sets Univalence axiom: equality of types (A =Type B) is (equivalent to) equivalence of types (Equiv A B) all structures/properties respect equivalence Not by collapsing equivalence, but by exploiting proof-relevant equality: transport does real work 19
Higher inductive types [Bauer,Lumsdaine,Shulman,Warren] New way of forming types: Inductive type specified by generators not only for points (elements), but also for paths 20
Constructivity Non-affirmation of classical principles Computational interpretation? Proof-relevant mathematics 21
Homotopy Type Theory type theory new programs and types new possibilities for computerchecked proofs category theory homotopy theory 22
Outline 1.Certified homotopy theory 2.Certified software 23
Outline 1.Certified homotopy theory 2.Certified software 24
Homotopy Theory A branch of topology, the study of spaces and continuous deformations 25 [image from wikipedia]
Homotopy in HoTT π1(s 1 ) = Z πk<n(s n ) = 0 Hopf fibration π2(s 2 ) = Z π3(s 2 ) = Z James Construction Freudenthal πn(s n ) = Z K(G,n) Cohomology axioms Blakers-Massey Van Kampen Covering spaces Whitehead for n-types π4(s 3 ) = Z? [Brunerie, Finster, Hou, Licata, Lumsdaine, Shulman] 26
Homotopy in HoTT π1(s 1 ) = Z πk<n(s n ) = 0 Hopf fibration π2(s 2 ) = Z π3(s 2 ) = Z James Construction Freudenthal πn(s n ) = Z K(G,n) Cohomology axioms Blakers-Massey Van Kampen Covering spaces Whitehead for n-types π4(s 3 ) = Z? [Brunerie, Finster, Hou, Licata, Lumsdaine, Shulman] 26
Homotopy Groups Homotopy groups of a space X: π1(x) is fundamental group (group of loops) π2(x) is group of homotopies (2-dimensional loops) π3(x) is group of 3-dimensional loops 27
Telling spaces apart = 28
Telling spaces apart = fundamental group is non-trivial (Z Z) fundamental group is trivial 28
The Circle Circle S 1 is a higher inductive type generated by loop base 29
The Circle Circle S 1 is a higher inductive type generated by base : S 1 loop : base = base base loop 29
The Circle Circle S 1 is a higher inductive type generated by point base : S 1 loop : base = base base loop 29
The Circle Circle S 1 is a higher inductive type generated by point path base : S 1 loop : base = base base loop 29
The Circle Circle S 1 is a higher inductive type generated by point path base : S 1 loop : base = base loop -1 id base loop Free type: equipped with structure id loop -1 inv : loop o loop -1 = id... loop o loop 29
The Circle Circle recursion: function S 1! X determined by base loop base : X loop : base = base base loop 30
The Circle Circle recursion: function S 1! X determined by base loop base : X loop : base = base base loop Circle induction: To prove a predicate P for all points on the circle, suffices to prove P(base), continuously in the loop 30
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id loop base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id loop loop -1 base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id loop loop -1 loop o loop base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id loop loop -1 loop o loop loop -1 o loop -1 base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id loop loop -1 loop o loop loop -1 o loop -1 loop o loop -1 base loop 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? id loop loop -1 loop o loop loop -1 o loop -1 base loop loop o loop -1 = id 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id 0 loop loop -1 loop o loop loop -1 o loop -1 loop o loop -1 = id 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id loop 0 1 loop -1 loop o loop loop -1 o loop -1 loop o loop -1 = id 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id loop loop -1 0 1-1 loop o loop loop -1 o loop -1 loop o loop -1 = id 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id loop loop -1 loop o loop 0 1-1 2 loop -1 o loop -1 loop o loop -1 = id 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id loop loop -1 loop o loop loop -1 o loop -1 0 1-1 2-2 loop o loop -1 = id 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id loop loop -1 loop o loop loop -1 o loop -1 loop o loop -1 = id 0 1-1 2-2 0 31
Fundamental group of circle How many different loops are there on the circle, up to homotopy? base loop id loop loop -1 loop o loop loop -1 o loop -1 0 1-1 2-2 integers are codes for paths on the circle loop o loop -1 = id 0 31
Fundamental group of circle Definition. Ω(S 1 ) is the type of loops at base i.e. the type (base =S1 base) 32
Fundamental group of circle Definition. Ω(S 1 ) is the type of loops at base i.e. the type (base =S1 base) Theorem. Ω(S 1 ) is equivalent to Z, by a map that sends o to + 32
Fundamental group of circle Definition. Ω(S 1 ) is the type of loops at base i.e. the type (base =S1 base) Theorem. Ω(S 1 ) is equivalent to Z, by a map that sends o to + Corollary: Fundamental group of the circle is isomorphic to Z 32
Fundamental group of circle Definition. Ω(S 1 ) is the type of loops at base i.e. the type (base =S1 base) Theorem. Ω(S 1 ) is equivalent to Z, by a map that sends o to + Corollary: Fundamental group of the circle is isomorphic to Z 0-truncation (set of connected components) of Ω(S 1 ) 32
Fundamental group of circle Theorem. Ω(S 1 ) is equivalent to Z Proof (Shulman, L.): two mutually inverse functions wind : Ω(S 1 )! Z loop - : Z! Ω(S 1 ) 33
Fundamental group of circle Theorem. Ω(S 1 ) is equivalent to Z Proof (Shulman, L.): two mutually inverse functions wind : Ω(S 1 )! Z loop - : Z! Ω(S 1 ) loop 0 = id loop +n = loop o loop o loop (n times) loop -n = loop -1 o loop -1 o loop -1 (n times) 33
Universal Cover wind : Ω(S 1 )! Z defined by lifting a loop to the cover, and giving the other endpoint of 0 34
Universal Cover wind : Ω(S 1 )! Z defined by lifting a loop to the cover, and giving the other endpoint of 0 lifting is functorial 34
Universal Cover wind : Ω(S 1 )! Z defined by lifting a loop to the cover, and giving the other endpoint of 0 lifting is functorial lifting loop adds 1 34
Universal Cover wind : Ω(S 1 )! Z defined by lifting a loop to the cover, and giving the other endpoint of 0 lifting is functorial lifting loop adds 1 lifting loop -1 subtracts 1 34
Universal Cover wind : Ω(S 1 )! Z defined by lifting a loop to the cover, and giving the other endpoint of 0 lifting is functorial lifting loop adds 1 lifting loop -1 subtracts 1 Example: wind(loop o loop -1 ) = 0 + 1-1 = 0 34
Universal Cover 35
Universal Cover Cover : S 1! Type Cover(base) := Z Cover1(loop) := ua(successor) : Z = Z 35
Universal Cover defined by circle recursion Cover : S 1! Type Cover(base) := Z Cover1(loop) := ua(successor) : Z = Z 35
Universal Cover defined by circle recursion Cover : S 1! Type Cover(base) := Z Cover1(loop) := ua(successor) : Z = Z interpret loop as add 1 bijection 35
Universal Cover defined by circle recursion Cover : S 1! Type Cover(base) := Z Cover1(loop) := ua(successor) : Z = Z univalence interpret loop as add 1 bijection 35
Winding number wind : Ω(S 1 )! Z wind(p) = transportcover(p,0) lift p to cover, starting at 0 36
Winding number wind : Ω(S 1 )! Z wind(p) = transportcover(p,0) lift p to cover, starting at 0 wind(loop -1 o loop) 36
Winding number wind : Ω(S 1 )! Z wind(p) = transportcover(p,0) lift p to cover, starting at 0 wind(loop -1 o loop) = transport Cover (loop -1 o loop, 0) 36
Winding number wind : Ω(S 1 )! Z wind(p) = transportcover(p,0) lift p to cover, starting at 0 wind(loop -1 o loop) = transport Cover (loop -1 o loop, 0) = transport Cover (loop -1, transport Cover (loop,0)) 36
Winding number wind : Ω(S 1 )! Z wind(p) = transportcover(p,0) lift p to cover, starting at 0 wind(loop -1 o loop) = transport Cover (loop -1 o loop, 0) = transport Cover (loop -1, transport Cover (loop,0)) = transport Cover (loop -1, 1) 36
Winding number wind : Ω(S 1 )! Z wind(p) = transportcover(p,0) lift p to cover, starting at 0 wind(loop -1 o loop) = transport Cover (loop -1 o loop, 0) = transport Cover (loop -1, transport Cover (loop,0)) = transport Cover (loop -1, 1) = 0 36
Fundamental group of the circle The HoTT book Computer-checked 37
πn(s n ) in HoTT k th homotopy group n-dimensional sphere [image from wikipedia] 38
πn(s n ) in HoTT k th homotopy group n-dimensional sphere [image from wikipedia] 38
πn(s n ) = Z for n 1 Proof: Induction on n Base case: π1(s 1 ) = Z Inductive step: πn+1(s n+1 ) = πn(s n ) 39
πn(s n ) = Z for n 1 Proof: Induction on n Base case: π1(s 1 ) = Z Inductive step: πn+1(s n+1 ) = πn(s n ) Key lemma: S n n = Ω(S n+1 ) n 39
πn(s n ) = Z for n 1 Proof: Induction on n Base case: π1(s 1 ) = Z Inductive step: πn+1(s n+1 ) = πn(s n ) Key lemma: S n n = Ω(S n+1 ) n n-truncation: best approximation of a type such that all (n+1)-paths are equal 39
πn(s n ) = Z for n 1 Proof: Induction on n Base case: π1(s 1 ) = Z Inductive step: πn+1(s n+1 ) = πn(s n ) Key lemma: S n n = Ω(S n+1 ) n n-truncation: best approximation of a type such that all (n+1)-paths are equal higher inductive type generated by basen : S n loopn : Ω n (S n ) 39
S n n = Ω(S n+1 ) n n-truncation of S n is the type of codes for loops on S n+1
S n n = Ω(S n+1 ) n n-truncation of S n is the type of codes for loops on S n+1 Decode: promote n-dimensional loop on S n to n+1-dimensional loop on S n+1
S n n = Ω(S n+1 ) n n-truncation of S n is the type of codes for loops on S n+1 Decode: promote n-dimensional loop on S n to n+1-dimensional loop on S n+1 Encode: define fibration Code(x:S n+1 ) with Code(basen+1) := S n n Code(loopn+1) := equivalence S n n S n n rotating by loopn
π2(s 2 ): Hopf fibration
Synthetic homotopy theory Gap between informal and formal proofs is small Proofs are constructive*: can run them Results apply in a variety of settings, from simplicial sets (hence topological spaces) to Quillen model categories and -topoi* New type-theoretic proofs/methods 42 *work in progress
Outline 1.Certified homotopy theory 2.Certified software 43
Patches Patch a a 2c2 diff b c d c = < b --- > d Version control Collaborative editing 44
a b c id a b c
a b c id a b c a p a q a b d d c c e
a b c id a b c q o p a p a q a b d d c c e
a b c id a b c a b c p a d c q o p a p a q a b d d c c e
a b c id a b c a b c p a d c!p q o p a p a q a b d d c c e
a b c id a b c a b c p a d c!p q o p undo/rollback a p a q a b d d c c e
Patches are paths a b c id a b c a b c p a d c!p q o p undo/rollback a p a q a b d d c c e
Merging a d c p a b c q a b e 46
Merging a d c p a b c q a b e q a p d e 46
Merging p=b d at 1 p a b q q=c e at 2 c a d c a b e q a p d e 46
Merging p=b d at 1 p a b q q=c e at 2 c a d c a b e q a p d e p =p q =q 46
Merging p=b d at 1 p a b q q=c e at 2 c a d c = a b e q a p d e p =p q =q 46
Merging merge : (p q : Patch)! Σq,p :Patch. Maybe(q o p = p o q) 47
Merging merge : (p q : Patch)! Σq,p :Patch. Maybe(q o p = p o q) Equational theory of patches = paths between paths 47
Basic Patches f i b r a t i o n a b @ 2 f i b f i a a b @ 2 48
Basic Patches Repository is a char vector of length n f i b r a t i o n Basic patch is a b @ i where i<n a b @ 2 f i b f i a a b @ 2 48
Patches as a HIT Repos:Type 49
Patches as a HIT Repos:Type doc[n] points describe repository contents 49
Patches as a HIT Repos:Type a b@i doc[n] points describe repository contents paths are patches 49
Patches as a HIT Repos:Type compressed a b@i doc[n] points describe repository contents paths are patches 49
Patches as a HIT Repos:Type compressed gzip a b@i doc[n] points describe repository contents paths are patches 49
Patches as a HIT Repos:Type compressed gzip a b@i doc[n] points describe repository contents paths are patches 49
Patches as a HIT Repos:Type compressed gzip a b@i doc[n] points describe repository contents paths are patches doc[n] doc[n] doc[n] doc[n] 49
Patches as a HIT Repos:Type compressed gzip a b@i doc[n] points describe repository contents paths are patches doc[n] a b@i c d@j doc[n] doc[n] c d@j a b@i doc[n] 49
Patches as a HIT Repos:Type compressed gzip a b@i doc[n] points describe repository contents paths are patches paths between paths are equations between patches doc[n] a b@i c d@j doc[n] doc[n] c d@j a b@i doc[n] 49
Patches as a HIT Repos:Type compressed gzip a b@i doc[n] points describe repository contents paths are patches paths between paths are equations between patches doc[n] a b@i c d@j doc[n] doc[n] c d@j a b@i doc[n] i j 49
Generators for HIT 50
Generators for HIT Repos : Type 50
Generators for HIT Repos : Type doc[n] : Repos compressed : Repos 50
Generators for HIT Repos : Type doc[n] : Repos compressed : Repos (a b@i) : doc[n] = doc[n] if a,b:char, i<n gzip : doc[n] = compressed 50
Generators for HIT Repos : Type doc[n] : Repos compressed : Repos (a b@i) : doc[n] = doc[n] if a,b:char, i<n gzip : doc[n] = compressed commute: (a b at i)o(c d at j) if i j =(c d at j)o(a b at i) 50
Type: Patch Type: Repos Elements: Points: Paths: doc[n] a b@i Equality: (a b at i)o(c d at j)= (c d at j)o(a b at i)... id o p = p = p o id po(qor) = (poq)or Paths between paths: commute : (a b at i)o(c d at j)= (c d at j)o(a b at i)!p o p = id = p o!p p=p p=q if q=p p=r if p=q and q=r!p =!p if p = p p o q = p o q if p = p and q = q 51
Repos recursion To define a function it suffices to Repos! A 52
Repos recursion To define a function it suffices to Repos! A map the element generators of Repos to elements of A 52
Repos recursion To define a function it suffices to Repos! A map the element generators of Repos to elements of A map the equality generators of Repos to equalities between the corresponding elements of A 52
Repos recursion To define a function it suffices to Repos! A map the element generators of Repos to elements of A map the equality generators of Repos to equalities between the corresponding elements of A map the equality-between-equality generators to equalities between the corresponding equalities in A 52
Repos recursion To define a function it suffices to Repos! A map the element generators of Repos to elements of A map the equality generators of Repos to equalities between the corresponding elements of A map the equality-between-equality generators to equalities between the corresponding equalities in A All functions on Repos respect patches All functions on patches respect patch equality 52
Interpreter Goal is to define: interp : doc[n] = doc[n]! Bijection (Vec Char n) (Vec Char n) 53
Interpreter Goal is to define: interp : doc[n] = doc[n]! Bijection (Vec Char n) (Vec Char n) interp(id) = (λx.x, ) interp(q o p) = (interp q) ob (interp p) interp(!p) =!b (interp p) interp(a b@i) = swapat a b i 53
Interpreter Goal is to define: interp : doc[n] = doc[n]! Bijection (Vec Char n) (Vec Char n) interp(id) = (λx.x, ) interp(q o p) = (interp q) ob (interp p) interp(!p) =!b (interp p) interp(a b@i) = swapat a b i But only tool available is RepoDesc recursion: no direct recursion over paths 53
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Need to pick A and define I(doc[n]) := : A I 1 (a b@i) := : I(doc[n]) = I(doc[n]) I2(compose) := 54
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Key idea: pick A = Type and define I(doc[n]) := : Type I 1 (a b@i) := : I(doc[n]) = I(doc[n]) I2(compose) := 55
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Key idea: pick A = Type and define I(doc[n]) := Vec Char n : Type I 1 (a b@i) := : I(doc[n]) = I(doc[n]) I2(compose) := 56
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Key idea: pick A = Type and define I(doc[n]) := Vec Char n : Type I 1 (a b@i) := : Vec Char n = Vec Char n I2(compose) := 57
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Key idea: pick A = Type and define I(doc[n]) := Vec Char n : Type I 1 (a b@i) := ua(swapat a b i) : Vec Char n = Vec Char n I2(compose) := 58
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Key idea: pick A = Type and define I(doc[n]) := Vec Char n : Type I 1 (a b@i) := ua(swapat a b i) : Vec Char n = Vec Char n I2(compose) := univalence 58
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(a b at i) = swapat a b i Key idea: pick A = Type and define I(doc[n]) := Vec Char n : Type I 1 (a b@i) := ua(swapat a b i) : Vec Char n = Vec Char n I2(compose) := <proof about swapat> 59
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(p) = ua -1 (I1(p)) Key idea: pick A = Type and define I(doc[n]) := Vec Char n : Type I 1 (a b@i) := ua(swapat a b i) : Vec Char n = Vec Char n I2(compose) := <proof about swapat> 60
interp : doc[n]=doc[n]! Bijection (Vec Char n) (Vec Char n) interp(p) = ua -1 (I1(p)) Satisfies the desired equations (as propositional equalities): interp(id) = (λx.x, ) interp(q o p) = (interp q) ob (interp p) interp(!p) =!b (interp p) interp(a b@i) = swapat a b i 61
Summary 62
Summary I : Repos! Type interprets Repos as Types, patches as bijections, satisfying patch equalities 62
Summary I : Repos! Type interprets Repos as Types, patches as bijections, satisfying patch equalities Higher inductive elim. defines functions that respect equality: you specify what happens on the generators; homomorphically extended to id,o,!,... 62
Summary I : Repos! Type interprets Repos as Types, patches as bijections, satisfying patch equalities Higher inductive elim. defines functions that respect equality: you specify what happens on the generators; homomorphically extended to id,o,!,... Univalence lets you give a computational model of equality proofs (here, patches); guaranteed to satisfy laws 62
Summary I : Repos! Type interprets Repos as Types, patches as bijections, satisfying patch equalities Higher inductive elim. defines functions that respect equality: you specify what happens on the generators; homomorphically extended to id,o,!,... Univalence lets you give a computational model of equality proofs (here, patches); guaranteed to satisfy laws Shorter definition and code: 1 basic patch & 4 basic axioms of equality, instead of 4 patches & 14 equations 62
Operational semantics Can t run these programs yet Some special cases known, some recent progress: Licata&Harper, POPL 12 Coquand&Barras, 13 Shulman, 13 Bezem&Coquand&Huber, 13 Would support proof automation and programming applications 63
Outline 1.Certified homotopy theory 2.Certified software 64
Homotopy Type Theory type theory new programs and types category theory new certified programs and proofs homotopy theory 65