Algorithms

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

Arthur Ning-Chih Yang, Yi-Ping You, Wuu Yang

Key points

From the paper's conclusion
  • We prove that this minimization problem is NP-hard, by a polynomial-time reduction from graph coloring.

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.

Read the paper

Discussion

Science Skim's AI key points, plus readers' public thoughts

Readers' thoughts

No reader thoughts yet.

Related papers