# Does a language dictate the order of the word?

Lets take the Language $$L = \{ (ab)^na^k | n \ge k \}$$

Does it dictate, that the $$(ab)^n$$ comes before the $$a^k$$ ? Or is the order irrelevant as long as it matches the $$n \ge k$$ criterium?

In simple terms: is the word $$aaaababab \in L$$ ?

And if so, does this apply for every language?

• Yes, order matters. The fundamental operation is "string concatenation", for which order is important. One question: if you were happy about transposing $(ab)^n$ and $a^k$, why wouldn't you also be happy about transposing the $a$ and $b$ inside $(ab)^n$ to get a string like $aaabbabb$?
– Stef
Feb 13 at 10:21
• Makes sense, thank you. I've a problem trying to show that I'm able to pump up $a^k$ (pumping-lemma)... but that's one for another question. Feb 13 at 10:38

Yes, order matters. The fundamental operation used in the definition of language $$L$$ is "string concatenation", for which order is important.

One question: if you were happy about transposing $$(ab)^n$$ and $$a^k$$, why wouldn't you also be happy about transposing the $$a$$ and $$b$$ inside $$(ab)^n$$ to get a string like $$aaabbabb$$?

Of course it's possible to construct languages which are stable under "anagraming", but you'll need to make that explicit in the notation, for instance:

$$L_2 = \left\{ w \in \{a,b\}^* \, \middle| \, \#_a(w) \geq \#_b(w) \right\}$$

now $$L_2$$ is the language of all words that contain more $$a$$ than $$b$$, regardless of order.

• Thank you. This really helped me a lot! Feb 13 at 11:28
• @BaderAbuRadi I agree. But the language $L$ in the question is defined by the concatenation notation used in $(ab)^na^k$, and that is why two words $w_1$ and $w_2$ can be anagrams of eachother even though $w_1 \in L$ and $w_2 \notin L$. The language $L_2$ in my answer also consists of words which are ordered sequences of letters by definition, yet $L_2$ is agnostic of the order of letters in its words, because it doesn't use concatenation in its definition.
– Stef
Feb 13 at 12:40
• Words are ordered by definition, even before introducing concatenation. First we define words, then we define concatenation. Feb 13 at 12:41
• @Stef You can look at any word as a concatenation of letters, this does not make it the reason for "order matters". Order matters because words are ordered sequences of letters. Feb 13 at 12:43
• Your answer is fine. I just did not like the way it is written. It confuses words with concatenation of letters. At the end of the day, it does not matter as everything is consistent, but to be precise, note that $ab$ is a word and $a\cdot b$ is a concatenation of two words. Before even defining concatenation, the word $ab$ does not equal the word $ba$ as words are ordered -- that's the origin of it. Anyway, people do not make the distinction between $ab$ and $a\cdot b$, its just a side note. Feb 13 at 13:33