0% found this document useful (0 votes)
55 views49 pages

FL 5

This document summarizes the key concepts of a Turing machine. A Turing machine consists of an infinite tape divided into cells, a head that reads and writes symbols on the tape, finite states, and transition rules. The transition rules specify the symbol to write, head movement, and next state based on the current symbol and state. A Turing machine either accepts by halting in an accepting state, rejects by halting in a non-accepting state, or enters an infinite loop. Examples demonstrate how Turing machines operate on input strings and determine acceptance, rejection, or non-halting via infinite looping.

Uploaded by

eyobeshete16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views49 pages

FL 5

This document summarizes the key concepts of a Turing machine. A Turing machine consists of an infinite tape divided into cells, a head that reads and writes symbols on the tape, finite states, and transition rules. The transition rules specify the symbol to write, head movement, and next state based on the current symbol and state. A Turing machine either accepts by halting in an accepting state, rejects by halting in a non-accepting state, or enters an infinite loop. Examples demonstrate how Turing machines operate on input strings and determine acceptance, rejection, or non-halting via infinite looping.

Uploaded by

eyobeshete16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Chapter 5

Turing Machine

1
Alan Turing -- 1912 – 1954
• Founder of computer science, mathematician,
philosopher, codebreaker, strange visionary and
a gay man before his time.

• Influential
• 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?

• http://www.turing.org.uk/turing/

2
A Turing Machine

10 01 1 1
0 1 1 1 1 1 1 0 1 1 0 1 1 0 0 0

• 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. 3
A Turing Machine…
Tape - No boundaries -- infinite length

...... ......

Read-Write head - The head moves Left or Right


• The head at each transition
Control Unit (time step):
1. Reads a symbol
2. Writes a symbol
3. Moves Left or Right

4
Example: Time 0

...... ......
a b a c

Time 1

...... ......
a b k c

1. Reads a
2. Writes
k
3. Moves Left
5
Time 1

...... ......
a b k c

Time 2

...... ......
a f k c

1. Reads
b
2. Writes
f
3. Moves Right
6
The Input String

Input string Blank symbol

...... ......
  a b a c   

head

Head starts at the leftmost position


of the input string

7
States & Transitions
Write
Read Move Left

q1 a  b, L q2

Move Right

q1 a  b, R q2
8
Example:
Time 1

...... ......
  a b a c   

q1
current state

q1 a  b, R q2
9
Time 1

...... ......
  a b a c   

q1
Time 2
...... ......
  a b b c   

q2

q1 a  b, R q2
10
Example: Time 1

...... ......
  a b a c   

q1
Time 2
...... ......
  a b b c   

q2

q1 a  b, L q2
11
Example: Time 1

...... ......
  a b a c   

q1
Time 2

...... ......
  a b b c g  

q2

q1   g, R q2
12
A Turing Machine…
• Turing Machines are deterministic

Allowed
Not Allowed
a  b, R q2 a  b, R q2

q1 q1
q3 a  d, L q3
b  d, L

No lambda transitions allowed

13
Partial Transition Function
Example:
...... ......
  a b a c   

q1
Allowed:
a  b, R q2
No transition
q1 for input symbol c
b  d, L q3
14
Halting
• The machine halts in a state if there is no transition to follow.

...... ......
  a b a c   

q1

No transition from q1
q1
HALT!!!

15
Halting…
Example
...... ......
  a b a c   

q1

a  b, R q2
No possible transition
q
from 1 and symbol c
q1
b  d, L q3 HALT!!!

16
Accepting States

q1 q2 Allowed

q1 q2 Not Allowed

• Accepting states have no outgoing transitions.


• The machine halts and accepts.

17
Acceptance…
Accept Input string If machine halts
in an accept state

If machine halts
in a non-accept state
Reject Input string or
If machine enters
an infinite loop

18
A Turing Machine… Example

Input alphabet   {a , b }

Accepts the language:


a*
a  a, R

  , L
q0 q1

19
Time 0
  a a a  

q0

a  a, R

  , L
q0 q1

20
Time 1
  a a a  

q0

a  a, R

  , L
q0 q1

21
Time 2
  a a a  

q0

a  a, R

  , L
q0 q1

22
Time 3
  a a a  

q0

a  a, R

  , L
q0 q1

23
Time 4
  a a a  

q1

a  a, R Halt & Accept

  , L
q0 q1

24
Rejection Example

Time 0
  a b a  

q0

a  a, R

  , L
q0 q1
25
Rejection Example…

Time 1
  a b a  

q0
No possible Transition

Halt & Reject


a  a, R

  , L
q0 q1
26
Infinite Loop Example

A Turing machine for language a * b( a  b) *

b  b, L
a  a, R

  , L
q0 q1

27
Time 0
  a b a  

q0

b  b, L
a  a, R

  , L
q0 q1

28
Time 1
  a b a  

q0

b  b, L
a  a, R

  , L
q0 q1

29
Time 2
  a b a  

q0

b  b, L
a  a, R

  , L
q0 q1

30
Time 2
  a b a  
q0
Time 3
  a b a  

Infinite loop
q0
Time 4
  a b a  
q0
Time 5
  a b a  
q0 31
Infinite Loop….
Because of the infinite loop:

• The accepting state cannot be reached.

• The machine never halts .

• The input string is rejected.

32
A Turing Machine… Example

n n
Turing machine for the language: {a b }
n 1

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L

y  y , R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 33
A Turing Machine… Example

Basic Idea: Algorithm


Match a’s with b’s:
Repeat:
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

34
Time 0
 a a b b  

q0

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 35
Time 1
 x a b b  

q1

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 36
Time 2
 x a b b  

q1

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 37
Time 3
 x a y b  

q2

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 38
Time 4
 x a y b  

q2

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 39
Time 5
 x a y b  

q0

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 40
Time 6
 x x y b  

q1

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 41
Time 7
 x x y b  

q1

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 42
Time 8
 x x y y  

q2

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 43
Time 9
 x x y y  

q2

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 44
Time 10
 x x y y  

q0

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 45
Time 11
 x x y y  

q3

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 46
Time 12
 x x y y  

q3

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 47
Time 13
 x x y y  

q4
Halt & Accept

q4 y  y, R y  y, L
y  y, R a  a, R a  a, L
  , L
y  y, R a  x, R b  y, L
q3 q0 q1 q2
x  x, R 48
A Turing Machine: Formal Definition
Input Tape
alphabet alphabet

States

M  (Q, , ,  , q0 , , F )

Transition Accept
function states

Initial
blank
state

49

You might also like