To gain practice with designing constructions, let’s prove the following
Theorem: the class of DFA-decidable languages is closed under union.
In other words, if \(L_1 = L(D_1)\) and \(L_2 = L(D_2)\), then we must prove the existence of a DFA \(D\) such that \(L_1 \cup L_2 = L(D)\).
Idea: simulate \(D_1\) and \(D_2\) in parallel, and accept if either \(D_1\) or \(D_2\) accepts.
\(L(D_1) = \setbuild{a^n}{n \equiv 2 \mod 3}\)
\(L(D_2) = \setbuild{a^n}{n \equiv 1 \mod 5 \; \text{ or } \; n \equiv 4 \mod 5}\)
What do we need to keep track of to execute this simulation?
Which pair of states are the machines in?
Formally:
Let \(D_1 = (Q_1, \Sigma, \delta_1, s_1, F_1)\) and \(D_2 = (Q_2, \Sigma, \delta_2, s_2, F_2)\) be two DFAs.
We construct a new DFA \(D = (Q, \Sigma, \delta, s, F)\) to decide \(L(D_1) \cup L(D_2)\)
by simulating \(D_1\) and \(D_2\) in parallel:
Then after reading a string \(w\) that puts \(D_1\) in state \(p_1\) and \(D_2\) in state \(p_2\),
the new DFA \(D\) will be in state \((p_1, p_2)\).
We already showed that the DFA-decidable languages are closed under union:
If \(L_1 = L(D_1)\) and \(L_2 = L(D_2)\), then we can construct \(D\) such that \(L(D) = L_1 \cup L_2\).
Formally:
What about intersection?
Theorem: the DFA-decidable languages are closed under intersection:
If \(L_1 = L(D_1)\) and \(L_2 = L(D_2)\), then we can construct \(D\) such that \(L(D) = L_1 \color{red} \cap \color{black} L_2\).
Formally:
Just update the accept states!
Theorem: the DFA-decidable languages are closed under intersection:
If \(L_1 = L(D_1)\) and \(L_2 = L(D_2)\), then we can construct \(D\) such that \(L(D) = L_1 \color{red} \cap \color{black} L_2\).
Under which of the following operations are DFA-decidable languages closed?
If \(L_1\) and \(L_2\) are DFA-decidable, then \(L_1 \cup L_2\) is DFA-decidable.
\[ L_1, L_2 \text{ DFA-decidable} \; \Longrightarrow \; L_1 \cup L_2 \text{ DFA-decidable} \]
But if \(L_1 \cup L_2\) is DFA-decidable, then \(L_1\) and \(L_2\) are not necessarily DFA-decidable.
\[ L_1, L_2 \text{ DFA-decidable} \cancel{\Longleftarrow} L_1 \cup L_2 \text{ DFA-decidable} \]
Let’s survey our progress on proving closure properties for DFA-decidable languages.
Let’s consider the concatenation of
\(L_1 = \setbuild{w \in \{0, 1\}^*}{ \#_1(w) \equiv 1 \mod 2}\), and \(L_2 = \setbuild{w \in \{0, 1\}^*}{ \#_1(w) \equiv 1 \mod 3}\)
If we immediately “jump” from odd
to \(q_0\) by redirecting the transition \(\texttt{even} \stackrel{1}{\to} \texttt{odd}\) into \(\texttt{even} \stackrel{1}{\to} \texttt{q0}\), then the string \(1111 = 111 \circ 1\) is rejected despite \(111 \in L_1\) and \(1 \in L_2\).
The same “where to split?” difficulty is encountered for Kleene star.
The more convenient and flexible NFA model makes it simpler to construct a machine deciding the concatenation and Kleene star of languages.
Once we demonstrate how to convert an NFA to a DFA, this will prove that DFA-decidable languages are closed under concatenation and Kleene star.
First: how can we simplify the union construction with NFAs?
\(L(D_1) = \setbuild{a^n}{n \equiv 2 \mod 3}\)
\(L(D_2) = \setbuild{a^n}{n \equiv 1 \mod 5 \; \text{ or } \; n \equiv 4 \mod 5}\)
Just create a new start state and add \(\emptystring\)-transitions to the start states of \(D_1\) and \(D_2\).
The more convenient and flexible NFA model makes it simpler to construct a machine deciding the concatenation and Kleene star of languages.
Once we demonstrate how to convert an NFA to a DFA, this will prove that DFA-decidable languages are closed under concatenation and Kleene star.
First: how can we simplify the union construction with NFAs?
Just create a new start state and add \(\emptystring\)-transitions to the start states of \(D_1\) and \(D_2\).
Let’s consider the concatenation of
\(L_1 = \setbuild{w \in \{0, 1\}^*}{ \#_1(w) \equiv 1 \mod 2}\), and
\(L_2 = \setbuild{w \in \{0, 1\}^*}{ \#_1(w) \equiv 1 \mod 3}\)
Let’s consider the concatenation of
\(L(N_1) = \setbuild{w \in \{0, 1\}^*}{ \texttt{int}(w, 2) \not \equiv 2 \mod 3 }\), and
\(L(N_2) = \setbuild{w \in \{0, 1\}^*}{ \texttt{int}(w, 2) \equiv 2 \mod 3}\)
Here \(\texttt{int}(w, 2)\) is the integer value of \(w\) in base 2.
Consider the star of: \(L(N_1) = \setbuild{w \in \{\string{a, b}\}^*}{ w \text{ has an odd number of } \string{b} \text{'s followed by an } \string{a}}\)
This changes the behavior of the original NFA \(N_1\)! … accepts \(\string{bb}\) even though \(\string{bb} \notin L(N_1)^*\)
Consider the star of: \(L(N_1) = \setbuild{w \in \{\string{a, b}\}^*}{ w \text{ has an odd number of } \string{b} \text{'s followed by an } \string{a}}\)