\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 Deposit\_2}
\rhead {\rm Page \thepage~of \pageref{LastPage}}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
%---------------------------------------------------------
\begin{document}
\thispagestyle{empty}
\begin{description}
\BTitle{Deposit\_2}{4 Sep 2012}{02:39:59 PM}
\MACHINE{Deposit\_2}
\cmt{ introduce transaction, diff ATM and Bank }
\REFINES{Deposit\_1}
\SEES{Deposit\_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{ atmCash }
		\Item{ cardInAtm }
		\Item{ trans }
		\Item{ reqDep }
		\Item{ respDep }
		\Item{ processedDep }
		\Item{ atmDepAm }
		\Item{ atmCashA }
		\Item{ accBalOnAtm }
	\end{description}
\INVARIANTS
	\begin{description}
		\nItemX{ inv4 }{ trans \in  \pow(ATM) }
		\nItemX{ inv5 }{ reqDep \in  \pow(trans) }
		\nItemX{ inv6 }{ respDep \in  \pow(trans) }
		\nItemX{ inv7 }{ processedDep \in  \pow(ATM) }
		\nItemX{ inv8 }{ atmDepAm \in  ATM \pfun  \nat }
		\nItemX{ inv9 }{ partition(trans, reqDep, respDep) }
		\nItemX{ inv10 }{ atmCashA \in  ATM \tfun  \nat }
		\nItemX{ inv11 }{ accBalOnAtm \in  ACCOUNT \pfun  \nat }
		\nItemX{ inv12 }{ \forall c\qdot  c \in  ran(cardInAtm) \limp  c \in  validCard  }
	\end{description}
\EVENTS
	\INITIALISATION
		\begin{description}
		\BeginAct
			\begin{description}
			\nItemX{ act3 }{ bal :=  \emptyset  }
			\nItemX{ act4 }{ atmCash :=  ATM \cprod  \{ 0\}  }
			\nItemX{ act6 }{ validCard :=  \emptyset  }
			\nItemX{ act7 }{ cardInAtm :=  \emptyset  }
			\nItemX{ act8 }{ cardAcct :=  \emptyset  }
			\nItemX{ act12 }{ trans :=   \emptyset  }
			\nItemX{ act13 }{ reqDep :=   \emptyset  }
			\nItemX{ act14 }{ atmDepAm :=  \emptyset  }
			\nItemX{ act15 }{ processedDep :=  \emptyset  }
			\nItemX{ act16 }{ respDep :=  \emptyset  }
			\nItemX{ act17 }{ atmCashA :=  ATM \cprod  \{ 0\}  }
			\nItemX{ act18 }{ accBalOnAtm :=  \emptyset  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {reqDeposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ c }
			\ItemX{ am }
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ grd2 }{ am \in  \nat_1 }
			\nItemX{ grd3 }{ c \in  ran(cardInAtm) }
			\nItemX{ grd4 }{ a \in  dom(cardInAtm) }
			\nItemX{ grd5 }{ cardInAtm(a) = c }
			\nItemX{ grd6 }{ c \in  validCard }
			\nItemX{ grd9 }{ a \notin  trans }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ reqDep :=  reqDep \bunion  \{ a\}  }
			\nItemX{ act2 }{ trans :=  trans \bunion  \{ a\}  }
			\nItemX{ act3 }{ atmDepAm(a) :=  am }
			\end{description}
		\EndAct
		\end{description}
	\EVT {depositB}
	\REF {Deposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ acc }
			\ItemX{ am }
			\ItemX{ c }
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\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(cardInAtm) }
			\nItemX{ grd9 }{ cardInAtm(a) = c }
			\nItemX{ grd10 }{ a \in  reqDep }
			\nItemX{ grd11 }{ a \in  dom(atmDepAm) }
			\nItemX{ grd12 }{ atmDepAm(a) = am }
			\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 {respDeposit}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ grd1 }{ a \in  processedDep }
			\nItemX{ grd2 }{ a \in  reqDep }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act1 }{ respDep :=  respDep \bunion  \{ a\}  }
			\nItemX{ act3 }{ processedDep :=  processedDep \setminus  \{ a\}  }
			\nItemX{ act4 }{ reqDep :=  reqDep \setminus  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {depositATM}
		\begin{description}
		\AnyPrm
			\begin{description}
			\ItemX{ am }
			\ItemX{ a }
			\end{description}
		\WhereGrd
			\begin{description}
			\nItemX{ grd8 }{ a \in  respDep }
			\nItemX{ grd9 }{ a \in  dom (atmDepAm) }
			\nItemX{ grd10 }{ atmDepAm(a) = am }
			\end{description}
		\ThenAct
			\begin{description}
			\nItemX{ act2 }{ atmCashA(a) :=  atmCashA(a) + am }
			\nItemX{ act4 }{ respDep :=  respDep \setminus  \{ a\}  }
			\nItemX{ act5 }{ trans :=  trans \setminus  \{ a\}  }
			\end{description}
		\EndAct
		\end{description}
	\EVT {Transfer}
	\cmt{ External event, DO NOT REFINE }
	\EXTD {Transfer}
		\begin{description}
		\AnyPrm
			\begin{description}
			\Item{ src\_ac }
			\Item{ dest\_ac }
			\Item{ am }
			\Item{ c }
			\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 <  bal(src\_ac) }
			\end{description}
		\ThenAct
			\begin{description}
			\nItem{ 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}
