schemas. nature of a schema: scope of names in a z specification names that are not confined inside...

56
Schemas

Post on 20-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Schemas

Nature of a schema: scope of names in a Z specification

• Names that are not confined inside schemas.• Need to declare and called as global declaration• Names introduced are called global variables

- names of given sets

- names introduced by syntactic equivalence

- names introduced by axiomatic description

- names introduced by generic definition

- names of data types

- names of schemas

• A schema contains a declaration part and a predicate part

• Declaration part declares some local declarations• Predicate part expresses some requirements about

values of the variables• The name of a schema will be used elsewhere in the

document to refer to the mathematical text

example

• If userid and Password are given sets

Time_sharing

password: Userid ↛ Password

logged_on : ℙ Userid

logged_on dom password

• Res ≙ [ w: Title ↛ seq Person | sp : ran w • sp ≠ ‹›]

Declaration part

• Introduces some names and establishes their types• To establish the type of the names we can use any

names of sets that are globally declared• These sets can be used in any of the constructions that

yield set values such as

- power set

- union, intersection etc

- cartesian product

- relation, function etc

- domain, range, etc

example

Library

on_loan, on-shelves, books : ℙ Book

borrowers : ℙ Person

lent_to : Book ↛ Person

on_loan, on_shelves, books, and borrowers are declared to be set values, but they are not known in the declaration part of this schema, and cannot be used here.

example

• The notions that

- the books that are associated with borrowers in lent_to are exactly the books in on_loan, and

- the persons associated with the books in lent_to must all be members of borrowers

cannot be formalized by declaring

lent_to : on_loan borrowers

but must be formalized in the predicate part

Predicate part

• Defines conditions that constrain the values declared in the declaration part

• The names used in the construction of predicates must be either:

- globally declared, or

- declared in the declaration part of the schema

example

Library

on_loan, on-shelves, books : ℙ Book

borrowers : ℙ Person

lent_to : Book ↛ Person

on_loan = dom lent_to

ran lent_to borrowers

on_loan on-shelves = books

on_loan on-shelves =

Example : informal explanation

• The books on loan are exactly those for which we have a record of a borrower

• Books can only be recorded as having been lent to known borrowers

• Every book belonging to the library is either on loan or on the shelves

• No book can be recorded as being on loan and on the shelves