Notes from my career hiatus.

Limits of Logic #4: Recursion Theorem

Definition

Let F be a set of operations on a set A.

That is to say, the Frecursive set is the smallest Fclosed set.


This definition formalizes recursive definitions which are "a way of defining an infinite set or relation, or a function with an infinite domain."

An example of a recursive definition of a set is the set of even numbers:

Here, we have recursively defined the property of "evenness" E. Ultimately, a property really just is a set of all and only those elements which have that property. So the property E really is the set of all even numbers.

In putting our recurvise definition of E in context with the formal definition of Frecursiveness, we see that F here contains two functions f0 and fn:

  1. A zero place function that outputs f0=0.
  2. A one place function fn:nn+2.

What does an Fclosed set look like? The even numbers E are not the only Fclosed set. Note how the set of all natural numbers is also Fclosed; 0 and nn+2.

Along with the closure property (that E is Fclosed), E also has the inductive property. Intuitively, the inductive proeprty tells us that if for any X:

Then really, alll even numbers are in X.

In other words, if any X is Fclosed, then EX. Note how X can represent any property (e.g. "nice") and since we know that X is Fclosed, we can prove by induction that every even number is "nice".

Now see that E is the smallest Fclosed set -- which we define as being Frecursive. Intuitively, f0 tells us that 0 is necessarily in an Fclosed set, and fn takes 0 to 2, which takes us to 4, ... and eventually all and only even numbers.


Exercise 2.3.2

For any set of operations F on a set A, there is exactly one Frecursive set.

Proof:

Let X,YA be arbitrary Frecursive sets.

Both X and Y are Fclosed. But then, by definition, X is Finductive which means that XY. Similarly, we have that YX. Therefore, X=Y i.e. there is exactly one Frecursive set.


Definition

The relation m is less than or equal to n is recursively defined as follows:

Note that this definition of a relation defines a set of ordered pairs (m,n).

In the context of the formal definition recursive definitions, here F contains a one place function f1:× that takes n(n,n), and a two place function f2:×× that takes (m,n)(m,suc(n)). Therefore, the relation is the Frecursive set on these operations.


Example 2.2.6

Prove that for any numbers m and n such that mn, either m=n or msuc(n).

Proof:

Call (m,n) nice iff either m=n or msuc(n).

We are trying to prove that for every (m,n) such that holds, (m,n) is nice.

We shall prove this by induction on the relation.

Base Case nn.

By the first rule of the recursive definition, (n,n) is a -pair. Clearly, (n,n) is nice since n=n.

Inductive Case mnmsuc(n).

By the second rule of our recursive definition of , we have that if (m,n) is a -pair, then so is (m,suc(n)).

So, we'll assume that (m,n) is nice and show that it follows that (m,suc(n)) is also nice.

So, assume that (m,n) is nice, that is, m=nsuc(m)n.

Case m=n:

m=nsuc(m)=suc(n). Therefore, suc(m)suc(n) based on the first rule of the definition, and so, (m,suc(n)) is nice.

Case suc(m)n:

suc(m)nsuc(m)suc(n) based on the second rule of the definition, and so, (m,suc(n)) is nice.

In either case, (m,suc(n)) is nice.

Hence, we have proved that for any numbers m and n such that mn, either m=n or msuc(n).

Exercise 2.2.7

Prove by induction that for all numbers m,n,k if mn and nk then mk.

Proof:

Let m be any number and (n,k) be a -pair.

We want to show by induction on the relation that for any -pair (n,k), we have mnmk.

Base Case -pair (n,n)

By the first rule of the recursive definition, (n,n) is a -pair. Clearly, mnmn. The base case is satisfied.

Inductive case nknsuc(k)

By the second rule of our recursive definition of , we have that if (n,k) is a -pair, then so is (n,suc(k)).

So, we'll assume that mnmk holds, and show that it follows that mnmsuc(k).

So, let mn. But then it follows from our assumption that mk and by the the second rule of the recursive definition of , we have that msuc(k).

Therefore, mnmsuc(k).

2.3.4 The Recursion Theorem

Let A be a set. Let z be an element of A, and let s:AA be a function. Then there is a unique function f:A with these two properties:

Call these Recursive Properties.

We prove this theorem in parts. Particularly we prove that following relation "selects" is functional:

For a number n and an element aA we define the relation n selects a recusrively as follows:

We want to show that each number selects exactly value. Once we have done this, we will check the function for Recursive properties.

2.3.5 Exercise

Prove each of the following by induction on the definition of selects:

  1. If 0 selects a then a=z.
  2. If suc(n) selects a then there is some bA such that n selects b and s(b)=a.

Proof of 1:

By induction on the selects relation, we want to show that for every selects-pair (n,a), it holds that n=0a=z.

Base case: (0,z) is a selects-pair

Here, (n,a)=(0,z)n=0a=z. Therefore, it holds that If 0 selects a then a=z.

Inductive case: n selects asuc(n) selects s(a).

Here, we assume that for (n,a) it holds that n=0a=z.

We now show that it follows that for (suc(n),s(a)), it holds that suc(n)=0s(a)=z.

Note how suc(n)=0 is always false. Therefore, suc(n)=0s(a)=z trivially holds.

Therefore, we have shown by induction on the selects relation that if 0 selects a, then a=z.

Proof of 2:

We want to show that for every selects pair (p,a), it holds that p=suc(n)s(b)=a(n,b)selects.

Base case: (0,z) is a selects-pair

Here, (p,a)=(0,z)p=0. Note how suc(n)=0 is always false.

Therefore, p=suc(n)s(b)=a(n,b)selects holds trivially.

Inductive case: p selects asuc(p) selects s(a).

We assume that for (p,a), it holds that p=suc(n)s(b)=a(n,b)selects.

We show that it follows for (suc(p),s(a)) that p=suc(n)s(b)=a(n,b)selects.

Note that clearly suc(p) is a successor of some n, particularly it is the successor of p, and a is such that s(a)=s(a)(p,a)selects.

Therefore, (suc(p),s(a)) that p=suc(n)s(b)=a(n,b)selects holds trivially.

We have shown by induction on the selects relation that If suc(n) selects a then there is some bA such that n selects b and s(b)=a.

2.3.6 Exercise

Prove the following:

  1. For each number n there is at least one aA such that n selects a.
  2. For each number n there is at most one aA such that n selects a.

Proof for 1:

We prove by induction on the natural numbers that For each number n there is at least one aA such that n selects a.

Base case: n=0

By definition of the selects relation, we have that n=0 selects zA. Therefore, the base case is satisfied.

Inductive case: Assume there is some aA such that n selects a.

We show that there is some bA such that suc(n) selects b. Note by definition of the selects relation, suc(n) selects b=s(a)A. Therefore the inductive case is satisfied.

We have shown by induction that for each number n there is at least one aA such that n selects a.

Proof for 2:

We prove by induction on the natural numbers that For each number n there is at most one aA such that n selects a.

Base case: n=0

By the result of 2.3.5 - 1, we have shown that if 0 selects some aA, then a=z. Therefore, 0 selects at most one value. The base case is satisfied.

Inductive case: Assume there is at most one aA such that n selects a.

We show that there is at most one b \in A$ such that suc(n) selects b.

Note by definition of the selects relation, suc(n) selects s(a)A.

Now let's say that suc(n) selects some bA. Then by the result in 2.3.5-2, there is some xA such that n selects x and b=s(x).

But by our assumption, n selects at most one aA. Therefore, x=a and s(x)=s(a)=b where suc(n) selects b=s(a).

Therefore, suc(n) selects at most one value, that is, s(a).

We have proved by induction that for each number n there is at most one aA such that n selects a.

Completing the proof of Recursion theorem

Based on our results in 2.3.5 and 2.3.6 we can pick out a unique function f:A such that:

f(n)=a iff n selects a for every n and aA.

We now prove that:

  1. For each aA, f(0)=a iff a=z.
  2. For each aA, f(suc(n))=a iff a=s(f(n)).

Proof for 1:

Let f(0)=a for some aA. Then, by the definition of f, we have that 0 selects a. But 0 exclusively selects zA. This implies that a=z.

For the other direction, let a=z. We know 0 selects z. Therefore, by definition of f, we have that f(0)=z=a.

Therefore, we have proved that for each aA, f(0)=a iff a=z.

Proof for 2:

Let f(suc(n))=a. But then, we know that there is some bA such that n selects b and a=s(b). By the definition of f, f(n)=b.

Therefore, f(suc(n))=a=s(f(n)).

For the other direction, assume a=s(f(n)). By definition of f, we have that n selects f(n). By the definition of the selects relation, we have that suc(n) selects s(f(n)). But again by definition of f, we have that f(suc(n))=s(f(n)).

Therefore, f(suc(n))=a=s(f(n)).

We have proved that for each aA, f(suc(n))=a iff a=s(f(n)).

This completes the proof of the recursion theorem.