Question

Show that any LL grammar is unambiguous.

(Note: This is so obvious it is hard to prove. Instead, prove the contrapositive: ambiguous implies not LL(k) for any k.)

Answer #1

Leave T and N alone the arrangements of terminal and non-terminal images.

Allow the accompanying to hold

MaybeEmpty(s) = valid <=> s - >* void

First(s) = X containing all x for which there exists Y with the end goal that s - >* xY

Follow(A) = X containing all x for which there exists Y,Z with the end goal that S - >* YAxZ

Note that a language structure is LL(1) if the accompanying holds for each pair of creations A - > B and A - > C:

1. (not MaybeEmpty(B)) or (not MaybeEmpty(C))

2. (First(B) meet First(C)) = void

3. MaybeEmpty(C) => (First(B) cross Follow(A)) = void

Think about a language with is LL(1), with A - > B and A - > C. In other words there is some series of terminals TZ which concedes various deductions by particular parse trees.

Assume that the left induction arrives at S - >* TAY - >* TZ. The subsequent stage might be either TAY - > TBY, or TAY - > TCY. Hence the language is questionable if both BY - >* Z and CY - >* Z. (Note that since An is a discretionary non-terminal, if no such case exists, the language is non-equivocal.)

Case 1: Z = void

By rule 1 of LL(1) punctuations, at generally one of B and C can determine void (non-uncertain case).

Case 2: Z non-void, and neither B nor C infer void

By rule 2 of LL(1) language structures, at generally one of B and C can allow further inference in light of the fact that the main terminal of Z can't be in both First(B) and First(C) (non-questionable case).

Case 3: Z non-void, and either MaybeEmpty(B) or MaybeEmpty(C)

Note the by rule 1 of LL(1) sentence structures, B and C can't both determine void. Assume consequently that MaybeEmpty(C) is valid.

This gives two sub-cases.

Case 3a: CY - > Y; and Case 3b: CY - >* DY, where D isn't unfilled.

In 3a we should pick between BY - >* Z and CY - > Y - >* Z, however notice that First(Y) subset-of Follow(A). Since Follow(A) doesn't meet First(B), just a single determination can continue (non-equivocal).

In 3b we should pick between BY - >* Z and CY - >* DY - >* Z, yet notice that First(D) subset-of First(C). Since First(C) doesn't meet First(B), just a single determination can continue (non-uncertain).

Along these lines for each situation the induction must be extended by one of the accessible creations. Thusly the punctuation isn't vague.

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 5 minutes ago

asked 6 minutes ago

asked 10 minutes ago

asked 34 minutes ago

asked 36 minutes ago

asked 36 minutes ago

asked 43 minutes ago

asked 43 minutes ago

asked 44 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago