# Recursively Enumerable and Recursive Languages by tangshuming

VIEWS: 0 PAGES: 61

• pg 1
```									            Recursively Enumerable
and
Recursive Languages

Fall 2004            COMP 335        1
Definition:
A language is recursively enumerable
if some Turing machine accepts it

Fall 2004                  COMP 335                2
Let         L be a recursively enumerable language
and     M the Turing Machine that accepts it

For string         w:
if     w L        then   M halts in a final state

if         w L   then   M halts in a non-final state
or loops forever
Fall 2004                   COMP 335                 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
Fall 2004                  COMP 335             4
Let         L be a recursive language
and     M the Turing Machine that accepts it

For string        w:

if    w L        then    M halts in a final state

if     w L        then   M halts in a non-final state

Fall 2004                    COMP 335                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

Fall 2004                   COMP 335                  6
Non Recursively Enumerable

Recursively Enumerable

Recursive

Fall 2004             COMP 335           7
A Language which
is not
Recursively Enumerable

Fall 2004            COMP 335        8
We want to find a language that
is not Recursively Enumerable

This language is not accepted by any
Turing Machine

Fall 2004             COMP 335             9
Consider alphabet     {a}

Strings:   a, aa, aaa, aaaa, 
1     2           3       4
a a           a       a       

Fall 2004                 COMP 335                10
Consider Turing Machines
that accept languages over alphabet   {a}

They are countable:

M1 , M 2 , M 3 , M 4 , 

Fall 2004               COMP 335                11
Example language accepted by M i

L( M i )  {aa, aaaa, aaaaaa}

L( M i )  {a , a , a }
2        4       6

Alternative representation

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

L( M i )    0     1      0              1        0       1       0       
Fall 2004                        COMP 335                                12
1       2                  3       4
a   a                  a       a       

L ( M1 )   0   1              0           1       

L( M 2 )    1   0                  0       1       

L( M 3 )    0   1              1           1       

L( M 4 )    0   0              0           1       

Fall 2004                  COMP 335                       13
Consider the language

L  {a : a  L( M i )}
i     i

L consists from the 1’s in the diagonal
Fall 2004              COMP 335              14
1         2                  3       4
a         a                  a       a       

L ( M1 )   0         1              0           1       

L( M 2 )    1          0                 0       1       

L( M 3 )    0         1              1           1       

L( M 4 )    0         0              0           1       

L  {a , a ,}
3         4
Fall 2004                        COMP 335                       15
Consider the language              L

L  {a : a  L( M i )}
i    i

L  {a : a  L( M i )}
i    i

L        consists of the 0’s in the diagonal

Fall 2004                   COMP 335              16
1         2                  3       4
a     a                  a       a       

L ( M1 )   0     1              0           1       

L( M 2 )    1     0                  0       1       

L( M 3 )    0     1              1           1       

L( M 4 )    0     0              0           1       

L  {a , a ,}
1         2
Fall 2004                    COMP 335                       17
Theorem:
Language   L   is not recursively enumerable

Fall 2004              COMP 335                18
Proof:

L   is recursively enumerable

There must exist some machine    Mk
that accepts L

L( M k )  L
Fall 2004                COMP 335            19
1       2                  3       4
a   a                  a       a       

L ( M1 )   0   1              0           1       

L( M 2 )    1   0                  0       1       

L( M 3 )    0   1              1           1       

L( M 4 )    0   0              0           1       

Question: M k  M1 ?
Fall 2004                  COMP 335                       20
1        2                  3            4
a     a                  a            a       

L ( M1 )     0    1              0                1       

L( M 2 )      1    0                  0            1       

L( M 3 )     0     1              1                1       

L( M 4 )     0     0              0                1       
1
a  L( M k )
1
Fall 2004                     COMP 335
a  L ( M1 )     21
1       2                  3       4
a   a                  a       a       

L ( M1 )   0   1              0           1       

L( M 2 )    1   0                  0       1       

L( M 3 )    0   1              1           1       

L( M 4 )    0   0              0           1       

Question: M k  M 2 ?
Fall 2004                  COMP 335                       22
1       2                  3            4
a    a                  a            a       

L ( M1 )    0    1              0                1       

L( M 2 )     1    0                  0            1       

L( M 3 )     0    1              1                1       

L( M 4 )     0    0              0                1       
2
a  L( M k )
2
Fall 2004                    COMP 335
a  L( M 2 )     23
1       2                  3       4
a   a                  a       a       

L ( M1 )   0   1              0           1       

L( M 2 )    1   0                  0       1       

L( M 3 )    0   1              1           1       

L( M 4 )    0   0              0           1       

Question: M k  M 3 ?
Fall 2004                  COMP 335                       24
1        2                  3            4
a     a                  a            a       

L ( M1 )     0    1              0                1       

L( M 2 )      1    0                  0            1       

L( M 3 )     0     1              1                1       

L( M 4 )     0     0              0                1       
3
a  L( M k )
3
Fall 2004                     COMP 335
a  L( M 3 )     25
Similarly:           M k  Mi       for any   i

Because either:

a  L( M k )
i
a  L( M k )
i
or
a  L( M i )
i
a  L( M i )
i

Fall 2004                  COMP 335                  26
Therefore, the machine         M k cannot exist

Therefore, the language L
is not recursively enumerable

End of Proof
Fall 2004             COMP 335                  27
Observation:

There is no algorithm that describes   L

(otherwise L would be accepted by
some Turing Machine)

Fall 2004                   COMP 335                   28
Non Recursively Enumerable

L
Recursively Enumerable

Recursive

Fall 2004             COMP 335               29
A Language which is
Recursively Enumerable
and not Recursive

Fall 2004            COMP 335        30
We want to find a language which

Is recursively               But not
enumerable                   recursive

There is a                             The machine
Turing Machine                         doesn’t halt
that accepts                           on some input
the language
Fall 2004                    COMP 335                   31
We will prove that the language

L  {a : a  L( M i )}
i   i

Is recursively enumerable
but not recursive

Fall 2004             COMP 335       32
1         2                  3       4
a         a                  a       a       

L ( M1 )   0         1              0           1       

L( M 2 )    1          0                 0       1       

L( M 3 )    0         1              1           1       

L( M 4 )    0         0              0           1       

L  {a , a ,}
3         4
Fall 2004                        COMP 335                       33
Theorem:

The language   L  {a : a  L( M i )}
i   i

is recursively enumerable

Fall 2004                  COMP 335                 34
Proof:

We will give a Turing Machine that
accepts L

Fall 2004              COMP 335            35
Turing Machine that accepts           L
For any input string        w
• Compute i , for which         wa      i

• Find Turing machine          Mi
(using an enumeration procedure
for Turing Machines)
i
• Simulate    M i on input a
• If    M i accepts, then accept w
End of Proof
Fall 2004                   COMP 335                    36
Observation:

Recursively enumerable
L  {a : a  L( M i )}
i   i

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

(Thus, also not recursive)

Fall 2004               COMP 335          37
Theorem:

The language   L  {a : a  L( M i )}
i   i

is not recursive

Fall 2004                  COMP 335                 38
Proof:
Assume for contradiction that           L is recursive

Then        L   is recursive:
Take the Turing Machine          M that accepts L
M halts on any input:
If   M accepts then reject
If   M rejects then accept
Fall 2004                  COMP 335                  39
Therefore:

L is recursive

But we know:

L is not recursively enumerable
thus, not recursive

Fall 2004             COMP 335                40
Therefore,    L       is not recursive

End of Proof
Fall 2004                     COMP 335               41
Non Recursively Enumerable

L
Recursively Enumerable

L
Recursive

Fall 2004             COMP 335                 42
Turing acceptable languages
and
Enumeration Procedures

Fall 2004              COMP 335           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

Fall 2004              COMP 335                   44
Theorem:
if a language L is recursive then
there is an enumeration procedure for it

Fall 2004              COMP 335                 45
Proof:

Enumeration Machine

~                    M
M

Enumerates all
Accepts   L
strings of input alphabet
Fall 2004             COMP 335                  46
If the alphabet is {a, b} then
~
M can enumerate strings as follows:

a
b
aa
ab
ba
bb
aaa
aab
......
Fall 2004            COMP 335            47
Enumeration procedure

Repeat:
~ generates a string w
M
M checks if w L
YES: print        w to output
NO:      ignore   w

End of Proof
Fall 2004                   COMP 335                  48
Example:          L  {b, ab, bb, aaa,....}
~                               Enumeration
M                L(M )            Output
a
b                   b                b
aa
ab                 ab               ab
ba
bb                bb                bb
aaa                aaa               aaa
aab
......             ......            ......
Fall 2004                     COMP 335                    49
Theorem:

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

Fall 2004           COMP 335               50
Proof:

Enumeration Machine

~                    M
M

Enumerates all
Accepts L
strings of input alphabet
Fall 2004             COMP 335                51
If the alphabet is {a, b} then
~
M can enumerate strings as follows:

a
b
aa
ab
ba
bb
aaa
aab
Fall 2004            COMP 335            52
NAIVE APPROACH
Enumeration procedure

Repeat:
~ generates a string w
M
M checks if w L
YES: print           w to output
NO:         ignore    w

Problem: If w  L
machine M        may loop forever
Fall 2004            COMP 335                      53
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   w1
Fall 2004             COMP 335              54
~ Generates third string w
M                         3

M executes first step on w3
second step on   w2
third step on   w1

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

Fall 2004                   COMP 335              55
w1   w2             w3   w4   

1    1              1    1

Step
in          2    2              2    2
string
3    3              3    3


Fall 2004            COMP 335                 56
If for any string wi
machine M halts in a final state
then it prints wi on the output

End of Proof
Fall 2004                  COMP 335            57
Theorem:

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

Fall 2004                 COMP 335              58
Proof:
Input Tape
w

Machine that
accepts L

Enumerator
Compare
for L

Fall 2004                COMP 335             59
Turing machine that accepts           L
For input string     w
Repeat:
• Using the enumerator,
generate the next string of   L
• Compare generated string with     w
If same, accept and exit loop

End of Proof
Fall 2004                  COMP 335                 60
We have proven:

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

Fall 2004             COMP 335                 61

```
To top