Regular expressions
Subject: Compilers
Links: Strings and Grammars
Assume that two expressions
Def: Regular expressions are those expression that can be constructed from the following rules:
is regular expression denoting the . is regular expression denoting the language consisting of only the empty string, . , where , is a regular expression denoting the language of the single symbol , that is, . - If
and are regular expressions denoting the languages and , respectively, then: is a regular expression denoting . is a regular expression denoting . is a regular expression denoting .
Def: Two regular expression are equal
Finite-State Automatons
Def: A deterministic finite-state automaton is a
is a finite nonempty set of elements called states is an alphabet called the input alphabet. is a mapping from to . is called the initial state of starting state. is a nonempty set of final states.
The mappingmust follow the following conditions: for every . fro all and .
A sentence
Nondeterministic Finite-State Automatons
Def: A nondeterministic finite-state automaton is
is a finite nonempty set of elements called states is an alphabet called the input alphabet. is a mapping from to . is called the initial state of starting state. is a nonempty set of final states.
The mappingnow must satisfy the following:$$
\begin{align*}
M(Q, \varepsilon) = {Q} \qquad \qquad \qquad &\text{where}\
M(Q, Tt) = \bigcup_{P \in M(Q, T)} M(P, t) \qquad &\text{whereand } \
M({Q_1, \dots Q_n}, x) = \bigcup_{i = 1}^n M(Q_i, x) \qquad & \text{where}
\end{align*}$$We also extend the definition of a NFA to accept an stringso that .
Th: Let
- The alphabet of states consiste of all the subsets of
. An element of is denoted as where are states fo . The states are in the same canonical order so that form some states in , is always . - The set of input characters
is the same for and . - The mapping
is defined as $$M'([S_1, \dots, S_i], T) = [R_1, \dots R_j]$$where $$M({S_1, \dots, S_i}, T) = {R_1, \dots R_j}.$$ - If the starting state of
, then . us the set of all states in containing a final stat in .
Then the set of string accepted byis the same as for .
Def: A nondeterministic finite-state automaton with
Def:
Th: Define
Th: There exists a nondeterministic finite-state auntomaton
Th: There exists a regular grammar