Automata Theory Lab

  1. Home
  2. Automata Theory Lab

Automata Theory Lab

Three finite-automaton simulators written in C++ that show how the same idea grows in power and in complexity: a deterministic machine, a nondeterministic one, and a nondeterministic one with ε-moves. Each program prints the state path for the words it processes, and each comes with a transition diagram drawn from its Graphviz source.

All three work over the alphabet {0, 1} and print their transition table at the end of the run.

  • Category :Theory of Computation / C++
  • Stack :C++17, Graphviz
  • Automata :DFA, NFA, ε-NFA
  • Output :State paths + Accepted / Rejected
  • Status :Working

1. DFA — Deterministic Finite Automaton

A four-state machine over the binary alphabet. It starts and accepts in state A, so it recognises words with an even number of 0s and an even number of 1s. The program walks the first 500 binary words and prints the state path of every accepted word.

  • Exactly one transition per state and symbol.
  • Invalid symbols are reported and stop the run.
  • Example accepted path for 1001: A→C→D→C→A.
  • States :A, B, C, D
  • Start / Accept :A / A
  • Language :even #0 and even #1
  • Method :Iterative simulation
DFA transition diagram
01
→*ABC
BAD
CDA
DCB

dfa/dfa.cpp

2. NFA — Nondeterministic Finite Automaton

Nine states with several possible moves per symbol. A recursive backtracking search explores every branch and prints each path with its verdict; the word is accepted if at least one path ends in state 9. In the diagram, blue edges are symbol 0 and orange edges are symbol 1.

  • Non-short-circuit | makes every branch run, so the full search tree is printed.
  • Accepting condition: input consumed while standing in state 9.
  • States :1 – 9
  • Start / Accept :1 / 9
  • Method :Recursive backtracking
  • Branching :up to 4 moves per symbol
NFA transition diagram
01
→12,45
24,61,5,3
32,65
42,81,5,7
52,4,6,81,3,7,9
62,83,5,9
74,85
84,67,5,9
*98,65

nfa/nfa.cpp

3. ε-NFA — NFA with epsilon moves

Six states plus empty (ε) transitions that change state without consuming input. In the recursion this is a call that does not advance the input index. State E branches into B and C for free, and B can jump to the accepting state D at the end of the word.

  • Dashed orange edges in the diagram are ε-transitions.
  • Tested words: 1, 0, 000, 111, 011 accepted; 11, 01, 010 rejected.
  • States :A – F
  • Start / Accept :A / D
  • Method :Recursive search with ε-closure
  • ε-moves :B→D, E→B, E→C
E-NFA transition diagram with epsilon moves
01ε
→AEB
BCD
CD
*DD
EFB,C
FD

enfa/enfa.cpp

Related Projects

Zhelezyaka (AI JARVIS concept)

Zhelezyaka (AI JARVIS concept)

Local AI Assistant / Concept
Automatic Mafia

Automatic Mafia

Python / PySide6 / Face Recognition
Neuron Offline AI

Neuron Offline AI

Offline AI / Memory / Modular Architecture

Project Summary

Send a direct message about this project and it will be delivered to my email.