RegularLanguage-TOC Sipser
RegularLanguage-TOC Sipser
FIGURE 1.22
Accepts strings containing 001
DEFINITION 1.23
Let A and B be languages. We define the regular operations union,
concatenation, and star as follows:
• Union: A ∪ B = {x| x ∈ A or x ∈ B}.
• Concatenation: A ◦ B = {xy| x ∈ A and y ∈ B}.
• Star: A∗ = {x1 x2 . . . xk | k ≥ 0 and each xi ∈ A}.
You are already familiar with the union operation. It simply takes all the
strings in both A and B and lumps them together into one language.
The concatenation operation is a little trickier. It attaches a string from A
in front of a string from B in all possible ways to get the strings in the new
language.
The star operation is a bit different from the other two because it applies to
a single language rather than to two different languages. That is, the star oper-
ation is a unary operation instead of a binary operation. It works by attaching
any number of strings in A together to get a string in the new language. Because
Copyright 2012 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the
eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional
content at any time if subsequent rights restrictions require it.
1.1 FINITE AUTOMATA 45
EXAMPLE 1.24
Let the alphabet Σ be the standard 26 letters {a, b, . . . , z}. If A = {good, bad}
and B = {boy, girl}, then
A ∪ B = {good, bad, boy, girl},
A ◦ B = {goodboy, goodgirl, badboy, badgirl}, and
A∗ = {ε, good, bad, goodgood, goodbad, badgood, badbad,
goodgoodgood, goodgoodbad, goodbadgood, goodbadbad, . . . }.
THEOREM 1.25
The class of regular languages is closed under the union operation.
PROOF IDEA We have regular languages A1 and A2 and want to show that
A1 ∪ A2 also is regular. Because A1 and A2 are regular, we know that some finite
automaton M1 recognizes A1 and some finite automaton M2 recognizes A2 . To
prove that A1 ∪ A2 is regular, we demonstrate a finite automaton, call it M , that
recognizes A1 ∪ A2 .
This is a proof by construction. We construct M from M1 and M2 . Machine
M must accept its input exactly when either M1 or M2 would accept it in order
to recognize the union language. It works by simulating both M1 and M2 and
accepting if either of the simulations accept.
How can we make machine M simulate M1 and M2 ? Perhaps it first simulates
M1 on the input and then simulates M2 on the input. But we must be careful
here! Once the symbols of the input have been read and used to simulate M1 ,
we can’t “rewind the input tape” to try the simulation on M2 . We need another
approach.
Copyright 2012 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the
eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional
content at any time if subsequent rights restrictions require it.
46 CHAPTER 1 / REGULAR LANGUAGES
Pretend that you are M . As the input symbols arrive one by one, you simulate
both M1 and M2 simultaneously. That way, only one pass through the input is
necessary. But can you keep track of both simulations with finite memory? All
you need to remember is the state that each machine would be in if it had read
up to this point in the input. Therefore, you need to remember a pair of states.
How many possible pairs are there? If M1 has k1 states and M2 has k2 states, the
number of pairs of states, one from M1 and the other from M2 , is the product
k1 × k2 . This product will be the number of states in M , one for each pair. The
transitions of M go from pair to pair, updating the current state for both M1 and
M2 . The accept states of M are those pairs wherein either M1 or M2 is in an
accept state.
PROOF
Let M1 recognize A1 , where M1 = (Q1 , Σ, δ1 , q1 , F1 ), and
M2 recognize A2 , where M2 = (Q2 , Σ, δ2 , q2 , F2 ).
3 This expression would define M ’s accept states to be those for which both members of
the pair are accept states. In this case, M would accept a string only if both M1 and M2
accept it, so the resulting language would be the intersection and not the union. In fact,
this result proves that the class of regular languages is closed under intersection.
Copyright 2012 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the
eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional
content at any time if subsequent rights restrictions require it.
1.2 NONDETERMINISM 47
We have just shown that the union of two regular languages is regular, thereby
proving that the class of regular languages is closed under the union operation.
We now turn to the concatenation operation and attempt to show that the class
of regular languages is closed under that operation, too.
THEOREM 1.26
The class of regular languages is closed under the concatenation operation.
To prove this theorem, let’s try something along the lines of the proof of the
union case. As before, we can start with finite automata M1 and M2 recognizing
the regular languages A1 and A2 . But now, instead of constructing automaton
M to accept its input if either M1 or M2 accept, it must accept if its input can
be broken into two pieces, where M1 accepts the first piece and M2 accepts the
second piece. The problem is that M doesn’t know where to break its input
(i.e., where the first part ends and the second begins). To solve this problem, we
introduce a new technique called nondeterminism.
1.2
NONDETERMINISM
Nondeterminism is a useful concept that has had great impact on the theory of
computation. So far in our discussion, every step of a computation follows in a
unique way from the preceding step. When the machine is in a given state and
reads the next input symbol, we know what the next state will be—it is deter-
mined. We call this deterministic computation. In a nondeterministic machine,
several choices may exist for the next state at any point.
Nondeterminism is a generalization of determinism, so every deterministic
finite automaton is automatically a nondeterministic finite automaton. As Fig-
ure 1.27 shows, nondeterministic finite automata may have additional features.
Copyright 2012 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the
eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional
content at any time if subsequent rights restrictions require it.