Recall warm-up
- Minimal DFA states for strings containing
ab?Stuck? Peek at 1.1.3 DFA design patterns
Language (|w| = k pattern) Minimal states starts with w k + 2 contains w / ends with w k + 1 |x| ≡ r mod n n |x| = k, |x| ≤ k k + 2 |x| ≥ k k + 1 #a mod m and/or #b mod n m·n (typical) binary value ≡ 0 mod k, k odd k binary ÷ 2ʲ j + 1 k-th symbol from start fixed k + 2 Divisibility update: r ← (base·r + digit) mod k.
- Write A − B using ∩ and complement.
Stuck? Peek at 0.2.1 Sets
- x ∈ A (element) vs X ⊆ A (subset). ∅ ⊆ every set. A = B ⇔ A ⊆ B and B ⊆ A.
- A ∪ B, A ∩ B, A − B = A ∩ B̅, A̅ = U − A. De Morgan: (A∪B)̅ = A̅∩B̅, (A∩B)̅ = A̅∪B̅.
- |A ∪ B| = |A| + |B| − |A ∩ B|. |A × B| = |A|·|B|. |P(A)| = 2^|A|.
- |∅| = 0, |{∅}| = 1, P(∅) = {∅}.
- What is L(M) when no accepting state is reachable?
Stuck? Peek at 1.1.2 Extended transition function and regular languages
- δ̂(q, ε) = q; δ̂(q, wa) = δ(δ̂(q, w), a); δ̂(q, xy) = δ̂(δ̂(q, x), y).
- L(M) = { w : δ̂(q₀, w) ∈ F }. Regular ⇔ accepted by some DFA. All finite languages are regular.
- From the graph: empty ⇔ no reachable final; Σ* ⇔ all reachable states final; infinite ⇔ cycle on a path start→final.
- Prove correctness with state meanings + induction on |w|.
The Hook
An airport scanner checks a bag for two things at once: “no liquids over 100 ml” and “no sharp objects”. It doesn’t scan twice — it runs both checks in parallel as the bag passes. A DFA can do the same: run two DFAs side by side on one pass, remembering a pair of states. This proves that combinations of regular languages are regular, and it’s how GATE expects you to count states for combined conditions.
Predict First
DFA A has 3 states, DFA B has 4 states. A DFA that runs both at once would need at most how many states?
Core Concept
Prediction check
At most 3 × 4 = 12: one state per pair (state of A, state of B). Some pairs may be unreachable or merge after minimization, so 12 is an upper bound.
| B1 | B2 | B3 | B4 | |
|---|---|---|---|---|
| A1 | (A1,B1) | (A1,B2) | (A1,B3) | (A1,B4) |
| A2 | (A2,B1) | (A2,B2) | (A2,B3) | (A2,B4) |
| A3 | (A3,B1) | (A3,B2) | (A3,B3) | (A3,B4) |
The product construction
δ((p, q), a) = (δ₁(p, a), δ₂(q, a)).
After reading w, the product is in (δ̂₁(s₁, w), δ̂₂(s₂, w)) — it knows exactly where both machines are. Only the choice of accepting pairs changes:
- Intersection L₁ ∩ L₂: F = F₁ × F₂ (both accept).
- Union L₁ ∪ L₂: F = (F₁ × Q₂) ∪ (Q₁ × F₂) (either accepts).
- Difference L₁ − L₂: F = F₁ × (Q₂ − F₂).
- Symmetric difference: exactly one accepts.
Conclusion: regular languages are closed under union, intersection and difference — combining regular languages this way always gives a regular language.
| pair | a | b | ∩ | ∪ | L₁ − L₂ |
|---|---|---|---|---|---|
| → EP | OP | EQ | ✓ | ✓ | |
| EQ | OP | EQ | ✓ | ✓ | |
| OP | EP | OQ | |||
| OQ | EP | OQ | ✓ |
Build only what you can reach
In practice, start from (s₁, s₂) and add pairs as transitions reach them (like BFS, Lesson 0.2.5). Unreachable pairs never matter.
Complement of a DFA
It works because a DFA run always ends in exactly one state, and that state is accepting in exactly one of M, M̅. So regular languages are closed under complement, and the number of states doesn’t change.
Using complement to save work
“Strings that do not contain aba”: build contains-aba (4 states), swap F. Same 4 states. Complementing never changes the minimal state count.
Putting it together
- Run two DFAs in parallel on pairs of states; only the accepting set decides ∩, ∪ or −.
- At most m × n states; build reachable pairs only.
- Complement = complete the DFA, then swap F. Regular languages are closed under ∪, ∩, −, complement.
Visual
Product of “#a even” (E/O) with “ends with b” (P = last symbol not b or nothing read, Q = last symbol b). Intersection accepts only EQ.
States: EP, EQ, OP, OQ
Transitions: EP>OP: a; EP>EQ: b; EQ>OP: a; EQ>EQ: b; OP>EP: a; OP>OQ: b; OQ>EP: a; OQ>OQ: b
a b union F = {EP, EQ, OQ} (E accepts or Q accepts)
→ EP OP EQ intersection = {EQ}
* EQ OP EQ difference L₁−L₂ = {EP} (even a's, not ending in b)
OP EP OQ
OQ EP OQ
trace "abab": EP ─a→ OP ─b→ OQ ─a→ EP ─b→ EQ ACCEPT (2 a's, ends b)
trace "ab" : EP ─a→ OP ─b→ OQ REJECT (odd a's)Worked Examples
In the product above, which states are accepting for L₁ ∪ L₂ (“even a’s OR ends with b”)?
Show the full solution
Pairs where E holds or Q holds: EP, EQ, OQ. Only OP (odd a’s, not ending in b) rejects. Trace “a”: EP→OP reject ✓; “ab”: →OQ accept ✓.
Complement the starts-with-a DFA (1.1.1). What language results, and why must D be kept?
Show the full solution
Swap: q0 and D become accepting, q1 non-accepting. New language: strings that do not start with a = {ε} ∪ strings starting with b. If D had been omitted, “ba” would have nowhere to go and be rejected by both machines — but “ba” does not start with a, so the complement must accept it. D is what catches it.
M₁ (3 states) accepts strings with #a ≡ 0 (mod 3). M₂ (2 states) accepts strings ending in b. Upper bound and actual minimal states for L₁ − L₂?
Show the full solution
Upper bound 3 × 2 = 6. All 6 pairs are reachable (counts and last symbol vary independently) and distinguishable (a-count mod 3 matters; whether the last symbol is b matters for acceptance now). So the minimal DFA has 6 states.
GATE Traps
- Complement by swapping F only works on a complete DFA — add the dead state first.
- Swapping F in an NFA (next chapter) does not give the complement.
- m × n is an upper bound; the minimal DFA can be smaller when pairs merge or are unreachable.
- Union accepting set is not F₁ × F₂ — that is intersection.
Memory Hook
Product = two runners on the same track holding hands; you only decide at the finish line whether you needed one or both to win.
Connect the Dots
Phase 1, Chapter 1 complete: DFAs, their languages, design patterns, combining and complementing. But designing some DFAs is painful (try “third symbol from the end is 1”). Next chapter introduces a machine allowed to guess — and shows it is no more powerful, just far more convenient.
Self-Test
- NAT
Product construction of a 4-state and a 5-state DFA has at most how many states?
Write your answer before opening the key.
- MCQ
In the product DFA, for L₁ − L₂ the accepting set is:
- F₁ × F₂
- F₁ × (Q₂ − F₂)
- (Q₁ − F₁) × F₂
- (F₁ × Q₂) ∪ (Q₁ × F₂)
- MSQ
Which are true?
- Regular languages are closed under complement
- Swapping F in any DFA drawing (dead state omitted) gives the complement
- Complementing a DFA does not change its number of states
- Regular languages are closed under intersection
- NAT
Minimal DFA states for strings over {a,b} that do NOT contain
aa?Write your answer before opening the key.
- MCQ
L₁ = strings of even length, L₂ = strings of odd length over {a,b}. Product DFA for L₁ ∩ L₂ — its language is:
- Σ*
- ∅
- {ε}
- even-length strings
Rule Card
- Product: states Q₁×Q₂, δ((p,q),a) = (δ₁(p,a), δ₂(q,a)), start (s₁,s₂).
- ∩: F₁×F₂. ∪: F₁×Q₂ ∪ Q₁×F₂. −: F₁×(Q₂−F₂). ≤ |Q₁|·|Q₂| states.
- Complement: complete the DFA (add dead state), swap F ↔ Q−F; same state count.
- Regular languages closed under ∪, ∩, −, complement.
Concept Ledger
- product construction
- pair state (p, q)
- closure (an operation keeps the family)
- closed under union, intersection, difference, complement
- complement DFA (swap F)
- complete DFA
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- 3.
- A ∩ B̅.
- ∅.
Self-test answers
- 20 — 4 × 5.
- B — Accepted by M₁, rejected by M₂.
- A: Intersection.
- C: That is L₂ − L₁.
- D: Union.
- ACD — Complement and product constructions.
- B: The DFA must be complete first.
- 3 — Contains aa has 3 states (k+1); complement keeps 3.
- B — No string has both even and odd length, so the accepting pair (even-accept, odd-accept) is never reached.
- A: That would be the union.
- C: ε has even length but not odd.
- D: That is L₁.
Flashcards
- Product DFA accepting set for L₁ ∪ L₂?
Reveal answer
(F₁ × Q₂) ∪ (Q₁ × F₂) - Product DFA accepting set for L₁ ∩ L₂?
Reveal answer
F₁ × F₂ - How do you complement a DFA?
Reveal answer
Make it complete (add dead state), then swap accepting and non-accepting states. - Does complementing change the minimal state count?
Reveal answer
No.