research36 min studyLesson 994 in Mathematics

Inductive types and elimination principles

Read constructors as a specification of recursion and induction, including indexed outputs and positivity restrictions.

On this page

What you’ll understand

  • Derive recursion and dependent induction from the natural-number constructors.
  • Check why indexed constructors constrain the types of their eliminators.
  • Compute and prove a recursively defined square function using its actual induction hypothesis.

An inductive definition specifies how objects may be built and how they may be analyzed. For natural numbers, zero and successor generate the cases of every recursion and every induction proof. For indexed types, the constructors also explain how an index changes during construction. These rules turn informal reasoning about all generated objects into a typed elimination principle. The challenge is to choose a motive strong enough for the desired conclusion while respecting the restrictions that keep the definition well founded.

Constructors determine a recursor and its computation

Natural numbers have a zero constructor and a successor constructor taking an existing natural number to a new one. To define a function out of this type into a fixed type C, give a value in C for zero and a step turning the predecessor and its already computed result into the next result. Applying the recursor to a constructor then computes by the corresponding equation. These equations specify the program rather than merely asserting that some function satisfies a recurrence.

The step does not receive results for arbitrary future arguments. It receives the result on the structurally smaller predecessor. A general fixed-point operator would remove this restriction and allow nonterminating definitions, so it is not interchangeable with the natural-number recursor. In an actual proof assistant, accepted surface recursion must be translated to justified recursors or another supported well-founded construction. A visually decreasing example is useful evidence, but the formal termination argument still belongs to the definition.

rec⁡(c,s,0)≡c,rec⁡(c,s,succ⁡(n))≡s(n,rec⁡(c,s,n)).\operatorname{rec}(c,s,0)\equiv c,\qquad \operatorname{rec}(c,s,\operatorname{succ}(n))\equiv s(n,\operatorname{rec}(c,s,n)).
The symbol ≡ records the declared judgmental computation rules for this recursor.↔ Scroll wide equations horizontally.

Induction allows the result type to depend on the input

For a family P over natural numbers, an induction proof returns evidence in P of the particular input. Its base case belongs to P of zero. Its successor case takes n and evidence of P of n, then returns evidence of P of its successor. This dependent motive is the difference between merely computing values in one codomain and proving a family of statements. Ordinary recursion is the special case where the motive does not depend on n.

An insufficient motive can make a true claim impossible to finish in the available induction step. For example, a theorem about a recursive accumulator often needs a generalized statement involving every starting accumulator. Strengthening the motive is then a mathematical change to the invariant, not an extra inference rule. Each recursive call supplies only the induction hypothesis guaranteed by the constructors, so the proof must explain how that particular hypothesis advances the conclusion.

p0:P(0),s:∏n:N(P(n)→P(succ⁡(n)))⟹ind⁡(p0,s):∏n:NP(n).p_0:P(0),\quad s:\prod_{n:\mathbb N}\bigl(P(n)\to P(\operatorname{succ}(n))\bigr)\quad\Longrightarrow\quad \operatorname{ind}(p_0,s):\prod_{n:\mathbb N}P(n).
A dependent eliminator constructs an entire family of proofs, with its own base and successor computation rules.↔ Scroll wide equations horizontally.

Indices and positivity are part of the specification

A vector type indexed by length has an empty constructor at length zero and a cons constructor that raises the length by one. An operation taking the head of a vector should therefore require successor length: the constructors give no empty case at that index. Erasing the index and promising informally that the input is nonempty loses a typing guarantee. Dependent elimination analyzes both the object and the constraints that its constructor places on the index.

Not every syntactic recursive declaration is a legitimate inductive type. Standard intensional type theories restrict recursive occurrences, typically by strict positivity, so that the advertised eliminators preserve the intended logical behavior. A proposed constructor accepting a function from the new type into an unrelated type has a negative occurrence and cannot simply be admitted under those rules. Higher inductive definitions add specified path constructors and require additional elimination and computation rules; they are not already consequences of ordinary point constructors alone.

nil⁡:Vec⁡(A,0),cons⁡:A→Vec⁡(A,n)→Vec⁡(A,succ⁡(n)).\operatorname{nil}:\operatorname{Vec}(A,0),\qquad \operatorname{cons}:A\to\operatorname{Vec}(A,n)\to\operatorname{Vec}(A,\operatorname{succ}(n)).
The result index tells an eliminator which constructors can occur; it is not a runtime guess about list length.↔ Scroll wide equations horizontally.

A recurrence computes squares and an induction explains why

Define F at zero to be zero and define F at successor n to be F(n)+2n+1. Compute F(4), then prove that F(n) equals the square of n for every natural n.

  1. The recurrence gives successive values zero, one, four, nine, and sixteen. At each successor, add the next odd number: one, three, five, then seven. Thus F(4) computes to sixteen.

  2. Choose the induction motive asserting F(n)=n². At zero, both sides compute to zero, so reflexivity supplies the base equality. The statement is about all n, not only the five evaluated examples.

  3. In the successor step, assume F(n)=n². Substitute this equality into the defining recurrence to obtain n²+2n+1, then use the natural-number arithmetic identity for the square of a successor. This constructs the required equality at successor n from exactly the supplied induction hypothesis.

F(n+1)=F(n)+2n+1=n2+2n+1=(n+1)2.F(n+1)=F(n)+2n+1=n^2+2n+1=(n+1)^2.
The first equality unfolds the definition; the second uses the induction hypothesis; the last is a separately justified arithmetic identity.↔ Scroll wide equations horizontally.
The result

The evaluated result is sixteen, and induction proves the recurrence computes squares for every natural input.

Explore the model

Interactive lab

Interactive lab · function

Compare the computed value with a quadratic model

Pause and Reset, then set coefficient a to 1 and position x to 2. Predict value 4, matching F(2) from the recurrence. For a fresh comparison Reset and set a to 1 and x to 1: value is 1. The control cannot reach x=4, so F(4)=16 is computed on paper rather than requested from this instrument. The quadratic plot verifies these two numerical comparisons but does not execute recursion or establish induction. Edits retain time; Reset and both controls are required for each comparison.

Compare the computed value with a quadratic modelThis lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Current readings: y at chosen x: 0.608; Tangent slope · 2ax: 1.35; Signed area · ax³/3: 0.182. All parameters are adjustable with the labeled controls below.−2.4−1.201.22.4−9−4.504.59xy(x, ax²)
y = ax²TangentSigned integral
y at chosen x
0.608
Tangent slope · 2ax
1.35
Signed area · ax³/3
0.182
t = 0 s

This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forMatching finite evaluations supports a calculation, while the induction motive proves the statement for every generated input.

Check your understanding

What must the successor case of dependent natural-number induction supply?

Try it yourself

Compute F(5) from the recurrence. Then explain why a head operation has a direct constructor-based definition on Vec(A,succ(n)) but cannot return an A from Vec(A,0) for arbitrary A without additional input.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Continue from F(4)=16 and inspect the indices of nil and cons.

Compare with the solution

The next odd increment is nine, so F(5)=25. For successor-length vectors, dependent elimination reduces a head operation to the cons case and returns the stored first element. A zero-length vector can be nil, which contains no element of A. If a head function at length zero existed for every A, choose A to be the empty type and apply it to nil; the result would inhabit the empty type. The missing zero case is therefore a genuine typing obstruction.

Take it with you

  • Constructors determine recursion, induction, and their computation rules.
  • A dependent motive states the exact invariant advanced by the induction hypothesis.
  • Indexed constructors and positivity restrictions are logical parts of an inductive declaration.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.