Regular Languages Equivalences
Regular Languages and Deterministic Finite Automata
Equivalent Ways to Describe Regular Languages
A regular language can be characterized in several mathematically equivalent ways. These descriptions may look very different, but they all recognize exactly the same class of languages.
Different representations make different properties easier to see:
A finite-state automaton makes the machine’s states and transitions visible.
A transition function gives an algorithmic or tabular description of the same behavior.
A graph interpretation treats accepted words as paths through a directed graph.
A program interpretation views the automaton as a program with a fixed amount of memory.
Because these perspectives are equivalent, a property that is difficult to understand in one representation may become obvious in another.
Finite-State Automata as Machines
A finite-state automaton is an abstract machine that reads an input string one symbol at a time.
It can be imagined as having:
A keyboard containing symbols from a finite alphabet.
A limited internal memory represented by a finite set of states.
An indicator light that determines whether the input is accepted.
The machine operates as follows:
It begins in a designated start state.
It reads the input one character at a time.
Each character causes the machine to change state according to fixed rules.
After the entire input has been read, the machine checks its current state.
If the current state is an accepting state, the indicator light is on and the input is accepted.
Otherwise, the input is rejected.
The machine does not change while waiting for input. It has no internal clock and does not receive information from external sources. Its behavior changes only when it reads another input symbol.
Determinism
A deterministic finite automaton, or DFA, has exactly one possible next state for every combination of:
Current state
Input symbol
There is no randomness or uncertainty. If the machine is in state q and reads symbol a, the next state is completely determined.
A DFA always has a uniquely defined computation for every input string.
The term deterministic emphasizes that the same input, when processed from the same initial state, always produces the same result.
The Meaning of “Finite”
The word finite refers to the machine’s memory.
A finite-state automaton has only finitely many possible internal states. Consequently, it cannot remember an arbitrarily long input in complete detail.
Suppose a machine has n possible states and reads a string longer than n symbols. By the pigeonhole principle, the machine must eventually revisit a state it has already occupied.
When a state is revisited, the machine has returned to exactly the same internal configuration. From that point forward, the machine responds to future input exactly as it did the first time it reached that state.
This means that the machine effectively forgets the specific history that led to the repeated state.
Consequences of Finite Memory
A finite-state automaton:
Cannot store the entire input string.
Cannot remember an unlimited counter.
Must discard information as new input arrives.
Can remember only information that can be encoded using one of its finitely many states.
Processes the input incrementally rather than saving everything for analysis at the end.
The machine can still recognize useful patterns, but only patterns that require a bounded amount of memory.
For example, a machine can remember whether it has seen an even or odd number of a particular symbol because only two memory conditions are needed. It cannot generally remember an arbitrarily large exact count.
Finite-State Automata and Turing Machines
Finite-state automata and Turing machines represent different levels of computational power.
Finite-State Automata
A finite-state automaton has:
A finite number of states.
A fixed, bounded amount of memory.
No ability to expand its memory as the input grows.
It is an abstraction of systems that must process large or continuous streams of data without storing the entire stream.
Examples of similar practical situations include:
Processing data streams.
Monitoring network traffic.
Detecting patterns in text as it arrives.
Filtering data while retaining only a small summary.
Controlling systems with a finite number of operating modes.
Turing Machines
A Turing machine is modeled as having an effectively unlimited tape. Its available memory can grow as needed during computation.
Turing machines are therefore an abstraction of computers whose memory is sufficiently large compared with the data being processed.
A real computer does not literally have infinite memory. However, the unlimited-tape model is useful because it captures computations in which the available memory is treated as unbounded.
Real Computers Have Finite States
Every physical computer actually has finite memory. If a computer has m bits of memory, then its memory alone has at most
possible configurations.
Thus, in a strict physical sense, a computer is closer to a finite-state machine than to a true Turing machine. However:
For small inputs, the computer may behave as though it has unlimited memory.
For sufficiently large inputs, its finite memory becomes significant.
Eventually, it must either reject additional data, reuse memory, or discard information.
This illustrates a duality:
Turing machines: effectively unlimited memory.
Finite-state automata: explicitly limited memory.
State Diagrams
A DFA is commonly represented using a state diagram, a directed graph that displays:
States as circles.
Transitions as directed arrows.
Input symbols as labels on arrows.
The start state as a state with an incoming arrow from outside the diagram.
Accepting states as double-circled states.
Consider a DFA with the states:
State 0
State 1
State 2
The input alphabet is:
Each arrow describes what happens when a particular symbol is read.
For example:
If the machine is in state 1 and reads c, it moves to state 2.
If the machine is in state 0 and reads b, it moves according to the arrow labeled b.
The machine starts in state 0.
State 1 is accepting because it is double-circled.
One Transition for Each Input Symbol
For a DFA, each state must have exactly one defined outgoing transition for each symbol in the alphabet.
For instance, if the alphabet is {a,b,c}, then from state 1 there must be:
One transition labeled a.
One transition labeled b.
One transition labeled c.
There cannot be two different possible destinations for the same state-symbol pair. A rule such as “from state 1, reading a might lead to state 0 or state 2” would not be deterministic.
Resetting the Machine
Before processing a new input word, the automaton is reset to its start state.
This reset is important because the machine should evaluate each word independently. The answer for a word must not depend on which words were processed previously.
For the example automaton:
Every input begins in state 0.
The machine processes the entire word from that starting point.
The final state determines whether the word is accepted.
Unlike a desktop computer, the automaton does not preserve arbitrary memory between separate inputs.
Accepting States
An accepting state is a state in which the machine accepts the input if the input ends there.
Accepting states are represented by double circles in a state diagram.
A DFA may have:
No accepting states.
One accepting state.
Several accepting states.
All states as accepting states.
The set of accepting states can be any subset of the total state set.
Acceptance depends only on the state reached after the final input symbol has been processed. A word may pass through an accepting state during its computation but still be rejected if it ends in a nonaccepting state.
Running an Example Automaton
The example automaton has:
Start state: 0
Accepting state: 1
Trap state: 2
Some computations illustrate how the machine works.
Input b
The machine begins in state 0.
Reading
breturns the machine to state 0.The input ends in state 0.
State 0 is not accepting.
Therefore, b is rejected.
Input ba
The machine processes the symbols in order:
bkeeps the machine in state 0.amoves the machine from state 0 to state 1.
The input ends in accepting state 1, so ba is accepted.
Input baa
Continuing from the computation above:
b: state 0→0First
a: state 0→1Second
a: state 1→0
The input ends in state 0, so baa is rejected.
Input baaba
The machine processes:
b: state 0→0a: state 0→1a: state 1→0b: state 0→0a: state 0→1
The input ends in state 1, so baaba is accepted.
Input bacba
If the machine reads a c, it moves to state 2.
For bacba:
b: the machine remains in the nonaccepting portion of the diagram.a: the machine changes state.c: the machine moves to state 2.banda: the machine remains trapped in state 2.
Because state 2 cannot lead to the accepting state, the word is rejected.
Trap States
A trap state is a state from which acceptance can no longer be reached. Once the machine enters such a state, all future input leaves it in a rejecting condition.
In this example, state 2 is a trap state:
A
csends the machine to state 2.Once in state 2, the machine stays there.
State 2 is not accepting.
The Language Recognized by the Example
The example DFA accepts exactly the strings satisfying both conditions:
The string contains an odd number of
asymbols.The string contains no
csymbols.
The symbol b does not affect acceptance.
Why the Machine Tracks the Number of a Symbols
The machine uses two states to track the parity of the number of a symbols:
State 0: an even number of
asymbols has been read.State 1: an odd number of
asymbols has been read.
Each new a switches between these states:
Even to odd.
Odd to even.
Thus, after an odd number of a symbols, the machine is in state 1.
Why b Does Not Matter
Reading b leaves the machine’s state unchanged. Therefore, b symbols do not affect whether the number of a symbols is even or odd.
The machine effectively ignores all b symbols.
Why c Causes Rejection
Reading c moves the machine to state 2, which is a rejecting trap state. Therefore, any word containing even one c is rejected.
The language recognized by the DFA can be described as:
The set of all strings over {a,b,c} that contain no
cand contain an odd number ofasymbols.
Because a DFA recognizes this set of strings, the set is a regular language.
Alphabets, Words, and Languages
Alphabet
An alphabet is a finite set of symbols.
It is usually denoted by the Greek letter Σ.
For the example:
The symbols do not need to be letters from an ordinary human language. They could instead represent:
Digits.
Machine instructions.
Network events.
Logical symbols.
Tokens in a programming language.
Word
A word is a finite string of symbols from an alphabet.
Examples over {a,b,c} include:
abbbaabaccab
In this context, word has a mathematical meaning. It does not have to be an English word or have any linguistic meaning.
Language
A language is any set of words over an alphabet.
For example, the set
could form a language if all of its elements are strings over the chosen alphabet.
A language is regular if some deterministic finite automaton accepts exactly the words in that language.
A language is regular precisely when it can be recognized by a finite-state automaton.
Transition Functions
A state diagram is useful for visualizing a DFA, but a transition function gives a more formal and algorithmic description.
The transition function is usually denoted by the lowercase Greek letter δ.
It takes two inputs:
The current state.
The next input symbol.
It returns:
The state that the machine enters after reading that symbol.
Formally, for a DFA with state set Q and alphabet Σ:
For example:
means that if the machine is currently in state 1 and reads the symbol c, it moves to state 2.
Transition Tables
The transition function can be represented as a table.
The rows correspond to current states, and the columns correspond to input symbols. Each entry specifies the next state.
A transition table is often more convenient than a graph when:
The automaton has many states.
The automaton is being implemented in software.
The transition rules must be systematically examined.
An algorithm needs direct access to the next-state information.
Separate Transition Functions for Each Symbol
Instead of using one function with two inputs, the transitions can be separated into one function for each input symbol.
For each symbol x∈Σ, define a function:
where δx(q) is the state reached from q after reading x.
For the example automaton:
The Function for a
The symbol a switches the machine between states 0 and 1 while leaving state 2 unchanged:
δa(0)=1
δa(1)=0
δa(2)=2
Thus, a changes the parity-tracking state.
The Function for b
The symbol b acts as the identity function:
δb(0)=0
δb(1)=1
δb(2)=2
In general:
for every state q.
The Function for c
The symbol c sends every state to state 2:
This explains why c acts as an immediate rejection symbol.
Two Equivalent Transition Perspectives
The two descriptions are equivalent:
One function δ(q,x) takes both the current state and input symbol.
A collection of functions δx(q) provides one state-to-state function for each symbol.
The first form emphasizes the complete transition rule. The second form emphasizes the effect of each individual input symbol.
Formal Definition of a DFA
A deterministic finite automaton is commonly specified as a five-part tuple:
Each component has a specific role.
Alphabet Σ
Σ is the finite set of permitted input symbols.
For the example:
State Set Q
Q is the finite set of internal states.
For the example:
Start State q0
q0 is the state in which the automaton begins processing every input.
For the example:
Transition Function δ
δ specifies the next state for every current-state and input-symbol combination:
Accepting-State Set F
F is the set of accepting states. It must be a subset of Q:
For the example:
The set F may contain any number of states, including zero or all of the states.
Three Perspectives on a DFA
A DFA can be understood in several complementary ways.
A Collection of Functions
The transition rules can be treated as functions from the finite state set to itself.
Each input symbol determines one such function.
Composing these functions corresponds to reading a sequence of input symbols.
The final output state determines acceptance.
This perspective is useful for algebraic and functional reasoning.
A Directed Graph
The state diagram is a directed graph:
Vertices represent states.
Edges represent transitions.
Edge labels represent input symbols.
The start state identifies where paths begin.
Accepting states identify where accepting paths may end.
Every input word corresponds to a path through the graph. A word is accepted exactly when its path begins at the start state and ends at an accepting state.
A Computer Program
A DFA can also be viewed as a program with a fixed amount of memory:
Initialize the memory to represent the start state.
Read the input one symbol at a time.
Update the memory according to the current symbol.
After the input ends, return true or false according to the final memory state.
These are not different machines. They are different ways of describing the same machine.
DFA-Like Computer Programs
A program can resemble a finite-state automaton when it has:
A fixed, bounded amount of memory.
A loop that reads input one item at a time.
A fixed update rule for each input item.
A final yes-or-no decision based on the stored memory.
A typical streaming program has three conceptual parts.
1. Memory Declaration
The program declares variables and data structures.
If the declarations permit only finitely many possible configurations, then the program’s memory can be viewed as a finite set of states.
For example:
A Boolean variable has two possible values.
A bounded integer has finitely many possible values.
A fixed-size array of bounded integers also has finitely many configurations.
2. Initialization
The program initializes its variables before reading the input.
This corresponds to placing the automaton in its start state.
3. Input-Processing Loop
The program reads characters or data items repeatedly until it reaches the end of the input, often represented by an end-of-file condition.
For each input item, it updates its memory. This is analogous to applying the DFA’s transition function.
After the input ends, the program examines its memory and returns a Boolean result:
trueif the input should be accepted.falseif the input should be rejected.
Fixed Memory and Its Limits in Programs
Even ordinary programming-language data types have finite ranges.
For example, a fixed-size integer can represent only a bounded set of values. If a program attempts to count an input quantity larger than the integer’s maximum representable value, the count may become incorrect.
A fixed-size array also has only finitely many possible configurations. Therefore, if all memory is fixed and bounded, the program has only finitely many possible memory states.
This does not mean that every practical program is best analyzed as a DFA. A program may dynamically allocate additional memory or use data structures whose size grows with the input. Such programs are not limited to a fixed finite set of memory configurations.
The key question is:
Does the program’s relevant memory remain bounded independently of the input length?
If so, the program may fundamentally behave like a finite-state automaton.
Streaming Computation
Finite-state automata are especially useful for understanding streaming computation.
A streaming system:
Receives data incrementally.
Cannot necessarily store the entire input.
Maintains a compact summary of what has been seen.
Discards information that is no longer needed.
Makes a decision based on the summary at the end.
The states represent the summaries that the system retains.
For the example language, the machine needs to remember only:
Whether the number of
asymbols seen so far is even or odd.Whether a
chas appeared.
That information can be represented with only three states.
Key Relationships
The central relationships are:
A DFA is a finite-memory machine that processes input one symbol at a time.
A state diagram visualizes the DFA’s states and transitions.
A transition function formalizes the same transitions.
A path through the diagram represents the computation on an input word.
An accepting path begins at the start state and ends in an accepting state.
A regular language is exactly a language recognized by some DFA.
A fixed-memory program can often be interpreted as a DFA.
Finite memory allows machines to recognize patterns that require bounded information but prevents them from storing arbitrary input histories.
Regular languages are the languages that can be recognized using a finite amount of memory and deterministic, symbol-by-symbol processing.

Ask anything
We've read this whole study set, so questions about it get the best answers.