3.1.0.6 Example. Consider the restricted URM below that operates over the input alphabet {0, 1}

Images

What does this program do? It has scanned a string of parity 0 (sum of its digits is even) and halted iff it halted while in state 0. This claim will be revisited after we formalize the automaton concept. Images

3.1.1   The Flow-Diagram Model

The formalization is achieved by first abstracting a command

Images

as the configuration below:

Images

Figure capturing (1) above

Thus the “read” part is implicit, while the labeled arrow that connects the states L and M denotes exactly the semantics of (1). Therefore, an entire automaton is a directed graph —that is, a finite set of (possibly) labeled circles, the states , and a finite set of arrows, the transitions , the latter labeled by members of the automaton’s input alphabet. The arrows or edges interconnect the states. If L = M , then we have the configuration

Images

where the optional label could be L , or M , L = M (as above), or nothing.

We depict the partition of states into accepting and rejecting by using two concentric circles for each accepting state as below.

Images

The special start state is denoted by drawing an arrow, that comes from nowhere, pointing to the state.

Images

To summarize and firm up:

3.1.1.1 Definition. (FA as Flow Diagrams) A finite automaton , for short, FA , over the input alphabet Σ is a finite directed graph of circular nodes—the states— and interconnecting edges—the transitions— the latter labeled by members of Σ. We impose a restriction to the automaton’s structure: For every state L and every a ∈ Σ, there will be precisely one edge, labeled a , leaving L and pointing to some state M (possibly, L = M ).

We say the automaton is fully specified (corresponding to the italics in the part “For every state L and every a ∈ A, there will be . . .” ) and deterministic (corresponding to the italics in the part “there will be precisely one edge, . . . ”).

This graph depiction of a FA is called its flow diagram and is akin to a programming “flow chart”. Images

Images 3.1.1.2 Remark. (1) Thus, full specification makes the transition function total —that is, for any state-input pair 〈 L, a 〉 as argument, it will yield some state as output. On the other hand, determinism ensures that the transition function is indeed a function (single-valued).

(2) Each “legal” input symbol is a member of the alphabet Σ, and vice versa. In the preamble of this chapter we referred to such legal symbols as “digits” in the interest of preserving the inheritance from the URM of Section 2.1.1 , the latter being a number-theoretic programming language. But what is a “digit”? In binary notation it is one of 0 or 1. In decimal notation we have the digits 0, 1, . . . , 9. In hexadecimal notation 112 we add the “digits” a , b , c , d , e , f that have “values”, in that order, 10, 11, 12, 13, 14, 15. The objective is to have single-symbol, atomic, digits to avoid ambiguities in string notation (cf. 1.1.3.1 ). Thus, a “digit” is an atomic symbol (unlike “10” or “11”).

We will drop the terminology “digit” from now on. Thus our automata alphabets are finite sets of symbols , period. Images

3.1.1.3 Example. Thus, if our alphabet is A = {0, 1}, then we cannot have the following configurations be part of a FA.

Nonototal Transition Function

Images

Non-determinism

Images

3.1.1.4 Example. The FA of the example of 3.1.0.6 , in flow diagram form but with no decision on which state(s) is/are accepting is given below:

Images

We wrote q 0 and q 1 for the states “0” and “1” of 3.1.0.6 . Images

Another way to define a FA without the help of flow diagrams is as follows:

3.1.1.5 Alternative Definition. (FA—Algebraically) A finite automaton, FA , is a toolbox M = 〈 Q , A , q 0 , δ , F 〉, 113 where

(1) Q is a finite set of states.

(2) A is a finite set of symbols; the input alphabet.

(3) q 0 ∈ Q is the distinguished start state.

(4) δ : Q × A → Q is a total function, called the transition function .

(5) F ⊆ Q is the set of accepting states; Q − F is the set of rejecting states. Images

Images 3.1.1.6 Remark. Let us compare Definitions 3.1.1.1 and 3.1.1.5 .

(1) The set of states corresponds with the nodes of the graph (flow diagram) model. It is convenient—but not theoretically necessary in general—to actually name (label) the nodes with names from Q.

(2) The A in the flow diagram model is not announced separately, but can be extracted as the set of all edge labels.

(3) q 0 —the start state by any name; q 0 being generic—in the graph model is recognized/indicated as the node pointed at by an arrow that emanates from no node.

(4) δ : Q × A → Q in the graph model is given by the arrow structure: Referring to the figure at the beginning of 3.1.1 , we have δ ( L, a ) = M .

δ is sometimes given as a (finite) so-called transition matrix, which at row L and column a will hold M and nothing else in the illustrated case. δ being a function guarantees determinism, that is, at most one entry in each location in the matrix. Totalness guarantees at least one entry, and hence exactly one entry, in each location.

(5) The members of F in the graph model are identified by being concentric circles. Images

How does a FA compute? From the URM analogy, we understand the computation of a FA consisting of successive read moves, and attendant changes of state, until the program halts (by reading the eof). At that point we proclaim that the string formed by the stream of symbols read is accepted or rejected according as the halted machine is in an accepting or rejecting state.

To formalize this we use snapshots or IDs as we did in the full URM model of 2.1.1 . The IDs of the FA are, however, very simple, since the machine (program) is incapable of altering the input stream.

3.1.1.7 Definition. (FA Computations; Acceptance) Let M = 〈 Q , A , q 0 , δ , F 〉 be a FA, and x be an input string—that is, a string over A that is presented as a stream of input symbols. An M-ID or simply ID related to x is a string of the form tqu , where q ∈ Q , and x = tu.

Intuitively , this means that the computing agent, the FA, is in state q and that the next input to process is the first symbol of u . If u = images —and hence the ID is simplified to tq —then M has halted (no more input).

Formally, an ID of the form tq has no next ID. We call it a terminal ID. However, an ID of form tqau′ , where a ∈ A , has a unique next ID; this one: ta Images u′, provided δ ( q , a ) = Images . We write

tqau′ ⊢ M ta Images u′

or, simply (if M is understood)

tqau ′ ⊢ ta Images u′

and pronounce it “(ID) tqau′ yields (ID) ta Images u′”.

We say that M accepts the string x iff, for some q ∈ F , we have q 0 x ⊢ Images xq.

The language accepted by the FA M is denoted generically by L ( M ) and is the subset of A * given by L ( M ) = { x : (∃ q ∈ F ) q 0 x ⊢ Images xq }.

An ID of the form q 0 x is called a start-ID. Images

Images     3.1.1.8 Remark. (1) Of course, ⊢ Images is the reflexive transitive closure of ⊢ M (cf. 1.6.0.23 ) and therefore I ⊢ Images J —where I (not necessarily a start-ID) and J (not necessarily terminal) are IDs—means that I = J or, for some IDs I m , m = 1, . . . , k −1, we have

Images

We call the disjunction of sequence (1) with “ I = J ”, or the shorthand notation of this disjunction, I ⊢ Images J , an M-computation , or simply a computation.

We may write (1) more informatively (but still suppressing reference to the I j ) in the shorthand I ⊢ k J , since there are exactly k occurrences of the relation ⊢ in (1).

The notations I ⊢ ≤ n J and I ⊢ < n J mean I ⊢ m J where, respectively, m ≤ n and m < n .

(2) Let x = a 1 a 2 · · · a n , where the a j are symbols of the input alphabet A = { b 1 , b 2 , . . . b r } of some FA M. Since

a 1 a 2 · · · p m a m · · · a n ⊢ a 1 a 2 · · · a m p m +1 a m +1 · · · a n

iff

Images

is a transition that belongs to the FA, when viewed as a flow diagram, then the existence of a computation that starts at state p 1 , ends at state p n +1 (not necessarily halting there 114 ), which consumed (read) an input sequence x while doing so

p 1 a 1 . . . a n ⊢ a 1 p 2 a 2 . . . a n ⊢ a 1 . . . p 3 a 3 . . . a n ⊢ etc
             ⊢ a 1 . . . p m a m . . . a n ⊢ a 1 . . . p m +1 a m +1 . . . a n ⊢ a 1 . . . a n p n +1

is equivalent to the existence of a labeled path—that we will aptly call a computation path— in the flow diagram M , from p 1 to p n +1 whose labels, concatenated from left to right, form the string x:

Images

In particular, a string x over the input alphabet belongs to L ( M ) iff it is formed by concatenating the labels of a path such as the above, where p 1 = q 0 (start state) and p n +1 is accepting. In this case we have an accepting path.

We see that the flowchart model of a FA is more than a static depiction of an automaton’s “vital” parameters, Q , A , q 0 , δ , F . Rather , all computations, including accepting computations, are also encoded within the model as certain paths. Images

3.1.1.9 Proposition. If M is a FA, then images ∈ L ( M ) iff q 0 is an accepting state .

Proof . First, say images ∈ L ( M ). By 3.1.1.7 , we have

Images

for some q that is accepting. Since 〈 q 0 , images 〉 is not in the domain of δ ( images is not in the input alphabet), the only way to have (1) hold is as equality: That is, q 0 images = images q ; that is, q 0 = q.

Conversely, if q 0 ∈ F , then since q 0 images = q 0 = images q 0 , we have q 0 images ⊢* images q 0 and thus images ∈ L ( M ). Images

Images 3.1.1.10 Example. ( Examples 3.1.0.6 and 3.1.1.4 Revisited) We prove here that if in 3.1.1.4 only q 0 is accepting, then L ( M ) is the set of all 0-1-strings of 0 (even) parity, while if only q 1 is accepting, then L ( M ) consists of all strings of parity 1 (odd parity).

We prove a bit more:

Images

only if . We do induction on the length | x | of x , to show that if

Images

then x has parity j.

For | x | = 0 we have x = images , thus (2) yields j = 0. But indeed, the parity of images is 0 as we needed to conclude.

Assume the claim for any x of length n. Let now | x | = n + 1.

Case where x = y 0. From (2), we have q 0 y 0 ⊢* y q m 0 ⊢ y 0 q j . By looking at the FA in 3.1.1.4 we see that input 0 does not cause state change, thus m = j.

By the I.H., y has parity m , but then so does x = y 0; hence j = m correctly gives this parity.

Case where _x = y__ 1. Once again, we have, from (2), _q 0 y 1 ⊢* y q m 1 ⊢ y 1 q j . By the I.H., the parity of y is m , thus the parity of y l is 1 − m . We will be done if j = 1 − m . This indeed is the case from the diagram of 3.1.1.4 : Input 1 sends q 0 to q 1 , but sends q 1 to q 0 .

Conversely, the if. Suppose that x has parity j. By induction on the length n of x we prove that we will have (2). First, if x = images , then (2) becomes q 0 images ⊢* images q 0 . Since the parity of this x is 0, we have landed on the correct state.

Assume now that if | x | \= n (fixed) has parity j , then we have (2).

Consider the case of | x | = n + 1, of parity j .

Case where x = y 0. We have q 0 y 0 ⊢* y q m 0 ⊢ y 0 q r . Now, the parity of y is j as well, so the I.H. yields that m = j. What is r ? Well, each of q 0 , q 1 is sent back to itself by input 0. Thus r = m = j .

Case where x = y 1. We have q 0 y 1 ⊢* y q m 1 ⊢ y l q r . Now, parity of y is 1 − j thus the I.H. yields that m = 1 − j. What is r ? Well, each of q 0 , q 1 is sent to the other by input 1. Thus r = 1 − m = j , as needed. Images

Images Of course, if none of the two states is accepting then L ( M ) = Images , while if both are accepting, then L ( M ) = {0, 1}*—the set of all strings over {0, 1}. Images

3.1.1.11 Example. This example is much simpler than the preceding one. We readily see that the following automaton’s only accepting paths will follow zero or more times the “loop” labeled 0 (attached to the start state), and then the edge labeled 1 to end up with an accepting state. Thus, its “ L ( M )” is the set {0 n 1 : n ≥ 0}, where we are reminded that for any string x , we have defined x n by

x 0 = images

x n +1 \= x n x

Images

Note that we need not assign state names in this example in order to discuss what the FA does. The only purpose of the state below the accepting state is to ensure the transition function δ is total (the FA must be fully specified) as required by the definition. This state is one from which one cannot escape as once in it, all transitions lead back to it. For that reason it is often called a trap state.

The reader should note the use of two shorthand notations in labeling: One, we used two labels on the vertical down-pointing edge. This abbreviates the use of two edges going from the accepting to the trap state, one labeled 0, the other 1. We could also have used the label “0, 1” at the left or right of the arrow, “,” serving as a separator. This latter notational convention was used in labeling the loop attached to the trap state. Images

3.1.1.12 Example. The two one-state FA over the input alphabet {0, 1} pictured here accept the languages Images and {0, 1}*, respectively.

Images

Images

Images

3.1.2   Some Closure Properties

When one introduces a class of languages , 115 like the sets L ( M ), one next poses a number of interesting and fundamental questions about them. Such as, what (settheoretic) closure properties do they have? Is the membership problem of such languages decidable?

The latter has rather a trivial answer for the L ( M ). Given an L ( M )— finitely , via a FA M —and a string, x , over the alphabet of M. The question “is x ∈ L ( M )?” has an algorithmic solution: We just run M on input x. Since a FA halts on all inputs (by encountering eof ), this task terminates. Then x ∈ L ( M ) iff the state in which the computation halted is accepting.

How about closure under ∩? ∪? Complement?

3.1.2.1 Theorem. Sets of the type L ( M ) over a common input alphabet are closed under union.

Proof . The proof is constructive. So let M and N be two FA over the input alphabet A = { a l , . . ., a k }. Without loss of generality (since we do not have to name the states anyway), the states of M are Q M = { q 0 , q 1 , . . . , q m } while those of N are Q N \= { p 0 , p 1 , . . . , p n } with q 0 and p 0 being the respective start states.

We build a new FA, let us call it K , over the same input alphabet A . Its state set is Q M × Q N , thus the states of K are named by pairs 〈 q i , p j 〉 where q i ∈ Q M and p j ∈ Q N

K has a transition

Images

iff M has the transition

Images

and N has the transition

Images

A state 〈 q , p 〉 of K is accepting, iff q is accepting in M, or p is accepting in N, or both.

Let now x = a j 1 a j 2 . . . a j i , . . . a j t , be an input string. Since the FA are fully specified (their δ are total), there are M- and N -paths

Images

and

Images

and a corresponding K -path labeled x , and this—by (1), (2) and (3)—is none other than

Images

Thus, we have the labeled paths (2′) and (3′) iff we have the labeled path (1′).

By the italicized sentence above concerning accepting states of K , we have that (2′) or (3′) (or both) are accepting paths iff so is (1′). That is, L ( K ) = L ( M )∪ L ( N ).
Images

3.1.2.2 Corollary. Sets of the type L ( M ) over a common input alphabet are closed under intersection.

Proof. Modify the proof above so that accepting states of K are those pairs 〈 q , p 〉 such that q and p are accepting in M and N , respectively. Images

3.1.2.3 Proposition. Sets of the type L ( M ) over an input alphabet A are closed under complement. That is, for any M there is an N such that L ( N ) = A * − L ( M ).

Proof. This proof is also constructive. Since x ∈ L ( N ) iff x ∉ L ( M ) we simply need N to compute exactly as M —and hence to have structurally the same flow diagram as that for M —but have its accepting states be the rejecting states of M and vice versa. Indeed, under these circumstances, we have for the arbitrary input x a computation q 0 x ⊢ Images xq with q accepting iff we have q 0 x ⊢ Images xq with q rejecting.

Pause. Full specification guarantees a computation for any x . Images Images

3.1.2.4 Example. The automaton that accepts the complement of the language of the FA in Example 3.1.1.11 is drawn without comment below.

Images

Images

3.1.3   How to Prove that a Set is Not Acceptable by a FA; Pumping Lemma

Is there a FA M such that L ( M ) = {0 n 1 n : n ≥ 0}? No? How can we be sure? The following theorem, known as the pumping lemma enables us to establish such “negative” results.

3.1.3.1 Theorem. (Pumping Lemma) If S = L ( M ) for some FA M, then there is a constant C that we will refer to as a pumping constant such that for any string x ∈ S, if | x | ≥ C, then we can decompose it as x = uvw so that

(1) v ≠ images

(2) uv i w ∈ S, for all i ≥ 0

and

(3) | uv | ≤ C.

Images A pumping constant is not uniquely determined by S . Images

Proof . So, let S = L ( M ) for some FA M of n states. We will show that if we take C = n 116 this will work.

Let then x = a 1 a 2 · · · a n · · · a m be a string of S. As chosen, it satisfies | x | ≥ C. An accepting computation path of M with input x looks like this:

Images

where p 1 , p 2 , . . . denotes a (notationally) convenient renaming of the states visited after q 0 in the computation. In the sequence

q 0 , p 1 , p 2 , . . . , p n

we have named n + 1 states, while we only have n . Thus, at least two names refer to the same state.

We may redraw the computation above as follows:

Images

We can now partition x into u, v and w parts from the picture above: We set

u = a 1 a 2 . . . a i

v = a i +1 a i +2 . . . a j

and

w = a j +1 a j +2 . . . a m

Note that

(1) v ≠ images , since there is at least one edge ( a i +1 ) emanating from p i on the sub-path that connects this state to the (identical) state p j .

(2) We may utilize the loop v zero or more times (along with u in the front and w at the tail) to always obtain an accepting path (cf. 3.1.1.8 ). Thus, all of uv i w belong to L ( M )—i.e., S.

(3) Since | uv | = j ≤ n , we have also verified that | uv | ≤ C. Images

Images The repeating pair p i , p j may occur anywhere between q 0 and p n . Images

3.1.3.2 Example. The language S = {0 n 1 n : n ≥ 0} is not acceptable by any FA. By way of contradiction, suppose that it is, and let C be a pumping constant associated with it. Let x = 0 C 1 C . This is in S and satisfies | x | ≥ C. By the pumping lemma, we have a decomposition x = uvw with | uv | ≤ C and uv i w in S for all i ≥ 0. This cannot be, since uv is composed of 0s only due to its length restriction, and thus, for example, for i = 0, the string uw ∉ S as it has the wrong form: It has at least one less zero than it has ones (we miss all the zeros of v ). Images

Images All proofs by 3.1.3.1 are by contradiction and they prove non acceptability by any FA (or, equivalently, NFA). Images

3.1.3.3 Example. We introduced FA as special URMs that cannot write. That in itself almost at once implies that they cannot do “arithmetic”. For example, they cannot compute ⋋ x . x + 1. “Trivially”, you say, “how can they add 1 if they cannot write?”

Well, let us press on: How about accepting the language over A = {0, 1}, given by T = {0 n 10 n +1 : n ≥ 0}?

We would agree that if this is FA-acceptable, then in a roundabout way FA “know” how to add 1 and thus “compute” the graph of ⋋ x . x + 1.

Alas, they cannot. Say T is FA-acceptable, and let C be an appropriate pumping constant. Choose x = 0 C 10 C +1 . Splitting x as uvw with | uv | ≤ C we see that 1 is to the right of v . Thus, uw (using v 0 ) is not in T since the relation between the 0s to the left and those to the right of 1 is destroyed. This contradicts the assumption that T is FA-acceptable. Images

Images 3.1.3.4 Remark. Indeed FA cannot even compute the identity function, ⋋x.x , as it should be clear from 3.1.3.2 : One can think that we get “ n in (0s) and n out (1s)”.

Another way to see that the identity function cannot be “computed” by FA is by proving, adapting the argument for T above, that {0 n 10 n : n ≥ 0 } is not FA-acceptable. This coding of the identity uses the same input and output notation. Images

3.1.3.5 Example. The set over the alphabet {0} given by P = {0 q : q is a prime number} is not FA-acceptable.

Assume the contrary, and let C be an appropriate pumping constant. Let Q ≥ C be prime. We show that considering the string x = 0 Q will lead us to a contradiction. Well, as x is longer than C , let us write—according to 3.1.3.1 — x = uvw. By said theorem, we must have that all numbers | u | + i | v | + | w |, for i ≥ 0 are prime. These numbers have the form

Images

where a = | v | ≥ 1 and b = | u | + | w |. Can all these numbers in (1) (for all i ) be prime?

Here is why not, and hence our contradiction: First, b = 0 is clearly impossible, since the numbers have the form ai , and, e.g., a 6 is not prime.

Second, say b ≠ 0. Now taking i = b , one of the numbers of the form (1) is ( a + 1) b . So, if b > 1 then this is not prime (recall that a + 1 ≥ 2). If however b = 1, then take i = 2 + a to obtain the number (of type (1)) a 2 + 2 a + 1 = ( a + 1) 2 . But this is not prime! Images

Images The preceding shows that we can have a set that is sufficiently complex and thus fails to be FA-acceptable even over a single-symbol alphabet. Here is another such case. Images

3.1.3.6 Example. Consider Q = {0 n 2 : n ≥ 0} over the alphabet A = {0}. It will not come as a surprise that Q is not FA-acceptable.

For suppose it is. Then, if C is an appropriate pumping constant, consider x = 0 C 2 . Clearly, x ∈ Q and is long enough. So, split it as x = uvw with | uv | ≤ C and v ≠ images .

Now, by 3.1.3.1 ,

Images

But

C 2 ≤ | uvvw | ≤ | uvw | + | uv | ≤ C 2 + C < C 2 + 2 C + 1 = (C + 1) 2

Thus, the number | uvvw | is not a perfect square being between two successive ones. But this will not do, because by (1), for some n , we have uvvw = 0 n 2 and thus | uvvw | = n 2 —a perfect square after all! Images

Images Hmm. Can we do anything useful with FA? Well, yes, for example, compilers of programming languages have an automaton front-end that will preprocess the input (which is a program written in some high level language) and extract all sorts of tokens such as, for example, names of variables. The principle of variable naming is captured by the following language (set of names) over A = { L , D }, where we chose “L” to suggest “letter” and “D” to suggest “digit”: “A name for a variable is a string over A that starts with an L and continues with zero or more L s or D s”.

This language is V = { L }{ L , D }*. An FA that accepts this language is the following:

Images

But remember that this volume is about fundamental limitations of computing, not a how-to manual for, say, compiler writing. So we will leave this discussion at that. Images