Skip to content

Commit

Permalink
Move explicit bound of state-space to TLC's state constraint.
Browse files Browse the repository at this point in the history
[Refactor]
  • Loading branch information
lemmy committed Mar 18, 2022
1 parent 43691aa commit 502b1d6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
9 changes: 5 additions & 4 deletions .github/MCswscop.tla
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
------------------------- MODULE MCswscop -------------------------
EXTENDS swscop, IOUtils

MaxNumOp ==
\A i \in Clients: op[i] < 5

mcNumClients ==
1

mcMaxNumOp ==
5

mcK ==
2

Expand Down Expand Up @@ -45,8 +45,9 @@ SPECIFICATION Spec
\* Add statements after this line.
CHECK_DEADLOCK
FALSE
CONSTRAINT
MaxNumOp
CONSTANT
MaxNumOp <- mcMaxNumOp
NumClients <- mcNumClients
Consistency <- mcConsistency
K <- mcK
Expand Down
9 changes: 5 additions & 4 deletions .github/MCswscrw.tla
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
------------------------- MODULE MCswscrw -------------------------
EXTENDS swscrw, IOUtils

MaxNumOp ==
\A i \in Clients: op[i] < 5

mcNumClients ==
1

mcMaxNumOp ==
5

mcK ==
2

Expand Down Expand Up @@ -45,8 +45,9 @@ SPECIFICATION Spec
\* Add statements after this line.
CHECK_DEADLOCK
FALSE
CONSTRAINT
MaxNumOp
CONSTANT
MaxNumOp <- mcMaxNumOp
NumClients <- mcNumClients
Consistency <- mcConsistency
K <- mcK
Expand Down
15 changes: 6 additions & 9 deletions scenario1/swscop.tla
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-------------------------- MODULE swscop --------------------------
EXTENDS Naturals, Integers, Sequences, FiniteSets
CONSTANT NumClients, MaxNumOp, Consistency, K
CONSTANT NumClients, Consistency, K
ASSUME Consistency \in {"Eventual", "Consistent_Prefix", "Session", "Bounded_Staleness", "Strong"}
ASSUME MaxNumOp<10 /\ NumClients=1
ASSUME NumClients=1
Cloud == 0
Clients == 1..NumClients
(* --algorithm swscop {
Expand Down Expand Up @@ -50,7 +50,7 @@ variables
variables
m = <<>>; op=0; chistory = <<0>>; ses=1;
{
CW: while(op<MaxNumOp) {
CW: while(TRUE) {
op:=op+1;
send(Cloud, [type |-> "Write", dat |-> op, ses|->ses, orig |-> self]);
CWA: receive(m); \* Ack
Expand Down Expand Up @@ -145,12 +145,9 @@ cosmosdb(self) == D(self) \/ DW(self) \/ DE(self) \/ DP(self) \/ DS(self)
\/ DB(self) \/ DG(self)

CW(self) == /\ pc[self] = "CW"
/\ IF op[self]<MaxNumOp
THEN /\ op' = [op EXCEPT ![self] = op[self]+1]
/\ chan' = [chan EXCEPT ![Cloud] = Append(chan[Cloud], ([type |-> "Write", dat |-> op'[self], ses|->ses[self], orig |-> self]))]
/\ pc' = [pc EXCEPT ![self] = "CWA"]
ELSE /\ pc' = [pc EXCEPT ![self] = "Done"]
/\ UNCHANGED << chan, op >>
/\ op' = [op EXCEPT ![self] = op[self]+1]
/\ chan' = [chan EXCEPT ![Cloud] = Append(chan[Cloud], ([type |-> "Write", dat |-> op'[self], ses|->ses[self], orig |-> self]))]
/\ pc' = [pc EXCEPT ![self] = "CWA"]
/\ UNCHANGED << Database, msg, m, chistory, ses >>

CWA(self) == /\ pc[self] = "CWA"
Expand Down
13 changes: 5 additions & 8 deletions scenario2/swscrw.tla
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-------------------------- MODULE swscrw --------------------------
EXTENDS Naturals, Integers, Sequences, FiniteSets
CONSTANT NumClients, MaxNumOp, Consistency, K
CONSTANT NumClients, Consistency, K
ASSUME Consistency \in {"Eventual", "Consistent_Prefix", "Session", "Bounded_Staleness", "Strong"}
ASSUME MaxNumOp<10 /\ NumClients=1
ASSUME NumClients=1
Cloud == 0
Clients == 1..NumClients
(* --algorithm swscrw {
Expand Down Expand Up @@ -50,7 +50,7 @@ variables
variables
m = <<>>; op=0; v=0; chistory = <<0>>; ses=1;
{
CR: while(op<MaxNumOp) {
CR: while(TRUE) {
send(Cloud, [type |-> Consistency, ses|->ses, orig |-> self]); \* read
CRA: receive(m); \* Reply
chistory:= Append(chistory,m.dat);
Expand Down Expand Up @@ -147,11 +147,8 @@ cosmosdb(self) == D(self) \/ DW(self) \/ DE(self) \/ DP(self) \/ DS(self)
\/ DB(self) \/ DG(self)

CR(self) == /\ pc[self] = "CR"
/\ IF op[self]<MaxNumOp
THEN /\ chan' = [chan EXCEPT ![Cloud] = Append(chan[Cloud], ([type |-> Consistency, ses|->ses[self], orig |-> self]))]
/\ pc' = [pc EXCEPT ![self] = "CRA"]
ELSE /\ pc' = [pc EXCEPT ![self] = "Done"]
/\ chan' = chan
/\ chan' = [chan EXCEPT ![Cloud] = Append(chan[Cloud], ([type |-> Consistency, ses|->ses[self], orig |-> self]))]
/\ pc' = [pc EXCEPT ![self] = "CRA"]
/\ UNCHANGED << Database, msg, m, op, v, chistory, ses >>

CRA(self) == /\ pc[self] = "CRA"
Expand Down

0 comments on commit 502b1d6

Please sign in to comment.