Automata

In this section, we give some necessary preliminary background on formal language and automata theory.

A (finite) state automaton (also known as a finite state-machine) is an intuitive and natural description of a discrete event system. The automaton always resides in one of a finite number of states, and transits between these states on the occurrence of events. The fact that the state-space (in our case) is finite carries both advantages and disadvantages. It is relatively easy to display an automaton graphically, simply draw all the states and all the transitions between them. It is also possible to represent an automaton in matrix-form; with the rows corresponding to the states transition from and the columns representing the states transiting to, while the matrix itself holds the events. Furthermore, algorithms operating on automata usually enumerate the state-space, so that its finiteness guarantees that the algorithms terminate (if they are careful not to enumerate each state more than once). Thus, the finite state-space means that automata problems are computable. For a system with infinite state-space, this is not necessarily self-evident. On the downside, the finite state-space limits the expressiveness of an automaton; some things simply cannot be modeled. For instance, an automaton can model addition but not multiplication. However, this problem seems not to be of any real significance. Computability much more significant (for us) than expressiveness. It seems that automata can profitably model all the discrete events systems that we aim to control.

Basics

A (deterministic) finite state automaton P is described by a 4-tuple  where

·       is the finite set of states (or rather, state-names).

·       is a finite set of events (or rather, event-labels); the alphabet.

·       is the initial state, the state that the automaton occupies initially.

·       is the transition function that describes for a state and an event the state that the automaton occupies after the occurrence of the event, the transition.

A state represents a configuration or situation under which certain physical laws, rules and policies apply. For instance, a machine can be in the state Idle from which it can be loaded so that it enters the state Loaded. The state summarizes all information necessary to determine future behavior, given that future input can be observed. (Note that “input” is not (yet) well defined.) 

An event represents an incident that causes the automaton to move from one state to another, perhaps the same state. Events are considered atomic, they cannot be interrupted, and instantaneous, they take zero time. The lack of the concept of time means that there is no modeling of when in continuos time an event occurs, only logical properties are captured. One event can occur before another, one event is possible only after another has occurred, and so on. The advantage of this is that it simplifies the reasoning, making it hold for a broader class of systems with, for instance, different interpretation of time

Events are said to be associated with the transitions, meaning that either the event is generated when the automaton performs the transitions, or the transition is triggered by the occurrence of the event (generated by some other automaton, perhaps). However, this causality we will abstract away from as far as possible, since this significantly simplifies the reasoning and the theory. We will simply say that the automaton executes the event and not imply any assumption about where that event is actually generated. Note that an automaton can only execute events from its alphabet. However, some events of the alphabet may never be executed. Thus, the execution of an event implies that this event is in the alphabet of the automaton, but the non-execution of a certain event does not say anything about whether that event is in the alphabet or not. In fact, the presence of events that are never executed is significant for control purposes.

In the SCT events can be either controllable (possible to influence) or uncontrollable (“spontaneous”) as well as observable (for an external viewer) and unobservable. We will only consider observable events that are either controllable or uncontrollable. Uncontrollable events cannot be influenced by an outside bystander, their occurrence is solely at the discretion of the automaton itself.  Controllable events, on the other hand, can be disabled by the bystander so as not to occur although they are possible in the automaton. Typically, uncontrollable events represent the completion of a command represented by a controllable event, or the occurrence of a failure. For instance, once a machine is started it cannot be neither forced nor prevented from finishing the job or breaking down.

Note that for degenerate cases no initial state iP may exist. We allow this special case, despite the obvious breach of notation;  would then be non-existent, let us denote this by . One such case is the null automaton  with alphabet

The transition function is generally a partial function, not defined for all combinations of states and events. For instance, for a resource that can only be loaded with one product at a time there is no transition on the load event from the Loaded state. Note that there may be transitions to and from the same state, so called self-loops

As an automaton transits between its states, it executes events. It is normally assumed that the event execution can be observed by an outside observer (while the exact states visited cannot, in general). Imagine this observer writing down the events she sees executed. For one thing, this allows us to assume that no two events occur simultaneously; if they did the observer would still have to write them down in some order and that order would not matter[1]. Such a record of a finite set of events executed by an automaton is called a trace (or a string). The empty trace, corresponding to no event yet seen, is denoted by . The set of all traces that can be executed by an automaton P is denoted, and called the language of P. We can immediately note the following points.

1.       is a subset of all the traces possible over the alphabet  (denoted by , see below).

2.      When  then (and only then) .

3.       if and only if , since the empty string will always belong to.

4.      If, then ab and a are both traces of, hence  is said to be prefix-closed (or simply closed).

For two alphabets  and  define their concatenation  as the set of all combinations of event-pairs where the first belongs to  while the second belongs to , that is . For an alphabet , define  and . Then an element  (for some m) is called a trace (or string). Thus, a trace is an arbitrary sequence of events from some alphabet. The length of the trace  is m, denoted . The null string (or empty string)  is denoted . Of course, . The set of all finite traces of an alphabet  is defined as . Each trace in  is finite, but there exists infinitely many (compare the set of natural numbers; each number is finitely large, but whatever number one picks there does always exist a larger one). Any subset of  is called a language over .

We can extend the transition function above to traces in the following recursive way

where ,  and . Thus,  defines for a state and a trace the state that is reached after the sequential occurrence of all the events of the trace. Since each event can be regarded as a trace of length one, this extension is straightforward. Again,  is generally not defined for all traces of , but only a subset. The subset of traces for which the transfer function is defined from the initial state of an automaton P is denoted . Thus, . This is called the prefix closed language of P, since it by definition is prefix-closed, that is, for every trace in the language all its initial sub-traces (prefixes, see below) are also in the language.

It is also useful to define the transition function for sets of traces. This is straightforward, as for ,

.

Note that this implies that .

The class of languages able to be represented by finite state automata is said to be regular.Given a prefix-closed regular language K there does always exist a finite automaton  such that. Though there may exist many automata with the same language, it is well known that a unique minimal one exists for any regular language; minimal in the sense that it has the least necessary number of states and transitions.

A state  such that there exists a trace  so that  is said to be reachable. An automaton with only reachable states will be said to be accessible. Non-reachable states are of limited importance to us (none, in fact). While non-reachable states are not likely to appear while modeling (we choose that ourselves, after all), in some cases when manipulating automata (such as when removing states and transitions) non-reachable states may result. Therefore, we make the following remark.

We will only consider the reachable state space of an automaton.

Thus, we will always assume that all automata are accessible. In the (rare) cases that we want to emphasize that we regard only the accessible part of a certain automaton A, we will write .

Note that for two automata  and , it may very well hold that  while . This is a consequence of the partial nature of the transition function.

Automaton

 

For the automaton A above, we have that

The initial state is indicated by a small arrow, see q0 above. The accessible states are the ones reachable from the initial state, including the initial state itself, that is, . The other states, that is , are not accessible, and meaningless for practical purposes (they are formally valid, though).

Note that the event e is present in the alphabet does not label any transition. Thus, it is allowed for an automaton to have events in its alphabet that will never be executed. In fact, this is a crucial point for control purposes.

The language represented by A is .

Automata can be represented graphically or formally, both representations are shown above. It can also be represented in matrix form. Such a matrix is square, with the number of rows and columns equal to the number of states. That is, for an automaton A, the matrix is of dimension . If the matrix is called M, the element  if and only if there exists a transition from state qi to qj labeled with s, that is, when . The elements of the matrix either are events or undefined for the cases where the transition function is undefined. Even if the matrices usually become very sparse, they are often a good representation for computer manipulation.

We will refer to the rows as the from states and the columns as the to states, since the matrix element corresponding to their juncture represents the transition from the row state to the column state.

Matrix Representation

The following (very sparse) matrix describes the automaton A above. The from states are represented by the rows and the to states by the columns. The dots denote undefined transitions.

From the above matrix, we can see, for instance, that there exists a transition from q2 to q5 labeled by d.

Obviously, the matrix representation only expresses the transition function. Thus, this representation must be augmented with the alphabet to fully define the automaton.

Automata Relations

For two automata  and  when , ,  and  then  is said to be a sub-automaton of , denoted . A sub-automaton is a subset of its super-automaton such that it has the same initial state, and includes the same transitions between its subset of the super-automatons states[2]. Graphically, a sub-automaton is a sub-graph of the super-automaton including the initial state.

The sub-automaton relation is

1.      reflexive – , and

2.      transitive – .

Automata equality can be defined on different levels of detail; we will be satisfied with two, language equivalence and isomorphism (or structural equivalence).

The language equivalence regards two automata  and  as equivalent if  and . Clearly, this is an equivalence relation (that is, it is reflexive, symmetric and transitive).

Isomorphism equates two automata  and  when . Again, this is an equivalence relation (its transitiveness follows from the transitiveness of the sub-automata relation).

Obviously, isomorphism implies language equivalence. If  and  are the unique (deterministic) minimal state-machines representing the languages  and, respectively, then language equality is equivalent to isomorphism.

Synchronous Composition

Often, two automata,  and  are brought together with the intention to interact. This interaction is modeled by the some events being present in the alphabet of both automata. These events will be executed synchronously by both automata. The interaction is then modeled by the (full) synchronous composition where

 , with

 

Here  regarded as undefined when x or y is undefined. If  (so that ) then an event occurs in the composed automaton if and only if it can occur in both automata simultaneously. In that case, the language of the composition is the intersection of the respective languages, .

The synchronous composition operator has some interesting properties.

1.      It is idempotent – .

2.      It is commutative – .

3.      It is associative – .

Refinement

Obviously, when  then . However, the converse does not necessarily hold. Since it will be important for us to know exactly when , we will define the refinement relation . Note that,  and since , thus  guarantees that . The refinement relation has some interesting properties that can be proved from the properties of the synchronous composition operator above.

1.      It is reflexive – .

2.      It is antisymmetric – .

3.      It is transitive – .

In particular we can note that .

Finally we can note that when two automata refine a third, then their synchronous composition also refines the third; that is, .

Synchronization

Above we have three automata. Their synchronous compositions are shown below. We can assume that the alphabet of respective automata above consists of the shown events, except that . When synchronizing A and B all events can occur if and only if they can simultaneously occur in both automata. The alphabet of  will, of course, include c.  Thus,  will be equal to B.  In the synchronous composition of A and C, an event of A will occur if and only if it can simultaneously occur in C. However, the c event of C is not influenced by A.  Thus,  is equal to C. Finally, since , an event will occur in the composition if and only if it can occur in both automata simultaneously. Since the c event cannot occur in B at all, it will also not be possible in .

In the state  of , C can execute c, which is not in . What happens then is that A remains in its  state, while C executes c and transits to . On the other hand, in  of , C cannot execute the c event on its own, since . Thus, C cannot transit to . In this way, B can “control” the c event since it has this event in its alphabet, whereas A cannot influence the execution of c.

Note that formally there are more states arising through the synchronous composition, such as  for . However, we only concern ourselves with the accessible parts, which is what is shown above.

Sub-automata and Refinement subref.cdr

The automaton S is a sub-automaton of P, since S defines a “sub-structure” of P. Obviously, S also refines P, since , synchronizing P with S picks out the sub-structure that S defines.

 F is not a sub-automaton of either P or S, but it refines them both; .

Note that the state-names need not be known (nor related between the automata) for us to be able to determine whether one automaton refines or is a sub-automaton of another. This is entirely governed by the structure. For instance, the traces ab and ba reach the same state in S, just as they do in P. Thus, the existence of an injective function  such that   as mentioned in the footnote above can be asserted. This function can actually be taken to define the sub-automata relation. In the same way, similar but non-injective functions can be asserted to exist between F and S and P, respectively, thus determining the refinement relation. (A good exercise for the ambitious reader would be to name the states and define the functions.)

Marked States

Sometimes, it may be interesting to be able to express certain significant sub-tasks of an automaton. It may be that it is necessary to distinguish between when some task has been carried out in full and when it is only partially fulfilled. This can be done by augmenting the automaton definition with a set of marked states. Thus, we can define a marked automaton P as a 5-tuple , where the four first elements are as above, and  is the set of marked states, states that are specified as being of some significance. Typically these represent the completion of certain (sub-)tasks. For example, the Idle state is typically a marked state, representing the finishing of a work cycle. Naturally, this work cycle can be repeated again and again.

The subset of automata traces that reach marked states is said to be the marked language, . The following remarks can be made about the marked language.

1.       — this is obvious from the definition above.

2.      When  then  (just as in the prefix-closed case).

3.       if and only if  (similar to the prefix-closed case).

4.      When , then (and only then) .

5.      That  tells us nothing about , a or ab ( is generally not prefix-closed).

6.       means that .

A trace has a set of prefixes , that is, the set of traces consisting of any number of leading symbols of s. For example, a trace  has the following set of prefixes . Thus, both the empty string and s itself are prefixes of a trace s. The prefix-closure of a language L is defined as , that is, the union of all the prefixes of the traces of the language. A language L for which  is said to be prefix-closed (or simply closed). Note that for two languages such that  it always holds that .

For any regular language K (prefix-closed or not) there does always exist an automaton  such that. Furthermore, this automaton can always be chosen so that. As in the prefix-closed case above, there does exist a unique minimal such automaton, minimal in the sense of the least number of states.

If there exists a trace  such that  (that is, s reaches a marked state from q) then q is said to be coreachable. An automaton with only coreachable states will be said to be coaccessible. In the case that we will regard only the coreachable sub-automaton of a certain automaton A, we will write .

Why must ?

Why does the sub-automata relation require the alphabets to be equal, could we not simply be content with? Furthermore, by the definition of the sub-automata relation (as it stands above), strong equality guarantees that  but why do we require this also for language equality?

A natural thing of our relations (sub-automata and equivalence) would be that two related automata “behave” the same in the same context. This means, for instance, that when synchronized with the same automaton the relation should still hold. That is, if two automata A and B are equivalent, then their synchronous compositions with a third automaton C should also be equivalent. Also, we would want to have that when  then .

Regard the above three automata, where A and B only differ in that  includes the c event. The other two have the shown events as alphabets. Particularly A does not have c in its alphabet. Note that  and . Assume that we did not require  for either the sub-automata or the equivalence relation. Then A and B above would be equivalent and . However, since their alphabets are not equal they do not behave the same in the context of C. Certainly, C and B are not (language) equivalent, nor does it hold that .

If an automaton is both accessible and coaccessible it will be said to be trim. The act of removing states and transitions to make an automaton trim is called trimming. Note that a trimmed automaton represents the same marked language as the original non-trimmed one, while the closed language may have changed significantly. When an automaton A is trim  it follows[3] that its closed language is equal to the prefix-closure of its marked language, that is, . This means that any string of the closed language can always be extended into a string of the marked language. Thus, from any reachable state some marked state can always be reached.  will be used to denote the trim sub-automaton of A.

To be able to use marked and non-marked automata together in the same framework, we will make the following convention.

A non-marked automaton  can always be regarded as a marked automaton  with .

Marked Automaton

Regard again the basic (non-marked) automaton from the example above (page 21), but now with marked states added. Marked states are encircled below, thus we have.

The marked language is .

The coaccessible states are those from which the only marked state can be reached, including the marked state itself, that is . Note that state q4 is coaccessible but not accessible. State q5 on the other hand is accessible but not coaccessible. States q6 and q7 are neither accessible nor coaccessible, and from a practical point of view, they are meaningless (yet they are formally valid, of course). Likewise, q4 is for practical purposes meaningless, while this is not (necessarily) the case for q5.

Note that the transition from q2 to q5, labeled by d, affects the closed language but not the marked language.

Removing all states not in  (and the associated transitions) will make A trim. This will not change , while the bd trace will disappear from .

Of course, this convention means that when no marked states are defined, then the closed and the marked languages are equal. Be sure to note the difference between a non-marked automaton and a marked automaton with no marked states. In the former case, according to our convention, the marked language is non-null (assuming the state-set is non-empty) whereas in the latter case, the marked language is empty.

Given a marked automaton, it will be of value to speak of its non-marked counterpart , which is the automaton we get by just disregarding the marked states. Thus, given  its non-marked counterpart is simply .

Allowing the automata definition to be extended by marked states means we must redefine what we mean by sub-automata, synchronous composition and refinement. Those redefinitions must also be such that they include the previous definitions, or at least make it simple to relate to those. The above remark actually simplifies this for us.

A marked automaton is a sub-automaton of another marked automaton if their non-marked counterparts are sub-automata related and the marked states of the sub-automaton are a subset of the marked states of the super-automaton. Thus, for  to be a sub-automaton of , we require that  and . Viewing a non-marked automaton as marked (as defined in the remark above) makes this a simple extension to the definition of the non-marked sub-automata relation. A non-marked sub-automaton will be a sub-automaton by the marked definition as well.

The synchronous composition of two marked automata is equal will only differ from the synchronous composition of their non-marked counterparts in the marked states. The marked states of the synchronous composition are those states that are marked by both automata. That is, for the automata A and B of the last paragraph, in addition to the synchronous composition of their non-marked counterparts as defined above, the marked states will be. Note that the resulting automaton may have less marked states than either of the two original automata.

The marked sub-automata definition defines structural equality in the same way as the non-marked sub-automata (although a little stronger). However, the language equality must be extended (and strengthened) to the marked case. Straightforwardly, two automata A and B are language equal if their closed and marked languages are equal, that is, if  and . Again, this will obviously hold when regarding a non-marked automaton as a marked automaton.

Forbidden States

Similar to the introduction of the marked states, we might want to be able to introduce forbidden states[4]. Forbidden states specify a region of the state-space that we do not want the automaton to visit during its execution. The motivation for introducing this non-standard extension[5] is that it is often useful to be able to specify what we do not want to allow a system to do, instead of specifying everything that we do want to allow.

We augment a marked automaton P with a set of forbidden states, defining P as a 6-tuple  where the first five elements are as above, and  are the forbidden states. The forbidden language  is the subset of  that pass through a forbidden state, that is, . Note that  is the set of prefixes of s and  is (by definition) the union of the states reached by those prefixes. Thus, if at least one of the prefixes end in a forbidden state the string s is part of the forbidden language. This is what we want the forbidden states to define; any trace that passes through a forbidden state is forbidden.

The marked and closed languages as defined above are not affected by the forbidden states. This may or may not be the “correct” interpretation, however, to keep all previous definitions intact, this is the interpretation we make here. Instead, we will define two other languages that consider the forbidden states. These are the “primed languages”

 is the set of prefix-closed traces and  is the set of marked traces that do not pass through forbidden states. We can note some properties of the forbidden language.

1.      —obvious from the definition above

2.      When  then  (just as in the marked case).

3.       if and only if  (and hence ).

4.      If  then, all strings s such that  belongs to .

Forbidden States

Regard the automaton A from the previous example, but now with forbidden states added. These are denoted by being over-crossed, thus we have .

The closed and marked languages are as before. The forbidden language is , and the “primed” languages are and .

Just as in the marked case, to let us use marked and non-marked automata together with automata with forbidden states, we emphasize the following principle.

An automaton  with no forbidden states can always be regarded as an automaton with an empty forbidden state-set, .

Obviously, then the primed languages are equal to the corresponding non-primed languages. Furthermore, note that this remark also covers the non-marked case, by way of the remark given when discussing marked automata.

Again, we need to formulate the definitions of sub-automata, synchronous composition and refinement in the presence of forbidden states. Those redefinitions must also be such that they include the previous definitions, or at least make it simple to relate to those. The above remark actually simplifies this for us. In addition, by introducing forbidden states, it makes sense to speak of the non-forbidden counterpart of an automaton, which is the automaton we get by simply disregarding the forbidden states. So, for the automaton  its non-forbidden counterpart is .

Perhaps surprisingly, a sub-automaton is allowed to forbid more than its super-automaton. That is, an automaton is a sub-automaton of another if their non-forbidden counterparts are sub-automata related, and the forbidden states of the sub-automaton is a superset of the forbidden states of the super-automaton. Thus, an automaton  is a sub-automaton of an automaton  if  and . Note that this generally means that . However, it also means that the primed languages of the sub-automaton are sub-languages of the primed languages of the super-automaton;  and , and this is actually the rationale behind allowing the sub-automaton to forbid more than its super-automaton. Observe also that the non-primed languages are not affected by the forbidden states, and hence related as above.

The forbidden states of the synchronous composition of two automata is the set of states that are forbidden by either of the automata. That is, . This is a natural interpretation, forbidden states should not “disappear” in the result of the composition. It also means that the result may have more forbidden states than either of the two original automata.

Forbidden states further strengthen the equality relations, both the structural and the language equalities. Would it be reasonable to regard two automata equal despite having different forbidden states? In fact, the answer is yes. However, this is a technical issue that we will not have any use for in the following chapters, so we refrain from delving into this here.

The act of removing forbidden states from an automaton is called purging. Obviously, a purged automaton has the primed languages as its closed and marked languages, while the forbidden language is empty. Let  denote the purged version of the automaton A. Then ,  and . This holds whether A originally had any forbidden states or not. By convention, purging includes making the automaton accessible, so in fact we always have that . Algorithmically, purging is simply a removal of the forbidden states followed by the removal of the non-reachable states that may have resulted.



[1] There are other proofs of the non-simultaneousness of events, such as the theory of relativity, see for instance Peterson (1981).

[2] The sub-automata relation can also be defined by the existence of an injective function  such that  . This definition places no restrictions on the naming on the states. The state-space of a sub-automaton need not be a subset of the super automaton state-space. Thus, the apparent loss of generality above is actually nonexistent.

[3] Since A is guaranteed to be accessible, this implication is actually equivalence.

[4] Technically, we will regard both marking and forbidden states as specification, se Chapter 3.

[5] As opposed to the marked states.