ConceptComplete

Recursion and Inductive Constructions

Recursion is the dual of induction: while induction proves properties of all natural numbers, recursion defines functions and sequences on natural numbers. Both stem from the well-founded structure of ω\omega.

DefinitionPrimitive Recursion

A function f:ωk+1ωf: \omega^{k+1} \to \omega is defined by primitive recursion from functions g:ωkωg: \omega^k \to \omega and h:ωk+2ωh: \omega^{k+2} \to \omega if:

f(x1,,xk,0)=g(x1,,xk)f(x1,,xk,n+1)=h(x1,,xk,n,f(x1,,xk,n))\begin{align*} f(x_1, \ldots, x_k, 0) &= g(x_1, \ldots, x_k) \\ f(x_1, \ldots, x_k, n+1) &= h(x_1, \ldots, x_k, n, f(x_1, \ldots, x_k, n)) \end{align*}

The value at n+1n+1 depends on the previous value at nn, building up the function recursively.

ExampleFactorial Function

The factorial function n!=123nn! = 1 \cdot 2 \cdot 3 \cdots n can be defined by primitive recursion:

0!=1(n+1)!=(n+1)n!\begin{align*} 0! &= 1 \\ (n+1)! &= (n+1) \cdot n! \end{align*}

Here g()=1g() = 1 (constant function) and h(n,y)=(n+1)yh(n, y) = (n+1) \cdot y. By the recursion theorem, this uniquely determines a function f:ωωf: \omega \to \omega with f(n)=n!f(n) = n!.

Computing: 1!=10!=11! = 1 \cdot 0! = 1, 2!=21!=22! = 2 \cdot 1! = 2, 3!=32!=63! = 3 \cdot 2! = 6, etc.

DefinitionCourse-of-Values Recursion

A more general form allows the value at n+1n+1 to depend on all previous values:

f(n+1)=h(n,f(0),f(1),,f(n))f(n+1) = h(n, f(0), f(1), \ldots, f(n))

This is equivalent to primitive recursion but sometimes more convenient. It corresponds to strong induction.

ExampleAckermann Function

The Ackermann function demonstrates that not all computable functions are primitive recursive:

A(0,n)=n+1A(m+1,0)=A(m,1)A(m+1,n+1)=A(m,A(m+1,n))\begin{align*} A(0, n) &= n + 1 \\ A(m+1, 0) &= A(m, 1) \\ A(m+1, n+1) &= A(m, A(m+1, n)) \end{align*}

This grows extremely rapidly: A(4,2)A(4, 2) has over 19,000 digits. The Ackermann function is computable (by double recursion) but not primitive recursive, showing that recursion can be more powerful than simple iteration.

TheoremUnique Readability

Every natural number nωn \in \omega has a unique representation. Specifically:

  1. Either n=0n = 0, or
  2. n=S(m)=m+1n = S(m) = m + 1 for a unique mωm \in \omega

This is immediate from the construction: n=m{m}n = m \cup \{m\}, and we can recover mm as the largest element of nn.

Remark

Unique readability is crucial for induction and recursion. It ensures that when we define a function by cases f(0)=af(0) = a and f(n+1)=h(n,f(n))f(n+1) = h(n, f(n)), these cases are mutually exclusive and exhaustive, so ff is well-defined.

DefinitionStructural Recursion

More abstractly, we can define functions by structural recursion on any well-founded structure. For natural numbers, this means:

Given aAa \in A and h:ω×AAh: \omega \times A \to A, there exists a unique f:ωAf: \omega \to A with:

f(n)={aif n=0h(m,f(m))if n=S(m)f(n) = \begin{cases} a & \text{if } n = 0 \\ h(m, f(m)) & \text{if } n = S(m) \end{cases}

This principle extends to trees, lists, and other inductive data structures.

ExampleBinary Representation

Every natural number has a unique binary representation. We can define a function bin:ω{0,1}\text{bin}: \omega \to \{0,1\}^* (finite binary strings) recursively:

bin(0)=0bin(2n)=bin(n)0bin(2n+1)=bin(n)1\begin{align*} \text{bin}(0) &= 0 \\ \text{bin}(2n) &= \text{bin}(n) \cdot 0 \\ \text{bin}(2n+1) &= \text{bin}(n) \cdot 1 \end{align*}

For instance: bin(5)=bin(22+1)=bin(2)1=(bin(1)0)1=((bin(0)1)0)1=101\text{bin}(5) = \text{bin}(2 \cdot 2 + 1) = \text{bin}(2) \cdot 1 = (\text{bin}(1) \cdot 0) \cdot 1 = ((\text{bin}(0) \cdot 1) \cdot 0) \cdot 1 = 101.

TheoremExistence of Arithmetic

Using primitive recursion, we can define addition, multiplication, and exponentiation on ω\omega, and prove all their standard properties by induction:

  1. Associativity: (m+n)+p=m+(n+p)(m + n) + p = m + (n + p)
  2. Commutativity: m+n=n+mm + n = n + m
  3. Distributivity: m(n+p)=mn+mpm \cdot (n + p) = m \cdot n + m \cdot p
  4. Identity: m+0=mm + 0 = m and m1=mm \cdot 1 = m
  5. No zero divisors: mn=0m=0n=0m \cdot n = 0 \Rightarrow m = 0 \lor n = 0

These are proved by induction on one variable while holding others fixed.

ExampleDivision with Remainder

The division algorithm can be proved by strong induction: for any m,nωm, n \in \omega with n>0n > 0, there exist unique q,rωq, r \in \omega with m=qn+rm = qn + r and r<nr < n.

Proof sketch: By strong induction on mm. If m<nm < n, take q=0,r=mq = 0, r = m. Otherwise mnm \geq n, so by induction hypothesis applied to mnm - n, we have mn=qn+rm - n = q'n + r' with r<nr' < n. Then m=(q+1)n+rm = (q'+1)n + r' with r<nr' < n.

DefinitionIntegers from Natural Numbers

We can construct the integers from ω\omega using equivalence classes. Define an equivalence relation on ω×ω\omega \times \omega by:

(a,b)(c,d)    a+d=b+c(a, b) \sim (c, d) \iff a + d = b + c

The equivalence class [(a,b)][(a, b)] represents the integer aba - b. The set Z=(ω×ω)/\mathbb{Z} = (\omega \times \omega) / \sim with operations:

[(a,b)]+[(c,d)]=[(a+c,b+d)][(a,b)][(c,d)]=[(ac+bd,ad+bc)]\begin{align*} [(a, b)] + [(c, d)] &= [(a+c, b+d)] \\ [(a, b)] \cdot [(c, d)] &= [(ac+bd, ad+bc)] \end{align*}

forms an integral domain extending ω\omega.

Remark

This construction shows how all of arithmetic—and indeed all of mathematics—can be built from the empty set through the axioms of ZFC. The natural numbers come from the axiom of infinity, and more complex number systems (integers, rationals, reals, complex numbers) are constructed via quotients, completions, and other set-theoretic operations.

Recursion and induction are two sides of the same coin, both exploiting the well-founded nature of ω\omega. Together, they provide the foundation for all discrete mathematics and computer science.