Tag. LL

Notes (5)

Definition. First Sets in Dependent Lambek Calculus first-set-in-dependent-lambek

The first set of a grammar 𝐴 may be captured in Lambek𝙳 via the following proposition:

π‘βˆ‰π–₯π—‚π—‹π—Œπ—(𝐴)≔𝐴&('𝑐'βŠ—βŠ€)⊒βŠ₯

Or perhaps with ones of the grammars

𝐴⇒¬('𝑐'βŠ—βŠ€),'𝑐'βŠ—βŠ€β‡’Β¬π΄

Definition. FollowLast Sets in Dependent Lambek Calculus followlast-set-in-dependent-lambek

The followlast set of a grammar 𝐴 may be captured in Lambek𝙳 via the following proposition:

π‘βˆ‰π–₯π–«π–Ίπ—Œπ—(𝐴)≔𝐴&(π΄βŠ—'𝑐'βŠ—βŠ€)⊒βŠ₯

Or perhaps with ones of the grammars

𝐴⇒¬(π΄βŠ—'𝑐'βŠ—βŠ€),π΄βŠ—'𝑐'βŠ—βŠ€β‡’Β¬π΄

Definition. LL(1) Condition ll1-condition

A context-free grammar satisfies the LL(1) condition if it satisfies the following three conditions:

  • All of its productions have pairwise disjoint first sets
  • If a concatenation of nonterminals π΄βŠ—π΅ appears in a production, then 𝐴 has a disjoint followlast set from the first set of 𝐡
  • At most one production is nullable

This is essentially the type system of [1], which characterizes the LL(1) condition for context-free expressions.

Intutively, an LL(1) grammar can be parsed unambiguously, and without backtracking, by a predictive parser that only needs one token of lookahead.

Definition. Nullability in Dependent Lambek Calculus nullability-in-dependent-lambek

The nullability (π–­π—Žπ—…π—…(β‹…)) of a grammar 𝐴 may be captured in Lambek𝙳 via the following proposition:

Β¬π–­π—Žπ—…π—…(𝐴)≔𝐴&πœ–βŠ’βŠ₯

Or perhaps with one of the grammars

π΄β‡’Β¬πœ€,πœ€β‡’Β¬π΄

Definition. Sequential Unambiguity sequential-unambiguity

Grammars 𝐴 and 𝐡 are sequentially unambiguous if the followlast set of 𝐴 is disjoint from the first set of 𝐡.

π–₯π–«π–Ίπ—Œπ—(𝐴)∩π–₯π—‚π—‹π—Œπ—(𝐡)=βˆ…

We can understand this intuitively by characterizing the behavior of a left-to-right parser of π΄βŠ—π΅. First it searches for a parse of 𝐴, then upon finding a character that is not in π–₯π–«π–Ίπ—Œπ—(𝐴) it may begin trying search for 𝐡.

That is, there is a unique boundary between the 𝐴-parse and the 𝐡-parse.

tag-LL tag