Computability Theory Turing Machines Professor MSc. Ivan A. Escobar [email protected].
-
Upload
sherman-steven-douglas -
Category
Documents
-
view
221 -
download
0
Transcript of Computability Theory Turing Machines Professor MSc. Ivan A. Escobar [email protected].
![Page 2: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/2.jpg)
Recalling
A finite automata is a computational model that has a limited quantity of memory available. They are good models for devices that have a small
amount of memory.
A pushdown automata is a computational model that has a unlimited quantity of memory available but possesses some restrictions in they way it can use it. LIFO memory management.
![Page 3: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/3.jpg)
Important Observation
The previous models don’t have the sufficient properties to represent a general purpose computational model.
![Page 4: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/4.jpg)
TMs
We introduce the most powerful of the automata we will study: Turing Machines (TMs) Invented by Alan Turing in 1936.
TMs can compute any function normally considered computable
Indeed we can define computable to mean computable by a TM
![Page 5: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/5.jpg)
Turing Machines
A Turing machine (TM) can compute everything a usual computer program can compute may be less efficient
But the computation allows a mathematical analysis of questions like : What is computable? What is decidable? What is complexity?
![Page 6: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/6.jpg)
State control
a a b a
input
- - -
A Turing Machine is a theoretical computer consisting of a tape of infinite length and a read-write head which can move left and right across the tape.
![Page 7: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/7.jpg)
Informal definition
TMs uses an infinite memory (tape)
Tape initially contain input string followed by blanks
When started, a TM executes a series of discrete transitions, as determined by its transition function and by the initial characters on the tape
![Page 8: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/8.jpg)
Informal definition
For each transition, the machine checks what state it is in and what character is written on
the tape below the head. Based on those, it then changes to a new state,
writes a new character on the tape, and moves the head one space left or right.
The machine stops after transferring to the special HALT (accept or reject) state.
If TM doesn’t enter a HALT state, it will go on forever
![Page 9: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/9.jpg)
Differences between FA and TMs
A TM can both write on the tape and read from it
The read-write head can move both to the left and to the right
The tape is infinite
The special states of rejecting and accepting take immediate effect
![Page 10: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/10.jpg)
Examples
aa,Rba,R
aa,R means TM reads the symbol a, it replaces it with aand moves head to right
This TM when reading an a will move right one square stays in the same start state. When it scans a b, it will change this symbol to an a and go into the other state (accept state).
![Page 11: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/11.jpg)
Examples
A TM (M1) that tests for memberships in the language B= {w#w | w belongs to {0,1}*}
We want to design M1 to accept if its input is a member of B.
Idea: Zig-zag across tape, crossing off matching symbols
![Page 12: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/12.jpg)
Machine M1 Design
M1 makes multiple passes over the input string with the read-write head.
On each pass it matches one of the characters on each side of the # symbol.
To keep track of which symbols have been checked already, M1 crosses off each symbol as it is examined.
![Page 13: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/13.jpg)
Machine M1 Design
If it crosses off all the symbols, that means that everything matched successfully, and M1 goes into an accept state.
If it discovers a mismatch, it enters a reject state.
![Page 14: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/14.jpg)
M1: Algorithm
![Page 15: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/15.jpg)
Examples: M1
Tape head starts over leftmost symbol
Record symbol in control and overwrite X
Scan right: reject if blank encountered before #
When # encountered, move right one space
If symbols don’t match, reject
a b b # a b b X b b # a b bX b b # a b bb
![Page 16: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/16.jpg)
Examples
Overwrite X
Scan left, past # to X
Move one space right
Record symbol and overwrite X
When # encountered, move right one space
If symbols don’t match, reject
X X b # X b bbX b b # X b b bX X b # X b b
![Page 17: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/17.jpg)
Examples
Finally scan left
If a or b encountered, reject
When blank encountered, accept
bX X X # X X X
![Page 18: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/18.jpg)
Formal Definition
A Turing Machine is a 7-tuple (Q,∑,T, ξ,q0,qaccept, qreject), where Q is a finite set of states ∑ is a finite set of symbols called the alphabet T is the tape alphabet, where – belongs to T, and ∑⊆ T ξ : Q x T Q x T x {L,R} is the transition function q0 Є Q is the start state qaccept ⊆ Q is the accept state qreject ⊆ Q is the reject state, where qaccept ≠ qreject
![Page 19: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/19.jpg)
Transition function
ξ : Q x T Q x T x {L,R} is the transition functionξ(q,a) = (r,b,L) means
in state q where head reads tape symbol a
the machine overwrites a with b
enters state r
move the head left
![Page 20: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/20.jpg)
Workings of a TM
M = (Q,∑,T, ξ,q0,qaccept, qreject) computes as follows
Input w=w1w2…wn is on leftmost n tape squares
Rest of tape is blank –
Head is on leftmost square of tape
![Page 21: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/21.jpg)
Workings of a TM
M = (Q,∑,T, ξ,q0,qaccept, qaccept)
When computation starts M Proceeds according to transition function ξ
If M tries to move head beyond left-hand-end of tape, it doesn’t move
Computation continues until qaccept or qaccept is reached
Otherwise M runs forever
![Page 22: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/22.jpg)
Configurations
Computation changes Current state Current head position Tape contents
![Page 23: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/23.jpg)
Configurations
Configuration 1011r0111
Means State is r Left-Hand-Side (LHS) is 1011 Right-Hand-Side (RHS) is 0111 Head is on RHS 0
![Page 24: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/24.jpg)
Configurations
uarbv yields upacv if ξ(r,b) = (p,c,L)
uarbv yields uacpv if ξ(r,b) = (p,c,R)
Special cases: rbv yields pcv if ξ(r,b) = (p,c,L) The head moves (tries) to the left, so it only
overwrites if it is in the extreme left end.
wr is the same as wr– (right hand end)
![Page 25: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/25.jpg)
More configurations
We have starting configuration q0w
Indicates machine is in a start state q0 with its head at the leftmost position.
accepting configuration w0qacceptw1
rejecting configuration w0qrejectw1
halting configurations w0qacceptw1 w0qrejectw1
![Page 26: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/26.jpg)
Observations
The accept and reject configurations do not derive in further configurations (or states).
![Page 27: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/27.jpg)
Accepting a language
TM M accepts input w if a sequence of configurations C1,C2,…,Ck exist C1 is start configuration of M on w
Each Ci yields Ci+1
Ck is an accepting configuration
![Page 28: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/28.jpg)
TM Language
The collection of strings that M accepts is the language of M, denoted by L(M).
![Page 29: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/29.jpg)
Detailed example
![Page 30: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/30.jpg)
Detailed example
![Page 31: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/31.jpg)
Detailed Example
Do the following test runs: q10.
q100.
q1000.
q10000.
![Page 32: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/32.jpg)
Detailed Example
Sample run for q10000.
![Page 33: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/33.jpg)
Software:
JFLAP (http://jflap.org)
DEMO:
![Page 34: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/34.jpg)
Exercise 2:
B= {w#w | w belongs to {0,1}*}
![Page 35: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/35.jpg)
Exercise 2
Design the state transition diagram based on the previous informal definition of the turing machine M3.
Test the diagram with 001101#001101
Transfer the diagram to JFLAP
![Page 36: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/36.jpg)
State Diagram
![Page 37: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/37.jpg)
Enumerable languages
Definition: A language is (recursively) enumerable if some TM accepts it In some other textbooks Turing-recognizable
![Page 38: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/38.jpg)
Enumerable languages
On an input to a TM we may accept reject loop (run for ever)
Not very practical: never know if TM will halt
![Page 39: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/39.jpg)
Enumerable languages
Definition: A TM decides a language if it always halts in an accept or reject state. Such a TM is called a decider
A decider that recognizes some language is said to decide that language.
Definition: A language is decidable if someTM decides it Some textbooks use recursive instead of decidable
Therefore, every decidable language is enumerable, but not the reverse!
![Page 40: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/40.jpg)
Example of decidable language
Here is a decidable language L={aibjck | ix j = k, I,j,k > 0}
Because there exist a TM that decides it
How?
![Page 41: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/41.jpg)
Example of decidable language
How?1. Scan from left to right to check that input is of the form
a*b*c*2. Return to the start3. Cross off an a and 4. scan right till you see a b5. Mark each b and scan right till you see a c6. Cross off that c7. Move left to the next b, and repeat previous two steps until
all b’s are marked8. Unmark all b’s and go to the start of the tape9. Goto step 1 until all a’s are crossed off10. Check if all c’s are crossed off; if so accept; otherwise reject
![Page 42: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/42.jpg)
TM: Variants
Turing Machine head stays put Does not add any power Three possible states for the tape {L,R,S}
Nondetermisim added to TMs Does not add any power Halting states may produce transitions.
![Page 43: Computability Theory Turing Machines Professor MSc. Ivan A. Escobar iescobar@itesm.mx.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649e9e5503460f94ba04b7/html5/thumbnails/43.jpg)
Remarks
Many models have been proposed for general-purpose computation
Remarkably all “reasonable” models are equivalent to Turing Machines
All ”reasonable” programming languages like C, C++, Java, Prolog, etc are equivalent
The notion of an algorithm is model-independent!