Download presentation
Presentation is loading. Please wait.
1
Promotion
2
Promotion is a structuring technique that may be used whenever the state of a system contains multiple, indexed instances of the same component. It is most useful when several operations are possible upon the component, and their effect is independent of the index: that is, their effect is the same for each instance.
3
Example1 The state of a game of trivial pursuit might be described using the following pair of schemas:
4
Example1
5
The change in state associated with a single player answering a scoring question correctly could be described by:
6
Example1 The change in local state - in the individual player's score - could be described by
7
Example1 The following mixed operation identifies a particular local score; one of the copies indexed by score:
8
Example1 The following operation describes the change in global state that accompanies such a correct answer: Removing the extra names from the declaration, we obtain a global operation schema:
9
Promotion Schema If Local describes a copy of the local state and Global describes a copy of the global state, then a promotion schema Promote will contain decorated and undecorated copies of both Local and Global. If LocalOperation contains decorated and undecorated copies of Local, then we may promote LocalOperation to the global operation
10
Example2
12
Each mailbox is a binding:
13
Example2 A local operation:
14
Example2 A promotion schema:
15
Example2 A global operation:
16
Example2 A global operation (without promotion):
17
Example3
19
A local operation :
20
Example3
22
Example We wish to describe a library of musical recordings on tape or compact disc. We shall call this system as AudioLib. We want to attach a loan category to each recording copy and we want to maintain a record of the date on which the copy was loaned out.
23
Example For this system the set Recording is defined by a schema so that the members of this set have a particular structure Recording cat : Category loans : seq Date rec : RecordingDetails –Date is a given set and RecordingDetails is either a given set or a schema type defined elseware –Two loan categories: Category ::= Loanable | Restricted
24
Example A given set of identifiers used to identify uniquely each distinct physical tape or compact disc in AudioLib stock [RecId]
25
Example We define the abstract state for the AudioLib system AudioLib stock : RecId ↛ Recording out : RecId ↛ Listener listeners : Listener dom out dom stock ran out listeners r : dom out (stock r).cat = Loanable
26
Example The predicate part of this schema says that: - only items of stock can be out on loan - loans can only be made to registered listeners - items out on loan must be loanable and not restricted to the library
27
Example We define an operation to change the loan category of a Recording ChangeCategory Recording newcat? : Category report! : Report cat ≠ newcat? (report! = Ok cat’ = newcat?) cat = newcat? (report! = NoChange cat’ = cat?) loans’ = loans rec’ = rec
28
Example To promote operations on individual Recordings to be operations on the AudioLib abstract state, we factored using promotion; we define a promotion schema Promote AudioLib Recording rcid? : RecId rcid? dom stock Recording = stock rcid? stock’ = stock {rcid? ↦ Recording’}
29
Example The constraint Recording = stock rcid? ensures that Recording concerned is the one corresponding to stock rcid? The constraint stock’ = stock {rcid? ↦ Recording’} ensures that stock is unchanged except that rcid? Is now associated with the modified Recording we could define an operation ChangeRecordingCateg as: ChangeRecordingCateg ≙ Recording ChangeCategory Promote
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.