15-453

FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
* Read chapter 4 of the book for next time *

Lecture9x.ppt

REVIEW

A Turing Machine is represented by a 7-tuple T = (Q, , , H, q0, qaccept, qreject): Q is a finite set of states is the input alphabet, where ‘ 

is the tape alphabet, a superset of ; H:Qv Qv

v {L, R} is the transition func

q0  Q is the start state qaccept  Q is the accept state qreject  Q is the reject state, and qreject { qaccept

CONFIGURATION: (1) tape contents,
(2) current state, (3) location of read/write head.
q7

1

1

0

1

0

0

0

1

1

0

11010q700110

A TM recognizes a language iff it accepts all and only those strings in the language. . A language L is called decidable or recursive iff some TM decides L. A language L is called Turing-recognizable or recursively enumerable iff some TM recognizes L. A TM decides a language L iff it accepts all strings in L and rejects all strings not in L.

e.) if some TM recognizes it. r. languages recursive languages .A language is called Turing-recognizable or recursively enumerable (r.e. A language is called decidable or recursive if some TM decides it.

e. ‡ If TMA recognizes it.) ‡ One of them will eventually recognize the input string. ‡ If TMR recognizes it. How can we prove this? ‡ Run TMA and TMR in parallel. . then accept. interleave them. then reject. we can build a new machine that decides A. (Or more precisely. then A is decidable. Given: a Turing Machine TMA that recognizes A and a Turing Machine TMR that recognizes šA.Theorem: If A and šA are r.

2n .A TM that decides { 0 | n • 0 } We want to accept iff: ‡ the input string consists entirely of zeros. ‡ Otherwise. then accept. ‡ Repeatedly divide the number of zeros in half until it becomes an odd number. and ‡ the number of zeros is a power of 2. ‡ If we are left with a single zero. High-Level Idea. reject.

(Divides number in half.A TM that decides { 0 | n • 0 } PSEUDOCODE: 1. 5. Else if the tape had an odd number of 0¶s. Move the head back to the first input symbol. accept. Sweep from left to right. reject. Go to step 1. If in step 1.) 2. 2n . cross out every other 0. 4. 3. the tape had only one 0.

R .R .{0 |n•0} q2 . R q1 0 x. R . R x.R x. R . L 0. R x. L .R x q0 0 x x.L x q3 0 0. R 0 2n x 0 x.R x x. R q4 qreject qaccept .

R 0 2n x x.{0 |n•0} q2 .R . R xq20x0.R x.R x q0 0 x x.R . L q1000 xq300 . R . L q00000 0 0.R . R q1 0 x. R qreject qaccept . R x x0xq3 q 3 x0q2x x. R 0 q2x0x q4 x0x q2 x x.L x0q40 x.

j. k • 1} Example aaabbbbcccccccccccc 3 4 3×4 = 12 .C = {aibjck | k = i j. and i.

} } . For each occurrence of a: { For each occurrence of b: { Delete an occurrence of c. j. and i.C = {aibjck | k = i j. k • 1} High-Level Idea.

Uncross all the b¶s. crossing out one of each until all b¶s are out. 2. . If all a¶s are crossed out. If the input doesn¶t match a*b*c*. Cross off an a. If too few c¶s. reject.C = {aibjck | k = i j. then accept. 4. scan to the right until b. and i. Check if all c¶s are crossed off. 3. Move the head back to the leftmost symbol. k • 1} PSEUDOCODE: 1. else reject. j. reject. If yes. then repeat stage 3. If there¶s another a left. Sweep between b¶s and c¶s.

and i.C = {aibjck | k = i j. j. k • 1} aabbbcccccc xabbbcccccc xayyyzzzccc xabbbzzzccc xxyyyzzzzzz .

an old TM can still simulate it! Example: Turing machines with multiple tapes. and other tapes are used for scratch work.TURING-MACHINE VARIANTS Turing machines can be extended in various ways. . Input comes in on one tape. but so long as a new TM only reads and writes a finite number of symbols in each step.

R}k .MULTITAPE TURING MACHINES FINITE STATE CONTROL H:Qv k Qv k v {L.

# # . 1 0 0 # . .Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine 1 FINITE STATE CONTROL 0 0 FINITE STATE CONTROL .

0 0 # . .Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine 1 FINITE STATE CONTROL 0 0 FINITE STATE CONTROL 1 . # # .

THE CHURCH-TURING THESIS Anything that can be computed by algorithm (in our intuitive sense of the term ³algorithm´) can be computed by a Turing Machine. .

a). b. a). (q.We can encode a TM as a string of 0s and 1s n states start state reject state 0n 10m 10k 10s 10t 10r 10u 1« m tape symbols (first k are input symbols) accept state blank symbol ( (p. L) ) = 0p10a10q10b10 ( (p. R) ) = 0p10a10q10b11 . (q. b.

w) | G is a CFG that generates string w } . etc. w) | B is an NFA that accepts string w } ACFG = { (G. we can encode DFAs. CFGs. into strings of 0s and 1s So we can define the following languages: ADFA = { (B. NFAs. w) | B is a DFA that accepts string w } ANFA = { (B.Similarly.

ADFA = { (B. w) | B is an NFA that accepts string w } Theorem: ANFA is decidable ACFG = { (G. w) | B is a DFA that accepts string w } Theorem: ADFA is decidable Proof Idea: Simulate B on w ANFA = { (B. w) | G is a CFG that generates string w } Theorem: ACFG is decidable Proof Idea: Transform G into Chomsky Normal Form. Try all derivations of length 2|w|-1 .

UNDECIDABLE PROBLEMS .

Turing-recognizable) L is decidable (recursive) Theorem: L is decidable if both L and šL are recursively enumerable .w * TM yes accept TM no reject yes w * wL? wL? no accept reject or no output L is semi-decidable (recursively enumerable.

(Works for any .) Then we will prove something stronger: There are semi-decidable (r.There are languages over {0.1} that are not decidable. this is major: it means there are things that formal computational models inherently cannot do.) languages that are NOT decidable. . If we believe the Church-Turing Thesis. We will show there is no function from the set of all Turing Machines onto the set of all languages over {0.1}. We can prove this using a counting argument.e.

Languages over {0.1} Turing Machines .

Cantor·s Theorem Let L be any set and 2L be the power set of L Theorem: There is no map from L onto 2L Proof: Assume. for every elem x in L. that there is an onto map f : L p 2L Let S = { x  L | x ‘ f(x) } We constructed S so that. for a contradiction. the set S differs from f(x): S  f(x) because x  S iff x ‘ f(x) .

) .28347279« 0.11111111« 1 5 0..11101..88388384« 8 6 0.77635284« 0. 1) Proof: Suppose f is such a function: 1 2 3 4 5 : [ nth digit of r ] = 1 0 2 0.12345678« : if [ nth digit of f(n) ] { 1 otherwise f(n) { r for all n ( Here. r = 0.Theorem: There is no onto function from the positive integers to the real numbers in (0.

1) (5.4«}.1) (2.5) « : : : : : ·.4) (1.1) (1.4) (4.2) (1.1) (3.1) (4.2.5) « (5.4) (5.3) (3.3) (1.3.4) (2.2) (3.5) « (4.3) (4.3) (2.4) (3.5) « (3.2) (5.5) « (2.2) (2.3) (5.Sidenote Let Z+ = {1. .2) (4. There exists a bijection between Z+ and Z+ v Z+ (or Q+) (1.

2L always has µmore¶ elements than L .THE MORAL: For any set L.

1} are semi-decidable {decidable languages over {0.1}} {Turing Machines} {Strings of 0s and 1s} {Languages over {0. in fact: not all languages over {0.1}} {semi-decidable langs over {0.Not all languages over {0.1} are decidable.1}} {Sets of strings of 0s and 1s} Set L Powerset of L: L 2 .

w).THE ACCEPTANCE PROBLEM ATM = { (M. If M ever accepts. If M ever rejects. U accepts (M. w) | M is a TM that accepts string w } Theorem: ATM is semi-decidable (r. Therefore. U runs M on w.e. accept. U recognizes ATM .w)  M accepts w  (M. reject. : Define a TM U as follows: U is a universal TM On input (M.e.) but NOT decidable ATM is r.w)  ATM Therefore.

w) | M is a TM that accepts string w } ATM is undecidable: (proof by contradiction) Assume machine H decides ATM Accept H( (M.w) ) = Reject if M does not accept w Construct a new TM D as follows: on input M. run H on (M.ATM = { (M.M) and output the opposite of H Reject D( M ) = D Accept if M accepts M D D Contradiction! if M does not accept M D D if M accepts w .

OUTPUT OF H M1 M1 M2 M3 M4 : D reject reject accept accept M2 M3 M4 « reject reject accept reject D accept reject accept accept accept accept accept reject accept accept accept reject reject reject reject reject ? .

but NOT decidable Theorem: šATM is not even r.Theorem: ATM is r.e.! The Halting Problem is Not Decidable .e.

M ) Rejects D( M ) = D D D No output if H ( D M ) has No output M. D Reject if H ( D M ) Accepts Accept if H ( M . why?) Accept H( (M.M) and output M.ATM = { (M.D) ) = No output .w) | M is a TM that accepts string w } ATM is undecidable: A constructive proof: Let machine H semi-decides ATM (Such  . D No Contradictions ! H( (D. run H on (M.w) ) = if M accepts w Reject or No output if M does not accept w Construct a new TM D as follows: on input M.

In other words. Given any good candidate for deciding the Halting Problem.We have shown: Given any presumed machine H for ATM. we can effectively construct an instance where the machine fails. .D) ‘ ATM but H fails to tell us that. we can effectively construct a TM D such that (D. For any machine H that recognizes ATM we can effectively give an instance where H fails to decide ATM In other words.

w) If H rejects then reject If H accepts. run M on w until it halts: Accept if M accepts and Reject if M rejects . that TM H decides HALTTM We use H to construct a TM D that decides ATM On input (M. D runs H on (M.w). for a contradiction.THE HALTING PROBLEM HALTTM = { (M.w) | M is a TM that halts on string w } Theorem: HALTTM is undecidable Proof: Assume.

w) (M.w) If M halts D H Does M halt on w? w M If M doesn¶t halt: REJECT .(M.

one can show that a language L is undecidable by showing that if it is decidable.In many cases. then so is ATM We reduce deciding ATM to deciding the language in question ATM ” L We just showed: ATM ” HaltTM Is HaltTM ” ATM ? .

Read chapter 4 of the book for next time .