Parikhs Theorem in Automata Theory



The Parikhs Theorem provides a unique perspective on context-free languages (CFLs). It focuses on the number of occurrences of terminal symbols in CFL, disregarding their order. This theorem was first proved by Rohit Parikh in 1961 and later republished in 1966. In this chapter, we will cover the basics of Parikh's Theorem.

Basics of Parikh's Theorem

To get the basic idea of Parikhs Theorem, it states that if we consider only the frequency of terminal symbols in strings of a context-free language, the language cannot be distinguishable from a regular language. This is because the Parikh image of a context-free language is semi-linear.

In simpler terms, we can say that every context-free language can be matched to some regular language that has the same frequency distribution of symbols.

The Theorem Statement

It says that the Parikh image of a context-free language is semi-linear or, equivalently, that every context-free language has the same Parikh image as some regular language. So for any given context-free grammar, there exists a finite automaton that can recognize a regular language with the same Parikh image.

Parikh Image

We have talked about the Parikh image, let us see the concept of Parikh Image. The Parikh image of a word over an alphabet is a vector that counts the number of occurrences of each symbol in the word.

For a language, the Parikh image is the set of all such vectors for every word in the language.

Example of Parikh Image

Let us see two examples to illustrate this −

Example 1

Consider the word bccba over the alphabet {a, b, c}.

The Parikh image of this word is (1, 2, 2), where 1 represents the occurrence of a, 2 represents the occurrence of b, and 2 represents the occurrence of c.

We denote this as,

$$\mathrm{\Pi \{a, b, c\} (bccba) = (1, 2, 2)}$$

Example 2

Consider the word cabaaabb over the alphabet {a, b, c}.

The Parikh image of this word is (4, 3, 1), where 4 represents the occurrence of a, 3 represents the occurrence of b, and 1 represents the occurrence of c.

We denote this as,

$$\mathrm{\Pi \{a, b, c\} (\text{cabaaabb}) = (4, 3, 1)}$$

Derivation of Parikhs Theorem

Let us see Parikh vector for a word over a given alphabet.

Parikh Vector Definition

Let ∑ be an alphabet consisting of symbols {a1, a2, …, ak}.

The Parikh vector of a word is a function that maps a word to a vector of natural numbers (Nk).

This vector counts the number of occurrences of each symbol in the word. Formally, for a word w, the Parikh vector p(w) is defined as p(w) = (|w|a1, |w|a2, …, |w|ak).

  • Statement 1 − Let L be a context-free language. The set of Parikh vectors for words in L, denoted as P(L), is a semi-linear set. This means that the Parikh vectors of words in a context-free language form a semi-linear set, which is a Presburger-definable subset of Nk.
  • Statement 2 − If S is any semi-linear set, the language of words whose Parikh vectors belong to S is commutatively equivalent to some regular language. In essence, this implies that every context-free language is commutatively equivalent to some regular language.

These statements highlight that the image under p (Parikh vector function) of both context-free languages and regular languages is the same, represented as a set of semi-linear sets.

Application in Bounded Languages

Parikh's Theorem has a particular significance for bounded languages. A language L is bounded if it is a subset of w1*……..wk*, where w1,….. , wk are fixed words.

Ginsburg and Spanier extended Parikh's Theorem by providing a necessary and sufficient condition for bounded languages to be context-free.

Ginsburg-Spanier Theorem

The theorem states that a bounded language L is context-free if and only if the set {(n1,…….,nk) | w1n1…… wknk ∈ L} is a stratified semi-linear set.

Examples of Parikhs Theorem

Let us see some practical examples to see how Parikhs Theorem works.

Example 1: Context-Free Language L = {0n1n | n >= 1}

Here, the language consists of strings where the number of 0s equals the number of 1s.

For instance, the string 000111 belongs to this language because it has three 0s and three 1s.

The Parikh vector for this string w = '000111' is P(w) = {3, 3}.

Example 2: Context-Free Language L = {0n1n | n < 3 , n >= 1}

In this case, the language consists of strings where the number of 0s and 1s are equal, but the number of 0s and 1s is either 1 or 2.

For n = 1, the string is 01, and for n = 2, the string is 0011.

The Parikh vectors for these strings are:

  • P(‘01’) = {1, 1}
  • P(‘0011’) = {2, 2}

Therefore, the Parikh image of this language is P(L) = { {1,1}, {2,2} }.

Since we can determine the set of Parikh vectors for the given language, we can construct a deterministic finite automaton (DFA) for this language. This DFA is commutatively equivalent to some regular language.

Corollaries of Parikhs Theorem

Parikh's Theorem concludes several corollaries:

  • Every CFL is "letter-equivalent" to a regular language − For example, the context-free language {anbn | n ≥ 0} is letter-equivalent to the regular language (ab)*.
  • Lengths of a CFL form an ultimately periodic set
  • CFLs over a single-letter alphabet are regular.
  • Parikh's Theorem is useful for deciding whether strings with a given number of terminals are accepted by context-free grammar.

Conclusion

In this chapter, we explained the concept of Parikh's Theorem, which shows the relationship between context-free languages and regular languages by focusing on the number of terminal symbols rather than their order.

We covered the concept of Parikh images along with the derivation of the theorem, and its application to bounded languages. Through examples, we showed how Parikh vectors help us understand the properties of context-free languages and their equivalence to regular languages.

Advertisements