0% found this document useful (0 votes)
45 views

Turingmachines 120327094202 Phpapp02

- Turing machines are a simple mathematical model of a general purpose computer invented by Alan Turing in 1936. - A Turing machine has a tape divided into cells, a head that can read and write symbols on the tape, finite states, and transition rules determining the head's behavior based on the current state and symbol. - Turing machines can simulate any algorithm and are capable of performing any calculation that can be performed by a real-world computer.
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)
45 views

Turingmachines 120327094202 Phpapp02

- Turing machines are a simple mathematical model of a general purpose computer invented by Alan Turing in 1936. - A Turing machine has a tape divided into cells, a head that can read and write symbols on the tape, finite states, and transition rules determining the head's behavior based on the current state and symbol. - Turing machines can simulate any algorithm and are capable of performing any calculation that can be performed by a real-world computer.
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/ 71

Turing Machines

• Invented by Alan Turing in 1936.

• A simple mathematical model of a


general purpose computer.

• It is capable of performing any calculation


which can be performed by any
computing machine.
The Language Hierarchy

n n n
a b c ? ww ?

Context-Free Languages

a nb n
R
ww
Regular Languages
a a*b
* *
Languages accepted by
Turing Machines
n n
a b c n
ww
Context-Free Languages

a nb n
R
ww NDPA

Regular Languages
Finite
a a*b Automata
* *
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 perform the


following steps:

1. Reads a symbol
2. Writes a symbol
3. Moves Left or Right
Example:
Time 0
...... a b a c ......

Time 1
...... a b k c ......

1. Reads a

2. Writes k
Time 1
...... a b k c ......

Time 2
...... a f k c ......

1. Reads
b f
2.
3. Writes
Moves Right
The Input String
Input string Blank symbol

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

head
Head starts at the leftmost position
of the input string
Are treated as left and right brackets for the
input written on the tape.
States & Transitions
Read Write
Move Left

a b,
q1 q2
L

Move Right

a b,
q1 q2
R
Example:
Time 1
...... a b a c ......

q1
curren
t state

a b,
q1 q2
R
Time 1
...... a b a c ......

q1

...... Time 2 ......


a b b c

q2
a b,
q1 q2
R
Example:
Time 1
...... a b a c ......

q1

...... Time ......


a b2 b c

q2
a b,
q1 q2
L
Example:
Time 1
...... a b a c ......

q1

Time 2
...... a b b c g ......

q2
g,
q1 q2
R
Determinism
Turing Machines are deterministic

Allowed Not
Allowed
a b, R q2 q2
a b, R
q1 q1
b d, q3 a d, q3
L L
No lambda transitions allowed
Partial Transition Function
Example:

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

q1

a b, Allowed:
q2
R No transition
q1
for input symbol c
b d, q3
Halting

The machine halts if there are


no possible transitions to follow
Example:

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

q1

a b, q2
R No possible transition
q1
HALT!!!
b d, q3
Final States
q1 q2 Allowed

q1 q2 Not
Allowed

• Final states have no outgoing transitions

• In a final state the machine halts


Acceptance
If machine halts
Accept Input
in a final state

If machine halts
in a non-final state
Reject Input or
If machine enters
an infinite loop
Turing Machine Example
A Turing machine that accepts the language:
aa *

a a, R

q0 ,
q
L
1
Time 0 a a a

q0

a a,
R

q0 ,
q
L
1
Time 1 a a a

q0

a a,
R

q0 ,
q
L
1
Time 2 a a a

q0

a a,
R

q0 ,
q
L
1
Time 3 a a a

q0

a a,
R

q0 ,
q
L
1
Time 4 a a a

q1

a a, Halt & Accept


R

q0 ,
q
L
1
Rejection Example

Time 0 a b a

q0

a, qR ,
0 q
L
1
Time 1 a b a

q0

No possible Transition
a a, Halt & Reject
R

q0 ,
q
L
1
Infinite Loop Example

b b,
L
a a,
R ,
q0 q
L
1
Time 0 a b a

q0

b b, L
a a, R

q0 ,
q
L
1
Time 1 a b a

q0

b b, L
a a, R

q0 ,
q
L
1
Time 2 a b a

q0

b b, L
a a, R

q0 ,
q
L
1
Time 2 a b a

q0
Time 3 a b a

q0
Time 4 a b a

q0
Time 5 a b a

... Infinite Loop q0


Because of the infinite loop:

• The final state cannot be reached

•The machine never halts

•The input is not accepted


Another Turing Machine
Example
n n
Turing machine for the language {a b }

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 0 a a b b

q0

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 1 x a b b

q1

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 2 x a b b

q1

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 3 x a y b

q2

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 4 x a y b

q2

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 5 x a y b

q0

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 6 x x y b

q1

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 7 x x y b

q1

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 8 x x y y

q2

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 9 x x y y

q2

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 10 x x y y

q0

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 11 x x y y

q3

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 12 x x y y

q3

q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Time 13 x x y y

q4

Halt & Accept


q4 y y, y y,
y y, R L
R ,
a a, R a a,
y, R q aL
q3 y 0 x, b y,L q
q 2
R L
1
x x,
Observation:

If we modify the
machine for the language n n
{a b }

we can easily construct


a machine for the language n n n
{a b c }
Formal Definitions
for
Turing Machines
Transition Function

c d,
q1 L q2

(q1,c) (q2 , d,
L)
Turing Machine:
Input Tape
alphabet alphabet
States

M (Q, , , , q0 , , F )

A partial
Final
Transition
states
function Initial
Blank : a special symbol
state Of
Configuration
c a b a

q1

Instantaneous description: ca q1 ba
Time 4 Time 5
x a y b x a y b

q2 q0

A Move: q2 xayb  x q0
ayb
Time 4 Time 5
x a y b x a y b

q2 q0

Time 6 Time 7
x x y b x x y b

q1 q1

q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b


Equivalent notation

q2 xayb  x q0 ayb  xx q1 yb  xxy q1


b

Equivalent notation: q2 xayb  xxy q1 b


Initial configuration: q0 w

Input string

w
a a b b

q0
The Accepted Language
For any Turing Machine M

L(M {w : q0 w  x1 q f x2}
)

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


Design a Turing machine to recognize all
strings in which 010 is present as a
substring. 0,0,R

0,0,R 1,1,R 0,0,R


q0 q1 q2 H

1,1,R
1,1, R
DFA for the previous language
0

0 1 0
q0 q1 q2

1
1

0,1
Turing machine for odd no of 1’s

1, 1 , R
1, b , R

1, b , R
Recursively Enumerable
and
Recursive

Languages
Definition:
A language is recursively
enumerable
if some Turing machine accepts it
Let L be a recursively enumerable language

and M the Turing Machine that accepts it

For string w :

if w L then M halts in a final state

L then M halts in a non-final state


if w
or loops forever
Definition:
A language is recursive
if some Turing machine accepts it
and halts on any input string

In other words:
A language is recursive if there is
a membership algorithm for it
Let L be a recursive language

and M the Turing Machine that accepts it

For string w :

if w L then M halts in a final state


L
if w then M halts in a non-final state
We will prove:

1. There is a specific language


which is not recursively enumerable
(not accepted by any Turing Machine)

2. There is a specific language


which is recursively enumerable
but not recursive
Non Recursively Enumerable

Recursively Enumerable

Recursive

You might also like