WHY 2 states: parity is a yes/no fact; you never need the actual count, just even vs odd. This is the 80/20 insight — keep the minimal memory that distinguishes accept from reject.
Q={E,O} ("even-so-far","odd-so-far"), start E, F={E}
δ(E,0)=O, δ(O,0)=E (a 0 flips parity)
δ(E,1)=E, δ(O,1)=O (a 1 is irrelevant — self-loop)
Trace w=0100:E0O1O0E0O. End O∈/F ⇒ rejected. Check: 0100 has three 0's (odd) ⇒ correctly rejected. ✓
Machine:Q={A,B,C}, Σ={a,b}, start A, F={C},
δ(A,a)=B,δ(A,b)=A,δ(B,a)=B,δ(B,b)=C,δ(C,a)=B,δ(C,b)=A.
Recall Forecast: does this DFA accept "abab"? (predict before reading)
Forecast:C is reached only by reading "b" while in B, i.e. an "...ab" ending. So accept iff string ends in "ab".
Verify trace of abab:AaBbCaBbC. End C∈F ⇒ accepted. Forecast confirmed (it ends in "ab"). ✓
(Q,Σ,δ,q0,F) — states, alphabet, transition function, start state, accept states.
What is the type signature of the DFA transition function δ?
δ:Q×Σ→Q (total, single-valued).
What makes a finite automaton deterministic?
For every (state, symbol) pair there is exactly one next state — δ is a total function, no choices, no ε-moves.
Define δ^(q,ε) and δ^(q,xa).
δ^(q,ε)=q; δ^(q,xa)=δ(δ^(q,x),a).
When does a DFA M accept string w?
When δ^(q0,w)∈F.
What is L(M)?
{w∈Σ∗:δ^(q0,w)∈F} — the set of all strings it accepts.
What is a "regular language"?
A language recognized by some DFA.
In a state diagram, what does a double circle mean?
An accept (final) state, i.e. a member of F.
In a state diagram, what marks the start state?
An arrow coming from nowhere into that state.
If a state diagram is missing an arrow for some symbol, what does a DFA require?
A hidden total δ — really a transition to a dead/trap state (loops on itself, non-accepting).
Does a DFA accept ε iff what?
Iff q0∈F (the start state is accepting).
Difference between δ and δ^?
δ reads one symbol; δ^ reads a whole string by recursion.
Recall Feynman: explain a DFA to a 12-year-old
Imagine a board game with a few squares. You start on the START square. Someone reads you a string of letters one at a time. Each square has a rule: "if you hear an a, hop to that square; if you hear a b, hop to this square." You just keep hopping — you have NO notebook, NO memory except which square you're standing on. When the letters run out, look down: if you're on a glowing (double-circle) square, you shout "YES, this word is in my club!"; otherwise "NO." That's a DFA: a finite hopping game where the square you're on is your whole brain.
Dekho, DFA ek bahut simple "machine" hai jiske paas sirf finite memory hai — na koi notebook, na koi extra storage. Uske paas kuch states hote hain (circles), aur jis bhi state pe vo abhi khada hai, wahi uski poori memory hai. Input string ek-ek symbol karke aata hai, aur har symbol pe machine ek fixed rule (transition function δ) follow karke agle state pe jump karta hai. "Deterministic" ka matlab: har (state, symbol) ke liye sirf ek hi next state — koi guessing nahi, koi choice nahi.
Formal definition yaad rakhne ke liye 5 cheezein chahiye, yaani 5-tuple (Q,Σ,δ,q0,F): Q = saare states, Σ = alphabet (jo symbols read honge), δ = transition rule Q×Σ→Q, q0 = start state, aur F = accept (final) states. String complete padhne ke baad agar machine kisi accept state (F ka member, diagram me double circle) pe khada hai, toh string accept, warna reject. Iska formal version δ^ se aata hai: δ^(q,ε)=q aur δ^(q,xa)=δ(δ^(q,x),a).
State diagram bas isi tuple ki picture hai — circle = state, double circle = accept, bahar se aati arrow = start, aur labelled arrow = δ ki ek line. Real life me ye important hai kyunki tokenizers, regex search, password/pattern checking — sab DFA jaisi cheez se chalti hain.
Ek common galti: agar diagram me kisi symbol ki arrow missing dikhe, mat socho "undefined hai". DFA me δtotal hona chahiye — woh missing arrow asal me ek hidden "dead/trap state" ki taraf jaati hai. Aur dusri galti: ε (empty string) ko bhulna mat — agar q0∈F hai toh empty string bhi accept hoti hai. Bas itna pakka rakho, baaki sab same logic pe chalta hai.