Part III · Precision Types, Hardware & Refinement Ch 10 · 35 min · ProveIt/Ch10.lean

64-Bit Hardware Truth (`UInt64` & `BitVec`)

Catching `2^64 - 1` wrap-around blind spots with `bv_decide` and auditing LRAT trust tiers.

5-Line Famous Bug · Binary Search Midpoint on 64-Bit Registers
def midBuggy (lo hi : BitVec 64) : BitVec 64 :=
  (lo + hi) >>> 1
-- Proved in Java's java.util.Arrays for 9 years before Joshua Bloch's bug report!
-- What happens when `lo = 2^63` (`0x8000000000000000`) and `hi = 2^63`?
Socratic Gate · Commit to a Prediction Unanswered · Locks on commit

On 64-bit hardware (`BitVec 64` / `UInt64`), if `lo = 0x8000000000000000` (`2^63`) and `hi = 0x8000000000000000` (`2^63`), what does `(lo + hi) >>> 1` compute?

Why Property Fuzzers Miss `2^64` Wrap-Arounds—and `bv_decide` Never Does

Random property tests sample small integers or uniform random values that hit narrow overflow windows (balance + fee < balance when balance > 2^64 - fee) with probability < 2^-50. Lean 4's bv_decide bit-blasts fixed-width BitVec goals to SAT and checks an LRAT unsatisfiability certificate, either returning an exact bit-level counterexample or sealing all 2^64 values.

Understanding `#print axioms` on `bv_decide` (`DECISIONS.md` Ruling #4)

To verify big LRAT certificates quickly, bv_decide evaluates its verified certificate checker via Lean.ofReduceBool / Lean.trustCompiler. That means #print axioms shows those two trust markers—the same ones emitted by dangerous raw native_decide! In Chapter 13 and Browser Lab 3, you will see how lake exe verigate --trust-tier=bv-lrat safely allows bv_decide while still blocking raw native_decide.

⊢ ProveIt/Ch10.lean · Hardware-Exact Midpoint Proof via `bv_decide`
Step 1 / 1
Lean Infoview Open Goal
Hands-On Exercise (ProveIt/Ch10.lean):

In `ProveIt/Ch10.lean` (and Browser Lab 5), verify overflow-checked `UInt64` / `BitVec 64` escrow and pointer-offset arithmetic with `bv_decide`.

Finished the Socratic gate, Infoview trace, and playground run?
Record completion in local browser storage to track your 20-unit progress.