A stable election is won once the votes of a quorum are counted
ProvedOpenSearchProgress.election_wonFor every payload type V, cluster parameters P with P.InitCompatible and P.strategy = ElectionStrategy.DEFAULT_INSTANCE, every cluster W with Reachable P W, every node c, term t and list of node ids Q such that
cand every member ofQare cluster-manager-eligible;Qis a quorum of both ofc's configurations:(W.node c).lastCommittedConfiguration.hasQuorum Q = trueand(W.node c).lastAcceptedConfiguration.hasQuorum Q = true;cand every member ofQare in a term belowt:(W.node q).currentTerm < tforq = cand for everyq ∈ Q;
and every cluster W' with ElectionExec P c t Q (W.node c).lastAcceptedTerm (W.node c).lastAcceptedVersion W W' such that (W'.node c).currentTerm = t and every member of Q is among c's join votes (q ∈ (W'.node c).joinVotes.nodes for every q ∈ Q): (W'.node c).electionWon = true.
No hypothesis on the voters' accepted states is needed: the votes are already counted. During the period c's committed configuration may change by a commit, but only to its accepted configuration, of which Q is also a quorum.
import Definitions.Def_OpenSearchProgress open OpenSearchCoordination OpenSearchSafety OpenSearchProgress
theorem OpenSearchProgress.election_won {V : Type} (P : Params) (hP : P.InitCompatible)
(hes : P.strategy = ElectionStrategy.DEFAULT_INSTANCE) (W : Cluster V) (hW : Reachable P W)
(c : NodeId) (t : Nat) (Q : List NodeId) (hc : P.eligible c = true) (hQ : ∀ q ∈ Q, P.eligible q = true)
(hquorum : (W.node c).lastCommittedConfiguration.hasQuorum Q = true ∧
(W.node c).lastAcceptedConfiguration.hasQuorum Q = true)
(hterm : ∀ q, q = c ∨ q ∈ Q → (W.node q).currentTerm < t)
(W' : Cluster V)
(hE : ElectionExec P c t Q (W.node c).lastAcceptedTerm (W.node c).lastAcceptedVersion W W')
(hct : (W'.node c).currentTerm = t) (hvotes : ∀ q ∈ Q, q ∈ (W'.node c).joinVotes.nodes) :
(W'.node c).electionWon = true := by sorryRead-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: OpenSearchProgress.election_won
Notions used
The full expansions are in readback_Def_OpenSearchProgress.md.
Node-state notation. For a node state :
- is the current term;
- and are the term and version of its last accepted state;
- and are that state's last committed and last accepted configurations;
- is the list of ids in the join votes, and is
electionWon.
For a configuration (a strictly increasing list of ids) and a list of ids, (X.hasQuorum L = true) means . It is false when is empty or , and it is monotone in .
Reachable clusters and the election period. These are as in the read-back of election_vote_accepted. is a finite, possibly empty, sequence of Steps. Compared with an arbitrary Step, the period imposes these restrictions:
- no new publication request is sent;
- a start-join at any node on a request in term requires , or requester and ;
- and the voters do not bootstrap and are not restarted, except that a non-eligible node may
restartAny; - and the voters accept only publications with key .
In this theorem, of .
How electionWon changes. Each successful handleJoin sets it to , where is the new vote list. Under the default strategy that value is , computed with the node's configurations at that moment. handleStartJoin and both kinds of restart set it to false. No other handler changes it. Join votes are cleared by handleStartJoin and by restarts, and grow only through handleJoin.
1. Declaration
The universally quantified variables and hypotheses, in order:
| Name | Type / statement |
|---|---|
V (implicit) | Type |
P | Params |
hP | |
hes | |
W | Cluster V (start of the period) |
hW | |
c | node id (candidate) |
t | (election term) |
Q | list of node ids (voters) |
hc | |
hQ | |
hquorum | |
hterm | |
W' | Cluster V |
hE | |
hct | |
hvotes |
Conclusion. .
What this amounts to. hterm and hct together show that entered term during the period, by a start-join that cleared its votes and set . cannot be restarted during the period, so the flag at is the value computed by the last successful handleJoin at after that start-join; such a call exists because hvotes and make the vote list non-empty. The theorem asserts that this value is true. The hypothesis hquorum refers to 's configurations at the start . The hypothesis hvotes refers to 's join votes at the end .
2. What is not constrained
-
Non-emptiness.
hquorumforces and both of 's configurations at to be non-empty, since is false for an empty configuration and for an empty list. -
No freshness or
hconf. There is no freshness hypothesis and nohconf. Whether voters' joins could be accepted does not matter here, becausehvotesassumes the votes are present. The theorem does not derive the votes. -
Every member of must have voted.
hvotesrequires every member of to be among 's join votes, not merely a quorum's worth, so members of outside 's configurations must also have voted. Since can be chosen as a minimal quorum, this concerns how the theorem is applied, not its content. 's votes may also include nodes outside . -
Start configurations versus end configurations.
hquorumspeaks of 's configurations at , not at . The following is derived, not stated:- during the period accepts no publication, so is fixed;
- a commit at while is still in its old term can replace by , which
hquorum's second conjunct covers; - once is in term , no commit can apply at , because .
The theorem thus implicitly claims that 's configurations, at the moment it computes its last
wonflag, are still covered by . -
Nothing beyond the flag. The theorem says nothing about how the votes were obtained, about or publish votes, or about other nodes. Those may be in any term, including , at .
-
Implicit claim about other winners. The conclusion makes a winner of term in a reachable cluster. The Safety definitions' invariant field
Inv.won_uniquesays at most one node wins each term. So the theorem implicitly asserts that its hypotheses exclude another node having won term before or during the period. No hypothesis says so directly; it would have to follow fromhquorum,hterm(no voter is in term at ),hvotesand reachability. -
Empty execution.
htermandhctexclude the empty execution and force . -
Vacuity. The hypotheses are satisfiable, using the two-node example of the
election_vote_acceptedread-back with and , :- node 1 start-joins on its own request for term 1, sending a join to itself;
- node 2 start-joins on node 1's request;
- node 1 handles its own join, giving votes , not yet a quorum of ;
- node 1 handles node 2's join, giving votes .
Then
hvotesholds,hquorumholds ( is a quorum of ), and the conclusion is a real claim.
3. Plain-language summary
Take any stable election period that starts in a reachable cluster where:
- the eligible candidate and the voters are in terms below ;
- is a majority of both of 's configurations, under the default election strategy.
If ends the period in term holding join votes from every member of , then 's electionWon flag is set. This is the "the votes suffice" half of election progress. It assumes the votes rather than deriving them.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.