Finite State Automata (DFA)
We aim to develop a mathematical model of computers based on the following observations:
- A computer has internal states.
- It processes inputs from a finite alphabet.
- 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 , where
- is a finite set called the states,
- is a finite set called the alphabet,
- is a transition function,
- is the start state,
- is the set of accpet states.
Computation. Let be a finite automaton and let be a string where each . Then accepts if a sequence of states exists with three conditions:
- ,
- , ,
- .
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 is the set of all strings that machine accepts, we say that is the language of machine and write . We say that recognizes or that accepts .
Regular Language. A regular language is the language that can be recognized by some finite state automaton.
Set Operations. Let and be languages. We define the regular operations union, concatenation, and star as follows:
- Union: .
- Concatenation: .
- Star: .
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 , where
- is a finite set called the states,
- is a finite set called the alphabet,
- is a transition function, where is the power set of ,
- is the start state,
- is the set of accpet states.
Computation. Let be a finite automaton and let be a string where each . Then accepts if a sequence of states exists with three conditions:
- ,
- , ,
- .
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 , there is a number where, for every of length at least , can be devided into three pieces , such that
- , for every ,
- , and
- .
Regular Expression
Regular expression is a popular application of NFA.
Definition. Say that is a regular expression of an alphabet if is
- for some ,
- ,
- ,
- , where are regular expressions,
- , where are regular expressions,
- , where is a regular expressions.
When we want to distinguish between a regular expression and the language that it describes, we write to be the language of .
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 . 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 , where
- is a finite set called the states,
- is a finite set called the alphabet,
- is the start state,
- is the set of accpet states,
- is a transition function, where is the collection of all regular expressions over .
Computation. Let be a GNFA and let be a string where each . Then accepts if it can be rewritten as , where each , such that there exists a sequence of states with three conditions:
- ,
- each , where is the regular expression on the arrow from to ,
- .
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.