Executable failure-rate counters for the descent-certificate checker (bounded test, failure count, automatic width)
DefinitioncollatzFrontierCoverageThis module fixes the executable coverage/failure-rate counters for the descent-certificate checker of Def_collatzFrontierCertificate. boundedCertificateTest L m n is one fully specified, finite call to the actual executable checker: it runs the generator candidateCertificate on input n with descent steps and fuel/modulus exponent , then checks the result with checkDescent (returning false outright when ). boundedCertificateFailureCount R L m counts, among the first positive odd integers (), how many are rejected by boundedCertificateTest L m; this is a genuinely computable natural number, built from Finset.filter and a Decidable predicate — not an unbounded existential membership test. automaticCertificateFailureCount R m is the same count with the ambient bit-width computed automatically from (as , the least with ), so the failure count becomes a function of and the accuracy parameter alone:
Role. automaticCertificateFailureCount is the quantity bounded by the explicit failure-rate theorem and shown to vanish asymptotically by the asymptotic-coverage theorem in this contribution.
Formalization Note. Verbatim defs-only transcription of lean/CollatzFrontier/ExecutableCertificateCoverage.lean on the cited branch.
import Definitions.Def_collatzFrontierCertificate
import Mathlib.Data.Nat.Log
/-
Executable coverage/failure-rate counters for the descent-certificate checker, taken
verbatim (defs only, no proofs) from `lean/CollatzFrontier/ExecutableCertificateCoverage.lean`
on branch research/executable-coverage-20261002 @ 3835de1.
`boundedCertificateTest` is one fully specified, finite call to the actual executable
checker on the generated candidate certificate at a fixed accuracy parameter `m` (budget
`4m` steps, fuel/modulus exponent `L + 8m`). `boundedCertificateFailureCount` counts, among
the first `R` positive odd integers, how many are rejected by this one finite test; it is a
genuinely computable `Nat`, built from `Finset.filter` and `Decidable`, not an unbounded
existential search. `automaticCertificateFailureCount` fixes the ambient bit-width `L`
automatically (as `Nat.clog 2 (2 * R)`, the least `L` with `2 * R ≤ 2 ^ L`) so the count
depends only on `R` and `m`.
-/
namespace CollatzFrontier
/-- One fully specified, finite call to the actual executable checker: candidate exponent
budget and modulus exponent both `L + 2 * (4 * m)`, over `4 * m` descent steps, at
accuracy parameter `m`. Fails (returns `false`) when `m = 0` or the checker rejects. -/
def boundedCertificateTest (L m n : ℕ) : Bool :=
if m = 0 then false else
checkDescent (candidateCertificate (L + 2 * (4 * m)) (4 * m - 1) n
(2 ^ (L + 2 * (4 * m))))
/-- Among the first `R` positive odd integers `2*i+1` (`i < R`), the number rejected by
`boundedCertificateTest L m`. A genuinely computable `Nat.card`-style count. -/
def boundedCertificateFailureCount (R L m : ℕ) : ℕ :=
((Finset.range R).filter (fun i => boundedCertificateTest L m (2 * i + 1) = false)).card
/-- The same failure count with the ambient bit-width `L` computed automatically from `R`
(as the least `L` with `2 * R ≤ 2 ^ L`), so the count is a function of `R` and `m` alone. -/
def automaticCertificateFailureCount (R m : ℕ) : ℕ :=
boundedCertificateFailureCount R (Nat.clog 2 (2 * R)) m
end CollatzFrontier