2

Are there languages such that A ⊂ B ⊂ C ⊂ D ⊂ E over the alphabet {a,b,c} where:

A is not context-free

B is context-free and non-regular

C is regular

D is non regular

E is regular and not {a,b,c}*

starball
  • 20,030
  • 7
  • 43
  • 238
Lilith X
  • 99
  • 1
  • 9

2 Answers2

2

Start by taking non-context-free language A over {a,b}. For example A = { ww | w \in {a,b}*}, but any other would also work.

You can then build the other languages on top of that:

  • B = {a,b}* U {a^i c^i | i >= 0}
  • C = {a,b}* U {a,c}*
  • D = {a,b}* U {a,c}* U {b^i c^i | i>= 0}
  • E = {a,b}* U {a,c}* U {b,c}*

You can then verify for each of these that they have the desired properties.

1

First, let us simplify this and take care of E by just not using c in any language and making E the language (a + b)*. Next, let us deal with D by making it the same as E, but with all strings of prime length greater than two removed. We can choose C to be the set of all even-length strings over {a, b}: (aa + ab + ba + bb)*. For a context-free and non-regular language we can choose the set of even-length palindromes over {a, b}: S -> aSa | bSb | e. Finally, we can choose as A the set of even-length palindromes over {a, b} which begin with a prime number of as.

We might have tried getting rid of D by making it the union of C and some language involving only b, then making C equal to a* and then trying to find A and B using only a... but we might have had trouble finding a context-free non-regular language involving only one symbol.

Patrick87
  • 27,682
  • 3
  • 38
  • 73
  • how do we prove that D is not regular? and B context free and non-regular? – Lilith X Feb 12 '20 at 18:47
  • @LilithX To show the language of all strings except those with prime length greater than two is not regular, we can argue that it is the difference of the regular language E and the language of all strings of prime length greater than two. By closure properties, this implies the language of all strings of prime length greater than two is regular. This can be shown to be false using the pumping lemma for regular languages. For B: this too can be proved to be irregular using the pumping lemma for regular languages. – Patrick87 Feb 12 '20 at 19:13
  • Thank you very much! last question, how can we prove A is context free? – Lilith X Feb 12 '20 at 19:36
  • @LilithX The question requests that A not be context-free. As I have defined A, it is in fact not context free; you might be able to show this using the pumping lemma for context-free languages. If not and having a handy proof is required, you could use something simpler, maybe a subset of even-length palindromes that are also of the form ww, or a^nb^naab^na^n, something like that. – Patrick87 Feb 12 '20 at 19:47