Skip to content
Part IA Michaelmas, Lent Term

NFA with Epsilon Transitions

Motivation

When combining NFAs, it is useful to have “silent” transitions that consume no input.

Definition

An NFA-ε\varepsilon is an NFA with an additional ε\varepsilon-transition relation τ⊆Q×Q\tau \subseteq Q \times Q.

We write q→εq′q \xrightarrow{\varepsilon} q' if (q,q′)∈τ(q, q') \in \tau.

Full Specification

M=(Q,Σ,Δ,τ,s,F)M = (Q, \Sigma, \Delta, \tau, s, F) where:

  • Q,Σ,s,FQ, \Sigma, s, F as before
  • Δ⊆Q×Σ×Q\Delta \subseteq Q \times \Sigma \times Q: labelled transitions
  • τ⊆Q×Q\tau \subseteq Q \times Q: ε\varepsilon-transitions

Extended Transition Relation

Epsilon Closure

The ε\varepsilon-closure of state qq, written E(q)E(q), is the set of states reachable from qq via only ε\varepsilon-transitions:

E(q)={q′:q→ε∗q′}E(q) = \{q' : q \xrightarrow{\varepsilon^*} q'\}

where →ε∗\xrightarrow{\varepsilon^*} is the reflexive-transitive closure of →ε\xrightarrow{\varepsilon}.

Extended Transition

Define q⇒wq′q \Rightarrow w q' inductively:

q⇒εqq→aq′′q′′⇒wq′q⇒awq′q→εq′′q′′⇒wq′q⇒wq′\frac{}{q \Rightarrow_\varepsilon q} \qquad \frac{q \xrightarrow{a} q'' \quad q'' \Rightarrow_w q'}{q \Rightarrow_{aw} q'} \qquad \frac{q \xrightarrow{\varepsilon} q'' \quad q'' \Rightarrow_w q'}{q \Rightarrow_w q'}

Language

w∈L(M)  ⟺  ∃qf∈F.s⇒wqfw \in L(M) \iff \exists q_f \in F. s \Rightarrow_w q_f

Example

NFA-ε\varepsilon for a∗ba^*b:

NFA-epsilon for a*b

  • Q={q0,q1,q2}Q = \{q_0, q_1, q_2\}
  • q0→aq0q_0 \xrightarrow{a} q_0 (loop on ‘a’)
  • q0→εq1q_0 \xrightarrow{\varepsilon} q_1 (epsilon transition)
  • q1→bq2q_1 \xrightarrow{b} q_2 (accept on ‘b’)
  • F={q2}F = \{q_2\}

Accepts: bb, abab, aabaab, aaabaaab, … (strings of aa‘s ending in bb)

Epsilon Closure Example

For the above NFA:

  • E(q0)={q0,q1}E(q_0) = \{q_0, q_1\} (can reach q1q_1 via ε\varepsilon)
  • E(q1)={q1}E(q_1) = \{q_1\}
  • E(q2)={q2}E(q_2) = \{q_2\}

Eliminating Epsilon Transitions

Any NFA-ε\varepsilon can be converted to an equivalent NFA without ε\varepsilon-transitions.

Construction

Given M=(Q,Σ,Δ,τ,s,F)M = (Q, \Sigma, \Delta, \tau, s, F), define NFA M′=(Q,Σ,Δ′,s′,F′)M' = (Q, \Sigma, \Delta', s', F'):

Δ′={(q,a,q′):∃q′′.q→ε∗q′′∧q′′→aq′}\Delta' = \{(q, a, q') : \exists q''. q \xrightarrow{\varepsilon^*} q'' \land q'' \xrightarrow{a} q'\}

s′=ss' = s F′=F∪{q:E(q)∩F≠∅}F' = F \cup \{q : E(q) \cap F \neq \emptyset\}

Using Epsilon Transitions for Concatenation

To recognise L1⋅L2L_1 \cdot L_2, connect NFAs:

  1. Add ε\varepsilon-transitions from accepting states of M1M_1 to start of M2M_2
  2. Start state is s1s_1
  3. Accepting states are those of M2M_2

Concatenation via epsilon transitions

Using Epsilon for Union

To recognise L1∪L2L_1 \cup L_2:

  1. Create new start state snews_{\text{new}}
  2. Add ε\varepsilon-transitions to s1s_1 and s2s_2
  3. Accepting states are F1∪F2F_1 \cup F_2

Union via epsilon transitions


Summary

  • NFA-ε\varepsilon allows transitions that consume no input
  • E(q)E(q) = set of states reachable via ε\varepsilon-transitions only
  • ε\varepsilon-transitions simplify construction of combined automata
  • Any NFA-ε\varepsilon can be converted to equivalent NFA