Skip to content
Part IA Michaelmas, Lent Term

DFA: Deterministic Finite Automata

Definition

A deterministic finite automaton (DFA) is a tuple M=(Q,Σ,δ,s,F)M = (Q, \Sigma, \delta, s, F) where:

ComponentDescription
QQFinite set of states
Σ\SigmaInput alphabet (finite)
δ:Q×ΣQ\delta : Q \times \Sigma \to QTransition function
sQs \in QStart state
FQF \subseteq QAccepting states

Key Feature: Determinism

For every state qq and symbol aa, there is exactly one next state δ(q,a)\delta(q, a).

  • No ambiguity
  • No “stuck” states (unless δ\delta is partial)
  • Exactly one computation path for each input

Extended Transition Function

Definition

Extend δ:Q×ΣQ\delta : Q \times \Sigma \to Q to δ^:Q×ΣQ\hat{\delta} : Q \times \Sigma^* \to Q:

δ^(q,ε)=q\hat{\delta}(q, \varepsilon) = q δ^(q,aw)=δ^(δ(q,a),w)\hat{\delta}(q, aw) = \hat{\delta}(\delta(q, a), w)

Language

wL(M)    δ^(s,w)Fw \in L(M) \iff \hat{\delta}(s, w) \in F

The string is accepted iff the unique computation path ends in an accepting state.

Example: Divisible by 3

DFA over {0,1,2}\{0, 1, 2\} accepting numbers whose digit sum is divisible by 3:

DFA for divisible by 3

  • Q={q0,q1,q2}Q = \{q_0, q_1, q_2\} (remainder mod 3)
  • δ(qi,d)=q(i+d)mod3\delta(q_i, d) = q_{(i+d) \bmod 3}
  • s=q0s = q_0, F={q0}F = \{q_0\}

Example: Even Parity

DFA over {0,1}\{0, 1\} accepting strings with an even number of 1s:

DFA for even parity

  • Q={q0,q1}Q = \{q_0, q_1\} (parity of seen 1s)
  • δ(q0,0)=q0\delta(q_0, 0) = q_0, δ(q0,1)=q1\delta(q_0, 1) = q_1
  • δ(q1,0)=q1\delta(q_1, 0) = q_1, δ(q1,1)=q0\delta(q_1, 1) = q_0
  • s=q0s = q_0, F={q0}F = \{q_0\}

Example: Ends with “ab”

DFA over {a,b}\{a, b\} accepting strings ending in “ab”:

DFA for ends with ab

  • Q={q0,q1,q2,qd}Q = \{q_0, q_1, q_2, q_d\}
  • Transitions (key ones):
    • q0q_0: last char is bb (or start)
    • q1q_1: last char is aa
    • q2q_2: last two chars are abab
    • qdq_d: dead state (or integrate below)
  • More commonly: Q={q0,q1,q2}Q = \{q_0, q_1, q_2\} with careful transitions
StateInput aaInput bb
q0q_0q1q_1q0q_0
q1q_1q1q_1q2q_2
q2q_2q1q_1q0q_0

F={q2}F = \{q_2\}

Complete vs Partial DFAs

Complete DFA

δ\delta is total: there is exactly one transition for every (q,a)Q×Σ(q, a) \in Q \times \Sigma.

Every input has a unique complete computation.

Partial DFA

δ\delta may be undefined for some (q,a)(q, a).

If computation reaches an undefined transition, the string is rejected.

Conversion

Any partial DFA can be converted to a complete DFA by adding a “trap” or “dead” state.

Rejection

A DFA rejects string ww if:

δ^(s,w)F\hat{\delta}(s, w) \notin F

The computation exists (deterministically) but ends in a non-accepting state.

State Diagram Convention

  • Circles represent states
  • Double circles represent accepting states
  • Arrow from “start” marks the start state
  • Labelled arrows between states show transitions

Summary

  • DFA: (Q,Σ,δ,s,F)(Q, \Sigma, \delta, s, F) with deterministic transition function
  • Exactly one computation path per input
  • Accept iff final state is in FF
  • Complete vs partial: complete has all transitions defined