


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















This chapter introduces the notions of deterministic and nondeterministic finite automata and explores connections among several classes of languages: Regular, DFA-Acceptable, and NFA- acceptable. Along the way, we describe an important algorithm for converting an NFA into an equivalent DFA; that is a DFA that accepts the very same language as the NFA. We shall also derive a very powerful tool, commonly known as the Pumping Lemma, which will allow us to prove that certain languages are inherently too complex for any DFA or NFA to recognize.
An automaton^1 is a machine that behaves according to a precise set of instructions. A finite automa- ton^2 is a mathematical abstraction of a specific type of simple machine; one with extremely limited capabilities, but with many theoretical and practical applications. We shall first study the deter- ministic finite automaton, or DFA, in which every action of the machine is uniquely determined, and then the non-deterministic version, or NFA, in which some actions of the machine may be chosen arbitrarily.
Finite automata^3 are machines that can recognize languages possessing relatively simple patterns. The machine “reads” the symbols of a string, which we imagine to be printed on a “tape” that extends infinitely to the right. We refer to each location on the tape where a symbol can be written as a “cell.” All the cells following the last symbol of the string are considered to be “blank.” See Figure 5.1. Beginning in its initial state, or start state, the machine reads the tape from the left-most symbol, moving a read head along it in discrete steps, one symbol at a time. Every time the machine reads a symbol, two things happen simultaneously:
This process continues until the last symbol of the string has been read, at which point the read head is positioned over the “blank” cell just past the end of the string. The state that the machine is left in at this point can be used to classify the string; in particular, the machine distinguishes between strings that leave the machine in an accept state and those that do not. The deterministic version of such a machine is formally specified by the 5-tuple (Σ, Q, q 0 , A, δ), where
Notice that there is no explicit mention of the tape or read head in this formalism. The idea of an infinite tape arises from the fact that the input string is not part of the machine definition; instead, we conceive of the machine as being capable of processing arbitrarily long (albeit finite) input strings that are written on its tape.
The operation of this machine can also be given a completely formal definition that captures the intuitive description given above. For this we will require the notion of a configuration, or instanta- neous snapshot of the machine, and a yields relation, which will define the sequence of configurations that a machine enters as it operates. We first provide some basic notation and a convenient means of representing a DFA diagrammatically.
Let M denote the machine (Σ, Q, q 0 , A, δ), and let w ∈ Σ∗^ be some string. We shall use the notation SM(w) to denote the set of states of machine M after reading string w; of course, for a DFA, this set will always be a singleton, as it is always left in precisely one state. If the single element of SM(w) is in the set A of the accept states, we say that the machine accepts or recognizes the string w. We can also state this condition as SM(w) ∩ A 6 = ∅. The set of all recognized strings constitutes a language associated with M. More precisely, we define
L(M ) def = {w ∈ Σ∗^ | SM(w) ∩ A 6 = ∅} (5.1)
to be the language accepted (or recognized) by the machine M.^4 Such languages form an important class, so we shall give them a special name.
Definition 11 A language is called DFA-acceptable if and only if a DFA (Deterministic Finite Automaton) can be constructed that recognizes it.
(^4) We could have also written the criterion in Equation (5.1) as SM(w) ⊂ A. While these definitions are equivalent in the case of DFAs, we will find that they are not equivalent for NFAs. In particular, SM(w) ∩ A 6 = ∅ generalizes immediately to NFAs, while SM(w) ⊂ A does not.
q
q
q
q
q
b
a
b
a
b
a a (^) b
b
a
Figure 5.2: A state diagram for a DFA that accepts a simple language over the alphabet {a, b}. Here state q 0 is the “initial state,” states q 2 and q 3 are “accept” states, and state q 4 is a non-accepting “trap.”
More formally, the machine would be written as the 5-tuple (Σ, Q, q 0 , A, δ), where
Σ = {a, b} Q = {q 0 , q 1 , q 2 , q 3 , q 4 } A = {q 2 , q 3 } δ = {(q 0 , a, q 2 ), (q 0 , b, q 1 ), (q 1 , a, q 1 ), (q 1 , b, q 3 ), (q 2 , a, q 3 ), (q 2 , b, q 1 ), (q 3 , a, q 4 ), (q 3 , b, q 3 ), (q 4 , a, q 4 ), (q 4 , b, q 4 )}.
Here each ordered pair ((q, a), q′) defined by the function δ : Q × Σ → Q has been abbreviated to (q, a, q′). Since δ is a function defined on Q × Σ, as a set it must contain exactly one tuple for every (q, a) ∈ Q × Σ. In terms of the state diagram, this means that every state is represented by a circle, and each circle must have an arrow leaving it for each letter in the alphabet. The state diagram is actually a complete specification of the DFA, but one that is far easier to think about. Given the state diagram of a DFA, we can always construct the corresponding 5-tuple, and vise versa.
Once a symbol is read, it is never considered by the machine again, because the read head moves only to the right. Consequently, when a symbol is read, its influence is recorded solely in the machine state that is entered next. All subsequent computation is completely determined by the current state of the machine, q, and the unread portion of the tape, u. We combine this information into an ordered pair (q, u) called the configuration of the machine; the sequence of configurations completely describes the behavior of the machine on a given string. If δ(q, a) = q′^ and w = au, where w and u are strings in Σ∗, then one can think of δ as defining a “transformation” from one configuration to another, which we write as
(q, w) ` (q′, u), (5.2)
which is read “configuration (q, w) yields configuration (q′, u) in one step.” The symbol ` actually represents a binary relation on Q × Σ∗, which is formally defined by
(q 1 , w 1 ) ` (q 2 , w 2 ) ⇐⇒ [ δ(q 1 , a) = q 2 ∧ w 1 = aw 2 ] ,
where w 1 and w 2 are strings in Σ∗, and a ∈ Σ. Here w 2 can be any string at all, including the empty string, because the next transition made by the machine is completely determined by the current state q 1 and the current symbol a (although subsequent transitions will depend on w 2 ). It follows that
(q 1 , au) (q 2 , u) ⇐⇒ (q 1 , av) (q 2 , v)
for all strings u and v in Σ∗. While fairly obvious, this simple fact is one of the tools that allows us to reason formally about the behavior of a DFA. In particular, the implication
(q 1 , a) (q 2 , ε) =⇒ (q 1 , aw) (q 2 , w)
for any w ∈ Σ∗^ will be a useful transformation in constructing formal proofs about DFAs. However, we also need a way to reason about the composition of many steps in a computation. To this end, we define the reflexive transitive closure of the binary relation `.
From the relation ` we define a new relation
∗ by forming the reflexive transitive closure of , which extends it to include all finite sequences of steps that the machine M can take. That is, for a given machine M , the configuration (q 1 , u) eventually reaches the configuration (q 2 , v) if and only if
(q 1 , u)
∗ ` (q 2 , v),
which we read as “configuration (q 1 , u) yields configuration (q 2 , v) after zero or more steps (of machine M )”. More formally, we may give an inductive definition of this relation as
(q 1 , u) ` (q 2 , v) =⇒ (q 1 , u)
∗ ` (q 2 , v) (5.3)
q ∈ Q ∧ a ∈ Σ =⇒ (q, a)
∗ (q, a) (5.4) [ (q 1 , u) (q 2 , v) ∧ (q 2 , v)
∗ ` (q 3 , w)
=⇒ (q 1 , u)
∗ ` (q 3 , w) (5.5)
where u, v, and w are strings in Σ∗. Implication (5.3) makes the new relation an extension (that is, a superset) of the old relation, implication (5.4) makes the new relation reflexive, and implication (5.5) makes the new relation transitive (that is, closed under composition). Taken together, these impli-
cations completely specify the binary relation
∗ ` for a given machine M. From this definition it follows that w ∈ L(M ) if and only if
(q 0 , w)
∗ ` (q′, ε) (5.6)
for some q′^ ∈ A.
5.2 Nondeterminism
A Nondeterministic Finite Automaton (NFA) is a generalization of a deterministic finite automaton (DFA) in which any given transition may be incompletely determined by the current state of the
These generalizations require that we abandon the notion of a transition “function,” since ambiguous transitions produce multiple values; for example, we would have both δ(p, a) = q and δ(p, a) = r in the example (d) of Figure 5.3. To remedy this, we replace the function δ with the relation ∆. Thus, an NFA is formally defined to be a 5-tuple (Σ, Q, q 0 , A, ∆), where all of the symbols have the same meanings as in the DFA, with the exception that ∆ is now the transition relation on the set Q × Σ∗^ × Q. Each 3-tuple in this relation represents the current state, the string labeling a transition, and the state the transition leads to. Notice that this one change accommodates all four of the generalizations above.
Let M denote an NFA. We shall say that M accepts (or recognizes) a string w ∈ Σ∗^ if and only if there is some sequence of nondeterministic choices that M could make in processing w that would lead to an accept state. Equivalently, M accepts w if and only if at least one of the “clones” generated via nondeterminism ends in an accept state. It is easy to see how all of the interpretations of nondeterminism mentioned above lead to exactly the same conclusions regarding acceptance of strings.
As in the deterministic case we shall let SM(w) denote the set of states that an NFA may be left in after reading the string w; while this set will always be a singleton for a DFA, in the case of an NFA it may have any number of elements, including zero. The elements of this set correspond to all possible states that can be reached by making different decisions while reading the string w. This property leads to a slightly different notion of what it means for an NFA to “accept” a string. We have the following definitions for NFAs, which parallel those for DFAs.
Definition 12 Let machine M be an NFA. We say that M accepts a string w ∈ Σ∗^ if and only if SM(w) ∩ A 6 = ∅. That is, if and only if at least one sequence of choices can be made while reading the string that leaves the machine in an accept state after reading the string.
Definition 13 The language accepted (or recognized) by an NFA M = (Σ, Q, q 0 , A, ∆) is defined to be the set {w ∈ Σ∗^ | SM(w) ∩ A 6 = ∅}, which is denoted by L(M ), as in the deterministic case.
Definition 14 A language is called NFA-acceptable if and only if an NFA (Nondeterministic Finite Automaton) can be constructed that accepts it.
Clearly all DFA-acceptable languages are also NFA-acceptable. This follows immediately from the definition of NFAs, which are simply generalizations of DFAs. Thus, every DFA is also a valid NFA; one in which none of generalizations noted above are actually exploited.
q0 q
q
q3 q
a
b a
c
a
c b
c
b
b
a
c
a
b c
Figure 5.4: A DFA that recognizes the language ab∗^ ∪ ac∗.
Nondeterminism is not intended to model randomness that may occur in actual machines, such as quantum effects or hardware failures. As we shall see, nondeterminism is primarily a powerful theoretical tool; it will allow us to prove things about finite automata that would otherwise be very cumbersome. Nondeterminism is also a convenient notational device.
As a first concrete example of the utility of nondeterminism, we note that it frequently allows for great economy in specifying machines. Consider the DFA shown in Figure 5.4, which recognizes the simple language ab∗^ ∪ ac∗^ over the alphabet {a, b, c}. Here we have labeled some of the transitions with sets as an abbreviation for multiple arrows that share the same beginning and ending states; that is, the set notation encodes “parallel” edges, whereas a string of characters (in an NFA) encodes multiple edges that are “in sequence.”
Using the conventions of an NFA, the same language can be recognized with a much simpler machine. In the NFA shown in Figure 5.5, only three states suffice, thanks to the conveniences afforded by nondeterminism. The trap has been removed by simply not specifying transitions that cannot lead to an accept state. The resulting NFA has both fewer states and fewer transitions.
Figure 5.6: Diagrammatic representations of two finite automata M 1 and M 2 (either deterministic or non- deterministic). The only features that are relevant are the start states, shown as single circles, and the accept states, shown as double circles.
Figure 5.7: New machines built from M 1 and M 2 that accept the (a) union of the two original languages, the (b) concatenation, and the (c) Kleene star of one of the original languages. The dashed circles indicate states that are no longer accepting states.
First, observe that an NFA with no accept states accepts the empty language ∅, and that for any a ∈ Σ the machine shown in Figure 5.3(a) with p as initial state and q as an accept state accepts the singleton language {a}. Thus, all of the trivial regular languages are also NFA-acceptable.
We next demonstrate that all of the closure properties listed above also hold, from which it will follow that all regular languages are NFA-acceptable. To do this, let us depict machines M 1 and M 2 , which accept languages L 1 and L 2 , respectively, as in Figure 5.6. These simplified illustrations depict only the initial state and accepting states, of which there may be any number.
Without loss of generality, let us assume that the state labels appearing in the two diagrams are distinct. Then, from these two state diagrams we may construct state diagrams depicting new machines by adding states and/or edges. Figure 5.7(a) shows the state diagram for a machine that accepts the language L 1 ∪ L 2 , obtained by adding a new start state and two null transitions. Figure 5.7(b) shows a similar construction for a machine that accepts the language L 1 ◦ L 2. Finally, Figure 5.7(c) shows a machine that accepts the language L 1 ∗.
It is now easy to see that the NFA-acceptable languages includes all of the regular languages, since we can construct an NFA that accepts any language that can be represented by a regular expression.
We need only echo each of the operations represented in the regular expression as an operation applied to machines; the result will be an NFA that accepts exactly the same language as that represented by the regular expression.
In this section we shall use induction to prove that the set of DFA-acceptable languages is a subset of the regular languages. That is, we shall prove the following theorem.
Theorem 16 The language accepted by every DFA is regular.
Proof: Let M = (Q, Σ, q 0 , A, δ) be a DFA with states Q = { 1 , 2 , 3 ,... , n} and initial state q 0 = 1. Let Rk(i, j) denote the set of strings that would cause M to pass from state i to state j without ever passing through a state labeled k or higher. That is, w ∈ Rk(i, j) if and only if machine M , when started in state i, would end up in state j after reading w, but without ever leaving or entering states k through n (with the possible exceptions of the first or last transitions, respectively). Then
L(M ) =
m∈A
Rn+1(1, m), (5.7)
since Rn+1(1, m) excludes no intermediate states, and all accepting states are accounted for. We shall now show that Rk(i, j) is always regular using induction on k. As the base case, observe that when k = 1 the machine cannot pass through any intermediate states, so we have
R 1 (i, j) = {a ∈ Σ | δ(i, a) = j} ∪ E(i, j), (5.8)
where E(i, j) = {ε} when i = j, and ∅ otherwise. That is, R 1 (i, j) consists of all symbols for which there is a direct transition from i to j, plus the empty string ε in the case where i = j. As a finite language, R 1 (i, j) is clearly regular. Now suppose that R 1 (i, j), R 2 (i, j),... , Rk(i, j) are all regular as the inductive hypothesis, and observe that
Rk+1(i, j) = Rk(i, j) ∪ Rk(i, k) ◦ Rk(k, k)∗^ ◦ Rk(k, j). (5.9)
It then follows from Equation (5.9) that Rk+1(i, j) is also regular, as it consists of concatenations and a Kleene star of regular languages. Finally, we conclude from Equation (5.7) that L(M ) is also regular, as it is a union of regular languages. §
In this section we shall prove that the set of NFA-acceptable languages is a subset of the DFA- acceptable languages. Since inclusion in the opposite direction is obvious (as noted above), we have the following theorem.
Theorem 17 A language is accepted by an NFA if and only if it is accepted by some DFA.
s
t v
u w
~
~
a
~
a
b
c
Figure 5.9: An example of an NFA with multiple null transitions. Such transitions complicate the conversion of the machine to a DFA; at each step we must find all states that are reachable by these transitions as well.
transitions.
(a) Let S be a state in the DFA under construction that has no outgoing edge labeled “a”, where “a” is some symbol in Σ. If there is no such state, then exit the loop. (b) Let T be the set of all states reachable in the expanded NFA via exactly one a-transition in combination with any number of null transitions, starting from any of the states s ∈ S. (c) If a state with the label T does not already exist in the DFA, create one. Note that T may be the empty set, ∅. (d) Add an edge from S to T and label it with the symbol a.
By applying this algorithm to the previous NFA, which accepted the language ab∗^ ∪ ac∗, we arrive at the DFA shown in Figure 5.8. Note that step number 1 above did not apply here, since every edge in the original NFA was labeled by a single symbol. Coincidentally, the resulting DFA is identical to the one in Figure 5.4, except for the state labels. This will not always be the case. Frequently the above algorithm will introduce far more states than are necessary and be more complex than a machine built directly from the language description. The purpose of this conversion algorithm is primarily theoretical; it simply demonstrates the equivalence of NFAs and DFAs.
As a final example, consider the NFA shown in Figure 5.9, which has three null transitions. Note, in particular, that two additional states are now reachable from the start state via null transitions,
0
{s,t,v}
{t,u,v,w}
{u} {t,v,w}
c
b
a
a
c
b
a
b c
c
b
b
a
a c
Figure 5.10: This is the machine obtained by converting the NFA shown in Figure 5.9 to a DFA. Note that all null transitions are gone, and all missing transitions have been filled in.
so they are included in the start of the constructed DFA. Converting this NFA to a DFA, we arrive at the machine shown in Figure 5.10. In finding the three state labels along the top it was necessary to follow multiple null transitions in the original NFA.
In the previous section we showed that the class of NFA-acceptable languages was a subset of the DFA-acceptable languages by giving a conversion algorithm from NFAs to equivalent DFAs. We’ll now show that the DFA constructed by the algorithm in fact recognize the same language as the original NFA.
Theorem 18 Let M = (Q, Σ, q 0 , A, ∆) be an arbitrary nondeterministic finite automaton (NFA)
5.4 Closure Properties of Regular Languages
By their very definition the set of regular languages over a common alphabet are closed with respect to concatenation, union, and Kleene star. In this section we extend this list to include several more common operations on languages.
Theorem 20 Regular languages are closed under complementation, intersection, subtraction, and symmetric difference.
Proof: First, we shall use the fact that every regular language is accepted by some DFA to prove that regular languages are closed under complementation. Let L be a regular language and let M = (Q, Σ, q 0 , A, δ) be a DFA that accepts it. Now define another DFA M ′^ = (Σ, Q, q 0 , Q − A, δ). We claim that M ′^ accepts the language Σ∗^ − L, which is the complement L of the language L. This is easy to see, since SM’(w) = SM(w) for every w ∈ Σ∗, so SM’(w) 6 ∈ Q − A if and only if SM(w) ∈ A. Therefore, M ′^ rejects a string w if and only if M accepts it.
Given the closure properties we have established thus far, the remaining operations are easily seen to be closed. We need only observe that each can be expressed in terms of other operations under which regular languages have been previously shown to be closed. Thus,
L 1 ∩ L 2 =
L 1 − L 2 = {w ∈ L 1 | w 6 ∈ L 2 } = L 1 ∩ L 2 (5.19) L 1 ™ L 2 = {w ∈ L 1 ∪ L 2 | w 6 ∈ L 1 ∩ L 2 } = (L 1 − L 2 ) ∪ (L 2 − L 1 ). (5.20)
The operation denoted by “™” is known as symmetric difference. It is important to observe that the method we used above to construct a DFA that accepts L from one that accepts L does not carry over directly to NFAs. That is, if we simply change accepting states into non-accepting states, and vise versa, in an arbitrary NFA, the resulting machine will in general not accept the complement of the original language.
5.5 The Pumping Lemma
We start by establishing several elementary rules governing the operation of finite automata that will prove useful later. Let Σ be an alphabet, and let a and b denote arbitrary symbols in Σ. From the definition of the “yields” relation for the finite automaton M , denoted by ` , we may obtain the elementary composition rule
(q 1 , a) (q 2 , ε) =⇒ (q 1 , ab) (q 2 , b), (5.21)
which simply affirms that the next step taken by machine M is unaffected by the symbol immediately
following the current position of the read head. From the definition of the relation
∗ ` , rule (5.21) may be inductively extended to strings, yielding the rule
(q 1 , u)
∗ ` (q 2 , ε) =⇒ (q 1 , uv)
∗ ` (q 2 , v), (5.22)
where u and v now denote strings in Σ∗. By the transitivity of
∗ ` , we may then immediately formulate the fundamental composition rule for finite automata: [ (q 1 , u)
∗ ` (q 2 , ε) ∧ (q 2 , v)
∗ ` (q 3 , ε)
=⇒ (q 1 , uv)
∗ ` (q 3 , ε). (5.23)
From rule (5.23) it follows by induction on n that
(q, v)
∗ ` (q, ε) =⇒ (q, vn)
∗ ` (q, ε) (5.24)
for all n ∈ N. Finally, from rules (5.23) and (5.24) together, we obtain
[ (q 1 , u)
∗ ` (q 2 , ε) ∧ (q 2 , v)
∗ ` (q 2 , ε)
=⇒ (q 1 , uvn)
∗ ` (q 2 , ε) (5.25)
for all n ∈ N. When q 1 is the initial state of machine M , rule (5.25) may be be more succinctly stated as
SM(u) = SM(uv) =⇒ SM(u) = SM(uvn) (5.26)
for all n ∈ N. Rule (5.26) will be an essential element in establishing the first pumping lemma, which is a powerful tool for identifying languages that cannot be recognized by finite automata. This lemma is proven in the following section.
While it is easy to see from a counting argument that there are uncountably many non-regular (i.e. non-DFA-acceptable) languages, such an argument provides no means of identifying a specific non-regular language. To prove that a language is not regular, we must show that no DFA recognizes it. As is frequently the case, a negative result (e.g. that no DFA accepts language L) is more challenging to prove than the corresponding positive result (e.g. that machine M accepts language L), since the latter can be demonstrated by simply exhibiting a machine that accepts L. To attack this problem, we first introduce the notion of a pumping property that may or may not be possessed by any given string in a language.
Definition 15 Let k be a natural number and let L be a language. Then we shall say that w ∈ L has the first pumping property of length k (with respect to the language L) if and only if there exist strings x, y, and z (not necessarily in the language L) such that w = xyz, |xy| ≤ k, |y| ≥ 1, and xynz ∈ L for all n ≥ 0.
The word “pumping” in this definition is motivated by the fact that any number of copies of the string y may be inserted (or “pumped”) into the machine M , following the prefix x, without changing the state of M.
The following powerful lemma provides a method for demonstrating non-regularity of a large class of (but not all of) the non-regular languages.
Lemma 1 (The Pumping Lemma for Regular Languages) Let L be a regular language. Then for some k ∈ N, every w ∈ L with |w| ≥ k has the first pumping property of length k.
which is a predicate on strings, w, which is defined to be true if and only if w has the first pumping property of length k with respect to the language L. Note that the predicate depends on both the length k and the language L, which we make explicit by affixing k and L as subscript and superscript, respectively. Next, let Reg be a predicate on languages such that Reg(L) is true if and only if L is regular. We may now state the first pumping lemma more succinctly in terms of these predicates.
Lemma 2 (Predicate form of Lemma 1) Let L be any language. Then
Reg(L) =⇒
∃ k ∈ N, ∀w ∈ L, |w| ≥ k ⊃ ΠLk (w)
Since every element of a regular language must possess the “pumping property” for sufficiently large k, a language that fails to have this property for all k cannot be regular. Stated in this way, it is clearly the contrapositive of lemma 2 that allows us to draw conclusions about a language. Thus, we state the contrapositive as a lemma in its own right.
Lemma 3 (Contrapositive of Lemma 2) Let L be any language. Then
[ ∀ k ∈ N, ∃w ∈ L, |w| ≥ k ∧ ¬ΠLk (w)
=⇒ ¬Reg(L). (5.29)
The bracketed expression in Equation (5.29) is the negation of the bracketed expression in Equa- tion (5.28)^5. To make use of lemma 3, we must show that the negation of the predicate ΠLk (w) holds for some sufficiently long string w ∈ L. We now look at what is entailed by this negation. To make the notation a bit more concise, we’ll encapsulate various properties as predicates on strings or languages. First, we define the “partition” and the “pump” predicates by
Pk(w, x, y, z) def = [ w = xyz ∧ |xy| ≤ k ∧ |y| ≥ 1 ] (5.30) QL(x, y, z) def = ∀n ∈ N (xynz ∈ L) (5.31)
respectively, where k ∈ N. Note that equations Equation (5.30) and (5.31) actually define families of predicates. The predicate Pk(w, x, y, z) is true if and only if the strings x, y, and z form a “partition” of the string w that satisfies all of the language-independent^6 prerequisites of the first pumping property of length k, and QL(x, y, z) is true if and only if the remaining language-dependent^7 property holds. We may then define the complete “pumping property” predicate by
ΠLk (w) def = ∃ x, y, z ( Pk(w, x, y, z) ∧ QL(x, y, z) ) , (5.32)
which is true if and only if the string w ∈ L possesses the pumping property of length k (with respect to the language L), as defined earlier. Recall that x, y, and z may be any strings in Σ∗, and needn’t
(^5) Recall that A ⊃ B is simply shorthand for ¬A∨B. Hence, the negation of ∃x ∀y A(x, y) ⊃ B(x, y) is ∀x ∃y A(x, y)∧ ¬B(x, y). (^6) We refer to these properties as “language-independent” because they merely require xyz to be a proper partition of w with restrictions on the lengths of xy and y. These properties do not mention the language L at all. (^7) This predicate is always relative to a specific language L, as it requires all of the “pumped” strings to be in L. Hence, we refer to it as “language-dependent.”
be elements of L themselves. We now have
¬ΠLk (w) ⇐⇒ ¬∃ x, y, z [ Pk(w, x, y, z) ∧ QL(x, y, z) ] ⇐⇒ ∀ x, y, z [ ¬Pk(w, x, y, z) ∨ ¬QL(x, y, z) ] ⇐⇒ ∀ x, y, z [ Pk(w, x, y, z) ⊃ ¬QL(x, y, z) ] ⇐⇒ ∀ x, y, z [ Pk(w, x, y, z) ⊃ ∃n ¬ (xynz ∈ L) ] ⇐⇒ ∀ x, y, z [ Pk(w, x, y, z) ⊃ ∃n (xynz /∈ L) ].
We now assemble the various pieces, and state the final predicate form of the pumping lemma for regular languages as another lemma.
Lemma 4 (Contrapositive of Lemma 2, Version 2) Let L be any language. If
∀ k ∈ N, ∃w ∈ L, |w| ≥ k ∧ ∀ x, y, z [ Pk(w, x, y, z) ⊃ ∃n (xynz /∈ L) ] , (5.33)
then L is not regular.
Thus, to show that a language L is not not regular, using the contrapositive of the first pumping lemma, we must show that for every k ∈ N, we can find some string w ∈ L with |w| ≥ k that fails to have the pumping property of length k. That is, for all valid partitionings of w into xyz (meaning w = xyz, |xy| ≤ k, and |y| ≥ 1), there is some n ∈ N such that xynz /∈ L. We now show how to apply this lemma.
Theorem 21 The language L 1 = {anbn^ | n ≥ 1 } is not regular.
Proof: Let k ∈ N be given. We shall now select a string w ∈ L 1 that is of length at least k; since we are at liberty to chose any such w, we’ll choose one that will make the rest of the proof as easy as possible. Let w = akbk, which clearly has length greater than k. Now consider any partition w = xyz such that |xy| ≤ k and |y| ≥ 1. Then y must consist entirely of a’s. (This is precisely why the string akbk^ was convenient for this particular proof). This implies that xy^2 z will have more a’s than b’s. More precisely
∣ ∣xy^2 z
a =^ |w|a^ +^ |y|a^ >^ |w|b^ +^ |y|b^ =^
∣xy^2 z
b ,^ (5.34)
since |y|a ≥ 1 while |y|b = 0. It follows immediately that xy^2 z cannot be of the form anbn, which always has the same number of a’s ad b’s. Consequently, xy^2 z /∈ L 1. We have thus shown that for any k ∈ N, there is a string of length at least k (namely akbk) that fails to have the pumping property of length k. Therefore, L 1 is not regular. §
Theorem 22 The language L 2 = {an^ | n ∈ N ∧ n is prime} is not regular.