The Rules of the Game

Types, constructors, and propositions-as-types: proving a theorem is the same as building an element

The Rules of the Game

Set theory is a pile of axioms: assertions, dropped from above, about a single membership relation. Type theory is not like that. It is a game — the positions are judgments like “a is an element of the type A”, and the moves are rules for getting new judgments from old ones. There are no axioms at all in the basic system. Everything you can assert, you can assert because you built it, and everything you build computes.

Remarkably few rules are needed, and they all follow one rhythm. Every type is introduced by the same five-part pattern; functions are primitive machines rather than sets of pairs; and — the payoff of this lesson — logic does not have to be added on top. A proposition simply is a type, and proving it simply is constructing one of its elements. This page is the minimum type theory the rest of the module stands on.

The Five-Part Pattern

Every type in the theory arrives the same way. Formation: how to name the type. Constructors: how to build its elements — and, crucially, these are the only ways elements arise. Eliminator: how to use an arbitrary element, by explaining what to do with each constructor. Computation rule: when the eliminator meets a constructor, it actually computes. And sometimes a uniqueness principle, saying every element might as well have come from a constructor.

That is the whole game. Pairs, numbers, functions, and eventually circles and spheres are all instances of one template. Functions themselves are primitive: a function is a machine λx. Φ, and applying it to an argument substitutes and simplifies — the rule called β-reduction. No graphs of ordered pairs anywhere.

Interactive: The Recursion Machine

The computation rules are not metaphors — they run. Step the ℕ-recursor gear by gear and watch double(2) unfold into succ(succ(succ(succ(0)))), watch if-then-else turn out to be the Bool eliminator, and watch what goes wrong with an equation the recursor cannot produce.

Definition
double(0)       :≡ 0
double(succ(n)) :≡ succ(succ(double(n)))
double(succ(succ(0)))
highlighted: the redex — the part a computation rule can rewrite
step 0 / 3

Two Kinds of Equal

The machine above shows the first kind: judgmental equality, written ≡. It holds by definition — double(2) ≡ 4 because the computation rules grind one expression into the other, and no insight, argument, or citation is involved. The system checks it mechanically, the way a calculator checks nothing.

The second kind is propositional equality: a = b is a type, and to assert it you must construct an element of that type — a proof. The statement n + 1 = 1 + n is the classic border case. It is true for every n, but the recursor for addition peels succ off only its first argument, so the two sides do not compute to a common form for a variable n. You need induction: an actual proof object, built by hand.

Hold on to this distinction — it is the hinge of the whole subject. Judgmental equality is invisible bookkeeping. Propositional equality is a type, and things of the same type have structure: elements, maps, and — as the rest of this module shows — the geometry of paths.

Logic for Free

Here is the move that makes type theory a foundation rather than a programming curiosity. Read each proposition as a type — the type of its evidence — and every logical connective turns out to be a type former you already have:

PropositionType
True𝟙 (the unit type)
False𝟘 (the empty type)
A and BA × B
A or BA + B
A implies BA → B
not AA → 𝟘
for all x, P(x)Π(x : A) P(x)
there exists x with P(x)Σ(x : A) P(x)

Proving a theorem now means building an element of the corresponding type — mathematics and programming become the same activity. But the logic you get is constructive, and that changes what “or” means. An element of A + B is inl(a) or inr(b): it carries the information of which side holds. You cannot prove a disjunction by showing that both sides failing would be absurd; you must deliver a side. That is why one direction of De Morgan’s law goes through below and the other jams.

Interactive: Proof by Hole-Filling

A De Morgan law, proved the type-theoretic way. Click through the English proof on the left and watch each sentence fill a hole □ in the growing term on the right — assumptions become λs, case analysis forks a hole, applications close them. Then switch tabs and try the converse, which every classical logician believes, and find the hole that nothing can fill.

Goal
(¬A × ¬B) → ¬(A + B)

If A is refutable and B is refutable, then “A or B” is refutable.

The proof in English — click each sentence
The proof term — holes are □
One hole, whose type is the whole theorem. Filling it completely is proving the theorem.

Interactive: Families, Fibers, and Sections

The dictionary’s last two rows — Π and Σ — deserve a picture, because it is the picture the whole module runs on. A type family B : A → 𝒰 hangs one type over each point of A, like fibers over a base. Here the family is Fin(n + 1), the finite types. Toggle the three views, and in the sections view drag to thread your own dependent function through the fibers.

base: n = 0 … 50Fin(1)1Fin(2)2Fin(3)3Fin(4)4Fin(5)5Fin(6)
Fin : ℕ → 𝒰
A type family: one type sitting over each element of the base. Over n lives Fin(n + 1), the finite type with exactly n + 1 elements — so the fibers grow as you move right. A family of types indexed by a type is the type-theoretic picture that later becomes “fibration”.

Key Takeaways

  • Type theory is rules, not axioms: positions are judgments, moves are inference rules, and nothing is asserted that was not constructed.
  • Every type follows one five-part pattern: formation, constructors, eliminator, computation rule, and (sometimes) uniqueness — from A × B to ℕ to the spheres built later in this module.
  • Two equalities: judgmental equality (double(2) ≡ 4) holds by computation alone; propositional equality (n + 1 = 1 + n) is a type whose elements are proofs, and it can take real work to inhabit.
  • Propositions are types, proofs are elements: and = ×, or = +, implies = →, not A = A → 𝟘, for-all = Π, exists = Σ.
  • The logic is constructive: a proof of A + B must say which side —so ¬A × ¬B → ¬(A + B) is a two-line term, while the converse has an unfillable hole.
  • Type families are fibers over a base: a dependent function Π(x : A) B(x) is a section picking one point per fiber, Σ(x : A) B(x) is the total space, and the type-theoretic axiom of choice is simply provable. This picture becomes “families are fibrations” in the lessons on transport.