next up previous
Next: Finite State Automata Up: No Title Previous: Nondeterminism

Putting Everything So Far Together

Suppose I have an integer set, t, and in its interface is a choose action that doesn't take any arguments and removes and returns an element from t.

tex2html_wrap807

where choose is specified as follows:

1

 chooseĒ()/ok(int)

pre tex2html_wrap_inline765

post tex2html_wrap_inline767

The nondeterminism shows up in the specification for choose in the use of the set membership operator ( tex2html_wrap_inline769 ) in the post-condition. I don't know which element of t will be returned; I know only that some element will be returned.

You might notice that the labels on the arcs in the state transition diagram above are different (by what is returned by choose); however, most people would still view the state transition function as nondeterministic because they would abstract from the actual value returned. In other words they would define tex2html_wrap_inline551 something like this:

tex2html_wrap_inline775

Finally, in a programming language that supports exception handling I would probably export a more robust interface for the choose action:

1

 chooseĒ()/okĒ(int), empty()

pre true

post tex2html_wrap_inline779

tex2html_wrap_inline781

In general, the template I use for each action in A of tex2html_wrap_inline543 is:

1

 actionĒ(inputs)/ tex2html_wrap_inline787 

pre tex2html_wrap_inline639

post tex2html_wrap_inline641

where inputs is a list of arguments and their types, tex2html_wrap_inline793 is the name of one of i termination conditions (including ``ok'') and tex2html_wrap_inline797 is the type of the result corresponding to tex2html_wrap_inline793 . tex2html_wrap_inline645 and tex2html_wrap_inline647 are state predicates as defined earlier. The reserved identifiers I use are:

I'm glossing over a number of technicalities here regarding state variables to store input arguments and the type of the result returned, depending on how an action terminates.

Finally, for simplicity, let's assume actions return only normally unless specified otherwise (by explicitly listing exceptional conditions in their headers). Under this default case, we can avoid clutter in our specifications by not always having to write ``terminates = ok'' in the post-conditions of our actions.


next up previous
Next: Finite State Automata Up: No Title Previous: Nondeterminism

Norman Papernick
Mon Mar 18 15:31:49 EST 1996