Prev Up Next
Go backward to Announcements
Go up to Top
Go forward to Some Preliminaries to LR(1) parsing

The Correctness of LR(0) parsing

  1. Lemma 2: For kernel items, [N -> 1 . 2 ] ( 0, ) only if [ N 1 . 2 ] is valid for .
  2. Now, assuming Lemma 1, we can prove Lemma 2 by induction on the length of . The basis step is so simple that we will look at the induction step first:
    induction
    Assume that we know that the theorem holds for all strings of length n and consider some string x such that is of length n and x is a single symbol.

    Suppose that [ N 1 x . 2 ] is an item in ( 0, x ). The fact that this item is in this set implies that the item [ N 1 . x 2 ] must be in ( 0, ). This, together with our inductive assumption implies that [ N 1 . x 2 ] must be valid for . Therefore, there exists a derivation:

    S' N 1 x 2
    with 1 = . This, however implies that [ N 1 x . 2 ] is indeed valid for x.
    basis
    Similarly, when we consider strings of length 0, the only kernel item in ( 0, eps) is [ S' . S]. The derivation S' S' S shows that this item is valid for eps.

Computer Science 434
Department of Computer Science
Williams College

Prev Up Next