Ck Z specs uo you undersLand LhaL specs ln Z conslsL of schemas?
We can use Z schemas Lo formally
speclfy funcLlons/procedural modules eg a funcLlon module SC81 or more complex funcLlons/procedural modules eg SorL for sorLlng elemenLs eLc We can also use Z schemas Lo formally speclfy classes/daLa absLracLlon modules lor example lf we wanL Lo speclfy a class wlLh aLLrlbuLes and operaLlons Lhen we produce a schema where we lnLroduce/declare aLLrlbuLes and schemas for operaLlons eg one schema for each operaLlon are we clear abouL lL? so for example lf we wanL Lo formally speclfy a class 8ankAccounL wlLh aLLrlbuLe balance and operaLlons deposlLwlLhdraw and currenLbalance Lhen we produce a schema where we lnLroduce/declare balance (Lhls schema ln a sense speclfles Lhe sLaLe) and we produce schemas for each operaLlon leLs noLlce LhaL some operaLlons/funcLlons are updaLlng ones some are enqulrles eg deposlL and wlLhdraw are updaLlng ones whlle currenLbalance ls enqulry updaLlng operaLlons change Lhe sLaLe (ln Lhls case balance) enqulrles do noL change Lhe sLaLe (eg balance) clear so far? ok LeL me conLlnuelor updaLlng operaLlons we produce schamas wlLh Lhe symbol uLL1A (ln Creek alphabeL) whlch means change/dlfference of Lhe sLaLe before and afLer Lhe operaLlon lor enqulry operaLlons we use anoLher Creek leLLer xl So when you read formal specs you lmmedlaLely know wlch schemas speclfy updaLlng and whlch enqulry operaLlons As you remember each schema conslsLs of 2 parLs ueclaraLlon and redlcaLe parLs
LeLs see how Lo wrlLe a schema for Lhe sLaLe of class 8ankAccounL So golng back Lo Lhe sLaLe schema for 8ankAccounL ln ueclaraLlon parL you lnLroduce/declare varlables whcl speclfy Lhe sLaLe ln Lhls case balance Clear? you [usL wrlLe balance and lLs Lype lf Lhere are any consLralnLs (eg buslness consLralnLs) lmposed on sLaLe varlables you should speclfy Lhem ln Lhe redlcaLe parL eg balance00 whlch means LhaL balance ls never negaLlve
now leLs focus on schemas whlch speclfy operaLlons/funcLlons ln Lhe ueclaraLlon parL you normally lnLroduce/declare parameLers so for example for deposlL Lhe obvlous parameLer ls amounL noLe LhaL some parameLers are lnpuL parameLers some are ouLpuL prameLers (le resulLs) we have Lo clearly lndlcaLe Lhls uslng decoraLlons ! and ? So Lo summarlse so far ln ueclaraLlon parL we lnLroduce parameLers and we dlsLlngulsh beLween lnpuL and ouLpuL parameLers Clear? And flnally Lhe redlcaLe parL of an operaLlon schema whlch ls Lhe mosL lmporLanL as lL acLually speclfles whaL an operaLlon/funcLlon ls for ln general redlcaLe parL lncludes a number of predlcaLes whlch speclfy condlLlons LhaL musL be meL by sLaLe varlables and lnpuL parameLers 8LlC8L Lhe operaLlon so some sorL of 8LcondlLlons and predlcaLes/condlLlons LhaL musL be meL Al1L8 Lhe operaLlon/funcLlon so some sorL of CS1condlLlons ls LhaL clear? so ln Lhe case of deposlL operaLlon we have Lo speclfy LhaL parameLer amounL 0 Lhls ls an obvlous 8L condldLlon slnce amounL0 ls lncorrecL anoLher Lhlng whlch we wanL Lo conslder ls Lhe sLaLe le balance buL for deposlL Lhere are no any consLralnLs/condlLlon for balance so we end up wlLh only one predlcaLe/condlLlon (8L) amounL0 so now we have Lo speclfy condlLlons/predlcaLes whlch should be meL Al1L8 Lhe operaLlpo le CS1 clear? assume LhaL operaLlon deposlL does noL have any ouLpuL parameLer so we do noL have Lo boLher abouL lL buL we have Lo speclfy Lhe CPAnMCL Lo Lhe S1A1L (whlch ls represenLed by balance)! Clear? and Lhe correspondlng predlcaLe/condlLlons ls balance balance amounL l am sorry for some reason symbol plus ls noL vlslble plus beLween balance and amounL 1he sLandard convenLlon ls Lo use Lo speclfy sLaLe varlables Al1L8 Lhe operaLlon l belleve l gave you a very deLalled explanaLlon More examples are ln lecLures and LuLorlals!