Welcome to your first lesson in our exploration of the theoretical foundations of computer science. Your goal to understand the "science" behind computing—the fundamental questions of what is computable and what makes problems hard—begins here. We will start with the simplest, most foundational model of computation: the finite automaton.
This first module, "The Power of Finite Memory," investigates machines that can only remember a finite amount of information. Today's lesson focuses on a specific type: the Deterministic Finite Automaton (DFA). By the end of this lesson, you will be able to formally define what a DFA is and trace its computation on any given input string to determine if the string is accepted or rejected.
1. The Core Idea: A Machine with Finite Memory
Before diving into formalisms, let's build an intuition for what a finite automaton is. At its core, it's an abstract model of a machine that has a fixed, finite number of "states" or "configurations." It processes an input string of symbols one by one, and each symbol causes the machine to transition from its current state to a new one. The computation is determined entirely by the sequence of states it visits.
A simple light switch is a good analogy. It has two states: On and Off. The inputs are "flick switch up" and "flick switch down." If the light is Off (the state) and you provide the input "flick up," it transitions to the On state. This is the fundamental principle: a current state, an input, and a resulting next state.
To see this idea applied to a computational problem, watch the first part of the following video from MIT OpenCourseWare. It introduces a simple finite automaton and its components using a "state diagram."
1. Introduction, Finite Automata, Regular Expressions
This video, by Prof. Michael Sipser (author of the standard textbook on this subject), will give you a clear visual and conceptual introduction to finite automata.
First, watch the conceptual introduction from the beginning. Focus on the core components he identifies: States (the circles) Transitions (the arrows) Start state (the arrow from nowhere) Accepting states (the double circles) Next, see how this machine "computes" by watching the demonstration from tracing an input. Pay attention to how the machine follows the transitions for each symbol in the input string and how the final state determines whether the string is "accepted" or "rejected."
As you saw, the machine's "language" is the set of all input strings that it accepts. The example machine, M1, accepts any string of 0s and 1s that contains "11" as a substring. This simple device, with just three states, can solve a specific pattern-matching problem.
2. The Formal Definition of a DFA
Visual diagrams are intuitive, but for rigorous analysis and proofs, we need a precise mathematical definition. This aligns with your preference for starting with abstract principles. A formal definition eliminates ambiguity and allows us to reason about these machines' properties universally.
A Deterministic Finite Automaton (DFA) is formally defined as a 5-tuple (a list of five mathematical objects):
Where:
- is a finite set of states.
- (Sigma) is a finite set called the alphabet, which defines the allowed input symbols.
- (delta) is the transition function. It dictates the machine's movement. It is a function , meaning it takes a state from and a symbol from as input and returns the next state in . The "deterministic" part of the name comes from the fact that for any given state and input symbol, there is exactly one next state.
- is the start state, where the machine begins its computation.
- is the set of accept states (or final states).
To solidify this abstract definition, let's watch the next segment of the MIT video, where Prof. Sipser formalizes the machine M1 from the introduction.
1. Introduction, Finite Automata, Regular Expressions
This part of the video directly connects the state diagram you saw earlier to its formal 5-tuple definition.
Watch from the formal definition where he introduces the 5-tuple. Then, continue from the M1 example to see how the components of M1 are explicitly listed. Notice how the transition function \delta can be represented by a table.
The following image provides another excellent summary, showing a state diagram, its formal 5-tuple definition, and its transition table side-by-side.

For a concise, text-based reference on these definitions, you can review the following document.
[PDF] ECS 120 Notes - Computer Science | UC Davis Engineering
These notes provide a crisp, formal definition of a DFA and its components, which you may find useful for reference.
Read the sections titled "1.1 Finite Automata" and "1.1.1 Formal Definition of a Finite Automaton (Syntax)" on pages 1-2. You can skim the initial example trace and focus on Definition 1.1.1 and the subsequent formal description of the machine M1. You can also quickly look at section "0.1.5 Strings and Languages" (page xi) if you need a refresher on terms like alphabet, string, and language.
3. Tracing a Computation
Now that we have a formal definition, let's define computation formally. A DFA computes on an input string by processing it one symbol at a time, starting from the start state.
We can trace this process using instantaneous configurations. A configuration is represented as a pair [q, w], where q is the current state and w is the remaining (unread) part of the input string.
A single step of computation is denoted by the ⊢ ("yields") symbol. If the machine is in state with ax as the remaining string (where a is the next symbol and x is the rest of the string), and if , we write:
This reads: "The configuration [q_i, ax] yields the configuration [q_j, x] in one step."
A full computation is a sequence of such steps. We use ⊢* to denote a sequence of zero or more steps.
A DFA accepts an input string if the computation starting from the initial configuration ends in a configuration where is an accept state (). Here, (epsilon) represents the empty string, signifying that all input has been read. If the final state is not in , the string is rejected.
Let's trace the string ababb on the following machine M1, which is designed to accept any string containing bb.
Caption: A DFA with three states that accepts strings over the alphabet {a, b} containing at least one occurrence of "bb". State 0 is the start state, and state 2 is the sole accept state.
The formal definition of this machine is:
- is given by the diagram.
Trace for input ababb:
- Start: The initial configuration is
[0, ababb]. - Read 'a': . So,
[0, ababb] ⊢ [0, babb]. - Read 'b': . So,
[0, babb] ⊢ [1, abb]. - Read 'a': . So,
[1, abb] ⊢ [0, bb]. - Read 'b': . So,
[0, bb] ⊢ [1, b]. - Read 'b': . So,
[1, b] ⊢ [2, \epsilon].
The computation ends in state 2. Since , the string ababb is accepted.
Trace for input ababa:
[0, ababa]⊢ [0, baba](reading 'a')⊢ [1, aba](reading 'b')⊢ [0, ba](reading 'a')⊢ [1, a](reading 'b')⊢ [0, \epsilon](reading 'a')
The computation ends in state 0. Since , the string ababa is rejected.
Your Turn: Practice Tracing
Now, use the DFA pictured below, which is designed to accept strings with an even number of 0s. The start state is , which is also the only accept state.
Trace the computation for the input string 1011001. Does the machine accept or reject this string? Write down the sequence of configurations.
Solution
The DFA's formal definition is:
- Start state is
- ,
- ,
Trace for 1011001:
[q_0, 1011001]⊢ [q_0, 011001](reading '1')⊢ [q_1, 11001](reading '0')⊢ [q_1, 1001](reading '1')⊢ [q_1, 001](reading '1')⊢ [q_0, 01](reading '0')⊢ [q_1, 1](reading '0')⊢ [q_1, \epsilon](reading '1')
The computation ends in state . Since , the string 1011001 is rejected. This is correct, as the string contains three 0s (an odd number).
Conclusion
In this lesson, we established the first building block in our study of computation. We explored the intuitive concept of a finite automaton and, more importantly, solidified it with a precise, formal definition.
Here are the key takeaways:
- A Deterministic Finite Automaton (DFA) is a model of a machine with finite memory, represented formally as a 5-tuple: .
- The machine's behavior is dictated by the transition function , which deterministically maps a current state and an input symbol to a single next state.
- A DFA computes by reading an input string symbol by symbol, transitioning between states. We can formally track this process using instantaneous configurations.
- A string is accepted if the machine ends in a state belonging to the set of accept states . Otherwise, it is rejected.
- The set of all strings a machine accepts is called the language of the machine, denoted .
While simple, DFAs are powerful enough to form the basis for practical tools like text search utilities (e.g., grep), network packet filters, and the lexical analyzers in compilers that tokenize source code.
In our next lesson, we will introduce a seemingly more powerful type of finite automaton: the Nondeterministic Finite Automaton (NFA). NFAs can have multiple possible next states for a single input, introducing an element of "choice." This will lead us to a fundamental question: does this added flexibility of nondeterminism allow these machines to recognize languages that DFAs cannot?