fall 2004comp 3351 recursively enumerable and recursive languages

61
Fall 2004 COMP 335 1 Recursively Enumerable and Recursive Languages

Post on 19-Dec-2015

246 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 1

Recursively Enumerable and

Recursive Languages

Page 2: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 2

Definition:

A language is recursively enumerableif some Turing machine accepts it

Page 3: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 3

For string :

Let be a recursively enumerable languageL

and the Turing Machine that accepts itM

Lw

w

if then halts in a final state M

Lwif then halts in a non-final stateM

or loops forever

Page 4: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 4

Definition:

A language is recursiveif some Turing machine accepts itand halts on any input string

In other words: A language is recursive if there is a membership algorithm for it

Page 5: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 5

For string :

Let be a recursive languageL

and the Turing Machine that accepts itM

Lw

w

if then halts in a final state M

Lwif then halts in a non-final stateM

Page 6: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 6

We will prove:

1. There is a specific language which is not recursively enumerable (not accepted by any Turing Machine)

2. There is a specific language which is recursively enumerable but not recursive

Page 7: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 7

Recursive

Recursively Enumerable

Non Recursively Enumerable

Page 8: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 8

A Language which is not

Recursively Enumerable

Page 9: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 9

We want to find a language thatis not Recursively Enumerable

This language is not accepted by anyTuring Machine

Page 10: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 10

Consider alphabet }{a

Strings: ,,,, aaaaaaaaaa

1a 2a 3a 4a

Page 11: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 11

Consider Turing Machinesthat accept languages over alphabet }{a

They are countable:

,,,, 4321 MMMM

Page 12: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 12

Example language accepted by

},,{)( aaaaaaaaaaaaML i

},,{)( 642 aaaML i

iM

Alternative representation

1a 2a 3a 4a 5a 6a 7a

)( iML

0 1 1 10 0 0

Page 13: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 13

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Page 14: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 14

Consider the language

)}(:{ iii MLaaL

L consists from the 1’s in the diagonal

Page 15: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 15

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 43 aaL

Page 16: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 16

Consider the language

)}(:{ iii MLaaL

L consists of the 0’s in the diagonal

)}(:{ iii MLaaL

L

Page 17: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 17

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 21 aaL

Page 18: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 18

Theorem:

Language is not recursively enumerableL

Page 19: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 19

Proof:

is recursively enumerableL

Assume for contradiction that

There must exist some machinethat accepts

kML

LML k )(

Page 20: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 20

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?1MMk

Page 21: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 21

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 1MMk )(

)(

11

1

MLa

MLa k

Page 22: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 22

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?2MMk

Page 23: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 23

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 2MMk )(

)(

22

2

MLa

MLa k

Page 24: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 24

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?3MMk

Page 25: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 25

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 3MMk )(

)(

33

3

MLa

MLa k

Page 26: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 26

Similarly: ik MM

)(

)(

ii

ki

MLa

MLa

)(

)(

ii

ki

MLa

MLa

for any i

Because either:

or

Page 27: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 27

Therefore, the machine cannot exist kM

Therefore, the languageis not recursively enumerable

L

End of Proof

Page 28: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 28

Observation:

There is no algorithm that describes L

(otherwise would be accepted by some Turing Machine)

L

Page 29: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 29

Recursive

Recursively Enumerable

Non Recursively Enumerable

L

Page 30: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 30

A Language which is Recursively Enumerable

and not Recursive

Page 31: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 31

We want to find a language which

There is a Turing Machine that accepts the language

The machinedoesn’t halt on some input

Is recursively enumerable

But notrecursive

Page 32: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 32

We will prove that the language

)}(:{ iii MLaaL

Is recursively enumerablebut not recursive

Page 33: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 33

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 43 aaL

Page 34: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 34

The language

Theorem:

)}(:{ iii MLaaL

is recursively enumerable

Page 35: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 35

Proof:

We will give a Turing Machine thataccepts L

Page 36: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 36

Turing Machine that accepts LFor any input string w

• Compute , for which iaw• Find Turing machine iM

(using an enumeration procedure for Turing Machines)

• Simulate on inputiMia

• If accepts, then accept iM w

i

End of Proof

Page 37: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 37

Observation:

)}(:{ iii MLaaL

)}(:{ iii MLaaL

Recursively enumerable

Not recursively enumerable

(Thus, also not recursive)

Page 38: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 38

Theorem:

The language )}(:{ iii MLaaL

is not recursive

Page 39: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 39

Proof:

Assume for contradiction that is recursive

Then is recursive:

L

L

Take the Turing Machine that accepts M L

halts on any input:M

If accepts then rejectIf rejects then accept

MM

Page 40: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 40

Therefore:

L is recursive

But we know:

L is not recursively enumerable

thus, not recursive

CONTRADICTION!!!!

Page 41: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 41

Therefore, is not recursiveL

End of Proof

Page 42: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 42

L

Recursive

Recursively Enumerable

Non Recursively Enumerable

L

Page 43: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 43

Turing acceptable languages and

Enumeration Procedures

Page 44: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 44

We will prove:

• If a language is recursive then there is an enumeration procedure for it

• A language is recursively enumerable if and only if there is an enumeration procedure for it

(weak result)

(strong result)

Page 45: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 45

Theorem:

if a language is recursive then there is an enumeration procedure for it

L

Page 46: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 46

Proof:

MM~

Enumeration Machine

Accepts LEnumerates allstrings of input alphabet

Page 47: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 47

If the alphabet is then can enumerate strings as follows:

},{ baM~

abaaabbabbaaaaab......

Page 48: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 48

Enumeration procedure

Repeat:

M~ generates a string

M

w

checks if Lw

YES: print to output w

NO: ignore w

End of Proof

Page 49: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 49

Example:

M~

abaaabbabbaaaaab......

)(ML

b

ab

bbaaa

......

,....},,,{ aaabbabbL Enumeration

Output

b

ab

bbaaa

......

Page 50: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 50

Theorem:

if language is recursively enumerable thenthere is an enumeration procedure for it

L

Page 51: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 51

Proof:

MM~

Enumeration Machine

Accepts LEnumerates allstrings of input alphabet

Page 52: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 52

If the alphabet is then can enumerate strings as follows:

},{ baM~

abaaabbabbaaaaab

Page 53: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 53

Enumeration procedure

Repeat: M~ generates a string

M

w

checks if Lw

YES: print to output w

NO: ignore w

NAIVE APPROACH

Problem:If machine may loop forever

LwM

Page 54: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 54

M~

M

1w

executes first step on

BETTER APPROACH

1w

M~ Generates second string 2w

M executes first step on 2w

second step on 1w

Generates first string

Page 55: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 55

M~ Generates third string 3w

M executes first step on 3w

second step on 2w

third step on 1w

And so on............

Page 56: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 56

1w 2w 3w 4w

1

Step instring

1 1 1

2 2 2 2

3 3 3 3

Page 57: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 57

If for any string machine halts in a final statethen it prints on the output

Miw

iw

End of Proof

Page 58: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 58

Theorem:

If for language there is an enumeration procedurethen is recursively enumerable

L

L

Page 59: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 59

Proof:

wInput Tape

Enumeratorfor L

Compare

Machine that accepts L

Page 60: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 60

Turing machine that accepts L

Repeat:

• Using the enumerator, generate the next string ofL

For input string w

• Compare generated string with w

If same, accept and exit loop

End of Proof

Page 61: Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages

Fall 2004 COMP 335 61

We have proven:

A language is recursively enumerable if and only if there is an enumeration procedure for it