introduction to the z example two. 2 write z specifications for the birthday book problem the...

11
Introduction to the Z Example Two

Upload: natalie-owen

Post on 22-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

Introduction to the ZExample Two

Page 2: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

2

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.

Page 3: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

3

The Z specification should include:

Given Sets State Schema Initial State Operations

Page 4: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

4

The Birthday Book Z Specification

1. Given Sets [NAME,DATE]

Page 5: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

5

The Birthday Book Z Specification

2. State definition

BirthDayBook

known: ℙ NAME

Birthday: NAME ⇸ DATE

known = dom birthday

Notation: D ⇸ R

⇸ ↦ Ξ ∀ × → Δ ≠ ∧ ∨ ∉ ∈ ∅ ∃ ℤ ℕ ℙ ℝ ≙

Page 6: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

Birthday Function: Example

known = {Ahmed, Zaid, Qais} birthday = {Ahmed ↦ 17-Ram, Zaid ↦ 27-Sha, Qais ↦ 10-Raj}

The notation x ↦ y

Page 7: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

7

The Birthday Book Z Specification

3. Initial State BirthDayInit

BirthdayBook

known = Ø

Page 8: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

8

The Birthday Book Z Specification

Operations

1. Add birthday2. Find birthday3. Remind

Page 9: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

9

The Birthday Book Z Specification

4. Operations (AddBirthday) AddBirthday BirthdayBook

name? : NAMEdate?: DATE

name? knownknown’= known {name?}birthday’ = birthday {name? ↦ date?}

Page 10: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

10

The Birthday Book Z Specification

4. Operations (FindBirthday) FindBirthday BirthdayBook

name? : NAMEdate!: DATE

name? known

date! = birthday(name?)

X

Page 11: Introduction to the Z Example Two. 2 Write Z specifications for the Birthday Book Problem  The Birthday Book system keeps track of people’s birthdays

11

The Birthday Book Z Specification

4. Operations (Remind) Remind BirthdayBook

cards! : ℙ NAMEtoday?: DATE

cards!= {n: known | birthday (n) = today!}

X