\documentclass[10pt,a4paper]{report}
\usepackage[top=3cm, bottom=2.5cm, left=3cm, right=2.5cm] {geometry}
\usepackage {bsymb,b2latex}
\usepackage{fancyhdr,lastpage,color}
\lhead{\rm An Event-B Specification of pw2}
\rhead {\rm Page \thepage~of \pageref{LastPage}}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
%---------------------------------------------------------
\begin{document}
\thispagestyle{empty}
\begin{description}
\BTitle{pw2}{13 Dec 2011}{11:10:22 PM}
\MACHINE{pw2}
\REFINES{pw1}
\VARIABLES
	\begin{description}
		\Item{ ENVIRONMENT }
		\Item{ CONTROLLING }
		\Item{ VALIDATED }
		\Item{ VALIDATEDNOTCOMPLETE }
		\Item{ VALIDATEDCOMPLETE }
		\Item{ PRIORITIZED }
		\Item{ sel\_comm }
		\bcmt{ Comment }
		\Item{ up\_out }
		\bcmt{ Comment }
		\Item{ down\_out }
		\bcmt{ Comment }
		\Item{ v\_dri }
		\Item{ v\_pass }
	\end{description}
\INVARIANTS
	\begin{description}
		\nItemX{ typeof\_VALIDATEDNOTCOMPLETE }{ VALIDATEDNOTCOMPLETE \in  BOOL }
		\nItemX{ typeof\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE \in  BOOL }
		\nItemX{ distinct\_states\_in\_rrm01 }{ (VALIDATED = TRUE) \limp  partition(\{ TRUE\} , \{ VALIDATEDNOTCOMPLETE\}  \binter  \{ TRUE\} , \{ VALIDATEDCOMPLETE\}  \binter  \{ TRUE\} ) }
		\nItemX{ VALIDATEDNOTCOMPLETE\_substateof\_VALIDATED }{ (VALIDATEDNOTCOMPLETE = TRUE) \limp  (VALIDATED = TRUE) }
		\nItemX{ VALIDATEDCOMPLETE\_substateof\_VALIDATED }{ (VALIDATEDCOMPLETE = TRUE) \limp  (VALIDATED = TRUE) }
		\nItemX{ v\_driátype }{ v\_dri \in  0\upto 1 }
		\nItemX{ v\_passátype }{ v\_pass \in  0\upto 1 }
	\end{description}
\EVENTS
	\INITIALISATION
		\\\textit{extended}
		\begin{description}
		\BeginAct
			\begin{description}
			\nItem{ init\_CONTROLLING }{ CONTROLLING :=  FALSE }
			\nItem{ init\_ENVIRONMENT }{ ENVIRONMENT :=  TRUE }
			\nItem{ init\_up\_out }{ up\_out :=  0 }
			\nItem{ init\_down\_out }{ down\_out :=  0 }
			\nItem{ init\_PRIORITIZED }{ PRIORITIZED :=  FALSE }
			\nItem{ init\_sel\_comm }{ sel\_comm :=  0 }
			\nItem{ init\_VALIDATED }{ VALIDATED :=  FALSE }
			\nItemX{ init\_v\_dri }{ v\_dri :=  0 }
			\nItemX{ init\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE :=  FALSE }
			\nItemX{ init\_VALIDATEDNOTCOMPLETE }{ VALIDATEDNOTCOMPLETE :=  FALSE }
			\nItemX{ init\_v\_pass }{ v\_pass :=  0 }
			\end{description}
		\EndAct
		\end{description}
	\EVT {PE}
	\EXTD {PE}
		\begin{description}
		\WhenGrd
			\begin{description}
			\nItem{ isin\_ENVIRONMENT }{ ENVIRONMENT = TRUE }
			\end{description}
		\ThenAct
			\begin{description}
			\nItem{ enter\_CONTROLLING }{ CONTROLLING :=  TRUE }
			\nItem{ leave\_ENVIRONMENT }{ ENVIRONMENT :=  FALSE }
			\nItem{ enter\_VALIDATED }{ VALIDATED :=  TRUE }
			\nItemX{ enter\_VALIDATEDNOTCOMPLETE }{ VALIDATEDNOTCOMPLETE :=  TRUE }
			\end{description}
		\EndAct
		\end{description}
	\EVT {Ex\_Comm}
	\EXTD {Ex\_Comm}
		\begin{description}
		\AnyPrm
			\begin{description}
			\Item{ dwn }
			\bcmt{ Comment }
			\Item{ up }
			\bcmt{ Comment }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItem{ dwn\_type }{ dwn \in  0\upto 1 }
			\cmt{ Comment }
			\nItem{ isin\_PRIORITIZED }{ PRIORITIZED = TRUE }
			\nItem{ up\_type }{ up \in  0\upto 1 }
			\cmt{ Comment }
			\end{description}
		\ThenAct
			\begin{description}
			\nItem{ up\_out\_set }{ up\_out :=  up }
			\cmt{ Comment }
			\nItem{ enter\_ENVIRONMENT }{ ENVIRONMENT :=  TRUE }
			\nItem{ down\_out\_set }{ down\_out :=  dwn }
			\cmt{ Comment }
			\nItem{ leave\_PRIORITIZED }{ PRIORITIZED :=  FALSE }
			\nItem{ leave\_CONTROLLING }{ CONTROLLING :=  FALSE }
			\end{description}
		\EndAct
		\end{description}
	\EVT {ValidateCom}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ pp }
			\ItemX{ dd }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ isin\_VALIDATEDNOTCOMPLETE }{ VALIDATEDNOTCOMPLETE = TRUE }
			\nItemX{ ppType }{ pp \in  0\upto 1 }
			\nItemX{ ddType }{ dd \in  0\upto 1 }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ enter\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE :=  TRUE }
			\nItemX{ set\_v\_dri }{ v\_dri :=  dd }
			\nItemX{ leave\_VALIDATEDNOTCOMPLETE }{ VALIDATEDNOTCOMPLETE :=  FALSE }
			\nItemX{ set\_v\_pass }{ v\_pass :=  pp }
			\end{description}
		\EndAct
		\end{description}
	\EVT {selectPass}
	\REF {SelCommand}
		\begin{description}
		\WhenGrd
			\begin{description}
			\nItemX{ v\_dri\_notactive }{ v\_dri = 0 }
			\nItemX{ isin\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE = TRUE }
			\end{description}
		\Witnesses
			\begin{description}
			\nItem{ cc }{ cc=v\_pass }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ enter\_PRIORITIZED }{ PRIORITIZED :=  TRUE }
			\nItemX{ sel\_comm\_set }{ sel\_comm :=  v\_pass }
			\cmt{ Comment }
			\nItemX{ leave\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE :=  FALSE }
			\nItemX{ leave\_VALIDATED }{ VALIDATED :=  FALSE }
			\end{description}
		\EndAct
		\end{description}
	\EVT {selectDri}
	\REF {SelCommand}
		\begin{description}
		\WhenGrd
			\begin{description}
			\nItemX{ isin\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE = TRUE }
			\nItemX{ v\_dri\_active }{ v\_dri \neq  0 }
			\end{description}
		\Witnesses
			\begin{description}
			\nItem{ cc }{ cc=v\_dri }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ enter\_PRIORITIZED }{ PRIORITIZED :=  TRUE }
			\nItemX{ leave\_VALIDATEDCOMPLETE }{ VALIDATEDCOMPLETE :=  FALSE }
			\nItemX{ sel\_comm\_set }{ sel\_comm :=  v\_dri }
			\cmt{ Comment }
			\nItemX{ leave\_VALIDATED }{ VALIDATED :=  FALSE }
			\end{description}
		\EndAct
		\end{description}
\END
\end{description}
\end{document}
