1 / 28

CIT Phone Directory Z Specification Document

CIT Phone Directory Z Specification Document. Sections of a Z document. I ntroduction Types used in the specification State and its invariant properties Initial state Operations and enquiries Error handling Final versions of operations and enquiries. 1. Introduction.

sukey
Download Presentation

CIT Phone Directory Z Specification Document

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIT Phone Directory Z Specification Document

  2. Sections of a Z document • Introduction • Types used in the specification • State and its invariant properties • Initial state • Operations and enquiries • Error handling • Final versions of operations and enquiries

  3. 1. Introduction • The CIT wants to write Z specifications for their phone directory. Some people have two phones, and others may share the same phone.

  4. 2. The Types [PERSON, PHONE] RESPONSE :: = OK | alreadyKnown |notKnown

  5. 3. State definition • Directory • staff: ℙ PERSON • dir: PERSON  PHONE • staff = dom dir X  Y is the set of relations between X and Y

  6. 4. Initial State Init Directory staff = 

  7. 5. Operations (AddItemOK) AddItemOK  Directory name?: PERSON num? : PHONE; r!: RESPONSE {name? ↦ num?}  dir staff’ = staff  {name?} dir’ = dir  {name? ↦ num?} r!=OK

  8. 5. Operations (DeleteItemOK) DeleteitemOK  Directory name? : PERSON num? : PHONE name? Œ num?dir dir’ = dir \ {name? ↦ num?}

  9. Using maplet notation • The mapletŒsymbol is used to describe the relation elements:TeacherCourse == { bb ŒITBP120, hhŒITBP220, yaŒITBP120, bb ŒSWEB320} bb ŒITBP120 is read as “bb maps to ITBP120”.

  10. Relations: domain and range • Teacher-Course== { b ŒITBP120, hhŒITBP220, yaŒITBP120, bb ŒSWEB320} • Domain: domTeacher-Course= { bb, hh, ya} • Range: ran Teacher-Course= { ITBP120, ITBP220, SWEB320}

  11. Operations on relations • Teacher-Course== { bb ŒITBP120, hhŒITBP220, yaŒITBP120, bb ŒSWEB320} • Domain restriction Restricts the relation to only those pairs in which the first element is contained in the set provided: { hh} Teacher-Course= { hhŒITBP220 }

  12. Operations on relations • Range restriction Restricts the relation to only those pairs in which the second element is contained in the set provided: Teacher-Course {ITBP120} = { yaŒITBP120, bb ŒITBP120 }

  13. Operations on relations (continued) • Domain subtraction  (also known as domain anti-restriction) Restricts the relation to only those pairs in which the first element is not contained in the set provided: { bb } Teacher-Course = {hhŒITBP220, yaŒITBP120}

  14. Operations on relations (continued) • Range subtraction (also known as range anti-restriction) Restricts the relation to only those pairs in which the second element is not contained in the set provided: Teacher-Course  { ITBP120 } = {hhŒITBP220, bb ŒSWEB320}

  15. 5. Operations (DeleteNameOK) DeleteNameOK  Directory name? : PERSON name? staff dir’ = ????? means the tuples whose first element is “name?” will not appear in dir’.

  16. 5. Operations (DeleteNameOK) DeleteNameOK  Directory name? : PERSON name? staff dir’ = {name?}  dir means the tuples whose first element is “name?” will not appear in dir’.

  17. 5. Operations (DeleteNumOK) DeleteNumOK  Directory num? : PHONE num? ran dir dir’ = ?????  means the tuples whose second element is “num?” will not appear in dir’.

  18. 5. Operations (DeleteNumOK) DeleteNumOK  Directory num? : PHONE num? ran dir dir’ = dir  {num?}  means the tuples whose second element is “num?” will not appear in dir’.

  19. 5. Operations (ListNumOK) ListNumOK Directory name? : PERSON phones! : P PHONE name? staff phones! = {n: PHONE | (name? ↦ n) dir}

  20. 5. Operations (ListNamesOK) ListNameOK  Directory num? : PHONE names! : P PERSON num? rang dir names! = {n: PERSON | (n ↦ num?) dir}

  21. 5. Error Handling AddItemError UAEUSystem name? : PERSON num? : PHONE reply! : RESPONSE (name? ↦ num?) dir reply! = alreadyKnown

  22. 6. Final Versions of Operations and Enquiries The final versions of operations can be specified, in a linear form, as follows: AddItem≡AddItemOK v AddItemError

  23. Modification of functions Consider the following function: studentproject: PERSON  PROJECT studentproject = { NouraŒprojectA, Aisha ŒprojectB} If Noura has changed a project, we should change our function. How? We can use Union: studentproject’ = studentproject { NouraŒnewProject } But this produces a relation, not a function: studentproject’ = {NouraŒprojectA, Aisha ŒprojectB , NouraŒnewProject }

  24. Modification of functions (continued) As a solution, Z provides the function override operator  studentproject’ = studentproject{ NouraŒnewProject } So the new studentproject set is: {NouraŒnewProject, AishaŒprojectB}

  25. Function override operator Function override adds pairs from f1 to f2 such that it: • acts as a set unionwhen no element of f2 is mapped anywhere by f1 (domf1 domf2 = ), {NouraŒprojectA }  { KhadijaŒ projectC } ={NouraŒprojectA }  {KhadijaŒ projectC }

  26. 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}

  27. The Exam Schedule Z Specification Operations (AddExam) AddExam  ExamSchedule course? : COURSE date?: DATE course?  courses courses’=courses {course?} exam’ = exam  {course?  date?} Difference between and

  28. The Exam Schedule Z Specification Operations (ChangeDate) ChangeDate  ExamSchedule course? : COURSE date?: DATE course?  courses exam’ = exam  {course?  date?} Difference between and

More Related