\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 mATM\_T}
\rhead {\rm Page \thepage~of \pageref{LastPage}}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
%---------------------------------------------------------
\begin{document}
\thispagestyle{empty}
\begin{description}
\BTitle{mATM\_T}{23 Apr 2012}{03:56:06 PM}
\MACHINE{mATM\_T}
\SEES{Context\_mATM\_T}
\VARIABLES
	\begin{description}
		\Item{ validCard }
		\Item{ cardInAtm }
		\Item{ trAmount }
		\Item{ transOkAtm }
		\Item{ srcAcc }
		\Item{ destAcc }
		\Item{ recvRespTransferOk }
		\Item{ recvRespTransferFail }
		\Item{ trans }
	\end{description}
\INVARIANTS
	\begin{description}
		\nItemX{ typing\_cardInAtm }{ cardInAtm \in  \pow(ATM \cprod  CARD) }
		\nItemX{ typing\_trans }{ trans \in  \pow(ATM) }
		\nItemX{ typing\_trAmount }{ trAmount \in  \pow(ATM \cprod  \intg ) }
		\nItemX{ typing\_recvRespTransferOk }{ recvRespTransferOk \in  \pow(ATM) }
		\nItemX{ typing\_transOkAtm }{ transOkAtm \in  \pow(ATM \cprod  BOOL) }
		\nItemX{ typing\_recvRespTransferFail }{ recvRespTransferFail \in  \pow(ATM) }
		\nItemX{ typing\_destAcc }{ destAcc \in  \pow(ATM \cprod  ACCOUNT) }
		\nItemX{ typing\_validCard }{ validCard \in  \pow(CARD) }
		\nItemX{ typing\_srcAcc }{ srcAcc \in  \pow(ATM \cprod  ACCOUNT) }
		\nItemX{ BalTransfer\_0\_IntegralATM\_0\_inv4 }{ validCard \subseteq   CARD }
		\nItemX{ BalTransfer\_1\_inv10 }{ cardInAtm \in   ATM \pfun  CARD }
		\nItemX{ BalTransfer\_2\_inv8 }{ trAmount \in  ATM \pfun  \nat_1 }
		\nItemX{ BalTransfer\_2\_inv11 }{ transOkAtm \in  ATM \pfun  BOOL }
		\nItemX{ BalTransfer\_2\_inv12 }{ srcAcc \in  ATM \pfun  ACCOUNT }
		\nItemX{ BalTransfer\_2\_inv13 }{ destAcc \in  ATM \pfun  ACCOUNT }
		\nItemX{ BalTransfer\_2\_inv17 }{ \forall  c \qdot  c \in  ran(cardInAtm) \limp  c \in  validCard }
	\end{description}
\EVENTS
	\INITIALISATION
		\begin{description}
		\BeginAct
			\begin{description}
			\nItemX{ act4 }{ validCard :=  \emptyset  }
			\nItemX{ act7 }{ cardInAtm :=  \emptyset  }
			\nItemX{ act18 }{ trAmount :=  \emptyset  }
			\nItemX{ act21 }{ transOkAtm :=  \emptyset  }
			\nItemX{ act22 }{ srcAcc :=  \emptyset  }
			\nItemX{ act23 }{ destAcc :=  \emptyset  }
			\nItemX{ act30 }{ trans :=  \emptyset  }
			\nItemX{ act24 }{ recvRespTransferOk :=   \emptyset  }
			\nItemX{ act26 }{ recvRespTransferFail :=   \emptyset  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {SendReqTransfer}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ c }
			\ItemX{ src\_ac }
			\ItemX{ dest\_ac }
			\ItemX{ am }
			\ItemX{ a }
			\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{ grd3 }{ am \in  \nat_1 }
			\nItemX{ grd5 }{ src\_ac \neq  dest\_ac }
			\nItemX{ grd4 }{ c \in  validCard }
			\nItemX{ grd7 }{ a \mapsto  c \in  cardInAtm }
			\nItemX{ grd8 }{ a \in  ATM }
			\nItemX{ grd11 }{ a \notin  trans }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act2 }{ trAmount(a) :=  am }
			\nItemX{ act3 }{ srcAcc(a) :=  src\_ac }
			\nItemX{ act4 }{ destAcc(a) :=  dest\_ac }
			\nItemX{ act11 }{ trans :=  trans \bunion  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {RecvRespTransferOk}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_a }{ a \in  ATM }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ recvRespTransferOk :=   recvRespTransferOk \bunion  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {RecvRespTransferFail}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_a }{ a \in  ATM }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ recvRespTransferFail :=   recvRespTransferFail \bunion  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {TransferOKAtm}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_a }{ a \in  ATM }
			\nItemX{ grd11 }{ a \in  recvRespTransferOk }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ transOkAtm(a) :=   TRUE }
			\nItemX{ act7 }{ trans :=  trans \setminus  \{ a\}  }
			\nItemX{ act6 }{ recvRespTransferOk :=  recvRespTransferOk \setminus  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {TransferFailsAtm}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_a }{ a \in  ATM }
			\nItemX{ grd11 }{ a \in  recvRespTransferFail }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ transOkAtm(a) :=   FALSE }
			\nItemX{ act7 }{ trans :=  trans \setminus  \{ a\}  }
			\nItemX{ act6 }{ recvRespTransferFail :=  recvRespTransferFail \setminus  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {Deposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ acc }
			\ItemX{ am }
			\ItemX{ c }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ typing\_c }{ c \in  CARD }
			\nItemX{ typing\_am }{ am \in  \intg  }
			\nItemX{ grd1 }{ acc \in  ACCOUNT }
			\nItemX{ grd3 }{ am \in  \nat_1 }
			\nItemX{ grd4 }{ c \in  validCard }
			\end{description}
		\ThenAct
			\begin{description}
			\Item{ skip }
			\end{description}
		\EndAct
		\end{description}
\END
\end{description}
\end{document}
