Skip to content

Commit

Permalink
Refactor abstract consensus specification (#6475)
Browse files Browse the repository at this point in the history
* Refactor (simplify) TypeOK to use (more concise) Sequences!Seq operator.
* Define InitialLogs less explicitly.
* Add assumptions about abs.tla's constants (TLAPS will likely need those assumptions should we attempt writing a proof).
* Mitigate state-space explosion during explicit-state model checking by declaring constant Servers to be symmetric.

Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
  • Loading branch information
lemmy authored Sep 27, 2024
1 parent f798800 commit 6fb0b5f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
4 changes: 3 additions & 1 deletion tla/consensus/MCabs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ INVARIANTS

PROPERTIES
AppendOnlyProp


SYMMETRY
Symmetry
5 changes: 4 additions & 1 deletion tla/consensus/MCabs.tla
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---- MODULE MCabs ----

EXTENDS abs
EXTENDS abs, TLC

Symmetry ==
Permutations(Servers)

CONSTANTS NodeOne, NodeTwo, NodeThree

Expand Down
22 changes: 14 additions & 8 deletions tla/consensus/abs.tla
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@
\* Abstract specification for a distributed consensus algorithm.
\* Assumes that any node can atomically inspect the state of all other nodes.

EXTENDS Sequences, SequencesExt, Naturals, FiniteSets, FiniteSetsExt
EXTENDS Sequences, SequencesExt, Naturals, FiniteSets, FiniteSetsExt, Relation

CONSTANT Servers, Terms, MaxLogLength
CONSTANT Servers
ASSUME IsFiniteSet(Servers)

\* Terms is (strictly) totally ordered with a smallest element.
CONSTANT Terms
ASSUME /\ IsStrictlyTotallyOrderedUnder(<, Terms)
/\ \E min \in Terms : \A t \in Terms : t <= min

CONSTANT MaxLogLength
ASSUME MaxLogLength \in Nat

\* Commit logs from each node
\* Each log is append-only and the logs will never diverge.
VARIABLE cLogs

TypeOK ==
/\ cLogs \in [Servers ->
UNION {[1..l -> Terms] : l \in 0..MaxLogLength}]
cLogs \in [Servers -> Seq(Terms)]

StartTerm == Min(Terms)

InitialLogs == {
<<>>,
<<StartTerm, StartTerm>>,
<<StartTerm, StartTerm, StartTerm, StartTerm>>}
InitialLogs ==
UNION {[ 1..n -> {StartTerm} ] : n \in {0,2,4}}

Init ==
cLogs \in [Servers -> InitialLogs]
Expand Down

0 comments on commit 6fb0b5f

Please sign in to comment.