📐 Cubical Type Theory ELI5 — I keep hearing about it but am scared

Posted in Type Theory & Formal Verification  |  29 replies  |  1,847 views  |  Started by CubeScared
#1   CubeScared

Hi everyone!! Long time lurker, first real post (aside from my intro).

So I've been trying to get into HoTT and I keep seeing "cubical type theory" everywhere. People on this forum and on the HoTT discord throw the acronyms CCHM, CHM, Cubical Agda around like they're obvious, but when I try to read the actual papers my brain just gives up immediately. 😭

I've read the HoTT Book (like, most of it) and I vaguely understand that univalence is an axiom there — you postulate it. And I know that's apparently a problem? But I don't really understand why that's bad or what cubical type theory actually does differently.

Could someone please give me a gentle ELI5? I'm not scared of math but I am scared of 50-page papers full of De Morgan algebras. 🙈

📌 What I already know (roughly):
  • Basic dependent type theory (MLTT)
  • HoTT book Chapters 1–6
  • Vague idea that univalence = "equivalent types are equal"
  • Have Agda installed, never tried the cubical mode

Thank you in advance!! 🐱

— scared of cubes but not of catgirls 🐱
#2   CubicalCatgirl

Welcome to your first real post!! 🎉 This is actually one of my favourite topics to explain, so let me try.

The core problem with Book HoTT

You're right that univalence in the HoTT Book is an axiom. That means it's a statement you add to the type theory without giving it any computational rule — you just say "this is true, trust me." The problem is that when you add an axiom, there is no way for Agda or Coq to know how it should compute. In particular, canonicity no longer holds — you can produce terms that are stuck (booleans that are neither true nor false, for example, that don't reduce further). It's like having a programming language where you can't actually run the programs.

💜 Key insight: what's canonicity?

Canonicity says every closed term of a basic type (like Bool or ) reduces to a constructor. If you can prove true = false via some axiom, you might get a closed term of type Bool that's stuck. That's bad!

What cubical type theory does instead

Cubical TT gives the univalence axiom actual computational content. Instead of just asserting it, the type theory is built so that univalence is a provable theorem. This means the system stays canonical — every closed term computes to a value. This is also why it's called "cubical": the key idea is to add an interval type I where a variable i : I corresponds intuitively to a point in the real unit interval [0, 1].

A path between two terms a b : A is literally a function I → A that sends i0 to a and i1 to b. A 2-dimensional path (a homotopy between paths) is a function I → I → A. A 3-dimensional one is I → I → I → A. Hence: cubes!

-- A path is just a function from the interval! path-example : Path ℕ 0 0 path-example = λ i → 0 -- the constant path (refl) -- Function extensionality is now PROVABLE, not an axiom: funExt : {f g : A → B} → ((x : A) → f x ≡ g x) → f ≡ g funExt h = λ i x → h x i

Notice funExt: in Book HoTT you need to postulate it. In cubical TT it falls out directly! Function extensionality is directly provable.

— paths all the way down 🐱 | Cubical Agda contributor | she/her
#3   PathsAllTheWayDown

Great start from CubicalCatgirl! Let me add a bit more intuition for OP.

Think of it this way. In ordinary MLTT, equality is given by the identity type Id A a b, which is inductively generated just by refl : Id A a a. The elimination principle (J) is powerful, but opaque — you can't look inside a proof of equality and compute with it directly.

Cubical TT replaces this opacity with something concrete. The core idea of HoTT is a correspondence between paths (as in topology) and proof-relevant equalities — and in cubical TT this correspondence is taken very literally: a path in type A is represented as a function out of the interval, I → A. You can evaluate that function. Paths compute!

📖 Agda Cubical docs say:

"A path in a type A is represented like a function out of the interval, I → A."

This is the magic: because equality proofs are functions, you can do things to them. You can compose paths, reverse them (using the De Morgan negation ~ i on the interval), and crucially, you can transport values along them in a way that actually computes.

The De Morgan algebra on I

The interval I isn't just a boring interval. Its elements form a De Morgan algebra with min (∧), max (∨), and negation (~). This gives you "connections" — the ability to build higher-dimensional cubes out of lower-dimensional ones. It's what makes the whole thing tick.

-- Interval operations: -- i ∧ j (minimum / connection) -- i ∨ j (maximum / connection) -- ~ i (reversal: ~ i0 = i1, ~ i1 = i0) -- Path reversal is free! sym : {x y : A} → x ≡ y → y ≡ x sym p = λ i → p (~ i)

In Book HoTT you prove sym by J-induction. Here it's a one-liner that literally just flips the interval. 🤯

— it's paths all the way down | she/they | homotopy type theory appreciator
#4   CubeScared

Oh wow okay this is starting to click!! So the interval type is what makes everything work — paths are actual functions, not abstract tokens of equality that you can only eliminate via J.

But I still don't quite get how this gets you univalence as a theorem rather than an axiom. Like... the whole point of univalence is that equivalent types are equal, right? How does having an interval type magically prove that? There must be more going on?

Also — what are these "Glue types" I've seen mentioned? And what's the difference between CCHM and CHM? I've seen both and have no idea if they're different things or the same thing abbreviated differently. 😅

#5   CubicalCatgirl

Great questions! Let me address both.

Glue types and how univalence becomes provable

Having the interval alone isn't enough for univalence — you need a way to "glue together" different types along an equivalence. Enter Glue types. The rough idea: given a type A and a partial equivalence T ≃ A defined on some "face" of the cube, you can construct a new type that equals A on one side but looks like T on the other.

💜 Glue intuition:

Think of two puzzle pieces — types A and B connected by an equivalence f. Glue types let you build a path (a 1-cube) in the universe whose left face is A and whose right face is B. That path is the proof that A = B. Glue types let you turn equivalences between types into paths between types.

-- ua : the univalence function, using Glue ua : A ≃ B → A ≡ B ua {A = A} {B = B} e = λ i → Glue B (λ { (i = i0) → (A , e) ; (i = i1) → (B , idEquiv B) })

So univalence (ua) is literally a definition using Glue, not an axiom you postulate!

CCHM vs CHM — the acronym zoo 🦁

💜 The acronym breakdown:

CCHM = Cohen, Coquand, Huber, Mörtberg. The 2016/2018 paper "Cubical Type Theory: a constructive interpretation of the univalence axiom." This is the foundational paper and the system it defines. It uses a De Morgan cube category and Kan composition as a single primitive operation.

CHM = Coquand, Huber, Mörtberg. The follow-up paper "On Higher Inductive Types in Cubical Type Theory." This extends the system with a general schema for higher inductive types (HITs). Crucially, CHM decomposes Kan composition into two simpler operations: homogeneous composition (hcomp) and generalized transport (transp).

Cubical Agda implements a variation of CCHM where the Kan operations are decomposed as in CHM. That's why you see both acronyms in the Agda docs!

So when someone says "Cubical Agda uses CCHM," they mean the underlying theory. When they say "it follows CHM for HITs," they mean the specific decomposition that makes the HIT schema work.

— paths all the way down 🐱 | Cubical Agda contributor | she/her
#6   UnivalentUnicorn

Adding some context on why canonicity matters practically, because I think this point is undersold.

In Book HoTT with univalence as an axiom, you can write a proof that some function f : ℕ → ℕ satisfies some property — but if your proof uses the univalence axiom somewhere in the chain, the proof term is stuck. Your proof assistant can't reduce it. You can't extract computational content from it. It's a mathematical proof, but not a program.

Cubical TT addresses this by making univalence compute. Cubical type theory provides a novel representation of equality proofs that gives computational content to univalence, making it possible to constructively transport programs and properties between equivalent types.

A concrete example: In Cubical Agda, if you have Bool ≡ Bool via the negation equivalence (swap true and false), you can transport the proof true ≠ false along this path and it will actually compute to false ≠ true. In Book HoTT with an axiom, that transport is stuck.

-- This is a theorem in Cubical Agda, not an axiom: -- Bool has a non-trivial automorphism notEquiv : Bool ≃ Bool notEquiv = isoToEquiv (iso not not notnot notnot) -- We get a non-trivial path Bool ≡ Bool notPath : Bool ≡ Bool notPath = ua notEquiv -- And it COMPUTES: transport along notPath maps true ↦ false _ : transport notPath true ≡ false _ = refl -- yes, this checks by reduction!
⚠️ Important nuance:

There's a subtlety: the Martin-Löf identity type (with J computing on refl) and the cubical path type are not definitionally isomorphic — they are only propositionally equivalent. This means J's computation rule doesn't hold definitionally for path types. You can recover the identity type as a separate type, but most Cubical Agda code prefers path types precisely because they satisfy many useful definitional equalities.

— univalence is the only real equivalence | she/her | proud unicorn 🦄
#7   PathsAllTheWayDown

Let me make a direct comparison table since OP asked about Book HoTT vs Cubical. This is the thing that confused me for a long time too:

Feature Book HoTT (Coq/Agda + axioms) Cubical Agda
Univalence Axiom (doesn't compute) Theorem via Glue types ✓
Function extensionality Axiom (or derived) Built-in theorem ✓
Canonicity Fails ✗ Holds ✓
HITs Postulated User-definable with def. comp. ✓
Path type vs Id type Id type, J computes on refl Path type (I→A); Id available separately
J computation rule Holds definitionally ✓ Only propositionally for path types
sym (path reversal) Proven by J-induction λ i → p (~ i)

The tradeoff: cubical is computationally richer, but the path type doesn't have J computing definitionally, which can make some proofs that rely on pattern-matching on identity proofs slightly more awkward. In practice the Cubical Agda library provides both, and most people use path types.

There's also a HoTT-UF.agda compatibility layer in the agda/cubical library that provides the standard Book HoTT interface but implemented with cubical primitives under the hood — best of both worlds for migration!

— it's paths all the way down | she/they | homotopy type theory appreciator
#8   CubeScared

Okay I changed my avatar from scared cat to happy cat because I'm actually understanding this 😸

The table from PathsAllTheWayDown is really helpful. One more question: what's the actual relationship between CCHM cubical and Cartesian cubical type theory? I've also seen "RedTT" mentioned somewhere. Are there like... multiple competing cubical type theories?

And should a beginner just dive straight into Cubical Agda, or is there a better starting point?

#9   UnivalentUnicorn

Yes, there are several competing (and complementary) cubical type theories! The differences lie mostly in what cube category you use and what filling operations you have. Here's a quick tour:

💜 The cubical landscape:
  • CCHM (De Morgan cubical) — Cohen, Coquand, Huber, Mörtberg. Uses a rich cube category with reversals, connections, and diagonals (a free De Morgan algebra generated by an interval). This is what Cubical Agda implements. Strong: it validates univalence and supports a wide variety of HITs.
  • Cartesian Cubical TT — Angiuli, Favonia, Harper (and others). Uses a simpler Cartesian cube category (fewer maps). Computationally motivated, was implemented in RedTT/cooltt. Different tradeoffs in what composition operations are needed.
  • XTT — Sterling, Angiuli, Gratzer. A cubical type theory where UIP (uniqueness of identity proofs) is a theorem rather than an axiom — so it's a cubical set theory for Bishop sets (h-sets). Not for HoTT per se, but very elegant for setoid-level math.
  • Guarded Cubical TT — extends CCHM with guarded recursion for working with coinductive types.

Where to start? My recommendation:

  1. Install Agda + the agda/cubical library from GitHub
  2. Read the Cubical Agda docs — they're surprisingly gentle
  3. Try the lecture notes from Anders Mörtberg's cubicaltt hands-on introduction (HoTT blog, 2017)
  4. Start by proving things like funExt, sym, cong cubically — it'll click fast
  5. Then try the circle as a HIT and compute π₁(S¹) ≅ ℤ

The 1lab is also a fantastic modern cubical Agda library with great documentation — highly recommend poking around there.

— univalence is the only real equivalence | she/her | proud unicorn 🦄
#10   CubicalCatgirl

Perfect thread. Let me give a TL;DR for anyone finding this later:

📌 CUBICAL TYPE THEORY — TLDR FOR CATGIRLS AND OTHERS
  • Problem: HoTT Book takes univalence and HITs as axioms → canonicity breaks, nothing computes through them.
  • Solution: Cubical TT adds an interval type I with endpoints i0, i1. Paths = functions I → A. Everything is computational.
  • Interval structure: De Morgan algebra (in CCHM). Gives reversals (~i), connections (i∧j, i∨j), needed to build higher cubes.
  • Glue types: The magic ingredient that makes univalence provable (not axiomatic). Turn equivalences into paths in the universe.
  • CCHM: The main cubical TT (Cohen-Coquand-Huber-Mörtberg, 2018). Implements univalence + HITs constructively.
  • CHM: Extension adding a cleaner schema for HITs by decomposing Kan filling into hcomp + transp.
  • Cubical Agda: CCHM-flavour, with CHM-style decomposition. The main practical system today.
  • Book HoTT compat: agda/cubical has a HoTT-UF interface. You can import Book-HoTT style primitives that compute under the hood.

@CubeScared you're clearly already thinking about this the right way. Fear not the cubes — they are your friends! 🧊🐱

Welcome to the cubical side. We have refl on everything.

— paths all the way down 🐱 | Cubical Agda contributor | she/her
📝 Post Reply
Logged in as: CubeScared  |  Not you?
Rules: be kind, stay on-topic, no spoilers for Paper HoTT 😄