nonNegative maps the Java longs exactly two-to-one onto [0, 2^63)
ProvedOpenSearchPreVote.nonNegative_two_to_oneFor every natural number and every integer with (a Java long): nonNegative n = v iff , or when , respectively (Long.MIN_VALUE) when . Every value in has exactly two preimages among the longs, so a uniformly distributed long gives a uniformly distributed nonNegative value. The theorem is the counting statement; no probability is formalized.
import Definitions.Def_OpenSearchPreVote open OpenSearchCoordination OpenSearchPreVote
theorem OpenSearchPreVote.nonNegative_two_to_one (v : Nat) (hv : v < 2 ^ 63) (n : Int)
(hn : -2 ^ 63 ≤ n ∧ n < 2 ^ 63) :
nonNegative n = v ↔ n = v ∨ n = (if v = 0 then -2 ^ 63 else -(v : Int)) := 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: OpenSearchPreVote.nonNegative_two_to_one
Notions used
. For any integer ,
The Lean text -2 ^ 63 parses as , which is Java's Long.MIN_VALUE. I confirmed the parse with pp.parens; would give the same value anyway, since is odd.
1. Declaration
Binders and hypotheses.
- ;
- : ;
- ;
- : , that is, is in Java's long range.
Conclusion.
Here on the right is cast to an integer.
Unfolded:
- For , the longs mapped to are exactly and .
- For , the longs mapped to are exactly and .
In both cases the two candidates are distinct and lie in . So every value in has exactly two preimages among the longs, and is exactly two-to-one from the longs onto . That the candidates lie in range is elementary arithmetic and is not itself part of the statement.
2. What is not constrained
- Integers outside the long range. excludes them, so nothing is said about them. There is just , so the preimage sets differ. For example, , which I checked by evaluation.
- Values . excludes them. The theorem does not state that no long maps to such a value, although that is true by the definition.
- What is not stated. Nothing is said about or about the uniformity of the derived delays, for example the bias introduced by when the bound does not divide .
- Vacuity. None. Both hypotheses are satisfiable, for example with and .
3. Plain-language summary
Restricted to Java long values, sends exactly and to each with , and exactly and Long.MIN_VALUE to . Each value in therefore has exactly two long preimages.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.