Primitive Recursive Functions in Automata Theory



Primitive recursive functions are a subclass of total recursive functions. These functions play an important role formal language and automata theory. They are computable functions that can be constructed using simple operations like zero functions, successor functions, projection functions, and more complex operations such as composition and recursion.

In this chapter, we will cover the basic concepts of primitive recursive functions and provide examples for a better understanding.

Recursive Functions

For a basic recap, first understand the broader category of recursive functions, which include partial and total recursive functions.

Partial and Total Functions

A function is termed partial if it is not defined for all possible inputs, meaning for some inputs, the function might not yield a result. Conversely, a total function is defined for every possible input within a given set, meaning it always produces a result.

Example

Let A and B be sets of positive integers. If a function f(x) is defined as x2, the relation A → B only exists if x belongs to the set of perfect squares like 4, 9, 16, etc. Here, f(16) is defined, but f(20) is undefined, making it a partial function. On the other hand, if we define a function f(x) = x + 1, it is a total function because it is defined for all integers.

Partial and Total Recursive Functions

When it comes to recursive functions −

  • Partial recursive functions are those computed by a Turing machine that may not halt for every input, potentially running indefinitely for some cases.
  • Total recursive functions are a subset of partial recursive functions for which the Turing machine always halts and returns a result for every input.

Example

The addition of two integers, f(x, y) = x + y, is a total recursive function because it always produces a result regardless of the values of x and y.

Concept of Primitive Recursive Functions

Primitive recursive functions are a further subset of total recursive functions. They are important because they can be defined through a finite number of basic operations, such as composition and recursion, starting from a few basic functions like the zero function, successor function, and projection function.

Defining Primitive Recursive Functions

Formally, a function $\mathrm{f(x_1,\: x_2, \: ...\: ,x_n)}$ is primitive recursive if it can be expressed as follows −

$$\mathrm{f(x_1,\: x_2,\: \dotso \:,x_n \:\: 1,\: 0) \:=\: g(x_1,\: x_2,\: \dotso \:,x_n\: \: 1)}$$

$$\mathrm{f(x_1, \: x_2, \:\dotso,\: x_n \:\: 1,\: y \:+\: 1) \:=\: h(x_1,\: x_2,\: \dotso,\: x_n,\: f(x_1,\: x_2,\: \dotso,\: x_n \:\: 1,\: y))}$$

Where g and h are also primitive recursive functions.

Examples of Primitive Recursive Functions

In this section, let's take a look at some basic examples of primitive recursive functions.

Zero Function

The zero function Z(x) = 0 for all x N (where N is the set of natural numbers) is a basic primitive recursive function. It essentially erases its input and returns zero.

Example

A Turing machine can be designed to simulate this function by moving through the input and replacing every symbol with zero.

Zero Function

Successor Function

The successor function S(x) = x + 1 for all x N is another basic primitive recursive function. It simply increments the value of its input by 1.

Example

A Turing machine simulating the successor function would move to the rightmost position and add a '1' to the input value.

Successor Function

Projection Function

Projection functions are denoted as Pin(x1, x2, , xn) = xi. They return the i-th input from the list of inputs.

Example

A Turing machine can be designed to take a sequence of inputs and output the i-th input by counting and projecting it.

Composing and Recursing Functions

Primitive recursive functions can also be formed by composing these basic functions or by recursion.

Example 1: Adding two numbers is primitive recursive.

$$\mathrm{f(x,\: y) \:=\: x \:+\: y}$$

$$\mathrm{f(x,\: 0) \:=\: x}$$

$$\mathrm{f(x,\: y \:+\: 1) \:=\: f(x,\: y) \:+\: 1 }$$

This function can be constructed from the zero and successor functions, making it primitive recursive.

Example 2: Multiplying two numbers is primitive recursive.

$$\mathrm{f(x,\: y) \:=\: x\: \times \: y}$$

$$\mathrm{f(x,\: 0) \:=\: 0}$$

$$\mathrm{f(x,\:y \:+\: 1) \:=\: f(x,\: y) \:+\: x }$$

Since addition is primitive recursive, multiplication is also primitive recursive by composition.

Example 3: Exponentiation, where f(x, y) = xy, is primitive recursive.

$$\mathrm{f(x,\: 0) \:=\: 1}$$

$$\mathrm{f(x,\: y \:+\: 1) \:=\: (x,\: y) \:\times\: x}$$

Given that multiplication is primitive recursive, so is exponentiation.

Advanced Example: Factorial Function

Let us prove that the factorial function, fact(x), is primitive recursive.

  • Base Case: fact(0) = 1
  • Recursive Step: fact(x + 1) = (x + 1) fact(x)

Here, since multiplication is primitive recursive, the factorial function, constructed through recursion, is also primitive recursive.

Conclusion

In this chapter, we explored the concept of primitive recursive functions. Starting with the basics of recursive functions, we covered partial and total recursive functions. We explained the construction of primitive recursive functions with examples such as the zero function, successor function, and more complex functions like addition, multiplication, and exponentiation, for a better understanding.

Advertisements