November 3, 2009Introduction to Cognitive Science Lecture 15: Theory of Computation II 1 Languages...

26
November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II 1 Languages Accepted by Turing Languages Accepted by Turing Machines Machines Example 2: Example 2: Language L = {a Language L = {a [n] [n] b b [n] [n] | n > 0} on the | n > 0} on the alphabet {a, b}. alphabet {a, b}. q q 7 q q 1 1 q q 2 B/B B/B a/B a/B q q 3 q q 8 q q 6 6 q q 5 b/L b/L a/L a/L b/L b/L B/L B/L q q 4 b/B b/B B/R B/R a/R a/R b/R b/R B/L B/L B/R B/R
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of November 3, 2009Introduction to Cognitive Science Lecture 15: Theory of Computation II 1 Languages...

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

1

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

2

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BaabbB…BaabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

3

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabbB…BBabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

4

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabbB…BBabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

5

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabbB…BBabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

6

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabbB…BBabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

7

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabbB…BBabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

8

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabbB…BBabbB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

9

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabBB…BBabBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

10

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabBB…BBabBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

11

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabBB…BBabBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

12

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabBB…BBabBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

13

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBabBB…BBabBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

14

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBbBB…BBBbBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

15

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBbBB…BBBbBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

16

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBbBB…BBBbBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

17

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBbBB…BBBbBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

18

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBBBB…BBBBBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

19

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

B/BB/B

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBBBB…BBBBBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

20

Languages Accepted by Turing MachinesLanguages Accepted by Turing Machines

Example 2: Example 2:

Language L = {aLanguage L = {a[n][n]bb[n][n] | n > 0} on the alphabet {a, b}. | n > 0} on the alphabet {a, b}.

qq77

qq11 qq22

Accept!Accept!

a/Ba/Bqq33

qq88 qq66 qq55

b/Lb/L

a/La/L

b/Lb/L

B/LB/Lqq44

b/Bb/B

B/RB/R

a/Ra/R

b/Rb/R

B/LB/LB/RB/R

……BBBBBB…BBBBBB… ↑ ↑

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

21

TMs as ComputersTMs as ComputersSo what languages can Turing machines accept?So what languages can Turing machines accept?

This class of languages is called the This class of languages is called the recursively recursively enumerable languagesenumerable languages..

For example, it includes the language For example, it includes the language L = {aL = {a[n][n]bb[n][n] | n > 0}, which is not a regular language. | n > 0}, which is not a regular language.

This shows that the unlimited memory leads to This shows that the unlimited memory leads to increased computational capabilitiesincreased computational capabilities..

But what about theBut what about the functions functions that Turing machines that Turing machines can compute?can compute?

(After the TM halts, the symbols on the tape can be (After the TM halts, the symbols on the tape can be regarded as the output of the TM, or the result of the regarded as the output of the TM, or the result of the function it computes.) function it computes.)

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

22

Church’s ThesisChurch’s Thesis

Church’s thesis:Church’s thesis:

Any function that can be algorithmically computed Any function that can be algorithmically computed can also be computed by a Turing machine.can also be computed by a Turing machine.

Why is it only a Why is it only a thesisthesis??

There is no general mathematical definition of There is no general mathematical definition of algorithm – it is always specific to a particular scheme, algorithm – it is always specific to a particular scheme, i.e., a programming language.i.e., a programming language.

Therefore, Church’s thesis cannot be proved.Therefore, Church’s thesis cannot be proved.

However, no counterexample has been found, and no However, no counterexample has been found, and no scientist seriously doubts that Church’s thesis is scientist seriously doubts that Church’s thesis is correct.correct.

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

23

The Halting ProblemThe Halting Problem

Are there any functions that cannot be computed?Are there any functions that cannot be computed?

Yes! Yes!

The most famous of those is the halting problem.The most famous of those is the halting problem.

Let us enumerate all possible Turing machines, i.e., Let us enumerate all possible Turing machines, i.e., give them numbers 1, 2, 3, …give them numbers 1, 2, 3, …

Then the function HALT(x, y) is true if Turing machine Then the function HALT(x, y) is true if Turing machine y terminates when given input x, and is false y terminates when given input x, and is false otherwise.otherwise.

Here comes a Here comes a surprisesurprise::

HALT(x, y) is not a computable function.HALT(x, y) is not a computable function.

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

24

The Halting ProblemThe Halting Problem

Because of Church’s thesis, we can state the halting Because of Church’s thesis, we can state the halting problem in a more general form:problem in a more general form:

There exists no algorithm that can decide for any There exists no algorithm that can decide for any other algorithm whether its computation will ever halt other algorithm whether its computation will ever halt for a given input. for a given input.

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

25

The Halting ProblemThe Halting ProblemIt may surprise you that there is no algorithm for It may surprise you that there is no algorithm for solving the halting problem.solving the halting problem.

But did we not assume that the Theory of But did we not assume that the Theory of Computation applies to Computation applies to allall things that compute, things that compute, including our including our brainsbrains??

And is it not possible for a And is it not possible for a computer scientistcomputer scientist to to analyze a given program and find out whether it will analyze a given program and find out whether it will terminate for a particular input or not (even if this terminate for a particular input or not (even if this analysis takes a very long time)?analysis takes a very long time)?

No, actually we can devise a very simple Turing No, actually we can devise a very simple Turing machine or computer program for which to date machine or computer program for which to date nobodynobody is able to tell whether it will ever terminate. is able to tell whether it will ever terminate.

November 3, 2009 Introduction to Cognitive Science Lecture 15: Theory of Computation II

26

The Halting ProblemThe Halting Problem

This program is based on This program is based on Goldbach’s conjectureGoldbach’s conjecture, , which assumes that every even number 4 is the which assumes that every even number 4 is the sum of two prime numbers.sum of two prime numbers.

For example, 4 = 2 + 2, 6 = 3 + 3, 48 = 41 + 7.For example, 4 = 2 + 2, 6 = 3 + 3, 48 = 41 + 7.

It was first stated by Goldbach in 1742, and despite It was first stated by Goldbach in 1742, and despite great efforts, nobody has ever been able to prove or great efforts, nobody has ever been able to prove or disprove it.disprove it.

It would be easy to build a Turing machine or write a It would be easy to build a Turing machine or write a C, Java, or Basic program that searches for a C, Java, or Basic program that searches for a counterexample to this conjecture.counterexample to this conjecture.

Nobody knowsNobody knows whether this program will ever halt. whether this program will ever halt.