Automata Ch3
Automata Ch3
Theory
Chapter three (1)
Context Free Languages and Context-free Grammar(CFG)
• S is the start symbol which is used to derive the string. We can derive
the string by repeatedly replacing a non-terminal by the right-hand
side of the production until all non-terminal have been replaced by
terminal symbols.
• Construct the CFG for the language having any number of a's over the
set ∑= {a}.
• Solution:
As we know the regular expression for the above language is
r.e. = a*
• Production rule for the Regular expression is as follows:
• S → aS rule 1
• S → ε rule 2
• S → aSa
• S → abSba from rule 2
• S → abbSbba from rule 2
• S → abbcbba from rule 3
1. Leftmost Derivation:
• In the leftmost derivation, the input is scanned and replaced with the
production rule from left to right. So in leftmost derivation, we read
the input string from left to right.
• Example:
• Production rules: and Input a - b + a
E -> E + E
E -> E - E
E -> a | b
02/02/2024 For third year CS student by Gezahiegn.T In 2022 11
Continue..
• The leftmost derivation is:
•E=E+E
•E=E-E+E
•E=a-E+E
• E=a-b+E
• E=a-b+a
A → aB
B → Sb
• Solution:
• Leftmost derivation: