Skip to content

Commit b0dfb61

Browse files
committed
Added comments and made a minor re-org of Chameneos.tla spec to improve readability.
1 parent 84fe75b commit b0dfb61

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

Diff for: specifications/Chameneos/Chameneos.pdf

11.4 KB
Binary file not shown.

Diff for: specifications/Chameneos/Chameneos.tla

+35-20
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@
33
(* A specification of a 'concurrency game' requiring concurrent *)
44
(* and symmetrical cooperation - https://cedric.cnam.fr/fichiers/RC474.pdf *)
55
(***************************************************************************)
6-
76
EXTENDS Integers
87

8+
RECURSIVE Sum(_, _)
9+
Sum(f, S) == IF S = {} THEN 0
10+
ELSE LET x == CHOOSE x \in S : TRUE
11+
IN f[x] + Sum(f, S \ {x})
12+
13+
-----------------------------------------------------------------------------
14+
15+
Color == {"blue", "red", "yellow"}
16+
Faded == CHOOSE c : c \notin Color
17+
18+
Complement(c1, c2) == IF c1 = c2
19+
THEN c1
20+
ELSE CHOOSE cid \in Color \ {c1, c2} : TRUE
21+
22+
-----------------------------------------------------------------------------
23+
924
\* N - number of total meeting after which chameneoses fade
1025
\* M - number of chameneoses
1126
CONSTANT N, M
@@ -15,27 +30,23 @@ VARIABLE chameneoses, meetingPlace, numMeetings
1530

1631
vars == <<chameneoses, meetingPlace, numMeetings>>
1732

18-
Color == {"blue", "red", "yellow"}
19-
Faded == CHOOSE c : c \notin Color
20-
2133
ChameneosID == 1 .. M
2234
MeetingPlaceEmpty == CHOOSE e : e \notin ChameneosID
2335

24-
RECURSIVE Sum(_, _)
25-
Sum(f, S) == IF S = {} THEN 0
26-
ELSE LET x == CHOOSE x \in S : TRUE
27-
IN f[x] + Sum(f, S \ {x})
36+
TypeOK ==
37+
\* For each chameneoses, remember its current color and how many meetings it has been in.
38+
/\ chameneoses \in [ ChameneosID -> (Color \cup {Faded}) \X (0 .. N) ]
39+
\* A meetingPlace (called Mall in the original paper) keeps track of the chameneoses
40+
\* creature that is currently waiting to meet another creature.
41+
/\ meetingPlace \in ChameneosID \cup {MeetingPlaceEmpty}
2842

29-
TypeOK == /\ chameneoses \in [ ChameneosID -> (Color \cup {Faded}) \X (0 .. N) ]
30-
/\ meetingPlace \in ChameneosID \cup {MeetingPlaceEmpty}
31-
32-
Complement(c1, c2) == IF c1 = c2
33-
THEN c1
34-
ELSE CHOOSE cid \in Color \ {c1, c2} : TRUE
43+
Init == /\ chameneoses \in [ChameneosID -> Color \X {0}]
44+
/\ meetingPlace = MeetingPlaceEmpty
45+
/\ numMeetings = 0
3546

3647
Meet(cid) == IF meetingPlace = MeetingPlaceEmpty
3748
THEN IF numMeetings < N
38-
\* chameneos enters meeting empty meeting place
49+
\* chameneos enters empty meeting place
3950
THEN /\ meetingPlace' = cid
4051
/\ UNCHANGED <<chameneoses, numMeetings>>
4152
\* chameneos takes on faded color
@@ -51,16 +62,20 @@ Meet(cid) == IF meetingPlace = MeetingPlaceEmpty
5162
![meetingPlace] = <<newColor, @[2] + 1>>]
5263
/\ numMeetings' = numMeetings + 1
5364

54-
Init == /\ chameneoses \in [ChameneosID -> Color \X {0}]
55-
/\ meetingPlace = MeetingPlaceEmpty
56-
/\ numMeetings = 0
57-
58-
\* repeatedly try to enter meeting place for chameneoses that are not faded yet
65+
\* Repeatedly try to enter meeting place for chameneoses that are not faded yet.
66+
\* The system terminates once the color of all chameneoses is faded.
5967
Next == /\ \E c \in { x \in ChameneosID : chameneoses[x][1] /= Faded} : Meet(c)
6068

6169
Spec == Init /\ [][Next]_vars
6270

71+
-----------------------------------------------------------------------------
72+
73+
\* Upon termination, the sum of the (individual) meetings that all creates have
74+
\* been in, is equal to 2*N. It is *not* guaranteed that all chameneoses have
75+
\* been in a meeting with another chameneoses. See section A. Game termination
76+
\* on page 5 of the original papaer).
6377
SumMet == numMeetings = N => LET f[c \in ChameneosID] == chameneoses[c][2]
6478
IN Sum(f, ChameneosID) = 2 * N
79+
THEOREM Spec => []SumMet
6580

6681
=============================================================================

0 commit comments

Comments
 (0)