Context-Free Grammars: CSE 211 (Theory of Computation)
Context-Free Grammars: CSE 211 (Theory of Computation)
Context-Free Grammars: CSE 211 (Theory of Computation)
Context-Free Grammars
CSE 211 (Theory of Computation)
Assistant Professor
Department of Computer Science and Engineering
Bangladesh University of Engineering & Technology
P→
P→0
P→1
P → 0P0
P → 1P1
CFG - an example
(a + b)(a + b + 0 + 1)∗
CFG - an example
Leftmost derivation
At each step we replace the leftmost variable by one of its
production bodies
Rightmost derivation
At each step we replace the rightmost variable by one of its
production bodies
Leftmost Derivation
Rightmost Derivation
Language of a grammar
Parse Trees
X1 , X2 . . . Xk
Designing CFGs
Designing CFGs
Designing CFGs
Designing CFGs
Designing CFGs
Designing CFGs
Designing CFGs
S → S1 |S2 | · · · |Sk
Exercise
Design a DFA for the language
{w|w contains at least three 1s} and convert it to CFG