0
$\begingroup$

{a^n b^m c^k | n > m + k}

My problem of understanding is how to create a new a before the b's if you create new c's.

Hopefully someone can help me out.

$\endgroup$
1

1 Answer 1

0
$\begingroup$

You can firstly spawn $k$ letter $c$'s providing an $a$ for every $c$ spawned, then start putting $m$ $b$'s between $a$ and $c$ adding $a$ for every $b$. Also letter $a$ can be created any number of times after all $b$ and $c$ letters are created. This approach can be done with the following CFG: $$G = (V, \Sigma, S, R), \: V = \{S, A, B, B', C, C'\} \cup \Sigma,$$ and the rules are $$R = \begin{cases} S \to AC, \\ S \to AB, \\ C \to ACC', \\ C \to AC', \\ C \to ABC', \\ B \to ABB', \\ B \to AB', \\ C' \to c, \\ C' \to e, \\ B' \to b, \\ B' \to e, \\ A \to Aa, \\ A \to a. \end{cases}$$ This grammar is definetely not the most beautiful and short, I have put some safety checks there. However, it demonstrates the idea of my solution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.