Finite State Automata (DFA)

We aim to develop a mathematical model of computers based on the following observations:

  1. A computer has internal states.
  2. It processes inputs from a finite alphabet.
  3. Its state transitions are determined by the current state and input.

When the number of internal states is finite, the computer can be modeled as a finite-state automaton.

Definition. A finite state automaton is a five-tuple ⟨Q,Σ,δ,S,F⟩\langle Q, \Sigma , \delta, S, F \rangle, where

  • QQ is a finite set called the states,
  • Σ\Sigma is a finite set called the alphabet,
  • δ:Q×Σ→Q\delta : Q \times \Sigma \to Q is a transition function,
  • S∈QS \in Q is the start state,
  • F⊆QF \subseteq Q is the set of accpet states.

Computation. Let M=⟨Q,Σ,δ,S,F⟩M = \langle Q, \Sigma , \delta, S, F \rangle be a finite automaton and let w=w1w2…wnw = w_1 w_2 \ldots w_n be a string where each wi∈Σw_i \in \Sigma. Then MM accepts ww if a sequence of states r0,r1,…,rn∈Qr_0, r_1, \ldots, r_n \in Q exists with three conditions:

  1. r0=Sr_0 = S,
  2. δ(ri,wi+1)=ri+1\delta(r_i, w_{i + 1}) = r_{i + 1}, ∀ i∈{0,…,n−1}\forall \, i \in \{ 0, \ldots, n - 1 \},
  3. rn∈Fr_n \in F.

Under these definitions, a finite state automaton is a computer designed for a specific task. The "algorithm" for performing this task is hard-wired into the computer, encoded in its internal states and transition function.

What can be computed by the model?

A fundamental question is: what can this mathematical model compute? We use set operations to explore the computational capabilities of this model.

Language. If AA is the set of all strings that machine MM accepts, we say that AA is the language of machine MM and write L(M)=AL(M) = A. We say that MM recognizes AA or that MM accepts AA.

Regular Language. A regular language is the language that can be recognized by some finite state automaton.

Set Operations. Let AA and BB be languages. We define the regular operations union, concatenation, and star as follows:

  • Union: A∪B={x∣x∈A or x∈B}A \cup B = \{ x \mid x \in A \text{ or } x \in B \}.
  • Concatenation: A∘B={xy∣x∈A and y∈B}A \circ B = \{ x y \mid x \in A \text{ and } y \in B \}.
  • Star: A∗={x1x2…xk∣k≥0 and each xi∈A}A^∗ = \{ x_1 x_2 \ldots x_k \mid k \ge 0 \text{ and each } x_i \in A \}.

A collection of strings is called a regular language if it can be "computed" or "recognized" by an automaton.

The following theorem states that if two collections of strings are regular languages, then there exist automata that can compute their union, intersection, and concatenation. Moreover, if a collection of strings is a regular language, there exists an automaton that can compute its Kleene star.

Theorem. The class of regular language is closed under union, intersection, concatenation and star operations.

The theorem for union and intersection operations can be easily proven based on DFAs. For concatenation and star operations, the proof is simpler under an equivalent model.

Nondeterministic Finite State Automata(NFA)

Definition. A nondeterministic finite state automaton is a five-tuple ⟨Q,Σ,δ,S,F⟩\langle Q, \Sigma , \delta, S, F \rangle, where

  • QQ is a finite set called the states,
  • Σ\Sigma is a finite set called the alphabet,
  • δ:Q×Σϵ→P(Q)\delta : Q \times \Sigma_{\epsilon} \to P(Q) is a transition function, where P(Q)P(Q) is the power set of QQ,
  • S∈QS \in Q is the start state,
  • F⊆QF \subseteq Q is the set of accpet states.

Computation. Let M=⟨Q,Σ,δ,S,F⟩M = \langle Q, \Sigma , \delta, S, F \rangle be a finite automaton and let w=w1w2…wnw = w_1 w_2 \ldots w_n be a string where each wi∈Σϵw_i \in \Sigma_\epsilon. Then MM accepts ww if a sequence of states r0,r1,…,rn∈Qr_0, r_1, \ldots, r_n \in Q exists with three conditions:

  1. r0=Sr_0 = S,
  2. ri+1∈δ(ri,wi+1)r_{i + 1} \in \delta(r_i, w_{i + 1}), ∀ i∈{0,…,n−1}\forall \, i \in \{ 0, \ldots, n - 1 \},
  3. rn∈Fr_n \in F.

Theorem. Every NFA has an equivalent DFA.

What can't be computed by the model?

To understand the power of finite automata, it is essential to also recognize their limitations. The pumping lemma provides a tool for proving that a language cannot be recognized by any finite automaton.

Theorem (Pumping Lemma). For every regular language LL, there is a number pp where, for every ω∈L\omega \in L of length at least pp, ω\omega can be devided into three pieces ω=xyz\omega = xyz, such that

  • xyiz∈Lxy^iz \in L, for every i≥0i \ge 0,
  • ∣xy∣≤p|xy| \le p, and
  • ∣y∣>0|y| > 0. ​ ​ ​ ​

Regular Expression

Regular expression is a popular application of NFA.

Definition. Say that RR is a regular expression of an alphabet Σ\Sigma if RR is

  1. {a}\{ a \} for some a∈Σa \in \Sigma,
  2. {ϵ}\{ \epsilon \},
  3. ∅\varnothing,
  4. (R1∪R2)(R_1 \cup R_2), where R1,R2R_1, R_2 are regular expressions,
  5. (R1∘R2)(R_1 \circ R_2), where R1,R2R_1, R_2 are regular expressions,
  6. (R1∗)(R_1^*), where R1R_1 is a regular expressions.

When we want to distinguish between a regular expression RR and the language that it describes, we write L(R)L(R) to be the language of RR.

Theorem. Every regular language has a regular expression that describes it.

Hint: Proving that a DFA can be converted into a regular expression is via a model called generalized nondeterministic finite automaton, GNFA, which is simply nondeterministic finite automaton wherein the transition arrows may have any regular expressions as labels, instead of only members of the alphabet or ϵ\epsilon. We focus on a special form, where there is one arrow goes from every state to every other state and also from each state to itself, except that

  • The start state has no arrows coming in from any other state.

  • There is only a single accept state which is not the same as the start state, and it has no arrows going to any other state.

The formal definitions are given below.

Definition. A generalized nondeterministic finite state automaton is a five-tuple ⟨Q,Σ,δ,S,F⟩\langle Q, \Sigma , \delta, S, F \rangle, where

  • QQ is a finite set called the states,
  • Σ\Sigma is a finite set called the alphabet,
  • S∈QS \in Q is the start state,
  • A∈QA \in Q is the set of accpet states,
  • δ:(Q−F)×(Q−A)→R\delta : (Q - F) \times (Q - A) \to \mathcal{R} is a transition function, where R\mathcal{R} is the collection of all regular expressions over Σ\Sigma.

Computation. Let M=⟨Q,Σ,δ,S,F⟩M = \langle Q, \Sigma , \delta, S, F \rangle be a GNFA and let w=w1w2…wmw = w_1 w_2 \ldots w_m be a string where each wi∈Σϵw_i \in \Sigma_\epsilon. Then MM accepts ww if it can be rewritten as w=s1s2…,snw = s_1 s_2 \ldots, s_n, where each si∈Σ∗s_i \in \Sigma^*, such that there exists a sequence of states r0,r1,…,rn∈Qr_0, r_1, \ldots, r_n \in Q with three conditions:

  1. r0=Sr_0 = S,
  2. each si∈L(Ri)s_i \in L(R_i), where Ri=δ(ri,ri+1)R_i = \delta(r_i, r_{i + 1}) is the regular expression on the arrow from rir_i to ri+1r_{i + 1},
  3. rn=Ar_n = A.

Every DFA can be transformed into a GNFA. Then, we iteratively remove states from the GNFA, updating the regular expressions on the arrows at each step while preserving the accepted language. This process continues until only two states remain, and the regular expression on the final arrow represents the desired result.

Reference

[1] M. Sipser, Introduction to the theory of computation, Third edition, Cengage Learning, 2013.