-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappendable-coordination.als
More file actions
executable file
·67 lines (57 loc) · 1.89 KB
/
appendable-coordination.als
File metadata and controls
executable file
·67 lines (57 loc) · 1.89 KB
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
59
60
61
62
63
64
65
66
67
// We will be dealing with sequences of events and states indexed by time
open util/ordering[Time]
// Events and states will be ordered/indexed by Time
some sig Time { }
// An event happens at a point in time and is related to some nodes
abstract sig Event {
nodes: Node set -> Time
} {
// All events must happen before we run out of time
no nodes.last
}
// There are 2 events sent/created by nodes: Reset, Register
some sig Register extends Event { }
some sig Reset extends Event { }
some sig Node { } {
// The reset event must happen only once
one (Reset.nodes[this])
// Register and reset events don't overlap
no (Reset.nodes[this] & Register.nodes[this])
// All register events must happen after the one reset event
Register.nodes[this] in Reset.nodes[this].nexts
// There must be at least one point in time where the node registers.
// This means our nodes are "live"
some Register.nodes[this]
}
// The state consists of a set of registered nodes at some point in time
some sig State {
time: Time,
registrants: Node set -> time
}
// We have 1-1 mapping between State and Time
fact {
time in State one -> one Time
}
// The transition relations that specifies what happens to the state at
// successive points in time given what events are happening at the
// current time.
pred transition(t, t': Time) {
some (Reset.nodes.t) => {
// Reset event clears the registrants at the next point in time
no State.registrants.t'
} else {
// Otherwise there are no reset events at this time so register the nodes
State.registrants.t' = State.registrants.t + Register.nodes.t
}
}
fact {
no State.registrants.first
all t: Time, t': t.next | transition[t, t']
}
//check {
// Node in State.registrants.last
//} for exactly 2 Node, 5 Time, 5 State, 5 Event
// Make sure the states are consistent
run {
Node in State.registrants.last
} for exactly 2 Node, 3 Time, 3 State, 3 Event