turing machines, computability, computers and intelligence

37
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 29: Computability, Turing Machines, Can Computers Think?

Upload: peterbuck

Post on 17-Nov-2014

1.573 views

Category:

Documents


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Turing Machines, Computability, Computers and Intelligence

1

Foundations of Software DesignFall 2002Marti Hearst

Lecture 29: Computability, Turing Machines, Can Computers Think?  

 

Page 2: Turing Machines, Computability, Computers and Intelligence

2

Computability

• Is there anything a computer cannot compute?• Linked to the notion of what is an algorithm.

Page 3: Turing Machines, Computability, Computers and Intelligence

3

Alan Turing

• An amazing scientist– Helped solved the Enigma Machine (WWII)– Advances in Probability Theory

• Invented the theory behind computers– Turing Machine– Turing Test

Page 4: Turing Machines, Computability, Computers and Intelligence

4

Turing Machines

• Anything that can be computed by a finite set of rules can be computed by a Turing machine.

• Turing Equivalence– We saw that finite automata are less powerful than TMs

• Can’t compute • Thus not Turing-equivalent

– Modern computers and programming languages are all Turing-equivalent

nnba

Page 5: Turing Machines, Computability, Computers and Intelligence

5Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

*aRegular Languages

Context-Free Languagesnnba Rww

nnn cba ww

**ba

Languages accepted byTuring Machines

Page 6: Turing Machines, Computability, Computers and Intelligence

6Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

A Turing Machine

............Tape

Read-Write headControl Unit

Page 7: Turing Machines, Computability, Computers and Intelligence

7Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

The Tape

............

Read-Write head

No boundaries -- infinite length

The head moves Left or Right

Page 8: Turing Machines, Computability, Computers and Intelligence

8Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

............

Read-Write head

The head at each time step:

1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right

Page 9: Turing Machines, Computability, Computers and Intelligence

9Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

............

Example:Time 0

............Time 1

1. Reads2. Writes

a a cb

a b k c

ak

3. Moves Left

Page 10: Turing Machines, Computability, Computers and Intelligence

10Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

The Input String

............

Blank symbol

head

a b ca

Head starts at the leftmost positionof the input string

Input string

Page 11: Turing Machines, Computability, Computers and Intelligence

11Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

States & Transitions

1q 2qLba ,

Read Write Move Left

1q 2qRba ,

Move Right

Page 12: Turing Machines, Computability, Computers and Intelligence

12Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

Example:

1q 2qRba ,

............ a b ca

Time 1

1qcurrent state

Page 13: Turing Machines, Computability, Computers and Intelligence

13Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

............ a b caTime 1

1q 2qRba ,

............ a b cbTime 2

1q

2q

Page 14: Turing Machines, Computability, Computers and Intelligence

14Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

Determinism

1q

2qRba ,

Allowed Not Allowed

3qLdb ,

1q

2qRba ,

3qLda ,

Turing Machines are deterministic

Page 15: Turing Machines, Computability, Computers and Intelligence

15Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

Halting

The machine halts if there areno possible transitions to follow

Page 16: Turing Machines, Computability, Computers and Intelligence

16Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

Example:

............ a b ca

1q

1q

2qRba ,

3qLdb ,

No possible transition

HALT!!!

Page 17: Turing Machines, Computability, Computers and Intelligence

17Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

Final States1q 2q Allowed

1q 2q Not Allowed

• Final states have no outgoing transitions• In a final state the machine halts

Page 18: Turing Machines, Computability, Computers and Intelligence

18Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

AcceptanceAccept 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

Page 19: Turing Machines, Computability, Computers and Intelligence

19Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

Infinite Loop Example

0q

Raa ,

L,1q

Lbb ,

A Turing machine for language *aa

Page 20: Turing Machines, Computability, Computers and Intelligence

20Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

baTime 0

0q

a

0q

Raa ,

L,1q

Lbb ,

Page 21: Turing Machines, Computability, Computers and Intelligence

21Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

baTime 1

0q

a

0q

Raa ,

L,1q

Lbb ,

Page 22: Turing Machines, Computability, Computers and Intelligence

22Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

baTime 2

0q

a

0q

Raa ,

L,1q

Lbb ,

Page 23: Turing Machines, Computability, Computers and Intelligence

23Adapted from slide by Costas Busch, http://www.cs.rpi.edu/courses/fall01/modcomp/

baTime 2

0q

a

baTime 3

0q

a

baTime 4

0q

a

baTime 5

0q

a... Infinite Loop

Page 24: Turing Machines, Computability, Computers and Intelligence

24Adapted from slides by Lee Wee Sun, http://www.comp.nus.edu.sg/~cs1305/2000/

Church-Turing Thesis

The Church-Turing thesis says that Turing machine algorithms are the same as our intuitive notion of algorithms.– Most people think the Church Turing thesis is correct.– It means, among other things that

• 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.

• Tasks that humans agree is an algorithm can always be executed on a computer.

Page 25: Turing Machines, Computability, Computers and Intelligence

25Adapted from slides by Lee Wee Sun, http://www.comp.nus.edu.sg/~cs1305/2000/

The Halting Problem

• An example of something that is not computable.

• Created by Turing in 1936 to define a problem which no algorithmic procedure can solve.

• Can we write a program that will take in a user's program and inputs and decide whether – it will eventually stop, or– it will run infinitely in some infinite loop ?

Page 26: Turing Machines, Computability, Computers and Intelligence

26Adapted from slides by Lee Wee Sun, http://www.comp.nus.edu.sg/~cs1305/2000/

Proof (by contradiction)

• Assume that it is possible to write a program to solve the Halting Problem.

• Denote this program by HaltAnswerer(prog,inputs). • HaltAnswerer(prog,inputs) will

– return yes if prog will halt on inputs and – no otherwise.

• A program is just a string of characters– E.g. your Java program is just a long string of characters

• An input can also be considered as just a string of characters

• So HaltAnswerer is effectively just working on two strings

Page 27: Turing Machines, Computability, Computers and Intelligence

27Adapted from slides by Lee Wee Sun, http://www.comp.nus.edu.sg/~cs1305/2000/

Proof (cont.)

• We can now write another program Loopy(prog) that uses HaltAnswerer

• The program Loopy(prog) does the following:

[1] If HaltAnswerer(prog,prog) returns yes, Loopy will go into an infinite loop.

[2] If HaltAnswerer(prog,prog) returns no, Loopy will halt.

Page 28: Turing Machines, Computability, Computers and Intelligence

28Adapted from slides by Lee Wee Sun, http://www.comp.nus.edu.sg/~cs1305/2000/

Proof (cont.)

[1] If HaltAnswerer(prog,prog) returns yes, Loopy will go into an infinite loop.

[2] If HaltAnswerer(prog,prog) returns no, Loopy will halt.

• Consider what happens when we run Loopy(Loopy).– If Loopy loops infinitely,

• HaltAnswerer(Loopy,Loopy) return no which by [2] above means Loopy will halt.

– If Loopy halts, • HaltAnswerer(Loopy,Loopy) will return yes which by [1] above

means Loopy will loop infinitely.

• Conclusion: Our assumption that it is possible to write a program to solve the Halting Problem has resulted in a contradiction.

Page 29: Turing Machines, Computability, Computers and Intelligence

29

Diagonalization

• Not Diagon Alley• A proof by contradiction technique

– Uses the notion of Infinity• The name comes from a proof that shows you can’t ever list all

numbers.– Assume you list all possible binary numbers– Diagonalization shows you can always construct a new

number that is not yet in the list• Have to assume numbers can have infinite length

– Construct the new number by choosing the opposite of the number on the diagonal.

Page 30: Turing Machines, Computability, Computers and Intelligence

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 …

Page 31: Turing Machines, Computability, Computers and Intelligence

31

The Universal Turing Machine

• There are an infinite number of Turing Machines• There are an infinite number of calculations that

can be done with a finite set of rules.• However, we can define a Universal Turing

Machine which can simulate all possible TMs– Comes from the definition of TMs– You convert the description of the TM and its input into

two tapes, and use these as the input to the UTM

Page 32: Turing Machines, Computability, Computers and Intelligence

32

The Halting Problem

• Halting Problem: – There is no procedure for telling whether an arbitrary TM

will halt on a given input.• Use Diagonalization to show this.

– Again, proof by contradiction– Assume there is a rule for deciding if a TM will halt.

• Construct a table as follows:– List all Turing machines down the side– List the possible inputs across the top– In position (j,i) put the result of executing Turing machine j

on input i• If it halts, output H• If it doesn’t halt, output ?

Page 33: Turing Machines, Computability, Computers and Intelligence

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 ? …

Page 34: Turing Machines, Computability, Computers and Intelligence

34

Diagonalization on the Halting Problem

• Now define a new TM called D that will halt for all inputs. It outputs– H if TMi(i) does not halt– ? if TMi(i) does halt

• We already said that the assumption is that we can always decide if a TM halts.

• Also, we said this table lists all possible TMs.– So D must be in the table.

• But this means that we are saying that D outputs halt if it doesn’t halt! – To see this, give D as input to itself.

• This is a contradiction. Hence the premise does not hold: We cannot determine if an arbitrary program will halt.

Page 35: Turing Machines, Computability, Computers and Intelligence

35

“Going Meta”

• This proof based in part on Gödel’s Theorem• If you are interested in these kinds of

questions (and other things related to “going meta” like compiler compilers), see– Gödel, Escher, Bach: An Eternal Golden Braid, by

Douglas Hofstadter.

Page 36: Turing Machines, Computability, Computers and Intelligence

36

The Turing Test

• An observer – Interacts with a keyboard and monitor– Has to distinguish which of two respondents is a

computer and which is human.

• There is a contest with a $100,000 prize!– For the first computer whose responses are

indistinguishable from a human's. – The Loebner Prize http://www.loebner.net/Prizef/loebner-prize.html

• It’s actually pretty easy to fool people over the short term.

• Chat room ’bots work quite well.

Page 37: Turing Machines, Computability, Computers and Intelligence

37

What is Intelligence?

• Do androids dream … ?

• What would it take for a computer’s thoughts to be indistinguishable from a human’s?

• THIS is the deepest question of CS.