# Constructive proof to show the quotient of two regular languages is regular

I have a question regarding the quotient of two regular languages, $$R$$ and $$L$$.

I saw the answers to this question: are regular languages closed under division and the proof sketch is not constructive, because $$L$$ can be any language. I'm thinking about a constructive proof when $$L$$ is regular: how can we construct that $$F2$$ group in the case when $$L$$ is regular?

We can't go over every word $$x$$ in $$L$$ and check if $$\delta(q,x)\in F1$$ in the case when $$L$$ is infinite...

In the question you link to, the automaton for the operation "division" (usually known as "quotient") $$L_1/L_2$$ is obtained from a FSA $$M_1 = (Q,\Sigma,\delta,q_0,F_1)$$ for $$L_1$$ by changing the final states. The new states are given as $$F_2=\{q\in Q \mid \delta(q,x)\in F_1 \text{ for some } x\in L_2\}$$.

The quotient is regular for regular $$L_1$$ even when $$L_2$$ is arbitrarily complex.

We can't go over every word $$x$$ in $$L_2$$ and check if $$\delta(q,x)\in F_1$$ in the case when $$L$$ is infinite...

You are right that in general the construction is not effective. We just know how the final states are chosen, but we cannot definitely say which states are final. But in case $$L_2$$ is regular, we can determine which states are final, as regular languages are closed under intersection.

For any state $$q$$ change $$M_1$$ simply by setting $$q$$ as its new initial state (instead of $$q_0$$): $$M_q = (Q,\Sigma,\delta,q,F_1)$$. Now $$q$$ is final (in $$F_2$$) iff the intersection $$L(M_q) \cap L_2$$ is nonempty. Because any $$x$$ is the intersection is precisely an $$x\in L_2$$ for which $$\delta(q,x)\in F_1$$ as required.

The quotient of two languages $$R$$ and $$L$$ is $$R/L = \left\{x\in \Sigma^{*} : \exists y \in L. xy \in R\right\}$$

Here is a constructive solution using a non-deterministic finite automaton (NFA) to show $$R/L$$ is regular when both $$R$$ and $$L$$ are regular.

Let $$(Q_1,\Sigma,\delta_1,s_1,F_1)$$ and $$(Q_2,\Sigma,\delta_2,s_2,F_2)$$ be deterministic finite automata for $$R$$ and $$L$$ respectively. Define a NFA

$$D=(Q_1 \times \{s_2\} \times \{1\} \cup Q_1 \times Q_2\times \{2\}, \Sigma, \delta, (s_1,s_2, 1), F_1 \times F_2\times \{2\})$$ where the transitions are:

• $$\delta((q_1,s_2,1),\sigma) = \{ (\delta_1(q_1,\sigma),s_2, 1)\}$$.
• $$\delta((q_1,s_2,1),\epsilon) = \{ (q_1,s_2, 2)\}$$.
• $$\delta((q_1,q_2,2),\sigma) = \{ (\delta_1(q_1,\sigma),\delta_2(q_2,\sigma), 2)\}$$.

I'll leave it as an exercise for you to verify the language accepted by $$D$$ is $$R/L$$.