172k views
0 votes
Context free languages are those which we can develop a pushdown automaton (PDA) or a context-free grammar (CFG) for.

Pick a context-free language L that is not regular.
1) Give an English language description of the language. For example, L = {w in {0,1}* | w = 0n1n for some n >= 0}
2) Prove that L is not regular. Use the pumping lemma for the regular languages.
3) Show a PDA for L.
4) Show a CFG for L. Use Stanford's syntax.

1 Answer

2 votes

Final answer:

A context-free language L consisting of strings with equal numbers of 0s followed by 1s is not regular as proven using the pumping lemma, and its representation can be shown by constructing a PDA and a CFG using Stanford's syntax. Therefore, the correct answer is 1) Give an English language description of the language. For example, L = {w in {0,1}* | w = 0n1n for some n >= 0}.

Step-by-step explanation:

The context-free language L we will consider is {w ∈ {0,1}* | w = 0n1n for some n ≥ 0}. This language consists of strings made of n zeroes followed by n ones, such as 0011 or 000111.

To prove that L is not regular using the pumping lemma for regular languages, assume that L is regular. By the pumping lemma, there exists a pumping length p, such that any string s in L with a length of at least p can be divided into three parts, x, y, and z, where |xy| ≤ p, |y| > 0, and for any i ≥ 0, the string xyiz is also in L.
Let s = 0p1p. According to the lemma, y consists only of 0’s. If we pump y (i.e., take i = 2), we get more 0s than 1s, which is not a string in L. Thus, L cannot be regular.

Next, to show a PDA for L, one can construct a PDA that pushes 0s onto the stack and then pops them for each 1 read. If the stack is empty after reading all 1s, the string is accepted.

Finally, to show a CFG for L using Stanford's syntax, we can define the grammar G as follows:

  • S → 0S1 | ε


This grammar generates a string of n 0s followed by n 1s, which satisfies the language L.

User Forage
by
8.8k points