Recap: Kleene Closure
- $L^* = \{w \in \Sigma^* ~|~ \exists n \in \mathbb N. ~w \in L^n \}$
- think of L* as the set of strings you can make if you have a collection of stamps, one for each string in L, and you form every possible string that can be made from those stamps
Rethinking Regular languages
- several tools for showing language $L$ is regular
- construct DFA for L
- construct NFA for L
- combine several simpler regular languages together via closure properties to form L
- we’ll build up all regular languages
Regular expressions
- way of describing a language via a string representation
- conceptually, strings describing how to assemble a larger language out of smaller pieces
Atomic Regular Expressions
- three simple building blocks
- $\emptyset$ → regular expression that represents the empty language $\emptyset$
- For any $a \in \Sigma$, symbol $a$ is a regular expression for the language $\{a\}$
- write out the letter a → describes the language $\{a\}$
- $\varepsilon$ → regular expression that represents the language $\{ \varepsilon \}$
Remember, $\{\varepsilon \} \neq \emptyset$, and $\{ \varepsilon \} \neq \varepsilon$.
Compound Regular Expressions (note: regex = regular expression)
- If $R_1$ and $R_2$ are regular expressions, $R_1R_2$ is a regular expression for the concatenation of the languages of $R_1$ and $R_2$
- writing “hi” means concatenating $\{h\}$ and $\{i\}$ → $\{hi\}$
- any string with just letters represents the set with just that string in it
- $R_1 \cup R_2$ is a regular expression for the union of $R_1$ and $R_2$
- writing “hello $\cup$ goodbye” = $\{ hello, goodbye\}$
- If $R$ is a regular expression, $R^*$ is a regular expression for the Kleene closure of the language of $R$
- e.g. $z^* = \{z\}^*=\{\varepsilon, z, zz, zzz, zzzz,\dots \}$
- parentheses in regular expressions → $(R)$ means the same thing as $R$