# Recursion-theoretic if-statements

1. Jun 19, 2011

### kanima

Hi, there, I was wondering if anyone knew a good way to implement if-statements in recursion-theoretic terms. Basically, I've come to the understanding that primitive recursion is analogous to a for-loop and mu-recursion to more general while-loops, but is there in general a simple analog of an if-statement in recursion theory?

For example, suppose that given partial recursive functions $g$ and $h$ I had the following algorithm which takes $x$ as input.

if $x < 50$ then
return $g(x)$​

else
return $h(x)$​

How could I define a partial recursive function computing the above algorithm? What if the condition $x < 50$ were replaced by some more general recursive predicate $R(x)$?

I suspect this shouldn't be so difficult but I am quite new to this subject. If this is the case, I would be quite glad if someone would share their knowledge me.

Thanks!

2. Jun 20, 2011

### Stephen Tashi

I don't know the answer to your question, but it prompted me to look up "partial recursive function". I notice there a considerable difference between how it is defined on the Wikipedia (http://en.wikipedia.org/wiki/Computable_function) versus Wolfram (http://mathworld.wolfram.com/RecursiveFunction.html).

If we use the Wolfram definition, your question could be interpreted as asking how to write a function who definition has an "if ... then " clause as a series of equations. However, I'm not sure that question is significant if we are allowed to use "function symbols" in the equations unless there is some restriction on what functions can be represented by "function symbol". Is there something that says a "function symbol" cannot stand for a function (say on the non-negative integers) which is the list of pairs (x, f(x)) = { (1,0),(2,0),(3,1),(4,1),.... }, which amounts to f(k) = 0 if k < 3 and f(k) = 1 otherwise.

Last edited by a moderator: Apr 26, 2017
3. Jun 20, 2011

### kanima

Sorry, I should have been more specific, especially because of the many guises this same subject appears in.

My definition of partial recursive function is more in line with the one given in the following wikipedia article:
http://en.wikipedia.org/wiki/Μ-recursive_function.

Wikipedia calls them partial $\mu$-recursive functions, and the https://www.amazon.com/Classical-Re...05X/ref=sr_1_1?ie=UTF8&qid=1308593616&sr=8-1"I am following simply calls them partial recursive functions.

The class of functions defined in this way is equivalent to the class of those defined in the Wolfram link. This class of functions is also equivalent to the class of Turing-computable functions: functions whose values can be computed by some Turing machine.

It shouldn't be very difficult to implement conditional if-statements on Turing machines (since they're pretty natural models of computation). However, I am interested in seeing how a function computed by an algorithm with an if-statement can be built up from definition given in the wikipedia page on $\mu$-recursive functions.

Last edited by a moderator: Apr 26, 2017
4. Jun 20, 2011

### Stephen Tashi

Perhaps the place to start is to find a function T(x) that returns 1 if x < 50 and returns 0 otherwise. Then the function you asked about is defined by f(x) = T(x)g(x) + (1-T(x))h(x).

What is a "general recursive predicate"? Is there a definition or theorem that says its evaluation (as true or false , or 1 or 0) is computable.

5. Jun 23, 2011

### kanima

Yes, I believe you're right, and looks like the answer was quite simple after all. By a recursive predicate I did just mean a recursive function that could only give the values 0 or 1. So I guess the function $f$ in your example would be recursive if the predicate $T$ expressing the condition was recursive.