Every time you type code, write a mathematical formula, or ask a voice assistant a question, some program must decide: does this string of symbols follow the rules? That question is parsing, and for the broadest useful class of grammars — context-free grammars — the answer has been known since 1965 thanks to an algorithm built around a single elegant idea.
The Cocke-Younger-Kasami algorithm (CYK, independently discovered by John Cocke, Daniel Younger, and Tadao Kasami) decides whether a given sentence of length n belongs to a context-free language in time , where |G| is the size of the grammar. It does this by filling a triangular table of subproblems: can the non-terminal symbol A generate the substring from position i to position j? The answer for short substrings feeds into the answer for longer ones, bottom-up.
That cubic bound is not just theoretical. It is the reason every production compiler, every code editor with syntax highlighting, and every natural-language parser begins with the same idea: build the triangle, read the answer from the top cell.
Comments
Loading comments...