Computer Science, asked by barlacktr5268, 1 year ago

Define ambiguity with suitable example in automatagrammer

Answers

Answered by dhruv0002
0

Explanation:

A CFG is said to be ambiguous if and only if it contains more than one derivation trees for same string.

Definition of Ambiguous Grammar: Let G = (N,T, P, S ) be a CFG. A string w ∈ L(G) is said to be “ambiguously derivable “if there are two or more different derivation trees for that string in G.

Definition of Ambiguous Grammar: A CFG given by G = (N, T, P, S) is said to be “ambiguous” if there exists at least one string in L(G) which is ambiguously derivable. Otherwise it is unambiguous.

Ambiguity is a property of a grammar, and it is usually, but not always possible to find an equivalent unambiguous grammar.

An “inherantly ambiguous language” is a language for which no unambiguous grammar exists.

Solved Example:

Show that the grammar G with production

S → a | aAb | abSb

A → aAAb | bS

is ambiguous.

Solution:

S ⟹ abSb ( ∵ S → abSb)

⟹ abab (∵ S → a)

Similarly,

S ⟹ aAb ( ∵ S → aAb)

⟹ abSb (∵ A → bS)

⟹ abab (∵ S → a)

Since ‘abab’ has two different derivations, the grammar G is ambiguous.


dhruv0002: Kiny mark the answer as brainliest, if it helps :)
Answered by Anonymous
0

Explanation:

A grammar is said to be ambiguous if there exists more than one leftmost derivation or more than one rightmost derivation or more than one parse tree for the given input string. If the grammar has ambiguity, then it is not good for compiler construction. ...

Attachments:
Similar questions