Equivalence of FAs and REs
San Skulrattanakulchai
February 28, 2019
FAs vs REs
- Throughout this slide, we will fix an alphabet \(\Sigma\). Every mention of a finite automaton assumes its alphabet is \(\Sigma\). Similarly, every mention of a regular expression assumes its alphabet is \(\Sigma\).
- We will prove that as a language-defining mechanism, regular expressions is as powerful as the finite automata.
- First we will show that every regular expression \(R\) has an NFA \(N\) such that \(L(R) = L(N)\).
- Next we will show that every DFA \(M\) has a regular expression \(R\) such that \(L(M) = L(R)\).
Part 1: REs are no more powerful than FAs
- We prove this fact by structural induction.
- Base Cases:
- For the regular expression ∅, we use the NFA \((\{q\}, \Sigma, \delta, q, \emptyset)\) where \(\delta\) is the empty function.
- For the regular expression \(\epsilon\), we use the NFA \((\{q\}, \Sigma, \delta, q, \{q\})\) where \(\delta\) is again the empty function.
- For any regular expression \(a\), where \(a\in\Sigma\), we use the NFA \((\{q_1, q_2\}, \Sigma, \delta, q_1, \{q_2\})\) such that \(\delta(q_1, a) = \{q2\}\), and for any other combination of state \(q\) and symbol \(a\), \(\delta(q,a) = \emptyset\).
- Recursive Cases:
- For \(R_1 R_2\), “connect the the NFA for \(R_1\) and the one for \(R_2\) serially”
- For \(R_1 \cup R_2\), “connect the the NFA for \(R_1\) and the one for \(R_2\) in parallel”
- For \(R^*\), from each final state add an \(\epsilon\)-edge to the old start state, and introduce a final new start state with an \(\epsilon\)-edge to the old start state.
- [Proof to be done in class.]
Part 2: FAs are no more powerful than REs
- Given a DFA, we will show how to convert it to an RE.
- A useful lemma for solving a recurrence relation on languages under the regular operations.
- Lemma: Let \(\Sigma\) be an alphabet and let \(B\), \(C\), \(L\) be languages over \(\Sigma\) such that \(\epsilon\notin B\) and \[
L = BL \cup C.
\] Then \[
L = B^*C.
\]
Converting a DFA to an equivalent RE
- Let DFA \(M = (Q,\Sigma,\delta,q_0,F)\) be given.
- For each \(q\in Q\), define \(L_q = L(M_q)\) where \(M_q = (Q,\Sigma,\delta,q,F)\), i.e., \(M_q\) is just \(M\) with \(q\) as start state.
- From this definition, we conclude that, for each \(q\notin F\), \[
L_q = \bigcup_{a\in\Sigma} a L_{\delta(q,a)}
\] and for each \(q\in F\), \[
L_q = \epsilon \cup \bigcup_{a\in\Sigma} a L_{\delta(q,a)}.
\]
- From this system of equations, we can solve for \(L_{q_0}\) by repeatedly applying the Lemma on the previous slide and back substitution.
- [Demonstrate by examples in class.]