\documentclass{article}
\usepackage{amssymb,pepa}
\begin{document}
\title{An example of using the PEPA \LaTeX\ style}
\author{Stephen Gilmore}
\date{4th June 2003}
\maketitle
This is an example of modelling chemical reactions in PEPA\@.
We have that hydrogen atoms either come into the system from the
outside (so you have one more) or are formed when a water molecule
breaks down (then you get two).
\begin{displaymath}
\begin{array}{rcl}
Hydrogen_{0} &\rmdef& (gain\_Hydrogen, r_1).Hydrogen_{1}\\
&+& (split\_Water, \infty).Hydrogen_{2}\\
\end{array}
\end{displaymath}
If you have at least one hydrogen atom then something new can happen,
which is that a hydrogen atom can leave the system.
\begin{displaymath}
\begin{array}{rcl}
Hydrogen_{1} &\rmdef& (gain\_Hydrogen, r_1).Hydrogen_{2}\\
&+& (split\_Water, \infty).Hydrogen_{3}\\
&+& (lose\_Hydrogen, r_3).Hydrogen_{0}\\
\end{array}
\end{displaymath}
If you have at least two hydrogen atoms then you can do all of the
above and you can also now make water.
\begin{displaymath}
\begin{array}{rcl}
Hydrogen_{n+2} &\rmdef& (gain\_Hydrogen, r_1).Hydrogen_{n+3}\\
&+& (split\_Water, \infty).Hydrogen_{n+4}\\
&+& (lose\_Hydrogen, r_3).Hydrogen_{n+1}\\
&+& (form\_Water, r_4).Hydrogen_{n}\\
\end{array}
\end{displaymath}
Of course you need an oxygen atom to make water. These either come
into the system from outside or they are obtained when water or carbon
dioxide break down.
\begin{displaymath}
\begin{array}{rcl}
Oxygen_{0} &\rmdef& (gain\_Oxygen, r_5).Oxygen_{1}\\
&+& (split\_Water, \infty).Oxygen_{1}\\
&+& (split\_Gas, \infty).Oxygen_{2}\\
\\
Oxygen_{1} &\rmdef& (gain\_Oxygen, r_5).Oxygen_{2}\\
&+& (split\_Water, \infty).Oxygen_{2}\\
&+& (split\_Gas, \infty).Oxygen_{3}\\
&+& (form\_Water, r_6).Oxygen_{0}\\
&+& (lose\_Oxygen, r_7).Oxygen_{0}\\
\end{array}
\end{displaymath}
When you have at least two oxygen atoms you can make carbon dioxide.
\begin{displaymath}
\begin{array}{rcl}
Oxygen_{n+2} &\rmdef& (gain\_Oxygen, r_5).Oxygen_{n+3}\\
&+& (split\_Water, \infty).Oxygen_{n+3}\\
&+& (split\_Gas, \infty).Oxygen_{n+4}\\
&+& (form\_Water, r_6).Oxygen_{n+1}\\
&+& (lose\_Oxygen, r_7).Oxygen_{n+1}\\
&+& (form\_Gas, r_8).Oxygen_{n}\\
\end{array}
\end{displaymath}
The definition of the carbon process is similar to the above.
Compounds like water and gas go like this.
\begin{displaymath}
\begin{array}{rcl}
Water_{0} &\rmdef& (gain\_Water, r_9).Water_{1}\\
&+& (form\_Water, \infty).Water_{1}\\
\\
Water_{n+1} &\rmdef& (gain\_Water, r_9).Water_{n+2}\\
&+& (form\_Water, \infty).Water_{n+2}\\
&+& (split\_Water, r_{10}).Water_{n}\\
&+& (lose\_Water, r_{11}).Water_{n}\\
\end{array}
\end{displaymath}
Of course compounds could fuse with other compounds to make more
complex compounds, perhaps freeing up atoms in the process.
Finally we require the processes to synchronise on the right
activities. If we just had hydrogen, oxygen and water we would write
this:
\begin{displaymath}
\begin{array}{rcl}
System1 &\rmdef& (Hydrogen_{n\_H} \sync{\mathcal{L}} Oxygen_{n\_O})
\sync{\mathcal{L}} Water_{n\_W}
\end{array}
\end{displaymath}
where $\mathcal{L}=\{form\_Water, split\_Water\}$
The synchronisation set requires all
three processes to synchronise on these activities. The number of
hydrogen atoms changes by two each time but the number of oxygen atoms
and the number of water molecules changes by one. Activities not in
the synchronisation sets ($gain\_Hydrogen$, $lose\_Water$, ...) are
performed independently by any of the processes at any time.
When we have carbon and gas as well we just continue with the same
general pattern, building on the previous version of the system.
\begin{displaymath}
\begin{array}{rcl}
System2 &\rmdef& (System1 \sync{\mathcal{K}} Carbon_{n\_C})
\sync{\mathcal{K}} Gas_{n\_G}
\end{array}
\end{displaymath}
where $\mathcal{K}=\{form\_Gas, split\_Gas\}$.
\end{document}