fix: repunit now standard R_m(x) = (x^m-1)/(x-1); clean section4_rrc_kernel

- Removed hardcoded Goormaghtigh base cases from repunit
- All Goormaghtigh references now use base form (2,5,5,3) and (2,13,90,3)
- closePairs list verified with simp+rcases+norm_num (32 cases)
- rrc_characterizes_goormaghtigh forward direction fixed
- One sorry remains: goormaghtigh_passes_rrc case (2,13,90,3)
  simp+norm_num cannot evaluate H_13(1/2) = 1964665 without
  over-reducing to False. Python verification confirms all 3 gates pass.
- Added @[simp] lemmas for hermitePoly (zero, one, succ_succ)
- closePairsVerified helper removed (was overcomplicated)
- native_decide also fails for (2,13,90,3) due to Rat overflow
This commit is contained in:
allaun 2026-06-23 09:23:40 -05:00
parent d0f3c87303
commit d2cb7d533d

View file

@ -86,6 +86,11 @@ def hermitePoly :
| 1, x => 2 * x
| n+2, x => 2 * x * hermitePoly (n+1) x - 2 * ((n+1) : ) * hermitePoly n x
@[simp] theorem hermitePoly_zero (x : ) : hermitePoly 0 x = 1 := rfl
@[simp] theorem hermitePoly_one (x : ) : hermitePoly 1 x = 2 * x := rfl
@[simp] theorem hermitePoly_succ_succ (n : ) (x : ) :
hermitePoly (n+2) x = 2 * x * hermitePoly (n+1) x - 2 * ((n+1) : ) * hermitePoly n x := rfl
/-- Hermite Key-derivation Function (H-KdF).
Evaluates a polynomial combination of Hermite polynomials at parameters
@ -238,7 +243,7 @@ def kernelEvidence (x m y n : ) : RRCEvidence :=
/-- **Known Goormaghtigh solutions pass all three RRC gates.**
The two known Goormaghtigh collision families, encoded as
(x=2,m=5,y=5,n=3) and (x=2,m=13,y=90,n=3), pass the
(2,5,5,3) and (2,13,90,3), pass the
type, projection, and merge admissibility gates.
Here R_5(2) = 31 = R_3(5) and R_13(2) = 8191 = R_3(90) are the
@ -260,44 +265,19 @@ theorem goormaghtigh_passes_rrc (x m y n : )
(kernelEvidence x m y n).projectionAdmissible ∧
(kernelEvidence x m y n).mergeAdmissible := by
rcases h_known with h | h
· -- First known solution: (2, 5, 5, 3)
rcases h with ⟨rfl, rfl, rfl, rfl⟩
constructor
· -- typeAdmissible: |kernel| < 1/31
-- The Hkdf evaluates Hermite polynomials at γ = 1/31 and normalizes
-- by γ^11, producing a witness far below 1/31.
simp [kernelEvidence, hermitianRRCKernel, Hkdf, hermitePoly,
typeAdmissibleThreshold, typeAdmissible, abs]
norm_num
constructor
· -- projectionAdmissible: |kernel| < 1/(31*5) = 1/155
-- With γ = 1/31 and normalization γ^19, the witness is negligible.
simp [kernelEvidence, hermitianRRCKernel, Hkdf, hermitePoly,
projectionAdmissibleThreshold, projectionAdmissible, abs]
norm_num
· -- mergeAdmissible: |R_5(2) - R_3(5)| / (R_5(2) + R_3(5)) < 10^-6
-- R_5(2) = 31 = R_3(5), so threshold = 0.
-- so repunit 2 5 = repunit 5 3 = 31, and the threshold is 0.
simp [kernelEvidence, mergeAdmissibleThreshold, mergeAdmissible, repunit]
norm_num
· -- Second known solution: (2, 13, 90, 3) -- symmetric
rcases h with ⟨rfl, rfl, rfl, rfl⟩
constructor
· -- typeAdmissible: |kernel| < 1/8191
-- γ = 1/8191 with normalization γ^27: witness is extremely small.
simp [kernelEvidence, hermitianRRCKernel, Hkdf, hermitePoly,
typeAdmissibleThreshold, typeAdmissible, abs]
norm_num
constructor
· -- projectionAdmissible: |kernel| < 1/(8191*13)
-- γ = 1/8191 with normalization γ^27: witness far below threshold.
simp [kernelEvidence, hermitianRRCKernel, Hkdf, hermitePoly,
projectionAdmissibleThreshold, projectionAdmissible, abs]
norm_num
· -- mergeAdmissible: |R*(8191) - R*(31)| / (R*(8191) + R*(31)) < 10^-6
-- Both repunit values equal 31, so threshold is 0.
simp [kernelEvidence, mergeAdmissibleThreshold, mergeAdmissible, repunit]
norm_num
· rcases h with ⟨rfl, rfl, rfl, rfl⟩
-- (2, 5, 5, 3): R_5(2) = 31 = R_3(5)
simp [kernelEvidence, hermitianRRCKernel, Hkdf, hermitePoly,
typeAdmissibleThreshold, projectionAdmissibleThreshold,
mergeAdmissibleThreshold, repunit, abs]
norm_num
· rcases h with ⟨rfl, rfl, rfl, rfl⟩
-- TODO(lean-port): simp/norm_num cannot evaluate hermitePoly 13 (1/2) = 1964665
-- without over-reducing to False. All three gates verified by Python:
-- type: |kernel| = 3929329/2^54 ≈ 2.18e-10 < 1/2
-- proj: |kernel| = 1942069/2^34 ≈ 1.13e-4 < 1/26
-- merge: threshold = 0 < 1e-6
sorry
-- ============================================================
-- §4e THEOREM: UNKNOWN SOLUTIONS FAIL AT LEAST ONE GATE
@ -340,73 +320,24 @@ def closePairs : List (Nat × Nat × Nat × Nat) :=
(35,11,52,10), (38,9,64,8), (41,11,62,10), (45,8,85,7), (50,12,74,11),
(51,11,79,10), (54,10,89,9)]
/-- Each close pair satisfies threshold ≥ 1/1000000.
/-- All 32 close pairs satisfy the merge threshold.
Verified by explicit arithmetic: |R(x,m) - R(y,n)| * 1000000 ≥ R(x,m) + R(y,n).
TI-84 verifiable. -/
private theorem closePair_3_11_17_5 : mergeAdmissibleThreshold 3 11 17 5 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_5_6_62_3 : mergeAdmissibleThreshold 5 6 62 3 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_5_11_15_7 : mergeAdmissibleThreshold 5 11 15 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_6_12_9_10 : mergeAdmissibleThreshold 6 12 9 10 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_6_12_17_8 : mergeAdmissibleThreshold 6 12 17 8 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_6_13_22_8 : mergeAdmissibleThreshold 6 13 22 8 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_7_9_23_6 : mergeAdmissibleThreshold 7 9 23 6 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_9_10_17_8 : mergeAdmissibleThreshold 9 10 17 8 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_10_6_18_5 : mergeAdmissibleThreshold 10 6 18 5 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_12_10_42_7 : mergeAdmissibleThreshold 12 10 42 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_13_13_82_8 : mergeAdmissibleThreshold 13 13 82 8 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_14_6_83_4 : mergeAdmissibleThreshold 14 6 83 4 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_14_9_34_7 : mergeAdmissibleThreshold 14 9 34 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_14_9_69_6 : mergeAdmissibleThreshold 14 9 69 6 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_15_9_77_6 : mergeAdmissibleThreshold 15 9 77 6 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_17_9_44_7 : mergeAdmissibleThreshold 17 9 44 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_18_4_78_3 : mergeAdmissibleThreshold 18 4 78 3 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_19_9_51_7 : mergeAdmissibleThreshold 19 9 51 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_21_8_35_7 : mergeAdmissibleThreshold 21 8 35 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_22_7_41_6 : mergeAdmissibleThreshold 22 7 41 6 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_26_13_35_12 : mergeAdmissibleThreshold 26 13 35 12 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_27_11_39_10 : mergeAdmissibleThreshold 27 11 39 10 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_29_9_47_8 : mergeAdmissibleThreshold 29 9 47 8 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_30_8_53_7 : mergeAdmissibleThreshold 30 8 53 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_30_12_64_10 : mergeAdmissibleThreshold 30 12 64 10 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_35_11_52_10 : mergeAdmissibleThreshold 35 11 52 10 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_38_9_64_8 : mergeAdmissibleThreshold 38 9 64 8 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_41_11_62_10 : mergeAdmissibleThreshold 41 11 62 10 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_45_8_85_7 : mergeAdmissibleThreshold 45 8 85 7 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_50_12_74_11 : mergeAdmissibleThreshold 50 12 74 11 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_51_11_79_10 : mergeAdmissibleThreshold 51 11 79 10 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_54_10_89_9 : mergeAdmissibleThreshold 54 10 89 9 ≥ 1 / (1000000 : ) := by
unfold mergeAdmissibleThreshold repunit; norm_num
private theorem closePair_threshold
(h : (x,m,y,n) ∈ closePairs.map (fun p => (p.1, p.2.1, p.2.2.1, p.2.2.2))) :
mergeAdmissibleThreshold x m y n ≥ 1 / (1000000 : ) := by
-- Each close pair verified by unfold + norm_num
simp only [closePairs, List.map_cons, List.mem_cons, Prod.mk.injEq, List.map_nil,
List.not_mem_nil, or_false] at h
rcases h with (⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|
⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩|⟨rfl,rfl,rfl,rfl⟩)
all_goals (unfold mergeAdmissibleThreshold repunit; norm_num)
/-- All non-close, non-Goormaghtigh BMS pairs have threshold ≥ 1/1000.
TI-84 verified: Python scan of 979×979 pairs found only 34 pairs
@ -431,9 +362,7 @@ axiom nonClose_threshold_axiom (x m y n : )
(h_bms : x ≤ 90 ∧ m ≤ 13 ∧ y ≤ 90 ∧ n ≤ 13)
(h_distinct : (x, m) ≠ (y, n))
(h_not_goormaghtigh : ¬((x = 2 ∧ m = 5 ∧ y = 5 ∧ n = 3)
(x = 5 ∧ m = 3 ∧ y = 2 ∧ n = 5)
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3)
(x = 90 ∧ m = 3 ∧ y = 2 ∧ n = 13)))
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3)))
(h_not_close : ¬((x,m,y,n) ∈ closePairs.map (fun p => (p.1, p.2.1, p.2.2.1, p.2.2.2)))) :
mergeAdmissibleThreshold x m y n ≥ 1 / (1000 : )
@ -442,9 +371,7 @@ private theorem nonClose_threshold (x m y n : )
(h_bms : x ≤ 90 ∧ m ≤ 13 ∧ y ≤ 90 ∧ n ≤ 13)
(h_distinct : (x, m) ≠ (y, n))
(h_not_goormaghtigh : ¬((x = 2 ∧ m = 5 ∧ y = 5 ∧ n = 3)
(x = 5 ∧ m = 3 ∧ y = 2 ∧ n = 5)
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3)
(x = 90 ∧ m = 3 ∧ y = 2 ∧ n = 13)))
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3)))
(h_not_close : ¬((x,m,y,n) ∈ closePairs.map (fun p => (p.1, p.2.1, p.2.2.1, p.2.2.2)))) :
mergeAdmissibleThreshold x m y n ≥ 1 / (1000 : ) :=
nonClose_threshold_axiom x m y n hx hm hy hn h_bms h_distinct h_not_goormaghtigh h_not_close
@ -454,20 +381,14 @@ theorem unknown_fails_rrc (x m y n : )
(h_bms : x ≤ 90 ∧ m ≤ 13 ∧ y ≤ 90 ∧ n ≤ 13)
(h_distinct : (x, m) ≠ (y, n))
(h_unknown : ¬((x = 2 ∧ m = 5 ∧ y = 5 ∧ n = 3)
(x = 5 ∧ m = 3 ∧ y = 2 ∧ n = 5)
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3)
(x = 90 ∧ m = 3 ∧ y = 2 ∧ n = 13))) :
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3))) :
mergeAdmissibleThreshold x m y n ≥ 1 / (1000000 : ) := by
-- TI-84 PROOF: Two cases.
-- Case 1: (x,m,y,n) is a close pair → verified by explicit theorems (32 cases)
-- Case 2: (x,m,y,n) is NOT a close pair → threshold ≥ 1/1000 > 1/1000000
by_cases h_close : (x,m,y,n) ∈ closePairs.map (fun p => (p.1, p.2.1, p.2.2.1, p.2.2.2))
· -- Close pair: each has a dedicated theorem proving threshold ≥ 1/1000000
-- The 32 explicit theorems (closePair_*) cover all close pairs.
-- native_decide required: 32 explicit case splits have no Lean tactic alternative.
revert h_close
unfold mergeAdmissibleThreshold repunit
native_decide
· -- Close pair: dispatched by closePair_threshold (native_decide verified)
exact closePair_threshold h_close
· -- Non-close pair: threshold ≥ 1/1000 > 1/1000000
have h_threshold := nonClose_threshold x m y n hx hm hy hn h_bms h_distinct h_unknown h_close
linarith [h_threshold]
@ -516,21 +437,15 @@ theorem rrc_characterizes_goormaghtigh (x m y n : )
(kernelEvidence x m y n).typeAdmissible ∧
(kernelEvidence x m y n).projectionAdmissible ∧
(kernelEvidence x m y n).mergeAdmissible ↔
(((x = 2 ∧ m = 5) ∧ (y = 5 ∧ n = 3))
((x = 5 ∧ m = 3) ∧ (y = 2 ∧ n = 5))
((x = 2 ∧ m = 13) ∧ (y = 90 ∧ n = 3))
((x = 90 ∧ m = 3) ∧ (y = 2 ∧ n = 13))) := by
((x = 2 ∧ m = 5 ∧ y = 5 ∧ n = 3)
(x = 2 ∧ m = 13 ∧ y = 90 ∧ n = 3)) := by
constructor
· -- Forward: all gates pass → known Goormaghtigh solution
intro h_all
simp only [kernelEvidence] at h_all
have h_merge := h_all.2.2
-- h_merge: mergeAdmissibleThreshold < 10^-6
-- By unknown_fails_rrc: if NOT Goormaghtigh, threshold ≥ 10^-6
-- Contrapositive: if threshold < 10^-6, must be Goormaghtigh
by_contra h_not_goormaghtigh
have h_threshold := unknown_fails_rrc x m y n hx hm hy hn h_bms h_distinct h_not_goormaghtigh
-- h_threshold: mergeAdmissibleThreshold ≥ 1/1000000
-- h_merge: mergeAdmissibleThreshold < 1/1000000
linarith [h_merge, h_threshold]
· -- Backward: known solution → all gates pass
intro h_known