CSCI 341 Theory of Computation

Fall 2025, with Schmid
\(\looparrowleft\) determinizationregular expressions \(\leadsto\)

The Structure of \(\mathsf{Fin}\)

So far, we have seen that if a language is totally deterministically finitely recognizable, deterministically finitely recognizable, or finitely recognizable, then it is all three. That is, \[ \mathsf{TDFin} = \mathsf{DFin} = \mathsf{Fin} \] This has a ton of very interesting consequences for the structure of \(\mathsf{Fin}\). In particular, \(\mathsf{Fin}\) is closed under a number of common set-operations.

Complements

Remember that for any two sets \(X\) and \(Y\), \[ Y \setminus X = \{y \in Y \mid \text{\(y\) is not in \(X\)}\} \] So, in particular, for a language \(L \subseteq A\), \(A^* \setminus L\) is the language consisting of all words that are not in \(L\). This language, \(A^*\setminus L\), is the complement of the language \(L\).

(Flip the Switch 1) Draw a state diagram of the two-state automaton \(\mathcal A = (\{x_0, x_1\}, \{a, b\}, \{(x_0, a, x_1), (x_1, a, x_0)\}, \{x_1\})\).
  1. Is \(\mathcal A\) deterministic or total?
  2. What language is accepted by the state \(x_0\)?
  3. Now flip the states, set \(F = \{x_0\}\) instead. Now what language is accepted by the state \(x_0\)?
(Flip the Switch 2) Draw a total deterministic automaton with a state that accepts the following language over the alphabet \(A = \{1\}\). \[ L = \{w \in A^* \mid \text{\(|w|\) is a multiple of \(3\)}\} \] Change \(F\) in this automaton so that the same state accepts \[ A^* \setminus L = \{w \in A^* \mid \text{\(|w|\) is not a multiple of \(3\)}\} \]
(Flip the Switch 3?) Now consider the following automaton \[ \mathcal A = (\{x_0, x_1, x_2\}, \{a\}, \{ (x_0, a, x_1), (x_0, a, x_2) \}, \{x_0\}) \]
  1. Draw a state diagram for \(\mathcal A\).
  2. Is \(\mathcal A\) total or deterministic?
  3. What language \(L\) does \(x_0\) accept?
  4. Play the same trick as in Flip the Switch 1 and 2 to make \(x_0\) accept \(A^* \setminus L\). Did it work? What language does \(x_0\) accept now?
  5. What makes the trick work?
(Closed under Complement) The family of finitely recognizable languages is closed under complements. That is, if \(L \in \mathsf{Fin}\), then \(A^* \setminus L \in \mathsf{Fin}\).
Let \(L \in \mathsf{Fin}\). By the Finite Recognizability Theorem, there is a total deterministic automaton \(\mathcal A = (Q, A, \delta, F)\) and a state \(x \in Q\) such that \(\mathcal L(\mathcal A, x) = L\).
Claim: Let \(\mathcal A' = (Q, A, \delta, Q\setminus F)\). Then \(\mathcal L(\mathcal A', x) = A^* \setminus L\).
You are going to prove this Claim in the problem below. Because \(\mathcal A\) is a total deterministic automaton, \(\mathcal A'\) is a total deterministic automaton. By the Claim above, \(\mathcal A'\) is a total deterministic automaton with a state \(x\) that accepts \(A^*\setminus L\). Therefore, \(L \in \mathsf{Fin}\).
(Finish Closed under Complement) Prove the Claim in the Proof of the Closed under Complement theorem.
Remember that if you want to show that two sets are equal, you need to show that they are contained in each other. So, for the \(\mathcal L(\mathcal A', x) \subseteq A^* \setminus L\) direction, let \(w \in \mathcal L(\mathcal A', x)\) (this means that \(x\) accepts \(w\) in \(\mathcal A'\)) and show that \(w \in A^*\setminus L\), i.e., \(w \notin L\) (this is the same thing as saying that \(x\) rejects \(w\) in \(\mathcal A\)). Similarly for the \(\mathcal L(\mathcal A', x) \supseteq A^* \setminus L\) direction.

Unions and Intersections

It's also true that \(\mathsf{Fin}\) is closed under unions and intersections. We are going to show the first statement together, and you are going to show the second. It helps to see a few examples of this in action.

You should take pictures of the automata you build in Union of Constants to reflect on later.

(Union of Constants) For each language in the alphabet \(A = \{a,b\}\) below, start by writing down a few words of the language. Then design a total deterministic finite automaton with a state that accepts the language.
  1. \(L_1 = \{a^n \in A^* \mid n \in \mathbb N\}\)
  2. \(L_2 = \{b^n \in A^* \mid n \in \mathbb N\}\)
  3. \(L_3 = L_1 \cup L_2\)
  4. \(L_4 = \{(ab)^n \in A^* \mid n \in \mathbb N\}\)
  5. \(L_5 = L_1 \cup L_4\)
You need \(4\) states for \(L_3\) and \(6\) for \(L_6\).

There is something funky going on in these examples; you might have missed it. If you did the Union of Constants exercise right, then you might know what I am referring to when I say that \(2 \times 2 = 4\) and \(2 \times 3 = 6\). This is not a coincidence!

The Product Constructions

When you are confronted with two finitely recognizable languages \(L_1\) and \(L_2\) and you want to combine them in some way to make a new finitely recognizable language, your best bet is to combine some automata and states that accept \(L_1\) and \(L_2\) individually. This is a different flavour of automaton construction than determinization, since the input is two automata instead of one.

One way to combine finitely recognizable languages is by taking their union. To show that the union is finitely recognizable, we can use an automaton construction that combines two automata called the union-product construction.

(Union-product Construction) Fix an alphabet of input letters \(A\), and let \(\mathcal A_1 = (Q_1, A, \delta_1, F_1)\) and \(\mathcal A_2 = (Q_2, A, \delta_2, F_2)\) be total deterministic automata. Then the union-product of \(\mathcal A_1\) and \(\mathcal A_2\) is the automaton \(\mathcal A_1\oplus \mathcal A_2 = (Q_1 \times Q_2, A, \delta^\times, F^\oplus)\), where
  • \(Q_1 \times Q_2\) is the Cartesian product of \(Q_1\) and \(Q_2\), which is the set of pairs \((x, y)\) where \(x \in Q_1\) and \(y \in Q_2\).
  • \(\delta^\times\) is the transition relation defined by the following: \[ (x_1, y_1) \xrightarrow{a}_{\delta^\times} (x_1, y_2) \text{ if and only if } x_1 \xrightarrow{a}_{\delta_1} x_2 \text{ and } y_1 \xrightarrow{a}_{\delta_2} y_2 \] In other words, in \(\mathcal A_1 \oplus \mathcal A_2\), states travel together.
  • \(F^\oplus = \{(x, y) \in Q_1 \times Q_2 \mid x \in F_1 \text{ or }y \in F_2\}\), i.e., a pair \((x, y)\) accepts if one of \(x\) or \(y\) accepts.
(Our First Union-Product) Consider the two automata below.
Two automata, both four states. Above, \(\mathcal A_1 = (Q_1, A, \delta_1, F_1)\) and \(\mathcal A_2 = (Q_2, A, \delta_2, F_2)\).
There are \(2 \times 2 = 4\) states of the union-product \(\mathcal A_1 \oplus \mathcal A_2\), namely \[ Q_1 \times Q_2 = \{(x_1, y_1), (x_1, y_2), (x_2, y_1), (x_2, y_2)\} \] Now let's take a look at the definition of the transition function: in \(\mathcal A_1 \oplus \mathcal A_2\), we have
  • \((x_1, y_1) \xrightarrow{a} (x_2, y_1)\), because \(x_1 \xrightarrow{a} x_2\) in \(\mathcal A_1\) and \(y_1 \xrightarrow{a} y_1\) in \(\mathcal A_2\)
  • \((x_1, y_1) \xrightarrow{b} (x_1, y_2)\), because \(x_1 \xrightarrow{b} x_1\) in \(\mathcal A_1\) and \(y_1 \xrightarrow{b} y_2\) in \(\mathcal A_2\)
  • \((x_1, y_2) \xrightarrow{a} (x_2, y_1)\), because \(x_1 \xrightarrow{a} x_2\) in \(\mathcal A_1\) and \(y_2 \xrightarrow{a} y_1\) in \(\mathcal A_2\)
  • \((x_1, y_2) \xrightarrow{b} (x_1, y_1)\), because \(x_1 \xrightarrow{b} x_1\) in \(\mathcal A_1\) and \(y_2 \xrightarrow{b} y_1\) in \(\mathcal A_2\)
and so on. Furthermore, the accepting states of \(\mathcal A_1 \oplus \mathcal A_2\) are \[ F^\oplus = \{ (x_1, y_2), (x_2, y_1), (x_2, y_2) \} \] because one of these states is accepting in each pair.
(Sketching the Union-product) Draw the state diagram for the union-product \(\mathcal A_1 \oplus \mathcal A_2\) in the figure above.
(Union of Constants Again) Return to the total deterministic automata you built in Union of Constants earlier. Construct the union-product of the automata you built to accept \(L_1\) and \(L_2\) and compare it with the automaton you built to accept \(L_3\). (If you like, repeat for \(L_4\), \(L_5\), and \(L_6\).)

Importantly, the union-product of two total deterministic automata is a total deterministic automaton, by construction. Every pair of states has exactly one out-going transition for each letter \(a \in A\), because every state in \(\mathcal A_1\) or \(\mathcal A_2\) has exactly one outgoing transition for each letter.

The significance of the union-product construction is that it allows us to prove that \(\mathsf{Fin}\) is closed under unions, in the following sense.

(Closure under Union) Let \(L_1, L_2 \in \mathsf{Fin}\). Then \(L_1 \cup L_2 \in \mathsf{Fin}\).
Let \(\mathcal A_1 = (Q_1, A, \delta_1, F_1)\) be a total deterministic automaton with a state \(x \in Q_1\) such that \(\mathcal L(\mathcal A_1, x) = L_1\), and let \(\mathcal A_2 = (Q_2, A, \delta_2, F_2)\) be a total deterministic automaton with a state \(y \in Q_2\) such that \(\mathcal L(\mathcal A_2, y) = L_2\).
Claim. Let \(\mathcal A = \mathcal A_1 \oplus \mathcal A_2\). Then \(\mathcal L(\mathcal A, (x, y)) = L_1 \cup L_2\).
If we manage to prove the claim, then we are done: \(\mathcal A_1 \oplus \mathcal A_2\) is a finite automaton with a state that accepts \(L_1 \cup L_2\).

So let's prove the claim. We need to show two things: (1) that \(\mathcal L(\mathcal A, (x, y)) \subseteq L_1 \cup L_2\), and (2) that \(\mathcal L(\mathcal A, (x, y)) \supseteq L_1 \cup L_2\).

To see (1), let \(w \in \mathcal L(\mathcal A, (x,y))\). Write \(w = b_0 b_1 \cdots b_{n-1}\). Then there is a path \[ (x, y) \xrightarrow{b_0} (x_1, y_1) \xrightarrow{b_1} \cdots \xrightarrow{b_{n-1}} (x_{n}, y_{n}) \] and either \(x_n \in F_1\) or \(y_n \in F_2\). By definition, this means that we have found two paths through \(\mathcal A_1\) and \(\mathcal A_2\): \[\begin{gathered} x \xrightarrow{b_0} x_1 \xrightarrow{b_1} x_2 \xrightarrow{b_2} \cdots \xrightarrow{b_{n-1}} x_n \qquad \text{in \(\mathcal A_1\)}\\ y \xrightarrow{b_0} y_1 \xrightarrow{b_1} y_2 \xrightarrow{b_2} \cdots \xrightarrow{b_{n-1}} y_n \qquad \text{in \(\mathcal A_2\)} \end{gathered}\] If \(x_n \in F_1\), the first path tells us that \(w \in L_1\). If \(y_n \in F_2\), then the second path tells us that \(w \in L_2\). It follows that \(w \in L_1 \cup L_2\).

To see (2), let \(w \in L_1 \cup L_2\). Then either \(w \in L_1\) or \(w \in L_2\). The rest of the proof is the same in either case, so let's just assume that \(w \in L_1\) for now. Again, let \(w = b_0b_1\cdots b_{n-1}\). Since \(L_1 = \mathcal L(\mathcal A, x)\), \(w \in L_1\) means that there is a path \[ x \xrightarrow{b_0} x_1 \xrightarrow{b_1} x_2 \xrightarrow{b_2} \cdots \xrightarrow{b_{n-1}} x_n \] in \(\mathcal A_1\) such that \(x_n \in F_1\).

Now here is where we need that \(\mathcal A_1\) and \(\mathcal A_2\) are total and deterministic: since \(\mathcal A_2\) is total and deterministic, we can form a path, \[ y \xrightarrow{b_0} y_1 \xrightarrow{b_1} y_2 \xrightarrow{b_2} \cdots \xrightarrow{b_{n-1}} y_n \] in \(\mathcal A_2\) (recall that there is always an outgoing transition because of totality). It doesn't matter which path we choose, we just need to know it exists, because it tells us there is a path \[ (x, y) \xrightarrow{b_0} (x_1, y_1) \xrightarrow{b_1} \cdots \xrightarrow{b_{n-1}} (x_{n}, y_{n}) \] Since \(x_n \in F_1\), \((x_n, y_n) \in F^\oplus\), and therefore \(w = b_0b_1 \cdots b_{n-1} \in \mathcal L(\mathcal A, (x,y))\). It follows that \(L_1 \cup L_2 \subseteq \mathcal L(A, (x, y))\).

Since we have shown both that \(\mathcal L(\mathcal A, (x, y)) \subseteq L_1 \cup L_2\) and that \(\mathcal L(\mathcal A, (x, y)) \supseteq L_1 \cup L_2\), we have proven the Claim. Since the Claim implies the Closure Under Union Theorem, we are done.

The title of this subsection is The Product Constructions, plural. There are indeed two, and I bet you can find the other one.

Closure under Intersection Let \(L_1, L_2 \in \mathsf{Fin}\). Then \(L_1 \cap L_2 \in \mathsf{Fin}\).
(Intersection-product Construction) Let \(\mathcal A_1 = (Q_1, A, \delta_1, F_1)\) and \(\mathcal A_2 = (Q_2, A, \delta_2, F_2)\) be total deterministic automata, and let \(x \in Q_1\) and \(y \in Q_2\). Let \(L_1 = \mathcal L(\mathcal A_1, x)\) and \(L_2 = \mathcal L(\mathcal A_2, x)\). Change the accepting states in the union-product construction to obtain an automaton \(\mathcal A_1 \otimes \mathcal A_2 = (Q_1 \times Q_2, A, \delta^\times, F^ \otimes)\) such that \(\mathcal L(\mathcal A_1 \otimes \mathcal A_2, (x, y)) = L_1 \cap L_2\). Explain how to obtain a proof of the Closure under Intersection Theorem from the proof of the Closure under Union Theorem (i.e., what would you change?).
It's called the intersection-product construction, not the union-product construction!
(Intersection Examples) For each language in the alphabet \(A = \{a,b\}\) below, start by writing down a few words of the language. Then design a total deterministic finite automaton with a state that accepts the language.
  1. \(L_1 = \{a^nb^m \in A^* \mid n,m \in \mathbb N\}\)
  2. \(L_2 = \{b^na^m \in A^* \mid n,m \in \mathbb N\}\)
  3. \(L_3 = L_1 \cap L_2\)
  4. \(L_4 = \{a^nb(ba)^m \in A^* \mid n,m \in \mathbb N\}\)
  5. \(L_5 = L_1 \cap L_4\)
(Hello De Morgan) One of De Morgan's laws is the identity \[ Z \setminus (X \cup Y) = (Z \setminus X) \cap (Z \setminus Y) \] Use this identity to prove the Closure under Intersection Theorem a different way than constructing a new automaton.
You need to use the Closure under Complement and Closure under Union Theorems.
Top