Download lean/OAI/NumberTheory/CubicGram/IntegerBasis.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 4.57 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/NumberTheory/CubicGram/IntegerBasis.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/NumberTheory/CubicGram/IntegerBasis.lean
-
curl -L -o IntegerBasis.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/NumberTheory/CubicGram/IntegerBasis.lean
4.57 kB
Lean 4 · 18
declarations statementsfull
def coordinatesMap : (Fin 2 → ℤ) →ₗ[ℤ] Eisenstein where body · 3 lines
toFun v := ofCoords (v 0) (v 1)
map_add' v w := by simp [ofCoords, add_mul]; ring
map_smul' n v := by simp [ofCoords]; ringlemma coordinatesMap_bijective : Function.Bijective coordinatesMap := by proof · 10 lines
constructor
· intro v w h
have hh := coordinates_unique (congrArg (fun z : Eisenstein => (z : ℂ)) h)
funext i
fin_cases i
· exact hh.1
· exact hh.2
· intro z
obtain ⟨a,b,h⟩ := exists_coordinates z
exact ⟨![a,b], Subtype.ext h.symm⟩def coordinatesEquiv : (Fin 2 → ℤ) ≃ₗ[ℤ] Eisenstein := body · 1 line
LinearEquiv.ofBijective coordinatesMap coordinatesMap_bijectivedef integerBasis : Basis (Fin 2) ℤ Eisenstein := body · 1 line
(Pi.basisFun ℤ (Fin 2)).map coordinatesEquivinstance : Module.Free ℤ Eisenstein := Module.Free.of_basis integerBasis instance : Module.Finite ℤ Eisenstein := Module.Finite.of_basis integerBasis @[simp] lemma integerBasis_zero : integerBasis 0 = 1 := by proof · 1 line
simp [integerBasis, coordinatesEquiv, coordinatesMap, ofCoords, Pi.basisFun_apply]@[simp] lemma integerBasis_one : integerBasis 1 = omegaE := by proof · 1 line
simp [integerBasis, coordinatesEquiv, coordinatesMap, ofCoords, Pi.basisFun_apply]lemma integerBasis_repr_ofCoords (a b : ℤ) :
integerBasis.repr (ofCoords a b) = Finsupp.equivFunOnFinite.symm ![a,b] := by proof · 5 lines
apply Finsupp.equivFunOnFinite.injective
change coordinatesEquiv.symm (ofCoords a b) = ![a,b]
apply coordinatesEquiv.injective
simp only [LinearEquiv.apply_symm_apply]
rfllemma ofCoords_mul (a b c d : ℤ) :
ofCoords a b * ofCoords c d = ofCoords (a*c-b*d) (a*d+b*c-b*d) := by proof · 8 lines
apply Subtype.ext
change ((a : ℂ) + b * omega) * (c + d * omega) = _
rw [ofCoords_coe]
have h : omega^2 = -omega - 1 := by linear_combination omega_quadratic
push_cast
ring_nf
rw [h]
ringlemma ofCoords_mul_omega (a b : ℤ) : ofCoords a b * omegaE = ofCoords (-b) (a-b) := by proof · 2 lines
rw [show omegaE = ofCoords 0 1 by simp [ofCoords], ofCoords_mul]
simplemma leftMulMatrix_ofCoords (a b : ℤ) :
Algebra.leftMulMatrix integerBasis (ofCoords a b) = !![a, -b; b, a-b] := by proof · 3 lines
ext i j
fin_cases i <;> fin_cases j <;>
simp [Algebra.leftMulMatrix_eq_repr_mul, ofCoords_mul_omega, integerBasis_repr_ofCoords]lemma algebra_norm_ofCoords (a b : ℤ) :
Algebra.norm ℤ (ofCoords a b) = a^2 - a*b + b^2 := by proof · 3 lines
rw [Algebra.norm_eq_matrix_det integerBasis, leftMulMatrix_ofCoords, Matrix.det_fin_two]
simp
ringlemma algebra_norm_cast (z : Eisenstein) : (Algebra.norm ℤ z : ℝ) = norm z := by proof · 2 lines
obtain ⟨⟨a,b⟩,rfl⟩ := ofCoords_surjective z
rw [algebra_norm_ofCoords, norm, ofCoords_coe, coordinates_norm]lemma residues_card {z : Eisenstein} (hz : z ≠ 0) : Nat.card (Residues z) = normNat z := by proof · 19 lines
have hdet := Submodule.natAbs_det_basis_change integerBasis
((modulus z).restrictScalars ℤ) (Ideal.basisSpanSingleton integerBasis hz)
have hh : integerBasis.det (fun i =>
((Ideal.basisSpanSingleton integerBasis hz i : modulus z) : Eisenstein)) =
Algebra.norm ℤ z := by
rw [Algebra.norm_eq_matrix_det integerBasis, Basis.det_apply]
congr 1
ext i j
simp [Basis.toMatrix_apply, Ideal.basisSpanSingleton_apply,
Algebra.leftMulMatrix_eq_repr_mul]
change (integerBasis.det (fun i =>
((Ideal.basisSpanSingleton integerBasis hz i : modulus z) : Eisenstein))).natAbs =
Nat.card (Residues z) at hdet
rw [hh] at hdet
have hn : 0 ≤ Algebra.norm ℤ z := by
exact_mod_cast (algebra_norm_cast z).symm ▸ norm_nonneg z
rw [← hdet]
apply Nat.cast_injective (R := ℝ)
rw [normNat_cast, ← Int.cast_natCast, Int.natCast_natAbs, abs_of_nonneg hn, algebra_norm_cast]lemma norm_eq_zero_iff {z : Eisenstein} : norm z = 0 ↔ z = 0 := by proof · 5 lines
rw [norm, Complex.normSq_eq_zero]
constructor
· exact fun h => Subtype.ext h
· rintro rfl
rfllemma normNat_ne_zero {z : Eisenstein} (hz : z ≠ 0) : normNat z ≠ 0 := by proof · 4 lines
intro h
apply hz
apply norm_eq_zero_iff.mp
rw [← normNat_cast, h, Nat.cast_zero]lemma finite_residues {z : Eisenstein} (hz : z ≠ 0) : Finite (Residues z) := proof · 1 line
Nat.finite_of_card_ne_zero (by rw [residues_card hz]; exact normNat_ne_zero hz)Outline
- def
coordinatesMap14 - lemma
coordinatesMap_bijective19 - def
coordinatesEquiv31 - def
integerBasis34 - instance
37 - instance
38 - lemma
integerBasis_zero40 - lemma
integerBasis_one43 - lemma
integerBasis_repr_ofCoords46 - lemma
ofCoords_mul54 - lemma
ofCoords_mul_omega65 - lemma
leftMulMatrix_ofCoords69 - lemma
algebra_norm_ofCoords75 - lemma
algebra_norm_cast81 - lemma
residues_card85 - lemma
norm_eq_zero_iff106 - lemma
normNat_ne_zero113 - lemma
finite_residues119