Foundations of Software Design Fall 2002 Marti Hearst Lecture 29:  Computability, Turing Machines, Can Computers Think?    
Computability <ul><li>Is there anything a computer cannot compute? </li></ul><ul><li>Linked to the notion of what is an al...
Alan Turing <ul><li>An amazing scientist </li></ul><ul><ul><li>Helped solved the Enigma Machine (WWII) </li></ul></ul><ul>...
Turing Machines <ul><li>Anything that can be computed by a finite set of rules can be computed by a Turing machine. </li><...
Regular Languages Context-Free Languages Languages accepted by Turing Machines
A Turing Machine ...... ...... Tape Read-Write head Control Unit
The Tape ...... ...... Read-Write head No boundaries -- infinite length The head moves Left or Right
...... ...... Read-Write head The head at each time step: 1.  Reads a symbol 2.  Writes a symbol 3.  Moves Left or Right
...... ...... Example: Time 0 ...... ...... Time 1 1.  Reads 2.  Writes  3.  Moves Left
The Input String ...... ...... Blank symbol head Head starts at the leftmost position of the input string Input string
States & Transitions Read Write Move Left Move Right
Example: ...... ...... Time 1 current state
...... ...... Time 1 ...... ...... Time 2
Determinism Allowed Not  Allowed Turing Machines are deterministic
Halting The machine  halts   if there are no possible transitions to follow
Example: ...... ...... No possible transition HALT!!!
Final States Allowed Not  Allowed <ul><li>Final states have no outgoing transitions </li></ul><ul><li>In a final state the...
Acceptance Accept Input If machine halts  in a final state  Reject Input If machine  halts  in a non-final state or If mac...
Infinite Loop Example A Turing machine for language
Time 0
Time 1
Time 2
Time 2 Time 3 Time 4 Time 5 ... Infinite Loop
Church-Turing Thesis <ul><li>The  Church-Turing thesis  says that Turing machine algorithms are the same as our intuitive ...
The Halting Problem <ul><li>An example of something that is not computable. </li></ul><ul><li>Created by Turing in 1936 to...
Proof (by contradiction) <ul><li>Assume that it is possible to write a program to solve the Halting Problem. </li></ul><ul...
Proof (cont.) <ul><li>We can now write another program  Loopy(prog)  that uses  HaltAnswerer   </li></ul><ul><li>The progr...
Proof (cont.) <ul><ul><li>[1]  If  HaltAnswerer( prog , prog )  returns  yes ,  </li></ul></ul><ul><ul><ul><li>Loopy  will...
Diagonalization <ul><li>Not  Diagon Alley </li></ul><ul><li>A proof by contradiction technique </li></ul><ul><ul><li>Uses ...
Diagonalization B1 0 0 0 0 0 … B2 0 0 1 0 1 … B3 1 0 1 1 0 … B4 0 1 1 1 1 … B5 1 1 0 0 0 … … D 1 1 0 0 1 …
The Universal Turing Machine <ul><li>There are an infinite number of Turing Machines </li></ul><ul><li>There are an infini...
The Halting Problem <ul><li>Halting Problem:  </li></ul><ul><ul><li>There is no procedure for telling whether an arbitrary...
Diagonalization 1 2 3 4 5 … T1 H H ? H H … T2 ? ? H H H … T3 H H H H H … T4 H H H ? H … T5 H H H H H … … D ? H ? H ? …
Diagonalization on the Halting Problem <ul><li>Now define a new TM called D that will halt for all inputs.  It outputs </l...
“Going Meta” <ul><li>This proof based in part on Gödel’s Theorem </li></ul><ul><li>If you are interested in these kinds of...
The Turing Test <ul><li>An observer  </li></ul><ul><ul><li>Interacts with a keyboard and monitor </li></ul></ul><ul><ul><l...
What is Intelligence? <ul><li>Do androids dream … ? </li></ul><ul><li>What would it take for a computer’s thoughts to be i...
Upcoming SlideShare
Loading in …5
×

Turing Machines, Computability, Computers and Intelligence

1,585 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,585
On SlideShare
0
From Embeds
0
Number of Embeds
137
Actions
Shares
0
Downloads
122
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Turing Machines, Computability, Computers and Intelligence

  1. 1. Foundations of Software Design Fall 2002 Marti Hearst Lecture 29: Computability, Turing Machines, Can Computers Think?    
  2. 2. Computability <ul><li>Is there anything a computer cannot compute? </li></ul><ul><li>Linked to the notion of what is an algorithm. </li></ul>
  3. 3. Alan Turing <ul><li>An amazing scientist </li></ul><ul><ul><li>Helped solved the Enigma Machine (WWII) </li></ul></ul><ul><ul><li>Advances in Probability Theory </li></ul></ul><ul><li>Invented the theory behind computers </li></ul><ul><ul><li>Turing Machine </li></ul></ul><ul><ul><li>Turing Test </li></ul></ul>
  4. 4. Turing Machines <ul><li>Anything that can be computed by a finite set of rules can be computed by a Turing machine. </li></ul><ul><li>Turing Equivalence </li></ul><ul><ul><li>We saw that finite automata are less powerful than TMs </li></ul></ul><ul><ul><ul><li>Can’t compute </li></ul></ul></ul><ul><ul><ul><li>Thus not Turing-equivalent </li></ul></ul></ul><ul><ul><li>Modern computers and programming languages are all Turing-equivalent </li></ul></ul>
  5. 5. Regular Languages Context-Free Languages Languages accepted by Turing Machines
  6. 6. A Turing Machine ...... ...... Tape Read-Write head Control Unit
  7. 7. The Tape ...... ...... Read-Write head No boundaries -- infinite length The head moves Left or Right
  8. 8. ...... ...... Read-Write head The head at each time step: 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right
  9. 9. ...... ...... Example: Time 0 ...... ...... Time 1 1. Reads 2. Writes 3. Moves Left
  10. 10. The Input String ...... ...... Blank symbol head Head starts at the leftmost position of the input string Input string
  11. 11. States & Transitions Read Write Move Left Move Right
  12. 12. Example: ...... ...... Time 1 current state
  13. 13. ...... ...... Time 1 ...... ...... Time 2
  14. 14. Determinism Allowed Not Allowed Turing Machines are deterministic
  15. 15. Halting The machine halts if there are no possible transitions to follow
  16. 16. Example: ...... ...... No possible transition HALT!!!
  17. 17. Final States Allowed Not Allowed <ul><li>Final states have no outgoing transitions </li></ul><ul><li>In a final state the machine halts </li></ul>
  18. 18. Acceptance Accept Input If machine halts in a final state Reject Input If machine halts in a non-final state or If machine enters an infinite loop
  19. 19. Infinite Loop Example A Turing machine for language
  20. 20. Time 0
  21. 21. Time 1
  22. 22. Time 2
  23. 23. Time 2 Time 3 Time 4 Time 5 ... Infinite Loop
  24. 24. Church-Turing Thesis <ul><li>The Church-Turing thesis says that Turing machine algorithms are the same as our intuitive notion of algorithms. </li></ul><ul><ul><li>Most people think the Church Turing thesis is correct. </li></ul></ul><ul><ul><li>It means, among other things that </li></ul></ul><ul><ul><ul><li>You can simulate any computer program that runs on any hardware in any language with any other program on any other hardware using any other language. </li></ul></ul></ul><ul><ul><ul><li>Tasks that humans agree is an algorithm can always be executed on a computer. </li></ul></ul></ul>
  25. 25. The Halting Problem <ul><li>An example of something that is not computable. </li></ul><ul><li>Created by Turing in 1936 to define a problem which no algorithmic procedure can solve. </li></ul><ul><li>Can we write a program that will take in a user's program and inputs and decide whether </li></ul><ul><ul><li>it will eventually stop , or </li></ul></ul><ul><ul><li>it will run infinitely in some infinite loop ? </li></ul></ul>
  26. 26. Proof (by contradiction) <ul><li>Assume that it is possible to write a program to solve the Halting Problem. </li></ul><ul><li>Denote this program by HaltAnswerer( prog , inputs ). </li></ul><ul><li>HaltAnswerer( prog , inputs ) will </li></ul><ul><ul><li>return yes if prog will halt on inputs and </li></ul></ul><ul><ul><li>no otherwise. </li></ul></ul><ul><li>A program is just a string of characters </li></ul><ul><ul><li>E.g. your Java program is just a long string of characters </li></ul></ul><ul><li>An input can also be considered as just a string of characters </li></ul><ul><li>So HaltAnswerer is effectively just working on two strings </li></ul>
  27. 27. Proof (cont.) <ul><li>We can now write another program Loopy(prog) that uses HaltAnswerer </li></ul><ul><li>The program Loopy(prog) does the following: </li></ul><ul><ul><li>[1] If HaltAnswerer( prog , prog ) returns yes , </li></ul></ul><ul><ul><ul><li>Loopy will go into an infinite loop . </li></ul></ul></ul><ul><ul><li>[2] If HaltAnswerer( prog , prog ) returns no , </li></ul></ul><ul><ul><ul><li>Loopy will halt. </li></ul></ul></ul>
  28. 28. Proof (cont.) <ul><ul><li>[1] If HaltAnswerer( prog , prog ) returns yes , </li></ul></ul><ul><ul><ul><li>Loopy will go into an infinite loop . </li></ul></ul></ul><ul><ul><li>[2] If HaltAnswerer( prog , prog ) returns no , </li></ul></ul><ul><ul><ul><li>Loopy will halt. </li></ul></ul></ul><ul><li>Consider what happens when we run Loopy ( Loopy ). </li></ul><ul><ul><li>If Loopy loops infinitely , </li></ul></ul><ul><ul><ul><li>HaltAnswerer( Loopy , Loopy ) return no which by [2] above means Loopy will halt . </li></ul></ul></ul><ul><ul><li>If Loopy halts , </li></ul></ul><ul><ul><ul><li>HaltAnswerer( Loopy , Loopy ) will return yes which by [1] above means Loopy will loop infinitely . </li></ul></ul></ul><ul><li>Conclusion: Our assumption that it is possible to write a program to solve the Halting Problem has resulted in a contradiction. </li></ul>
  29. 29. Diagonalization <ul><li>Not Diagon Alley </li></ul><ul><li>A proof by contradiction technique </li></ul><ul><ul><li>Uses the notion of Infinity </li></ul></ul><ul><li>The name comes from a proof that shows you can’t ever list all numbers. </li></ul><ul><ul><li>Assume you list all possible binary numbers </li></ul></ul><ul><ul><li>Diagonalization shows you can always construct a new number that is not yet in the list </li></ul></ul><ul><ul><ul><li>Have to assume numbers can have infinite length </li></ul></ul></ul><ul><ul><li>Construct the new number by choosing the opposite of the number on the diagonal. </li></ul></ul>
  30. 30. Diagonalization B1 0 0 0 0 0 … B2 0 0 1 0 1 … B3 1 0 1 1 0 … B4 0 1 1 1 1 … B5 1 1 0 0 0 … … D 1 1 0 0 1 …
  31. 31. The Universal Turing Machine <ul><li>There are an infinite number of Turing Machines </li></ul><ul><li>There are an infinite number of calculations that can be done with a finite set of rules. </li></ul><ul><li>However, we can define a Universal Turing Machine which can simulate all possible TMs </li></ul><ul><ul><li>Comes from the definition of TMs </li></ul></ul><ul><ul><li>You convert the description of the TM and its input into two tapes, and use these as the input to the UTM </li></ul></ul>
  32. 32. The Halting Problem <ul><li>Halting Problem: </li></ul><ul><ul><li>There is no procedure for telling whether an arbitrary TM will halt on a given input. </li></ul></ul><ul><li>Use Diagonalization to show this. </li></ul><ul><ul><li>Again, proof by contradiction </li></ul></ul><ul><ul><li>Assume there is a rule for deciding if a TM will halt. </li></ul></ul><ul><li>Construct a table as follows: </li></ul><ul><ul><li>List all Turing machines down the side </li></ul></ul><ul><ul><li>List the possible inputs across the top </li></ul></ul><ul><ul><li>In position (j,i) put the result of executing Turing machine j on input i </li></ul></ul><ul><ul><ul><li>If it halts, output H </li></ul></ul></ul><ul><ul><ul><li>If it doesn’t halt, output ? </li></ul></ul></ul>
  33. 33. Diagonalization 1 2 3 4 5 … T1 H H ? H H … T2 ? ? H H H … T3 H H H H H … T4 H H H ? H … T5 H H H H H … … D ? H ? H ? …
  34. 34. Diagonalization on the Halting Problem <ul><li>Now define a new TM called D that will halt for all inputs. It outputs </li></ul><ul><ul><li>H if TMi(i) does not halt </li></ul></ul><ul><ul><li>? if TMi(i) does halt </li></ul></ul><ul><li>We already said that the assumption is that we can always decide if a TM halts. </li></ul><ul><li>Also, we said this table lists all possible TMs. </li></ul><ul><ul><li>So D must be in the table. </li></ul></ul><ul><li>But this means that we are saying that D outputs halt if it doesn’t halt! </li></ul><ul><ul><li>To see this, give D as input to itself. </li></ul></ul><ul><li>This is a contradiction. Hence the premise does not hold: We cannot determine if an arbitrary program will halt. </li></ul>
  35. 35. “Going Meta” <ul><li>This proof based in part on Gödel’s Theorem </li></ul><ul><li>If you are interested in these kinds of questions (and other things related to “going meta” like compiler compilers), see </li></ul><ul><ul><li>Gödel, Escher, Bach: An Eternal Golden Braid , by Douglas Hofstadter. </li></ul></ul>
  36. 36. The Turing Test <ul><li>An observer </li></ul><ul><ul><li>Interacts with a keyboard and monitor </li></ul></ul><ul><ul><li>Has to distinguish which of two respondents is a computer and which is human. </li></ul></ul><ul><li>There is a contest with a $100,000 prize! </li></ul><ul><ul><li>For the first computer whose responses are indistinguishable from a human's. </li></ul></ul><ul><ul><li>The Loebner Prize http://www.loebner.net/Prizef/loebner-prize.html </li></ul></ul><ul><ul><ul><li>It’s actually pretty easy to fool people over the short term. </li></ul></ul></ul><ul><ul><ul><li>Chat room ’bots work quite well. </li></ul></ul></ul>
  37. 37. What is Intelligence? <ul><li>Do androids dream … ? </li></ul><ul><li>What would it take for a computer’s thoughts to be indistinguishable from a human’s? </li></ul><ul><li>THIS is the deepest question of CS. </li></ul>

×