0% found this document useful (0 votes)
9 views

08 TOC

The document discusses the elimination of epsilon, unit productions, and useless symbols from context-free grammars (CFG). It explains the processes involved in each elimination step, providing examples and definitions related to pushdown automata (PDA) and their transitions. Additionally, it touches on the hierarchy of languages and includes self-learning questions to reinforce understanding of the concepts presented.

Uploaded by

sinhaaaryankumar
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
9 views

08 TOC

The document discusses the elimination of epsilon, unit productions, and useless symbols from context-free grammars (CFG). It explains the processes involved in each elimination step, providing examples and definitions related to pushdown automata (PDA) and their transitions. Additionally, it touches on the hierarchy of languages and includes self-learning questions to reinforce understanding of the concepts presented.

Uploaded by

sinhaaaryankumar
Copyright
© © All Rights Reserved
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/ 90

Elimination of epsilon, unit

productions and useless


symbols from CFG
Elimination of epsilon

• If the language does not contain ε, then all the ε production can be
eliminated.
• But if ε is present in the language, then other ε production can be
eliminated except for S→ε
𝑆 → 𝑎𝑆𝑏|𝑎𝐴𝑏
𝐴→ε

1. Find all the null production and then all the nullable variable (even after
some number of derivations) 𝐴 → ε
2. Go to the RHS of every production then write the production with and
without the nullable variable
𝑆 → 𝑎𝑆𝑏|𝑎𝐴𝑏|ab
𝐴→ε
3. Finally remove the variable whose production is missing
𝑆 → 𝑎𝑆𝑏|𝑎𝐴𝑏|ab

𝑆 → 𝑎𝑆𝑏|ab
𝑆 → 𝐴𝐵 nullable variable ={A,B,S}
𝐴 → 𝑎𝐴𝐴|ε
𝐵 → 𝑏𝐵𝐵|ε

𝑆 → 𝐴𝐵|𝐵|𝐴|ε
𝐴 → 𝑎𝐴𝐴|𝑎𝐴|𝑎
𝐵 → 𝑏𝐵𝐵|𝑏𝐵|𝑏
𝑆 → 𝐴𝑏𝑎𝐶
𝐴 → 𝐵𝐶 nullable variable ={C,B,A}
𝐵 → 𝑏|ε
𝐶 → 𝐷|ε
𝐷→𝑑

𝑆 → 𝐴𝑏𝑎𝐶|𝑏𝑎𝐶|𝐴𝑏𝑎|𝑏𝑎
𝐴 → 𝐵𝐶|𝐵|𝐶
𝐵→𝑏
𝐶→𝐷
𝐷→𝑑

Elimination of epsilon leads to addition of unit productions (example 𝐶 → 𝐷)


Elimination of unit production

𝑆→𝐴
𝐴→𝐵
𝐵→𝐶
𝐵→𝑑
Elimination of unit production
𝑆 → 𝐴𝑎|𝐵
𝐵 → 𝐴|𝑏𝑏
𝐴 → 𝑎|𝑏𝑐|𝐵
• Write all the grammars without the unit production
𝑆 → 𝐴𝑎
𝐵 → 𝑏𝑏
𝐴 → 𝑎|𝑏𝑐
• Substitute all the possible derivation from the unit production variables
𝑆 → 𝐴𝑎 𝑏𝑏 𝑎|𝑏𝑐
𝐵 → 𝑏𝑏|𝑎|𝑏𝑐
𝐴 → 𝑎|𝑏𝑐|𝑏𝑏
𝑆 → 𝐴𝐵
𝐴→𝑎
𝐵 → 𝐶|𝑏
𝐶→𝐷
𝐷→𝐸
𝐸→𝑎
𝑆 → 𝐴𝐵
𝐴→𝑎
𝐵 → 𝑏|a
𝐶→𝑎
𝐷→𝑎 Unreachable (useless production or symbols)
𝐸→𝑎
Elimination of Useless symbols

Useful symbols
• If a variable is able to derive a terminal or string of terminals only, then it
might be useful.
• Every variable must be reachable from the start symbol.
• Every derived unit terminals
𝑆 → 𝐴𝐵|𝑎
𝐴 → 𝐵𝐶|𝑏
𝐵 → 𝑎𝐵|𝐶
𝐶 → 𝑎𝐶|𝐵
Identify the set of useful symbols {𝑎, 𝑏, 𝑆, 𝐴}

Delete all the useless symbols and its production in the LHS and useless symbols (the whole term) in the RHS

𝑆 → 𝐴𝐵|𝑎
𝐴 → 𝐵𝐶|𝑏
𝐵 → 𝑎𝐵|𝐶
𝐶 → 𝑎𝐶|𝐵

Remove all the unreachable variable

𝑆→𝑎
𝐴→𝑏
𝑆 → 𝐴𝐵|𝐴𝐶
𝐴 → 𝑎𝐴𝑏 𝑏𝐴𝑎 𝑎
𝐵 → 𝑏𝑏𝐴|𝑎𝑎𝐵|𝐴𝐵 set of useful symbols {𝑎, 𝑏, 𝐴, 𝐵, 𝑆}
𝐶 → 𝑎𝑏𝐶𝐴|𝑎𝐷𝑏
𝐷 → 𝑏𝐷𝑎𝐶
𝑆 → 𝐴𝐵|𝐴𝐶
𝐴 → 𝑎𝐴𝑏 𝑏𝐴𝑎 𝑎
𝐵 → 𝑏𝑏𝐴|𝑎𝑎𝐵|𝐴𝐵
𝐶 → 𝑎𝑏𝐶𝐴|𝑎𝐷𝑏
𝐷 → 𝑏𝐷𝑎𝐶
𝑆 → 𝐴𝐵
𝐴 → 𝑎𝐴𝑏 𝑏𝐴𝑎 𝑎
𝐵 → 𝑏𝑏𝐴|𝑎𝑎𝐵|𝐴𝐵
𝑆 → 𝐴𝐵𝐶|𝐵𝑎𝐵
𝐴 → 𝑎𝐴 𝐵𝑎𝐶 𝑎𝑎𝑎 set of useful symbols {𝑎, 𝑏, 𝐴, 𝐵, 𝑆}

𝐵 → 𝑏𝐵𝑏|𝑎
𝐶 → 𝐶𝐴|𝐴𝐶

𝑆 → 𝐵𝑎𝐵
𝐴 → 𝑎𝐴|𝑎𝑎𝑎
𝐵 → 𝑏𝐵𝑏|𝑎

𝑆 → 𝐵𝑎𝐵
𝐵 → 𝑏𝐵𝑏|𝑎
Self Learning Questions
• Explain using suitable example, the different types of Grammars according to
Noam Chomsky.
• How are the different types of Grammars differ from each other?
• What is the difference between Regular Language and Context Free
Language?
• What do you mean by derivation Tree in the context of TOC? Give example.
• What do you mean by Ambiguous Grammar in the context of TOC? Give
example.
• what is Chomsky normal form in the context of TOC? Give example.
• Define Parsing and Parse Trees using suitable example in the context of TOC?
Hierarchy of languages
Regular Languages  Finite State Machines, Regular Expression
Context Free Languages  Context Free Grammar, Push-down Automata

Non-Recursively Enumerable Languages

Recursively Enumerable Languages

Recursive Languages

Context-Free Languages

Regular Languages

14
Pushdown Automata (PDA)

• Informally:
• A PDA is an NFA-ε with a stack.
• Transitions are modified to accommodate stack operations.

• Questions:
• What is a stack?
• How does a stack help?

• A DFA can “remember” only a finite amount of information, whereas a PDA can
“remember” an infinite amount of (certain types of) information, in one memory-stack

15
• Example:

{0n1n | 0=<n} is not regular, but

{0n1n | 0nk, for some fixed k} is regular, for any fixed k.

• For k=3:
L = {ε, 01, 0011, 000111}

0 0 0
q0 q1 q2 q3

1 1 1 1
0/1 1 1
0/1 q7 q6 q5 q4
0
0
0
16
• In a DFA, each state remembers a finite amount of information.

• To get {0n1n | 0n} with a DFA would require an infinite number of states using
the preceding technique.

• An infinite stack solves the problem for {0n1n | 0n} as follows:


• Read all 0’s and place them on a stack
• Read all 1’s and match with the corresponding 0’s on the stack

• Only need two states to do this in a PDA

• Similarly for {0n1m0n+m | n,m0}

17
Formal Definition of a PDA

• A pushdown automaton (PDA) is a seven-tuple:

M = (Q, Σ, Г, δ, q0, z0, F)

Q A finite set of states


Σ A finite input alphabet
Г A finite stack alphabet
q0 The initial/starting state, q0 is in Q
z0 A starting stack symbol, is in Г // need not always remain at the bottom of stack
F A set of final/accepting states, which is a subset of Q
δ A transition function, where

δ: Q x (Σ U {ε}) x Г –> finite subsets of Q x Г* (Deterministic PDA)


δ : Q x (Σ U {ε}) x (Γ U {ε}) → 2Q x (Γ U {ε}) (Non Deterministic PDA)
18
• Consider the various parts of δ:

tape
Q x (Σ U {ε}) x Г –> finite subsets of Q x Г*
a ε
• Q on the LHS means that at each step in a computation, a PDA must consider its’
current state.
tape head
• Г on the LHS means that at each step in a computation, a PDA must consider the
stack head symbol on top of its’ stack.
• Σ U {ε} on the LHS means that at each step in a computation, a PDA may or may not
consider the current input symbol, i.e., it may have epsilon transitions.
finite
stack • “Finite subsets” on the RHS means that at each step in a computation, a PDA may
control
have several options.
• Q on the RHS means that each option specifies a new state.
• Г* on the RHS means that each option specifies zero or more stack symbols that
will replace the top stack symbol, but in a specific sequence.

19
Example of PDA
Top of the Stack
Push a

a,𝑍0 |𝑎𝑍0 𝑎
𝑞1
𝑍0 𝑍0
𝑏, 𝑎|ε Input symbol
Pop a
𝑞2

𝑎,𝑍0 |𝑎𝑍0 : when 𝑎 is the input and 𝑍0 is on top of the stack, push 𝑎 into the stack
𝑏, ε|ε
𝑏, 𝑎|ε: when 𝑏 is the input, 𝑎 is on top of the stack and right hsnd side of the rule is ε
No operation pop 𝑎 from the stack
• Two types of PDA transitions:

δ(q, a, z) = {(p1,γ1), (p2,γ2),…, (pm,γm)}

• Current state is q
• Current input symbol is a
• Symbol currently on top of the stack z
• Move to state pi from q
• Replace z with γi on the stack (leftmost symbol on top)
• Move the input head to the next input symbol

a/z/ γ1 p1

q a/z/ γ2 p2
a/z/ γm
:

pm
21
• Two types of PDA transitions:

δ(q, ε, z) = {(p1,γ1), (p2,γ2),…, (pm,γm)}

• Current state is q
• Current input symbol is not considered
• Symbol currently on top of the stack z
• Move to state pi from q
• Replace z with γi on the stack (leftmost symbol on top)
• No input symbol is read

ε/z/ γ1 p1

q ε/z/ γ2 p2
ε/z/ γm
:

pm
22
𝛿: 𝑄 × Σ × Г → 𝑄 × Г∗ (Transition function for Deterministic PDA)

δ 𝑞, 𝑎, 𝑎 = 𝑞, ε Operation = POP

𝑎𝑖

δ 𝑞, 𝑎, 𝑎 = 𝑞, 𝑎𝑎 Operation = PUSH

𝑎𝑖

δ 𝑞, 𝑎, 𝑎 = 𝑞, 𝑎 Operation = No operation
an b n
a a a b b b ε

a
a
a
𝑍0

𝑎, 𝑍0 |𝑎𝑍0 𝑏, 𝑎|ε δ 𝑞𝑜 , 𝑎, 𝑍0 = 𝑞𝑜 , 𝑎𝑍0


δ 𝑞𝑜 , 𝑎, 𝑎 = 𝑞𝑜 , 𝑎𝑎
𝑞0 𝑏, 𝑎|ε 𝑞1
ε, 𝑍0 |𝑍0

𝑎, 𝑎|𝑎𝑎 𝑞2
PUSH POP No operation
δ 𝑞𝑜 , 𝑎, 𝑍0 = 𝑞, 𝑍0
PUSH POP No operation
δ 𝑞𝑜 , 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
PUSH POP No operation
δ 𝑞, 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
δ 𝑞, ε, ε = 𝑞, ε
PUSH POP No operation
δ 𝑞, 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
δ 𝑞, ε, ε = 𝑞, ε No operation
PUSH POP No operation
δ 𝑞, 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
δ 𝑞, ε, ε = 𝑞, ε No operation
δ 𝑞, 𝑎, 𝑥 = 𝑞, 𝑦𝑥
PUSH POP No operation
δ 𝑞, 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
δ 𝑞, ε, ε = 𝑞, ε No operation
δ 𝑞, 𝑎, 𝑥 = 𝑞, 𝑦𝑥 Push 𝑦

Whenthe state is q and a comes as an input and x is on top of the stack, then push y into the stack

. . . a . . .

y
x x
. .
PUSH POP No operation
δ 𝑞, 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
δ 𝑞, ε, ε = 𝑞, ε No operation
δ 𝑞, 𝑎, 𝑥 = 𝑞, 𝑦𝑥 Push 𝑦
δ 𝑞, 𝑎, 𝑏 = 𝑞, ε
PUSH POP No operation
δ 𝑞, 𝑎, 𝑍0 = 𝑞, 𝑍0 No operation
δ 𝑞, ε, ε = 𝑞, ε No operation
δ 𝑞, 𝑎, 𝑥 = 𝑞, 𝑦𝑥 Push 𝑦
δ 𝑞, 𝑎, 𝑏 = 𝑞, ε Pop b
𝐹𝐴 < 𝐷𝑃𝐷𝐴 < 𝑁𝐷𝑃𝐷𝐴 𝑜𝑟 𝑃𝐷𝐴
Accepts RL
Accepts DCFL Accepts CFL
PDA
• It can accept using Final state mechanism (After reading whole input, If PDA halts at final
then it accepts given input)

• It can accept using Empty Stack mechanism(After reading whole input, If we can make
stack as empty then given input is accepted)
𝐿1 = 𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑙𝑎𝑛𝑔𝑢𝑎𝑔𝑒 𝑎𝑐𝑐𝑒𝑝𝑡𝑒𝑑 𝑏𝑦 𝑃𝐷𝐴 𝑢𝑠𝑖𝑛𝑔 𝐹𝑖𝑛𝑎𝑙 𝑠𝑡𝑎𝑡𝑒 𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑛𝑐𝑒.

𝐿2 = 𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑙𝑎𝑛𝑔𝑢𝑎𝑔𝑒 𝑎𝑐𝑐𝑒𝑝𝑡𝑒𝑑 𝑏𝑦 𝑃𝐷𝐴 𝑢𝑠𝑖𝑛𝑔 𝐸𝑚𝑝𝑡𝑦 𝑆𝑡𝑎𝑐𝑘 𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑛𝑐𝑒.

1. 𝐿1 ⊂ 𝐿2
2. 𝐿1 ⊃ 𝐿2
3. 𝐿1 = 𝐿2
𝐿1 = 𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑙𝑎𝑛𝑔𝑢𝑎𝑔𝑒 𝑎𝑐𝑐𝑒𝑝𝑡𝑒𝑑 𝑏𝑦 𝑃𝐷𝐴 𝑢𝑠𝑖𝑛𝑔 𝐹𝑖𝑛𝑎𝑙 𝑠𝑡𝑎𝑡𝑒 𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑛𝑐𝑒.

𝐿2 = 𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑙𝑎𝑛𝑔𝑢𝑎𝑔𝑒 𝑎𝑐𝑐𝑒𝑝𝑡𝑒𝑑 𝑏𝑦 𝑃𝐷𝐴 𝑢𝑠𝑖𝑛𝑔 𝐸𝑚𝑝𝑡𝑦 𝑆𝑡𝑎𝑐𝑘 𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑛𝑐𝑒.

1. 𝐿1 ⊂ 𝐿2
2. 𝐿1 ⊃ 𝐿2
3. 𝐿1 = 𝐿2

𝐿1 = 𝐿2 = Set of all CFLs


an b n
using Final State Mechanism

𝑎, 𝑍0 |𝑎𝑍0 𝑎, 𝑎|𝑎𝑎 𝑎, 𝑎|𝑎𝑎 𝑎, 𝑎|𝑎𝑎 𝑏, 𝑎|ε 𝑏, 𝑎|ε 𝑏, 𝑎|ε ε, 𝑍0 |𝑍0


𝑏, 𝑎|ε
a a a a b b b b ε

Push a’s Pop b’s

𝑎, 𝑍0 |𝑎𝑍0 𝑏, 𝑎|ε

a 𝑏, 𝑎|ε
𝑞0 𝑞1
a ε, 𝑍0 |𝑍0
a 𝑎, 𝑎|𝑎𝑎
ε, 𝑍0 |𝑍0 𝑞2
a
𝑍0
Accepted
an b n
using empty Stack Mechanism

𝑎, 𝑍0 |𝑎𝑍0 𝑎, 𝑎|𝑎𝑎 𝑎, 𝑎|𝑎𝑎 𝑎, 𝑎|𝑎𝑎 𝑏, 𝑎|ε 𝑏, 𝑎|ε 𝑏, 𝑎|ε ε, 𝑍0 |𝑍0


𝑏, 𝑎|ε
a a a a b b b b ε

Push a’s Pop b’s


𝑎, 𝑍0 |𝑎𝑍0
𝑎, 𝑎|𝑎𝑎 𝑏, 𝑎|ε

a 𝑏, 𝑎|ε
𝑞0 𝑞1
a ε, 𝑍0 |ε
a
ε, 𝑍0 |ε 𝑞2
a
𝑍0
Accepted
an b n
Using state transition method
If the state is 𝑞𝑜 and 𝑎 is the input and 𝑍0 is on the top of the stack,
δ 𝑞𝑜 , 𝑎, 𝑍0 = 𝑞𝑜 , 𝑎𝑍0 the transition state will be the same 𝑞𝑜 and 𝑎 is pushed on top of 𝑍0
δ 𝑞𝑜 , 𝑎, 𝑎 = 𝑞𝑜 , 𝑎𝑎
δ 𝑞𝑜 , 𝑏, 𝑎 = 𝑞1 , ε If the state is 𝑞𝑜 and if we see 𝑏 as the input and 𝑎 is on the top of the stack,
δ 𝑞1 , 𝑏, 𝑎 = 𝑞1 , ε the transition state will be changed to 𝑞1 and 𝑎 is pop from the top of the stack.
δ 𝑞1 , ε, 𝑍0 = 𝑞2 , 𝑍0 or 𝑞1 , ε

𝑎, 𝑍0 |𝑎𝑍0 𝑏, 𝑎|ε

𝑏, 𝑎|ε
𝑞0 𝑞1
ε, 𝑍0 |𝑍0

𝑎, 𝑎|𝑎𝑎 𝑞2
𝑤#𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

a b a a b b # b b a a b a ε
𝑤#𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

a b a a b b # b b a a b a ε

𝑎, 𝑍0 |𝑎𝑍0
𝑏, 𝑍0 |𝑏𝑍0
𝑎, 𝑎|𝑎𝑎
𝑎, 𝑏|𝑎𝑏
𝑏, 𝑎|𝑏𝑎
𝑏, 𝑏|𝑏𝑏

𝑞0
𝑤#𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

a b a a b b # b b a a b a ε

𝑎, 𝑍0 |𝑎𝑍0
𝑏, 𝑍0 |𝑏𝑍0
𝑎, 𝑎|𝑎𝑎
𝑎, 𝑏|𝑎𝑏
𝑏, 𝑎|𝑏𝑎
𝑏, 𝑏|𝑏𝑏 #, 𝑍0 |𝑍0
#, 𝑎|𝑎
#, 𝑏|𝑏
𝑞0
𝑤#𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

a b a a b b # b b a a b a ε

𝑎, 𝑍0 |𝑎𝑍0
𝑏, 𝑍0 |𝑏𝑍0
𝑎, 𝑎|𝑎𝑎
𝑎, 𝑏|𝑎𝑏
𝑏, 𝑎|𝑏𝑎 𝑏, 𝑏|ε
𝑏, 𝑏|𝑏𝑏 #, 𝑍0 |𝑍0 𝑎, 𝑎|ε
#, 𝑎|𝑎
#, 𝑏|𝑏
𝑞0 𝑞1 𝑞2
ε, 𝑍0 |𝑍0
{𝑎𝑖 #𝑎 𝑗 |𝑖 > 𝑗} a a a a a # a a ε

a
a
a
a
𝑍0
{𝑎𝑖 #𝑎 𝑗 |𝑖 > 𝑗} a a a a a # a a ε

a
a
a
a
𝑍0

𝑎, 𝑍0 |𝑎𝑍0 ε, 𝑎|ε
𝑎, 𝑍0 |𝑎𝑍0 𝑎, 𝑎|ε
𝑎, 𝑎|ε 𝑎, 𝑎|𝑎𝑎 ε , 𝑍0 | ε
𝑎, 𝑎|𝑎𝑎
#, 𝑎|𝑎 𝑞2
#, 𝑎|𝑎 𝑞2 𝑞0 𝑞1
𝑞0 𝑞1 ε, 𝑎|ε
ε, 𝑎|𝑎

Using Empty Stack


Using Final state
1. {𝑎𝑛 #𝑎𝑛 }
2. {𝑎𝑚 #𝑎𝑛 |𝑚 > 𝑛}
3. {𝑎𝑛 𝑏 2𝑛 }
1. {𝑎𝑚 𝑏 𝑛 𝑐 𝑘 |𝑚 = 𝑛 𝑂𝑟 𝑛 = 𝑘}

𝑏, 𝑎|ε 𝑐, 𝑍0 |𝑍0

𝑎, 𝑎|𝑎𝑎 𝑐, 𝑍0 |𝑍0
𝑎, 𝑍0 |𝑎𝑍0 𝑏, 𝑎|ε ε, 𝑍0 |𝑍0

𝑞0 𝑞2
𝑏, 𝑏|𝑏𝑏 𝑐, 𝑏|ε

𝑏, 𝑎|𝑏𝑎 ε, 𝑎|𝑎

𝑐, 𝑏|ε
𝑎, ε|𝑎 ∶
Push 𝑎 without looking at the Stack valid
only at NDPDA or PDA.
Identify the Languages

an b n

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

an b n

1. Regular
𝑎, ε|𝑎 𝑏, 𝑎|ε
2. DCFL
ε, ε|ε
3. CFL 𝑞0 𝑞1 𝑞2
ε, 𝑍0 |𝑍0
4. Not CFL
Identify the Languages

an b n 𝑐 ∗

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

an b n 𝑐 ∗

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

an b ∗ 𝑐 𝑛

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

an b ∗ 𝑐 𝑛

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

a∗ b n 𝑐 𝑛

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

a∗ b n 𝑐 𝑛

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑚 𝑏 𝑛 𝑐 𝑘 |𝑚 = 𝑛 𝑂𝑟 𝑚 = 𝑘}

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑚 𝑏 𝑛 𝑐 𝑘 |𝑚 = 𝑛 𝑂𝑟 𝑚 = 𝑘}

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑚 𝑏 𝑛 |𝑚 = 2𝑛 𝑂𝑟 𝑛 = 2𝑚}

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑚 𝑏 𝑛 |𝑚 = 2𝑛 𝑂𝑟 𝑛 = 2𝑚}

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑤#𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑤#𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages (Assignment)

𝑤𝑤 𝑅 |𝑤ϵ 𝑎, 𝑏 ∗

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{an bm |𝑚 = 𝑛 𝑂𝑅 𝑚 ≠ 𝑛}

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{an bm |𝑚 = 𝑛 𝑂𝑅 𝑚 ≠ 𝑛}

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{aPrime }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{aPrime }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{an! }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{an! }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

2𝑛
{a }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

2𝑛
{a }

1. Regular
2. DCFL
3. CFL
4. Not CFL
NOTE: IF L is over one symbol then “L is Regular iff L is CFL”
Identify the Languages

{𝑎𝑛 𝑏 𝑛 𝑐 𝑛 }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑛 𝑏 𝑛 𝑐 𝑛 }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑛 𝑛 2 𝑛 3
{𝑎 𝑏 𝑐 }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑛 𝑛 2 𝑛 3
{𝑎 𝑏 𝑐 }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑛 𝑏 2𝑛 𝑐 3𝑛 }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑛 𝑏 2𝑛 𝑐 3𝑛 }

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages (Assignment)

{𝑎𝑛 𝑏 𝑛! }

1. Regular
2. DCFL
3. CFL
4. Not CFL
DPDA PDA(NPDA)
Some PDAs are non DPDA Every DPDA is PDA
It is less powerful than NPDA. It is more powerful than DPDA.
It is possible to convert every DPDA to a It is not possible to convert every NPDA to a
corresponding NPDA. corresponding DPDA.
The language accepted by DPDA is a subset of the The language accepted by NPDA is not a subset of
language accepted by NDPA. the language accepted by DPDA.
The language accepted by DPDA is called The language accepted by NPDA is called
DCFL(Deterministic Context-free Language) which is NCFL(Non-deterministic Context-free Language).
a subset of NCFL(Non-deterministic Context-free
Language) accepted by NPDA.
There is only one state transition from one state to There may or may not be more than one state
another state for an input symbol. transition from one state to another state for
same input symbol.
Closure Properties

For DCFLs For CFLs

Union 𝐷𝐶𝐹𝐿1 ∪ 𝐷𝐶𝐹𝐿2 𝐶𝐹𝐿1 ∪ 𝐶𝐹𝐿2

Intersection 𝐷𝐶𝐹𝐿1 ∩ 𝐷𝐶𝐹𝐿2 𝐶𝐹𝐿1 ∩ 𝐶𝐹𝐿2

Complement 𝐷𝐶𝐹𝐿 𝐶𝐹𝐿

Difference 𝐷𝐶𝐹𝐿1 − 𝐷𝐶𝐹𝐿2 𝐶𝐹𝐿1 − 𝐶𝐹𝐿2

Concatenation 𝐷𝐶𝐹𝐿1 . 𝐷𝐶𝐹𝐿2 𝐶𝐹𝐿1 . 𝐶𝐹𝐿2

Reversal (𝐷𝐶𝐹𝐿)𝑅𝑒𝑣 (𝐶𝐹𝐿)𝑅𝑒𝑣


Closure Properties

For DCFLs For CFLs

Union 𝐷𝐶𝐹𝐿1 ∪ 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 ∪ 𝐶𝐹𝐿2

Intersection 𝐷𝐶𝐹𝐿1 ∩ 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 ∩ 𝐶𝐹𝐿2

Complement 𝐷𝐶𝐹𝐿 Closed 𝐶𝐹𝐿

Difference 𝐷𝐶𝐹𝐿1 − 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 − 𝐶𝐹𝐿2

Concatenation 𝐷𝐶𝐹𝐿1 . 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 . 𝐶𝐹𝐿2

Reversal (𝐷𝐶𝐹𝐿)𝑅𝑒𝑣 Not Closed (𝐶𝐹𝐿)𝑅𝑒𝑣


Closure Properties

For DCFLs For CFLs

Union 𝐷𝐶𝐹𝐿1 ∪ 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 ∪ 𝐶𝐹𝐿2 Closed

Intersection 𝐷𝐶𝐹𝐿1 ∩ 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 ∩ 𝐶𝐹𝐿2 Not Closed

Complement 𝐷𝐶𝐹𝐿 Closed 𝐶𝐹𝐿 Not Closed

Difference 𝐷𝐶𝐹𝐿1 − 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 − 𝐶𝐹𝐿2 Not Closed

Concatenation 𝐷𝐶𝐹𝐿1 . 𝐷𝐶𝐹𝐿2 Not Closed 𝐶𝐹𝐿1 . 𝐶𝐹𝐿2 Closed

Reversal (𝐷𝐶𝐹𝐿)𝑅𝑒𝑣 Not Closed (𝐶𝐹𝐿)𝑅𝑒𝑣 Closed


Operations For DCFLs For CFLs
Kleene Star Not Closed Closed
Subset Not Closed Not Closed
Prefix Closed Closed
Suffix Not Closed Closed
Substring Not Closed Closed
Substitution and Not Closed Closed
Homomorphism
Inverse Homomorphism Closed Closed
Identify the Languages

{𝑎𝑛 𝑏 𝑛 |𝑛 ≥ 0} is_____________

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

{𝑎𝑛 𝑏 𝑛 |𝑛 ≥ 0} is_____________

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑤𝑤|𝑤 ∈ {𝑎, 𝑏}∗ } is_____________

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑤𝑤|𝑤 ∈ {𝑎, 𝑏}∗ } is_____________

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑎𝑛 #𝑎2𝑛 |𝑛 ≥ 0 𝑖𝑠______________

1. Regular
2. DCFL
3. CFL
4. Not CFL
Identify the Languages

𝑎𝑛 #𝑎2𝑛 |𝑛 ≥ 0 𝑖𝑠______________

1. Regular
2. DCFL
3. CFL
4. Not CFL
Self Learning Questions
• What do you mean by Greibach normal form (GNF) in the context of TOC?
Give example.
• Using appropriate example, explain the steps to covert CFG to GNF in the
context of TOC? Give example.
• Using appropriate example, explain the steps to covert Context Free
Grammar to Chomsky Normal Form in the context of TOC? Give example.
• what is Context-sensitive Grammar (CSG) and Language (CSL) in the context
of TOC? Give example.
• Using appropriate example, explain the Closure Properties for Context-
sensitive Language.

You might also like