← back to index

Topoi

Bartosz Milewski · 2017 · Category Theory for Programmers, Ch. 23

Prereqs: 🍞 Ch11 (Limits and Colimits), 🍞 Ch9 (Function Types). 10 min.

A topos is a category that behaves like a universe of sets. It has all finite limits, exponentials (function objects), and a subobject classifier Ω that generalizes true/false. In Set, Ω = {true, false} and subsets correspond to characteristic functions. In a presheaf topos, Ω can have more truth values: the internal logic is intuitionistic, not classical.

A 1 B Ω m (mono) true ! χ A = pullback of true along χ χ(x) = true if x ∈ A, false otherwise

Subobjects: the categorical notion of "subset"

In set theory, a subset is defined by membership. In category theory, a subobject is an equivalence class of monomorphisms (injective arrows). A monomorphism m : a → b is an arrow that can be cancelled on the left: if m · g = m · g' then g = g'. Two monos into the same object are equivalent when they factor through each other via an isomorphism.

Scheme

The subobject classifier Ω

A subobject classifier is an object Ω with a distinguished arrow true : 1 → Ω such that every monomorphism f : a ↪ b is the pullback of true along a unique arrow χ : b → Ω. The arrow χ is the characteristic function of the subobject. In Set, Ω = {true, false}, and χ is the indicator function: χ(x) = true if x is in the subset, false otherwise.

Scheme

The three axioms of a topos

A category is a topos when it satisfies three conditions: (1) it is cartesian closed (has a terminal object, all binary products, and exponentials), (2) it has all finite limits (equalizers + products give you pullbacks, and everything else), and (3) it has a subobject classifier. Set is the prototypical topos. But there are others where Ω has more than two elements.

Scheme

Multi-valued truth in a presheaf topos

In Set, Ω has two elements. But in a presheaf topos (functors from a small category Cop to Set), the subobject classifier can have more truth values. A "truth value" at stage c is a sieve on c: a downward-closed set of arrows into c. The maximal sieve (all arrows) is "totally true." The empty sieve is "false." Everything in between is a degree of partial truth. This is why the internal logic of a topos is intuitionistic: the law of excluded middle can fail.

Scheme

The sieve calculation is correct for this two-object category. General presheaf topoi require computing sieves over arbitrary diagrams.

Intuitionistic logic: no excluded middle

The internal logic of a topos is intuitionistic. All the standard logical connectives exist: conjunction (∧) via products, disjunction (∨) via coproducts, implication (⇒) via exponentials. But the law of excluded middle (p ∨ ¬p = true) does not hold in general. A proposition is "true" only when you can construct a proof. Double negation does not collapse: ¬¬p does not imply p. This makes topoi a natural home for constructive mathematics and computation.

Scheme

Notation reference

Blog / Math Scheme Meaning
ΩomegaSubobject classifier
true : 1 → Ω(true-arrow _)Distinguished arrow picking out "true"
χ : b → Ω(char-fn subset)Characteristic function of a subobject
Sub(b) ≅ C(b, Ω)(pullback-of-true chi B)Ω represents the subobject functor
Sieve on c(max-sieve . (id-b f))Downward-closed set of arrows into c
¬p = p ⇒ ⊥(h-not a)Negation in Heyting algebra
p ∨ ¬p ≠ ⊤(h-or 1 (h-not 1))Excluded middle fails in intuitionistic logic
Neighbors

Milewski chapters

Foundations (Wikipedia)

Translation notes

The blog post is conceptual rather than code-heavy: no Haskell implementations appear. This page translates the definitions into executable Scheme and Python. The subobject classifier in Set is straightforward (characteristic functions are just indicator functions). The presheaf example uses the simplest non-trivial category (two objects, one non-identity arrow) to show that Ω can have three truth values. In general, Ω(c) is the set of all sieves on c, which can be large. The Heyting algebra section demonstrates the linear order (false < partial < true); in richer presheaf categories, the truth values form a more complex partial order. The blog post also discusses the connection between topoi and alternative foundations of mathematics: topos theory provides a framework where "true" means "provable," aligning with constructive mathematics and type theory.

Ready for the real thing? Read the blog post. Start with the subobject classifier definition, then trace how sieves generalize truth values.