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εqq \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 qwqq \Rightarrow w q' inductively:

qεqqaqqwqqawqqεqqwqqwq\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

wL(M)    qfF.swqfw \in L(M) \iff \exists q_f \in F. s \Rightarrow_w q_f

Example

NFA-ε\varepsilon for aba^*b:

NFA-epsilon for a*b

  • Q={q0,q1,q2}Q = \{q_0, q_1, q_2\}
  • q0aq0q_0 \xrightarrow{a} q_0 (loop on ‘a’)
  • q0εq1q_0 \xrightarrow{\varepsilon} q_1 (epsilon transition)
  • q1bq2q_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εqqaq}\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 L1L2L_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 L1L2L_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 F1F2F_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