# Context free grammar for L={ ((ab)^n)^m }

I want to write a cfg for the following language:

$$L = {((ab)^n)^m }$$ $$m,n >= 0$$

this language produces (abababababab) where:
$$n=2, m=3 \\ or \\ n=3, m=2$$

I have no idea what to do with it!

No need for a CFG: this language is regular!

$$L = (ab)^*$$

Any number of $$ab$$s is in the language: just set $$n$$ to 1, and $$m$$ to the number of repetitions. So all you need is a Kleene star.

If you really want a CFG, you can do it like this:

$$S \rightarrow SX \mid \varepsilon$$ $$X \rightarrow ab$$

This is the "standard" way of translating a Kleene star into a CFG.

• Knowing this makes the grammar easier but the question about how to write a CFG for this regular (and, therefore, context-free) language remains. – David Richerby Mar 21 at 14:55
• @DavidRicherby Added a translation – Draconis Mar 21 at 14:59