This file contains a demonstration of how to use PSF for process
specification and test it using the simulator.

1) Consider the following specification of A coffee machine.
   (You might want to copy this specification to the file coffee.psf
   in order to try the tools yourself)


process module coffee
begin

  exports
    begin

      atoms
        serve-tea, serve-coffee
        take-tea, take-coffee
        tea, coffee
        choose-tea, choose-coffee
        offer-choice-tea, offer-choice-coffee
        tea-chosen, coffee-chosen

      processes
        system
        machine
        tea-user
        coffee-user

    end

  sets of atoms
    h = {serve-tea, serve-coffee, take-tea, take-coffee,
         choose-tea, choose-coffee, offer-choice-tea, offer-choice-coffee}
         
  communications
    serve-tea | take-tea = tea
    serve-coffee | take-coffee = coffee
    choose-tea | offer-choice-tea = tea-chosen
    choose-coffee | offer-choice-coffee = coffee-chosen

  definitions
    system = encaps(h, tea-user || coffee-user || machine)
    tea-user = choose-tea . take-tea . tea-user
    coffee-user = choose-coffee . take-coffee . coffee-user
    machine = (offer-choice-tea . serve-tea + 
               offer-choice-coffee . serve-coffee) . machine

end coffee

   This module specifies a process system which is constructed from three
   parallel components: a tea-user, a coffee-user and a machine. The
   tea-user chooses tea and then takes his tea; the coffee-user chooses
   coffee and takes coffee, while the machine offers the choice for tea
   or coffee and serves the appropriate drink.

2) Compile this specification:
   (The commands after example% should be typed literally by the user.)

example% psf coffee.psf
   
   This creates a file coffee.til

3) Test the specification with the simulator:
   First we test the tea-user in separation.
   (Note: The simulator needs the X11 windows system to be active)

example% sim coffee.til
   Several windows pop up. Use your left mouse pointer for selcting
   buttons.
click on "Default trace" in the function window.
   This way all executed actions will be displayed in the display
   window.
click on "tea-user" in the choose window.
   We want to simulate the tea-user. The only action that the tea-user
   can do is choose-tea.
click on "choose-tea" in the choose window.
   The next action is take-tea.
click on "take-tea" in the choose window.
   Repeat this several times and conclude that the tea-user
   alternatively executes choose-tea and take-tea.
click on "Random" in the function window.
   Repeated behaviour of the tea-user can be observed easily in the trace
   window.
click on "Random" in the function window.
   To stop the tracer.

4) Test the machine separately.
click on "Reset" in the function window.
click on "machine" in the choose window.
   This displays two possible continuations in the choose window.
click on "offer-choice-tea" in the choose window.
   There is only one continuation: serve-tea.
click on "serve-tea" in the choose window.
   By selecting "Random" one checks that sometimes the machine
   serves tea and the other times it serves coffee.

5) Test the behaviour of the system.
click on "Reset" in the function window.
click on "system" in the choose window.
   First step through the behaviour manually and then start the
   tracer.
click on "Random" in the function window.
   Supporse we are only interested in the choice of the drink and not
   in serving it. We only want to display the actions coffee-chosen and
   tea-chosen in the trace window.
click on "Default trace" in the function window.
   To turn of the default to display all actions.
click on "Trace" in the function window.
click on "coffee" in the <modules> window.
click on "coffee-chosen" and "tea-chosen" in the <objexts> window.
click on "quit" in the <modules> window.
click on "Random" in the function window.
   The trace window will only display the actions chosen.

6) Introduce an error in the specification and see how this leads to a
   deadlock when simulating the system.
click on "Quit simulator" from the submenu of "Special" in the function window.
   Change the definition of the tea-user in:
tea-user = choose-tea . take-coffee . tea-user
   Compile again and start the simulator.
   Select Default trace, system and random.
   The system now comes into a deadlock.
