Nested two-pair count language (source code)

= Nested two-pair count language

The language
$$
\{a^{4r}b^{5s}c^{2s}d^{3r}:r,s\geq0\}
$$
is context-free. The grammar
$$
S\to aaaaSddd\mid T,
\qquad
T\to bbbbbTcc\mid\epsilon
$$
nests the $a,d$ dependency around the $b,c$ dependency.