Computing with Univalence Daniel R. Licata with Robert Harper Carnegie Mellon University 1
Identity Types A type M, N : A Id A (M,N) type 2
Identity Types A type M, N : A Id A (M,N) type C : A → type F : A → B α : Id A (M,N) α : Id A (M,N) P : C [M] resp F α : Id B (F M,F N) subst C α P : C[N] Refl : Id A (M,M) all families respect identity 2
Identity Types A type M, N : A Id A (M,N) type C : A → type F : A → B α : Id A (M,N) α : Id A (M,N) P : C [M] resp F α : Id B (F M,F N) subst C α P : C[N] Refl : Id A (M,M) all families respect identity Computation rules: subst C Refl P ≡ P definitional equality: used silently resp F Refl ≡ Refl 2
Id in HoTT = Paths C : A → type F : A → B α : Id A (M,N) α : Id A (M,N) P : C [M] resp F α : Id B (F M,F N) subst C α P : C[N] Refl : Id A (M,M) Not the least type containing reflexivity (we’ll add other canonical inhabitants soon) Not the greatest type everything respects (not forced to include all consistent equalities) 3
Id in HoTT = Paths To define a type, you get to specify: what are its members? M : A what are its paths? α : Id A (M,N) (really a judgement α : M ≃ A N) Refl subst resp (and a few more operations) are an interface that you must implement 4
Id in HoTT = Paths To define a type, you get to specify: what are its members? M : A what are its paths? α : Id A (M,N) (really a judgement α : M ≃ A N) Refl subst resp (and a few more operations) are an interface that you must implement generalization of the Martin-Löf/NuPRL methodology of members and equality… 4
[Hofmann&Streicher, Univalence Voevodsky] “Isomorphic types are identical” 5
[Hofmann&Streicher, Univalence Voevodsky] “Isomorphic types are identical” in the sense of Id: interchangeable in all contexts 5
[Hofmann&Streicher, Univalence Voevodsky] “Isomorphic types are identical” really means in the sense of Id: homotopy equivalence interchangeable in all contexts 5
Univalence A, B : U universe = type of (small) types Univalence axiom entails the existence of a term ua : HEquiv(A,B) → Id U (A,B) f : A → B α : Id A → A (g o f, id) g : B → A β : Id B → B (f o g, id) (f,g, α , β ) : HEquiv( A, B) 6
Univalence A, B : U universe = type of (small) types Univalence axiom entails the existence of a term ua : HEquiv(A,B) → Id U (A,B) f : A → B α : Id A → A (g o f, id) g : B → A β : Id B → B (f o g, id) (f,g, α , β ) : HEquiv( A, B) HEquiv, and therefore Id, have computational content! They are structures, not propositions 6
“Isomorphic Types are Interchangeable” ua : HEquiv(A,B) → Id U (A,B) C : U → U (f,g, α , β ) : HEquiv( A, B) P : C [A] subst C ua(f,g, α , β ) P : C[B] 7
Constructivity Standard computation rule subst C Refl P ≡ P is clearly insufficient: added an introduction rule subst C ua(f,g, α , β ) P without adding a is stuck ! new β rule 8
Constructivity Standard computation rule subst C Refl P ≡ P is clearly insufficient: added an introduction rule subst C ua(f,g, α , β ) P without adding a is stuck ! new β rule Open problem: Can you normalize a program that is written using univalence? 8
Constructivity Open problem: Can you normalize a program that is written using univalence? Conjecture: yes! univalence is admissible in type theory without U: all constructions respect type isomorphism UA demands that constructions on U do too should be able to eliminate UA using admissibility 9
Approaches to Computation Constructive model in simplicial sets/types [Coquand&Huber, next] or in weak ω -groupoids [Altenkirch et al., later today] This work: progress on special case using syntactic techniques inspired by groupoid model 10
Canonicity for 2D type theory [Licata&Harper, POPL’12] Take various equations from the Hofmann/Streicher groupoid model as (strict) definitional equalities ≡ Consistency by groupoid model Prove canonicity If ⋅ ⊢ M : 2 then M ≡ true or M ≡ false by “logical groupoids” 11
Canonicity for 2D type theory If ⋅ ⊢ M : 2 then M ≡ true or M ≡ false Simplifications: 2 dimensional means - E.g. Id U (A,B) can have computational content… - but Id Id(M,N) ( α , β ) is trivial (equality reflection + UIP). 12
Canonicity for 2D type theory If ⋅ ⊢ M : 2 then M ≡ true or M ≡ false Simplifications: 2 dimensional means - E.g. Id U (A,B) can have computational content… - but Id Id(M,N) ( α , β ) is trivial (equality reflection + UIP). All paths between paths are reflexivity: β : Id Id(M,N) ( α 1 , α 2 ) β : Id Id(M,N) ( α 1 , α 2 ) α 1 ≡ α 2 β ≡ Refl 13
Canonicity for 2D type theory If ⋅ ⊢ M : 2 then M ≡ true or M ≡ false Simplifications: 2 dimensional means - E.g. Id U (A,B) can have computational content… - but Id Id(M,N) ( α , β ) is trivial (equality reflection + UIP). We avoid normalizing homotopies. Only proved canonicity up to ≡ , which includes equality reflection: not yet an algorithm. 14
Canonicity for 2D type theory If ⋅ ⊢ M : 2 then M ≡ true or M ≡ false Simplifications: 2 dimensional means - E.g. Id U (A,B) can have computational content… - but Id Id(M,N) ( α , β ) is trivial (equality reflection + UIP). We avoid normalizing homotopies. Only proved canonicity up to ≡ , which includes equality reflection: not yet an algorithm. But proof suggests an algorithm for 2D, and perhaps for low levels of ∞ D 14
Key Idea C : A → type F : A → B α : Id A (M,N) α : Id A (M,N) P : C [M] resp F α : Id B (F M,F N) subst C α P : C[N] Admissibility of univalence = generic programs: subst computes guided by the structure of C resp computes guided by the structure of F similar non-uniform definitions for other groupoid operations not surprising from semantics but need to express it in syntax 15
[Altenkirch et al.’s OTT does this for sets; Key Idea we do it for groupoids] C : A → type F : A → B α : Id A (M,N) α : Id A (M,N) P : C [M] resp F α : Id B (F M,F N) subst C α P : C[N] Admissibility of univalence = generic programs: subst computes guided by the structure of C resp computes guided by the structure of F similar non-uniform definitions for other groupoid operations not surprising from semantics but need to express it in syntax 15
Computational interpretation 1.Define each type by members and paths, with Refl -1 o satisfying groupoid laws 2.Define subst C α M for each C 3.Define resp F α for each F and α 4.Define full Id-elim rule J using subst (1,2,3 simultaneous) 16
Computational interpretation 1.Define each type by members and paths, with Refl -1 o satisfying groupoid laws 2.Define subst C α M for each C 3.Define resp F α for each F and α 4.Define full Id-elim rule J using subst 17
Type A * B Members: (M, N) where M : A and N : B Paths: α : Id A (M,N) β : Id B (M’, N’) pair ≃ α β : Id A*B (M,N)(M’,N’) Refl (M,N) ≡ pair ≃ Refl M Refl N (pair ≃ α β ) -1 ≡ (pair ≃ α -1 β -1 ) (pair ≃ α β ) o (pair ≃ α ’ β ’) ≡ (pair ≃ α o α ’ β o β ’) 18
Type A * B Members: (M, N) where M : A and N : B Paths: α : Id A (M,N) β : Id B (M’, N’) pair ≃ α β : Id A*B (M,N)(M’,N’) Refl (M,N) ≡ pair ≃ Refl M Refl N justifies Refl rule (pair ≃ α β ) -1 ≡ (pair ≃ α -1 β -1 ) (pair ≃ α β ) o (pair ≃ α ’ β ’) ≡ (pair ≃ α o α ’ β o β ’) 18
Type A * B Members: (M, N) where M : A and N : B Paths: α : Id A (M,N) β : Id B (M’, N’) pair ≃ α β : Id A*B (M,N)(M’,N’) Refl (M,N) ≡ pair ≃ Refl M Refl N justifies Refl rule (pair ≃ α β ) -1 ≡ (pair ≃ α -1 β -1 ) needed later (pair ≃ α β ) o (pair ≃ α ’ β ’) ≡ (pair ≃ α o α ’ β o β ’) 18
Type U Members: <names for small sets>, which determine types by the type El(A : U) Paths: (f,g, α , β ) : HEquiv A B ua(f,g, α , β ) : Id U ( A, B) Refl A ≡ (x:El(A).x,x:El(A).x,x.Refl x ,x.Refl x ) (ua(f,g, α , β )) -1 ≡ … (ua(f’,g’, α ’, β ’)) o (ua(f’,g’, α ’, β ’)) ≡ … 19
Circle S 1 loop b Members: b : S 1 Paths: freely generated by - -1 and Refl b and (- o -) from loop : b ≃ b such that groupoid laws hold up to ≡ for 2TT up to ≃ for full HoTT 20
Computational interpretation 1.Define each type by members and paths, with Refl -1 and o satisfying groupoid laws 2.Define subst C α M for each family C 3.Define resp F α for each F and α 4.Define full Id-elim rule J using subst 21
Subst C : A → type α : Id A (M,N) P : C [M] subst C α P : C[N] To be a family of types over A, C must have an associated operation subst C Functionality (à la NuPRL) becomes functoriality 22
Case for x.A(x) * B(x) Id( θ 1, θ 2) Want subst x.A(x) x B(x) α : A[ θ 1] * B[ θ 1] A[ θ 2] * B[ θ 2] → Have: 23
Case for x.A(x) * B(x) Id( θ 1, θ 2) Want subst x.A(x) x B(x) α : A[ θ 1] * B[ θ 1] A[ θ 2] * B[ θ 2] → Have: subst A α : A[ θ 1] → A[ θ 2] 23
Case for x.A(x) * B(x) Id( θ 1, θ 2) Want subst x.A(x) x B(x) α : A[ θ 1] * B[ θ 1] A[ θ 2] * B[ θ 2] → Have: subst A α : A[ θ 1] → A[ θ 2] subst B α : B[ θ 1] → B[ θ 2] 23
Recommend
More recommend