Lexical analysis

DFA Minimization

Merge equivalent DFA states by partition refinement and find strings that tell two states apart.

  • Lecture reference: Lexical Analysis IV · slide 11

Input

Build the DFA from

Thompson’s construction, then the subset construction. The DFA is not minimized first.

Add regular definitions
Tab inserts a tab. Press Escape, then Tab, to move focus out of the editor.

The DFA the subset construction builds from the NFA for (1 | 0)*1: ABCDHI, FGABCDHI, EJGABCDHI.

Lecture reference: Lexical Analysis IV · slide 10

From the slides “Is the previous DFA minimal?”

Lecture reference: Lexical Analysis IV · slide 11
Show answer

No. ABCDHI and FGABCDHI are equivalent: neither accepts, and both go to FGABCDHI on 0 and to EJGABCDHI on 1. Merging them leaves 2 states.

Partition refinement 3 states

Round 0 of 1
Round 0: the non-accepting states form block 1; the accepting states form block 2.

P0 = block1 { ABCDHI, FGABCDHI }block2 { EJGABCDHI }

Round 0 initial partition

Accepting and non-accepting states start in different blocks.

Round 0: the block each state starts in
StateAcceptingBlock
ABCDHInoblock1
FGABCDHInoblock1
EJGABCDHIyesblock2

The empty string "" tells an accepting state from a non-accepting one, so they start in different blocks.

Tell two states apart

Equivalent

No string tells ABCDHI and FGABCDHI apart. Both end up in block 1 and merge into ABCDHI.

The shortest string, first in shortlex order, that one state accepts and the other rejects. Missing transitions go to the trap state.

Minimal DFA

3 states in the DFA
2 in the minimal DFA
Each state of the minimal DFA and the states it merges
BlockStateMerges
block1 ABCDHI , start { ABCDHI, FGABCDHI }
block2 EJGABCDHI , accepting{ EJGABCDHI }
Transition table
Transition table of the minimal DFA
State01
ABCDHI , start ABCDHIEJGABCDHI
EJGABCDHI , accepting ABCDHIEJGABCDHI
Open in Finite Automata