Welcome to the world of finite automata, the simplest formal model of computation. Imagine a machine with strictly limited memory, capable only of remembering its current “state” from a finite set. (Think of a traffic light: it can only be red, yellow, or green, and its next color depends only on its current color and a timer.) It reads an input string, one symbol at a time, from left to right. Based on the symbol it reads and its current state, it transitions to a new state. It has no memory of how it got there, other than what the state itself represents.

This model, despite its simplicity, is incredibly powerful and forms the basis of many real-world applications, from the lexical analysis phase of a compiler to pattern matching in a text editor. In this chapter, we will use finite automata as a gentle introduction to the core concepts of computation: configurations, computation steps, determinism, nondeterminism, and the fundamental question of what a given computational model can and cannot do.

3.1 Aims

By the end of this chapter, you will be able to:

  1. Model Simple Computations: Understand how to formally define a computation using the model of a Deterministic Finite Automaton (DFA) and apply this model to solve simple decision problems.
  2. Master DFA Design: Develop a core design strategy for building DFAs that recognize specific patterns or “languages,” focusing on the “state as memory” principle.
  3. Grasp Key Computational Concepts: Build intuition for fundamental ideas like configurations, computation steps, determinism, nondeterminism, and simulation in a simple, tangible context, providing a foundation for more complex models.
  4. Explore Nondeterminism: Learn about Nondeterministic Finite Automata (NFAs), understand their relationship to DFAs via the subset construction, and appreciate the trade-offs between expressive power and size.
  5. Prove Limitations: Learn how to formally prove that certain problems cannot be solved by finite automata using powerful techniques like the Pumping Lemma for Regular Languages and the Kolmogorov Complexity Method.

3.2 Representations of Finite Automata

At its heart, a computational model is defined by the answers to a few basic questions: What are its elementary operations? How much memory does it have? How does it get input and produce output?

For a finite automaton, memory is its most constrained aspect: it possesses no explicit memory beyond its inherent program structure. The machine cannot use variables to store data. The only information it has is its current location in the program, its current “state.”

The most intuitive way to visualize finite automata is as a directed graph where nodes are states and edges are transitions. This visual representation often provides the quickest path to understanding how a DFA works before diving into the formal definitions.

3.2.1 Formal Definition of a Deterministic Finite Automaton (DFA)

To reason about these machines precisely, we move from the graphical intuition to a formal mathematical definition.

Definition 3.1 (Deterministic Finite Automaton)

A deterministic finite automaton (DFA) is a 5-tuple , where:

  1. is a finite, non-empty set of states. These represent the machine’s limited memory.
  2. is a finite, non-empty set called the input alphabet. These are the symbols the machine can read.
  3. is the transition function. It’s a total function that takes the current state and the current input symbol and determines the unique next state. (Think of it as a rule: “IF I am in state ‘q’ AND I read symbol ‘a’, THEN I MUST go to state ‘p’”).
  4. is the start state. The state the machine begins in before processing any input.
  5. is the set of accepting states (or final states). If the machine finishes processing input in one of these states, the input word is accepted.

To define what it means for a DFA to “run” and process an input, we introduce the following concepts:

  • A configuration of a DFA is a pair , where is the current state and is the unread portion of the input. (Imagine it as a snapshot of the machine’s current situation: “where am I now, and what’s left to read?”). The initial configuration for an input is .
  • A computation step is a relation on configurations. We write if . This describes how the machine moves from one configuration to the next by reading one symbol and changing state.
  • A computation on an input is a finite sequence of computation steps starting from the initial configuration and ending in a configuration where the input is empty.
  • A DFA accepts a word if its computation on ends in an accepting state, i.e., with . Otherwise, it rejects the word.

The language accepted by a DFA M, denoted , is the set of all words that accepts. Languages that can be accepted by a DFA are called regular languages.

Definition 3.2 (Extended Transition Function)

To simplify notation and describe the state after processing an entire string, we define the extended transition function . It is defined recursively:

  1. for any state . (Processing the empty string doesn’t change the state).
  2. for any state , string , and symbol . (Process , then apply the transition for ).

Using this, the language of a DFA can be defined concisely as:

3.2.2 Designing DFAs: State as Memory

The key to designing a DFA is to determine what finite information the machine needs to remember as it reads the input. Each state effectively acts as a tiny memory cell, representing a specific property or summary of the prefix read so far. For example, a state might remember if an even or odd number of ‘0’s has been encountered, or the longest suffix of the input read so far that is also a prefix of a target pattern.

Design Strategy: The Meaning of States

  1. Identify Required Information: Determine the distinct properties or states of knowledge about the input prefix that you need to track to solve the problem (i.e., to decide whether the input belongs to the language).
  2. Assign States: Assign one unique state to each of these properties. These states collectively form the set .
  3. Define Transitions: For each state and each input symbol , determine how reading changes the property represented by . This defines the transition .
  4. Designate Start State: The start state usually represents the property of having read the empty prefix.
  5. Designate Accepting States: The set of accepting states consists of all states that represent properties corresponding to the acceptance condition of the language.

DFA to accept strings containing "001"

Let’s design a DFA for the language .

We need to remember how much of the “001” pattern we have just seen as a suffix.

  • State Meanings:
    • : The initial state. No prefix of “001” has been seen yet, or the last part seen doesn’t contribute to “001” (e.g., ends in 1).
    • : The suffix seen so far is “0”. We are looking for “01”.
    • : The suffix seen so far is “00”. We are looking for “1”.
    • : We have seen “001”. This is an accepting state, and once this pattern is found, any further input doesn’t change the acceptance outcome.
  • Transitions:
    • From :
      • If we read a 1, we are still looking for “001” from scratch. So, .
      • If we read a 0, we have “0”. Move to . So, .
    • From (suffix is “0”):
      • If we read a 0, the suffix is “00”. Move to . So, .
      • If we read a 1, the suffix is “01”. This breaks the “001” pattern that started with “0”. We effectively reset back to the state where we’ve seen nothing productive, which is . So, .
    • From (suffix is “00”):
      • If we read a 1, the pattern “001” is complete. Move to . So, .
      • If we read a 0, the suffix is “000”. This still ends in “00”, so we remain in . So, .
    • From (seen “001”):
      • Any further input ( 0 or 1) means the string still contains “001”. Stay in . So, , .
  • Start State: .
  • Accepting States: .

The resulting state diagram elegantly captures this logic.


3.3 Simulations and Closure Properties

A powerful technique in computer science is to show that one model can simulate another. We can use this idea to combine automata and prove important properties about the class of regular languages. Understanding closure properties is crucial because it tells us that if we have machines for two languages, we can build a new machine for their union, intersection, etc., without leaving the class of regular languages.

Lemma 3.2 (Closure under Set Operations)

Let and be two regular languages. Then the languages , , and are also regular.


3.4 Proofs of Nonexistence

How can we be sure that a language like is not regular? We need a way to prove that no DFA, no matter how cleverly designed, can accept it. The core limitation of a DFA is its finite memory (its states). If a string is long enough, the DFA must repeat a state, creating a loop. This observation is the key to techniques like the Pumping Lemma and the application of Kolmogorov Complexity.

Lemma 3.3

Let be an EA. Let , , such that

for a (i.e., ). Then for every there exists an , such that and lead to the same state , i.e., in particular

3.4.1 The Pumping Lemma for Regular Languages

The Pumping Lemma for Regular Languages is a fundamental tool used to prove that certain languages are not regular. At its heart, it captures the idea that any finite automaton, when processing a sufficiently long string, must eventually repeat a state. This repetition implies a loop in its computation, and anything in that loop can be “pumped” (repeated or removed) without changing whether the string is accepted.

Lemma 3.4 (The Pumping Lemma for Regular Languages)

If is a regular language, then there exists a constant (called the pumping length, which is at least the number of states in a DFA for ) such that for any string with , can be divided into three parts, , satisfying the following conditions:

  1. . (The “pumpable” part must occur within the first symbols of ).

  2. . (The middle part must not be empty, meaning there is actually a loop).

  3. For all , the string is also in . (This is the “pumping” part: we can repeat the middle segment any number of times (including zero) and the resulting word will still be in the language).

How to Use the Pumping Lemma (Proof by Contradiction):

The Pumping Lemma is primarily used to prove that a language is not regular. The procedure is as follows:

  1. Assume for Contradiction: Assume that the language is regular.
  2. Apply Pumping Lemma: By the Pumping Lemma, there must exist a pumping length .
  3. Choose a “Clever” String: Select a specific word such that . This choice is critical and must be strategic, often picking a word that highlights the “non-regular” property (e.g., for ).
  4. Consider All Decompositions: Show that for all possible ways to decompose into that satisfy conditions (1) and (2) of the Pumping Lemma ( and ).
  5. Find a Contradiction: For each valid decomposition, find at least one value of for which the “pumped” string is not in .
  6. Conclude: Since we found a contradiction to the Pumping Lemma, our initial assumption that is regular must be false. Therefore, is not a regular language.

Proving is Not Regular Using Lemma 3.3

Intuitively, should be hard for any DFA because a DFA would need to “count” the number of zeros to ensure it matches the number of ones. However, a DFA has a fixed, finite number of states, meaning it cannot count arbitrarily high. We can formalize this intuition using Lemma 3.3.

  1. Assume for Contradiction: Assume that is regular.
  2. DFA Existence: Then there exists a DFA that accepts . Let be the number of states in .
  3. Consider a Set of Words: Consider the words: .
  4. Apply Pigeonhole Principle: When processes these words, it must end in some state after reading each word. Since there are words and only states, by the Pigeonhole Principle, there must exist two distinct words and (where ) such that ends in the same state after reading them. That is, for some state .
  5. Apply Lemma 3.3: According to Lemma 3.3, if , then for any suffix , it must hold that .
  6. Find a Contradiction: Let’s choose a specific suffix .
    • Consider the word . This word is clearly in by definition.
    • Now consider the word . Since , the number of zeros () is strictly greater than the number of ones (). Therefore, .
  7. Contradiction: We have but , which contradicts the conclusion from Lemma 3.3 that .
  8. Conclusion: Our initial assumption that is regular must be false. Therefore, is not a regular language.

3.4.2 Proving Non-Regularity using Kolmogorov Complexity

Another powerful method for proving that a language is not regular stems from Kolmogorov complexity. Regular languages are processed by finite automata, which have finite memory. This implies that regular languages cannot “count” arbitrarily high or store unbounded information about the input prefix. Kolmogorov complexity provides a formal framework for this intuition.

Theorem 3.1 (Kolmogorov Complexity and Regular Languages)

If is a regular language over , then there exists a constant such that for every , the Kolmogorov complexity of is bounded:

where is the -th word in (the sublanguage consisting of suffixes such that (for fixed prefix ) is in ), ordered canonically.

How to Use Kolmogorov Complexity to Prove Non-Regularity:

This method also proceeds by contradiction:

  1. Assume for Contradiction: Assume the language is regular.
  2. Apply Theorem 3.1: Choose a sequence of prefixes and consider the corresponding languages .
  3. Find a Contradiction: Show that for some , its Kolmogorov complexity grows faster than (where is the canonical index of ), thus contradicting Theorem 3.1. This is often done by choosing to be an incompressible string or one whose information content is provably high.

Proving is Not Regular Using Kolmogorov Complexity

  1. Assume is regular. By Theorem 3.1, there exists a constant such that for the -th word in .
  2. Consider the prefix for an arbitrary large . The language . For to be in , must be . (Since is the only word in that starts with ).
  3. So, . The 1st word () in in canonical order.
  4. According to Theorem 3.1, .
  5. However, we know that for sufficiently large must be approximately (or at least itself for random strings). More precisely, the string can be generated by a program that prints ‘1’ times, and the shortest such program would have length approximately . So .
  6. Comparing with : for sufficiently large , . This is a contradiction.
  7. Therefore, is not regular.

This method often feels more intuitive for some problems, especially those involving “counting” or “matching” patterns where finite memory proves insufficient.


3.5 Nondeterminism

What if we allow a machine to have multiple possible next states for the same input symbol? Or even to change state without reading any input at all (known as -transitions or -transitions)? This is the concept of nondeterminism. (Imagine the machine “guessing” the correct path to an accepting state, or exploring all paths simultaneously.)

3.5.1 Formal Definition of a Nondeterministic Finite Automaton (NFA)

Definition 3.3 (Nondeterministic Finite Automaton)

A nondeterministic finite automaton (NFA) is a 5-tuple , where all components are defined similarly to a DFA, except for the transition function:

  1. is a finite, non-empty set of states.
  2. is a finite, non-empty set called the input alphabet.
  3. (or for NFAs with -transitions) is the transition function. Here, is the power set of , meaning the transition function maps to a set of possible next states.
  4. is the start state.
  5. is the set of accepting states.

An NFA accepts a word if there is at least one path of transitions from the start state to an accepting state that consumes the entire word . If all possible computation paths for a word lead to a non-accepting state or get stuck (no transition defined), the word is rejected.

NFA for strings ending with "01"

Let’s design an NFA for . This NFA can “guess” when it is about to see the “01” suffix.

  • : Initial state. Can stay here on any input, or nondeterministically guess that a 0 is the start of the “01” suffix.

    • (can stay in or move to if it sees 0).
    • (must stay in if it sees 1).
  • : We have seen a 0 that might be the start of “01”. We are looking for 1.

    • (move to accepting state if 1 is seen).
    • (if 0 is seen, we still have a 0, so can stay in ).
  • : Accepting state. We have seen “01”. This state is only reached at the end of the word for acceptance.

  • Start State: .

  • Accepting States: .

This NFA is simpler than a DFA for the same language. For example, a DFA would need to remember if it saw a 0, 10, or 110, etc.

3.5.2 Equivalence of NFAs and DFAs (Subset Construction)

Surprisingly, nondeterminism does not add any fundamental computational power to finite automata. Any language that can be recognized by an NFA can also be recognized by an equivalent DFA. This is a crucial result: it means NFAs are a convenient tool for designing automata due to their flexibility, while DFAs are what we actually implement for unambiguous execution.

Theorem 3.2 (Equivalence of NFAs and DFAs)

For every NFA , there exists an equivalent DFA such that .


3.6 Summary

  • Finite Automata are fundamental, simple computational models with finite memory, defined by a set of states and transitions based on input symbols.
  • DFAs are deterministic, meaning for any given state and input symbol, there’s always a single, unique next state. Their design relies on encoding necessary information about the input’s history into the states.
  • Regular Languages are the class of languages recognized by DFAs (and NFAs). This class is robustly closed under common set operations like union, intersection, and complement, provable using constructive techniques like the product construction.
  • The Pumping Lemma is a critical theoretical tool for proving that a language is not regular. It highlights the finite memory limitation of DFAs by showing that sufficiently long strings in a regular language must contain a “pumpable” segment.
  • The Kolmogorov Complexity Method offers an alternative, often more intuitive, approach to proving non-regularity. It exploits the fact that regular languages cannot “compress” or “count” arbitrary amounts of information about their words or their suffixes.
  • NFAs introduce nondeterminism, allowing multiple possible transitions from a state for a given input, or even -transitions. While NFAs can be significantly more concise and easier to design for certain languages, they do not increase the fundamental computational power beyond DFAs.
  • The Subset Construction (or power set construction) provides a constructive proof of the equivalence of NFAs and DFAs by showing how to build a deterministic machine that simulates all possible paths of a nondeterministic one. This construction, however, can lead to an exponential increase in the number of states.

Previous Chapter: Chapter 2 - Alphabets, Words, Languages, and Problem Representation Next Up: Chapter 4 - Turing Machines

Exercises

Exercise 3.1 (DFA Design)

Design a DFA that accepts the language (i.e., the length of is even).

Exercise 3.2 (DFA Design)

Design a DFA that accepts strings over representing binary numbers divisible by 3.

Exercise 3.3 (Closure Properties - Product Construction)

Let and . Design a DFA that accepts .

Exercise 3.4 (Pumping Lemma)

Use the Pumping Lemma to prove that is not regular.

Exercise 3.5 (Kolmogorov Complexity for Non-Regularity)

Use the Kolmogorov Complexity Method to prove that is not regular. (A palindrome reads the same forwards and backwards, e.g., 0110, 101).

Exercise 3.6 (NFA Design)

Design an NFA that accepts strings over containing 010 as a subword. Provide its formal definition and a state diagram.

Exercise 3.7 (Subset Construction)

Convert the NFA from Exercise 3.6 (strings containing 010) into an equivalent DFA using the Subset Construction algorithm.

Exercise 3.8 (Pumping Lemma)

Use the Pumping Lemma to prove that is not regular.


Key Takeaways

  • Finite Automata are Memory-Limited: DFAs and NFAs represent computation with finite, fixed memory (states). This is their defining characteristic and limitation.
  • DFAs are Formal Language Processors: They provide a precise mathematical model for recognizing regular languages, forming the basis of lexical analysis and simple pattern matching.
  • State as Memory: The art of DFA design lies in encoding all necessary information about the input prefix into the finite set of states.
  • Closure Properties: Regular languages are closed under fundamental set operations (union, intersection, complement), meaning applying these operations to regular languages always yields another regular language. This is often proven constructively using techniques like the product construction.
  • Proving Non-Regularity: The Pumping Lemma and Kolmogorov Complexity provide powerful formal methods to demonstrate that a language cannot be recognized by any finite automaton, thereby establishing limits of computational models.
  • Nondeterminism’s Role: NFAs simplify language description by allowing multiple transitions. Crucially, they do not increase the computational power beyond DFAs; any NFA can be converted to an equivalent DFA (via Subset Construction), though this may involve an exponential increase in states. This highlights that nondeterminism can offer conciseness, but not fundamental power, for this class of automata.