Skip to Content
AlgorithmsAlgorithms
  • Article
  • Open Access

25 November 2026

31 Pages

A New Technique in Graph-to-State-Machine Reduction Proofs

,
and
Computer Science Department, National Yang Ming Chiao Tung University, Hsinchu City 30010, Taiwan
*
Author to whom correspondence should be addressed.

Abstract

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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.