-
Notifications
You must be signed in to change notification settings - Fork 207
Finite Monotonic #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Finite Monotonic #153
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8034c04
Turn `Convergence` from a state predicate that is true or false of th…
lemmy 7c7576b
Add a fairness constraint (not machine-closed) that asserts there are…
lemmy 3debf30
Add script and model spec to explore diferent fairness constraints wi…
lemmy 8e9dc07
Add TRUE, i.e., no fairness as a possible fairness constraint.
lemmy f3763ac
Do not switch between `GarbageCollect` and no `GarbageCollect` conjoi…
lemmy 45443ef
Assert the shape of the counterexamples under all configuration. Log …
lemmy d8bdb00
Ensure that the exit/return value of nested TLC runs is either
lemmy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
SPECIFICATION FairSpec | ||
|
||
POSTCONDITION PostCondition | ||
|
||
CONSTANTS | ||
Node = {n1, n2} | ||
Next <- MCNext | ||
Fairness <- MCFairness | ||
Monotonicity <- MCMonotonicity | ||
|
||
INVARIANTS | ||
TypeOK | ||
Safety | ||
|
||
PROPERTIES | ||
Convergence | ||
Monotonicity | ||
|
||
CONSTRAINTS StateConstraint | ||
CONSTANTS Increment <- MCIncrement | ||
VIEW View |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
------ MODULE MCCRDT ----- | ||
EXTENDS CRDT, IOUtils, TLC, TLCExt, Sequences, CSV | ||
|
||
Divergence == | ||
\* D=0 means there is no divergence. D=1 means Gossip synchronizes the system in a single step. | ||
atoi(IOEnv.D) | ||
ASSUME Divergence \in Nat | ||
|
||
Constraint == | ||
IOEnv.C = ToString(TRUE) | ||
ASSUME Constraint \in BOOLEAN | ||
|
||
GB == | ||
IOEnv.G = ToString(TRUE) | ||
ASSUME GB \in BOOLEAN | ||
|
||
F == | ||
atoi(IOEnv.F) | ||
ASSUME F \in 0..7 | ||
|
||
------ | ||
|
||
SetMin(s) == CHOOSE e \in s : \A o \in s : e <= o | ||
|
||
GarbageCollect == | ||
LET Transpose == SetMin({counter[n][o] : n, o \in Node}) IN | ||
counter' = [ | ||
n \in Node |-> [ | ||
o \in Node |-> counter[n][o] - Transpose | ||
] | ||
] | ||
|
||
------ | ||
|
||
View == | ||
IF GB THEN vars ELSE | ||
LET Transpose == SetMin({counter[n][o] : n, o \in Node}) IN | ||
[ | ||
n \in Node |-> [ | ||
o \in Node |-> counter[n][o] - Transpose | ||
] | ||
] | ||
|
||
------ | ||
|
||
S == INSTANCE CRDT | ||
|
||
MCIncrement(n) == | ||
/\ IF Constraint THEN TRUE ELSE counter[n][n] < Divergence | ||
/\ S!Increment(n) | ||
|
||
MCNext == | ||
\/ S!Next | ||
\/ GB /\ GarbageCollect | ||
|
||
MCFairness == | ||
\* Note that TLC doesn't accept the following fairness condition if written with CASE. | ||
IF F = 0 THEN TRUE | ||
ELSE IF F = 1 THEN WF_vars(GarbageCollect) | ||
ELSE IF F = 2 THEN \A n \in Node : WF_vars(Increment(n)) | ||
ELSE IF F = 3 THEN WF_vars(Next) | ||
ELSE IF F = 4 THEN \A n, o \in Node : WF_vars(Gossip(n,o)) | ||
ELSE IF F = 5 THEN WF_vars(Next) /\ ~ \E n \in Node : <>[][Increment(n)]_vars | ||
ELSE IF F = 6 THEN WF_vars(Next) /\ \A n, o \in Node : <>[][Gossip(n,o)]_vars | ||
ELSE IF F = 7 THEN Convergence | ||
ELSE FALSE | ||
|
||
MCMonotonicity == [][ | ||
\/ S!Monotonic | ||
\/ \A a, b, c, d \in Node : | ||
(counter'[a][b] - counter[a][b]) = (counter'[c][d] - counter[c][d]) | ||
]_vars | ||
|
||
------ | ||
|
||
StateConstraint == | ||
IF Constraint THEN \A n, o \in Node : counter[n][o] <= Divergence ELSE TRUE | ||
|
||
------ | ||
|
||
CSVFile == | ||
IOEnv.O | ||
|
||
NoCounterExample == | ||
CounterExample.action = {} /\ CounterExample.state = {} | ||
|
||
CounterExampleWithStuttering == | ||
\E a \in CounterExample.action : a[1][1] = a[3][1] \* stuttering condition | ||
|
||
CounterExampleWithLasso == | ||
\E a \in CounterExample.action : a[1][1] > a[3][1] \* lasso condition | ||
|
||
CounterExampleShape == | ||
CASE NoCounterExample -> "none" | ||
[] CounterExampleWithStuttering -> "stuttering" | ||
[] CounterExampleWithLasso -> "lasso" | ||
[] OTHER -> "unexpected" | ||
|
||
PostCondition == | ||
CASE Divergence = 0 /\ NoCounterExample -> TRUE | ||
[] Divergence > 0 /\ F \in 0..1 /\ CounterExampleWithStuttering -> TRUE | ||
[] Divergence > 0 /\ F \in 0..1 /\ CounterExampleWithStuttering -> TRUE | ||
|
||
\* Changing Increment's enablement by conjoining counter[n][n] < Divergence causes (bogus) stuttering. | ||
[] Divergence = 1 /\ F = 2 /\~Constraint /\ CounterExampleWithStuttering -> TRUE | ||
[] Divergence > 1 /\ F = 2 /\~Constraint /\ CounterExampleWithStuttering -> TRUE | ||
|
||
[] Divergence = 1 /\ F = 2 /\ Constraint /\ NoCounterExample -> TRUE | ||
[] Divergence > 1 /\ F = 2 /\ Constraint /\ CounterExampleWithLasso -> TRUE | ||
|
||
[] Divergence = 1 /\ F \in 3..7 /\ NoCounterExample -> TRUE | ||
[] Divergence > 1 /\ F \in 3..5 /\ CounterExampleWithLasso -> TRUE | ||
[] Divergence > 1 /\ F \in 6..7 /\ NoCounterExample -> TRUE | ||
[] OTHER -> | ||
/\ CSVRecords(CSVFile) = 0 => CSVWrite("F#D#G#C#CounterExample", <<>>, CSVFile) \* Write header if file is empty. | ||
/\ CSVWrite("%1$s#%2$s#%3$s#%4$s#%5$s", <<F, Divergence, GB, Constraint, CounterExampleShape>>, CSVFile) | ||
|
||
====== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
lemmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$ wget https://nightly.tlapl.us/dist/tla2tools.jar | ||
$ wget https://github.com/tlaplus/CommunityModules/releases/latest/download/CommunityModules-deps.jar | ||
$ java -jar tla2tools.jar -config SCCRDT.tla SCCRDT.tla | ||
|
||
----------------------------- MODULE SCCRDT ----------------------------- | ||
EXTENDS TLC, Naturals, Sequences, IOUtils, CSV | ||
|
||
CSVFile == | ||
"MCCRDT-" \o ToString(JavaTime) \o ".csv" | ||
|
||
CmdLine == | ||
<<"java", "-jar", TLCGet("config").install, "-note", "MCCRDT.tla">> | ||
|
||
ASSUME \A c \in [ D: 0..3, F: 0..7, G: BOOLEAN, C: BOOLEAN, O: {CSVFile} ] : | ||
PrintT(c) /\ IOEnvExec(c, CmdLine).exitValue \in {0, 10, 13} | ||
|
||
============================================================================= | ||
---- CONFIG SCCRDT ---- | ||
==== |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.