1 / 14

CS100J Lecture 27

CS100J Lecture 27. Previous Lecture Interfaces Comparable Reflection super Re-Reading: Lewis & Loftus, Section 5.5 Savitch, Appendix 7 This Lecture What can be computed? What can not be computed? Can human capabilities be matched?. What can be computed?.

Download Presentation

CS100J Lecture 27

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS100J Lecture 27 • Previous Lecture • Interfaces • Comparable • Reflection • super • Re-Reading: • Lewis & Loftus, Section 5.5 • Savitch, Appendix 7 • This Lecture • What can be computed? • What can not be computed? • Can human capabilities be matched? Lecture 28

  2. What can be computed? • Church's Thesis: Whatever can be computed can be implemented in the CS100 subset of Java • Pessimists: Terrible – we will never discover any fundamentally more powerful mechanism permitting new things to be computed. • Optimists: Great – we can start immediately trying to program the most difficult problems. Lecture 28

  3. Is there anything that can not be computed? Yes. There exists a function f: N ->Nthat is not computable. (1) Consider all Java programs of the form: staticvoid main(String [] args) { TokenReader in = new TokenReader(System.in); int x = in.readInt(); /* Let y be f(x), for some f: N->N. */ iny y; . . . System.out.println(y); } All such programs are enumerable; e.g., they can be listed from smallest to largest, in alphabetical order within each given size. (2) All functions f: N->N that are computed by such programs are enumerable, e.g., just list the functions computed by the above programs and eliminate duplicates. (3) (Cantor) It is impossible to enumerate all functions f: N->N; i.e. any conceivable list naturals programs 0 first function f0 1 second function f1 2 third function f2 etc. etc. necessarily omits some function, e.g., f(i) = fi(i)+1. (4) So the list given in (2) must be incomplete. Q.E.D. Lecture 28

  4. What specifically can not be computed? The Halting Problem [A. M. Turing, 1938] (1) Consider Java programs of the restricted form staticvoid main(String [] args) { TokenReader in = new TokenReader(System.in); String s = in.readString(); . . . } (2) One possible input for such a program is a copy of itself, (say all on one line). (3) Some such programs, given a copy of themselves, loop forever: staticvoid main(String [] args) { TokenReader in = new TokenReader(System.in); String s = in.readString(); while ( s.substring(0,6).equals(”static”)) { } } (4) Other such programs, given a copy of themselves, halt: staticvoid main(String [] args) { TokenReader in = new TokenReader(System.in); String s = in.readString(); } Lecture 28

  5. (5) Suppose the following program H existed. /* Program H. */ staticvoid main(String [] args) { TokenReader in = new TokenReader(System.in); String s = in.readString() boolean b; /* Set b==true if s is a program that loops when given s as input, else set b==false. */ ... if ( b ) System.out.println("loops"); else System.out.println("halts"); } Note that for every possible input s, program H prints a message and halts. Lecture 28

  6. (6) Then the following program H' would also have to exist. /* Program H’. */ staticvoid main(String [] args) { TokenReader in = new TokenReader(System.in); String s = in.readString() boolean b; /* Set b==true if s is a program that loops when given s as input, else set b==false. */ ... if ( b ) System.out.println(”loops"); elsewhile( true ) { } } (7) Now consider running program H' on input H'. Does it halt or loop? Answer: Neither! Suppose it halts. Then b must be true. But b is true only if s (i.e., H') loops when given s (i.e., H') as input. Contradiction. Suppose it loops. Then b must be false. But b is false only if s (i.e., H') does not loop when given s (i.e., H') as input. Contradiction. (8) Therefore programs H’ and H can not exist. Lecture 28

  7. Can computers match human capabilities? • How can we answer such a question objectively? Turing Test: Terminal A Person Terminal B Computer If Person A can not tell which terminal the Computer is attached to, the Computer passes the test. Lecture 28

  8. ElizaA fanciful attempt to pass the Turing Test • Computer plays psychiatrist. • Program has list of keywords weighted by priority. • Program finds highest priority keyword in sentence. If none, it bluffs. • Each keyword has list of patterns. • Each pattern has several responses. • Program matches a pattern, then outputs a least recently used response. • Responses sometimes incorporate sentence fragments with pronouns reversed. Lecture 28

  9. Sample Eliza Output Men are all alike. IN WHAT WAY. They are always bugging us about something or other. CAN YOU THINK OF A SPECIFIC EXAMPLE. Well, my boyfriend made me come here. YOUR BOYFRIEND MADE YOU COME HERE. He says I'm depressed much of the time. I AM SORRY TO HEAR YOU ARE DEPRESSED. It's true, I am unhappy. DO YOU THINK COMING HERE WILL HELP YOU NOT TO BE UNHAPPY. I need some help, that much seems certain. WHAT WOULD IT MEAN TO YOU IF YOU GOT SOME HELP. Perhaps I could learn to get along with my mother. TELL ME MORE ABOUT YOUR FAMILY. My mother takes care of me. WHO ELSE IN YOUR FAMILY TAKES CARE OF YOU. etc. Lecture 28

  10. Natural Language Translation • Ambiguity makes problem very difficult. For example, Time flies like an arrow, fruit flies like a banana. • Translate English into Russian then back into English. The spirit is willing but the flesh is weak. becomes The vodka is ok but the meat is rotten. Lecture 28

  11. Can computers solve problems posed in natural language? • High-school algebra word problems. Program reads problem in English, defines variables and sets up equations, then solves equations, and outputs answer in English. College physics word problems. "A 150 pound man is standing 10 feet from the top of a 40 foot ladder. The bottom of the ladder is wedged between the ground and a building, and the top of the ladder is attached to the building by a horizontal rope 15 feet long. What is the tension of the rope?” As above, but also applies appropriate physical laws and outputs illustrative diagram. Lecture 28

  12. Can computers solve general problems? • Monkey and banana problems. A monkey is in a room with a chair. Bananas are hanging from the ceiling. The monkey can not reach the bananas while standing on the floor, but can move the chair. The monkey can reach the bananas while standing on the chair when the chair is positioned under the bananas. How can the monkey eat the bananas. Lecture 28

  13. Monkeys and bananas problem, continued staticvoid main(String [] args) { . . . while(bananasPosition != monkeyStomach) choice { if (monkeyAltitude == onChair && chairPosition == underBananas) bananasPosition = monkeyStomach; if (monkeyAltitude == onChair) monkeyAltitude = offChair; if (monkeyAltitude == offChair && monkeyPosition == chairPosition) monkeyAltitude = onChair; if (monkeyAltitude == offChair) monkeyPosition = underBananas; if (monkeyPosition == chairPosition && monkeyAltitude == offChair) { monkeyPosition = underBananas; chairPosition = underBananas; } } /* choice */ } Lecture 28

  14. Can computers reproduce? John von Neuman's self-reproducing cellular automaton. • Initial Universe: • Transition Function: f : N9 -> N 0 0 0 0 0 0 0 0 0 0 Lecture 28

More Related