\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 mBank\_D}
\rhead {\rm Page \thepage~of \pageref{LastPage}}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
%---------------------------------------------------------
\begin{document}
\thispagestyle{empty}
\begin{description}
\BTitle{mBank\_D}{4 Sep 2012}{01:04:23 PM}
\MACHINE{mBank\_D}
\SEES{Context\_mBank\_D}
\VARIABLES
	\begin{description}
		\Item{ bal }
		\Item{ cardAcct }
		\Item{ atmCash }
		\Item{ processedDep }
		\Item{ cardInAtmB }
		\Item{ atmDepAmB }
		\Item{ recvReqDep }
	\end{description}
\INVARIANTS
	\begin{description}
		\nItemX{ typing\_recvReqDep }{ recvReqDep \in  \pow(ATM) }
		\nItemX{ typing\_atmDepAmB }{ atmDepAmB \in  \pow(ATM \cprod  \intg ) }
		\nItemX{ typing\_bal }{ bal \in  \pow(ACCOUNT \cprod  \intg ) }
		\nItemX{ typing\_cardInAtmB }{ cardInAtmB \in  \pow(ATM \cprod  CARD) }
		\nItemX{ typing\_processedDep }{ processedDep \in  \pow(ATM) }
		\nItemX{ typing\_atmCash }{ atmCash \in  \pow(ATM \cprod  \intg ) }
		\nItemX{ typing\_cardAcct }{ cardAcct \in  \pow(CARD \cprod  ACCOUNT) }
		\nItemX{ Deposit\_0\_IntegralATM\_0\_inv1 }{ bal \in  ACCOUNT \pfun  \nat }
		\nItemX{ Deposit\_0\_IntegralATM\_0\_inv2 }{ cardAcct \in  CARD \pfun  ACCOUNT }
		\nItemX{ Deposit\_1\_inv2 }{ atmCash \in  ATM \tfun  \nat }
		\nItemX{ Deposit\_4\_inv3 }{ cardInAtmB \in  ATM \pfun  CARD }
		\nItemX{ Deposit\_4\_inv5 }{ atmDepAmB \in  ATM \pfun  \nat }
	\end{description}
\EVENTS
	\INITIALISATION
		\begin{description}
		\BeginAct
			\begin{description}
			\nItemX{ act3 }{ bal :=  \emptyset  }
			\nItemX{ act4 }{ atmCash :=  ATM \cprod  \{ 0\}  }
			\nItemX{ act8 }{ cardAcct :=  \emptyset  }
			\nItemX{ act15 }{ processedDep :=  \emptyset  }
			\nItemX{ act18 }{ recvReqDep :=  \emptyset  }
			\nItemX{ act25 }{ cardInAtmB :=  \emptyset  }
			\nItemX{ act27 }{ atmDepAmB :=  \emptyset  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {recvReqDeposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\ItemX{ am }
			\ItemX{ c }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_c }{ c \in  CARD }
			\nItemX{ typing\_am }{ am \in  \intg  }
			\nItemX{ typing\_a }{ a \in  ATM }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ recvReqDep :=  recvReqDep \bunion  \{ a\}  }
			\nItemX{ act5 }{ atmDepAmB(a) :=  am }
			\nItemX{ act6 }{ cardInAtmB(a) :=  c }
			\end{description}
		\EndAct
		\end{description}
	\EVT {depositB}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ acc }
			\ItemX{ am }
			\ItemX{ c }
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_c }{ c \in  CARD }
			\nItemX{ typing\_am }{ am \in  \intg  }
			\nItemX{ grd1 }{ acc \in  ACCOUNT }
			\nItemX{ grd2 }{ acc \in  dom(bal) }
			\nItemX{ grd3 }{ am \in  \nat_1 }
			\nItemX{ grd5 }{ c \mapsto  acc \in  cardAcct }
			\nItemX{ grd6 }{ a \in  ATM }
			\nItemX{ grd7 }{ a \in  dom(atmCash) }
			\nItemX{ grd8 }{ a \in  dom(cardInAtmB) }
			\nItemX{ grd9 }{ cardInAtmB(a) = c }
			\nItemX{ grd11 }{ a \in  dom(atmDepAmB) }
			\nItemX{ grd12 }{ atmDepAmB(a) = am }
			\nItemX{ grd13 }{ a \in  recvReqDep }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ bal(acc) :=  bal(acc) + am }
			\nItemX{ act2 }{ atmCash(a) :=  atmCash(a) + am }
			\nItemX{ act5 }{ processedDep :=  processedDep \bunion  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {sendRespDeposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_a }{ a \in  ATM }
			\nItemX{ grd1 }{ a \in  processedDep }
			\nItemX{ grd6 }{ a \in  recvReqDep }
			\nItemX{ grd2 }{ a \in  dom(cardInAtmB) }
			\nItemX{ grd4 }{ a \in  dom(atmDepAmB) }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act2 }{ processedDep :=  processedDep \setminus  \{ a\}  }
			\nItemX{ act10 }{ recvReqDep :=  recvReqDep \setminus  \{ a\}  }
			\nItemX{ act8 }{ atmDepAmB :=  \{ a\}  \domsub  atmDepAmB }
			\nItemX{ act9 }{ cardInAtmB :=  \{ a\}  \domsub  cardInAtmB }
			\end{description}
		\EndAct
		\end{description}
	\EVT {Transfer}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ src\_ac }
			\ItemX{ dest\_ac }
			\ItemX{ am }
			\ItemX{ c }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_c }{ c \in  CARD }
			\nItemX{ typing\_am }{ am \in  \intg  }
			\nItemX{ grd1 }{ src\_ac \in  ACCOUNT }
			\nItemX{ grd2 }{ dest\_ac \in  ACCOUNT }
			\nItemX{ grd4 }{ c \mapsto  src\_ac \in  cardAcct }
			\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) }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ bal :=   bal \ovl  \{ dest\_ac \mapsto  (bal(dest\_ac) + am), src\_ac \mapsto (bal(src\_ac) -  am)\}  }
			\end{description}
		\EndAct
		\end{description}
\END
\end{description}
\end{document}
