Download lean/OAI/NumberTheory/SingleFold/LocalDescent.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 7.66 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/NumberTheory/SingleFold/LocalDescent.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/NumberTheory/SingleFold/LocalDescent.lean
-
curl -L -o LocalDescent.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/NumberTheory/SingleFold/LocalDescent.lean
7.66 kB
| import OAI.NumberTheory.SingleFold.SquareSupport | |
| namespace OAI | |
| namespace SingleFold.LocalFive | |
| lemma mod_five_anisotropic (c : ℤ) (hc : c=2 ∨ c= -2) (a b : ℤ) (h : (5:ℤ) ∣ a^2-c*b^2) : | |
| (5:ℤ) ∣ a ∧ (5:ℤ) ∣ b := by | |
| have hh : (a:ZMod 5)^2-(c:ZMod 5)*(b:ZMod 5)^2=0 := by | |
| exact_mod_cast (ZMod.intCast_zmod_eq_zero_iff_dvd (a^2-c*b^2) 5).mpr h | |
| have hz : (a:ZMod 5)=0 ∧ (b:ZMod 5)=0 := by | |
| rcases hc with rfl | rfl | |
| · exact (by decide : ∀ a b : ZMod 5, a^2-2*b^2=0 → a=0 ∧ b=0) _ _ (by simpa using hh) | |
| · exact (by decide : ∀ a b : ZMod 5, a^2-(-2)*b^2=0 → a=0 ∧ b=0) _ _ (by simpa using hh) | |
| exact ⟨(ZMod.intCast_zmod_eq_zero_iff_dvd a 5).mp hz.1, | |
| (ZMod.intCast_zmod_eq_zero_iff_dvd b 5).mp hz.2⟩ | |
| lemma five_dvd_of_sq {a : ℤ} (h : (5:ℤ) ∣ a^2) : (5:ℤ) ∣ a := | |
| (show Prime (5:ℤ) by norm_num).dvd_of_dvd_pow h | |
| lemma no_norm_five_int (c : ℤ) (hc : c=2 ∨ c= -2) (N : ℕ) : ∀ R S : ℤ, R^2-c*S^2=5*(N:ℤ)^2 → N=0 := by | |
| induction N using Nat.strong_induction_on with | |
| | h N ih => | |
| intro R S he | |
| by_cases hN : N=0 | |
| · exact hN | |
| obtain ⟨hr,hs⟩ := mod_five_anisotropic c hc R S ⟨(N:ℤ)^2, he⟩ | |
| obtain ⟨r,hr⟩ := hr | |
| obtain ⟨s,hs⟩ := hs | |
| have hd : (5:ℤ) ∣ (N:ℤ)^2 := ⟨r^2-c*s^2, by rw [hr,hs] at he; nlinarith only [he]⟩ | |
| have hd' : 5 ∣ N := by exact_mod_cast five_dvd_of_sq hd | |
| obtain ⟨n,hn⟩ := hd' | |
| have hnl : n < N := by omega | |
| have he' : r^2-c*s^2=5*(n:ℤ)^2 := by | |
| rw [hr,hs,hn] at he | |
| push_cast at he | |
| nlinarith only [he] | |
| have hn0 := ih n hnl r s he' | |
| omega | |
| lemma no_norm_five (c : ℤ) (hc : c=2 ∨ c= -2) (r s : ℚ) : r^2-(c:ℚ)*s^2 ≠ 5 := by | |
| intro h | |
| let N := r.den*s.den | |
| let R : ℤ := r.num*s.den | |
| let S : ℤ := s.num*r.den | |
| have he : R^2-c*S^2=5*(N:ℤ)^2 := by | |
| have h' : (R:ℚ)^2-(c:ℚ)*(S:ℚ)^2=5*(N:ℚ)^2 := by | |
| dsimp [R,S,N] | |
| push_cast | |
| have hr := r.num_div_den | |
| have hs := s.num_div_den | |
| rw [←hr,←hs] at h | |
| field_simp at h | |
| nlinarith only [h] | |
| exact_mod_cast h' | |
| have hz := no_norm_five_int c hc N R S he | |
| exact (Nat.mul_ne_zero r.den_ne_zero s.den_ne_zero) hz | |
| lemma no_norm_ten (r s : ℚ) : r^2-10*s^2 ≠ 5 := by | |
| intro h | |
| have hr : r ≠ 0 := by intro hh; rw [hh] at h; nlinarith [sq_nonneg s] | |
| have h' : (5/r)^2-(-2:ℤ)*(5*s/r)^2=5 := by | |
| push_cast | |
| field_simp | |
| nlinarith only [h] | |
| exact no_norm_five (-2) (Or.inr rfl) (5/r) (5*s/r) h' | |
| end SingleFold.LocalFive | |
| namespace SingleFold.Descent | |
| open WeierstrassCurve WeierstrassCurve.Affine WeierstrassCurve.Affine.Point | |
| lemma alpha_five_when_zero (P : E.Point) (h0 : classOf (alphaVal 0 P)=1) : | |
| classOf (alphaVal 5 P)=1 ∨ classOf (alphaVal 5 P)=classOf 5 := by | |
| cases P with | |
| | zero => exact Or.inl (by simp [←zero_def]) | |
| | some x y h => | |
| have hsq := (classOf_eq_one_iff (alphaVal_ne_zero 0 (by norm_num) (some x y h))).mp h0 | |
| by_cases hx : x=0 | |
| · have hs : IsSquare (-25:ℚ) := by | |
| simp only [alphaVal,adjusted,hx,sub_self] at hsq | |
| convert hsq using 1; norm_num | |
| obtain ⟨r,hr⟩ := hs | |
| nlinarith [sq_nonneg r] | |
| have hs : IsSquare x := by simpa [alphaVal,adjusted,hx] using hsq | |
| obtain ⟨r,hr⟩ := hs | |
| have hxp : 0 < x := lt_of_le_of_ne (by nlinarith [sq_nonneg r]) (Ne.symm hx) | |
| have hx5 : x ≠ 5 := by | |
| intro he | |
| exact not_isSquare_prime 5 (by norm_num) (by change IsSquare (5:ℚ); rw [←he]; exact ⟨r,hr⟩) | |
| have hx5p : 5 < x := by | |
| have he := equation h | |
| by_contra hn | |
| have hl : x < 5 := lt_of_le_of_ne (le_of_not_gt hn) hx5 | |
| have hm : x*(5-x)*(x+5)>0 := mul_pos (mul_pos hxp (sub_pos.mpr hl)) (by linarith) | |
| nlinarith [sq_nonneg y] | |
| obtain ⟨d,s,hd,hs0,he⟩ := supported_five (some x y h) | |
| have ha : alphaVal 5 (some x y h)=x-5 := by simp [alphaVal,adjusted,sub_ne_zero.mpr hx5] | |
| rw [ha] at he ⊢ | |
| have hdpos : 0 < d := Nat.pos_of_ne_zero (by intro hh; subst d; norm_num at hd) | |
| have hnneg : ¬ x-5= -((d:ℚ)*s^2) := by | |
| have hdq : 0 ≤ (d:ℚ) := Nat.cast_nonneg d | |
| have hnon := mul_nonneg hdq (sq_nonneg s) | |
| intro hh | |
| linarith | |
| have he := he.resolve_right hnneg | |
| have hdle := Nat.le_of_dvd (by norm_num : 0 < 10) hd | |
| interval_cases d <;> norm_num at hd | |
| · left | |
| rw [he] | |
| simpa using classOf_mul_sq (d:=1) (by norm_num) hs0 | |
| · exfalso | |
| apply LocalFive.no_norm_five 2 (Or.inl rfl) r s | |
| norm_num at he ⊢ | |
| nlinarith only [hr,he] | |
| · right | |
| rw [he] | |
| exact classOf_mul_sq (by norm_num) hs0 | |
| · exfalso | |
| apply LocalFive.no_norm_ten r s | |
| norm_num at he | |
| nlinarith only [hr,he] | |
| noncomputable def a0 : E.Point →+ Additive SquareClass := alpha 0 (by norm_num) (by norm_num) | |
| noncomputable def a5 : E.Point →+ Additive SquareClass := alpha 5 (by norm_num) (by norm_num) | |
| def T0 : E.Point := some 0 0 (E.equation_iff_nonsingular.mp (by norm_num [WeierstrassCurve.Affine.equation_iff,E])) | |
| def T5 : E.Point := some 5 0 (E.equation_iff_nonsingular.mp (by norm_num [WeierstrassCurve.Affine.equation_iff,E])) | |
| def G : E.Point := some (25/4) (75/8) (E.equation_iff_nonsingular.mp (by norm_num [WeierstrassCurve.Affine.equation_iff,E])) | |
| lemma a0_T0 : a0 T0 = Additive.ofMul (classOf (-1)) := by | |
| change classOf _ = _ | |
| have hh := classOf_mul_sq (d := -1) (r := 5) (by norm_num) (by norm_num) | |
| norm_num [T0,alphaVal,adjusted] at * | |
| exact hh | |
| lemma a0_T5 : a0 T5 = Additive.ofMul (classOf 5) := by | |
| change classOf (alphaVal 0 T5) = classOf 5 | |
| norm_num [T5,alphaVal,adjusted] | |
| lemma a0_G : a0 G = 0 := by | |
| change classOf _ = 1 | |
| have hh := classOf_mul_sq (d := 1) (r := 5/2) (by norm_num) (by norm_num) | |
| norm_num [G,alphaVal,adjusted] at * | |
| exact hh | |
| lemma a5_G : a5 G = Additive.ofMul (classOf 5) := by | |
| change classOf _ = _ | |
| have hh := classOf_mul_sq (d := 5) (r := 1/2) (by norm_num) (by norm_num) | |
| norm_num [G,alphaVal,adjusted] at * | |
| exact hh | |
| lemma normalize_a0 (P : E.Point) : ∃ S : E.Point, | |
| (S=0 ∨ S=T0 ∨ S=T5 ∨ S=T0+T5) ∧ a0 (P-S)=0 := by | |
| obtain h | h | h | h := alpha_zero_classes P | |
| · refine ⟨0,Or.inl rfl,?_⟩ | |
| change classOf (alphaVal 0 (P-0))=1 | |
| simpa only [sub_zero,classOf_one] using h | |
| · refine ⟨T0,Or.inr (Or.inl rfl),?_⟩ | |
| rw [map_sub,a0_T0] | |
| exact sub_eq_zero.mpr h | |
| · refine ⟨T5,Or.inr (Or.inr (Or.inl rfl)),?_⟩ | |
| rw [map_sub,a0_T5] | |
| exact sub_eq_zero.mpr h | |
| · refine ⟨T0+T5,Or.inr (Or.inr (Or.inr rfl)),?_⟩ | |
| rw [map_sub,map_add,a0_T0,a0_T5] | |
| apply sub_eq_zero.mpr | |
| change classOf (alphaVal 0 P)=classOf (-1)*classOf 5 | |
| rw [←classOf_mul (by norm_num) (by norm_num)] | |
| norm_num | |
| exact h | |
| theorem mod_two_cover (P : E.Point) : ∃ S : E.Point, ∃ b : Bool, ∃ Q : E.Point, | |
| (S=0 ∨ S=T0 ∨ S=T5 ∨ S=T0+T5) ∧ P = (S + if b then G else 0) + (2:ℕ) • Q := by | |
| obtain ⟨S,hS,h0⟩ := normalize_a0 P | |
| have h5 := alpha_five_when_zero (P-S) h0 | |
| rcases h5 with h5 | h5 | |
| · have hk : kummer (P-S)=0 := by | |
| apply Prod.ext | |
| · exact h0 | |
| · exact h5 | |
| obtain ⟨Q,hQ⟩ := (kummer_eq_zero_iff _).mp hk | |
| refine ⟨S,false,Q,hS,?_⟩ | |
| simp only [Bool.false_eq_true, ↓reduceIte, add_zero] | |
| rw [hQ] | |
| abel | |
| · have hk : kummer (P-S-G)=0 := by | |
| apply Prod.ext | |
| · change a0 (P-S-G)=0 | |
| rw [map_sub,h0,a0_G,sub_self] | |
| · change a5 (P-S-G)=0 | |
| rw [map_sub,a5_G] | |
| exact sub_eq_zero.mpr h5 | |
| obtain ⟨Q,hQ⟩ := (kummer_eq_zero_iff _).mp hk | |
| refine ⟨S,true,Q,hS,?_⟩ | |
| simp only [↓reduceIte] | |
| rw [hQ] | |
| abel | |
| end SingleFold.Descent | |
| end OAI | |