Labs ICT
โญ Pro Login

Deterministic Finite Automata (DFA)

Exactly one transition per symbol โ€” no ambiguity allowed.

Deterministic Finite Automata (DFA)

A DFA is a finite automaton where for every state and every input symbol, there is exactly one transition. "Deterministic" means the machine's next state is completely determined by its current state and the input symbol โ€” no guessing, no ambiguity.

A DFA is formally defined as a 5-tuple (Q, ฮฃ, ฮด, q0, F) where ฮด: Q ร— ฮฃ โ†’ Q is a total function โ€” it must produce a next state for every state-symbol pair.

State Diagrams

DFAs are typically visualized as directed graphs. Circles represent states, and directed edges represent transitions. The start state has an incoming arrow with no source. Accept states are marked with double circles.

Example: DFA accepting strings ending in "01"

    โ”Œโ”€โ”€โ”€0โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€1โ”€โ”€โ”€โ”
    โ”‚       โ–ผ    โ”‚       โ–ผ
  โ”Œโ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”       โ”Œโ•โ•โ•โ”
  โ”‚q0 โ”‚โ”€โ”€0โ”€โ”€โ–ถ โ”‚q0 โ”‚โ”€โ”€1โ”€โ”€โ–ถ โ”‚q1 โ”‚
  โ””โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”˜       โ””โ•โ•โ•โ”˜
   โ–ฒ            โ–ฒ           โ”‚
   โ”‚     0      โ”‚     0     โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
   โ”‚            โ”‚     1     โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Start: q0
Accept: {q1}

ฮด(q0, 0) = q0
ฮด(q0, 1) = q1
ฮด(q1, 0) = q0
ฮด(q1, 1) = q1

Trace Execution

Let's trace "101" through the DFA above. Start at q0. Read 1 โ†’ move to q1. Read 0 โ†’ move to q0. Read 1 โ†’ move to q1. End in q1 (accept). So "101" is accepted.

Now trace "100". Start at q0. Read 1 โ†’ move to q1. Read 0 โ†’ move to q0. Read 0 โ†’ stay at q0. End in q0 (reject). So "100" is not accepted โ€” it doesn't end in "01".

Key Properties

A DFA has no epsilon transitions. From any state, reading any symbol from the alphabet leads to exactly one state. This makes DFAs easy to simulate โ€” you just follow the transitions. There's no branching, no backtracking, and no ambiguity.

Every regular language has a DFA that accepts it. The number of states in the minimal DFA for a language is unique โ€” this is the Myhill-Nerode theorem.

๐Ÿงช Quick Quiz

In a DFA, for each state and input symbol, there is: