Identity Types in HoTT vs. Book HoTT vs. Cubical โ€” what's the actual difference?

๐Ÿ“Œ Pinned ๐Ÿ’ฌ 84 replies ๐Ÿ‘ 2,341 views ๐Ÿ”ฅ Very Active Forum: HoTT & Univalent Foundations
UnivalenceFan
๐ŸŒธ Adjoint Functor
๐ŸฆŠ
Posts: 1,204
Joined: 2022-03
Rep: โ˜…โ˜…โ˜…โ˜†
Prover: Agda
#1

ok so I keep seeing these terms thrown around and honestly I need a definitive thread about this. Like we have:

Id โ€” the Martin-Lรถf identity type (inductive family, J eliminator)
Path โ€” cubical path types (maps out of an interval)
PropEq โ€” the thing Agda calls _โ‰ก_ (also Id basically??)
Book HoTT style โ€” whatever the HoTT Book does
Cubical HoTT โ€” Cubical Agda / CCHM / etc.

Are these literally the same type? Are they equivalent but not definitionally equal? Does it matter which one I use? I'm so confused nya~~

Like I can see in Cubical Agda there's Cubical.Core.Id for "identity type" and also Path from the cubical primitives, and they're both there but apparently different?? The docs even say something about this but I find it really confusing.

Specific questions:
1. What is the fundamental definitional difference?
2. Why does cubical have BOTH Id and Path?
3. Is PropEq in vanilla Agda the same as Id in HoTT? Or Book HoTT?
4. What does univalence have to do with all this?
5. What is PathP??

Please someone who actually understands this stuff give me a good explanation ๐Ÿ™ gonna make tea and wait nya~

๐Ÿฑ 50 ๐Ÿ’œ 38 ๐Ÿค” 22 ๐Ÿ”ฅ 17 Same tbh 11
CubicalCat
๐Ÿ’œ Kan Fibration
๐Ÿˆ
Posts: 4,887
Joined: 2020-11
Rep: โ˜…โ˜…โ˜…โ˜…โ˜…
Prover: Cubical Agda
#2

OK perfect question, let me give the big picture first and then go deep nya~

THE FUNDAMENTAL SPLIT: Inductive Id vs. Path Types

Martin-Lรถf Identity Type (Id / PropEq): This is the OG. The identity type is introduced as an inductive family with one constructor (refl), and everything follows from the J eliminator. This is what standard MLTT has, what the HoTT Book uses as its formal foundation, and what vanilla Agda's _โ‰ก_ is.

-- Standard MLTT / Book HoTT / vanilla Agda PropEq data Id (A : Set) : A โ†’ A โ†’ Set where refl : (x : A) โ†’ Id A x x -- or in Agda notation: data _โ‰ก_ {A : Set} : A โ†’ A โ†’ Set where refl : {x : A} โ†’ x โ‰ก x

Cubical Path Types: Completely different animal. In cubical type theory, maps out of an interval primitive are used to define cubical path types, rather than the inductive family of Martin-Lรถf identity types. A path from a to b in type A is literally a function I โ†’ A where I is an abstract interval.

-- Cubical Agda: Path types -- PathP : (A : I โ†’ Set) โ†’ A i0 โ†’ A i1 โ†’ Set -- Path : (A : Set) โ†’ A โ†’ A โ†’ Set -- Path A a b = PathP (ฮป _ โ†’ A) a b -- refl is just the constant function! refl : {A : Set} {x : A} โ†’ Path A x x refl {x = x} = ฮป i โ†’ x

The correspondence is taken very literally in Cubical Agda: a path in a type A is represented like a function out of the interval, I โ†’ A. This is the core philosophical shift.

๐Ÿฑ 112 ๐Ÿ’œ 94 ๐Ÿ”– saved 67 ๐Ÿคฏ 45
CubicalCat
๐Ÿ’œ Kan Fibration
๐Ÿˆ
Posts: 4,887
Joined: 2022-11
Rep: โ˜…โ˜…โ˜…โ˜…โ˜…
Prover: Cubical Agda
#3

(continuing my previous post, hit the char limit)

So why does Cubical Agda have BOTH?

Good question! Cubical Agda has Path (the native cubical type) and also Cubical.Core.Id (the identity type defined using cubical primitives). The cubical identity type and the path type are equivalent, so all of the results for one can be transported to the other one (using univalence).

The reason both exist is ergonomics. The Id type in Cubical Agda supports J and pattern matching on refl (which J-encoded proofs rely on), but the native cubical Path type is much nicer to work with interactively because you can define proofs using lambda notation.

โš ๏ธ Key practical difference:
The syntax for path types does not work for the identity types, making many proofs more involved. Furthermore, the path types satisfy many useful definitional equalities that the identity types don't.

For example with Path types you can directly compose paths, apply them, and use them in function extensionality proofs without needing combinators. With Id you're stuck doing everything through J.

The official recommendation in Cubical Agda is: "use the cubical identity types unless you really need J to compute on refl."

๐Ÿฑ 87 ๐Ÿ’œ 71 ๐Ÿ“Œ pinned this in my head 55
PropTruncPurr
๐ŸŒธ Setoid Kitten
๐Ÿพ
Posts: 632
Joined: 2023-01
Rep: โ˜…โ˜…โ˜†โ˜†
Prover: Coq
#4

wait so in Coq/vanilla Agda when I write Prop or eq or _โ‰ก_ that's just the inductive family Id type right? And it's basically what "Book HoTT" uses?

And the whole point of going cubical is to make univalence actually COMPUTE instead of just being an axiom that's stuck?

I feel like that's the crux of it but maybe I'm missing something

๐Ÿฑ 23 good q 18
KanExtensionKitty
๐Ÿ’œ Monad Transformer
๐Ÿ”ฎ
Posts: 2,109
Joined: 2021-06
Rep: โ˜…โ˜…โ˜…โ˜…
Prover: Lean 4
#5
PropTruncPurr wrote:
And the whole point of going cubical is to make univalence actually COMPUTE instead of just being an axiom that's stuck?

Exactly! You've got the core insight. Cubical type theory is a version of homotopy type theory in which univalence is not just an axiom but a theorem, hence, since this is constructive, has "computational content."

In Book HoTT, the situation is:

-- Book HoTT / vanilla Agda with postulates -- Univalence is an AXIOM โ€” it's just stuck, never computes postulate univalence : {A B : Set} โ†’ (A โ‰ƒ B) โ‰ƒ (A โ‰ก B) -- transport along ua f doesn't reduce definitionally -- you can prove it reduces *propositionally* but that's it

In Cubical Agda:

-- Cubical: univalence COMPUTES via Glue types -- ua : A โ‰ƒ B โ†’ Path Set A B -- uaฮฒ : transport (ua e) x โ‰ก e .fst x โ† this is DEFINITIONAL -- transport along a path derived from an equivalence -- actually reduces to applying the equivalence!

So the practical payoff is: transporting along the path that we get from applying ua to an equivalence is hence the same as applying the equivalence โ€” but in cubical this is a definitional equality, not just propositional. Your proofs can actually compute nya~

Also this is why function extensionality is a theorem in cubical rather than an axiom: function extensionality is a theorem in cubical type theory, rather than an axiom as is the case in Martin-Lรถf type theory.

๐Ÿฑ 95 ๐Ÿ’œ 83 ๐Ÿคฏ mind = blown 61 ๐Ÿ”ฅ 39
MLTTMeowington
๐ŸŒธ Sheaf Section
๐Ÿ“–
Posts: 3,441
Joined: 2019-08
Rep: โ˜…โ˜…โ˜…โ˜…โ˜…
Prover: Agda + Coq
#6

Let me add the "Book HoTT vs Cubical" framing more explicitly because I think that's the confusion OP is having:

Book HoTT (first generation HoTT):

โ‘  Based on intensional Martin-Lรถf Type Theory
โ‘ก Identity types characterized by path induction (J)
โ‘ข Univalence is an axiom (not computational)
โ‘ฃ Many laws are not definitional e.g. Id(Aร—B)((a,b),(a',b')) โ‰ข Id_A(a,a') ร— Id_B(b,b')

Cubical Type Theory (second generation HoTT):

โ‘  Paths defined as maps out of an interval "exo-type" I
โ‘ก Cubical Kan operations asserted explicitly in syntax
โ‘ข Univalence proved from "Glue types" โ€” it computes!
โ‘ฃ Has proper canonicity / computational content

The big philosophical difference CubicalCat didn't mention: in Book HoTT, operations such as transport and path composition are defined by induction on the paths; thus they reduce when the paths are reflexivity, but are stuck otherwise. However you CAN prove they reduce typally based on the form of the type.

Cubical flips this: the type-based reductions become judgmental, while the path-based ones become merely propositional. So it's not that cubical is strictly "better" โ€” it makes different tradeoffs!

๐Ÿฑ 78 ๐Ÿ’œ 66 ๐Ÿ“Œ saving 44
UnivalenceFan
๐ŸŒธ Adjoint Functor
๐ŸฆŠ
Posts: 1,204
Joined: 2022-03
Rep: โ˜…โ˜…โ˜…โ˜†
Prover: Agda
#7
MLTTMeowington wrote:
Cubical flips this: the type-based reductions become judgmental, while the path-based ones become merely propositional.

OK wait that's actually a really cool way to put it. So it's not like cubical is just "strictly better" โ€” it's making a different design choice about WHICH equalities are definitional?

but then my brain short-circuits: if Path and Id in cubical are equivalent (via univalence I guess?) does that mean using either one is "equally valid" for formal proofs? or does the distinction show up in extracted computation?

also you mentioned PropEq in vanilla Agda โ€” that IS the Id inductive family right? just with different notation? I always assumed it was the same thing.

๐Ÿฑ 19 ๐Ÿ’ฌ good follow up 14
CubicalCat
๐Ÿ’œ Kan Fibration
๐Ÿˆ
Posts: 4,887
Joined: 2020-11
Rep: โ˜…โ˜…โ˜…โ˜…โ˜…
Prover: Cubical Agda
#8
UnivalenceFan wrote:
if Path and Id in cubical are equivalent does that mean using either one is "equally valid"?

For formal mathematical content: yes, they're equivalent. But for computational purposes: not really.

Think of it this way. Path types in cubical have rich definitional equalities that let proofs actually reduce. Id types (even in cubical) only reduce when you pattern-match on refl. So if you want your extracted programs to compute nicely, you use Path.

There's actually a really nice quote from the Cubical Agda interface that captures this โ€” when they wrap cubical primitives in the Book HoTT style interface, they note that "pattern matching on refl is not available" for the identity type, and you have to use J instead. That's the cost.

As for PropEq in vanilla Agda: yes, _โ‰ก_ in standard Agda (without --cubical) is exactly the inductive family identity type. One constructor refl, J eliminator, the whole deal. Same as Book HoTT's Id. The difference is just spelling/notation.

The big difference: in vanilla Agda + HoTT axioms, you're working with stuck terms โ€” ua and funext are postulates that never reduce. In cubical Agda, this gives an axiom-free version of HoTT/UF which computes properly.

Concretely: if you transport a monoid structure along ua of some equivalence, in vanilla HoTT+axioms the resulting operation is stuck. In cubical it actually reduces to the expected operation on the new carrier. That's huge for doing actual verified computation!

๐Ÿฑ 134 ๐Ÿ’œ 117 ๐Ÿ”ฅ 89 ๐Ÿคฏ 74 saved 52
PathoverPrincess
๐ŸŒธ HITs Enjoyer
๐ŸŒบ
Posts: 891
Joined: 2022-09
Rep: โ˜…โ˜…โ˜…โ˜†
Prover: Cubical Agda
#9

Nobody answered OP's question 5 about PathP yet! Let me do that nya~

PathP: heterogeneous path types / path-over types

-- PathP : (A : I โ†’ Set) โ†’ A i0 โ†’ A i1 โ†’ Set -- "A path from (a : A i0) to (b : A i1) over the line A" -- Regular Path is a special case where A is constant: Path A a b = PathP (ฮป _ โ†’ A) a b

PathP is a heterogeneous path type. The "P" stands for "path-over" โ€” it's a path that lives over a line of types (a function I โ†’ Set). So if you have a path p : A โ‰ก B (a path between types) then PathP (ฮป i โ†’ p i) a b is a path from a : A to b : B that "lies over" the type path p.

This generalizes the HoTT Book's notion of "path-over" or heterogeneous equality. These non-dependent path types are supposed to correspond to the identity types of HoTT/UF while PathP is a cubical version of the "path-over" types of HoTT, that is, paths living over a line of types.

Why is this useful? Because when working with HITs (higher inductive types), your path constructors often go between terms of different types (or at least types that vary over a dimension). Having built-in PathP is extremely handy โ€” you don't need JM (John Major equality) or other heterogeneous equality hacks from vanilla type theory.

-- Example: transport is PathP -- If p : A โ‰ก B and a : A and b : B, then -- "transport p a โ‰ก b" is the same as "PathP p a b" -- No need to explicitly write transport! โœจ
๐Ÿฑ 88 ๐Ÿ’œ 72 ๐ŸŒบ PathP supremacy 55 ๐Ÿ”– saved 40
WTypeWitch
๐Ÿ”ฎ Ordinal Meow
๐Ÿง™
Posts: 567
Joined: 2023-04
Rep: โ˜…โ˜…โ˜†โ˜†
Prover: Lean 4
#10

Can I throw in the "practical choice" angle? Because I think there's also a "which should I actually use" dimension here that OP probably cares about:

There are actually good reasons to keep using Book HoTT style (Id type + axioms) even if you know cubical:

1. Model-agnostic: Code using Book HoTT/Id style works in more models (simplicial sets, etc.) not just cubical sets
2. Accessibility: There's a book for HoTT/UF and there isn't one for cubical type theory
3. Portability: Competing alternatives to cubical may emerge โ€” Book HoTT code is more likely to be future-proof
4. Tooling: Pattern-matching on refl works in vanilla Agda/Coq with Id types

Reasons to go cubical:

1. Computation: Univalence and funext actually compute
2. HITs: Higher inductive types work much better
3. PathP: Heterogeneous equality is built in
4. No axioms: Everything is definitional, no postulates needed

Honestly for most practical Agda work I see people using Cubical Agda now, but the HoTT Book+axioms style is still the lingua franca for communicating ideas.

๐Ÿฑ 65 ๐Ÿ’œ 59 practical 43
HOTTcat
๐Ÿ’œ Third-Gen Theorist
๐Ÿš€
Posts: 1,337
Joined: 2021-02
Rep: โ˜…โ˜…โ˜…โ˜…
Prover: Narya
#11

Real nerd moment: nobody's mentioned the third generation stuff yet (Shulman's H.O.T.T. / Higher Observational Type Theory)!

The generations go roughly:

1st gen: Book HoTT Id type = inductive, J eliminator Univalence = axiom (stuck computation) FunExt = axiom 2nd gen: Cubical Type Theory (CCHM, ABCFHL, Cubical Agda) Path type = maps out of interval I Univalence = theorem via Glue types (computes!) FunExt = theorem Cost: dimension variables, Kan operations, auxiliary syntax 3rd gen: H.O.T.T. (higher observational TT, work in progress) Id type = observational / structural characterizations Univalence = definitional equality (computes!) FunExt = theorem No dimension variables or cubical machinery

The cubical approach has a philosophical cost: cubical type theories achieve computational univalence only by adding syntax for auxiliary/spurious interval types with rewrite rules which encode technical detail that has no abstract motivation โ€” the interval I isn't really a "type" in the traditional sense, it's an exo-type that leaks into the theory.

H.O.T.T. tries to get the computational benefits without the interval machinery. Still work in progress but really exciting stuff! Check out the HOTT thread for more.

๐Ÿฑ 101 ๐Ÿ’œ 88 ๐Ÿš€ future 77 ๐Ÿคฏ 66
UnivalenceFan
๐ŸŒธ Adjoint Functor
๐ŸฆŠ
Posts: 1,204
Joined: 2022-03
Rep: โ˜…โ˜…โ˜…โ˜†
Prover: Agda
#12

OK let me try to write a summary of what I've learned from this thread so far before more replies come in (this blew up fast?? 84 replies already??)

My Understanding (please correct me!)

Id / PropEq / _โ‰ก_: All names for the Martin-Lรถf inductive identity type. One constructor (refl), everything via J. This is "Book HoTT" and vanilla Agda/Coq.

Path: Cubical path type = function out of interval I. Refl is the constant function ฮป i โ†’ x. Much richer definitional equalities.

PathP: Heterogeneous version of Path, living over a type line A : I โ†’ Set. Generalizes "path-over" / dependent paths.

Book HoTT: Uses Id + univalence as axiom. Works in all โˆž-toposes. Computation is limited (stuck terms). Lingua franca of HoTT community.

Cubical HoTT: Uses Path. Univalence is a theorem via Glue types. Everything computes! Requires dimension variables / Kan machinery.

The equivalence: Id and Path are homotopy-equivalent (via univalence), but NOT definitionally isomorphic. The latter supports J but only with typal computation rule.

Thank you all so much!!! This is exactly what I needed nya~ ๐ŸฆŠ๐Ÿ’œ going to install Cubical Agda tonight

still following the thread though because I'm sure someone will bring up XTT or cartesian cubical or something and blow my mind again lmao

๐Ÿฑ 147 ๐Ÿ’œ 133 โœ… correct summary 119 ๐ŸฆŠ OP 98 nya~ 87
๐Ÿ“ Post Reply โ€” Identity Types in HoTT vs. Book HoTT vs. Cubical
Logged in as: CatGirlGuest | Login | Register