# Unrestricted Languages

As the name implies, the class of unrestricted languages is the least restrictive class in the Chomsky Hierarchy, and is the set of languages generated by unrestricted grammars. Unrestricted grammars are grammars composed of a finite number of rules of the form A -> B, where A and B are strings of terminal and non-terminal symbols, and A is not the empty string. The languages produced by these grammars are also referred to as recursively enumerable, as a recursive function could theoretically generate all the strings in them, although not necessarily in a finite time.

## Turing Machines

Equivalent to the class of unrestricted languages is the class of languages recognized by a Turing machine. A Turing machine (TM) is identical to an LBA (see Context Sensitive Languages), with one exception: a Turing machine's tape is infinite. In its standard form, the Turing machine's tape has a left endpoint but continues indefinitely to the right. Other infinite models for the tape, such as a tape infinite in both directions, or multiple infinite tapes, are equivalent to the standard form.
The Turing Machine is the most powerful machine in the hierarchy, with the power to emulate any of the other machines. It is equivalent in power to most programming languages, although computers only contain finite memory, while a true Turing Machine has infinite memory.

### Universal Turing Machine

Turing Machines can also be programmed as something called a Universal Turing Machine (UTM), a single TM (meaning a single set of states, rules, and alphabet) that can accept as input another TM encoded as a string, together with an input string. The Universal Turing Machine can then emulate the other TM running the input string. This universal emulation of its own class is a property not shared by any other machine in the hierarchy. Some of them can be programmed to emulate a specific subset of their class, but none of them can emulate any given member of their class.

### Looping

However powerful they may be, they do have limitations. One of the most obvious limitations is that unlike LBAs, a TM has an infinite number of conditions, due to the infinite tape. This means that the TM can not only loop, it can be in an infinite running, non-halting pattern that never loops. As an example, consider a naively programmed TM designed to take as input a positive integer a and to determine if the square root of a is rational by calculating it and printing it out on the tape. If that machine is given the number 2 as input, it will never complete printing the irrational number ${\sqrt {2}}$, and so will run forever.

## Examples

The code below is a sample TM emulator in Perl. Given the description of a machine and an input string, it simulates the machine processing the input string, and shows whether the machine accepts or not.
The syntax is: progname.pl TMFile inputFile, where TMFile is a text file containing the TM instructions, and inputFile is a text file containing the input string. Some sample inputs, including a set of TM instructions for a machine to multiply two numbers, can be found under sample TM inputs
A sample TM emulator in Perl.
Previous | Next