Ch03 Handout
Ch03 Handout
Chapter 3
The Church-Turing Thesis
Section 3.1: Turing Machines
Courtesy of Arthur G. Werschulz
Fordham University
Department of Computer and Information Sciences
Spring, 2014
1 / 48 2 / 48
3 / 48 4 / 48
What is a Turing machine? Turing machine
Informal description
I Contains an infinite tape
I Tape initially contains the input string, with blanks
everywhere else.
I Machine can read and write from tape, and move left or right
Control
after each action.
I The machine continues until it enters an accept state or a a b a b ...
reject state, at which point it immediately stops and outputs
accept or reject.
Very different from FSAs and PDAs.
I The machine can loop forever.
I Why can’t an FSA or PDA loop forever?
I Answer: FSA/PDA terminates when input string is fully
processed, taking only one “action” for each input symbol
processed.
5 / 48 6 / 48
7 / 48 8 / 48
Sample execution Formal definition of a Turing machine
9 / 48 10 / 48
11 / 48 12 / 48
Turing recognizable and decidable languages Turing machine: Example #2
n
I Design a TM M2 that decides A = { 02 : n ≥ 0 }, the
I The set of strings that a Turing machine M accepts is the language of all strings of 0s whose length is a power of two.
I Without designing it, do you think (intuitively) that this can
language of M, or the language recognized by M, be done? Why?
denoted L(M). I We could write a (C++, Java, Perl, . . . ) program to do this.
I Definitions: I Since a TM can do anything a computer can do, this can be
I A language is Turing recognizable (sometimes called done by a TM.
recursively enumerable) if some Turing machine recognizes it. I Solution? Basic idea: Divide by 2 each time and see whether
I A Turing machine that halts on all inputs is a decider. A remainder is 1: boxed
decider that recognizes a language decides it.
I A language is (Turing-) decidable (sometimes called recursive) while true do
if it is decided by some Turing machine. sweep left to right across the tape, crossing off every other 0;
I Notes: if tape has exactly one 0 then accept;
I Language is decidable if it’s Turing recognizable by a TM that ;
always halts, i.e., there is a decider for that language. if tape has an odd number of 0s then reject;
I Every decidable language is Turing-recognizable.
I It is possible for a TM to halt only on those strings it accepts.
return the head to the left-hand end of the tape;
;
end
13 / 48 14 / 48
15 / 48 16 / 48
Turing machine: Example #3 (cont’d) Transducers
19 / 48 20 / 48
Decidability
21 / 48 22 / 48
Variants of Turing machines TM variant #1: Let the head stay put
23 / 48 24 / 48
TM variant #2: Multi-tape TMs Proof of equivalence of variant #2
25 / 48 26 / 48
I On input of w = w1 w2 . . . wn , machine S will look like I Can add nondeterminism to Turing machines.
I Similar to what was done in adding nondeterminism to other
#w˙1 w2 . . . wn # ˙ # ˙ . . . # ˙ # models, e.g., moving from DFAs to NFAs: allow transition
function to choose a subset of states.
I To simulate a single move, S scans its tape from the first # to
the (k + 1)st #, to determine the symbols under the virtual I Transition function for deterministic TM is
heads. Then S makes a second pass to update the heads and δ : Q × Γ → Q × Γ × {L, R}.
contents, based on M’s transition function. I Nondeterministic Turing machine has transition function
I If at any point, S moves one of the virtual heads to the right δ : Q × Γ → P(Q × Γ × {L, R}).
of a #, this action means that M has moved the head to a I Computation of NDTM: tree whose branches correspond to
previously-unread blank portion of the tape. So S writes a different possibilities for the machine.
blank symbol onto this cell, and shifts everything to the right I If some branch of computation leads to accept state, the
on the tape one unit to the right. NDTM accepts its input.
27 / 48 28 / 48
TM variant #3: Nondeterministic TM (cont’d) Enumerators
29 / 48 30 / 48
I First direction: If enumerator E enumerates language A, then I Many TM variants proposed, some of which may appear very
different.
a TM M recognizes A.
I All have unlimited access to unlimited memory.
For every w generated by E , the TM M will run E (a TM) I All models with this feature turn out to be equivalent, under
and check to see if the output matches w . If it ever matches, reasonable assumptions (i.e., that one can only do a finite
then accept. amount of work in one step).
I Other direction: If a TM M recognizes a language A, we I Thus TMs are universal model of computation. The classes of
construct an enumerator E for AA as follows:
∗
algorithms are the same, independent of the specific model of
I Let s1 , s2 , s3 , . . . be the list of all possible strings in Σ .
I For i = 1, 2, . . . computation.
I Run M for i steps on each input s1 , s2 , . . . , si . I To get some insight, note that all programming languages are
I If any computation is accepted, then print corresponding sj . equivalent. For example, one can write a compiler for any
I Loop over i implements a breadth-first search, which language in any other language (assuming basic constructs are
eventually generates everything without getting stuck. available).
31 / 48 32 / 48
What is an algorithm?
33 / 48 34 / 48
I In 1900, David Hilbert proposed 23 mathematical problems I Can’t prove nonexistence results for algorithms without
for the next century. precise definition of “algorithm”.
I Hilbert’s Tenth Problem: I Definition provided in 1936:
I Devise an algorithm for determining whether a multivariate I λ-calculus (A. Church).
integer polynomial has an integral root, i.e., whether there I TMs (A. Turing).
exist x1 , x2 , . . . , xn ∈ Z such that I These were shown to be equivalent.
I Church-Turing thesis: “computable” means “TM-computable”.
p(x1 , x2 , . . . , xn ) = 0.
Connection between intuitive and formal notions of algorithm.
I Instead of “algorithm”, Hilbert said “a process by which it can
I In 1970, Yuri Matiyasevich (PhD dissertation) showed that no
determined by a finite number of operations”. algorithm exists for testing whether an arbitrary integer
I For example, the polynomial 6x 3 yz 2 + 3xy 2 − x 3 − 10 has an polynomial has integral roots. (Sometimes called “DPRM
integral root (x, y , z) = (5, 3, 0). theorem”.)
I He assumed that such a method exists. Of course, there’s always an answer (“yes” or “no”); but
I He was wrong. there’s no algorithm that gives us the answer.
35 / 48 36 / 48
More on Hilbert’s Tenth Problem More on Hilbert’s Tenth Problem (cont’d)
I Hilbert essentially asked whether
37 / 48 38 / 48
39 / 48 40 / 48
Example: Algorithmic level Example: Algorithmic level (cont’d)
Algorithmic description of M?
algoruled
parameter: the encoding hG i of an undirected graph G = (V , E )
return : accept if G is connected, reject otherwise.
I Let A be language of all strings representing graphs that are select and mark the first node in V ;
connected, i.e., any node can be reached from any other node. repeat
foreach node v ∈ V do
A = { hG i : G is a connected undirected graph }. if ∃ edge (v , w ) with previously-marked w ∈ V then
mark v ;
I Give me a high-level description of the TM M for deciding A. ;
end
until no new nodes are marked;
foreach v ∈ V do
if v is not marked then r;
eturn(reject) ;
end
41 / 48
return(accept); 42 / 48
Function connected(hG i)