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 :
A, B and C
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:
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.
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:
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.
Since we found a string s in L that cannot be pumped according to the lemma, Language A is not regular.
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.
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.
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.
| 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 |
| 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\}^*\}\) |
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.
These languages typically fall into higher classes of the Chomsky hierarchy, such as Context-Free Languages.
Consider the production rules of grammer G:
S → AbB
A → aAb ∣ λ
B → bB ∣ λ
Which of the following language L is generated by grammer G?
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:
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?
Consider the following grammar:
S → 0A|0BB
A → 00A|λ
B → 1B|11C
C → B
Which language does this grammar generate?
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