Every random delay lies between one millisecond and the bound
ProvedOpenSearchElectionTimer.randomDelay_rangeFor every natural number M with 1 ≤ M and every draw x : Fin (2^64): 1 ≤ randomDelay M x and randomDelay M x ≤ M. The random part of an attempt's delay lies in (0, M], the range stated by the scheduler's documentation (ElectionSchedulerFactory.java:71-83, 163-167).
import Definitions.Def_OpenSearchElectionTimer open OpenSearchPreVote OpenSearchElectionTimer
theorem OpenSearchElectionTimer.randomDelay_range (M : Nat) (hM : 1 ≤ M) (x : Fin (2 ^ 64)) :
1 ≤ randomDelay M x ∧ randomDelay M x ≤ M := 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: OpenSearchElectionTimer.randomDelay_range
Notions used
Draws. A draw is an element of . The draw is read as the Java long , an order-preserving bijection onto .
nonNegative. if , and otherwise. It is a natural number.
randomDelay. For :
The remainder is the natural-number remainder, with Lean's convention . This transcribes Java's toPositiveLongAtMost(randomNumber, upperBound) = nonNegative(randomNumber) % upperBound + 1 (ESF:169-172), applied to the draw.
1. Declaration
theorem OpenSearchElectionTimer.randomDelay_range (M : Nat) (hM : 1 ≤ M) (x : Fin (2 ^ 64)) :
1 ≤ randomDelay M x ∧ randomDelay M x ≤ M
Binders and hypotheses, in order:
- ;
- ;
- , any of the draws.
Conclusion (in ):
that is,
2. What is not constrained
- No upper bound on . Values above , beyond any Java
long, are allowed. For the conclusion still holds, but the values reach at most , so is not filled. - Pointwise only. The statement covers each draw separately. It says nothing about how often each value occurs (see
randomDelay_cardandrandomDelay_near_uniform), and it does not claim that every value in is attained. - is necessary. For , Lean gives , so the second conjunct fails. Java excludes with an assertion.
- Satisfiable, not vacuous. The hypothesis holds for example with .
- Covers every Java
long.toLongis a bijection onto thelongrange, so "for every " amounts to "for every valuerandom.nextLong()could return". This is a statement about the Lean function. The link to Java is the transcription, which matches ESF:169-172 for .
3. Plain-language summary
For any bound and every possible 64-bit draw, the random part of an election attempt's delay is at least and at most . This matches the range "(0, upperBound]" documented on the Java method toPositiveLongAtMost. The theorem says nothing about the distribution of the delay.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.