16

Let $\Sigma = \{ 0, 1 \}$. A language $L \subseteq \Sigma^* $ is said to have the "anti-palindrome" property if for every string $w$ that is a palindrome, $w\notin L$. In addition, for every string $u$ that is not a palindrome either $u\in L$ or $\mathrm{Reverse}(u) \in L$, but not both(!) (exclusive or).

I understand the anti-palindrome property, but I could not find any languages that have this property. The closest one I could find is $\Sigma^* \setminus L$, but it does not have the exclusive or part... that is, for example, both $01$ and $10$ are in $L$.

Could anyone give me an example of a language that has this propery? Or possibly even more than a single example, because I fail to see what kind of limitations this puts on a language. (Must it be non-regular? Context Free? Or not even in $R$? and etc.)

David Richerby
  • 82,470
  • 26
  • 145
  • 239
Mařík Savenko
  • 364
  • 1
  • 12

3 Answers3

13

One example will be $L = \{ x\ \ |\ \ binary(x) < binary(x^R), x\in [0,1]^*\}$.

And yet another example $L' = \{ x\ \ |\ \ binary(x) > binary(x^R), x\in [0,1]^*\}$.

The idea is, if $x \neq x^R$ you make a rule to choose only one of them. You need to choose the rule such that palindromes should be rejected ($f(x) < f(x^R)$, for palindromes you must have $f(x)= f(x^R)$).You can also change the alphabet, I took binary alphabet just to get a quick answer.

$L$ and $L'$ above are not regular. And every anti-palindromic language will be non-regular and can be as bad as a non-RE language. Examble of an undecidable language: $L=\{x\ \ |\ \ $such that $ binary(x)<binary(x^R)$ if both $x$ and $x^R$ $\not\in$ Halt or both $x$ and $x^R$ $\in$ Halt, otherwise if $x \in$ Halt$\}$

Klaus Draeger explained in the comment below that anti-palindromic language given at the beginning of the answer is context-free: $L=\{x0y1x^R\ |\ x,y\in\{0,1\}^*\}$

Sarvottamananda
  • 4,877
  • 1
  • 14
  • 19
11

About generating a few examples:

Building on the answer of @shreesh, we can prove that every anti-palindrome language must be of the form $$ L = \{ x \ |\ x < x^R \}\qquad (*) $$ for some strict total ordering $<$.

Indeed, given any anti-palindrome $L$, we can define an associated $<$ as follows. We start by taking any enumeration $x_0,x_1,\ldots$ of $\{0,1\}^*$, where each word occurs exactly once. Then, we alter the enumeration: for each pair of non-palindromes $x,x^R$, we swap their position so to make the one that belongs to $L$ to appear before the other. The new enumeration induces a total ordering $<$ satisfying $(*)$.

That every $L$ defined as $(*)$ is non-palindrome is trivial, so $(*)$ is a complete characterization of non-palindrome languages.

Addressing the original question, we now know that we can obtain several examples of anti-palindrome languages $L$ by crafting orderings $<$. We also know that by doing that we are not restricting ourselves to a subclass of languages, losing generality.


About the question "can these languages be regular?":

To prove that any anti-palindrome $L$ is non regular, assume by contradiction it is regular.

  1. Since regularity is preserved by reversal, $L^R$ is also regular.
  2. Since regularity is preserved by union, $L \cup L^R$, which is the set of all the non-palindromes, is also regular.
  3. Since regularity is preserved by complement, the set of all palindromes is regular.

From the last statement, we can derive a contradiction by pumping. (See e.g. here for a solution)

chi
  • 14,704
  • 1
  • 31
  • 40
10

For what it's worth, here is a simple context-free grammar for one anti-palindromic language:

$$\begin{align} S &\to 0 S 0 \mid 1 S 1 \mid 0 X 1 \\ X &\to \epsilon \mid X 0 \mid X 1 \end{align}$$

(In fact, this is the anti-palindromic language proposed by @shreesh, using lexicographic comparison for the less-than operator.)

Anton Trunov
  • 3,499
  • 1
  • 19
  • 26
rici
  • 12,150
  • 22
  • 40