The FA formalism provides us with tools to finitely define certain languages: Such a language—defined as an L ( M ) over some alphabet A , for some FA M —contains a string x iff there is an accepting computation

Images

or, equivalently an accepting path within the FA (given as a flow diagram) whose labels from left to right form x.

Images

The computation (1) above, equivalently, the path labeled x within the FA, are uniquely determined by x since the automaton’s δ —the transition relation —is a total function.

Much is to be gained in theoretical flexibility if we relax both the requirements that δ is single-valued (a function) and total.

This gives rise to a nondeterministic model of finite automata, a “NFA”, that may accept a string in more than one ways, that is, there may be more than one distinct paths from q 0 to an accepting state q , each labeled by the same string x.

Indeed, even more flexibility is attained if we also allow “unconditional jumps“ from one state to another, such as

Images

which, in the first approximation, will have unlabeled edges as above. However, in order to retain the central property that we may “read off” what string is accepted by any given accepting path, namely, by simply concatenating the edge labels of the path from left to right , we will label all unconditional jumps by a string that is neutral with respect to concatenation— that is, by images . For this reason, unconditional jumps are also called “ images moves”.

3.2.0.7 Example. The displayed flow diagram below, over the alphabet {0, 1}, incorporates all the liberties in notation and convention introduced in the preceding discussion.

We have two images moves, and the string 1 can be accepted in two distinct ways: One is to follow the top images move, and then go once around the loop, consuming input 1. The other is to follow the bottom images move, and then follow the transition labeled 1 to the accepting state at the bottom (reading 1 in the process).

Folklore jargon will have us speak of guessing when we describe what the diagram does with an input. For example, to accept the input 00 one would say that the NFA guesses that it should follow the upper epsilon, and then it would go twice around the top loop, on input 0 in each case.

Images

This diagram is an example of a nondeterministic finite automaton , or NFA; it has images moves, its transition relation—as depicted by the arrows—is not a function (e.g., the top accepting state has two distinct responses on input 1), nor is it total. For example, the bottom accepting state is not defined on any input, nor is the start state: images is not an input! Images

Images Returning to the issue of guessing , we emphasize that a NFA simply provides the mathematical framework within which we can formulate and verify an existential statement of the type

for some given input x, an accepting path exists

Given an acceptable input, the NFA does not actually guess “correct” moves (from among a set of choices), either in a hidden manner (consulting the Oracle in Delphi, for example), or in an explicit computational manner (e.g., parallelism, backtracking) toward finding an accepting path for said x. Simply, the NFA formalism allows us to state , and provides tools so that we can verify , the statement

for some given input x an accepting path exists ( 3.2.0.9 )          (1)

just as the language of logic allows us to state statements such as (∃ y ), Images ( y, x) , and offers tools for their proof.

An independent agent, which could be ourselves or a FA—yes, we will see that every NFA can be can simulated by some FA!—can effect the verification that indeed an accepting path labeled x exists. Images

3.2.0.8 Definition. (NFA as Flow Diagrams) A nondeterministic finite automaton , or NFA , 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 A . It is specified as in Definition 3.1.1.1 with some amendments:

  • The restriction (for FA) that 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 ) is removed.
  • The NFA need not be fully specified.
  • It is allowed unconditional jumps, that is, edges labeled only by images .

We will generically use names such as M, N , or K for NFA, just as we did for the case of FA. Images

Images The above can be recast in an algebraic formulation, viewing a NFA from an alternative point of view as a tuple of ingredients Q , A , etc., just as we did for the FA. If one does so, one will relax the requirement that δ be a single-valued relation, and will also relax the requirement of totalness. One will also allow δ to have inputs of the type 〈 q , images 〉 making sure to view this as an extension of what δ can deal with (as inputs) rather than mistaking this as an extension of the input alphabet. Said alphabet cannot have the empty string as a member.

We will not pursue the algebraic model, as the flow diagram model will do all we want it to do.

It is trivial that since a NFA is defined by relaxing requirements in 3.1.1.1 , any FA is also a NFA, but not conversely, as the preceding example demonstrates. Images

The NFA “computes” as follows:

3.2.0.9 Definition. (NFA Computations; String Acceptance) Let M be a NFA over the input alphabet Σ. An accepting path is a path in M from the start state to some accepting state.

A string x over Σ is accepted by M iff x is obtained by concatenating the path labels from left to right in an accepting path. We say that x names , or is the name of, said accepting path. L ( M ) denotes the set of all strings over Σ accepted by M. We say that M accepts L ( M ). Images

3.2.0.10 Example. The following is a NFA but not a FA (why?). It accepts the language {0}*{1} (cf. notation in 1.1.3.3 ).

Images

Images

3.2.0.11 Example. NFA are much easier to construct than FA, partly because of the convenience of the images moves, and the lack of concern about single-valuedness of δ . Also, partly due to lack of concern for totalness: we do not have to worry about “installing” a trap state. For example, the following NFA over A = {0, 1} accepts its alphabet A as we can trivially see that there are just two accepting paths: one named “0” and one named “1”.

Images

    Images

3.2.1   From FA to NFA and Back

We noted earlier that any FA is a NFA (compare Definitions 3.1.1.1 and 3.2.0.8 ), thus the NFA are at least as powerful as the FA. They can do all that the deterministic model can do. It is a bit of a surprise that the opposite is also true: For every NFA M we can construct a FA N , such that L ( M ) = L ( N ).

Thus, in the case of these very simple machines, nondeterminism (“guessing”) buys convenience, but not real power.

How does one simulate a NFA on an input x ? The most straightforward idea is to trace all possible paths labeled x (due to nondeterminism they may be more than one—or none at all) in parallel and accept if one (or more) of those is accepting.

The principle of this idea is illustrated below.

images

Say the input to the NFA M is x = ab . . . Suppose that a leads the start state—which is at “level 0”—to three states; we draw all three. These are at level 1. We repeat for each state at level 1 on input b : Say, for the sake of discussion, that, of the three states at level 1, the first leads to one state on input b , the second leads to two and the third leads to none. We draw these three states obtained on input b ; they are at level 2, etc.

A FA can keep track of all the states at the various levels since they can be no more than the totality of states of the NFA M ! The amount of information at each level is independent of the input size—i.e., it is a constant—and moreover can be coded as a single FA-state (depicted in the figure by an ellipse) that uses a “compound” name, consisting of all the NFA state names at that level. This has led to the idea that the simulating FA must have as states nodes whose names are sets of state names of the NFA. Clearly, for this construction, state names are important through which we can keep track of and describe what we are doing. Here are the details:

3.2.1.1 Definition. ( a -successors) Let M be a NFA over an input alphabet Σ, q be a state, and a ∈ Σ. A state p is an a-successor of q iff there is an edge from q to p , labeled a . images

images In a NFA a -successors need not be unique, nor need to exist (for every pair 〈 q , a 〉). On the other hand, in a FA they exist and are unique. images

3.2.1.2 Definition. ( images -closure) Let M be a NFA with state-set Q and let S ⊆ Q . The images -closure of S , denoted by images ( S ), is defined to be the smallest set that includes S but also includes all q ∈ Q , such that there is a path, named images , from some p ∈ S to q .

When we speak of the images -closure of a state q , we mean that of the set { q } and write images ( q ) rather than images ({ q }). images

images Note that a path named images will have all its edges named images . images

3.2.1.3 Example. Consider the NFA below.

images

We compute some images -closures: images ( a ) = { a , b , d }; images ( c ) = { c , a , b , d }. images

3.2.1.4 Theorem. Let M be a NFA with state set Q and input alphabet Σ. Then there is a FA N that has as state set a subset of images ( Q )— the power set of Q — and the same input alphabet as that of M. N satisfies L ( M ) = L ( N ).

images We say that two automata M and N (whether both are FA or both are NFA, or we have one of each kind) are equivalent iff L ( M ) = L ( N ). Thus, the above says that for any NFA there is an equivalent FA. In fact, this can be strengthened as the proof shows: We can construct the equivalent FA. images

Proof . The FA N will have as state set some subset of images ( Q ), meaning that every state of N will have a compound name consisting of the names (in any order, hence set rather than sequence) of the members of some subset of Q . Moreover,

  • The start state of N is images ( q 0 ), where q 0 is the start state of M .
  • A state of N is accepting iff its name contains at least one accepting state of M .
  • Let S be a state of N and let a ∈ Σ. The unique a -successor of S in N is constructed as follows:

(1) Construct the set of all a -successors in M of all members of S . Call T this set of a -successors.

(2) Construct images ( T ); this is the a -successor of S in N .

images As an illustration, we compute some 0-successors in the FA constructed as above if the given NFA is that of Example 3.2.1.3 .

(I) For state { a , b , d } step (1) yields { c }. Step (2) yields the images -closure of { c }: The state { c , a , b , d } is the 0-successor.

(II) For state { c , a , b , d } step (1) yields { c }. Step (2) yields the images -closure of { c }: The state { c , a , b , d } is the 0-successor; that is, the 0-edge loops back to where it started. images

We return to the proof. We will show that this construction of the FA N works. So let us prove first that L ( M ) ⊆ L ( N ).

Let x = a 1 a 2 . . . a n ∈ L ( M ). Without loss of generality, we have an accepting path in M that is labeled as follows:

images

where each images ji depicts j i ≥ 0 consecutive path edges, each labeled images , where j i \= 0 in this context means that the j i group has no images -moves . We show this M -path graphically below as the zig-zag path with horizontal segments alternating with down-sloping segments. For easy reference, we assign the level number i to each horizontal part labeled images j i +1 , which is the one that is followed immediately by a down-sloping edge labeled a i +1 .

images

Now the FA N that is constructed as detailed in the above three bullets will—its δ being total—have a unique 117 path labeled a 1 a 2 . . . a n from its start state to some other state, its states being denoted by ellipses in the diagram.

images The diagram implicitly claims that each N -state at level i , depicted as an ellipse in the diagram,

(A) contains as part of its name all the states that participate in the M -sub-path with name images j i +1 , for i = 0,1,2, . . .

(B) the N -state at level i has the N -state shown, and partially named , at the next level as its a i +1 -successor.

We prove (A) by an easy induction on i and obtain (B) at once (bullet three on p. 262 ) as a side-effect. Indeed, for level i = 0 (basis), all the state names shown (from M ) are in images ( q 0 ) and we are done by the first bullet on p. 262 .

Taking as I.H. the validity of (A) for a fixed unspecified level i —where we have an N -state S —we look next at level i + 1, where we have an N -state T .

By definition of “level”, level i + 1 is reached by the edge named a i +1 . By the assumption on how M accepts x , the edge named a i +1 bridges the two indicated states, q and r . From what we know about the components present in the name of S (I.H.), the third bullet that describes the transitions of N entails that all states in the images -path from r to p are in the N -state T . images

The string will be accepted by N iff the state pointed at by a n —at level n —is accepting in N . This is so by the fact that the last state of the M -computation is accepting and—by (A)—is part of the last N -state in the above N -path.

We turn to the converse. So let x = a 1 a 2 . . . a n ∈ L ( N ). We will argue that x ∈ L ( M ).

We will reuse the above figure. Let us concentrate at first only on the elliptical states of the FA N and the indicated in the figure interconnecting transitions, which from top to bottom form the accepting N -computation path labeled a 1 a 2 . . . a n . We will want to produce a corresponding accepting M -path, that we will “fold” and fit its “horizontal” ( images -moves) parts inside appropriate ellipse states. This time it will be most convenient to do so starting at the bottom of the FA path and work backwards.

Thus the last (bottommost) state of N is two things:

(i) accepting ; hence must contain an accepting M -state (as illustrated)

(ii) the a n -successor of the preceding N -state (not illustrated). Therefore ( p. 262 ), the latter must contain an M -state from which the a n -edge emanates and this edge either points to the illustrated accepting M -state, or, more generally , to a different M -state, which is part of the last ellipse’s name and is connected to the accepting M -state by an images -path. We always adopt the general case (illustrated).

Continuing to build an M -computation path backwards, from an accepting state toward the start state—and “folding it” inside the ellipses of N as we go, leaving only the edges labeled a j to connect levels—assume that we have reached the ellipse at level i + 1. This N -state acts on input a i +2 that emanates from the M -state p inside the ellipse. By the third bullet on p. 262 , this p must have become part of the ellipse’s name either by directly being pointed to by the a i +1 -edge—emanating from some M -state, that we will call q , inside the i -level ellipse—or the edge from q actually points to a state r inside the level- i + 1 ellipse, this r , in turn, pointing to p via an images -path (the “general case”), as illustrated.

Once we reach level 1 in this way, we have a state p ′ (of M ) as part of the level-1 ellipse’s name, which—as in the general case at level i + 1—is either pointed to by the a 1 -edge (emanating from q ′) directly, or indirectly via an images -path from r ′, as illustrated. Finally, at level 0, we have N ’s start state. Thus, either q ′ is the start state of M , or, more generally, as illustrated, q ′ is reachable from M ’s start state by an images path. We have constructed an accepting path in M , labeled x . images

images In theory, to construct a FA for a given NFA we draw all the states of the latter and then determine the interconnections via edges, for each state-pair and each member of the input alphabet Σ. In practice we may achieve significant economy of effort if we start building the FA “from the start state down”: That is, starting with the start state (level 0) we determine all its a -successors, for each a ∈ Σ. At the end of this step we will have drawn all states at “level 1”. In the next step for each state at level 1, draw its a -successors, for each a ∈ Σ. And so on.

This sequence of steps terminates since there are only a finite number of states in the FA and we cannot keep writing new ones; that is, sooner or later we will stop introducing new states: edges will point “back” to existing states. See the following example. images

3.2.1.5 Example. We convert the NFA of 3.2.1.3 to a FA. See below, and review the above comment and the proof of 3.2.1.4 , in particular, the three bullets on p. 262 , to verify that the given is correct, and follows procedure.

images

You will notice the aforementioned economy of effort achieved by our process. We have only three states in the FA as opposed to the predicted 32 ( = 2 5 ) of the proof of Theorem 3.2.1.4 . But what happened to the other states? Why are they not listed by our procedure?

Because the procedure only constructs FA states that are accessible by the start state via a computation path. These are the only ones that can possibly participate in an accepting path. The others are irrelevant to accepting computations—indeed to any computations that start with the start state—and can be omitted without affecting the set accepted by the FA. images

images 3.2.1.6 Example. Suppose that we have converted a NFA M into a FA N . Let a be in the input alphabet. What is the a -successor of the state named images in N ? Well, there is no M state q that connects some state in images to q with label a . Thus, the set of a -successors ( in M ) of states from images is itself the empty set. In other words, the a -successor of images in N is images . The edge labeled a loops back to it.

Therefore, in the context of the NFA-to-FA conversion, images is a trap state in N . images