170 likes | 313 Views
The Halting Problem. Sipser 4.2 (pages 173-182). Taking stock. All languages. Turing-recognizable. ?. D. Turing-decidable. Context-free languages. a n b n c n. Regular languages. 0 n 1 n. 0 * 1 *. Are there problems a computer can’t solve?!. But they seem so powerful…
E N D
The Halting Problem Sipser 4.2 (pages 173-182)
Taking stock All languages Turing-recognizable ? D Turing-decidable Context-free languages anbncn Regular languages 0n1n 0*1*
Are there problems a computer can’t solve?! • But they seem so powerful… • What about software verification? • Given a program and a specification of what it should do, can we check if it is correct?
What about deciding TMs? • ATM = {<M,w> | M is a TM and M accepts w} • Theorem 4.11: ATM is undecidable! • Is it even recognizable? • Let U = “On input <M,w>, where M is a TM: • Simulate M on input w. • If M ever enters its accept state, accept; if M ever enters its reject state, reject.”
Towards proving undecidability • Cantor 1873: How can we tell whether one infinite set is “larger” than another? • A function f from A to B is • One-to-one if f(x) ≠ f(y) if x≠y • (f never maps two elements to the same value) • Onto if every element of B is hit • A correspondence is a function that is both one-to-one and onto
Countable sets • Sets A and B have the same size if: • A and B are finite with the same number of elements • A and B are infinite with a correspondence between them • A set is countable if it is finite or has the same size as N • (natural numbers1, 2, 3,…)
For example… • E = { even natural numbers } is countable • Define f : N→ E as f(n) = 2n
Diagonalization • Theorem 4.17: R is uncountable. • Proof: By contradiction. Assume there is a correspondence. We find a real number x ≠ f(n) for any natural number n.
Put your thinking caps on! • How do we show that: • Σ* is countable • assumeΣ = {0,1} • B = { all infinite binary sequences } is uncountable
Uh-oh… • Theorem 4.18: Some languages are not Turing-recognizable. • Proof: Let L be the set of all languages over Σ. Define a correspondence from L to B. Σ*= { ε, 0, 1, 00, 01, 10, 11, 000, 001,…} A = { 0, 00, 01, 000, 001,…} ΧA= 0 1 0 1 1 0 0 1 1 …
The Halting Problem • ATM = {<M,w> | M is a TM and M accepts w} • Theorem 4.11: ATM is undecidable. • Proof: By contradiction. Assume H is a decider for ATM. We construct a TM D = “On input <M>, where M is a TM: • Run H in input <M, <M>> • If H accepts, reject; if H rejects, accept.”
Huh? • What if we run D on <D>? • Then • Contradiction! Then H cannot exist and ATM is undecidable.
Where is the diagonalization? • Running a machine on its description
Where is the diagonalization? • Running H on a machine and its description
Where is the diagonalization? • Adding D to the picture
So have we found a language that is not Turing-recognizable? • Theorem 4.22: A language is decidable iff it and its complement are recognizable • Then ATM is not Turing-recognizable!
Updating the picture All languages Turing-recognizable ATM D Turing-decidable Context-free languages anbncn Regular languages 0n1n 0*1*