The document discusses how context-free languages are closed under union, concatenation, and Kleene closure operations but not under intersection or complement operations. It provides examples to illustrate closure under union, concatenation, and Kleene closure.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
12 views
Closure Proeprty
The document discusses how context-free languages are closed under union, concatenation, and Kleene closure operations but not under intersection or complement operations. It provides examples to illustrate closure under union, concatenation, and Kleene closure.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9
Closure properties of CFL
4/25/2023 C.P.Shabariram AP(SG)/CSE 1
Closure properties of CFL • Context-free language is closed under the following: – Union – Concatenation – Kleene clousure • The CFLs do not get closed under the following: – Intersection – Complement
4/25/2023 C.P.Shabariram AP(SG)/CSE 2
Union • L1 and L2 are two context-free languages, • L1 ∪ L2 will also be context-free.
4/25/2023 C.P.Shabariram AP(SG)/CSE 3
Union - Example • In case L1 = { anbn , n > 0} • The corresponding grammar for L1: • S1 → aS1b|ab • In case L2 = { cmdm , m ≥ 0} • The corresponding grammar for L2: • S2 → cS2d| ε • The union of L1 and L2 would be L = L1 ∪ L2 = { anbn } ∪ { cmdm } • The corresponding grammar for L1 ∪ L2 , • S → S1 | S2 4/25/2023 C.P.Shabariram AP(SG)/CSE 4 Concatenation • L1 and L2 are two context-free languages, • L1 L2 will also be context-free.
4/25/2023 C.P.Shabariram AP(SG)/CSE 5
Concatenation - Example • In case L1 = { anbn , n > 0} • The corresponding grammar for L1: • S1 → aS1b|ab • In case L2 = { cmdm , m ≥ 0} • The corresponding grammar for L2: • S2 → cS2d| ε • The union of L1 and L2 would be L = L1 L2 = { anbn } { cmdm } • The corresponding grammar for L1 L2 , • S → S1S2 4/25/2023 C.P.Shabariram AP(SG)/CSE 6 Kleene closure • L is a CFL, then L* would also be context- free.
4/25/2023 C.P.Shabariram AP(SG)/CSE 7
Example • In case L = { anbn , n ≥ 0} • The corresponding grammar : S → aSb| ε • Thus, the Kleene Star L1 = {anbn }* • The corresponding grammar S1 → SS1 | ε
4/25/2023 C.P.Shabariram AP(SG)/CSE 8
Not closed under ∩ & ’ • Intersection − In case L1 and L2 are CFLs, then the L1 ∩ L2 is not context-free. • Complement − In case the L1 is a CFL, L1’ might not be context-free.