4.6.6 · D2Theory of Computation

Visual walkthrough — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

2,000 words9 min readBack to topic

We keep ONE concrete pair of tiny machines the whole way, so nothing is abstract.


Step 0 — What is a machine that reads a string?

Our two robots for the whole page:

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star
  • Robot (left, blue): accepts strings over with an even number of s. State = "so far even", state = "so far odd". Reading a flips ; reading a changes nothing. Start = , happy = (double circle).
  • Robot (right, pink): accepts strings that end in . State = "last letter was not (or nothing read yet)", state = "last letter was ". Reading a jumps to ; reading a jumps to . Start = , happy = .

Every symbol we use below is one of these circles and arrows. Nothing else exists yet.


Step 1 — The question we want a machine to answer

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

We need a single machine that watches both facts at once.


Step 2 — The idea: run both robots in parallel

Because has circles and has circles , the number of possible pairs is . Here they are as a grid:

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

Step 3 — How the combined machine moves

Let us actually draw an arrow. Start at and read a :

  • : reading at keeps it at (a never changes -parity).
  • : reading at jumps to (last letter is now ).
  • So .
Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

Repeat this for every box and both letters and you get the full product machine — every circle has exactly one -arrow and one -arrow, so it is still a proper deterministic robot.


Step 4 — Where does it start?

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

Step 5 — Who says YES? (the ONLY place AND vs OR differ)

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

Step 6 — Trace a real string end to end

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star

Step 7 — Edge and degenerate cases (never leave a gap)


The one-picture summary

Figure — Regular languages — closed under union, intersection, complement, concatenation, Kleene star
Recall Feynman retelling in plain words

Picture two little reading-robots side by side. You read the same string out loud, one letter at a time, and both robots step forward together on every letter. To keep score you just note where each robot is standing — a pair of positions, like "(robot A on E, robot B on Y)". That pair is the state of one big combined robot; there are (A's spots) × (B's spots) of them. The combined robot's move rule is nothing new: each half of the pair just obeys its own old robot. It starts at "(A's start, B's start)". The only decision left is when to shout YES: if you want both conditions, shout only when both halves are on a happy spot; if you want either condition, shout when at least one half is happy. Same wiring, different YES-lights. Because we literally built this machine out of the two given ones, the result is still something a finite robot accepts — so it is still a regular language. That is the whole proof, and you drew every piece of it.

Recall Quick self-test

How many states does the product of an -state DFA and an -state DFA have? ::: Exactly (one per pair). For intersection, which pairs accept? ::: Only pairs where both coordinates are accepting: . For union, which pairs accept? ::: Pairs where at least one coordinate accepts: . Does the transition wiring differ between AND and OR? ::: No — only the set of accepting states differs.


Related: Deterministic Finite Automata (DFA) · Regular Expressions · Product Construction · De Morgan's Laws · Pumping Lemma for Regular Languages · back to the parent topic.