Z:%20Operations%20on%20Schemas - PowerPoint PPT Presentation

About This Presentation
Title:

Z:%20Operations%20on%20Schemas

Description:

Using Z: Specification, Refinement, and Proof, Jim Woodcock and Jim Davies, Prentice-Hall, ... The schema language is used to structure and compose ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 30
Provided by: davidli3
Category:

less

Transcript and Presenter's Notes

Title: Z:%20Operations%20on%20Schemas


1
Z Operations on Schemas
  • David Lightfoot
  • based on work of
  • Andrew Simpson

2
Reference
  • Using Z Specification, Refinement, and Proof,
  • Jim Woodcock and Jim Davies,
  • Prentice-Hall,
  • 1996
  • (Chapter 11)

3
Agenda
  • Operation schemas
  • Input and output
  • Initialisation schemas
  • Schema disjunction
  • Schema conjunction
  • Schema negation

4
The schema language
  • The schema language is used to structure and
    compose mathematical descriptions of systems
  • It collates pieces of information, encapsulates
    them, and names them for re-use
  • It is the second component of the Z notation the
    first is the mathematical language

5
Change of state
  • To describe the effect of an operation, we
    consider two copies of the state schema one
    describing the state before, the other describing
    the state afterwards
  • An operation schema describes the relationship
    between the two states
  • The inclusion of two copies of the state ensures
    that the constraint part of the state schema (the
    state invariant) is preserved

6
Operation schemas
  • An operation schema includes two copies of the
    corresponding state schema
  • ? Operation ________
  • State
  • State?
  • ?___________
  • ?
  • ?_____________
  • We use the undecorated state to represent the
    state before the operation and the primed state
    to represent the state afterwards

7
Example
  • ? Purchase0 ________
  • BoxOffice
  • BoxOffice?
  • ?___________
  • s? ? seating \ dom sold
  • sold? sold ? s? ? c?
  • seating? seating
  • ?_____________

8
Input and output
  • An operation may involve inputs and outputs
  • These are declared in the normal way, although
    there is a convention regarding their names
  • the name of an input must end in a question mark
    ?
  • the name of an output must end in an exclamation
    mark !

9
Example
  • ? Operation ________
  • State
  • State?
  • i? I
  • o! O
  • ?___________
  • ?_____________

10
Example
  • ? Purchase0 ________
  • BoxOffice
  • BoxOffice?
  • s? Seat
  • c? Customer
  • ?___________
  • s? ? seating \ dom sold
  • sold? sold ? s? ? c?
  • seating? seating
  • ?_____________

11
? (Delta) and ? (Xi)
  • There is another convention regarding operation
    schemas
  • if a schema describes an operation upon a state
    described by S, we include ?S (delta S)in its
    declaration (in place of S and S?)
  • if, in addition, the operation leaves the state
    unchanged we include ?S (in place of ?S)

12
Example
  • ? Purchase0 ________
  • ?BoxOffice
  • s? Seat
  • c? Customer
  • ?___________
  • s? ? seating \ dom sold
  • sold? sold ? s? ? c?
  • seating? seating
  • ?_____________

13
Example
  • An operation that leaves the state of the box
    office unchanged
  • ? QueryAvailability ________
  • ?BoxOffice
  • available! ?
  • ?___________
  • available! (seating \ dom sold)
  • ?_____________

14
Initialisation
  • An initialisation is a special operation for
    which the before state is unimportant
  • Such an operation can be modelled by an operation
    schema that contains only a decorated copy of the
    state
  • ? StateInit ________
  • State?
  • ?___________
  • ?_____________

15
Question
  • How might we complete the following?
  • ? BoxOfficeInit ________
  • BoxOffice?
  • allocation? ?Seat
  • ?___________
  • ?_____________

16
BoxOfficeInit
  • ? BoxOfficeInit ________
  • BoxOffice?
  • allocation? ?Seat
  • ?___________
  • seating? allocation?
  • sold? ?
  • ?_____________

17
Schema disjunction
  • If S and T are two schemas then their
    disjunction, S ? T is also a schema
  • in which the declaration is a merging of the two
    declarations
  • in which the constraint is a disjunction
    (oring) of the two constraints

18
Schema conjunction
  • If S and T are two schemas then their
    conjunction, S ? T is also a schema
  • in which the declaration is a merging of the two
    declarations
  • in which the constraint is a disjunction
    (anding) of the two constraints

19
Schema negation
  • If S is a schema then its negation, ? Sis also
    a schema
  • in which the declaration the same as that of S
  • in which the constraint is the negation
    (noting) of the constraint of S

20
Examples
  • ? S ________
  • a A
  • b B
  • ?________
  • P
  • ?__________
  • ? T ________
  • b B
  • c C
  • ?________
  • Q
  • ?__________
  • S ? T is equivalent to
  • ?________
  • a A
  • b B
  • c C
  • ?________
  • P ? Q
  • ?__________
  • S ? T is equivalent to
  • ?________
  • a A
  • b B
  • c C
  • ?________
  • P ? Q
  • ?__________

21
Examples
  • ? S ________
  • a A
  • b B
  • ?________
  • P
  • ?__________
  • ? S is equivalent to
  • ?________
  • a A
  • b B
  • ?________
  • ? P
  • ?__________

22
Example
  • If we define
  • ? NotAvailable ________
  • ?BoxOffice
  • s? Seat
  • ?___________
  • s? ? seating \ dom sold
  • ?_____________
  • then the schema disjunction
  • Purchase0 ? NotAvailable
  • describes a total operation

23
Constructing operations
  • Although disjunction is the obvious operator for
    constructing operation schemas, conjunction can
    also be useful
  • Response okay sorry
  • ? Success ________
  • r! Response
  • ?___________
  • r! okay
  • ?____________
  • ? Failure ________
  • r! Response
  • ?___________
  • r! sorry
  • ?_____________

24
Total operation
  • The operation of purchasing a seat may be
    described by
  • Purchase ?
  • (Purchase0 ? Success)
  • ?
  • (NotAvailable ? Failure)

25
Question
  • How might we complete the following operation?
  • ? ReturnTicket0 ________
  • ?BoxOffice
  • s? Seat
  • c? Customer
  • ?___________
  • ?_____________

26
ReturnTicket0
  • ? ReturnTicket0 ________
  • ?BoxOffice
  • s? Seat
  • c? Customer
  • ?___________
  • s? ? c? ? sold
  • sold? sold \ s? ? c?
  • seating? seating
  • ?_____________

27
Question
  • How might we complete the following operation?
  • ? ReturnNotPossible ________
  • ?BoxOffice
  • s? Seat
  • c? Customer
  • ?___________
  • ?_____________

28
ReturnNotPossible
  • ? ReturnNotPossible ________
  • ?BoxOffice
  • s? Seat
  • c? Customer
  • ?___________
  • s? ? c? ? sold
  • ?_____________

29
Summary
  • We may use operation schemas to describe the
    effect of operations on the state of our system
  • The inclusion of ?S in an operation schema
    denotes that the operation will change the state
    of S
  • The inclusion of ?S indicates that the operation
    is concerned with the state of S, but will leave
    it unchanged
  • Operation schemas may have input and output
  • An initialisation schema describes the state of
    our system at the beginning of its life
  • Disjunction and conjunction may be used to
    combine operation schemas
Write a Comment
User Comments (0)
About PowerShow.com