Parikh's theorem

From HandWiki

Parikh's theorem in theoretical computer science says that if one looks only at the number of occurrences of each terminal symbol in a context-free language, without regard to their order, then the language is indistinguishable from a regular language.[1] It is useful for deciding that strings with a given number of terminals are not accepted by a context-free grammar.[2] It was first proved by Rohit Parikh in 1961[3] and republished in 1966.[4]

Definitions and formal statement

Let Σ={a1,a2,,ak} be an alphabet. The Parikh vector of a word is defined as the function p:Σ*k, given by[1] p(w)=(|w|a1,|w|a2,,|w|ak) where |w|ai denotes the number of occurrences of the letter ai in the word w.

A subset of k is said to be linear if it is of the form u0+u1++um={u0+t1u1++tmumt1,,tm} for some vectors u0,,um. A subset of k is said to be semi-linear if it is a union of finitely many linear subsets.

Theorem — Let L be a context-free language or a regular language, let P(L) be the set of Parikh vectors of words in L, that is, P(L)={p(w)wL}. Then P(L) is a semi-linear set.

If S is any semi-linear set, then there exists a regular language (which a fortiori is context-free) whose Parikh vectors is S.

In short, the image under p of context-free languages and of regular languages is the same, and it is equal to the set of semilinear sets.

Two languages are said to be commutatively equivalent if they have the same set of Parikh vectors. Thus, every context-free language is commutatively equivalent to some regular language.

Proof

The second part is easy to prove.

The first part is less easy. The following proof is credited to Goldstine.[5]

First we need a small strengthening of the pumping lemma for context-free languages:

Lemma — If L is generated by a Chomsky normal form grammar, then N1, such that

For any k1, and for any wL with |w|Nk, there exists a way to split w into segments ux1xkzyky1v, and a nonterminal symbol A, such that

|xiyi|1 for all i, and |x1xkzyky1|Nk

S*uAvA*zi,A*xiAyi

The proof is essentially the same as the standard pumping lemma: use the pigeonhole principle to find k copies of some nonterminal symbol A in the longest path in the shortest derivation tree.

Strengthening for bounded languages

A language L is bounded if Lw1*wk* for some fixed words w1,,wk. Ginsburg and Spanier [6] gave a necessary and sufficient condition, similar to Parikh's theorem, for bounded languages.

Call a linear set stratified, if in its definition for each i1 the vector ui has the property that it has at most two non-zero coordinates, and for each i,j1 if each of the vectors ui,uj has two non-zero coordinates, i1<i2 and j1<j2, respectively, then their order is not i1<j1<i2<j2. A semi-linear set is stratified if it is a union of finitely many stratified linear subsets.

Ginsburg-Spanier — A bounded language L is context-free if and only if {(n1,,nk)w1n1wknkL} is a stratified semi-linear set.

Significance

The theorem has multiple interpretations. It shows that a context-free language over a singleton alphabet must be a regular language and that some context-free languages can only have ambiguous grammars[further explanation needed]. Such languages are called inherently ambiguous languages. From a formal grammar perspective, this means that some ambiguous context-free grammars cannot be converted to equivalent unambiguous context-free grammars.

References

  1. 1.0 1.1 Kozen, Dexter (1997). Automata and Computability. New York: Springer-Verlag. ISBN 3-540-78105-6. 
  2. Håkan Lindqvist. "Parikh's theorem". Umeå Universitet. http://www8.cs.umu.se/kurser/TDBC92/VT06/final/3.pdf. 
  3. Parikh, Rohit (1961). "Language Generating Devices". Quarterly Progress Report, Research Laboratory of Electronics, MIT. 
  4. Parikh, Rohit (1966). "On Context-Free Languages". Journal of the Association for Computing Machinery 13 (4): 570–581. doi:10.1145/321356.321364. http://portal.acm.org/citation.cfm?id=321364&dl=. 
  5. Goldstine, J. (1977-01-01). "A simplified proof of parikh's theorem" (in en). Discrete Mathematics 19 (3): 235–239. doi:10.1016/0012-365X(77)90103-0. ISSN 0012-365X. https://dx.doi.org/10.1016/0012-365X%2877%2990103-0. 
  6. Ginsburg, Seymour; Spanier, Edwin H. (1966). "Presburger formulas, and languages". Pacific Journal of Mathematics 16 (2): 285–296. doi:10.2140/pjm.1966.16.285. https://projecteuclid.org/euclid.pjm/1102994974.