Regular languages
A deterministic finite automaton (DFA) is a tuple $D = (Q, Σ, δ, q_0, F)$ where
-
$Q$ is a non-empty finite set (of states);
-
$Σ$ is a non-empty finite set (the alphabet);
-
$δ: Q\times Σ\to Q$ (the transition function);
-
$q_0 \in Q$ (the start state); and
-
$F\subseteq Q$ a subset (of accepting states).
Extend $δ$ to $\hat δ: Q\times{}$$Σ^\ast$${}\to Q$ by $$ \begin{align*} \hat δ(q, ε) = q, \qquad \hat δ(q, wa) = δ(\hat δ(q, w), a). \end{align*} $$
For every word $w=a_0 a_1 \ldots a_n\in \mathbb{W}$, the state sequence of the computation is $$ \begin{alignat}{1} q_0 & &&= \hat δ(q_0, ε), \\ q_1 &= δ(q_0, a_0) &&= \hat δ(q_0, a_0), \\ q_2 &= δ(q_1, a_1) &&= \hat δ(q_0, a_0 a_1), \\ \vdots \\ q_{n+1} &= δ(q_n, a_n) &&= \hat δ(q_0, a_0 a_1 \ldots a_n) = \hat δ(q_0, w). \end{alignat} $$
The language of $D$ is $$ \begin{align*} \mathcal{L}(D) = \sb{w\in Σ^\ast}{\hat δ(q_0, w) \in F}. \end{align*} $$
A language $L\subseteq Σ^\ast$ is regular if it is accepted by a DFA.
We can represent a DFA using a transition diagram
or a transition table
![]()
A nondeterministic finite automaton (NFA) is a tuple $N = (Q, Σ, δ, q_0, F)$ where
-
$Q$ is a non-empty finite set (of states);
-
$Σ$ is a non-empty finite set (the alphabet);
-
$δ: Q\times Σ\to \mathcal{P}(Q)$ (the transition function);
-
$q_0 \in Q$ (the start state); and
-
$F\subseteq Q$ a subset (of accepting states).
Extend $δ$ to $\hat δ: Q\times Σ^\ast\to \mathcal{P}(Q)$ by $$ \begin{align*} \hat δ(q,ε) = \set{q}, \qquad \hat δ(q, wa) = \bigcup \sb{δ(p,a)}{p\in \hat δ(q,w)}. \end{align*} $$
For every word $w=a_0 a_1 \ldots a_n\in Σ^\ast$, the state set sequence is $$ \begin{align*} X_0 &= \set{q_0}, \qquad X_{i+1} = \bigcup \sb{δ(p,a_i)}{p\in X_i}. \end{align*} $$
The language accepted by $N$ is $$ \begin{align*} \mathcal{L}(N) = \sb{w\in Σ^\ast}{\hat δ(q_0, w) \cap F \neq \emptyset}. \end{align*} $$
An $ε$-nondeterministic finite automaton ($ε$-NFA) is a tuple $E = (Q, Σ, δ, q_0, F)$ where
-
$Q$ is a non-empty finite set (of states);
-
$Σ$ is a non-empty finite set (the alphabet);
-
$δ: Q\times (Σ\times \set{ε})\to \mathcal{P}(Q)$ (the transition function);
-
$q_0 \in Q$ (the start state); and
-
$F\subseteq Q$ a subset (of accepting states).
Let the $ε$-closure of a set $S\subseteq Q$ be $$ \begin{align*} \op{ecl}(S) := \bigcup_{n=0}^{\infty} S_n \qquad \text{where }S_0 := S,\; S_{n+1} = S_n \cup \bigcup_{q\in S_{n}} δ(q, ε). \end{align*} $$
Extend $δ$ to $\hat δ: Q \times Σ^\ast\to \mathcal{P}(Q)$ by $$ \begin{align*} \hat δ(q, ε) := \op{ecl}(q), \qquad \hat δ(q, wa) := \op{ecl}\left(\bigcup \sb{δ(p, a)}{p\in \hat δ(q, w)}\right). \end{align*} $$ The language accepted by $E$ is $$ \begin{align*} \mathcal{L}(N) := \sb{w\in Σ^\ast}{\hat δ(q_0, w)\cap F \neq \emptyset}. \end{align*} $$
Let $D = (Σ, Q, δ, q_0, F)$ and $D' = (Σ, Q', δ', q_0', F')$ be deterministic automata over the same alphabet $Σ$.
A map $f: Q \to Q'$ is a homomorphism from $D$ to $D'$ if
-
$f(δ(q, a)) = δ'(f(q), a)$ for all $q\in Q$ and $a\in Σ$;
-
$f(q_0) = q_0'$; and
-
for any $q\in Q,$ we have $q\in F$ iff $f(q) \in F'$.
$f: Q\to Q'$ is an isomorphism if $f$ is a bijective homomorphism.
By induction, we also have $f(\hat δ(q), w) = \hat δ'(f(q), w)$ for any $q\in Q$, $w\in Σ^\ast$.
Let $D$ and $D'$ be deterministic automata.
If $D$ and $D'$ are homomorphic, then $\mathcal{L}(D) = \mathcal{L}(D')$.
Let $L\subseteq Σ^\ast$ be a language. We say $L$ _satisfies the (regular) pumping lemma with pumping number $n$_ if for every word $w\in L$ with length $|w|\geq n$, there exists words $x,y,z\in Σ^\ast$ such that
-
$w = xyz$;
-
$|y|>0$;
-
$|xy|\leq n$;
-
$xy^k z\in L$ for all $k=0,1,2,\ldots$.
For every regular language $L$, there exists some $n$ such that $L$ satisfies the regular pumping lemma with pumping number $n$.
Let $L\subseteq Σ^\ast$ be a language.
The Kleene plus operation is $$ \begin{align*} L^+ = \sb{w\in Σ^\ast}{\exists w_0, \ldots, w_n\in L \text{ such that } w = w_0 \ldots w_n}, \end{align*} $$ i.e. finite concatenation of one or more elements of $L$.
The Kleene star operation is $$ \begin{align*} L^\ast = L^+ \cup \set{ε}. \end{align*} $$
Let $Σ$ be an alphabet.
Among the finite strings over the set of symbols $Σ \sqcup \set{\emptyset, ε, (, ), +, {}^* }$, we define the notion of regular expression by recursion:
-
$\emptyset$ is a regular expression;
-
$ε$ is a regular expression;
-
$(R + S)$ is a regular expression if $R,S$ are regular expressions;
-
$(RS)$ is a regular expression if $R,S$ are regular expressions;
-
$R^\ast$ is a regular expression if $R$ is a regular expression.
We usually omit unnecessary parentheses.
We associate languages to regular expressions by recursion:
-
$\mathcal{L}(\emptyset) = \emptyset$;
-
$\mathcal{L}(ε) = \set{ε}$;
-
$\mathcal{L}(a) = \set{a}$ if $a\in Σ$;
-
$\mathcal{L}(R+S) = \mathcal{L}(R) \cup \mathcal{L}(S)$;
-
$\mathcal{L}(RS) = \mathcal{L}(R) \, \mathcal{L}(S)$;
-
$\mathcal{L}(R^*) = \mathcal{L}(R)$$^*$;
For any regular expression $R$, there is a DFA $D$ such that $\mathcal{L}(R) = \mathcal{L}(D)$, and vice versa.
Let $L$ and $M$ be regular languages over an alphabet $Σ$. The following are also regular:
Let $D = (Σ, Q, δ, q_0, F)$ be a deterministic automaton.
A state $q\in Q$ is accessible if there exists a word $w\in Σ^\ast$ such that $\hat δ(q_0, w) = q$. Otherwise it is inaccessible.
-
Note if $f: Q \to Q'$ is an homomorphism between automata $D$ and $D'$, then $q'\in Q'$ being accessible implies $q' \in \mathrm{range}(f)$.
Let $D = (Σ, Q, δ, q_0, F)$ be a deterministic automaton.
Two states $q, q'\in Q$ are indistinguishable if $\hat δ(q, w)\in F \iff \hat δ(q', w)\in F$ for all words $w\in \mathbb{W}$.
A word $w\in Σ^\ast$ is said to distinguish $q$ and $q'$ if $\hat δ(q,w) \in F$ and $\hat δ(q', w)\not\in F$ or vice versa.
Define an equivalence relation $\sim$ on $Q$ where $q\sim q'$ if $q,q'$ are indistinguishable, and write $[q]$ for the equivalence class of $q$. The quotient automaton is $$ \begin{align*} D/{\sim} = (Σ, Q/{\sim}, [δ], [q_0], [F]) \end{align*} $$ where $[δ]([q], a) = [δ(q,a)]$ and $[F] = \sb{[q]}{q\in F}$.
Note if $f: Q \to Q'$ is an homomorphism between automata $D$ and $D'$, then for any distinguishable $p,q\in Q$, we have $f(p) \neq f(q)$.
The quotient automaton is well-defined. (Derivation)
A deterministic automaton is said to be irreducible if it has neither inaccessible states nor indistinguishable distinct states.
No two distinct states of a quotient automaton are indistinguishable.
For any deterministic automaton $D$, we have $\mathcal{L}(D) = \mathcal{L}($$D/{\sim}$$)$.
Let $f$ be a homomorphism between deterministic automata $D$ and $D'$.
-
If $D$ is irreducible, then $f$ is injective.
-
If $D'$ is irreducible, then $f$ is surjective.
Every deterministic automaton $D$ has a minimal automaton $I$, unique up to isomorphism. That is, there exists an irreducible automaton $I$ with $\mathcal{L}(D) = \mathcal{L}(I)$ and at most as many states as $D$. Moreover, if $I$ and $I'$ are irreducible automata, then $\mathcal{L}(I) = \mathcal{L}(I')$ iff they are isomorphic.
The emptiness problem for regular grammars is solvable.
The equivalence problem for regular grammars is solvable.
or a transition table