All Exams Test series for 1 year @ ₹349 only
Question

Which of the following languages are not regular?

A. L = {(01) n 0k | n > k, k >= 0}

B. L = {c nb ka n + k | n >= 0, k >= 0}

C. L = {0 n1 k| n ≠ k}

Choose the correct answer from the options given below :

The correct answer is

A, B and C

Understanding Regular Languages and the Pumping Lemma

Regular languages are a class of formal languages that can be recognized by finite automata. To determine if a language is not regular, a common technique is to use the Pumping Lemma for Regular Languages. This lemma states that if a language L is regular, then there exists some integer p (called the pumping length) such that for any string s in L with $|s| \geq p$, s can be divided into three substrings, s = xyz, satisfying the following conditions:

  • |y| > 0 (y is not empty)
  • |xy| ≤ p (the combined length of x and y is at most p)
  • For all i ≥ 0, the string xyiz is also in L.

If we can find a string s in L with $|s| \geq p$ that cannot be pumped according to these conditions (i.e., for some i ≥ 0, xyiz is not in L, regardless of how we split s into xyz obeying the first two conditions), then L is not regular.

Analyzing Language A: \(L = \{(01)^n 0^k | n > k, k ≥ 0\}\)

Let's test Language A for regularity using the Pumping Lemma. Assume L is regular and let p be the pumping length.

Choose a string \(s \in L\) such that \(|s| \geq p\). A suitable string is \(s = (01)^p 0^{p-1}\). Here, \(n=p\) and \(k=p-1\). Since \(p \geq 1\), \(n > k\) holds for \(p > 1\). Let's assume \(p > 1\). The length of s is \(|s| = 2p + (p-1) = 3p - 1\), which is greater than or equal to p.

According to the Pumping Lemma, s can be divided into \(s = xyz\) such that \(|y| > 0\), \(|xy| \le p\), and \(xy^i z \in L\) for all \(i \ge 0\).

Since \(|xy| \le p\) and \(s = (01)^p 0^{p-1}\), the substring \(xy\) must be contained within the first p characters of s. The first p characters of s are part of the \((01)^p\) block. Specifically, the first p characters are \(0101...01\) (ending after the p-th character). Thus, \(y\) must be a non-empty substring of this prefix of length p.

Let \(y\) be a non-empty substring within the first p characters. Consider the following cases for y:

  • If \(y\) consists only of 0s or only of 1s (e.g., \(y=0\) or \(y=1\)), then pumping \(y\) (e.g., \(xy^0z\)) will result in a string where the initial structure is not of the form \((01)^m\). This means the resulting string is not in L.
  • If \(y\) consists of both 0s and 1s, \(y\) must be a substring of \(0101...\) (the first p characters). For instance, \(y\) could be \(01\), \(10\), \(010\), etc., as long as it's within the first p characters. Let's take \(s = (01)^p 0^{p-1}\) and a split where \(y\) is within the \((01)^p\) part and \(|xy| \le p\). A simple split could have \(x=(01)^a\) and \(y=(01)^b\) where \(a+b \le p\) and \(b \ge 1\), and \(z=(01)^{p-a-b} 0^{p-1}\). Pumping down with \(i=0\) gives \(xy^0z = (01)^a (01)^{p-a-b} 0^{p-1} = (01)^{p-b} 0^{p-1}\). The number of (01) blocks is \(n' = p-b\) and the number of trailing zeros is \(k' = p-1\). For this string to be in L, we need \(n' > k'\), i.e., \(p-b > p-1\). This simplifies to \(-b > -1\), or \(b < 1\). However, the Pumping Lemma requires \(|y| = 2b \ge 1\), which means \(b \ge 1/2\), so \(b \ge 1\) for integer \(b\). Thus, \(b \ge 1\) contradicts \(b < 1\). If \(y\) is a single character 0 or 1 from the $(01)^p$ part, say \(y=0\), then \(xy^0z\) removes a 0 from the $(01)^p$ block, disrupting the structure or counts such that it's not in L. For example, if \(s=(01)^p 0^{p-1}\), take $x=(01)^{p-1}0$, $y=1$, $z=(01)^0 0^{p-1}$. $|xy|=2(p-1)+1+1=2p$. This fails $|xy| \leq p$.

Let's try again with \(s = (01)^p 0^{p-1}\). $|xy| \leq p$. $y$ is a substring of the first $p$ characters of $s$. These characters are $0101...$ from the $(01)^p$ part. $y$ is thus a substring of the sequence $0,1,0,1,...$ up to the $p$-th character.

  • If \(y\) contains only 0s or only 1s, pumping \(y\) breaks the alternating \(01\) pattern. E.g., if \(y=0\), \(xy^0z\) removes a 0, resulting in something like \((01)...1...(01)0^{p-1}\), which is not in L.
  • If \(y\) contains both 0s and 1s, \(y\) must be of the form \(01... \) or \(10...\). Let's consider \(y=01\). For \(s=(01)^p 0^{p-1}\), we can find a split like \(x=(01)^a\), \(y=01\), \(z=(01)^{p-a-1} 0^{p-1}\) such that \(|xy| = 2a+2 \leq p\). If we choose \(a=0\), \(x=\epsilon\), \(y=01\), \(z=(01)^{p-1} 0^{p-1}\), then \(|xy|=2 \leq p\) (for \(p \ge 2\)) and \(|y|=2 > 0\). Pumping down \(i=0\): \(xy^0z = \epsilon \cdot (01)^0 \cdot (01)^{p-1} 0^{p-1} = (01)^{p-1} 0^{p-1}\). In this string, the number of (01) blocks is \(n'=p-1\) and the number of trailing zeros is \(k'=p-1\). Here, \(n' = k'\), so \(n' > k'\) is false. Thus, \(xy^0z \notin L\).

Since we found a string s in L that cannot be pumped according to the lemma, Language A is not regular.

Analyzing Language B: \(L = \{c^n b^k a^{n+k} | n ≥ 0, k ≥ 0\}\)

Assume Language B is regular and let p be the pumping length.

Choose \(s = c^p b^p a^{2p} \in L\). Here \(n=p\) and \(k=p\), so \(n+k = 2p\). \(|s| = p+p+2p = 4p\), which is \(\ge p\).

According to the Pumping Lemma, \(s = xyz\) such that \(|y| > 0\), \(|xy| \le p\), and \(xy^i z \in L\) for all \(i \ge 0\).

Since \(|xy| \le p\), and the first p characters of \(s\) are all \(c\)'s (\(c^p\)), both \(x\) and \(y\) must consist entirely of \(c\)'s. So, \(x = c^a\), \(y = c^b\), and \(z = c^{p-a-b} b^p a^{2p}\), where \(a \ge 0\), \(b \ge 1\) (since \(|y| > 0\)), and \(a+b \le p\).

Consider pumping down with \(i=0\): \(xy^0z = c^a c^{p-a-b} b^p a^{2p} = c^{p-b} b^p a^{2p}\).

The number of \(c\)'s in this new string is \(n' = p-b\). The number of \(b\)'s is \(k' = p\). The number of \(a\)'s is \(2p\).

For this string to be in L, it must be of the form \(c^{n'} b^{k'} a^{n'+k'}\). The number of \(a\)'s must equal the sum of the number of \(c\)'s and \(b\)'s.

So, we need \(2p = n' + k' = (p-b) + p = 2p - b\).

This equation \(2p = 2p - b\) implies \(b=0\). However, the Pumping Lemma requires \(|y| = b \ge 1\).

This is a contradiction. Therefore, Language B is not regular.

Analyzing Language C: \(L = \{0^n 1^k | n \ne k\}\)

Let's analyze Language C. Consider the complement of L with respect to the set of strings of the form \(0^*1^*\). The set of strings of the form \(0^*1^*\) is \(R = \{0^n 1^k | n \ge 0, k \ge 0\}\), which is a regular language (accepted by a simple automaton). The complement of L within R is \(L^c = \{0^n 1^k | n \ge 0, k \ge 0\} \setminus \{0^n 1^k | n \ne k\} = \{0^n 1^k | n = k, n \ge 0, k \ge 0\} = \{0^n 1^n | n \ge 0\}\).

Let's prove that the language \(L' = \{0^n 1^n | n \ge 0\}\) is not regular using the Pumping Lemma. Assume L' is regular and let p be the pumping length.

Choose \(s = 0^p 1^p \in L'\). \(|s| = 2p \ge p\).

According to the Pumping Lemma, \(s = xyz\) such that \(|y| > 0\), \(|xy| \le p\), and \(xy^i z \in L'\) for all \(i \ge 0\).

Since \(|xy| \le p\), \(xy\) must be within the initial \(0^p\) part of the string. Thus, \(x = 0^a\), \(y = 0^b\), \(z = 0^{p-a-b} 1^p\), where \(a \ge 0\), \(b \ge 1\) (since \(|y| > 0\)), and \(a+b \le p\).

Consider pumping up with \(i=2\): \(xy^2z = 0^a (0^b)^2 0^{p-a-b} 1^p = 0^{a+2b+p-a-b} 1^p = 0^{p+b} 1^p\).

In the string \(0^{p+b} 1^p\), the number of 0s is \(p+b\) and the number of 1s is \(p\). Since \(b \ge 1\), \(p+b > p\).

For \(xy^2z\) to be in \(L'=\{0^n 1^n | n \ge 0\}\), the number of 0s must equal the number of 1s. We need \(p+b = p\). This implies \(b=0\), which contradicts the condition \(|y| = b \ge 1\).

Thus, \(xy^2z \notin L'\).

This proves that \(L' = \{0^n 1^n | n \ge 0\}\) is not regular.

Now, recall that the class of regular languages is closed under complementation. If L were regular, then its complement \(L^c = \{0^n 1^n | n \ge 0\}\) (within \(0^*1^*\)) would also have to be regular. But we just showed that \(L^c\) is not regular.

Therefore, Language C is not regular.

Conclusion

Based on the analysis using the Pumping Lemma and properties of regular languages, we conclude that languages A, B, and C are all not regular.

Summary of Language Analysis
Language Form Method Used Regularity
A \((01)^n 0^k, n > k\) Pumping Lemma Not Regular
B \(c^n b^k a^{n+k}\) Pumping Lemma Not Regular
C \(0^n 1^k, n \ne k\) Pumping Lemma / Closure Properties Not Regular

Revision Table: Key Concepts in Formal Languages

Concept Description Example
Alphabet (\(\Sigma\)) A finite set of symbols. \(\{0, 1\}\), \(\{a, b, c\}\)
String A finite sequence of symbols from an alphabet. \(0101\), \(abc\), \(\epsilon\) (empty string)
Language A set of strings over an alphabet. \(\{0^n 1^n | n \ge 0\}\), \(\{\text{all binary strings}\}\)
Regular Language A language that can be recognized by a Finite Automaton (FA). \(\{0^n | n \ge 0\}\) (regex \(0^*\)), \(\{01\}^*\)
Pumping Lemma A necessary condition for a language to be regular. Used to prove non-regularity. Used above for A, B, C.
Finite Automaton (FA) A simple model of computation for recognizing regular languages. DFA (Deterministic FA), NFA (Non-deterministic FA)
Context-Free Language (CFL) A language generated by a Context-Free Grammar (CFG), or recognized by a Pushdown Automaton (PDA). Regular languages are a subset of CFLs. \(\{0^n 1^n | n \ge 0\}\), \(\{ww^R | w \in \{0,1\}^*\}\)

Additional Information on Non-Regular Languages

Languages that require counting or balancing symbols in a way that depends on unbounded memory are often not regular. Finite automata have a finite number of states, meaning they have limited memory. They cannot count arbitrary large numbers or remember relationships between widely separated parts of a string if the count or relationship isn't bounded by the number of states.

  • Language A (\((01)^n 0^k | n > k\)) requires comparing the number of (01) blocks (effectively \(n\)) with the number of trailing zeros (\(k\)). This comparison (\(n > k\)) requires remembering potentially large counts of both parts, which a finite automaton cannot do.
  • Language B (\(c^n b^k a^{n+k}\)) requires checking if the count of \(a\)'s equals the sum of the counts of \(c\)'s and \(b\)'s. Remembering \(n\) and \(k\) independently and then verifying their sum requires memory beyond what a FA possesses.
  • Language C (\(0^n 1^k | n \ne k\)) is the complement of the non-regular language \(\{0^n 1^n | n = k\}\) within the regular set \(0^*1^*\). The need to distinguish unequal counts (\(n \ne k\)) when \(n\) and \(k\) can be arbitrarily large also implies a need for unbounded counting/comparison memory.

These languages typically fall into higher classes of the Chomsky hierarchy, such as Context-Free Languages.

Was this answer helpful?

Important Questions from Regular Languages - Teaching

  1. Consider the production rules of grammer G:

    S → AbB

    A → aAb ∣ λ

    B → bB ∣ λ

    Which of the following language L is generated by grammer G?

  2. Consider the following regular expressions:

    (a) r = a(b + a)*

    (b) s = a(a + b) +

    (c) t = aa*b

    Choose the correct answer from the options given below based on the relation between the languages generated by the regular expressions above:

  3. Let L 1 and L 2 be languages over ∑ = {a, b} represented by the regular expressions (a* + b)* and (a + b)* respectively.

    Which of the following is true with respect to the two languages?

  4. Consider the following grammar:

    S → 0A|0BB

    A → 00A|λ

    B → 1B|11C

    C → B

    Which language does this grammar generate?

  5. Consider ∑ = {w, x} and T = {x, y, z}. Define homomorphism h by:

    h(x) = xzy

    h(w) = zxyy

    If L is the regular language denoted by r = (w + x*)(ww)*, then the regular language h(L) is given by
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App