FORMAL METHODS

FORMAL METHODS

Question 1: Answer
(a)    Operation Price
This is defined as:
Price
?StockDB
Quantity? : Quantity
——————————
Quantity’ e Accepted \ allowed
Accepted’ = Accepted {stock?}
Adopts’ = Permits

(b)    Operation Restock
RestockOK
?StockDB
Goods? : CAR
—————————–
Goods’ e Accepted \ Allowed
Capacity’ < RequiredCapacity {Stock?}
RestockOK’ = Permits
(c)    Sumbag
Sumbag = (10 + 2 + 3 + 3 + 4 + 10) = 32
(d)    Vend
?Stock
Goods? : BagGoods
—————————–
Coins’ e Accepted \ Allowed
Capacity’: Insert {Coin?}
Cost – Coins = Change
Question 2: Answer
(a)    Operation SelectPrinter
SelectPrinter
Printer: Group {laser, color}
———————————————————
Input: Name
(b)    Operation QueueFile
QueueFile
Input: {PrinterName, File}
——————————————————–
File? Queue

(c)    SelectPrinter Schema
QueueFile: File
SubmitJob? (filename, Group)
——————————————————————-
AddFile: PrinterQueue
(d)    Operration Print
Print
PrinterName, QueueFile
QueueFile: Print
Question 3: Answer
(a)    FilteringCache
FilteringCache
MaxURLs: N
————————————————-
MaxURLs >0)
(b)    AddCacheEntry
AddCacheEntry
NewURL, Space > MaxURLs,
———————————————————————-
Access: Allowed
(c)    AddFullCache
AddFullCache
NewURL: N
———————————————————————
MaxURLs > 0
Access < N
(d)    AddURL (NewURL: Filter, URL<>N)
AddURL
(NewURL: Filter
———————————————————-
URL<>N
(e)    The specification provides a suitable starting point for programming because it separates the URLs into valid variables for the Cache and the Filter. The

specification assists in the construction of the algorithm using the variables identified., hence it will reduce the chances of logical errors in programs.
Question 5: Answer
(a)    State Schema
SportsHireSystem
Equipment: (EquipmentName, serialnumber, value)
ModelState (sport1, sport)
(b)    Schema Hire
Hire (EquipmentName, EquipmentNumber, Customer)
(c)    The Hire Operation may fail if the number of customers in need of the equipment exceeds the number of available equipment.
Schema:
Hire ?NumberOfCustomers > NumberOfEquipment
(d)    Implementing the specification
I choose C++ as my programming Language
I write an algorithm, which compares the number of equipment to that of the customers as follows.
Public void int Enquire()
Int cust, eq;
Cout<<”Input the number of customers (cust)”
Cin>>cust;
Cout<<”Input the number of equipment (eq)”

READ ALSO :   LASA—Applying Cultural Theoretical Approache

Paper 2011 – 2013
Question 1: Answer
(a)    A state invariant records the constraints upon, and relationships between, state variables.
(b)    —– InitClubDB ——-
PersonMemberOfCategory
InitClubDB
Person
Category
———————-
Person? e MemberOf
? InitClubDB
Category = Category
MemberOf = MemberOf \ (People?)
(C)
Person e Category
Category e InitClubDB
Person e InitClubDB
There is no contradiction in the constraints, hence, a valid state exists and the specification is not meaningless
(c)    Operation JoinOK enforces the rule for joining the group or category.
JoinOK New Member (Categories, Members, Group)
A person Becomes member when qualification is attained
—– JoinOK ——-
CategoryDB
Person? PERSON
———————–
Person? e Qualified \ Joins
Joins’ =Joins\ {Group?}
Qualified = Qualified
(d). Precondition of the JoinOK is a Boolean expression of the condition defining when an operation is expected to take place.
Calculation:
pre JoinOK = ? CategoryDB _ JoinOK
Question 2:  Answer
(a)    Set Definition
Film = (Film1, Film 2—–FilmN)
Writer = (W1, W2 —-WN)
Director = (D1, D2….Dn)
(b)    State Schema FilmInfo
———– FilmInfo ———–
Director? : Director
Writer? : Writer
———————–
Film e Writes
Directed’ = Directed
Writes’ = Writes / Film
(c)    Partial Operation AddFilm
——— AddFilm ———
Film: Film
Writer: Writer
Director: Director
—————————-
Film e Directed \ Writes
Directed’ = Directed
Writes’ = writes U {Film?}
(d)    Partial operation FilmCreated
————- FilmCreated ——-
Film
Film’
D? : Director
W? : Writer
—————————-
D? e Directing
Directing?’ = Directing U {D? ?F?}
Directing’ = Directing

(e)    Partial Operation NotSameDirector

— NotSameDirector –
Film
Director? : Director
Film? :Director! = {Director}
Question 3: Answer
(a)    State Variable : Parent
Option 1
— Parent —
Person: Person
Child, Child’: Person
Parent, Parent’: Person
—————————
Parent
Option 2
— Parent —
Person: Person
Child, Child’: Person
Parent, Parent’: Person
—————————
Child
I would choose the second option because it demonstrates the many to one realtionship. This is because all people (both parent and child) fall in the set of child. A

READ ALSO :   Corporate tax : Basis rules

parent is a child to someone, but not all children are parents.
(b)    State Schema GenDB
—– GenDB ——
Person: : = Parent | Child
Sex :: = male | female
—————————————
Parent, Child: Person
Child e Parent= {Male, Female}
(c)    Operation AddRelationship
—— AddRelationship —-
Parent: Person
Child: Person
Sex ::= Male | Female
——————————–
Child! e Person
Parent! e Person
(d)    ChangeName Operation
Parent: Person
Child: Person
N! : Name
——————————–
Sex ::= Male | Female
NewName ! = #(name \ namegiven)

Question 5: Answer

(a)    Warehouse
—— Warehouse—–
?Item
———————————
ItemNumber : N ? N1
N’ = N + 1 V
N’ = N1
(b)    Axiomatic Function
StockLevel = SumStock(6 + 8 + 12 + 7 + 7 + 4 + 5) = 49
(c)    Operation schema DailyOrder
?DailyOrder
Stock: N
——————————
ReorderLevel: Stock ? 49
NewOrder = N1e (N1 < 49)

(d)    Partial Operation ReceiveStock
?ReceiveStock
Stock: N1
NewOrder: N
—————————
Stock ‘= stock
Stock: = Stock U NewOrder
(e)    Partial Operatioon DisdpatchOrder
?DisdpatchOrder
Stock: N1
Order: N
—————————
Stock ‘= stock
Dispatched’: dispatched
Stock: = Stock (N1 – DispatchedOrder)

PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET AN AMAZING DISCOUNT 🙂