$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^r = w, |w| = n \}$ where x is palindrome of length n, find regex for $n = 1$.

104 Views Asked by At

$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^r = w, |w| = n \}$

Informally $x$ is palindrome of length $n$,

where $\Sigma = \{0,1\}$.


I'm having a hard time understanding this.

For $n = 1$,

$L_1 = (0+1)^*(0+1)^*$ (Why? What does this mean?),

$L_1^c = \sigma$ (What would the compliment mean).

For $n = 2$,

$L_2 = (0+1)^*(00+11)(0+1)^*$,

$L_2^c = (10)^*(\epsilon + 1) + (01)^*(\epsilon + 0)$.

So my attempt on $n = 3$ (the above two were given),

$L_3 = (0+1)^* (000 + 111 + 101 + 010) (0+1)^*$,

$L_3^c = (100)^*(\epsilon + 1) + (011)^*(\epsilon + 0)$.

I get how regexes work I just don't understand how $L_1$ is the regex for palindrome of length one. Not sure what the compliment means. Same for $L_2$.

1

There are 1 best solutions below

0
On BEST ANSWER

$L_n$ is the set of strings in $\Sigma^*$ that have a palindrome of length $n$ as a substring. The complement of a language $L^C$ on an alphabet $\Sigma$ is the set of strings in $\Sigma^*$ that are not in $L$.

For $L_1$, every string of length $1$ is a palindrome, namely $1$ and $0$. Any nonempty string is in $L_1$, so $$ L_1=L((0+1)(0+1)^*) $$ since any nonempty string is either a $1$ or $0$ followed by some number of $1$'s and $0$'s. The complement of the language is just the empty string (which we denote $\epsilon$). $$ L_1^C=\{\epsilon\} $$ For $L_2$, the palindromes of length $2$ are $11$ and $00$, so the language is any string with either $11$ or $00$ preceded and followed by some number of $1$'s and $0$'s. $$ L_2=L((0+1)^*(00+11)(0+1)^*) $$ The complement of $L_2$ is the set of strings that don't contain $11$ or $00$, so these are just strings of alternating $1$'s and $0$'s. These could begin or end with $0$ or $1$, but the string must alternate characters. $$ L_2^C=L((01)^*(0+\epsilon) + (10)^*(1+\epsilon)) $$ For $L_3$, the palindromes of length $3$ are $000$, $010$, $101$, and $111$, so$$ L_3=L((0+1)^*(000+010+101+111)(0+1)^*) $$ The complement of $L_3$, the strings that do not contain $000$, $010$, $101$, or $111$, is more difficult. Consider such a string that begin with $00$. The next character must be $1$ since if it was $0$, the string would contain $000$. Now, the next character for string $001$ must be $1$ since if it was $0$, the string would contain $010$. We can continue this argument to get $00110011...$ for arbitrarily long strings. From this, we can see that if the string has at least $4$ characters, it can be represented as some number of repetitions of $0011$, $0110$, $1100$, or $1001$ followed by a prefix of that string. Otherwise, if it has less than $4$ characters, it is a substring of one of these. $$ L_3^C=((0011)^*(\epsilon+0+00+001)+(0110)^*(\epsilon+0+01+011) \\ +(1100)^*(\epsilon+1+11+110)+(1001)^*(\epsilon+1+10+100)) $$