Presentation is loading. Please wait.

Presentation is loading. Please wait.

10 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.

Similar presentations


Presentation on theme: "10 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal."— Presentation transcript:

1 10 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Schemas

2 10 May 2009Instructor: Tasneem Darwish2 Outlines The schema Schemas as types Schemas as declarations Schemas as predicates Renaming Generic schemas

3 10 May 2009Instructor: Tasneem Darwish3 Schemas 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: collecting pieces of information, encapsulating them, and naming them for re-use.

4 10 May 2009Instructor: Tasneem Darwish4 Schemas The mathematical language of Z is powerful enough to describe most aspects of system behaviour. but the unstructured application of mathematics results in descriptions that are difficult to understand. A schema is a piece of mathematical text which is a structure describing some variables whose values are constrained in some way.

5 10 May 2009Instructor: Tasneem Darwish5 Schemas Example 11.2 A concert hall uses a software system to keep track of bookings for performances. Inside the hall is a certain amount of seating, some or all of which may be made available to customers for a given performance.  we introduce seats and customers, as given sets:  The box office maintains a record of which seats have been sold, and to whom  no seat can be sold to two different customers (this relation is a function)  a set seating, a subset of Seat, to represent the seating allocated for the performance.

6 10 May 2009Instructor: Tasneem Darwish6 Schemas Example 11.2 A concert hall uses a software system to keep track of bookings for performances. Inside the hall is a certain amount of seating, some or all of which may be made available to customers for a given performance.  It should not be possible to book seating that has not been allocated; the following predicate should be true at all times  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.

7 10 May 2009Instructor: Tasneem Darwish7 Schemas A schema consists of two parts: 1)a declaration of variables; 2)and a predicate constraining their values. We can write the text of a schema in one of two forms: 1)Horizontally 2) Vertically

8 10 May 2009Instructor: Tasneem Darwish8 Schemas Example 11.3 We can write the box office schema in horizontal form, as or in vertical form, as The order in which variables are introduced is unimportant.

9 10 May 2009Instructor: Tasneem Darwish9 Schemas We may name a schema by writing Or by embedding the name in the top line of the schema box Example 11.4 We can name the box office schema text by writing

10 10 May 2009Instructor: Tasneem Darwish10 Schemas Two schemas are equivalent if they introduce the same variables, and place the same constraints upon them Example 11.5 The following two schemas are equivalent

11 10 May 2009Instructor: Tasneem Darwish11 Schemas we may put each declaration on a new line, and leave out the semicolons. Also, we may put each conjunct on a new line, and leave out the conjunction symbols. For example, the predicate is another way of writing This is not the case where the line is broken with another operator

12 10 May 2009Instructor: Tasneem Darwish12 Schemas Example 11.6 The schema of Example 11.5 could be written in the following form: If the schema text introduces components, but places no constraints upon them, then we may omit the predicate part. Example 11.7 The following schema text has a single component, a set of seats called stalls, with no constraints This is equivalent to the text

13 10 May 2009Instructor: Tasneem Darwish13 Schemas as types In our mathematical language, there are four ways of introducing a type: as a given set, as a free type, as a power set, or as a Cartesian product. If we require a composite type, one with a variety of different components, then the schema language offers a useful alternative. The following schema corresponds to a composite data type with two components: an integer called a, and a set of integers called c. We may introduce elements of this type: the declaration s :SchemaOne introduces an object s of schema type SchemaOne.

14 10 May 2009Instructor: Tasneem Darwish14 Schemas as types To write an object of schema type in extension, we list the component names and the values to which they are bound a is bound to 2 and c is bound to the set {1, 2, 3}. Example 11.9 A date is an object consisting of two named components: the name of a month and the number of a day. We may define Month as the set of months Month == { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec} The set of all valid dates may be represented as a schema type:

15 10 May 2009Instructor: Tasneem Darwish15 Schemas as types If s is an object of schema type SchemaOne, we may write s.a and s.c to denote the integer component and set component of s, respectively. Example 11.10 In a token ring or Ethernet network, information is transmitted in the form of data frames. Each frame has a source address, a destination, and a data component. The type of all frames is a schema type Address is the set of all addresses in the network, Data is the set of all possible data components. If f is an object of type Frame, then we write f.source to denote its source, f.destination to denote its destination, and f.data to denote its data component

16 10 May 2009Instructor: Tasneem Darwish16 Schemas as declarations A schema may be used whenever a declaration is expected For example, consider the schema  The following set consists of those sets of integers c that contain the integer 0  The same effect could be achieved by replacing SchemaTwo with a list of declarations and a constraint  or by declaring an object of type SchemaTwo and selecting the two components:

17 10 May 2009Instructor: Tasneem Darwish17 Schemas as declarations Example 11.12 If Date is the schema named in Example 11.9, then the set comprehension describes the set of all months that have 31 days:


Download ppt "10 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal."

Similar presentations


Ads by Google