1
Unit 10
Turing machine
Decidability
Decision problems in FA
2
Turing Machines
Proposed by Alan Turing, 1936.
• Unlimited and unrestricted memory.
• A model of a general purpose
computer.
• Can do anything that a real
computer can do.
• Cannot solve all problems!!
3
The Turing Machine
• An infinite tape - unlimited memory.
• A tape head - can move left and right.
• Can read from the tape and write on the tape.
b b a c b
head
b d a c __
4
Input/Output
*...21 nwwww
0 0 1 1 1 _ _ _
qaccept
*...21 nwwww0 1 0 _ _ _ _ _ ...q0
...
_
InitialConfiguration
FinalConfiguration
Input
Output
5
Initial Configuration
• Input: Appears on the leftmost n slots of the
tape.
• The rest of the tape is blank („_‟).
• Head starts on the left-most square.
• Initial state: q0
*...21 nwwwwb b a _ _ _ _ _ ...q0head
6
Final Configuration• During the computation the head can read and
write to the tape and move right or left until it
reach reject or accept states.
• Final state: q {qaccept , qreject}
• The tape contains uw.
– The string u appears to the left of the head.
– The string w appears under the head and its right.
– The rest of the tape is blank.
– The output is the string u.
*...21 nwwww0 0 1 0 1 _ _ _
qaccept
u w
7
Possible Outcomes of a TM
• The possible outcomes of a TM on a word w
can be:
– stop with “reject” state.
– stop with “accept” state.
– loop forever.
8
Differences Between Finite Automata and TM
• A TM can both read and write.
• The head can move left and right.
• The tape is infinite.
• The special cases of reject and accept take
an immediate action.
• A TM can produce an output.
9
TM: Definition
Formally: A TM is defined by
(Q, , , , q0, qaccept, qreject)
• Q is the set of states.
• is the input alphabet _ .
• is the tape alphabet, _ and .
• : Qx Qxx{R,L} the transition function.
• q0, qaccept, qreject the start, accept and reject
states. qaccept qreject
10
The Transition Function
• The transition function
: Qx Qxx{R,L}
• The transition (p,a)(q,b,R) is depicted as:
p qab,R
p qab,R
a,cb,R
cb,R
11
Example: L={w#w|w{0,1}*}
0 1 0 0 # 0 1 ...0 0 _
...x 1 0 0 # 0 1 0 0 _
x 1 0 0 # x 1 0 0 _ ...x x x x # x x x x _ ...accept
12
Process:
1. Scan and check that the input contains a single #. If not reject.
2. Zig-zag to check whether corresponding positions on either sides of # contain the same symbol. If not, reject. Cross off the checked symbols.
3. When all symbols to the left of # are crossed, check for remaining symbols to the right of #. If any symbol, reject. Otherwise, accept.
Example: L={w#w|w{0,1}*}
13
TM’s state diagram recognizing: B={w#w|w{0,1}*}
14
The Turing-Church Conjecture 1936
• If an algorithm exists for solving a problem
then there is an equivalent Turing machine
solving that algorithm.
• This gives a formal model for the intuitive
notion of “algorithms”.
• This means that a Turing machine can do
what any computer can do, and there isn‟t a
more powerful computational model than TM.
15
Decision Problems
• Problems for which the answer is “yes/no”.
• Any problem can be reduced to a decision
problem.
16
Arithmetic as a decision problem
• A membership problem determines whether a
word w is in a language L.
• Any problem can be reduced to the
membership problem of a word in a language.
• Example: An arithmetical problem of finding
the answer to: 3*7=?
• This problem can be formulated as a question:
– which of the following words belong to the language
of correct arithmetic statements:
3*7=0, 3*7=1, … , 3*7=21, 3*7=22, …
17
Decidability
Informally:
• Decidability of problem X – whether the problem has an algorithm which solves it (decides it), i.e. whether there is an TM which:
1. always halts
2. with the correct answer
• A decidable problem has such an algorithm/TM/grammar.
• An undecidable problem does not have such an algorithm/TM/grammar.
18
DFA Membership
• Input: DFA A and a string w
• Output: “yes” if wL(A); “no” otherwise.
• Theorem: DFA membership is decidable.
19
Proof of decidability
• The algorithm to decide the problem is:
– Simulate A with a TM:
• start A on w from q0
• if ‟(q0,w) F return “yes”
• otherwise return “no”
• The algorithm will always halt after |w| steps.
20
NFA Membership
• Input: NFA B and a string w
• Output: “yes” if wL(B); “no” otherwise.
• Theorem: NFA membership is decidable.
21
Proof of decidability
• The algorithm to decide the problem is:
– Convert NFA B to an equivalent DFA C
– Apply “DFA membership” TM to C and w
– If TM accepts w, accept, otherwise reject.
• The algorithm will always halt after |w| steps.
22
CFG Membership
• Input: CFG G and a string w
• Output: “yes” if wL(G); “no” otherwise.
• Theorem: CFG membership is decidable.
23
Proof of decidability
• Option 1:
– List all derivations ={u | S * u}
– Check whether w.
– Will it work?
• Option2:
– Convert G into equivalent Chomsky NF.
– List all derivations ={u | S * u} with
2|w|-1 steps
– Check whether w
24
TM Membership
• Input: TM M and a string w
• Output: “yes” if M accepts w; “no” otherwise.
• Theorem: TM membership is undecidable.
25
Proof of un-decidability
• In next course!
Classes of Languages
26
Turing -recognizable
decidable
context-free
regular
Recap
27
Recap
Regular Languages:
• Finite Automata (Q,,,q0,F)
• Regular languages
• Closures of RL (union, intersection,
complements, minus)
• Non deterministic automaton: : Qx2Q
• Equivalence DFANFA
• Closures of RL (concatenation, Kleene star).
28
Recap
• Regular Expressions
• Equivalence DFA RE
• Minimal DFA and equivalent DFAs
• Non regular languages: The Pumping Lemma
29
Recap
Context-Free Languages:
• Context-Free Grammar G=(V, , S, R)
• Regular grammar (Aw, AwB)
• Equivalence NFA regular-grammar
• Closure of CFL (Union, Concatenation,
Kleene star)
• Chomsky Normal Form (ABC, A)
• Chomsky Hierarchy of grammars
30
Recap
• Pushdown automata (Q, , , , q0, F)
• Equivalence PDA CFG
• Non context-free languages: The pumping
lemma
• Turing Machines
• Decidability
31
32
Aims
• Practical techniques and tools - useful in
compilation, translation, data compression etc.
• Formalization of the concept of language -
useful in formal linguistics etc.
• Computational models - useful in answering
basic questions about computations.
• Understanding of the computer abilities and its
limits
– In a problem Solvable?
– At what resources?
THE END33