Deterministic Finite Automaton (DFA)
A DFA is a 5-tuple where:
- = finite set of states
- = finite input alphabet
- = transition function
- = start state
- = set of accept (final) states
Computation
- Start in state
- Read input symbol by symbol
- Transition according to
- Accept if end in a state in ; 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))
, , = start,
| 0 | 1 | |
|---|---|---|
Language of a DFA
The language of DFA is the set of all strings accepts:
A language is regular if some DFA recognizes it.
Extended Transition Function
processes entire strings:
Then:
Nondeterministic Finite Automaton (NFA)
An NFA allows:
- Multiple transitions for same symbol
- Epsilon () transitions (no input consumed)
- Missing transitions (implicit rejection)
where:
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 states, equivalent DFA may have up to states.
Why Use NFAs?
- Often smaller/simpler to design
- Easier to compose (union, concatenation)
- Can convert to DFA when needed
Epsilon Closure
For state , the epsilon closure is the set of states reachable from using only -transitions.
For set :
Regular Languages
Closure Properties
Regular languages are closed under:
- Union:
- Intersection:
- Concatenation:
- Kleene star:
- Complement:
- Difference:
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)
- Mark pairs where one is accept, other is not
- Mark if for some , is marked
- Repeat until no new marks
- Unmarked pairs are equivalent; merge them
Theorem
The minimal DFA for a regular language is unique (up to isomorphism).
Examples of Regular Languages
| Language | Description |
|---|---|
| Binary strings divisible by 3 | DFA with 3 states |
| Strings with even 0s | 2 states |
| Strings with "11" substring | 3 states |
| Strings not containing "101" | 4 states |
Limitations
DFAs cannot recognize:
- (equal a's and b's)
- (repeated strings)
- (perfect square lengths)
These require more powerful models (pushdown automata, Turing machines).