Introduction to Turing Machines 1 1 1 1 1 1 1 1 1 1 1 1 1
Alan Turing -- 1912 – 1954 Mathematician, a computer scientis Influantial Development of computer sciences provided an influential formalisation of the concept of the algorithm and computation with the Turing Machine Turing Test contribute to the debate of AI Can machines think? One of the 100 more imp. People in 20th century 21st on BBC nation wide poll of the 100 Greatest britons http://www.turing.org.uk/turing/ http://en.wikipedia.org/wiki/Alan_Turing/
The Turing Machine A TM consists of an infinite length tape, on which 1 1 1 1 1 1 1 1 1 1 1 1 1 1 A TM consists of an infinite length tape, on which input is provided as a finite sequence of symbols. A head reads the input tape. The TM starts at start state s0. On reading an input symbol it optionally replaces it with another symbol, changes its internal state and moves one cell to the right or left. In the above diagram, TM states are depicted by different colours. So, when the head moves, its colour also changes indicating that it has changed its internal state.
The Turing Machine A TM is defined as: TM = <S, T, s0, d, H> where, S is a set of TM states T is a set of tape symbols s0 is the start state H S is a set of halting states d : S x T S x T x {L,R} is the transition function A TM begins computation at state s0. At each computational step, it reads the present tape symbol, changes its internal state, optionally writes another symbol onto tape, and moves one cell to the left or right in the tape. The TM halts computation (and accepts the input string) when it reaches one of the halt states in H.
A Turing Machine Tape ...... ...... Read-Write head Control Unit
The Tape No boundaries -- infinite length ...... ...... Read-Write head The head moves Left or Right
...... ...... Read-Write head The head at each time step: 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right
Example: Time 0 ...... ...... Time 1 ...... d 1. Reads 2. Writes d 3. Moves Left
Time 1 ...... ...... b s Time 2 ...... ...... f s b 1. Reads 2. Writes f 3. Moves Right
The Input String Input string Blank symbol ...... ...... # # # # # head Head starts at the leftmost position of the input string. The input string is never empty
States & Transitions Write Read Move Left Move Right
R d a , ® Example: Time 1 ...... ...... a current state Time 2 ......
Example: Time 1 ...... ...... a Time 2 ...... ...... b
L g , ® # Example: Time 1 ...... ...... Time 2 ...... ...... # # # # #
Determinism Not Allowed Turing Machines are deterministic Allowed No lambda transitions allowed
Partial Transition Function Example: # ...... Allowed: No transition for input symbol
Halting The machine halts if there are no possible transitions to follow ...... ...... # # # # # No possible transition HALT!!!
Final States Not Allowed Allowed Final states have no outgoing transitions In a final state the machine halts
Acceptance If machine halts Accept Input in a final state in a non-final state or If machine enters an infinite loop Reject Input
Turing Machine Example A Turing machine that accepts the language:
Time 0
Time 1
Time 2
Time 3
Time 4 Halt & Accept
Rejection Example Time 0
Time 1 No possible Transition Halt & Reject
Infinite Loop Example A Turing machine for language
Time 0
Time 1
Time 2
Time 2 Time 3 Infinite loop Time 4 Time 5
Because of the infinite loop: The final state cannot be reached The machine never halts The input is not accepted
Another Turing Machine Example Turing machine for the language
Time 0
Time 1
Time 2
Time 3
Time 4
Time 5
Time 6
Time 7
Time 8
Time 9
Time 10
Time 11
Time 12
Time 13 Halt & Accept
Observation: If we modify the machine for the language we can easily construct a machine for the language
Formal Definitions for Turing Machines
Transition Function
Transition Function
Turing Machine: Input alphabet Tape alphabet States Transition function Final states Initial state blank
Configuration Instantaneous description:
Time 4 Time 5 A Move:
Time 4 Time 5 Time 6 Time 7
Equivalent notation:
Initial configuration: Input string
The Accepted Language For any Turing Machine Initial state Final state
Standard Turing Machine The machine we described is the standard: Deterministic Infinite tape in both directions Tape is the input/output file
Computing Functions with Turing Machines
A function has: Result Region: Domain:
A function may have many parameters: Example: Addition function
Integer Domain Decimal: 5 Binary: 101 We prefer unary representation: easier to manipulate with Turing machines Unary: 11111
Definition: A function is computable if there is a Turing Machine such that: Initial configuration Final configuration initial state final state For all Domain
In other words: A function is computable if there is a Turing Machine such that: Initial Configuration Final Configuration For all Domain
Example The function is computable are integers Turing Machine: Input string: unary Output string: unary
Start initial state The 0 is the delimiter that separates the two numbers
Start initial state Finish final state
The 0 helps when we use the result for other operations Finish final state
Turing machine for function
Execution Example: Time 0 (2) (2) Final Result
Time 0
Time 1
Time 2
Time 3
Time 4
Time 5
Time 6
Time 7
Time 8
Time 9
Time 10
Time 11
Time 12 HALT & accept
Another Example The function is computable is integer Turing Machine: Input string: unary Output string: unary
Start initial state Finish final state
Turing Machine Pseudocode for Replace every 1 with $ Repeat: Find rightmost $, replace it with 1 Go to right end, insert 1 Until no more $ remain
Turing Machine for
Example Start Finish
Simple TM Examples Turing Machine U+1: Given a string of 1s on a tape (followed by an infinite number of 0s), add one more 1 at the end of the string. #111100000000……. #1111100000000………. A tape is denoted by #11110000…. Where # is the start of the tape.
Simple TM Examples TM: U+1 d(s0, 1) |-- (s0, 1, R) d(s0, 0) |-- (h, 1, STOP) #s0111100000….. #1s011100000….. #11s01100000….. #111s0100000….. #1111s000000….. #11111h0000….. STOP TM computations are illustrated in the form #s11110000… which shows the TM to be in state s, and at the beginning of the tape.
Another Example if The function if is computable
Turing Machine for if if Input: Output: or
Turing Machine Pseudocode: Repeat Match a 1 from with a 1 from Until all of or is matched If a 1 from is not matched erase tape, write 1 else erase tape, write 0
Combining Turing Machines
Block Diagram Turing Machine input output
Example: if if Adder Comparer Eraser
Turing’s Thesis Any mathematical problem solving that can be described by a mechanical procedure (algorithm) can be modeled by a Turing machine. All computers today perform only mechanical problem solving. They are no more expressive than a Turing machine. A philosophical question: Do digital computers today perform only mechanical computations? What about our thinking? Do we think mechanically? Can we reduce our thought processes to an algorithm?
Turing’s Thesis Turing’s thesis is not a “theorem” there is no “proof” for the thesis. The theorem may be refuted by showing at least one task that is performed by a digital computer which cannot be performed by a Turing machine. Many contentions have been made to this end. However, till date there have not been any conclusive evidence to refute Turing’s thesis. Although Turing’s a-machine were the most popular, there are many more machines proposed by Turing. Basically they are meant to be more powerful than a-machines. These include the c-machines (choice machines), o-machines (oracle machines) and u-machines (unorganized machines). However, there have been no conclusive proofs about whether they are more expressive than a-machines.
Conclusions TMs are at a level that is much below the assembly language of any typical microprocessor. So in the practical world, TMs are more useful in what they cannot do rather than in what they can.
Lab2 Write some simpleTuring machine programs QUESTIONS?