| About this closure stuff... |
of LR(0) items for a grammar G with
productions P, we define closure(
) to be the smallest
set of LR(0) items such that:
) 
1 . N2
2]
closure(
)
and N2
3
P
then
[N2
.
3]
closure(
)
)
' equal to
.
1 . M
2 ]

'
such that M
3
P and
[ M
.
3 ] 
' add
[M
.
3 ] to
'.
By identifying the invariant of the loop. Namely:
At the beginning (and end) of each iteration of step (b),
' is a subset of the closure of
.
.
3 ] that the iteration will
add must also be a member of closure(
) by the
definition of closure.
These facts establish that
' will always be a subset of
closure(
). If the loop terminates, then we know that
' must contain closure(
) and therefore
' = closure(
). Luckily, the loop must terminate since
there are only a finite number of LR(0) items that step (b)
could add to
'.
| About this closure stuff... |