VDMSL Case Study - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

VDMSL Case Study

Description:

change the overdraft limit associated with an account; ... 'If I create a new account with an overdraft limit of 200, I will not be allowed ... – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 30
Provided by: aaron63
Category:
Tags: vdmsl | case | overdraft | study

less

Transcript and Presenter's Notes

Title: VDMSL Case Study


1
VDM-SL Case Study
Learning Outcomes
At the end of this lecture you should be able to
  • Analyse and informally specify a complete system
    using UML class diagrams
  • Develop a formal VDM specification from an
    informal UML specification.
  • Rigorously interrogate a formal specification

2
The Requirements Definition
The software is expected to be able to do the
following
  • create a new account
  • remove an existing account
  • record a deposit transaction
  • record a withdrawal transaction
  • update the personal details (name, address and so
    on) of a customer's account
  • change the overdraft limit associated with an
    account
  • produce a statement of transactions associated
    with an account
  • display the balance of an account
  • display the personal details of an account.

3
The UML specification
AccountSys accounts Account addAccount
(AccNum, Details, Real) removeAccount
(AccNum) deposit(AccNum, Date, Real) withdraw(AccN
um, Date, Real) changeDetails(AccNum,
Details) changeLimit(AccNum, Real) getAllTransacti
ons(AccNum) Transaction getBalance(AccNum)
Real getAccount(AccNum) Account getDetails(AccNu
m) Details getLimit(AccNum)
Real getAllAccounts() Account
contains(AccNum) Boolean isEmpty()
Boolean getTotal() Integer
4
Additional types The Account type
Account number AccNum details
Details balance Real limit Real transactions
Transaction
5
Additional types The Transaction type
Transaction date Date type TransactionType amo
unt Real
6
Additional types The TransactionType type
ltltenumerationgtgt TransactionType withdrawal deposi
t
7
Formally specifying the types in VDM-SL
types AccNum TOKEN Date TOKEN Details
TOKEN TransactonType lt withdrawal gtlt deposit
gt
8
Formally specifying the types in VDM-SL
Transaction date Date amount
? transactionType TransactionType inv
mk-Transaction(-,a,-) ? a gt 0
9
Formally specifying the types in VDM-SL
Account number AccNum details
Details balance ? limit
? transactions Transaction inv
mk-Account(-,-,b,l,t) ?
l 0
limit is non-negative
? b -l
balance within limit
? balanceOf(t) b
balance matches transactions
10
Formally specifying the state in VDM-SL
state AccountSys of accounts
Account
AccNum
inv mk-AccountSys(a) ? account numbers in
domain also in range
? num ? dom a ? num a(num).number
init mk-AccountSys(a) ? a ? end
11
Auxiliary functions balanceOf
balanceOf( transIn Transactions ) total
? pre true post let dep transIn(i).amount
i ? inds transIn ? transIn(i).transact
ionType ltdepositgt in let withd
transIn(i).amount i ? inds transIn
? transIn(i).transactionType ltwithdrawalgt
in total sum(dep) - sum(withd)
?
?
true

?
?
?
?
?

?
?
12
Auxiliary functions sum
sum ? ? ? sum(seqIn) ? if seqIn
then 0 else hd seqIn sum(tl seqIn)
13
Operation specifications addAccount
addAccount( ) ext pre post
numberIn AccNum, detailsIn Details, limitIn
?
wr
accounts
numberIn ? dom accounts
? limitIn ? 0
numberIn ? mk-Account(numberIn, detailsIn, 0,
limitIn,
14
Operation specifications removeAccount
removeAccount( ) ext
pre post
numberIn AccNum
wr
accounts
numberIn ? dom accounts
accounts numberIn
15
Operation specifications deposit
deposit( ) ext pre post
numberIn AccNum, dateIn Date, amountIn ?
wr
accounts
? amountIn gt 0
numberIn ? dom accounts
let bal ( (numberIn)).balance
in let trans (
(numberIn)).transactions
in let newTrans mk-Transaction(dateIn,
amountIn,lt depositgt)
in accounts numberIn ?
?( (numberIn), balance ?
bal amountIn, transactions ? trans
newTrans)
16
Operation specifications withdraw
withdraw( ) ext pre post
numberIn AccNum, dateIn Date, amountIn ?
wr
accounts
? amountIn gt 0
numberIn ? dom accounts
? (accounts(numberIn)).balance - amountIn -
(accounts(numberIn)).limit
let bal ( (numberIn)).balance
in let trans (
(numberIn)).transactions
in let newTrans mk-Transaction(dateIn,
amountIn,lt withdrawalgt)
in accounts numberIn ?
?( (numberIn), balance ?
bal - amountIn, transactions ? trans
newTrans)
17
Operation specifications changeDetails
changeDetails( ) ext pre post
numberIn AccNum, detailsIn Details
wr
accounts
numberIn ? dom accounts
accounts numberIn ?
?( (numberIn), details ? detailsIn)
18
Operation specifications changeLimit
changeLimit( ) ext pre post
numberIn AccNum, limitIn ?
wr
accounts
numberIn ? dom accounts
? limitIn ? 0
? accounts(numberIn).balance ? - limitIn
accounts numberIn ?
?( (numberIn), limit ? limitIn)
19
Operation specifications getDetails
getDetails( ) ext pre post
numberIn AccNum
detailsOut Details
rd
accounts
numberIn ? dom accounts
detailsOut (accounts(numberIn)).details
20
Operation specifications getBalance
getBalance( ) ext pre post
numberIn AccNum
balanceOut ?
rd
accounts
numberIn ? dom accounts
balanceOut (accounts(numberIn)).balance
21
Operation specifications getLimit
getLimit( ) ext pre post
numberIn AccNum
limitOut ?
accounts
rd
numberIn ? dom accounts
limitOut (accounts(numberIn)).limit
22
Operation specifications getAllTransactions
getAllTransactions( ) ext pre post
numberIn AccNum
transactionsOut Transaction
rd
accounts
numberIn ? dom accounts
transactionsOut (accounts(numberIn)).transactio
ns
23
Operation specifications contains
contains( ) ext pre post
numberIn AccNum
query ?
rd
accounts
TRUE
query ? numberIn ? dom accounts
24
Operation specifications isEmpty
isEmpty( ) ext pre post
query ?
rd
accounts
TRUE
query ? accounts ?
25
Operation specifications getTotal
getTotal( ) ext pre post
totalOut ?
rd
accounts
TRUE
totalOut card dom accounts
26
Rigorously checking specifications
One of the advantages of formal specifications is
that they can tested before an implementation
is developed.
Test
Test
27
Example
If I create a new account with an overdraft
limit of 200, I will not be allowed to withdraw
300 until after more money has been deposited.
addAccount (AccNum, Details, Real) removeAccount
(AccNum) deposit(AccNum, Date, Real) withdraw(AccN
um, Date, Real) changeDetails(AccNum,
Details) changeLimit(AccNum, Real) getAllTransacti
ons(AccNum) Transaction getBalance(AccNum)
Real getAccount(AccNum) Account getDetails(AccNu
m) Details getLimit(AccNum)
Real getAllAccounts() Account
contains(AccNum) Boolean isEmpty()
Boolean getTotal() Integer
28
Example
If I create a new account with an overdraft
limit of 200, I will not be allowed to withdraw
300 until after more money has been deposited.
addAccount ( AccNum, Details , Real )
001
200
withdraw( AccNum , Date , Real )
001
300
29
addAccount( ) ext pre post
numberIn AccNum, detailsIn Details, limitIn
?
wr
accounts
numberIn ? dom accounts
? limitIn ? 0
001
200
numberIn ? mk-Account( numberIn , detailsIn ,
0, limitIn ,
001
001
200
withdraw( ) ext pre
numberIn AccNum, dateIn Date, amountIn ?
wr
accounts
300
? amountIn gt 0
numberIn ? dom accounts
001
? (accounts(numberIn)).balance - amountIn -
(accounts(numberIn)).limit
001
001
300
Write a Comment
User Comments (0)
About PowerShow.com