A direct branching algorithm for checking equivalence of strict deterministic vs. LL(k) grammars

Etsuji Tomita
1983 Computer Compacts  
We present here an equivalence checking algorithm which operate> directly on a pair of strict deterministic vs. LL(k) grammars. It is also straightforwardly applicable to a pair of LL(k) grammars, though an LL(k) grammar is not necessarily strict deterministic. The Basic idea is from Korenjak and Hopcroft's branching algorithm for simple deterministic grammars, but ours is so distinguished that it is throughout free from mixing the nonterminals of the respective grammars in question and then
more » ... y simple. Any of these algorithms is carried out by constructing step by step a rooted tree named comparison tree or transformation tree in which each node is labeled by an equ.ivalence equation for a pair of nonterminal strings. Then the crux of algorithms of this kind is how to avoid infinite proliferation of the tree in case the given grammars are equivalent. As a counterplan for it, the so called rype B replacement [IO] or its variants, i.e. splitting [ 121 or B-transformation [8] have been employed. These steps, however, may generate such nodes as are labeled by equivalence equations which contain strings of mixed nonterminals or artificially introduced symbols, and this complicates the algorithm. Instead of such steps, we adopt here another one named skipping that has been proposed in a new direct branching algorithm for checking equivalence of some classes of deterministic pushdown automata (Tomita [ 18]), to simplify and extend the previous algorithms. In this paper, we present a direct branching algorithm for checking equivalence of a pair of strict deterministic vs. LL(L) grammars, in which the nonterminals of the two grammars in question riced not be 'mixed'. This msy prove general applicability of our direct branching algorithm. The algorithm is so designed that it can also be applied to a pair of LL(k) grammars without any change, though an LL(K) grammar is not necessarily strict deterministic. An example of checking equivalence of two LL(k) grammars is given for reference in the Appendix. While the equivalence problems mentioned above have already been solved via corresponding deterministic pushdown automata [ 17, 14, 18; and 16 for two LL(k ) grammars], cf. [6, 201, our algorithm solves these problems directly operating on grammars and is simple. Definitions and notation [4,1J Definition 2.1.
doi:10.1016/0167-7136(83)90163-4 fatcat:zxrq6i4pwjhsbklqx4xdm53mri