2

I am pretty desperate finding the correct context free grammar for the following language: $$L=\{a^lb^mc^n \mid l,m,n \in \mathbb{N}_0, \, l\geq 2n+m\}$$

I would really appreciate if anyone could tell me how to generate the CFG from this language as I am stuck on this one for 2 days now.

I can't find a solution for adding the right amount of $b$'s and $c$'s to a generated string.

At the moment I have: $$ \begin{align*} S &\rightarrow aS \mid T \mid U \mid \varepsilon \\ T &\rightarrow aTb \mid \varepsilon \\ U &\rightarrow aaUc \mid \varepsilon \end{align*}$$

dkaeae
  • 4,997
  • 1
  • 15
  • 31
JK96
  • 23
  • 3

1 Answers1

3

It might be easier than you have been thinking.

$$\begin{aligned} S&\rightarrow aS\mid U\\ U&\rightarrow aaUc\mid T\\ T&\rightarrow aTb\mid \epsilon \end{aligned}$$

The idea is to identify the language that could be obtained by a fixed operation that peels off some symbols. Peeling off $a$'s, we shrink words in $S$ to words in $U$. Peeling off some $a$'s and $c$'s, we shrink words in $U$ to words in $T$. $$\begin{aligned} S&=\{a^ka^{2n}a^mb^mc^n \mid k,m,n \in \mathbb{N}_0\}\\ U&=\{a^{2n}a^mb^mc^n \mid m,n \in \mathbb{N}_0\}\\ T&=\{a^mb^m\mid m \in \mathbb{N}_0\} \end{aligned}$$

John L.
  • 38,985
  • 4
  • 33
  • 90