\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 BalTransfer\_1}
\rhead {\rm Page \thepage~of \pageref{LastPage}}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
%---------------------------------------------------------
\begin{document}
\thispagestyle{empty}
\begin{description}
\BTitle{BalTransfer\_1}{25 Jun 2012}{04:14:47 PM}
\MACHINE{BalTransfer\_1}
\cmt{ intro atm, card and transfer failure }
\REFINES{BalTransfer\_0}
\SEES{BalTransfer\_CO1}
\VARIABLES
	\begin{description}
		\Item{ bal }
		\bcmt{ Shared variable, DO NOT REFINE }
		\Item{ validCard }
		\bcmt{ Shared variable, DO NOT REFINE }
		\Item{ cardAcct }
		\bcmt{ Shared variable, DO NOT REFINE }
		\Item{ transferOkA }
		\Item{ transferFailA }
		\Item{ cardInAtm }
	\end{description}
\INVARIANTS
	\begin{description}
		\nItemX{ inv9 }{ transferOkA \in  \pow(ATM) }
		\nItemX{ in10 }{ transferFailA \in  \pow(ATM) }
		\nItemX{ inv10 }{ cardInAtm \in   ATM \pfun  CARD }
		\nItemX{ inv11 }{ transferOkA \binter  transferFailA = \emptyset  }
	\end{description}
\EVENTS
	\INITIALISATION
		\\\textit{extended}
		\begin{description}
		\BeginAct
			\begin{description}
			\nItem{ act1 }{ bal :=  \emptyset  }
			\nItem{ act2 }{ cardAcct :=  \emptyset  }
			\nItem{ act4 }{ validCard :=  \emptyset  }
			\nItemX{ act5 }{ transferOkA :=  \emptyset  }
			\nItemX{ act6 }{ transferFailA :=  \emptyset  }
			\nItemX{ act7 }{ cardInAtm :=  \emptyset  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {TransferOK}
	\EXTD {Transfer}
		\begin{description}
		\AnyPrm
			\begin{description}
			\Item{ src\_ac }
			\Item{ dest\_ac }
			\Item{ am }
			\Item{ c }
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItem{ grd1 }{ src\_ac \in  ACCOUNT }
			\nItem{ grd2 }{ dest\_ac \in  ACCOUNT }
			\nItem{ grd3 }{ c \in  validCard }
			\nItem{ grd4 }{ c \mapsto  src\_ac \in  cardAcct }
			\nItem{ grd5 }{ am \in  \nat_1 }
			\nItem{ grd6 }{ src\_ac \in  dom(bal) }
			\nItem{ grd7 }{ dest\_ac \in  dom(bal) }
			\nItem{ grd8 }{ src\_ac \neq  dest\_ac }
			\nItem{ grd9 }{ am \leq  bal(src\_ac) }
			\nItemX{ grd11 }{ a \in  dom(cardInAtm) }
			\nItemX{ grd12 }{ c = cardInAtm(a) }
			\nItemX{ grd13 }{ a \notin  (transferOkA \bunion  transferFailA) }
			\end{description}
		\ThenAct
			\begin{description}
			\nItem{ act1 }{ bal :=   bal \ovl  \{ dest\_ac \mapsto  (bal(dest\_ac) + am), src\_ac \mapsto (bal(src\_ac) -  am)\}  }
			\nItemX{ act2 }{ transferOkA :=   transferOkA \bunion  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {TransferFails}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ src\_ac }
			\ItemX{ dest\_ac }
			\ItemX{ am }
			\ItemX{ c }
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ grd1 }{ src\_ac \in  ACCOUNT }
			\nItemX{ grd2 }{ dest\_ac \in  ACCOUNT }
			\nItemX{ grd3 }{ c \in  validCard }
			\nItemX{ grd5 }{ am \in  \nat_1 }
			\nItemX{ grd6 }{ src\_ac \in  dom(bal) }
			\nItemX{ grd7 }{ dest\_ac \in  dom(bal) }
			\nItemX{ grd8 }{ src\_ac \neq  dest\_ac }
			\nItemX{ grd9 }{ am >  bal(src\_ac) \lor  c \mapsto  src\_ac \notin  cardAcct  }
			\nItemX{ grd11 }{ a \in  dom(cardInAtm) }
			\nItemX{ grd12 }{ c = cardInAtm(a) }
			\nItemX{ grd13 }{ a \notin  (transferOkA \bunion  transferFailA) }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act2 }{ transferFailA :=   transferFailA \bunion  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {Deposit}
	\cmt{ External event, DO NOT REFINE }
	\REF {Deposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ acc }
			\ItemX{ am }
			\ItemX{ c }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ grd1 }{ acc \in  ACCOUNT }
			\nItemX{ grd2 }{ acc \in  dom(bal) }
			\nItemX{ grd3 }{ am \in  \nat_1 }
			\nItemX{ grd4 }{ c \in  validCard }
			\nItemX{ grd5 }{ c \mapsto  acc \in  cardAcct }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ bal(acc) :=  bal(acc) + am }
			\end{description}
		\EndAct
		\end{description}
	\EVT {FinishTransfer}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ grd1 }{ a \in  ATM }
			\nItemX{ grd2 }{ a \in  (transferOkA \bunion  transferFailA) }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ transferOkA :=  transferOkA \setminus  \{ a\}  }
			\nItemX{ act2 }{ transferFailA :=  transferFailA \setminus  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
\END
\end{description}
\end{document}
