1 / 17

University of Palestine Faculty of Applied Engineering and Urban Planning

University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Schemas. Outlines. The schema Schemas as types Schemas as declarations Schemas as predicates Renaming Generic schemas. Schemas.

Download Presentation

University of Palestine Faculty of Applied Engineering and Urban Planning

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Schemas Instructor: Tasneem Darwish

  2. Outlines • The schema • Schemas as types • Schemas as declarations • Schemas as predicates • Renaming • Generic schemas Instructor: Tasneem Darwish

  3. 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. Instructor: Tasneem Darwish

  4. 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. Instructor: Tasneem Darwish

  5. 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. Instructor: Tasneem Darwish

  6. 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. Instructor: Tasneem Darwish

  7. Schemas • A schema consists of two parts: • a declaration of variables; • and a predicate constraining their values. • We can write the text of a schema in one of two forms: • Horizontally • Vertically Instructor: Tasneem Darwish

  8. 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. Instructor: Tasneem Darwish

  9. 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 Instructor: Tasneem Darwish

  10. 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 Instructor: Tasneem Darwish

  11. 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 Instructor: Tasneem Darwish

  12. 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 Instructor: Tasneem Darwish

  13. 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. Instructor: Tasneem Darwish

  14. 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: Instructor: Tasneem Darwish

  15. 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 Instructor: Tasneem Darwish

  16. 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 integersc 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: Instructor: Tasneem Darwish

  17. 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: Instructor: Tasneem Darwish

More Related