Mathematics,
I'm studying for a final that I have, and I need help with a problem.
Give a context-free grammar to generate the following language $L = \{ a^ib^jc^k \space|\space 0 \leq i \leq j \leq i + k \}$
What does $0 \leq i \leq j \leq i + k$ mean I should do in terms of creating the grammar? Does it mean the number of a's must be less than (or equal to) the number of b's, and the number of b's must be less than or equal to the number of a's and c's combined?
If so, here is my attempt.
$G = ({S, A, B, T, E},{a, b, c},{S, R})$
$S \rightarrow AB \\ A \rightarrow B \\ A \rightarrow aB \\ A \rightarrow a \\ B \rightarrow bB \\ B \rightarrow AB \\ B \rightarrow bbT \\ T \rightarrow cT \\ T \rightarrow cE \\ E \rightarrow \epsilon $
Is this correct? If so, can it be reduced to fewer rules?
Edit: I think I overthought it. Here's another try:
$G = ((S, T), (a, b, \epsilon), S, R)$
where $R$ contains the rules:
$S \rightarrow cSb \\ S \rightarrow T \\ T \rightarrow cTa \\ T \rightarrow \epsilon \\$
I believe this is correct, but it wouldn't hurt for a member to look at my answer.
Third attempt: $S \rightarrow AB \\ A \rightarrow aAb \\ B \rightarrow Bc \\ B \rightarrow bBc \\ A \rightarrow \epsilon \\ B \rightarrow \epsilon$
\{and\}. – Brian M. Scott Dec 8 '12 at 7:18