A New Technique in Graph-to-State-Machine Reduction Proofs
檔案
本條目沒有附加檔案。
日期
2026-11-25
類型
系所
期刊名稱
Algorithms
卷期與頁次
第 19 卷第 12 期,頁 1035
ISSN
1999-4893
語言
英文
摘要
LALR(1) parsers are obtained by merging every pair of LR(1) states with identical cores, but such merging can introduce reduce–reduce conflicts. A natural alternative is to merge as many similar states as possible while keeping the parser conflict-free. We prove that this minimization problem is NP-hard, by a polynomial-time reduction from graph coloring. Given a graph F with n nodes, we construct a conflict-free LR(1) grammar whose canonical LR(1) machine has O(n3) states. Exactly n of these states can be merged, one for each node of F, and two of them conflict if and only if the corresponding nodes in F are adjacent. Hence F is k-colorable if and only if the machine can be reduced to at most C+k states, where C depends only on n. The construction relies on three devices. Every pair of nodes is encoded in the grammar, adjacent or not. A lookahead terminal is shared exactly when two nodes are adjacent. Filler rules make all mergeable states have identical cores. These devices may be useful in other reductions from graph problems to parser state machines.