This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
SyncTerminationDetection.tla
58 lines (45 loc) · 1.94 KB
/
SyncTerminationDetection.tla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---------------------- MODULE SyncTerminationDetection ----------------------
(***************************************************************************)
(* An abstract specification of the termination detection problem in a *)
(* ring with synchronous communication. *)
(***************************************************************************)
EXTENDS Naturals
CONSTANT N
ASSUME NAssumption == N \in Nat \ {0}
Node == 0 .. N-1
VARIABLES
active, \* activation status of nodes
terminationDetected \* has termination been detected?
TypeOK ==
/\ active \in [Node -> BOOLEAN]
/\ terminationDetected \in BOOLEAN
terminated == \A n \in Node : ~ active[n]
(***************************************************************************)
(* Initial condition: the nodes can be active or inactive, termination *)
(* may (but need not) be detected immediately if all nodes are inactive. *)
(***************************************************************************)
Init ==
/\ active \in [Node -> BOOLEAN]
/\ terminationDetected \in {FALSE, terminated}
Terminate(i) == \* node i terminates
/\ active[i]
/\ active' = [active EXCEPT ![i] = FALSE]
(* possibly (but not necessarily) detect termination if all nodes are inactive *)
/\ terminationDetected' \in {terminationDetected, terminated'}
Wakeup(i,j) == \* node i activates node j
/\ active[i]
/\ active' = [active EXCEPT ![j] = TRUE]
/\ UNCHANGED terminationDetected
DetectTermination ==
/\ terminated
/\ terminationDetected' = TRUE
/\ UNCHANGED active
Next ==
\/ \E i \in Node : Terminate(i)
\/ \E i,j \in Node : Wakeup(i,j)
\/ DetectTermination
vars == <<active, terminationDetected>>
Spec == Init /\ [][Next]_vars /\ WF_vars(DetectTermination)
Stable == [](terminationDetected => []terminated)
Live == terminated ~> terminationDetected
=============================================================================