# Understanding the Definition by Recursion theorem

I have just started reading Logic and Structure (5th edition) by Dirk Van Dalen. In the second chapter there is "Theorem 2.1.6 (Definition by Recursion)". I have no problem understanding nor proving it. My problem is with the examples that the book claims are applications of this technique. To give context, I will quote the theorem:

(Theorem 2.1.6) Let mappings $$H_\square : A^2 \rightarrow A$$ and $$H_\neg : A \rightarrow A$$ be given and let $$H_{at}$$ be a mapping from the set of atoms into A, then there exists exactly one mapping $$F : PROP \rightarrow A$$ such that:
$$\begin{cases} F(\varphi) = H_{at}(\varphi ) \quad \text{for } \varphi \text{ atomic} \\ F((\varphi \square \psi)) = H_\square(F(\varphi), F(\psi)) \\ F((\neg \varphi))=H_\neg(F(\varphi )) \end{cases}$$

The book then, as an example of this technique (theorem), defines the rank function as follows:

$$\begin{cases} r(\varphi)=0\quad \text{for atomic } \varphi ,\\ r((\varphi \square \psi))=max(r(\varphi),r(\psi))+1,\\ r((\neg \varphi))=r(\varphi)+1. \end{cases}$$

This is where I get confused. I can't see how the theorem is used in this definition. Does the function $$r$$ in this definition, correspond to the function $$H$$ in the theorem? If yes, shouldn't it be of type $$\mathbb{N}^2 \rightarrow \mathbb{N}$$ instead of $$PROP \rightarrow \mathbb{N}$$ in $$r((\varphi\square\psi))$$? (given $$A$$ is $$\mathbb{N}$$ in this case). Does $$r$$ correspond to $$F$$? If it's the case, why do we need the theorem? The theorem guarantees the existence of such unique function, but here, we directly construct it. How would this definition be invalid if we hadn't proven the theorem? In my opinion, if we were to use the theorem to define $$r$$, we would have to do something like:

If we define:

$$\begin{cases} H_{at}(\varphi)=0 \quad \text{for atomic } \varphi,\\ H_\square(n_1, n_2) = max(n_1, n_2) + 1 \quad \text{for } n_1,n_2 \in \mathbb{N},\\ H_\neg(n) = n + 1 \quad \text{for } n \in \mathbb{N}. \end{cases}$$

Then, according to 2.1.6, there exists a unique function $$F : PROP \rightarrow \mathbb{N}$$ satisfying the conditions explained above. We name this function $$r$$.

The book also defines the set of subformulas of a proposition as an example of this technique:

$$\begin{cases} Sub(\varphi) = \{\varphi\} \quad \text{for atomic } \varphi \\ Sub((\varphi \square \psi))=Sub(\varphi)\cup Sub(\psi) \cup\{\varphi\square\psi\} \\ Sub(\neg\varphi)=Sub(\varphi)\cup\{\neg\varphi\}. \end{cases}$$

I think the relation between this definition and the theorem is even more problematic. How are we going to define $$H_\square$$, so that we can have $$Sub((\varphi \square \psi)) = H_\square(Sub(\varphi), Sub(\psi))$$ to be equal to $$Sub(\varphi)\cup Sub(\psi) \cup\{\varphi\square\psi\}$$? In particular the $$\{\varphi\cup\psi\}$$ part. $$H_\square$$ takes two sets of subforumulas, it doesn't know which formula's subformulas they are. Maybe we must get $$\varphi$$ from $$Sub(\varphi)$$ by taking the element with the highest rank? Then we must prove such element is unique (not that it's hard to prove, but it should at least be pointed out). If it's the case, I should reconsider self-studying this book as there is so much detail omitted.

In your first example, r corresponds to F.

You say something along the lines of not needing the theorem due to the direct construction. Rather, the proof of the theorem guarantees that our direct construction works. Here is analogy (hopefully you know some LA). Typically, when talking about a linear function, we define its action only on the basis vectors. This works since any function defined on a basis extends uniquely to a function defined on the whole vector space. Here we have done something similar. The "direct construction" only specifies r's action on the "constructors" of formulae. That we are talking about a particular r is guaranteed by the theorem.

Also, your $$H_\square$$ should be $$max(n1,n2)+1$$. Since authors are lazy, they do not wish to specify all the H_underscore functions, and the theorem guarantees that they can just talk about r. Hopefully you can now answer your own second example.

• Thank you for answer. I still can't get the point (I'm new to this kind of math). What does it mean for a function to "work"? Did we prove that $f(x)=x$ works? You plug a number in, and you get the result. Imagine a world where the theorem doesn't hold, and I present you the same definition of $r$, what makes it invalid? Can't we simply plug a proposition and get a number? Jun 13, 2023 at 19:31
• Regarding the second example, I edited the post, could you please reread that part? Jun 13, 2023 at 19:32
• when we specify a (total) function, we must define it on every input. Further it must be well defined on each input. Finally, if we introduce a name, we must have a definite referent. A priori, given the H_ underscore functions, we don't know if any of these conditions hold Jun 13, 2023 at 20:03
• Again, the vector space analogy is instructive. Given a function defined only on basis vectors, we do not a priori know the functions action on the other vectors of the vector space. Suppose we have a prop with conjunctions and negations and we don't know if rank as a whole is well def. we only know a priori that its rank as a whole is found from the rank of its consitutients. But if we are not sure that rank as a whole is well def, then knowing that rank of consitutents is well def will not a priori assure us any more that rank as a whole is well def. Jun 13, 2023 at 20:09
• @PharazFadaei - But how do you know that $r$ is well-defined? A function gives a unique value to each argument. If I have a "function" $f$ such that $f(x)$ is the number which squared results in $x$, then $f$ is not well-defined, since there is no such unique number (think of negatives). In order to show that this type of case does not arise for $r$, you will need the theorem. Jun 15, 2023 at 1:13

After some time of confusion, skepticism, and reading multiple sources, I finally found A Mathematical Introduction to Logic by Herbert B. Enderton. This book, before proving the theorem, illustrates that such recursively defined function can be ill-defined. Here is the example from the book:

If we define $$f: \mathbb{N}^2\rightarrow\mathbb{N}$$ and $$g : \mathbb{N}\rightarrow\mathbb{N}$$ as $$f(x, y) = x \cdot y$$ and $$g(x)=x+1$$, and try to define the function $$H : \mathbb{N}\rightarrow\mathbb{N}$$ recursively as:

$$\begin{cases} H(0) = 0, \\ H(f(x, y)) = f(H(x), H(y)),\\ H(g(x)) = H(x) + 2. \end{cases}$$

Then $$H$$ is not well-defined (i.e., is not a function), and no such function can exist. ($$H(1)$$ can be computed using both the second and the third formulas, yielding different results, since $$1 = g(0)$$ and also $$1 = f(g(0), g(0))$$.)

So the theorem is of course required to be able to define such functions on $$PROP$$.