110 likes | 210 Views
Introduction to the Z Example Two. Write Z specifications for the Birthday Book Problem. The Birthday Book system keeps track of people’s birthdays. It allows you to add and search for birthdays. Also, it issues reminders. The Z specification should include:. Given Sets State Schema
E N D
Write Z specifications for the Birthday Book Problem • The Birthday Book system keeps track of people’s birthdays. It allows you to add and search for birthdays. Also, it issues reminders.
The Z specification should include: • Given Sets • State Schema • Initial State • Operations
The Birthday Book Z Specification 1. Given Sets [NAME,DATE]
The Birthday Book Z Specification • State definition • BirthDayBook • known: ℙ NAME • Birthday: NAME ⇸DATE • known = dombirthday • Notation: D⇸ R • ⇸ ↦ Ξ ∀ × → Δ ≠ ∧ ∨ ∉ ∈ ∅ ∃ ℤ ℕ ℙ ℝ ≙ •
Birthday Function: Example • known = {Ahmed, Zaid, Qais} • birthday = {Ahmed ↦ 17-Ram, Zaid↦ 27-Sha, Qais↦ 10-Raj} • The notation x ↦ y
The Birthday Book Z Specification 3. Initial State BirthDayInit BirthdayBook known = Ø
The Birthday Book Z Specification Operations Add birthday Find birthday Remind
The Birthday Book Z Specification Operations (AddBirthday) AddBirthday BirthdayBook name? : NAME date?: DATE name? known known’= known {name?} birthday’ = birthday {name? ↦ date?}
The Birthday Book Z Specification Operations (FindBirthday) FindBirthday BirthdayBook name? : NAME date!: DATE name? known date! = birthday(name?) X
The Birthday Book Z Specification Operations (Remind) Remind BirthdayBook cards! : ℙ NAME today?: DATE cards!= {n: known | birthday (n) = today!} X