CYK Parsing with Span Dynamic Programming

Fill a triangular table of parse spans and retain split witnesses when a derivation tree is needed.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. The table stores nonterminals that generate a substring
  2. Store a successful rule and split to reconstruct

The table stores nonterminals that generate a substring

For a grammar in Chomsky normal form, initialize a length-one span with every variable having a rule for that terminal. Fill longer spans \([i,j)\) in increasing length. For each split \(k\), a production \(A\to BC\) can add \(A\) when \(B\) generates \([i,k)\) and \(C\) generates \([k,j)\). A parse tree of a longer nonempty span necessarily has exactly such a root split, proving completeness by induction.

Store a successful rule and split to reconstruct

Membership asks whether the start variable appears in the full span. One successful rule and split per table entry lets the parser recover one tree. All derivations can share substructures in a packed representation, which can be much smaller than listing their trees individually. Straightforward evaluation uses \(O(n^3)\) time for fixed grammar and quadratic space. Dynamic programming state design explains why a span and its variable summarize sufficient information.[1][2]

References

  1. John Hopcroft, Rajeev Motwani and Jeffrey Ullman, Context-Free Grammars and Languages ↩
  2. Michael Sipser, Introduction to the Theory of Computation ↩