Recursively Enumerable and Recursive Languages 1 L Definition: - - PDF document

recursively enumerable and recursive languages
SMART_READER_LITE
LIVE PREVIEW

Recursively Enumerable and Recursive Languages 1 L Definition: - - PDF document

Review Languages and Grammars Alphabets, strings, languages Regular Languages Deterministic Finite and Nondeterministic Automata CS 301 - Lecture 23 Equivalence of NFA and DFA Regular Expressions Regular Grammars


slide-1
SLIDE 1

1

CS 301 - Lecture 23 Recursive and Recursively Enumerable Languages

Fall 2008

Review

  • Languages and Grammars

– Alphabets, strings, languages

  • Regular Languages

– Deterministic Finite and Nondeterministic Automata – Equivalence of NFA and DFA Regular Expressions – Regular Grammars – Properties of Regular Languages – Languages that are not regular and the pumping lemma

  • Context Free Languages

– Context Free Grammars – Derivations: leftmost, rightmost and derivation trees – Parsing and ambiguity – Simplifications and Normal Forms – Nondeterministic Pushdown Automata – Pushdown Automata and Context Free Grammars – Deterministic Pushdown Automata – Pumping Lemma for context free grammars – Properties of Context Free Grammars

  • Turing Machines

– Definition, Accepting Languages, and Computing Functions – Combining Turing Machines and Turing’s Thesis – Turing Machine Variations – Universal Turing Machine and Linear Bounded Automata – Today: Recursive and Recursively Enumerable Languages

Recursively Enumerable and Recursive Languages

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

slide-2
SLIDE 2

2

For string : Let be a recursively enumerable language

L

and the Turing Machine that accepts it

M L w∈ w

if then halts in a final state

M L w∉

if then halts in a non-final state

M

  • r loops forever

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 For string : Let be a recursive language

L

and the Turing Machine that accepts it

M L w∈ w

if then halts in a final state

M L w∉

if then halts in a non-final state

M

Turing acceptable languages and Enumeration Procedures

slide-3
SLIDE 3

3

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)

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

L

Proof:

M M ~

Enumeration Machine Accepts L Enumerates all strings of input alphabet If the alphabet is then can enumerate strings as follows:

} , { b a

M ~

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

slide-4
SLIDE 4

4

Enumeration procedure Repeat:

M ~

generates a string

M w

checks if

L w∈

YES: print to output

w

NO: ignore w

End of Proof

Example:

M ~

a b aa ab ba bb aaa aab ...... ) (M L b ab bb aaa ...... ,....} , , , { aaa bb ab b L =

Enumeration Output

b ab bb aaa ......

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

L

Proof:

M M ~

Enumeration Machine Accepts L Enumerates all strings of input alphabet

slide-5
SLIDE 5

5

If the alphabet is then can enumerate strings as follows:

} , { b a

M ~

a b aa ab ba bb aaa aab

Enumeration procedure Repeat:

M ~

generates a string

M w

checks if

L w∈

YES: print to output

w

NO: ignore w NAIVE APPROACH Problem: If machine may loop forever

L w∉ M M ~ M

1

w

executes first step on BETTER APPROACH 1

w M ~

Generates second string 2

w M

executes first step on 2

w

second step on 1

w

Generates first string

M ~

Generates third string 3

w M

executes first step on 3

w

second step on 2

w

third step on 1

w

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

slide-6
SLIDE 6

6

1

w

2

w

3

w

4

w

1 Step in string

1 1 1 2 2 2 2 3 3 3 3 If for any string machine halts in a final state then it prints on the output

M

i

w

i

w

End of Proof

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

L L

Proof:

w

Input Tape Enumerator for L Compare Machine that accepts L

slide-7
SLIDE 7

7

Turing machine that accepts L Repeat:

  • Using the enumerator,

generate the next string of L For input string w

  • Compare generated string with w

If same, accept and exit loop

End of Proof

We have proven: A language is recursively enumerable if and only if there is an enumeration procedure for it 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 Recursive Recursively Enumerable Non Recursively Enumerable

slide-8
SLIDE 8

8

Some Languages Are Not Recursively Enumerable Proof Using Uncountable Sets

A set is uncountable if it is not countable Definition: Theorem: Let be an infinite countable set The powerset of is uncountable S

2 S S

Proof: Since is countable, we can write

S } , , , {

3 2 1

… s s s S =

Elements of S

slide-9
SLIDE 9

9

Elements of the powerset have the form:

} , {

3 1 s

s } , , , {

10 9 7 5

s s s s

…… We encode each element of the power set with a binary string of 0’s and 1’s 1

s

2

s

3

s

4

s 

1

} { 1 s

Powerset element Encoding

1 1

} , {

3 2 s

s

1 1 1

} , , {

4 3 1

s s s   

Let’s assume (for contradiction) that the powerset is countable. Then: we can enumerate the elements of the powerset

1 1 1 1 1 1 1 1 1

Powerset element Encoding 1

t

2

t

3

t

4

t

   

slide-10
SLIDE 10

10

Take the powerset element whose bits are the complements in the diagonal

1 1 1 1 1 1 1 1 1

1

t

2

t

3

t

4

t

   

New element:

… 0011

(birary complement of diagonal) The new element must be some

  • f the powerset

i

t

However, that’s impossible: the i-th bit of must be the complement of itself from definition of i

t

i

t

Contradiction!!! Since we have a contradiction: The powerset of is uncountable S

2 S

slide-11
SLIDE 11

11

An Application: Languages Example Alphabet :

} , { b a

The set of all Strings:

} , , , , , , , , , { } , {

*

… aab aaa bb ba ab aa b a b a S λ = =

infinite and countable Example Alphabet :

} , { b a

The set of all Strings:

} , , , , , , , , , { } , {

*

… aab aaa bb ba ab aa b a b a S λ = =

infinite and countable A language is a subset of :

} , , { aab ab aa L = S

Example Alphabet :

} , { b a

The set of all Strings:

} , , , , , , , , , { } , {

*

… aab aaa bb ba ab aa b a b a S λ = =

infinite and countable The powerset of contains all languages:

} }, , , }{ , { }, { }, {{ 2 … aab ab aa b a a

S

λ =

1

L

2

L

3

L

4

L

uncountable

 S

Languages: uncountable Turing machines: countable

1

L

2

L

3

L

k

L

1

M

2

M

3

M  

?

There are more languages than Turing Machines

slide-12
SLIDE 12

12

There are some languages not accepted by Turing Machines (These languages cannot be described by algorithms) Conclusion: Languages Accepted by Turing Machines Languages not accepted by Turing Machines

k

L

A Language which is not Recursively Enumerable

We want to find a language that is not Recursively Enumerable This language is not accepted by any Turing Machine

slide-13
SLIDE 13

13

Consider alphabet

} {a

Strings:

… , , , , aaaa aaa aa a

1

a

2

a

3

a

4

a 

Consider Turing Machines that accept languages over alphabet

} {a

They are countable:

… , , , ,

4 3 2 1

M M M M

Example language accepted by

} , , { ) ( aaaaaa aaaa aa M L

i =

} , , { ) (

6 4 2

a a a M L

i =

i

M

Alternative representation

1

a

2

a

3

a

4

a

5

a

6

a

7

a ) (

i

M L  1 1 1 

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

slide-14
SLIDE 14

14

Consider the language

)} ( : {

i i i

M L a a L ∈ = L

consists from the 1’s in the diagonal

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

} , , {

4 3

… a a L =

Consider the language

)} ( : {

i i i

M L a a L ∈ =

L

consists of the 0’s in the diagonal

)} ( : {

i i i

M L a a L ∉ = L

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

} , , {

2 1

… a a L =

slide-15
SLIDE 15

15

Theorem: Language is not recursively enumerable

L

Proof: is recursively enumerable

L

Assume for contradiction that There must exist some machine that accepts k

M L L M L

k =

) (

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

Question:

?

1

M Mk =

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

Answer:

1

M Mk ≠ ) ( ) (

1 1 1

M L a M L a

k

∉ ∈

slide-16
SLIDE 16

16

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

Question:

?

2

M Mk =

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

Answer:

2

M Mk ≠ ) ( ) (

2 2 2

M L a M L a

k

∉ ∈

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

Question:

?

3

M Mk =

1

a

2

a

3

a

4

a ) (

1

M L  1 1  ) (

2

M L ) (

3

M L 1 1  1 1 1  ) (

4

M L 1 

Answer:

3

M Mk ≠ ) ( ) (

3 3 3

M L a M L a

k

∈ ∉

slide-17
SLIDE 17

17

Similarly: i k

M M ≠ ) ( ) (

i i k i

M L a M L a ∈ ∉ ) ( ) (

i i k i

M L a M L a ∉ ∈

for any i Because either:

  • r

Therefore, the machine cannot exist k

M

Therefore, the language is not recursively enumerable

L

End of Proof

Observation: There is no algorithm that describes L (otherwise would be accepted by some Turing Machine)

L

Recursive Recursively Enumerable Non Recursively Enumerable

L

slide-18
SLIDE 18

18

What’s Next

  • Read

– Linz Chapter 1,2.1, 2.2, 2.3, (skip 2.4), 3, 4, 5, 6.1, 6.2, (skip 6.3), 7.1, 7.2, 7.3, (skip 7.4), 8, 9, 10, 11 – JFLAP Chapter 1, 2.1, (skip 2.2), 3, 4, 5, 6, 7, (skip 8), 9, (skip 10), 11

  • Next Lecture Topics From 11.1, 11.2, 11.3, and 11.4

– More Recursive Languages, Unrestricted Grammars, Context Sensitive Grammars, and the Chomsky Hierarchy

  • Quiz 3 in Recitation on Wednesday 11/12

– Covers Linz 7.1, 7.2, 7.3, (skip 7.4), 8, and JFLAP 5,6,7 – Closed book, but you may bring one sheet of 8.5 x 11 inch paper with any notes you like. – Quiz will take the full hour

  • Homework

– Homework Due Thursday