Equivalence (formal languages)


In formal language theory, weak equivalence of two grammars means they generate the same set of strings, i.e. that the formal language they generate is the same. In compiler theory the notion is distinguished from strong equivalence, which additionally means that the two parse trees are reasonably similar in that the same semantic interpretation can be assigned to both.
Vijay-Shanker and Weir demonstrates that Linear Indexed Grammars, Combinatory Categorial Grammars, Tree-adjoining Grammars, and Head Grammars are weakly equivalent formalisms, in that they all define the same string languages.
On the other hand, if the two grammars generate the same set of derivation trees, then the two languages are strongly equivalent. Chomsky introduces the notion of strong equivalence, and argues that only strong equivalence is relevant when comparing grammar formalisms. Kornai and Pullum and Miller offer a refined notion of strong equivalence that allows for isomorphic relationships between the syntactic analyses given by different formalisms. Yoshinaga, Miyao, and Tsujii offers a proof of the strong equivalency of the LTAG and HPSG formalisms.

Context-free grammar example

As an example, consider the following two context-free grammars, given in Backus-Naur form:

::= "+" | "-"
| "*" | "/"
| "x" | "y" | "z" | "1" | "2" | "3" | ""


::= | "+" | "-"
::= | "*" | "/"
::= "x" | "y" | "z" | "1" | "2" | "3" | ""

Both grammars generate the same set of strings, viz. the set of all arithmetical expressions that can be built from the variables "x", "y", "z", the constants "1", "2", "3", the operators "+", "-", "*", "/", and parentheses "".
However, a concrete syntax tree of the second grammar always reflects the usual order of operations, while a tree from the first grammar need not.
For the example string "1+2*3", the right part of the picture shows its unique parse tree with the second grammar; evaluating this tree in postfix order will yield the proper value, 7.
In contrast, the left picture part shows one of the parse trees for that string with the first grammar; evaluating it in postfix order will yield 9.
Since the second grammar cannot generate a tree corresponding to the left picture part, while the first grammar can, both grammars are not strongly equivalent.

Generative capacity

In linguistics, the weak generative capacity of a grammar is defined as the set of all strings generated by it, while a grammar's strong generative capacity refers to the set of "structural descriptions" generated by it.
As a consequence, two grammars are considered weakly equivalent if their weak generative capacities coincide; similar for strong equivalence.
The notion of generative capacity was introduced by Noam Chomsky in 1963.