Recursive Functions andTuring Machines - an introduction

Recursive Functions:

Setting: In this section all functions will be of the form MATH where again MATHare the natural numbers.

Definition The following are primitive recursive functions:

  1. The successor function, MATH.

  2. The constant functions, MATHany $\QTR{Large}{c}$

  3. Projections, MATH.

  4. composition: Given primitive recursive functions MATH then

    is primitive recursive:

  5. primitive recursion: Given primitive recursive functions MATHand MATH

    then the function MATH defined by the following two equations is primitive recursive:

_______________________________________________________________

Example 1:

MATH

MATH

MATH

Example 2 (less formally):

MATH

MATH

MATH

MATH

Example 3 (Exercise $\QTR{Large}{n!}$):

MATH

________________________________________________________________

Definition: The following are partial recursive functions:

  1. Any primative recursive function.

  2. If $\QTR{Large}{g}$ is a partial recursive function such thatMATH is defined for all $\QTR{Large}{y<m}$:

MATH

If no such $\QTR{Large}{m}$ exists then MATHis undefined.

A partial recursive function MATH that is defined for all MATH is called (total) recursive.

___________________________________________________________________________

Notation and Examples:

  1. The predecessor function:

    MATH

    MATH

    Note MATH

  2. Truncated Subtraction:

    MATH

    MATH

  3. The Equals Function:

    MATH

  4. (An Aside) The C equals operator:

    $\QTR{Large}{eq}$(MATH

  5. Square Root:

    $\QTR{Large}{sqrt}$($\QTR{Large}{x)=}$ MATH

    Note that $\QTR{Large}{sqrt}$($\QTR{Large}{0)}$ and $\QTR{Large}{sqrt}$($\QTR{Large}{1)}$ are defined.

The Church-Turing Thesis:

Recursive functions are identical to the set of functions MATH that can mechanically computed, that is, are programmable on some deterministic computer.

_________________________________________________________________________

Turing Machines:

Figure

Definition :

A Turing Machine $\QTR{Large}{T}$ consists of:

Notation: MATHdenotes that is in state $\QTR{Large}{q_{i}}$ and the tape contains the consecutive sequence of symbols MATH with all blanks to the left of $\QTR{Large}{s_{1}}$ and to the right of $\QTR{Large}{s_{n}}$.

Moreover the head is over the cell containing $\QTR{Large}{s_{j}}$. We call this the state of $\QTR{Large}{T}$ , as opposed to the head state.


Given MATH and valid step MATHwe write MATH More generally MATHwill be used to denote a sequence of valid steps refered to as a derivation.

__________________________________________________________________________________________

Alternate Definitions: There are many computationally equivalent definitions of Turing Machine..

One A: simple, in fact more commonly used, variation is as above except in the Transition Function, rather than Head MATH, only MATH are available.

To create a computationally equivalent MATH for a given MATH Turing Machine

Two Another variant defines MATH. Here, in a given step, either the cell under the Head gets rewritten or the Head moves not both.

Exercise (Due ): Show that Two is computationally equivalent to the original definition or to One , hence all three are equivalent. MATH

Three:....An n-tape Turing Machine $\QTR{Large}{T}$ consists of:

______________________________________________________________________

The Subtract 1 Turing Machine:

Figure

Exercise (Due May 2 ): Build a Turing Machine that interchanges the position of two strings of $\QTR{Large}{1}$ s and $\QTR{Large}{0}$ s that a separated by a single blank and with the tape blank elsewhere.

That is, starting with a tape that contains MATH with the Head positioned over the cell containing the initial $\QTR{Large}{x}$ , halts when the tape contains

MATHwith the Head positioned over the cell containing the initial $\QTR{Large}{y}$ .

Hints:

  1. MATH

  2. MATH

A little care has to be taken because one of the two strings may be empty (or both, the tape could be blank)

Figure

________________________________________________________________________________________________________

Theorem(Informal):

_________________________________________________________________________________________________________

Universal Turing Machines:

An Intel Corporation Almost Universal Turing Machine

Theorem(Informal):

Technicalities:

The first step in the proof of this Theorem would be developing a general alphabet encoding that could be used to encode the alphabet of any Turing Machine.

MATHwould have to be understood in terms of that encoding.

______________________________________________________________

A Convenient 3-tape Turing Machine :

We say such a Turing Machine halts on input $\QTR{Large}{p}$ with output $\QTR{Large}{x}$ , and write MATH if $\QTR{Large}{p}$ is to the left of the input head and $\QTR{Large}{x}$ is to the left of the output head after $\QTR{Large}{T}$ halts. .

____________________________________________________________________________________________________________________

Exercise (Due May 2 ): (Informal, again Kolmogorov Complexity ) Given Turing Machines MATHand MATH , and descriptions MATH, MATH .$\QTR{Large}{>}$ realizing functions MATH what would a description for a Turing Machine realizing MATH look like. You answer should, again informally, list a series of general steps creating the description from any MATHand MATH .$\QTR{Large}{>,}$ (Hint: How would you do this using Java, or C, or javascript)

______________________________________________________________

A Prefix Universal Turing Machine:

Yet another 3-tape variant, important for Kolmogorov Complexity, has

MATH ,

Note: Getting from A Convenient 3-tape UniversalTuring Machine to A Prefix Universal Turing Machine is not a huge step (see the encodings below)

___________________________________________________________________________________

"Standard" notation:For a string $\QTR{Large}{x}$ , MATH

A simple prefix encoding:

For any string MATH in MATH , define MATH to be $\QTR{Large}{n\ 1}$s followed by a $\QTR{Large}{0}$.followed by $\QTR{Large}{x}$.

MATH , $\QTR{Large}{.}$(MATH

The map MATH is a prefix encoding of MATH. and MATH

The "standard" prefix encoding

Let $\QTR{Large}{b}$($\QTR{Large}{x)}$ be the following binary string ordering function

For any string MATH in MATH , $\QTR{Large}{\ }$define MATHto be the prefix encoding above, of MATH

.MATH ,where MATHthe least integer MATH

Finally letMATH , concatinating $\QTR{Large}{c(x)}$ and $\QTR{Large}{x.}$

The map MATH is a prefix encoding of MATH.called the standard prefix encoding.

.$\QTR{Large}{\ }$ MATHwhere, again ,MATH , a significant improvement. as $\QTR{Large}{n}$ becomes large

MATH

psudo code to decode MATH

  1. $\QTR{Large}{m=}$ Count $\QTR{Large}{1}$ s up to but not including first $\QTR{Large}{0}$ , The next $\QTR{Large}{m}$ string characters, after the $\QTR{Large}{0}$ is the binary representation of the length of $\QTR{Large}{x\ }$, call this MATH.

  2. MATH

  3. $\QTR{Large}{x=}$next $\QTR{Large}{n}$ string binary digits after the first $\QTR{Large}{2m+1}$

  4. The next string begins after the first MATH

decoding MATH

  1. $\QTR{Large}{m=2\ }$and MATH

  2. MATH

  3. MATH

MATH

A Simpler Short Prefix Encoding:

For any string $\QTR{Large}{x\ }$ in MATH MATH, let MATH be the binary representation of$\ \QTR{Large}{n}$ Let MATH MATH.

Finally let MATH

.$\QTR{Large}{\ }$ MATH

For the example above:

MATH

Exercise (Due May 2 ) Verify that the "standard" or simpler short prefix encoding is indeed a prefix encoding.