computability and the halting problem
play

Computability and the Halting Problem CS251 Programming Languages - PowerPoint PPT Presentation

Computability and the Halting Problem CS251 Programming Languages Spring 2016, Lyn Turbak Department of Computer Science Wellesley College Key Concepts from CS235 This lecture


  1. Computability and 
 the Halting Problem CS251 ¡Programming ¡Languages ¡ Spring ¡2016, ¡Lyn ¡Turbak ¡ ¡ Department ¡of ¡Computer ¡Science ¡ Wellesley ¡College ¡

  2. Key Concepts from CS235 This ¡lecture ¡summarizes ¡key ¡concepts ¡from ¡ CS235 ¡Formal ¡ Languages ¡and ¡Automata ¡that ¡are ¡important ¡to ¡understand ¡ for ¡PL ¡design: • Computable ¡func?ons ¡ • Uncomputable ¡(= ¡undecidable) ¡func?ons ¡ – The ¡hal?ng ¡problem ¡ – Reduc?on ¡ – Uncomputability ¡and ¡PL ¡design ¡ • The Church/Turing hypothesis • Turing-completeness 2-2

  3. Computability ¡ • A ¡func?on ¡ f ¡is ¡computable ¡if ¡there ¡is ¡a ¡program ¡that ¡ takes ¡some ¡finite ¡number ¡of ¡steps ¡before ¡hal?ng ¡and ¡ producing ¡output ¡ f(x). ¡ • Computable: ¡ ¡ ¡f(x) ¡= ¡x ¡+ ¡1 , ¡for ¡natural ¡numbers ¡ – addi?on ¡algorithm ¡ • Uncomputable ¡(a.k.a. ¡undecidable) ¡func?ons ¡exist! ¡ – We’ll ¡first ¡prove ¡this ¡by ¡a ¡“coun?ng ¡argument”: ¡there ¡are ¡way ¡ more ¡func?ons ¡than ¡there ¡are ¡programs ¡to ¡compute ¡them! ¡ – Then ¡we’ll ¡show ¡a ¡concrete ¡example: ¡the ¡hal?ng ¡problem. ¡ ¡ 2-3

  4. Some ¡Simple ¡Sets ¡ Bool ¡= ¡the ¡booleans ¡= ¡{true, ¡false} ¡ Nat ¡= ¡the ¡natural ¡numbers ¡= ¡{0, ¡1, ¡2, ¡3 ¡…} ¡ Pos ¡= ¡the ¡posi?ve ¡integers ¡= ¡{1, ¡2, ¡3, ¡4, ¡…} ¡ Int ¡= ¡all ¡integers ¡ ¡= ¡{ ¡…, ¡-­‑3, ¡-­‑2, ¡-­‑1, ¡0, ¡1, ¡2, ¡3, ¡…} ¡ Rat ¡= ¡all ¡ra?onal ¡numbers ¡(frac?ons, ¡w/o ¡duplicates) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡{…, ¡-­‑3/2, ¡-­‑2/3, ¡-­‑1/3, ¡-­‑2/1, ¡-­‑1/1, ¡0/1, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1/1, ¡1/2, ¡2/1, ¡1/3, ¡2/3, ¡3/2, ¡…} ¡ Real ¡= ¡all ¡real ¡numbers ¡= ¡{0, ¡17, ¡-­‑2.5, ¡1.736, ¡-­‑5.3333…, ¡3.141…, ¡….} ¡ Irrat ¡= ¡all ¡irra?onal ¡numbers ¡(cannot ¡be ¡expressed ¡as ¡frac?ons ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡{sqrt(2) ¡=1.414.., ¡pi ¡= ¡3.14159…, ¡e ¡= ¡2.718…, ¡…} ¡ ¡ 2-4

  5. Nat ¡and ¡Pos ¡Have ¡the ¡“Same ¡Size” ¡ Nat ¡ ≅ ¡Pos ¡by ¡the ¡pictured ¡bijec?on ¡ Nat ¡ ¡ ¡ ¡0 ¡ ¡ ¡ ¡ ¡ ¡1 ¡ ¡ ¡ ¡ ¡ ¡2 ¡ ¡ ¡ ¡ ¡ ¡3 ¡ ¡ ¡… ¡ Pos ¡ ¡ ¡ ¡1 ¡ ¡ ¡ ¡ ¡ ¡2 ¡ ¡ ¡ ¡ ¡ ¡3 ¡ ¡ ¡ ¡ ¡ ¡4 ¡ ¡ ¡… ¡ ¡ 2-5

  6. Nat ¡and ¡Int ¡Have ¡the ¡Same ¡Size! ¡ Nat ¡ ≅ ¡Int ¡by ¡the ¡pictured ¡bijec?on ¡ Nat 0 1 2 3 4 5 6 … f Int 0 1 -1 2 -2 3 -3 … Int … -3 -2 -1 0 1 2 3 … f -1 Nat … 6 4 2 0 1 3 5 … This ¡is ¡an ¡example ¡of ¡ proof ¡by ¡construc>on . ¡ ¡ 2-6

  7. Countable ¡and ¡Uncountable ¡Sets ¡ A ¡set ¡S ¡is ¡ • ¡ finite ¡iff ¡S ¡ ≅ ¡{1, ¡2, ¡…, ¡n} ¡for ¡some ¡n. ¡ • ¡ infinite ¡iff ¡S ¡is ¡not ¡finite. ¡ ¡ ¡ • ¡ countably ¡ infinite ¡iff ¡S ¡ ≅ ¡Nat. ¡ ¡ • ¡ countable ¡iff ¡S ¡is ¡finite ¡or ¡countably ¡infinite. ¡ ¡ ¡ ¡I.e., ¡there ¡is ¡a ¡procedure ¡for ¡enumera?ng ¡all ¡the ¡ ¡ ¡ ¡elements ¡of ¡S. ¡ ¡ • ¡ uncountable ¡iff ¡S ¡is ¡not ¡countable ¡ We ’ ve ¡seen ¡that ¡Bool, ¡Nat, ¡and ¡Int ¡are ¡countable. ¡ Now ¡we ’ ll ¡see ¡that ¡(1) ¡Rat ¡is ¡countable ¡and ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(2) ¡Real ¡and ¡Irrat ¡are ¡uncountable ¡ 2-7

  8. Rat ¡is ¡Countable ¡ Key ¡idea: ¡can ¡enumerate ¡Nat ¡x ¡Nat ¡as ¡follows: ¡ ¡ Mopping ¡up: ¡ • ¡Need ¡to ¡eliminate ¡duplicates, ¡e.g., ¡ ¡1/2= ¡2/4 ¡ • ¡Need ¡to ¡handle ¡nega?ve ¡ra?onal ¡(as ¡in ¡showing ¡Int ¡countable). ¡ 2-8

  9. Real ¡is ¡Uncountable: ¡Diagonaliza?on ¡ Key ¡idea: ¡use ¡a ¡special ¡form ¡of ¡ proof ¡by ¡contradic>on ¡ known ¡as ¡ diagonaliza>on . ¡ ¡ ¡ Assume ¡that ¡[0,1) ¡ ⊆ ¡Real ¡is ¡countable ¡and ¡derive ¡a ¡contradic?on. ¡ ¡ If ¡[0,1) ¡is ¡countable, ¡there ¡must ¡be ¡a ¡bijec?on ¡f ¡ ∈ ¡Nat ¡→ ¡[0,1) ¡that ¡ enumerates ¡all ¡real ¡numbers ¡between ¡0 ¡(inclusive) ¡and ¡1 ¡(exclusive). ¡I.e., ¡if ¡r ¡ ∈ ¡[0,1), ¡ then ¡there ¡is ¡an ¡n ¡ ∈ ¡ Nat ¡s.t. ¡f(n) ¡= ¡r. ¡ ¡ ¡ If ¡this ¡is ¡so, ¡we ¡can ¡construct ¡a ¡table ¡of ¡f ¡whose ¡rows ¡are ¡f(n) ¡and ¡whose ¡ columns ¡show ¡the ¡digits ¡aker ¡the ¡decimal ¡point ¡for ¡each ¡number. ¡ ¡ f(0) 1 4 1 5 f(1) 7 3 8 2 … f(2) 5 4 9 6 f(3) 8 2 7 3 . . . 2-9

  10. Real ¡Diagonaliza?on ¡Con?nued ¡ ¡ f(0) 1 4 1 5 f(1) 7 3 8 2 … f(2) 5 4 9 6 f(3) 8 2 7 3 . . . Focus ¡on ¡the ¡diagonal ¡table ¡entries, ¡and ¡construct ¡a ¡number ¡whose ¡decimal ¡ representa?on ¡differs ¡from ¡every ¡posi?on ¡in ¡the ¡diagonal*. ¡E.g., ¡ ¡.2786 ¡… ¡ ¡ Any ¡such ¡number ¡is ¡ not ¡a ¡row ¡in ¡the ¡table ¡and ¡so ¡is ¡not ¡in ¡the ¡image ¡of ¡f. ¡ ¡ Thus, ¡the ¡assump?on ¡that ¡f ¡is ¡a ¡bijec?on ¡is ¡wrong! ¡ ¡ X ¡proof ¡by ¡contradic>on ¡ Indeed, ¡it’s ¡ way ¡wrong. ¡The ¡number ¡of ¡counterexamples ¡we ¡can ¡construct ¡is ¡ a ¡ way ¡bigger ¡infinity ¡ (an ¡ uncountable ¡infinity) ¡than ¡the ¡row ¡s ¡in ¡the ¡table. ¡ ¡ Diagonaliza?on ¡is ¡the ¡heart ¡of ¡the ¡hal?ng ¡theorem ¡proof ¡we’ll ¡see ¡soon. ¡ ¡ * ¡For ¡technical ¡reasons, ¡should ¡not ¡use ¡0 ¡or ¡9 ¡in ¡the ¡constructed ¡number. ¡ ¡ 2-10

  11. Irrat ¡is ¡Uncountable ¡ Real ¡= ¡Rat ¡U ¡Irrat. ¡ We ¡know ¡Rat ¡is ¡countable. ¡ ¡ Assume ¡Irrat ¡is ¡countable. ¡Then ¡Real ¡would ¡be ¡countable. ¡ ¡ But ¡we ¡know ¡Real ¡is ¡uncountable. ¡Thus, ¡the ¡assump?on ¡that ¡ ¡ Irrat ¡is ¡countable ¡is ¡wrong. ¡ X ¡proof ¡by ¡contradic>on. ¡ Conclusion: ¡Irrat ¡is ¡uncountable. ¡ ¡ 2-11

  12. Alphabets, ¡Strings, ¡and ¡Languages ¡ An ¡ alphabet ¡is ¡a ¡set ¡of ¡symbols. ¡ ¡ ¡ ¡ ¡E.g.: ¡ ¡ Σ 1 ¡= ¡{0,1}; ¡ ¡ ¡ Σ 2 ¡= ¡{-­‑,0,+} ¡ ¡ ¡ ¡ Σ 3 ¡= ¡{a,b, ¡…, ¡y, ¡z}; ¡ ¡ ¡ Σ 4 ¡= ¡{ J , ¡ ⇒ , ¡a ¡, ¡aa ¡} ¡ ¡ A ¡ string ¡ over ¡ Σ ¡is ¡a ¡sequence ¡of ¡symbols ¡from ¡ Σ . ¡ ¡ ¡ The ¡empty ¡string ¡is ¡oken ¡wriqen ¡ ε . ¡ Σ * ¡denotes ¡all ¡strings ¡over ¡ Σ . ¡ ¡ ¡E.g.: ¡ • ¡ Σ 1 * ¡contains ¡ ε , ¡0, ¡1, ¡00, ¡01, ¡10, ¡11, ¡000, ¡… ¡ ¡ • ¡ Σ 2 * ¡contains ¡ ε , ¡-­‑, ¡0, ¡+, ¡-­‑-­‑, ¡-­‑0, ¡-­‑+, ¡0-­‑, ¡00, ¡0+, ¡+-­‑, ¡+0, ¡++, ¡-­‑-­‑-­‑, ¡… ¡ • ¡ Σ 3 * ¡contains ¡ ε , ¡a, ¡b, ¡…, ¡aa, ¡ab, ¡…, ¡bar, ¡baz, ¡foo, ¡wellesley, ¡… ¡ • ¡ Σ 4 * ¡contains ¡ ε , ¡ J , ¡ ⇒ , ¡ ¡ a ¡, ¡aa, ¡…, ¡ ¡ a ¡ ⇒ ¡ J , ¡…, ¡a ¡aa ¡, ¡ ¡ ¡ aa ¡a ¡ ¡,… ¡ ¡ ¡ A ¡ language ¡ over ¡ Σ ¡is ¡any ¡subset ¡of ¡ Σ *. ¡ ¡ I.e., ¡it ’ s ¡a ¡set ¡of ¡strings ¡over ¡ Σ . ¡ ¡E.g.: ¡ • ¡L 1 ¡over ¡ Σ 1 ¡is ¡all ¡sequences ¡of ¡1s ¡and ¡all ¡sequences ¡of ¡10s. ¡ • ¡L 2 ¡over ¡ Σ 2 ¡is ¡all ¡strings ¡with ¡equal ¡numbers ¡of ¡-­‑, ¡0, ¡and ¡+. ¡ ¡ • ¡L 3 ¡over ¡ Σ 3 ¡is ¡all ¡lowercase ¡words ¡in ¡the ¡OED. ¡ • ¡L 4 ¡over ¡ Σ 4 ¡is ¡{ J , ¡ J ¡ ⇒ ¡ J , ¡a ¡aa ¡}. ¡ 2-12

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend