Вы находитесь на странице: 1из 61

Recursively Enumerable and Recursive Languages

Courtesy Costas Busch - RPI

Definition: A language is recursively enumerable if some Turing machine accepts it

Courtesy Costas Busch - RPI

Let and

L be a recursively enumerable language M the Turing Machine that accepts it

For string if if

w:
then then

w L
w L

M halts in a final state

M halts in a non-final state


or loops forever
Courtesy Costas Busch - RPI 3

Definition: A language is recursive if some Turing machine accepts it and halts on any input string

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


Courtesy Costas Busch - RPI 4

Let and

L be a recursive language M the Turing Machine that accepts it

For string if if

w:
then then

w L w L

M halts in a final state M halts in a non-final state


Courtesy Costas Busch - RPI 5

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


Courtesy Costas Busch - RPI 6

Non Recursively Enumerable

Recursively Enumerable

Recursive

Courtesy Costas Busch - RPI

A Language which is not Recursively Enumerable

Courtesy Costas Busch - RPI

We want to find a language that is not Recursively Enumerable

This language is not accepted by any Turing Machine

Courtesy Costas Busch - RPI

Consider alphabet Strings:

{a}

a, aa, aaa, aaaa, a a


1 2

Courtesy Costas Busch - RPI

10

Consider Turing Machines that accept languages over alphabet

{a}

They are countable:

M1, M 2 , M 3 , M 4 , -

Courtesy Costas Busch - RPI

11

Example language accepted by M i

L( M i ) ! {aa, aaaa, aaaaaa} L( M i ) ! {a , a , a }


Alternative representation 2 4 6

. .
12

L( M i ) 0

Courtesy Costas Busch - RPI

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .
13

1
0

1
0 0

L( M 3 )
L( M 4 )

1
0

1
0

1 1

Courtesy Costas Busch - RPI

Consider the language i i

L ! {a : a L( M i )}

L consists from the 1s in the diagonal


Courtesy Costas Busch - RPI 14

a
L ( M1 )

a 1

a 0
0

a 1 1

. . . . .

L( M 2 )
L( M 3 ) L( M 4 )

1 0 0

0 1 0
3

1 0
4

1 1

L ! {a , a ,- }
Courtesy Costas Busch - RPI 15

Consider the language i i

L ! {a : a L( M i )} L ! {a : a L( M i )}
L
consists of the 0s in the diagonal
Courtesy Costas Busch - RPI 16

a
L ( M1 )

a 0
0

a 1 1

. . . . .

1
0

L( M 2 )
L( M 3 ) L( M 4 )

1 0 0

1 0
1

1 0
2

1 1

L ! {a , a ,- }
Courtesy Costas Busch - RPI 17

Theorem: Language

L is not recursively enumerable

Courtesy Costas Busch - RPI

18

Proof: Assume for contradiction that

L is recursively enumerable

There must exist some machine that accepts L

Mk

L( M k ) ! L
Courtesy Costas Busch - RPI 19

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .

0 1
0 0

1
0

L( M 3 )
L( M 4 )

1
0

1
0

1 1

Question: M k ! M1 ?
Courtesy Costas Busch - RPI 20

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .

0 1
0 0

1
0

L( M 3 )
L( M 4 )
Answer:

1
0

1
0
1 1

1 1

M k { M1

a L( M k ) a L ( M1 )
21

Courtesy Costas Busch - RPI

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .

0 1
0 0

1
0

L( M 3 )
L( M 4 )

1
0

1
0

1 1

Question: M k ! M 2 ?
Courtesy Costas Busch - RPI 22

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .

0 1
0 0

1
0

L( M 3 )
L( M 4 )
Answer:

1
0

1
0
2 2

1 1

Mk { M2

a L( M k ) a L( M 2 )
23

Courtesy Costas Busch - RPI

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .

0 1
0 0

1
0

L( M 3 )
L( M 4 )

1
0

1
0

1 1

Question: M k ! M 3 ?
Courtesy Costas Busch - RPI 24

a
L ( M1 ) L( M 2 )

a
0 0

a 1 1

. . . . .

0 1
0 0

1
0

L( M 3 )
L( M 4 )
Answer:

1
0

1
0
3 3

1 1

M k { M3

a L( M k ) a L( M 3 )
25

Courtesy Costas Busch - RPI

Similarly:

Mk { Mi

for any

Because either:

a L( M k ) a L( M i )
i

or

a L( M k ) a L( M i )
i

Courtesy Costas Busch - RPI

26

Therefore, the machine

M k cannot exist

Therefore, the language L is not recursively enumerable

End of Proof
Courtesy Costas Busch - RPI 27

Observation: There is no algorithm that describes

(otherwise L would be accepted by some Turing Machine)

Courtesy Costas Busch - RPI

28

Non Recursively Enumerable

L
Recursively Enumerable

Recursive

Courtesy Costas Busch - RPI

29

A Language which is Recursively Enumerable and not Recursive

Courtesy Costas Busch - RPI

30

We want to find a language which Is recursively enumerable But not recursive

There is a Turing Machine that accepts the language


Courtesy Costas Busch - RPI

The machine doesnt halt on some input


31

We will prove that the language

L ! {a : a L( M i )}
Is recursively enumerable but not recursive

Courtesy Costas Busch - RPI

32

a
L ( M1 )

a 1

a 0
0

a 1 1

. . . . .

L( M 2 )
L( M 3 ) L( M 4 )

1 0 0

0 1 0
3

1 0
4

1 1

L ! {a , a ,- }
Courtesy Costas Busch - RPI 33

Theorem: The language

L ! {a : a L( M i )}

is recursively enumerable

Courtesy Costas Busch - RPI

34

Proof: We will give a Turing Machine that accepts L

Courtesy Costas Busch - RPI

35

Turing Machine that accepts For any input string

w
i

Compute i , for which

w!a Find Turing machine M i

(using an enumeration procedure for Turing Machines)

Simulate If

M i on input a
End of Proof
Courtesy Costas Busch - RPI

M i accepts, then accept w


36

Observation: Recursively enumerable i i L ! {a : a L( M i )}

Not recursively enumerable i i L ! {a : a L( M i )}


(Thus, also not recursive)
Courtesy Costas Busch - RPI 37

Theorem: The language

L ! {a : a L( M i )}

is not recursive

Courtesy Costas Busch - RPI

38

Proof: Assume for contradiction that

L is recursive

Then

L is recursive: M that accepts L

Take the Turing Machine

M halts on any input:


If If

M accepts then reject M rejects then accept


Courtesy Costas Busch - RPI 39

Therefore:

L is recursive

But we know:

L is not recursively enumerable


thus, not recursive CONTRADICTION!!!!
Courtesy Costas Busch - RPI 40

Therefore,

is not recursive

End of Proof
Courtesy Costas Busch - RPI 41

Non Recursively Enumerable

L
Recursively Enumerable

L
Recursive

Courtesy Costas Busch - RPI

42

Turing acceptable languages and Enumeration Procedures

Courtesy Costas Busch - RPI

43

We will prove:
(weak result)

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

(strong result)

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


Courtesy Costas Busch - RPI 44

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

Courtesy Costas Busch - RPI

45

Proof: Enumeration Machine

~ M

Enumerates all strings of input alphabet


Courtesy Costas Busch - RPI

Accepts

L
46

If the alphabet is {a, b} then ~ M can enumerate strings as follows:

a b aa ab ba bb aaa aab ......


Courtesy Costas Busch - RPI 47

Enumeration procedure Repeat:

~ generates a string w M M checks if w L


YES: print NO: ignore

w to output w

End of Proof
Courtesy Costas Busch - RPI 48

Example:

L ! {b, ab, bb, aaa,....}


L(M )
Enumeration Output

~ M

a b aa ab ba bb aaa aab ......

b ab bb aaa ......
Courtesy Costas Busch - RPI

b ab bb aaa ......
49

Theorem: if language L is recursively enumerable then there is an enumeration procedure for it

Courtesy Costas Busch - RPI

50

Proof: Enumeration Machine

~ M

Enumerates all strings of input alphabet


Courtesy Costas Busch - RPI

Accepts L
51

If the alphabet is {a, b} then ~ M can enumerate strings as follows:

a b aa ab ba bb aaa aab
Courtesy Costas Busch - RPI 52

NAIVE APPROACH Enumeration procedure Repeat:

~ generates a string w M M checks if w L


YES: print NO: ignore

w to output w

Problem: If w L machine M

may loop forever


53

Courtesy Costas Busch - RPI

BETTER APPROACH

~ Generates first string w M 1 M executes first step on w1 ~ Generates second string w M 2 M executes first step on w2
second step on
Courtesy Costas Busch - RPI

w1
54

~ Generates third string w M 3 M executes first step on w3


second step on third step on And so on............

w2 w1

Courtesy Costas Busch - RPI

55

w1
1 Step in string 2 3

w2
1 2 3

w3
1 2 3

w4
1 2 3

.
Courtesy Costas Busch - RPI 56

If for any string wi machine M halts in a final state then it prints wi on the output

End of Proof
Courtesy Costas Busch - RPI 57

Theorem: If for language L there is an enumeration procedure then L is recursively enumerable

Courtesy Costas Busch - RPI

58

Proof:

Input Tape

w
Machine that accepts L

Enumerator for L

Compare

Courtesy Costas Busch - RPI

59

Turing machine that accepts For input string Repeat:

Using the enumerator, generate the next string of

Compare generated string with If same, accept and exit loop


End of Proof
Courtesy Costas Busch - RPI

60

We have proven: A language is recursively enumerable if and only if there is an enumeration procedure for it

Courtesy Costas Busch - RPI

61

Вам также может понравиться