5 Composing Specications
5.3 The Main Theorem
5.3.1 A Precise Statement of the Composition Principle
Having discussed composition and implementation, we come to the prob-lem of proving that the composition of specications
S
1 andS
2 imple-ments a specicationS
. As we observed in (5) of Section 5.2, we must prove R1(S
1)\R2(S
2)S
. One might attempt to prove this with the renement-mapping method of Section 5.2.2. Since we cannot expect to construct the realizable part of a specication, we would have to prove the stronger result thatS
1\S
2 implementsS
. However,S
has the formE
)M
and eachS
i has the formE
i )M
i. The renement-mapping method proves that a specication of the formE
)M
0 implementsE
)M
, butS
1 \S
2 is not in this form. A simple renement mapping won't work; we need the Composition Principle.We now restate the Composition Principle, for the case
n
= 2, in terms of our formal denitions. The principle's premises are that system is the composition of systems 1 and 2, the specication of isE
)M
, and the specication of each i isE
i )M
i. As we have already indi-cated,E
,E
1, andE
2must be safety properties. Also needed are some addi-tional assumptions that are natural consequences of our method of writing specications|assumptions that we disregard for now, but add ashypothe-ses of the theorem and discuss afterwards. The hypothehypothe-ses of the principle consist of three conditions:
1. guarantees
M
if each componenti guaranteesM
i.Formally, this condition asserts that
M
1\M
2M
. It can be sat-ised automatically by takingM
to beM
1\M
2. We can therefore simplify the Composition Principle by eliminatingM
, and letting the conclusion assert that satisesE
)M
1 \M
2. To show that satises the specicationE
)M
, one proves thatE
)M
1 \M
2 implementsE
)M
, using the renement-mapping method described in Section 5.2.2.2. The environment assumption
E
i of each component i is satised if the environment of satisesE
and every j satisesM
j.This condition asserts that
E
\M
1\M
2E
1 andE
\M
1\M
2E
2, two assertions that can be combined asE
\M
1\M
2E
1\E
2. 3. Every componentiguaranteesM
iunder environment assumptionE
i.This condition simply asserts that each component i satises its specication
E
i )M
i.The Composition Principle's conclusion asserts that satises the speci-cation
E
)M
1\M
2. (Remember that we have replacedM
byM
1\M
2.) When the principle is formulated in terms of specications rather than sys-tems, condition 3 disappears and the conclusion states that the composition of the components' specications implements the system's specication. The Composition Principle then becomes the proof rule:E
\M
1\M
2E
1\E
2R1(
E
1 )M
1)\R2(E
2 )M
2)E
)M
1\M
2 (6) Unfortunately, this rule is not valid. To obtain a valid rule, we must replace its hypothesis with a stronger one.Rule (6) appears unreasonably circular because it allows one to assume
M
i in proving the environment assumptionE
i that is necessary for compo-nenti to guaranteeM
i. This suggests that we strengthen the hypothesis by disallowing the use ofM
i in provingE
i, obtaining the rule:E
\M
2E
1; E
\M
1E
2R1(
E
1 )M
1)\R2(E
2 )M
2)E
)M
1\M
2 (7)This rule is indeed valid. However, it would be wrong to attribute the invalidity of (6) to simple circularity. Rule (7) is also circular, and it would be incorrect without the additional assumptions that we have been ignoring.
For example, suppose we could take
E
1 =E
2 =M
1 =M
2 =P
for some safety propertyP
. Both hypotheses of (7) then reduce to the tautologyE
\P
P
; and eachE
i)M
ibecomesP
)P
, an identically true specication satised by any system. Rule (7) would then yield the ridiculous conclusion that the composition of any two systems satises the specicationE
)P
. Not only is (7) valid despite its circularity, but there is an even stronger valid rule that looks just as circular as (6). The way to strengthen (7) is suggested by a closer examination of its hypotheses. The rst hypothesis asserts thatE
andM
2 implyE
1. PropertyE
1 is assumed to be a safety property, and any safety property that is implied byM
2 is implied byM
2. We would therefore expectE
\M
2to implyE
1only ifE
\M
2 does. Similarly,E
\M
1 should implyE
2 only ifE
\M
1 does. Proposition 12 shows that the following inference rules are indeed valid|again, under certain natural assumptions.E
\M
2E
1E
\M
2E
1E
\M
1E
2E
\M
1E
2 (8)We can thus replace
M
1 andM
2 by their closures in the hypotheses of (7).But we can do even more. In the hypothesis, we can actually assume both
M
1 andM
2 when provingE
1 andE
2. In other words, rule (6) is valid if, in the hypothesis, we replaceM
1 andM
2 byM
1 andM
2. Thus, one can assumeM
i when proving the assumptionE
i that is necessary for i to guaranteeM
i.We now state our precise results. The hypotheses of the proposition and the theorem are discussed later. The proposition asserts the rst rule of (8);
the second rule is obtained by the obvious substitutions. In the theorem, we have strengthened the proof rule's conclusion by replacing
E
)M
1\M
2 with its realizable part.Proposition 12
If 1, 2, and1[2 are agent sets andE
,E
1, andM
2 are properties such that:1.
E
=I
\P
where(a)
I
is a state predicate.(b)
P
is a safety property that constrains at most :(1[2).2.
E
is a safety property.3.
1\2 =;4.
M
2 is a2-abstract property.Then the rule of inference
E
\M
2E
1E
\M
2E
1 is sound.Theorem 2
If1, 2, and1[2 are agent sets andE
,E
1,E
2,M
1, andM
2 are properties such that:1.
E
=I
\P
,E
1 =I
1\P
1, andE
2=I
2\P
2, where (a)I
,I
1, andI
2 are state predicates.(b)
P
,P
1, andP
2 are safety properties that constrain at most:(
1[2),:1, and :2, respectively.2.
M
1 andM
2 constrain at most1 and 2, respectively.3.
1\2 =;Then the rule of inference
E
\M
1\M
2E
1\E
2R1(
E
1 )M
1)\R2(E
2)M
2) R1[2(E
)M
1\M
2) is sound.The theorem handles the composition of two systems. It has an obvious generalization to the composition of
n
systems, for anyn
2.E
\M
1\:::
\M
nE
1\:::
\E
nR1(
E
1)M
1)\:::
\Rn(E
n)M
n)R1[:::[n(
E
)M
1\:::
\M
n)This rule can be derived from the theorem by using Proposition 11.
5.3.2 The Hypotheses of the Theorem and Proposition
We now discuss the theorem's three numbered hypotheses|which imply the rst three hypotheses of the proposition|and the proposition's fourth hypothesis.
1. It is not hard to show that any safety property
E
0 can be written asI
0\P
0, whereI
0 is a state predicate andP
0 is a safety property that constrains at most , for some set of agents . IfE
0 species the environment of a system with agent set , then should equal:
. Therefore, hypothesis 1 will be satised if the environment as-sumptionsE
,E
1, andE
2 are safety properties. Theorem 1 allows us to rewrite a specication so its environment assumption is a safety property.Observe that a system implemented by components with agent sets
1 and 2 should have 1 [ 2 as its agent set. But, the higher-level specicationE
)M
we are ultimately trying to verify may be written in terms of an agent setrather than1[2. In this case, we must perform a renaming operation, substituting1[2 for, before applying the theorem.2. In the transition-axiom approach, each
M
i has the form9
x
:I
x\TA:(Ux)\TA(N)\L
and we expect
M
i to equal 9x
:I
x\TA:i(Ux)\TAi(N), in which case hypothesis 2 is satised.3. As we mentioned in Section 5.1.2, this hypothesis means that the two components are distinct. They need be distinct only at the cur-rent level of abstraction; their implementations could contain common parts. For example, the two components might specify distinct pro-gram procedures, while their implementations both invoke a common subprocedure. We can consider the subprocedure to be executed by dierent agents depending upon which procedure invoked it. Alterna-tively, we can generalize our notion of implementation to allow renam-ing of agents. In practice, this hypothesis seems to be a petty nuisance of the formalism, not a real concern.
4. When we write
M
directly, either as an abstract program or by any sort of logical formula, individual agents are not mentioned. The onlyreference to agents is through the symbol \
2", soM
2 is automatically 2-abstract.5.3.3 The Hypotheses of the Proof Rule
We now show how one veries the hypothesis
E
\M
1\M
2E
1\E
2 of the theorem's proof rule, using the systems1 and 2 of Figure 3 as a generic example.Each of the \wires" inp, mid, and out will have an associated protocol that the systems on its two ends are expected to obey. For each wire
w
, letI
w be the initial condition for the wire, letL
w be the property asserting that the agent set correctly executes the protocol for the system on the left side of the wire, and letR
w be the corresponding property for the right side of the wire.For example, suppose the state component mid consists of a register