import Mathlib /-! # Integral -/ namespace OAI.NumberTheory.Splitting.Integral.SplitPrimesConstruction open _root_.Polynomial _root_.NumberField open scoped _root_.NumberField /-- A number field admits a power basis generated by an algebraic integer. -/ theorem exists_integral_powerBasis (L : Type*) [Field L] [NumberField L] : ∃ B : PowerBasis ℚ L, IsIntegral ℤ B.gen := by let B := Field.powerBasisOfFiniteOfSeparable ℚ L obtain ⟨m, hm⟩ := IsIntegral.exists_multiple_integral_of_isLocalization (nonZeroDivisors ℤ) (Rₘ := ℚ) B.gen B.isIntegral_gen let x : L := (m : ℤ) • B.gen have hx : IsIntegral ℤ x := hm have hm0 : ((m : ℤ) : ℚ) ≠ 0 := by exact_mod_cast nonZeroDivisors.coe_ne_zero m have htop : Algebra.adjoin ℚ {x} = ⊤ := by apply B.adjoin_eq_top_of_gen_mem_adjoin have h := (Algebra.adjoin ℚ {x}).smul_mem (Algebra.subset_adjoin (Set.mem_singleton x)) (((m : ℤ) : ℚ)⁻¹) convert h using 1 dsimp [x] rw [← Int.cast_smul_eq_zsmul ℚ, smul_smul, inv_mul_cancel₀ hm0, one_smul] let B' := PowerBasis.ofAdjoinEqTop' (hx.tower_top : IsIntegral ℚ x) htop exact ⟨B', by simpa [B'] using hx⟩ /-- The conductor of an integral primitive element contains a nonzero integer. -/ theorem exists_integer_mem_conductor (L : Type*) [Field L] [NumberField L] (B : PowerBasis ℚ L) (hint : IsIntegral ℤ B.gen) : ∃ d : ℤ, d ≠ 0 ∧ (d : 𝓞 L) ∈ conductor ℤ (⟨B.gen, hint⟩ : 𝓞 L) := by let θ : 𝓞 L := ⟨B.gen, hint⟩ have hdint : IsIntegral ℤ (Algebra.discr ℚ B.basis) := by apply Algebra.discr_isIntegral intro i rw [B.basis_eq_pow] exact hint.pow _ obtain ⟨d, hd⟩ := IsIntegrallyClosed.isIntegral_iff.mp hdint have hd0 : d ≠ 0 := by intro h have hn := (Algebra.discr_isUnit_of_basis ℚ B.basis).ne_zero apply hn rw [← hd, h, map_zero] refine ⟨d, hd0, ?_⟩ change ∀ z : 𝓞 L, (d : 𝓞 L) * z ∈ Algebra.adjoin ℤ {θ} intro z have hz := Algebra.discr_mul_isIntegral_mem_adjoin ℚ hint (NumberField.RingOfIntegers.isIntegral_coe z) have hmap : (Algebra.adjoin ℤ {θ}).map (IsScalarTower.toAlgHom ℤ (𝓞 L) L) = Algebra.adjoin ℤ {B.gen} := by rw [AlgHom.map_adjoin, Set.image_singleton] rfl have hz' : algebraMap (𝓞 L) L ((d : 𝓞 L) * z) ∈ (Algebra.adjoin ℤ {θ}).map (IsScalarTower.toAlgHom ℤ (𝓞 L) L) := by rw [hmap] convert hz using 1 simp only [map_mul, map_intCast, ← hd, Algebra.smul_def] simp obtain ⟨y, hy, heq⟩ := hz' have heq' : y = (d : 𝓞 L) * z := (FaithfulSMul.algebraMap_injective (𝓞 L) L) heq exact heq' ▸ hy /-- Only finitely many primes divide the conductor exponent. -/ theorem integral_generator_exponent_ne_zero (L : Type*) [Field L] [NumberField L] (B : PowerBasis ℚ L) (hint : IsIntegral ℤ B.gen) : RingOfIntegers.exponent (⟨B.gen, hint⟩ : 𝓞 L) ≠ 0 := by obtain ⟨d, hd0, hd⟩ := exists_integer_mem_conductor L B hint change Ideal.absNorm (Ideal.under ℤ (conductor ℤ (⟨B.gen, hint⟩ : 𝓞 L))) ≠ 0 rw [ne_eq, Ideal.absNorm_eq_zero_iff] intro h have hm : d ∈ Ideal.under ℤ (conductor ℤ (⟨B.gen, hint⟩ : 𝓞 L)) := hd rw [h, Ideal.mem_bot] at hm exact hd0 hm /-- Normality implies that the integral minimal polynomial splits already over the ring of integers. -/ theorem integral_minpoly_splits (L : Type*) [Field L] [NumberField L] [IsGalois ℚ L] (θ : 𝓞 L) : ((minpoly ℤ θ).map (algebraMap ℤ (𝓞 L))).Splits := by have hfield : ((minpoly ℤ θ).map (algebraMap ℤ L)).Splits := by have h := Normal.splits (inferInstance : Normal ℚ L) (θ : L) rw [minpoly.isIntegrallyClosed_eq_field_fractions ℚ L θ.isIntegral, Polynomial.map_map, ← IsScalarTower.algebraMap_eq] at h exact h apply Splits.of_splits_map_of_injective (i := algebraMap (𝓞 L) L) (FaithfulSMul.algebraMap_injective (𝓞 L) L) · simpa only [Polynomial.map_map, ← IsScalarTower.algebraMap_eq] using hfield · intro a ha have ha' : aeval a (minpoly ℤ θ) = 0 := by simpa only [Polynomial.map_map, ← IsScalarTower.algebraMap_eq, IsRoot.def, eval_map_algebraMap] using (isRoot_of_mem_roots ha) exact ⟨⟨a, ⟨minpoly ℤ θ, minpoly.monic θ.isIntegral, ha'⟩⟩, rfl⟩ end OAI.NumberTheory.Splitting.Integral.SplitPrimesConstruction