Correctness of the canonical LR table #
This file gives a small grammar-symbol-stack semantics for the canonical table. It separates the mathematical handle-pruning proof from the later finite-control/buffer simulation by the concrete DPDA.
- input : List T
Instances For
Instances For
One trusted table step. The suffix equation in the reduction constructor is not an extra parser test: on reachable kernels it follows from semantic item validity. Recording it here makes the handle-pruning invariant explicit.
- shift {T : Type} [Fintype T] {G : CF_grammar T} {k : ℕ} {gamma : List (symbol T G.augment.nt)} {a : T} {w : List T} (haction : tableAction G k (scanKernel G k gamma) (observe k (a :: w)) = TableAction.shift) : Step G k { stack := gamma, input := a :: w } { stack := gamma ++ [symbol.terminal a], input := w }
- reduce {T : Type} [Fintype T] {G : CF_grammar T} {k : ℕ} {gamma p : List (symbol T G.augment.nt)} {w : List T} {r : RuleIndex G.augment} (haction : tableAction G k (scanKernel G k gamma) (observe k w) = TableAction.reduce r) (hgamma : gamma = p ++ (ruleAt G.augment r).2) : Step G k { stack := gamma, input := w } { stack := p ++ [symbol.nonterminal (ruleAt G.augment r).1], input := w }
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
A convenient completed item naming a rule occurrence.
Equations
Instances For
Fresh augmentation never inserts the fresh start symbol into an embedded right-hand side.
A surviving occurrence of the fresh initial nonterminal can only be the untouched root configuration.
A displayed rightmost prehandle exposes its production as a reduction in the canonical state at the completed handle boundary.
Before a later displayed handle boundary, LR(k) conflict freedom forces the total table's default shift.
A block of terminals before a displayed handle can be shifted without the table skipping an earlier reduction.
Prefix/terminal-suffix comparison at a rightmost handle boundary.
The only terminal-suffix split of the one-symbol fresh root whose prefix is empty or ends in a nonterminal is the root itself with empty suffix.
Result of pruning a counted rightmost derivation: either the table has accepted, or the degenerate zero-step derivation has reached the fresh root.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reverse a counted rightmost derivation by shifting up to each displayed handle and then taking the unique LR(k) reduction.
The parser stack never contains the fresh augmented start nonterminal. That symbol is recognized by the accept action rather than pushed by a reduction.
Equations
Instances For
Every word generated by an LR(k) grammar is accepted by its canonical table (for positive lookahead).