Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

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

3 13 May 2009Instructor: Tasneem Darwish3 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:

4 13 May 2009Instructor: Tasneem Darwish4 Schemas as declarations If a set comprehension has no term part, then the type of objects in the set depends upon the characteristic tuple of the declaration. For example, in the set  the characteristic tuple is the pair (a, c)  and the type of objects in the set is Z × PZ.  The set consists of every pair (a, c) that meets the stated onstraint. In a schema, the order in which components are declared is unimportant, so the characteristic tuple of is different from (a,c) the characteristic tuple has one component: the binding which is called characteristic binding.

5 13 May 2009Instructor: Tasneem Darwish5 Schemas as declarations If S is the name of a schema, then we write ɵ S to denote the characteristic binding of components from S. For example, A schema may be used as the declaration part of a lambda expression. For example, If SchemaOne is defined as

6 13 May 2009Instructor: Tasneem Darwish6 Schemas as declarations Example 11.15 An object of schema type BoxOffice has two components: a set of seats allocated for the performance, and a record of which seats have been sold, and to whom. Given such an object, we may be interested in the set of seats that have yet to be sold. The function  maps an object of type BoxOffice to the number of unsold seats, calculated as the size of the set difference between seating and domsold

7 13 May 2009Instructor: Tasneem Darwish7 Schemas as declarations A schema may be used as the declaration part of a quantified expression. Example 11.16 The following predicate states that there is an object of schema type Date such that the value of month is feb and the value of day is 29: This is true: there can be 29 days in February. Example 11.17 The following predicate states that, for any object of schema type Date, the value of day must be less than or equal to 30: This is false, March is a month with 31 days

8 13 May 2009Instructor: Tasneem Darwish8 Schemas as declarations Whenever a schema appears as the declaration part of a quantified expression, the same result could be achieved by declaring an object of schema type. For example, the quantified predicate is logically equivalent to

9 13 May 2009Instructor: Tasneem Darwish9 Schemas as Predicates A schema may be used as a predicate, provided that each component of the schema has already been declared as a variable of the correct type. For example: The following quantified expression states that any integer a and set of integers c satisfying the predicate SchemaThree must also satisfy the predicate SchemaTwo.

10 13 May 2009Instructor: Tasneem Darwish10 Schemas as Predicates When we use a schema as a predicate, we should remember that the declaration part may include some constraint information For example, the following schema appears equivalent to SchemaTwo, but its not: Normalisation is to rewrite a schema so that all of the constraint information appears in the predicate part.

11 13 May 2009Instructor: Tasneem Darwish11 Schemas as Predicates For example, Schema four can be rewritten as Example 11.20 The schema Date introduces two variables, month and day. Using this schema as a predicate, we can show that The schema date can be normalized as

12 13 May 2009Instructor: Tasneem Darwish12 Renaming It is sometimes useful to rename the components of a schema; in this way, we are able to introduce a different collection of variables with the same pattern of declaration and constraint. For example, we might wish to introduce variables q and s under the constraint of SchemaTwo: the schema is equivalent to the schema

13 13 May 2009Instructor: Tasneem Darwish13 Renaming Renaming the components of a schema produces a new schema type Example 11.22 We may use another renaming to describe a new schema for Date.

14 13 May 2009Instructor: Tasneem Darwish14 Generic schemas we can rename the components of a schema but we cannot change their types. If we wish to use the same structure for a variety of different types, we may define a generic schema If we choose X to be Z then the we will get a schema which is equivalent to schematwo SchemaFive [Z]= schemaTwo


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

Similar presentations


Ads by Google