goldbach-spectral-bridge
Li and Liu's GRH + S ⇒ Goldbach in Lean, checked against the paper by Comparator: clean it up together, and settle S
| 1 | module |
| 2 | |
| 3 | import Mathlib.Tactic.NormNum.Prime |
| 4 | |
| 5 | public import ConditionalGoldbach.Proofs.WideWeight |
| 6 | |
| 7 | @[expose] public section |
| 8 | |
| 9 | set_option autoImplicit false |
| 10 | noncomputable section |
| 11 | open scoped BigOperators |
| 12 | namespace ConditionalGoldbach |
| 13 | attribute [local instance] Classical.propDecidable |
| 14 | |
| 15 | lemma experiment_prime_pair_ne {p q : ℕ} (hp : p.Prime) (_hq : q.Prime) |
| 16 | (he : p+q=experimentN) : p≠q := by |
| 17 | intro hh |
| 18 | have hpv : p=15015 := by norm_num [experimentN] at he; omega |
| 19 | have hn : ¬Nat.Prime 15015 := by norm_num |
| 20 | exact hn (hpv ▸ hp) |
| 21 | |
| 22 | lemma experiment_prime_pair_coprime {p q : ℕ} (hp : p.Prime) (hq : q.Prime) |
| 23 | (he : p+q=experimentN) : Nat.Coprime (p*q) experimentN := by |
| 24 | have hneq := experiment_prime_pair_ne hp hq he |
| 25 | have hc (p q : ℕ) (hp : p.Prime) (hq : q.Prime) (he : p+q=experimentN) (hn : p≠q) : |
| 26 | Nat.Coprime p experimentN := by |
| 27 | apply hp.coprime_iff_not_dvd.mpr |
| 28 | intro hd |
| 29 | rw [← he] at hd |
| 30 | have hpd : p∣q := (Nat.dvd_add_iff_right (dvd_refl p)).mpr hd |
| 31 | exact hn ((Nat.prime_dvd_prime_iff_eq hp hq).mp hpd) |
| 32 | exact (hc p q hp hq he hneq).mul_left (hc q p hq hp (by omega) hneq.symm) |
| 33 | |
| 34 | def orderedWidePrimeMass : ℝ := ∑ p ∈ Finset.range (experimentN+1), |
| 35 | if p.Prime ∧ (experimentN-p).Prime then wideCutoff p^2 else 0 |
| 36 | |
| 37 | def unorderedWidePrimeMass : ℝ := ∑ p ∈ Finset.range (experimentN+1), |
| 38 | if p.Prime ∧ (experimentN-p).Prime ∧ p≤experimentN-p then wideCutoff p^2 else 0 |
| 39 | |
| 40 | lemma orderedWidePrimeMass_eq_twice : orderedWidePrimeMass=2*unorderedWidePrimeMass := by |
| 41 | let S := (Finset.range (experimentN+1)).filter (fun p => p.Prime ∧ (experimentN-p).Prime) |
| 42 | have hswap : (∑ p ∈ S.filter (fun p => ¬p≤experimentN-p), wideCutoff p^2)= |
| 43 | ∑ p ∈ S.filter (fun p => p≤experimentN-p), wideCutoff p^2 := by |
| 44 | apply Finset.sum_bij (fun p _ => experimentN-p) |
| 45 | · intro p hp |
| 46 | rcases Finset.mem_filter.mp hp with ⟨hS,hgt⟩ |
| 47 | rcases Finset.mem_filter.mp hS with ⟨hr,hp,hq⟩ |
| 48 | have hn : p≤experimentN := by simpa only [Finset.mem_range,Nat.lt_succ_iff] using hr |
| 49 | have hrev : experimentN-(experimentN-p)=p := Nat.sub_sub_self hn |
| 50 | simp only [Finset.mem_filter,S,Finset.mem_range,Nat.lt_succ_iff,hrev] |
| 51 | exact ⟨⟨Nat.sub_le _ _,hq,hp⟩,by omega⟩ |
| 52 | · intro p hp q hq he |
| 53 | have hpN : p≤experimentN := by |
| 54 | have hh := (Finset.mem_filter.mp (Finset.mem_filter.mp hp).1).1 |
| 55 | simpa only [Finset.mem_range,Nat.lt_succ_iff] using hh |
| 56 | have hqN : q≤experimentN := by |
| 57 | have hh := (Finset.mem_filter.mp (Finset.mem_filter.mp hq).1).1 |
| 58 | simpa only [Finset.mem_range,Nat.lt_succ_iff] using hh |
| 59 | omega |
| 60 | · intro p hp |
| 61 | rcases Finset.mem_filter.mp hp with ⟨hS,hle⟩ |
| 62 | rcases Finset.mem_filter.mp hS with ⟨hr,hp,hq⟩ |
| 63 | have hn : p≤experimentN := by simpa only [Finset.mem_range,Nat.lt_succ_iff] using hr |
| 64 | have hneq := experiment_prime_pair_ne hp hq (Nat.add_sub_of_le hn) |
| 65 | have hrev : experimentN-(experimentN-p)=p := Nat.sub_sub_self hn |
| 66 | refine ⟨experimentN-p,?_,hrev⟩ |
| 67 | simp only [Finset.mem_filter,S,Finset.mem_range,Nat.lt_succ_iff,hrev] |
| 68 | exact ⟨⟨Nat.sub_le _ _,hq,hp⟩,by omega⟩ |
| 69 | · intro p hp |
| 70 | have hpN : p≤experimentN := by |
| 71 | have hh := (Finset.mem_filter.mp (Finset.mem_filter.mp hp).1).1 |
| 72 | simpa only [Finset.mem_range,Nat.lt_succ_iff] using hh |
| 73 | rw [Nat.cast_sub hpN] |
| 74 | rw [← wideCutoff_reflection] |
| 75 | have hs := Finset.sum_filter_add_sum_filter_not S (fun p => p≤experimentN-p) (fun p => wideCutoff p^2) |
| 76 | rw [hswap] at hs |
| 77 | have he : orderedWidePrimeMass=∑ p ∈ S, wideCutoff p^2 := by simp [orderedWidePrimeMass,S,Finset.sum_filter] |
| 78 | have hl : unorderedWidePrimeMass=∑ p ∈ S.filter (fun p => p≤experimentN-p), wideCutoff p^2 := by |
| 79 | simp only [unorderedWidePrimeMass,S,Finset.filter_filter,Finset.sum_filter] |
| 80 | apply Finset.sum_congr rfl |
| 81 | intro p hp |
| 82 | simp only [and_assoc] |
| 83 | rw [he,hl] |
| 84 | linarith |
| 85 | |
| 86 | lemma unorderedWidePrimeMass_add_edge : unorderedWidePrimeMass+edgeCorrection=(unorderedPrimePairs:ℝ) := by |
| 87 | let pred := fun p : ℕ => p.Prime ∧ (experimentN-p).Prime ∧ p≤experimentN-p |
| 88 | have he : edgeCorrection=∑ p ∈ Finset.range (experimentN+1), if pred p then 1-wideCutoff p^2 else 0 := by |
| 89 | unfold edgeCorrection |
| 90 | apply Finset.sum_subset |
| 91 | · intro p hp |
| 92 | simp only [Finset.mem_range,experimentN] at hp ⊢ |
| 93 | omega |
| 94 | · intro p hp hout |
| 95 | have hge : 1000≤p := by simpa only [Finset.mem_range,not_lt] using hout |
| 96 | by_cases hh : pred p |
| 97 | · have hbound : (p:ℝ)∈Set.Icc (1000:ℝ) (experimentN-1000) := by |
| 98 | have hpq := hh.2.2 |
| 99 | constructor |
| 100 | · exact_mod_cast hge |
| 101 | · have : p≤29030 := by norm_num [experimentN] at hpq; omega |
| 102 | norm_num [experimentN] |
| 103 | exact_mod_cast this |
| 104 | rw [ite_eq_left hh,wideCutoff_plateau p hbound] |
| 105 | norm_num |
| 106 | · exact ite_eq_right hh |
| 107 | have hc : (unorderedPrimePairs:ℝ)=∑ p ∈ Finset.range (experimentN+1), if pred p then (1:ℝ) else 0 := by |
| 108 | unfold unorderedPrimePairs |
| 109 | rw [Finset.card_eq_sum_ones,Finset.sum_filter] |
| 110 | push_cast |
| 111 | rfl |
| 112 | rw [he,hc] |
| 113 | unfold unorderedWidePrimeMass |
| 114 | rw [← Finset.sum_add_distrib] |
| 115 | apply Finset.sum_congr rfl |
| 116 | intro p hp |
| 117 | change (if pred p then _ else _)+(if pred p then _ else _)=(if pred p then _ else _) |
| 118 | split_ifs <;> ring |
| 119 | |
| 120 | end ConditionalGoldbach |
