#!/usr/bin/env python3 """Generate the Lean witness for the 0029 review: the two exact rationals the independent assembly produced, checked in Lean against the axiom's own interval, plus the identities that tie them to `Challenge.lean`'s definitions.""" import json from fractions import Fraction as F from pathlib import Path OUT = Path(__file__).resolve().parent / "Pg186IHWitness.lean" HERE = Path(__file__).resolve().parent vals = {} for law in ("trapz", "exact", "mean", "double"): d = json.load(open(HERE / ("0029_result_%s.json" % law), encoding="utf-8")) vals[law] = F(d["exact"]) head = r'''/- Pg186IHWitness — machine-checked certificates for the independent review of the 2026 claimed 186 gap (programme 0029). Three things are proved here, all by `norm_num` on exact rationals: 1. `trialMesh` is the rational the assembly's denominator is built from; 2. the axiom's lower endpoint `23685317816 / 10^24` *is* the certificate's source-normalisation denominator `2960664727 / 125000000000000000000000` — the scalar that scales all 149 source bounds; 3. the exact rational the independent assembly computed for each of the four cell laws, so that "inside the axiom interval" is a checked proposition and not a decimal reading. Nothing here is a proof of the axiom or of any asymptotic statement: `trialIH` itself is `noncomputable` (a 40-fold integral over `Measure.pi`), so it cannot be evaluated in Lean at all; what is checked is the arithmetic of the finite computation and its membership in the interval the axiom asserts. -/ import Challenge open PrimeGap186 namespace Pg186IHWitness /-- `Challenge.lean`'s mesh is the rational the assembly's exact denominator uses. -/ theorem trialMesh_eq : trialMesh = (2742997 : ℚ) / 258046918656 := by norm_num [trialMesh] /-- The axiom's lower endpoint is exactly the certificate's source-normalisation denominator (its `source_normalization_denominator` record). -/ theorem i_lower_eq_source_denominator : ((23685317816 : ℚ) / 10 ^ 24) = 2960664727 / 125000000000000000000000 := by norm_num /-- The largest cap is 68225 mesh widths, as the assembly's shell schedule assumes. -/ theorem largest_cap_eq : trialLargestCap = 68225 * trialMesh := by norm_num [trialLargestCap] ''' body = [] names = { "trapz": "control_value_in_interval -- the certificate's own cell law", "exact": "experiment_value_in_interval -- the paper's cell mass, integrated exactly", } for law, title in names.items(): v = vals[law] body.append("/-- %s -/\n" % title) body.append("theorem %s :\n" % { "trapz": "control_value_in_interval", "exact": "experiment_value_in_interval", }[law]) body.append(" ((23685317816 : ℚ) / 10 ^ 24 <= (%d : ℚ) / %d) /\\\n" % (v.numerator, v.denominator)) body.append(" ((%d : ℚ) / %d <= (23685317890 : ℚ) / 10 ^ 24) := by\n" % (v.numerator, v.denominator)) body.append(" constructor <;> norm_num\n\n") # the two counter-laws are OUTSIDE, also checked for law, name, side in (("mean", "counter_law_density_is_above", "above"), ("double", "counter_law_double_average_is_below", "below")): v = vals[law] body.append("/-- the %s counter-law is outside the interval (%s) -/\n" % (law, side)) body.append("theorem %s :\n" % name) if side == "above": body.append(" (23685317890 : ℚ) / 10 ^ 24 < (%d : ℚ) / %d := by\n" % (v.numerator, v.denominator)) else: body.append(" (%d : ℚ) / %d < (23685317816 : ℚ) / 10 ^ 24 := by\n" % (v.numerator, v.denominator)) body.append(" norm_num\n\n") body.append("end Pg186IHWitness\n") OUT.write_text(head + "".join(body), encoding="utf-8") print("wrote", OUT, OUT.stat().st_size, "B") for law, v in vals.items(): print("%-7s %d/%d" % (law, v.numerator, v.denominator))