I'm trying to understand how the construction of simple grammars works.
In my textbook, there's the following example I am supposed to find a grammar for:
Let $L_1= \{a^n b^n c^m d^m \mid n \geq 1, m \geq 0\}$ be a language over the alphabet $\Sigma = \{a,b,c,d\}$. Find a grammar $G = (\Sigma, N, S, P)$ - where $N$ denotes the non-terminals, $S$ the start symbol and $P$ the production rules - such that $L(G) = L_1$, i.e. the grammar $G$ generates the language $L_1$.
These were my first thoughts analyzing the problem:
- We need to have the same number of $a$'s and $b$'s
- We need to have the same number of $c$'s and $d$'s
- There needs to be at least one $a$ and one $b$
- Examples of such a string: $aabbcccddd$, $ab$, $aabbcd$
Furthermore, let $\lambda$ be the empty symbol.
The start symbol $S$ should map to something like: $$ S \rightarrow XY$$
Then $$X \rightarrow aZb, \; Z \rightarrow X | \lambda$$ $$Y \rightarrow cYd | \lambda$$
Would something like that work? I'm confused because the textbook presented similar grammars and the production rules almost never used the empty symbol ($\lambda$).
Is it possible to construct this grammar without using $\lambda$?