-
Notifications
You must be signed in to change notification settings - Fork 0
/
CStruct.tla
73 lines (54 loc) · 2.06 KB
/
CStruct.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
------------------------------ MODULE CStruct ------------------------------
(***************************************************************************)
(* Lamport's CStructs. See the paper "Generalized Consensus and Paxos". *)
(***************************************************************************)
EXTENDS Sequences, Misc
CONSTANTS Cmd, CStruct, _ \bullet _, Bottom
(***************************************************************************)
(* Appending a sequence of commands to a CStruct *)
(***************************************************************************)
RECURSIVE StarRec(_,_)
StarRec(s, cs) ==
IF cs = <<>>
THEN s
ELSE StarRec(s \bullet Head(cs), Tail(cs))
s \star cs == StarRec(s, cs)
Str(C) == {Bottom \star cs : cs \in Seq(C)}
s \preceq t ==
\/ /\ s \in CStruct
/\ t \in CStruct
/\ \E cs \in Seq(Cmd) : t = s \star cs
\/ /\ s = None(CStruct)
/\ t = None(CStruct)
s \sqsubset t ==
/\ s \preceq t
/\ s # t
INSTANCE OrderRelations WITH S <- CStruct
Compat(s,t) ==
\E ub \in CStruct : IsUB(ub, {s,t})
IsCompatible(S) ==
\A s,t \in S : Compat(s,t)
Contains(s, c) ==
\E cs1,cs2 \in Seq(Cmd) : c = ((Bottom \star cs1) \bullet c) \star cs2
CS0 ==
\A s \in CStruct, c \in Cmd : s \bullet c \in CStruct
CS1 ==
CStruct = Str(Cmd)
CS2 == IsPartialOrder
CS3 ==
\A P \in SUBSET Cmd \ {{}} :
/\ \A s,t \in Str(P) :
/\ s \sqcap t \in Str(P)
/\ IsGLB(s \sqcap t, {s,t}) \* GLB exists
/\ Compat(s,t) =>
/\ s \sqcup t \in Str(P)
/\ IsLUB(s \sqcup t, {s,t}) \* LUB exists
CS4 ==
\A s,t \in CStruct, c \in Cmd :
Compat(s,t) /\ Contains(s,c) /\ Contains(t,c) =>
Contains(s \sqcap t, c)
IsCStruct == CS0 /\ CS1 /\ CS2 /\ CS3 /\ CS4
=============================================================================
\* Modification History
\* Last modified Wed Jun 08 11:30:23 EDT 2016 by nano
\* Created Wed Nov 11 14:21:02 EST 2015 by nano