This day will discuss regular expressions, and their equivalence to NFAs/DFAs. We will also look at a new state elimination algorithm
Regular Expressions
If you are involved with computer science in any way, you have probably heard of Regex and whatnot to recognize certain patterns within a string.
- every Regex describes a regular language, where
- language is a set of strings
- matched strings in “language”
- unmatched ” are not!
A regex automata would look something like:
Every regex has an equivalent DFA/NFA
Lets create a formal definition.
Formal Definition of Regex
- - union - which means
- - kleene star - 0 or more occurrences of a “starred” expression ,
Definition: we say that R is a regex if:
- R is a variable for some , ex. where 0 is regex
- R is
- r is empty language
These are all the base cases
Let’s look at some features of a regex:
- where both regexs’
- ” ” ” "" ” ”
- where is a regex
- where is a regex
- what this means is that it is the same as but with removed
Something new… GNFAs
Generalized Nondeterministic Finite Automaton
A GNFAs is a new type of automata that is used to convert a regex into an NFA. It is a generalization of NFAs and DFAs.
A typical NFA has a set of states, a set of transitions, and a set of accepting states. A GNFAs is similar, but it has a set of transitions that are labeled with regular expressions instead of single symbols.
Representation of a GNFAs: