Z Specification
Z Specification
Submitted by:
AMNA 3046/FBAS/BSSE/F16A
ADEELA FAROOQ 3044/FBAS/BSSE/F16A
Submitted to:
SIR AHSAN
Register
EMAIL: := set of users email
UNAME ::= set of usernames of the system
PWORD ::= set of passwords of the system
MESSAGE :: = set of output messages of the system
initialization schema
init
Register
Username=∅
Email=∅
operational schema
Register
Δ Register
userfirst? : UNAME
userlast? : UNAME
eml? : EMAIL
pass? : PWORD
msg!: MESSAGE
(eml? ∉ Email) ⇒
( Email′ = Email ⋃ { eml? }) ∧ (Username′ = Username ⋃ {userfirst? ∪ userlast?} ∧
( Password ′= Password ⋃ {eml? ↦ pass? } )
msg ! = “ hi”username
RegisterFail
Ξ Register
eml? : EMAIL
msg ! : MESSAGE
eml? ∈ Email ⇒
msg ! = “ Email entered is registered already”
▪ Login
login
username : ℙUNAME
password : UNAME ⇸ ℙWORD
active : ℙUNAME
username = domain password
active ⊆ username
initialization schema
init
login
username = ∅
active = ∅
operational schema
login
Δlogin
User? : UNAME
Pass? : ℙWORD
Msg! MESSAGE
User? ∉ active
Pass? = password(user?)
active′ = active ∪ {user?}
msg! = “hi”user?
logout
Δlogin
u?:UNAME
u? = username
u?∈ active
active′ = active ⧹{u?}
▪ manage profile
userinfo::=set of userinformation
UNAME ::= set of usernames of the system
account::=set of registered accounts
active::=set of username who are active
state space schema
manageprofile
u:UNAME
acc: Account
u∈ active
u ∈ username
initialization schema
init
manageprofile
accounts=∅
active= ∅
operational schema
deleteaccount
Δmanageprofile
acc?Account
acc? ∈ accounts
accounts′ = accounts⧹{acc?}
changeinfo
Δmanageprofile
Username? UNAME
Info? userinfo
∃ account : Account | account ∈ accounts ∧ account(username)=username?
account(info) = info?
account′ = account
detdetails
≙manageprofile
Username? : UNAME
msg! : userinfo
∃a: Account | a∈ accounts ∧ a(username)= username? ⦁
msg! =a(info)
changepassword
Δmanageprofile
Δlogin
User? UNAME
Oldpass?ℙWORD
newpass?ℙWORD
user?∈username ∧ oldpass? = password(user?)⇒
password′ = password ⧹{user? ↦ password(user?)} ∪ {user? → newpass?}
add account
Δregister
acc?Account ;
acc? ∉ accounts
accounts′= accounts ∪ {acc?}
▪ Place order
Order::=set of orders
UNAME ::= set of usernames of the system
operational schema
create order
Δplaceorder
Order?:order
User? : UNAME
Oid? : ID
User? ∈ username
order? ∉ orders
orders′ = orders ∪ {order?}
update order
Δplaceorder
Order? : order;
order? ∈ orders
order′ = order?
Remove order
Δplace order
Order?:order
Order? ∈ orders
orders′ = orders ⧹{order?}
▪ Sale
Sales::=set of offers/sales
Products::=set of products availible
initialization schema
init
sale
sales=
sales = ∅
operational schema
create sale
Δsale
Sale? :SALE
product? :ID
oid! : ID
(sale? ∉ sales) ∧ (product? ∈ products) ⇒
sales′ = sales ∪ {sale?}
oid! = sale?(oid)
update sale
Δsale
Price? : double;
Oid? : ID;
∃ sale : SALE | sale ∈ sales ∧ sale(oid) = oid? ⦁
sale(price) =price?
sale′ =sale
remove sale
Δsale
oid? : ID
∃ sale : SALE | sale ∈ sales ∧ sale(oid) = oid?⦁
sales′ = sales ⧹ {sale}
▪ Favourites
initialization schema
initi
favourite
favourites = ∅
operational schema
add pdoduct
Δfavourite
Pro? : PRODUCT
(pro? ∈ products) ∧ (pro? ∉ favourites)⇒
favourites′ = favourites ∪ {pro?}
remove product
Δfavourites
Pro? PRODUCT
(pro? ∈ products ) ∧ (pro? ∈ favourites) ⇒
favourites′ = favourites⧹{pro?}
view favourites
≙favourites
Favourite! : PRODUCT
U? : UNAME
U? ∈ username
Favourite! = u?(favourite)
▪ Store
Stores::=set of stores
Address:=set of addresses
initialization schema
init
store
stores = ∅
operational schema
create store
Δstore
Store ? : STORE
Sid!: id
Store? ∉ stores
stores′ = stores ∪ {store?}
sid ! = store?.sid
change address
Δ store
add? : ADDRESS
Sid? : id
∃ store : STORE | store ∈ stores ∧ store(sid) = sid? ⦁
Store(address) = add?
store′ = store
remove store
Δ store
Sid? :id
∃ store : STORE | store ∈ stores ∧
Store(sid) = sid? ⦁
stores′ = stores⧹{store}
get details
≙ store
Result! Store
Sid? : id
∃ store : store | store ∈ stores ∧
Store(sid) = sid? ⦁
Result! = store
▪ Address book
Address:=set of addresses
UNAME := set of username
Initialization schema
init
Address book
address = ∅
operational schema
add address
Δ Address book
U? :UNAME
Ph#? :ADDRESS
Pincode? : ADDRESS
City?: ADDRESS
State? : ADDRESS
Streetname?: ADDRESS
u? ∈ username
address′ = address ∪ {u? → (ph#? , pincode?, city?, state?,streetname?)}
▪ checkout
UNAME ::= set of usernames of the system
initialization schema
init
checkout
orders = ∅
operational schema
shippinfo
Δcheckout
Shipadd? STRING
u? : UNAME
update user : USER
u? ∈ username
updateuser(address) = shipadd?
user′ = user⧹{u?} ∪ updateuser
ordersummary
≙checkout
U? : UNAME
O? : ORDER
Price ! : double
Qty? : ℕ
Ordersummary! : int
(u? ∈ username ) ∧ (o? ∈ order)
o.qty? * o.price!
get payment
Δ checkout
U? :UNAME
Payment method ! : string
Updateuser : USER
U? ∈ username ∧
Updateuser(payment method) = paymaent mathod? ⇒
user′ = user ⧹{u?} ∪ update user
▪ Product
Products::=set of products
operational schema
create product
Δ product
Pro? : product
Id? : id
Details? : string
Pro? ∈ products
∃ p: product | p∈ products ∧ p(id) = pro?(id) ⦁
products′ = products ∪ {pro? , details}
id! = pro?(id)
change price
Δproduct
Id?:id
∃ product :product | product ∈ products ∧ product(id) = id? ⦁
Product(price) = price?
products′ = products
delete product
Δ product
Id ? :id
∃ product : product | product ∈ products ∧ product(id) = id? ⦁
Products′ = productn⧹ {product}
Get deatails
≙ product
Id? : id
Result! : product
∃ product : product | product ∈ products ∧ product(id) = id? ⦁
Result ! = product
checkstock
≙ product
Id? : id
R! = Response
If id? ∈ Product
If Qtty > 0
R! = Success
Else
R! = Failed
Else R! = Failed
▪ Order history
Orderslist::=set of all orders
Order list
Order list : olist
Orderslist : ℙlist
Oid : id
Olid : id
Orderlist ⊆ product
initialization schema
init
order history
orderslist = ∅
operational schema
add orderlist
Δ orderlist
Oid? : id
Orderslist? : olist
∃ o : olist | o ∈ orderlist ∧
O(oid) = oid? ⦁
Orderlist? ∉ orderslist
orderslist′ = orderslist ∪ {orderlist?}
delete orderlist
Δorderlist
Oid? : id
∃ orderL : olist | orderL ∈ orderslist ∧
orderL(olid) = olid? ⦁
orderslist′ = orderslist ⧹ {orderL}
▪ Search item
Products::=set of products
searchitem
pro:PRODUCT
id:ID
pro ⊆products
initialization schema
init
searchitem
products=∅
operational schema
search
≙searchitem
Pro?:PRODUCT
P!: PRODUCT
Pro? ∈ products⦁
P!=product(pro?)
▪ Category
Category::=set of catagories present in system
Initialization Schema
Init
Category
Category = ∅
Operational Schema
AddCategory
Δ Category
option? : CATGRY
option ? ∉ Category ⇒
category′=category ⋃ {option?}
RemoveCategory
Δ Category
option? : CATGRY
option ? ∈ Category ⇒
category′=category ∖ {option?}