Download Schemas-Formal Specification Methods in Software Development-Lecture Slides and more Slides Software Development Methodologies in PDF only on Docsity!
Chapter No. 11
Schemas
Introduction
- In the Z notation there are two languages
- the mathematical language and
- the schema language.
- The mathematical language is used to describe various aspects of a design - objects, and - the relationships between them.
- The schema language is used to structure and compose descriptions - collating pieces of information, encapsulating them, and naming them for re-use. docsity.com
Introduction
- We believe that the use of schemas helps to promote a good specification style.
- However, as with any notation, the language of schemas requires careful and judicious application if it is not to be abused.
- We should take care to develop simple theories and to use schemas to present them in an elegant and comprehensible fashion.
Introduction
- This chapter is an introduction to schemas their appearance, and information it contain
- We see how they may be used as types, as declarations, and as predicates.
- In subsequent chapters, we present a language of schema operators, and show how schemas may be used in reasoning about formal descriptions.
The Schema
- One of the most basic things that we can do to help the reader or indeed the writer of a specification is to identify commonly used concepts and factor them out from the mathematical description of a system.
- In this way, we can encapsulate an important concept and give it a name, thus increasing our vocabulary and our mental power.
The Schema
- In formal specifications, we see a pattern occurring over and over again: a piece of mathematical text which is a structure describing some variables whose values are constrained in some way.
- We call this introduction of variables under some constraint a schema.
Example: Concert Hall
- The box office maintains a record of which seats have been sold, and to whom.
- This relationship is a functional because no seat can be sold to two different customers: sold ³ Seat © Customer
- To allow for the possibility that seats may be added to or removed from, we introduce a set seating, a subset of Seat, to represent the seating allocated for the performance.
Example: Concert Hall
- It should not be possible to book seating that has not been allocated; the following predicate should be true at all times dom sold º seating
- That is, the domain of sold should be a subset of seating.
- This property, together with the declarations of sold and seating, forms a schema which we shall call BoxOffice.
Formalizing Box Office
Example 11.3 We can write the box office schema in horizontal form, as
[Seating : ¡ Seat; sold : Seat © Customer | dom sold º seating]
Or in vertical form as
[Seating : ¡ Seat; sold : Seat © Customer
dom sold º seating]
Associating Names with Schema
- The schema language includes a special operator for associating names with it.
- Horizontal
Name á [declaration | predicate
Name declaration
predicate
Constraint as a Part of Predicate
- Declaration part of box office includes constraint that relation sold between Seat and Customer must be functional.
- The following schema, in which this constraint appears as part of the predicate, is entirely equivalent:
BoxOffice [Seating : ¡ Seat; sold : Seat ¨ Customer
dom sold º seating]^ sold ³ Seat © Customer
Another Way of Defining Schema
Example : 11.6 The schema of Example 11.5 could be written in the following form:
BoxOffice Seating : ¡ Seat sold : Seat ¨ Customer
dom sold º seating sold ³ Seat © Customer
Schemas as Type
- Schema below corresponds to a composite data type with two components: an integer called a, and a set of integers called c.
SchemaOne a : ¤ c : ¡ ¤
- We may introduce elements of this type in the usual way: the declaration s : SchemaOne introduces an object s of schema type SchemaOne.
Binding in a Schema
- To write an object of schema type in extension, we list the component names and the values to which they are bound. This requires a new piece of notation:
Ýa â 2, c â {1, 2, 3}Þ
is a binding in which a is bound to 2 and c is bound to the set {1, 2, 3}