1

How can we show that the class of regular languages is closed under the following operation?

Let $L_1$ and $L_2$ be laguages over $\Sigma=\{0, 1\}$.

The operation is: $$\{x \in L_1 \mid \text{ for some } y \in L_2, \text{ strings } x \text{ and } y \text{ contains equal numbers of } 1s \}$$

Is the only way to show this to create a NFA of the new language?

I have done the following:

Let $M_{L_1}=(Q_{L_1},\Sigma ,\delta_{L_1},q_{L_1},F_{L_1})$ the DFA that recognizes $L_1$ and $M_{L_2}=(Q_{L_2},\Sigma ,\delta_{L_2},q_{L_2},F_{L_2})$ the DFA that recognizes $L_2$.

Let $M=(Q,\Sigma ,\delta,q,F)$ the NFA that recognizes the operation.

$Q=Q_{L_1}\times Q_{L_2}, \ \ q=(q_{L_1},q_{L_2})$.

Is this correct? Which is the transition function?

Raphael
  • 73,212
  • 30
  • 182
  • 400
Mary Star
  • 451
  • 4
  • 13

2 Answers2

4

Let $$ L = \{ x \in L_1 \mid \text{there exists }y \in L_2 \text{ such that } |x|_1 = |y|_1\} $$ Let $\pi: \Sigma^* \to a^*$ be the homomorphism defined by $\pi(u) = a^{|u|_1}$. I claim that $$ L = L_1 \cap \pi^{-1}(\pi(L_2)) $$ Since regular languages are closed under homomorphisms, inverses of homomorphisms and intersection, it will follow that $L$ is regular.

Proof of the claim. \begin{align} L_1 \cap \pi^{-1}(\pi(L_2)) &= \{ x \in L_1 \mid \pi(x) \in \pi(L_2) \} \\ &= \{ x \in L_1 \mid \text{there exists }y \in L_2 \text{ such that } \pi(x) = \pi(y)\}\\ &= \{ x \in L_1 \mid \text{there exists }y \in L_2 \text{ such that } |x|_1 = |y|_1\} \\ &= L \end{align}

J.-E. Pin
  • 6,219
  • 21
  • 39
3

Well, you are almost correct so far. But the trick is in the transitions. Cross-product construction, as you suggest, means that you intend to mimic both NFAs. But in this case you do not mimic them exactly in the same way. The part corresponding to the automaton $M_1$ for $L_1$ is mimicked for acceptance of the input string, while the part corresponding to the automaton $M_2$ for $L_2$ ignores the input and mimicks non-deterministically acceptance of some arbitrarily chosen input (ignoring the real input).

Furthermore, the states are not just $(q_{L_1},q_{L_2})$, but there is a third component, which is true or false, so that states are of the form $(q_{L_1},q_{L_2}, eq)$, where $eq$ can be $true$ or $false$.

This third component is true when you have mimicked scanning the same number of $1$'s for $M_1$ and for $M_2$.

But remember that the first is scanning the input string, while the second is scanning a non-existent randomly chosen string.

The last point is that you mimick both NFA asynchronously. Either you mimick the first or you mimick the second. Never both at the same time.

So you start mimicking the first on the true input until you scan a 1. Then you start mimicking the second on its non-deterministically chosen input until you scan a 1. Then you resume with the first until you scan a 1. Then you resume the second until ... etc. And you are careful that the $eq$ component of the state triple is $true$ only when both computations have seen the same number of $1$'s. You stop also when computations reach the end of their input (except for empty transitions), whether real input or made-up input.

Accepting states are triple of the form $(q_{a1},q_{a2}, true)$ where $q_{a1}$ and $q_{a2}$ are accepting states of the two initial automata.

Good luck

babou
  • 19,645
  • 43
  • 77