Lec3
Lec3
Lec3
Theorem 1.1. 2-DFA is equivalent to NFA (and thus DFA), that is, if a
language is accepted by some 2-DFA, then there exists an NFA accepting the
same language.
• The same state does not repeat at any two odd locations or any two
even locations. (Otherwise, the machine will run into a loop.) This
implies the length k < 2|Q|.
1
Figure 1: valid crossing sequence
Let Q′ be the set of all valid crossing sequences, where |Q′ | ≤ |Q|2|Q| ,
q0 = [q0 ] and F ′ = {[p] : p ∈ F ). For the transition function δ ′ : Q′ × Σ → Q′ ,
δ ′ ([q1 , . . . , qk ], a) = [p1 , . . . , pl ]
If |Q| = 10, then the DFA will have 210 states, which is greater than
20
the number of particles in the universe. In that sense, the above theorem
is a purely mathematical statement. Understanding the difference between
polynomial and exponential is what complexity theory all about.
The following exercises are challenging, which says the exponential blow-
up is necessary.
Exercise 1.2 (*). Construct a 2-DFA with |Q| states such that there does not
exist any equivalent NFA with the number of states ≤ |Q|a for any constant
a > 0.
Exercise 1.3 (*). Construct a 2-DFA with |Q| states such that there does
not exist any equivalent DFA with 2|Q| states for any constant a > 0.
a
2
2 Lexical Analyzer
In ALGOL, an identifier has the following form (regular expression)
(letter)(letter + digit)∗
In Fortan,
(letter)(ϵ + letter + digit)∗
Exercise 2.1. Construct a DFA accepting the above regular expressions.
In many compiler, the lexical analyzers are implemented using DFA.
3 Pumping Lemma
Pumping lemma says something about regular language, which is not as great
as its name.
Lemma 3.1 (Pumping Lemma). If L ⊆ Σ∗ is a regular language, then
there exists a constant n such that if z ∈ L and |z| > n, then there exists
u, v, w ∈ Σ∗ such that z = uvw, |uv| ≤ n and |v| ≥ 1 and uv i w ∈ L for any
i ≥ 0.
Proof. Take a DFA M = (Q, Σ, δ, q0 , F ) accepting L, and let n = |Q|. Let
z ∈ L be a string with length |z| > n. Consider the sequence of states in M
accepting z. Since |z| > |Q|, there must exist a state which has been visited
more than once; let p be the first such state. Let u be the string from q0 to
p, and let v be the first loop from p to itself, and let w be the rest.
It is easily checked that all the properties in the lemma are satisfied.
Let us see a few applications of pumping lemma.
Proposition 3.2. L = {0l 1l : l ≥ 0} is not regular.
Proof. Suppose to the contrary that L is regular. Let n be as in the pumping
lemma. Let l > n.
Let z = 0l 1l ∈ L. By the pumping lemma, 0l 1l = uvw, where |uv| ≤ n,
which implies both u and v are consecutive 0’s. By the lemma, uv 2 w ∈ L,
which is a contradiction, because uv 2 w has more 0’s than 1’s.
Proposition 3.3. L = {0i : i ≥ 0} is not regular.
2
3
Figure 2: path accepting z
z = 00 . . . 0} .
| {z
(n+1)2 times
which is a contradiction!
4
Figure 3: ϵ-NFA accepting L1 ∪ L2
L1 ∪ L2 = L1 ∩ L2