Joined: 2023-04
Location: ∞-Groupoid
Fav type: S¹
Okay so you've learned about ordinary inductive types — ℕ, lists, trees, etc. You know that they're defined by point constructors: zero : ℕ, suc : ℕ → ℕ, and so on. Every element of the type is built from these constructors.
But here's the thing: in Homotopy Type Theory (HoTT), types are spaces and equality proofs are paths. So what if we want to define a type that has non-trivial path structure baked in from the start? Like… what if we want a type that is a circle? A torus? This is exactly where Higher Inductive Types (HITs) come in!
HITs are inductive types that can have not just point constructors, but also path constructors (and higher path constructors). A path constructor introduces a proof of equality between elements of the type being defined.
Key insight: ordinary inductive types tell you what the points of a type are; HITs additionally tell you what the paths (and higher paths) are.
The canonical first example is the circle. The circle S¹ is inductively generated by a single point and a single non-trivial loop. In Cubical Agda:
The loop constructor says "there is a path from base to base". This is a non-trivial path — it's not refl! This single path constructor is enough to give S¹ the homotopy type of the topological circle.
The elimination/recursion principle is also richer: to define a function out of S¹, you must provide not only a point in the target, but also a loop at that point. A map f : S¹ → X is specified by giving a point and a loop in X — the image of the generators.
Let's go further. The torus is generated by one point, two loops, and a 2-path (a path-between-paths) witnessing that the two loops commute. In Cubical Agda it looks like:
Functions defined by pattern-matching on HITs compute definitionally, for all constructors. This means we get actual computational content, not just propositional equalities!
Nyaa~ That last line is wild. The torus is (propositionally equal to) the product of two circles. This is an elementary result in topology that has a surprisingly non-trivial proof in Book HoTT due to lack of definitional computation for higher constructors, but in Cubical Agda with proper HITs it's almost trivial!
Another key example: suspensions. Given a type A, the suspension Σ A has two poles and a meridian path for each point of A:
The suspension operation builds higher spheres from lower ones. Susp Bool ≃ S¹, Susp S¹ ≃ S², and so on. This is the key to doing synthetic homotopy theory in type theory!
HITs aren't just for topology nerds. They're also essential for logic! Truncations can be constructed using higher inductive types and are quite important to doing homotopy theory in type theory.
The propositional truncation ‖ A ‖₋₁ (aka ∥ A ∥) squashes all paths together so the result is a mere proposition:
The (-1)-truncation is known as the propositional truncation: given a type A it returns a proposition ∥ A ∥ which is true if and only if A is inhabited. The path constructor squash adds paths between all pairs of elements — collapsing the type into a proof-irrelevant proposition.
More generally, the n-truncation ‖ A ‖ₙ equates all morphisms of level higher than n in A. For example:
- (-2)-truncation: contractibility (everything is trivial)
- (-1)-truncation: mere proposition (propositional truncation)
- 0-truncation: h-set (set-truncation — the set of connected components)
- 1-truncation: h-groupoid (groupoid-truncation)
Perhaps the most general construction: pushouts. Given types A, B, C and maps f : C → A, g : C → B, the pushout glues A and B together along C:
HITs generalise quotient types, and allow us to define types with non-trivial higher equality types, such as spheres, suspensions and the torus. But they also construct more mundane things like the Cauchy reals, free algebras, and quotient types!
Short answer: because classical set-theoretic foundations can't directly express homotopy-invariant constructions. In set theory, a "quotient" is always a quotient by a set-level equivalence relation. HITs let us quotient by a higher structure.
Also: without HITs, we can't even define the fundamental group of the circle internally in type theory! We need S¹ to even state what π₁(S¹) = ℤ means.
Next to univalence, HITs are the most important new aspect of homotopy type theory, allowing us to construct higher-dimensional "spaces" such as spheres and tori; perform homotopical constructions such as suspensions, truncations, localizations, and homotopy colimits; and generate free algebraic structures of all sorts.
I'll stop here for now — this post is already getting long nya~ But please ask questions! I'm especially happy to go deeper on any specific HIT. Next post I'll cover the induction principle in detail — i.e., how to actually prove things about HITs using dependent elimination. 🐾