Sie sind auf Seite 1von 30

# CSC3113

Theory Of Computation

Computability Theory
Computability
Introduction

Turing Machine
TM-computable/recognizable languages
Variants of TMs
Nondeterministic TMs
Robustness of the Turing model

Mashiour Rahman
Assistant Professor
Computer Science Department

Turing Machines

Alan M. Turing
(19121954)
In 1936, Turing introduced his abstract model for
computation in is article On Computable Numbers,
with an application to the Entscheidungsproblem.
At the same time, Alonzo Church published
similar ideas and results.
However, the Turing model has become the
standard model in theoretical computer science.
CSC3113 Theory Of

Mashiour

Turing Machine 2

Informal Description TM
1 0 1 1 _

0 # 1 _

internal
state set Q

_ At every step,

letter xi from the
one-way infinite
tape.

## Depending on its state and the letter xi, the TM

- writes down a letter,
- jumps to a new state.
CSC3113 Theory Of

Mashiour

Turing Machine 3

Input Convention
w1 w2 wn

state q0

## Initially, the tape contains the input

and the TM is in start state q0.

## During the computation, the head moves left

and right (but not beyond the leftmost point),
the internal state of the machine changes,
and the content of the tape is rewritten.
CSC3113 Theory Of

Mashiour

Turing Machine 4

TURING MACHINE
FINITE
STATE
qq01
CONTROL

AI

INFINITE TAPE
CSC3113 Theory Of

Mashiour

Turing Machine 5

Output Convention
The computation can proceed indefinitely, or the
machines reaches one of the two halting states:
v1

v2 vm _

state qaccept

CSC3113 Theory Of

v1 v2 vm _

or

Mashiour

state qreject

Turing Machine 6

Formal Definition
A Turing machine M is defined by a
7-tuple (Q,,,,q0,qA,qR), with
Q finite set of states
finite input alphabet (without _)
finite tape alphabet with { _ }
q0 start state Q
qA accept state Q
qR reject state Q
the transition function
: Q\{qA,qR} Q {L,R}
CSC3113 Theory Of

Mashiour

Turing Machine 7

## Testing membership in B = { w#w | w {0,1}* }

STATE
q1,FIND qGO LEFT
q0, FIND
q1,# FINDAnd
q0,FIND
# q#, FIND
SO ON

x
0
1

CSC3113 Theory Of

x
1

1
#

#
0

0x
1

Mashiour

Turing Machine 8

write

move
, R

0 0, R

qA

0 0, R
, R
qR

CSC3113 Theory Of

Mashiour

0 0, R
, L

Turing Machine 9

Configuration of a TM
The configuration of a Turing machine consists of
the current state q Q
the current tape contents *

## This can be expressed as an element of *Q*:

1 0 1 1 _

q9
CSC3113 Theory Of

0 # 1 _

## becomes 101 q9 1_0#1

Mashiour

Turing Machine 10

CONFIGURATIONS

11010q700110
q7

CSC3113 Theory Of

Mashiour

Turing Machine 11

An Elementary TM Step
Let,
u,v * ;
a,b,c ;
qi,qjQ, and
M be a TM with transition function .

## We say that the configuration uaqibv yields

the configuration uacqjb if and only if:
(qi,b) = (qj,c,R).
Similarly, uaqibv yields uqjacb if and only if
(qi,b) = (qj,c,L).
CSC3113 Theory Of

Mashiour

Turing Machine 12

Terminology
starting configuration on input w: q0w
accepting configuration: uqAv
rejecting configuration: uqRv
The accepting and rejecting configurations
are the halting configurations.

CSC3113 Theory Of

Mashiour

Turing Machine 13

Accepting TMs
A Turing machine M accepts input w* if and only if
there is a finite sequence of configurations C1,C2,
,Ck with
C1 the starting configuration q0w
for all i=1,,k1 Ci yields Ci+1 (following Ms )
Ck is an accepting configuration uqAv

## The language that consists of all inputs that are

accepted by M is denoted by L(M).

CSC3113 Theory Of

Mashiour

Turing Machine 14

Turing Recognizable
A language L is Turing-recognizable if and
only if there is a TM M such that L=L(M).
Also called: a recursively enumerable
language.
Note: On an input wL, the machine M can
halt in a rejecting state, or it can loop
indefinitely.
How do you distinguish between a very
long computation and one that will never
halt?
CSC3113 Theory Of

Mashiour

Turing Machine 15

Turing Decidable
A language L = L(M) is decided by the TM M if
on every w, the TM finishes in a halting
configuration.
That is - qA for all wL and qR for all wL.
A language L is Turing-decidable if and only
if there is a TM M that decides L.
Also called: a recursive language.

CSC3113 Theory Of

Mashiour

Turing Machine 16

Example A = { 0j | j=2n }
Approach:
If j=0 then reject;
If j=1 then accept;
if j is even then divide by two;
if j is odd and j >1then reject.
Repeat if necessary.
Steps:
1.
2.
3.
4.
5.

## Check if j=0 or j=1, accept/reject accordingly

Check, by going left to right if the string has even or odd number
of zeros
If odd then reject
If even then go back left, erasing half the zeros
goto step 1

CSC3113 Theory Of

Mashiour

Turing Machine 17

## State diagrams of TMs

Like with PDA, we can represent Turing machines
by (elaborate) diagrams.

## If transition rule says: (qi,b) = (qj,c,R),

then:
b c,R
qi
qj

CSC3113 Theory Of

Mashiour

Turing Machine 18

x x, L
0 0, L

{0 |n0}

q2
, R

, L

x x, R
q0

x x, R
q1

0 , R

x x, R
, R

qR

, R

q3

0 x, R
0 x, R

qA

q4
, R

CSC3113 Theory Of

0 0, R

Mashiour

x x, R

Turing Machine 19

x x, L
q 0000
0 0 0, L

{0 |n0}

xq 00

, R

, 3L

x x, R
q0

x0qx4
0 x, R
q1

0 , R

x x, R
, R

qR

q1000

q2

, R

x0xq3
q3

0 x, R

x0q2x

0 x, R

qA

xq
0x0, R
0 2
q2x0x
qq24x0x

q1x0x
x x, R
q
x0x
, R A
CSC3113 Theory Of

Mashiour

Turing Machine 20

C = {aibjck | ij = k and i, j, k 1}

aabbbcccccc
xabbbcccccc
xayyyzzzccc
xabbbzzzccc
xxyyyzzzzzz
CSC3113 Theory Of

Mashiour

Turing Machine 21

## Multitape Turing Machines

A k-tape Turing machine M has k different tapes and read/write
by the 7-tuple (Q,,,,q0,qA,qR), with
Q finite set of states
finite input alphabet (without _)
finite tape alphabet with { _ }
q0 start state Q
qA accept state Q
qR reject state Q
the transition function
: Q\{qA,qR} k Q k {L,R}k
CSC3113 Theory Of

Mashiour

Turing Machine 22

## MULTITAPE TURING MACHINES

FINITE
STATE
CONTROL

: Q k Q k {L,R}k
CSC3113 Theory Of

Mashiour

Turing Machine 23

## Theorem: Every Multitape Turing Machine can be

transformed into a single tape Turing Machine
1

FINITE
STATE
CONTROL

FINITE
STATE
CONTROL
CSC3113 Theory Of

Mashiour

#
Turing Machine 24

## k-tape TMs versus 1-tape TMs

Theorem: For every multi-tape TM M, there
is a single-tape TM M such that L(M)=L(M).
Or, for every multi-tape TM M, there is an
equivalent single-tape TM M.
Proving and understanding these kinds of
robustness results, is essential for
appreciating the power of the Turing machine
model.
From this theorem Corollary follows:
A language L is TM-recognizable if and only if
some multi-tape TM recognizes L.
CSC3113 Theory Of

Mashiour

Turing Machine 25

Nondeterministic TMs
A nondeterministic Turing machine M can have several
options at every step. It is defined by
the 7-tuple (Q,,,,q0,qA,qR), with
Q finite set of states
finite input alphabet (without _)
finite tape alphabet with { _ }
q0 start state Q
qA accept state Q
qR reject state Q
the transition function
: Q\{qA,qR} P (Q {L,R})
CSC3113 Theory Of

Mashiour

Turing Machine 26

Robustness
Just like k-tape TMs, nondeterministic Turing
machines are not more powerful than simple
TMs:
Every nondeterministic TM has an equivalent
3-tape Turing machine, which in turn has
an equivalent 1-tape Turing machine.
Hence: A language L is recognizable if and
only if some nondeterministic TM recognizes
it.
The Turing machine model is extremely robust.
CSC3113 Theory Of

Mashiour

Turing Machine 27

## Computing with Nondeterministic TMs

Evolution of the n.d. TM
represented by a tree
of configurations (rather
than a single path).

C1
C2

## If there is (at least)

one accepting leave, C
5
then the TM accepts.

t=1
C4 t=2

C3

t=3
C6

reject

accept

CSC3113 Theory Of

Mashiour

Turing Machine 28

## Simulating Nondeterministic TMs with

Deterministic Ones
We want to search every path down the tree
for accepting configurations.
Bad idea: depth first. This approach can get
lost in never-halting paths.
Good idea: breadth first. For time step 1,2,

we list all possible configurations of the nondeterministic TM. The simulating TM accepts
when it lists an accepting configuration.
CSC3113 Theory Of

Mashiour

Turing Machine 29

Let b be the maximum number
of children of a node.
C2
Any node in the tree can
be uniquely identified by
a string {1,,b}*.
C5 C

## Example: location of the

rejecting configuration is (3,1).

C1

t=1
C4 t=2

C3

reject

t=3

accept

## With the lexicographical listing , (1), (2),, (b), (1,1),

(1,2),,(1,b), (2,1), et cetera, we cover all nodes.
CSC3113 Theory Of

Mashiour

Turing Machine 30