Regular Expressions and Regular Languages
Regular Expressions (RE)
A regular expression describes a regular language using operators:
- Union (
or ): - Concatenation (
): - Kleene Star (
):
Examples
Converting RE to -NFA
Theorem: For every regular expression, there is an
Proof by induction on the number of operators in the RE. Each constructed
- One start state (no incoming arcs)
- One accepting state (no outgoing arcs)
Basis ( operators)
- Symbol
: Two states connected by a transition on
Induction
Union (
- Take
-NFAs for and - Add new start and final states
-transitions from new start to and start states -transitions from and final states to new final state
Concatenation (
- Take
-NFAs for and - Merge
's final state with 's start state (via -transition)
Kleene Star (
- Add new start and final states
-transition from new start to start, from final to new final -transition from new start to new final (for in ) -transition from final back to start (for repetition)
Converting DFA to Regular Expression
-Path Method
States of the DFA are named
Let
Recursive Construction
Base (
): is: - The union of labels of arcs from
to , or if none - Plus
if
- The union of labels of arcs from
Induction:
Intuitively: go from
to either without using state , or go to , loop at zero or more times, then go from to .
Final RE
The language of the DFA =
Equivalence of RE and Finite Automata
We now have a complete cycle:
All four representations define exactly the same class — regular languages.
Closure Properties of Regular Languages
Regular languages are closed under:
- Union: Take RE
for , for , then for - Concatenation:
for - Kleene Star:
for - Intersection: Product construction of DFAs
- Complement: Swap final/non-final states in DFA
- Difference:
- Reversal: Reverse all transitions, swap start/final, convert NFA to DFA
- Homomorphism: Replace each symbol
by the RE for - Inverse Homomorphism: Modify DFA transition function
Proving Non-Regularity: Pumping Lemma for Regular Languages
Statement: If
(non-empty pumpable portion) - For all
,
Intuition: A DFA with
Strategy for Proving Non-Regularity
- Assume
is regular. Let be the PL constant. - Choose
with (carefully — must work for ALL legal decompositions) - Consider any decomposition
with and - Find
such that - Contradiction —
is not regular
Classic Non-Regular Examples
: Pick . Since , consists of only 0's. Pumping gives for . : Same idea, is all 0's. : Pick . Pumping down ( ) removes 0's, giving at most zeros and ones — contradiction.