1

Consider the problem of, given two CFGs $G_1$ and $G_2$, deciding whether they accept the same language, $L(G_1)=L(G_2)$. Call this problem $EQ_{CFG}$.

Also consider the problem of deciding whether a given CFG accepts some palindrome. Call this problem $SOMEPAL_{CFG}$.

I need to show that $EQ_{CFG}\le_P SOMEPAL_{CFG}$.


To do so, we imagine that there is some machine $M$ which decides $SOMEPAL_{CFG}$ and try to leverage this to decide $EQ_{CFG}$. To that end, we let $G_1,G_2$ be some two CFGs and try to decide whether they accept the same language.

We can construct the grammar $G_1G_2^R$ which concatenates $G_1$ with the "reverse grammar" of $G_2$. $G_1$ and $G_2$ share some word if this grammar is non-empty. But that's not quite what we want.

CFLs are not closed under complement, so we are not immediately guaranteed that there even exists a complement grammar for any of these.

And I haven't come with any other ideas for this, so I'd appreciate any help. Thanks!

Addem
  • 387
  • 1
  • 13

2 Answers2

1

You are thinking along the right lines. You can indeed use $G_2^R$ and a closure property.

reinierpost
  • 6,294
  • 1
  • 24
  • 40
1

Equality is a stated by a proposition starting with $\forall$, but membership of a string with some property is stated by a proposition starting with $\exists$. In fact, $\mathrm{EQ_{CFG}}$ is $\Pi_1$-complete and $\mathrm{SOMEPAL_{CFG}}$ is $\Sigma_1$-complete in the arithmetic hierarchy ($\Sigma_1 = \mathrm{RE}$ and $\Pi_1 = \mathrm{coRE}$).

Therefore, the reduction cannot be a many-one reduction, and must use a "negation" of the oracle call result somewhere in the reduction. That is why your current approach necessary fails.

Let me write a concrete many-one reduction from $\mathrm{NEQ_{CFG}}$ (the complement language of $\mathrm{EQ_{CFG}}$) to $\mathrm{SOMEPAL_{CFG}}$:

Let $\Sigma$ be the original alphabet then add new symbols $\#, \%$. Define $L_{\neq} := \{ x_1 \# x_2^R \mid x_1, x_2 \in \Sigma^{\ast}, x_1 \ne x_2 \}$ then you can show that $L_{\neq}$ is context-free (CS.SE question).

Given grammars $G_1$ and $G_2$, one can construct a context-free grammar for the language $L := \{ x_1^R \# x_2 \% x_3 \# x_4^R \mid x_1 \in L(G_1), x_2 \in L(G_2), x_3, x_4 \in \Sigma^{\ast}, x_3 \neq x_4 \}$ using $G_1$, $G_2$ and the grammar of $L_{\neq}$.

Now, you can show that there exists a palindrome in $L$ if and only if there exists strings $x_1 \in L(G_1)$, $x_2 \in L(G_2)$ and $x_1 \neq x_2$, concluding the proof.

pcpthm
  • 2,962
  • 6
  • 16