You are on page 1of 23

RECAP: EXAMPLE

• Design a CFG that generates all the even integers up to


998
SOLUTION

S->AB|AAB|0|2|4|6|8

A->0|1|2|3|4|5|6|7|8|9

B->0|2|4|6|8
IDENTIFYING NON-CONTEXT FREE
LANGUAGES
HOW TO IDENTIFY NON-CONTEXT-FREE LANGUAGES?
HOW TO IDENTIFY NON-CONTEXT-FREE LANGUAGES?

Just like regular languages … we have


Pumping Lemma for Context-free languages
RECAP: PUMPING LEMMA (FOR REGULAR LANGUAGES)
PUMPING LEMMA FOR CONTEXT FREE LANGUAGES
EXAMPLE – I
Prove that L = {anbncn : n ≥ 0} is not context free.
EXAMPLE – I
Prove that L = {anbncn : n ≥ 0} is not context free.

❖Is this the only decomposition possible for this problem?


EXAMPLE – I

• Prove that L = {anbncn : n ≥ 0} is not context free.


• Now let’s pick a string w from L such that |w| > m, we pick w=ambmcm
• w = uvxyz
• u vxy z

• w= aaaaaaaaa..aa bbbbbbb…bb ccccc..cc


• u vxy z

• w= aaaaaaaaa..aa bbbbbbb…bb ccccc..cc


EXAMPLE - II
QUESTION
ANSWER
EXERCISE

• Show that the language L = {𝑎𝑛 𝑏 𝑗 ห𝑛 = 𝑗 2 } is not context free


CLOSURE PROPERTIES OF CFLs
DEFINITION

• It express the idea that when one/ several languages are CFLs, and L is formed from them by applying
certain operations, which is also CFL, then CFLs are closed under those operations
CLOSURE UNDER UNION
CLOSURE UNDER CONCATENATION
CLOSURE UNDER STAR CLOSURE
CLOSURE UNDER INTERSECTION
• CFLs are not closed under intersection
• Let’s consider L3 = {anbncn : n ≥ 0}
• L3 = L1 ∩ L2, where L1 = { anbncm : n ≥ 0, m ≥ 0 }, L2 = { anbmcm : n ≥ 0, m ≥ 0}
• Both L1 and L2 are CFLs

• For L1:

• Similarly we can show that L2 is also Context free

• If the CFLs are closed under intersection, then L3 would also be CFL.
• But, it was proved earlier that L3 is not CFL
CLOSURE UNDER COMPLEMENTATION

• CFLs are not closed under complementation


ANOTHER PROPERTY

• Let L1 be a context-free language and L2 be a regular language, then L1 ∩ L2 is


context-free
QUESTION

• Suppose, L1 = {a100b100}, L1 = ?

You might also like