Definition:Regular Expression

Definition
A regular expression is an algebraic structure on an alphabet $\Sigma$ defined as follows:


 * The empty-set regular expression, $\varnothing$, is a regular expression.


 * The empty-word regular expression, $\epsilon$, is a regular expression.


 * Every $\sigma \in \Sigma$ is a regular expression. (These are called literals.)


 * If $R_1$ and $R_2$ are regular expressions, $R_1 R_2$ is a regular expression (concatenation).


 * If $R_1$ and $R_2$ are regular expressions, $R_1 \mid R_2$ is a regular expression (alternation).


 * If $R$ is a regular expression, $R^*$ is a regular expression (Kleene star).

Every regular expression $R$ on an alphabet $\Sigma$ defines a language $L \left({R}\right) \subseteq \Sigma^*$, where $\Sigma^*$ is the set of all (finite-length) words (sequences) of symbols in $\Sigma$:


 * $ L \left({\varnothing}\right) = \varnothing $ (the empty set).


 * $ L \left({\epsilon}\right) = \left\{ { \left[{}\right] }\right\} $ (the set containing only the empty word).


 * If $R$ is a literal $\sigma$, $ L \left({R}\right) = \left\{ { \left[{ \sigma }\right] }\right\} $ (i.e., the set containing only the single-symbol word “$\sigma$”).


 * If $R$ is a concatenation $R_1 R_2$, $ L \left({R}\right) = \left\{ { w_1 w_2 : w_1 \in L \left({R_1}\right), w_2 \in L \left({R_2}\right) }\right\} $, where $w_1 w_2$ is the concatenation of the words $w_1$ and $w_2$.


 * If $R$ is an alternation $R_1 \mid R_2$, $ L \left({R}\right) = L \left({R_1}\right) \cup L \left({R_2}\right)$.


 * If $R$ is a Kleene star $R_1^*$, $ L\left({R}\right) $ is the smallest set satisfying the following:
 * $\left[{}\right] \in L \left({R}\right) $ (the empty word is in the set);
 * if $w_1 \in L \left({R}\right)$ and $w_2 \in L \left({R_1}\right)$, then $w_1 w_2 \in L \left({R}\right)$.