Defining L(G) in set notation Let G be the grammar:

S --> ASB | λ

A --> aAb | λ

B --> bBa | ba

Use set notation to define L(G).

So I came across two different answers to this question, none of which are mine, and then compared them to mine. I'm wondering if they are all equivalent.

Answer 1: $L(G) = \{a^{n_1}b^{n_1}...a^{n_k}b^{n_k}b^{m_1}a^{m_1}...b^{m_l}a^{m_l} | n_i, m_j &gt; 0, l \ge 0, k \ge 0, k \le l\}$

Answer 2: $L(G) = \{(a^{n}b^{n})^i(b^{m}a^{m})^i |  n \ge 0, m &gt; 0, i \ge 0\}$

My answer: $L(G) = \{(a^{n}b^{n})^k(b^{m}a^{m})^l |  n, k, l \ge 0, m &gt; 0\}$

My answer seems similar to the second one. Are all three of these correct for this grammar?
They are not all equivalent.

Strings in the expression $(a^nb^n)^k$ have several (i.e., $k$) copies of the same string $a^nb^n$, whereas in $a^{n_1}b^{n_1}\dots a^{n_k}b^{n_k}$ the number of letters in each $a^{n_i}b^{n_i}$ may differ.

As $aaabbbaaabbbaaabbb$ versus $aabbaaaabbbbab$.

A shorter way of denoting words with different numbers would be
$\{ a^nb^n \mid n\ge0\}^*$.

Now check out your three languages and the given grammar.