Professional Documents
Culture Documents
C OMPUTATION
R EGULAR L ANGUAGES
T HEOREM
If L1 and L2 are regular languages, so are L1 ∪ L2 ,
L1 ∩ L2 and L1 − L2 .
P ROOF I DEA
Construct cross-product DFAs
M1 M2
Reverse: LR = {ω = a1 . . . an |ω R = an . . . a1 ∈ L}
Concatenation: L1 · L2 = {ων|ω ∈ L1 and ν ∈ L2 }
Star Closure: L∗ = {ω1 ω2 . . . ωk |k ≥ 0 and ωi ∈ L}
T HEOREM
The reverse of a regular language is also a regular
language.
T HEOREM
Every NFA has an equivalent DFA.
P ROOF I DEA
Convert the NFA to an equivalent DFA that
accepts the same language.
If the NFA has k states, then there are 2k possible
subsets (still finite)
The states of the DFA are labeled with subsets of
the states of the NFA
Thus the DFA can have up to 2k states.
S LIDES FOR 15-453 L ECTURE 3 FALL 2015 28 / 34
NFA S AND DFA S ARE EQUIVALENT
T HEOREM
Every NFA has an equivalent DFA.
C ONSTRUCTION
Let N = (Q, Σ, δ, q0 , F ) be an NFA. We construct
M = (Q 0 , Σ, δ 0 , q00 , F 0 ).
1 Q 0 = 2Q , the power set of Q
2 For R ∈ Q 0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ (δ(r , a)) for
some r ∈ R}
For R ∈ Q, the -closure of R, is defined as
(R) = {q|q is reachable from some r ∈ R
by traveling along zero or more − transitions}
3 q00 = ({q0 })
4 F 0 = {R ∈ Q 0 |R ∩ F 6= φ}: at least one of the states in R is a
final state of N
S LIDES FOR 15-453 L ECTURE 3 FALL 2015 29 / 34
NFA E XAMPLE
δ0 a b
φ φ φ
{1} φ {2}
{2} {2, 3} {3}
{3} {1, 3} φ
{1, 2} {2, 3} {2, 3}
{1, 3} {1, 3} {2}
{2, 3} {1, 2, 3} {3}
({1}) = {1, 3} {1, 2, 3} {1, 2, 3} {2, 3}
δ0 a b
φ φ φ
{1} φ {2}
{2} {2, 3} {3}
{3} {1, 3} φ
{1, 2} {2, 3} {2, 3}
{1, 3} {1, 3} {2}
{2, 3} {1, 2, 3} {3}
({1}) = {1, 3} {1, 2, 3} {1, 2, 3} {2, 3}
Nondeterminism
Clone the FA at choice points
Guess and verify
Nondeterministic FA
Multiple transitions from a state with the same input symbol
-transitions
NFAs are equivalent to DFAs
Determinization procedure builds a DFA with up to 2k states
for an NFA with k states.
R∪φ=R
R = R = R
φ∗ =
Note that we do not have explicit operators for
intersection or complementation!
See http://perldoc.perl.org/perlre.html
T HEOREM
A language is regular if and only if some regular expression describes
it.
L EMMA - T HE if PART
If a language is described by a regular expression, then it is regular
P ROOF I DEA
Inductively convert a given regular expression to an NFA.
a for a ∈ Σ
Union
Let N1 and N2 be NFAs for R1 and R2
respectively. Then the NFA for R1 ∪ R2 is
Concatenation
Let N1 and N2 be NFAs for R1 and R2
respectively. Then the NFA for R1 R2 is
Star
Let N be NFAs for R. Then the NFA for R∗ is
T HEOREM
A language is regular if and only if some regular expression describes
it.
P ROOF I DEA
Generalized transitions: label transitions with regular expressions
Iteratively eliminate states of the GNFA one by one, until only two
states and a single generalized transition is left.
Now consider