HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Regular languages that seem irregular

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
seemlanguagesregularirregularthat

Problem

I'm trying to find examples of languages that don't seem regular, but are. A reference to where such examples may be found is also appreciated.

So far I've found two. One is $L_1=\{a^ku\,\,|\,\,u\in \{a,b\}^∗$ and $u$ contains at least $k$ $a$'s, for $k\geq 1\}$, from this post, and the other is $L_2 = \{uww^rv\,\,|\,\, u,w,v\in\{a,b\}^+\}$, which is an exercise (exercise 19 from section 4.3) in An Introduction to Formal Languages and Automata by Peter Linz.

I suppose the aspect of seeming to be regular depends on your familiarity with the topic, but, for me, I would have said that those languages were not regular at a first glance. The trick seems to be to write a simple language in more complicated terms, like using $ww^R$, which reminds us of the irregular language of even length palindromes.

I'm not looking for extremely complicated ways of expressing a regular language, just some examples where the definition of the language seems to rely on concepts that usually make a language irregular, but are then "absorbed" by the other terms in the definition.

Solution

My favorite example of this, which is often used as a difficult/tricky exercise, is the language:
$$L=\{w\in \{0,1\}^*:w \text{ has an equal number of } 01\text{ and }10\}$$
This has the strong flavor of the non-regular "same number of $0$ and $1$", but the alternation of $0$ and $1$ makes it regular nonetheless.

Context

StackExchange Computer Science Q#153698, answer score: 24

Revisions (0)

No revisions yet.