git as a hit
play

Git as a HIT Dan Licata Wesleyan University 1 1 Darcs Git as a - PowerPoint PPT Presentation

Git as a HIT Dan Licata Wesleyan University 1 1 Darcs Git as a HIT Dan Licata Wesleyan University 1 1 HITs 2 Generator for 2 HITs Homotopy Type Theory is an extension of Agda/Coq based on connections with homotopy theory


  1. Type: Patch Type: RepoDesc Element: vec : RepoDesc Elements: Equality: Patch { a ↔ b at i : vec = vec Equality: Equality between equalities: (a ↔ b at i)o(c ↔ d at j)= commute : (c ↔ d at j)o(a ↔ b at i) (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 … basic axioms only! !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’ 17 17

  2. Type: Patch Type: RepoDesc Element: vec : RepoDesc Elements: Equality: Patch { a ↔ b at i : vec = vec Equality: Equality between equalities: (a ↔ b at i)o(c ↔ d at j)= commute : (c ↔ d at j)o(a ↔ b at i) (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 … basic axioms only! !p o p = id = p o !p p=p Everything else comes p=q if q=p “for free” from p=r if p=q and q=r !p = !p’ if p = p’ the equality type! p o q = p’ o q’ if p = p’ and q = q’ 17 17

  3. Typed Patches RepoDesc : Type vec : RepoDesc generators for elements compressed : RepoDesc a ↔ b at i : vec = vec generators for equalities gzip : vec = compressed 18 Generator for 18

  4. Typed Patches RepoDesc : Type vec : RepoDesc generators for elements compressed : RepoDesc a ↔ b at i : vec = vec generators for equalities gzip : vec = compressed { Patch vec compressed 18 Generator for 18

  5. Patches as a HIT 1.How do you define Patch using a higher inductive type? 2.What is the elimination rule for RepoDesc ? 3.How do you use the elim. rule to define interp ? 19 19

  6. RepoDesc recursion To define a function RepoDesc � A it su ffi ces to 20 Generator for 20

  7. RepoDesc recursion To define a function RepoDesc � A it su ffi ces to map the element generators of RepoDesc to elements of A 20 Generator for 20

  8. RepoDesc recursion To define a function RepoDesc � A it su ffi ces to map the element generators of RepoDesc to elements of A map the equality generators of RepoDesc to equalities between the corresponding elements of A 20 Generator for 20

  9. RepoDesc recursion To define a function RepoDesc � A it su ffi ces to map the element generators of RepoDesc to elements of A map the equality generators of RepoDesc to equalities between the corresponding elements of A map the equality-between-equality generators to equalities between the corresponding equalities in A 20 Generator for 20

  10. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give 21 Generator for 21

  11. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A 21 Generator for 21

  12. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) 21 Generator for 21

  13. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) 21 Generator for 21

  14. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) You only specify f on generators, not id , o , ! ,group laws,congruence,… (1 patch and 4 basic axioms, instead of 4 and 14!) 21 Generator for 21

  15. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) 22 Generator for 22

  16. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) Type-generic equality rules say that functions act homomorphically on id , o , ! ,… 22 Generator for 22

  17. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give =f 1 (a ↔ b at i)o f(vec) := … : A f 1 (c ↔ d at j) f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) Type-generic equality rules say that functions act homomorphically on id , o , ! ,… 22 Generator for 22

  18. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) 23 Generator for 23

  19. RepoDesc recursion To define a function f : RepoDesc � A it su ffi ces to give f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose a b c d i j i ≠ j) := … : f 1 ((a ↔ b at i)o(c ↔ d at j)) = f 1 ((c ↔ d at j)o(a ↔ b at j)) All functions on RepoDesc respect patches All functions on patches respect patch equality 23 Generator for 23

  20. Patches as a HIT 1.How do you define Patch using a higher inductive type? 2.What is the elimination rule for RepoDesc ? 3.How do you use the elim. rule to define interp ? 24 24

  21. Interp Goal is to define: interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(id) = ( λ x.x, …) interp(q o p) = (interp q) o b (interp p) interp(!p) = ! b (interp p) interp(a ↔ b at i) = swapat a b i 25 Generator for 25

  22. Interp Goal is to define: interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(id) = ( λ x.x, …) interp(q o p) = (interp q) o b (interp p) interp(!p) = ! b (interp p) interp(a ↔ b at i) = swapat a b i But only tool available is RepoDesc recursion: no direct recursion over proofs of equality 25 Generator for 25

  23. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Need to pick A and define f(vec) := … : A f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose) := … 26 Generator for 26

  24. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define f(vec) := … : Type f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose) := … 27 Generator for 27

  25. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define f(vec) := Vec Char n : Type f 1 (a ↔ b at i) := … : f(vec) = f(vec) f 2 (compose) := … 28 Generator for 28

  26. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define f(vec) := Vec Char n : Type f 1 (a ↔ b at i) := … : Vec Char n = Vec Char n f 2 (compose) := … 29 Generator for 29

  27. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define f(vec) := Vec Char n : Type f 1 (a ↔ b at i) := ua(swapat a b i) : Vec Char n = Vec Char n f 2 (compose) := … 30 Generator for 30

  28. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define f(vec) := Vec Char n : Type f 1 (a ↔ b at i) := ua(swapat a b i) : Vec Char n = Vec Char n f 2 (compose) := … Voevodky’s univalence axiom ⊃ bijective types are equal 30 Generator for 30

  29. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define f(vec) := Vec Char n : Type f 1 (a ↔ b at i) := ua(swapat a b i) : Vec Char n = Vec Char n f 2 (compose) := <proof about swapat as before> 31 Generator for 31

  30. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(a ↔ b at i) = swapat a b i Key idea: pick A = Type and define I(vec) := Vec Char n : Type I 1 (a ↔ b at i) := ua(swapat a b i) : Vec Char n = Vec Char n I 2 (compose) := <proof about swapat as before> 32 Generator for 32

  31. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(p) = ua -1 (I 1 (p)) Key idea: pick A = Type and define I(vec) := Vec Char n : Type I 1 (a ↔ b at i) := ua(swapat a b i) : Vec Char n = Vec Char n I 2 (compose) := <proof about swapat as before> 33 Generator for 33

  32. interp : vec = vec � Bijection (Vec Char n) (Vec Char n) interp(p) = ua -1 (I 1 (p)) Satisfies the desired equations (as propositional equalities): interp(id) = ( λ x.x, …) interp(q o p) = (interp q) o b (interp p) interp(!p) = ! b (interp p) interp(a ↔ b at i) = swapat a b i 34 Generator for 34

  33. Summary 35 Generator for 35

  34. Summary I : RepoDesc � Type interprets RepoDesc ’s as Type s, patches as bijections, satisfying patch equalities 35 Generator for 35

  35. Summary I : RepoDesc � Type interprets RepoDesc ’s as Type s, 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 , ! ,... 35 Generator for 35

  36. Summary I : RepoDesc � Type interprets RepoDesc ’s as Type s, 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 35 Generator for 35

  37. Summary I : RepoDesc � Type interprets RepoDesc ’s as Type s, 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 than using quotients: 1 basic patch & 4 basic axioms of equality, instead of 4 patches & 14 equations 35 Generator for 35

  38. Where does this programming technique come from? 36 Generator for 36

  39. Homotopy type theory p b a 37 37

  40. Homotopy type theory a space is a type A p b a 37 37

  41. Homotopy type theory a space is a type A p b a points are elements a:A 37 37

  42. Homotopy type theory a space is a type A p b a points are elements paths are a:A proofs of equality p : a = A b 37 37

  43. Homotopy type theory a space is a type A path operations p b a points are elements paths are a:A proofs of equality p : a = A b 37 37

  44. Homotopy type theory a space is a type A path operations id : a = a (refl) p id b a points are elements paths are a:A proofs of equality p : a = A b 37 37

  45. Homotopy type theory a space is a type A path operations id : a = a (refl) p id !p !p : b = a (sym) b a points are elements paths are a:A proofs of equality p : a = A b 37 37

  46. Homotopy type theory a space is a type A path operations id : a = a (refl) p id !p !p : b = a (sym) b a q o p : a = c (trans) q c points are elements paths are a:A proofs of equality p : a = A b 37 37

  47. Homotopy type theory a space is a type A path operations id : a = a (refl) p id !p !p : b = a (sym) b a q o p : a = c (trans) q c homotopies id o p = p points are !p o p = id elements paths are r o (q o p) a:A proofs of equality = (r o q) o p p : a = A b 37 37

Recommend


More recommend