Você está na página 1de 32

The Church-Turing Thesis

Chapter 3
Giorgi Japaridze
Theory of Computability
Components of a Turing machine (TM)
3.1.a
Giorgi Japaridze Theory of Computability



(Q,E,I,o,start,accept,reject)
Q is the set of states
E is the input alphabet not containing the blank symbol -
I is the tape alphabet, where -eI and E_I
o is the transition function of the type QI QI{L,R}
start,accept,reject eQ, where reject=accept; the states
accept and reject are called halting states.
There are no transitions from the halting states, and they immediately take effect!
xy,R
q1 q2
If the current tape symbol is x, replace it with y, move the head right and go to
q2. The label xx,R is simply written as xR.
If we here have L instead of R, then the head is moved left, unless it was on the
first cell, in which case it remains where it was.
a a b a b b - - - - - -
How a Turing machine works
3.1.b
Giorgi Japaridze Theory of Computability


0x,R
q2 q3
start
accept
q4
q5
reject
0 -,R
- R
x R
- R
0R
0 x,R
- R
- L
0 L
x L
xR
xR
xR
- R
- x 0 0 - - - - - - -
Configuration:
1. Current state;
2. Tape contents;
3. Head position
Definitions
3.1.c1
Giorgi Japaridze Theory of Computability


A TM accepts an input string iff, on this input, sooner or later it enters
the accept state.
Otherwise the string is considered rejected.
Thus, the input is rejected in two cases:
1) The machine enters the reject state at some point, or
2) The machine never halts (never enters a halting state).
A Turing machine is said to be a decider iff it halts on every input.
The language recognized by a TM --- the set the strings that TM accepts;
If this machine is a decider, then we say that it not only recognizes,
but also decides that language.
A language is said to be Turing-recognizable iff some TM recognizes it.
A language is said to be Turing-decidable iff some TM decides it.
Recognizing vs deciding
3.1.c2
Giorgi Japaridze Theory of Computability


accept
reject
0 R - R
- R
0 R
- R
0 R
What language does the above machine recognize?
Does it decide that language?
accept
reject
0 R - R
- R
0 R
What language does the above machine recognize?
Does it decide that language?
Diagrams without the reject state
3.1.d
Giorgi Japaridze Theory of Computability


0x,R
q2 q3
start
accept
q4
q5
0 -,R
- R
0R 0 x,R
- R - L
0 L
x L
xR
xR
xR
The reject state can be safely removed.
It will be understood that all the missing transitions lead to the reject state.
Designing TM: Example 1
3.1.e1
Giorgi Japaridze Theory of Computability


Design a TM that recognizes (better decides) {#
n
=
m
| n=m}
1. Sweep left to right across the tape, testing if the input has the form
#
*
=
*
; if not, reject; if yes, go back to the beginning of the tape
and go to step 2 (state q3).

start
q1
R
# R = R
q2
- L
q9
R
L
= L
x L
- L
q3
# L
Designing TM: Example 1
3.1.e2
Giorgi Japaridze Theory of Computability


2. Keep going to the right, replace the first you see before = with
x and go to step 3 (state q5);
if you reach = without seeing a , go to step 4 (state q6).
q3
q4
xR
# R
x,R
q5
q6
= R
Designing TM: Example 1
3.1.e3
Giorgi Japaridze Theory of Computability


3. Keep going to the right, pass = and then replace the first you see
with x and go to the beginning of the tape, step 2 (this can be
done by going to state q9);
if you reach a blank without seeing a , reject.
q5
q7
R
= R
x,R
q9
xR
Designing TM: Example 1
3.1.e4
Giorgi Japaridze Theory of Computability


4. Keep going to the right as long as you see x. If you see a before
reaching a blank, reject; otherwise accept.
q6
accept
xR
- R
Designing TM: Example 1
3.1.e5
Giorgi Japaridze Theory of Computability


start
q1
R
# R = R
q2
- L
q9
R
L
= L
x L
- L
q3
# L
q4
xR
# R
x,R
q5
= R
q7
= R
x,R
q6
accept
xR
- R
# =
- - -
R
xR
Designing TM: Example 2
3.1.f
Giorgi Japaridze Theory of Computability


start
q1
R
# R < R
q2
- L
q9
R
L
< L
x L
q3
# L
q4
xR
# R
x,R
q5
< R
q7
< R
x,R
q6
accept
xR
R
Design a TM that decides {#
n
<
m
| n<m}
R
xR
L
< L
x L
- L
Designing TM: Example 3
3.1.g
Giorgi Japaridze Theory of Computability


start q1
R
+ R = R
q2
- L
q9
R
+ L
L
= L
x L
- L
q3
# L
q4
xR
+R
# R
x,R
q5
= R
q7
= R
x,R
q6
accept
xR
- R
R
+R
xR
Design a TM that decides {#
n
+
m
=
k
| n+m=k}
q0
# R
R
Designing TM: Example 4
3.1.h
Giorgi Japaridze Theory of Computability


Design a TM that decides {#
n

m
=
k
| nm=k}
Step 1: Check if the string has the form #
*

*
=
*
. If not, reject;
If yes, go back to the beginning of the tape, step 2.
= # -
Step 2: Find the first between # and , delete it and go to step 3;
If no such was found, go to step 5.
Step 3: Find the first between and =, delete it and go to step 4;
If no such was found, go to the beginning of the tape, restoring on
the way back all the deleted between and =, and go to step 2.
Step 4: Find the first after =, delete it, go back to , and go to step 3;
If no such was found before seeing a blank, reject.
Step 5: Go right past = ; if no is found there before reaching a blank,
accept; otherwise reject.
Testing whether the head is at the beginning of the tape
3.1.i
Giorgi Japaridze Theory of Computability


Tape alphabet: {x
1
,,x
n
} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;
2. Read the current symbol.
If it is $, restore the remembered symbol and go to Yes.
If it is not $, move right, restore the remembered symbol and go to No.
Beg?
x
1
$,L
$ x
1
,L
a
1

x
1
,,x
n
R
Yes
x
1
,R

L

No
b
1

Temp
Design a fragment of a TM that, from a state Beg?, goes to a state Yes or No,
depending on whether you are at the beginning of the tape or not,
without corrupting the contents of the tape.
a
n

x
1
,,x
n
R
b
n

$ x
n
,L
x
n
$,L
x
n
,R


Implementing the go to the beginning of the tape operation
3.1.j
Giorgi Japaridze Theory of Computability


Go to the beginning Beg?
No
Yes
Done
Design a fragment of a TM that, from a state Go to the beginning,
goes to the beginning of the tape and state Done.
Move left and test if you are at the beginning of the tape.
If yes, go to Done.
If not, repeat the step.
Shifting tape contents
3.1.k
Giorgi Japaridze Theory of Computability


Shift Done
Design a fragment of a TM that types 0 in the current cell and shifts the
(old) contents of the remaining tape one cell to the right.
Assume the tape alphabet is {0,1,-}.
1. Read the current symbol, remember it, type 0 and move right.
2. While the current symbol is not -, remember it, type the
previously remembered symbol and move right.
3. Once you see a blank, type
the remembered symbol
and you are done.
A TM for the element distinctness problem
3.1.l
Giorgi Japaridze Theory of Computability


0

1

#

1

#

0

1

0

#

1

0

#

1

0

-

x
1
x
2
x
3
x
4
See page 135 for a description of such a TM
Design a TM that decides the language
E={#x
1
#x
2
##x
n
| each x
i
e{0,1} and x
i
=x
j
for each i=j}
# x
1
# x
2
# x
3
# x
4
#

x
5
Turing machines with the stay put option
3.2.a
Giorgi Japaridze Theory of Computability



A transition of this type of machine may have either L (move left),
Or R (move right), or S (stay put).
ab,S
Replace a with b and go to state q2 without moving the head
This does not increase the power of the machine, because the above
transition can be simulated with the ordinary TM as follows:
q1 q2
Multitape Turing machines
3.2.b
Giorgi Japaridze Theory of Computability



A multitape TM has k tapes, each with its own read/write had.
Initially, the input is written on the first tape, and all the other tapes
are blank, with each head at the beginning of the corresponding tape.

For a 3-tape TM, a transition will look like
0,1,11,0,1,R,R,L
q1 q2
If you are in state q1 and see 0 on Tape
1
, 1 on Tape
2
and 1 on Tape
3
,
type 1 on Tape1, 0 on Tape2 and 1 on Tape3;
move Head
1
right, Head
2
right and Head
3
left;
go to state q2.
Multitape Turing machines: Example
3.2.c
Giorgi Japaridze Theory of Computability



Design a fragment of a 2-tape TM that swaps the contents of the tapes,
from the position where the heads are at the beginning and there are
no blanks followed by non-blank symbols. Tape alphabet: {0,1,-}
0,00,0,R,R
0,11,0,R,R
0,- -,0,R,R
1,00,1,R,R
1,11,1,R,R
1,- -,1,R,R
-,00,-,R,R
-,11,-,R,R
Swap
Done
-,- - ,-,L,L
Tape
1



Tape
2

1 1 0 -
0 0 - -
Simulating multitape TM with ordinary TM
3.2.d
Giorgi Japaridze Theory of Computability



Theorem 3.13: Every multitape TM M has an equivalent single-tape TM S.
Tape
1


M: Tape
2

Tape
3



S:
0 0 1 -
- - - -
Proof idea: The tape contents and the head positions of M can be
represented on the single tape of S and correspondingly updated as
shown on the following example for a 3-tape M; S follows the steps of
M and accepts iff M accepts.
- - - -
# 0 0 1

- # - # #
q0
- - - - - -
. . .
Nondeterministic Turing machines
3.2.e
Giorgi Japaridze Theory of Computability



A nondeterministic TM is allowed to have more than 1 transition
for a given tape symbol:






A string is accepted, if one of the branches of computation takes us
to the accept state.
ab,R
ac,L
q2
q1
q3
Theorem 3.16: Every nondeterministic TM has an equivalent
deterministic TM.
Proof omitted. Idea: Simulate every possible branch of computation
in a breadth-first manner.
Turing machines with an output
(not in the textbook!)
3.2.f
Giorgi Japaridze Theory of Computability



The only difference with ordinary TM is that a TM with an output
(TMO) has a state halt instead of accept and reject; if and when such a
machine reaches the halt state, the contents of the tape (up to the first
blank cell) will be considered its output.
Example: Design a machine that, for every input w, returns w0.
Computable functions
3.2.g
Giorgi Japaridze Theory of Computability


A function g: E* E* is said to be computable, iff there is a TMO
M such that for every input weE* M returns the output u with u=g(w).
In this case we say that M computes g.

The graph of a function g: E* E* is the language
{(w,u) | weE*, u=g(w)}

E.g., the graph of the above function f is
{(c,0), (0,00), (1,10), (00,000), (01,010), },
i.e.
{(w,u) | we{0,1}*, u=w0}
Example: Let f: {0,1}* {0,1}* be the function defined by
f(w)=w0,
so that f(c)=0, f(0)=00, f(1)=10, f(00)=000, f(01)=010, etc.
Then f is computable as we saw on the previous slide.
Computability vs. decidability
3.2.h
Giorgi Japaridze Theory of Computability


Theorem: A function is computable iff its graph is decidable.
Proof sketch. Let g: E* E* be a function.


(): Suppose C is a TMO that computes g. Construct a TM D that works as follows:

D = On input t:
1. If t does not have the form (w,u), where w,ueE*, then reject. Otherwise,
2. Simulate C for input w. If it returns u, accept; otherwise reject.
(:): Suppose a TM D decides the graph of g. Let s
1
,s
2
,s
3
, be the lexicographic list of
all strings over the alphabet E. Construct a TMO C that works as follows:

C =On input t:
Simulate D for each of the inputs (t,s
1
), (t,s
2
),(t,s
3
), until you find s
i

such that (t,s
i
) is accepted, and return this s
i

Algorithms
3.3.a
Giorgi Japaridze Theory of Computability



The intuitive notion of algorithms: An algorithm (procedure, recipe)
is a collection of simple instructions for carrying out some task.
We need a strict mathematical definition of an algorithm. The above
definition obviously does not qualify.
Examples:
The elementary school algorithms for adding, subtracting, multiplying,
etc.;
Converting an NFA to an equivalent DFA, or a RE to NFA, or an
NFA to RE, etc.;
Calculating students GPAs;
Sorting algorithms;
Any other procedures Dr. Levitin taught you.
To carry out an algorithm, you only need to mechanically (blindly)
follow its instructions. No understanding of the objects you are
manipulating, no understanding of what you are doing is needed!
Algorithms should deal with strings
3.3.b
Giorgi Japaridze Theory of Computability



The structure of an algorithm:

Input(s) Output
or
Input(s) Yes (accept) or No (reject)
The attempt to formalize the notion of algorithm should start from
strictly specifying what kind of objects can be inputs/outputs.
These are going to be only. strings
No loss of generality: non-string objects can be easily represented with
strings. A tuple of such objects can also be represented with a
(one single) string.
After all, computers exclusively deal with strings --- strings over the
alphabet {0,1} !
Encoding
3.3.c
Giorgi Japaridze Theory of Computability



Encoding numbers: 0,1,2,3,,34,, or 0,1,10,11,,100010,
Encoding pairs of numbers: (4,2), (1,3), , or 4#2, 1#3,, or aaabb, abbb,
Encoding --- representing objects as strings in some standard way.

There are usually many ways to encode; as one encoding can be
easily (algorithmically) converted into another, it does not matter
which encoding we choose.
Encoding people: David Stewart, Dongfei Wei, , or
Stewart, David, Wei, Dungfei, or 315-21-5541, 326-11-1521
Encoding assembly language instructions: Their machine language equivalents.
If O is an object, <O> will stand for a (the) encoding of O.
Encoding graphs
3.3.d
Giorgi Japaridze Theory of Computability



1
4 5
2 3
G =
<G> = (1,2,3,4,5)((1,4),(1,5),(2,3),(4,5))
Algorithm M for checking if a graph is connected:

M = On input <G>, the encoding of a graph G:
1. Select the first node of G and mark it.
2. Repeat the following stage until no new nodes are marked:
3. For each node in G, mark it if it is attached by an edge to a
node that is already marked.
4. Scan all the nodes of G to determine whether they all are
marked. If they are, accept; otherwise reject.
The Church-Turing thesis
3.3.e
Giorgi Japaridze Theory of Computability


(the intuitive notion of) Algorithm
=
Turing machine
The Church-Turing thesis:
It can never been mathematically proven!
Importance: Without the Church-Turing thesis, you can never prove
that a certain problem has no algorithmic solution.
Example - Hilberts 10th problem (see page 154).
The three levels of TM descriptions
3.3.f
Giorgi Japaridze Theory of Computability


1. Formal description:
The TM is fully described, say, by giving a
transition diagram, or
list of states, input/tape alphabets, a table for the transition function.
Examples: Slides 3.1.b, 3.1.f, etc.
2. Implementation description:
English is used to describe the way that the machine moves its
head and stores data on its tape. Details of states or transition
functions are not given.
Example: Slide 3.1.h
3. High-level description:
English is used to describe the algorithm, without worrying about
implementation-level details. There is no mention of head, tape etc.
Example: Slide 3.3d;
All the algorithms taught in CSC 8301

Você também pode gostar