This directory contains the interface automata models for the components in
the Dining Philosopers demo, and a program that checks for deadlock inherent
in the model. The interface automata models are stored in MoML files. They
are CSPReceiver.xml, ConditionalSend.xml, ConditionalBranchController.xml,
Philosopher.xml, Chopstick.xml, and SimpleSend.xml. Except the last one,
all of the others reflect part of the behavior of the Ptolemy II classes
with the same name. The SimpleSend automaton is an abstract version of the
composition of the ConditionalSendController and two ConditionalSend. Since
the ConditionalBranchController automaton is quite complicated, SimpleSend
is used in the deadlock checking.

The file blocks.fm shows the IO relation of instances of the automata in
the model. It shows one philosopher, one chopstick, and the associated
receivers and conditional send block. It also gives the names for all
the transitions in the composition.

The program Check.java composes the Dinining Philosopher model and checks for
deadlock. This program needs to run in this directory. The usage is:

java -Xmx256m -classpath <class_path_of_ptII> ptolemy.domains.csp.demo.DiningPhilosophers.checkDeadlock.Check <numberOfPhilosophers>

If the number of philosophers is 2, the program finishes in about
5 minutes on an IBM Thinkpad 600X laptop. A sample output of the program is
in the file "result2". It shows the information of the intermediate and final
compositions and lists two deadlock states at the end. These two states
correspond to the situation where both philosophers are holding the chopstick
on his/her left and waiting for the ones on his/her right, and vice versa.
The state name in the output is the concatenation of the names in the
individual automata, in the order of Philosopher, left receiver of philosopher,
right receiver of philosopher, Chopstick, left receiver of chopstick, 
right receiver of chopstick, and SimpleSend. This sequence repeats for the
second philosopher and chopstick pair. For example, in the first deadlock
state, the first philosopher is in state 5, which is the state that waits for
the "get" call on right receiver to return, and the right receiver is in state
"cS", which is the state that waits for the philosopher on its right to
return the chopstick by calling "put". The other part of the state names
can be interpreted in a similar way.

Currently, if the number of philosophers is more than 2, the program does not
finish. This reflects the well known state explosion problem in automata
composition. Of course, the interface automata implementation in Ptolemy II
is not optimized for model checking, so this experiment is far from reaching
the limit that the state of the art implementation and algorithm can handle.
The goal here is to explore the modeling of Ptolemy II components
and test the interface automata implementation.

