A recursive definition has two parts: a basis step (starting values or elements) and a recursive step (how to build new ones from old ones). Structural induction is how you prove things about objects defined this way.
Recursively defined functions
- Basis step: give (or the first few values).
- Recursive step: give a rule for in terms of earlier values.
Basis: . Recursive rule: for .
Ask: how do I get from ?
| Explicit | Recursive step | Basis |
|---|---|---|
| (arithmetic) | ||
| (geometric) | ||
Always state the basis. A recursive rule without a starting value defines nothing.
Make a table and fill it in order: Each value only uses ones you have already written down. With two previous terms (like Fibonacci) you need two starting values.
, , and for .
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 |
Recursively defined sets
- Basis step: list the initial elements.
- Recursive step: rules that build new elements from elements already in the set.
- Exclusion rule (implicit): nothing else is in the set.
Generate: , then , then , … so , the positive multiples of 5. (Proving this takes two inclusions. See Structural induction below.)
Find the period of the pattern. The basis lists one "block" of elements; the recursive step adds the period.
| Set | Basis | Recursive step |
|---|---|---|
| Positive multiples of 5 | ||
| Odd positive integers | ||
| Positive integers not divisible by 7 | ||
| All even integers (incl. negatives) | ||
| Positive powers of 3 | ||
If the set includes negative numbers, you need a rule that goes down too.
Strings
- is the empty string (no characters).
- (the Kleene closure) is the set of all strings over , defined recursively: ; if and then .
- Concatenation is " followed by ." It is not commutative: but . For every string, .
Convention: are symbols; are strings.
| Function | Basis | Recursive step (, ) |
|---|---|---|
| length | ||
| number of 1s, bit strings | , for | |
| number of 0s, bit strings | ||
| reversal | ||
| power |
| Set | Basis | Recursive step |
|---|---|---|
| Palindromes (bit strings) | ||
Well-formed formulae
Formulas are defined recursively too: the basis gives the atoms, the recursive step gives the operators with parentheses.
- Propositional logic: Basis: , , and every propositional variable. Recursive: if are wffs, so are , , , , .
- Arithmetic: Basis: every numeral and variable. Recursive: , , , , .
- Sets: Basis: every set or set variable. Recursive: , , , .
Full binary trees
- Basis: a single vertex is a full binary tree.
- Recursive: if are disjoint full binary trees, then (a new root with left subtree and right subtree ) is a full binary tree.
| Basis (single root) | Recursive () | |
|---|---|---|
| height | ||
| vertices | ||
| leaves | ||
| internal vertices |
Facts (all proved by structural induction): , , .
Structural induction
To prove a property holds for every element of a recursively defined set:
- Basis step: show it holds for every element given in the basis.
- Recursive step: assume it holds for the elements used in a recursive rule (this is the IH). Show it holds for the new element built from them. Do this for every recursive rule.
Integers / sets: Basis: check the listed elements. Step: "Assume (and ) have the property; show (or , , …) does too."
Strings: Basis: prove . Step: assume , prove for every .
Full binary trees: Basis: prove it for the single-vertex tree. Step: assume it for and , prove it for using the recursive formulas for , , , .
Proving a recursive set equals a described set
To show , prove both inclusions.
Proof
Part 1: (ordinary induction on ). Let : .
- Basis: by the basis step.
- Step: if , then since too, the recursive step gives .
Part 2: (structural induction).
- Basis: .
- Step: assume are in , so and . Then and , so .
By Parts 1 and 2, . ∎
Proof
Fix and use structural induction on . Let : .
Basis (): .
Recursive step. Assume . For any :
∎
: ; if then and . Show every satisfies .
Proof
Basis: .
Recursive step: Assume . Then and . Both new elements have the property. ∎
Showing the converse fails: , but , is not for an integer , and is not a perfect square. So .
- Only checking one of the recursive rules. Every rule needs its own case.
- In the basis for strings, the case is , the empty string.
- Using structural induction for the "" direction. That direction is usually ordinary induction (show each element of can be built).
Ackermann's function (this book's version)
Useful facts: for , for , and (a tower of twos).
Always expand the inner argument first. Example: .
- "Clean closure" should be Kleene closure ().
- The identity for the empty string is . Your notes wrote .
- In the proof of , the basis case is , not .
Exam checklist
- Compute values of a recursively defined function (including two-term recurrences and Ackermann).
- Convert an explicit formula or a described set into a recursive definition.
- Describe the set produced by a recursive definition.
- Give recursive definitions on strings (length, ones, reversal, powers, palindromes).
- Write a structural induction proof (sets, strings, full binary trees), handling every rule.
- Prove via two inclusions.