Busch Complexity ectures: Turing Machines Prof. Busch - SU 1
The anguage Hierarchy a n b n c n? ww? Context-Free anguages n b n a ww egular anguages a* a *b* Prof. Busch - SU 2
a n b anguages accepted by Turing Machines n c n Context-Free anguages n b n a ww ww egular anguages a* a *b* Prof. Busch - SU 3
Tape... A Turing Machine... Control Unit ead-write head Prof. Busch - SU 4
The Tape... No boundaries -- infinite length... ead-write head The head moves eft or ight Prof. Busch - SU 5
...... ead-write head The head at each transition (time step): 1. eads a symbol 2. Writes a symbol 3. Moves eft or ight Prof. Busch - SU 6
Example:... a Time 0 b a c...... Time 1 a b k c... 1. eads 2. Writes a k 3. Moves eft Prof. Busch - SU 7
... Time 1 a b k c...... Time 2 a f k c... 1. eads 2. Writes b 3. Moves ight f Prof. Busch - SU 8
The Input String Input string Blank symbol... a b a c... head Head starts at the leftmost position of the input string Prof. Busch - SU 9
States & Transitions ead Write Move eft q a b, q2 1 Move ight q a b, q2 1 Prof. Busch - SU 10
Example: Time 1... a b a c... q 1 current state q a b, q2 1 Prof. Busch - SU 11
Time 1... a b a c... q 1 Time 2... a b b c... q 2 q a b, q2 1 Prof. Busch - SU 12
Example: Time 1... a b a c... q 1 Time 2... a b b c... q a b, q2 1 q 2 Prof. Busch - SU 13
Example: Time 1... a b a c... q 1 Time 2... a b b c g... q 2 g, q q2 1 Prof. Busch - SU 14
Determinism Turing Machines are deterministic Allowed Not Allowed a b, q 2 a b, q 2 q 1 q 1 b d, q 3 a d, q 3 No lambda transitions allowed Prof. Busch - SU 15
Example: Partial Transition Function... a b a c... q 1 q 1 a b, b d, q 2 q 3 Allowed: No transition for input symbol c Prof. Busch - SU 16
Halting The machine halts in a state if there is no transition to follow Prof. Busch - SU 17
Halting Example 1:... a b a c... q 1 q1 No transition from HAT!!! q 1 Prof. Busch - SU 18
Halting Example 2:... a b a c... q 1 a b, q 2 No possible transition q 1 from q1 and symbol c b d, q 3 HAT!!! Prof. Busch - SU 19
Accepting States q1 q2 Allowed q1 q2 Not Allowed Accepting states have no outgoing transitions The machine halts and accepts Prof. Busch - SU 20
Acceptance Accept Input string If machine halts in an accept state eject Input string If machine halts in a non-accept state or If machine enters an infinite loop Prof. Busch - SU 21
Observation: In order to accept an input string, it is not necessary to scan all the symbols in the string Prof. Busch - SU 22
Turing Machine Example Input alphabet Σ = { a, b} Accepts the language: a*, q 1 Prof. Busch - SU 23
Time 0 a a a, q 1 Prof. Busch - SU 24
Time 1 a a a, q 1 Prof. Busch - SU 25
Time 2 a a a, q 1 Prof. Busch - SU 26
Time 3 a a a, q 1 Prof. Busch - SU 27
Time 4 a a a q 1 Halt & Accept, q 1 Prof. Busch - SU 28
ejection Example Time 0 a b a, q 1 Prof. Busch - SU 29
Time 1 a b a No possible Transition Halt & eject, q 1 Prof. Busch - SU 30
A simpler machine for same language but for input alphabet Σ = {a } Accepts the language: a* Prof. Busch - SU 31
Time 0 a a a Halt & Accept Not necessary to scan input Prof. Busch - SU 32
Infinite oop Example A Turing machine for language a * + b( a + b) * b b,, q 1 Prof. Busch - SU 33
Time 0 a b a b b,, q 1 Prof. Busch - SU 34
Time 1 a b a b b,, q 1 Prof. Busch - SU 35
Time 2 a b a b b,, q 1 Prof. Busch - SU 36
Time 2 a b a Time 3 Time 4 Time 5 a b a a b a a b a Infinite loop Prof. Busch - SU 37
Because of the infinite loop: The accepting state cannot be reached The machine never halts The input string is rejected Prof. Busch - SU 38
Another Turing Machine Example n n Turing machine for the language { a b } n 1 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 39
Basic Idea: Match a s with b s: epeat: replace leftmost a with x find leftmost b and replace it with y Until there are no more a s or b s If there is a remaining a or b reject Prof. Busch - SU 40
Time 0 a a b b q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 41
Time 1 x a b b q 1 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 42
Time 2 x a b b q 1 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 43
Time 3 x a y b q 2 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 44
Time 4 x a y b q 2 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 45
Time 5 x a y b q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 46
Time 6 x x y b q 1 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 47
Time 7 x x y b q 1 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 48
Time 8 x x y y q 2 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 49
Time 9 x x y y q 2 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 50
Time 10 x x y y q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 51
Time 11 x x y y q 3 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 52
Time 12 x x y y q 3 q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 53
Time 13 x x y y q 4 Halt & Accept q 4, q 3 a x, q0 1 b y, q q2 x x, Prof. Busch - SU 54
Observation: If we modify the machine for the language n n { a b } we can easily construct a machine for the language { a b c } n n n Prof. Busch - SU 55
Formal Definitions for Turing Machines Prof. Busch - SU 56
Transition Function q a b, q2 1 δ ( 2 q 1, a) = ( q, b, ) Prof. Busch - SU 57
Transition Function q c d, q2 1 δ ( 2 q 1, c) = ( q, d, ) Prof. Busch - SU 58
Turing Machine: States Input alphabet Tape alphabet M = ( Q, Σ, Γ, δ, q0,, F) Transition function Initial state Accept states blank Prof. Busch - SU 59
Configuration c a b a q 1 Instantaneous description: ca q 1 ba Prof. Busch - SU 60
Time 4 Time 5 x a y b x a y b q 2 A Move: q2 xayb x q0 ayb (yields in one mode) Prof. Busch - SU 61
Time 4 Time 5 x a y b x a y b q 2 Time 6 Time 7 x x y b x x y b q 1 A computation q 2 xayb x q0 ayb xx q1 yb xxy q 1 q 1 b Prof. Busch - SU 62
q 2 xayb x q0 ayb xx q1 yb xxy q 1 b Equivalent notation: q2 xayb xxy q1 b Prof. Busch - SU 63
Initial configuration: w Input string w a a b b Prof. Busch - SU 64
The Accepted anguage For any Turing Machine M ( M ) = { w : q0 w x1 q f x 2 } Initial state Accept state Prof. Busch - SU 65
If a language by a Turing machine then we say that is accepted M is: Turing ecognizable Other names used: Turing Acceptable ecursively Enumerable Prof. Busch - SU 66