Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.
-
Upload
brenda-skinner -
Category
Documents
-
view
213 -
download
1
Transcript of Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.
![Page 1: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/1.jpg)
1
Formal Methods and Models
Z Specification of the Library System
Boumediene BelkhoucheFall 2012
![Page 2: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/2.jpg)
2
Library System Description The library has many books on different topics The library has registered readers A book may have several copies Each copy in the library has a unique ID Each reader has a unique ID At any time a certain number of copies of books
are on loan to readers A reader cannot borrow more than a certain
maximum Available books are kept on the library shelves A book can be borrowed or returned When a book is returned, it is put back on the shelf
![Page 3: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/3.jpg)
3
Library System Operations
Issue a copy of a book to a reader (borrow) Return a copy of a borrowed book by the
reader Add a copy of a book to the library Remove a copy of a book from the library Enquire which books are borrowed by a
given reader Enquire which reader has a given book Register a new reader Remove an existing reader
![Page 4: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/4.jpg)
4
A Z Specification Consists of 4 parts
Given sets, data types and constants
State definition Initial state Operations
![Page 5: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/5.jpg)
5
Z Specification of the Library1. Given Sets [Book, Copy, Reader]
NB. Symbols used:
⇸ ↦ Ξ ∀ × → Δ ≠ ∧ ∨ ∉ ∈ ∃ ℤ ℕ ℙ ℝ ∅ ≙
![Page 6: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/6.jpg)
6
Z Specification of the Library2. State definition
Librarystock: Copy ⇸ Bookissued: Copy ⇸ Readershelved: Copyreaders: Reader
shelved dom issued = dom stockshelved dom issued = ran issued readers∀ r : readers #(issued {r}) maxloans
![Page 7: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/7.jpg)
7
Explanationsstock records copies of books in the libraryissued records which copies are on loan and
to whomshelved is a subset of the copies on the
shelves and available for borrowingreaders is the set of registered readers
![Page 8: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/8.jpg)
8
Z Specification of the Library3. Initial State Library_Init
ΔLibrary
shelved’ = Ø
issued’ = Ø
readers’ = Ø
![Page 9: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/9.jpg)
9
![Page 10: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/10.jpg)
10
Symbols used:
⇸ ↦ Ξ ∀ × → Δ ≠ ∧ ∨ ∉ ∈ ∃ ℤ ℕ ℙ ℝ ∅ ≙ : Teacher-Course {ITBP120} tuples whose second element is “ITBP120” are
returned. : { bb } Teacher-Course tuples whose first element is “bb” are returned. : dir {num?}tuples whose second element is “num?” are
removed. : {name?} dir tuples whose first element is “name?” are removed.
![Page 11: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/11.jpg)
11
Function override operator
Function override adds pairs from f1 to f2 such that it:
acts as a domain subtraction and a set union, if any element of f2 is mapped anywhere by f1,
{Noura Œ projectA } {Noura Œ newProj}
=
({Noura } studentproject) {Noura Œ newProj}
![Page 12: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/12.jpg)
12
Z Specification of the Library4. Operations
WcopiesOK Library
c! : Copy r? : Reader r? ∈ readers
c! = dom (issued {r?})
Restricts range to only those elements of the argument
![Page 13: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/13.jpg)
13
Z Specification of the Library4. Operations
RemoveCopyOK Library c? : Copy
c? ∈ shelved shelved’ = shelved \ {c?}stock’ = {c?} stock
Restricts the domain to only those elements not equal to the argument
![Page 14: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/14.jpg)
14
Z Specification of the Library4. Operations
Borrow Library
c? : Copy r? : Reader c? ∈ shelved r? ∈ readers
# (issued {r?}) maxloansissued’ = issued {c? ↦ r?}
shelved’ = shelved {c?}stock’ = stock; readers’ = readers
![Page 15: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/15.jpg)
15
Z Specification of the Library4. Operations
Return Library
c? : Copy r? : Reader c? ∈ dom issued r? ∈ readers
issued’ = issued {c? ↦ r?} shelved’ = shelved {c?}
stock’ = stock; readers’ = readers
![Page 16: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/16.jpg)
16
A Z Specification for the Library IS4. Operations
WhoHasCopy Ξ Library
c? : Copy; r! : Reader
c? ∈ dom issued r! = issued (c?)
![Page 17: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/17.jpg)
17
Z Specification of the Library4. Operations
RegisterReader Library r? : Reader
r? ∉ readers readers’ = reader {r?}
![Page 18: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/18.jpg)
18
Z Specification of the Library4. Operations
RemoveReader Library r? : reader
r? ∈ readers readers’ = reader {r?}
What if r? has borrowed books?
![Page 19: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/19.jpg)
19
Z Specification of the Library4. Operations
AddCopyReport Ξ Library stock: Copy ⇸ Book b? : Book rep! : Report
b? ∈ ran stock rep! = CopyAdded b? ∉ ran stock rep! = NewTitleAdded
![Page 20: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/20.jpg)
20
Z Specification of the Library4. Operations
EnterNewCopy Library b? : Book
c: Copy c ∉ dom stock
stock’ = stock {c ↦ b?} shelved’ = shelved {c}issued’ = issued; readers’ = readers
![Page 21: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/21.jpg)
21
Z Specification of the Library4. Operations
AddCopy ≙ EnterNewCopy ∧ CopyReport
![Page 22: Z Specification of the Library System Boumediene Belkhouche Fall 2012 1.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e905503460f94b943d7/html5/thumbnails/22.jpg)
22
Z Specification of the Library4. Operations
Execise: do
1. Which books a reader has2. Remove a copy from the library