Automata & LanguagesTopic #36 of 40

Finite Automata

DFA, NFA, state diagrams, transition tables, and language acceptance.

Deterministic Finite Automaton (DFA)

A DFA is a 5-tuple M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F) where:

  • QQ = finite set of states
  • Σ\Sigma = finite input alphabet
  • δ:Q×ΣQ\delta: Q \times \Sigma \to Q = transition function
  • q0Qq_0 \in Q = start state
  • FQF \subseteq Q = set of accept (final) states

Computation

  1. Start in state q0q_0
  2. Read input symbol by symbol
  3. Transition according to δ\delta
  4. Accept if end in a state in FF; otherwise reject

State Diagrams

Visual representation:

  • Circles = states
  • Double circles = accept states
  • Arrow into state = start state
  • Labeled arrows = transitions

Example: Strings ending in "1"

     0          1          0
→(q0)──→(q0)  (q0)──→((q1))  ((q1))──→(q0)
                              1
                        ((q1))──→((q1))

Q={q0,q1}Q = \{q_0, q_1\}, Σ={0,1}\Sigma = \{0, 1\}, q0q_0 = start, F={q1}F = \{q_1\}

δ\delta01
q0q_0q0q_0q1q_1
q1q_1q0q_0q1q_1

Language of a DFA

The language L(M)L(M) of DFA MM is the set of all strings MM accepts: L(M)={wΣM accepts w}L(M) = \{w \in \Sigma^* \mid M \text{ accepts } w\}

A language is regular if some DFA recognizes it.

Extended Transition Function

δ^:Q×ΣQ\hat{\delta}: Q \times \Sigma^* \to Q processes entire strings:

δ^(q,ϵ)=q\hat{\delta}(q, \epsilon) = q δ^(q,wa)=δ(δ^(q,w),a)\hat{\delta}(q, wa) = \delta(\hat{\delta}(q, w), a)

Then: L(M)={wδ^(q0,w)F}L(M) = \{w \mid \hat{\delta}(q_0, w) \in F\}

Nondeterministic Finite Automaton (NFA)

An NFA allows:

  • Multiple transitions for same symbol
  • Epsilon (ϵ\epsilon) transitions (no input consumed)
  • Missing transitions (implicit rejection)

N=(Q,Σ,δ,q0,F)N = (Q, \Sigma, \delta, q_0, F) where:

  • δ:Q×(Σ{ϵ})P(Q)\delta: Q \times (\Sigma \cup \{\epsilon\}) \to \mathcal{P}(Q)

Acceptance

NFA accepts if any computation path leads to accept state.

Example: Strings containing "01"

     0,1        0          1
→(q0)──→(q0)──→(q1)──→((q2))
                        0,1
                   ((q2))──→((q2))

NFA vs DFA

Power

NFAs and DFAs recognize exactly the same languages (regular languages).

Conversion: NFA to DFA (Subset Construction)

DFA states = subsets of NFA states

For NFA with nn states, equivalent DFA may have up to 2n2^n states.

Why Use NFAs?

  • Often smaller/simpler to design
  • Easier to compose (union, concatenation)
  • Can convert to DFA when needed

Epsilon Closure

For state qq, the epsilon closure E(q)E(q) is the set of states reachable from qq using only ϵ\epsilon-transitions.

For set SS: E(S)=qSE(q)E(S) = \bigcup_{q \in S} E(q)

Regular Languages

Closure Properties

Regular languages are closed under:

  • Union: L1L2L_1 \cup L_2
  • Intersection: L1L2L_1 \cap L_2
  • Concatenation: L1L2L_1 L_2
  • Kleene star: LL^*
  • Complement: L\overline{L}
  • Difference: L1L2L_1 - L_2

Constructing DFAs

Union: Product construction, accept if either accepts. Intersection: Product construction, accept if both accept. Complement: Swap accept and non-accept states.

DFA Minimization

Goal

Find equivalent DFA with minimum number of states.

Algorithm (Table-Filling)

  1. Mark pairs (p,q)(p, q) where one is accept, other is not
  2. Mark (p,q)(p, q) if for some aa, (δ(p,a),δ(q,a))(\delta(p,a), \delta(q,a)) is marked
  3. Repeat until no new marks
  4. Unmarked pairs are equivalent; merge them

Theorem

The minimal DFA for a regular language is unique (up to isomorphism).

Examples of Regular Languages

LanguageDescription
Binary strings divisible by 3DFA with 3 states
Strings with even 0s2 states
Strings with "11" substring3 states
Strings not containing "101"4 states

Limitations

DFAs cannot recognize:

  • {anbnn0}\{a^n b^n \mid n \geq 0\} (equal a's and b's)
  • {www{a,b}}\{ww \mid w \in \{a,b\}^*\} (repeated strings)
  • {an2n0}\{a^{n^2} \mid n \geq 0\} (perfect square lengths)

These require more powerful models (pushdown automata, Turing machines).