--------------------------------------------------------------------------------
-- T_Powers.tex
--
-- Simple example to test multi-synchronisation. Parallelism of 
-- four processes that synchronise on channel 'm'. Process 'Read' 
-- reads a value from channel 'n' and processes SecondPower, 
-- ThirdPower and FourthPower calculate the second, third and 
-- fourth power of the value.
--------------------------------------------------------------------------------

--ADAPTADO AO LATEX DO PARSER 1.5.0 DE CZT

\begin{circus}
    \circchannel m, n, sndPower, trdPower, fthPower: \nat
\end{circus}

\begin{circus}
    \circprocess Read \circdef \circbegin
\end{circus}

\begin{circusaction}
    \circspot n?x \then m!x \then \Skip
\end{circusaction}

\begin{circus}
    \circend
\end{circus}

\begin{circus}
    \circprocess\ SecondPower \circdef\ \circbegin\
\end{circus}

\begin{circusaction}
    \circspot m?x \then sndPower!(x
     * x
     ) \then \Skip
\end{circusaction}

\begin{circus}
    \circend
\end{circus}

\begin{circus}
    \circprocess\ ThirdPower \circdef\ \circbegin\
\end{circus}

\begin{circusaction}
    \circspot m?x \then trdPower!(x * x * x) \then \Skip
\end{circusaction}

\begin{circus}
    \circend
\end{circus}

\begin{circus}
    \circprocess\ FourthPower \circdef\ \circbegin\
\end{circus}

\begin{circusaction}
    \circspot m?x \then fthPower!(x * x * x * x) \then \Skip
\end{circusaction}

\begin{circus}
    \circend
\end{circus}

\begin{circus}
    \circprocess\ Powers \circdef\ 
        Read 
            \lpar \lchanset m \rchanset \rpar
        ( SecondPower
            \lpar \lchanset m \rchanset \rpar
        ( ThirdPower
            \lpar \lchanset m \rchanset \rpar
        FourthPower ) )
\end{circus}

