Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Limitations of Context Free Languages - Automata and Complexity Theory - Lecture Slides, Slides of Theory of Automata

Some concept of Automata and Complexity Theory are Administrivia, Closure Properties, Context-Free Grammars, Decision Properties, Deterministic Finite Automata, Intractable Problems, More Undecidable Problems. Main points of this lecture are: Limitations of Context Free Languages, Pumping Lemma, Not Regular, Regular Languages, Languages, Same Number, Some Intuition, Pushdown Automaton, Context-Free Grammar, Derivations

Typology: Slides

2012/2013

Uploaded on 04/29/2013

juni
juni 🇮🇳

4

(17)

122 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Limitations of context-free languages
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Limitations of Context Free Languages - Automata and Complexity Theory - Lecture Slides and more Slides Theory of Automata in PDF only on Docsity!

Limitations of context-free languages

Non context-free languages

• Recall the pumping lemma for regular languages

allows us to show some languages are not regular

Are these languages context-free?

L

1

= {a

n

b

n

: n ≥ 0}

L

2

= {x: x has same number of as and bs}

L

3

n

: n is prime}

L

4

= {a

n

b

n

c

n

: n ≥ 0}

L

5

= {x#x

R

: x ∈ {0, 1}*}

L

6

= {x#x: x ∈ {0, 1}*}

More intuition

• Suppose we could construct some CFG for L

4

, e.g.

• We do some derivations

of “long” strings

S → BC

B → CS | b

C → SB | a

S ⇒ BC

⇒ CSC

⇒ aSC

⇒ aBCC

⇒ abCC

⇒ abaC

⇒ abaSB

⇒ abaBCB

⇒ ababCB

⇒ ababaB

⇒ ababab

More intuition

• If derivation is long enough, some variable must

appear twice on same path in parse tree

S ⇒ BC

⇒ CSC

⇒ aSC

⇒ aBCC

⇒ abCC

⇒ abaC

⇒ abaSB

⇒ abaBCB

⇒ ababCB

⇒ ababaB

⇒ ababab

S

B C

C S S B

B C B C

a

b a b a b

More intuition

• We can repeat this many times

• Every sufficiently large derivation will have a

part that

can be repeated indefinitely

  • This is caused by cycles in the grammar

ababab

ababbabb

ababbbabbb

abab

n

ab

n

bb

General picture

u

u

v

v

v

w

x

y

y

u

v

v

v

w

x

y

uvwxy uv

3

wx

3

y

A

A

A

A

A

A

A

A

A

x

x

x

x

w

xvvwxxy

Pumping lemma for context-free

languages

  • Theorem: For every context-free language L

There exists a number n such that for every

string z in L, we can write z = uvwxy where

 |vwx| ≤ n

 |vx| ≥ 1

 For every i ≥ 0, the string uv

i

wx

i

y is in L.

u w y

x v

Pumping lemma for context-free

languages

  • So to prove L is not context-free, it is enough that

For every n there exists z in L, such that for

every way of writing z = uvwxy where

 |vwx| ≤ n and  |vx| ≥ 1, the string uv

i

wx

i

y

is

not in L for some i ≥ 0.

u w y

x v

Example

adversary

choose n

write z = uvwxy

(|vwx| ≤ n,|vx| ≥ 1)

you

choose z ∈ L

choose i

you win if uv

i

wx

i

y ∉ L

1

2

adversary

n

write z = uvwxy

you

z = a

n

b

n

c

n

i =?

1

2

L

4

= {a

n

b

n

c

n

: n ≥ 0}

u w y

x v

a a a ... a a b b b ... b b c c c ... c c

Example

• Case 1: v or x contains two kinds of symbols

Then uv

2

wx

2

y not in L because pattern is wrong

• Case 2: v and x both contain one kind of

symbol

Then uv

2

wx

2

y does not have same number of

x

v

a a a ... a a b b b ... b b c c c ... c c

x

v

a a a ... a a b b b ... b b c c c ... c c