You've written a yacc grammar (or some other LALR grammar in the tool of your choice), and you've decided that you want to refactor some productions for efficiency, clarity, whatever. For example, you had:
xs : xs ';' x
| xs ';'
| x
You want to make it more obvious that there can be multiple semicolons, so you rewrite it as:
semi_plus : semi_plus ';'
| ';'
xs : xs semi_plus x
| x
OK, so, looks plausible... but did I actually do the refactoring correctly? It would be great if I could pass these declarations to a tool that would tell me if the grammars are equivalent or not. (For now, let us consider solely the question of whether or not we recognize the same languages.)
One knee-jerk reaction is to quote that context free grammar equivalence is undecidable. In fact, even the problem of determining if a CFG is regular is undecidable. But yacc does not recognize CFGs: it recognizes deterministic context free grammars, and for these, it is known that equivalence is decidable. But has anyone implemented any of these decision procedures?