Prev Up Next
Go backward to Announcements
Go up to Top
Go forward to About this closure stuff...

The Correctness of LR(0) parsing

  1. The correctness of the LR(0) parsers we have discussed rests on the theorem:
    Theorem
    [ N 1 . 2 ] ( 0, ) iff [ N 1 . 2 ] is valid for .
  2. Rather than completely prove the theorem, I would like to prove it in one direction (the easy one) and let you convince yourselves of the other direction. In particular, I will prove that:
    [N -> 1 . 2 ] ( 0, ) only if [ N 1 . 2 ] is valid for .
  3. The proof of this lemma is simplified by identifying a way to partition the set of LR(0) items associated with a state of the LR(0) machine into tow parts.
    Kernel items
    We say that an LR(0) item is a kernel item if either:
    1. it is the item [ S' . S ], or
    2. it is of the form [ N 1 . 2 ] for 1 != .
    All other items are called non-kernel items.

    Note that the set of items associated with a state in the LR(0) machine is just the closure of the set of kernel items associated with the state. In particular, all items in goto(,x) are kernel items.

  4. Given this partition, we can break the proof of this half of the theorem into two lemmas:
    Lemma 1: Given a set of LR(0) items valid for some (Vn U Vt)*, all items in closure() are valid for .
    Lemma 2: For kernel items, [N -> 1 . 2 ] ( 0, ) only if [ N 1 . 2 ] is valid for .

Computer Science 434
Department of Computer Science
Williams College

Prev Up Next