Professional Documents
Culture Documents
FAFL Final Lecture 25.1 CMH
FAFL Final Lecture 25.1 CMH
Lecture 25.1
Ambiguity in Grammars and Languages
S c h o o l o f C o m p u t i n g a n d I n f o r m a t i o n Te c h n o l o g y
Chaithra M H
AY:2020-2021
OUTLINE
Recap of Previous Lecture
Lecture Discussion
Examples-ambiguous grammar
Differences between ambiguous and unambiguous grammar
Ambiguity in Grammars and Languages
Topic for the lecture
TOPIC OF THE LECTURE
Languages
Ambiguity in
and Grammars
Grammars and
in Ambiguity
on Examples •
Languages
Ambiguity in Grammars and Languages
Objective and Outcome of Lecture
construct
Ambigui
ty in
Gramma
rs and
Languag Outcome
es to Lecture
solve the
• given
Illustrat
problem
e the
by
constru
applying
ction of
LMD or
Ambigui
RMD Objective
ty
techniquin Lecture
Gramm
es.
ars and
Languag
es for a
given
gramma
OBJECTIVE AND OUTCOME OF LECTURE
r.
Ambiguity in Grammars and Languages
Problems on Ambiguity in Grammars and Languages
EXAMPLE-1
a S a X
a S
a X
a X
a X
a
a
Since there are two leftmost derivations for the same sentence aaaa, the
grammar G is ambiguous.
EXAMPLE-2
• A CFG is ambiguous if there is a string in the language that is the yield of two or
more parse trees.
• Example: S -> SS | (S) | ()
• Two parse trees for ()()() on next slide.
EXAMPLE 2 – CONTINUED
Since there are two leftmost derivations for the same sentence ( )( )( ) the
grammar G is ambiguous.
DISCUSSION
5 MINUTES