Exercises — Regular languages — closed under union, intersection, complement, concatenation, Kleene star
Level 1 — Recognition
(Can you name the right closure rule and quote the construction?)
Recall Solution L1.1
All five. Union, intersection, complement, concatenation, and Kleene star each have an explicit machine construction, so the result always has a machine, so it is regular by definition. Answer: 5 of 5.
Recall Solution L1.2
You swap accept and non-accept states. New machine . Why this works (one line): a DFA lands in exactly one state on any string, so "not accepted" and "accepted-by-the-flipped-set" are the same event. New accept set .
Recall Solution L1.3
Accept set (both coordinates final). Transition: — feed the same letter to both robots at once. See Product Construction.
Level 2 — Application
(Build the actual machine / carry out the construction.)
Recall Solution L2.1
A product DFA has states — one for every combination of "where robot A is" and "where robot B is." Here states. Label A's states (even s, accepting) and (odd). Label B's states (last letter was , accepting) and (not). The four product states are . Accept = both final: only . See the picture below — the two axes are the two robots, the one accepting corner is highlighted.

Recall Solution L2.2
Union = accept if at least one coordinate is final. So . (A happy, B anything). (B happy). Union of those: — three accepting states. The only rejecting state is : odd s and doesn't end in , so neither condition holds.
Recall Solution L2.3
An -transition is a "free jump" the robot may take without reading a letter. A string in splits as (in ) then (in ), and we don't know where — so we let the machine guess by jumping to the instant could finish. Add one -transition from each accept state of to : from and from , so transitions. New accepts only. 's old accept states stop being final (finishing is no longer "done" — you still owe a from ).
Level 3 — Analysis
(Reason about why a construction does or does not work.)
Recall Solution L3.1
Take (exactly the two-letter string ). A minimal machine: with accepting. For we loop back from to . If we also mark accepting, watch the input : read : ; read : ; loop : ; read : . String ends in — not accepting, good. But consider ... the real failure: any string that passes through mid-word (after a completed copy and one more letter that returns to start) can be wrongly accepted when is final. Cleanest counterexample: if has an incoming letter-transition (common after minimization), a partial word that lands back on without completing a copy of gets accepted. Fix (as in the parent): use a fresh state as new start and the sole -acceptor, loop back to (never into ). Then is accepted via and no mid-word position is falsely final.
Recall Solution L3.2
Nondeterminism means: the string is accepted iff some guess works, and rejected iff no guess works. A wrong split (jumping to too early or late) simply leads to a branch that fails to reach an accept state — it costs nothing. The string is accepted only when there exists a split with and , which is exactly the definition of . So guessing can never accept a string outside : a fake accept would require a real split, contradiction.
Recall Solution L3.3
= the language accepting no strings; its DFA is a single non-accepting sink (). Flipping: , so every state accepts accepts everything . ✓ = accepts all strings; DFA is a single accepting state (). Flipping: , accepts nothing . ✓ Both results are regular (each is a one-state DFA), confirming complement stays inside the club even in degenerate cases.
Level 4 — Synthesis
(Combine several closure rules to settle a language.)
Recall Solution L4.1
= "any number of s (including zero)" is regular (single-letter Kleene star). Likewise . — a block of s concatenated with a block of s. Concatenation of two regular languages is regular. Therefore is regular. ∎ Why this is the point: we proved regularity purely by closure algebra, never designing states. Equivalently it is the regular expression .
Recall Solution L4.2
Let .
- = "contains " : concatenation of the regular pieces , the constant string , and . Regular (concatenation + star).
- = "even length" : take pairs of letters and star them. Regular (concatenation + star).
- The target is , union of two regular languages ⇒ regular. ∎ As a regex: .
Recall Solution L4.3
De Morgan (sets): . Put : (double complement cancels). ✓ identity holds. Why it re-proves closure: we already know regular languages are closed under complement (flip) and intersection (product). The identity writes using only those two operations. So if are regular, so is — no new machine needed. This is a second, independent proof besides the direct product-union construction.
Level 5 — Mastery
(Use closure to transfer non-regularity, and defend a subtle construction.)
Recall Solution L5.1
Strategy: if were regular, closure would force a language we know is non-regular to be regular — contradiction.
- Suppose, for contradiction, is regular.
- (any s then any s) is regular.
- Regular languages are closed under intersection, so would be regular.
- Compute it: a string in has the form ; it lies in iff , i.e. . So .
- But is not regular (pumping lemma). Contradiction.
- Therefore is not regular. ∎ Why this step-by-step works: closure runs backward — it transfers non-regularity from the known-bad language up to . The intersection with is the "filter" that isolates the troublesome equal-count strings.
Recall Solution L5.2
Base NFA for : start , (accept, the string ), (accept, the string ). Accepts . Star build: add fresh (new start, accepting). -jumps: (enter one copy) and from each old accept back to (restart). New accept set .

Checks:
- : stay on (accepting). ✓ (this is the case).
- : (accepting). ✓
- : — reading as three copies of "" — ends on . ✓ (Also reachable as .)
- Nothing false: every accepting path either sits on (read nothing) or ends on immediately after reading a full copy of ; loop-backs go to , never into , so no mid-copy position is accepting.
Recall Solution L5.3
No. , which is not regular. The subtle point: closure guarantees regularity only for finitely many applications of the operations. Union closure says is regular for two (and by induction any fixed finite number of) regular inputs. It says nothing about combining infinitely many. Each finite union is regular; the limit need not be. Closure is a finite-composition promise, not an infinite one.
Recall One-screen recap
Complement ::: flip accept/non-accept on a DFA (determinize an NFA first). Intersection ::: product DFA, accept . Union ::: product with accept , or an -NFA guessing a machine, or De Morgan. Concatenation ::: -jump from every accept of to start of ; accepts . Kleene star ::: fresh accepting start , , loop each old accept back to ; accepts . Non-regularity trick ::: intersect the suspect language with a simple regular language to expose a known non-regular one.