Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The invariant holds in every reachable cluster

Proved
OpenSearchSafety.reachable_inv

by pitimespi · Nov 1, 2026 · Mathlib 0df444a (Lean v4.33.1)

cluster-coordinationconsensuscrash-recoveryelasticsearchformal-verificationinductive-invariantleader-electionmessage-passingopensearchpaxosraftreconfigurationsafetyzen2

For every payload type V, cluster parameters P with P.InitCompatible and P.strategy = ElectionStrategy.DEFAULT_INSTANCE, and every cluster W with Reachable P W: Inv P W.

Preamble
import Definitions.Def_OpenSearchSafety
open OpenSearchCoordination OpenSearchSafety
Formal statement
theorem OpenSearchSafety.reachable_inv {V : Type} (P : Params) (hP : P.InitCompatible)
    (hes : P.strategy = ElectionStrategy.DEFAULT_INSTANCE) (W : Cluster V) (hW : Reachable P W) : Inv P W := by sorry
Source
OpenSearch b2a54ba5c0defba3d1d20423e911d4bf920bab19: CoordinationState (the per-node handlers as transcribed by the OpenSearchCoordination mission; handleCommit lines 523-573, isPublishQuorum 156-158, invariant 601-611): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/main/java/org/opensearch/cluster/coordination/CoordinationState.java; Coordinator (the calls into CoordinationState: handleApplyCommit lines 419-452, handlePublishRequest 454-526, startElection 583-602, abdicateTo 604-620, ensureTermAtLeast 635-641, joinLeaderInTerm 643-657, setInitialConfiguration 1101-1161, handleJoin 1267-1299, publish 1350 with the handleClientValue call at 1404, CoordinatorPublication.handlePublishResponse 1871-1876): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java; ClusterBootstrapService (requirements 146-157, onFoundPeersUpdated 176-215, startBootstrap 259-273, checkRequirements 306-335): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java#L146-L335; GatewayMetaState.start (persisted state loaded and rebuilt 141-231, remote restore 169-188, synchronous and asynchronous persistence 199-207, nodes without the cluster-manager and data roles 232-255): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/main/java/org/opensearch/gateway/GatewayMetaState.java#L126-L257; PersistedStateRegistry.addPersistedState (lines 38-41): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/main/java/org/opensearch/cluster/coordination/PersistedStateRegistry.java#L38-L41; ElectionStrategy (DEFAULT_INSTANCE lines 46-59): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/main/java/org/opensearch/cluster/coordination/ElectionStrategy.java#L44-L110; the randomized safety test CoordinationStateTestCluster (reboot 156-193, runRandomly 279-329, invariant 331-370): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java and CoordinationStateTests.testSafety (lines 917-924): https://github.com/opensearch-project/OpenSearch/blob/b2a54ba5c0defba3d1d20423e911d4bf920bab19/server/src/test/java/org/opensearch/cluster/coordination/CoordinationStateTests.java#L917-L924; for comparison, Elastic's TLA+ model ZenWithTerms (HandleCommit 241-250, CommittedValuesDescendantsFromInitialValue 338-347, CommitHasQuorumVsPreviousCommittedConfiguration 349-358): https://github.com/elastic/elasticsearch-formal-models/blob/ca30663506a7e18de9d23fabbc70a369903d7c98/ZenWithTerms/tla/ZenWithTerms.tla
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5 (independent sub-agent, blind: Lean code + auditor instructions only)

Read-back: OpenSearchSafety.reachable_inv

Notions used

Sources and conventions. Rendered from Definitions/Def_OpenSearchCoordination.lean, Definitions/Def_OpenSearchSafety.lean and the stub Theorems/Thm_OpenSearchSafety_reachable_inv.lean; Java line numbers refer to OpenSearch b2a54ba5c0defba3d1d20423e911d4bf920bab19 (CS = CoordinationState.java, CM = CoordinationMetadata.java, ES = ElectionStrategy.java, CO = Coordinator.java, CBS = ClusterBootstrapService.java), checked against the local checkout. Throughout, VVV is an arbitrary payload type, PPP a parameter record and WWW a cluster; csncs_ncsn​ abbreviates W.node(n)W.\mathrm{node}(n)W.node(n), the coordination state of node nnn in WWW, and "m∈sentm \in \mathrm{sent}m∈sent" means W.sent(m)W.\mathrm{sent}(m)W.sent(m). Booleans are read as truth values: "won(cs)\mathrm{won}(cs)won(cs)" means electionWon = true, "¬won(cs)\neg\mathrm{won}(cs)¬won(cs)" means electionWon = false.

Nodes, configurations, quorums. Node ids are natural numbers. A discovery node ddd is a pair (d.id,d.cm)(d.\mathrm{id}, d.\mathrm{cm})(d.id,d.cm) of an id and a Boolean (isClusterManagerNode). A voting configuration ccc is a strictly increasing list of node ids, hence duplicate-free; two configurations are equal exactly when they have the same members. ∅\emptyset∅ denotes the empty configuration EMPTY_CONFIG; "ccc is empty" means its list is empty. For a configuration ccc and any list qqq of ids,

hasQuorum(c,q)  ⟺  2⋅∣{x∈c:x∈q}∣>∣c∣,\mathrm{hasQuorum}(c, q) \iff 2\cdot\big|\{x \in c : x \in q\}\big| > |c| ,hasQuorum(c,q)⟺2⋅​{x∈c:x∈q}​>∣c∣,

so the empty configuration has no quorum, and ids of qqq outside ccc as well as repetitions in qqq are irrelevant. Transcription check: matches VotingConfiguration.hasQuorum (CM:405-409).

A vote collection is a list of node ids; the empty collection is [ ][\,][]; isQuorum(v,c):=hasQuorum(c,v)\mathrm{isQuorum}(v, c) := \mathrm{hasQuorum}(c, v)isQuorum(v,c):=hasQuorum(c,v); addVote(v,d)\mathrm{addVote}(v, d)addVote(v,d) is (d.id::v, added)(d.\mathrm{id} :: v,\ \text{added})(d.id::v, added) if d.cmd.\mathrm{cm}d.cm is true and d.id∉vd.\mathrm{id} \notin vd.id∈/v, and (v, not added)(v,\ \text{not added})(v, not added) otherwise. Transcription check: VoteCollection (CS:750-814) keys a map by node id; addVote (CS:755-757) changes the key set exactly in the same cases.

Cluster states. A cluster state sss has a term s.term∈Ns.\mathrm{term} \in \mathbb{N}s.term∈N, a version s.version∈Zs.\mathrm{version} \in \mathbb{Z}s.version∈Z, a metadata version s.mv∈Zs.\mathrm{mv} \in \mathbb{Z}s.mv∈Z, a last committed and a last accepted configuration s.lccs.\mathrm{lcc}s.lcc and s.lacs.\mathrm{lac}s.lac, an optional natural number s.cmNodes.\mathrm{cmNode}s.cmNode (the cluster-manager node), two Booleans s.uuidKnowns.\mathrm{uuidKnown}s.uuidKnown and s.uuidCommitteds.\mathrm{uuidCommitted}s.uuidCommitted, and a payload s.value∈Vs.\mathrm{value} \in Vs.value∈V. Two cluster states are equal when all nine fields are. vomv(s)\mathrm{vomv}(s)vomv(s) (versionOrMetadataVersion) is s.mvs.\mathrm{mv}s.mv if s.term=0s.\mathrm{term} = 0s.term=0 and s.versions.\mathrm{version}s.version otherwise. markCommitted(s)\mathrm{markCommitted}(s)markCommitted(s) is sss with lcc\mathrm{lcc}lcc replaced by s.lacs.\mathrm{lac}s.lac and with uuidCommitted\mathrm{uuidCommitted}uuidCommitted set to true when s.uuidKnowns.\mathrm{uuidKnown}s.uuidKnown is true; nothing else changes (transcribes CS:703-740; the Java assertion at CS:708-710 is not checked).

Message contents. A join jjj has a source and a target discovery node j.srcj.\mathrm{src}j.src, j.tgtj.\mathrm{tgt}j.tgt, a term j.term∈Nj.\mathrm{term} \in \mathbb{N}j.term∈N, a last accepted term j.lat∈Nj.\mathrm{lat} \in \mathbb{N}j.lat∈N and a last accepted version j.lav∈Zj.\mathrm{lav} \in \mathbb{Z}j.lav∈Z; two joins are equal when all five fields are. A publish response is a pair ⟨t,v⟩∈N×Z\langle t, v\rangle \in \mathbb{N}\times\mathbb{Z}⟨t,v⟩∈N×Z. An apply-commit request is a triple ⟨d,t,v⟩\langle d, t, v\rangle⟨d,t,v⟩ of a discovery node, a term and a version. A start-join request is a pair of a discovery node and a term; it is not a cluster message (see the steps).

Coordination states. A coordination state cscscs has a local node cs.localNodecs.\mathrm{localNode}cs.localNode (a discovery node), a current term ct(cs)∈N\mathrm{ct}(cs) \in \mathbb{N}ct(cs)∈N, a last accepted state cs.lascs.\mathrm{las}cs.las (a cluster state), two vote collections joinVotes(cs)\mathrm{joinVotes}(cs)joinVotes(cs) and pubVotes(cs)\mathrm{pubVotes}(cs)pubVotes(cs), Booleans started(cs)\mathrm{started}(cs)started(cs) (startedJoinSinceLastReboot) and won(cs)\mathrm{won}(cs)won(cs) (electionWon), a last published version lpv(cs)∈Z\mathrm{lpv}(cs) \in \mathbb{Z}lpv(cs)∈Z and a last published configuration lpc(cs)\mathrm{lpc}(cs)lpc(cs). lat(cs)\mathrm{lat}(cs)lat(cs), lav(cs)\mathrm{lav}(cs)lav(cs), lcc(cs)\mathrm{lcc}(cs)lcc(cs), lac(cs)\mathrm{lac}(cs)lac(cs) are the term, version, last committed and last accepted configuration of cs.lascs.\mathrm{las}cs.las. init(d,t,s)\mathrm{init}(d, t, s)init(d,t,s) is the coordination state with local node ddd, current term ttt, last accepted state sss, both vote collections empty, started\mathrm{started}started and won\mathrm{won}won false, lpv=0\mathrm{lpv} = 0lpv=0 and lpc=s.lac\mathrm{lpc} = s.\mathrm{lac}lpc=s.lac (the constructor, CS:84-106).

Election strategies. An election strategy is a Boolean function σ(d,t,at,av,c1,c2,v)\sigma(d, t, at, av, c_1, c_2, v)σ(d,t,at,av,c1​,c2​,v) of a discovery node, two naturals, an integer, two configurations and a vote collection; DEFAULT_INSTANCE is the constant-true function. isElectionQuorumσ(cs,v):=isQuorum(v,lcc(cs))∧isQuorum(v,lac(cs))∧σ(cs.localNode,ct(cs),lat(cs),lav(cs),lcc(cs),lac(cs),v)\mathrm{isElectionQuorum}_\sigma(cs, v) := \mathrm{isQuorum}(v, \mathrm{lcc}(cs)) \wedge \mathrm{isQuorum}(v, \mathrm{lac}(cs)) \wedge \sigma(cs.\mathrm{localNode}, \mathrm{ct}(cs), \mathrm{lat}(cs), \mathrm{lav}(cs), \mathrm{lcc}(cs), \mathrm{lac}(cs), v)isElectionQuorumσ​(cs,v):=isQuorum(v,lcc(cs))∧isQuorum(v,lac(cs))∧σ(cs.localNode,ct(cs),lat(cs),lav(cs),lcc(cs),lac(cs),v); for the default strategy the third conjunct is true. isPublishQuorum(cs,v):=isQuorum(v,lcc(cs))∧isQuorum(v,lpc(cs))\mathrm{isPublishQuorum}(cs, v) := \mathrm{isQuorum}(v, \mathrm{lcc}(cs)) \wedge \mathrm{isQuorum}(v, \mathrm{lpc}(cs))isPublishQuorum(cs,v):=isQuorum(v,lcc(cs))∧isQuorum(v,lpc(cs)). Transcription check: ES:68-88 with CS:144-154, and CS:156-158.

Parameters. A parameter record PPP consists of elig:N→Bool\mathrm{elig} : \mathbb{N} \to \mathrm{Bool}elig:N→Bool (eligible: whether a node is cluster-manager-eligible), a predicate initConfs\mathrm{initConfs}initConfs on configurations (an arbitrary set of "bootstrap configurations": possibly empty, possibly containing ∅\emptyset∅, possibly infinite), and an election strategy σP\sigma_PσP​ (strategy). dn(n):=(n,elig(n))\mathrm{dn}(n) := (n, \mathrm{elig}(n))dn(n):=(n,elig(n)); "xxx is eligible" means elig(x)=\mathrm{elig}(x) = elig(x)= true. InitCompatible(P)\mathrm{InitCompatible}(P)InitCompatible(P) holds when for all configurations X,YX, YX,Y with initConfs(X)\mathrm{initConfs}(X)initConfs(X) and initConfs(Y)\mathrm{initConfs}(Y)initConfs(Y) and all lists q1,q2q_1, q_2q1​,q2​ of eligible ids,

hasQuorum(X,q1)∧hasQuorum(Y,q2)  ⟹  ∃x, x∈q1∧x∈q2\mathrm{hasQuorum}(X, q_1) \wedge \mathrm{hasQuorum}(Y, q_2) \implies \exists x,\ x \in q_1 \wedge x \in q_2hasQuorum(X,q1​)∧hasQuorum(Y,q2​)⟹∃x, x∈q1​∧x∈q2​

(for X=YX = YX=Y this is automatic: two majorities of one configuration meet).

Messages and clusters. A cluster message is one of: join(j)\mathsf{join}(j)join(j); pubReq(a,s,pt,pv)\mathsf{pubReq}(a, s, pt, pv)pubReq(a,s,pt,pv), a publish request from node aaa carrying a cluster state sss and a ghost parent (pt,pv)∈N×Z(pt, pv) \in \mathbb{N}\times\mathbb{Z}(pt,pv)∈N×Z; pubResp(a,d,r)\mathsf{pubResp}(a, d, r)pubResp(a,d,r), a publish response rrr from node aaa to node ddd; commit(c)\mathsf{commit}(c)commit(c), an apply-commit request ccc. A cluster WWW is a function W.nodeW.\mathrm{node}W.node from node ids to coordination states together with a predicate W.sentW.\mathrm{sent}W.sent on messages (the messages sent so far). W.set(n,cs)W.\mathrm{set}(n, cs)W.set(n,cs) replaces node nnn's state by cscscs and changes nothing else; W.send(m)W.\mathrm{send}(m)W.send(m) adds mmm to the sent set and changes nothing else. A key is a pair (t,v)∈N×Z(t, v) \in \mathbb{N}\times\mathbb{Z}(t,v)∈N×Z; the key of a publication pubReq(a,s,pt,pv)\mathsf{pubReq}(a, s, pt, pv)pubReq(a,s,pt,pv) is (s.term,s.version)(s.\mathrm{term}, s.\mathrm{version})(s.term,s.version).

The handlers. Each handler returns either an error (the corresponding step is then impossible) or a result. Guards are tested in the order listed; the first that applies gives the error.

  • setInitialState(cs,s)\mathrm{setInitialState}(cs, s)setInitialState(cs,s): error if lac(cs)\mathrm{lac}(cs)lac(cs) is non-empty; otherwise cscscs with cs.las:=scs.\mathrm{las} := scs.las:=s (nothing else changes). Its contract initialStateContract(cs,s)\mathrm{initialStateContract}(cs, s)initialStateContract(cs,s) is the conjunction: lat(cs)=0\mathrm{lat}(cs) = 0lat(cs)=0; lcc(cs)\mathrm{lcc}(cs)lcc(cs) empty; lpv(cs)=0\mathrm{lpv}(cs) = 0lpv(cs)=0; lpc(cs)\mathrm{lpc}(cs)lpc(cs) empty; ¬won(cs)\neg\mathrm{won}(cs)¬won(cs); joinVotes(cs)\mathrm{joinVotes}(cs)joinVotes(cs) and pubVotes(cs)\mathrm{pubVotes}(cs)pubVotes(cs) empty; s.term=0s.\mathrm{term} = 0s.term=0; s.version=lav(cs)s.\mathrm{version} = \mathrm{lav}(cs)s.version=lav(cs); s.lacs.\mathrm{lac}s.lac and s.lccs.\mathrm{lcc}s.lcc non-empty. Transcription check: CS:180-204; the contract is the eleven assertions CS:190-201.
  • handleStartJoin(cs,(d,t))\mathrm{handleStartJoin}(cs, (d, t))handleStartJoin(cs,(d,t)): error if t≤ct(cs)t \le \mathrm{ct}(cs)t≤ct(cs); otherwise the pair of cscscs with ct:=t\mathrm{ct} := tct:=t, lpv:=0\mathrm{lpv} := 0lpv:=0, lpc:=lac(cs)\mathrm{lpc} := \mathrm{lac}(cs)lpc:=lac(cs), started:=\mathrm{started} :=started:= true, won:=\mathrm{won} :=won:= false and both vote collections emptied (last accepted state unchanged), and the join ⟨cs.localNode,d,t,lat(cs),vomv(cs.las)⟩\langle cs.\mathrm{localNode}, d, t, \mathrm{lat}(cs), \mathrm{vomv}(cs.\mathrm{las})\rangle⟨cs.localNode,d,t,lat(cs),vomv(cs.las)⟩ (source, target, term, last accepted term, last accepted version — the metadata version when lat(cs)=0\mathrm{lat}(cs) = 0lat(cs)=0). Transcription check: CS:213-255.
  • handleJoinσ(cs,j)\mathrm{handleJoin}_\sigma(cs, j)handleJoinσ​(cs,j): errors, in order, if j.term≠ct(cs)j.\mathrm{term} \ne \mathrm{ct}(cs)j.term=ct(cs); if ¬started(cs)\neg\mathrm{started}(cs)¬started(cs); if j.lat>lat(cs)j.\mathrm{lat} > \mathrm{lat}(cs)j.lat>lat(cs); if j.lat=lat(cs)j.\mathrm{lat} = \mathrm{lat}(cs)j.lat=lat(cs) and j.lav>vomv(cs.las)j.\mathrm{lav} > \mathrm{vomv}(cs.\mathrm{las})j.lav>vomv(cs.las); if lac(cs)\mathrm{lac}(cs)lac(cs) is empty. Otherwise, with (v′,b)=addVote(joinVotes(cs),j.src)(v', b) = \mathrm{addVote}(\mathrm{joinVotes}(cs), j.\mathrm{src})(v′,b)=addVote(joinVotes(cs),j.src) and w=isElectionQuorumσ(cs,v′)w = \mathrm{isElectionQuorum}_\sigma(cs, v')w=isElectionQuorumσ​(cs,v′), the result is cscscs with joinVotes:=v′\mathrm{joinVotes} := v'joinVotes:=v′ and won:=w\mathrm{won} := wwon:=w, and moreover lpv:=lav(cs)\mathrm{lpv} := \mathrm{lav}(cs)lpv:=lav(cs) if www holds and won(cs)\mathrm{won}(cs)won(cs) did not; together with the Boolean bbb ("vote added"). The target j.tgtj.\mathrm{tgt}j.tgt is not examined. Transcription check: CS:264-339; the Java assertions CS:265 (target is the local node) and CS:323-324 (a won election is not lost) are not checked by the handler.
  • handleClientValue(cs,s)\mathrm{handleClientValue}(cs, s)handleClientValue(cs,s): errors, in order, if ¬won(cs)\neg\mathrm{won}(cs)¬won(cs); if lpv(cs)≠lav(cs)\mathrm{lpv}(cs) \ne \mathrm{lav}(cs)lpv(cs)=lav(cs); if s.term≠ct(cs)s.\mathrm{term} \ne \mathrm{ct}(cs)s.term=ct(cs); if s.version≤lpv(cs)s.\mathrm{version} \le \mathrm{lpv}(cs)s.version≤lpv(cs); if s.lac≠lac(cs)s.\mathrm{lac} \ne \mathrm{lac}(cs)s.lac=lac(cs) and lcc(cs)≠lac(cs)\mathrm{lcc}(cs) \ne \mathrm{lac}(cs)lcc(cs)=lac(cs); if ¬isQuorum(joinVotes(cs),s.lac)\neg\mathrm{isQuorum}(\mathrm{joinVotes}(cs), s.\mathrm{lac})¬isQuorum(joinVotes(cs),s.lac). Otherwise cscscs with lpv:=s.version\mathrm{lpv} := s.\mathrm{version}lpv:=s.version, lpc:=s.lac\mathrm{lpc} := s.\mathrm{lac}lpc:=s.lac, pubVotes:=[ ]\mathrm{pubVotes} := [\,]pubVotes:=[], together with the publish request carrying sss. Its contract clientValueContract(cs,s)\mathrm{clientValueContract}(cs, s)clientValueContract(cs,s) is s.lcc=lcc(cs)s.\mathrm{lcc} = \mathrm{lcc}(cs)s.lcc=lcc(cs). Transcription check: CS:348-407; the contract is the assertion CS:397-398.
  • handlePublishRequest(cs,s)\mathrm{handlePublishRequest}(cs, s)handlePublishRequest(cs,s): error if s.term≠ct(cs)s.\mathrm{term} \ne \mathrm{ct}(cs)s.term=ct(cs). Otherwise, if s.term=lat(cs)s.\mathrm{term} = \mathrm{lat}(cs)s.term=lat(cs) and s.version≤lav(cs)s.\mathrm{version} \le \mathrm{lav}(cs)s.version≤lav(cs): when s.term≠0s.\mathrm{term} \ne 0s.term=0, error; when s.term=0s.\mathrm{term} = 0s.term=0 (the "Zen1" branch), error if s.cmNodes.\mathrm{cmNode}s.cmNode is none, accept if s.cmNode=some ms.\mathrm{cmNode} = \mathrm{some}\ ms.cmNode=some m with some m≠cs.las.cmNode\mathrm{some}\ m \ne cs.\mathrm{las}.\mathrm{cmNode}some m=cs.las.cmNode, error otherwise. In all remaining cases, accept. To accept is to return cscscs with cs.las:=scs.\mathrm{las} := scs.las:=s and the response ⟨s.term,s.version⟩\langle s.\mathrm{term}, s.\mathrm{version}\rangle⟨s.term,s.version⟩. Transcription check: CS:416-460 (a null incoming cluster-manager in the Zen1 branch throws in Java).
  • handlePublishResponse(cs,d,r)\mathrm{handlePublishResponse}(cs, d, r)handlePublishResponse(cs,d,r): errors, in order, if ¬won(cs)\neg\mathrm{won}(cs)¬won(cs); if r.term≠ct(cs)r.\mathrm{term} \ne \mathrm{ct}(cs)r.term=ct(cs); if r.version≠lpv(cs)r.\mathrm{version} \ne \mathrm{lpv}(cs)r.version=lpv(cs). Otherwise let v′v'v′ be the collection returned by addVote(pubVotes(cs),d)\mathrm{addVote}(\mathrm{pubVotes}(cs), d)addVote(pubVotes(cs),d); the result is cscscs with pubVotes:=v′\mathrm{pubVotes} := v'pubVotes:=v′, together with the optional apply-commit request some ⟨cs.localNode,r.term,r.version⟩\mathrm{some}\ \langle cs.\mathrm{localNode}, r.\mathrm{term}, r.\mathrm{version}\ranglesome ⟨cs.localNode,r.term,r.version⟩ if isQuorum(v′,lcc(cs))∧isQuorum(v′,lpc(cs))\mathrm{isQuorum}(v', \mathrm{lcc}(cs)) \wedge \mathrm{isQuorum}(v', \mathrm{lpc}(cs))isQuorum(v′,lcc(cs))∧isQuorum(v′,lpc(cs)), and none\mathrm{none}none otherwise. Transcription check: CS:471-515.
  • handleCommit(cs,⟨d,t,v⟩)\mathrm{handleCommit}(cs, \langle d, t, v\rangle)handleCommit(cs,⟨d,t,v⟩): errors, in order, if t≠ct(cs)t \ne \mathrm{ct}(cs)t=ct(cs); if t≠lat(cs)t \ne \mathrm{lat}(cs)t=lat(cs); if v≠lav(cs)v \ne \mathrm{lav}(cs)v=lav(cs). Otherwise cscscs with cs.las:=markCommitted(cs.las)cs.\mathrm{las} := \mathrm{markCommitted}(cs.\mathrm{las})cs.las:=markCommitted(cs.las). The source ddd is not examined. Transcription check: CS:523-573.

Restart states. RestartState(s,s′)\mathrm{RestartState}(s, s')RestartState(s,s′) holds when either (i) s′s's′ agrees with sss on term, version, lcc\mathrm{lcc}lcc, lac\mathrm{lac}lac, uuidKnown\mathrm{uuidKnown}uuidKnown and uuidCommitted\mathrm{uuidCommitted}uuidCommitted (its metadata version, cluster-manager node and payload are free); or (ii) s.term=0s.\mathrm{term} = 0s.term=0, s.lcc=s.lac=∅s.\mathrm{lcc} = s.\mathrm{lac} = \emptysets.lcc=s.lac=∅, s.uuidKnown=s.\mathrm{uuidKnown} =s.uuidKnown= false, and s′.term=0s'.\mathrm{term} = 0s′.term=0, s′.lcc=s′.lac=∅s'.\mathrm{lcc} = s'.\mathrm{lac} = \emptysets′.lcc=s′.lac=∅ (every other field of s′s's′, including its version, is free). Citation check: in GatewayMetaState.java (141-207) an eligible node reloads its persisted current term, version and metadata (the metadata includes the coordination metadata and the cluster-UUID flags). The remote-store path (169-186) is taken by an eligible node with remote cluster state enabled when its local cluster UUID is unknown and the remote store knows one; the restored state is built on Metadata.EMPTY_METADATA (line 296), to which RemoteStoreRestoreService.restore adds index metadata, global settings, templates, customs and the remote version, but no coordination metadata and no cluster UUID — so its term is 0 and its configurations are empty, as in (ii). Java also persists the rest of the metadata (payload, metadata version), which (i) leaves free: more behaviours than Java.

Initial clusters. Initial(P,W)\mathrm{Initial}(P, W)Initial(P,W) holds when every node nnn has csn=init(dn(n),0,sn)cs_n = \mathrm{init}(\mathrm{dn}(n), 0, s_n)csn​=init(dn(n),0,sn​) for some cluster state sns_nsn​ with sn.term=0s_n.\mathrm{term} = 0sn​.term=0 and sn.lcc=sn.lac=∅s_n.\mathrm{lcc} = s_n.\mathrm{lac} = \emptysetsn​.lcc=sn​.lac=∅ (the version, metadata version, cluster-manager node, cluster-UUID flags and payload of sns_nsn​ are arbitrary and may differ from node to node), and no message is sent.

Steps. StepP(W,W′)\mathrm{Step}_P(W, W')StepP​(W,W′) holds exactly in the following nine cases (all objects arbitrary unless constrained):

  1. bootstrap: a node nnn, a configuration XXX with initConfs(X)\mathrm{initConfs}(X)initConfs(X), a cluster state sss with initialStateContract(csn,s)\mathrm{initialStateContract}(cs_n, s)initialStateContract(csn​,s) and s.lcc=s.lac=Xs.\mathrm{lcc} = s.\mathrm{lac} = Xs.lcc=s.lac=X, and setInitialState(csn,s)=ok cs′\mathrm{setInitialState}(cs_n, s) = \mathrm{ok}\ cs'setInitialState(csn​,s)=ok cs′; then W′=W.set(n,cs′)W' = W.\mathrm{set}(n, cs')W′=W.set(n,cs′). Node nnn need not be eligible (the Coordinator rejects non-eligible nodes and imposes further guards, CO:1110-1141; omitting them only adds behaviours).
  2. startJoin: nodes nnn, srcsrcsrc with srcsrcsrc eligible, a term ttt, and handleStartJoin(csn,(dn(src),t))=ok (cs′,j)\mathrm{handleStartJoin}(cs_n, (\mathrm{dn}(src), t)) = \mathrm{ok}\ (cs', j)handleStartJoin(csn​,(dn(src),t))=ok (cs′,j); then W′=W.set(n,cs′).send(join(j))W' = W.\mathrm{set}(n, cs').\mathrm{send}(\mathsf{join}(j))W′=W.set(n,cs′).send(join(j)). No message from srcsrcsrc is required.
  3. join: a node nnn and a join jjj with join(j)∈sent\mathsf{join}(j) \in \mathrm{sent}join(j)∈sent, j.tgt.id=nj.\mathrm{tgt}.\mathrm{id} = nj.tgt.id=n and handleJoinσP(csn,j)=ok (cs′,b)\mathrm{handleJoin}_{\sigma_P}(cs_n, j) = \mathrm{ok}\ (cs', b)handleJoinσP​​(csn​,j)=ok (cs′,b); then W′=W.set(n,cs′)W' = W.\mathrm{set}(n, cs')W′=W.set(n,cs′).
  4. clientValue: a node nnn and a cluster state sss with clientValueContract(csn,s)\mathrm{clientValueContract}(cs_n, s)clientValueContract(csn​,s) and handleClientValue(csn,s)=ok (cs′,p)\mathrm{handleClientValue}(cs_n, s) = \mathrm{ok}\ (cs', p)handleClientValue(csn​,s)=ok (cs′,p); then W′=W.set(n,cs′).send(pubReq(n,s,lat(csn),lav(csn)))W' = W.\mathrm{set}(n, cs').\mathrm{send}(\mathsf{pubReq}(n, s, \mathrm{lat}(cs_n), \mathrm{lav}(cs_n)))W′=W.set(n,cs′).send(pubReq(n,s,lat(csn​),lav(csn​))): the request carries the state of ppp, which is sss, and as ghost parent the key of nnn's last accepted state (unchanged by the handler).
  5. publish: nodes nnn, srcsrcsrc and pubReq(src,s,pt,pv)∈sent\mathsf{pubReq}(src, s, pt, pv) \in \mathrm{sent}pubReq(src,s,pt,pv)∈sent with handlePublishRequest(csn,s)=ok (cs′,r)\mathrm{handlePublishRequest}(cs_n, s) = \mathrm{ok}\ (cs', r)handlePublishRequest(csn​,s)=ok (cs′,r); then W′=W.set(n,cs′).send(pubResp(n,src,r))W' = W.\mathrm{set}(n, cs').\mathrm{send}(\mathsf{pubResp}(n, src, r))W′=W.set(n,cs′).send(pubResp(n,src,r)). Any node may handle any sent publish request.
  6. respond: nodes nnn, srcsrcsrc and pubResp(src,n,r)∈sent\mathsf{pubResp}(src, n, r) \in \mathrm{sent}pubResp(src,n,r)∈sent with handlePublishResponse(csn,dn(src),r)=ok (cs′,o)\mathrm{handlePublishResponse}(cs_n, \mathrm{dn}(src), r) = \mathrm{ok}\ (cs', o)handlePublishResponse(csn​,dn(src),r)=ok (cs′,o); then W′=W.set(n,cs′)W' = W.\mathrm{set}(n, cs')W′=W.set(n,cs′) if o=noneo = \mathrm{none}o=none and W′=W.set(n,cs′).send(commit(c))W' = W.\mathrm{set}(n, cs').\mathrm{send}(\mathsf{commit}(c))W′=W.set(n,cs′).send(commit(c)) if o=some co = \mathrm{some}\ co=some c.
  7. commit: a node nnn and commit(c)∈sent\mathsf{commit}(c) \in \mathrm{sent}commit(c)∈sent with handleCommit(csn,c)=ok cs′\mathrm{handleCommit}(cs_n, c) = \mathrm{ok}\ cs'handleCommit(csn​,c)=ok cs′; then W′=W.set(n,cs′)W' = W.\mathrm{set}(n, cs')W′=W.set(n,cs′). Any node may handle any sent commit.
  8. restart: an eligible node nnn and a cluster state s′s's′ with RestartState(csn.las,s′)\mathrm{RestartState}(cs_n.\mathrm{las}, s')RestartState(csn​.las,s′); then W′=W.set(n,init(csn.localNode,ct(csn),s′))W' = W.\mathrm{set}(n, \mathrm{init}(cs_n.\mathrm{localNode}, \mathrm{ct}(cs_n), s'))W′=W.set(n,init(csn​.localNode,ct(csn​),s′)).
  9. restartAny: a node nnn that is not eligible, any term ttt and any cluster state s′s's′; then W′=W.set(n,init(csn.localNode,t,s′))W' = W.\mathrm{set}(n, \mathrm{init}(cs_n.\mathrm{localNode}, t, s'))W′=W.set(n,init(csn​.localNode,t,s′)).

Messages are never removed from the sent set; a sent message may be handled any number of times, or never.

Reachability. ReachableP\mathrm{Reachable}_PReachableP​ is the least predicate on clusters that holds of every WWW with Initial(P,W)\mathrm{Initial}(P, W)Initial(P,W) and holds of W′W'W′ whenever it holds of WWW and StepP(W,W′)\mathrm{Step}_P(W, W')StepP​(W,W′).

Commits. Committed(W,t,v)\mathrm{Committed}(W, t, v)Committed(W,t,v) holds when commit(⟨d,t,v⟩)∈sent\mathsf{commit}(\langle d, t, v\rangle) \in \mathrm{sent}commit(⟨d,t,v⟩)∈sent for some discovery node ddd (the source is irrelevant).

Descent. Parent(W,(t,v),(t′,v′))\mathrm{Parent}(W, (t, v), (t', v'))Parent(W,(t,v),(t′,v′)) holds when some pubReq(a,s,t,v)∈sent\mathsf{pubReq}(a, s, t, v) \in \mathrm{sent}pubReq(a,s,t,v)∈sent has s.term=t′s.\mathrm{term} = t's.term=t′ and s.version=v′s.\mathrm{version} = v's.version=v′: a publication of key (t′,v′)(t', v')(t′,v′) was sent with ghost parent (t,v)(t, v)(t,v). Descends(W,k,k′)\mathrm{Descends}(W, k, k')Descends(W,k,k′), for keys k,k′k, k'k,k′, is the least relation that holds when k′=kk' = kk′=k — for every key, whether or not anything was published under it — and that holds of (k,k′′)(k, k'')(k,k′′) whenever it holds of (k,k′)(k, k')(k,k′) and Parent(W,k′,k′′)\mathrm{Parent}(W, k', k'')Parent(W,k′,k′′). Thus Descends(W,k,k′)\mathrm{Descends}(W, k, k')Descends(W,k,k′) means: k=k′k = k'k=k′, or there is a chain k=k0,k1,…,km=k′k = k_0, k_1, \dots, k_m = k'k=k0​,k1​,…,km​=k′ with m≥1m \ge 1m≥1 and Parent(W,ki−1,ki)\mathrm{Parent}(W, k_{i-1}, k_i)Parent(W,ki−1​,ki​) for each iii. Descent relates keys through ghost parents only; it says nothing about the payloads of the states.

Auxiliary notions of the invariant.

  • KeyLE((t,v),(t′,v′))\mathrm{KeyLE}((t, v), (t', v'))KeyLE((t,v),(t′,v′)): t<t′t < t't<t′, or t=t′t = t't=t′ and v≤v′v \le v'v≤v′.
  • Below((lt,lv),(bt,bv))\mathrm{Below}((lt, lv), (bt, bv))Below((lt,lv),(bt,bv)): lt<btlt < btlt<bt, or lt=btlt = btlt=bt and (bt=0bt = 0bt=0 or lv≤bvlv \le bvlv≤bv) — at term 000 versions are not compared.
  • Realizes(P,W,(t,v),x,y)\mathrm{Realizes}(P, W, (t, v), x, y)Realizes(P,W,(t,v),x,y): either t=0t = 0t=0, x=yx = yx=y and initConfs(x)\mathrm{initConfs}(x)initConfs(x) (with vvv unconstrained); or some pubReq(a,s,pt,pv)∈sent\mathsf{pubReq}(a, s, pt, pv) \in \mathrm{sent}pubReq(a,s,pt,pv)∈sent has s.term=ts.\mathrm{term} = ts.term=t, s.version=vs.\mathrm{version} = vs.version=v, y=s.lacy = s.\mathrm{lac}y=s.lac, and either x=s.lccx = s.\mathrm{lcc}x=s.lcc, or x=s.lacx = s.\mathrm{lac}x=s.lac and Committed(W,t,v)\mathrm{Committed}(W, t, v)Committed(W,t,v).
  • JoinVoters(P,W,L,t,J)\mathrm{JoinVoters}(P, W, L, t, J)JoinVoters(P,W,L,t,J): every x∈Jx \in Jx∈J is eligible and some join(j)∈sent\mathsf{join}(j) \in \mathrm{sent}join(j)∈sent has j.src.id=xj.\mathrm{src}.\mathrm{id} = xj.src.id=x, j.tgt.id=Lj.\mathrm{tgt}.\mathrm{id} = Lj.tgt.id=L and j.term=tj.\mathrm{term} = tj.term=t.
  • BaseVoters(P,W,L,t,(bt,bv),J)\mathrm{BaseVoters}(P, W, L, t, (bt, bv), J)BaseVoters(P,W,L,t,(bt,bv),J): the same, the witnessing join satisfying in addition Below((j.lat,j.lav),(bt,bv))\mathrm{Below}((j.\mathrm{lat}, j.\mathrm{lav}), (bt, bv))Below((j.lat,j.lav),(bt,bv)).
  • RespVoters(P,W,(t,v),A)\mathrm{RespVoters}(P, W, (t, v), A)RespVoters(P,W,(t,v),A): every x∈Ax \in Ax∈A is eligible and pubResp(x,d,⟨t,v⟩)∈sent\mathsf{pubResp}(x, d, \langle t, v\rangle) \in \mathrm{sent}pubResp(x,d,⟨t,v⟩)∈sent for some ddd.
  • ElectionRecord(P,W,L,t,(bt,bv),x,y,J)\mathrm{ElectionRecord}(P, W, L, t, (bt, bv), x, y, J)ElectionRecord(P,W,L,t,(bt,bv),x,y,J): bt<tbt < tbt<t, Realizes(P,W,(bt,bv),x,y)\mathrm{Realizes}(P, W, (bt, bv), x, y)Realizes(P,W,(bt,bv),x,y), BaseVoters(P,W,L,t,(bt,bv),J)\mathrm{BaseVoters}(P, W, L, t, (bt, bv), J)BaseVoters(P,W,L,t,(bt,bv),J), hasQuorum(x,J)\mathrm{hasQuorum}(x, J)hasQuorum(x,J) and hasQuorum(y,J)\mathrm{hasQuorum}(y, J)hasQuorum(y,J).
  • Won(P,W,b,t)\mathrm{Won}(P, W, b, t)Won(P,W,b,t): bbb is eligible, and either (won(csb)\mathrm{won}(cs_b)won(csb​) and ct(csb)=t\mathrm{ct}(cs_b) = tct(csb​)=t) or some pubReq(b,s,pt,pv)∈sent\mathsf{pubReq}(b, s, pt, pv) \in \mathrm{sent}pubReq(b,s,pt,pv)∈sent has s.term=ts.\mathrm{term} = ts.term=t.

The invariant. Inv(P,W)\mathrm{Inv}(P, W)Inv(P,W) is the conjunction of the following 30 statements (Lean field names in parentheses); nodes n,m,a,b,dn, m, a, b, dn,m,a,b,d range over all node ids, j,j′j, j'j,j′ over all joins, rrr over all publish responses.

Every node nnn:

  1. (localNode_eq) csn.localNode=dn(n)cs_n.\mathrm{localNode} = \mathrm{dn}(n)csn​.localNode=dn(n).
  2. (idle_of_not_won) ¬won(csn)⇒lpv(csn)=0∧pubVotes(csn)=[ ]\neg\mathrm{won}(cs_n) \Rightarrow \mathrm{lpv}(cs_n) = 0 \wedge \mathrm{pubVotes}(cs_n) = [\,]¬won(csn​)⇒lpv(csn​)=0∧pubVotes(csn​)=[].
  3. (won_started) won(csn)⇒started(csn)\mathrm{won}(cs_n) \Rightarrow \mathrm{started}(cs_n)won(csn​)⇒started(csn​).
  4. (votes_started) joinVotes(csn)≠[ ]⇒started(csn)\mathrm{joinVotes}(cs_n) \ne [\,] \Rightarrow \mathrm{started}(cs_n)joinVotes(csn​)=[]⇒started(csn​).
  5. (started_term_pos) started(csn)⇒ct(csn)≥1\mathrm{started}(cs_n) \Rightarrow \mathrm{ct}(cs_n) \ge 1started(csn​)⇒ct(csn​)≥1.
  6. (won_quorum) won(csn)⇒isQuorum(joinVotes(csn),lcc(csn))∧isQuorum(joinVotes(csn),lac(csn))\mathrm{won}(cs_n) \Rightarrow \mathrm{isQuorum}(\mathrm{joinVotes}(cs_n), \mathrm{lcc}(cs_n)) \wedge \mathrm{isQuorum}(\mathrm{joinVotes}(cs_n), \mathrm{lac}(cs_n))won(csn​)⇒isQuorum(joinVotes(csn​),lcc(csn​))∧isQuorum(joinVotes(csn​),lac(csn​)).
  7. (not_won_no_quorum) ¬won(csn)⇒¬(isQuorum(joinVotes(csn),lcc(csn))∧isQuorum(joinVotes(csn),lac(csn)))\neg\mathrm{won}(cs_n) \Rightarrow \neg\big(\mathrm{isQuorum}(\mathrm{joinVotes}(cs_n), \mathrm{lcc}(cs_n)) \wedge \mathrm{isQuorum}(\mathrm{joinVotes}(cs_n), \mathrm{lac}(cs_n))\big)¬won(csn​)⇒¬(isQuorum(joinVotes(csn​),lcc(csn​))∧isQuorum(joinVotes(csn​),lac(csn​))).
  8. (joinVotes_sent) every m∈joinVotes(csn)m \in \mathrm{joinVotes}(cs_n)m∈joinVotes(csn​) is eligible, and some join(j)∈sent\mathsf{join}(j) \in \mathrm{sent}join(j)∈sent has j.src.id=mj.\mathrm{src}.\mathrm{id} = mj.src.id=m, j.tgt.id=nj.\mathrm{tgt}.\mathrm{id} = nj.tgt.id=n, j.term=ct(csn)j.\mathrm{term} = \mathrm{ct}(cs_n)j.term=ct(csn​) and Below((j.lat,j.lav),(lat(csn),lav(csn)))\mathrm{Below}((j.\mathrm{lat}, j.\mathrm{lav}), (\mathrm{lat}(cs_n), \mathrm{lav}(cs_n)))Below((j.lat,j.lav),(lat(csn​),lav(csn​))).
  9. (publishVotes_sent) every m∈pubVotes(csn)m \in \mathrm{pubVotes}(cs_n)m∈pubVotes(csn​) is eligible and pubResp(m,n,⟨ct(csn),lpv(csn)⟩)∈sent\mathsf{pubResp}(m, n, \langle \mathrm{ct}(cs_n), \mathrm{lpv}(cs_n)\rangle) \in \mathrm{sent}pubResp(m,n,⟨ct(csn​),lpv(csn​)⟩)∈sent.

Every eligible node nnn:

  1. (term_le) lat(csn)≤ct(csn)\mathrm{lat}(cs_n) \le \mathrm{ct}(cs_n)lat(csn​)≤ct(csn​).
  2. (accepted_realizes) (lat(csn)=0∧lcc(csn)=∅∧lac(csn)=∅)∨Realizes(P,W,(lat(csn),lav(csn)),lcc(csn),lac(csn))\big(\mathrm{lat}(cs_n) = 0 \wedge \mathrm{lcc}(cs_n) = \emptyset \wedge \mathrm{lac}(cs_n) = \emptyset\big) \vee \mathrm{Realizes}(P, W, (\mathrm{lat}(cs_n), \mathrm{lav}(cs_n)), \mathrm{lcc}(cs_n), \mathrm{lac}(cs_n))(lat(csn​)=0∧lcc(csn​)=∅∧lac(csn​)=∅)∨Realizes(P,W,(lat(csn​),lav(csn​)),lcc(csn​),lac(csn​)).

Joins and publish responses:

  1. (join_wf) if join(j)∈sent\mathsf{join}(j) \in \mathrm{sent}join(j)∈sent then j.src=dn(j.src.id)j.\mathrm{src} = \mathrm{dn}(j.\mathrm{src}.\mathrm{id})j.src=dn(j.src.id) and j.tgt.idj.\mathrm{tgt}.\mathrm{id}j.tgt.id is eligible.
  2. (join_term_le) if join(j)∈sent\mathsf{join}(j) \in \mathrm{sent}join(j)∈sent and j.src.idj.\mathrm{src}.\mathrm{id}j.src.id is eligible then j.term≤ct(csj.src.id)j.\mathrm{term} \le \mathrm{ct}(cs_{j.\mathrm{src}.\mathrm{id}})j.term≤ct(csj.src.id​).
  3. (join_unique) if join(j),join(j′)∈sent\mathsf{join}(j), \mathsf{join}(j') \in \mathrm{sent}join(j),join(j′)∈sent, j.src.idj.\mathrm{src}.\mathrm{id}j.src.id is eligible, j.src.id=j′.src.idj.\mathrm{src}.\mathrm{id} = j'.\mathrm{src}.\mathrm{id}j.src.id=j′.src.id and j.term=j′.termj.\mathrm{term} = j'.\mathrm{term}j.term=j′.term, then j=j′j = j'j=j′ (all five fields, in particular the same target).
  4. (join_after_response) if join(j)∈sent\mathsf{join}(j) \in \mathrm{sent}join(j)∈sent, pubResp(a,d,r)∈sent\mathsf{pubResp}(a, d, r) \in \mathrm{sent}pubResp(a,d,r)∈sent, j.src.id=aj.\mathrm{src}.\mathrm{id} = aj.src.id=a, aaa is eligible and r.term<j.termr.\mathrm{term} < j.\mathrm{term}r.term<j.term, then KeyLE((r.term,r.version),(j.lat,j.lav))\mathrm{KeyLE}((r.\mathrm{term}, r.\mathrm{version}), (j.\mathrm{lat}, j.\mathrm{lav}))KeyLE((r.term,r.version),(j.lat,j.lav)).
  5. (response_le) if pubResp(a,d,r)∈sent\mathsf{pubResp}(a, d, r) \in \mathrm{sent}pubResp(a,d,r)∈sent and aaa is eligible, then r.term≤ct(csa)r.\mathrm{term} \le \mathrm{ct}(cs_a)r.term≤ct(csa​) and KeyLE((r.term,r.version),(lat(csa),lav(csa)))\mathrm{KeyLE}((r.\mathrm{term}, r.\mathrm{version}), (\mathrm{lat}(cs_a), \mathrm{lav}(cs_a)))KeyLE((r.term,r.version),(lat(csa​),lav(csa​))).
  6. (response_published) if pubResp(a,d,r)∈sent\mathsf{pubResp}(a, d, r) \in \mathrm{sent}pubResp(a,d,r)∈sent then some pubReq(d,s,pt,pv)∈sent\mathsf{pubReq}(d, s, pt, pv) \in \mathrm{sent}pubReq(d,s,pt,pv)∈sent — sent by the addressee ddd — has s.term=r.terms.\mathrm{term} = r.\mathrm{term}s.term=r.term and s.version=r.versions.\mathrm{version} = r.\mathrm{version}s.version=r.version.

Publications: for every pubReq(a,s,pt,pv)∈sent\mathsf{pubReq}(a, s, pt, pv) \in \mathrm{sent}pubReq(a,s,pt,pv)∈sent:

  1. (pub_wf) aaa is eligible, s.term≥1s.\mathrm{term} \ge 1s.term≥1, pt≤s.termpt \le s.\mathrm{term}pt≤s.term, pv<s.versionpv < s.\mathrm{version}pv<s.version, and pt=0⇒initConfs(s.lcc)pt = 0 \Rightarrow \mathrm{initConfs}(s.\mathrm{lcc})pt=0⇒initConfs(s.lcc).
  2. (pub_parent) if pt≥1pt \ge 1pt≥1, some pubReq(a′,s′,pt′,pv′)∈sent\mathsf{pubReq}(a', s', pt', pv') \in \mathrm{sent}pubReq(a′,s′,pt′,pv′)∈sent has s′.term=pts'.\mathrm{term} = pts′.term=pt, s′.version=pvs'.\mathrm{version} = pvs′.version=pv, [s.lcc=s′.lccs.\mathrm{lcc} = s'.\mathrm{lcc}s.lcc=s′.lcc, or s.lcc=s′.lacs.\mathrm{lcc} = s'.\mathrm{lac}s.lcc=s′.lac and Committed(W,pt,pv)\mathrm{Committed}(W, pt, pv)Committed(W,pt,pv)], and [s.lac≠s′.lac⇒s.lcc=s′.lacs.\mathrm{lac} \ne s'.\mathrm{lac} \Rightarrow s.\mathrm{lcc} = s'.\mathrm{lac}s.lac=s′.lac⇒s.lcc=s′.lac].
  3. (pub_unique) every pubReq(a′,s′,pt′,pv′)∈sent\mathsf{pubReq}(a', s', pt', pv') \in \mathrm{sent}pubReq(a′,s′,pt′,pv′)∈sent with s′.term=s.terms'.\mathrm{term} = s.\mathrm{term}s′.term=s.term and s′.version=s.versions'.\mathrm{version} = s.\mathrm{version}s′.version=s.version has a′=aa' = aa′=a, s′=ss' = ss′=s, pt′=ptpt' = ptpt′=pt and pv′=pvpv' = pvpv′=pv.
  4. (pub_rooted) Descends(W,(0,v0),(s.term,s.version))\mathrm{Descends}(W, (0, v_0), (s.\mathrm{term}, s.\mathrm{version}))Descends(W,(0,v0​),(s.term,s.version)) for some v0∈Zv_0 \in \mathbb{Z}v0​∈Z.
  5. (pub_same_term) every pubReq(a′,s′,pt′,pv′)∈sent\mathsf{pubReq}(a', s', pt', pv') \in \mathrm{sent}pubReq(a′,s′,pt′,pv′)∈sent with s′.term=s.terms'.\mathrm{term} = s.\mathrm{term}s′.term=s.term has Descends(W,(s.term,s.version),(s′.term,s′.version))\mathrm{Descends}(W, (s.\mathrm{term}, s.\mathrm{version}), (s'.\mathrm{term}, s'.\mathrm{version}))Descends(W,(s.term,s.version),(s′.term,s′.version)) or the converse.
  6. (pub_voters) some list JJJ has JoinVoters(P,W,a,s.term,J)\mathrm{JoinVoters}(P, W, a, s.\mathrm{term}, J)JoinVoters(P,W,a,s.term,J), hasQuorum(s.lcc,J)\mathrm{hasQuorum}(s.\mathrm{lcc}, J)hasQuorum(s.lcc,J) and hasQuorum(s.lac,J)\mathrm{hasQuorum}(s.\mathrm{lac}, J)hasQuorum(s.lac,J).
  7. (pub_election) if pt<s.termpt < s.\mathrm{term}pt<s.term, some yyy and JJJ have ElectionRecord(P,W,a,s.term,(pt,pv),s.lcc,y,J)\mathrm{ElectionRecord}(P, W, a, s.\mathrm{term}, (pt, pv), s.\mathrm{lcc}, y, J)ElectionRecord(P,W,a,s.term,(pt,pv),s.lcc,y,J).

Commits:

  1. (commit_quorum) for every commit(⟨d,t,v⟩)∈sent\mathsf{commit}(\langle d, t, v\rangle) \in \mathrm{sent}commit(⟨d,t,v⟩)∈sent, some pubReq(a,s,pt,pv)∈sent\mathsf{pubReq}(a, s, pt, pv) \in \mathrm{sent}pubReq(a,s,pt,pv)∈sent has s.term=ts.\mathrm{term} = ts.term=t and s.version=vs.\mathrm{version} = vs.version=v, and some list AAA has RespVoters(P,W,(t,v),A)\mathrm{RespVoters}(P, W, (t, v), A)RespVoters(P,W,(t,v),A), hasQuorum(s.lac,A)\mathrm{hasQuorum}(s.\mathrm{lac}, A)hasQuorum(s.lac,A), and either hasQuorum(s.lcc,A)\mathrm{hasQuorum}(s.\mathrm{lcc}, A)hasQuorum(s.lcc,A), or [Committed(W,pt,pv)\mathrm{Committed}(W, pt, pv)Committed(W,pt,pv) and some pubReq(a′,s′,pt′,pv′)∈sent\mathsf{pubReq}(a', s', pt', pv') \in \mathrm{sent}pubReq(a′,s′,pt′,pv′)∈sent has s′.term=pts'.\mathrm{term} = pts′.term=pt, s′.version=pvs'.\mathrm{version} = pvs′.version=pv, s′.lac=s.lacs'.\mathrm{lac} = s.\mathrm{lac}s′.lac=s.lac].

Leaders:

  1. (won_unique) Won(P,W,a,t)∧Won(P,W,b,t)⇒a=b\mathrm{Won}(P, W, a, t) \wedge \mathrm{Won}(P, W, b, t) \Rightarrow a = bWon(P,W,a,t)∧Won(P,W,b,t)⇒a=b.
  2. (pub_source_term) for every pubReq(a,s,pt,pv)∈sent\mathsf{pubReq}(a, s, pt, pv) \in \mathrm{sent}pubReq(a,s,pt,pv)∈sent: s.term<ct(csa)s.\mathrm{term} < \mathrm{ct}(cs_a)s.term<ct(csa​), or s.term=ct(csa)s.\mathrm{term} = \mathrm{ct}(cs_a)s.term=ct(csa​) and (won(csa)\mathrm{won}(cs_a)won(csa​) or ¬started(csa)\neg\mathrm{started}(cs_a)¬started(csa​)).
  3. (leader_pubs) if won(csn)\mathrm{won}(cs_n)won(csn​), every pubReq(a,s,pt,pv)∈sent\mathsf{pubReq}(a, s, pt, pv) \in \mathrm{sent}pubReq(a,s,pt,pv)∈sent with s.term=ct(csn)s.\mathrm{term} = \mathrm{ct}(cs_n)s.term=ct(csn​), whoever its sender aaa, has s.version≤lpv(csn)s.\mathrm{version} \le \mathrm{lpv}(cs_n)s.version≤lpv(csn​), Descends(W,(s.term,s.version),(ct(csn),lpv(csn)))\mathrm{Descends}(W, (s.\mathrm{term}, s.\mathrm{version}), (\mathrm{ct}(cs_n), \mathrm{lpv}(cs_n)))Descends(W,(s.term,s.version),(ct(csn​),lpv(csn​))), isQuorum(joinVotes(csn),s.lcc)\mathrm{isQuorum}(\mathrm{joinVotes}(cs_n), s.\mathrm{lcc})isQuorum(joinVotes(csn​),s.lcc) and isQuorum(joinVotes(csn),s.lac)\mathrm{isQuorum}(\mathrm{joinVotes}(cs_n), s.\mathrm{lac})isQuorum(joinVotes(csn​),s.lac).
  4. (leader_inflight) if won(csn)\mathrm{won}(cs_n)won(csn​) and lpv(csn)≠lav(csn)\mathrm{lpv}(cs_n) \ne \mathrm{lav}(cs_n)lpv(csn​)=lav(csn​), some sss has pubReq(n,s,lat(csn),lav(csn))∈sent\mathsf{pubReq}(n, s, \mathrm{lat}(cs_n), \mathrm{lav}(cs_n)) \in \mathrm{sent}pubReq(n,s,lat(csn​),lav(csn​))∈sent, s.term=ct(csn)s.\mathrm{term} = \mathrm{ct}(cs_n)s.term=ct(csn​), s.version=lpv(csn)s.\mathrm{version} = \mathrm{lpv}(cs_n)s.version=lpv(csn​), lpc(csn)=s.lac\mathrm{lpc}(cs_n) = s.\mathrm{lac}lpc(csn​)=s.lac, and either lcc(csn)=s.lcc\mathrm{lcc}(cs_n) = s.\mathrm{lcc}lcc(csn​)=s.lcc, or [lcc(csn)=s.lac\mathrm{lcc}(cs_n) = s.\mathrm{lac}lcc(csn​)=s.lac, Committed(W,lat(csn),lav(csn))\mathrm{Committed}(W, \mathrm{lat}(cs_n), \mathrm{lav}(cs_n))Committed(W,lat(csn​),lav(csn​)) and lac(csn)=s.lac\mathrm{lac}(cs_n) = s.\mathrm{lac}lac(csn​)=s.lac].
  5. (leader_settled) if won(csn)\mathrm{won}(cs_n)won(csn​) and lpv(csn)=lav(csn)\mathrm{lpv}(cs_n) = \mathrm{lav}(cs_n)lpv(csn​)=lav(csn​): either lat(csn)=ct(csn)\mathrm{lat}(cs_n) = \mathrm{ct}(cs_n)lat(csn​)=ct(csn​) and lpc(csn)=lac(csn)\mathrm{lpc}(cs_n) = \mathrm{lac}(cs_n)lpc(csn​)=lac(csn​), or lat(csn)<ct(csn)\mathrm{lat}(cs_n) < \mathrm{ct}(cs_n)lat(csn​)<ct(csn​) and no pubReq(a,s,pt,pv)∈sent\mathsf{pubReq}(a, s, pt, pv) \in \mathrm{sent}pubReq(a,s,pt,pv)∈sent has s.term=ct(csn)s.\mathrm{term} = \mathrm{ct}(cs_n)s.term=ct(csn​).

Docstring remarks. The docstring of idle_of_not_won says that a node that has not won "has published nothing in its term"; the term only says lpv=0\mathrm{lpv} = 0lpv=0 and no publish votes, which a node that published in its current term and then restarted also satisfies. The docstring of leader_pubs speaks of "an elected node's publications of its term"; the term covers every publication of that term, whoever sent it (a stronger statement).

1. Declaration

Binders and hypotheses, in order:

  1. an implicit payload type VVV and a parameter record PPP;
  2. hP : InitCompatible(P)\mathrm{InitCompatible}(P)InitCompatible(P);
  3. hes : σP=\sigma_P =σP​= DEFAULT_INSTANCE;
  4. a cluster WWW and hW : ReachableP(W)\mathrm{Reachable}_P(W)ReachableP​(W).

Conclusion. Inv(P,W)\mathrm{Inv}(P, W)Inv(P,W): all thirty conjuncts above hold in every reachable cluster.

2. What is not constrained

  • elig\mathrm{elig}elig and initConfs\mathrm{initConfs}initConfs are arbitrary apart from InitCompatible(P)\mathrm{InitCompatible}(P)InitCompatible(P); the payload type VVV is arbitrary. Only the default election strategy is covered.
  • Reachable clusters include every interleaving of the nine steps: messages lost, duplicated, delayed and reordered; crashes and restarts at any time; start-joins from any eligible node with any higher term; any client value the handlers accept.
  • The statement asserts only the conclusion; that it follows from inv_init and the nine step lemmas by induction on ReachableP\mathrm{Reachable}_PReachableP​ is not part of it.
  • Not vacuous: reachable clusters with publications and commits exist (the one-node scenario in the read-back of commit_reachable).

3. Plain-language summary

In every cluster reachable from a fresh one, the thirty-part invariant holds — when the bootstrap configurations are pairwise compatible and the default election strategy is used.

Human review
  • Endorsed by Shuze Chen · Nov 1, 2026

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Nov 1, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me