Skip to content

Commit 98bcd4f

Browse files
committed
If the composition of A and B is such that the every composite behavior
is the concatenation of a behavior defined by A and a behavior defined by B, we won't need the variable `y`. Instead, Spec is changed to use ITE with ENABLED evaluated on the next-state relation of spec A.
1 parent 4f34443 commit 98bcd4f

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

specifications/composition/Composition.tla

+13-22
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,23 @@ VARIABLES x, \* Abstract/very high-level representation of the overall computati
2020
\* Think of it as some computation going on. At a certain state
2121
\* of the computation, the composed system transitions into the
2222
\* next phase.
23-
y, \* Represents the phase that the composed system is in.
24-
\* This toy example has three phases: <<"A", "B", "C">>.
2523
z \* z is the variable that is only going to be present in spec A.
26-
varsA == <<x, y, z>>
24+
varsA == <<x, z>>
2725

2826
InitA ==
2927
/\ x = 0
30-
/\ y = "A"
3128
/\ z = TRUE
3229

3330
NextA ==
34-
/\ y = "A"
31+
/\ x < 6
3532
/\ x' = x + 1
36-
/\ IF x' = 5
37-
THEN y' = "B"
38-
ELSE UNCHANGED y
3933
/\ z' = ~ z
4034

4135
==================================
4236

4337
(* COMPONENT Spec B *)
44-
VARIABLES x,
45-
y
46-
varsB == <<x, y>>
38+
VARIABLES x
39+
varsB == <<x>>
4740

4841
\* ++Observation: This is most likely not the original Init predicate of a
4942
\* standalone B component, unless perhaps we consider spec A
@@ -54,15 +47,10 @@ varsB == <<x, y>>
5447
InitB ==
5548
/\ x \in Nat \* Spec B may starts with x being any natural number,
5649
\* which is where A left off.
57-
/\ y \in {"A", "B"} \* Phase A or B, otherwise InitA /\ InitB in Spec
58-
\* below will equal FALSE.
5950

6051
NextB ==
61-
/\ y = "B"
52+
/\ x < 10
6253
/\ x' = x + 1
63-
/\ IF x' = 10 \* (Make sure values is greater than in spec A)
64-
THEN y' = "C" \* Phase C of the composed system (or ultimate termination).
65-
ELSE UNCHANGED y
6654

6755
-----------------------------------------------------------------------------
6856

@@ -77,23 +65,26 @@ OpenNextB ==
7765
/\ UNCHANGED <<restOfTheUniverse>>
7866

7967
vars ==
80-
<<x,y,restOfTheUniverse>>
68+
<<x,restOfTheUniverse>>
8169

8270
(* Composition of A and B (A /\ B) *)
8371
(* Down here we know about the internals *)
8472
(* of spec A and B (whitebox component). *)
8573

8674
INSTANCE A WITH z <- restOfTheUniverse
8775

88-
Spec == InitA /\ InitB /\ [][ \/ [NextA]_vars
89-
\/ [OpenNextB]_vars
76+
Spec == InitA /\ InitB /\ [][ IF ENABLED NextA THEN [NextA]_vars
77+
ELSE [OpenNextB]_vars
9078
]_vars
9179

92-
Inv == y \in {"A","B","C"}
80+
Inv == x \in 0..10
9381
THEOREM Spec => Inv
9482

83+
\* Not a theorem due to no fairness constraint.
84+
Live ==
85+
<>[](x = 10)
9586
=============================================================================
9687
\* Modification History
97-
\* Last modified Fri Jun 12 17:30:28 PDT 2020 by markus
88+
\* Last modified Fri Jun 12 17:34:09 PDT 2020 by markus
9889
\* Last modified Fri Jun 12 16:30:19 PDT 2020 by Markus Kuppe
9990
\* Created Fri Jun 12 10:30:09 PDT 2020 by Leslie Lamport

0 commit comments

Comments
 (0)