Recursive definitions and structural induction
Define finite objects through constructors and prove a property by covering every way those objects can be built.
On this page
The question for today
What you’ll understand
- Separate base objects from recursive constructors.
- Prove a property of every finite expression by structural induction.
- Track why a recursive definition terminates and is unambiguous.
Induction need not proceed through the consecutive integers printed on a page. Mathematical objects can be built from smaller objects: lists from shorter lists, expressions from subexpressions, and trees from subtrees. A recursive definition describes these building rules. Structural induction then follows the same rules to prove a property of every finite object they generate. The definition tells you which proof cases are required rather than leaving you to guess a suitable formula in n.
A recursive definition specifies a generated collection
Consider fully parenthesized expressions built from one symbol x using a binary plus constructor. First declare x an expression. Next, whenever A and B are expressions, declare the parenthesized object (A + B) an expression. Finally, the collection contains only objects obtainable by finitely many uses of these rules. That last clause excludes unexplained objects and infinitely descending constructions. The syntax concerns written trees; it does not identify two expressions merely because their numerical evaluations might agree.
A recursive function on these expressions needs a value for the base symbol and a rule that computes the value at a compound expression from values at its immediate subexpressions. For example, leaf count assigns one to x and adds the counts of the two children. This is well founded because each child is a strictly smaller finite syntax tree. If the notation allowed more than one parse, the proposed definition would require an additional argument that the result is independent of the parse.
Prove one case for every constructor
Structural induction proves a claim first for each base object and then for each constructor under the assumption that it already holds for the constructor’s immediate inputs. For our grammar there is one base case and one binary case. The two child expressions can have very different sizes, so ordinary predecessor induction would obscure the construction. The structural hypotheses are exactly the claims about A and B needed to handle (A + B).
To prove that a full binary expression has one more leaf than plus symbol, define another recursive function counting plus symbols. The base has one leaf and zero plus symbols. In the compound case, leaf counts add, while plus counts add and gain one for the new root. Substituting the two child hypotheses yields the desired difference. This argument covers every finite shape produced by the grammar, including highly unbalanced trees, without assuming that both children have equal depth.
The grammar limits the theorem
Changing the constructors can change the invariant. If a unary negation constructor is added, counting every operation as an internal node no longer makes leaves equal internal nodes plus one: the expression −x already violates that revised claim. A corrected invariant could count only binary constructors, or use a general relation between nodes and outgoing edges. Always reread the grammar after extending a language; a proof that omits the new constructor no longer establishes a universal statement about the expanded collection.
Distinguish structural induction from evaluating a few example trees and from induction on an arbitrary integer label attached to them. A size-based proof can work, but it must show that every recursive input has smaller size and that every object of the next size is covered. Structural induction makes those obligations explicit through the construction rules. It also explains reliable recursive programs: each clause should match a constructor, and each recursive call should be on an input justified by that constructor.
Work it through
Count leaves in a concrete expression tree
Evaluate L and I on the expression ((x + x) + (x + (x + x))) and connect the calculation to the general identity.
The left subtree (x + x) has two leaves and one plus constructor. The innermost right pair (x + x) has the same counts by the base and binary recursive rules.
The right subtree (x + (x + x)) therefore has three leaves and two plus constructors: add one leaf to the inner pair, and add the new root constructor to its plus count.
At the outer root, add the child leaf counts to get five. Add their plus counts and one root to get four. Thus L = I + 1 for this example, while the structural induction proves the relationship for all generated expressions.
This expression has five leaves and four binary plus constructors, regardless of the numerical value eventually assigned to x.
The living notebook
Explore the model
Interactive lab · spectral
Inspect a recursively defined finite sum
Fix decay p and increase mode count N. The plotted sine sum gains exactly its new Nth term. Predict how the next sum is built from the previous one before moving the control. This is a linear recursion on finite sums, illustrating the definition-to-proof connection; it is not a binary-tree renderer or a proof about infinite sums.
- Sum at x = π/2
- 0.867
- Smallest wavelength
- 2π / 5
- Highest-mode coefficient
- 0.2
A finite sum of sin(nx − t)/nᵖ. Playback changes t; increasing the cutoff includes finer spatial scales. This is not a proof about a continuum limit or renormalization. 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 forProof cases should mirror the constructors that define the objects.
Pause & reason
Check your understanding
Your turn
Try it yourself
Finite lists use the constructors empty and prepend(a, list). Define length recursively and prove that length(append(A,B)) = length(A) + length(B), by induction on A.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use append(empty,B) = B and append(prepend(a,A),B) = prepend(a,append(A,B)).
Compare with the solution
Define length(empty) = 0 and length(prepend(a,A)) = 1 + length(A). At A empty, both sides of the desired equality are length(B). For a prepended list, assume the equality for its tail A. The left side becomes 1 + length(append(A,B)), then 1 + length(A) + length(B) by the hypothesis, which equals length(prepend(a,A)) + length(B). These are all constructors, so structural induction proves the identity for every finite A and B.
Keep the idea
Take it with you
- A recursive definition needs base rules, constructor rules, and a finite-generation scope.
- Structural induction follows every constructor using claims about its immediate inputs.
- A theorem’s invariant may need revision when the grammar changes.
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.