CS100J Lecture 27 - PowerPoint PPT Presentation

About This Presentation
Title:

CS100J Lecture 27

Description:

... largest, in alphabetical order within each ... Program has list of keywords weighted by priority. ... Time flies like an arrow, fruit flies like a banana. ... – PowerPoint PPT presentation

Number of Views:109
Avg rating:3.0/5.0
Slides: 15
Provided by: Mill1
Category:

less

Transcript and Presenter's Notes

Title: CS100J Lecture 27


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?

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.

3
Is there anything that can not be computed?
  • Yes. There exists a function f N -gtN that is not
    computable.
  • (1) Consider all Java programs of the form
  • static void main(String args)
  • TokenReader in new TokenReader(System.in)
  • int x in.readInt()
  • / Let y be f(x), for some f N-gtN. /
  • 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-gtN 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-gtN i.e. any conceivable list
  • naturals programs
  • 0 first function f0
  • 1 second function f1
  • 2 third function f2

4
What specifically can not be computed?
  • The Halting Problem A. M. Turing, 1938
  • (1) Consider Java programs of the restricted form
  • static void 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
  • static void main(String args)
  • TokenReader in new TokenReader(System.in)
  • String s in.readString()
  • while ( s.substring(0,6).equals(static))

5
  • (5) Suppose the following program H existed.
  • / Program H. /
  • static void main(String args)
  • TokenReader in new TokenReader(System.in)
  • String s in.readString()
  • boolean b
  • / Set btrue if s is a program that loops
    when
  • given s as input, else set bfalse. /
  • ...
  • 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.

6
  • (6) Then the following program H' would also have
    to exist.
  • / Program H. /
  • static void main(String args)
  • TokenReader in new TokenReader(System.in)
  • String s in.readString()
  • boolean b
  • / Set btrue if s is a program that loops
    when
  • given s as input, else set bfalse. /
  • ...
  • if ( b ) System.out.println(loops")
  • else while( 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.

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.

8
Eliza A 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.

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.

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.

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.

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.

13
Monkeys and bananas problem, continued
  • static void 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

14
Can computers reproduce?
  • John von Neuman's self-reproducing cellular
    automaton.
  • Initial Universe
  • Transition Function f N9 -gt N
  • 0 0 0 0 0 0 0 0 0 0
Write a Comment
User Comments (0)
About PowerShow.com