cd5560 faber formal languages, automata and models of computation lecture 13 mälardalen university...

168
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 13 Mälardalen University 2007

Upload: briar

Post on 25-Feb-2016

35 views

Category:

Documents


0 download

DESCRIPTION

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 13 Mälardalen University 2007. Content Introduction Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice’s Theorem Interactive Computing & Persistent TM’s (Dina Goldin). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

1

CD5560

FABERFormal Languages, Automata

and Models of ComputationLecture 13

Mälardalen University

2007

Page 2: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

2

Content

Introduction Universal Turing Machine Chomsky Hierarchy DecidabilityReducibilityUncomputable FunctionsRice’s TheoremInteractive Computing & Persistent TM’s (Dina Goldin)

Page 3: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

3

http://www.turing.org.uk/turing/

Who was Alan Turing?Founder of computer science, mathematician, philosopher, codebreaker, visionary man before his time.

http://www.cs.usfca.edu/www.AlanTuring.net/turing_archive/index.html- Jack Copeland and Diane Proudfoot

http://www.turing.org.uk/turing/ The Alan Turing Home PageAndrew Hodges

Page 4: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

4

Alan Turing

1912 (23 June): Birth, London

1926-31: Sherborne School

1930: Death of friend Christopher Morcom

1931-34: Undergraduate at King's College, Cambridge University

1932-35: Quantum mechanics, probability, logic

1935: Elected fellow of King's College, Cambridge

1936: The Turing machine, computability, universal machine

1936-38: Princeton University. Ph.D. Logic, algebra, number theory

1938-39: Return to Cambridge. Introduced to German Enigma cipher machine

1939-40: The Bombe, machine for Enigma decryption

1939-42: Breaking of U-boat Enigma, saving battle of the Atlantic

Page 5: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

5

Alan Turing

1943-45: Chief Anglo-American crypto consultant. Electronic work.

1945: National Physical Laboratory, London

1946: Computer and software design leading the world.

1947-48: Programming, neural nets, and artificial intelligence

1948: Manchester University

1949: First serious mathematical use of a computer

1950: The Turing Test for machine intelligence

1951: Elected FRS. Non-linear theory of biological growth

1952: Arrested as a homosexual, loss of security clearance

1953-54: Unfinished work in biology and physics

1954 (7 June): Death (suicide) by cyanide poisoning, Wilmslow, Cheshire.

Page 6: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

6

Hilbert’s Program, 1900

Hilbert’s hope was that mathematics would be reducible to finding proofs (manipulating the strings of symbols) from a fixed system of axioms, axioms that everyone could agree were true.

Can all of mathematics be made algorithmic, or will there always be new problems that outstrip any given algorithm, and so require creative acts of mind to solve?

Page 7: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

7

TURING MACHINES

Page 8: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

8

Turing’s "Machines". These machines are humans who calculate. (Wittgenstein)

A man provided with paper, pencil, and rubber, and subject to strict discipline, is in effect a universal machine. (Turing)

Page 9: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

9

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

Read-Write headControl Unit

Standard Turing Machine

Page 10: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

10

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

Read-Write head

No boundaries -- infinite length

The head moves Left or Right

The Tape

Page 11: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

11

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

Read-Write head

1. Reads a symbol2. Writes a symbol3. Moves Left or Right

The head at each time step:

Page 12: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

12

ExampleTime 0

............ a a cb

Time 1............ a b k c

1. Reads a2. Writes k3. Moves Left

Page 13: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

13

Head starts at the leftmost positionof the input string

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

Blank symbol

head

a b ca

Input string

The Input String

#####

Page 14: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

14

1q 2qLba ,

Read Write Move Left

1q 2qRba ,

Move Right

States & Transitions

Page 15: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

15

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

1q 2qRba ,

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

1q

2q

# # # #

# # # # #

Page 16: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

16

Determinism

1q

2qRba ,

Allowed Not Allowed

3qLdb ,

1q

2qRba ,

3qLda ,

No lambda transitions allowed in standard TM!

Turing Machines are deterministic

Page 17: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

17

Formal Definitions for

Turing Machines

Page 18: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

18

Transition Function

1q 2qRba ,

),,(),( 21 Rbqaq

Page 19: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

19

Turing Machine

),#,,,,,( 0 FqQM

Transitionfunction

Initialstate

blank

Finalstates

States

Inputalphabet

Tapealphabet

Page 20: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

20

Universal Turing Machine

Page 21: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

21

A limitation of Turing Machines:

Better are reprogrammable machines.

Turing Machines are “hardwired”

they executeonly one program

Page 22: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

22

Solution: Universal Turing Machine

• Reprogrammable machine

• Simulates any other Turing Machine

Characteristics:

Page 23: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

23

Universal Turing Machine

simulates any other Turing Machine M

Input of Universal Turing Machine

• Description of transitions of M• Initial tape contents of M

Page 24: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

24

Universal Turing Machine

Description of Three tapes

MTape Contents of

Tape 2

State of M

Tape 3

M

Tape 1

Page 25: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

25

We describe Turing machine as a string of symbols:

We encode as a string of symbols

M

M

Description of M

Tape 1

Page 26: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

26

Alphabet Encoding

Symbols: a b c d

Encoding: 1 11 111 1111

Page 27: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

27

State Encoding

States: 1q 2q 3q 4q

Encoding: 1 11 111 1111

Head Move Encoding

Move:

Encoding:

L R

1 11

Page 28: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

28

Transition Encoding

Transition: ),,(),( 21 Lbqaq

Encoding: 10110110101

separator

Page 29: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

29

Machine Encoding

Transitions:

),,(),( 21 Lbqaq

Encoding:

10110110101

),,(),( 32 Rcqbq

110111011110101100

separator

Page 30: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

30

Tape 1 contents of Universal Turing Machine:

encoding of the simulated machine M as a binary string of 0’s and 1’s

Page 31: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

31

A Turing Machine is described with a binary string of 0’s and 1’s.

The set of Turing machines forms a language:

Each string of the language isthe binary encoding of a Turing Machine.

Therefore:

Page 32: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

32

Language of Turing Machines

L = { 010100101,

00100100101111,

111010011110010101, …… }

(Turing Machine 1)

(Turing Machine 2)

……

Page 33: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

33

The Chomsky Hierarchy

Page 34: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

34Non-recursively enumerable

Recursively-enumerable

Recursive

Context-sensitive

Context-free

Regular

The Chomsky Language Hierarchy

Page 35: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

35

Unrestricted Grammars

Productionsvu

String of variablesand terminals

String of variablesand terminals

Page 36: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

36

Example of unrestricted grammar

dAccAaB

aBcS

Page 37: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

37

A language L is recursively enumerableif and only if it is generated by anunrestricted grammar.

Theorem

Page 38: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

38

Context-Sensitive Grammars

and |||| vu

Productions

vu

String of variablesand terminals

String of variablesand terminals

Page 39: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

39

The language }{ nnn cbais context-sensitive:

aaAaaaBBbbBBbccAcbAAb

aAbcabcS

|

|

Page 40: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

40

A language L is context sensitiveif and only if it is accepted by a Linear-Bounded automaton.

Theorem

Page 41: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

41

Linear Bounded Automata (LBAs)are the same as Turing Machineswith one difference:

The input string tape spaceis the only tape space allowed to use.

Page 42: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

42

[ ]a b c d e

Left-endmarker

Input string

Right-endmarker

Working space in tape

All computation is done between end markers.

Linear Bounded Automaton (LBA)

Page 43: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

43

There is a language which is recursivebut not context-sensitive.

Observation

Page 44: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

44

Decidability

Page 45: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

45

Consider problems with answer YES or NO.

Examples

• Does Machine M have three states ?

• Is string w a binary number?

• Does DFA M accept any input?

Page 46: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

46

A problem is decidable if some Turing machinesolves (decides) the problem.

Decidable problems:

• Does Machine M have three states ?

• Is string w a binary number?

• Does DFA M accept any input?

Page 47: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

47

Turing Machine

Inputprobleminstance

YES

NO

The Turing machine that solves a problemanswers YES or NO for each instance.

Page 48: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

48

The machine that decides a problem:

• If the answer is YES then halts in a yes state

• If the answer is NO then halts in a no state

These states may not be the final states.

Page 49: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

49

Turing Machine that decides a problem

YES and NO states are halting states

YES

NO

Page 50: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

50

Difference between

Recursive Languages accept (“Acceptera”) and Decidable problems decide (“Avgöra”)

The YES states may not be final states.

For decidable problems:

Page 51: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

51

Some problems are undecidable:

There is no Turing Machine thatsolves all instances of the problem.

Page 52: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

52

A famous undecidable problem:

The halting problem

Page 53: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

53

The Halting Problem

Input:• Turing Machine M• String w

Question: Does M halt on w?

Page 54: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

54

Theorem

The halting problem is undecidable.

Proof

Assume to the contrary thatthe halting problem is decidable.

Page 55: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

55

There exists Turing Machine Hthat solves the halting problem

M halts on w

HM

w

YES

NO M doesn’t halt on w

Page 56: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

56

H

wwM 0qyq

nq

Input:initial tape contents

encoding of Mstring w

YES

NO

Construction of H

Page 57: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

57

Construct machine H´

If H returns YES then loop forever.

If H returns NO then halt.

Page 58: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

58

H

wwM 0qyq

nq NO

aq bq

H

Loop forever

YES

Page 59: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

59

HConstruct machine

Input:

If M halts on input Mw

Then loop forever

Else halt

Mw (machine )M

Page 60: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

60

Mw MM wwcopy

Mw H

H

Page 61: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

61

HRun machine with input itself

Input:

If halts on input

Then loop forever

Else halt

Hw ˆ (machine )H

H Hw ˆ

Page 62: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

62

on input H Hw ˆ

If halts then loops forever.

If doesn’t halt then it halts.

:

H

H

CONTRADICTION !

Page 63: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

63

This means that

The halting problem is undecidable.

END OF PROOF

Page 64: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

64

Another proof of the same theorem

If the halting problem was decidable thenevery recursively enumerable languagewould be recursive.

Page 65: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

65

Theorem

The halting problem is undecidable.

Proof

Assume to the contrary thatthe halting problem is decidable.

Page 66: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

66

There exists Turing Machine Hthat solves the halting problem.

M halts on w

HM

w

YES

NO M doesn’t halt on w

Page 67: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

67

Let L be a recursively enumerable language.

Let M be the Turing Machine that accepts L.

We will prove that L is also recursive:

We will describe a Turing machine thataccepts L and halts on any input.

Page 68: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

68

M halts on w ?YES

NOM

w

Run M with input w

Hreject w

Turing Machine that accepts Land halts on any input

Halts on final state

Halts on non-final state

accept w

reject w

Page 69: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

69

Therefore L is recursive.

But there are recursively enumerablelanguages which are not recursive.

Contradiction!

Since L is chosen arbitrarily, we have proven that every recursively enumerablelanguage is also recursive.

Page 70: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

70

Therefore, the halting problem is undecidable.

END OF PROOF

Page 71: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

71

A simple undecidable problem:

The Membership Problem

Page 72: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

72

The Membership Problem

Input:

• Turing Machine M• String w

Question: Does M accept w?

Page 73: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

73

Theorem

The membership problem is undecidable.

Proof

Assume to the contrary thatthe membership problem is decidable.

Page 74: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

74

There exists Turing Machine Hthat solves the membership problem

M accepts w

HM

w

YES

NO M rejects w

Page 75: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

75

Let L be a recursively enumerable language.

Let M be the Turing Machine that accepts L.

We will prove that L is also recursive:

We will describe a Turing machine that

accepts L and halts on any input.

Page 76: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

76

M accepts w?NO

YESM

w

Haccept w

Turing Machine that accepts Land halts on any input

reject w

Page 77: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

77

But there are recursively enumerablelanguages which are not recursive.

Contradiction!

Therefore L is recursive.

Since L is chosen arbitrarily, we have proven that every recursively enumerablelanguage is also recursive.

Page 78: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

78

Therefore, the membership problem is undecidable.

END OF PROOF

Page 79: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

79

Reducibility

Page 80: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

80

Problem A is reduced to problem B.

If we can solve problem B then

we can solve problem A.

B

A

Page 81: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

81

If B is decidable then A is decidable.

If A is undecidable then B is undecidable.

Problem A is reduced to problem B.

Page 82: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

82

Example

the halting problem

reduced to

the state-entry problem.

Page 83: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

83

The state-entry problem

Input:

•Turing Machine M•State q•String w

Question:

Does M enter state qon input w?

Page 84: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

84

Theorem

The state-entry problem is undecidable.

ProofReduce the halting problem to

the state-entry problem.

Page 85: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

85

Suppose we have an algorithm (Turing Machine)that solves the state-entry problem.

We will construct an algorithmthat solves the halting problem.

Page 86: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

86

Algorithm for state-entry problem

Mw

q

YES

NO

M enters q

Assume we have the state-entry algorithm:

M doesn’t enter q

Page 87: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

87

Algorithm for Halting problem

M

w

YES

NO

We want to design the halting algorithm:

M halts on q

M doesn’t halt on q

Page 88: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

88

Modify input machine M • Add new state q

• From any halting state add transitions to q

M q

halting states

singlehalt state

M

Page 89: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

89

M halts

M halts on state q

if and only if

Page 90: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

90

Algorithm for halting problem

Input: machine M and string w

2. Run algorithm for state-entry problem

with inputs: M’, q, w

1. Construct machine M’ with state q

Page 91: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

91

Generate

M M

w

M qw

State-entryalgorithm

Halting problem algorithm

YES

NO

YES

NO

Page 92: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

92

Since the halting problem is undecidable,it must be that the state-entry problemis also undecidable.

END OF PROOF

We reduced the halting problemto the state-entry problem.

Page 93: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

93

Input: Turing Machine M

Question: Does M halt when started with a blank tape?

Another example

The halting problem reduced tothe blank-tape halting problem.

Page 94: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

94

ProofReduce the halting problem to theblank-tape halting problem.

Theorem

The blank-tape halting problem is undecidable.

Page 95: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

95

Suppose we have an algorithmfor the blank-tape halting problem.

We will construct an algorithmfor the halting problem.

Page 96: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

96

Algorithm for blank-tape halting problem

M

YES

NO

M halts onblank tape

Assume we have the blank-tape halting algorithm

M doesn’t halton blank tape

Page 97: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

97

M

We want to design the halting algorithm:

Algorithm for halting problem

w

YES

NO

M halts on w

M doesn’t halt on w

Page 98: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

98

wMConstruct a new machine

• On blank tape writes w• Then continues execution like M

wM

Mthen write w

step 1 step2if blank tape execute

with input w

Page 99: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

99

M halts on input string

wM halts when started with blank tape.

if and only if

w

Page 100: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

100

Algorithm for halting problem

1. Construct wM

2. Run algorithm for blank-tape halting problem with input wM

Inputs: machine and stringM w

Page 101: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

101

Generate

wMMw

Blank-tape halting algorithm

Halting problem algorithm

YES

NOwM

YES

NO

Page 102: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

102

Since the halting problem is undecidable,the blank-tape halting problem is also undecidable.

END OF PROOF

We reduced the halting problemto the blank-tape halting problem.

Page 103: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

103

Summary of Undecidable Problems

Halting Problem

Does machine M halt on input w?

Membership problem

Does machine M accept string w?

In other words: Is a string w a member of a

recursively enumerable language L?)

Page 104: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

104

Does machine M halt when startingon blank tape?

Blank-tape halting problem

State-entry Problem:

Does machine M enter state q on input w?

Page 105: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

105

Uncomputable Functions

Page 106: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

106

Uncomputable Functions

A function is uncomputable if it cannotbe computed for all of its domain.

Domain Range

f

Page 107: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

107

An uncomputable function:

)(nfmaximum number of moves until

any Turing machine with n states halts when started with the blank tape.

Example

Page 108: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

108

TheoremFunction is uncomputable.

)(nf

Then the blank-tape halting problem is decidable.

ProofAssume to the contrary that

is computable.)(nf

Page 109: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

109

Algorithm for blank-tape halting problem

Input: machine M

1. Count states of : M m2. Compute )(mf3. Simulate for steps starting with empty tape

M )(mf

If halts then return YES otherwise return NO

M

Page 110: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

110

Therefore, the blank-tape haltingproblem must be decidable.

However, we know that the blank-tape halting problem is undecidable.

Contradiction!

Page 111: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

111

Therefore, function is uncomputable.

)(nf

END OF PROOF

Page 112: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

112

Rice’s Theorem

Page 113: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

113

Non-trivial properties of recursively enumerable languages:

any property possessed by some (not all)recursively enumerable languages.

Definition

Page 114: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

114

Some non-trivial properties of recursively enumerable languages:

• L is empty

• L is finite

• L contains two different stringsof the same length

Page 115: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

115

Rice’s Theorem

Any non-trivial property of a recursively enumerable languageis undecidable.

Page 116: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

116

We will prove some non-trivial propertieswithout using Rice’s theorem.

Page 117: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

117

TheoremFor any recursively enumerable language Lit is undecidable whether it is empty.

ProofWe will reduce the membership problem

to the problem of deciding whether Lis empty.

Page 118: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

118

Membership problem:

Does machine M accept string w?

Page 119: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

119

Algorithm for empty languageproblem

MYES

NO

Assume we have the empty language algorithm:

Let M be the machine that accepts L

L(M) non-empty

LML )(

L(M) empty

Page 120: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

120

Algorithm for membershipproblem

M

w

YES

NO

M accepts w

We will design the membership algorithm:

M rejects w

Page 121: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

121

First construct machine wM

When M enters a final state, compare original input string with w.

Accept if original input is

the same as w.

Page 122: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

122

Lw

)( wML is not empty

if and only if

}{)( wML w

Page 123: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

123

Algorithm for membership problem

Inputs: machine and string M w

1. Construct wM

2. Determine if is empty )( wML

YES: then )(MLw

NO: then )(MLw

Page 124: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

124

construct

wM

Check if

)( wMLis empty

YES

NO

M

w

NO

YES

Membership algorithm

wM

Page 125: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

125

Since the membership problem is undecidable,the empty language problem is also undecidable.

END OF PROOF

We reduced the empty language problemto the membership problem.

Page 126: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

126

Decidability…continued…

Page 127: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

127

Theorem

For a recursively enumerable language Lit is undecidable whether L is finite.

Proof

We will reduce the halting problemto the finite language problem.

Page 128: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

128

Assume we have the finite language algorithm:

Algorithm for finite languageproblem

M

YES

NO

L(M) finite

Let M be the machine that accepts L

LML )(

L(M) not finite

Page 129: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

129

We will design the halting problem algorithm:

MAlgorithm for halting problem

w

YES

NO

M halts on w

M doesn’t halt on w

Page 130: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

130

First construct machine .wM

When M enters a halt state, accept any input (infinite language).

Initially simulates M on input w.

Otherwise accept nothing (finite language).

Page 131: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

131

M halts on

)( wML is not finite.

if and only if

w

Page 132: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

132

Algorithm for halting problem:Inputs: machine and string M w

1. Construct wM2. Determine if is finite )( wML

YES: then doesn’t halt on M wNO: then halts on M w

Page 133: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

133

construct

wM

Check if

)( wMLis finite

YES

NO

M

w

NO

YES

Machine for halting problem

Page 134: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

134

Since the halting problem is undecidable,the finite language problem is also undecidable.

END OF PROOF

We reduced the finite language problemto the halting problem.

Page 135: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

135

TheoremFor a recursively enumerable language L it is undecidable whether L contains two different strings of same length.

ProofWe will reduce the halting problemto the two strings of equal length- problem.

Page 136: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

136

Assume we have the equal-strings algorithm:

Let M be the machine that accepts L:

LML )(

Algorithm for two-stringsproblem

MYES

NO

L(M) contains

L(M) does not containtwo equal length strings

Page 137: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

137

We will design the halting problem algorithm:

MAlgorithm for halting problem

w

YES

NO

M halts on w

M doesn’t halt on w

Page 138: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

138

First construct machine wM

When M enters a halt state, accept symbols a and b.

Initially simulates M on input w.

(two equal length strings)

Page 139: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

139

M halts on

wM

if and only if

w

accepts and a b

(two equal length strings)

Page 140: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

140

Algorithm for halting problem

Inputs: machine and string M w

1. Construct wM2. Determine if accepts two strings of equal length

wM

YES: then halts on M wNO: then doesn’t halt on M w

Page 141: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

141

construct

wMCheck if

)( wMLhas twoequal lengthstrings

YES

NO

M

w

YES

NO

Machine for halting problem

Page 142: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

142

Since the halting problem is undecidable,the two strings of equal length problem is also undecidable.

END OF PROOF

We reduced the two strings of equal length - problem to the halting problem.

Page 143: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

143

If is a set of Turing-acceptable languages, containing some but not all such languages, no TM can decide for an arbitrary Turing-acceptable language L if L belongs to or not.

Rice's theorem: (Henry Gordon Rice ) If S is a non-trivial property of Turing-acceptable languages, then the problem ‘Does L(M) have the property S? is undecidable.

Any nontrivial property of the language recognized by a Turing machine is undecidable.(Only trivial properties of programs are algorithmically decidable. Undecidability is not the exception when it comes to recursively enumerable sets, it is the rule. )

Page 144: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

144

Example

Given a Turing machine M, is it possible to decide if all strings accepted by M start and end with the same symbol?

Page 145: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

145

Undecidable

Problem is about non-trivial property of a language. There exist TM’s with given property, and TM’s without.

Page 146: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

146

Formally

= { L | TM acceptable languagesWith strings that start and end

with the same symbol. }

Page 147: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

147

 Interaction: Conjectures, Results, and Myths

Dina GoldinUniv. of Connecticut, Brown University

http://www.cse.uconn.edu/~dqg

Page 148: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

148

Fundamental Questions Underlying Theory of Computation

What is computation?

How is computation modeled?

Page 149: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

149

Shared Wisdom(from our undergraduate Theory of Computation courses)

computation: finite transformation of input to output

input: finite size (e.g. string or number)

closed system: all input available at start, all output generated at end

behavior: functions, transformation of input data to output data

Church-Turing thesis: Turing Machines capture this (algorithmic) notion of computation

Mathematical worldview:

All computable problems

are function-based.

Page 150: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

150

“The theory of computability and non-computability [is] usually referred to as the theory of recursive functions... the notion of TM has been made central in the development."

Martin Davis, Computability & Unsolvability, 1958

“Of all undergraduate CS subjects, theoretical computer science has changed the least over the decades.”

SIGACT News, March 2004

“A TM can do anything that a computer can do.”Michael Sipser, Introduction to the Theory of Computation, 1997

The Mathematical Worldview

Page 151: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

151

The Operating System Conundrum*

Real programs, such as operating systems and word processors, often receive an unbounded amount of input over time, and never "finish" their task. Turing machines do not model such ongoing computation well…

[TM entry, Wikipedia]

If a computation does not

terminate, it’s “useless” – but aren’t OS’s

useful??

* Enigma

Page 152: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

152

Rethinking Shared Wisdom:(what do computers do?)

computation: finite transformation of input to output

input: finite-size (string or number)

closed system: all input available at start, all output generated at end

behavior: functions, algorithmic transformation of input data to output data

Church-Turing thesis: Turing Machines capture this (algorithmic) notion of computation

computation: ongoing process which performs a task or delivers a service

dynamically generated stream of input tokens (requests, percepts, messages)

open system: later inputs depend on earlier outputs and vice versa (I/O entanglement, history dependence)

behavior: processes, components, control devices, reactive systems, intelligent agents

Wegner’s conjecture: Interaction is more powerful than algorithms

Page 153: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

153

Example: Driving home from work

Algorithmic input: a description of the world (a static “map”)

Output: a sequence of pairs of #s (time-series data)- for turning the wheel- for pressing gas/break

Similar to classic AI search/planning problems.

Page 154: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

154

But… in a real-world environment, the output depends on every grain of sand in the road (chaotic behavior).

Can we possibly have a map that’s detailed enough?Worse yet… the domain is dynamic. The output depends on weather conditions, and on other drivers and pedestrians.

We can’t possibly be expected to predict that in advance!Nevertheless the problem is solvable!

Google “autonomous vehicle research”

Driving home from work (cont.)

?

Page 155: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

155

Driving home from work (cont.)

The problem is solvable interactively.

Interactive input: stream of video camera images, gathered as we are driving

Output: the desired time-series data, generated as we are driving

similar to control systems, or online computation

A paradigm shift in the conceptualization of computational problem solving.

Page 156: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

156

Sequential Interaction

• Sequential interactive computation: system continuously interacts with its environment

by alternately accepting an input string and computing a corresponding output string.

• Examples:- method invocations of an object instance

in an OO language- a C function with static variables- queries/updates to single-user databases- recurrent neural networks

- control systems- online computation- transducers- dynamic algorithms- embedded systems

Page 157: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

157

Sequential Interaction Thesis

• Universal PTM: simulates any other PTM– Need additional input describing the PTM (only once)

• Example: simulating Answering Machine(simulate AM, will-do), (record hello, ok), (erase, done), (record John, ok),(record Hopkins, ok), (playback, John Hopkins), …

Simulation of other sequential interactive systems is analogous.

Whenever there is an effective method for performing sequential interactive computation, this computation

can be performed by a Persistent Turing Machine

Page 158: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

158

Church-Turing Thesis Revisited

• Church-Turing Thesis: Whenever there is an effective method for obtaining the values of a mathematical function, the function can be computed by a Turing Machine

• Common Reinterpretation (Strong Church-Turing Thesis) A TM can do (compute) anything that any computer can do!

Page 159: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

159

Church-Turing Thesis Revisited

• The equivalence of the two is a myth – the function-based behavior of algorithms does not

capture all forms of computation– this myth has been dogmatically accepted by the CS

community• Turing himself would have denied it

– in the same paper where he introduced what we now call Turing Machines, he also introduced choice machines, as a distinct model of computation

– choice machines extend Turing Machines to interaction by allowing a human operator to make choices during the computation.

Page 160: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

160

Origins of the Church-Turing Thesis Myth

A TM can do anything that a computer can do.

Based on several claims:1. A problem is solvable if there exists a Turing Machine

for computing it.2. A problem is solvable if it can be specified by an algorithm.3. Algorithms are what computers do.

Each claim is correct in isolationprovided we understand the underlying assumptions

Together, they induce an incorrect conclusionTMs = solvable problems = algorithms = computation

Page 161: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

161

Deconstructing the Turing Thesis Myth (1)

TMs = solvable problems

• Assumes:All computable problems are function-based.

• Reasons: – Theory of Computation started as a field of mathematics;

mathematical principles were adopted for the fundamental notions of computation, identifying computability with the computation of functions, as well as with Turing Machines.

– The batch-based modus operandi of original computers did not lend itself to other conceptualizations of computation.

Page 162: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

162

Deconstructing the Turing Thesis Myth (2)

solvable problems = algorithms

Assumes:- Algorithmic computation is also function based;

i.e., the computational role of an algorithm is to transform input data to output data.

• Reasons: – Original (mathematical) meaning of “algorithms”

E.g. Euclid’s greatest common divisor algorithm

– Original (Knuthian) meaning of “algorithms” “An algorithm has zero or more inputs, i.e., quantities which are given to it initially before the algorithm begins.“ [Knuth’68]

Page 163: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

163

Deconstructing the Turing Thesis Myth (3)

algorithms = computation

• Reasons: – The ACM Curriculum (1968): Adopted algorithms as the central concept of

CS without explicit agreement on the meaning of this term.

– Textbooks: When defining algorithms, the assumption of their closed function-based nature was often left implicit, if not forgotten

“An algorithm is a recipe, a set of instructions or the specifications of a process for doing something. That something is usually solving a problem of some sort.” [Rice&Rice’69]

“An algorithm is a collection of simple instructions for carrying out some task. Commonplace in everyday life, algorithms sometimes are called procedures or recipes...” [Sipser’97]

Page 164: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

164

The Shift to Interaction in CS

Computation = transforming input to output

Computation = carrying out a task over time

Logic and search in AI Intelligent agents, partially observable environments, learning

Procedure-oriented programming

Object-oriented programming

Closed systems Open systemsCompositional behavior Emergent behaviorRule-based reasoning Simulation, control, semi-

Markov processes

Algorithmic Interactive

Page 165: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

165

The Interactive Turing Test• From answering questions to holding

discussions.• Learning from -- and adapting to -- the

questioner.• “Book intelligence” vs. “street smarts”.

“It is hard to draw the line at what is intelligence and what is environmental interaction. In a sense, it does not really matter which is which, as all intelligent systems must be situated in some world or other if they are to be useful entities.” [Brooks]

Page 166: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

166

• Many other interactive models– Reactive [MP] and embedded systems– Dataflow, I/O automata [Lynch], synchronous languages, finite/pushdown

automata over infinite words– Interaction games [Abramsky], online algorithms [Albers]– TM extensions: on-line Turing machines [Fischer], interactive Turing

machines [Goldreich]...

• Concurrency Theory– Focuses on communication (between concurrent agents/processes) rather

than computation [Milner]– Orthogonal to the theory of computation and TMs.

• What makes PTMs unique?– Provably more expressive than TMs.– Bridging the gap between concurrency theory (labeled transition systems)

and traditional TOC.

Modeling Interactive Computation: PTMs in Perspective

Page 167: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

167

• Theory of Sequential Interactionconjecture: notions analogous to computational complexity, logic, and recursive functions can be developed for sequential interaction computation

• Multi-stream interaction– From hidden variables to hidden interfaces conjecture: multi-stream interaction is more powerful

than sequential interaction [Wegner’97]• Formalizing indirect interaction

– Interaction via persistent, observable changes to the common environment

– In contrast to direct interaction (via message passing)

conjecture: direct interaction does not capture all forms of multi-agent behaviors

Future Work: 3 conjectures

Page 168: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 13 Mälardalen University 2007

168

Referenceshttp://www.cse.uconn.edu/~dqg/papers/

[Wegner’97] Peter WegnerWhy Interaction is more Powerful than AlgorithmsCommunications of the ACM, May 1997

[EGW’04] Eugene Eberbach, Dina Goldin, Peter Wegner Turing's Ideas and Models of Computationbook chapter, in Alan Turing: Life and Legacy of a Great Thinker, Springer 2004

[I&C’04] Dina Goldin, Scott Smolka, Paul Attie, Elaine SondereggerTuring Machines, Transition Systems, and InteractionInformation & Computation Journal, 2004

[GW’04] Dina Goldin, Peter WegnerThe Church-Turing Thesis: Breaking the Mythpresented at CiE 2005, Amsterdam, June 2005 to be published in LNCS