source
stringlengths
17
118
lean4
stringlengths
0
335k
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Completion.lean
import Mathlib.NumberTheory.NumberField.InfinitePlace.Completion deprecated_module (since := "2025-09-24")
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Basic.lean
import Mathlib.Algebra.Algebra.Rat import Mathlib.Algebra.CharZero.AddMonoidHom import Mathlib.Algebra.Ring.Int.Parity import Mathlib.Algebra.Ring.Int.Units import Mathlib.RingTheory.DedekindDomain.IntegralClosure /-! # Number fields This file defines a number field and the ring of integers corresponding to it. ## Main definitions - `NumberField` defines a number field as a field which has characteristic zero and is finite dimensional over ℚ. - `RingOfIntegers` defines the ring of integers (or number ring) corresponding to a number field as the integral closure of ℤ in the number field. ## Implementation notes The definitions that involve a field of fractions choose a canonical field of fractions, but are independent of that choice. ## References * [D. Marcus, *Number Fields*][marcus1977number] * [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic] * [P. Samuel, *Algebraic Theory of Numbers*][samuel1967] ## Tags number field, ring of integers -/ /-- A number field is a field which has characteristic zero and is finite dimensional over ℚ. -/ @[stacks 09GA] class NumberField (K : Type*) [Field K] : Prop where [to_charZero : CharZero K] [to_finiteDimensional : FiniteDimensional ℚ K] open Function Module open scoped nonZeroDivisors /-- `ℤ` with its usual ring structure is not a field. -/ theorem Int.not_isField : ¬IsField ℤ := fun h => Int.not_even_one <| (h.mul_inv_cancel two_ne_zero).imp fun a => by rw [← two_mul]; exact Eq.symm namespace NumberField variable (K L : Type*) [Field K] [Field L] -- See note [lower instance priority] attribute [instance] NumberField.to_charZero NumberField.to_finiteDimensional protected theorem isAlgebraic [NumberField K] : Algebra.IsAlgebraic ℚ K := Algebra.IsAlgebraic.of_finite _ _ instance [NumberField K] [NumberField L] [Algebra K L] : FiniteDimensional K L := Module.Finite.of_restrictScalars_finite ℚ K L /-- A finite extension of a number field is a number field. -/ theorem of_module_finite [NumberField K] [Algebra K L] [Module.Finite K L] : NumberField L where to_charZero := charZero_of_injective_algebraMap (algebraMap K L).injective to_finiteDimensional := letI := charZero_of_injective_algebraMap (algebraMap K L).injective Module.Finite.trans K L variable {K} {L} in instance of_intermediateField [NumberField K] [NumberField L] [Algebra K L] (E : IntermediateField K L) : NumberField E := of_module_finite K E variable {K} in instance of_subfield [NumberField K] (E : Subfield K) : NumberField E where to_finiteDimensional := FiniteDimensional.left ℚ E K theorem of_tower [NumberField K] [NumberField L] [Algebra K L] (E : Type*) [Field E] [Algebra K E] [Algebra E L] [IsScalarTower K E L] : NumberField E := letI := Module.Finite.left K E L of_module_finite K E theorem of_ringEquiv (e : K ≃+* L) [NumberField K] : NumberField L := letI := CharZero.of_addMonoidHom e.toAddMonoidHom (by simp) e.injective { to_charZero := inferInstance to_finiteDimensional := (e : K ≃ₗ[ℚ] L).finiteDimensional } /-- The ring of integers (or number ring) corresponding to a number field is the integral closure of ℤ in the number field. This is defined as its own type, rather than a `Subalgebra`, for performance reasons: looking for instances of the form `SMul (RingOfIntegers _) (RingOfIntegers _)` makes much more effective use of the discrimination tree than instances of the form `SMul (Subtype _) (Subtype _)`. The drawback is we have to copy over instances manually. -/ def RingOfIntegers : Type _ := integralClosure ℤ K @[inherit_doc] scoped notation "𝓞" => NumberField.RingOfIntegers namespace RingOfIntegers instance : CommRing (𝓞 K) := inferInstanceAs (CommRing (integralClosure _ _)) instance : IsDomain (𝓞 K) := inferInstanceAs (IsDomain (integralClosure _ _)) instance [NumberField K] : CharZero (𝓞 K) := inferInstanceAs (CharZero (integralClosure _ _)) instance : Algebra (𝓞 K) K := inferInstanceAs (Algebra (integralClosure _ _) _) instance : NoZeroSMulDivisors (𝓞 K) K := inferInstanceAs (NoZeroSMulDivisors (integralClosure _ _) _) instance : Nontrivial (𝓞 K) := inferInstanceAs (Nontrivial (integralClosure _ _)) instance {L : Type*} [Ring L] [Algebra K L] : Algebra (𝓞 K) L := inferInstanceAs (Algebra (integralClosure _ _) L) instance {L : Type*} [Ring L] [Algebra K L] : IsScalarTower (𝓞 K) K L := inferInstanceAs (IsScalarTower (integralClosure _ _) K L) instance {G : Type*} [Group G] [MulSemiringAction G K] : MulSemiringAction G (𝓞 K) := inferInstanceAs (MulSemiringAction G (integralClosure ℤ K)) instance {G : Type*} [Group G] [MulSemiringAction G K] : SMulDistribClass G (𝓞 K) K := inferInstanceAs (SMulDistribClass G (integralClosure ℤ K) K) variable {K} /-- The canonical coercion from `𝓞 K` to `K`. -/ @[coe] abbrev val (x : 𝓞 K) : K := algebraMap _ _ x /-- This instance has to be `CoeHead` because we only want to apply it from `𝓞 K` to `K`. -/ instance : CoeHead (𝓞 K) K := ⟨val⟩ lemma coe_eq_algebraMap (x : 𝓞 K) : (x : K) = algebraMap _ _ x := rfl @[ext] theorem ext {x y : 𝓞 K} (h : (x : K) = (y : K)) : x = y := Subtype.ext h @[norm_cast] theorem eq_iff {x y : 𝓞 K} : (x : K) = (y : K) ↔ x = y := NumberField.RingOfIntegers.ext_iff.symm @[simp] lemma map_mk (x : K) (hx) : algebraMap (𝓞 K) K ⟨x, hx⟩ = x := rfl lemma coe_mk {x : K} (hx) : ((⟨x, hx⟩ : 𝓞 K) : K) = x := rfl lemma mk_eq_mk (x y : K) (hx hy) : (⟨x, hx⟩ : 𝓞 K) = ⟨y, hy⟩ ↔ x = y := by simp @[simp] lemma mk_one : (⟨1, one_mem _⟩ : 𝓞 K) = 1 := rfl @[simp] lemma mk_zero : (⟨0, zero_mem _⟩ : 𝓞 K) = 0 := rfl -- TODO: these lemmas don't seem to fire? @[simp] lemma mk_add_mk (x y : K) (hx hy) : (⟨x, hx⟩ : 𝓞 K) + ⟨y, hy⟩ = ⟨x + y, add_mem hx hy⟩ := rfl @[simp] lemma mk_mul_mk (x y : K) (hx hy) : (⟨x, hx⟩ : 𝓞 K) * ⟨y, hy⟩ = ⟨x * y, mul_mem hx hy⟩ := rfl @[simp] lemma mk_sub_mk (x y : K) (hx hy) : (⟨x, hx⟩ : 𝓞 K) - ⟨y, hy⟩ = ⟨x - y, sub_mem hx hy⟩ := rfl @[simp] lemma neg_mk (x : K) (hx) : (-⟨x, hx⟩ : 𝓞 K) = ⟨-x, neg_mem hx⟩ := rfl /-- The ring homomorphism `(𝓞 K) →+* (𝓞 L)` given by restricting a ring homomorphism `f : K →+* L` to `𝓞 K`. -/ def mapRingHom {K L : Type*} [Field K] [Field L] (f : K →+* L) : (𝓞 K) →+* (𝓞 L) where toFun k := ⟨f k.val, map_isIntegral_int f k.2⟩ map_zero' := by ext; simp only [map_mk, map_zero] map_one' := by ext; simp only [map_mk, map_one] map_add' x y:= by ext; simp only [map_mk, map_add] map_mul' x y := by ext; simp only [map_mk, map_mul] @[simp] theorem mapRingHom_apply {K L : Type*} [Field K] [Field L] (f : K →+* L) (x : 𝓞 K) : (mapRingHom f x : L) = f (x : K) := rfl /-- The ring isomorphism `(𝓞 K) ≃+* (𝓞 L)` given by restricting a ring isomorphism `e : K ≃+* L` to `𝓞 K`. -/ def mapRingEquiv {K L : Type*} [Field K] [Field L] (e : K ≃+* L) : (𝓞 K) ≃+* (𝓞 L) := RingEquiv.ofRingHom (mapRingHom e) (mapRingHom e.symm) (RingHom.ext fun x => ext (EquivLike.right_inv e x.1)) (RingHom.ext fun x => ext (EquivLike.left_inv e x.1)) @[simp] theorem mapRingEquiv_apply {K L : Type*} [Field K] [Field L] (e : K ≃+* L) (x : 𝓞 K) : (mapRingEquiv e x : L) = e (x : K) := rfl @[simp] theorem mapRingEquiv_symm_apply {K L : Type*} [Field K] [Field L] (e : K ≃+* L) (x : 𝓞 L) : ((mapRingEquiv e).symm x : K) = e.symm (x : L) := rfl end RingOfIntegers /-- Given an algebra structure between two fields, this instance creates an algebra structure between their two rings of integers. -/ instance inst_ringOfIntegersAlgebra [Algebra K L] : Algebra (𝓞 K) (𝓞 L) := (RingOfIntegers.mapRingHom (algebraMap K L)).toAlgebra -- diamond at `reducible_and_instances` https://github.com/leanprover-community/mathlib4/issues/10906 example : Algebra.id (𝓞 K) = inst_ringOfIntegersAlgebra K K := rfl namespace RingOfIntegers /-- The algebra homomorphism `(𝓞 K) →ₐ[𝓞 k] (𝓞 L)` given by restricting an algebra homomorphism `f : K →ₐ[k] L` to `𝓞 K`. -/ def mapAlgHom {k K L F : Type*} [Field k] [Field K] [Field L] [Algebra k K] [Algebra k L] [FunLike F K L] [AlgHomClass F k K L] (f : F) : (𝓞 K) →ₐ[𝓞 k] (𝓞 L) where toRingHom := mapRingHom f commutes' x := SetCoe.ext (AlgHomClass.commutes ((f : K →ₐ[k] L).restrictScalars (𝓞 k)) x) /-- The isomorphism of algebras `(𝓞 K) ≃ₐ[𝓞 k] (𝓞 L)` given by restricting an isomorphism of algebras `e : K ≃ₐ[k] L` to `𝓞 K`. -/ def mapAlgEquiv {k K L E : Type*} [Field k] [Field K] [Field L] [Algebra k K] [Algebra k L] [EquivLike E K L] [AlgEquivClass E k K L] (e : E) : (𝓞 K) ≃ₐ[𝓞 k] (𝓞 L) := AlgEquiv.ofAlgHom (mapAlgHom e) (mapAlgHom (e : K ≃ₐ[k] L).symm) (AlgHom.ext fun x => ext (EquivLike.right_inv e x.1)) (AlgHom.ext fun x => ext (EquivLike.left_inv e x.1)) instance inst_isScalarTower (k K L : Type*) [Field k] [Field K] [Field L] [Algebra k K] [Algebra k L] [Algebra K L] [IsScalarTower k K L] : IsScalarTower (𝓞 k) (𝓞 K) (𝓞 L) := IsScalarTower.of_algHom (mapAlgHom (IsScalarTower.toAlgHom k K L)) variable {K} /-- The canonical map from `𝓞 K` to `K` is injective. This is a convenient abbreviation for `FaithfulSMul.algebraMap_injective`. -/ lemma coe_injective : Function.Injective (algebraMap (𝓞 K) K) := FaithfulSMul.algebraMap_injective _ _ /-- The canonical map from `𝓞 K` to `K` is injective. This is a convenient abbreviation for `map_eq_zero_iff` applied to `FaithfulSMul.algebraMap_injective`. -/ lemma coe_eq_zero_iff {x : 𝓞 K} : algebraMap _ K x = 0 ↔ x = 0 := map_eq_zero_iff _ coe_injective /-- The canonical map from `𝓞 K` to `K` is injective. This is a convenient abbreviation for `map_ne_zero_iff` applied to `FaithfulSMul.algebraMap_injective`. -/ lemma coe_ne_zero_iff {x : 𝓞 K} : algebraMap _ K x ≠ 0 ↔ x ≠ 0 := map_ne_zero_iff _ coe_injective theorem isIntegral_coe (x : 𝓞 K) : IsIntegral ℤ (algebraMap _ K x) := x.2 theorem isIntegral (x : 𝓞 K) : IsIntegral ℤ x := by obtain ⟨P, hPm, hP⟩ := x.isIntegral_coe refine ⟨P, hPm, ?_⟩ rwa [IsScalarTower.algebraMap_eq (S := 𝓞 K), ← Polynomial.hom_eval₂, coe_eq_zero_iff] at hP instance [NumberField K] : IsFractionRing (𝓞 K) K := integralClosure.isFractionRing_of_finite_extension ℚ _ instance : IsIntegralClosure (𝓞 K) ℤ K := integralClosure.isIntegralClosure _ _ instance : Algebra.IsIntegral ℤ (𝓞 K) := IsIntegralClosure.isIntegral_algebra ℤ K instance [NumberField K] : IsIntegrallyClosed (𝓞 K) := integralClosure.isIntegrallyClosedOfFiniteExtension ℚ /-- The ring of integers of `K` are equivalent to any integral closure of `ℤ` in `K` -/ protected noncomputable def equiv (R : Type*) [CommRing R] [Algebra R K] [IsIntegralClosure R ℤ K] : 𝓞 K ≃+* R := (IsIntegralClosure.equiv ℤ R K _).symm.toRingEquiv variable (K) instance [CharZero K] : CharZero (𝓞 K) := CharZero.of_module _ K variable [NumberField K] instance : IsNoetherian ℤ (𝓞 K) := IsIntegralClosure.isNoetherian _ ℚ K _ /-- The ring of integers of a number field is not a field. -/ theorem not_isField : ¬IsField (𝓞 K) := by have h_inj : Function.Injective (algebraMap ℤ (𝓞 K)) := RingHom.injective_int (algebraMap ℤ (𝓞 K)) intro hf exact Int.not_isField (((IsIntegralClosure.isIntegral_algebra ℤ K).isField_iff_isField h_inj).mpr hf) instance : IsDedekindDomain (𝓞 K) := IsIntegralClosure.isDedekindDomain ℤ ℚ K _ instance : Free ℤ (𝓞 K) := IsIntegralClosure.module_free ℤ ℚ K (𝓞 K) instance : IsLocalization (Algebra.algebraMapSubmonoid (𝓞 K) ℤ⁰) K := IsIntegralClosure.isLocalization_of_isSeparable ℤ ℚ K (𝓞 K) /-- A ℤ-basis of the ring of integers of `K`. -/ noncomputable def basis : Basis (Free.ChooseBasisIndex ℤ (𝓞 K)) ℤ (𝓞 K) := Free.chooseBasis ℤ (𝓞 K) variable {K} {M : Type*} /-- Given `f : M → K` such that `∀ x, IsIntegral ℤ (f x)`, the corresponding function `M → 𝓞 K`. -/ def restrict (f : M → K) (h : ∀ x, IsIntegral ℤ (f x)) (x : M) : 𝓞 K := ⟨f x, h x⟩ /-- Given `f : M →+ K` such that `∀ x, IsIntegral ℤ (f x)`, the corresponding function `M →+ 𝓞 K`. -/ def restrict_addMonoidHom [AddZeroClass M] (f : M →+ K) (h : ∀ x, IsIntegral ℤ (f x)) : M →+ 𝓞 K where toFun := restrict f h map_zero' := by simp only [restrict, map_zero, mk_zero] map_add' x y := by simp only [restrict, map_add, mk_add_mk _] /-- Given `f : M →* K` such that `∀ x, IsIntegral ℤ (f x)`, the corresponding function `M →* 𝓞 K`. -/ def restrict_monoidHom [MulOneClass M] (f : M →* K) (h : ∀ x, IsIntegral ℤ (f x)) : M →* 𝓞 K where toFun := restrict f h map_one' := by simp only [restrict, map_one, mk_one] map_mul' x y := by simp only [restrict, map_mul, mk_mul_mk _] section extension variable (K L : Type*) [Field K] [Field L] [Algebra K L] instance : IsScalarTower (𝓞 K) (𝓞 L) L := IsScalarTower.of_algebraMap_eq' rfl instance : IsIntegralClosure (𝓞 L) (𝓞 K) L := IsIntegralClosure.tower_top (R := ℤ) /-- The ring of integers of `L` is isomorphic to any integral closure of `𝓞 K` in `L` -/ protected noncomputable def algEquiv (R : Type*) [CommRing R] [Algebra (𝓞 K) R] [Algebra R L] [IsScalarTower (𝓞 K) R L] [IsIntegralClosure R (𝓞 K) L] : 𝓞 L ≃ₐ[𝓞 K] R := (IsIntegralClosure.equiv (𝓞 K) R L _).symm /-- Any extension between ring of integers is integral. -/ instance extension_algebra_isIntegral : Algebra.IsIntegral (𝓞 K) (𝓞 L) := IsIntegralClosure.isIntegral_algebra (𝓞 K) L /-- Any extension between ring of integers of number fields is Noetherian. -/ instance extension_isNoetherian [NumberField K] [NumberField L] : IsNoetherian (𝓞 K) (𝓞 L) := IsIntegralClosure.isNoetherian (𝓞 K) K L (𝓞 L) /-- The kernel of the algebraMap between ring of integers is `⊥`. -/ theorem ker_algebraMap_eq_bot : RingHom.ker (algebraMap (𝓞 K) (𝓞 L)) = ⊥ := (RingHom.ker_eq_bot_iff_eq_zero (algebraMap (𝓞 K) (𝓞 L))).mpr <| fun x hx => by have h : (algebraMap K L) x = (algebraMap (𝓞 K) (𝓞 L)) x := rfl simp only [hx, map_zero, map_eq_zero, RingOfIntegers.coe_eq_zero_iff] at h exact h /-- The algebraMap between ring of integers is injective. -/ theorem algebraMap.injective : Function.Injective (algebraMap (𝓞 K) (𝓞 L)) := (RingHom.injective_iff_ker_eq_bot (algebraMap (𝓞 K) (𝓞 L))).mpr (ker_algebraMap_eq_bot K L) instance : NoZeroSMulDivisors (𝓞 K) (𝓞 L) := NoZeroSMulDivisors.iff_algebraMap_injective.mpr <| algebraMap.injective K L instance : NoZeroSMulDivisors (𝓞 K) L := NoZeroSMulDivisors.trans_faithfulSMul (𝓞 K) (𝓞 L) L end extension end RingOfIntegers variable [NumberField K] /-- A basis of `K` over `ℚ` that is also a basis of `𝓞 K` over `ℤ`. -/ noncomputable def integralBasis : Basis (Free.ChooseBasisIndex ℤ (𝓞 K)) ℚ K := Basis.localizationLocalization ℚ (nonZeroDivisors ℤ) K (RingOfIntegers.basis K) @[simp] theorem integralBasis_apply (i : Free.ChooseBasisIndex ℤ (𝓞 K)) : integralBasis K i = algebraMap (𝓞 K) K (RingOfIntegers.basis K i) := Basis.localizationLocalization_apply ℚ (nonZeroDivisors ℤ) K (RingOfIntegers.basis K) i @[simp] theorem integralBasis_repr_apply (x : (𝓞 K)) (i : Free.ChooseBasisIndex ℤ (𝓞 K)) : (integralBasis K).repr (algebraMap _ _ x) i = (algebraMap ℤ ℚ) ((RingOfIntegers.basis K).repr x i) := Basis.localizationLocalization_repr_algebraMap ℚ (nonZeroDivisors ℤ) K _ x i theorem mem_span_integralBasis {x : K} : x ∈ Submodule.span ℤ (Set.range (integralBasis K)) ↔ x ∈ (algebraMap (𝓞 K) K).range := by rw [integralBasis, Basis.localizationLocalization_span, LinearMap.mem_range, IsScalarTower.coe_toAlgHom', RingHom.mem_range] theorem RingOfIntegers.rank : Module.finrank ℤ (𝓞 K) = Module.finrank ℚ K := IsIntegralClosure.rank ℤ ℚ K (𝓞 K) end NumberField namespace Rat open NumberField instance numberField : NumberField ℚ where to_charZero := inferInstance to_finiteDimensional := by -- The vector space structure of `ℚ` over itself can arise in multiple ways: -- all fields are vector spaces over themselves (used in `Rat.finiteDimensional`) -- all char 0 fields have a canonical embedding of `ℚ` (used in `NumberField`). -- Show that these coincide: convert (inferInstance : FiniteDimensional ℚ ℚ) /-- The ring of integers of `ℚ` as a number field is just `ℤ`. -/ noncomputable def ringOfIntegersEquiv : 𝓞 ℚ ≃+* ℤ := RingOfIntegers.equiv ℤ @[simp] theorem ringOfIntegersEquiv_apply_coe (z : 𝓞 ℚ) : (Rat.ringOfIntegersEquiv z : ℚ) = algebraMap (𝓞 ℚ) ℚ z := by obtain ⟨z, rfl⟩ := Rat.ringOfIntegersEquiv.symm.surjective z simp theorem ringOfIntegersEquiv_symm_apply_coe (x : ℤ) : (ringOfIntegersEquiv.symm x : ℚ) = ↑x := eq_intCast ringOfIntegersEquiv.symm _ ▸ rfl end Rat namespace AdjoinRoot section open scoped Polynomial attribute [-instance] DivisionRing.toRatAlgebra /-- The quotient of `ℚ[X]` by the ideal generated by an irreducible polynomial of `ℚ[X]` is a number field. -/ instance {f : Polynomial ℚ} [hf : Fact (Irreducible f)] : NumberField (AdjoinRoot f) where to_charZero := charZero_of_injective_algebraMap (algebraMap ℚ _).injective to_finiteDimensional := by convert (AdjoinRoot.powerBasis hf.out.ne_zero).finite end end AdjoinRoot
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Ideal.lean
import Mathlib.NumberTheory.NumberField.Ideal.Asymptotics deprecated_module (since := "2025-06-04")
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/FractionalIdeal.lean
import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.FractionalIdeal.Norm import Mathlib.RingTheory.FractionalIdeal.Operations /-! # Fractional ideals of number fields Prove some results on the fractional ideals of number fields. ## Main definitions and results * `NumberField.basisOfFractionalIdeal`: A `ℚ`-basis of `K` that spans `I` over `ℤ` where `I` is a fractional ideal of a number field `K`. * `NumberField.det_basisOfFractionalIdeal_eq_absNorm`: for `I` a fractional ideal of a number field `K`, the absolute value of the determinant of the base change from `integralBasis` to `basisOfFractionalIdeal I` is equal to the norm of `I`. -/ variable (K : Type*) [Field K] [NumberField K] namespace NumberField open scoped nonZeroDivisors section Basis open Module -- This is necessary to avoid several timeouts attribute [local instance 2000] Submodule.module instance (I : FractionalIdeal (𝓞 K)⁰ K) : Module.Free ℤ I := by refine Free.of_equiv (LinearEquiv.restrictScalars ℤ (I.equivNum ?_)).symm exact nonZeroDivisors.coe_ne_zero I.den instance (I : FractionalIdeal (𝓞 K)⁰ K) : Module.Finite ℤ I := by refine Module.Finite.of_surjective (LinearEquiv.restrictScalars ℤ (I.equivNum ?_)).symm.toLinearMap (LinearEquiv.surjective _) exact nonZeroDivisors.coe_ne_zero I.den instance (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : IsLocalizedModule ℤ⁰ ((Submodule.subtype (I : Submodule (𝓞 K) K)).restrictScalars ℤ) where map_units x := by rw [← (Algebra.lmul _ _).commutes, Algebra.lmul_isUnit_iff, isUnit_iff_ne_zero, eq_intCast, Int.cast_ne_zero] exact nonZeroDivisors.coe_ne_zero x surj x := by obtain ⟨⟨a, _, d, hd, rfl⟩, h⟩ := IsLocalization.surj (Algebra.algebraMapSubmonoid (𝓞 K) ℤ⁰) x refine ⟨⟨⟨Ideal.absNorm I.1.num * (algebraMap _ K a), I.1.num_le ?_⟩, d * Ideal.absNorm I.1.num, ?_⟩, ?_⟩ · simp_rw [FractionalIdeal.val_eq_coe, FractionalIdeal.coe_coeIdeal] refine (IsLocalization.mem_coeSubmodule _ _).mpr ⟨Ideal.absNorm I.1.num * a, ?_, ?_⟩ · exact Ideal.mul_mem_right _ _ I.1.num.absNorm_mem · rw [map_mul, map_natCast] · refine Submonoid.mul_mem _ hd (mem_nonZeroDivisors_of_ne_zero ?_) rw [Nat.cast_ne_zero, ne_eq, Ideal.absNorm_eq_zero_iff] exact FractionalIdeal.num_eq_zero_iff.not.mpr <| Units.ne_zero I · simp_rw [LinearMap.coe_restrictScalars, Submodule.coe_subtype] at h ⊢ rw [← h] simp only [Submonoid.mk_smul, zsmul_eq_mul, Int.cast_mul, Int.cast_natCast, algebraMap_int_eq, eq_intCast, map_intCast] ring exists_of_eq h := ⟨1, by rwa [one_smul, one_smul, ← (Submodule.injective_subtype I.1.coeToSubmodule).eq_iff]⟩ /-- A `ℤ`-basis of a fractional ideal. -/ noncomputable def fractionalIdealBasis (I : FractionalIdeal (𝓞 K)⁰ K) : Basis (Free.ChooseBasisIndex ℤ I) ℤ I := Free.chooseBasis ℤ I /-- A `ℚ`-basis of `K` that spans `I` over `ℤ`, see `mem_span_basisOfFractionalIdeal` below. -/ noncomputable def basisOfFractionalIdeal (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : Basis (Free.ChooseBasisIndex ℤ I) ℚ K := (fractionalIdealBasis K I.1).ofIsLocalizedModule ℚ ℤ⁰ ((Submodule.subtype (I : Submodule (𝓞 K) K)).restrictScalars ℤ) theorem basisOfFractionalIdeal_apply (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) (i : Free.ChooseBasisIndex ℤ I) : basisOfFractionalIdeal K I i = fractionalIdealBasis K I.1 i := (fractionalIdealBasis K I.1).ofIsLocalizedModule_apply ℚ ℤ⁰ _ i theorem mem_span_basisOfFractionalIdeal {I : (FractionalIdeal (𝓞 K)⁰ K)ˣ} {x : K} : x ∈ Submodule.span ℤ (Set.range (basisOfFractionalIdeal K I)) ↔ x ∈ (I : Set K) := by rw [basisOfFractionalIdeal, (fractionalIdealBasis K I.1).ofIsLocalizedModule_span ℚ ℤ⁰ _] simp open Module in theorem fractionalIdeal_rank (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : finrank ℤ I = finrank ℤ (𝓞 K) := by rw [finrank_eq_card_chooseBasisIndex, RingOfIntegers.rank, finrank_eq_card_basis (basisOfFractionalIdeal K I)] end Basis section Norm open Module /-- The absolute value of the determinant of the base change from `integralBasis` to `basisOfFractionalIdeal I` is equal to the norm of `I`. -/ theorem det_basisOfFractionalIdeal_eq_absNorm (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) (e : (Free.ChooseBasisIndex ℤ (𝓞 K)) ≃ (Free.ChooseBasisIndex ℤ I)) : |(integralBasis K).det ((basisOfFractionalIdeal K I).reindex e.symm)| = FractionalIdeal.absNorm I.1 := by rw [← FractionalIdeal.abs_det_basis_change (RingOfIntegers.basis K) I.1 ((fractionalIdealBasis K I.1).reindex e.symm)] congr ext simpa using basisOfFractionalIdeal_apply K I _ end Norm end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Embeddings.lean
import Mathlib.NumberTheory.NumberField.InfinitePlace.Ramification import Mathlib.NumberTheory.NumberField.InfinitePlace.TotallyRealComplex deprecated_module (since := "2025-04-30")
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/House.lean
import Mathlib.NumberTheory.SiegelsLemma import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic import Mathlib.NumberTheory.NumberField.EquivReindex /-! # House of an algebraic number This file defines the house of an algebraic number `α`, which is the largest of the modulus of its conjugates. ## References * [D. Marcus, *Number Fields*][marcus1977number] * [Hua, L.-K., *Introduction to number theory*][hua1982house] ## Tags number field, algebraic number, house -/ variable {K : Type*} [Field K] [NumberField K] namespace NumberField noncomputable section open Module.Free Module canonicalEmbedding Matrix Finset attribute [local instance] Matrix.seminormedAddCommGroup /-- The house of an algebraic number as the norm of its image by the canonical embedding. -/ def house (α : K) : ℝ := ‖canonicalEmbedding K α‖ /-- The house is the largest of the modulus of the conjugates of an algebraic number. -/ theorem house_eq_sup' (α : K) : house α = univ.sup' univ_nonempty (fun φ : K →+* ℂ ↦ ‖φ α‖₊) := by rw [house, ← coe_nnnorm, nnnorm_eq, ← sup'_eq_sup univ_nonempty] theorem house_sum_le_sum_house {ι : Type*} (s : Finset ι) (α : ι → K) : house (∑ i ∈ s, α i) ≤ ∑ i ∈ s, house (α i) := by simp only [house, map_sum]; apply norm_sum_le_of_le; intros; rfl theorem house_nonneg (α : K) : 0 ≤ house α := norm_nonneg _ theorem house_mul_le (α β : K) : house (α * β) ≤ house α * house β := by simp only [house, map_mul]; apply norm_mul_le @[simp] theorem house_intCast (x : ℤ) : house (x : K) = |x| := by simp only [house, map_intCast, Pi.intCast_def, pi_norm_const, Complex.norm_intCast, Int.cast_abs] end end NumberField namespace NumberField.house noncomputable section variable (K) open Module.Free Module canonicalEmbedding Matrix Finset attribute [local instance] Matrix.seminormedAddCommGroup section DecidableEq variable [DecidableEq (K →+* ℂ)] /-- `c` is defined as the product of the maximum absolute value of the entries of the inverse of the matrix `basisMatrix` and `finrank ℚ K`. -/ private def c := (finrank ℚ K) * ‖((basisMatrix K).transpose)⁻¹‖ private theorem c_nonneg : 0 ≤ c K := by rw [c] positivity theorem basis_repr_norm_le_const_mul_house (α : 𝓞 K) (i : K →+* ℂ) : ‖(((integralBasis K).reindex (equivReindex K).symm).repr α i : ℂ)‖ ≤ (c K) * house (algebraMap (𝓞 K) K α) := by let σ := canonicalEmbedding K calc _ ≤ ∑ j, ‖(basisMatrix K)ᵀ⁻¹ i j‖ * ‖σ (algebraMap (𝓞 K) K α) j‖ := by rw [← inverse_basisMatrix_mulVec_eq_repr] exact norm_sum_le_of_le _ fun _ _ ↦ (norm_mul _ _).le _ ≤ ∑ j, ‖((basisMatrix K).transpose)⁻¹‖ * ‖σ (algebraMap (𝓞 K) K α) j‖ := by gcongr exact norm_entry_le_entrywise_sup_norm ((basisMatrix K).transpose)⁻¹ _ ≤ ∑ _ : K →+* ℂ, ‖fun i j => ((basisMatrix K).transpose)⁻¹ i j‖ * house (algebraMap (𝓞 K) K α) := by gcongr with j exact norm_le_pi_norm (σ ((algebraMap (𝓞 K) K) α)) j _ = ↑(finrank ℚ K) * ‖((basisMatrix K).transpose)⁻¹‖ * house (algebraMap (𝓞 K) K α) := by simp [Embeddings.card, mul_assoc] /-- `newBasis K` defines a reindexed basis of the ring of integers of `K`, adjusted by the inverse of the equivalence `equivReindex`. -/ private def newBasis := (RingOfIntegers.basis K).reindex (equivReindex K).symm /-- `supOfBasis K` calculates the supremum of the absolute values of the elements in `newBasis K`. -/ private def supOfBasis : ℝ := univ.sup' univ_nonempty fun r ↦ house (algebraMap (𝓞 K) K (newBasis K r)) end DecidableEq private theorem supOfBasis_nonneg : 0 ≤ supOfBasis K := by simp only [supOfBasis, le_sup'_iff, mem_univ, and_self, exists_const, house_nonneg] variable {α : Type*} {β : Type*} (a : Matrix α β (𝓞 K)) /-- `a' K a` returns the integer coefficients of the basis vector in the expansion of the product of an algebraic integer and a basis vectors. -/ private def a' : α → β → (K →+* ℂ) → (K →+* ℂ) → ℤ := fun k l r => (newBasis K).repr (a k l * (newBasis K) r) /-- `asiegel K a` is the integer matrix of the coefficients of the product of matrix elements and basis vectors. -/ private def asiegel : Matrix (α × (K →+* ℂ)) (β × (K →+* ℂ)) ℤ := fun k l => a' K a k.1 l.1 l.2 k.2 variable (ha : a ≠ 0) include ha in private theorem asiegel_ne_0 : asiegel K a ≠ 0 := by simp +unfoldPartialApp only [asiegel, a'] simp only [ne_eq] rw [funext_iff]; intro hs simp only [Prod.forall] at hs apply ha rw [← Matrix.ext_iff]; intro k' l specialize hs k' let ⟨b⟩ := Fintype.card_pos_iff.1 (Fintype.card_pos (α := (K →+* ℂ))) have := ((newBasis K).repr.map_eq_zero_iff (x := (a k' l * (newBasis K) b))).1 <| by ext b' specialize hs b' rw [funext_iff] at hs simp only [Prod.forall] at hs apply hs simp only [mul_eq_zero] at this exact this.resolve_right (Basis.ne_zero (newBasis K) b) variable {p q : ℕ} (h0p : 0 < p) (hpq : p < q) (x : β × (K →+* ℂ) → ℤ) (hxl : x ≠ 0) /-- `ξ` is the product of `x (l, r)` and the `r`-th basis element of the newBasis of `K`. -/ private def ξ : β → 𝓞 K := fun l => ∑ r : K →+* ℂ, x (l, r) * (newBasis K r) include hxl in private theorem ξ_ne_0 : ξ K x ≠ 0 := by intro H apply hxl ext ⟨l, r⟩ rw [funext_iff] at H have hblin := Basis.linearIndependent (newBasis K) simp only [zsmul_eq_mul, Fintype.linearIndependent_iff] at hblin exact hblin (fun r ↦ x (l, r)) (H _) r private theorem lin_1 (l k r) : a k l * (newBasis K) r = ∑ u, (a' K a k l r u) * (newBasis K) u := by simp only [Basis.sum_repr (newBasis K) (a k l * (newBasis K) r), a', ← zsmul_eq_mul] variable [Fintype β] (cardβ : Fintype.card β = q) (hmulvec0 : asiegel K a *ᵥ x = 0) include hxl hmulvec0 in private theorem ξ_mulVec_eq_0 : a *ᵥ ξ K x = 0 := by funext k; simp only [Pi.zero_apply]; rw [eq_comm] have lin_0 : ∀ u, ∑ r, ∑ l, (a' K a k l r u * x (l, r) : 𝓞 K) = 0 := by intro u have hξ := ξ_ne_0 K x hxl rw [Ne, funext_iff, not_forall] at hξ rcases hξ with ⟨l, hξ⟩ rw [funext_iff] at hmulvec0 specialize hmulvec0 ⟨k, u⟩ simp only [Fintype.sum_prod_type, mulVec, dotProduct, asiegel] at hmulvec0 rw [sum_comm] at hmulvec0 exact mod_cast hmulvec0 have : 0 = ∑ u, (∑ r, ∑ l, a' K a k l r u * x (l, r) : 𝓞 K) * (newBasis K) u := by simp only [lin_0, zero_mul, sum_const_zero] have : 0 = ∑ r, ∑ l, x (l, r) * ∑ u, a' K a k l r u * (newBasis K) u := by conv at this => enter [2, 2, u]; rw [sum_mul] rw [sum_comm] at this rw [this]; congr 1; ext1 r conv => enter [1, 2, l]; rw [sum_mul] rw [sum_comm]; congr 1; ext1 r rw [mul_sum]; congr 1; ext1 r ring rw [sum_comm] at this rw [this]; congr 1; ext1 l rw [ξ, mul_sum]; congr 1; ext1 l rw [← lin_1]; ring variable {A : ℝ} (habs : ∀ k l, (house ((algebraMap (𝓞 K) K) (a k l))) ≤ A) variable [DecidableEq (K →+* ℂ)] /-- `c₂` is the product of the maximum of `1` and `c`, and `supOfBasis`. -/ private abbrev c₂ := max 1 (c K) * (supOfBasis K) private theorem c₂_nonneg : 0 ≤ c₂ K := mul_nonneg (le_trans zero_le_one (le_max_left ..)) (supOfBasis_nonneg _) variable [Fintype α] (cardα : Fintype.card α = p) (Apos : 0 ≤ A) (hxbound : ‖x‖ ≤ (q * finrank ℚ K * ‖asiegel K a‖) ^ ((p : ℝ) / (q - p))) include habs Apos in private theorem asiegel_remark : ‖asiegel K a‖ ≤ c₂ K * A := by have := c_nonneg K rw [Matrix.norm_le_iff] · intro kr lu calc ‖asiegel K a kr lu‖ = |asiegel K a kr lu| := ?_ _ ≤ c K * house ((algebraMap (𝓞 K) K) (a kr.1 lu.1 * ((newBasis K) lu.2))) := ?_ _ ≤ c K * house ((algebraMap (𝓞 K) K) (a kr.1 lu.1)) * house ((algebraMap (𝓞 K) K) ((newBasis K) lu.2)) := ?_ _ ≤ c K * A * house ((algebraMap (𝓞 K) K) ((newBasis K) lu.2)) := ?_ _ ≤ c K * A * supOfBasis K := ?_ _ ≤ c₂ K * A := ?_ · simp only [Int.cast_abs, ← Real.norm_eq_abs (asiegel K a kr lu)]; rfl · have remark := basis_repr_norm_le_const_mul_house K simp only [Basis.repr_reindex, Finsupp.mapDomain_equiv_apply, integralBasis_repr_apply, eq_intCast, Rat.cast_intCast, Complex.norm_intCast] at remark exact mod_cast remark ((a kr.1 lu.1 * ((newBasis K) lu.2))) kr.2 · simp only [house, map_mul, mul_assoc] gcongr apply norm_mul_le · rw [mul_assoc, mul_assoc] gcongr _ * (?_ * _) · apply house_nonneg · exact habs kr.1 lu.1 · gcongr simp only [supOfBasis, le_sup'_iff, mem_univ]; use lu.2 · rw [mul_right_comm, c₂] gcongr exacts [supOfBasis_nonneg _, le_max_right ..] · exact mul_nonneg (c₂_nonneg _) Apos /-- `c₁ K` is the product of `finrank ℚ K` and `c₂ K` and depends on `K`. -/ private def c₁ := finrank ℚ K * c₂ K include habs Apos hxbound hpq in private theorem house_le_bound : ∀ l, house (ξ K x l).1 ≤ (c₁ K) * ((c₁ K * q * A) ^ ((p : ℝ) / (q - p))) := by let h := finrank ℚ K intro l have H₀ : 0 ≤ NumberField.house.supOfBasis K := supOfBasis_nonneg _ have H₁ : 0 < (q - p : ℝ) := sub_pos.mpr <| mod_cast hpq calc _ = house (algebraMap (𝓞 K) K (∑ r, (x (l, r)) * ((newBasis K) r))) := rfl _ ≤ ∑ r, house (((algebraMap (𝓞 K) K) (x (l, r))) * ((algebraMap (𝓞 K) K) ((newBasis K) r))) := ?_ _ ≤ ∑ r, ‖x (l, r)‖ * house ((algebraMap (𝓞 K) K) ((newBasis K) r)) := ?_ _ ≤ ∑ r, ‖x (l, r)‖ * (supOfBasis K) := ?_ _ ≤ ∑ _r : K →+* ℂ, ((↑q * h * ‖asiegel K a‖) ^ ((p : ℝ) / (q - p))) * supOfBasis K := ?_ _ ≤ h * (c₂ K) * ((q * c₁ K * A) ^ ((p : ℝ) / (q - p))) := ?_ _ ≤ c₁ K * ((c₁ K * ↑q * A) ^ ((p : ℝ) / (q - p))) := ?_ · simp_rw [← map_mul, map_sum]; apply house_sum_le_sum_house · gcongr with r _; convert house_mul_le .. simp only [map_intCast, house_intCast, Int.cast_abs, Int.norm_eq_abs] · unfold supOfBasis gcongr with r _ simp only [le_sup'_iff, mem_univ, true_and]; use r · gcongr with r _ exact le_trans (norm_le_pi_norm x ⟨l, r⟩) hxbound · simp only [sum_const, card_univ, nsmul_eq_mul] rw [Embeddings.card, mul_comm _ (supOfBasis K), c₂, c₁, ← mul_assoc, ← mul_assoc (q : ℝ), mul_assoc (q * _ : ℝ)] gcongr · exact le_mul_of_one_le_left (supOfBasis_nonneg K) (le_max_left ..) · exact asiegel_remark K a habs Apos · rw [mul_comm (q : ℝ) (c₁ K)]; rfl include hpq h0p cardα cardβ ha habs in /-- There exists a "small" non-zero algebraic integral solution of an non-trivial underdetermined system of linear equations with algebraic integer coefficients. -/ theorem exists_ne_zero_int_vec_house_le : ∃ (ξ : β → 𝓞 K), ξ ≠ 0 ∧ a *ᵥ ξ = 0 ∧ ∀ l, house (ξ l).1 ≤ c₁ K * ((c₁ K * q * A) ^ ((p : ℝ) / (q - p))) := by classical let h := finrank ℚ K have hphqh : p * h < q * h := mul_lt_mul_of_pos_right hpq finrank_pos have h0ph : 0 < p * h := by rw [mul_pos_iff]; constructor; exact ⟨h0p, finrank_pos⟩ have hfinp : Fintype.card (α × (K →+* ℂ)) = p * h := by rw [Fintype.card_prod, cardα, Embeddings.card] have hfinq : Fintype.card (β × (K →+* ℂ)) = q * h := by rw [Fintype.card_prod, cardβ, Embeddings.card] have ⟨x, hxl, hmulvec0, hxbound⟩ := Int.Matrix.exists_ne_zero_int_vec_norm_le' (asiegel K a) (by rwa [hfinp, hfinq]) (by rwa [hfinp]) (asiegel_ne_0 K a ha) simp only [hfinp, hfinq, Nat.cast_mul] at hmulvec0 hxbound rw [← sub_mul, mul_div_mul_right _ _ (mod_cast finrank_pos.ne')] at hxbound have Apos : 0 ≤ A := by have ⟨k⟩ := Fintype.card_pos_iff.1 (cardα ▸ h0p) have ⟨l⟩ := Fintype.card_pos_iff.1 (cardβ ▸ h0p.trans hpq) exact le_trans (house_nonneg _) (habs k l) use ξ K x, ξ_ne_0 K x hxl, ξ_mulVec_eq_0 K a x hxl hmulvec0, house_le_bound K a hpq x habs Apos hxbound end end NumberField.house
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/FinitePlaces.lean
import Mathlib.Algebra.Order.Archimedean.Submonoid import Mathlib.Algebra.GroupWithZero.Range import Mathlib.Data.Int.WithZero import Mathlib.NumberTheory.NumberField.InfinitePlace.Embeddings import Mathlib.RingTheory.DedekindDomain.AdicValuation import Mathlib.RingTheory.DedekindDomain.Factorization import Mathlib.RingTheory.Ideal.Norm.AbsNorm import Mathlib.RingTheory.Valuation.Archimedean import Mathlib.Topology.Algebra.Valued.NormedValued /-! # Finite places of number fields This file defines finite places of a number field `K` as absolute values coming from an embedding into a completion of `K` associated to a non-zero prime ideal of `𝓞 K`. ## Main Definitions and Results * `NumberField.adicAbv`: a `v`-adic absolute value on `K`. * `NumberField.FinitePlace`: the type of finite places of a number field `K`. * `NumberField.FinitePlace.embedding`: the canonical embedding of a number field `K` to the `v`-adic completion `v.adicCompletion K` of `K`, where `v` is a non-zero prime ideal of `𝓞 K` * `NumberField.FinitePlace.norm_def`: the norm of `embedding v x` is the same as the `v`-adic absolute value of `x`. See also `NumberField.FinitePlace.norm_def'` and `NumberField.FinitePlace.norm_def_int` for versions where the `v`-adic absolute value is unfolded. * `NumberField.FinitePlace.mulSupport_finite`: the `v`-adic absolute value of a non-zero element of `K` is different from 1 for at most finitely many `v`. * The valuation subrings of the field at the `v`-valuation and it's adic completion are discrete valuation rings. ## Tags number field, places, finite places -/ open Ideal IsDedekindDomain HeightOneSpectrum WithZeroMulInt WithZero open scoped WithZero NNReal section DVR variable (A : Type*) [CommRing A] [IsDedekindDomain A] (K : Type*) [Field K] [Algebra A K] [IsFractionRing A K] (v : HeightOneSpectrum A) (hv : Finite (A ⧸ v.asIdeal)) instance : IsPrincipalIdealRing (v.valuation K).integer := by rw [(Valuation.integer.integers (v.valuation K)).isPrincipalIdealRing_iff_not_denselyOrdered, WithZero.denselyOrdered_set_iff_subsingleton] simpa using (v.valuation K).toMonoidWithZeroHom.range_nontrivial -- TODO: make this inferred from `IsRankOneDiscrete` instance : IsDiscreteValuationRing (v.valuation K).integer where not_a_field' := by simp only [ne_eq, Ideal.ext_iff, IsLocalRing.mem_maximalIdeal, mem_nonunits_iff, Valuation.Integer.not_isUnit_iff_valuation_lt_one, Ideal.mem_bot, Subtype.forall, not_forall] obtain ⟨π, hπ⟩ := v.valuation_exists_uniformizer K use π simp [Valuation.mem_integer_iff, ← exp_zero, Subtype.ext_iff, - exp_neg, ← (v.valuation K).map_eq_zero_iff, hπ] instance : IsPrincipalIdealRing (v.adicCompletionIntegers K) := by unfold HeightOneSpectrum.adicCompletionIntegers rw [(Valuation.valuationSubring.integers (Valued.v)).isPrincipalIdealRing_iff_not_denselyOrdered, WithZero.denselyOrdered_set_iff_subsingleton] simpa using Valued.v.range_nontrivial -- TODO: make this inferred from `IsRankOneDiscrete`, or -- develop the API for a completion of a base `IsDVR` ring instance : IsDiscreteValuationRing (v.adicCompletionIntegers K) where not_a_field' := by unfold HeightOneSpectrum.adicCompletionIntegers simp only [ne_eq, Ideal.ext_iff, Valuation.mem_maximalIdeal_iff, Ideal.mem_bot, Subtype.ext_iff, ZeroMemClass.coe_zero, Subtype.forall, Valuation.mem_valuationSubring_iff, not_forall, exists_prop] obtain ⟨π, hπ⟩ := v.valuation_exists_uniformizer K use π simp [hπ, ← exp_zero, - exp_neg, ← (Valued.v : Valuation (v.adicCompletion K) ℤᵐ⁰).map_eq_zero_iff] end DVR namespace NumberField.RingOfIntegers.HeightOneSpectrum section AbsoluteValue variable {K : Type*} [Field K] [NumberField K] (v : HeightOneSpectrum (𝓞 K)) /-- The norm of a maximal ideal is `> 1` -/ lemma one_lt_absNorm : 1 < absNorm v.asIdeal := by by_contra! h apply IsPrime.ne_top v.isPrime rw [← absNorm_eq_one_iff] have : 0 < absNorm v.asIdeal := by rw [Nat.pos_iff_ne_zero, absNorm_ne_zero_iff] exact v.asIdeal.finiteQuotientOfFreeOfNeBot v.ne_bot cutsat /-- The norm of a maximal ideal as an element of `ℝ≥0` is `> 1` -/ lemma one_lt_absNorm_nnreal : 1 < (absNorm v.asIdeal : ℝ≥0) := mod_cast one_lt_absNorm v /-- The norm of a maximal ideal as an element of `ℝ≥0` is `≠ 0` -/ lemma absNorm_ne_zero : (absNorm v.asIdeal : ℝ≥0) ≠ 0 := ne_zero_of_lt (one_lt_absNorm_nnreal v) /-- The `v`-adic absolute value on `K` defined as the norm of `v` raised to negative `v`-adic valuation -/ noncomputable def adicAbv : AbsoluteValue K ℝ := v.adicAbv <| one_lt_absNorm_nnreal v theorem adicAbv_def {x : K} : adicAbv v x = toNNReal (absNorm_ne_zero v) (v.valuation K x) := rfl /-- The `v`-adic absolute value is nonarchimedean -/ theorem isNonarchimedean_adicAbv : IsNonarchimedean (adicAbv v) := v.isNonarchimedean_adicAbv <| one_lt_absNorm_nnreal v end AbsoluteValue end RingOfIntegers.HeightOneSpectrum section FinitePlace variable {K : Type*} [Field K] [NumberField K] (v : HeightOneSpectrum (𝓞 K)) open RingOfIntegers.HeightOneSpectrum /-- The embedding of a number field inside its completion with respect to `v`. -/ noncomputable def FinitePlace.embedding : WithVal (v.valuation K) →+* adicCompletion K v := UniformSpace.Completion.coeRingHom theorem FinitePlace.embedding_apply (x : K) : embedding v x = ↑x := rfl noncomputable instance instRankOneValuedAdicCompletion : Valuation.RankOne (Valued.v : Valuation (v.adicCompletion K) ℤᵐ⁰) where hom := { toFun := toNNReal (absNorm_ne_zero v) map_zero' := rfl map_one' := rfl map_mul' := MonoidWithZeroHom.map_mul (toNNReal (absNorm_ne_zero v)) } strictMono' := toNNReal_strictMono (one_lt_absNorm_nnreal v) exists_val_nontrivial := by rcases Submodule.exists_mem_ne_zero_of_ne_bot v.ne_bot with ⟨x, hx1, hx2⟩ use x dsimp [adicCompletion] rw [valuedAdicCompletion_eq_valuation' v (x : K)] constructor · simpa only [ne_eq, map_eq_zero, FaithfulSMul.algebraMap_eq_zero_iff] · apply ne_of_lt rwa [valuation_of_algebraMap, intValuation_lt_one_iff_mem] /-- The `v`-adic completion of `K` is a normed field. -/ noncomputable instance instNormedFieldValuedAdicCompletion : NormedField (adicCompletion K v) := Valued.toNormedField (adicCompletion K v) ℤᵐ⁰ /-- A finite place of a number field `K` is a place associated to an embedding into a completion with respect to a maximal ideal. -/ def FinitePlace (K : Type*) [Field K] [NumberField K] := {w : AbsoluteValue K ℝ // ∃ v : HeightOneSpectrum (𝓞 K), place (FinitePlace.embedding v) = w} /-- Return the finite place defined by a maximal ideal `v`. -/ noncomputable def FinitePlace.mk (v : HeightOneSpectrum (𝓞 K)) : FinitePlace K := ⟨place (embedding v), ⟨v, rfl⟩⟩ lemma toNNReal_valued_eq_adicAbv (x : WithVal (v.valuation K)) : toNNReal (absNorm_ne_zero v) (Valued.v x) = adicAbv v x := rfl /-- The norm of the image after the embedding associated to `v` is equal to the `v`-adic absolute value. -/ theorem FinitePlace.norm_def (x : WithVal (v.valuation K)) : ‖embedding v x‖ = adicAbv v x := by simp [NormedField.toNorm, instNormedFieldValuedAdicCompletion, Valued.toNormedField, Valued.norm, Valuation.RankOne.hom, embedding_apply, ← toNNReal_valued_eq_adicAbv] /-- The norm of the image after the embedding associated to `v` is equal to the norm of `v` raised to the power of the `v`-adic valuation. -/ theorem FinitePlace.norm_def' (x : WithVal (v.valuation K)) : ‖embedding v x‖ = toNNReal (absNorm_ne_zero v) (v.valuation K x) := by rw [norm_def, adicAbv_def] /-- The norm of the image after the embedding associated to `v` is equal to the norm of `v` raised to the power of the `v`-adic valuation for integers. -/ theorem FinitePlace.norm_def_int (x : 𝓞 (WithVal (v.valuation K))) : ‖embedding v x‖ = toNNReal (absNorm_ne_zero v) (v.intValuation x) := by rw [norm_def, adicAbv_def, valuation_of_algebraMap] /-- The `v`-adic absolute value satisfies the ultrametric inequality. -/ theorem RingOfIntegers.HeightOneSpectrum.adicAbv_add_le_max (x y : K) : adicAbv v (x + y) ≤ (adicAbv v x) ⊔ (adicAbv v y) := isNonarchimedean_adicAbv v x y /-- The `v`-adic absolute value of a natural number is `≤ 1`. -/ theorem RingOfIntegers.HeightOneSpectrum.adicAbv_natCast_le_one (n : ℕ) : adicAbv v n ≤ 1 := (isNonarchimedean_adicAbv v).apply_natCast_le_one_of_isNonarchimedean /-- The `v`-adic absolute value of an integer is `≤ 1`. -/ theorem RingOfIntegers.HeightOneSpectrum.adicAbv_intCast_le_one (n : ℤ) : adicAbv v n ≤ 1 := (isNonarchimedean_adicAbv v).apply_intCast_le_one_of_isNonarchimedean open FinitePlace /-- The `v`-adic norm of an integer is at most 1. -/ theorem FinitePlace.norm_le_one (x : 𝓞 (WithVal (v.valuation K))) : ‖embedding v x‖ ≤ 1 := by rw [norm_def] exact v.adicAbv_coe_le_one (one_lt_absNorm_nnreal v) x /-- The `v`-adic norm of an integer is 1 if and only if it is not in the ideal. -/ theorem FinitePlace.norm_eq_one_iff_notMem (x : 𝓞 (WithVal (v.valuation K))) : ‖embedding v x‖ = 1 ↔ x ∉ v.asIdeal := by rw [norm_def] exact v.adicAbv_coe_eq_one_iff (one_lt_absNorm_nnreal v) x @[deprecated (since := "2025-05-23")] alias FinitePlace.norm_eq_one_iff_not_mem := FinitePlace.norm_eq_one_iff_notMem /-- The `v`-adic norm of an integer is less than 1 if and only if it is in the ideal. -/ theorem FinitePlace.norm_lt_one_iff_mem (x : 𝓞 (WithVal (v.valuation K))) : ‖embedding v x‖ < 1 ↔ x ∈ v.asIdeal := by rw [norm_def] exact v.adicAbv_coe_lt_one_iff (one_lt_absNorm_nnreal v) x end FinitePlace namespace FinitePlace variable {K : Type*} [Field K] [NumberField K] instance : FunLike (FinitePlace K) K ℝ where coe w x := w.1 x coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext <| congr_fun h) instance : MonoidWithZeroHomClass (FinitePlace K) K ℝ where map_mul w := w.1.map_mul map_one w := w.1.map_one map_zero w := w.1.map_zero instance : NonnegHomClass (FinitePlace K) K ℝ where apply_nonneg w := w.1.nonneg @[simp] theorem mk_apply (v : HeightOneSpectrum (𝓞 K)) (x : K) : mk v x = ‖embedding v x‖ := rfl /-- For a finite place `w`, return a maximal ideal `v` such that `w = finite_place v` . -/ noncomputable def maximalIdeal (w : FinitePlace K) : HeightOneSpectrum (𝓞 K) := w.2.choose @[simp] theorem mk_maximalIdeal (w : FinitePlace K) : mk (maximalIdeal w) = w := Subtype.ext w.2.choose_spec @[simp] theorem norm_embedding_eq (w : FinitePlace K) (x : K) : ‖embedding (maximalIdeal w) x‖ = w x := by conv_rhs => rw [← mk_maximalIdeal w, mk_apply] theorem pos_iff {w : FinitePlace K} {x : K} : 0 < w x ↔ x ≠ 0 := w.1.pos_iff @[simp] theorem mk_eq_iff {v₁ v₂ : HeightOneSpectrum (𝓞 K)} : mk v₁ = mk v₂ ↔ v₁ = v₂ := by refine ⟨?_, fun a ↦ by rw [a]⟩ contrapose! intro h rw [DFunLike.ne_iff] have ⟨x, hx1, hx2⟩ : ∃ x : 𝓞 K, x ∈ v₁.asIdeal ∧ x ∉ v₂.asIdeal := by by_contra! H exact h <| HeightOneSpectrum.ext_iff.mpr <| IsMaximal.eq_of_le (isMaximal v₁) IsPrime.ne_top' H use x simp only [mk_apply] rw [← norm_lt_one_iff_mem] at hx1 rw [← norm_eq_one_iff_notMem] at hx2 linarith theorem maximalIdeal_mk (v : HeightOneSpectrum (𝓞 K)) : maximalIdeal (mk v) = v := by rw [← mk_eq_iff, mk_maximalIdeal] /-- The equivalence between finite places and maximal ideals. -/ noncomputable def equivHeightOneSpectrum : FinitePlace K ≃ HeightOneSpectrum (𝓞 K) where toFun := maximalIdeal invFun := mk left_inv := mk_maximalIdeal right_inv := maximalIdeal_mk lemma maximalIdeal_injective : (fun w : FinitePlace K ↦ maximalIdeal w).Injective := equivHeightOneSpectrum.injective lemma maximalIdeal_inj (w₁ w₂ : FinitePlace K) : maximalIdeal w₁ = maximalIdeal w₂ ↔ w₁ = w₂ := equivHeightOneSpectrum.injective.eq_iff theorem mulSupport_finite_int {x : 𝓞 K} (h_x_nezero : x ≠ 0) : (Function.mulSupport fun w : FinitePlace K ↦ w x).Finite := by have (w : FinitePlace K) : w x ≠ 1 ↔ w x < 1 := ne_iff_lt_iff_le.mpr <| norm_embedding_eq w x ▸ norm_le_one w.maximalIdeal x simp_rw [Function.mulSupport, this, ← norm_embedding_eq, norm_lt_one_iff_mem, ← Ideal.dvd_span_singleton] have h : {v : HeightOneSpectrum (𝓞 K) | v.asIdeal ∣ span {x}}.Finite := by apply Ideal.finite_factors simp only [Submodule.zero_eq_bot, ne_eq, span_singleton_eq_bot, h_x_nezero, not_false_eq_true] have h_inj : Set.InjOn FinitePlace.maximalIdeal {w | w.maximalIdeal.asIdeal ∣ span {x}} := Function.Injective.injOn maximalIdeal_injective refine (h.subset ?_).of_finite_image h_inj simp only [dvd_span_singleton, Set.image_subset_iff, Set.preimage_setOf_eq, subset_refl] theorem mulSupport_finite {x : K} (h_x_nezero : x ≠ 0) : (Function.mulSupport fun w : FinitePlace K ↦ w x).Finite := by rcases IsFractionRing.div_surjective (A := 𝓞 K) x with ⟨a, b, hb, rfl⟩ simp_all only [ne_eq, div_eq_zero_iff, FaithfulSMul.algebraMap_eq_zero_iff, not_or, map_div₀] obtain ⟨ha, hb⟩ := h_x_nezero simp_rw [← RingOfIntegers.coe_eq_algebraMap] apply ((mulSupport_finite_int ha).union (mulSupport_finite_int hb)).subset intro w simp only [Function.mem_mulSupport, ne_eq, Set.mem_union] contrapose! simp +contextual only [ne_eq, one_ne_zero, not_false_eq_true, div_self, implies_true] end FinitePlace end NumberField namespace IsDedekindDomain.HeightOneSpectrum variable {K : Type*} [Field K] [NumberField K] open NumberField.FinitePlace NumberField.RingOfIntegers NumberField.RingOfIntegers.HeightOneSpectrum open scoped NumberField lemma equivHeightOneSpectrum_symm_apply (v : HeightOneSpectrum (𝓞 K)) (x : K) : (equivHeightOneSpectrum.symm v) x = ‖embedding v x‖ := rfl open Ideal in lemma embedding_mul_absNorm (v : HeightOneSpectrum (𝓞 K)) {x : 𝓞 (WithVal (v.valuation K))} (h_x_nezero : x ≠ 0) : ‖embedding v x‖ * absNorm (v.maxPowDividing (span {x})) = 1 := by rw [maxPowDividing, map_pow, Nat.cast_pow, norm_def, adicAbv_def, WithZeroMulInt.toNNReal_neg_apply _ ((v.valuation K).ne_zero_iff.mpr (coe_ne_zero_iff.mpr h_x_nezero))] push_cast rw [← zpow_natCast, ← zpow_add₀ <| mod_cast (zero_lt_one.trans (one_lt_absNorm_nnreal v)).ne'] norm_cast rw [zpow_eq_one_iff_right₀ (Nat.cast_nonneg' _) (mod_cast (one_lt_absNorm_nnreal v).ne')] simp [valuation_of_algebraMap, intValuation_if_neg, h_x_nezero] end IsDedekindDomain.HeightOneSpectrum
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/AdeleRing.lean
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic import Mathlib.NumberTheory.NumberField.InfinitePlace.Completion import Mathlib.RingTheory.DedekindDomain.FiniteAdeleRing /-! # The adele ring of a number field This file contains the formalisation of the infinite adele ring of a number field as the finite product of completions over its infinite places and the adele ring of a number field as the direct product of the infinite adele ring and the finite adele ring. ## Main definitions - `NumberField.InfiniteAdeleRing` of a number field `K` is defined as the product of the completions of `K` over its infinite places. - `NumberField.InfiniteAdeleRing.ringEquiv_mixedSpace` is the ring isomorphism between the infinite adele ring of `K` and `ℝ ^ r₁ × ℂ ^ r₂`, where `(r₁, r₂)` is the signature of `K`. - `NumberField.AdeleRing K` is the adele ring of a number field `K`. - `NumberField.AdeleRing.principalSubgroup K` is the subgroup of principal adeles `(x)ᵥ`. ## Main results - `NumberField.InfiniteAdeleRing.locallyCompactSpace` : the infinite adele ring is a locally compact space. ## References * [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic] ## Tags infinite adele ring, adele ring, number field -/ noncomputable section namespace NumberField open InfinitePlace AbsoluteValue.Completion InfinitePlace.Completion IsDedekindDomain /-! ## The infinite adele ring The infinite adele ring is the finite product of completions of a number field over its infinite places. See `NumberField.InfinitePlace` for the definition of an infinite place and `NumberField.InfinitePlace.Completion` for the associated completion. -/ /-- The infinite adele ring of a number field. -/ def InfiniteAdeleRing (K : Type*) [Field K] := (v : InfinitePlace K) → v.Completion namespace InfiniteAdeleRing variable (K : Type*) [Field K] instance : CommRing (InfiniteAdeleRing K) := Pi.commRing instance : Inhabited (InfiniteAdeleRing K) := ⟨0⟩ instance [NumberField K] : Nontrivial (InfiniteAdeleRing K) := (inferInstanceAs <| Nonempty (InfinitePlace K)).elim fun w => Pi.nontrivial_at w instance : TopologicalSpace (InfiniteAdeleRing K) := Pi.topologicalSpace instance : IsTopologicalRing (InfiniteAdeleRing K) := Pi.instIsTopologicalRing instance : Algebra K (InfiniteAdeleRing K) := Pi.algebra _ _ @[simp] theorem algebraMap_apply (x : K) (v : InfinitePlace K) : algebraMap K (InfiniteAdeleRing K) x v = x := rfl /-- The infinite adele ring is locally compact. -/ instance locallyCompactSpace [NumberField K] : LocallyCompactSpace (InfiniteAdeleRing K) := Pi.locallyCompactSpace_of_finite open scoped Classical in /-- The ring isomorphism between the infinite adele ring of a number field and the space `ℝ ^ r₁ × ℂ ^ r₂`, where `(r₁, r₂)` is the signature of the number field. -/ abbrev ringEquiv_mixedSpace : InfiniteAdeleRing K ≃+* mixedEmbedding.mixedSpace K := RingEquiv.trans (RingEquiv.piEquivPiSubtypeProd (fun (v : InfinitePlace K) => IsReal v) (fun (v : InfinitePlace K) => v.Completion)) (RingEquiv.prodCongr (RingEquiv.piCongrRight (fun ⟨_, hv⟩ => Completion.ringEquivRealOfIsReal hv)) (RingEquiv.trans (RingEquiv.piCongrRight (fun v => Completion.ringEquivComplexOfIsComplex ((not_isReal_iff_isComplex.1 v.2)))) (RingEquiv.piCongrLeft (fun _ => ℂ) <| Equiv.subtypeEquivRight (fun _ => not_isReal_iff_isComplex)))) @[simp] theorem ringEquiv_mixedSpace_apply (x : InfiniteAdeleRing K) : ringEquiv_mixedSpace K x = (fun (v : {w : InfinitePlace K // IsReal w}) => extensionEmbeddingOfIsReal v.2 (x v), fun (v : {w : InfinitePlace K // IsComplex w}) => extensionEmbedding v.1 (x v)) := rfl /-- Transfers the embedding of `x ↦ (x)ᵥ` of the number field `K` into its infinite adele ring to the mixed embedding `x ↦ (φᵢ(x))ᵢ` of `K` into the space `ℝ ^ r₁ × ℂ ^ r₂`, where `(r₁, r₂)` is the signature of `K` and `φᵢ` are the complex embeddings of `K`. -/ theorem mixedEmbedding_eq_algebraMap_comp {x : K} : mixedEmbedding K x = ringEquiv_mixedSpace K (algebraMap K _ x) := by ext v <;> simp only [ringEquiv_mixedSpace_apply, algebraMap_apply, extensionEmbedding, extensionEmbeddingOfIsReal, extensionEmbedding_of_comp, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, UniformSpace.Completion.extensionHom] · rw [UniformSpace.Completion.extension_coe (WithAbs.isUniformInducing_of_comp <| v.1.norm_embedding_of_isReal v.2).uniformContinuous x] exact mixedEmbedding.mixedEmbedding_apply_isReal _ _ _ · rw [UniformSpace.Completion.extension_coe (WithAbs.isUniformInducing_of_comp <| v.1.norm_embedding_eq).uniformContinuous x] exact mixedEmbedding.mixedEmbedding_apply_isComplex _ _ _ end InfiniteAdeleRing /-! ## The adele ring -/ /-- `AdeleRing (𝓞 K) K` is the adele ring of a number field `K`. More generally `AdeleRing R K` can be used if `K` is the field of fractions of the Dedekind domain `R`. This enables use of rings like `AdeleRing ℤ ℚ`, which in practice are easier to work with than `AdeleRing (𝓞 ℚ) ℚ`. Note that this definition does not give the correct answer in the function field case. -/ def AdeleRing (R K : Type*) [CommRing R] [IsDedekindDomain R] [Field K] [Algebra R K] [IsFractionRing R K] := InfiniteAdeleRing K × FiniteAdeleRing R K namespace AdeleRing variable (R K : Type*) [CommRing R] [IsDedekindDomain R] [Field K] [Algebra R K] [IsFractionRing R K] instance : CommRing (AdeleRing R K) := Prod.instCommRing instance : Inhabited (AdeleRing R K) := ⟨0⟩ instance : TopologicalSpace (AdeleRing R K) := instTopologicalSpaceProd instance : IsTopologicalRing (AdeleRing R K) := instIsTopologicalRingProd instance : Algebra K (AdeleRing R K) := Prod.algebra _ _ _ @[simp] theorem algebraMap_fst_apply (x : K) (v : InfinitePlace K) : (algebraMap K (AdeleRing R K) x).1 v = x := rfl @[simp] theorem algebraMap_snd_apply (x : K) (v : HeightOneSpectrum R) : (algebraMap K (AdeleRing R K) x).2 v = x := rfl theorem algebraMap_injective [NumberField K] : Function.Injective (algebraMap K (AdeleRing R K)) := fun _ _ hxy => (algebraMap K _).injective (Prod.ext_iff.1 hxy).1 /-- The subgroup of principal adeles `(x)ᵥ` where `x ∈ K`. -/ abbrev principalSubgroup : AddSubgroup (AdeleRing R K) := (algebraMap K _).range.toAddSubgroup end AdeleRing end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Cyclotomic/PID.lean
import Mathlib.NumberTheory.NumberField.ClassNumber import Mathlib.NumberTheory.NumberField.Cyclotomic.Basic import Mathlib.NumberTheory.NumberField.Cyclotomic.Embeddings /-! # Cyclotomic fields whose ring of integers is a PID. We prove that `ℤ [ζₚ]` is a PID for specific values of `p`. The result holds for `p ≤ 19`, but the proof is more and more involved. ## Main results * `three_pid`: If `IsCyclotomicExtension {3} ℚ K` then `𝓞 K` is a principal ideal domain. * `five_pid`: If `IsCyclotomicExtension {5} ℚ K` then `𝓞 K` is a principal ideal domain. -/ universe u namespace IsCyclotomicExtension.Rat open NumberField Polynomial InfinitePlace Nat Real cyclotomic variable (K : Type u) [Field K] [NumberField K] /-- If `IsCyclotomicExtension {3} ℚ K` then `𝓞 K` is a principal ideal domain. -/ theorem three_pid [IsCyclotomicExtension {3} ℚ K] : IsPrincipalIdealRing (𝓞 K) := by apply RingOfIntegers.isPrincipalIdealRing_of_abs_discr_lt rw [absdiscr_prime 3 K, IsCyclotomicExtension.finrank (n := 3) K (irreducible_rat (by simp)), nrComplexPlaces_eq_totient_div_two 3, totient_prime Nat.prime_three] simp only [Int.reduceNeg, succ_sub_succ_eq_sub, tsub_zero, zero_lt_two, Nat.div_self, pow_one, cast_ofNat, neg_mul, one_mul, abs_neg, Int.cast_abs, Int.cast_ofNat, abs_of_pos (zero_lt_three' ℝ), factorial_two] suffices (2 * (3 / 4) * (2 ^ 2 / 2)) ^ 2 < (2 * (π / 4) * (2 ^ 2 / 2)) ^ 2 from lt_trans (by norm_num) this gcongr exact pi_gt_three /-- If `IsCyclotomicExtension {5} ℚ K` then `𝓞 K` is a principal ideal domain. -/ theorem five_pid [IsCyclotomicExtension {5} ℚ K] : IsPrincipalIdealRing (𝓞 K) := by have : Fact (Nat.Prime 5) := ⟨Nat.prime_five⟩ apply RingOfIntegers.isPrincipalIdealRing_of_abs_discr_lt rw [absdiscr_prime 5 K, IsCyclotomicExtension.finrank (n := 5) K (irreducible_rat (by simp)), nrComplexPlaces_eq_totient_div_two 5, totient_prime Nat.prime_five] simp only [Int.reduceNeg, succ_sub_succ_eq_sub, tsub_zero, reduceDiv, even_two, Even.neg_pow, one_pow, cast_ofNat, Int.reducePow, one_mul, Int.cast_abs, Int.cast_ofNat, abs_of_pos (show (0 : ℝ) < 125 by simp), div_pow, show 4! = 24 by rfl] suffices (2 * (3 ^ 2 / 4 ^ 2) * (4 ^ 4 / 24)) ^ 2 < (2 * (π ^ 2 / 4 ^ 2) * (4 ^ 4 / 24)) ^ 2 from lt_trans (by norm_num) this gcongr exact pi_gt_three end IsCyclotomicExtension.Rat
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Cyclotomic/Basic.lean
import Mathlib.NumberTheory.Cyclotomic.Discriminant import Mathlib.RingTheory.Ideal.Norm.AbsNorm import Mathlib.RingTheory.Norm.Transitivity import Mathlib.RingTheory.Polynomial.Eisenstein.IsIntegral import Mathlib.RingTheory.Prime /-! # Ring of integers of `p ^ n`-th cyclotomic fields We gather results about cyclotomic extensions of `ℚ`. In particular, we compute the ring of integers of a `p ^ n`-th cyclotomic extension of `ℚ`. ## Main results * `IsCyclotomicExtension.Rat.isIntegralClosure_adjoin_singleton_of_prime_pow`: if `K` is a `p ^ k`-th cyclotomic extension of `ℚ`, then `(adjoin ℤ {ζ})` is the integral closure of `ℤ` in `K`. * `IsCyclotomicExtension.Rat.cyclotomicRing_isIntegralClosure_of_prime_pow`: the integral closure of `ℤ` inside `CyclotomicField (p ^ k) ℚ` is `CyclotomicRing (p ^ k) ℤ ℚ`. * `IsCyclotomicExtension.Rat.absdiscr_prime_pow` and related results: the absolute discriminant of cyclotomic fields. -/ universe u open Algebra IsCyclotomicExtension Polynomial NumberField open scoped Cyclotomic Nat variable {p : ℕ} {k : ℕ} {K : Type u} [Field K] {ζ : K} [hp : Fact p.Prime] namespace IsCyclotomicExtension.Rat variable [CharZero K] variable (k K) in theorem finrank [NeZero k] [IsCyclotomicExtension {k} ℚ K] : Module.finrank ℚ K = k.totient := IsCyclotomicExtension.finrank K <| Polynomial.cyclotomic.irreducible_rat (NeZero.pos _) /-- The discriminant of the power basis given by `ζ - 1`. -/ theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (hk : p ^ (k + 1) ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ (k + 1)).totient / 2) * p ^ (p ^ k * ((p - 1) * (k + 1) - 1)) := by rw [← discr_prime_pow_ne_two hζ (cyclotomic.irreducible_rat (NeZero.pos _)) hk] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm theorem discr_odd_prime' [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p - 1) / 2) * p ^ (p - 2) := by rw [← discr_odd_prime hζ (cyclotomic.irreducible_rat hp.out.pos) hodd] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm /-- The discriminant of the power basis given by `ζ - 1`. Beware that in the cases `p ^ k = 1` and `p ^ k = 2` the formula uses `1 / 2 = 0` and `0 - 1 = 0`. It is useful only to have a uniform result. See also `IsCyclotomicExtension.Rat.discr_prime_pow_eq_unit_mul_pow'`. -/ theorem discr_prime_pow' [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ k).totient / 2) * p ^ (p ^ (k - 1) * ((p - 1) * k - 1)) := by rw [← discr_prime_pow hζ (cyclotomic.irreducible_rat (NeZero.pos _))] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm /-- If `p` is a prime and `IsCyclotomicExtension {p ^ k} K L`, then there are `u : ℤˣ` and `n : ℕ` such that the discriminant of the power basis given by `ζ - 1` is `u * p ^ n`. Often this is enough and less cumbersome to use than `IsCyclotomicExtension.Rat.discr_prime_pow'`. -/ theorem discr_prime_pow_eq_unit_mul_pow' [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : ∃ (u : ℤˣ) (n : ℕ), discr ℚ (hζ.subOnePowerBasis ℚ).basis = u * p ^ n := by rw [hζ.discr_zeta_eq_discr_zeta_sub_one.symm] exact discr_prime_pow_eq_unit_mul_pow hζ (cyclotomic.irreducible_rat (NeZero.pos _)) /-- If `K` is a `p ^ k`-th cyclotomic extension of `ℚ`, then `(adjoin ℤ {ζ})` is the integral closure of `ℤ` in `K`. -/ theorem isIntegralClosure_adjoin_singleton_of_prime_pow [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : IsIntegralClosure (adjoin ℤ ({ζ} : Set K)) ℤ K := by refine ⟨Subtype.val_injective, @fun x => ⟨fun h => ⟨⟨x, ?_⟩, rfl⟩, ?_⟩⟩ swap · rintro ⟨y, rfl⟩ exact IsIntegral.algebraMap ((le_integralClosure_iff_isIntegral.1 (adjoin_le_integralClosure (hζ.isIntegral (NeZero.pos _)))).isIntegral _) let B := hζ.subOnePowerBasis ℚ have hint : IsIntegral ℤ B.gen := (hζ.isIntegral (NeZero.pos _)).sub isIntegral_one -- This can't be a `local instance` because it has metavariables. letI := IsCyclotomicExtension.finiteDimensional {p ^ k} ℚ K have H := discr_mul_isIntegral_mem_adjoin ℚ hint h obtain ⟨u, n, hun⟩ := discr_prime_pow_eq_unit_mul_pow' hζ rw [hun] at H replace H := Subalgebra.smul_mem _ H u.inv rw [← smul_assoc, ← smul_mul_assoc, Units.inv_eq_val_inv, zsmul_eq_mul, ← Int.cast_mul, Units.inv_mul, Int.cast_one, one_mul, smul_def, map_pow] at H cases k · haveI : IsCyclotomicExtension {1} ℚ K := by simpa using hcycl have : x ∈ (⊥ : Subalgebra ℚ K) := by rw [singleton_one ℚ K] exact mem_top obtain ⟨y, rfl⟩ := mem_bot.1 this replace h := (isIntegral_algebraMap_iff (algebraMap ℚ K).injective).1 h obtain ⟨z, hz⟩ := IsIntegrallyClosed.isIntegral_iff.1 h rw [← hz, ← IsScalarTower.algebraMap_apply] exact Subalgebra.algebraMap_mem _ _ · have hmin : (minpoly ℤ B.gen).IsEisensteinAt (Submodule.span ℤ {(p : ℤ)}) := by have h₁ := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hint have h₂ := hζ.minpoly_sub_one_eq_cyclotomic_comp (cyclotomic.irreducible_rat (NeZero.pos _)) rw [IsPrimitiveRoot.subOnePowerBasis_gen] at h₁ rw [h₁, ← map_cyclotomic_int, show Int.castRingHom ℚ = algebraMap ℤ ℚ by rfl, show X + 1 = map (algebraMap ℤ ℚ) (X + 1) by simp, ← map_comp] at h₂ rw [IsPrimitiveRoot.subOnePowerBasis_gen, map_injective (algebraMap ℤ ℚ) (algebraMap ℤ ℚ).injective_int h₂] exact cyclotomic_prime_pow_comp_X_add_one_isEisensteinAt p _ refine adjoin_le ?_ (mem_adjoin_of_smul_prime_pow_smul_of_minpoly_isEisensteinAt (n := n) (Nat.prime_iff_prime_int.1 hp.out) hint h (by simpa using H) hmin) simp only [Set.singleton_subset_iff, SetLike.mem_coe] exact Subalgebra.sub_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) theorem isIntegralClosure_adjoin_singleton_of_prime [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : IsIntegralClosure (adjoin ℤ ({ζ} : Set K)) ℤ K := by rw [← pow_one p] at hζ hcycl exact isIntegralClosure_adjoin_singleton_of_prime_pow hζ /-- The integral closure of `ℤ` inside `CyclotomicField (p ^ k) ℚ` is `CyclotomicRing (p ^ k) ℤ ℚ`. -/ theorem cyclotomicRing_isIntegralClosure_of_prime_pow : IsIntegralClosure (CyclotomicRing (p ^ k) ℤ ℚ) ℤ (CyclotomicField (p ^ k) ℚ) := by have hζ := zeta_spec (p ^ k) ℚ (CyclotomicField (p ^ k) ℚ) refine ⟨IsFractionRing.injective _ _, @fun x => ⟨fun h => ⟨⟨x, ?_⟩, rfl⟩, ?_⟩⟩ · obtain ⟨y, rfl⟩ := (isIntegralClosure_adjoin_singleton_of_prime_pow hζ).isIntegral_iff.1 h refine adjoin_mono ?_ y.2 simp only [Set.singleton_subset_iff, Set.mem_setOf_eq] exact hζ.pow_eq_one · rintro ⟨y, rfl⟩ exact IsIntegral.algebraMap ((IsCyclotomicExtension.integral {p ^ k} ℤ _).isIntegral _) theorem cyclotomicRing_isIntegralClosure_of_prime : IsIntegralClosure (CyclotomicRing p ℤ ℚ) ℤ (CyclotomicField p ℚ) := by rw [← pow_one p] exact cyclotomicRing_isIntegralClosure_of_prime_pow end IsCyclotomicExtension.Rat section PowerBasis open IsCyclotomicExtension.Rat namespace IsPrimitiveRoot section CharZero variable [CharZero K] /-- The algebra isomorphism `adjoin ℤ {ζ} ≃ₐ[ℤ] (𝓞 K)`, where `ζ` is a primitive `p ^ k`-th root of unity and `K` is a `p ^ k`-th cyclotomic extension of `ℚ`. -/ @[simps!] noncomputable def _root_.IsPrimitiveRoot.adjoinEquivRingOfIntegers [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : adjoin ℤ ({ζ} : Set K) ≃ₐ[ℤ] 𝓞 K := let _ := isIntegralClosure_adjoin_singleton_of_prime_pow hζ IsIntegralClosure.equiv ℤ (adjoin ℤ ({ζ} : Set K)) K (𝓞 K) /-- The ring of integers of a `p ^ k`-th cyclotomic extension of `ℚ` is a cyclotomic extension. -/ instance IsCyclotomicExtension.ringOfIntegers [IsCyclotomicExtension {p ^ k} ℚ K] : IsCyclotomicExtension {p ^ k} ℤ (𝓞 K) := let _ := (zeta_spec (p ^ k) ℚ K).adjoin_isCyclotomicExtension ℤ IsCyclotomicExtension.equiv _ ℤ _ (zeta_spec (p ^ k) ℚ K).adjoinEquivRingOfIntegers /-- The integral `PowerBasis` of `𝓞 K` given by a primitive root of unity, where `K` is a `p ^ k` cyclotomic extension of `ℚ`. -/ noncomputable def integralPowerBasis [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : PowerBasis ℤ (𝓞 K) := (Algebra.adjoin.powerBasis' (hζ.isIntegral (NeZero.pos _))).map hζ.adjoinEquivRingOfIntegers /-- Abbreviation to see a primitive root of unity as a member of the ring of integers. -/ abbrev toInteger {k : ℕ} [NeZero k] (hζ : IsPrimitiveRoot ζ k) : 𝓞 K := ⟨ζ, hζ.isIntegral (NeZero.pos _)⟩ end CharZero lemma coe_toInteger {k : ℕ} [NeZero k] (hζ : IsPrimitiveRoot ζ k) : hζ.toInteger.1 = ζ := rfl /-- `𝓞 K ⧸ Ideal.span {ζ - 1}` is finite. -/ lemma finite_quotient_toInteger_sub_one [NumberField K] {k : ℕ} (hk : 1 < k) (hζ : IsPrimitiveRoot ζ k) : haveI : NeZero k := NeZero.of_gt hk Finite (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1}) := by refine Ideal.finiteQuotientOfFreeOfNeBot _ (fun h ↦ ?_) simp only [Ideal.span_singleton_eq_bot, sub_eq_zero] at h exact hζ.ne_one hk (RingOfIntegers.ext_iff.1 h) /-- We have that `𝓞 K ⧸ Ideal.span {ζ - 1}` has cardinality equal to the norm of `ζ - 1`. See the results below to compute this norm in various cases. -/ lemma card_quotient_toInteger_sub_one [NumberField K] {k : ℕ} [NeZero k] (hζ : IsPrimitiveRoot ζ k) : Nat.card (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1}) = (Algebra.norm ℤ (hζ.toInteger - 1)).natAbs := by rw [← Submodule.cardQuot_apply, ← Ideal.absNorm_apply, Ideal.absNorm_span_singleton] lemma toInteger_isPrimitiveRoot {k : ℕ} [NeZero k] (hζ : IsPrimitiveRoot ζ k) : IsPrimitiveRoot hζ.toInteger k := IsPrimitiveRoot.of_map_of_injective (by exact hζ) RingOfIntegers.coe_injective variable [CharZero K] @[simp] theorem integralPowerBasis_gen [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : hζ.integralPowerBasis.gen = hζ.toInteger := Subtype.ext <| show algebraMap _ K hζ.integralPowerBasis.gen = _ by rw [integralPowerBasis, PowerBasis.map_gen, adjoin.powerBasis'_gen] simp only [adjoinEquivRingOfIntegers_apply, IsIntegralClosure.algebraMap_lift] rfl /- We name `hcycl` so it can be used as a named argument, but this is unused in the declaration otherwise, so we need to disable the linter. -/ set_option linter.unusedVariables false in @[simp] theorem integralPowerBasis_dim [hcycl : IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : hζ.integralPowerBasis.dim = φ (p ^ k) := by simp [integralPowerBasis, ← cyclotomic_eq_minpoly hζ (NeZero.pos _), natDegree_cyclotomic] /-- The algebra isomorphism `adjoin ℤ {ζ} ≃ₐ[ℤ] (𝓞 K)`, where `ζ` is a primitive `p`-th root of unity and `K` is a `p`-th cyclotomic extension of `ℚ`. -/ @[simps!] noncomputable def _root_.IsPrimitiveRoot.adjoinEquivRingOfIntegers' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : adjoin ℤ ({ζ} : Set K) ≃ₐ[ℤ] 𝓞 K := have : IsCyclotomicExtension {p ^ 1} ℚ K := by convert hcycl; rw [pow_one] adjoinEquivRingOfIntegers (p := p) (k := 1) (ζ := ζ) (by rwa [pow_one]) /-- The ring of integers of a `p`-th cyclotomic extension of `ℚ` is a cyclotomic extension. -/ instance _root_.IsCyclotomicExtension.ring_of_integers' [IsCyclotomicExtension {p} ℚ K] : IsCyclotomicExtension {p} ℤ (𝓞 K) := let _ := (zeta_spec p ℚ K).adjoin_isCyclotomicExtension ℤ IsCyclotomicExtension.equiv _ ℤ _ (zeta_spec p ℚ K).adjoinEquivRingOfIntegers' /-- The integral `PowerBasis` of `𝓞 K` given by a primitive root of unity, where `K` is a `p`-th cyclotomic extension of `ℚ`. -/ noncomputable def integralPowerBasis' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : PowerBasis ℤ (𝓞 K) := have : IsCyclotomicExtension {p ^ 1} ℚ K := by convert hcycl; rw [pow_one] integralPowerBasis (p := p) (k := 1) (ζ := ζ) (by rwa [pow_one]) @[simp] theorem integralPowerBasis'_gen [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.integralPowerBasis'.gen = hζ.toInteger := integralPowerBasis_gen (hcycl := by rwa [pow_one]) (by rwa [pow_one]) @[simp] theorem power_basis_int'_dim [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.integralPowerBasis'.dim = φ p := by rw [integralPowerBasis', integralPowerBasis_dim (hcycl := by rwa [pow_one]) (by rwa [pow_one]), pow_one] /-- The integral `PowerBasis` of `𝓞 K` given by `ζ - 1`, where `K` is a `p ^ k` cyclotomic extension of `ℚ`. -/ noncomputable def subOneIntegralPowerBasis [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : PowerBasis ℤ (𝓞 K) := PowerBasis.ofAdjoinEqTop' (RingOfIntegers.isIntegral ⟨ζ- 1, (hζ.isIntegral (NeZero.pos _)).sub isIntegral_one⟩) (by refine hζ.integralPowerBasis.adjoin_eq_top_of_gen_mem_adjoin ?_ convert Subalgebra.add_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) simp [RingOfIntegers.ext_iff, integralPowerBasis_gen, toInteger]) @[simp] theorem subOneIntegralPowerBasis_gen [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ k)) : hζ.subOneIntegralPowerBasis.gen = ⟨ζ - 1, Subalgebra.sub_mem _ (hζ.isIntegral (NeZero.pos _)) (Subalgebra.one_mem _)⟩ := by simp [subOneIntegralPowerBasis] /-- The integral `PowerBasis` of `𝓞 K` given by `ζ - 1`, where `K` is a `p`-th cyclotomic extension of `ℚ`. -/ noncomputable def subOneIntegralPowerBasis' [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : PowerBasis ℤ (𝓞 K) := have : IsCyclotomicExtension {p ^ 1} ℚ K := by rwa [pow_one] subOneIntegralPowerBasis (p := p) (k := 1) (ζ := ζ) (by rwa [pow_one]) @[simp, nolint unusedHavesSuffices] theorem subOneIntegralPowerBasis'_gen [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.subOneIntegralPowerBasis'.gen = hζ.toInteger - 1 := -- The `unusedHavesSuffices` linter incorrectly thinks this `have` is unnecessary. have : IsCyclotomicExtension {p ^ 1} ℚ K := by rwa [pow_one] subOneIntegralPowerBasis_gen (by rwa [pow_one]) /-- `ζ - 1` is prime if `p ≠ 2` and `ζ` is a primitive `p ^ (k + 1)`-th root of unity. See `zeta_sub_one_prime` for a general statement. -/ theorem zeta_sub_one_prime_of_ne_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (hodd : p ≠ 2) : Prime (hζ.toInteger - 1) := by letI := IsCyclotomicExtension.numberField {p ^ (k + 1)} ℚ K refine Ideal.prime_of_irreducible_absNorm_span (fun h ↦ ?_) ?_ · apply hζ.pow_ne_one_of_pos_of_lt one_ne_zero (one_lt_pow₀ hp.out.one_lt (by simp)) rw [sub_eq_zero] at h simpa using congrArg (algebraMap _ K) h rw [Nat.irreducible_iff_prime, Ideal.absNorm_span_singleton, ← Nat.prime_iff, ← Int.prime_iff_natAbs_prime] convert Nat.prime_iff_prime_int.1 hp.out apply RingHom.injective_int (algebraMap ℤ ℚ) rw [← Algebra.norm_localization (Sₘ := K) ℤ (nonZeroDivisors ℤ)] simp only [algebraMap_int_eq, map_natCast] exact hζ.norm_sub_one_of_prime_ne_two (Polynomial.cyclotomic.irreducible_rat (NeZero.pos _)) hodd /-- `ζ - 1` is prime if `ζ` is a primitive `2 ^ (k + 1)`-th root of unity. See `zeta_sub_one_prime` for a general statement. -/ theorem zeta_sub_one_prime_of_two_pow [IsCyclotomicExtension {2 ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (2 ^ (k + 1))) : Prime (hζ.toInteger - 1) := by have := IsCyclotomicExtension.numberField {2 ^ (k + 1)} ℚ K refine Ideal.prime_of_irreducible_absNorm_span (fun h ↦ ?_) ?_ · apply hζ.pow_ne_one_of_pos_of_lt one_ne_zero (one_lt_pow₀ (by decide) (by simp)) rw [sub_eq_zero] at h simpa using congrArg (algebraMap _ K) h rw [Nat.irreducible_iff_prime, Ideal.absNorm_span_singleton, ← Nat.prime_iff, ← Int.prime_iff_natAbs_prime] cases k · convert Prime.neg Int.prime_two apply RingHom.injective_int (algebraMap ℤ ℚ) rw [← Algebra.norm_localization (Sₘ := K) ℤ (nonZeroDivisors ℤ)] simp only [algebraMap_int_eq, map_neg, map_ofNat] simpa only [zero_add, pow_one, AddSubgroupClass.coe_sub, OneMemClass.coe_one, pow_zero] using hζ.norm_pow_sub_one_two (cyclotomic.irreducible_rat (by simp only [zero_add, pow_one, Nat.ofNat_pos])) convert Int.prime_two apply RingHom.injective_int (algebraMap ℤ ℚ) rw [← Algebra.norm_localization (Sₘ := K) ℤ (nonZeroDivisors ℤ), algebraMap_int_eq] exact hζ.norm_sub_one_two Nat.AtLeastTwo.prop (cyclotomic.irreducible_rat (by simp)) /-- `ζ - 1` is prime if `ζ` is a primitive `p ^ (k + 1)`-th root of unity. -/ theorem zeta_sub_one_prime [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) : Prime (hζ.toInteger - 1) := by by_cases htwo : p = 2 · subst htwo apply hζ.zeta_sub_one_prime_of_two_pow · apply hζ.zeta_sub_one_prime_of_ne_two htwo /-- `ζ - 1` is prime if `ζ` is a primitive `p`-th root of unity. -/ theorem zeta_sub_one_prime' [h : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : Prime ((hζ.toInteger - 1)) := by convert zeta_sub_one_prime (k := 0) (by simpa only [zero_add, pow_one]) simpa only [zero_add, pow_one] theorem subOneIntegralPowerBasis_gen_prime [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) : Prime hζ.subOneIntegralPowerBasis.gen := by simpa only [subOneIntegralPowerBasis_gen] using hζ.zeta_sub_one_prime theorem subOneIntegralPowerBasis'_gen_prime [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : Prime hζ.subOneIntegralPowerBasis'.gen := by simpa only [subOneIntegralPowerBasis'_gen] using hζ.zeta_sub_one_prime' /-- The norm, relative to `ℤ`, of `ζ - 1` in a `n`-th cyclotomic extension of `ℚ` where `n` is not a power of a prime number is `1`. -/ theorem norm_toInteger_sub_one_eq_one {n : ℕ} [IsCyclotomicExtension {n} ℚ K] (hζ : IsPrimitiveRoot ζ n) (h₁ : 2 < n) (h₂ : ∀ {p : ℕ}, Nat.Prime p → ∀ (k : ℕ), p ^ k ≠ n) : have : NeZero n := NeZero.of_gt h₁ norm ℤ (hζ.toInteger - 1) = 1 := by have : NumberField K := IsCyclotomicExtension.numberField {n} ℚ K have : NeZero n := NeZero.of_gt h₁ dsimp only rw [norm_eq_iff ℤ (Sₘ := K) (Rₘ := ℚ) le_rfl, map_sub, map_one, map_one, RingOfIntegers.map_mk, sub_one_norm_eq_eval_cyclotomic hζ h₁ (cyclotomic.irreducible_rat (NeZero.pos _)), eval_one_cyclotomic_not_prime_pow h₂, Int.cast_one] /-- The norm, relative to `ℤ`, of `ζ ^ p ^ s - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `ℚ` is p ^ p ^ s` if `s ≤ k` and `p ^ (k - s + 1) ≠ 2`. -/ lemma norm_toInteger_pow_sub_one_of_prime_pow_ne_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) {s : ℕ} (hs : s ≤ k) (htwo : p ^ (k - s + 1) ≠ 2) : Algebra.norm ℤ (hζ.toInteger ^ p ^ s - 1) = p ^ p ^ s := by have : NumberField K := IsCyclotomicExtension.numberField {p ^ (k + 1)} ℚ K rw [Algebra.norm_eq_iff ℤ (Sₘ := K) (Rₘ := ℚ) le_rfl] simp [hζ.norm_pow_sub_one_of_prime_pow_ne_two (cyclotomic.irreducible_rat (NeZero.pos _)) hs htwo] /-- The norm, relative to `ℤ`, of `ζ ^ 2 ^ k - 1` in a `2 ^ (k + 1)`-th cyclotomic extension of `ℚ` is `(-2) ^ 2 ^ k`. -/ lemma norm_toInteger_pow_sub_one_of_two [IsCyclotomicExtension {2 ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (2 ^ (k + 1))) : Algebra.norm ℤ (hζ.toInteger ^ 2 ^ k - 1) = (-2) ^ 2 ^ k := by have : NumberField K := IsCyclotomicExtension.numberField {2 ^ (k + 1)} ℚ K rw [Algebra.norm_eq_iff ℤ (Sₘ := K) (Rₘ := ℚ) le_rfl] simp [hζ.norm_pow_sub_one_two (cyclotomic.irreducible_rat (pow_pos (by decide) _))] /-- The norm, relative to `ℤ`, of `ζ ^ p ^ s - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `ℚ` is `p ^ p ^ s` if `s ≤ k` and `p ≠ 2`. -/ lemma norm_toInteger_pow_sub_one_of_prime_ne_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) {s : ℕ} (hs : s ≤ k) (hodd : p ≠ 2) : Algebra.norm ℤ (hζ.toInteger ^ p ^ s - 1) = p ^ p ^ s := by refine hζ.norm_toInteger_pow_sub_one_of_prime_pow_ne_two hs (fun h ↦ hodd ?_) apply eq_of_prime_pow_eq hp.out.prime Nat.prime_two.prime (k - s).succ_pos rwa [pow_one] /-- The norm, relative to `ℤ`, of `ζ - 1` in a `2 ^ (k + 2)`-th cyclotomic extension of `ℚ` is `2`. -/ theorem norm_toInteger_sub_one_of_eq_two_pow {k : ℕ} {K : Type*} [Field K] {ζ : K} [CharZero K] [IsCyclotomicExtension {2 ^ (k + 2)} ℚ K] (hζ : IsPrimitiveRoot ζ (2 ^ (k + 2))) : norm ℤ (hζ.toInteger - 1) = 2 := by have : NumberField K := IsCyclotomicExtension.numberField {2 ^ (k + 2)} ℚ K rw [norm_eq_iff ℤ (Sₘ := K) (Rₘ := ℚ) le_rfl, map_sub, map_one, eq_intCast, Int.cast_ofNat, RingOfIntegers.map_mk, hζ.norm_sub_one_two (Nat.le_add_left 2 k) (Polynomial.cyclotomic.irreducible_rat (Nat.two_pow_pos _))] /-- The norm, relative to `ℤ`, of `ζ - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `ℚ` is `p` if `p ≠ 2`. -/ lemma norm_toInteger_sub_one_of_prime_ne_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (hodd : p ≠ 2) : Algebra.norm ℤ (hζ.toInteger - 1) = p := by simpa only [pow_zero, pow_one] using hζ.norm_toInteger_pow_sub_one_of_prime_ne_two (Nat.zero_le _) hodd /-- The norm, relative to `ℤ`, of `ζ - 1` in a `2`-th cyclotomic extension of `ℚ` is `-2`. -/ theorem norm_toInteger_sub_one_of_eq_two [IsCyclotomicExtension {2} ℚ K] (hζ : IsPrimitiveRoot ζ 2) : norm ℤ (hζ.toInteger - 1) = -2 := by rw [show 2 = (2 ^ (0 + 1)) by norm_num] at hζ simpa using hζ.norm_toInteger_pow_sub_one_of_two /-- The norm, relative to `ℤ`, of `ζ - 1` in a `p`-th cyclotomic extension of `ℚ` is `p` if `p ≠ 2`. -/ lemma norm_toInteger_sub_one_of_prime_ne_two' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (h : p ≠ 2) : Algebra.norm ℤ (hζ.toInteger - 1) = p := by have : IsCyclotomicExtension {p ^ (0 + 1)} ℚ K := by simpa using hcycl replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ exact hζ.norm_toInteger_sub_one_of_prime_ne_two h /-- The norm, relative to `ℤ`, of `ζ - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `ℚ` is a prime if `p ^ (k + 1) ≠ 2`. -/ lemma prime_norm_toInteger_sub_one_of_prime_pow_ne_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (htwo : p ^ (k + 1) ≠ 2) : Prime (Algebra.norm ℤ (hζ.toInteger - 1)) := by have := hζ.norm_toInteger_pow_sub_one_of_prime_pow_ne_two (zero_le _) htwo simp only [pow_zero, pow_one] at this rw [this] exact Nat.prime_iff_prime_int.1 hp.out /-- The norm, relative to `ℤ`, of `ζ - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `ℚ` is a prime if `p ≠ 2`. -/ lemma prime_norm_toInteger_sub_one_of_prime_ne_two [hcycl : IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (hodd : p ≠ 2) : Prime (Algebra.norm ℤ (hζ.toInteger - 1)) := by have := hζ.norm_toInteger_sub_one_of_prime_ne_two hodd simp only at this rw [this] exact Nat.prime_iff_prime_int.1 hp.out /-- The norm, relative to `ℤ`, of `ζ - 1` in a `p`-th cyclotomic extension of `ℚ` is a prime if `p ≠ 2`. -/ lemma prime_norm_toInteger_sub_one_of_prime_ne_two' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) : Prime (Algebra.norm ℤ (hζ.toInteger - 1)) := by have : IsCyclotomicExtension {p ^ (0 + 1)} ℚ K := by simpa using hcycl replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ exact hζ.prime_norm_toInteger_sub_one_of_prime_ne_two hodd /-- In a `p ^ (k + 1)`-th cyclotomic extension of `ℚ `, we have that `ζ` is not congruent to an integer modulo `p` if `p ^ (k + 1) ≠ 2`. -/ theorem not_exists_int_prime_dvd_sub_of_prime_pow_ne_two [hcycl : IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (htwo : p ^ (k + 1) ≠ 2) : ¬(∃ n : ℤ, (p : 𝓞 K) ∣ (hζ.toInteger - n : 𝓞 K)) := by intro ⟨n, x, h⟩ -- Let `pB` be the power basis of `𝓞 K` given by powers of `ζ`. let pB := hζ.integralPowerBasis have hdim : pB.dim = p ^ k * (↑p - 1) := by simp [integralPowerBasis_dim, pB, Nat.totient_prime_pow hp.1 (Nat.zero_lt_succ k)] replace hdim : 1 < pB.dim := by rw [Nat.one_lt_iff_ne_zero_and_ne_one, hdim] refine ⟨by simp only [ne_eq, mul_eq_zero, NeZero.ne _, Nat.sub_eq_zero_iff_le, false_or, not_le, Nat.Prime.one_lt hp.out], ne_of_gt ?_⟩ by_cases hk : k = 0 · simp only [hk, zero_add, pow_one, pow_zero, one_mul, Nat.lt_sub_iff_add_lt, Nat.reduceAdd] at htwo ⊢ exact htwo.symm.lt_of_le hp.1.two_le · exact one_lt_mul_of_lt_of_le (one_lt_pow₀ hp.1.one_lt hk) (have := Nat.Prime.two_le hp.out; by cutsat) rw [sub_eq_iff_eq_add] at h -- We are assuming that `ζ = n + p * x` for some integer `n` and `x : 𝓞 K`. Looking at the -- coordinates in the base `pB`, we obtain that `1` is a multiple of `p`, contradiction. replace h := pB.basis.ext_elem_iff.1 h ⟨1, hdim⟩ have := pB.basis_eq_pow ⟨1, hdim⟩ rw [hζ.integralPowerBasis_gen] at this simp only [PowerBasis.coe_basis, pow_one] at this rw [← this, show pB.gen = pB.gen ^ (⟨1, hdim⟩ : Fin pB.dim).1 by simp, ← pB.basis_eq_pow, pB.basis.repr_self_apply] at h simp only [↓reduceIte, map_add, Finsupp.coe_add, Pi.add_apply] at h rw [show (p : 𝓞 K) * x = (p : ℤ) • x by simp, ← pB.basis.coord_apply, LinearMap.map_smul, ← zsmul_one, ← pB.basis.coord_apply, LinearMap.map_smul, show 1 = pB.gen ^ (⟨0, by cutsat⟩ : Fin pB.dim).1 by simp, ← pB.basis_eq_pow, pB.basis.coord_apply, pB.basis.coord_apply, pB.basis.repr_self_apply] at h simp only [smul_eq_mul, Fin.mk.injEq, zero_ne_one, ↓reduceIte, mul_zero, add_zero] at h exact (Int.prime_iff_natAbs_prime.2 (by simp [hp.1])).not_dvd_one ⟨_, h⟩ /-- In a `p ^ (k + 1)`-th cyclotomic extension of `ℚ `, we have that `ζ` is not congruent to an integer modulo `p` if `p ≠ 2`. -/ theorem not_exists_int_prime_dvd_sub_of_prime_ne_two [hcycl : IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (hodd : p ≠ 2) : ¬(∃ n : ℤ, (p : 𝓞 K) ∣ (hζ.toInteger - n : 𝓞 K)) := by refine not_exists_int_prime_dvd_sub_of_prime_pow_ne_two hζ (fun h ↦ ?_) simp_all only [(@Nat.Prime.pow_eq_iff 2 p (k + 1) Nat.prime_two).mp (by assumption_mod_cast), pow_one, ne_eq] /-- In a `p`-th cyclotomic extension of `ℚ `, we have that `ζ` is not congruent to an integer modulo `p` if `p ≠ 2`. -/ theorem not_exists_int_prime_dvd_sub_of_prime_ne_two' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) : ¬(∃ n : ℤ, (p : 𝓞 K) ∣ (hζ.toInteger - n : 𝓞 K)) := by have : IsCyclotomicExtension {p ^ (0 + 1)} ℚ K := by simpa using hcycl replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ exact not_exists_int_prime_dvd_sub_of_prime_ne_two hζ hodd theorem finite_quotient_span_sub_one [hcycl : IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) : Finite (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1}) := by have : NumberField K := IsCyclotomicExtension.numberField {p ^ (k + 1)} ℚ K refine Ideal.finiteQuotientOfFreeOfNeBot _ (fun h ↦ ?_) simp only [Ideal.span_singleton_eq_bot, sub_eq_zero] at h exact hζ.ne_one (one_lt_pow₀ hp.1.one_lt (Nat.zero_ne_add_one k).symm) (RingOfIntegers.ext_iff.1 h) theorem finite_quotient_span_sub_one' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : Finite (𝓞 K ⧸ Ideal.span {hζ.toInteger - 1}) := by have : IsCyclotomicExtension {p ^ (0 + 1)} ℚ K := by simpa using hcycl replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ exact hζ.finite_quotient_span_sub_one /-- In a `p ^ (k + 1)`-th cyclotomic extension of `ℚ`, we have that `ζ - 1` divides `p` in `𝓞 K`. -/ lemma toInteger_sub_one_dvd_prime [hcycl : IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) : ((hζ.toInteger - 1)) ∣ p := by by_cases htwo : p ^ (k + 1) = 2 · have ⟨hp2, hk⟩ := (Nat.Prime.pow_eq_iff Nat.prime_two).1 htwo simp only [add_eq_right] at hk have hζ' : ζ = -1 := by refine IsPrimitiveRoot.eq_neg_one_of_two_right ?_ rwa [hk, zero_add, pow_one, hp2] at hζ replace hζ' : hζ.toInteger = -1 := by ext exact hζ' rw [hζ', hp2] exact ⟨-1, by ring⟩ suffices (hζ.toInteger - 1) ∣ (p : ℤ) by simpa have := IsCyclotomicExtension.numberField {p ^ (k + 1)} ℚ K have H := hζ.norm_toInteger_pow_sub_one_of_prime_pow_ne_two (zero_le _) htwo rw [pow_zero, pow_one] at H rw [← Ideal.norm_dvd_iff, H] · simp · exact prime_norm_toInteger_sub_one_of_prime_pow_ne_two hζ htwo /-- In a `p`-th cyclotomic extension of `ℚ`, we have that `ζ - 1` divides `p` in `𝓞 K`. -/ lemma toInteger_sub_one_dvd_prime' [hcycl : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : hζ.toInteger - 1 ∣ p := by have : IsCyclotomicExtension {p ^ (0 + 1)} ℚ K := by simpa using hcycl replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ exact toInteger_sub_one_dvd_prime hζ /-- We have that `hζ.toInteger - 1` does not divide `2`. -/ lemma toInteger_sub_one_not_dvd_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) (hodd : p ≠ 2) : ¬ hζ.toInteger - 1 ∣ 2 := fun h ↦ by have : NumberField K := IsCyclotomicExtension.numberField {p ^ (k + 1)} ℚ K replace h : hζ.toInteger - 1 ∣ (2 : ℤ) := by simp [h] rw [← Ideal.norm_dvd_iff, hζ.norm_toInteger_sub_one_of_prime_ne_two hodd] at h · refine hodd <| (prime_dvd_prime_iff_eq ?_ ?_).1 ?_ · exact Nat.prime_iff.1 hp.1 · exact Nat.prime_iff.1 Nat.prime_two · exact Int.ofNat_dvd.mp h · rw [hζ.norm_toInteger_sub_one_of_prime_ne_two hodd] exact Nat.prime_iff_prime_int.1 hp.1 open IntermediateField in /-- Let `ζ` be a primitive root of unity of order `n` with `2 ≤ n`. Any prime number that divides the norm, relative to `ℤ`, of `ζ - 1` divides also `n`. -/ theorem prime_dvd_of_dvd_norm_sub_one {n : ℕ} (hn : 2 ≤ n) {K : Type*} [Field K] [NumberField K] {ζ : K} {p : ℕ} [hF : Fact (Nat.Prime p)] (hζ : IsPrimitiveRoot ζ n) (hp : haveI : NeZero n := NeZero.of_gt hn; (p : ℤ) ∣ norm ℤ (hζ.toInteger - 1)) : p ∣ n := by have : NeZero n := NeZero.of_gt hn obtain ⟨μ, hC, hμ, h⟩ : ∃ μ : ℚ⟮ζ⟯, ∃ (_ : IsCyclotomicExtension {n} ℚ ℚ⟮ζ⟯), ∃ (hμ : IsPrimitiveRoot μ n), norm ℤ (hζ.toInteger - 1) = norm ℤ (hμ.toInteger - 1) ^ Module.finrank ℚ⟮ζ⟯ K := by refine ⟨IntermediateField.AdjoinSimple.gen ℚ ζ, intermediateField_adjoin_isCyclotomicExtension ℚ hζ, coe_submonoidClass_iff.mp hζ, ?_⟩ have : NumberField ℚ⟮ζ⟯ := of_intermediateField _ rw [norm_eq_iff ℤ (Sₘ := K) (Rₘ := ℚ) le_rfl, map_sub, map_one, RingOfIntegers.map_mk, show ζ - 1 = algebraMap ℚ⟮ζ⟯ K (IntermediateField.AdjoinSimple.gen ℚ ζ - 1) by rfl, ← norm_norm (S := ℚ⟮ζ⟯), Algebra.norm_algebraMap, map_pow, map_pow, ← norm_localization ℤ (nonZeroDivisors ℤ) (Sₘ := ℚ⟮ζ⟯), map_sub (algebraMap _ _), RingOfIntegers.map_mk, map_one] rw [h] at hp rsuffices ⟨q, hq, t, s, ht₁, ht₂, hs⟩ : ∃ q, q.Prime ∧ ∃ t s, t ≠ 0 ∧ n = q ^ t ∧ (p : ℤ) ∣ (q : ℤ) ^ s := by obtain hn | hn := lt_or_eq_of_le hn · by_cases! h : ∃ q, q.Prime ∧ ∃ t, q ^ t = n · obtain ⟨q, hq, t, hn'⟩ := h have : Fact (Nat.Prime q) := ⟨hq⟩ cases t with | zero => simp [← hn'] at hn | succ r => rw [← hn'] at hC hμ refine ⟨q, hq, r + 1, Module.finrank (ℚ⟮ζ⟯) K, r.add_one_ne_zero, hn'.symm, ?_⟩ by_cases hq' : q = 2 · cases r with | zero => rw [← hn', hq', zero_add, pow_one] at hn exact hn.false.elim | succ k => rw [hq'] at hC hμ ⊢ rwa [hμ.norm_toInteger_sub_one_of_eq_two_pow] at hp · rwa [hμ.norm_toInteger_sub_one_of_prime_ne_two hq'] at hp · rw [IsPrimitiveRoot.norm_toInteger_sub_one_eq_one hμ hn, one_pow, Int.natCast_dvd_ofNat, Nat.dvd_one] at hp · exact (Nat.Prime.ne_one hF.out hp).elim · exact fun {p} a k ↦ h p a k · rw [← hn] at hμ hC ⊢ refine ⟨2, Nat.prime_two, 1, Module.finrank ℚ⟮ζ⟯ K, one_ne_zero, by rw [pow_one], ?_⟩ rwa [hμ.norm_toInteger_sub_one_of_eq_two, neg_eq_neg_one_mul, mul_pow, IsUnit.dvd_mul_left ((isUnit_pow_iff Module.finrank_pos.ne').mpr isUnit_neg_one)] at hp have : p = q := by rw [← Int.natCast_pow, Int.natCast_dvd_natCast] at hs exact (Nat.prime_dvd_prime_iff_eq hF.out hq).mp (hF.out.dvd_of_dvd_pow hs) rw [ht₂, this] exact dvd_pow_self _ ht₁ end IsPrimitiveRoot section absdiscr namespace IsCyclotomicExtension.Rat open nonZeroDivisors IsPrimitiveRoot variable (K p k) variable [CharZero K] /-- We compute the absolute discriminant of a `p ^ k`-th cyclotomic field. Beware that in the cases `p ^ k = 1` and `p ^ k = 2` the formula uses `1 / 2 = 0` and `0 - 1 = 0`. See also the results below. -/ theorem absdiscr_prime_pow [IsCyclotomicExtension {p ^ k} ℚ K] : haveI : NumberField K := IsCyclotomicExtension.numberField {p ^ k} ℚ K NumberField.discr K = (-1) ^ ((p ^ k).totient / 2) * p ^ (p ^ (k - 1) * ((p - 1) * k - 1)) := by have hζ := IsCyclotomicExtension.zeta_spec (p ^ k) ℚ K have : NumberField K := IsCyclotomicExtension.numberField {p ^ k} ℚ K let pB₁ := integralPowerBasis hζ apply (algebraMap ℤ ℚ).injective_int rw [← NumberField.discr_eq_discr _ pB₁.basis, ← Algebra.discr_localizationLocalization ℤ ℤ⁰ K] convert IsCyclotomicExtension.discr_prime_pow hζ (cyclotomic.irreducible_rat (NeZero.pos _)) using 1 · have : pB₁.dim = (IsPrimitiveRoot.powerBasis ℚ hζ).dim := by rw [← PowerBasis.finrank, ← PowerBasis.finrank] exact RingOfIntegers.rank K rw [← Algebra.discr_reindex _ _ (finCongr this)] congr 1 ext i simp_rw [Function.comp_apply, Module.Basis.localizationLocalization_apply, powerBasis_dim, PowerBasis.coe_basis, pB₁, integralPowerBasis_gen] convert ← ((IsPrimitiveRoot.powerBasis ℚ hζ).basis_eq_pow i).symm using 1 · simp_rw [algebraMap_int_eq, map_mul, map_pow, map_neg, map_one, map_natCast] open Nat in /-- We compute the absolute discriminant of a `p ^ (k + 1)`-th cyclotomic field. Beware that in the case `p ^ k = 2` the formula uses `1 / 2 = 0`. See also the results below. -/ theorem absdiscr_prime_pow_succ [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] : haveI : NumberField K := IsCyclotomicExtension.numberField {p ^ (k + 1)} ℚ K NumberField.discr K = (-1) ^ (p ^ k * (p - 1) / 2) * p ^ (p ^ k * ((p - 1) * (k + 1) - 1)) := by simpa [totient_prime_pow hp.out (succ_pos k)] using absdiscr_prime_pow p (k + 1) K /-- We compute the absolute discriminant of a `p`-th cyclotomic field where `p` is prime. -/ theorem absdiscr_prime [IsCyclotomicExtension {p} ℚ K] : haveI : NumberField K := IsCyclotomicExtension.numberField {p} ℚ K NumberField.discr K = (-1) ^ ((p - 1) / 2) * p ^ (p - 2) := by have : IsCyclotomicExtension {p ^ (0 + 1)} ℚ K := by rw [zero_add, pow_one] infer_instance rw [absdiscr_prime_pow_succ p 0 K] simp [Nat.sub_sub] end IsCyclotomicExtension.Rat end absdiscr end PowerBasis
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Cyclotomic/Ideal.lean
import Mathlib.NumberTheory.NumberField.Cyclotomic.Basic import Mathlib.NumberTheory.RamificationInertia.Galois import Mathlib.RingTheory.Ideal.Int import Mathlib.RingTheory.RootsOfUnity.CyclotomicUnits /-! # Ideals in cyclotomic fields In this file, we prove results about ideals in cyclotomic extensions of `ℚ`. ## Main results * `IsCyclotomicExtension.Rat.ncard_primesOver_of_prime_pow`: there is only one prime ideal above the prime `p` in `ℚ(ζ_pᵏ)` * `IsCyclotomicExtension.Rat.inertiaDeg_eq_of_prime_pow`: the residual degree of the prime ideal above `p` in `ℚ(ζ_pᵏ)` is `1`. * `IsCyclotomicExtension.Rat.ramificationIdx_eq_of_prime_pow`: the ramification index of the prime ideal above `p` in `ℚ(ζ_pᵏ)` is `p ^ (k - 1) * (p - 1)`. -/ namespace IsCyclotomicExtension.Rat open Ideal NumberField section PrimePow variable (p k : ℕ) [hp : Fact (Nat.Prime p)] {K : Type*} [Field K] [NumberField K] [hK : IsCyclotomicExtension {p ^ (k + 1)} ℚ K] {ζ : K} (hζ : IsPrimitiveRoot ζ (p ^ (k + 1))) local notation3 "𝒑" => (Ideal.span {(p : ℤ)}) instance isPrime_span_zeta_sub_one : IsPrime (span {hζ.toInteger - 1}) := by rw [Ideal.span_singleton_prime] · exact hζ.zeta_sub_one_prime · exact Prime.ne_zero hζ.zeta_sub_one_prime theorem associated_norm_zeta_sub_one : Associated (Algebra.norm ℤ (hζ.toInteger - 1)) (p : ℤ) := by by_cases h : p = 2 · cases k with | zero => rw [h, zero_add, pow_one] at hK hζ rw [hζ.norm_toInteger_sub_one_of_eq_two, h, Int.ofNat_two, Associated.neg_left_iff] | succ n => rw [h, add_assoc, one_add_one_eq_two] at hK hζ rw [hζ.norm_toInteger_sub_one_of_eq_two_pow, h, Int.ofNat_two] · rw [hζ.norm_toInteger_sub_one_of_prime_ne_two h] theorem absNorm_span_zeta_sub_one : absNorm (span {hζ.toInteger - 1}) = p := by simpa using congr_arg absNorm <| span_singleton_eq_span_singleton.mpr <| associated_norm_zeta_sub_one p k hζ theorem p_mem_span_zeta_sub_one : (p : 𝓞 K) ∈ span {hζ.toInteger - 1} := by convert Ideal.absNorm_mem _ exact (absNorm_span_zeta_sub_one ..).symm theorem span_zeta_sub_one_ne_bot : span {hζ.toInteger - 1} ≠ ⊥ := (Submodule.ne_bot_iff _).mpr ⟨p, p_mem_span_zeta_sub_one p k hζ, NeZero.natCast_ne p (𝓞 K)⟩ theorem liesOver_span_zeta_sub_one : (span {hζ.toInteger - 1}).LiesOver 𝒑 := by rw [liesOver_iff] refine Ideal.IsMaximal.eq_of_le (Int.ideal_span_isMaximal_of_prime p) IsPrime.ne_top' ?_ rw [span_singleton_le_iff_mem, mem_comap, algebraMap_int_eq, map_natCast] exact p_mem_span_zeta_sub_one p k hζ theorem inertiaDeg_span_zeta_sub_one : inertiaDeg 𝒑 (span {hζ.toInteger - 1}) = 1 := by have := liesOver_span_zeta_sub_one p k hζ rw [← Nat.pow_right_inj hp.out.one_lt, pow_one, ← absNorm_eq_pow_inertiaDeg' _ hp.out, absNorm_span_zeta_sub_one] attribute [local instance] FractionRing.liftAlgebra in theorem map_eq_span_zeta_sub_one_pow : (map (algebraMap ℤ (𝓞 K)) 𝒑) = span {hζ.toInteger - 1} ^ Module.finrank ℚ K := by have : IsGalois ℚ K := isGalois {p ^ (k + 1)} ℚ K have : IsGalois (FractionRing ℤ) (FractionRing (𝓞 K)) := by refine IsGalois.of_equiv_equiv (f := (FractionRing.algEquiv ℤ ℚ).toRingEquiv.symm) (g := (FractionRing.algEquiv (𝓞 K) K).toRingEquiv.symm) <| RingHom.ext fun x ↦ IsFractionRing.algEquiv_commutes (FractionRing.algEquiv ℤ ℚ).symm (FractionRing.algEquiv (𝓞 K) K).symm _ rw [map_span, Set.image_singleton, span_singleton_eq_span_singleton.mpr ((associated_norm_zeta_sub_one p k hζ).symm.map (algebraMap ℤ (𝓞 K))), ← Algebra.intNorm_eq_norm, Algebra.algebraMap_intNorm_of_isGalois, ← prod_span_singleton] conv_lhs => enter [2, σ] rw [span_singleton_eq_span_singleton.mpr (hζ.toInteger_isPrimitiveRoot.associated_sub_one_map_sub_one σ).symm] rw [Finset.prod_const, Finset.card_univ, ← Fintype.card_congr (galRestrict ℤ ℚ K (𝓞 K)).toEquiv, ← Nat.card_eq_fintype_card, IsGalois.card_aut_eq_finrank] theorem ramificationIdx_span_zeta_sub_one : ramificationIdx (algebraMap ℤ (𝓞 K)) 𝒑 (span {hζ.toInteger - 1}) = p ^ k * (p - 1) := by have := liesOver_span_zeta_sub_one p k hζ have h := isPrime_span_zeta_sub_one p k hζ rw [← Nat.totient_prime_pow_succ hp.out, ← finrank _ K, IsDedekindDomain.ramificationIdx_eq_multiplicity _ h, map_eq_span_zeta_sub_one_pow p k hζ, multiplicity_pow_self (span_zeta_sub_one_ne_bot p k hζ) (isUnit_iff.not.mpr h.ne_top)] exact map_ne_bot_of_ne_bot <| by simpa using hp.out.ne_zero variable (K) include hK in theorem ncard_primesOver_of_prime_pow : (primesOver 𝒑 (𝓞 K)).ncard = 1 := by have : IsGalois ℚ K := isGalois {p ^ (k + 1)} ℚ K have : 𝒑 ≠ ⊥ := by simpa using hp.out.ne_zero have h_main := ncard_primesOver_mul_ramificationIdxIn_mul_inertiaDegIn this (𝓞 K) (K ≃ₐ[ℚ] K) have hζ := hK.zeta_spec have := liesOver_span_zeta_sub_one p k hζ rwa [ramificationIdxIn_eq_ramificationIdx 𝒑 (span {hζ.toInteger - 1}) (K ≃ₐ[ℚ] K), inertiaDegIn_eq_inertiaDeg 𝒑 (span {hζ.toInteger - 1}) (K ≃ₐ[ℚ] K), inertiaDeg_span_zeta_sub_one, ramificationIdx_span_zeta_sub_one, mul_one, ← Nat.totient_prime_pow_succ hp.out, ← finrank _ K, IsGaloisGroup.card_eq_finrank (K ≃ₐ[ℚ] K) ℚ K, Nat.mul_eq_right] at h_main exact Module.finrank_pos.ne' theorem eq_span_zeta_sub_one_of_liesOver (P : Ideal (𝓞 K)) [hP₁ : P.IsPrime] [hP₂ : P.LiesOver 𝒑] : P = span {hζ.toInteger - 1} := by have : P ∈ primesOver 𝒑 (𝓞 K) := ⟨hP₁, hP₂⟩ have : span {hζ.toInteger - 1} ∈ primesOver 𝒑 (𝓞 K) := ⟨isPrime_span_zeta_sub_one p k hζ, liesOver_span_zeta_sub_one p k hζ⟩ have := ncard_primesOver_of_prime_pow p k K aesop include hK in theorem inertiaDeg_eq_of_prime_pow (P : Ideal (𝓞 K)) [hP₁ : P.IsPrime] [hP₂ : P.LiesOver 𝒑] : inertiaDeg 𝒑 P = 1 := by rw [eq_span_zeta_sub_one_of_liesOver p k K hK.zeta_spec P, inertiaDeg_span_zeta_sub_one] include hK in theorem ramificationIdx_eq_of_prime_pow (P : Ideal (𝓞 K)) [hP₁ : P.IsPrime] [hP₂ : P.LiesOver 𝒑] : ramificationIdx (algebraMap ℤ (𝓞 K)) 𝒑 P = p ^ k * (p - 1) := by rw [eq_span_zeta_sub_one_of_liesOver p k K hK.zeta_spec P, ramificationIdx_span_zeta_sub_one] end PrimePow section Prime variable (p : ℕ) [hp : Fact (Nat.Prime p)] {K : Type*} [Field K] [NumberField K] [hK : IsCyclotomicExtension {p} ℚ K] {ζ : K} (hζ : IsPrimitiveRoot ζ p) local notation3 "𝒑" => (Ideal.span {(p : ℤ)}) instance isPrime_span_zeta_sub_one' : IsPrime (span {hζ.toInteger - 1}) := by rw [← pow_one p] at hK hζ exact isPrime_span_zeta_sub_one p 0 hζ theorem inertiaDeg_span_zeta_sub_one' : inertiaDeg 𝒑 (span {hζ.toInteger - 1}) = 1 := by rw [← pow_one p] at hK hζ exact inertiaDeg_span_zeta_sub_one p 0 hζ theorem ramificationIdx_span_zeta_sub_one' : ramificationIdx (algebraMap ℤ (𝓞 K)) 𝒑 (span {hζ.toInteger - 1}) = p - 1 := by rw [← pow_one p] at hK hζ rw [ramificationIdx_span_zeta_sub_one p 0 hζ, pow_zero, one_mul] variable (K) include hK in theorem ncard_primesOver_of_prime : (primesOver 𝒑 (𝓞 K)).ncard = 1 := by rw [← pow_one p] at hK exact ncard_primesOver_of_prime_pow p 0 K theorem eq_span_zeta_sub_one_of_liesOver' (P : Ideal (𝓞 K)) [hP₁ : P.IsPrime] [hP₂ : P.LiesOver 𝒑] : P = span {hζ.toInteger - 1} := by rw [← pow_one p] at hK hζ exact eq_span_zeta_sub_one_of_liesOver p 0 K hζ P include hK in theorem inertiaDeg_eq_of_prime (P : Ideal (𝓞 K)) [hP₁ : P.IsPrime] [hP₂ : P.LiesOver 𝒑] : inertiaDeg 𝒑 P = 1 := by rw [eq_span_zeta_sub_one_of_liesOver' p K hK.zeta_spec P, inertiaDeg_span_zeta_sub_one'] include hK in theorem ramificationIdx_eq_of_prime (P : Ideal (𝓞 K)) [hP₁ : P.IsPrime] [hP₂ : P.LiesOver 𝒑] : ramificationIdx (algebraMap ℤ (𝓞 K)) 𝒑 P = p - 1 := by rw [eq_span_zeta_sub_one_of_liesOver' p K hK.zeta_spec P, ramificationIdx_span_zeta_sub_one'] end Prime end IsCyclotomicExtension.Rat
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Cyclotomic/Embeddings.lean
import Mathlib.NumberTheory.Cyclotomic.PrimitiveRoots import Mathlib.NumberTheory.NumberField.InfinitePlace.Basic /-! # Cyclotomic extensions of `ℚ` are totally complex number fields. We prove that cyclotomic extensions of `ℚ` are totally complex, meaning that `NrRealPlaces K = 0` if `IsCyclotomicExtension {n} ℚ K` and `2 < n`. ## Main results * `nrRealPlaces_eq_zero`: If `K` is a `n`-th cyclotomic extension of `ℚ`, where `2 < n`, then there are no real places of `K`. -/ universe u namespace IsCyclotomicExtension.Rat open NumberField InfinitePlace Module Complex Nat Polynomial variable {n : ℕ} [NeZero n] (K : Type u) [Field K] [CharZero K] /-- If `K` is a `n`-th cyclotomic extension of `ℚ`, where `2 < n`, then there are no real places of `K`. -/ theorem nrRealPlaces_eq_zero [IsCyclotomicExtension {n} ℚ K] (hn : 2 < n) : haveI := IsCyclotomicExtension.numberField {n} ℚ K nrRealPlaces K = 0 := by have := IsCyclotomicExtension.numberField {n} ℚ K apply (IsCyclotomicExtension.zeta_spec n ℚ K).nrRealPlaces_eq_zero_of_two_lt hn variable (n) /-- If `K` is a `n`-th cyclotomic extension of `ℚ`, then there are `φ n / n` complex places of `K`. Note that this uses `1 / 2 = 0` in the cases `n = 1, 2`. -/ theorem nrComplexPlaces_eq_totient_div_two [h : IsCyclotomicExtension {n} ℚ K] : haveI := IsCyclotomicExtension.numberField {n} ℚ K nrComplexPlaces K = φ n / 2 := by have := IsCyclotomicExtension.numberField {n} ℚ K by_cases hn : 2 < n · obtain ⟨k, hk : φ n = k + k⟩ := totient_even hn have key := card_add_two_mul_card_eq_rank K rw [nrRealPlaces_eq_zero K hn, zero_add, IsCyclotomicExtension.finrank (n := n) K (cyclotomic.irreducible_rat (NeZero.pos _)), hk, ← two_mul, Nat.mul_right_inj (by simp)] at key simp [hk, key, ← two_mul] · have : φ n = 1 := by by_cases h1 : 1 < n · convert totient_two exact (eq_of_le_of_not_lt (succ_le_of_lt h1) hn).symm · convert totient_one exact eq_of_le_of_not_lt (not_lt.mp h1) (by simp [NeZero.ne _]) rw [this] apply nrComplexPlaces_eq_zero_of_finrank_eq_one rw [IsCyclotomicExtension.finrank K (cyclotomic.irreducible_rat (NeZero.pos n)), this] end IsCyclotomicExtension.Rat
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Cyclotomic/Three.lean
import Mathlib.NumberTheory.NumberField.Cyclotomic.Embeddings import Mathlib.NumberTheory.NumberField.Cyclotomic.Basic import Mathlib.NumberTheory.NumberField.Units.DirichletTheorem import Mathlib.RingTheory.Fintype /-! # Third Cyclotomic Field We gather various results about the third cyclotomic field. The following notations are used in this file: `K` is a number field such that `IsCyclotomicExtension {3} ℚ K`, `ζ` is any primitive `3`-rd root of unity in `K`, `η` is the element in the units of the ring of integers corresponding to `ζ` and `λ = η - 1`. ## Main results * `IsCyclotomicExtension.Rat.Three.Units.mem`: Given a unit `u : (𝓞 K)ˣ`, we have that `u ∈ {1, -1, η, -η, η^2, -η^2}`. * `IsCyclotomicExtension.Rat.Three.eq_one_or_neg_one_of_unit_of_congruent`: Given a unit `u : (𝓞 K)ˣ`, if `u` is congruent to an integer modulo `3`, then `u = 1` or `u = -1`. This is a special case of the so-called *Kummer's lemma* (see for example [washington_cyclotomic], Theorem 5.36 -/ open NumberField Units InfinitePlace nonZeroDivisors Polynomial namespace IsCyclotomicExtension.Rat.Three variable {K : Type*} [Field K] variable {ζ : K} (hζ : IsPrimitiveRoot ζ 3) (u : (𝓞 K)ˣ) local notation3 "η" => (IsPrimitiveRoot.isUnit (hζ.toInteger_isPrimitiveRoot) (by decide)).unit local notation3 "λ" => hζ.toInteger - 1 lemma coe_eta : (η : 𝓞 K) = hζ.toInteger := rfl lemma _root_.IsPrimitiveRoot.toInteger_cube_eq_one : hζ.toInteger ^ 3 = 1 := hζ.toInteger_isPrimitiveRoot.pow_eq_one /-- Let `u` be a unit in `(𝓞 K)ˣ`, then `u ∈ [1, -1, η, -η, η^2, -η^2]`. -/ -- Here `List` is more convenient than `Finset`, even if further from the informal statement. -- For example, `fin_cases` below does not work with a `Finset`. theorem Units.mem [NumberField K] [IsCyclotomicExtension {3} ℚ K] : u ∈ [1, -1, η, -η, η ^ 2, -η ^ 2] := by have hrank : rank K = 0 := by dsimp only [rank] rw [card_eq_nrRealPlaces_add_nrComplexPlaces, nrRealPlaces_eq_zero (n := 3) K (by decide), zero_add, nrComplexPlaces_eq_totient_div_two (n := 3)] rfl obtain ⟨⟨x, e⟩, hxu, -⟩ := exist_unique_eq_mul_prod _ u replace hxu : u = x := by rw [← mul_one x.1, hxu] apply congr_arg rw [← Finset.prod_empty] congr rw [Finset.univ_eq_empty_iff, hrank] infer_instance obtain ⟨n, hnpos, hn⟩ := isOfFinOrder_iff_pow_eq_one.1 <| (CommGroup.mem_torsion _ _).1 x.2 replace hn : (↑u : K) ^ ((⟨n, hnpos⟩ : ℕ+) : ℕ) = 1 := by rw [← map_pow] convert map_one (algebraMap (𝓞 K) K) rw_mod_cast [hxu, hn] simp obtain ⟨r, hr3, hru⟩ := hζ.exists_pow_or_neg_mul_pow_of_isOfFinOrder (by decide) (isOfFinOrder_iff_pow_eq_one.2 ⟨n, hnpos, hn⟩) replace hr : r ∈ Finset.Ico 0 3 := Finset.mem_Ico.2 ⟨by simp, hr3⟩ replace hru : ↑u = η ^ r ∨ ↑u = -η ^ r := by rcases hru with h | h · left; ext; exact h · right; ext; exact h fin_cases hr <;> rcases hru with h | h <;> simp [h] /-- We have that `λ ^ 2 = -3 * η`. -/ private lemma lambda_sq : λ ^ 2 = -3 * η := by ext calc (λ ^ 2 : K) = η ^ 2 + η + 1 - 3 * η := by simp only [RingOfIntegers.map_mk, IsUnit.unit_spec]; ring _ = 0 - 3 * η := by simpa using hζ.isRoot_cyclotomic (by decide) _ = -3 * η := by ring /-- We have that `η ^ 2 = -η - 1`. -/ lemma eta_sq : (η ^ 2 : 𝓞 K) = -η - 1 := by rw [← neg_add', ← add_eq_zero_iff_eq_neg, ← add_assoc] ext; simpa using hζ.isRoot_cyclotomic (by decide) /-- If a unit `u` is congruent to an integer modulo `λ ^ 2`, then `u = 1` or `u = -1`. This is a special case of the so-called *Kummer's lemma*. -/ theorem eq_one_or_neg_one_of_unit_of_congruent [NumberField K] [IsCyclotomicExtension {3} ℚ K] (hcong : ∃ n : ℤ, λ ^ 2 ∣ (u - n : 𝓞 K)) : u = 1 ∨ u = -1 := by replace hcong : ∃ n : ℤ, (3 : 𝓞 K) ∣ (↑u - n : 𝓞 K) := by obtain ⟨n, x, hx⟩ := hcong exact ⟨n, -η * x, by rw [← mul_assoc, mul_neg, ← neg_mul, ← lambda_sq, hx]⟩ have hζ := IsCyclotomicExtension.zeta_spec 3 ℚ K have := Units.mem hζ u fin_cases this · left; rfl · right; rfl all_goals exfalso · exact hζ.not_exists_int_prime_dvd_sub_of_prime_ne_two' (by decide) hcong · apply hζ.not_exists_int_prime_dvd_sub_of_prime_ne_two' (by decide) obtain ⟨n, x, hx⟩ := hcong rw [sub_eq_iff_eq_add] at hx refine ⟨-n, -x, sub_eq_iff_eq_add.2 ?_⟩ simp only [Nat.cast_ofNat, mul_neg, Int.cast_neg, ← neg_add, ← hx, Units.val_neg, IsUnit.unit_spec, RingOfIntegers.neg_mk, neg_neg] · exact (hζ.pow_of_coprime 2 (by decide)).not_exists_int_prime_dvd_sub_of_prime_ne_two' (by decide) hcong · apply (hζ.pow_of_coprime 2 (by decide)).not_exists_int_prime_dvd_sub_of_prime_ne_two' (by decide) obtain ⟨n, x, hx⟩ := hcong refine ⟨-n, -x, sub_eq_iff_eq_add.2 ?_⟩ have : (hζ.pow_of_coprime 2 (by decide)).toInteger = hζ.toInteger ^ 2 := by ext; simp simp only [this, Nat.cast_ofNat, mul_neg, Int.cast_neg, ← neg_add, ← sub_eq_iff_eq_add.1 hx, Units.val_neg, val_pow_eq_pow_val, IsUnit.unit_spec, neg_neg] variable (x : 𝓞 K) /-- Let `(x : 𝓞 K)`. Then we have that `λ` divides one amongst `x`, `x - 1` and `x + 1`. -/ lemma lambda_dvd_or_dvd_sub_one_or_dvd_add_one [NumberField K] [IsCyclotomicExtension {3} ℚ K] : λ ∣ x ∨ λ ∣ x - 1 ∨ λ ∣ x + 1 := by classical have := hζ.finite_quotient_toInteger_sub_one (by decide) let _ := Fintype.ofFinite (𝓞 K ⧸ Ideal.span {λ}) let _ : Ring (𝓞 K ⧸ Ideal.span {λ}) := CommRing.toRing -- to speed up instance synthesis let _ : AddGroup (𝓞 K ⧸ Ideal.span {λ}) := AddGroupWithOne.toAddGroup -- ditto have := Finset.mem_univ (Ideal.Quotient.mk (Ideal.span {λ}) x) have h3 : Fintype.card (𝓞 K ⧸ Ideal.span {λ}) = 3 := by rw [← Nat.card_eq_fintype_card, hζ.card_quotient_toInteger_sub_one, hζ.norm_toInteger_sub_one_of_prime_ne_two' (by decide)] simp only [Nat.cast_ofNat, Int.reduceAbs] rw [Finset.univ_of_card_le_three h3.le] at this simp only [Finset.mem_insert, Finset.mem_singleton] at this rcases this with h | h | h · left exact Ideal.mem_span_singleton.1 <| Ideal.Quotient.eq_zero_iff_mem.1 h · right; left refine Ideal.mem_span_singleton.1 <| Ideal.Quotient.eq_zero_iff_mem.1 ?_ rw [RingHom.map_sub, h, RingHom.map_one, sub_self] · right; right refine Ideal.mem_span_singleton.1 <| Ideal.Quotient.eq_zero_iff_mem.1 ?_ rw [RingHom.map_add, h, RingHom.map_one, neg_add_cancel] /-- We have that `η ^ 2 + η + 1 = 0`. -/ lemma eta_sq_add_eta_add_one : (η : 𝓞 K) ^ 2 + η + 1 = 0 := by rw [eta_sq] ring /-- We have that `x ^ 3 - 1 = (x - 1) * (x - η) * (x - η ^ 2)`. -/ lemma cube_sub_one_eq_mul : x ^ 3 - 1 = (x - 1) * (x - η) * (x - η ^ 2) := by symm calc _ = x ^ 3 - x ^ 2 * (η ^ 2 + η + 1) + x * (η ^ 2 + η + η ^ 3) - η ^ 3 := by ring _ = x ^ 3 - x ^ 2 * (η ^ 2 + η + 1) + x * (η ^ 2 + η + 1) - 1 := by simp [hζ.toInteger_cube_eq_one] _ = x ^ 3 - 1 := by rw [eta_sq_add_eta_add_one hζ]; ring variable [NumberField K] [IsCyclotomicExtension {3} ℚ K] /-- We have that `λ` divides `x * (x - 1) * (x - (η + 1))`. -/ lemma lambda_dvd_mul_sub_one_mul_sub_eta_add_one : λ ∣ x * (x - 1) * (x - (η + 1)) := by rcases lambda_dvd_or_dvd_sub_one_or_dvd_add_one hζ x with h | h | h · exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_left h _) _ · exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_right h _) _ · refine dvd_mul_of_dvd_right ?_ _ rw [show x - (η + 1) = x + 1 - (η - 1 + 3) by ring] exact dvd_sub h <| dvd_add dvd_rfl hζ.toInteger_sub_one_dvd_prime' /-- If `λ` divides `x - 1`, then `λ ^ 4` divides `x ^ 3 - 1`. -/ lemma lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one {x : 𝓞 K} (h : λ ∣ x - 1) : λ ^ 4 ∣ x ^ 3 - 1 := by obtain ⟨y, hy⟩ := h have : x ^ 3 - 1 = λ ^ 3 * (y * (y - 1) * (y - (η + 1))) := by calc _ = (x - 1) * (x - 1 - λ) * (x - 1 - λ * (η + 1)) := by simp only [coe_eta, cube_sub_one_eq_mul hζ x]; ring _ = _ := by rw [hy]; ring rw [this, pow_succ] exact mul_dvd_mul_left _ (lambda_dvd_mul_sub_one_mul_sub_eta_add_one hζ y) /-- If `λ` divides `x + 1`, then `λ ^ 4` divides `x ^ 3 + 1`. -/ lemma lambda_pow_four_dvd_cube_add_one_of_dvd_add_one {x : 𝓞 K} (h : λ ∣ x + 1) : λ ^ 4 ∣ x ^ 3 + 1 := by replace h : λ ∣ -x - 1 := by convert h.neg_right using 1 exact (neg_add' x 1).symm convert (lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one hζ h).neg_right using 1 ring /-- If `λ` does not divide `x`, then `λ ^ 4` divides `x ^ 3 - 1` or `x ^ 3 + 1`. -/ lemma lambda_pow_four_dvd_cube_sub_one_or_add_one_of_lambda_not_dvd {x : 𝓞 K} (h : ¬ λ ∣ x) : λ ^ 4 ∣ x ^ 3 - 1 ∨ λ ^ 4 ∣ x ^ 3 + 1 := by rcases lambda_dvd_or_dvd_sub_one_or_dvd_add_one hζ x with H | H | H · contradiction · left exact lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one hζ H · right exact lambda_pow_four_dvd_cube_add_one_of_dvd_add_one hζ H end Three end Rat end IsCyclotomicExtension
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Ideal/Asymptotics.lean
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.NormLeOne import Mathlib.NumberTheory.NumberField.ClassNumber /-! # Asymptotics on integral ideals of a number field We prove several asymptotics involving integral ideals of a number field. ## Main results * `NumberField.ideal.tendsto_norm_le_and_mk_eq_div_atTop`: asymptotics for the number of (nonzero) integral ideals of bounded norm in a fixed class of the class group. * `NumberField.ideal.tendsto_norm_le_div_atTop`: asymptotics for the number of integral ideals of bounded norm. -/ noncomputable section open Ideal variable (K : Type*) [Field K] [NumberField K] namespace NumberField.Ideal open scoped nonZeroDivisors Real open Filter InfinitePlace mixedEmbedding euclidean fundamentalCone Submodule Topology Units variable {C : ClassGroup (𝓞 K)} {J : (Ideal (𝓞 K))⁰} {s : ℝ} private theorem tendsto_norm_le_and_mk_eq_div_atTop_aux₁ (hJ : ClassGroup.mk0 J = C⁻¹) : Nat.card {I : (Ideal (𝓞 K))⁰ // absNorm (I : Ideal (𝓞 K)) ≤ s ∧ ClassGroup.mk0 I = C} = Nat.card {I : (Ideal (𝓞 K))⁰ // (J : Ideal (𝓞 K)) ∣ I ∧ IsPrincipal (I : Ideal (𝓞 K)) ∧ absNorm (I : Ideal (𝓞 K)) ≤ s * absNorm (J : Ideal (𝓞 K))} := by simp_rw [← nonZeroDivisors_dvd_iff_dvd_coe] refine Nat.card_congr ?_ refine ((Equiv.dvd J).subtypeEquiv fun I ↦ ?_).trans (Equiv.subtypeSubtypeEquivSubtypeInter (fun I : (Ideal (𝓞 K))⁰ ↦ J ∣ I) _) rw [← ClassGroup.mk0_eq_one_iff (SetLike.coe_mem _)] simp_rw [Equiv.dvd_apply, Submonoid.coe_mul, ← Submonoid.mul_def, _root_.map_mul, hJ, inv_mul_eq_one, Nat.cast_mul, mul_comm s, eq_comm, and_comm, and_congr_left_iff] exact fun _ ↦ (mul_le_mul_iff_of_pos_left (Nat.cast_pos.mpr (absNorm_pos_of_nonZeroDivisors J))).symm open Classical in private def tendsto_norm_le_and_mk_eq_div_atTop_aux₂ : ↑({x | x ∈ (toMixed K) ⁻¹' fundamentalCone K ∧ mixedEmbedding.norm ((toMixed K) x) ≤ s} ∩ (ZLattice.comap ℝ (idealLattice K ((FractionalIdeal.mk0 K) J)) (toMixed K).toLinearMap)) ≃ {a : idealSet K J // mixedEmbedding.norm (a : mixedSpace K) ≤ s} := by rw [ZLattice.coe_comap] refine (((toMixed K).toEquiv.image _).trans (Equiv.setCongr ?_)).trans (Equiv.subtypeSubtypeEquivSubtypeInter _ (mixedEmbedding.norm · ≤ s)).symm ext simp_rw [mem_idealSet, Set.mem_image, Set.mem_inter_iff, Set.mem_preimage, SetLike.mem_coe, mem_idealLattice, FractionalIdeal.coe_mk0] constructor · rintro ⟨_, ⟨⟨hx₁, hx₂⟩, _, ⟨x, hx₃, rfl⟩, h⟩, rfl⟩ exact ⟨⟨hx₁, x, hx₃, h⟩, hx₂⟩ · rintro ⟨⟨hx₁, ⟨x, hx₂, rfl⟩⟩, hx₃⟩ exact ⟨(toMixed K).symm (mixedEmbedding K x), ⟨⟨hx₁, hx₃⟩, ⟨(x : K), by simp [hx₂], rfl⟩⟩, rfl⟩ variable (C) in /-- The limit of the number of nonzero integral ideals of norm `≤ s` in a fixed class `C` of the class group divided by `s` when `s → +∞`. -/ theorem tendsto_norm_le_and_mk_eq_div_atTop : Tendsto (fun s : ℝ ↦ (Nat.card {I : (Ideal (𝓞 K))⁰ // absNorm (I : Ideal (𝓞 K)) ≤ s ∧ ClassGroup.mk0 I = C} : ℝ) / s) atTop (𝓝 ((2 ^ nrRealPlaces K * (2 * π) ^ nrComplexPlaces K * regulator K) / (torsionOrder K * Real.sqrt |discr K|))) := by classical have h₁ : ∀ s : ℝ, {x | x ∈ toMixed K ⁻¹' fundamentalCone K ∧ mixedEmbedding.norm (toMixed K x) ≤ s} = toMixed K ⁻¹' {x | x ∈ fundamentalCone K ∧ mixedEmbedding.norm x ≤ s} := fun _ ↦ rfl have h₂ : {x | x ∈ fundamentalCone K ∧ mixedEmbedding.norm x ≤ 1} = normLeOne K := by ext; simp obtain ⟨J, hJ⟩ := ClassGroup.mk0_surjective C⁻¹ have h₃ : (absNorm J.1 : ℝ) ≠ 0 := (Nat.cast_ne_zero.mpr (absNorm_ne_zero_of_nonZeroDivisors J)) convert ((ZLattice.covolume.tendsto_card_le_div' (ZLattice.comap ℝ (mixedEmbedding.idealLattice K (FractionalIdeal.mk0 K J)) (toMixed K).toLinearMap) (F := fun x ↦ mixedEmbedding.norm (toMixed K x)) (X := (toMixed K) ⁻¹' (fundamentalCone K)) (fun _ _ _ h ↦ ?_) (fun _ _ h ↦ ?_) ((toMixed K).antilipschitz.isBounded_preimage (isBounded_normLeOne K)) ?_ ?_).mul (tendsto_const_nhds (x := (absNorm (J : Ideal (𝓞 K)) : ℝ) * (torsionOrder K : ℝ)⁻¹))).comp (tendsto_id.atTop_mul_const' <| Nat.cast_pos.mpr (absNorm_pos_of_nonZeroDivisors J)) using 2 with s · simp_rw [Ideal.tendsto_norm_le_and_mk_eq_div_atTop_aux₁ K hJ, id_eq, Nat.card_congr (Ideal.tendsto_norm_le_and_mk_eq_div_atTop_aux₂ K), ← card_isPrincipal_dvd_norm_le, Function.comp_def, Nat.cast_mul, div_eq_mul_inv, mul_inv, ← mul_assoc, mul_comm _ (torsionOrder K : ℝ)⁻¹, mul_comm _ (torsionOrder K : ℝ), mul_assoc] rw [inv_mul_cancel_left₀ (Nat.cast_ne_zero.mpr (torsionOrder_ne_zero K)), inv_mul_cancel₀ h₃, mul_one] · rw [h₁, h₂, MeasureTheory.measureReal_def, (volumePreserving_toMixed K).measure_preimage (measurableSet_normLeOne K).nullMeasurableSet, volume_normLeOne, ZLattice.covolume_comap _ _ _ (volumePreserving_toMixed K), covolume_idealLattice, ENNReal.toReal_mul, ENNReal.toReal_mul, ENNReal.toReal_pow, ENNReal.toReal_pow, ENNReal.toReal_ofNat, ENNReal.coe_toReal, NNReal.coe_real_pi, ENNReal.toReal_ofReal (regulator_pos K).le, FractionalIdeal.coe_mk0, FractionalIdeal.coeIdeal_absNorm, Rat.cast_natCast, div_eq_mul_inv, div_eq_mul_inv, mul_inv, mul_inv, mul_inv, inv_pow, inv_inv] ring_nf rw [mul_inv_cancel_right₀ h₃] · rwa [Set.mem_preimage, map_smul, smul_mem_iff_mem h.ne'] · dsimp only rw [map_smul, mixedEmbedding.norm_smul, euclidean.finrank, abs_of_nonneg h] · exact (toMixed K).continuous.measurable (measurableSet_normLeOne K) · rw [h₁, ← (toMixed K).coe_toHomeomorph, ← Homeomorph.preimage_frontier, (toMixed K).coe_toHomeomorph, (volumePreserving_toMixed K).measure_preimage measurableSet_frontier.nullMeasurableSet, h₂, volume_frontier_normLeOne] /-- The limit of the number of nonzero integral ideals of norm `≤ s` divided by `s` when `s → +∞`. -/ theorem tendsto_norm_le_div_atTop₀ : Tendsto (fun s : ℝ ↦ (Nat.card {I : (Ideal (𝓞 K))⁰ // absNorm (I : Ideal (𝓞 K)) ≤ s} : ℝ) / s) atTop (𝓝 ((2 ^ nrRealPlaces K * (2 * π) ^ nrComplexPlaces K * regulator K * classNumber K) / (torsionOrder K * Real.sqrt |discr K|))) := by classical convert Filter.Tendsto.congr' ?_ (tendsto_finset_sum Finset.univ (fun C _ ↦ tendsto_norm_le_and_mk_eq_div_atTop K C)) · rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, classNumber] ring · filter_upwards [eventually_ge_atTop 0] with s hs have : Fintype {I : (Ideal (𝓞 K))⁰ // absNorm (I : Ideal (𝓞 K)) ≤ s} := by simp_rw [← Nat.le_floor_iff hs] refine @Fintype.ofFinite _ (finite_setOf_absNorm_le₀ ⌊s⌋₊) let e := fun C : ClassGroup (𝓞 K) ↦ Equiv.subtypeSubtypeEquivSubtypeInter (fun I : (Ideal (𝓞 K))⁰ ↦ absNorm I.1 ≤ s) (fun I ↦ ClassGroup.mk0 I = C) simp_rw [← Nat.card_congr (e _), Nat.card_eq_fintype_card, Fintype.subtype_card] rw [Fintype.card, Finset.card_eq_sum_card_fiberwise (f := fun I ↦ ClassGroup.mk0 I.1) (t := Finset.univ) (fun _ _ ↦ Finset.mem_univ _), Nat.cast_sum, Finset.sum_div] /-- The limit of the number of integral ideals of norm `≤ s` divided by `s` when `s → +∞`. -/ theorem tendsto_norm_le_div_atTop : Tendsto (fun s : ℝ ↦ (Nat.card {I : Ideal (𝓞 K) // absNorm I ≤ s} : ℝ) / s) atTop (𝓝 ((2 ^ nrRealPlaces K * (2 * π) ^ nrComplexPlaces K * regulator K * classNumber K) / (torsionOrder K * Real.sqrt |discr K|))) := by have := (tendsto_norm_le_div_atTop₀ K).add tendsto_inv_atTop_zero rw [add_zero] at this apply this.congr' filter_upwards [eventually_ge_atTop 0] with s hs simp_rw [← Nat.le_floor_iff hs] rw [Ideal.card_norm_le_eq_card_norm_le_add_one, Nat.cast_add, Nat.cast_one, add_div, one_div] end NumberField.Ideal
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Ideal/KummerDedekind.lean
import Mathlib.NumberTheory.KummerDedekind import Mathlib.NumberTheory.NumberField.Basic import Mathlib.NumberTheory.RamificationInertia.Basic import Mathlib.RingTheory.Ideal.Int /-! # Kummer-Dedekind criterion for the splitting of prime numbers In this file, we give a specialized version of the Kummer-Dedekind criterion for the case of the splitting of rational primes in number fields. ## Main definitions Let `K` be a number field and `θ` an algebraic integer of `K`. * `RingOfIntegers.exponent`: the smallest positive integer `d` contained in the conductor of `θ`. It is the smallest integer such that `d • 𝓞 K ⊆ ℤ[θ]`, see `RingOfIntegers.exponent_eq_sInf`. * `RingOfIntegers.ZModXQuotSpanEquivQuotSpan`: The isomorphism between `(ℤ / pℤ)[X] / (minpoly θ)` and `𝓞 K / p(𝓞 K)` for a prime `p` which doesn't divide the exponent of `θ`. * `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod`: The bijection between the prime ideals of `K` above `p` and the monic irreducible factors of `minpoly ℤ θ` modulo `p` for a prime `p` which doesn't divide the exponent of `θ`. ## Main results * `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod`: The ideal corresponding to the class of `Q ∈ ℤ[X]` modulo `p` via `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod` is spanned by `p` and `Q(θ)`. * `NumberField.Ideal.inertiaDeg_primesOverSpanEquivMonicFactorsMod_symm_apply`: The residual degree of the ideal corresponding to the class of `Q ∈ ℤ[X]` modulo `p` via `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod` is equal to the degree of `Q mod p`. * `NumberField.Ideal.ramificationIdx_primesOverSpanEquivMonicFactorsMod_symm_apply`: The ramification index of the ideal corresponding to the class of `Q ∈ ℤ[X]` modulo `p` via `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod` is equal to the multiplicity of `Q mod p` in `minpoly ℤ θ`. -/ noncomputable section open Polynomial NumberField Ideal KummerDedekind UniqueFactorizationMonoid variable {K : Type*} [Field K] namespace RingOfIntegers /-- The smallest positive integer `d` contained in the conductor of `θ`. It is the smallest integer such that `d • 𝓞 K ⊆ ℤ[θ]`, see `exponent_eq_sInf`. It is set to `0` if `d` does not exists. -/ def exponent (θ : 𝓞 K) : ℕ := absNorm (under ℤ (conductor ℤ θ)) variable {θ : 𝓞 K} theorem exponent_eq_one_iff : exponent θ = 1 ↔ Algebra.adjoin ℤ {θ} = ⊤ := by rw [exponent, absNorm_eq_one_iff, comap_eq_top_iff, conductor_eq_top_iff_adjoin_eq_top] theorem not_dvd_exponent_iff {p : ℕ} [Fact (Nat.Prime p)] : ¬ p ∣ exponent θ ↔ Codisjoint (comap (algebraMap ℤ (𝓞 K)) (conductor ℤ θ)) (span {↑p}) := by rw [codisjoint_comm, ← IsCoatom.not_le_iff_codisjoint, ← under_def, ← Ideal.dvd_iff_le, ← Int.ideal_span_absNorm_eq_self (under ℤ (conductor ℤ θ)), span_singleton_dvd_span_singleton_iff_dvd, Int.natCast_dvd_natCast, exponent] exact isMaximal_def.mp <| Int.ideal_span_isMaximal_of_prime p theorem exponent_eq_sInf : exponent θ = sInf {d : ℕ | 0 < d ∧ (d : 𝓞 K) ∈ conductor ℤ θ} := by rw [exponent, Int.absNorm_under_eq_sInf] variable [NumberField K] {θ : 𝓞 K} {p : ℕ} [Fact p.Prime] /-- If `p` doesn't divide the exponent of `θ`, then `(ℤ / pℤ)[X] / (minpoly θ) ≃+* 𝓞 K / p(𝓞 K)`. -/ def ZModXQuotSpanEquivQuotSpan (hp : ¬ p ∣ exponent θ) : (ZMod p)[X] ⧸ span {map (Int.castRingHom (ZMod p)) (minpoly ℤ θ)} ≃+* 𝓞 K ⧸ span {(p : 𝓞 K)} := (quotientEquivAlgOfEq ℤ (by simp [Ideal.map_span, Polynomial.map_map])).toRingEquiv.trans ((quotientEquiv _ _ (mapEquiv (Int.quotientSpanNatEquivZMod p)) rfl).symm.trans ((quotMapEquivQuotQuotMap (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral).symm.trans (quotientEquivAlgOfEq ℤ (by simp [map_span])).toRingEquiv)) theorem ZModXQuotSpanEquivQuotSpan_mk_apply (hp : ¬ p ∣ exponent θ) (Q : ℤ[X]) : (ZModXQuotSpanEquivQuotSpan hp) (Ideal.Quotient.mk (span {map (Int.castRingHom (ZMod p)) (minpoly ℤ θ)}) (map (Int.castRingHom (ZMod p)) Q)) = Ideal.Quotient.mk (span {(p : 𝓞 K)}) (aeval θ Q) := by simp only [ZModXQuotSpanEquivQuotSpan, AlgEquiv.toRingEquiv_eq_coe, algebraMap_int_eq, RingEquiv.trans_apply, AlgEquiv.coe_ringEquiv, quotientEquivAlgOfEq_mk, quotientEquiv_symm_apply, quotientMap_mk, RingHom.coe_coe, mapEquiv_symm_apply, Polynomial.map_map, Int.quotientSpanNatEquivZMod_comp_castRingHom] exact congr_arg (quotientEquivAlgOfEq ℤ (by simp [map_span])) <| quotMapEquivQuotQuotMap_symm_apply (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral Q variable (p θ) in /-- The finite set of monic irreducible factors of `minpoly ℤ θ` modulo `p`. -/ abbrev monicFactorsMod : Finset ((ZMod p)[X]) := (normalizedFactors (map (Int.castRingHom (ZMod p)) (minpoly ℤ θ))).toFinset /-- If `p` does not divide `exponent θ` and `Q` is a lift of a monic irreducible factor of `minpoly ℤ θ` modulo `p`, then `(ℤ / pℤ)[X] / Q ≃+* 𝓞 K / (p, Q(θ))`. -/ def ZModXQuotSpanEquivQuotSpanPair (hp : ¬ p ∣ exponent θ) {Q : ℤ[X]} (hQ : Q.map (Int.castRingHom (ZMod p)) ∈ monicFactorsMod θ p) : (ZMod p)[X] ⧸ span {Polynomial.map (Int.castRingHom (ZMod p)) Q} ≃+* 𝓞 K ⧸ span {(p : 𝓞 K), (aeval θ) Q} := have h₀ : map (Int.castRingHom (ZMod p)) (minpoly ℤ θ) ≠ 0 := map_monic_ne_zero (minpoly.monic θ.isIntegral) have h_eq₁ : span {map (Int.castRingHom (ZMod p)) Q} = span {map (Int.castRingHom (ZMod p)) (minpoly ℤ θ)} ⊔ span {map (Int.castRingHom (ZMod p)) Q} := by rw [← span_insert, span_pair_comm, span_pair_eq_span_left_iff_dvd.mpr] simp only [Multiset.mem_toFinset] at hQ exact ((Polynomial.mem_normalizedFactors_iff h₀).mp hQ).2.2 have h_eq₂ : span {↑p} ⊔ span {(aeval θ) Q} = span {↑p, (aeval θ) Q} := by rw [span_insert] ((Ideal.quotEquivOfEq h_eq₁).trans (DoubleQuot.quotQuotEquivQuotSup _ _).symm).trans <| (Ideal.quotientEquiv (Ideal.map (Ideal.Quotient.mk _) (span {(Polynomial.map (Int.castRingHom (ZMod p)) Q)})) (Ideal.map (Ideal.Quotient.mk _) (span {aeval θ Q})) (ZModXQuotSpanEquivQuotSpan hp) (by simp [map_span, ZModXQuotSpanEquivQuotSpan_mk_apply])).trans <| (DoubleQuot.quotQuotEquivQuotSup _ _).trans (Ideal.quotEquivOfEq h_eq₂) end RingOfIntegers open RingOfIntegers IsDedekindDomain namespace NumberField.Ideal variable {θ : 𝓞 K} {p : ℕ} [Fact (Nat.Prime p)] attribute [local instance] Int.ideal_span_isMaximal_of_prime Ideal.Quotient.field open scoped Classical in private def primesOverSpanEquivMonicFactorsModAux (A : ℤ[X]) : {Q // Q ∈ normalizedFactors (map (Ideal.Quotient.mk (span {(p : ℤ)})) A)} ≃ (normalizedFactors (map (Int.castRingHom (ZMod p)) A)).toFinset := (normalizedFactorsEquiv (f := (mapEquiv (Int.quotientSpanNatEquivZMod p)).toMulEquiv) (by simp) (map (Ideal.Quotient.mk (span {(p : ℤ)})) A)).trans (Equiv.subtypeEquivRight (fun _ ↦ by simp [Polynomial.map_map])) private theorem primesOverSpanEquivMonicFactorsModAux_symm_apply (A : ℤ[X]) {Q : (ZMod p)[X]} (hQ : Q ∈ (normalizedFactors (map (Int.castRingHom (ZMod p)) A)).toFinset) : ((primesOverSpanEquivMonicFactorsModAux A).symm ⟨Q, hQ⟩ : (ℤ ⧸ span {(p : ℤ)})[X]) = Polynomial.map ((Int.quotientSpanNatEquivZMod p).symm) Q := rfl variable [NumberField K] /-- If `p` does not divide `exponent θ`, then the prime ideals above `p` in `K` are in bijection with the monic irreducible factors of `minpoly ℤ θ` modulo `p`. -/ def primesOverSpanEquivMonicFactorsMod (hp : ¬ p ∣ exponent θ) : primesOver (span {(p : ℤ)}) (𝓞 K) ≃ monicFactorsMod θ p := have h : span {(p : ℤ)} ≠ ⊥ := by simp [NeZero.ne p] ((Equiv.setCongr (by ext; simp [mem_primesOver_iff_mem_normalizedFactors _ h])).trans (normalizedFactorsMapEquivNormalizedFactorsMinPolyMk (Int.ideal_span_isMaximal_of_prime p) h (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral)).trans <| (primesOverSpanEquivMonicFactorsModAux _) theorem primesOverSpanEquivMonicFactorsMod_symm_apply (hp : ¬ p ∣ exponent θ) {Q : (ZMod p)[X]} (hQ : Q ∈ monicFactorsMod θ p) : ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨Q, hQ⟩ : Ideal (𝓞 K)) = (normalizedFactorsMapEquivNormalizedFactorsMinPolyMk inferInstance (by simp [NeZero.ne p]) (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral).symm ⟨Q.map (Int.quotientSpanNatEquivZMod p).symm, by rw [← primesOverSpanEquivMonicFactorsModAux_symm_apply] exact ((primesOverSpanEquivMonicFactorsModAux _).symm ⟨Q, hQ⟩).coe_prop⟩ := rfl /-- The ideal corresponding to the class of `Q ∈ ℤ[X]` modulo `p` via `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod` is spanned by `p` and `Q(θ)`. -/ theorem primesOverSpanEquivMonicFactorsMod_symm_apply_eq_span (hp : ¬ p ∣ exponent θ) {Q : ℤ[X]} (hQ : Q.map (Int.castRingHom (ZMod p)) ∈ monicFactorsMod θ p) : ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨Q.map (Int.castRingHom (ZMod p)), hQ⟩ : Ideal (𝓞 K)) = span {(p : (𝓞 K)), aeval θ Q} := by simp only [primesOverSpanEquivMonicFactorsMod_symm_apply, Polynomial.map_map, Int.quotientSpanNatEquivZMod_comp_castRingHom] rw [normalizedFactorsMapEquivNormalizedFactorsMinPolyMk_symm_apply_eq_span, span_union, span_eq, map_span, Set.image_singleton, map_natCast, ← span_insert] theorem liesOver_primesOverSpanEquivMonicFactorsMod_symm (hp : ¬ p ∣ exponent θ) {Q : ℤ[X]} (hQ : Q.map (Int.castRingHom (ZMod p)) ∈ monicFactorsMod θ p) : LiesOver (span {(p : (𝓞 K)), aeval θ Q}) (span {(p : ℤ)}) := by rw [← Ideal.primesOverSpanEquivMonicFactorsMod_symm_apply_eq_span hp hQ] exact ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨_, hQ⟩).prop.2 /-- The residual degree of the ideal corresponding to the class of `Q ∈ ℤ[X]` modulo `p` via `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod` is equal to the degree of `Q mod p`. -/ theorem inertiaDeg_primesOverSpanEquivMonicFactorsMod_symm_apply (hp : ¬ p ∣ exponent θ) {Q : ℤ[X]} (hQ : Q.map (Int.castRingHom (ZMod p)) ∈ monicFactorsMod θ p) : inertiaDeg (span {(p : ℤ)}) ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨Q.map (Int.castRingHom (ZMod p)), hQ⟩ : Ideal (𝓞 K)) = natDegree (Q.map (Int.castRingHom (ZMod p))) := by -- This is needed for `inertiaDeg_algebraMap` below to work have := liesOver_primesOverSpanEquivMonicFactorsMod_symm hp hQ rw [primesOverSpanEquivMonicFactorsMod_symm_apply_eq_span, inertiaDeg_algebraMap, ← finrank_quotient_span_eq_natDegree] refine Algebra.finrank_eq_of_equiv_equiv (Int.quotientSpanNatEquivZMod p) ?_ (by ext; simp) exact (ZModXQuotSpanEquivQuotSpanPair hp hQ).symm theorem inertiaDeg_primesOverSpanEquivMonicFactorsMod_symm_apply' (hp : ¬ p ∣ exponent θ) {Q : (ZMod p)[X]} (hQ : Q ∈ monicFactorsMod θ p) : inertiaDeg (span {(p : ℤ)}) ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨Q, hQ⟩ : Ideal (𝓞 K)) = natDegree Q := by obtain ⟨S, rfl⟩ := (map_surjective _ (ZMod.ringHom_surjective (Int.castRingHom (ZMod p)))) Q rw [inertiaDeg_primesOverSpanEquivMonicFactorsMod_symm_apply] /-- The ramification index of the ideal corresponding to the class of `Q ∈ ℤ[X]` modulo `p` via `NumberField.Ideal.primesOverSpanEquivMonicFactorsMod` is equal to the multiplicity of `Q mod p` in `minpoly ℤ θ`. -/ theorem ramificationIdx_primesOverSpanEquivMonicFactorsMod_symm_apply (hp : ¬ p ∣ exponent θ) {Q : ℤ[X]} (hQ : Q.map (Int.castRingHom (ZMod p)) ∈ monicFactorsMod θ p) : ramificationIdx (algebraMap ℤ (𝓞 K)) (span {(p : ℤ)}) ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨Q.map (Int.castRingHom (ZMod p)), hQ⟩ : Ideal (𝓞 K)) = multiplicity (Q.map (Int.castRingHom (ZMod p))) ((minpoly ℤ θ).map (Int.castRingHom (ZMod p))) := by rw [ramificationIdx_eq_multiplicity (map_ne_bot_of_ne_bot (by simp [NeZero.ne p])) inferInstance] · apply multiplicity_eq_of_emultiplicity_eq rw [← emultiplicity_map_eq (mapEquiv (Int.quotientSpanNatEquivZMod p).symm), emultiplicity_factors_map_eq_emultiplicity inferInstance (by simp [NeZero.ne p]) (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral] · simp only [primesOverSpanEquivMonicFactorsMod_symm_apply, Equiv.apply_symm_apply (normalizedFactorsMapEquivNormalizedFactorsMinPolyMk _ _ _ _), Polynomial.map_map, Int.quotientSpanNatEquivZMod_comp_castRingHom, mapEquiv_apply] · rw [← mem_primesOver_iff_mem_normalizedFactors _ (by simp [NeZero.ne p])] exact ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨_, hQ⟩).coe_prop theorem ramificationIdx_primesOverSpanEquivMonicFactorsMod_symm_apply' (hp : ¬ p ∣ exponent θ) {Q : (ZMod p)[X]} (hQ : Q ∈ monicFactorsMod θ p) : ramificationIdx (algebraMap ℤ (𝓞 K)) (span {(p : ℤ)}) ((primesOverSpanEquivMonicFactorsMod hp).symm ⟨Q, hQ⟩ : Ideal (𝓞 K)) = multiplicity Q ((minpoly ℤ θ).map (Int.castRingHom (ZMod p))) := by obtain ⟨S, rfl⟩ := (map_surjective _ (ZMod.ringHom_surjective (Int.castRingHom (ZMod p)))) Q rw [ramificationIdx_primesOverSpanEquivMonicFactorsMod_symm_apply] end NumberField.Ideal
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Ideal/Basic.lean
import Mathlib.NumberTheory.NumberField.Cyclotomic.Basic import Mathlib.NumberTheory.NumberField.Units.Basic /-! # Basic results on integral ideals of a number field We study results about integral ideals of a number field `K`. ## Main definitions and results * `Ideal.torsionMapQuot`: For `I` an integral ideal, the group morphism from the torsion of `K` to `(𝓞 K ⧸ I)ˣ`. * `Ideal.torsionMapQuot_injective`: If the ideal `I` is nontrivial and its norm is coprime with the order of the torsion of `K`, then the map `Ideal.torsionMapQuot` is injective. * `NumberField.torsionOrder_dvd_absNorm_sub_one`: If the norm of the (nonzero) prime ideal `P` is coprime with the order of the torsion of `K`, then the norm of `P` is congruent to `1` modulo `torsionOrder K`. -/ section torsionMapQuot open Ideal NumberField Units variable {K : Type*} [Field K] {I : Ideal (𝓞 K)} theorem IsPrimitiveRoot.not_coprime_norm_of_mk_eq_one [NumberField K] (hI : absNorm I ≠ 1) {n : ℕ} {ζ : K} (hn : 2 ≤ n) (hζ : IsPrimitiveRoot ζ n) (h : let _ : NeZero n := NeZero.of_gt hn; Ideal.Quotient.mk I hζ.toInteger = 1) : ¬ (absNorm I).Coprime n := by intro h₁ rw [← RingHom.map_one (Ideal.Quotient.mk I), Ideal.Quotient.eq] at h obtain ⟨p, hp, h₂⟩ := Nat.exists_prime_and_dvd hI have : Fact (p.Prime) := ⟨hp⟩ refine hp.not_dvd_one <| h₁ ▸ Nat.dvd_gcd h₂ ?_ exact hζ.prime_dvd_of_dvd_norm_sub_one hn <| Int.dvd_trans (Int.natCast_dvd_natCast.mpr h₂) (absNorm_dvd_norm_of_mem h) variable (I) /-- For `I` an integral ideal of `K`, the group morphism from the torsion of `K` to `(𝓞 K ⧸ I)ˣ`. -/ def Ideal.torsionMapQuot : (Units.torsion K) →* ((𝓞 K) ⧸ I)ˣ := (Units.map (Ideal.Quotient.mk I).toMonoidHom).restrict (torsion K) @[simp] theorem Ideal.torsionMapQuot_apply {x : (𝓞 K)ˣ} (hx : x ∈ torsion K) : torsionMapQuot I ⟨x, hx⟩ = Ideal.Quotient.mk I x := rfl variable {I} [NumberField K] theorem Ideal.torsionMapQuot_injective (hI₁ : absNorm I ≠ 1) (hI₂ : (absNorm I).Coprime (torsionOrder K)) : Function.Injective (torsionMapQuot I) := by refine (injective_iff_map_eq_one _).mpr fun ⟨ζ, hζ⟩ h ↦ ?_ rw [← rootsOfUnity_eq_torsion] at hζ obtain ⟨t, ht₀, ht, hζ⟩ := isPrimitiveRoot_of_mem_rootsOfUnity hζ suffices ¬ (2 ≤ t) by simpa [show t = 1 by grind] using hζ intro ht' let μ : K := ζ.val have hμ : IsPrimitiveRoot μ t := (IsPrimitiveRoot.coe_units_iff.mpr hζ).map_of_injective RingOfIntegers.coe_injective rw [Units.ext_iff, torsionMapQuot_apply, Units.val_one] at h refine hμ.not_coprime_norm_of_mk_eq_one hI₁ ht' h ?_ exact Nat.dvd_one.mp (hI₂ ▸ Nat.gcd_dvd_gcd_of_dvd_right (absNorm I) ht) /-- If the norm of the (nonzero) prime ideal `P` is coprime with the order of the torsion of `K`, then the norm of `P` is congruent to `1` modulo `torsionOrder K`. -/ theorem NumberField.torsionOrder_dvd_absNorm_sub_one {P : Ideal (𝓞 K)} (hP₀ : P ≠ ⊥) (hP₁ : P.IsPrime) (hP₂ : (absNorm P).Coprime (torsionOrder K)) : torsionOrder K ∣ absNorm P - 1 := by have : P.IsMaximal := Ring.DimensionLEOne.maximalOfPrime hP₀ hP₁ let _ := Ideal.Quotient.field P have hP₃ : absNorm P ≠ 1 := absNorm_eq_one_iff.not.mpr <| IsPrime.ne_top hP₁ have h := Subgroup.card_dvd_of_injective _ (torsionMapQuot_injective hP₃ hP₂) rwa [Nat.card_eq_fintype_card, Nat.card_units] at h end torsionMapQuot
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/InfinitePlace/Completion.lean
import Mathlib.Analysis.Normed.Field.WithAbs import Mathlib.NumberTheory.NumberField.InfinitePlace.Basic /-! # The completion of a number field at an infinite place This file contains the completion of a number field at an infinite place. This is ultimately achieved by applying the `UniformSpace.Completion` functor, however each infinite place induces its own `UniformSpace` instance on the number field, so the inference system cannot automatically infer these. A common approach to handle the ambiguity that arises from having multiple sources of instances is through the use of type synonyms. In this case, we use the type synonym `WithAbs` of a semiring. In particular this type synonym depends on an absolute value, which provides a systematic way of assigning and inferring instances of the semiring that also depend on an absolute value. The completion of a field at multiple absolute values is defined in `Mathlib/Algebra/Ring/WithAbs.lean` as `AbsoluteValue.Completion`. The completion of a number field at an infinite place is then derived in this file, as `InfinitePlace` is a subtype of `AbsoluteValue`. ## Main definitions - `NumberField.InfinitePlace.Completion` : the completion of a number field `K` at an infinite place, obtained by completing `K` with respect to the absolute value associated to the infinite place. - `NumberField.InfinitePlace.Completion.extensionEmbedding` : the embedding `v.embedding : K →+* ℂ` extended to `v.Completion →+* ℂ`. - `NumberField.InfinitePlace.Completion.extensionEmbeddingOfIsReal` : if the infinite place `v` is real, then this extends the embedding `v.embedding_of_isReal : K →+* ℝ` to `v.Completion →+* ℝ`. - `NumberField.InfinitePlace.Completion.ringEquivRealOfIsReal` : the ring isomorphism `v.Completion ≃+* ℝ` when `v` is a real infinite place; the forward direction of this is `extensionEmbeddingOfIsReal`. - `NumberField.InfinitePlace.Completion.ringEquivComplexOfIsComplex` : the ring isomorphism `v.Completion ≃+* ℂ` when `v` is a complex infinite place; the forward direction of this is `extensionEmbedding`. ## Main results - `NumberField.Completion.locallyCompactSpace` : the completion of a number field at an infinite place is locally compact. - `NumberField.Completion.isometry_extensionEmbedding` : the embedding `v.Completion →+* ℂ` is an isometry. See also `isometry_extensionEmbeddingOfIsReal` for the corresponding result on `v.Completion →+* ℝ` when `v` is real. - `NumberField.Completion.bijective_extensionEmbedding_of_isComplex` : the embedding `v.Completion →+* ℂ` is bijective when `v` is complex. See also `bijective_extensionEmbeddingOfIsReal` for the corresponding result for `v.Completion →+* ℝ` when `v` is real. ## Tags number field, embeddings, infinite places, completion, absolute value -/ noncomputable section namespace NumberField.InfinitePlace open AbsoluteValue.Completion variable {K : Type*} [Field K] (v : InfinitePlace K) /-- The completion of a number field at an infinite place. -/ abbrev Completion := v.1.Completion namespace Completion instance : NormedField v.Completion := letI := (WithAbs.isUniformInducing_of_comp v.norm_embedding_eq).completableTopField UniformSpace.Completion.instNormedFieldOfCompletableTopField (WithAbs v.1) lemma norm_coe (x : WithAbs v.1) : ‖(x : v.Completion)‖ = v (WithAbs.equiv v.1 x) := UniformSpace.Completion.norm_coe x instance : Algebra K v.Completion := inferInstanceAs <| Algebra (WithAbs v.1) v.1.Completion /-- The coercion from the rationals to its completion along an infinite place is `Rat.cast`. -/ lemma WithAbs.ratCast_equiv (v : InfinitePlace ℚ) (x : WithAbs v.1) : Rat.cast (WithAbs.equiv _ x) = (x : v.Completion) := (eq_ratCast (UniformSpace.Completion.coeRingHom.comp (WithAbs.equiv v.1).symm.toRingHom) x).symm lemma Rat.norm_infinitePlace_completion (v : InfinitePlace ℚ) (x : ℚ) : ‖(x : v.Completion)‖ = |x| := by rw [← (WithAbs.equiv v.1).apply_symm_apply x, WithAbs.ratCast_equiv, norm_coe, (WithAbs.equiv v.1).apply_symm_apply, Rat.infinitePlace_apply] /-- The completion of a number field at an infinite place is locally compact. -/ instance locallyCompactSpace : LocallyCompactSpace (v.Completion) := AbsoluteValue.Completion.locallyCompactSpace v.norm_embedding_eq /-- The embedding associated to an infinite place extended to an embedding `v.Completion →+* ℂ`. -/ def extensionEmbedding : v.Completion →+* ℂ := extensionEmbedding_of_comp v.norm_embedding_eq /-- The embedding `K →+* ℝ` associated to a real infinite place extended to `v.Completion →+* ℝ`. -/ def extensionEmbeddingOfIsReal {v : InfinitePlace K} (hv : IsReal v) : v.Completion →+* ℝ := extensionEmbedding_of_comp <| v.norm_embedding_of_isReal hv @[simp] theorem extensionEmbedding_coe (x : K) : extensionEmbedding v x = v.embedding x := extensionEmbedding_of_comp_coe v.norm_embedding_eq x @[simp] theorem extensionEmbeddingOfIsReal_coe {v : InfinitePlace K} (hv : IsReal v) (x : K) : extensionEmbeddingOfIsReal hv x = embedding_of_isReal hv x := extensionEmbedding_of_comp_coe (v.norm_embedding_of_isReal hv) x @[deprecated (since := "2025-09-24")] alias extensionEmbedding_of_isReal_coe := extensionEmbeddingOfIsReal_coe /-- The embedding `v.Completion →+* ℂ` is an isometry. -/ theorem isometry_extensionEmbedding : Isometry (extensionEmbedding v) := Isometry.of_dist_eq (extensionEmbedding_dist_eq_of_comp v.norm_embedding_eq) /-- The embedding `v.Completion →+* ℝ` at a real infinite place is an isometry. -/ theorem isometry_extensionEmbeddingOfIsReal {v : InfinitePlace K} (hv : IsReal v) : Isometry (extensionEmbeddingOfIsReal hv) := Isometry.of_dist_eq (extensionEmbedding_dist_eq_of_comp <| v.norm_embedding_of_isReal hv) @[deprecated (since := "2025-09-24")] alias isometry_extensionEmbedding_of_isReal := isometry_extensionEmbeddingOfIsReal /-- The embedding `v.Completion →+* ℂ` has closed image inside `ℂ`. -/ theorem isClosed_image_extensionEmbedding : IsClosed (Set.range (extensionEmbedding v)) := (isClosedEmbedding_extensionEmbedding_of_comp v.norm_embedding_eq).isClosed_range /-- The embedding `v.Completion →+* ℝ` associated to a real infinite place has closed image inside `ℝ`. -/ theorem isClosed_image_extensionEmbeddingOfIsReal {v : InfinitePlace K} (hv : IsReal v) : IsClosed (Set.range (extensionEmbeddingOfIsReal hv)) := (isClosedEmbedding_extensionEmbedding_of_comp <| v.norm_embedding_of_isReal hv).isClosed_range @[deprecated (since := "2025-09-24")] alias isClosed_image_extensionEmbedding_of_isReal := isClosed_image_extensionEmbeddingOfIsReal theorem subfield_ne_real_of_isComplex {v : InfinitePlace K} (hv : IsComplex v) : (extensionEmbedding v).fieldRange ≠ Complex.ofRealHom.fieldRange := by contrapose! hv simp only [not_isComplex_iff_isReal, isReal_iff] ext x obtain ⟨r, hr⟩ := hv ▸ extensionEmbedding_coe v x ▸ RingHom.mem_fieldRange_self _ _ simp only [ComplexEmbedding.conjugate_coe_eq, ← hr, Complex.ofRealHom_eq_coe, Complex.conj_ofReal] /-- If `v` is a complex infinite place, then the embedding `v.Completion →+* ℂ` is surjective. -/ theorem surjective_extensionEmbedding_of_isComplex {v : InfinitePlace K} (hv : IsComplex v) : Function.Surjective (extensionEmbedding v) := by rw [← RingHom.fieldRange_eq_top_iff] exact (Complex.subfield_eq_of_closed <| isClosed_image_extensionEmbedding v).resolve_left <| subfield_ne_real_of_isComplex hv /-- If `v` is a complex infinite place, then the embedding `v.Completion →+* ℂ` is bijective. -/ theorem bijective_extensionEmbedding_of_isComplex {v : InfinitePlace K} (hv : IsComplex v) : Function.Bijective (extensionEmbedding v) := ⟨(extensionEmbedding v).injective, surjective_extensionEmbedding_of_isComplex hv⟩ /-- The ring isomorphism `v.Completion ≃+* ℂ`, when `v` is complex, given by the bijection `v.Completion →+* ℂ`. -/ def ringEquivComplexOfIsComplex {v : InfinitePlace K} (hv : IsComplex v) : v.Completion ≃+* ℂ := RingEquiv.ofBijective _ (bijective_extensionEmbedding_of_isComplex hv) /-- If the infinite place `v` is complex, then `v.Completion` is isometric to `ℂ`. -/ def isometryEquivComplexOfIsComplex {v : InfinitePlace K} (hv : IsComplex v) : v.Completion ≃ᵢ ℂ where toEquiv := ringEquivComplexOfIsComplex hv isometry_toFun := isometry_extensionEmbedding v /-- If `v` is a real infinite place, then the embedding `v.Completion →+* ℝ` is surjective. -/ theorem surjective_extensionEmbeddingOfIsReal {v : InfinitePlace K} (hv : IsReal v) : Function.Surjective (extensionEmbeddingOfIsReal hv) := by rw [← RingHom.fieldRange_eq_top_iff, ← Real.subfield_eq_of_closed] exact isClosed_image_extensionEmbeddingOfIsReal hv @[deprecated (since := "2025-09-24")] alias surjective_extensionEmbedding_of_isReal := surjective_extensionEmbeddingOfIsReal /-- If `v` is a real infinite place, then the embedding `v.Completion →+* ℝ` is bijective. -/ theorem bijective_extensionEmbeddingOfIsReal {v : InfinitePlace K} (hv : IsReal v) : Function.Bijective (extensionEmbeddingOfIsReal hv) := ⟨(extensionEmbeddingOfIsReal hv).injective, surjective_extensionEmbeddingOfIsReal hv⟩ @[deprecated (since := "2025-09-24")] alias bijective_extensionEmbedding_of_isReal := bijective_extensionEmbeddingOfIsReal /-- The ring isomorphism `v.Completion ≃+* ℝ`, when `v` is real, given by the bijection `v.Completion →+* ℝ`. -/ def ringEquivRealOfIsReal {v : InfinitePlace K} (hv : IsReal v) : v.Completion ≃+* ℝ := RingEquiv.ofBijective _ (bijective_extensionEmbeddingOfIsReal hv) /-- If the infinite place `v` is real, then `v.Completion` is isometric to `ℝ`. -/ def isometryEquivRealOfIsReal {v : InfinitePlace K} (hv : IsReal v) : v.Completion ≃ᵢ ℝ where toEquiv := ringEquivRealOfIsReal hv isometry_toFun := isometry_extensionEmbeddingOfIsReal hv end NumberField.InfinitePlace.Completion
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/InfinitePlace/Basic.lean
import Mathlib.NumberTheory.NumberField.InfinitePlace.Embeddings import Mathlib.NumberTheory.NumberField.Norm import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots import Mathlib.Topology.Instances.Complex /-! # Infinite places of a number field This file defines the infinite places of a number field. ## Main Definitions and Results * `NumberField.InfinitePlace`: the type of infinite places of a number field `K`. * `NumberField.InfinitePlace.mk_eq_iff`: two complex embeddings define the same infinite place iff they are equal or complex conjugates. * `NumberField.InfinitePlace.IsReal`: The predicate on infinite places saying that a place is real, i.e., defined by a real embedding. * `NumberField.InfinitePlace.IsComplex`: The predicate on infinite places saying that a place is complex, i.e., defined by a complex embedding that is not real. * `NumberField.InfinitePlace.mult`: the multiplicity of an infinite place, that is the number of distinct complex embeddings that define it. So it is equal to `1` if the place is real and `2` if the place is complex. * `NumberField.InfinitePlace.prod_eq_abs_norm`: the infinite part of the product formula, that is for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where the product is over the infinite place `w` and `‖·‖_w` is the normalized absolute value for `w`. * `NumberField.InfinitePlace.card_add_two_mul_card_eq_rank`: the degree of `K` is equal to the number of real places plus twice the number of complex places. ## Tags number field, infinite places -/ open scoped Finset open NumberField Fintype Module variable {k : Type*} [Field k] (K : Type*) [Field K] {F : Type*} [Field F] /-- An infinite place of a number field `K` is a place associated to a complex embedding. -/ def NumberField.InfinitePlace := { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w } instance [NumberField K] : Nonempty (NumberField.InfinitePlace K) := Set.instNonemptyRange _ variable {K} /-- Return the infinite place defined by a complex embedding `φ`. -/ noncomputable def NumberField.InfinitePlace.mk (φ : K →+* ℂ) : NumberField.InfinitePlace K := ⟨place φ, ⟨φ, rfl⟩⟩ namespace NumberField.InfinitePlace instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K ℝ where coe w x := w.1 x coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x) lemma coe_apply {K : Type*} [Field K] (v : InfinitePlace K) (x : K) : v x = v.1 x := rfl @[ext] lemma ext {K : Type*} [Field K] (v₁ v₂ : InfinitePlace K) (h : ∀ k, v₁ k = v₂ k) : v₁ = v₂ := Subtype.ext <| AbsoluteValue.ext h instance : MonoidWithZeroHomClass (InfinitePlace K) K ℝ where map_mul w _ _ := w.1.map_mul _ _ map_one w := w.1.map_one map_zero w := w.1.map_zero instance : NonnegHomClass (InfinitePlace K) K ℝ where apply_nonneg w _ := w.1.nonneg _ @[simp] theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = ‖φ x‖ := rfl /-- For an infinite place `w`, return an embedding `φ` such that `w = infinite_place φ` . -/ noncomputable def embedding (w : InfinitePlace K) : K →+* ℂ := w.2.choose @[simp] theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w := Subtype.ext w.2.choose_spec @[simp] theorem mk_conjugate_eq (φ : K →+* ℂ) : mk (ComplexEmbedding.conjugate φ) = mk φ := by refine DFunLike.ext _ _ (fun x => ?_) rw [apply, apply, ComplexEmbedding.conjugate_coe_eq, Complex.norm_conj] theorem norm_embedding_eq (w : InfinitePlace K) (x : K) : ‖(embedding w) x‖ = w x := by nth_rewrite 2 [← mk_embedding w] rfl variable (K) in theorem embedding_injective : (embedding (K := K)).Injective := fun _ _ h ↦ by simpa using congr_arg mk h @[simp] theorem embedding_inj {v₁ v₂ : InfinitePlace K} : v₁.embedding = v₂.embedding ↔ v₁ = v₂ := (embedding_injective _).eq_iff variable (K) in theorem conjugate_embedding_injective : (fun (v : InfinitePlace K) ↦ ComplexEmbedding.conjugate v.embedding).Injective := star_injective.comp <| embedding_injective K variable (K) in theorem eq_of_embedding_eq_conjugate {v₁ v₂ : InfinitePlace K} (h : v₁.embedding = ComplexEmbedding.conjugate v₂.embedding) : v₁ = v₂ := by rw [← mk_embedding v₁, h, mk_conjugate_eq, mk_embedding] theorem eq_iff_eq (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x = r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ = r := ⟨fun hw φ => hw (mk φ), by rintro hφ ⟨w, ⟨φ, rfl⟩⟩; exact hφ φ⟩ theorem le_iff_le (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x ≤ r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r := ⟨fun hw φ => hw (mk φ), by rintro hφ ⟨w, ⟨φ, rfl⟩⟩; exact hφ φ⟩ theorem pos_iff {w : InfinitePlace K} {x : K} : 0 < w x ↔ x ≠ 0 := AbsoluteValue.pos_iff w.1 @[simp] theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexEmbedding.conjugate φ = ψ := by constructor · -- We prove that the map ψ ∘ φ⁻¹ between φ(K) and ℂ is uniform continuous, thus it is either the -- inclusion or the complex conjugation using `Complex.uniformContinuous_ringHom_eq_id_or_conj` intro h₀ obtain ⟨j, hiφ⟩ := (φ.injective).hasLeftInverse let ι := RingEquiv.ofLeftInverse hiφ have hlip : LipschitzWith 1 (RingHom.comp ψ ι.symm.toRingHom) := by change LipschitzWith 1 (ψ ∘ ι.symm) apply LipschitzWith.of_dist_le_mul intro x y rw [NNReal.coe_one, one_mul, NormedField.dist_eq, Function.comp_apply, Function.comp_apply, ← map_sub, ← map_sub] apply le_of_eq suffices ‖φ (ι.symm (x - y))‖ = ‖ψ (ι.symm (x - y))‖ by rw [← this, ← RingEquiv.ofLeftInverse_apply hiφ _, RingEquiv.apply_symm_apply ι _] rfl exact congrFun (congrArg (↑) h₀) _ cases Complex.uniformContinuous_ringHom_eq_id_or_conj φ.fieldRange hlip.uniformContinuous with | inl h => left; ext1 x conv_rhs => rw [← hiφ x] exact (congrFun h (ι x)).symm | inr h => right; ext1 x conv_rhs => rw [← hiφ x] exact (congrFun h (ι x)).symm · rintro (⟨h⟩ | ⟨h⟩) · exact congr_arg mk h · rw [← mk_conjugate_eq] exact congr_arg mk h /-- An infinite place is real if it is defined by a real embedding. -/ def IsReal (w : InfinitePlace K) : Prop := ∃ φ : K →+* ℂ, ComplexEmbedding.IsReal φ ∧ mk φ = w /-- An infinite place is complex if it is defined by a complex (i.e. not real) embedding. -/ def IsComplex (w : InfinitePlace K) : Prop := ∃ φ : K →+* ℂ, ¬ComplexEmbedding.IsReal φ ∧ mk φ = w theorem embedding_mk_eq (φ : K →+* ℂ) : embedding (mk φ) = φ ∨ embedding (mk φ) = ComplexEmbedding.conjugate φ := by rw [@eq_comm _ _ φ, @eq_comm _ _ (ComplexEmbedding.conjugate φ), ← mk_eq_iff, mk_embedding] @[simp] theorem embedding_mk_eq_of_isReal {φ : K →+* ℂ} (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ := by have := embedding_mk_eq φ rwa [ComplexEmbedding.isReal_iff.mp h, or_self] at this theorem isReal_iff {w : InfinitePlace K} : IsReal w ↔ ComplexEmbedding.IsReal (embedding w) := by refine ⟨?_, fun h => ⟨embedding w, h, mk_embedding w⟩⟩ rintro ⟨φ, ⟨hφ, rfl⟩⟩ rwa [embedding_mk_eq_of_isReal hφ] theorem isComplex_iff {w : InfinitePlace K} : IsComplex w ↔ ¬ComplexEmbedding.IsReal (embedding w) := by refine ⟨?_, fun h => ⟨embedding w, h, mk_embedding w⟩⟩ rintro ⟨φ, ⟨hφ, rfl⟩⟩ contrapose! hφ cases mk_eq_iff.mp (mk_embedding (mk φ)) with | inl h => rwa [h] at hφ | inr h => rwa [← ComplexEmbedding.isReal_conjugate_iff, h] at hφ @[simp] theorem conjugate_embedding_eq_of_isReal {w : InfinitePlace K} (h : IsReal w) : ComplexEmbedding.conjugate (embedding w) = embedding w := ComplexEmbedding.isReal_iff.mpr (isReal_iff.mp h) @[simp] theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComplex w := by rw [isComplex_iff, isReal_iff] @[simp] theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by rw [isComplex_iff, isReal_iff, not_not] theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by rw [← not_isReal_iff_isComplex]; exact em _ theorem ne_of_isReal_isComplex {w w' : InfinitePlace K} (h : IsReal w) (h' : IsComplex w') : w ≠ w' := fun h_eq ↦ not_isReal_iff_isComplex.mpr h' (h_eq ▸ h) variable (K) in theorem disjoint_isReal_isComplex : Disjoint {(w : InfinitePlace K) | IsReal w} {(w : InfinitePlace K) | IsComplex w} := Set.disjoint_iff.2 <| fun _ hw ↦ not_isReal_iff_isComplex.2 hw.2 hw.1 /-- The real embedding associated to a real infinite place. -/ noncomputable def embedding_of_isReal {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ := ComplexEmbedding.IsReal.embedding (isReal_iff.mp hw) @[simp] theorem embedding_of_isReal_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) : ((embedding_of_isReal hw) x : ℂ) = (embedding w) x := ComplexEmbedding.IsReal.coe_embedding_apply (isReal_iff.mp hw) x theorem norm_embedding_of_isReal {w : InfinitePlace K} (hw : IsReal w) (x : K) : ‖embedding_of_isReal hw x‖ = w x := by rw [← norm_embedding_eq, ← embedding_of_isReal_apply hw, Complex.norm_real] @[simp] theorem isReal_of_mk_isReal {φ : K →+* ℂ} (h : IsReal (mk φ)) : ComplexEmbedding.IsReal φ := by contrapose! h rw [not_isReal_iff_isComplex] exact ⟨φ, h, rfl⟩ lemma isReal_mk_iff {φ : K →+* ℂ} : IsReal (mk φ) ↔ ComplexEmbedding.IsReal φ := ⟨isReal_of_mk_isReal, fun H ↦ ⟨_, H, rfl⟩⟩ lemma isComplex_mk_iff {φ : K →+* ℂ} : IsComplex (mk φ) ↔ ¬ ComplexEmbedding.IsReal φ := not_isReal_iff_isComplex.symm.trans isReal_mk_iff.not @[simp] theorem not_isReal_of_mk_isComplex {φ : K →+* ℂ} (h : IsComplex (mk φ)) : ¬ ComplexEmbedding.IsReal φ := by rwa [← isComplex_mk_iff] open scoped Classical in /-- The multiplicity of an infinite place, that is the number of distinct complex embeddings that define it, see `card_filter_mk_eq`. -/ noncomputable def mult (w : InfinitePlace K) : ℕ := if (IsReal w) then 1 else 2 @[simp] theorem mult_isReal (w : {w : InfinitePlace K // IsReal w}) : mult w.1 = 1 := by rw [mult, if_pos w.prop] @[simp] theorem mult_isComplex (w : {w : InfinitePlace K // IsComplex w}) : mult w.1 = 2 := by rw [mult, if_neg (not_isReal_iff_isComplex.mpr w.prop)] theorem mult_pos {w : InfinitePlace K} : 0 < mult w := by rw [mult] split_ifs <;> norm_num @[simp] theorem mult_ne_zero {w : InfinitePlace K} : mult w ≠ 0 := ne_of_gt mult_pos theorem mult_coe_ne_zero {w : InfinitePlace K} : (mult w : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr mult_ne_zero theorem one_le_mult {w : InfinitePlace K} : (1 : ℝ) ≤ mult w := by rw [← Nat.cast_one, Nat.cast_le] exact mult_pos open scoped Classical in theorem card_filter_mk_eq [NumberField K] (w : InfinitePlace K) : #{φ | mk φ = w} = mult w := by conv_lhs => congr; congr; ext rw [← mk_embedding w, mk_eq_iff, ComplexEmbedding.conjugate, star_involutive.eq_iff] simp_rw [Finset.filter_or, Finset.filter_eq' _ (embedding w), Finset.filter_eq' _ (ComplexEmbedding.conjugate (embedding w)), Finset.mem_univ, ite_true, mult] split_ifs with hw · rw [ComplexEmbedding.isReal_iff.mp (isReal_iff.mp hw), Finset.union_idempotent, Finset.card_singleton] · refine Finset.card_pair ?_ rwa [Ne, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff] open scoped Classical in noncomputable instance NumberField.InfinitePlace.fintype [NumberField K] : Fintype (InfinitePlace K) := Set.fintypeRange _ open scoped Classical in @[to_additive] theorem prod_eq_prod_mul_prod {α : Type*} [CommMonoid α] [NumberField K] (f : InfinitePlace K → α) : ∏ w, f w = (∏ w : {w // IsReal w}, f w.1) * (∏ w : {w // IsComplex w}, f w.1) := by rw [← Equiv.prod_comp (Equiv.subtypeEquivRight (fun _ ↦ not_isReal_iff_isComplex))] simp [Fintype.prod_subtype_mul_prod_subtype] theorem sum_mult_eq [NumberField K] : ∑ w : InfinitePlace K, mult w = Module.finrank ℚ K := by classical rw [← Embeddings.card K ℂ, Fintype.card, Finset.card_eq_sum_ones, ← Finset.univ.sum_fiberwise (fun φ => InfinitePlace.mk φ)] exact Finset.sum_congr rfl (fun _ _ => by rw [Finset.sum_const, smul_eq_mul, mul_one, card_filter_mk_eq]) /-- The map from real embeddings to real infinite places as an equiv -/ noncomputable def mkReal : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } ≃ { w : InfinitePlace K // IsReal w } := by refine (Equiv.ofBijective (fun φ => ⟨mk φ, ?_⟩) ⟨fun φ ψ h => ?_, fun w => ?_⟩) · exact ⟨φ, φ.prop, rfl⟩ · rwa [Subtype.mk.injEq, mk_eq_iff, ComplexEmbedding.isReal_iff.mp φ.prop, or_self, ← Subtype.ext_iff] at h · exact ⟨⟨embedding w, isReal_iff.mp w.prop⟩, by simp⟩ /-- The map from nonreal embeddings to complex infinite places -/ noncomputable def mkComplex : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } → { w : InfinitePlace K // IsComplex w } := Subtype.map mk fun φ hφ => ⟨φ, hφ, rfl⟩ @[simp] theorem mkReal_coe (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) : (mkReal φ : InfinitePlace K) = mk (φ : K →+* ℂ) := rfl @[simp] theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) : (mkComplex φ : InfinitePlace K) = mk (φ : K →+* ℂ) := rfl variable [NumberField K] /-- The infinite part of the product formula : for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where `‖·‖_w` is the normalized absolute value for `w`. -/ theorem prod_eq_abs_norm (x : K) : ∏ w : InfinitePlace K, w x ^ mult w = abs (Algebra.norm ℚ x) := by classical convert (congr_arg (‖·‖) (Algebra.norm_eq_prod_embeddings ℚ ℂ x)).symm · rw [norm_prod, ← Fintype.prod_equiv RingHom.equivRatAlgHom (fun f => ‖f x‖) (fun φ => ‖φ x‖) fun _ => by simp [RingHom.equivRatAlgHom_apply]] rw [← Finset.prod_fiberwise Finset.univ mk (fun φ => ‖φ x‖)] have (w : InfinitePlace K) (φ) (hφ : φ ∈ ({φ | mk φ = w} : Finset _)) : ‖φ x‖ = w x := by rw [← (Finset.mem_filter.mp hφ).2, apply] simp_rw [Finset.prod_congr rfl (this _), Finset.prod_const, card_filter_mk_eq] · rw [eq_ratCast, Rat.cast_abs, ← Real.norm_eq_abs, ← Complex.norm_real, Complex.ofReal_ratCast] theorem one_le_of_lt_one {w : InfinitePlace K} {a : (𝓞 K)} (ha : a ≠ 0) (h : ∀ ⦃z⦄, z ≠ w → z a < 1) : 1 ≤ w a := by suffices (1 : ℝ) ≤ |Algebra.norm ℚ (a : K)| by contrapose! this rw [← InfinitePlace.prod_eq_abs_norm, ← Finset.prod_const_one] refine Finset.prod_lt_prod_of_nonempty (fun _ _ ↦ ?_) (fun z _ ↦ ?_) Finset.univ_nonempty · exact pow_pos (pos_iff.mpr ((Subalgebra.coe_eq_zero _).not.mpr ha)) _ · refine pow_lt_one₀ (apply_nonneg _ _) ?_ (by rw [mult]; split_ifs <;> norm_num) by_cases hz : z = w · rwa [hz] · exact h hz rw [← Algebra.coe_norm_int, ← Int.cast_one, ← Int.cast_abs, Rat.cast_intCast, Int.cast_le] exact Int.one_le_abs (Algebra.norm_ne_zero_iff.mpr ha) open scoped IntermediateField in theorem _root_.NumberField.is_primitive_element_of_infinitePlace_lt {x : 𝓞 K} {w : InfinitePlace K} (h₁ : x ≠ 0) (h₂ : ∀ ⦃w'⦄, w' ≠ w → w' x < 1) (h₃ : IsReal w ∨ |(w.embedding x).re| < 1) : ℚ⟮(x : K)⟯ = ⊤ := by rw [Field.primitive_element_iff_algHom_eq_of_eval ℚ ℂ ?_ _ w.embedding.toRatAlgHom] · intro ψ hψ have h : 1 ≤ w x := one_le_of_lt_one h₁ h₂ have main : w = InfinitePlace.mk ψ.toRingHom := by simp only [RingHom.toRatAlgHom_apply] at hψ rw [← norm_embedding_eq, hψ] at h contrapose! h exact h₂ h.symm rw [(mk_embedding w).symm, mk_eq_iff] at main cases h₃ with | inl hw => rw [conjugate_embedding_eq_of_isReal hw, or_self] at main exact congr_arg RingHom.toRatAlgHom main | inr hw => refine congr_arg RingHom.toRatAlgHom (main.resolve_right fun h' ↦ hw.not_ge ?_) have : (embedding w x).im = 0 := by rw [← Complex.conj_eq_iff_im] have := RingHom.congr_fun h' x simp at this rw [this] exact hψ.symm rwa [← norm_embedding_eq, ← Complex.re_add_im (embedding w x), this, Complex.ofReal_zero, zero_mul, add_zero, Complex.norm_real] at h · exact fun x ↦ IsAlgClosed.splits_codomain (minpoly ℚ x) theorem _root_.NumberField.adjoin_eq_top_of_infinitePlace_lt {x : 𝓞 K} {w : InfinitePlace K} (h₁ : x ≠ 0) (h₂ : ∀ ⦃w'⦄, w' ≠ w → w' x < 1) (h₃ : IsReal w ∨ |(w.embedding x).re| < 1) : Algebra.adjoin ℚ {(x : K)} = ⊤ := by rw [← IntermediateField.adjoin_simple_toSubalgebra_of_integral (IsIntegral.of_finite ℚ _)] exact congr_arg IntermediateField.toSubalgebra <| NumberField.is_primitive_element_of_infinitePlace_lt h₁ h₂ h₃ variable (K) open scoped Classical in /-- The number of infinite real places of the number field `K`. -/ noncomputable abbrev nrRealPlaces := card { w : InfinitePlace K // IsReal w } open scoped Classical in /-- The number of infinite complex places of the number field `K`. -/ noncomputable abbrev nrComplexPlaces := card { w : InfinitePlace K // IsComplex w } open scoped Classical in theorem card_real_embeddings : card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = nrRealPlaces K := Fintype.card_congr mkReal theorem card_eq_nrRealPlaces_add_nrComplexPlaces : Fintype.card (InfinitePlace K) = nrRealPlaces K + nrComplexPlaces K := by classical convert Fintype.card_subtype_or_disjoint (IsReal (K := K)) (IsComplex (K := K)) (disjoint_isReal_isComplex K) using 1 exact (Fintype.card_of_subtype _ (fun w ↦ ⟨fun _ ↦ isReal_or_isComplex w, fun _ ↦ by simp⟩)).symm open scoped Classical in theorem card_complex_embeddings : card { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } = 2 * nrComplexPlaces K := by suffices ∀ w : { w : InfinitePlace K // IsComplex w }, #{φ : {φ //¬ ComplexEmbedding.IsReal φ} | mkComplex φ = w} = 2 by rw [Fintype.card, Finset.card_eq_sum_ones, ← Finset.sum_fiberwise _ (fun φ => mkComplex φ)] simp_rw [Finset.sum_const, this, smul_eq_mul, mul_one, Fintype.card, Finset.card_eq_sum_ones, Finset.mul_sum, Finset.sum_const, smul_eq_mul, mul_one] rintro ⟨w, hw⟩ convert card_filter_mk_eq w · rw [← Fintype.card_subtype, ← Fintype.card_subtype] refine Fintype.card_congr (Equiv.ofBijective ?_ ⟨fun _ _ h => ?_, fun ⟨φ, hφ⟩ => ?_⟩) · exact fun ⟨φ, hφ⟩ => ⟨φ.val, by rwa [Subtype.ext_iff] at hφ⟩ · rwa [Subtype.mk_eq_mk, ← Subtype.ext_iff, ← Subtype.ext_iff] at h · refine ⟨⟨⟨φ, not_isReal_of_mk_isComplex (hφ.symm ▸ hw)⟩, ?_⟩, rfl⟩ rwa [Subtype.ext_iff, mkComplex_coe] · simp_rw [mult, not_isReal_iff_isComplex.mpr hw, ite_false] theorem card_add_two_mul_card_eq_rank : nrRealPlaces K + 2 * nrComplexPlaces K = finrank ℚ K := by classical rw [← card_real_embeddings, ← card_complex_embeddings, Fintype.card_subtype_compl, ← Embeddings.card K ℂ, Nat.add_sub_of_le] exact Fintype.card_subtype_le _ variable {K} theorem nrComplexPlaces_eq_zero_of_finrank_eq_one (h : finrank ℚ K = 1) : nrComplexPlaces K = 0 := by linarith [card_add_two_mul_card_eq_rank K] theorem nrRealPlaces_eq_one_of_finrank_eq_one (h : finrank ℚ K = 1) : nrRealPlaces K = 1 := by have := card_add_two_mul_card_eq_rank K rwa [nrComplexPlaces_eq_zero_of_finrank_eq_one h, h, mul_zero, add_zero] at this theorem nrRealPlaces_pos_of_odd_finrank (h : Odd (finrank ℚ K)) : 0 < nrRealPlaces K := by refine Nat.pos_of_ne_zero ?_ by_contra hc refine (Nat.not_odd_iff_even.mpr ?_) h rw [← card_add_two_mul_card_eq_rank, hc, zero_add] exact even_two_mul (nrComplexPlaces K) namespace IsPrimitiveRoot variable {ζ : K} {k : ℕ} theorem nrRealPlaces_eq_zero_of_two_lt (hk : 2 < k) (hζ : IsPrimitiveRoot ζ k) : NumberField.InfinitePlace.nrRealPlaces K = 0 := by refine (@Fintype.card_eq_zero_iff _ (_)).2 ⟨fun ⟨w, hwreal⟩ ↦ ?_⟩ rw [NumberField.InfinitePlace.isReal_iff] at hwreal let f := w.embedding have hζ' : IsPrimitiveRoot (f ζ) k := hζ.map_of_injective f.injective have him : (f ζ).im = 0 := by rw [← Complex.conj_eq_iff_im, ← NumberField.ComplexEmbedding.conjugate_coe_eq] congr have hre : (f ζ).re = 1 ∨ (f ζ).re = -1 := by rw [← Complex.abs_re_eq_norm] at him have := Complex.norm_eq_one_of_pow_eq_one hζ'.pow_eq_one (by cutsat) rwa [← him, ← abs_one, abs_eq_abs] at this cases hre with | inl hone => exact hζ'.ne_one (by cutsat) <| Complex.ext (by simp [hone]) (by simp [him]) | inr hnegone => replace hζ' := hζ'.eq_orderOf simp only [show f ζ = -1 from Complex.ext (by simp [hnegone]) (by simp [him]), orderOf_neg_one, ringChar.eq_zero, OfNat.zero_ne_ofNat, ↓reduceIte] at hζ' cutsat end IsPrimitiveRoot end NumberField.InfinitePlace /-! ## The infinite place of the rationals. -/ namespace Rat open NumberField /-- The infinite place of `ℚ`, coming from the canonical map `ℚ → ℂ`. -/ noncomputable def infinitePlace : InfinitePlace ℚ := .mk (Rat.castHom _) @[simp] lemma infinitePlace_apply (v : InfinitePlace ℚ) (x : ℚ) : v x = |x| := by rw [NumberField.InfinitePlace.coe_apply] obtain ⟨_, _, rfl⟩ := v simp instance : Subsingleton (InfinitePlace ℚ) where allEq a b := by ext; simp lemma isReal_infinitePlace : InfinitePlace.IsReal (infinitePlace) := ⟨Rat.castHom ℂ, by ext; simp, rfl⟩ end Rat
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean
import Mathlib.Algebra.Algebra.Hom.Rat import Mathlib.Analysis.Complex.Polynomial.Basic import Mathlib.NumberTheory.NumberField.Basic /-! # Embeddings of number fields This file defines the embeddings of a number field and, in particular, the embeddings into the field of complex numbers. ## Main Definitions and Results * `NumberField.Embeddings.range_eval_eq_rootSet_minpoly`: let `x ∈ K` with `K` a number field and let `A` be an algebraically closed field of char. 0. Then the images of `x` under the embeddings of `K` in `A` are exactly the roots in `A` of the minimal polynomial of `x` over `ℚ`. * `NumberField.Embeddings.pow_eq_one_of_norm_eq_one`: an algebraic integer whose conjugates are all of norm one is a root of unity. ## Tags number field, embeddings -/ open scoped Finset namespace NumberField.Embeddings section Fintype open Module variable (K : Type*) [Field K] [NumberField K] variable (A : Type*) [Field A] [CharZero A] /-- There are finitely many embeddings of a number field. -/ noncomputable instance : Fintype (K →+* A) := Fintype.ofEquiv (K →ₐ[ℚ] A) RingHom.equivRatAlgHom.symm variable [IsAlgClosed A] /-- The number of embeddings of a number field is equal to its finrank. -/ theorem card : Fintype.card (K →+* A) = finrank ℚ K := by rw [Fintype.ofEquiv_card RingHom.equivRatAlgHom.symm, AlgHom.card] instance : Nonempty (K →+* A) := by rw [← Fintype.card_pos_iff, NumberField.Embeddings.card K A] exact Module.finrank_pos end Fintype section Roots open Set Polynomial variable (K A : Type*) [Field K] [NumberField K] [Field A] [Algebra ℚ A] [IsAlgClosed A] (x : K) /-- Let `A` be an algebraically closed field and let `x ∈ K`, with `K` a number field. The images of `x` by the embeddings of `K` in `A` are exactly the roots in `A` of the minimal polynomial of `x` over `ℚ`. -/ theorem range_eval_eq_rootSet_minpoly : (range fun φ : K →+* A => φ x) = (minpoly ℚ x).rootSet A := by convert (NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1 ext a exact ⟨fun ⟨φ, hφ⟩ => ⟨φ.toRatAlgHom, hφ⟩, fun ⟨φ, hφ⟩ => ⟨φ.toRingHom, hφ⟩⟩ end Roots section Bounded open Module Polynomial Set variable {K : Type*} [Field K] [NumberField K] variable {A : Type*} [NormedField A] [IsAlgClosed A] [NormedAlgebra ℚ A] theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x‖ ≤ B) (i : ℕ) : ‖(minpoly ℚ x).coeff i‖ ≤ max B 1 ^ finrank ℚ K * (finrank ℚ K).choose (finrank ℚ K / 2) := by have hx := Algebra.IsSeparable.isIntegral ℚ x rw [← norm_algebraMap' A, ← coeff_map (algebraMap ℚ A)] refine coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _) (minpoly.natDegree_le x) (fun z hz => ?_) i classical rw [← Multiset.mem_toFinset] at hz obtain ⟨φ, rfl⟩ := (range_eval_eq_rootSet_minpoly K A x).symm.subset hz exact h φ variable (K A) /-- Let `B` be a real number. The set of algebraic integers in `K` whose conjugates are all smaller in norm than `B` is finite. -/ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K →+* A, ‖φ x‖ ≤ B}.Finite := by classical let C := Nat.ceil (max B 1 ^ finrank ℚ K * (finrank ℚ K).choose (finrank ℚ K / 2)) have := bUnion_roots_finite (algebraMap ℤ K) (finrank ℚ K) (finite_Icc (-C : ℤ) C) refine this.subset fun x hx => ?_; simp_rw [mem_iUnion] have h_map_ℚ_minpoly := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx.1 refine ⟨_, ⟨?_, fun i => ?_⟩, mem_rootSet.2 ⟨minpoly.ne_zero hx.1, minpoly.aeval ℤ x⟩⟩ · rw [← (minpoly.monic hx.1).natDegree_map (algebraMap ℤ ℚ), ← h_map_ℚ_minpoly] exact minpoly.natDegree_le x rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ] refine (Eq.trans_le ?_ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _) rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs] /-- An algebraic integer whose conjugates are all of norm one is a root of unity. -/ theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ : K →+* A, ‖φ x‖ = 1) : ∃ (n : ℕ) (_ : 0 < n), x ^ n = 1 := by obtain ⟨a, -, b, -, habne, h⟩ := @Set.Infinite.exists_ne_map_eq_of_mapsTo _ _ _ _ (x ^ · : ℕ → K) Set.infinite_univ (by exact fun a _ => ⟨hxi.pow a, fun φ => by simp [hx φ]⟩) (finite_of_norm_le K A (1 : ℝ)) wlog hlt : b < a · exact this K A hxi hx b a habne.symm h.symm (habne.lt_or_gt.resolve_right hlt) refine ⟨a - b, tsub_pos_of_lt hlt, ?_⟩ rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h refine h.resolve_right fun hp => ?_ specialize hx (IsAlgClosed.lift (R := ℚ)).toRingHom rw [eq_zero_of_pow_eq_zero hp, map_zero, norm_zero] at hx; norm_num at hx end Bounded end NumberField.Embeddings section Place variable {K : Type*} [Field K] {A : Type*} [NormedDivisionRing A] [Nontrivial A] (φ : K →+* A) /-- An embedding into a normed division ring defines a place of `K` -/ def NumberField.place : AbsoluteValue K ℝ := (IsAbsoluteValue.toAbsoluteValue (norm : A → ℝ)).comp φ.injective @[simp] theorem NumberField.place_apply (x : K) : (NumberField.place φ) x = norm (φ x) := rfl end Place namespace NumberField.ComplexEmbedding open Complex NumberField open scoped ComplexConjugate variable (K : Type*) [Field K] {k : Type*} [Field k] /-- A (random) lift of the complex embedding `φ : k →+* ℂ` to an extension `K` of `k`. -/ noncomputable def lift [Algebra k K] [Algebra.IsAlgebraic k K] (φ : k →+* ℂ) : K →+* ℂ := by letI := φ.toAlgebra exact (IsAlgClosed.lift (R := k)).toRingHom @[simp] theorem lift_comp_algebraMap [Algebra k K] [Algebra.IsAlgebraic k K] (φ : k →+* ℂ) : (lift K φ).comp (algebraMap k K) = φ := by unfold lift letI := φ.toAlgebra rw [AlgHom.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, RingHom.algebraMap_toAlgebra'] @[simp] theorem lift_algebraMap_apply [Algebra k K] [Algebra.IsAlgebraic k K] (φ : k →+* ℂ) (x : k) : lift K φ (algebraMap k K x) = φ x := RingHom.congr_fun (lift_comp_algebraMap K φ) x variable {K} /-- The conjugate of a complex embedding as a complex embedding. -/ abbrev conjugate (φ : K →+* ℂ) : K →+* ℂ := star φ @[simp] theorem conjugate_comp (φ : K →+* ℂ) (σ : k →+* K) : (conjugate φ).comp σ = conjugate (φ.comp σ) := rfl @[simp] theorem conjugate_coe_eq (φ : K →+* ℂ) (x : K) : (conjugate φ) x = conj (φ x) := rfl theorem place_conjugate (φ : K →+* ℂ) : place (conjugate φ) = place φ := by ext; simp only [place_apply, norm_conj, conjugate_coe_eq] /-- An embedding into `ℂ` is real if it is fixed by complex conjugation. -/ abbrev IsReal (φ : K →+* ℂ) : Prop := IsSelfAdjoint φ theorem isReal_iff {φ : K →+* ℂ} : IsReal φ ↔ conjugate φ = φ := isSelfAdjoint_iff theorem isReal_conjugate_iff {φ : K →+* ℂ} : IsReal (conjugate φ) ↔ IsReal φ := IsSelfAdjoint.star_iff /-- A real embedding as a ring homomorphism from `K` to `ℝ` . -/ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ where toFun x := (φ x).re map_one' := by simp only [map_one, one_re] map_mul' := by simp only [Complex.conj_eq_iff_im.mp (RingHom.congr_fun hφ _), map_mul, mul_re, mul_zero, tsub_zero, forall_const] map_zero' := by simp only [map_zero, zero_re] map_add' := by simp only [map_add, add_re, forall_const] @[simp] theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K) : (hφ.embedding x : ℂ) = φ x := by apply Complex.ext · rfl · rw [ofReal_im, eq_comm, ← Complex.conj_eq_iff_im] exact RingHom.congr_fun hφ x lemma IsReal.comp (f : k →+* K) {φ : K →+* ℂ} (hφ : IsReal φ) : IsReal (φ.comp f) := by ext1 x; simpa using RingHom.congr_fun hφ (f x) lemma isReal_comp_iff {f : k ≃+* K} {φ : K →+* ℂ} : IsReal (φ.comp (f : k →+* K)) ↔ IsReal φ := ⟨fun H ↦ by convert H.comp f.symm.toRingHom; ext1; simp, IsReal.comp _⟩ lemma exists_comp_symm_eq_of_comp_eq [Algebra k K] [IsGalois k K] (φ ψ : K →+* ℂ) (h : φ.comp (algebraMap k K) = ψ.comp (algebraMap k K)) : ∃ σ : Gal(K/k), φ.comp σ.symm = ψ := by letI := (φ.comp (algebraMap k K)).toAlgebra letI := φ.toAlgebra have : IsScalarTower k K ℂ := IsScalarTower.of_algebraMap_eq' rfl let ψ' : K →ₐ[k] ℂ := { ψ with commutes' := fun r ↦ (RingHom.congr_fun h r).symm } use (AlgHom.restrictNormal' ψ' K).symm ext1 x exact AlgHom.restrictNormal_commutes ψ' K x variable [Algebra k K] (φ : K →+* ℂ) (σ : Gal(K/k)) /-- `IsConj φ σ` states that `σ : Gal(K/k)` is the conjugation under the embedding `φ : K →+* ℂ`. -/ def IsConj : Prop := conjugate φ = φ.comp σ variable {φ σ} lemma IsConj.eq (h : IsConj φ σ) (x) : φ (σ x) = star (φ x) := RingHom.congr_fun h.symm x lemma IsConj.ext {σ₁ σ₂ : Gal(K/k)} (h₁ : IsConj φ σ₁) (h₂ : IsConj φ σ₂) : σ₁ = σ₂ := AlgEquiv.ext fun x ↦ φ.injective ((h₁.eq x).trans (h₂.eq x).symm) lemma IsConj.ext_iff {σ₁ σ₂ : Gal(K/k)} (h₁ : IsConj φ σ₁) : σ₁ = σ₂ ↔ IsConj φ σ₂ := ⟨fun e ↦ e ▸ h₁, h₁.ext⟩ lemma IsConj.isReal_comp (h : IsConj φ σ) : IsReal (φ.comp (algebraMap k K)) := by ext1 x simp only [conjugate_coe_eq, RingHom.coe_comp, Function.comp_apply, ← h.eq, starRingEnd_apply, AlgEquiv.commutes] lemma isConj_one_iff : IsConj φ (1 : Gal(K/k)) ↔ IsReal φ := Iff.rfl alias ⟨_, IsReal.isConjGal_one⟩ := ComplexEmbedding.isConj_one_iff lemma isConj_ne_one_iff (hσ : IsConj φ σ) : σ ≠ 1 ↔ ¬ IsReal φ := not_iff_not.mpr ⟨fun h ↦ isConj_one_iff.mp (h ▸ hσ), fun h ↦ (IsConj.ext_iff hσ).mpr h.isConjGal_one⟩ lemma IsConj.symm (hσ : IsConj φ σ) : IsConj φ σ.symm := RingHom.ext fun x ↦ by simpa using congr_arg star (hσ.eq (σ.symm x)) lemma isConj_symm : IsConj φ σ.symm ↔ IsConj φ σ := ⟨IsConj.symm, IsConj.symm⟩ lemma isConj_apply_apply (hσ : IsConj φ σ) (x : K) : σ (σ x) = x := by simp [← φ.injective.eq_iff, hσ.eq] theorem IsConj.comp (hσ : IsConj φ σ) (ν : Gal(K/k)) : IsConj (φ.comp ν) (ν⁻¹ * σ * ν) := by ext simpa [← AlgEquiv.mul_apply, ← mul_assoc] using RingHom.congr_fun hσ _ lemma orderOf_isConj_two_of_ne_one (hσ : IsConj φ σ) (hσ' : σ ≠ 1) : orderOf σ = 2 := orderOf_eq_prime_iff.mpr ⟨by ext; simpa using isConj_apply_apply hσ _, hσ'⟩ section Extension variable {K : Type*} (L : Type*) [Field K] [Field L] (ψ : K →+* ℂ) [Algebra K L] /-- If `L/K` and `ψ : K →+* ℂ`, then the type of `ComplexEmbedding.Extension L ψ` consists of all `φ : L →+* ℂ` such that `φ.comp (algebraMap K L) = ψ`. -/ protected abbrev Extension := { φ : L →+* ℂ // φ.comp (algebraMap K L) = ψ } namespace Extension variable (φ : ComplexEmbedding.Extension L ψ) {L ψ} theorem comp_eq : φ.1.comp (algebraMap K L) = ψ := φ.2 theorem conjugate_comp_ne (h : ¬IsReal ψ) : (conjugate φ).comp (algebraMap K L) ≠ ψ := by simp_all [ComplexEmbedding.isReal_iff, comp_eq] theorem not_isReal_of_not_isReal (h : ¬IsReal ψ) : ¬IsReal φ.1 := mt (IsReal.comp _) (comp_eq φ ▸ h) end Extension variable (K) {L ψ} /-- If `L/K` and `φ : L →+* ℂ`, then `IsMixed K φ` if the image of `φ` is complex while the image of `φ` restricted to `K` is real. This is the complex embedding analogue of `InfinitePlace.IsRamified K w`, where `w : InfinitePlace L`. It is not the same concept because conjugation of `φ` in this case leads to two distinct mixed embeddings but only a single ramified place `w`, leading to a two-to-one isomorphism between them. -/ abbrev IsMixed (φ : L →+* ℂ) := ComplexEmbedding.IsReal (φ.comp (algebraMap K L)) ∧ ¬ComplexEmbedding.IsReal φ /-- If `L/K` and `φ : L →+* ℂ`, then `IsMixed K φ` if `φ` is not mixed in `K`, i.e., `φ` is real if and only if it's restriction to `K` is. This is the complex embedding analogue of `InfinitePlace.IsUnramified K w`, where `w : InfinitePlace L`. In this case there is an isomorphism between unmixed embeddings and unramified infinite places. -/ abbrev IsUnmixed (φ : L →+* ℂ) := IsReal (φ.comp (algebraMap K L)) → IsReal φ theorem IsUnmixed.isReal_iff_isReal {φ : L →+* ℂ} (h : IsUnmixed K φ) : IsReal (φ.comp (algebraMap K L)) ↔ IsReal φ := by aesop (add simp [IsReal.comp]) end Extension end NumberField.ComplexEmbedding
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/InfinitePlace/Ramification.lean
import Mathlib.NumberTheory.NumberField.InfinitePlace.Basic import Mathlib.Analysis.Normed.Ring.WithAbs /-! # Ramification of infinite places of a number field This file studies the ramification of infinite places of a number field. ## Main Definitions and Results * `NumberField.InfinitePlace.comap`: the restriction of an infinite place along an embedding. * `NumberField.InfinitePlace.orbitRelEquiv`: the equiv between the orbits of infinite places under the action of the Galois group and the infinite places of the base field. * `NumberField.InfinitePlace.IsUnramified`: an infinite place is unramified in a field extension if the restriction has the same multiplicity. * `NumberField.InfinitePlace.not_isUnramified_iff`: an infinite place is not unramified (i.e., is ramified) iff it is a complex place above a real place. * `NumberField.InfinitePlace.IsUnramifiedIn`: an infinite place of the base field is unramified in a field extension if every infinite place over it is unramified. * `IsUnramifiedAtInfinitePlaces`: a field extension is unramified at infinite places if every infinite place is unramified. ## Tags number field, infinite places, ramification -/ open NumberField Fintype Module namespace NumberField.InfinitePlace open scoped Finset variable {k : Type*} [Field k] {K : Type*} [Field K] {F : Type*} [Field F] /-- The restriction of an infinite place along an embedding. -/ def comap (w : InfinitePlace K) (f : k →+* K) : InfinitePlace k := ⟨w.1.comp f.injective, w.embedding.comp f, by { ext x; change _ = w.1 (f x); rw [← w.2.choose_spec]; rfl }⟩ @[simp] lemma comap_mk (φ : K →+* ℂ) (f : k →+* K) : (mk φ).comap f = mk (φ.comp f) := rfl lemma comap_id (w : InfinitePlace K) : w.comap (RingHom.id K) = w := rfl lemma comap_comp (w : InfinitePlace K) (f : F →+* K) (g : k →+* F) : w.comap (f.comp g) = (w.comap f).comap g := rfl @[simp] lemma comap_apply (w : InfinitePlace K) (f : k →+* K) (x : k) : w.comap f x = w (f x) := rfl lemma comp_of_comap_eq {v : InfinitePlace k} {w : InfinitePlace K} {f : k →+* K} (h : w.comap f = v) (x : k) : w (f x) = v x := by simp [← h] lemma comap_mk_lift [Algebra k K] [Algebra.IsAlgebraic k K] (φ : k →+* ℂ) : (mk (ComplexEmbedding.lift K φ)).comap (algebraMap k K) = mk φ := by simp lemma IsReal.comap (f : k →+* K) {w : InfinitePlace K} (hφ : IsReal w) : IsReal (w.comap f) := by rw [← mk_embedding w, comap_mk, isReal_mk_iff] rw [← mk_embedding w, isReal_mk_iff] at hφ exact hφ.comp f lemma isReal_comap_iff (f : k ≃+* K) {w : InfinitePlace K} : IsReal (w.comap (f : k →+* K)) ↔ IsReal w := by rw [← mk_embedding w, comap_mk, isReal_mk_iff, isReal_mk_iff, ComplexEmbedding.isReal_comp_iff] lemma comap_surjective [Algebra k K] [Algebra.IsAlgebraic k K] : Function.Surjective (comap · (algebraMap k K)) := fun w ↦ ⟨(mk (ComplexEmbedding.lift K w.embedding)), by simp⟩ lemma mult_comap_le (f : k →+* K) (w : InfinitePlace K) : mult (w.comap f) ≤ mult w := by rw [mult, mult] split_ifs with h₁ h₂ h₂ pick_goal 3 · exact (h₁ (h₂.comap _)).elim all_goals decide variable [Algebra k K] (σ : Gal(K/k)) (w : InfinitePlace K) variable (k K) lemma card_mono [NumberField k] [NumberField K] : card (InfinitePlace k) ≤ card (InfinitePlace K) := have := Module.Finite.of_restrictScalars_finite ℚ k K Fintype.card_le_of_surjective _ comap_surjective variable {k K} /-- The action of the Galois group on infinite places. -/ @[simps! smul_coe_apply] instance : MulAction Gal(K/k) (InfinitePlace K) where smul := fun σ w ↦ w.comap σ.symm one_smul := fun _ ↦ rfl mul_smul := fun _ _ _ ↦ rfl lemma smul_eq_comap : σ • w = w.comap σ.symm := rfl @[simp] lemma smul_apply (x) : (σ • w) x = w (σ.symm x) := rfl @[simp] lemma smul_mk (φ : K →+* ℂ) : σ • mk φ = mk (φ.comp σ.symm) := rfl lemma comap_smul {f : F →+* K} : (σ • w).comap f = w.comap (RingHom.comp σ.symm f) := rfl variable {σ w} lemma isReal_smul_iff : IsReal (σ • w) ↔ IsReal w := isReal_comap_iff (f := σ.symm.toRingEquiv) lemma isComplex_smul_iff : IsComplex (σ • w) ↔ IsComplex w := by rw [← not_isReal_iff_isComplex, ← not_isReal_iff_isComplex, isReal_smul_iff] lemma ComplexEmbedding.exists_comp_symm_eq_of_comp_eq [IsGalois k K] (φ ψ : K →+* ℂ) (h : φ.comp (algebraMap k K) = ψ.comp (algebraMap k K)) : ∃ σ : Gal(K/k), φ.comp σ.symm = ψ := NumberField.ComplexEmbedding.exists_comp_symm_eq_of_comp_eq φ ψ h lemma exists_smul_eq_of_comap_eq [IsGalois k K] {w w' : InfinitePlace K} (h : w.comap (algebraMap k K) = w'.comap (algebraMap k K)) : ∃ σ : Gal(K/k), σ • w = w' := by rw [← mk_embedding w, ← mk_embedding w', comap_mk, comap_mk, mk_eq_iff] at h cases h with | inl h => obtain ⟨σ, hσ⟩ := ComplexEmbedding.exists_comp_symm_eq_of_comp_eq w.embedding w'.embedding h use σ rw [← mk_embedding w, ← mk_embedding w', smul_mk, hσ] | inr h => obtain ⟨σ, hσ⟩ := ComplexEmbedding.exists_comp_symm_eq_of_comp_eq ((starRingEnd ℂ).comp (embedding w)) w'.embedding h use σ rw [← mk_embedding w, ← mk_embedding w', smul_mk, mk_eq_iff] exact Or.inr hσ lemma mem_orbit_iff [IsGalois k K] {w w' : InfinitePlace K} : w' ∈ MulAction.orbit Gal(K/k) w ↔ w.comap (algebraMap k K) = w'.comap (algebraMap k K) := by refine ⟨?_, exists_smul_eq_of_comap_eq⟩ rintro ⟨σ, rfl : σ • w = w'⟩ rw [← mk_embedding w, comap_mk, smul_mk, comap_mk] congr 1; ext1; simp /-- The orbits of infinite places under the action of the Galois group are indexed by the infinite places of the base field. -/ noncomputable def orbitRelEquiv [IsGalois k K] : Quotient (MulAction.orbitRel Gal(K/k) (InfinitePlace K)) ≃ InfinitePlace k := by refine Equiv.ofBijective (Quotient.lift (comap · (algebraMap k K)) fun _ _ e ↦ (mem_orbit_iff.mp e).symm) ⟨?_, ?_⟩ · rintro ⟨w⟩ ⟨w'⟩ e exact Quotient.sound (mem_orbit_iff.mpr e.symm) · intro w obtain ⟨w', hw⟩ := comap_surjective (K := K) w exact ⟨⟦w'⟧, hw⟩ lemma orbitRelEquiv_apply_mk'' [IsGalois k K] (w : InfinitePlace K) : orbitRelEquiv (Quotient.mk'' w) = comap w (algebraMap k K) := rfl variable (k w) /-- An infinite place is unramified in a field extension if the restriction has the same multiplicity. -/ def IsUnramified : Prop := mult (w.comap (algebraMap k K)) = mult w /-- An infinite place is ramified in a field extension if it is not unramified. -/ abbrev IsRamified : Prop := ¬w.IsUnramified k variable {k} lemma isUnramified_self : IsUnramified K w := rfl variable {w} lemma IsUnramified.eq (h : IsUnramified k w) : mult (w.comap (algebraMap k K)) = mult w := h lemma isUnramified_iff_mult_le : IsUnramified k w ↔ mult w ≤ mult (w.comap (algebraMap k K)) := by rw [IsUnramified, le_antisymm_iff, and_iff_right] exact mult_comap_le _ _ variable [Algebra k F] lemma IsUnramified.comap_algHom {w : InfinitePlace F} (h : IsUnramified k w) (f : K →ₐ[k] F) : IsUnramified k (w.comap (f : K →+* F)) := by rw [InfinitePlace.isUnramified_iff_mult_le, ← InfinitePlace.comap_comp, f.comp_algebraMap, h.eq] exact InfinitePlace.mult_comap_le _ _ variable (K) variable [Algebra K F] [IsScalarTower k K F] lemma IsUnramified.of_restrictScalars {w : InfinitePlace F} (h : IsUnramified k w) : IsUnramified K w := by rw [InfinitePlace.isUnramified_iff_mult_le, ← h.eq, IsScalarTower.algebraMap_eq k K F, InfinitePlace.comap_comp] exact InfinitePlace.mult_comap_le _ _ lemma IsUnramified.comap {w : InfinitePlace F} (h : IsUnramified k w) : IsUnramified k (w.comap (algebraMap K F)) := h.comap_algHom (IsScalarTower.toAlgHom k K F) variable {K} /-- An infinite place is not unramified (i.e. ramified) iff it is a complex place above a real place. -/ lemma not_isUnramified_iff : ¬ IsUnramified k w ↔ IsComplex w ∧ IsReal (w.comap (algebraMap k K)) := by rw [IsUnramified, mult, mult, ← not_isReal_iff_isComplex] split_ifs with h₁ h₂ h₂ <;> simp only [not_true_eq_false, false_iff, and_self, forall_true_left, IsEmpty.forall_iff, not_and, OfNat.one_ne_ofNat, not_false_eq_true, true_iff, OfNat.ofNat_ne_one, h₁, h₂] exact h₁ (h₂.comap _) lemma isUnramified_iff : IsUnramified k w ↔ IsReal w ∨ IsComplex (w.comap (algebraMap k K)) := by rw [← not_iff_not, not_isUnramified_iff, not_or, not_isReal_iff_isComplex, not_isComplex_iff_isReal] theorem isRamified_iff : w.IsRamified k ↔ w.IsComplex ∧ (w.comap (algebraMap k K)).IsReal := not_isUnramified_iff theorem IsRamified.ne_conjugate {w₁ w₂ : InfinitePlace K} (h : w₂.IsRamified k) : w₁.embedding ≠ ComplexEmbedding.conjugate w₂.embedding := by by_cases h_eq : w₁ = w₂ · rw [isRamified_iff, isComplex_iff] at h exact Ne.symm (h_eq ▸ h.1) · contrapose! h_eq rw [← mk_embedding w₁, h_eq, mk_conjugate_eq, mk_embedding] variable (k) lemma IsReal.isUnramified (h : IsReal w) : IsUnramified k w := isUnramified_iff.mpr (Or.inl h) variable {k} lemma _root_.NumberField.ComplexEmbedding.IsConj.isUnramified_mk_iff {φ : K →+* ℂ} (h : ComplexEmbedding.IsConj φ σ) : IsUnramified k (mk φ) ↔ σ = 1 := by rw [h.ext_iff, ComplexEmbedding.isConj_one_iff, ← not_iff_not, not_isUnramified_iff, ← not_isReal_iff_isComplex, comap_mk, isReal_mk_iff, isReal_mk_iff, eq_true h.isReal_comp, and_true] lemma isUnramified_mk_iff_forall_isConj [IsGalois k K] {φ : K →+* ℂ} : IsUnramified k (mk φ) ↔ ∀ σ : Gal(K/k), ComplexEmbedding.IsConj φ σ → σ = 1 := by refine ⟨fun H σ hσ ↦ hσ.isUnramified_mk_iff.mp H, fun H ↦ ?_⟩ by_contra hφ rw [not_isUnramified_iff] at hφ rw [comap_mk, isReal_mk_iff, ← not_isReal_iff_isComplex, isReal_mk_iff, ← ComplexEmbedding.isConj_one_iff (k := k)] at hφ letI := (φ.comp (algebraMap k K)).toAlgebra letI := φ.toAlgebra have : IsScalarTower k K ℂ := IsScalarTower.of_algebraMap_eq' rfl let φ' : K →ₐ[k] ℂ := { star φ with commutes' := fun r ↦ by simpa using RingHom.congr_fun hφ.2 r } have : ComplexEmbedding.IsConj φ (AlgHom.restrictNormal' φ' K) := (RingHom.ext <| AlgHom.restrictNormal_commutes φ' K).symm exact hφ.1 (H _ this ▸ this) local notation "Stab" => MulAction.stabilizer Gal(K/k) lemma mem_stabilizer_mk_iff (φ : K →+* ℂ) (σ : Gal(K/k)) : σ ∈ Stab (mk φ) ↔ σ = 1 ∨ ComplexEmbedding.IsConj φ σ := by simp only [MulAction.mem_stabilizer_iff, smul_mk, mk_eq_iff] rw [← ComplexEmbedding.isConj_symm, ComplexEmbedding.conjugate, star_eq_iff_star_eq] refine or_congr ⟨fun H ↦ ?_, fun H ↦ H ▸ rfl⟩ Iff.rfl exact congr_arg AlgEquiv.symm (AlgEquiv.ext (g := AlgEquiv.refl) fun x ↦ φ.injective (RingHom.congr_fun H x)) lemma IsUnramified.stabilizer_eq_bot (h : IsUnramified k w) : Stab w = ⊥ := by rw [eq_bot_iff, ← mk_embedding w, SetLike.le_def] simp only [mem_stabilizer_mk_iff, Subgroup.mem_bot, forall_eq_or_imp, true_and] exact fun σ hσ ↦ hσ.isUnramified_mk_iff.mp ((mk_embedding w).symm ▸ h) lemma _root_.NumberField.ComplexEmbedding.IsConj.coe_stabilizer_mk {φ : K →+* ℂ} (h : ComplexEmbedding.IsConj φ σ) : (Stab (mk φ) : Set Gal(K/k)) = {1, σ} := by ext rw [SetLike.mem_coe, mem_stabilizer_mk_iff, Set.mem_insert_iff, Set.mem_singleton_iff, ← h.ext_iff, eq_comm (a := σ)] @[deprecated (since := "2025-07-08")] alias _root_.NumberField.ComplexEmbedding.IsConj.coe_stabilzer_mk := NumberField.ComplexEmbedding.IsConj.coe_stabilizer_mk variable (k w) lemma nat_card_stabilizer_eq_one_or_two : Nat.card (Stab w) = 1 ∨ Nat.card (Stab w) = 2 := by classical rw [← SetLike.coe_sort_coe, ← mk_embedding w] by_cases! h : ∃ σ, ComplexEmbedding.IsConj (k := k) (embedding w) σ · obtain ⟨σ, hσ⟩ := h simp only [hσ.coe_stabilizer_mk, Nat.card_eq_fintype_card, card_ofFinset, Set.toFinset_singleton] by_cases 1 = σ · left; simp [*] · right; simp [*] · left trans Nat.card ({1} : Set Gal(K/k)) · congr with x simp only [SetLike.mem_coe, mem_stabilizer_mk_iff, Set.mem_singleton_iff, or_iff_left_iff_imp, h x, IsEmpty.forall_iff] · simp variable {k w} lemma isUnramified_iff_stabilizer_eq_bot [IsGalois k K] : IsUnramified k w ↔ Stab w = ⊥ := by rw [← mk_embedding w, isUnramified_mk_iff_forall_isConj] simp only [eq_bot_iff, SetLike.le_def, mem_stabilizer_mk_iff, Subgroup.mem_bot, forall_eq_or_imp, true_and] lemma isUnramified_iff_card_stabilizer_eq_one [IsGalois k K] : IsUnramified k w ↔ Nat.card (Stab w) = 1 := by rw [isUnramified_iff_stabilizer_eq_bot, Subgroup.card_eq_one] lemma not_isUnramified_iff_card_stabilizer_eq_two [IsGalois k K] : ¬ IsUnramified k w ↔ Nat.card (Stab w) = 2 := by rw [isUnramified_iff_card_stabilizer_eq_one] obtain (e | e) := nat_card_stabilizer_eq_one_or_two k w <;> rw [e] <;> decide lemma isRamified_iff_card_stabilizer_eq_two [IsGalois k K] : IsRamified k w ↔ Nat.card (Stab w) = 2 := not_isUnramified_iff_card_stabilizer_eq_two lemma exists_isConj_of_isRamified [IsGalois k K] {φ : K →+* ℂ} (h : IsRamified k (mk φ)) : ∃ σ : Gal(K/k), ComplexEmbedding.IsConj φ σ := by rw [isRamified_iff_card_stabilizer_eq_two, Nat.card_eq_two_iff] at h obtain ⟨⟨x, hx⟩, ⟨y, hy⟩, h₁, -⟩ := h rw [mem_stabilizer_mk_iff] at hx hy grind open scoped Classical in lemma card_stabilizer [IsGalois k K] : Nat.card (Stab w) = if IsUnramified k w then 1 else 2 := by split · rwa [← isUnramified_iff_card_stabilizer_eq_one] · rwa [← not_isUnramified_iff_card_stabilizer_eq_two] lemma even_nat_card_aut_of_not_isUnramified [IsGalois k K] (hw : ¬ IsUnramified k w) : Even (Nat.card Gal(K/k)) := by by_cases H : Finite Gal(K/k) · cases nonempty_fintype Gal(K/k) rw [even_iff_two_dvd, ← not_isUnramified_iff_card_stabilizer_eq_two.mp hw] exact Subgroup.card_subgroup_dvd_card (Stab w) · convert Even.zero by_contra e exact H (Nat.finite_of_card_ne_zero e) lemma even_card_aut_of_not_isUnramified [IsGalois k K] (hw : ¬ IsUnramified k w) : Even (Nat.card Gal(K/k)) := even_nat_card_aut_of_not_isUnramified hw lemma even_finrank_of_not_isUnramified [IsGalois k K] (hw : ¬ IsUnramified k w) : Even (finrank k K) := by by_cases FiniteDimensional k K · exact IsGalois.card_aut_eq_finrank k K ▸ even_card_aut_of_not_isUnramified hw · exact finrank_of_not_finite ‹_› ▸ Even.zero lemma isUnramified_smul_iff : IsUnramified k (σ • w) ↔ IsUnramified k w := by rw [isUnramified_iff, isUnramified_iff, isReal_smul_iff, comap_smul, ← AlgEquiv.toAlgHom_toRingHom, AlgHom.comp_algebraMap] variable (K) in /-- A infinite place of the base field is unramified in a field extension if every infinite place over it is unramified. -/ def IsUnramifiedIn (w : InfinitePlace k) : Prop := ∀ v, comap v (algebraMap k K) = w → IsUnramified k v lemma isUnramifiedIn_comap [IsGalois k K] {w : InfinitePlace K} : (w.comap (algebraMap k K)).IsUnramifiedIn K ↔ w.IsUnramified k := by refine ⟨fun H ↦ H _ rfl, fun H v hv ↦ ?_⟩ obtain ⟨σ, rfl⟩ := exists_smul_eq_of_comap_eq hv rwa [isUnramified_smul_iff] at H lemma even_card_aut_of_not_isUnramifiedIn [IsGalois k K] {w : InfinitePlace k} (hw : ¬ w.IsUnramifiedIn K) : Even (Nat.card Gal(K/k)) := by obtain ⟨v, rfl⟩ := comap_surjective (K := K) w rw [isUnramifiedIn_comap] at hw exact even_card_aut_of_not_isUnramified hw lemma even_finrank_of_not_isUnramifiedIn [IsGalois k K] {w : InfinitePlace k} (hw : ¬ w.IsUnramifiedIn K) : Even (finrank k K) := by obtain ⟨v, rfl⟩ := comap_surjective (K := K) w rw [isUnramifiedIn_comap] at hw exact even_finrank_of_not_isUnramified hw variable (k K) variable [NumberField K] open Finset in open scoped Classical in lemma card_isUnramified [NumberField k] [IsGalois k K] : #{w : InfinitePlace K | w.IsUnramified k} = #{w : InfinitePlace k | w.IsUnramifiedIn K} * finrank k K := by letI := Module.Finite.of_restrictScalars_finite ℚ k K rw [← IsGalois.card_aut_eq_finrank, Finset.card_eq_sum_card_fiberwise (f := (comap · (algebraMap k K))) (t := {w : InfinitePlace k | w.IsUnramifiedIn K}), ← smul_eq_mul, ← sum_const] · refine sum_congr rfl (fun w hw ↦ ?_) obtain ⟨w, rfl⟩ := comap_surjective (K := K) w rw [mem_filter_univ] at hw trans #(MulAction.orbit Gal(K/k) w).toFinset · congr; ext w' rw [mem_filter, mem_filter_univ, Set.mem_toFinset, mem_orbit_iff, @eq_comm _ (comap w' _), and_iff_right_iff_imp] intro e; rwa [← isUnramifiedIn_comap, ← e] · rw [Nat.card_eq_fintype_card, ← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w, ← Nat.card_eq_fintype_card (α := Stab w), card_stabilizer, if_pos, mul_one, Set.toFinset_card] rwa [← isUnramifiedIn_comap] · simp [Set.MapsTo, isUnramifiedIn_comap] open Finset in open scoped Classical in lemma card_isUnramified_compl [NumberField k] [IsGalois k K] : #({w : InfinitePlace K | w.IsUnramified k} : Finset _)ᶜ = #({w : InfinitePlace k | w.IsUnramifiedIn K} : Finset _)ᶜ * (finrank k K / 2) := by letI := Module.Finite.of_restrictScalars_finite ℚ k K rw [← IsGalois.card_aut_eq_finrank, Finset.card_eq_sum_card_fiberwise (f := (comap · (algebraMap k K))) (t := ({w : InfinitePlace k | w.IsUnramifiedIn K} : Finset _)ᶜ), ← smul_eq_mul, ← sum_const] · refine sum_congr rfl (fun w hw ↦ ?_) obtain ⟨w, rfl⟩ := comap_surjective (K := K) w rw [compl_filter, mem_filter_univ] at hw trans Finset.card (MulAction.orbit Gal(K/k) w).toFinset · congr; ext w' rw [mem_filter, compl_filter, mem_filter_univ, @eq_comm _ (comap w' _), Set.mem_toFinset, mem_orbit_iff, and_iff_right_iff_imp] intro e; rwa [← isUnramifiedIn_comap, ← e] · rw [Nat.card_eq_fintype_card, ← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w, ← Nat.card_eq_fintype_card (α := Stab w), InfinitePlace.card_stabilizer, if_neg, Nat.mul_div_cancel _ zero_lt_two, Set.toFinset_card] rwa [← isUnramifiedIn_comap] · simp [Set.MapsTo, isUnramifiedIn_comap] open scoped Classical in lemma card_eq_card_isUnramifiedIn [NumberField k] [IsGalois k K] : Fintype.card (InfinitePlace K) = #{w : InfinitePlace k | w.IsUnramifiedIn K} * finrank k K + #({w : InfinitePlace k | w.IsUnramifiedIn K} : Finset _)ᶜ * (finrank k K / 2) := by rw [← card_isUnramified, ← card_isUnramified_compl, Finset.card_add_card_compl] end NumberField.InfinitePlace open NumberField variable (k : Type*) [Field k] (K : Type*) [Field K] (F : Type*) [Field F] variable [Algebra k K] [Algebra k F] [Algebra K F] [IsScalarTower k K F] /-- A field extension is unramified at infinite places if every infinite place is unramified. -/ class IsUnramifiedAtInfinitePlaces : Prop where isUnramified : ∀ w : InfinitePlace K, w.IsUnramified k instance IsUnramifiedAtInfinitePlaces.id : IsUnramifiedAtInfinitePlaces K K where isUnramified w := w.isUnramified_self lemma IsUnramifiedAtInfinitePlaces.trans [h₁ : IsUnramifiedAtInfinitePlaces k K] [h₂ : IsUnramifiedAtInfinitePlaces K F] : IsUnramifiedAtInfinitePlaces k F where isUnramified w := Eq.trans (IsScalarTower.algebraMap_eq k K F ▸ h₁.1 (w.comap (algebraMap _ _))) (h₂.1 w) lemma IsUnramifiedAtInfinitePlaces.top [h : IsUnramifiedAtInfinitePlaces k F] : IsUnramifiedAtInfinitePlaces K F where isUnramified w := (h.1 w).of_restrictScalars K lemma IsUnramifiedAtInfinitePlaces.bot [h₁ : IsUnramifiedAtInfinitePlaces k F] [Algebra.IsAlgebraic K F] : IsUnramifiedAtInfinitePlaces k K where isUnramified w := by obtain ⟨w, rfl⟩ := InfinitePlace.comap_surjective (K := F) w exact (h₁.1 w).comap K variable {K} lemma NumberField.InfinitePlace.isUnramified [IsUnramifiedAtInfinitePlaces k K] (w : InfinitePlace K) : IsUnramified k w := IsUnramifiedAtInfinitePlaces.isUnramified w variable {k} (K) lemma NumberField.InfinitePlace.isUnramifiedIn [IsUnramifiedAtInfinitePlaces k K] (w : InfinitePlace k) : IsUnramifiedIn K w := fun v _ ↦ v.isUnramified k variable {K} lemma IsUnramifiedAtInfinitePlaces_of_odd_card_aut [IsGalois k K] (h : Odd (Nat.card Gal(K/k))) : IsUnramifiedAtInfinitePlaces k K := ⟨fun _ ↦ not_not.mp (Nat.not_even_iff_odd.2 h ∘ InfinitePlace.even_card_aut_of_not_isUnramified)⟩ lemma IsUnramifiedAtInfinitePlaces_of_odd_finrank [IsGalois k K] (h : Odd (Module.finrank k K)) : IsUnramifiedAtInfinitePlaces k K := ⟨fun _ ↦ not_not.mp (Nat.not_even_iff_odd.2 h ∘ InfinitePlace.even_finrank_of_not_isUnramified)⟩ variable (k K) open Module in lemma IsUnramifiedAtInfinitePlaces.card_infinitePlace [NumberField k] [NumberField K] [IsGalois k K] [IsUnramifiedAtInfinitePlaces k K] : Fintype.card (InfinitePlace K) = Fintype.card (InfinitePlace k) * finrank k K := by classical rw [InfinitePlace.card_eq_card_isUnramifiedIn (k := k) (K := K), Finset.filter_true_of_mem, Finset.card_univ, Finset.card_eq_zero.mpr, zero_mul, add_zero] · exact Finset.compl_univ simp only [Finset.mem_univ, forall_true_left] exact InfinitePlace.isUnramifiedIn K namespace NumberField.InfinitePlace open ComplexEmbedding AbsoluteValue variable {K L : Type*} [Field K] [Field L] [Algebra K L] (w : InfinitePlace L) (v : InfinitePlace K) namespace LiesOver variable [w.1.LiesOver v.1] theorem comap_eq : w.comap (algebraMap K L) = v := by ext simpa only [coe_apply] using AbsoluteValue.ext_iff.1 (LiesOver.comp_eq w.1 v.1) _ theorem mk_embedding_comp : InfinitePlace.mk (w.embedding.comp (algebraMap K L)) = v := by rw [← comap_mk, w.mk_embedding, comap_eq w v] /-- If `w : InfinitePlace L` lies above `v : InfinitePlace K`, then either `w.embedding` extends `v.embedding` as complex embeddings, or `conjugate w.embedding` extends `v.embedding`. -/ theorem embedding_comp_eq_or_conjugate_embedding_comp_eq : w.embedding.comp (algebraMap K L) = v.embedding ∨ (conjugate w.embedding).comp (algebraMap K L) = v.embedding := by cases embedding_mk_eq (w.embedding.comp (algebraMap K L)) with | inl hl => exact .inl (hl ▸ congrArg embedding (mk_embedding_comp w v)) | inr hr => simpa using .inr (hr ▸ congrArg embedding (mk_embedding_comp w v)) variable {v} /-- If `w : InfinitePlace L` lies above `v : InfinitePlace K` and `v` is complex, then so is `w`. -/ theorem isComplex_of_isComplex_under (hv : v.IsComplex) : w.IsComplex := by rw [isComplex_iff, ComplexEmbedding.isReal_iff, RingHom.ext_iff, not_forall] at hv ⊢ obtain ⟨x, hx⟩ := hv use algebraMap K L x rw [← comap_eq w v, ← mk_embedding w, comap_mk] at hx rcases embedding_mk_eq (w.embedding.comp (algebraMap K L)) with (_ | _) <;> aesop /-- If `w : InfinitePlace L` lies above `v : InfinitePlace K` and `w` is real, then so is `v`. -/ theorem isReal_of_isReal_over (hw : w.IsReal) : v.IsReal := by rw [← not_isComplex_iff_isReal] at hw ⊢ exact mt (isComplex_of_isComplex_under w) hw end NumberField.InfinitePlace.LiesOver
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/InfinitePlace/TotallyRealComplex.lean
import Mathlib.NumberTheory.NumberField.InfinitePlace.Ramification /-! # Totally real and totally complex number fields This file defines the type of totally real and totally complex number fields. ## Main Definitions and Results * `NumberField.IsTotallyReal`: a number field `K` is totally real if all of its infinite places are real. In other words, the image of every ring homomorphism `K → ℂ` is a subset of `ℝ`. * `NumberField.IsTotallyComplex`: a number field `K` is totally complex if all of its infinite places are complex. * `NumberField.maximalRealSubfield`: the maximal real subfield of `K`. It is totally real, see `NumberField.isTotallyReal_maximalRealSubfield`, and contains all the other totally real subfields of `K`, see `NumberField.IsTotallyReal.le_maximalRealSubfield` ## Tags number field, infinite places, totally real, totally complex -/ namespace NumberField open InfinitePlace Module section TotallyRealField /- ## Totally real number fields -/ /-- A number field `K` is totally real if all of its infinite places are real. In other words, the image of every ring homomorphism `K → ℂ` is a subset of `ℝ`. -/ @[mk_iff] class IsTotallyReal (K : Type*) [Field K] [NumberField K] where isReal : ∀ v : InfinitePlace K, v.IsReal variable {F : Type*} [Field F] [NumberField F] {K : Type*} [Field K] [NumberField K] theorem nrComplexPlaces_eq_zero_iff : nrComplexPlaces K = 0 ↔ IsTotallyReal K := by simp [Fintype.card_eq_zero_iff, isEmpty_subtype, isTotallyReal_iff] theorem IsTotallyReal.complexEmbedding_isReal [IsTotallyReal K] (φ : K →+* ℂ) : ComplexEmbedding.IsReal φ := isReal_mk_iff.mp <| isReal (InfinitePlace.mk φ) @[simp] theorem IsTotallyReal.mult_eq [IsTotallyReal K] (w : InfinitePlace K) : mult w = 1 := mult_isReal ⟨w, isReal w⟩ theorem IsTotallyReal.ofRingEquiv [IsTotallyReal F] (f : F ≃+* K) : IsTotallyReal K where isReal _ := (isReal_comap_iff f).mp <| IsTotallyReal.isReal _ variable (F K) in theorem IsTotallyReal.of_algebra [IsTotallyReal K] [Algebra F K] : IsTotallyReal F where isReal w := by obtain ⟨W, rfl⟩ : ∃ W : InfinitePlace K, W.comap (algebraMap F K) = w := comap_surjective w exact IsReal.comap _ (IsTotallyReal.isReal W) @[deprecated (since := "2025-05-19")] alias IsTotally.of_algebra := IsTotallyReal.of_algebra instance [IsTotallyReal K] (F : IntermediateField ℚ K) : IsTotallyReal F := IsTotallyReal.of_algebra F K instance [IsTotallyReal K] (F : Subfield K) : IsTotallyReal F := IsTotallyReal.of_algebra F K variable (K) @[simp] theorem IsTotallyReal.nrComplexPlaces_eq_zero [h : IsTotallyReal K] : nrComplexPlaces K = 0 := nrComplexPlaces_eq_zero_iff.mpr h protected theorem IsTotallyReal.finrank [h : IsTotallyReal K] : finrank ℚ K = nrRealPlaces K := by rw [← card_add_two_mul_card_eq_rank, nrComplexPlaces_eq_zero_iff.mpr h, mul_zero, add_zero] instance : IsTotallyReal ℚ where isReal v := by rw [Subsingleton.elim v Rat.infinitePlace] exact Rat.isReal_infinitePlace section maximalRealSubfield open ComplexEmbedding /-- The maximal real subfield of `K`. It is totally real, see `NumberField.isTotallyReal_maximalRealSubfield`, and contains all the other totally real subfields of `K`, see `NumberField.IsTotallyReal.le_maximalRealSubfield`. -/ def maximalRealSubfield : Subfield K where carrier := {x | ∀ φ : K →+* ℂ, star (φ x) = φ x} mul_mem' hx hy _ := by rw [map_mul, star_mul, hx, hy, mul_comm] one_mem' := by simp add_mem' hx hy _ := by rw [map_add, star_add, hx, hy] zero_mem' := by simp neg_mem' := by simp inv_mem' := by simp theorem mem_maximalRealSubfield_iff (x : K) : x ∈ maximalRealSubfield K ↔ ∀ φ : K →+* ℂ, star (φ x) = φ x := .rfl instance isTotallyReal_maximalRealSubfield : IsTotallyReal (maximalRealSubfield K) where isReal w := by rw [InfinitePlace.isReal_iff, ComplexEmbedding.isReal_iff] ext x rw [RingHom.star_apply, ← lift_algebraMap_apply K w.embedding] exact x.prop _ variable {K} theorem IsTotallyReal.le_maximalRealSubfield (E : Subfield K) [IsTotallyReal E] : E ≤ maximalRealSubfield K := by intro x hx φ rw [show φ x = (φ.comp E.subtype) ⟨x, hx⟩ by simp, RCLike.star_def, ← conjugate_coe_eq] refine RingHom.congr_fun ?_ _ exact ComplexEmbedding.isReal_iff.mp <| isReal_mk_iff.mp <| isReal _ theorem isTotallyReal_iff_le_maximalRealSubfield {E : Subfield K} : IsTotallyReal E ↔ E ≤ maximalRealSubfield K := ⟨fun h ↦ h.le_maximalRealSubfield, fun h ↦ IsTotallyReal.ofRingEquiv (RingEquiv.ofBijective _ (Subfield.inclusion h).rangeRestrictField_bijective).symm⟩ instance isTotallyReal_sup {E F : Subfield K} [IsTotallyReal E] [IsTotallyReal F] : IsTotallyReal (E ⊔ F : Subfield K) := by simp_all [isTotallyReal_iff_le_maximalRealSubfield] instance isTotallyReal_iSup {ι : Type*} {k : ι → Subfield K} [∀ i, IsTotallyReal (k i)] : IsTotallyReal (⨆ i, k i : Subfield K) := by simp_all [isTotallyReal_iff_le_maximalRealSubfield] end maximalRealSubfield end TotallyRealField section TotallyComplexField /- ## Totally complex number fields -/ open InfinitePlace /-- A number field `K` is totally complex if all of its infinite places are complex. -/ @[mk_iff] class IsTotallyComplex (K : Type*) [Field K] [NumberField K] where isComplex : ∀ v : InfinitePlace K, v.IsComplex variable {F : Type*} [Field F] {K : Type*} [Field K] [NumberField K] [Algebra F K] theorem nrRealPlaces_eq_zero_iff : nrRealPlaces K = 0 ↔ IsTotallyComplex K := by simp [Fintype.card_eq_zero_iff, isEmpty_subtype, isTotallyComplex_iff] theorem IsTotallyComplex.complexEmbedding_not_isReal [IsTotallyComplex K] (φ : K →+* ℂ) : ¬ ComplexEmbedding.IsReal φ := isReal_mk_iff.not.mp <| not_isReal_iff_isComplex.mpr <| isComplex (InfinitePlace.mk φ) @[simp] theorem IsTotallyComplex.mult_eq [IsTotallyComplex K] (w : InfinitePlace K) : mult w = 2 := mult_isComplex ⟨w, isComplex w⟩ variable (K) @[simp] theorem IsTotallyComplex.nrRealPlaces_eq_zero [h : IsTotallyComplex K] : nrRealPlaces K = 0 := nrRealPlaces_eq_zero_iff.mpr h protected theorem IsTotallyComplex.finrank [h : IsTotallyComplex K] : finrank ℚ K = 2 * nrComplexPlaces K := by rw [← card_add_two_mul_card_eq_rank, nrRealPlaces_eq_zero_iff.mpr h, zero_add] end TotallyComplexField end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Units/Basic.lean
import Mathlib.GroupTheory.Torsion import Mathlib.NumberTheory.NumberField.InfinitePlace.Basic import Mathlib.RingTheory.LocalRing.RingHom.Basic import Mathlib.RingTheory.RootsOfUnity.Complex /-! # Units of a number field We prove some basic results on the group `(𝓞 K)ˣ` of units of the ring of integers `𝓞 K` of a number field `K` and its torsion subgroup. ## Main definition * `NumberField.Units.torsion`: the torsion subgroup of a number field. ## Main results * `NumberField.isUnit_iff_norm`: an algebraic integer `x : 𝓞 K` is a unit if and only if `|norm ℚ x| = 1`. * `NumberField.Units.mem_torsion`: a unit `x : (𝓞 K)ˣ` is torsion iff `w x = 1` for all infinite places `w` of `K`. ## Tags number field, units -/ open scoped NumberField noncomputable section open NumberField Units section Rat theorem Rat.RingOfIntegers.isUnit_iff {x : 𝓞 ℚ} : IsUnit x ↔ (x : ℚ) = 1 ∨ (x : ℚ) = -1 := by simp_rw [(isUnit_map_iff (Rat.ringOfIntegersEquiv : 𝓞 ℚ →+* ℤ) x).symm, Int.isUnit_iff, RingEquiv.coe_toRingHom, RingEquiv.map_eq_one_iff, RingEquiv.map_eq_neg_one_iff, ← Subtype.coe_injective.eq_iff]; rfl end Rat variable (K : Type*) [Field K] section IsUnit variable {K} theorem NumberField.isUnit_iff_norm [NumberField K] {x : 𝓞 K} : IsUnit x ↔ |(RingOfIntegers.norm ℚ x : ℚ)| = 1 := by convert (RingOfIntegers.isUnit_norm ℚ (F := K)).symm rw [← abs_one, abs_eq_abs, ← Rat.RingOfIntegers.isUnit_iff] end IsUnit namespace NumberField.Units section coe instance : CoeHTC (𝓞 K)ˣ K := ⟨fun x => algebraMap _ K (Units.val x)⟩ theorem coe_injective : Function.Injective ((↑) : (𝓞 K)ˣ → K) := RingOfIntegers.coe_injective.comp Units.val_injective variable {K} theorem coe_coe (u : (𝓞 K)ˣ) : ((u : 𝓞 K) : K) = (u : K) := rfl theorem coe_mul (x y : (𝓞 K)ˣ) : ((x * y : (𝓞 K)ˣ) : K) = (x : K) * (y : K) := rfl theorem coe_pow (x : (𝓞 K)ˣ) (n : ℕ) : ((x ^ n : (𝓞 K)ˣ) : K) = (x : K) ^ n := by rw [← map_pow, ← val_pow_eq_pow_val] theorem coe_zpow (x : (𝓞 K)ˣ) (n : ℤ) : (↑(x ^ n) : K) = (x : K) ^ n := by change ((Units.coeHom K).comp (map (algebraMap (𝓞 K) K))) (x ^ n) = _ exact map_zpow _ x n theorem coe_one : ((1 : (𝓞 K)ˣ) : K) = (1 : K) := rfl theorem coe_neg_one : ((-1 : (𝓞 K)ˣ) : K) = (-1 : K) := rfl theorem coe_ne_zero (x : (𝓞 K)ˣ) : (x : K) ≠ 0 := Subtype.coe_injective.ne_iff.mpr (_root_.Units.ne_zero x) end coe variable {K} /-- The group homomorphism `(𝓞 K)ˣ →* ℂˣ` induced by a complex embedding of `K`. -/ protected def complexEmbedding (φ : K →+* ℂ) : (𝓞 K)ˣ →* ℂˣ := (map φ).comp (map (algebraMap (𝓞 K) K).toMonoidHom) @[simp] protected theorem complexEmbedding_apply (φ : K →+* ℂ) (u : (𝓞 K)ˣ) : Units.complexEmbedding φ u = φ u := rfl protected theorem complexEmbedding_injective (φ : K →+* ℂ) : Function.Injective (Units.complexEmbedding φ) := (map_injective φ.injective).comp (map_injective RingOfIntegers.coe_injective) @[simp] protected theorem complexEmbedding_inj (φ : K →+* ℂ) (u v : (𝓞 K)ˣ) : Units.complexEmbedding φ u = Units.complexEmbedding φ v ↔ u = v := (Units.complexEmbedding_injective φ).eq_iff open NumberField.InfinitePlace variable (K) @[simp] protected theorem norm [NumberField K] (x : (𝓞 K)ˣ) : |Algebra.norm ℚ (x : K)| = 1 := by rw [← RingOfIntegers.coe_norm, isUnit_iff_norm.mp x.isUnit] variable {K} in theorem pos_at_place (x : (𝓞 K)ˣ) (w : InfinitePlace K) : 0 < w x := pos_iff.mpr (coe_ne_zero x) variable {K} in theorem sum_mult_mul_log [NumberField K] (x : (𝓞 K)ˣ) : ∑ w : InfinitePlace K, w.mult * Real.log (w x) = 0 := by simpa [Units.norm, Real.log_prod, Real.log_pow] using congr_arg Real.log (prod_eq_abs_norm (x : K)) section torsion /-- The torsion subgroup of the group of units. -/ def torsion : Subgroup (𝓞 K)ˣ := CommGroup.torsion (𝓞 K)ˣ instance : Nonempty (torsion K) := One.instNonempty variable [NumberField K] theorem mem_torsion {x : (𝓞 K)ˣ} : x ∈ torsion K ↔ ∀ w : InfinitePlace K, w x = 1 := by rw [eq_iff_eq (x : K) 1, torsion, CommGroup.mem_torsion] refine ⟨fun hx φ ↦ (((φ.comp <| algebraMap (𝓞 K) K).toMonoidHom.comp <| Units.coeHom _).isOfFinOrder hx).norm_eq_one, fun h ↦ isOfFinOrder_iff_pow_eq_one.2 ?_⟩ obtain ⟨n, hn, hx⟩ := Embeddings.pow_eq_one_of_norm_eq_one K ℂ x.val.isIntegral_coe h exact ⟨n, hn, by ext; rw [NumberField.RingOfIntegers.coe_eq_algebraMap, coe_pow, hx, NumberField.RingOfIntegers.coe_eq_algebraMap, coe_one]⟩ /-- The torsion subgroup is finite. -/ instance : Fintype (torsion K) := by refine @Fintype.ofFinite _ (Set.finite_coe_iff.mpr ?_) refine Set.Finite.of_finite_image ?_ (coe_injective K).injOn refine (Embeddings.finite_of_norm_le K ℂ 1).subset (fun a ⟨u, ⟨h_tors, h_ua⟩⟩ => ⟨?_, fun φ => ?_⟩) · rw [← h_ua] exact u.val.prop · rw [← h_ua] exact le_of_eq ((eq_iff_eq _ 1).mp ((mem_torsion K).mp h_tors) φ) /-- The torsion subgroup is cyclic. -/ instance : IsCyclic (torsion K) := subgroup_units_cyclic _ /-- The order of the torsion subgroup. -/ def torsionOrder [NumberField K] : ℕ := Fintype.card (torsion K) instance [NumberField K] : NeZero (torsionOrder K) := inferInstanceAs (NeZero (Fintype.card (torsion K))) theorem torsionOrder_ne_zero : torsionOrder K ≠ 0 := NeZero.ne (torsionOrder K) theorem torsionOrder_pos : 0 < torsionOrder K := Nat.pos_of_neZero (torsionOrder K) /-- If `k` does not divide `torsionOrder` then there are no nontrivial roots of unity of order dividing `k`. -/ theorem rootsOfUnity_eq_one {k : ℕ+} (hc : Nat.Coprime k (torsionOrder K)) {ζ : (𝓞 K)ˣ} : ζ ∈ rootsOfUnity k (𝓞 K) ↔ ζ = 1 := by rw [mem_rootsOfUnity] refine ⟨fun h => ?_, fun h => by rw [h, one_pow]⟩ refine orderOf_eq_one_iff.mp (Nat.eq_one_of_dvd_coprimes hc ?_ ?_) · exact orderOf_dvd_of_pow_eq_one h · have hζ : ζ ∈ torsion K := by rw [torsion, CommGroup.mem_torsion, isOfFinOrder_iff_pow_eq_one] exact ⟨k, k.prop, h⟩ rw [orderOf_submonoid (⟨ζ, hζ⟩ : torsion K)] exact orderOf_dvd_card /-- The group of roots of unity of order dividing `torsionOrder` is equal to the torsion group. -/ theorem rootsOfUnity_eq_torsion : rootsOfUnity (torsionOrder K) (𝓞 K) = torsion K := by ext ζ rw [torsion, mem_rootsOfUnity] refine ⟨fun h => ?_, fun h => ?_⟩ · rw [CommGroup.mem_torsion, isOfFinOrder_iff_pow_eq_one] exact ⟨torsionOrder K, torsionOrder_pos K, h⟩ · exact Subtype.ext_iff.mp (@pow_card_eq_one (torsion K) _ _ ⟨ζ, h⟩) /-- The image of `torsion K` by a complex embedding is the group of complex roots of unity of order `torsionOrder K`. -/ theorem map_complexEmbedding_torsion (φ : K →+* ℂ) : (torsion K).map (Units.complexEmbedding φ) = rootsOfUnity (torsionOrder K) ℂ := by apply Subgroup.eq_of_le_of_card_ge · rw [← rootsOfUnity_eq_torsion] exact map_rootsOfUnity _ (torsionOrder K) · let e := ((torsion K).equivMapOfInjective (Units.complexEmbedding φ) (Units.complexEmbedding_injective φ)).symm.toEquiv rw [Nat.card_eq_fintype_card, Complex.card_rootsOfUnity, Nat.card_congr e, torsionOrder, Nat.card_eq_fintype_card] theorem even_torsionOrder : Even (torsionOrder K) := by suffices orderOf (⟨-1, neg_one_mem_torsion⟩ : torsion K) = 2 by rw [even_iff_two_dvd, ← this] exact orderOf_dvd_card rw [← Subgroup.orderOf_coe, ← orderOf_units, Units.val_neg, val_one, orderOf_neg_one, ringChar.eq_zero, if_neg (by decide)] section odd variable {K} theorem torsion_eq_one_or_neg_one_of_odd_finrank (h : Odd (Module.finrank ℚ K)) (x : torsion K) : (x : (𝓞 K)ˣ) = 1 ∨ (x : (𝓞 K)ˣ) = -1 := by by_cases! hc : 2 < orderOf (x : (𝓞 K)ˣ) · rw [← orderOf_units, ← orderOf_submonoid] at hc linarith [IsPrimitiveRoot.nrRealPlaces_eq_zero_of_two_lt hc (IsPrimitiveRoot.orderOf (x.1 : K)), NumberField.InfinitePlace.nrRealPlaces_pos_of_odd_finrank h] · interval_cases hi : orderOf (x : (𝓞 K)ˣ) · linarith [orderOf_pos_iff.2 ((CommGroup.mem_torsion _ x.1).1 x.2)] · exact Or.intro_left _ (orderOf_eq_one_iff.1 hi) · rw [← orderOf_units, CharP.orderOf_eq_two_iff 0 (by decide)] at hi simp [← Units.val_inj, ← Units.val_inj, Units.val_neg, Units.val_one, hi] theorem torsionOrder_eq_two_of_odd_finrank (h : Odd (Module.finrank ℚ K)) : torsionOrder K = 2 := by classical refine (Finset.card_eq_two.2 ⟨1, ⟨-1, neg_one_mem_torsion⟩, by simp [← Subtype.coe_ne_coe], Finset.ext fun x ↦ ⟨fun _ ↦ ?_, fun _ ↦ Finset.mem_univ _⟩⟩) rw [Finset.mem_insert, Finset.mem_singleton, ← Subtype.val_inj, ← Subtype.val_inj] exact torsion_eq_one_or_neg_one_of_odd_finrank h x end odd end torsion end Units end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Units/Regulator.lean
import Mathlib.Algebra.Module.ZLattice.Covolume import Mathlib.LinearAlgebra.Matrix.Determinant.Misc import Mathlib.NumberTheory.NumberField.Units.DirichletTheorem /-! # Regulator of a number field We define and prove basic results about the regulator of a number field `K`. ## Main definitions and results * `NumberField.Units.regOfFamily`: the regulator of a family of units of `K`. * `NumberField.Units.regulator`: the regulator of the number field `K`. * `Number.Field.Units.regOfFamily_eq_det`: For any infinite place `w'`, the regulator of the family `u` is equal to the absolute value of the determinant of the matrix `(mult w * log w (u i)))_i, w` where `w` runs through the infinite places distinct from `w'`. * `Number.Field.Units.regOfFamily_div_regOfFamily`: Let `u` and `v` be two families of units. Assume that the subgroup `U` generated by `u` and `torsion K` is contained in the subgroup `V` generated by `v` and `torsion K`. Then the ratio `regOfFamily u / regOfFamily v` is equal to the index of `U` inside `V`. ## Tags number field, units, regulator -/ open scoped NumberField noncomputable section namespace NumberField.Units variable (K : Type*) [Field K] open MeasureTheory NumberField.InfinitePlace Module Submodule NumberField NumberField.Units.dirichletUnitTheorem variable [NumberField K] open scoped Classical in /-- An `equiv` between `Fin (rank K)`, used to index the family of units, and `{w // w ≠ w₀}` the index of the `logSpace`. -/ def equivFinRank : Fin (rank K) ≃ {w : InfinitePlace K // w ≠ w₀} := Fintype.equivOfCardEq <| by rw [Fintype.card_subtype_compl, Fintype.card_ofSubsingleton, Fintype.card_fin, rank] section regOfFamily open Matrix variable {K} /-- A family of units is of maximal rank if its image by `logEmbedding` is linearly independent over `ℝ`. -/ abbrev IsMaxRank (u : Fin (rank K) → (𝓞 K)ˣ) : Prop := LinearIndependent ℝ (fun i ↦ logEmbedding K (Additive.ofMul (u i))) open scoped Classical in /-- The images by `logEmbedding` of a family of units of maximal rank form a basis of `logSpace K`. -/ def basisOfIsMaxRank {u : Fin (rank K) → (𝓞 K)ˣ} (hu : IsMaxRank u) : Basis (Fin (rank K)) ℝ (logSpace K) := (basisOfPiSpaceOfLinearIndependent ((linearIndependent_equiv (equivFinRank K).symm).mpr hu)).reindex (equivFinRank K).symm @[simp] theorem basisOfIsMaxRank_apply {u : Fin (rank K) → (𝓞 K)ˣ} (hu : IsMaxRank u) (i : Fin (rank K)) : (basisOfIsMaxRank hu) i = logEmbedding K (Additive.ofMul (u i)) := by simp [basisOfIsMaxRank, Basis.coe_reindex, Equiv.symm_symm, Function.comp_apply, coe_basisOfPiSpaceOfLinearIndependent] theorem span_basisOfIsMaxRank {u : Fin (rank K) → (𝓞 K)ˣ} (hu : IsMaxRank u) : (span ℤ (Set.range (basisOfIsMaxRank hu))).toAddSubgroup = AddSubgroup.map (logEmbedding K) (Subgroup.closure (Set.range u)).toAddSubgroup := by rw [Subgroup.toAddSubgroup_closure, AddMonoidHom.map_closure, ← span_int_eq_addSubgroupClosure] congr; ext; simp theorem finiteIndex_iff_sup_torsion_finiteIndex (s : Subgroup (𝓞 K)ˣ) : s.FiniteIndex ↔ (s ⊔ torsion K).FiniteIndex := by refine ⟨fun h ↦ Subgroup.finiteIndex_of_le le_sup_left, fun h ↦ ?_⟩ rw [Subgroup.finiteIndex_iff, ← Subgroup.relIndex_mul_index (le_sup_left : s ≤ s ⊔ torsion K)] refine Nat.mul_ne_zero ?_ (Subgroup.finiteIndex_iff.mp h) rw [Subgroup.relIndex_sup_left] exact Subgroup.FiniteIndex.index_ne_zero open Subgroup in /-- A family of units is of maximal rank iff the index of the subgroup it generates has finite index. -/ theorem isMaxRank_iff_closure_finiteIndex {u : Fin (rank K) → (𝓞 K)ˣ} : IsMaxRank u ↔ (closure (Set.range u)).FiniteIndex := by classical have h₁ : (closure (Set.range u) ⊔ torsion K).index ≠ 0 ↔ Finite (unitLattice K ⧸ span ℤ (Set.range ((logEmbeddingEquiv K) ∘ Additive.toMul.symm ∘ QuotientGroup.mk ∘ u))) := by change _ ↔ Finite ((unitLattice K).toAddSubgroup ⧸ (span ℤ (Set.range _)).toAddSubgroup) rw [← AddSubgroup.index_ne_zero_iff_finite] have := index_map (closure (Set.range u)) (QuotientGroup.mk' (torsion K)) rw [QuotientGroup.ker_mk', QuotientGroup.range_mk', index_top, mul_one] at this rw [← this, ← index_toAddSubgroup, ← AddSubgroup.index_map_equiv _ (logEmbeddingEquiv K).toAddEquiv, Set.range_comp, ← map_span (logEmbeddingEquiv K), ← map_coe_toLinearMap, map_toAddSubgroup, span_int_eq_addSubgroupClosure, MonoidHom.map_closure, toAddSubgroup_closure, Set.range_comp, Set.range_comp, QuotientGroup.coe_mk', ← Equiv.image_symm_eq_preimage] rfl have h₂ : DiscreteTopology (span ℤ (Set.range fun i ↦ (logEmbedding K) (Additive.ofMul (u i)))) := by refine DiscreteTopology.of_subset (inferInstance : DiscreteTopology (unitLattice K)) ?_ rw [SetLike.coe_subset_coe, Submodule.span_le] rintro _ ⟨i, rfl⟩ exact ⟨Additive.ofMul (u i), mem_top, rfl⟩ rw [finiteIndex_iff_sup_torsion_finiteIndex, finiteIndex_iff, h₁, finiteQuotient_iff, unitLattice_rank, ← Set.finrank, IsMaxRank, linearIndependent_iff_card_eq_finrank_span, Real.finrank_eq_int_finrank_of_discrete h₂, Set.finrank, Set.finrank, ← finrank_map_subtype_eq, map_span, ← Set.range_comp', eq_comm] simp open scoped Classical in /-- The regulator of a family of units of `K`. -/ def regOfFamily (u : Fin (rank K) → (𝓞 K)ˣ) : ℝ := if hu : IsMaxRank u then ZLattice.covolume (span ℤ (Set.range (basisOfIsMaxRank hu))) else 0 theorem regOfFamily_eq_zero {u : Fin (rank K) → (𝓞 K)ˣ} (hu : ¬ IsMaxRank u) : regOfFamily u = 0 := by rw [regOfFamily, dif_neg hu] open scoped Classical in theorem regOfFamily_of_isMaxRank {u : Fin (rank K) → (𝓞 K)ˣ} (hu : IsMaxRank u) : regOfFamily u = ZLattice.covolume (span ℤ (Set.range (basisOfIsMaxRank hu))) := by rw [regOfFamily, dif_pos hu] theorem regOfFamily_pos {u : Fin (rank K) → (𝓞 K)ˣ} (hu : IsMaxRank u) : 0 < regOfFamily u := by classical rw [regOfFamily_of_isMaxRank hu] exact ZLattice.covolume_pos _ volume theorem regOfFamily_ne_zero {u : Fin (rank K) → (𝓞 K)ˣ} (hu : IsMaxRank u) : regOfFamily u ≠ 0 := (regOfFamily_pos hu).ne' theorem regOfFamily_ne_zero_iff {u : Fin (rank K) → (𝓞 K)ˣ} : regOfFamily u ≠ 0 ↔ IsMaxRank u := ⟨by simpa using (fun hu ↦ regOfFamily_eq_zero hu).mt, fun hu ↦ regOfFamily_ne_zero hu⟩ open scoped Classical in theorem regOfFamily_eq_det' (u : Fin (rank K) → (𝓞 K)ˣ) : regOfFamily u = |(of fun i ↦ logEmbedding K (Additive.ofMul (u ((equivFinRank K).symm i)))).det| := by by_cases hu : IsMaxRank u · rw [regOfFamily_of_isMaxRank hu, ZLattice.covolume_eq_det _ (((basisOfIsMaxRank hu).restrictScalars ℤ).reindex (equivFinRank K)), Basis.coe_reindex] congr 3 with i simp [basisOfIsMaxRank_apply hu] · rw [regOfFamily_eq_zero hu, det_eq_zero_of_not_linearIndependent_rows, abs_zero] rwa [IsMaxRank, ← linearIndependent_equiv (equivFinRank K).symm] at hu open scoped Classical in /-- Let `u : Fin (rank K) → (𝓞 K)ˣ` be a family of units and let `w₁` and `w₂` be two infinite places. Then, the two square matrices with entries `(mult w * log w (u i))_i` where `w ≠ w_j` for `j = 1, 2` have the same determinant in absolute value. -/ theorem abs_det_eq_abs_det (u : Fin (rank K) → (𝓞 K)ˣ) {w₁ w₂ : InfinitePlace K} (e₁ : {w // w ≠ w₁} ≃ Fin (rank K)) (e₂ : {w // w ≠ w₂} ≃ Fin (rank K)) : |(of fun i w : {w // w ≠ w₁} ↦ (mult w.val : ℝ) * (w.val (u (e₁ i) : K)).log).det| = |(of fun i w : {w // w ≠ w₂} ↦ (mult w.val : ℝ) * (w.val (u (e₂ i) : K)).log).det| := by -- We construct an equiv `Fin (rank K + 1) ≃ InfinitePlace K` from `e₂.symm` let f : Fin (rank K + 1) ≃ InfinitePlace K := (finSuccEquiv _).trans ((Equiv.optionSubtype _).symm e₁.symm).val -- And `g` corresponds to the restriction of `f⁻¹` to `{w // w ≠ w₂}` let g : {w // w ≠ w₂} ≃ Fin (rank K) := (Equiv.subtypeEquiv f.symm (fun _ ↦ by simp [f])).trans (finSuccAboveEquiv (f.symm w₂)).symm have h_col := congr_arg abs <| det_permute (g.trans e₂.symm) (of fun i w : {w // w ≠ w₂} ↦ (mult w.val : ℝ) * (w.val (u (e₂ i) : K)).log) rw [abs_mul, ← Int.cast_abs, Equiv.Perm.sign_abs, Int.cast_one, one_mul] at h_col rw [← h_col] have h := congr_arg abs <| submatrix_succAbove_det_eq_negOnePow_submatrix_succAbove_det' (of fun i w ↦ (mult (f w) : ℝ) * ((f w) (u i)).log) ?_ 0 (f.symm w₂) · rw [← det_reindex_self e₁, ← det_reindex_self g] · rw [Units.smul_def, abs_zsmul, Int.abs_negOnePow, one_smul] at h convert h · ext; simp only [ne_eq, reindex_apply, submatrix_apply, of_apply, Equiv.apply_symm_apply, Equiv.trans_apply, Fin.succAbove_zero, id_eq, finSuccEquiv_succ, Equiv.optionSubtype_symm_apply_apply_coe, f] · ext; simp only [ne_eq, Equiv.coe_trans, reindex_apply, submatrix_apply, Function.comp_apply, Equiv.apply_symm_apply, id_eq, of_apply]; rfl · intro _ simp_rw [of_apply, ← Real.log_pow] rw [← Real.log_prod, Equiv.prod_comp f (fun w ↦ (w (u _) ^ (mult w))), prod_eq_abs_norm, Units.norm, Rat.cast_one, Real.log_one] exact fun _ _ ↦ pow_ne_zero _ <| (map_ne_zero _).mpr (coe_ne_zero _) open scoped Classical in /-- For any infinite place `w'`, the regulator of the family `u` is equal to the absolute value of the determinant of the matrix with entries `(mult w * log w (u i))_i` for `w ≠ w'`. -/ theorem regOfFamily_eq_det (u : Fin (rank K) → (𝓞 K)ˣ) (w' : InfinitePlace K) (e : {w // w ≠ w'} ≃ Fin (rank K)) : regOfFamily u = |(of fun i w : {w // w ≠ w'} ↦ (mult w.val : ℝ) * Real.log (w.val (u (e i) : K))).det| := by simp [regOfFamily_eq_det', abs_det_eq_abs_det u e (equivFinRank K).symm, logEmbedding] open scoped Classical in /-- The degree of `K` times the regulator of the family `u` is equal to the absolute value of the determinant of the matrix whose columns are `(mult w * log w (fundSystem K i))_i, w` and the column `(mult w)_w`. -/ theorem finrank_mul_regOfFamily_eq_det (u : Fin (rank K) → (𝓞 K)ˣ) (w' : InfinitePlace K) (e : {w // w ≠ w'} ≃ Fin (rank K)) : finrank ℚ K * regOfFamily u = |(of (fun i w : InfinitePlace K ↦ if h : i = w' then (w.mult : ℝ) else w.mult * (w (u (e ⟨i, h⟩))).log)).det| := by let f : Fin (rank K + 1) ≃ InfinitePlace K := (finSuccEquiv _).trans ((Equiv.optionSubtype _).symm e.symm).val let g : {w // w ≠ w'} ≃ Fin (rank K) := (Equiv.subtypeEquiv f.symm (fun _ ↦ by simp [f])).trans (finSuccAboveEquiv (f.symm w')).symm rw [← det_reindex_self f.symm, det_eq_sum_row_mul_submatrix_succAbove_succAbove_det _ (f.symm w') (f.symm w'), abs_mul, abs_mul, abs_neg_one_pow, one_mul] · simp_rw [reindex_apply, submatrix_submatrix, ← f.symm.sum_comp, f.symm_symm, submatrix_apply, Function.comp_def, Equiv.apply_symm_apply, of_apply, dif_pos, ← Nat.cast_sum, sum_mult_eq, Nat.abs_cast] rw [regOfFamily_eq_det u w' e, ← Matrix.det_reindex_self g] congr with i j rw [reindex_apply, submatrix_apply, submatrix_apply, of_apply, of_apply, dif_neg] rfl · simp_rw [Equiv.forall_congr_left f, ← f.symm.sum_comp, reindex_apply, submatrix_apply, of_apply, f.symm_symm, f.apply_symm_apply, Finset.sum_dite_irrel, ne_eq, EmbeddingLike.apply_eq_iff_eq] intro _ h rw [dif_neg h, sum_mult_mul_log] end regOfFamily section regulator open scoped Classical in /-- The regulator of a number field `K`. -/ def regulator : ℝ := ZLattice.covolume (unitLattice K) theorem isMaxRank_fundSystem : IsMaxRank (fundSystem K) := by classical convert ((basisUnitLattice K).ofZLatticeBasis ℝ (unitLattice K)).linearIndependent rw [logEmbedding_fundSystem, Basis.ofZLatticeBasis_apply] open scoped Classical in theorem basisOfIsMaxRank_fundSystem : basisOfIsMaxRank (isMaxRank_fundSystem K) = (basisUnitLattice K).ofZLatticeBasis ℝ := by ext rw [Basis.ofZLatticeBasis_apply, basisOfIsMaxRank_apply, logEmbedding_fundSystem] theorem regulator_eq_regOfFamily_fundSystem : regulator K = regOfFamily (fundSystem K) := by classical rw [regOfFamily_of_isMaxRank (isMaxRank_fundSystem K), regulator, ← (basisUnitLattice K).ofZLatticeBasis_span ℝ, basisOfIsMaxRank_fundSystem] theorem regulator_pos : 0 < regulator K := regulator_eq_regOfFamily_fundSystem K ▸ regOfFamily_pos (isMaxRank_fundSystem K) theorem regulator_ne_zero : regulator K ≠ 0 := (regulator_pos K).ne' open scoped Classical in theorem regulator_eq_det' : regulator K = |(Matrix.of fun i ↦ logEmbedding K (Additive.ofMul (fundSystem K ((equivFinRank K).symm i)))).det| := by rw [regulator_eq_regOfFamily_fundSystem, regOfFamily_eq_det'] open scoped Classical in /-- For any infinite place `w'`, the regulator is equal to the absolute value of the determinant of the matrix with entries `(mult w * log w (fundSystem K i))_i` for `w ≠ w'`. -/ theorem regulator_eq_det (w' : InfinitePlace K) (e : {w // w ≠ w'} ≃ Fin (rank K)) : regulator K = |(Matrix.of fun i w : {w // w ≠ w'} ↦ (mult w.val : ℝ) * Real.log (w.val (fundSystem K (e i) : K))).det| := by rw [regulator_eq_regOfFamily_fundSystem, regOfFamily_eq_det] open scoped Classical in /-- The degree of `K` times the regulator of `K` is equal to the absolute value of the determinant of the matrix whose columns are `(mult w * log w (fundSystem K i))_i, w` and the column `(mult w)_w`. -/ theorem finrank_mul_regulator_eq_det (w' : InfinitePlace K) (e : {w // w ≠ w'} ≃ Fin (rank K)) : finrank ℚ K * regulator K = |(Matrix.of (fun i w : InfinitePlace K ↦ if h : i = w' then (w.mult : ℝ) else w.mult * (w (fundSystem K (e ⟨i, h⟩))).log)).det| := by rw [regulator_eq_regOfFamily_fundSystem, finrank_mul_regOfFamily_eq_det] end regulator section index open ZLattice variable {K} /-- Let `u` and `v` be two families of units. Assume that the subgroup `U` generated by `u` and `torsion K` is contained in the subgroup `V` generated by `v` and `torsion K`. Then the ratio `regOfFamily u / regOfFamily v` is equal to the index of `U` inside `V`. -/ theorem regOfFamily_div_regOfFamily {u v : Fin (rank K) → (𝓞 K)ˣ} (hv : IsMaxRank v) (h : Subgroup.closure (Set.range u) ⊔ torsion K ≤ Subgroup.closure (Set.range v) ⊔ torsion K) : regOfFamily u / regOfFamily v = (Subgroup.closure (Set.range u) ⊔ (torsion K)).relIndex (Subgroup.closure (Set.range v) ⊔ (torsion K)) := by classical by_cases hu : IsMaxRank u · have : span ℤ (Set.range (basisOfIsMaxRank hu)) ≤ span ℤ (Set.range (basisOfIsMaxRank hv)) := by rw [← toAddSubgroup_le, span_basisOfIsMaxRank hu, span_basisOfIsMaxRank hv, ← map_logEmbedding_sup_torsion (Subgroup.closure (Set.range u)).toAddSubgroup, ← map_logEmbedding_sup_torsion (Subgroup.closure (Set.range v)).toAddSubgroup, ← SupHomClass.map_sup, ← SupHomClass.map_sup] exact AddSubgroup.map_mono <| (OrderIso.le_iff_le Subgroup.toAddSubgroup).mpr h rw [regOfFamily_of_isMaxRank hu, regOfFamily_of_isMaxRank hv, covolume_div_covolume_eq_relIndex _ _ this, span_basisOfIsMaxRank hu, span_basisOfIsMaxRank hv, AddSubgroup.relIndex_map_map, logEmbedding_ker, ← OrderIso.map_sup, ← OrderIso.map_sup, ← Subgroup.relIndex_toAddSubgroup] · rw [regOfFamily_eq_zero hu, zero_div, eq_comm, Nat.cast_eq_zero] have : (Subgroup.closure (Set.range v) ⊔ torsion K).index ≠ 0 := by rw [← Subgroup.finiteIndex_iff, ← finiteIndex_iff_sup_torsion_finiteIndex] exact isMaxRank_iff_closure_finiteIndex.mp hv rwa [← mul_eq_zero_iff_right this, Subgroup.relIndex_mul_index h, ← Subgroup.not_finiteIndex_iff, ← finiteIndex_iff_sup_torsion_finiteIndex, ← isMaxRank_iff_closure_finiteIndex.not] /-- Let `u` be a family of units. Then the ratio `regOfFamily u / regulator K` is equal to the index of the subgroup generated by `u` and `torsion K` inside the group of units of `K`. -/ theorem regOfFamily_div_regulator (u : Fin (rank K) → (𝓞 K)ˣ) : regOfFamily u / regulator K = (Subgroup.closure (Set.range u) ⊔ (torsion K)).index := by rw [regulator_eq_regOfFamily_fundSystem, regOfFamily_div_regOfFamily (isMaxRank_fundSystem K) (by simp only [closure_fundSystem_sup_torsion_eq_top, le_top]), closure_fundSystem_sup_torsion_eq_top, Subgroup.relIndex_top_right] end index end Units end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean
import Mathlib.LinearAlgebra.Matrix.Gershgorin import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody import Mathlib.NumberTheory.NumberField.Units.Basic /-! # Dirichlet theorem on the group of units of a number field This file is devoted to the proof of Dirichlet unit theorem that states that the group of units `(𝓞 K)ˣ` of units of the ring of integers `𝓞 K` of a number field `K` modulo its torsion subgroup is a free `ℤ`-module of rank `card (InfinitePlace K) - 1`. ## Main definitions * `NumberField.Units.rank`: the unit rank of the number field `K`. * `NumberField.Units.fundSystem`: a fundamental system of units of `K`. * `NumberField.Units.basisModTorsion`: a `ℤ`-basis of `(𝓞 K)ˣ ⧸ (torsion K)` as an additive `ℤ`-module. ## Main results * `NumberField.Units.rank_modTorsion`: the `ℤ`-rank of `(𝓞 K)ˣ ⧸ (torsion K)` is equal to `card (InfinitePlace K) - 1`. * `NumberField.Units.exist_unique_eq_mul_prod`: **Dirichlet Unit Theorem**. Any unit of `𝓞 K` can be written uniquely as the product of a root of unity and powers of the units of the fundamental system `fundSystem`. ## Tags number field, units, Dirichlet unit theorem -/ noncomputable section open Module NumberField NumberField.InfinitePlace NumberField.Units variable (K : Type*) [Field K] namespace NumberField.Units.dirichletUnitTheorem /-! ### Dirichlet Unit Theorem We define a group morphism from `(𝓞 K)ˣ` to `logSpace K`, defined as `{w : InfinitePlace K // w ≠ w₀} → ℝ` where `w₀` is a distinguished (arbitrary) infinite place, prove that its kernel is the torsion subgroup (see `logEmbedding_eq_zero_iff`) and that its image, called `unitLattice`, is a full `ℤ`-lattice. It follows that `unitLattice` is a free `ℤ`-module (see `instModuleFree_unitLattice`) of rank `card (InfinitePlaces K) - 1` (see `unitLattice_rank`). To prove that the `unitLattice` is a full `ℤ`-lattice, we need to prove that it is discrete (see `unitLattice_inter_ball_finite`) and that it spans the full space over `ℝ` (see `unitLattice_span_eq_top`); this is the main part of the proof, see the section `span_top` below for more details. -/ open Finset variable {K} section NumberField variable [NumberField K] /-- The distinguished infinite place. -/ def w₀ : InfinitePlace K := (inferInstance : Nonempty (InfinitePlace K)).some variable (K) in /-- The `logSpace` is defined as `{w : InfinitePlace K // w ≠ w₀} → ℝ` where `w₀` is the distinguished infinite place. -/ abbrev logSpace := {w : InfinitePlace K // w ≠ w₀} → ℝ variable (K) in /-- The logarithmic embedding of the units (seen as an `Additive` group). -/ def _root_.NumberField.Units.logEmbedding : Additive ((𝓞 K)ˣ) →+ logSpace K := { toFun := fun x w ↦ mult w.val * Real.log (w.val ↑x.toMul) map_zero' := by simp; rfl map_add' := fun _ _ ↦ by simp [Real.log_mul, mul_add]; rfl } @[simp] theorem logEmbedding_component (x : (𝓞 K)ˣ) (w : {w : InfinitePlace K // w ≠ w₀}) : (logEmbedding K (Additive.ofMul x)) w = mult w.val * Real.log (w.val x) := rfl open scoped Classical in theorem sum_logEmbedding_component (x : (𝓞 K)ˣ) : ∑ w, logEmbedding K (Additive.ofMul x) w = -mult (w₀ : InfinitePlace K) * Real.log (w₀ (x : K)) := by have h := sum_mult_mul_log x rw [Fintype.sum_eq_add_sum_subtype_ne _ w₀, add_comm, add_eq_zero_iff_eq_neg, ← neg_mul] at h simpa [logEmbedding_component] using h end NumberField theorem mult_log_place_eq_zero {x : (𝓞 K)ˣ} {w : InfinitePlace K} : mult w * Real.log (w x) = 0 ↔ w x = 1 := by rw [mul_eq_zero, or_iff_right, Real.log_eq_zero, or_iff_right, or_iff_left] · linarith [(apply_nonneg _ _ : 0 ≤ w x)] · exact (Units.pos_at_place _ _).ne' · exact mult_coe_ne_zero variable [NumberField K] theorem logEmbedding_eq_zero_iff {x : (𝓞 K)ˣ} : logEmbedding K (Additive.ofMul x) = 0 ↔ x ∈ torsion K := by rw [mem_torsion] refine ⟨fun h w ↦ ?_, fun h ↦ ?_⟩ · by_cases hw : w = w₀ · suffices -mult w₀ * Real.log (w₀ (x : K)) = 0 by rw [neg_mul, neg_eq_zero, ← hw] at this exact mult_log_place_eq_zero.mp this rw [← sum_logEmbedding_component, sum_eq_zero] exact fun w _ ↦ congrFun h w · exact mult_log_place_eq_zero.mp (congrFun h ⟨w, hw⟩) · ext w rw [logEmbedding_component, h w.val, Real.log_one, mul_zero, Pi.zero_apply] theorem logEmbedding_ker : (logEmbedding K).ker = (torsion K).toAddSubgroup := by ext x rw [AddMonoidHom.mem_ker, ← ofMul_toMul x, logEmbedding_eq_zero_iff] simp theorem map_logEmbedding_sup_torsion (s : AddSubgroup (Additive (𝓞 K)ˣ)) : (s ⊔ (torsion K).toAddSubgroup).map (logEmbedding K) = s.map (logEmbedding K) := by rw [← logEmbedding_ker, AddSubgroup.map_eq_map_iff, sup_right_idem] open scoped Classical in theorem logEmbedding_component_le {r : ℝ} {x : (𝓞 K)ˣ} (hr : 0 ≤ r) (h : ‖logEmbedding K x‖ ≤ r) (w : {w : InfinitePlace K // w ≠ w₀}) : |logEmbedding K (Additive.ofMul x) w| ≤ r := by lift r to NNReal using hr simp_rw [Pi.norm_def, NNReal.coe_le_coe, Finset.sup_le_iff, ← NNReal.coe_le_coe] at h exact h w (mem_univ _) open scoped Classical in theorem log_le_of_logEmbedding_le {r : ℝ} {x : (𝓞 K)ˣ} (hr : 0 ≤ r) (h : ‖logEmbedding K (Additive.ofMul x)‖ ≤ r) (w : InfinitePlace K) : |Real.log (w x)| ≤ (Fintype.card (InfinitePlace K)) * r := by have tool : ∀ x : ℝ, 0 ≤ x → x ≤ mult w * x := fun x hx ↦ by nth_rw 1 [← one_mul x] refine mul_le_mul ?_ le_rfl hx ?_ all_goals { rw [mult]; split_ifs <;> norm_num } by_cases hw : w = w₀ · have hyp := congr_arg (‖·‖) (sum_logEmbedding_component x).symm replace hyp := (le_of_eq hyp).trans (norm_sum_le _ _) simp_rw [norm_mul, norm_neg, Real.norm_eq_abs, Nat.abs_cast] at hyp refine (le_trans ?_ hyp).trans ?_ · rw [← hw] exact tool _ (abs_nonneg _) · refine (sum_le_card_nsmul univ _ _ (fun w _ ↦ logEmbedding_component_le hr h w)).trans ?_ rw [nsmul_eq_mul] refine mul_le_mul ?_ le_rfl hr (Fintype.card (InfinitePlace K)).cast_nonneg simp · have hyp := logEmbedding_component_le hr h ⟨w, hw⟩ rw [logEmbedding_component, abs_mul, Nat.abs_cast] at hyp refine (le_trans ?_ hyp).trans ?_ · exact tool _ (abs_nonneg _) · nth_rw 1 [← one_mul r] exact mul_le_mul (Nat.one_le_cast.mpr Fintype.card_pos) (le_of_eq rfl) hr (Nat.cast_nonneg _) variable (K) /-- The lattice formed by the image of the logarithmic embedding. -/ noncomputable def _root_.NumberField.Units.unitLattice : Submodule ℤ (logSpace K) := Submodule.map (logEmbedding K).toIntLinearMap ⊤ open scoped Classical in theorem unitLattice_inter_ball_finite (r : ℝ) : ((unitLattice K : Set (logSpace K)) ∩ Metric.closedBall 0 r).Finite := by obtain hr | hr := lt_or_ge r 0 · convert Set.finite_empty rw [Metric.closedBall_eq_empty.mpr hr] exact Set.inter_empty _ · suffices {x : (𝓞 K)ˣ | IsIntegral ℤ (x : K) ∧ ∀ (φ : K →+* ℂ), ‖φ x‖ ≤ Real.exp ((Fintype.card (InfinitePlace K)) * r)}.Finite by refine (Set.Finite.image (logEmbedding K) this).subset ?_ rintro _ ⟨⟨x, ⟨_, rfl⟩⟩, hx⟩ refine ⟨x, ⟨x.val.prop, (le_iff_le _ _).mp (fun w ↦ (Real.log_le_iff_le_exp ?_).mp ?_)⟩, rfl⟩ · exact pos_iff.mpr (coe_ne_zero x) · rw [mem_closedBall_zero_iff] at hx exact (le_abs_self _).trans (log_le_of_logEmbedding_le hr hx w) refine Set.Finite.of_finite_image ?_ (coe_injective K).injOn refine (Embeddings.finite_of_norm_le K ℂ (Real.exp ((Fintype.card (InfinitePlace K)) * r))).subset ?_ rintro _ ⟨x, ⟨⟨h_int, h_le⟩, rfl⟩⟩ exact ⟨h_int, h_le⟩ section span_top /-! #### Section `span_top` In this section, we prove that the span over `ℝ` of the `unitLattice` is equal to the full space. For this, we construct for each infinite place `w₁ ≠ w₀` a unit `u_w₁` of `K` such that, for all infinite places `w` such that `w ≠ w₁`, we have `Real.log w (u_w₁) < 0` (and thus `Real.log w₁ (u_w₁) > 0`). It follows then from a determinant computation (using `Matrix.det_ne_zero_of_sum_col_lt_diag`) that the image by `logEmbedding` of these units is a `ℝ`-linearly independent family. The unit `u_w₁` is obtained by constructing a sequence `seq n` of nonzero algebraic integers that is strictly decreasing at infinite places distinct from `w₁` and of norm `≤ B`. Since there are finitely many ideals of norm `≤ B`, there exists two term in the sequence defining the same ideal and their quotient is the desired unit `u_w₁` (see `exists_unit`). -/ open NumberField.mixedEmbedding NNReal variable (w₁ : InfinitePlace K) {B : ℕ} (hB : minkowskiBound K 1 < (convexBodyLTFactor K) * B) include hB in /-- This result shows that there always exists a next term in the sequence. -/ theorem seq_next {x : 𝓞 K} (hx : x ≠ 0) : ∃ y : 𝓞 K, y ≠ 0 ∧ (∀ w, w ≠ w₁ → w y < w x) ∧ |Algebra.norm ℚ (y : K)| ≤ B := by have hx' := RingOfIntegers.coe_ne_zero_iff.mpr hx let f : InfinitePlace K → ℝ≥0 := fun w ↦ ⟨(w x) / 2, div_nonneg (AbsoluteValue.nonneg _ _) (by simp)⟩ suffices ∀ w, w ≠ w₁ → f w ≠ 0 by obtain ⟨g, h_geqf, h_gprod⟩ := adjust_f K B this obtain ⟨y, h_ynz, h_yle⟩ := exists_ne_zero_mem_ringOfIntegers_lt K (f := g) (by rw [convexBodyLT_volume]; convert hB; exact congr_arg ((↑) : NNReal → ENNReal) h_gprod) refine ⟨y, h_ynz, fun w hw ↦ (h_geqf w hw ▸ h_yle w).trans ?_, ?_⟩ · rw [← Rat.cast_le (K := ℝ), Rat.cast_natCast] calc _ = ∏ w : InfinitePlace K, w (algebraMap _ K y) ^ mult w := (prod_eq_abs_norm (algebraMap _ K y)).symm _ ≤ ∏ w : InfinitePlace K, (g w : ℝ) ^ mult w := by gcongr with w; exact (h_yle w).le _ ≤ (B : ℝ) := by simp_rw [← NNReal.coe_pow, ← NNReal.coe_prod] exact le_of_eq (congr_arg toReal h_gprod) · refine div_lt_self ?_ (by simp) exact pos_iff.mpr hx' intro _ _ rw [ne_eq, Nonneg.mk_eq_zero, div_eq_zero_iff, map_eq_zero, not_or] exact ⟨hx', by simp⟩ /-- An infinite sequence of nonzero algebraic integers of `K` satisfying the following properties: • `seq n` is nonzero; • for `w : InfinitePlace K`, `w ≠ w₁ → w (seq n + 1) < w (seq n)`; • `∣norm (seq n)∣ ≤ B`. -/ def seq : ℕ → { x : 𝓞 K // x ≠ 0 } | 0 => ⟨1, by simp⟩ | n + 1 => ⟨(seq_next K w₁ hB (seq n).prop).choose, (seq_next K w₁ hB (seq n).prop).choose_spec.1⟩ /-- The terms of the sequence are nonzero. -/ theorem seq_ne_zero (n : ℕ) : algebraMap (𝓞 K) K (seq K w₁ hB n) ≠ 0 := RingOfIntegers.coe_ne_zero_iff.mpr (seq K w₁ hB n).prop /-- The sequence is strictly decreasing at infinite places distinct from `w₁`. -/ theorem seq_decreasing {n m : ℕ} (h : n < m) (w : InfinitePlace K) (hw : w ≠ w₁) : w (algebraMap (𝓞 K) K (seq K w₁ hB m)) < w (algebraMap (𝓞 K) K (seq K w₁ hB n)) := by induction m with | zero => exfalso exact Nat.not_succ_le_zero n h | succ m m_ih => cases eq_or_lt_of_le (Nat.le_of_lt_succ h) with | inl hr => rw [hr] exact (seq_next K w₁ hB (seq K w₁ hB m).prop).choose_spec.2.1 w hw | inr hr => refine lt_trans ?_ (m_ih hr) exact (seq_next K w₁ hB (seq K w₁ hB m).prop).choose_spec.2.1 w hw /-- The terms of the sequence have norm bounded by `B`. -/ theorem seq_norm_le (n : ℕ) : Int.natAbs (Algebra.norm ℤ (seq K w₁ hB n : 𝓞 K)) ≤ B := by cases n with | zero => have : 1 ≤ B := by contrapose! hB simp only [Nat.lt_one_iff.mp hB, CharP.cast_eq_zero, mul_zero, zero_le] simp only [ne_eq, seq, map_one, Int.natAbs_one, this] | succ n => rw [← Nat.cast_le (α := ℚ), Nat.cast_natAbs, Int.cast_abs, Algebra.coe_norm_int] exact (seq_next K w₁ hB (seq K w₁ hB n).prop).choose_spec.2.2 /-- Construct a unit associated to the place `w₁`. The family, for `w₁ ≠ w₀`, formed by the image by the `logEmbedding` of these units is `ℝ`-linearly independent, see `unitLattice_span_eq_top`. -/ theorem exists_unit (w₁ : InfinitePlace K) : ∃ u : (𝓞 K)ˣ, ∀ w : InfinitePlace K, w ≠ w₁ → Real.log (w u) < 0 := by obtain ⟨B, hB⟩ : ∃ B : ℕ, minkowskiBound K 1 < (convexBodyLTFactor K) * B := by conv => congr; ext; rw [mul_comm] exact ENNReal.exists_nat_mul_gt (ENNReal.coe_ne_zero.mpr (convexBodyLTFactor_ne_zero K)) (ne_of_lt (minkowskiBound_lt_top K 1)) rsuffices ⟨n, m, hnm, h⟩ : ∃ n m, n < m ∧ (Ideal.span ({ (seq K w₁ hB n : 𝓞 K) }) = Ideal.span ({ (seq K w₁ hB m : 𝓞 K) })) · have hu := Ideal.span_singleton_eq_span_singleton.mp h refine ⟨hu.choose, fun w hw ↦ Real.log_neg (pos_at_place hu.choose w) ?_⟩ calc _ = w (algebraMap (𝓞 K) K (seq K w₁ hB m) * (algebraMap (𝓞 K) K (seq K w₁ hB n))⁻¹) := by rw [← congr_arg (algebraMap (𝓞 K) K) hu.choose_spec, mul_comm, map_mul (algebraMap _ _), ← mul_assoc, inv_mul_cancel₀ (seq_ne_zero K w₁ hB n), one_mul] _ = w (algebraMap (𝓞 K) K (seq K w₁ hB m)) * w (algebraMap (𝓞 K) K (seq K w₁ hB n))⁻¹ := map_mul _ _ _ _ < 1 := by rw [map_inv₀, mul_inv_lt_iff₀' (pos_iff.mpr (seq_ne_zero K w₁ hB n)), mul_one] exact seq_decreasing K w₁ hB hnm w hw refine Set.Finite.exists_lt_map_eq_of_forall_mem (t := {I : Ideal (𝓞 K) | Ideal.absNorm I ≤ B}) (fun n ↦ ?_) (Ideal.finite_setOf_absNorm_le B) rw [Set.mem_setOf_eq, Ideal.absNorm_span_singleton] exact seq_norm_le K w₁ hB n theorem unitLattice_span_eq_top : Submodule.span ℝ (unitLattice K : Set (logSpace K)) = ⊤ := by classical refine le_antisymm le_top ?_ -- The standard basis let B := Pi.basisFun ℝ {w : InfinitePlace K // w ≠ w₀} -- The image by log_embedding of the family of units constructed above let v := fun w : { w : InfinitePlace K // w ≠ w₀ } ↦ logEmbedding K (Additive.ofMul (exists_unit K w).choose) -- To prove the result, it is enough to prove that the family `v` is linearly independent suffices B.det v ≠ 0 by rw [← isUnit_iff_ne_zero, ← Basis.is_basis_iff_det] at this rw [← this.2] refine Submodule.span_monotone fun _ ⟨w, hw⟩ ↦ ⟨(exists_unit K w).choose, trivial, hw⟩ rw [Basis.det_apply] -- We use a specific lemma to prove that this determinant is nonzero refine det_ne_zero_of_sum_col_lt_diag (fun w ↦ ?_) simp_rw [Real.norm_eq_abs, B, Basis.coePiBasisFun.toMatrix_eq_transpose, Matrix.transpose_apply] rw [← sub_pos, sum_congr rfl (fun x hx ↦ abs_of_neg ?_), sum_neg_distrib, sub_neg_eq_add, sum_erase_eq_sub (mem_univ _), ← add_comm_sub] · refine add_pos_of_nonneg_of_pos ?_ ?_ · rw [sub_nonneg] exact le_abs_self _ · rw [sum_logEmbedding_component (exists_unit K w).choose] refine mul_pos_of_neg_of_neg ?_ ((exists_unit K w).choose_spec _ w.prop.symm) rw [mult]; split_ifs <;> norm_num · refine mul_neg_of_pos_of_neg ?_ ((exists_unit K w).choose_spec x ?_) · rw [mult]; split_ifs <;> norm_num · exact Subtype.ext_iff.not.mp (ne_of_mem_erase hx) end span_top end dirichletUnitTheorem section statements variable [NumberField K] open dirichletUnitTheorem Module /-- The unit rank of the number field `K`, it is equal to `card (InfinitePlace K) - 1`. -/ def rank : ℕ := Fintype.card (InfinitePlace K) - 1 instance instDiscrete_unitLattice : DiscreteTopology (unitLattice K) := by classical refine discreteTopology_of_isOpen_singleton_zero ?_ refine isOpen_singleton_of_finite_mem_nhds 0 (s := Metric.closedBall 0 1) ?_ ?_ · exact Metric.closedBall_mem_nhds _ (by simp) · refine Set.Finite.of_finite_image ?_ (Set.injOn_of_injective Subtype.val_injective) convert unitLattice_inter_ball_finite K 1 ext x refine ⟨?_, fun ⟨hx1, hx2⟩ ↦ ⟨⟨x, hx1⟩, hx2, rfl⟩⟩ rintro ⟨x, hx, rfl⟩ exact ⟨Subtype.mem x, hx⟩ open scoped Classical in instance instZLattice_unitLattice : IsZLattice ℝ (unitLattice K) where span_top := unitLattice_span_eq_top K protected theorem finrank_eq_rank : finrank ℝ (logSpace K) = Units.rank K := by classical simp only [finrank_fintype_fun_eq_card, Fintype.card_subtype_compl, Fintype.card_ofSubsingleton, rank] @[simp] theorem unitLattice_rank : finrank ℤ (unitLattice K) = Units.rank K := by classical rw [← Units.finrank_eq_rank, ZLattice.rank ℝ] /-- The map obtained by quotienting by the kernel of `logEmbedding`. -/ def logEmbeddingQuot : Additive ((𝓞 K)ˣ ⧸ (torsion K)) →+ logSpace K := MonoidHom.toAdditiveLeft <| (QuotientGroup.kerLift (AddMonoidHom.toMultiplicativeRight (logEmbedding K))).comp (QuotientGroup.quotientMulEquivOfEq (by ext rw [MonoidHom.mem_ker, AddMonoidHom.toMultiplicativeRight_apply_apply, ofAdd_eq_one, ← logEmbedding_eq_zero_iff])).toMonoidHom @[simp] theorem logEmbeddingQuot_apply (x : (𝓞 K)ˣ) : logEmbeddingQuot K (Additive.ofMul (QuotientGroup.mk x)) = logEmbedding K (Additive.ofMul x) := rfl theorem logEmbeddingQuot_injective : Function.Injective (logEmbeddingQuot K) := by unfold logEmbeddingQuot intro _ _ h simp_rw [MonoidHom.toAdditiveLeft_apply_apply, MonoidHom.coe_comp, MulEquiv.coe_toMonoidHom, Function.comp_apply, EmbeddingLike.apply_eq_iff_eq] at h exact (EmbeddingLike.apply_eq_iff_eq _).mp <| (QuotientGroup.kerLift_injective _).eq_iff.mp h /-- The linear equivalence between `(𝓞 K)ˣ ⧸ (torsion K)` as an additive `ℤ`-module and `unitLattice` . -/ def logEmbeddingEquiv : Additive ((𝓞 K)ˣ ⧸ (torsion K)) ≃ₗ[ℤ] (unitLattice K) := LinearEquiv.ofBijective ((logEmbeddingQuot K).codRestrict (unitLattice K) (Quotient.ind fun _ ↦ logEmbeddingQuot_apply K _ ▸ Submodule.mem_map_of_mem trivial)).toIntLinearMap ⟨fun _ _ ↦ by rw [AddMonoidHom.coe_toIntLinearMap, AddMonoidHom.codRestrict_apply, AddMonoidHom.codRestrict_apply, Subtype.mk.injEq] apply logEmbeddingQuot_injective K, fun ⟨a, ⟨b, _, ha⟩⟩ ↦ ⟨⟦b⟧, by simpa using ha⟩⟩ @[simp] theorem logEmbeddingEquiv_apply (x : (𝓞 K)ˣ) : logEmbeddingEquiv K (Additive.ofMul (QuotientGroup.mk x)) = logEmbedding K (Additive.ofMul x) := rfl instance : Module.Free ℤ (Additive ((𝓞 K)ˣ ⧸ (torsion K))) := by classical exact Module.Free.of_equiv (logEmbeddingEquiv K).symm instance : Module.Finite ℤ (Additive ((𝓞 K)ˣ ⧸ (torsion K))) := by classical exact Module.Finite.equiv (logEmbeddingEquiv K).symm -- Note that we prove this instance first and then deduce from it the instance -- `Monoid.FG (𝓞 K)ˣ`, and not the other way around, due to no `Subgroup` version -- of `Submodule.fg_of_fg_map_of_fg_inf_ker` existing. instance : Module.Finite ℤ (Additive (𝓞 K)ˣ) := by rw [Module.finite_def] refine Submodule.fg_of_fg_map_of_fg_inf_ker (MonoidHom.toAdditive (QuotientGroup.mk' (torsion K))).toIntLinearMap ?_ ?_ · rw [Submodule.map_top, LinearMap.range_eq_top.mpr (by exact QuotientGroup.mk'_surjective (torsion K)), ← Module.finite_def] infer_instance · rw [inf_of_le_right le_top, AddMonoidHom.coe_toIntLinearMap_ker, MonoidHom.coe_toAdditive_ker, QuotientGroup.ker_mk', Submodule.fg_iff_addSubgroup_fg, AddSubgroup.toIntSubmodule_toAddSubgroup, ← AddGroup.fg_iff_addSubgroup_fg] have : Finite (Subgroup.toAddSubgroup (torsion K)) := (inferInstance : Finite (torsion K)) exact AddGroup.fg_of_finite instance : Monoid.FG (𝓞 K)ˣ := by rw [Monoid.fg_iff_add_fg, ← AddGroup.fg_iff_addMonoid_fg, ← Module.Finite.iff_addGroup_fg] infer_instance theorem rank_modTorsion : Module.finrank ℤ (Additive ((𝓞 K)ˣ ⧸ (torsion K))) = rank K := by rw [← LinearEquiv.finrank_eq (logEmbeddingEquiv K).symm, unitLattice_rank] /-- A basis of the quotient `(𝓞 K)ˣ ⧸ (torsion K)` seen as an additive ℤ-module. -/ def basisModTorsion : Basis (Fin (rank K)) ℤ (Additive ((𝓞 K)ˣ ⧸ (torsion K))) := Basis.reindex (Module.Free.chooseBasis ℤ _) (Fintype.equivOfCardEq <| by rw [← Module.finrank_eq_card_chooseBasisIndex, rank_modTorsion, Fintype.card_fin]) /-- The basis of the `unitLattice` obtained by mapping `basisModTorsion` via `logEmbedding`. -/ def basisUnitLattice : Basis (Fin (rank K)) ℤ (unitLattice K) := (basisModTorsion K).map (logEmbeddingEquiv K) /-- A fundamental system of units of `K`. The units of `fundSystem` are arbitrary lifts of the units in `basisModTorsion`. -/ def fundSystem : Fin (rank K) → (𝓞 K)ˣ := -- `:)` prevents the `⧸` decaying to a quotient by `leftRel` when we unfold this later fun i ↦ Quotient.out ((basisModTorsion K i).toMul :) theorem fundSystem_mk (i : Fin (rank K)) : Additive.ofMul (QuotientGroup.mk (fundSystem K i)) = (basisModTorsion K i) := by simp_rw [fundSystem, Equiv.apply_eq_iff_eq_symm_apply, Additive.ofMul_symm_eq, Quotient.out_eq'] theorem logEmbedding_fundSystem (i : Fin (rank K)) : logEmbedding K (Additive.ofMul (fundSystem K i)) = basisUnitLattice K i := by rw [basisUnitLattice, Basis.map_apply, ← fundSystem_mk, logEmbeddingEquiv_apply] /-- The exponents that appear in the unique decomposition of a unit as the product of a root of unity and powers of the units of the fundamental system `fundSystem` (see `exist_unique_eq_mul_prod`) are given by the representation of the unit on `basisModTorsion`. -/ theorem fun_eq_repr {x ζ : (𝓞 K)ˣ} {f : Fin (rank K) → ℤ} (hζ : ζ ∈ torsion K) (h : x = ζ * ∏ i, (fundSystem K i) ^ (f i)) : f = (basisModTorsion K).repr (Additive.ofMul ↑x) := by suffices Additive.ofMul ↑x = ∑ i, (f i) • (basisModTorsion K i) by rw [← (basisModTorsion K).repr_sum_self f, ← this] calc Additive.ofMul ↑x _ = ∑ i, (f i) • Additive.ofMul ↑(fundSystem K i) := by rw [h, QuotientGroup.mk_mul, (QuotientGroup.eq_one_iff _).mpr hζ, one_mul, QuotientGroup.mk_prod, ofMul_prod]; rfl _ = ∑ i, (f i) • (basisModTorsion K i) := by simp_rw [fundSystem, QuotientGroup.out_eq', ofMul_toMul] /-- **Dirichlet Unit Theorem**. Any unit `x` of `𝓞 K` can be written uniquely as the product of a root of unity and powers of the units of the fundamental system `fundSystem`. -/ theorem exist_unique_eq_mul_prod (x : (𝓞 K)ˣ) : ∃! ζe : torsion K × (Fin (rank K) → ℤ), x = ζe.1 * ∏ i, (fundSystem K i) ^ (ζe.2 i) := by let ζ := x * (∏ i, (fundSystem K i) ^ ((basisModTorsion K).repr (Additive.ofMul ↑x) i))⁻¹ have h_tors : ζ ∈ torsion K := by rw [← QuotientGroup.eq_one_iff, QuotientGroup.mk_mul, QuotientGroup.mk_inv, ← ofMul_eq_zero, ofMul_mul, ofMul_inv, QuotientGroup.mk_prod, ofMul_prod] simp_rw [QuotientGroup.mk_zpow, ofMul_zpow, fundSystem, QuotientGroup.out_eq'] rw [add_eq_zero_iff_eq_neg, neg_neg] exact ((basisModTorsion K).sum_repr (Additive.ofMul ↑x)).symm refine ⟨⟨⟨ζ, h_tors⟩, ((basisModTorsion K).repr (Additive.ofMul ↑x) : Fin (rank K) → ℤ)⟩, ?_, ?_⟩ · simp only [ζ, _root_.inv_mul_cancel_right] · rintro ⟨⟨ζ', h_tors'⟩, η⟩ hf simp only [ζ, ← fun_eq_repr K h_tors' hf, Prod.mk.injEq, Subtype.mk.injEq, and_true] nth_rewrite 1 [hf] rw [_root_.mul_inv_cancel_right] /-- The units of the fundamental system and the torsion of `K` generate the full group of units of `K`. -/ theorem closure_fundSystem_sup_torsion_eq_top : Subgroup.closure (Set.range (fundSystem K)) ⊔ torsion K = ⊤ := by rw [Subgroup.eq_top_iff', sup_comm] intro x obtain ⟨c, rfl, _⟩ := exist_unique_eq_mul_prod K x exact Subgroup.mul_mem_sup (SetLike.coe_mem c.1) <| Subgroup.prod_mem _ fun i _ ↦ Subgroup.zpow_mem _ (Subgroup.subset_closure (Set.mem_range_self i)) _ end statements end NumberField.Units
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Discriminant/Different.lean
import Mathlib.NumberTheory.NumberField.Discriminant.Basic import Mathlib.RingTheory.DedekindDomain.LinearDisjoint import Mathlib.RingTheory.Ideal.Norm.RelNorm /-! # (Absolute) Discriminant and Different Ideal ## Main results - `NumberField.absNorm_differentIdeal`: The norm of `differentIdeal ℤ 𝒪` is the absolute discriminant. - `NumberField.natAbs_discr_eq_absNorm_differentIdeal_mul_natAbs_discr_pow`: Formula for the absolute discriminant of `L` in terms of that of `K` in an extension `L/K`. - `NumberField.natAbs_discr_eq_natAbs_discr_pow_mul_natAbs_discr_pow`: Assume that `K₁` and `K₂` are two linear disjoint number fields with coprime different ideals. Then, the absolute value of the discriminant of their compositum is equal to `|discr K₁| ^ [K₂ : ℚ] * |discr K₂| ^ [K₁ : ℚ]`. -/ namespace NumberField variable (K 𝒪 : Type*) [Field K] [NumberField K] [CommRing 𝒪] [Algebra 𝒪 K] variable [IsFractionRing 𝒪 K] [IsIntegralClosure 𝒪 ℤ K] [IsDedekindDomain 𝒪] [CharZero 𝒪] variable [Module.Finite ℤ 𝒪] open nonZeroDivisors IntermediateField lemma absNorm_differentIdeal : (differentIdeal ℤ 𝒪).absNorm = (discr K).natAbs := by refine (differentIdeal ℤ 𝒪).toAddSubgroup.relIndex_top_right.symm.trans ?_ rw [← Submodule.comap_map_eq_of_injective (f := Algebra.linearMap 𝒪 K) (FaithfulSMul.algebraMap_injective 𝒪 K) (differentIdeal ℤ 𝒪)] refine (AddSubgroup.relIndex_comap (IsLocalization.coeSubmodule K (differentIdeal ℤ 𝒪)).toAddSubgroup (algebraMap 𝒪 K).toAddMonoidHom ⊤).trans ?_ have := FractionalIdeal.quotientEquiv (R := 𝒪) (K := K) 1 (differentIdeal ℤ 𝒪) (differentIdeal ℤ 𝒪)⁻¹ 1 (by simp [differentIdeal_ne_bot]) FractionalIdeal.coeIdeal_le_one (le_inv_of_le_inv₀ (by simp [pos_iff_ne_zero, differentIdeal_ne_bot]) (by simpa using FractionalIdeal.coeIdeal_le_one)) one_ne_zero one_ne_zero have := Nat.card_congr this.toEquiv refine this.trans ?_ rw [FractionalIdeal.coe_one, coeIdeal_differentIdeal (K := ℚ), inv_inv] let b := integralBasis K let b' := (Algebra.traceForm ℚ K).dualBasis (traceForm_nondegenerate ℚ K) b have hb : Submodule.span ℤ (Set.range b) = (1 : Submodule 𝒪 K).restrictScalars ℤ := by ext let e := IsIntegralClosure.equiv ℤ (RingOfIntegers K) K 𝒪 simpa [e.symm.exists_congr_left, e] using mem_span_integralBasis K qify refine (AddSubgroup.relIndex_eq_abs_det (1 : Submodule 𝒪 K).toAddSubgroup (FractionalIdeal.dual ℤ ℚ 1 : FractionalIdeal 𝒪⁰ K).coeToSubmodule.toAddSubgroup ?_ b b' ?_ ?_).trans ?_ · rw [Submodule.toAddSubgroup_le, ← FractionalIdeal.coe_one] exact FractionalIdeal.one_le_dual_one ℤ ℚ (L := K) (B := 𝒪) · apply AddSubgroup.toIntSubmodule.injective rw [AddSubgroup.toIntSubmodule_closure, hb, Submodule.toIntSubmodule_toAddSubgroup] · apply AddSubgroup.toIntSubmodule.injective rw [AddSubgroup.toIntSubmodule_closure, ← LinearMap.BilinForm.dualSubmodule_span_of_basis, hb] simp · simp only [Module.Basis.det_apply, discr, Algebra.discr] rw [← eq_intCast (algebraMap ℤ ℚ), RingHom.map_det] congr! 2 ext i j simp [b', Module.Basis.toMatrix_apply, mul_comm (RingOfIntegers.basis K i), b, integralBasis_apply, ← map_mul, Algebra.trace_localization ℤ ℤ⁰] lemma discr_mem_differentIdeal : ↑(discr K) ∈ differentIdeal ℤ 𝒪 := by have := (differentIdeal ℤ 𝒪).absNorm_mem cases (discr K).natAbs_eq with | inl h => rwa [absNorm_differentIdeal (K := K), ← Int.cast_natCast, ← h] at this | inr h => rwa [absNorm_differentIdeal (K := K), ← Int.cast_natCast, Int.eq_neg_comm.mp h, Int.cast_neg, neg_mem_iff] at this attribute [local instance] FractionRing.liftAlgebra in theorem natAbs_discr_eq_absNorm_differentIdeal_mul_natAbs_discr_pow (L 𝒪' : Type*) [Field L] [NumberField L] [CommRing 𝒪'] [Algebra 𝒪' L] [IsFractionRing 𝒪' L] [IsIntegralClosure 𝒪' ℤ L] [IsDedekindDomain 𝒪'] [CharZero 𝒪'] [Algebra K L] [Algebra 𝒪 𝒪'] [Algebra 𝒪 L] [IsScalarTower 𝒪 K L] [IsScalarTower 𝒪 𝒪' L] [NoZeroSMulDivisors 𝒪 𝒪'] [Module.Free ℤ 𝒪'] [Module.Finite ℤ 𝒪'] [Module.Finite 𝒪 𝒪'] : (discr L).natAbs = Ideal.absNorm (differentIdeal 𝒪 𝒪') * (discr K).natAbs ^ Module.finrank K L := by have := congr_arg Ideal.absNorm (differentIdeal_eq_differentIdeal_mul_differentIdeal ℤ 𝒪 𝒪') rwa [absNorm_differentIdeal L, map_mul, Ideal.absNorm_algebraMap, absNorm_differentIdeal K, Algebra.finrank_eq_of_equiv_equiv (FractionRing.algEquiv 𝒪 K).toRingEquiv (FractionRing.algEquiv 𝒪' L).toRingEquiv] at this ext exact IsFractionRing.algEquiv_commutes (FractionRing.algEquiv 𝒪 K) (FractionRing.algEquiv 𝒪' L) _ variable (L : Type*) [Field L] theorem isCoprime_differentIdeal_of_isCoprime_discr {K₁ K₂ : Type*} [Field K₁] [NumberField K₁] [Field K₂] [NumberField K₂] [Algebra K₁ L] [Algebra K₂ L] (h : IsCoprime (discr K₁) (discr K₂)) : IsCoprime ((differentIdeal ℤ (𝓞 K₁)).map (algebraMap (𝓞 K₁) (𝓞 L))) ((differentIdeal ℤ (𝓞 K₂)).map (algebraMap (𝓞 K₂) (𝓞 L))) := by obtain ⟨u, v, h⟩ := h refine Ideal.isCoprime_iff_exists.mpr ⟨u * discr K₁, ?_, v * discr K₂, ?_, ?_⟩ · apply Ideal.mul_mem_left rw [← map_intCast (algebraMap (𝓞 K₁) (𝓞 L))] exact Ideal.mem_map_of_mem (algebraMap (𝓞 K₁) (𝓞 L)) <| discr_mem_differentIdeal _ _ · apply Ideal.mul_mem_left rw [← map_intCast (algebraMap (𝓞 K₂) (𝓞 L))] exact Ideal.mem_map_of_mem (algebraMap (𝓞 K₂) (𝓞 L)) <| discr_mem_differentIdeal _ _ rw [← Int.cast_mul, ← Int.cast_mul, ← Int.cast_add, h, Int.cast_one] variable [NumberField L] theorem discr_dvd_discr [Algebra K L] : discr K ∣ discr L := by suffices discr K ^ Module.finrank K L ∣ discr L from dvd_trans (dvd_pow_self _ (Nat.ne_zero_of_lt Module.finrank_pos)) this rw [← Int.dvd_natAbs, natAbs_discr_eq_absNorm_differentIdeal_mul_natAbs_discr_pow K (𝓞 K) L (𝓞 L), Nat.cast_mul, Nat.cast_pow, ← Int.mul_sign_self, mul_pow, ← mul_assoc, mul_comm _ (discr K ^ _), mul_assoc] exact Int.dvd_mul_right _ _ /-- Let `K₁` and `K₂` be two number fields and assume that `K₁/ℚ` is Galois. If `discr K₁` and `discr K₂` are coprime, then they are linear disjoint over `ℚ`. -/ theorem linearDisjoint_of_isGalois_isCoprime_discr (K₁ K₂ : IntermediateField ℚ L) [IsGalois ℚ K₁] (h : IsCoprime (discr K₁) (discr K₂)) : K₁.LinearDisjoint K₂ := by apply IntermediateField.LinearDisjoint.of_inf_eq_bot suffices IsUnit (discr ↥(K₁ ⊓ K₂)) by contrapose! this have : 1 < Module.finrank ℚ ↥(K₁ ⊓ K₂) := by refine Nat.one_lt_iff_ne_zero_and_ne_one.mpr ⟨Module.finrank_pos.ne', ?_⟩ rwa [ne_eq, ← IntermediateField.finrank_eq_one_iff] at this exact Int.isUnit_iff_abs_eq.not.mpr <| by linarith [abs_discr_gt_two this] exact h.isUnit_of_dvd' (NumberField.discr_dvd_discr _ _) (NumberField.discr_dvd_discr _ _) open IntermediateField IsDedekindDomain /-- Let `K₁` and `K₂` be two number fields and assume that their different ideals (over ℤ) are coprime. Then, the absolute value of the discriminant of their compositum is equal to `|discr K₁| ^ [K₂ : ℚ] * |discr K₂| ^ [K₁ : ℚ]`. -/ theorem natAbs_discr_eq_natAbs_discr_pow_mul_natAbs_discr_pow (K₁ K₂ : IntermediateField ℚ L) (h₁ : K₁.LinearDisjoint K₂) (h₂ : K₁ ⊔ K₂ = ⊤) (h₃ : IsCoprime ((differentIdeal ℤ (𝓞 K₁)).map (algebraMap (𝓞 K₁) (𝓞 L))) ((differentIdeal ℤ (𝓞 K₂)).map (algebraMap (𝓞 K₂) (𝓞 L)))) : (discr L).natAbs = (discr K₁).natAbs ^ Module.finrank ℚ K₂ * (discr K₂).natAbs ^ Module.finrank ℚ K₁ := by let _ : Algebra (FractionRing (𝓞 K₁)) (FractionRing (𝓞 L)) := FractionRing.liftAlgebra _ _ have h_main := natAbs_discr_eq_absNorm_differentIdeal_mul_natAbs_discr_pow K₂ (𝓞 K₂) L (𝓞 L) rwa [differentIdeal_eq_map_differentIdeal ℤ (𝓞 L) (𝓞 K₂) (𝓞 K₁) (F₁ := K₂) (F₂ := K₁) (by rwa [linearDisjoint_comm]) (by rwa [sup_comm]) (by rwa [isCoprime_comm]), Ideal.absNorm_algebraMap, absNorm_differentIdeal K₁, h₁.finrank_right_eq_finrank h₂, Algebra.finrank_eq_of_equiv_equiv (FractionRing.algEquiv _ K₁).toRingEquiv (FractionRing.algEquiv _ L).toRingEquiv, h₁.finrank_left_eq_finrank h₂] at h_main ext exact IsFractionRing.algEquiv_commutes (FractionRing.algEquiv (𝓞 K₁) K₁) (FractionRing.algEquiv (𝓞 L) L) _ end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Discriminant/Basic.lean
import Mathlib.Algebra.Module.ZLattice.Covolume import Mathlib.Analysis.Real.Pi.Bounds import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody import Mathlib.NumberTheory.NumberField.Discriminant.Defs import Mathlib.NumberTheory.NumberField.InfinitePlace.TotallyRealComplex import Mathlib.Tactic.Rify /-! # Number field discriminant This file defines the discriminant of a number field. ## Main result * `NumberField.abs_discr_gt_two`: **Hermite-Minkowski Theorem**. A nontrivial number field has discriminant greater than `2`. * `NumberField.finite_of_discr_bdd`: **Hermite Theorem**. Let `N` be an integer. There are only finitely many number fields (in some fixed extension of `ℚ`) of discriminant bounded by `N`. ## Tags number field, discriminant -/ -- TODO. Rewrite some of the FLT results on the discriminant using the definitions and results of -- this file namespace NumberField open Module NumberField NumberField.InfinitePlace Matrix open scoped Real nonZeroDivisors variable (K : Type*) [Field K] [NumberField K] open MeasureTheory MeasureTheory.Measure ZSpan NumberField.mixedEmbedding NumberField.InfinitePlace ENNReal NNReal Complex open scoped Classical in theorem _root_.NumberField.mixedEmbedding.volume_fundamentalDomain_latticeBasis : volume (fundamentalDomain (latticeBasis K)) = (2 : ℝ≥0∞)⁻¹ ^ nrComplexPlaces K * sqrt ‖discr K‖₊ := by let f : Module.Free.ChooseBasisIndex ℤ (𝓞 K) ≃ (K →+* ℂ) := (canonicalEmbedding.latticeBasis K).indexEquiv (Pi.basisFun ℂ _) let e : (index K) ≃ Module.Free.ChooseBasisIndex ℤ (𝓞 K) := (indexEquiv K).trans f.symm let M := (mixedEmbedding.stdBasis K).toMatrix ((latticeBasis K).reindex e.symm) let N := Algebra.embeddingsMatrixReindex ℚ ℂ (integralBasis K ∘ f.symm) RingHom.equivRatAlgHom suffices M.map ofRealHom = matrixToStdBasis K * (Matrix.reindex (indexEquiv K).symm (indexEquiv K).symm N).transpose by calc volume (fundamentalDomain (latticeBasis K)) _ = ‖((mixedEmbedding.stdBasis K).toMatrix ((latticeBasis K).reindex e.symm)).det‖₊ := by rw [← fundamentalDomain_reindex _ e.symm, ← norm_toNNReal, measure_fundamentalDomain ((latticeBasis K).reindex e.symm), volume_fundamentalDomain_stdBasis, mul_one] rfl _ = ‖(matrixToStdBasis K).det * N.det‖₊ := by rw [← nnnorm_real, ← ofRealHom_eq_coe, RingHom.map_det, RingHom.mapMatrix_apply, this, det_mul, det_transpose, det_reindex_self] _ = (2 : ℝ≥0∞)⁻¹ ^ Fintype.card {w : InfinitePlace K // IsComplex w} * sqrt ‖N.det ^ 2‖₊ := by have : ‖Complex.I‖₊ = 1 := by rw [← norm_toNNReal, norm_I, Real.toNNReal_one] rw [det_matrixToStdBasis, nnnorm_mul, nnnorm_pow, nnnorm_mul, this, mul_one, nnnorm_inv, coe_mul, ENNReal.coe_pow, ← norm_toNNReal, RCLike.norm_two, Real.toNNReal_ofNat, coe_inv two_ne_zero, coe_ofNat, nnnorm_pow, NNReal.sqrt_sq] _ = (2 : ℝ≥0∞)⁻¹ ^ Fintype.card { w // IsComplex w } * NNReal.sqrt ‖discr K‖₊ := by rw [← Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two, Algebra.discr_reindex, ← coe_discr, map_intCast, ← Complex.nnnorm_intCast] ext : 2 dsimp only [M] rw [Matrix.map_apply, Basis.toMatrix_apply, Basis.coe_reindex, Function.comp_apply, Equiv.symm_symm, latticeBasis_apply, ← commMap_canonical_eq_mixed, Complex.ofRealHom_eq_coe, stdBasis_repr_eq_matrixToStdBasis_mul K _ (fun _ => rfl)] rfl open scoped Classical in theorem _root_.NumberField.mixedEmbedding.covolume_integerLattice : ZLattice.covolume (mixedEmbedding.integerLattice K) = (2⁻¹) ^ nrComplexPlaces K * √|discr K| := by rw [ZLattice.covolume_eq_measure_fundamentalDomain _ _ (fundamentalDomain_integerLattice K), measureReal_def, volume_fundamentalDomain_latticeBasis, ENNReal.toReal_mul, ENNReal.toReal_pow, ENNReal.toReal_inv, toReal_ofNat, ENNReal.coe_toReal, Real.coe_sqrt, coe_nnnorm, Int.norm_eq_abs] open scoped Classical in theorem _root_.NumberField.mixedEmbedding.covolume_idealLattice (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : ZLattice.covolume (mixedEmbedding.idealLattice K I) = (FractionalIdeal.absNorm (I : FractionalIdeal (𝓞 K)⁰ K)) * (2⁻¹) ^ nrComplexPlaces K * √|discr K| := by rw [ZLattice.covolume_eq_measure_fundamentalDomain _ _ (fundamentalDomain_idealLattice K I), measureReal_def, volume_fundamentalDomain_fractionalIdealLatticeBasis, volume_fundamentalDomain_latticeBasis, ENNReal.toReal_mul, ENNReal.toReal_mul, ENNReal.toReal_pow, ENNReal.toReal_inv, toReal_ofNat, ENNReal.coe_toReal, Real.coe_sqrt, coe_nnnorm, Int.norm_eq_abs, ENNReal.toReal_ofReal (Rat.cast_nonneg.mpr (FractionalIdeal.absNorm_nonneg I.val)), mul_assoc] theorem exists_ne_zero_mem_ideal_of_norm_le_mul_sqrt_discr (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : ∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧ |Algebra.norm ℚ (a : K)| ≤ FractionalIdeal.absNorm I.1 * (4 / π) ^ nrComplexPlaces K * (finrank ℚ K).factorial / (finrank ℚ K) ^ (finrank ℚ K) * Real.sqrt |discr K| := by classical -- The smallest possible value for `exists_ne_zero_mem_ideal_of_norm_le` let B := (minkowskiBound K I * (convexBodySumFactor K)⁻¹).toReal ^ (1 / (finrank ℚ K : ℝ)) have h_le : (minkowskiBound K I) ≤ volume (convexBodySum K B) := by refine le_of_eq ?_ rw [convexBodySum_volume, ← ENNReal.ofReal_pow (by positivity), ← Real.rpow_natCast, ← Real.rpow_mul toReal_nonneg, div_mul_cancel₀, Real.rpow_one, ofReal_toReal, mul_comm, mul_assoc, ← coe_mul, inv_mul_cancel₀ (convexBodySumFactor_ne_zero K), ENNReal.coe_one, mul_one] · exact mul_ne_top (ne_of_lt (minkowskiBound_lt_top K I)) coe_ne_top · exact (Nat.cast_ne_zero.mpr (ne_of_gt finrank_pos)) convert exists_ne_zero_mem_ideal_of_norm_le K I h_le rw [div_pow B, ← Real.rpow_natCast B, ← Real.rpow_mul (by positivity), div_mul_cancel₀ _ (Nat.cast_ne_zero.mpr <| ne_of_gt finrank_pos), Real.rpow_one, mul_comm_div, mul_div_assoc'] congr 1 rw [eq_comm] calc _ = FractionalIdeal.absNorm I.1 * (2 : ℝ)⁻¹ ^ nrComplexPlaces K * sqrt ‖discr K‖₊ * (2 : ℝ) ^ finrank ℚ K * ((2 : ℝ) ^ nrRealPlaces K * (π / 2) ^ nrComplexPlaces K / (Nat.factorial (finrank ℚ K)))⁻¹ := by simp_rw [minkowskiBound, convexBodySumFactor, volume_fundamentalDomain_fractionalIdealLatticeBasis, volume_fundamentalDomain_latticeBasis, toReal_mul, toReal_pow, toReal_inv, coe_toReal, toReal_ofNat, mixedEmbedding.finrank, mul_assoc] rw [ENNReal.toReal_ofReal (Rat.cast_nonneg.mpr (FractionalIdeal.absNorm_nonneg I.1))] simp_rw [NNReal.coe_inv, NNReal.coe_div, NNReal.coe_mul, NNReal.coe_pow, NNReal.coe_div, coe_real_pi, NNReal.coe_ofNat, NNReal.coe_natCast] _ = FractionalIdeal.absNorm I.1 * (2 : ℝ) ^ (finrank ℚ K - nrComplexPlaces K - nrRealPlaces K + nrComplexPlaces K : ℤ) * Real.sqrt ‖discr K‖ * Nat.factorial (finrank ℚ K) * π⁻¹ ^ (nrComplexPlaces K) := by simp_rw [inv_div, div_eq_mul_inv, mul_inv, ← zpow_neg_one, ← zpow_natCast, mul_zpow, ← zpow_mul, neg_one_mul, mul_neg_one, neg_neg, Real.coe_sqrt, coe_nnnorm, sub_eq_add_neg, zpow_add₀ (two_ne_zero : (2 : ℝ) ≠ 0)] ring _ = FractionalIdeal.absNorm I.1 * (2 : ℝ) ^ (2 * nrComplexPlaces K : ℤ) * Real.sqrt ‖discr K‖ * Nat.factorial (finrank ℚ K) * π⁻¹ ^ (nrComplexPlaces K) := by congr rw [← card_add_two_mul_card_eq_rank, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] ring _ = FractionalIdeal.absNorm I.1 * (4 / π) ^ nrComplexPlaces K * (finrank ℚ K).factorial * Real.sqrt |discr K| := by rw [Int.norm_eq_abs, zpow_mul, show (2 : ℝ) ^ (2 : ℤ) = 4 by norm_cast, div_pow, inv_eq_one_div, div_pow, one_pow, zpow_natCast] ring theorem exists_ne_zero_mem_ringOfIntegers_of_norm_le_mul_sqrt_discr : ∃ (a : 𝓞 K), a ≠ 0 ∧ |Algebra.norm ℚ (a : K)| ≤ (4 / π) ^ nrComplexPlaces K * (finrank ℚ K).factorial / (finrank ℚ K) ^ (finrank ℚ K) * Real.sqrt |discr K| := by obtain ⟨_, h_mem, h_nz, h_nm⟩ := exists_ne_zero_mem_ideal_of_norm_le_mul_sqrt_discr K ↑1 obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem refine ⟨a, ne_zero_of_map h_nz, ?_⟩ simp_rw [Units.val_one, FractionalIdeal.absNorm_one, Rat.cast_one, one_mul] at h_nm exact h_nm /-- The Minkowski lower bound `n^{2n}/((4/pi)^{2r_2}*n!^2)` for the absolute value of the discriminant of a number field of degree n. -/ theorem abs_discr_ge' : (finrank ℚ K) ^ (2 * finrank ℚ K) / ((4 / π) ^ (2 * nrComplexPlaces K) * (finrank ℚ K).factorial ^ 2) ≤ |discr K| := by -- We use `exists_ne_zero_mem_ringOfIntegers_of_norm_le_mul_sqrt_discr` to get a nonzero -- algebraic integer `x` of small norm and the fact that `1 ≤ |Norm x|` to get a lower bound -- on `sqrt |discr K|`. obtain ⟨x, h_nz, h_bd⟩ := exists_ne_zero_mem_ringOfIntegers_of_norm_le_mul_sqrt_discr K have h_nm : (1 : ℝ) ≤ |Algebra.norm ℚ (x : K)| := by rw [← Algebra.coe_norm_int, ← Int.cast_one, ← Int.cast_abs, Rat.cast_intCast, Int.cast_le] exact Int.one_le_abs (Algebra.norm_ne_zero_iff.mpr h_nz) replace h_bd := le_trans h_nm h_bd rwa [← inv_mul_le_iff₀, inv_div, mul_one, Real.le_sqrt (by positivity) (by positivity), ← Int.cast_abs, div_pow, mul_pow, ← pow_mul, mul_comm _ 2, ← pow_mul, mul_comm _ 2] at h_bd exact div_pos (by positivity) <| pow_pos (Nat.cast_pos.mpr finrank_pos) (finrank ℚ K) theorem abs_discr_ge_of_isTotallyComplex [IsTotallyComplex K] : (finrank ℚ K) ^ (2 * finrank ℚ K) / ((4 / π) ^ (finrank ℚ K) * (finrank ℚ K).factorial ^ 2) ≤ |discr K| := by have := abs_discr_ge' K rwa [← IsTotallyComplex.finrank] at this theorem abs_discr_rpow_ge_of_isTotallyComplex [IsTotallyComplex K] : (finrank ℚ K) ^ 2 / ((4 / π) * (finrank ℚ K).factorial ^ (2 * (finrank ℚ K : ℝ)⁻¹)) ≤ |discr K| ^ (finrank ℚ K : ℝ)⁻¹ := by have h : 0 < (finrank ℚ K : ℝ) := Nat.cast_pos.mpr finrank_pos rw [← Real.rpow_le_rpow_iff (z := finrank ℚ K) (by positivity) (by positivity) h, Real.div_rpow (by positivity) (by positivity), ← Real.rpow_mul (by positivity), inv_mul_cancel₀ h.ne', Real.rpow_one, Real.mul_rpow (by positivity) (by positivity), Real.rpow_natCast, Real.rpow_natCast, ← pow_mul, ← Real.rpow_mul (by positivity), inv_mul_cancel_right₀ h.ne', Real.rpow_two] exact abs_discr_ge_of_isTotallyComplex K variable {K} theorem abs_discr_ge (h : 1 < finrank ℚ K) : (4 / 9 : ℝ) * (3 * π / 4) ^ finrank ℚ K ≤ |discr K| := by refine le_trans ?_ (abs_discr_ge' K) -- The sequence `a n` is a lower bound for `|discr K|`. We prove below by induction an uniform -- lower bound for this sequence from which we deduce the result. rw [mul_comm 2 _] let a : ℕ → ℝ := fun n => (n : ℝ) ^ (n * 2) / ((4 / π) ^ n * (n.factorial : ℝ) ^ 2) suffices ∀ n, 2 ≤ n → (4 / 9 : ℝ) * (3 * π / 4) ^ n ≤ a n by refine le_trans (this (finrank ℚ K) h) ?_ simp only [a] gcongr · exact (one_le_div Real.pi_pos).2 Real.pi_le_four · rw [← card_add_two_mul_card_eq_rank, mul_comm] exact Nat.le_add_left _ _ intro n hn induction n, hn using Nat.le_induction with | base => exact le_of_eq <| by simp [a, Nat.factorial_two]; field | succ m _ h_m => suffices (3 : ℝ) ≤ (1 + 1 / m : ℝ) ^ (2 * m) by convert_to _ ≤ (a m) * (1 + 1 / m : ℝ) ^ (2 * m) / (4 / π) · simp_rw [a, add_mul, one_mul, pow_succ, Nat.factorial_succ] field_simp simp [field, div_pow] ring · rw [_root_.le_div_iff₀ (by positivity), pow_succ] convert (mul_le_mul h_m this (by positivity) (by positivity)) using 1 field refine le_trans (le_of_eq (by simp [field]; norm_num)) (one_add_mul_le_pow ?_ (2 * m)) exact le_trans (by norm_num : (-2 : ℝ) ≤ 0) (by positivity) /-- **Hermite-Minkowski Theorem**. A nontrivial number field has discriminant greater than `2`. -/ theorem abs_discr_gt_two (h : 1 < finrank ℚ K) : 2 < |discr K| := by rw [← Nat.succ_le_iff] at h rify calc (2 : ℝ) < (4 / 9) * (3 * π / 4) ^ 2 := by nlinarith [Real.pi_gt_three] _ ≤ (4 / 9 : ℝ) * (3 * π / 4) ^ finrank ℚ K := by gcongr linarith [Real.pi_gt_three] _ ≤ |(discr K : ℝ)| := mod_cast abs_discr_ge h /-! ### Hermite Theorem This section is devoted to the proof of Hermite theorem. Let `N` be an integer . We prove that the set `S` of finite extensions `K` of `ℚ` (in some fixed extension `A` of `ℚ`) such that `|discr K| ≤ N` is finite by proving, using `finite_of_finite_generating_set`, that there exists a finite set `T ⊆ A` such that `∀ K ∈ S, ∃ x ∈ T, K = ℚ⟮x⟯` . To find the set `T`, we construct a finite set `T₀` of polynomials in `ℤ[X]` containing, for each `K ∈ S`, the minimal polynomial of a primitive element of `K`. The set `T` is then the union of roots in `A` of the polynomials in `T₀`. More precisely, the set `T₀` is the set of all polynomials in `ℤ[X]` of degrees and coefficients bounded by some explicit constants depending only on `N`. Indeed, we prove that, for any field `K` in `S`, its degree is bounded, see `rank_le_rankOfDiscrBdd`, and also its Minkowski bound, see `minkowskiBound_lt_boundOfDiscBdd`. Thus it follows from `mixedEmbedding.exists_primitive_element_lt_of_isComplex` and `mixedEmbedding.exists_primitive_element_lt_of_isReal` that there exists an algebraic integer `x` of `K` such that `K = ℚ(x)` and the conjugates of `x` are all bounded by some quantity depending only on `N`. Since the primitive element `x` is constructed differently depending on whether `K` has a infinite real place or not, the theorem is proved in two parts. -/ namespace hermiteTheorem open Polynomial open scoped IntermediateField variable (A : Type*) [Field A] [CharZero A] theorem finite_of_finite_generating_set {p : IntermediateField ℚ A → Prop} (S : Set {F : IntermediateField ℚ A // p F}) {T : Set A} (hT : T.Finite) (h : ∀ F ∈ S, ∃ x ∈ T, F = ℚ⟮x⟯) : S.Finite := by rw [← Set.finite_coe_iff] at hT refine Set.finite_coe_iff.mp <| Finite.of_injective (fun ⟨F, hF⟩ ↦ (⟨(h F hF).choose, (h F hF).choose_spec.1⟩ : T)) (fun _ _ h_eq ↦ ?_) rw [Subtype.ext_iff, Subtype.ext_iff] convert congr_arg (ℚ⟮·⟯) (Subtype.mk_eq_mk.mp h_eq) all_goals exact (h _ (Subtype.mem _)).choose_spec.2 variable (N : ℕ) /-- An upper bound on the degree of a number field `K` with `|discr K| ≤ N`, see `rank_le_rankOfDiscrBdd`. -/ noncomputable abbrev rankOfDiscrBdd : ℕ := max 1 (Nat.floor ((Real.log ((9 / 4 : ℝ) * N) / Real.log (3 * π / 4)))) /-- An upper bound on the Minkowski bound of a number field `K` with `|discr K| ≤ N`; see `minkowskiBound_lt_boundOfDiscBdd`. -/ noncomputable abbrev boundOfDiscBdd : ℝ≥0 := sqrt N * (2 : ℝ≥0) ^ rankOfDiscrBdd N + 1 variable {N} (hK : |discr K| ≤ N) include hK in /-- If `|discr K| ≤ N` then the degree of `K` is at most `rankOfDiscrBdd`. -/ theorem rank_le_rankOfDiscrBdd : finrank ℚ K ≤ rankOfDiscrBdd N := by have h_nz : N ≠ 0 := by refine fun h ↦ discr_ne_zero K ?_ rwa [h, Nat.cast_zero, abs_nonpos_iff] at hK have h₂ : 1 < 3 * π / 4 := by rw [_root_.lt_div_iff₀ (by positivity), ← _root_.div_lt_iff₀' (by positivity), one_mul] linarith [Real.pi_gt_three] obtain h | h := lt_or_ge 1 (finrank ℚ K) · apply le_max_of_le_right rw [Nat.le_floor_iff] · have h := le_trans (abs_discr_ge h) (Int.cast_le.mpr hK) contrapose! h rw [← Real.rpow_natCast] rw [Real.log_div_log] at h refine lt_of_le_of_lt ?_ (mul_lt_mul_of_pos_left (Real.rpow_lt_rpow_of_exponent_lt h₂ h) (by positivity : (0 : ℝ) < 4 / 9)) rw [Real.rpow_logb (lt_trans zero_lt_one h₂) (ne_of_gt h₂) (by positivity), ← mul_assoc, ← inv_div, inv_mul_cancel₀ (by simp), one_mul, Int.cast_natCast] · refine div_nonneg (Real.log_nonneg ?_) (Real.log_nonneg (le_of_lt h₂)) rw [mul_comm, ← mul_div_assoc, _root_.le_div_iff₀ (by positivity), one_mul, ← _root_.div_le_iff₀ (by positivity)] exact le_trans (by norm_num) (Nat.one_le_cast.mpr (Nat.one_le_iff_ne_zero.mpr h_nz)) · exact le_max_of_le_left h include hK in /-- If `|discr K| ≤ N` then the Minkowski bound of `K` is less than `boundOfDiscrBdd`. -/ theorem minkowskiBound_lt_boundOfDiscBdd : minkowskiBound K ↑1 < boundOfDiscBdd N := by have : boundOfDiscBdd N - 1 < boundOfDiscBdd N := by simp_rw [boundOfDiscBdd, add_tsub_cancel_right, lt_add_iff_pos_right, zero_lt_one] refine lt_of_le_of_lt ?_ (coe_lt_coe.mpr this) rw [minkowskiBound, volume_fundamentalDomain_fractionalIdealLatticeBasis, boundOfDiscBdd, add_tsub_cancel_right, Units.val_one, FractionalIdeal.absNorm_one, Rat.cast_one, ENNReal.ofReal_one, one_mul, mixedEmbedding.finrank, volume_fundamentalDomain_latticeBasis, coe_mul, ENNReal.coe_pow, coe_ofNat, show sqrt N = (1 : ℝ≥0∞) * sqrt N by rw [one_mul]] gcongr · exact pow_le_one₀ (by positivity) (by simp) · rwa [← NNReal.coe_le_coe, coe_nnnorm, Int.norm_eq_abs, ← Int.cast_abs, NNReal.coe_natCast, ← Int.cast_natCast, Int.cast_le] · exact one_le_two · exact rank_le_rankOfDiscrBdd hK include hK in theorem natDegree_le_rankOfDiscrBdd (a : 𝓞 K) (h : ℚ⟮(a : K)⟯ = ⊤) : natDegree (minpoly ℤ (a : K)) ≤ rankOfDiscrBdd N := by rw [Field.primitive_element_iff_minpoly_natDegree_eq, minpoly.isIntegrallyClosed_eq_field_fractions' ℚ a.isIntegral_coe, (minpoly.monic a.isIntegral_coe).natDegree_map] at h exact h.symm ▸ rank_le_rankOfDiscrBdd hK variable (N) theorem finite_of_discr_bdd_of_isReal : {K : { F : IntermediateField ℚ A // FiniteDimensional ℚ F} | haveI : NumberField K := @NumberField.mk _ _ inferInstance K.prop {w : InfinitePlace K | IsReal w}.Nonempty ∧ |discr K| ≤ N }.Finite := by classical -- The bound on the degree of the generating polynomials let D := rankOfDiscrBdd N -- The bound on the Minkowski bound let B := boundOfDiscBdd N -- The bound on the coefficients of the generating polynomials let C := Nat.ceil ((max B 1) ^ D * Nat.choose D (D / 2)) refine finite_of_finite_generating_set A _ (bUnion_roots_finite (algebraMap ℤ A) D (Set.finite_Icc (-C : ℤ) C)) (fun ⟨K, hK₀⟩ ⟨hK₁, hK₂⟩ ↦ ?_) -- We now need to prove that each field is generated by an element of the union of the root set simp_rw [Set.mem_iUnion] -- this is purely an optimization have : CharZero K := SubsemiringClass.instCharZero K haveI : NumberField K := @NumberField.mk _ _ inferInstance hK₀ obtain ⟨w₀, hw₀⟩ := hK₁ suffices minkowskiBound K ↑1 < (convexBodyLTFactor K) * B by obtain ⟨x, hx₁, hx₂⟩ := exists_primitive_element_lt_of_isReal K hw₀ this have hx := x.isIntegral_coe refine ⟨x, ⟨⟨minpoly ℤ (x : K), ⟨?_, fun i ↦ ?_⟩, ?_⟩, ?_⟩⟩ · exact natDegree_le_rankOfDiscrBdd hK₂ x hx₁ · rw [Set.mem_Icc, ← abs_le, ← @Int.cast_le ℝ] refine (Eq.trans_le ?_ <| Embeddings.coeff_bdd_of_norm_le ((le_iff_le (x : K) _).mp (fun w ↦ le_of_lt (hx₂ w))) i).trans ?_ · rw [minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs] · refine le_trans ?_ (Nat.le_ceil _) rw [show max ↑(max (B : ℝ≥0) 1) (1 : ℝ) = max (B : ℝ) 1 by simp, val_eq_coe, NNReal.coe_mul, NNReal.coe_pow, NNReal.coe_max, NNReal.coe_one, NNReal.coe_natCast] gcongr · exact le_max_right _ 1 · exact rank_le_rankOfDiscrBdd hK₂ · exact (Nat.choose_le_choose _ (rank_le_rankOfDiscrBdd hK₂)).trans (Nat.choose_le_middle _ _) · refine mem_rootSet.mpr ⟨minpoly.ne_zero hx, ?_⟩ exact (aeval_algebraMap_eq_zero_iff A (x : K) _).mpr (minpoly.aeval ℤ (x : K)) · rw [← (IntermediateField.lift_injective _).eq_iff, eq_comm] at hx₁ convert hx₁ · simp only [IntermediateField.lift_top] · simp only [IntermediateField.lift_adjoin, Set.image_singleton] calc minkowskiBound K 1 < B := minkowskiBound_lt_boundOfDiscBdd hK₂ _ = 1 * B := by rw [one_mul] _ ≤ convexBodyLTFactor K * B := by gcongr; exact mod_cast one_le_convexBodyLTFactor K theorem finite_of_discr_bdd_of_isComplex : {K : { F : IntermediateField ℚ A // FiniteDimensional ℚ F} | haveI : NumberField K := @NumberField.mk _ _ inferInstance K.prop {w : InfinitePlace K | IsComplex w}.Nonempty ∧ |discr K| ≤ N }.Finite := by classical -- The bound on the degree of the generating polynomials let D := rankOfDiscrBdd N -- The bound on the Minkowski bound let B := boundOfDiscBdd N -- The bound on the coefficients of the generating polynomials let C := Nat.ceil ((max (sqrt (1 + B ^ 2)) 1) ^ D * Nat.choose D (D / 2)) refine finite_of_finite_generating_set A _ (bUnion_roots_finite (algebraMap ℤ A) D (Set.finite_Icc (-C : ℤ) C)) (fun ⟨K, hK₀⟩ ⟨hK₁, hK₂⟩ ↦ ?_) -- We now need to prove that each field is generated by an element of the union of the root set simp_rw [Set.mem_iUnion] -- this is purely an optimization have : CharZero K := SubsemiringClass.instCharZero K haveI : NumberField K := @NumberField.mk _ _ inferInstance hK₀ obtain ⟨w₀, hw₀⟩ := hK₁ suffices minkowskiBound K ↑1 < (convexBodyLT'Factor K) * boundOfDiscBdd N by obtain ⟨x, hx₁, hx₂⟩ := exists_primitive_element_lt_of_isComplex K hw₀ this have hx := x.isIntegral_coe refine ⟨x, ⟨⟨minpoly ℤ (x : K), ⟨?_, fun i ↦ ?_⟩, ?_⟩, ?_⟩⟩ · exact natDegree_le_rankOfDiscrBdd hK₂ x hx₁ · rw [Set.mem_Icc, ← abs_le, ← @Int.cast_le ℝ] refine (Eq.trans_le ?_ <| Embeddings.coeff_bdd_of_norm_le ((le_iff_le (x : K) _).mp (fun w ↦ le_of_lt (hx₂ w))) i).trans ?_ · rw [minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs] · refine le_trans ?_ (Nat.le_ceil _) rw [val_eq_coe, NNReal.coe_mul, NNReal.coe_pow, NNReal.coe_max, NNReal.coe_one, Real.coe_sqrt, NNReal.coe_add 1, NNReal.coe_one, NNReal.coe_pow] gcongr · exact le_max_right _ 1 · exact rank_le_rankOfDiscrBdd hK₂ · rw [NNReal.coe_natCast, Nat.cast_le] exact (Nat.choose_le_choose _ (rank_le_rankOfDiscrBdd hK₂)).trans (Nat.choose_le_middle _ _) · refine mem_rootSet.mpr ⟨minpoly.ne_zero hx, ?_⟩ exact (aeval_algebraMap_eq_zero_iff A (x : K) _).mpr (minpoly.aeval ℤ (x : K)) · rw [← (IntermediateField.lift_injective _).eq_iff, eq_comm] at hx₁ convert hx₁ · simp only [IntermediateField.lift_top] · simp only [IntermediateField.lift_adjoin, Set.image_singleton] calc minkowskiBound K 1 < B := minkowskiBound_lt_boundOfDiscBdd hK₂ _ = 1 * B := by rw [one_mul] _ ≤ convexBodyLT'Factor K * B := by gcongr; exact mod_cast one_le_convexBodyLT'Factor K /-- **Hermite Theorem**. Let `N` be an integer. There are only finitely many number fields (in some fixed extension of `ℚ`) of discriminant bounded by `N`. -/ theorem _root_.NumberField.finite_of_discr_bdd : {K : { F : IntermediateField ℚ A // FiniteDimensional ℚ F} | haveI : NumberField K := @NumberField.mk _ _ inferInstance K.prop |discr K| ≤ N }.Finite := by refine Set.Finite.subset (Set.Finite.union (finite_of_discr_bdd_of_isReal A N) (finite_of_discr_bdd_of_isComplex A N)) ?_ rintro ⟨K, hK₀⟩ hK₁ -- this is purely an optimization have : CharZero K := SubsemiringClass.instCharZero K haveI : NumberField K := @NumberField.mk _ _ inferInstance hK₀ obtain ⟨w₀⟩ := (inferInstance : Nonempty (InfinitePlace K)) by_cases hw₀ : IsReal w₀ · apply Set.mem_union_left exact ⟨⟨w₀, hw₀⟩, hK₁⟩ · apply Set.mem_union_right exact ⟨⟨w₀, not_isReal_iff_isComplex.mp hw₀⟩, hK₁⟩ end hermiteTheorem end NumberField
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean
import Init.Data.ULift import Init.Data.Fin.Fold import Init.Data.List.Nat.Pairwise import Init.Data.List.Nat.Range import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.Localization.NormTrace /-! # Number field discriminant This file defines the discriminant of a number field. ## Main definitions * `NumberField.discr`: the absolute discriminant of a number field. ## Tags number field, discriminant -/ open Module -- TODO: Rewrite some of the FLT results on the discriminant using the definitions and results of -- this file namespace NumberField variable (K : Type*) [Field K] [NumberField K] /-- The absolute discriminant of a number field. -/ noncomputable abbrev discr : ℤ := Algebra.discr ℤ (RingOfIntegers.basis K) theorem coe_discr : (discr K : ℚ) = Algebra.discr ℚ (integralBasis K) := (Algebra.discr_localizationLocalization ℤ _ K (RingOfIntegers.basis K)).symm theorem discr_ne_zero : discr K ≠ 0 := by rw [← (Int.cast_injective (α := ℚ)).ne_iff, coe_discr] exact Algebra.discr_not_zero_of_basis ℚ (integralBasis K) theorem discr_eq_discr {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι ℤ (𝓞 K)) : Algebra.discr ℤ b = discr K := by let b₀ := Basis.reindex (RingOfIntegers.basis K) (Basis.indexEquiv (RingOfIntegers.basis K) b) rw [Algebra.discr_eq_discr (𝓞 K) b b₀, Basis.coe_reindex, Algebra.discr_reindex] theorem discr_eq_discr_of_algEquiv {L : Type*} [Field L] [NumberField L] (f : K ≃ₐ[ℚ] L) : discr K = discr L := by let f₀ : 𝓞 K ≃ₗ[ℤ] 𝓞 L := (f.restrictScalars ℤ).mapIntegralClosure.toLinearEquiv rw [← Rat.intCast_inj, coe_discr, Algebra.discr_eq_discr_of_algEquiv (integralBasis K) f, ← discr_eq_discr L ((RingOfIntegers.basis K).map f₀)] change _ = algebraMap ℤ ℚ _ rw [← Algebra.discr_localizationLocalization ℤ (nonZeroDivisors ℤ) L] congr 1 ext simp only [Function.comp_apply, integralBasis_apply, Basis.localizationLocalization_apply, Basis.map_apply] rfl theorem discr_eq_discr_of_ringEquiv {L : Type*} [Field L] [NumberField L] (f : K ≃+* L) : discr K = discr L := discr_eq_discr_of_algEquiv _ <| AlgEquiv.ofRingEquiv (f := f) fun _ ↦ by simp end NumberField namespace Rat open NumberField /-- The absolute discriminant of the number field `ℚ` is 1. -/ @[simp] theorem numberField_discr : discr ℚ = 1 := by let b : Basis (Fin 1) ℤ (𝓞 ℚ) := Basis.map (Basis.singleton (Fin 1) ℤ) ringOfIntegersEquiv.toAddEquiv.toIntLinearEquiv.symm calc NumberField.discr ℚ _ = Algebra.discr ℤ b := by convert (discr_eq_discr ℚ b).symm _ = Algebra.trace ℤ (𝓞 ℚ) (b default * b default) := by rw [Algebra.discr_def, Matrix.det_unique, Algebra.traceMatrix_apply, Algebra.traceForm_apply] _ = Algebra.trace ℤ (𝓞 ℚ) 1 := by rw [Basis.map_apply, RingEquiv.toAddEquiv_eq_coe, ← AddEquiv.toIntLinearEquiv_symm, AddEquiv.coe_toIntLinearEquiv, Basis.singleton_apply, show (AddEquiv.symm ↑ringOfIntegersEquiv) (1 : ℤ) = ringOfIntegersEquiv.symm 1 by rfl, map_one, mul_one] _ = 1 := by rw [Algebra.trace_eq_matrix_trace b]; simp alias _root_.NumberField.discr_rat := numberField_discr end Rat variable {ι ι'} (K) [Field K] [DecidableEq ι] [DecidableEq ι'] [Fintype ι] [Fintype ι'] /-- If `b` and `b'` are `ℚ`-bases of a number field `K` such that `∀ i j, IsIntegral ℤ (b.toMatrix b' i j)` and `∀ i j, IsIntegral ℤ (b'.toMatrix b i j)` then `discr ℚ b = discr ℚ b'`. -/ theorem Algebra.discr_eq_discr_of_toMatrix_coeff_isIntegral [NumberField K] {b : Basis ι ℚ K} {b' : Basis ι' ℚ K} (h : ∀ i j, IsIntegral ℤ (b.toMatrix b' i j)) (h' : ∀ i j, IsIntegral ℤ (b'.toMatrix b i j)) : discr ℚ b = discr ℚ b' := by replace h' : ∀ i j, IsIntegral ℤ (b'.toMatrix (b.reindex (b.indexEquiv b')) i j) := by intro i j convert h' i ((b.indexEquiv b').symm j) simp [Basis.toMatrix_apply] classical rw [← (b.reindex (b.indexEquiv b')).toMatrix_map_vecMul b', discr_of_matrix_vecMul, ← one_mul (discr ℚ b), Basis.coe_reindex, discr_reindex] congr have hint : IsIntegral ℤ ((b.reindex (b.indexEquiv b')).toMatrix b').det := IsIntegral.det fun i j => h _ _ obtain ⟨r, hr⟩ := IsIntegrallyClosed.isIntegral_iff.1 hint have hunit : IsUnit r := by have : IsIntegral ℤ (b'.toMatrix (b.reindex (b.indexEquiv b'))).det := IsIntegral.det fun i j => h' _ _ obtain ⟨r', hr'⟩ := IsIntegrallyClosed.isIntegral_iff.1 this refine isUnit_iff_exists_inv.2 ⟨r', ?_⟩ suffices algebraMap ℤ ℚ (r * r') = 1 by rw [← RingHom.map_one (algebraMap ℤ ℚ)] at this exact (IsFractionRing.injective ℤ ℚ) this rw [RingHom.map_mul, hr, hr', ← Matrix.det_mul, Basis.toMatrix_mul_toMatrix_flip, Matrix.det_one] rw [← RingHom.map_one (algebraMap ℤ ℚ), ← hr] rcases Int.isUnit_iff.1 hunit with hp | hm · simp [hp] · simp [hm]
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/NormLeOne.lean
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.FundamentalCone import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.PolarCoord import Mathlib.NumberTheory.NumberField.Units.Regulator /-! # Fundamental Cone: set of elements of norm ≤ 1 In this file, we study the subset `NormLeOne` of the `fundamentalCone` of elements `x` with `mixedEmbedding.norm x ≤ 1`. Mainly, we prove that it is bounded, its frontier has volume zero and compute its volume. ## Strategy of proof The proof is loosely based on the strategy given in [D. Marcus, *Number Fields*][marcus1977number]. 1. since `NormLeOne K` is norm-stable, in the sense that `normLeOne K = normAtAllPlaces⁻¹' (normAtAllPlaces '' (normLeOne K))`, see `normLeOne_eq_preimage_image`, it's enough to study the subset `normAtAllPlaces '' (normLeOne K)` of `realSpace K`. 2. A description of `normAtAllPlaces '' (normLeOne K)` is given by `normAtAllPlaces_normLeOne`, it is the set of `x : realSpace K`, nonnegative at all places, whose norm is nonzero and `≤ 1` and such that `logMap x` is in the `fundamentalDomain` of `basisUnitLattice K`. Note that, here and elsewhere, we identify `x` with its image in `mixedSpace K` given by `mixedSpaceOfRealSpace x`. 3. In order to describe the inverse image in `realSpace K` of the `fundamentalDomain` of `basisUnitLattice K`, we define the map `expMap : realSpace K → realSpace K` that is, in some way, the right inverse of `logMap`, see `logMap_expMap`. 4. Denote by `ηᵢ` (with `i ≠ w₀` where `w₀` is the distinguished infinite place, see the description of `logSpace` below) the fundamental system of units given by `fundSystem` and let `|ηᵢ|` denote `normAtAllPlaces (mixedEmbedding ηᵢ))`, that is the vector `(w (ηᵢ))_w` in `realSpace K`. Then, the image of `|ηᵢ|` by `expMap.symm` form a basis of the subspace `{x : realSpace K | ∑ w, x w = 0}`. We complete by adding the vector `(mult w)_w` to get a basis, called `completeBasis`, of `realSpace K`. The basis `completeBasis K` has the property that, for `i ≠ w₀`, the image of `completeBasis K i` by the natural restriction map `realSpace K → logSpace K` is `basisUnitLattice K`. 5. At this point, we can construct the map `expMapBasis` that plays a crucial part in the proof. It is the map that sends `x : realSpace K` to `Real.exp (x w₀) * ∏_{i ≠ w₀} |ηᵢ| ^ x i`, see `expMapBasis_apply'`. Then, we prove a change of variable formula for `expMapBasis`, see `setLIntegral_expMapBasis_image`. 6. We define a set `paramSet` in `realSpace K` and prove that `normAtAllPlaces '' (normLeOne K) = expMapBasis (paramSet K)`, see `normAtAllPlaces_normLeOne_eq_image`. Using this, `setLIntegral_expMapBasis_image` and the results from `mixedEmbedding.polarCoord`, we can then compute the volume of `normLeOne K`, see `volume_normLeOne`. 7. Finally, we need to prove that the frontier of `normLeOne K` has zero-volume (we will prove in passing that `normLeOne K` is bounded.) For that we prove that `volume (interior (normLeOne K)) = volume (closure (normLeOne K))`, see `volume_interior_eq_volume_closure`. Since we now that the volume of `interior (normLeOne K)` is finite since it is bounded by the volume of `normLeOne K`, the result follows, see `volume_frontier_normLeOne`. We proceed in several steps. 7.1. We prove first that `normAtAllPlaces⁻¹' (expMapBasis '' interior (paramSet K)) ⊆ interior (normLeOne K)`, see `subset_interior_normLeOne` (Note that here again we identify `realSpace K` with its image in `mixedSpace K`). The main argument is that `expMapBasis` is an open partial homeomorphism and that `interior (paramSet K)` is a subset of its source, so its image by `expMapBasis` is still open. 7.2. The same kind of argument does not work with `closure (paramSet)` since it is not contained in the source of `expMapBasis`. So we define a compact set, called `compactSet K`, such that `closure (normLeOne K) ⊆ normAtAllPlaces⁻¹' (compactSet K)`, see `closure_normLeOne_subset`, and it is almost equal to `expMapBasis '' closure (paramSet K)`, see `compactSet_ae`. 7.3. We get from the above that `normLeOne K ⊆ normAtAllPlaces⁻¹' (compactSet K)`, from which it follows easily that `normLeOne K` is bounded, see `isBounded_normLeOne`. 7.4. Finally, we prove that `volume (normAtAllPlaces ⁻¹' compactSet K) = volume (normAtAllPlaces ⁻¹' (expMapBasis '' interior (paramSet K)))`, which implies that `volume (interior (normLeOne K)) = volume (closure (normLeOne K))` by the above and the fact that `volume (interior (normLeOne K)) ≤ volume (closure (normLeOne K))`, which boils down to the fact that the interior and closure of `paramSet K` are almost equal, see `closure_paramSet_ae_interior`. ## Spaces and maps To help understand the proof, we make a list of (almost) all the spaces and maps used and their connections (as hinted above, we do not mention the map `mixedSpaceOfRealSpace` since we identify `realSpace K` with its image in `mixedSpace K`). * `mixedSpace`: the set `({w // IsReal w} → ℝ) × (w // IsComplex w → ℂ)` where `w` denote the infinite places of `K`. * `realSpace`: the set `w → ℝ` where `w` denote the infinite places of `K` * `logSpace`: the set `{w // w ≠ w₀} → ℝ` where `w₀` is a distinguished place of `K`. It is the set used in the proof of Dirichlet Unit Theorem. * `mixedEmbedding : K → mixedSpace K`: the map that sends `x : K` to `φ_w(x)` where, for all infinite place `w`, `φ_w : K → ℝ` or `ℂ`, resp. if `w` is real or if `w` is complex, denote a complex embedding associated to `w`. * `logEmbedding : (𝓞 K)ˣ → logSpace K`: the map that sends the unit `u : (𝓞 K)ˣ` to `(mult w * log (w u))_w` for `w ≠ w₀`. Its image is `unitLattice K`, a `ℤ`-lattice of `logSpace K`, that admits `basisUnitLattice K` as a basis. * `logMap : mixedSpace K → logSpace K`: this map is defined such that it factors `logEmbedding`, that is, for `u : (𝓞 K)ˣ`, `logMap (mixedEmbedding x) = logEmbedding x`, and that `logMap (c • x) = logMap x` for `c ≠ 0` and `norm x ≠ 0`. The inverse image of the fundamental domain of `basisUnitLattice K` by `logMap` (minus the elements of norm zero) is `fundamentalCone K`. * `expMap : realSpace K → realSpace K`: the right inverse of `logMap` in the sense that `logMap (expMap x) = (x_w)_{w ≠ w₀}`. * `expMapBasis : realSpace K → realSpace K`: the map that sends `x : realSpace K` to `Real.exp (x w₀) * ∏_{i ≠ w₀} |ηᵢ| ^ x i` where `|ηᵢ|` denote the vector of `realSpace K` given by `w (ηᵢ)` and `ηᵢ` denote the units in `fundSystem K`. -/ variable (K : Type*) [Field K] open Finset Module NumberField NumberField.InfinitePlace NumberField.mixedEmbedding NumberField.Units dirichletUnitTheorem namespace NumberField.mixedEmbedding.fundamentalCone section normAtAllPlaces variable [NumberField K] variable {K} theorem logMap_normAtAllPlaces (x : mixedSpace K) : logMap (mixedSpaceOfRealSpace (normAtAllPlaces x)) = logMap x := logMap_eq_of_normAtPlace_eq fun w ↦ by rw [normAtPlace_mixedSpaceOfRealSpace (normAtPlace_nonneg w x)] theorem norm_normAtAllPlaces (x : mixedSpace K) : mixedEmbedding.norm (mixedSpaceOfRealSpace (normAtAllPlaces x)) = mixedEmbedding.norm x := by simp_rw [mixedEmbedding.norm_apply, normAtPlace_mixedSpaceOfRealSpace (normAtAllPlaces_nonneg _ _)] theorem normAtAllPlaces_mem_fundamentalCone_iff {x : mixedSpace K} : mixedSpaceOfRealSpace (normAtAllPlaces x) ∈ fundamentalCone K ↔ x ∈ fundamentalCone K := by simp_rw [fundamentalCone, Set.mem_diff, Set.mem_preimage, logMap_normAtAllPlaces, Set.mem_setOf_eq, norm_normAtAllPlaces] end normAtAllPlaces section normLeOne_def variable [NumberField K] /-- The set of elements of the `fundamentalCone` of `norm ≤ 1`. -/ abbrev normLeOne : Set (mixedSpace K) := fundamentalCone K ∩ {x | mixedEmbedding.norm x ≤ 1} variable {K} in theorem mem_normLeOne {x : mixedSpace K} : x ∈ normLeOne K ↔ x ∈ fundamentalCone K ∧ mixedEmbedding.norm x ≤ 1 := Set.mem_sep_iff theorem measurableSet_normLeOne : MeasurableSet (normLeOne K) := (measurableSet_fundamentalCone K).inter <| measurableSet_le (mixedEmbedding.continuous_norm K).measurable measurable_const theorem normLeOne_eq_preimage_image : normLeOne K = normAtAllPlaces ⁻¹' (normAtAllPlaces '' (normLeOne K)) := by refine subset_antisymm (Set.subset_preimage_image _ _) ?_ rintro x ⟨y, hy₁, hy₂⟩ rw [mem_normLeOne, ← normAtAllPlaces_mem_fundamentalCone_iff, ← norm_normAtAllPlaces, ← mem_normLeOne] at hy₁ ⊢ rwa [← hy₂] @[deprecated (since := "2025-07-27")] alias normLeOne_eq_primeage_image := normLeOne_eq_preimage_image open scoped Classical in theorem normAtAllPlaces_normLeOne : normAtAllPlaces '' (normLeOne K) = mixedSpaceOfRealSpace ⁻¹' (logMap ⁻¹' ZSpan.fundamentalDomain ((basisUnitLattice K).ofZLatticeBasis ℝ (unitLattice K))) ∩ {x | (∀ w, 0 ≤ x w)} ∩ {x | mixedEmbedding.norm (mixedSpaceOfRealSpace x) ≠ 0} ∩ {x | mixedEmbedding.norm (mixedSpaceOfRealSpace x) ≤ 1} := by ext x refine ⟨?_, fun ⟨⟨⟨h₁, h₂⟩, h₃⟩, h₄⟩ ↦ ?_⟩ · rintro ⟨y, ⟨⟨h₁, h₂⟩, h₃⟩, rfl⟩ refine ⟨⟨⟨?_, ?_⟩, ?_⟩, ?_⟩ · rwa [Set.mem_preimage, ← logMap_normAtAllPlaces] at h₁ · exact fun w ↦ normAtPlace_nonneg w y · rwa [Set.mem_setOf_eq, ← norm_normAtAllPlaces] at h₂ · rwa [Set.mem_setOf_eq, ← norm_normAtAllPlaces] at h₃ · exact ⟨mixedSpaceOfRealSpace x, ⟨⟨h₁, h₃⟩, h₄⟩, normAtAllPlaces_mixedSpaceOfRealSpace h₂⟩ end normLeOne_def noncomputable section expMap variable {K} /-- The component of `expMap` at the place `w`. -/ @[simps] def expMap_single (w : InfinitePlace K) : OpenPartialHomeomorph ℝ ℝ where toFun := fun x ↦ Real.exp ((w.mult : ℝ)⁻¹ * x) invFun := fun x ↦ w.mult * Real.log x source := Set.univ target := Set.Ioi 0 open_source := isOpen_univ open_target := isOpen_Ioi map_source' _ _ := Real.exp_pos _ map_target' _ _ := trivial left_inv' _ _ := by simp only [Real.log_exp, mul_inv_cancel_left₀ mult_coe_ne_zero] right_inv' _ h := by simp only [inv_mul_cancel_left₀ mult_coe_ne_zero, Real.exp_log h] continuousOn_toFun := (continuousOn_const.mul continuousOn_id).rexp continuousOn_invFun := continuousOn_const.mul (Real.continuousOn_log.mono (by aesop)) /-- The derivative of `expMap_single`, see `hasDerivAt_expMap_single`. -/ abbrev deriv_expMap_single (w : InfinitePlace K) (x : ℝ) : ℝ := (expMap_single w x) * (w.mult : ℝ)⁻¹ theorem hasDerivAt_expMap_single (w : InfinitePlace K) (x : ℝ) : HasDerivAt (expMap_single w) (deriv_expMap_single w x) x := by simpa [expMap_single, mul_comm] using (HasDerivAt.comp x (Real.hasDerivAt_exp _) (hasDerivAt_mul_const (w.mult : ℝ)⁻¹)) variable [NumberField K] /-- The map from `realSpace K → realSpace K` whose components is given by `expMap_single`. It is, in some respect, a right inverse of `logMap`, see `logMap_expMap`. -/ def expMap : OpenPartialHomeomorph (realSpace K) (realSpace K) := OpenPartialHomeomorph.pi fun w ↦ expMap_single w variable (K) theorem expMap_source : expMap.source = (Set.univ : Set (realSpace K)) := by simp_rw [expMap, OpenPartialHomeomorph.pi_toPartialEquiv, PartialEquiv.pi_source, expMap_single, Set.pi_univ Set.univ] theorem expMap_target : expMap.target = Set.univ.pi fun (_ : InfinitePlace K) ↦ Set.Ioi 0 := by simp_rw [expMap, OpenPartialHomeomorph.pi_toPartialEquiv, PartialEquiv.pi_target, expMap_single] theorem injective_expMap : Function.Injective (expMap : realSpace K → realSpace K) := Set.injOn_univ.1 (expMap_source K ▸ expMap.injOn) theorem continuous_expMap : Continuous (expMap : realSpace K → realSpace K) := continuousOn_univ.mp <| (expMap_source K) ▸ expMap.continuousOn variable {K} @[simp] theorem expMap_apply (x : realSpace K) (w : InfinitePlace K) : expMap x w = Real.exp ((↑w.mult)⁻¹ * x w) := rfl theorem expMap_pos (x : realSpace K) (w : InfinitePlace K) : 0 < expMap x w := Real.exp_pos _ theorem expMap_smul (c : ℝ) (x : realSpace K) : expMap (c • x) = (expMap x) ^ c := by ext simp [mul_comm c _, ← mul_assoc, Real.exp_mul] theorem expMap_add (x y : realSpace K) : expMap (x + y) = expMap x * expMap y := by ext simp [mul_add, Real.exp_add] theorem expMap_sum {ι : Type*} (s : Finset ι) (f : ι → realSpace K) : expMap (∑ i ∈ s, f i) = ∏ i ∈ s, expMap (f i) := by ext simp [← Real.exp_sum, ← mul_sum] @[simp] theorem expMap_symm_apply (x : realSpace K) (w : InfinitePlace K) : expMap.symm x w = ↑w.mult * Real.log (x w) := rfl theorem logMap_expMap {x : realSpace K} (hx : mixedEmbedding.norm (mixedSpaceOfRealSpace (expMap x)) = 1) : logMap (mixedSpaceOfRealSpace (expMap x)) = fun w ↦ x w.1 := by ext rw [logMap, normAtPlace_mixedSpaceOfRealSpace (Real.exp_nonneg _), expMap_apply, Real.log_exp, mul_sub, mul_inv_cancel_left₀ mult_coe_ne_zero, hx, Real.log_one, zero_mul, mul_zero, sub_zero] theorem sum_expMap_symm_apply {x : K} (hx : x ≠ 0) : ∑ w : InfinitePlace K, expMap.symm ((normAtAllPlaces (mixedEmbedding K x))) w = Real.log (|Algebra.norm ℚ x| : ℚ) := by simp_rw [← prod_eq_abs_norm, Real.log_prod (fun _ _ ↦ pow_ne_zero _ ((map_ne_zero _).mpr hx)), Real.log_pow, expMap_symm_apply, normAtAllPlaces_mixedEmbedding] /-- The derivative of `expMap`, see `hasFDerivAt_expMap`. -/ abbrev fderiv_expMap (x : realSpace K) : realSpace K →L[ℝ] realSpace K := .pi fun w ↦ (ContinuousLinearMap.smulRight (1 : ℝ →L[ℝ] ℝ) (deriv_expMap_single w (x w))).comp (.proj w) theorem hasFDerivAt_expMap (x : realSpace K) : HasFDerivAt expMap (fderiv_expMap x) x := by simpa [expMap, fderiv_expMap, hasFDerivAt_pi', OpenPartialHomeomorph.pi_apply, ContinuousLinearMap.proj_pi] using fun w ↦ (hasDerivAt_expMap_single w _).hasFDerivAt.comp x (hasFDerivAt_apply w x) end expMap noncomputable section completeBasis variable [NumberField K] variable {K} open scoped Classical in /-- A fixed equiv between `Fin (rank K)` and `{w : InfinitePlace K // w ≠ w₀}`. -/ def equivFinRank : Fin (rank K) ≃ {w : InfinitePlace K // w ≠ w₀} := Fintype.equivOfCardEq <| by rw [Fintype.card_subtype_compl, Fintype.card_ofSubsingleton, Fintype.card_fin, rank] open scoped Classical in variable (K) in /-- A family of elements in the `realSpace K` formed of the image of the fundamental units and the vector `(mult w)_w`. This family is in fact a basis of `realSpace K`, see `completeBasis`. -/ def completeFamily : InfinitePlace K → realSpace K := fun i ↦ if hi : i = w₀ then fun w ↦ mult w else expMap.symm <| normAtAllPlaces <| mixedEmbedding K <| fundSystem K <| equivFinRank.symm ⟨i, hi⟩ /-- An auxiliary map from `realSpace K` to `logSpace K` used to prove that `completeFamily` is linearly independent, see `linearIndependent_completeFamily`. -/ def realSpaceToLogSpace : realSpace K →ₗ[ℝ] {w : InfinitePlace K // w ≠ w₀} → ℝ where toFun := fun x w ↦ x w.1 - w.1.mult * (∑ w', x w') * (Module.finrank ℚ K : ℝ)⁻¹ map_add' := fun _ _ ↦ funext fun _ ↦ by simpa [sum_add_distrib] using by ring map_smul' := fun _ _ ↦ funext fun _ ↦ by simpa [← mul_sum] using by ring theorem realSpaceToLogSpace_apply (x : realSpace K) (w : {w : InfinitePlace K // w ≠ w₀}) : realSpaceToLogSpace x w = x w - w.1.mult * (∑ w', x w') * (Module.finrank ℚ K : ℝ)⁻¹ := rfl theorem realSpaceToLogSpace_expMap_symm {x : K} (hx : x ≠ 0) : realSpaceToLogSpace (expMap.symm (normAtAllPlaces (mixedEmbedding K x))) = logMap (mixedEmbedding K x) := by ext w simp_rw [realSpaceToLogSpace_apply, sum_expMap_symm_apply hx, expMap_symm_apply, logMap, normAtPlace_apply, mul_sub, mul_assoc, norm_eq_norm] theorem realSpaceToLogSpace_completeFamily_of_eq : realSpaceToLogSpace (completeFamily K w₀) = 0 := by ext rw [realSpaceToLogSpace_apply, completeFamily, dif_pos rfl, ← Nat.cast_sum, sum_mult_eq, mul_inv_cancel_right₀ (Nat.cast_ne_zero.mpr Module.finrank_pos.ne'), sub_self, Pi.zero_apply] theorem realSpaceToLogSpace_completeFamily_of_ne (i : {w : InfinitePlace K // w ≠ w₀}) : realSpaceToLogSpace (completeFamily K i) = basisUnitLattice K (equivFinRank.symm i) := by ext rw [← logEmbedding_fundSystem, ← logMap_eq_logEmbedding, completeFamily, dif_neg, realSpaceToLogSpace_expMap_symm] exact coe_ne_zero _ theorem sum_eq_zero_of_mem_span_completeFamily {x : realSpace K} (hx : x ∈ Submodule.span ℝ (Set.range fun w : {w // w ≠ w₀} ↦ completeFamily K w.1)) : ∑ w, x w = 0 := by induction hx using Submodule.span_induction with | mem _ h => obtain ⟨w, rfl⟩ := h simp_rw [completeFamily, dif_neg w.prop, sum_expMap_symm_apply (coe_ne_zero _), Units.norm, Rat.cast_one, Real.log_one] | zero => simp | add _ _ _ _ hx hy => simp [sum_add_distrib, hx, hy] | smul _ _ _ hx => simp [← mul_sum, hx] variable (K) theorem linearIndependent_completeFamily : LinearIndependent ℝ (completeFamily K) := by classical have h₁ : LinearIndependent ℝ (fun w : {w // w ≠ w₀} ↦ completeFamily K w.1) := by refine LinearIndependent.of_comp realSpaceToLogSpace ?_ simp_rw [Function.comp_def, realSpaceToLogSpace_completeFamily_of_ne] convert (((basisUnitLattice K).ofZLatticeBasis ℝ _).reindex equivFinRank).linearIndependent simp have h₂ : completeFamily K w₀ ∉ Submodule.span ℝ (Set.range (fun w : {w // w ≠ w₀} ↦ completeFamily K w.1)) := by intro h have := sum_eq_zero_of_mem_span_completeFamily h rw [completeFamily, dif_pos rfl, ← Nat.cast_sum, sum_mult_eq, Nat.cast_eq_zero] at this exact Module.finrank_pos.ne' this rw [← linearIndependent_equiv (Equiv.optionSubtypeNe w₀), linearIndependent_option] exact ⟨h₁, h₂⟩ /-- A basis of `realSpace K` formed by the image of the fundamental units (which form a basis of a subspace `{x : realSpace K | ∑ w, x w = 0}`) and the vector `(mult w)_w`. For `i ≠ w₀`, the image of `completeBasis K i` by the natural restriction map `realSpace K → logSpace K` is `basisUnitLattice K` -/ def completeBasis : Basis (InfinitePlace K) ℝ (realSpace K) := basisOfLinearIndependentOfCardEqFinrank (linearIndependent_completeFamily K) (Module.finrank_fintype_fun_eq_card _).symm theorem completeBasis_apply_of_eq : completeBasis K w₀ = fun w ↦ (mult w : ℝ) := by rw [completeBasis, coe_basisOfLinearIndependentOfCardEqFinrank, completeFamily, dif_pos rfl] theorem completeBasis_apply_of_ne (i : {w : InfinitePlace K // w ≠ w₀}) : completeBasis K i = expMap.symm (normAtAllPlaces (mixedEmbedding K (fundSystem K (equivFinRank.symm i)))) := by rw [completeBasis, coe_basisOfLinearIndependentOfCardEqFinrank, completeFamily, dif_neg] theorem expMap_basis_of_eq : expMap (completeBasis K w₀) = fun _ ↦ Real.exp 1 := by ext simp_rw [expMap_apply, completeBasis_apply_of_eq, inv_mul_cancel₀ mult_coe_ne_zero] theorem expMap_basis_of_ne (i : {w : InfinitePlace K // w ≠ w₀}) : expMap (completeBasis K i) = normAtAllPlaces (mixedEmbedding K (fundSystem K (equivFinRank.symm i))) := by rw [completeBasis_apply_of_ne, expMap.right_inv (by simp [expMap_target, pos_at_place])] theorem abs_det_completeBasis_equivFunL_symm : |((completeBasis K).equivFunL.symm : realSpace K →L[ℝ] realSpace K).det| = Module.finrank ℚ K * regulator K := by classical rw [ContinuousLinearMap.det, ← LinearMap.det_toMatrix (completeBasis K), ← Matrix.det_transpose, regulator_eq_regOfFamily_fundSystem, finrank_mul_regOfFamily_eq_det _ w₀ equivFinRank.symm] congr 2 with w i rw [Matrix.transpose_apply, LinearMap.toMatrix_apply, Matrix.of_apply, ← Basis.equivFunL_apply, ContinuousLinearMap.coe_coe, ContinuousLinearEquiv.coe_apply, (completeBasis K).equivFunL.apply_symm_apply] split_ifs with hw · rw [hw, completeBasis_apply_of_eq] · simp_rw [completeBasis_apply_of_ne K ⟨w, hw⟩, expMap_symm_apply, normAtAllPlaces_mixedEmbedding] end completeBasis noncomputable section expMapBasis variable [NumberField K] variable {K} /-- The map that sends `x : realSpace K` to `Real.exp (x w₀) * ∏_{i ≠ w₀} |ηᵢ| ^ x i` where `|ηᵢ|` denote the vector of `realSpace K` given by `w (ηᵢ)` and `ηᵢ` denote the units in `fundSystem K`, see `expMapBasis_apply'`. -/ def expMapBasis : OpenPartialHomeomorph (realSpace K) (realSpace K) := (completeBasis K).equivFunL.symm.toHomeomorph.transOpenPartialHomeomorph expMap variable (K) theorem expMapBasis_source : expMapBasis.source = (Set.univ : Set (realSpace K)) := by simp [expMapBasis, expMap_source] theorem injective_expMapBasis : Function.Injective (expMapBasis : realSpace K → realSpace K) := (injective_expMap K).comp (completeBasis K).equivFun.symm.injective theorem continuous_expMapBasis : Continuous (expMapBasis : realSpace K → realSpace K) := (continuous_expMap K).comp (ContinuousLinearEquiv.continuous _) variable {K} theorem expMapBasis_pos (x : realSpace K) (w : InfinitePlace K) : 0 < expMapBasis x w := expMap_pos _ _ theorem expMapBasis_nonneg (x : realSpace K) (w : InfinitePlace K) : 0 ≤ expMapBasis x w := (expMapBasis_pos _ _).le theorem expMapBasis_apply (x : realSpace K) : expMapBasis x = expMap ((completeBasis K).equivFun.symm x) := rfl open scoped Classical in theorem expMapBasis_apply' (x : realSpace K) : expMapBasis x = Real.exp (x w₀) • fun w : InfinitePlace K ↦ ∏ i : {w // w ≠ w₀}, w (fundSystem K (equivFinRank.symm i)) ^ x i := by simp_rw [expMapBasis_apply, Basis.equivFun_symm_apply, Fintype.sum_eq_add_sum_subtype_ne _ w₀, expMap_add, expMap_smul, expMap_basis_of_eq, Pi.pow_def, Real.exp_one_rpow, Pi.mul_def, expMap_sum, expMap_smul, expMap_basis_of_ne, Pi.smul_def, smul_eq_mul, prod_apply, Pi.pow_apply, normAtAllPlaces_mixedEmbedding] open scoped Classical in theorem expMapBasis_apply'' (x : realSpace K) : expMapBasis x = Real.exp (x w₀) • expMapBasis (fun i ↦ if i = w₀ then 0 else x i) := by rw [expMapBasis_apply', expMapBasis_apply', if_pos rfl, smul_smul, ← Real.exp_add, add_zero] conv_rhs => enter [2, w, 2, i] rw [if_neg i.prop] theorem prod_expMapBasis_pow (x : realSpace K) : ∏ w, (expMapBasis x w) ^ w.mult = Real.exp (x w₀) ^ Module.finrank ℚ K := by simp_rw [expMapBasis_apply', Pi.smul_def, smul_eq_mul, mul_pow, prod_mul_distrib, prod_pow_eq_pow_sum, sum_mult_eq, ← prod_pow] rw [prod_comm] simp_rw [Real.rpow_pow_comm (apply_nonneg _ _), Real.finset_prod_rpow _ _ fun _ _ ↦ pow_nonneg (apply_nonneg _ _) _, prod_eq_abs_norm, Units.norm, Rat.cast_one, Real.one_rpow, prod_const_one, mul_one] theorem norm_expMapBasis (x : realSpace K) : mixedEmbedding.norm (mixedSpaceOfRealSpace (expMapBasis x)) = Real.exp (x w₀) ^ Module.finrank ℚ K := by simpa only [mixedEmbedding.norm_apply, normAtPlace_mixedSpaceOfRealSpace (expMapBasis_pos _ _).le] using prod_expMapBasis_pow x theorem norm_expMapBasis_ne_zero (x : realSpace K) : mixedEmbedding.norm (mixedSpaceOfRealSpace (expMapBasis x)) ≠ 0 := norm_expMapBasis x ▸ pow_ne_zero _ (Real.exp_ne_zero _) open scoped Classical in theorem logMap_expMapBasis (x : realSpace K) : logMap (mixedSpaceOfRealSpace (expMapBasis x)) ∈ ZSpan.fundamentalDomain ((basisUnitLattice K).ofZLatticeBasis ℝ (unitLattice K)) ↔ ∀ w, w ≠ w₀ → x w ∈ Set.Ico 0 1 := by classical simp_rw [ZSpan.mem_fundamentalDomain, equivFinRank.forall_congr_left, Subtype.forall] refine forall₂_congr fun w hw ↦ ?_ rw [expMapBasis_apply'', map_smul, logMap_real_smul (norm_expMapBasis_ne_zero _) (Real.exp_ne_zero _), expMapBasis_apply, logMap_expMap (by rw [← expMapBasis_apply, norm_expMapBasis, if_pos rfl, Real.exp_zero, one_pow]), Basis.equivFun_symm_apply, Fintype.sum_eq_add_sum_subtype_ne _ w₀, if_pos rfl, zero_smul, zero_add] conv_lhs => enter [2, 1, 2, w, 2, i] rw [if_neg i.prop] simp_rw [sum_apply, ← sum_fn, map_sum, Pi.smul_apply, ← Pi.smul_def, map_smul, completeBasis_apply_of_ne, expMap_symm_apply, normAtAllPlaces_mixedEmbedding, ← logEmbedding_component, logEmbedding_fundSystem, Finsupp.coe_finset_sum, Finsupp.coe_smul, sum_apply, Pi.smul_apply, Basis.ofZLatticeBasis_repr_apply, Basis.repr_self, Finsupp.single_apply, EmbeddingLike.apply_eq_iff_eq, Int.cast_ite, Int.cast_one, Int.cast_zero, smul_ite, smul_eq_mul, mul_one, mul_zero, Fintype.sum_ite_eq'] theorem normAtAllPlaces_image_preimage_expMapBasis (s : Set (realSpace K)) : normAtAllPlaces '' (normAtAllPlaces ⁻¹' (expMapBasis '' s)) = expMapBasis '' s := by apply normAtAllPlaces_image_preimage_of_nonneg rintro _ ⟨x, _, rfl⟩ w exact (expMapBasis_pos _ _).le open scoped Classical in theorem prod_deriv_expMap_single (x : realSpace K) : ∏ w, deriv_expMap_single w ((completeBasis K).equivFun.symm x w) = Real.exp (x w₀) ^ Module.finrank ℚ K * (∏ w : {w // IsComplex w}, expMapBasis x w.1)⁻¹ * (2⁻¹) ^ nrComplexPlaces K := by simp only [deriv_expMap_single, expMap_single_apply] rw [Finset.prod_mul_distrib] congr 1 · simp_rw [← prod_expMapBasis_pow, prod_eq_prod_mul_prod, expMapBasis_apply, expMap_apply, mult_isReal, mult_isComplex, pow_one, Finset.prod_pow, pow_two, mul_assoc, mul_inv_cancel₀ (Finset.prod_ne_zero_iff.mpr <| fun _ _ ↦ Real.exp_ne_zero _), mul_one] · simp [prod_eq_prod_mul_prod, mult_isReal, mult_isComplex] variable (K) /-- The derivative of `expMapBasis`, see `hasFDerivAt_expMapBasis`. -/ abbrev fderiv_expMapBasis (x : realSpace K) : realSpace K →L[ℝ] realSpace K := (fderiv_expMap ((completeBasis K).equivFun.symm x)).comp (completeBasis K).equivFunL.symm.toContinuousLinearMap theorem hasFDerivAt_expMapBasis (x : realSpace K) : HasFDerivAt expMapBasis (fderiv_expMapBasis K x) x := by change HasFDerivAt (expMap ∘ (completeBasis K).equivFunL.symm) (fderiv_expMapBasis K x) x exact (hasFDerivAt_expMap _).comp x (completeBasis K).equivFunL.symm.hasFDerivAt open Classical ContinuousLinearMap in theorem abs_det_fderiv_expMapBasis (x : realSpace K) : |(fderiv_expMapBasis K x).det| = Real.exp (x w₀ * Module.finrank ℚ K) * (∏ w : {w // IsComplex w}, expMapBasis x w.1)⁻¹ * 2⁻¹ ^ nrComplexPlaces K * (Module.finrank ℚ K) * regulator K := by simp_rw [fderiv_expMapBasis, det, coe_comp, LinearMap.det_comp, fderiv_expMap, coe_pi, coe_comp, coe_proj, LinearMap.det_pi, LinearMap.det_ring, ContinuousLinearMap.coe_coe, smulRight_apply, one_apply, one_smul, abs_mul, abs_det_completeBasis_equivFunL_symm, prod_deriv_expMap_single] simp_rw [abs_mul, Real.exp_mul, abs_pow, Real.rpow_natCast, abs_of_nonneg (Real.exp_nonneg _), abs_inv, abs_prod, abs_of_nonneg (expMapBasis_nonneg _ _), Nat.abs_ofNat] ring variable {K} open ENNReal MeasureTheory open scoped Classical in theorem setLIntegral_expMapBasis_image {s : Set (realSpace K)} (hs : MeasurableSet s) {f : (InfinitePlace K → ℝ) → ℝ≥0∞} (hf : Measurable f) : ∫⁻ x in expMapBasis '' s, f x = (2 : ℝ≥0∞)⁻¹ ^ nrComplexPlaces K * ENNReal.ofReal (regulator K) * (Module.finrank ℚ K) * ∫⁻ x in s, ENNReal.ofReal (Real.exp (x w₀ * Module.finrank ℚ K)) * (∏ i : {w : InfinitePlace K // IsComplex w}, .ofReal (expMapBasis (fun w ↦ x w) i))⁻¹ * f (expMapBasis x) := by rw [lintegral_image_eq_lintegral_abs_det_fderiv_mul volume hs (fun x _ ↦ (hasFDerivAt_expMapBasis K x).hasFDerivWithinAt) (injective_expMapBasis K).injOn] simp_rw [abs_det_fderiv_expMapBasis] have : Measurable expMapBasis := (continuous_expMapBasis K).measurable rw [← lintegral_const_mul _ (by fun_prop)] congr with x have : 0 ≤ (∏ w : {w // IsComplex w}, expMapBasis x w.1)⁻¹ := inv_nonneg.mpr <| Finset.prod_nonneg fun _ _ ↦ (expMapBasis_pos _ _).le rw [ofReal_mul (by positivity), ofReal_mul (by positivity), ofReal_mul (by positivity), ofReal_mul (by positivity), ofReal_pow (by positivity), ofReal_inv_of_pos (Finset.prod_pos fun _ _ ↦ expMapBasis_pos _ _), ofReal_inv_of_pos zero_lt_two, ofReal_ofNat, ofReal_natCast, ofReal_prod_of_nonneg (fun _ _ ↦ (expMapBasis_pos _ _).le)] ring end expMapBasis section paramSet variable [NumberField K] open scoped Classical in /-- The set that parametrizes `normAtAllPlaces '' (normLeOne K)`, see `normAtAllPlaces_normLeOne_eq_image`. -/ abbrev paramSet : Set (realSpace K) := Set.univ.pi fun w ↦ if w = w₀ then Set.Iic 0 else Set.Ico 0 1 theorem measurableSet_paramSet : MeasurableSet (paramSet K) := by refine MeasurableSet.univ_pi fun _ ↦ ?_ split_ifs · exact measurableSet_Iic · exact measurableSet_Ico open scoped Classical in theorem interior_paramSet : interior (paramSet K) = Set.univ.pi fun w ↦ if w = w₀ then Set.Iio 0 else Set.Ioo 0 1 := by simp [interior_pi_set Set.finite_univ, apply_ite] @[deprecated (since := "2025-08-26")] alias measurableSet_interior_paramSet := measurableSet_interior open scoped Classical in theorem closure_paramSet : closure (paramSet K) = Set.univ.pi fun w ↦ if w = w₀ then Set.Iic 0 else Set.Icc 0 1 := by simp [closure_pi_set, apply_ite] theorem normAtAllPlaces_normLeOne_eq_image : normAtAllPlaces '' (normLeOne K) = expMapBasis '' (paramSet K) := by ext x by_cases hx : ∀ w, 0 < x w · rw [← expMapBasis.right_inv (Set.mem_univ_pi.mpr hx), (injective_expMapBasis K).mem_set_image] simp only [normAtAllPlaces_normLeOne, Set.mem_inter_iff, Set.mem_setOf_eq, expMapBasis_nonneg, Set.mem_preimage, logMap_expMapBasis, implies_true, and_true, norm_expMapBasis, pow_le_one_iff_of_nonneg (Real.exp_nonneg _) Module.finrank_pos.ne', Real.exp_le_one_iff, ne_eq, pow_eq_zero_iff', Real.exp_ne_zero, false_and, not_false_eq_true, Set.mem_univ_pi] refine ⟨fun ⟨h₁, h₂⟩ w ↦ ?_, fun h ↦ ⟨fun w hw ↦ by simpa [hw] using h w, by simpa using h w₀⟩⟩ · split_ifs with hw · exact hw ▸ h₂ · exact h₁ w hw · refine ⟨?_, ?_⟩ · rintro ⟨a, ⟨ha, _⟩, rfl⟩ exact (hx fun w ↦ fundamentalCone.normAtPlace_pos_of_mem ha w).elim · rintro ⟨a, _, rfl⟩ exact (hx fun w ↦ expMapBasis_pos a w).elim theorem normLeOne_eq_preimage : normLeOne K = normAtAllPlaces ⁻¹' (expMapBasis '' (paramSet K)) := by rw [normLeOne_eq_preimage_image, normAtAllPlaces_normLeOne_eq_image] theorem subset_interior_normLeOne : normAtAllPlaces ⁻¹' (expMapBasis '' interior (paramSet K)) ⊆ interior (normLeOne K) := by rw [normLeOne_eq_preimage] refine subset_trans (Set.preimage_mono ?_) <| preimage_interior_subset_interior_preimage (continuous_normAtAllPlaces K) have : IsOpen (expMapBasis '' (interior (paramSet K))) := expMapBasis.isOpen_image_of_subset_source isOpen_interior (by simp [expMapBasis_source]) exact interior_maximal (Set.image_mono interior_subset) this open ENNReal MeasureTheory theorem closure_paramSet_ae_interior : closure (paramSet K) =ᵐ[volume] interior (paramSet K) := by rw [closure_paramSet, interior_paramSet, volume_pi] refine Measure.ae_eq_set_pi fun w _ ↦ ?_ split_ifs · exact Iio_ae_eq_Iic.symm · exact Ioo_ae_eq_Icc.symm theorem setLIntegral_paramSet_exp {n : ℕ} (hn : 0 < n) : ∫⁻ (x : realSpace K) in paramSet K, .ofReal (Real.exp (x w₀ * n)) = (n : ℝ≥0∞)⁻¹ := by classical have hn : 0 < (n : ℝ) := Nat.cast_pos.mpr hn rw [volume_pi, paramSet, Measure.restrict_pi_pi, lintegral_eq_lmarginal_univ 0, lmarginal_erase' _ (by fun_prop) (Finset.mem_univ w₀), if_pos rfl] simp_rw [Function.update_self, lmarginal, lintegral_const, Measure.pi_univ, if_neg (Finset.ne_of_mem_erase (Subtype.prop _)), Measure.restrict_apply_univ, Real.volume_Ico, sub_zero, ofReal_one, prod_const_one, mul_one, mul_comm _ (n : ℝ)] rw [← ofReal_integral_eq_lintegral_ofReal (integrableOn_exp_mul_Iic hn _), integral_exp_mul_Iic hn, mul_zero, Real.exp_zero, ofReal_div_of_pos hn, ofReal_one, ofReal_natCast, one_div] filter_upwards with _ using Real.exp_nonneg _ end paramSet section compactSet variable [NumberField K] open Pointwise open scoped Classical in /-- A compact set that contains `expMapBasis '' closure (paramSet K)` and furthermore is almost equal to it, see `compactSet_ae`. -/ abbrev compactSet : Set (realSpace K) := (Set.Icc (0 : ℝ) 1) • (expMapBasis '' Set.univ.pi fun w ↦ if w = w₀ then {0} else Set.Icc 0 1) theorem isCompact_compactSet : IsCompact (compactSet K) := by refine isCompact_Icc.smul_set <| (isCompact_univ_pi fun w ↦ ?_).image_of_continuousOn (continuous_expMapBasis K).continuousOn split_ifs · exact isCompact_singleton · exact isCompact_Icc theorem zero_mem_compactSet : 0 ∈ compactSet K := by refine Set.zero_mem_smul_iff.mpr (Or.inl ⟨Set.left_mem_Icc.mpr zero_le_one, ?_⟩) exact Set.image_nonempty.mpr (Set.univ_pi_nonempty_iff.mpr (by aesop)) theorem nonneg_of_mem_compactSet {x : realSpace K} (hx : x ∈ compactSet K) (w : InfinitePlace K) : 0 ≤ x w := by obtain ⟨c, hc, ⟨_, ⟨⟨a, ha, rfl⟩, _, rfl⟩⟩⟩ := hx exact mul_nonneg hc.1 (expMapBasis_pos _ _).le variable {K} in theorem compactSet_eq_union_aux₁ {x : realSpace K} (hx₀ : x ≠ 0) (hx₁ : x ∈ compactSet K) : x ∈ expMapBasis '' closure (paramSet K) := by classical obtain ⟨c, hc, ⟨_, ⟨y, hy, rfl⟩, rfl⟩⟩ := hx₁ refine ⟨fun w ↦ if w = w₀ then Real.log c else y w, ?_, ?_⟩ · rw [closure_paramSet, Set.mem_univ_pi] intro w split_ifs with h · refine Real.log_nonpos hc.1 hc.2 · simpa [h] using hy w (Set.mem_univ _) · have hc' : 0 < c := by contrapose! hx₀ rw [le_antisymm hx₀ hc.1, zero_smul] rw [expMapBasis_apply'', if_pos rfl, Real.exp_log hc'] congr with w split_ifs with h · simpa [h, eq_comm] using hy w₀ · rfl variable {K} in theorem compactSet_eq_union_aux₂ {x : realSpace K} (hx₀ : x ≠ 0) (hx₁ : x ∈ expMapBasis '' closure (paramSet K)) : x ∈ compactSet K := by classical simp only [closure_paramSet, Set.mem_image, Set.mem_smul, exists_exists_and_eq_and] at hx₁ ⊢ obtain ⟨y, hy, rfl⟩ := hx₁ refine ⟨Real.exp (y w₀), ⟨Real.exp_nonneg _, ?_⟩, fun i ↦ if i = w₀ then 0 else y i, Set.mem_univ_pi.mpr fun w ↦ ?_, by rw [expMapBasis_apply'' y]⟩ · exact Real.exp_le_one_iff.mpr (by simpa using hy w₀ (Set.mem_univ _)) · split_ifs with h · rfl · simpa [h] using hy w (Set.mem_univ _) theorem compactSet_eq_union : compactSet K = expMapBasis '' closure (paramSet K) ∪ {0} := by classical ext x by_cases hx₀ : x = 0 · simpa [hx₀] using zero_mem_compactSet K · refine ⟨fun hx ↦ Set.mem_union_left _ (compactSet_eq_union_aux₁ hx₀ hx), fun hx ↦ ?_⟩ simp only [Set.union_singleton, Set.mem_insert_iff, hx₀, false_or] at hx exact compactSet_eq_union_aux₂ hx₀ hx theorem expMapBasis_closure_subset_compactSet : expMapBasis '' closure (paramSet K) ⊆ compactSet K := by rw [compactSet_eq_union] exact Set.subset_union_left theorem closure_normLeOne_subset : closure (normLeOne K) ⊆ normAtAllPlaces ⁻¹' (compactSet K) := by rw [normLeOne_eq_preimage] refine ((continuous_normAtAllPlaces K).closure_preimage_subset _).trans (Set.preimage_mono ?_) refine (isCompact_compactSet K).isClosed.closure_subset_iff.mpr ?_ exact (Set.image_mono subset_closure).trans (expMapBasis_closure_subset_compactSet _) open MeasureTheory theorem compactSet_ae : compactSet K =ᵐ[volume] expMapBasis '' closure (paramSet K) := by rw [compactSet_eq_union] exact union_ae_eq_left_of_ae_eq_empty (by simp) end compactSet section main_results variable [NumberField K] open Bornology ENNReal MeasureTheory theorem isBounded_normLeOne : IsBounded (normLeOne K) := by classical rw [normLeOne_eq_preimage] suffices IsBounded (expMapBasis '' paramSet K) by obtain ⟨C, hC⟩ := isBounded_iff_forall_norm_le.mp this refine isBounded_iff_forall_norm_le.mpr ⟨C, fun x hx ↦ ?_⟩ rw [norm_eq_sup'_normAtPlace] refine sup'_le _ _ fun w _ ↦ ?_ simpa [normAtAllPlaces_apply, Real.norm_of_nonneg (normAtPlace_nonneg w x)] using (pi_norm_le_iff_of_nonempty _).mp (hC _ hx) w refine IsBounded.subset ?_ (Set.image_mono subset_closure) exact (isCompact_compactSet K).isBounded.subset (expMapBasis_closure_subset_compactSet K) open scoped Classical in theorem volume_normLeOne : volume (normLeOne K) = 2 ^ nrRealPlaces K * NNReal.pi ^ nrComplexPlaces K * .ofReal (regulator K) := by rw [volume_eq_two_pow_mul_two_pi_pow_mul_integral (normLeOne_eq_preimage_image K).symm (measurableSet_normLeOne K), normLeOne_eq_preimage, normAtAllPlaces_image_preimage_expMapBasis, setLIntegral_expMapBasis_image (measurableSet_paramSet K) (by fun_prop)] simp_rw [ENNReal.inv_mul_cancel_right (Finset.prod_ne_zero_iff.mpr fun _ _ ↦ ofReal_ne_zero_iff.mpr (expMapBasis_pos _ _)) (prod_ne_top fun _ _ ↦ ofReal_ne_top)] rw [setLIntegral_paramSet_exp K Module.finrank_pos, ofReal_mul zero_le_two, mul_pow, ofReal_ofNat, ENNReal.mul_inv_cancel_right (Nat.cast_ne_zero.mpr Module.finrank_pos.ne') (natCast_ne_top _), coe_nnreal_eq, NNReal.coe_real_pi, mul_mul_mul_comm, ← ENNReal.inv_pow, ← mul_assoc, ← mul_assoc, ENNReal.inv_mul_cancel_right (pow_ne_zero _ two_ne_zero) (pow_ne_top ENNReal.ofNat_ne_top)] open scoped Classical in theorem volume_interior_eq_volume_closure : volume (interior (normLeOne K)) = volume (closure (normLeOne K)) := by have h₁ : MeasurableSet (normAtAllPlaces ⁻¹' compactSet K) := (isCompact_compactSet K).measurableSet.preimage (continuous_normAtAllPlaces K).measurable have h₂ : MeasurableSet (normAtAllPlaces ⁻¹' (expMapBasis '' interior (paramSet K))) := by refine MeasurableSet.preimage ?_ (continuous_normAtAllPlaces K).measurable refine MeasurableSet.image_of_continuousOn_injOn ?_ (continuous_expMapBasis K).continuousOn (injective_expMapBasis K).injOn exact measurableSet_interior refine le_antisymm (measure_mono interior_subset_closure) ?_ refine (measure_mono (closure_normLeOne_subset K)).trans ?_ refine le_of_eq_of_le ?_ (measure_mono (subset_interior_normLeOne K)) rw [volume_eq_two_pow_mul_two_pi_pow_mul_integral Set.preimage_image_preimage h₁, normAtAllPlaces_image_preimage_of_nonneg (fun x a w ↦ nonneg_of_mem_compactSet K a w), volume_eq_two_pow_mul_two_pi_pow_mul_integral Set.preimage_image_preimage h₂, normAtAllPlaces_image_preimage_expMapBasis, setLIntegral_congr (compactSet_ae K), setLIntegral_expMapBasis_image measurableSet_closure (by fun_prop), setLIntegral_expMapBasis_image measurableSet_interior (by fun_prop), setLIntegral_congr (closure_paramSet_ae_interior K)] open scoped Classical in theorem volume_frontier_normLeOne : volume (frontier (normLeOne K)) = 0 := by rw [frontier, measure_diff, volume_interior_eq_volume_closure, tsub_self] · exact interior_subset_closure · exact measurableSet_interior.nullMeasurableSet · refine lt_top_iff_ne_top.mp <| lt_of_le_of_lt (measure_mono interior_subset) ?_ rw [volume_normLeOne] exact Batteries.compareOfLessAndEq_eq_lt.mp rfl end main_results end NumberField.mixedEmbedding.fundamentalCone
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean
import Mathlib.Algebra.Module.ZLattice.Basic import Mathlib.Analysis.InnerProductSpace.ProdL2 import Mathlib.MeasureTheory.Measure.Haar.Unique import Mathlib.NumberTheory.NumberField.FractionalIdeal import Mathlib.NumberTheory.NumberField.Units.Basic /-! # Canonical embedding of a number field The canonical embedding of a number field `K` of degree `n` is the ring homomorphism `K →+* ℂ^n` that sends `x ∈ K` to `(φ_₁(x),...,φ_n(x))` where the `φ_i`'s are the complex embeddings of `K`. Note that we do not choose an ordering of the embeddings, but instead map `K` into the type `(K →+* ℂ) → ℂ` of `ℂ`-vectors indexed by the complex embeddings. ## Main definitions and results * `NumberField.canonicalEmbedding`: the ring homomorphism `K →+* ((K →+* ℂ) → ℂ)` defined by sending `x : K` to the vector `(φ x)` indexed by `φ : K →+* ℂ`. * `NumberField.canonicalEmbedding.integerLattice.inter_ball_finite`: the intersection of the image of the ring of integers by the canonical embedding and any ball centered at `0` of finite radius is finite. * `NumberField.mixedEmbedding`: the ring homomorphism from `K` to the mixed space `K →+* ({ w // IsReal w } → ℝ) × ({ w // IsComplex w } → ℂ)` that sends `x ∈ K` to `(φ_w x)_w` where `φ_w` is the embedding associated to the infinite place `w`. In particular, if `w` is real then `φ_w : K →+* ℝ` and, if `w` is complex, `φ_w` is an arbitrary choice between the two complex embeddings defining the place `w`. ## Tags number field, infinite places -/ open Module variable (K : Type*) [Field K] namespace NumberField.canonicalEmbedding /-- The canonical embedding of a number field `K` of degree `n` into `ℂ^n`. -/ def _root_.NumberField.canonicalEmbedding : K →+* ((K →+* ℂ) → ℂ) := Pi.ringHom fun φ => φ theorem _root_.NumberField.canonicalEmbedding_injective [NumberField K] : Function.Injective (NumberField.canonicalEmbedding K) := RingHom.injective _ variable {K} @[simp] theorem apply_at (φ : K →+* ℂ) (x : K) : (NumberField.canonicalEmbedding K x) φ = φ x := rfl open scoped ComplexConjugate /-- The image of `canonicalEmbedding` lives in the `ℝ`-submodule of the `x ∈ ((K →+* ℂ) → ℂ)` such that `conj x_φ = x_(conj φ)` for all `∀ φ : K →+* ℂ`. -/ theorem conj_apply {x : ((K →+* ℂ) → ℂ)} (φ : K →+* ℂ) (hx : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K))) : conj (x φ) = x (ComplexEmbedding.conjugate φ) := by refine Submodule.span_induction ?_ ?_ (fun _ _ _ _ hx hy => ?_) (fun a _ _ hx => ?_) hx · rintro _ ⟨x, rfl⟩ rw [apply_at, apply_at, ComplexEmbedding.conjugate_coe_eq] · rw [Pi.zero_apply, Pi.zero_apply, map_zero] · rw [Pi.add_apply, Pi.add_apply, map_add, hx, hy] · rw [Pi.smul_apply, Complex.real_smul, map_mul, Complex.conj_ofReal] exact congrArg ((a : ℂ) * ·) hx theorem nnnorm_eq [NumberField K] (x : K) : ‖canonicalEmbedding K x‖₊ = Finset.univ.sup (fun φ : K →+* ℂ => ‖φ x‖₊) := by simp_rw [Pi.nnnorm_def, apply_at] theorem norm_le_iff [NumberField K] (x : K) (r : ℝ) : ‖canonicalEmbedding K x‖ ≤ r ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r := by obtain hr | hr := lt_or_ge r 0 · obtain ⟨φ⟩ := (inferInstance : Nonempty (K →+* ℂ)) refine iff_of_false ?_ ?_ · exact (hr.trans_le (norm_nonneg _)).not_ge · exact fun h => hr.not_ge (le_trans (norm_nonneg _) (h φ)) · lift r to NNReal using hr simp_rw [← coe_nnnorm, nnnorm_eq, NNReal.coe_le_coe, Finset.sup_le_iff, Finset.mem_univ, forall_true_left] variable (K) /-- The image of `𝓞 K` as a subring of `ℂ^n`. -/ def integerLattice : Subring ((K →+* ℂ) → ℂ) := (RingHom.range (algebraMap (𝓞 K) K)).map (canonicalEmbedding K) theorem integerLattice.inter_ball_finite [NumberField K] (r : ℝ) : ((integerLattice K : Set ((K →+* ℂ) → ℂ)) ∩ Metric.closedBall 0 r).Finite := by obtain hr | _ := lt_or_ge r 0 · simp [Metric.closedBall_eq_empty.2 hr] · have heq : ∀ x, canonicalEmbedding K x ∈ Metric.closedBall 0 r ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r := by intro x; rw [← norm_le_iff, mem_closedBall_zero_iff] convert (Embeddings.finite_of_norm_le K ℂ r).image (canonicalEmbedding K) ext; constructor · rintro ⟨⟨_, ⟨x, rfl⟩, rfl⟩, hx⟩ exact ⟨x, ⟨SetLike.coe_mem x, fun φ => (heq _).mp hx φ⟩, rfl⟩ · rintro ⟨x, ⟨hx1, hx2⟩, rfl⟩ exact ⟨⟨x, ⟨⟨x, hx1⟩, rfl⟩, rfl⟩, (heq x).mpr hx2⟩ /-- A `ℂ`-basis of `ℂ^n` that is also a `ℤ`-basis of the `integerLattice`. -/ noncomputable def latticeBasis [NumberField K] : Basis (Free.ChooseBasisIndex ℤ (𝓞 K)) ℂ ((K →+* ℂ) → ℂ) := by classical -- Let `B` be the canonical basis of `(K →+* ℂ) → ℂ`. We prove that the determinant of -- the image by `canonicalEmbedding` of the integral basis of `K` is nonzero. This -- will imply the result. let B := Pi.basisFun ℂ (K →+* ℂ) let e : (K →+* ℂ) ≃ Free.ChooseBasisIndex ℤ (𝓞 K) := Fintype.equivOfCardEq ((Embeddings.card K ℂ).trans (finrank_eq_card_basis (integralBasis K))) let M := B.toMatrix (fun i => canonicalEmbedding K (integralBasis K (e i))) suffices M.det ≠ 0 by rw [← isUnit_iff_ne_zero, ← Basis.det_apply, ← Basis.is_basis_iff_det] at this exact (basisOfPiSpaceOfLinearIndependent this.1).reindex e -- In order to prove that the determinant is nonzero, we show that it is equal to the -- square of the discriminant of the integral basis and thus it is not zero let N := Algebra.embeddingsMatrixReindex ℚ ℂ (fun i => integralBasis K (e i)) RingHom.equivRatAlgHom rw [show M = N.transpose by { ext : 2; rfl }] rw [Matrix.det_transpose, ← pow_ne_zero_iff two_ne_zero] convert (map_ne_zero_iff _ (algebraMap ℚ ℂ).injective).mpr (Algebra.discr_not_zero_of_basis ℚ (integralBasis K)) rw [← Algebra.discr_reindex ℚ (integralBasis K) e.symm] exact (Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two ℚ ℂ (fun i => integralBasis K (e i)) RingHom.equivRatAlgHom).symm @[simp] theorem latticeBasis_apply [NumberField K] (i : Free.ChooseBasisIndex ℤ (𝓞 K)) : latticeBasis K i = (canonicalEmbedding K) (integralBasis K i) := by simp [latticeBasis, integralBasis_apply, coe_basisOfPiSpaceOfLinearIndependent, Function.comp_apply, Equiv.apply_symm_apply] theorem mem_span_latticeBasis [NumberField K] {x : (K →+* ℂ) → ℂ} : x ∈ Submodule.span ℤ (Set.range (latticeBasis K)) ↔ x ∈ ((canonicalEmbedding K).comp (algebraMap (𝓞 K) K)).range := by rw [show Set.range (latticeBasis K) = (canonicalEmbedding K).toIntAlgHom.toLinearMap '' (Set.range (integralBasis K)) by rw [← Set.range_comp]; exact congrArg Set.range (funext (fun i => latticeBasis_apply K i))] rw [← Submodule.map_span, ← SetLike.mem_coe, Submodule.map_coe] rw [← RingHom.map_range, Subring.mem_map, Set.mem_image] simp only [SetLike.mem_coe, mem_span_integralBasis K] rfl theorem mem_rat_span_latticeBasis [NumberField K] (x : K) : canonicalEmbedding K x ∈ Submodule.span ℚ (Set.range (latticeBasis K)) := by rw [← Basis.sum_repr (integralBasis K) x, map_sum] simp_rw [map_rat_smul] refine Submodule.sum_smul_mem _ _ (fun i _ ↦ Submodule.subset_span ?_) rw [← latticeBasis_apply] exact Set.mem_range_self i theorem integralBasis_repr_apply [NumberField K] (x : K) (i : Free.ChooseBasisIndex ℤ (𝓞 K)) : (latticeBasis K).repr (canonicalEmbedding K x) i = (integralBasis K).repr x i := by rw [← Basis.restrictScalars_repr_apply ℚ _ ⟨_, mem_rat_span_latticeBasis K x⟩, eq_ratCast, Rat.cast_inj] let f := (canonicalEmbedding K).toRatAlgHom.toLinearMap.codRestrict _ (fun x ↦ mem_rat_span_latticeBasis K x) suffices ((latticeBasis K).restrictScalars ℚ).repr.toLinearMap ∘ₗ f = (integralBasis K).repr.toLinearMap from DFunLike.congr_fun (LinearMap.congr_fun this x) i refine Basis.ext (integralBasis K) (fun i ↦ ?_) have : f (integralBasis K i) = ((latticeBasis K).restrictScalars ℚ) i := by apply Subtype.val_injective rw [LinearMap.codRestrict_apply, AlgHom.toLinearMap_apply, Basis.restrictScalars_apply, latticeBasis_apply] rfl simp_rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, this, Basis.repr_self] end NumberField.canonicalEmbedding namespace NumberField.mixedEmbedding open NumberField.InfinitePlace Module Finset /-- The mixed space `ℝ^r₁ × ℂ^r₂` with `(r₁, r₂)` the signature of `K`. -/ abbrev mixedSpace := ({w : InfinitePlace K // IsReal w} → ℝ) × ({w : InfinitePlace K // IsComplex w} → ℂ) /-- The mixed embedding of a number field `K` into the mixed space of `K`. -/ noncomputable def _root_.NumberField.mixedEmbedding : K →+* (mixedSpace K) := RingHom.prod (Pi.ringHom fun w => embedding_of_isReal w.prop) (Pi.ringHom fun w => w.val.embedding) @[simp] theorem mixedEmbedding_apply_isReal (x : K) (w : {w // IsReal w}) : (mixedEmbedding K x).1 w = embedding_of_isReal w.prop x := by simp_rw [mixedEmbedding, RingHom.prod_apply, Pi.ringHom_apply] @[simp] theorem mixedEmbedding_apply_isComplex (x : K) (w : {w // IsComplex w}) : (mixedEmbedding K x).2 w = w.val.embedding x := by simp_rw [mixedEmbedding, RingHom.prod_apply, Pi.ringHom_apply] instance [NumberField K] : Nontrivial (mixedSpace K) := by obtain ⟨w⟩ := (inferInstance : Nonempty (InfinitePlace K)) obtain hw | hw := w.isReal_or_isComplex · have : Nonempty {w : InfinitePlace K // IsReal w} := ⟨⟨w, hw⟩⟩ exact nontrivial_prod_left · have : Nonempty {w : InfinitePlace K // IsComplex w} := ⟨⟨w, hw⟩⟩ exact nontrivial_prod_right protected theorem finrank [NumberField K] : finrank ℝ (mixedSpace K) = finrank ℚ K := by classical rw [finrank_prod, finrank_pi, finrank_pi_fintype, Complex.finrank_real_complex, sum_const, card_univ, ← nrRealPlaces, ← nrComplexPlaces, ← card_real_embeddings, Algebra.id.smul_eq_mul, mul_comm, ← card_complex_embeddings, ← NumberField.Embeddings.card K ℂ, Fintype.card_subtype_compl, Nat.add_sub_of_le (Fintype.card_subtype_le _)] theorem _root_.NumberField.mixedEmbedding_injective [NumberField K] : Function.Injective (NumberField.mixedEmbedding K) := by exact RingHom.injective _ section Measure open MeasureTheory.Measure MeasureTheory variable [NumberField K] open Classical in instance : IsAddHaarMeasure (volume : Measure (mixedSpace K)) := prod.instIsAddHaarMeasure volume volume open Classical in instance : NoAtoms (volume : Measure (mixedSpace K)) := by obtain ⟨w⟩ := (inferInstance : Nonempty (InfinitePlace K)) by_cases hw : IsReal w · have : NoAtoms (volume : Measure ({w : InfinitePlace K // IsReal w} → ℝ)) := pi_noAtoms ⟨w, hw⟩ exact prod.instNoAtoms_fst · have : NoAtoms (volume : Measure ({w : InfinitePlace K // IsComplex w} → ℂ)) := pi_noAtoms ⟨w, not_isReal_iff_isComplex.mp hw⟩ exact prod.instNoAtoms_snd variable {K} in open Classical in /-- The set of points in the mixedSpace that are equal to `0` at a fixed (real) place has volume zero. -/ theorem volume_eq_zero (w : {w // IsReal w}) : volume ({x : mixedSpace K | x.1 w = 0}) = 0 := by let A : AffineSubspace ℝ (mixedSpace K) := Submodule.toAffineSubspace (Submodule.mk ⟨⟨{x | x.1 w = 0}, by simp_all⟩, rfl⟩ (by simp_all)) convert Measure.addHaar_affineSubspace volume A fun h ↦ ?_ simpa [A] using (h ▸ Set.mem_univ _ : 1 ∈ A) end Measure section commMap /-- The linear map that makes `canonicalEmbedding` and `mixedEmbedding` commute, see `commMap_canonical_eq_mixed`. -/ noncomputable def commMap : ((K →+* ℂ) → ℂ) →ₗ[ℝ] (mixedSpace K) where toFun := fun x => ⟨fun w => (x w.val.embedding).re, fun w => x w.val.embedding⟩ map_add' := by simp only [Pi.add_apply, Complex.add_re, Prod.mk_add_mk, Prod.mk.injEq] exact fun _ _ => ⟨rfl, rfl⟩ map_smul' := by simp only [Pi.smul_apply, Complex.real_smul, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero, RingHom.id_apply, Prod.smul_mk, Prod.mk.injEq] exact fun _ _ => ⟨rfl, rfl⟩ theorem commMap_apply_of_isReal (x : (K →+* ℂ) → ℂ) {w : InfinitePlace K} (hw : IsReal w) : (commMap K x).1 ⟨w, hw⟩ = (x w.embedding).re := rfl theorem commMap_apply_of_isComplex (x : (K →+* ℂ) → ℂ) {w : InfinitePlace K} (hw : IsComplex w) : (commMap K x).2 ⟨w, hw⟩ = x w.embedding := rfl @[simp] theorem commMap_canonical_eq_mixed (x : K) : commMap K (canonicalEmbedding K x) = mixedEmbedding K x := by simp only [canonicalEmbedding, commMap, LinearMap.coe_mk, AddHom.coe_mk, Pi.ringHom_apply, mixedEmbedding, RingHom.prod_apply, Prod.mk.injEq] exact ⟨rfl, rfl⟩ /-- This is a technical result to ensure that the image of the `ℂ`-basis of `ℂ^n` defined in `canonicalEmbedding.latticeBasis` is a `ℝ`-basis of the mixed space `ℝ^r₁ × ℂ^r₂`, see `mixedEmbedding.latticeBasis`. -/ theorem disjoint_span_commMap_ker [NumberField K] : Disjoint (Submodule.span ℝ (Set.range (canonicalEmbedding.latticeBasis K))) (LinearMap.ker (commMap K)) := by refine LinearMap.disjoint_ker.mpr (fun x h_mem h_zero => ?_) replace h_mem : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K)) := by refine (Submodule.span_mono ?_) h_mem rintro _ ⟨i, rfl⟩ exact ⟨integralBasis K i, (canonicalEmbedding.latticeBasis_apply K i).symm⟩ ext1 φ rw [Pi.zero_apply] by_cases hφ : ComplexEmbedding.IsReal φ · apply Complex.ext · rw [← embedding_mk_eq_of_isReal hφ, ← commMap_apply_of_isReal K x ⟨φ, hφ, rfl⟩] exact congrFun (congrArg (fun x => x.1) h_zero) ⟨InfinitePlace.mk φ, _⟩ · rw [Complex.zero_im, ← Complex.conj_eq_iff_im, canonicalEmbedding.conj_apply _ h_mem, ComplexEmbedding.isReal_iff.mp hφ] · have := congrFun (congrArg (fun x => x.2) h_zero) ⟨InfinitePlace.mk φ, ⟨φ, hφ, rfl⟩⟩ cases embedding_mk_eq φ with | inl h => rwa [← h, ← commMap_apply_of_isComplex K x ⟨φ, hφ, rfl⟩] | inr h => apply RingHom.injective (starRingEnd ℂ) rwa [canonicalEmbedding.conj_apply _ h_mem, ← h, map_zero, ← commMap_apply_of_isComplex K x ⟨φ, hφ, rfl⟩] end commMap noncomputable section norm variable {K} open scoped Classical in /-- The norm at the infinite place `w` of an element of the mixed space -/ def normAtPlace (w : InfinitePlace K) : (mixedSpace K) →*₀ ℝ where toFun x := if hw : IsReal w then ‖x.1 ⟨w, hw⟩‖ else ‖x.2 ⟨w, not_isReal_iff_isComplex.mp hw⟩‖ map_zero' := by simp map_one' := by simp map_mul' x y := by split_ifs <;> simp theorem normAtPlace_nonneg (w : InfinitePlace K) (x : mixedSpace K) : 0 ≤ normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> exact norm_nonneg _ theorem normAtPlace_neg (w : InfinitePlace K) (x : mixedSpace K) : normAtPlace w (-x) = normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> simp theorem normAtPlace_add_le (w : InfinitePlace K) (x y : mixedSpace K) : normAtPlace w (x + y) ≤ normAtPlace w x + normAtPlace w y := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> exact norm_add_le _ _ theorem normAtPlace_smul (w : InfinitePlace K) (x : mixedSpace K) (c : ℝ) : normAtPlace w (c • x) = |c| * normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> simp theorem normAtPlace_real (w : InfinitePlace K) (c : ℝ) : normAtPlace w ((fun _ ↦ c, fun _ ↦ c) : (mixedSpace K)) = |c| := by rw [show ((fun _ ↦ c, fun _ ↦ c) : (mixedSpace K)) = c • 1 by ext <;> simp, normAtPlace_smul, map_one, mul_one] theorem normAtPlace_apply_of_isReal {w : InfinitePlace K} (hw : IsReal w) (x : mixedSpace K) : normAtPlace w x = ‖x.1 ⟨w, hw⟩‖ := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, dif_pos] theorem normAtPlace_apply_of_isComplex {w : InfinitePlace K} (hw : IsComplex w) (x : mixedSpace K) : normAtPlace w x = ‖x.2 ⟨w, hw⟩‖ := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, dif_neg (not_isReal_iff_isComplex.mpr hw)] @[simp] theorem normAtPlace_apply (w : InfinitePlace K) (x : K) : normAtPlace w (mixedEmbedding K x) = w x := by simp_rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, mixedEmbedding, RingHom.prod_apply, Pi.ringHom_apply, norm_embedding_of_isReal, norm_embedding_eq, dite_eq_ite, ite_id] theorem forall_normAtPlace_eq_zero_iff {x : mixedSpace K} : (∀ w, normAtPlace w x = 0) ↔ x = 0 := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · ext w · exact norm_eq_zero.mp (normAtPlace_apply_of_isReal w.prop _ ▸ h w.1) · exact norm_eq_zero.mp (normAtPlace_apply_of_isComplex w.prop _ ▸ h w.1) · simp_rw [h, map_zero, implies_true] @[simp] theorem exists_normAtPlace_ne_zero_iff {x : mixedSpace K} : (∃ w, normAtPlace w x ≠ 0) ↔ x ≠ 0 := by rw [ne_eq, ← forall_normAtPlace_eq_zero_iff, not_forall] @[fun_prop] theorem continuous_normAtPlace (w : InfinitePlace K) : Continuous (normAtPlace w) := by simp_rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> fun_prop variable [NumberField K] open scoped Classical in theorem nnnorm_eq_sup_normAtPlace (x : mixedSpace K) : ‖x‖₊ = univ.sup fun w ↦ ⟨normAtPlace w x, normAtPlace_nonneg w x⟩ := by have : (univ : Finset (InfinitePlace K)) = (univ.image (fun w : {w : InfinitePlace K // IsReal w} ↦ w.1)) ∪ (univ.image (fun w : {w : InfinitePlace K // IsComplex w} ↦ w.1)) := by ext; simp [isReal_or_isComplex] rw [this, sup_union, univ.sup_image, univ.sup_image, Prod.nnnorm_def, Pi.nnnorm_def, Pi.nnnorm_def] congr · ext w simp [normAtPlace_apply_of_isReal w.prop] · ext w simp [normAtPlace_apply_of_isComplex w.prop] open scoped Classical in theorem norm_eq_sup'_normAtPlace (x : mixedSpace K) : ‖x‖ = univ.sup' univ_nonempty fun w ↦ normAtPlace w x := by rw [← coe_nnnorm, nnnorm_eq_sup_normAtPlace, ← sup'_eq_sup univ_nonempty, ← NNReal.val_eq_coe, ← OrderHom.Subtype.val_coe, map_finset_sup', OrderHom.Subtype.val_coe] simp only [Function.comp_apply] /-- The norm of `x` is `∏ w, (normAtPlace x) ^ mult w`. It is defined such that the norm of `mixedEmbedding K a` for `a : K` is equal to the absolute value of the norm of `a` over `ℚ`, see `norm_eq_norm`. -/ protected def norm : (mixedSpace K) →*₀ ℝ where toFun x := ∏ w, (normAtPlace w x) ^ (mult w) map_one' := by simp only [map_one, one_pow, prod_const_one] map_zero' := by simp [mult] map_mul' _ _ := by simp only [map_mul, mul_pow, prod_mul_distrib] protected theorem norm_apply (x : mixedSpace K) : mixedEmbedding.norm x = ∏ w, (normAtPlace w x) ^ (mult w) := rfl protected theorem norm_nonneg (x : mixedSpace K) : 0 ≤ mixedEmbedding.norm x := univ.prod_nonneg fun _ _ ↦ pow_nonneg (normAtPlace_nonneg _ _) _ protected theorem norm_eq_zero_iff {x : mixedSpace K} : mixedEmbedding.norm x = 0 ↔ ∃ w, normAtPlace w x = 0 := by simp_rw [mixedEmbedding.norm, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, prod_eq_zero_iff, mem_univ, true_and, pow_eq_zero_iff mult_ne_zero] protected theorem norm_ne_zero_iff {x : mixedSpace K} : mixedEmbedding.norm x ≠ 0 ↔ ∀ w, normAtPlace w x ≠ 0 := by rw [← not_iff_not] simp_rw [ne_eq, mixedEmbedding.norm_eq_zero_iff, not_not, not_forall, not_not] theorem norm_eq_of_normAtPlace_eq {x y : mixedSpace K} (h : ∀ w, normAtPlace w x = normAtPlace w y) : mixedEmbedding.norm x = mixedEmbedding.norm y := by simp_rw [mixedEmbedding.norm_apply, h] theorem norm_smul (c : ℝ) (x : mixedSpace K) : mixedEmbedding.norm (c • x) = |c| ^ finrank ℚ K * (mixedEmbedding.norm x) := by simp_rw [mixedEmbedding.norm_apply, normAtPlace_smul, mul_pow, prod_mul_distrib, prod_pow_eq_pow_sum, sum_mult_eq] theorem norm_real (c : ℝ) : mixedEmbedding.norm ((fun _ ↦ c, fun _ ↦ c) : (mixedSpace K)) = |c| ^ finrank ℚ K := by rw [show ((fun _ ↦ c, fun _ ↦ c) : (mixedSpace K)) = c • 1 by ext <;> simp, norm_smul, map_one, mul_one] @[simp] theorem norm_eq_norm (x : K) : mixedEmbedding.norm (mixedEmbedding K x) = |Algebra.norm ℚ x| := by simp_rw [mixedEmbedding.norm_apply, normAtPlace_apply, prod_eq_abs_norm] theorem norm_unit (u : (𝓞 K)ˣ) : mixedEmbedding.norm (mixedEmbedding K u) = 1 := by rw [norm_eq_norm, Units.norm, Rat.cast_one] theorem norm_eq_zero_iff' {x : mixedSpace K} (hx : x ∈ Set.range (mixedEmbedding K)) : mixedEmbedding.norm x = 0 ↔ x = 0 := by obtain ⟨a, rfl⟩ := hx rw [norm_eq_norm, Rat.cast_abs, abs_eq_zero, Rat.cast_eq_zero, Algebra.norm_eq_zero_iff, map_eq_zero] variable (K) in @[fun_prop] protected theorem continuous_norm : Continuous (mixedEmbedding.norm : (mixedSpace K) → ℝ) := by refine continuous_finset_prod Finset.univ fun _ _ ↦ ?_ simp_rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, dite_pow] split_ifs <;> fun_prop end norm noncomputable section stdBasis open Complex MeasureTheory MeasureTheory.Measure ZSpan Matrix ComplexConjugate variable [NumberField K] /-- The type indexing the basis `stdBasis`. -/ abbrev index := {w : InfinitePlace K // IsReal w} ⊕ ({w : InfinitePlace K // IsComplex w}) × (Fin 2) open scoped Classical in /-- The `ℝ`-basis of the mixed space of `K` formed by the vector equal to `1` at `w` and `0` elsewhere for `IsReal w` and by the couple of vectors equal to `1` (resp. `I`) at `w` and `0` elsewhere for `IsComplex w`. -/ def stdBasis : Basis (index K) ℝ (mixedSpace K) := Basis.prod (Pi.basisFun ℝ _) (Basis.reindex (Pi.basis fun _ => basisOneI) (Equiv.sigmaEquivProd _ _)) variable {K} @[simp] theorem stdBasis_apply_isReal (x : mixedSpace K) (w : {w : InfinitePlace K // IsReal w}) : (stdBasis K).repr x (Sum.inl w) = x.1 w := rfl @[simp] theorem stdBasis_apply_isComplex_fst (x : mixedSpace K) (w : {w : InfinitePlace K // IsComplex w}) : (stdBasis K).repr x (Sum.inr ⟨w, 0⟩) = (x.2 w).re := rfl @[simp] theorem stdBasis_apply_isComplex_snd (x : mixedSpace K) (w : {w : InfinitePlace K // IsComplex w}) : (stdBasis K).repr x (Sum.inr ⟨w, 1⟩) = (x.2 w).im := rfl variable (K) open scoped Classical in theorem fundamentalDomain_stdBasis : fundamentalDomain (stdBasis K) = (Set.univ.pi fun _ => Set.Ico 0 1) ×ˢ (Set.univ.pi fun _ => Complex.measurableEquivPi ⁻¹' (Set.univ.pi fun _ => Set.Ico 0 1)) := by ext simp [stdBasis, mem_fundamentalDomain, Complex.measurableEquivPi] open scoped Classical in theorem volume_fundamentalDomain_stdBasis : volume (fundamentalDomain (stdBasis K)) = 1 := by rw [fundamentalDomain_stdBasis, volume_eq_prod, prod_prod, volume_pi, volume_pi, pi_pi, pi_pi, Complex.volume_preserving_equiv_pi.measure_preimage ?_, volume_pi, pi_pi, Real.volume_Ico, sub_zero, ENNReal.ofReal_one, prod_const_one, prod_const_one, prod_const_one, one_mul] exact (MeasurableSet.pi Set.countable_univ (fun _ _ => measurableSet_Ico)).nullMeasurableSet open scoped Classical in /-- The `Equiv` between `index K` and `K →+* ℂ` defined by sending a real infinite place `w` to the unique corresponding embedding `w.embedding`, and the pair `⟨w, 0⟩` (resp. `⟨w, 1⟩`) for a complex infinite place `w` to `w.embedding` (resp. `conjugate w.embedding`). -/ def indexEquiv : (index K) ≃ (K →+* ℂ) := by refine Equiv.ofBijective (fun c => ?_) ((Fintype.bijective_iff_surjective_and_card _).mpr ⟨?_, ?_⟩) · cases c with | inl w => exact w.val.embedding | inr wj => rcases wj with ⟨w, j⟩ exact if j = 0 then w.val.embedding else ComplexEmbedding.conjugate w.val.embedding · intro φ by_cases hφ : ComplexEmbedding.IsReal φ · exact ⟨Sum.inl (InfinitePlace.mkReal ⟨φ, hφ⟩), by simp [embedding_mk_eq_of_isReal hφ]⟩ · by_cases hw : (InfinitePlace.mk φ).embedding = φ · exact ⟨Sum.inr ⟨InfinitePlace.mkComplex ⟨φ, hφ⟩, 0⟩, by simp [hw]⟩ · exact ⟨Sum.inr ⟨InfinitePlace.mkComplex ⟨φ, hφ⟩, 1⟩, by simp [(embedding_mk_eq φ).resolve_left hw]⟩ · rw [Embeddings.card, ← mixedEmbedding.finrank K, ← Module.finrank_eq_card_basis (stdBasis K)] variable {K} @[simp] theorem indexEquiv_apply_isReal (w : {w : InfinitePlace K // IsReal w}) : (indexEquiv K) (Sum.inl w) = w.val.embedding := rfl @[simp] theorem indexEquiv_apply_isComplex_fst (w : {w : InfinitePlace K // IsComplex w}) : (indexEquiv K) (Sum.inr ⟨w, 0⟩) = w.val.embedding := rfl @[simp] theorem indexEquiv_apply_isComplex_snd (w : {w : InfinitePlace K // IsComplex w}) : (indexEquiv K) (Sum.inr ⟨w, 1⟩) = ComplexEmbedding.conjugate w.val.embedding := rfl variable (K) open scoped Classical in /-- The matrix that gives the representation on `stdBasis` of the image by `commMap` of an element `x` of `(K →+* ℂ) → ℂ` fixed by the map `x_φ ↦ conj x_(conjugate φ)`, see `stdBasis_repr_eq_matrixToStdBasis_mul`. -/ def matrixToStdBasis : Matrix (index K) (index K) ℂ := fromBlocks (diagonal fun _ => 1) 0 0 <| reindex (Equiv.prodComm _ _) (Equiv.prodComm _ _) (blockDiagonal (fun _ => (2 : ℂ)⁻¹ • !![1, 1; -I, I])) open scoped Classical in theorem det_matrixToStdBasis : (matrixToStdBasis K).det = (2⁻¹ * I) ^ nrComplexPlaces K := calc _ = ∏ _k : { w : InfinitePlace K // IsComplex w }, det ((2 : ℂ)⁻¹ • !![1, 1; -I, I]) := by rw [matrixToStdBasis, det_fromBlocks_zero₂₁, det_diagonal, prod_const_one, one_mul, det_reindex_self, det_blockDiagonal] _ = ∏ _k : { w : InfinitePlace K // IsComplex w }, (2⁻¹ * Complex.I) := by refine prod_congr (Eq.refl _) (fun _ _ => ?_) simp [field]; ring _ = (2⁻¹ * Complex.I) ^ Fintype.card {w : InfinitePlace K // IsComplex w} := by rw [prod_const, Fintype.card] open scoped Classical in /-- Let `x : (K →+* ℂ) → ℂ` such that `x_φ = conj x_(conj φ)` for all `φ : K →+* ℂ`, then the representation of `commMap K x` on `stdBasis` is given (up to reindexing) by the product of `matrixToStdBasis` by `x`. -/ theorem stdBasis_repr_eq_matrixToStdBasis_mul (x : (K →+* ℂ) → ℂ) (hx : ∀ φ, conj (x φ) = x (ComplexEmbedding.conjugate φ)) (c : index K) : ((stdBasis K).repr (commMap K x) c : ℂ) = (matrixToStdBasis K *ᵥ (x ∘ (indexEquiv K))) c := by simp_rw [commMap, matrixToStdBasis, LinearMap.coe_mk, AddHom.coe_mk, mulVec, dotProduct, Function.comp_apply, index, Fintype.sum_sum_type, diagonal_one, reindex_apply, ← univ_product_univ, sum_product, indexEquiv_apply_isReal, Fin.sum_univ_two, indexEquiv_apply_isComplex_fst, indexEquiv_apply_isComplex_snd, smul_of, smul_cons, smul_eq_mul, mul_one, Matrix.smul_empty, Equiv.prodComm_symm, Equiv.coe_prodComm] cases c with | inl w => simp_rw [stdBasis_apply_isReal, fromBlocks_apply₁₁, fromBlocks_apply₁₂, one_apply, Matrix.zero_apply, ite_mul, one_mul, zero_mul, sum_ite_eq, mem_univ, ite_true, add_zero, sum_const_zero, add_zero, ← conj_eq_iff_re, hx (embedding w.val), conjugate_embedding_eq_of_isReal w.prop] | inr c => rcases c with ⟨w, j⟩ fin_cases j · simp only [Fin.zero_eta, Fin.isValue, stdBasis_apply_isComplex_fst, re_eq_add_conj, mul_neg, fromBlocks_apply₂₁, zero_apply, zero_mul, sum_const_zero, fromBlocks_apply₂₂, submatrix_apply, Prod.swap_prod_mk, blockDiagonal_apply, of_apply, cons_val', cons_val_zero, empty_val', cons_val_fin_one, ite_mul, cons_val_one, sum_add_distrib, sum_ite_eq, mem_univ, ↓reduceIte, ← hx (embedding w), zero_add] ring · simp only [Fin.mk_one, Fin.isValue, stdBasis_apply_isComplex_snd, im_eq_sub_conj, mul_neg, fromBlocks_apply₂₁, zero_apply, zero_mul, sum_const_zero, fromBlocks_apply₂₂, submatrix_apply, Prod.swap_prod_mk, blockDiagonal_apply, of_apply, cons_val', cons_val_zero, empty_val', cons_val_fin_one, cons_val_one, ite_mul, neg_mul, sum_add_distrib, sum_ite_eq, mem_univ, ↓reduceIte, ← hx (embedding w), zero_add] ring_nf; simp [field] end stdBasis noncomputable section integerLattice variable [NumberField K] open Module.Free open scoped nonZeroDivisors /-- The image of the ring of integers of `K` in the mixed space. -/ protected abbrev integerLattice : Submodule ℤ (mixedSpace K) := LinearMap.range ((mixedEmbedding K).comp (algebraMap (𝓞 K) K)).toIntAlgHom.toLinearMap /-- A `ℝ`-basis of the mixed space that is also a `ℤ`-basis of the image of `𝓞 K`. -/ def latticeBasis : Basis (ChooseBasisIndex ℤ (𝓞 K)) ℝ (mixedSpace K) := by classical -- We construct an `ℝ`-linear independent family from the image of -- `canonicalEmbedding.lattice_basis` by `commMap` have := LinearIndependent.map (LinearIndependent.restrict_scalars (by { simpa only [Complex.real_smul, mul_one] using Complex.ofReal_injective }) (canonicalEmbedding.latticeBasis K).linearIndependent) (disjoint_span_commMap_ker K) -- and it's a basis since it has the right cardinality refine basisOfLinearIndependentOfCardEqFinrank this ?_ rw [← finrank_eq_card_chooseBasisIndex, RingOfIntegers.rank, finrank_prod, finrank_pi, finrank_pi_fintype, Complex.finrank_real_complex, sum_const, card_univ, ← nrRealPlaces, ← nrComplexPlaces, ← card_real_embeddings, Algebra.id.smul_eq_mul, mul_comm, ← card_complex_embeddings, ← NumberField.Embeddings.card K ℂ, Fintype.card_subtype_compl, Nat.add_sub_of_le (Fintype.card_subtype_le _)] @[simp] theorem latticeBasis_apply (i : ChooseBasisIndex ℤ (𝓞 K)) : latticeBasis K i = (mixedEmbedding K) (integralBasis K i) := by simp only [latticeBasis, coe_basisOfLinearIndependentOfCardEqFinrank, Function.comp_apply, canonicalEmbedding.latticeBasis_apply, integralBasis_apply, commMap_canonical_eq_mixed] theorem mem_span_latticeBasis {x : (mixedSpace K)} : x ∈ Submodule.span ℤ (Set.range (latticeBasis K)) ↔ x ∈ mixedEmbedding.integerLattice K := by rw [show Set.range (latticeBasis K) = (mixedEmbedding K).toIntAlgHom.toLinearMap '' (Set.range (integralBasis K)) by rw [← Set.range_comp]; exact congrArg Set.range (funext (fun i => latticeBasis_apply K i))] rw [← Submodule.map_span, ← SetLike.mem_coe, Submodule.map_coe] simp only [Set.mem_image, SetLike.mem_coe, mem_span_integralBasis K, RingHom.mem_range, exists_exists_eq_and] rfl theorem span_latticeBasis : Submodule.span ℤ (Set.range (latticeBasis K)) = mixedEmbedding.integerLattice K := Submodule.ext_iff.mpr fun _ ↦ mem_span_latticeBasis K instance : DiscreteTopology (mixedEmbedding.integerLattice K) := by classical rw [← span_latticeBasis] infer_instance open Classical in instance : IsZLattice ℝ (mixedEmbedding.integerLattice K) := by simp_rw [← span_latticeBasis] infer_instance open Classical in theorem fundamentalDomain_integerLattice : MeasureTheory.IsAddFundamentalDomain (mixedEmbedding.integerLattice K) (ZSpan.fundamentalDomain (latticeBasis K)) := by rw [← span_latticeBasis] exact ZSpan.isAddFundamentalDomain (latticeBasis K) _ theorem mem_rat_span_latticeBasis (x : K) : mixedEmbedding K x ∈ Submodule.span ℚ (Set.range (latticeBasis K)) := by rw [← Basis.sum_repr (integralBasis K) x, map_sum] simp_rw [map_rat_smul] refine Submodule.sum_smul_mem _ _ (fun i _ ↦ Submodule.subset_span ?_) rw [← latticeBasis_apply] exact Set.mem_range_self i theorem latticeBasis_repr_apply (x : K) (i : ChooseBasisIndex ℤ (𝓞 K)) : (latticeBasis K).repr (mixedEmbedding K x) i = (integralBasis K).repr x i := by rw [← Basis.restrictScalars_repr_apply ℚ _ ⟨_, mem_rat_span_latticeBasis K x⟩, eq_ratCast, Rat.cast_inj] let f := (mixedEmbedding K).toRatAlgHom.toLinearMap.codRestrict _ (fun x ↦ mem_rat_span_latticeBasis K x) suffices ((latticeBasis K).restrictScalars ℚ).repr.toLinearMap ∘ₗ f = (integralBasis K).repr.toLinearMap from DFunLike.congr_fun (LinearMap.congr_fun this x) i refine Basis.ext (integralBasis K) (fun i ↦ ?_) have : f (integralBasis K i) = ((latticeBasis K).restrictScalars ℚ) i := by apply Subtype.val_injective rw [LinearMap.codRestrict_apply, AlgHom.toLinearMap_apply, Basis.restrictScalars_apply, latticeBasis_apply] rfl simp_rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, this, Basis.repr_self] variable (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) /-- The image of the fractional ideal `I` in the mixed space. -/ abbrev idealLattice : Submodule ℤ (mixedSpace K) := LinearMap.range <| (mixedEmbedding K).toIntAlgHom.toLinearMap ∘ₗ ((I : Submodule (𝓞 K) K).subtype.restrictScalars ℤ) theorem mem_idealLattice {x : mixedSpace K} : x ∈ idealLattice K I ↔ ∃ y, y ∈ (I : Set K) ∧ mixedEmbedding K y = x := by simp [idealLattice] /-- The generalized index of the lattice generated by `I` in the lattice generated by `𝓞 K` is equal to the norm of the ideal `I`. The result is stated in terms of base change determinant and is the translation of `NumberField.det_basisOfFractionalIdeal_eq_absNorm` in the mixed space. This is useful, in particular, to prove that the family obtained from the `ℤ`-basis of `I` is actually an `ℝ`-basis of the mixed space, see `fractionalIdealLatticeBasis`. -/ theorem det_basisOfFractionalIdeal_eq_norm (e : (ChooseBasisIndex ℤ (𝓞 K)) ≃ (ChooseBasisIndex ℤ I)) : |Basis.det (latticeBasis K) ((mixedEmbedding K ∘ (basisOfFractionalIdeal K I) ∘ e))| = FractionalIdeal.absNorm I.1 := by suffices Basis.det (latticeBasis K) ((mixedEmbedding K ∘ (basisOfFractionalIdeal K I) ∘ e)) = (algebraMap ℚ ℝ) ((Basis.det (integralBasis K)) ((basisOfFractionalIdeal K I) ∘ e)) by rw [this, eq_ratCast, ← Rat.cast_abs, ← Equiv.symm_symm e, ← Basis.coe_reindex, det_basisOfFractionalIdeal_eq_absNorm K I e] rw [Basis.det_apply, Basis.det_apply, RingHom.map_det] congr ext i j simp_rw [RingHom.mapMatrix_apply, Matrix.map_apply, Basis.toMatrix_apply, Function.comp_apply] exact latticeBasis_repr_apply K _ i /-- A `ℝ`-basis of the mixed space of `K` that is also a `ℤ`-basis of the image of the fractional ideal `I`. -/ def fractionalIdealLatticeBasis : Basis (ChooseBasisIndex ℤ I) ℝ (mixedSpace K) := by let e : (ChooseBasisIndex ℤ (𝓞 K)) ≃ (ChooseBasisIndex ℤ I) := by refine Fintype.equivOfCardEq ?_ rw [← finrank_eq_card_chooseBasisIndex, ← finrank_eq_card_chooseBasisIndex, fractionalIdeal_rank] refine Basis.reindex ?_ e suffices IsUnit ((latticeBasis K).det ((mixedEmbedding K) ∘ (basisOfFractionalIdeal K I) ∘ e)) by rw [← Basis.is_basis_iff_det] at this exact Basis.mk this.1 (by rw [this.2]) rw [isUnit_iff_ne_zero, ne_eq, ← abs_eq_zero.not, det_basisOfFractionalIdeal_eq_norm, Rat.cast_eq_zero, FractionalIdeal.absNorm_eq_zero_iff] exact Units.ne_zero I @[simp] theorem fractionalIdealLatticeBasis_apply (i : ChooseBasisIndex ℤ I) : fractionalIdealLatticeBasis K I i = (mixedEmbedding K) (basisOfFractionalIdeal K I i) := by simp only [fractionalIdealLatticeBasis, Basis.coe_reindex, Basis.coe_mk, Function.comp_apply, Equiv.apply_symm_apply] theorem mem_span_fractionalIdealLatticeBasis {x : (mixedSpace K)} : x ∈ Submodule.span ℤ (Set.range (fractionalIdealLatticeBasis K I)) ↔ x ∈ mixedEmbedding K '' I := by rw [show Set.range (fractionalIdealLatticeBasis K I) = (mixedEmbedding K).toIntAlgHom.toLinearMap '' (Set.range (basisOfFractionalIdeal K I)) by rw [← Set.range_comp] exact congr_arg Set.range (funext (fun i ↦ fractionalIdealLatticeBasis_apply K I i))] rw [← Submodule.map_span, ← SetLike.mem_coe, Submodule.map_coe] rw [show Submodule.span ℤ (Set.range (basisOfFractionalIdeal K I)) = (I : Set K) by ext; simp [mem_span_basisOfFractionalIdeal]] rfl theorem span_idealLatticeBasis : (Submodule.span ℤ (Set.range (fractionalIdealLatticeBasis K I))) = (mixedEmbedding.idealLattice K I) := by ext x simp [mem_span_fractionalIdealLatticeBasis] instance : DiscreteTopology (mixedEmbedding.idealLattice K I) := by classical rw [← span_idealLatticeBasis] infer_instance open Classical in instance : IsZLattice ℝ (mixedEmbedding.idealLattice K I) := by simp_rw [← span_idealLatticeBasis] infer_instance open Classical in theorem fundamentalDomain_idealLattice : MeasureTheory.IsAddFundamentalDomain (mixedEmbedding.idealLattice K I) (ZSpan.fundamentalDomain (fractionalIdealLatticeBasis K I)) := by rw [← span_idealLatticeBasis] exact ZSpan.isAddFundamentalDomain (fractionalIdealLatticeBasis K I) _ end integerLattice noncomputable section namespace euclidean open MeasureTheory NumberField Submodule /-- The mixed space `ℝ^r₁ × ℂ^r₂`, with `(r₁, r₂)` the signature of `K`, as an Euclidean space. -/ protected abbrev mixedSpace := (WithLp 2 ((EuclideanSpace ℝ {w : InfinitePlace K // IsReal w}) × (EuclideanSpace ℂ {w : InfinitePlace K // IsComplex w}))) instance : Ring (euclidean.mixedSpace K) := have : Ring (EuclideanSpace ℝ {w : InfinitePlace K // IsReal w}) := (WithLp.equiv 2 _).ring have : Ring (EuclideanSpace ℂ {w : InfinitePlace K // IsComplex w}) := (WithLp.equiv 2 _).ring (WithLp.equiv 2 _).ring variable [NumberField K] open Classical in /-- The continuous linear equivalence between the Euclidean mixed space and the mixed space. -/ def toMixed : (euclidean.mixedSpace K) ≃L[ℝ] (mixedSpace K) := (WithLp.linearEquiv _ _ _).trans ((WithLp.linearEquiv _ _ _).prodCongr (WithLp.linearEquiv _ _ _)) |>.toContinuousLinearEquiv instance : Nontrivial (euclidean.mixedSpace K) := (toMixed K).toEquiv.nontrivial protected theorem finrank : finrank ℝ (euclidean.mixedSpace K) = finrank ℚ K := by rw [LinearEquiv.finrank_eq (toMixed K).toLinearEquiv, mixedEmbedding.finrank] open Classical in /-- An orthonormal basis of the Euclidean mixed space. -/ def stdOrthonormalBasis : OrthonormalBasis (index K) ℝ (euclidean.mixedSpace K) := OrthonormalBasis.prod (EuclideanSpace.basisFun _ ℝ) ((Pi.orthonormalBasis fun _ ↦ Complex.orthonormalBasisOneI).reindex (Equiv.sigmaEquivProd _ _)) open Classical in theorem stdOrthonormalBasis_map_eq : (euclidean.stdOrthonormalBasis K).toBasis.map (toMixed K).toLinearEquiv = mixedEmbedding.stdBasis K := by ext <;> rfl open Classical in theorem volumePreserving_toMixed : MeasurePreserving (toMixed K) where measurable := (toMixed K).continuous.measurable map_eq := by rw [← (OrthonormalBasis.addHaar_eq_volume (euclidean.stdOrthonormalBasis K)), Basis.map_addHaar, stdOrthonormalBasis_map_eq, Basis.addHaar_eq_iff, Basis.coe_parallelepiped, ← measure_congr (ZSpan.fundamentalDomain_ae_parallelepiped (stdBasis K) volume), volume_fundamentalDomain_stdBasis K] open Classical in theorem volumePreserving_toMixed_symm : MeasurePreserving (toMixed K).symm := by have : MeasurePreserving (toMixed K).toHomeomorph.toMeasurableEquiv := volumePreserving_toMixed K exact this.symm open Classical in /-- The image of ring of integers `𝓞 K` in the Euclidean mixed space. -/ protected def integerLattice : Submodule ℤ (euclidean.mixedSpace K) := ZLattice.comap ℝ (mixedEmbedding.integerLattice K) (toMixed K).toLinearMap instance : DiscreteTopology (euclidean.integerLattice K) := by classical rw [euclidean.integerLattice] infer_instance open Classical in instance : IsZLattice ℝ (euclidean.integerLattice K) := by simp_rw [euclidean.integerLattice] infer_instance end euclidean end noncomputable section plusPart open ContinuousLinearEquiv variable {K} (s : Set {w : InfinitePlace K // IsReal w}) open Classical in /-- Let `s` be a set of real places, define the continuous linear equiv of the mixed space that swaps sign at places in `s` and leaves the rest unchanged. -/ def negAt : mixedSpace K ≃L[ℝ] mixedSpace K := (piCongrRight fun w ↦ if w ∈ s then neg ℝ else ContinuousLinearEquiv.refl ℝ ℝ).prodCongr (ContinuousLinearEquiv.refl ℝ _) variable {s} @[simp] theorem negAt_apply_isReal_and_mem (x : mixedSpace K) {w : {w // IsReal w}} (hw : w ∈ s) : (negAt s x).1 w = -x.1 w := by simp_rw [negAt, prodCongr_apply, piCongrRight_apply, if_pos hw, ContinuousLinearEquiv.neg_apply] @[simp] theorem negAt_apply_isReal_and_notMem (x : mixedSpace K) {w : {w // IsReal w}} (hw : w ∉ s) : (negAt s x).1 w = x.1 w := by simp_rw [negAt, prodCongr_apply, piCongrRight_apply, if_neg hw, ContinuousLinearEquiv.refl_apply] @[deprecated (since := "2025-05-23")] alias negAt_apply_isReal_and_not_mem := negAt_apply_isReal_and_notMem @[simp] theorem negAt_apply_isComplex (x : mixedSpace K) (w : {w // IsComplex w}) : (negAt s x).2 w = x.2 w := rfl @[simp] theorem negAt_apply_snd (x : mixedSpace K) : (negAt s x).2 = x.2 := rfl theorem negAt_apply_norm_isReal (x : mixedSpace K) (w : {w // IsReal w}) : ‖(negAt s x).1 w‖ = ‖x.1 w‖ := by by_cases hw : w ∈ s <;> simp [hw] open MeasureTheory Classical in /-- `negAt` preserves the volume . -/ theorem volume_preserving_negAt [NumberField K] : MeasurePreserving (negAt s) := by refine MeasurePreserving.prod (volume_preserving_pi fun w ↦ ?_) (MeasurePreserving.id _) by_cases hw : w ∈ s · simp_rw [if_pos hw] exact Measure.measurePreserving_neg _ · simp_rw [if_neg hw] exact MeasurePreserving.id _ variable (s) in /-- `negAt` preserves `normAtPlace`. -/ @[simp] theorem normAtPlace_negAt (x : mixedSpace K) (w : InfinitePlace K) : normAtPlace w (negAt s x) = normAtPlace w x := by obtain hw | hw := isReal_or_isComplex w · simp_rw [normAtPlace_apply_of_isReal hw, negAt_apply_norm_isReal] · simp_rw [normAtPlace_apply_of_isComplex hw, negAt_apply_isComplex] /-- `negAt` preserves the `norm`. -/ @[simp] theorem norm_negAt [NumberField K] (x : mixedSpace K) : mixedEmbedding.norm (negAt s x) = mixedEmbedding.norm x := norm_eq_of_normAtPlace_eq (fun w ↦ normAtPlace_negAt _ _ w) /-- `negAt` is its own inverse. -/ @[simp] theorem negAt_symm : (negAt s).symm = negAt s := by ext x w · by_cases hw : w ∈ s · simp_rw [negAt_apply_isReal_and_mem _ hw, negAt, prodCongr_symm, prodCongr_apply, piCongrRight_symm_apply, if_pos hw, symm_neg, neg_apply] · simp_rw [negAt_apply_isReal_and_notMem _ hw, negAt, prodCongr_symm, prodCongr_apply, piCongrRight_symm_apply, if_neg hw, refl_symm, refl_apply] · rfl /-- For `x : mixedSpace K`, the set `signSet x` is the set of real places `w` s.t. `x w ≤ 0`. -/ def signSet (x : mixedSpace K) : Set {w : InfinitePlace K // IsReal w} := {w | x.1 w ≤ 0} @[simp] theorem negAt_signSet_apply_isReal (x : mixedSpace K) (w : {w // IsReal w}) : (negAt (signSet x) x).1 w = ‖x.1 w‖ := by by_cases hw : x.1 w ≤ 0 · rw [negAt_apply_isReal_and_mem _ hw, Real.norm_of_nonpos hw] · rw [negAt_apply_isReal_and_notMem _ hw, Real.norm_of_nonneg (lt_of_not_ge hw).le] @[simp] theorem negAt_signSet_apply_isComplex (x : mixedSpace K) (w : {w // IsComplex w}) : (negAt (signSet x) x).2 w = x.2 w := rfl variable (A : Set (mixedSpace K)) {x : mixedSpace K} variable (s) in /-- `negAt s A` is also equal to the preimage of `A` by `negAt s`. This fact is used to simplify some proofs. -/ theorem negAt_preimage : negAt s ⁻¹' A = negAt s '' A := by rw [ContinuousLinearEquiv.image_eq_preimage_symm, negAt_symm] /-- The `plusPart` of a subset `A` of the `mixedSpace` is the set of points in `A` that are positive at all real places. -/ abbrev plusPart : Set (mixedSpace K) := A ∩ {x | ∀ w, 0 < x.1 w} theorem neg_of_mem_negA_plusPart (hx : x ∈ negAt s '' (plusPart A)) {w : {w // IsReal w}} (hw : w ∈ s) : x.1 w < 0 := by obtain ⟨y, hy, rfl⟩ := hx rw [negAt_apply_isReal_and_mem _ hw, neg_lt_zero] exact hy.2 w theorem pos_of_notMem_negAt_plusPart (hx : x ∈ negAt s '' (plusPart A)) {w : {w // IsReal w}} (hw : w ∉ s) : 0 < x.1 w := by obtain ⟨y, hy, rfl⟩ := hx rw [negAt_apply_isReal_and_notMem _ hw] exact hy.2 w @[deprecated (since := "2025-05-23")] alias pos_of_not_mem_negAt_plusPart := pos_of_notMem_negAt_plusPart open scoped Function in -- required for scoped `on` notation /-- The images of `plusPart` by `negAt` are pairwise disjoint. -/ theorem disjoint_negAt_plusPart : Pairwise (Disjoint on (fun s ↦ negAt s '' (plusPart A))) := by intro s t hst refine Set.disjoint_left.mpr fun _ hx hx' ↦ ?_ obtain ⟨w, hw | hw⟩ : ∃ w, (w ∈ s ∧ w ∉ t) ∨ (w ∈ t ∧ w ∉ s) := Set.symmDiff_nonempty.mpr hst · exact lt_irrefl _ <| (neg_of_mem_negA_plusPart A hx hw.1).trans (pos_of_notMem_negAt_plusPart A hx' hw.2) · exact lt_irrefl _ <| (neg_of_mem_negA_plusPart A hx' hw.1).trans (pos_of_notMem_negAt_plusPart A hx hw.2) -- We will assume from now that `A` is symmetric at real places variable (hA : ∀ x, x ∈ A ↔ (fun w ↦ ‖x.1 w‖, x.2) ∈ A) include hA in theorem mem_negAt_plusPart_of_mem (hx₁ : x ∈ A) (hx₂ : ∀ w, x.1 w ≠ 0) : x ∈ negAt s '' (plusPart A) ↔ (∀ w, w ∈ s → x.1 w < 0) ∧ (∀ w, w ∉ s → x.1 w > 0) := by refine ⟨fun hx ↦ ⟨fun _ hw ↦ neg_of_mem_negA_plusPart A hx hw, fun _ hw ↦ pos_of_notMem_negAt_plusPart A hx hw⟩, fun ⟨h₁, h₂⟩ ↦ ⟨(fun w ↦ ‖x.1 w‖, x.2), ⟨(hA x).mp hx₁, fun w ↦ norm_pos_iff.mpr (hx₂ w)⟩, ?_⟩⟩ ext w · by_cases hw : w ∈ s · simp [negAt_apply_isReal_and_mem _ hw, abs_of_neg (h₁ w hw)] · simp [negAt_apply_isReal_and_notMem _ hw, abs_of_pos (h₂ w hw)] · rfl include hA in /-- Assume that `A` is symmetric at real places then, the union of the images of `plusPart` by `negAt` and of the set of elements of `A` that are zero at at least one real place is equal to `A`. -/ theorem iUnion_negAt_plusPart_union : (⋃ s, negAt s '' (plusPart A)) ∪ (A ∩ (⋃ w, {x | x.1 w = 0})) = A := by ext x rw [Set.mem_union, Set.mem_inter_iff, Set.mem_iUnion, Set.mem_iUnion] refine ⟨?_, fun h ↦ ?_⟩ · rintro (⟨s, ⟨x, ⟨hx, _⟩, rfl⟩⟩ | h) · simp_rw +singlePass [hA, negAt_apply_norm_isReal, negAt_apply_snd] rwa [← hA] · exact h.left · obtain hx | hx := exists_or_forall_not (fun w ↦ x.1 w = 0) · exact Or.inr ⟨h, hx⟩ · refine Or.inl ⟨signSet x, (mem_negAt_plusPart_of_mem A hA h hx).mpr ⟨fun w hw ↦ ?_, fun w hw ↦ ?_⟩⟩ · exact lt_of_le_of_ne hw (hx w) · exact lt_of_le_of_ne (lt_of_not_ge hw).le (Ne.symm (hx w)) open MeasureTheory variable [NumberField K] include hA in open Classical in theorem iUnion_negAt_plusPart_ae : ⋃ s, negAt s '' (plusPart A) =ᵐ[volume] A := by nth_rewrite 2 [← iUnion_negAt_plusPart_union A hA] refine (MeasureTheory.union_ae_eq_left_of_ae_eq_empty (ae_eq_empty.mpr ?_)).symm exact measure_mono_null Set.inter_subset_right (measure_iUnion_null_iff.mpr fun _ ↦ volume_eq_zero _) variable {A} in theorem measurableSet_plusPart (hm : MeasurableSet A) : MeasurableSet (plusPart A) := by convert_to MeasurableSet (A ∩ (⋂ w, {x | 0 < x.1 w})) · ext; simp · refine hm.inter (MeasurableSet.iInter fun _ ↦ ?_) exact measurableSet_lt measurable_const ((measurable_pi_apply _).comp' measurable_fst) variable (s) in theorem measurableSet_negAt_plusPart (hm : MeasurableSet A) : MeasurableSet (negAt s '' (plusPart A)) := negAt_preimage s _ ▸ (measurableSet_plusPart hm).preimage (negAt s).continuous.measurable variable {A} open Classical in /-- The image of the `plusPart` of `A` by `negAt` have all the same volume as `plusPart A`. -/ theorem volume_negAt_plusPart (hm : MeasurableSet A) : volume (negAt s '' (plusPart A)) = volume (plusPart A) := by rw [← negAt_symm, ContinuousLinearEquiv.image_symm_eq_preimage, volume_preserving_negAt.measure_preimage (measurableSet_plusPart hm).nullMeasurableSet] include hA in open Classical in /-- If a subset `A` of the `mixedSpace` is symmetric at real places, then its volume is `2^ nrRealPlaces K` times the volume of its `plusPart`. -/ theorem volume_eq_two_pow_mul_volume_plusPart (hm : MeasurableSet A) : volume A = 2 ^ nrRealPlaces K * volume (plusPart A) := by simp only [← measure_congr (iUnion_negAt_plusPart_ae A hA), measure_iUnion (disjoint_negAt_plusPart A) (fun _ ↦ measurableSet_negAt_plusPart _ A hm), volume_negAt_plusPart hm, tsum_fintype, sum_const, card_univ, Fintype.card_set, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat, nrRealPlaces] end plusPart noncomputable section realSpace open MeasureTheory /-- The `realSpace` associated to a number field `K` is the real vector space indexed by the infinite places of `K`. -/ abbrev realSpace := InfinitePlace K → ℝ variable {K} /-- The set of points in the `realSpace` that are equal to `0` at a fixed place has volume zero. -/ theorem realSpace.volume_eq_zero [NumberField K] (w : InfinitePlace K) : volume ({x : realSpace K | x w = 0}) = 0 := by let A : AffineSubspace ℝ (realSpace K) := Submodule.toAffineSubspace (Submodule.mk ⟨⟨{x | x w = 0}, by simp_all⟩, rfl⟩ (by simp_all)) convert Measure.addHaar_affineSubspace volume A fun h ↦ ?_ simpa [A] using (h ▸ Set.mem_univ _ : 1 ∈ A) /-- The continuous linear map from `realSpace K` to `mixedSpace K` which is the identity at real places and the natural map `ℝ → ℂ` at complex places. -/ def mixedSpaceOfRealSpace : realSpace K →L[ℝ] mixedSpace K := .prod (.pi fun w ↦ .proj w.1) (.pi fun w ↦ Complex.ofRealCLM.comp (.proj w.1)) theorem mixedSpaceOfRealSpace_apply (x : realSpace K) : mixedSpaceOfRealSpace x = ⟨fun w ↦ x w.1, fun w ↦ x w.1⟩ := rfl variable (K) in theorem injective_mixedSpaceOfRealSpace : Function.Injective (mixedSpaceOfRealSpace : realSpace K → mixedSpace K) := by refine (injective_iff_map_eq_zero mixedSpaceOfRealSpace).mpr fun _ h ↦ ?_ rw [mixedSpaceOfRealSpace_apply, Prod.mk_eq_zero, funext_iff, funext_iff] at h ext w obtain hw | hw := isReal_or_isComplex w · exact h.1 ⟨w, hw⟩ · exact Complex.ofReal_inj.mp <| h.2 ⟨w, hw⟩ theorem normAtPlace_mixedSpaceOfRealSpace {x : realSpace K} {w : InfinitePlace K} (hx : 0 ≤ x w) : normAtPlace w (mixedSpaceOfRealSpace x) = x w := by simp only [mixedSpaceOfRealSpace_apply] obtain hw | hw := isReal_or_isComplex w · rw [normAtPlace_apply_of_isReal hw, Real.norm_of_nonneg hx] · rw [normAtPlace_apply_of_isComplex hw, Complex.norm_of_nonneg hx] open scoped Classical in /-- The map from the `mixedSpace K` to `realSpace K` that sends the values at complex places to their norm. -/ abbrev normAtComplexPlaces (x : mixedSpace K) : realSpace K := fun w ↦ if hw : w.IsReal then x.1 ⟨w, hw⟩ else normAtPlace w x @[simp] theorem normAtComplexPlaces_apply_isReal {x : mixedSpace K} (w : {w // IsReal w}) : normAtComplexPlaces x w = x.1 w := by rw [normAtComplexPlaces, dif_pos] @[simp] theorem normAtComplexPlaces_apply_isComplex {x : mixedSpace K} (w : {w // IsComplex w}) : normAtComplexPlaces x w = ‖x.2 w‖ := by rw [normAtComplexPlaces, dif_neg (not_isReal_iff_isComplex.mpr w.prop), normAtPlace_apply_of_isComplex] theorem normAtComplexPlaces_mixedSpaceOfRealSpace {x : realSpace K} (hx : ∀ w, IsComplex w → 0 ≤ x w) : normAtComplexPlaces (mixedSpaceOfRealSpace x) = x := by ext w obtain hw | hw := isReal_or_isComplex w · rw [normAtComplexPlaces_apply_isReal ⟨w, hw⟩, mixedSpaceOfRealSpace_apply] · rw [normAtComplexPlaces_apply_isComplex ⟨w, hw⟩, mixedSpaceOfRealSpace_apply, Complex.norm_of_nonneg (hx w hw)] /-- The map from the `mixedSpace K` to `realSpace K` that sends each component to its norm. -/ abbrev normAtAllPlaces (x : mixedSpace K) : realSpace K := fun w ↦ normAtPlace w x @[simp] theorem normAtAllPlaces_apply (x : mixedSpace K) (w : InfinitePlace K) : normAtAllPlaces x w = normAtPlace w x := rfl variable (K) in theorem continuous_normAtAllPlaces : Continuous (normAtAllPlaces : mixedSpace K → realSpace K) := by fun_prop theorem normAtAllPlaces_nonneg (x : mixedSpace K) (w : InfinitePlace K) : 0 ≤ normAtAllPlaces x w := normAtPlace_nonneg _ _ theorem normAtAllPlaces_mixedSpaceOfRealSpace {x : realSpace K} (hx : ∀ w, 0 ≤ x w) : normAtAllPlaces (mixedSpaceOfRealSpace x) = x := by ext rw [normAtAllPlaces_apply, normAtPlace_mixedSpaceOfRealSpace (hx _)] theorem normAtAllPlaces_mixedEmbedding (x : K) (w : InfinitePlace K) : normAtAllPlaces (mixedEmbedding K x) w = w x := by rw [normAtAllPlaces_apply, normAtPlace_apply] theorem normAtAllPlaces_normAtAllPlaces (x : mixedSpace K) : normAtAllPlaces (mixedSpaceOfRealSpace (normAtAllPlaces x)) = normAtAllPlaces x := normAtAllPlaces_mixedSpaceOfRealSpace fun _ ↦ (normAtAllPlaces_nonneg _ _) theorem normAtAllPlaces_norm_at_real_places (x : mixedSpace K) : normAtAllPlaces (fun w ↦ ‖x.1 w‖, x.2) = normAtAllPlaces x := by ext w obtain hw | hw := isReal_or_isComplex w · simp_rw [normAtAllPlaces, normAtPlace_apply_of_isReal hw, norm_norm] · simp_rw [normAtAllPlaces, normAtPlace_apply_of_isComplex hw] theorem normAtComplexPlaces_normAtAllPlaces (x : mixedSpace K) : normAtComplexPlaces (mixedSpaceOfRealSpace (normAtAllPlaces x)) = normAtAllPlaces x := normAtComplexPlaces_mixedSpaceOfRealSpace fun _ _ ↦ (normAtAllPlaces_nonneg _ _) theorem normAtAllPlaces_eq_of_normAtComplexPlaces_eq {x y : mixedSpace K} (h : normAtComplexPlaces x = normAtComplexPlaces y) : normAtAllPlaces x = normAtAllPlaces y := by ext w obtain hw | hw := isReal_or_isComplex w · simpa [normAtAllPlaces_apply, normAtPlace_apply_of_isReal hw, normAtComplexPlaces_apply_isReal ⟨w, hw⟩] using congr_arg (|·|) (congr_fun h w) · simpa [normAtAllPlaces_apply, normAtPlace_apply_of_isComplex hw, normAtComplexPlaces_apply_isComplex ⟨w, hw⟩] using congr_fun h w theorem normAtAllPlaces_image_preimage_of_nonneg {s : Set (realSpace K)} (hs : ∀ x ∈ s, ∀ w, 0 ≤ x w) : normAtAllPlaces '' (normAtAllPlaces ⁻¹' s) = s := by rw [Set.image_preimage_eq_iff] rintro x hx refine ⟨mixedSpaceOfRealSpace x, funext fun w ↦ ?_⟩ rw [normAtAllPlaces_apply, normAtPlace_mixedSpaceOfRealSpace (hs x hx w)] end realSpace end NumberField.mixedEmbedding
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/PolarCoord.lean
import Mathlib.Analysis.SpecialFunctions.PolarCoord import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic /-! # Polar coordinate change of variables for the mixed space of a number field We define two polar coordinate changes of variables for the mixed space `ℝ^r₁ × ℂ^r₂` associated to a number field `K` of signature `(r₁, r₂)`. The first one is `mixedEmbedding.polarCoord` and has value in `realMixedSpace K` defined as `ℝ^r₁ × (ℝ ⨯ ℝ)^r₂`, the second is `mixedEmbedding.polarSpaceCoord` and has value in `polarSpace K` defined as `ℝ^(r₁+r₂) × ℝ^r₂`. The change of variables with the `polarSpace` is useful to compute the volume of subsets of the mixed space with enough symmetries, see `volume_eq_two_pi_pow_mul_integral` and `volume_eq_two_pow_mul_two_pi_pow_mul_integral` ## Main definitions and results * `mixedEmbedding.polarCoord`: the polar coordinate change of variables between the mixed space `ℝ^r₁ × ℂ^r₂` and `ℝ^r₁ × (ℝ × ℝ)^r₂` defined as the identity on the first component and mapping `(zᵢ)ᵢ` to `(‖zᵢ‖, Arg zᵢ)ᵢ` on the second component. * `mixedEmbedding.integral_comp_polarCoord_symm`: the change of variables formula for `mixedEmbedding.polarCoord` * `mixedEmbedding.polarSpaceCoord`: the polar coordinate change of variables between the mixed space `ℝ^r₁ × ℂ^r₂` and the polar space `ℝ^(r₁ + r₂) × ℝ^r₂` defined by sending `x` to `x w` or `‖x w‖` depending on whether `w` is real or complex for the first component, and to `Arg (x w)`, `w` complex, for the second component. * `mixedEmbedding.integral_comp_polarSpaceCoord_symm`: the change of variables formula for `mixedEmbedding.polarSpaceCoord` * `mixedEmbedding.volume_eq_two_pi_pow_mul_integral`: if the measurable set `A` of the mixed space is norm-stable at complex places in the sense that `normAtComplexPlaces⁻¹ (normAtComplexPlaces '' A) = A`, then its volume can be computed via an integral over `normAtComplexPlaces '' A`. * `mixedEmbedding.volume_eq_two_pow_mul_two_pi_pow_mul_integral`: if the measurable set `A` of the mixed space is norm-stable in the sense that `normAtAllPlaces⁻¹ (normAtAllPlaces '' A) = A`, then its volume can be computed via an integral over `normAtAllPlaces '' A`. -/ variable (K : Type*) [Field K] namespace NumberField.mixedEmbedding open NumberField NumberField.InfinitePlace NumberField.mixedEmbedding ENNReal MeasureTheory MeasureTheory.Measure Real noncomputable section realMixedSpace /-- The real mixed space `ℝ^r₁ × (ℝ × ℝ)^r₂` with `(r₁, r₂)` the signature of `K`. -/ abbrev realMixedSpace := ({w : InfinitePlace K // IsReal w} → ℝ) × ({w : InfinitePlace K // IsComplex w} → ℝ × ℝ) /-- The natural homeomorphism between the mixed space `ℝ^r₁ × ℂ^r₂` and the real mixed space `ℝ^r₁ × (ℝ × ℝ)^r₂`. -/ noncomputable def mixedSpaceToRealMixedSpace : mixedSpace K ≃ₜ realMixedSpace K := (Homeomorph.refl _).prodCongr <| .piCongrRight fun _ ↦ Complex.equivRealProdCLM.toHomeomorph @[simp] theorem mixedSpaceToRealMixedSpace_apply (x : mixedSpace K) : mixedSpaceToRealMixedSpace K x = (x.1, fun w ↦ Complex.equivRealProd (x.2 w)) := rfl variable [NumberField K] open scoped Classical in theorem volume_preserving_mixedSpaceToRealMixedSpace_symm : MeasurePreserving (mixedSpaceToRealMixedSpace K).symm := (MeasurePreserving.id _).prod <| volume_preserving_pi fun _ ↦ Complex.volume_preserving_equiv_real_prod.symm open scoped Classical in instance : IsAddHaarMeasure (volume : Measure (realMixedSpace K)) := prod.instIsAddHaarMeasure _ _ /-- The polar coordinate open partial homeomorphism of `ℝ^r₁ × (ℝ × ℝ)^r₂` defined as the identity on the first component and mapping `(rᵢ cos θᵢ, rᵢ sin θᵢ)ᵢ` to `(rᵢ, θᵢ)ᵢ` on the second component. -/ @[simps! apply target] def polarCoordReal : OpenPartialHomeomorph (realMixedSpace K) (realMixedSpace K) := (OpenPartialHomeomorph.refl _).prod (OpenPartialHomeomorph.pi fun _ ↦ polarCoord) theorem measurable_polarCoordReal_symm : Measurable (polarCoordReal K).symm := by refine measurable_fst.prodMk <| Measurable.comp ?_ measurable_snd exact measurable_pi_lambda _ fun _ ↦ continuous_polarCoord_symm.measurable.comp (measurable_pi_apply _) theorem polarCoordReal_source : (polarCoordReal K).source = Set.univ ×ˢ (Set.univ.pi fun _ ↦ polarCoord.source) := rfl private theorem abs_of_mem_polarCoordReal_target {x : realMixedSpace K} (hx : x ∈ (polarCoordReal K).target) (w : {w // IsComplex w}) : |(x.2 w).1| = (x.2 w).1 := abs_of_pos (hx.2 w (Set.mem_univ _)).1 open ContinuousLinearMap in /-- The derivative of `polarCoordReal.symm`, see `hasFDerivAt_polarCoordReal_symm`. -/ def FDerivPolarCoordRealSymm : realMixedSpace K → realMixedSpace K →L[ℝ] realMixedSpace K := fun x ↦ (fst ℝ _ _).prod <| (fderivPiPolarCoordSymm x.2).comp (snd ℝ _ _) theorem hasFDerivAt_polarCoordReal_symm (x : realMixedSpace K) : HasFDerivAt (polarCoordReal K).symm (FDerivPolarCoordRealSymm K x) x := by classical exact (hasFDerivAt_id x.1).prodMap x (hasFDerivAt_pi_polarCoord_symm x.2) open scoped Classical in theorem det_fderivPolarCoordRealSymm (x : realMixedSpace K) : (FDerivPolarCoordRealSymm K x).det = ∏ w : {w // IsComplex w}, (x.2 w).1 := by have : (FDerivPolarCoordRealSymm K x).toLinearMap = LinearMap.prodMap (LinearMap.id) (fderivPiPolarCoordSymm x.2).toLinearMap := rfl rw [ContinuousLinearMap.det, this, LinearMap.det_prodMap, LinearMap.det_id, one_mul, ← ContinuousLinearMap.det, det_fderivPiPolarCoordSymm] open scoped Classical in theorem polarCoordReal_symm_target_ae_eq_univ : (polarCoordReal K).symm '' (polarCoordReal K).target =ᵐ[volume] Set.univ := by rw [← Set.univ_prod_univ, volume_eq_prod, (polarCoordReal K).symm_image_target_eq_source, polarCoordReal_source, ← polarCoord.symm_image_target_eq_source, ← Set.piMap_image_univ_pi] exact set_prod_ae_eq .rfl pi_polarCoord_symm_target_ae_eq_univ open scoped Classical in theorem integral_comp_polarCoordReal_symm {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (f : realMixedSpace K → E) : ∫ x in (polarCoordReal K).target, (∏ w : {w // IsComplex w}, (x.2 w).1) • f ((polarCoordReal K).symm x) = ∫ x, f x := by rw [← setIntegral_univ (f := f), ← setIntegral_congr_set (polarCoordReal_symm_target_ae_eq_univ K), integral_image_eq_integral_abs_det_fderiv_smul volume (polarCoordReal K).open_target.measurableSet (fun x _ ↦ (hasFDerivAt_polarCoordReal_symm K x).hasFDerivWithinAt) (polarCoordReal K).symm.injOn f] refine setIntegral_congr_fun (polarCoordReal K).open_target.measurableSet fun x hx ↦ ?_ simp_rw [det_fderivPolarCoordRealSymm, Finset.abs_prod, abs_of_mem_polarCoordReal_target K hx] open scoped Classical in theorem lintegral_comp_polarCoordReal_symm (f : realMixedSpace K → ℝ≥0∞) : ∫⁻ x in (polarCoordReal K).target, (∏ w : {w // IsComplex w}, .ofReal (x.2 w).1) * f ((polarCoordReal K).symm x) = ∫⁻ x, f x := by rw [← setLIntegral_univ f, ← setLIntegral_congr (polarCoordReal_symm_target_ae_eq_univ K), lintegral_image_eq_lintegral_abs_det_fderiv_mul volume (polarCoordReal K).open_target.measurableSet (fun x _ ↦ (hasFDerivAt_polarCoordReal_symm K x).hasFDerivWithinAt) (polarCoordReal K).symm.injOn f] refine setLIntegral_congr_fun (polarCoordReal K).open_target.measurableSet (fun x hx ↦ ?_) simp_rw [det_fderivPolarCoordRealSymm, Finset.abs_prod, ENNReal.ofReal_prod_of_nonneg (fun _ _ ↦ abs_nonneg _), abs_of_mem_polarCoordReal_target K hx] end realMixedSpace section mixedSpace variable [NumberField K] /-- The polar coordinate open partial homeomorphism between the mixed space `ℝ^r₁ × ℂ^r₂` and `ℝ^r₁ × (ℝ × ℝ)^r₂` defined as the identity on the first component and mapping `(zᵢ)ᵢ` to `(‖zᵢ‖, Arg zᵢ)ᵢ` on the second component. -/ @[simps!] protected noncomputable def polarCoord : OpenPartialHomeomorph (mixedSpace K) (realMixedSpace K) := (OpenPartialHomeomorph.refl _).prod (OpenPartialHomeomorph.pi fun _ ↦ Complex.polarCoord) theorem polarCoord_target_eq_polarCoordReal_target : (mixedEmbedding.polarCoord K).target = (polarCoordReal K).target := rfl theorem polarCoord_symm_eq : (mixedEmbedding.polarCoord K).symm = (mixedSpaceToRealMixedSpace K).symm ∘ (polarCoordReal K).symm := rfl theorem measurable_polarCoord_symm : Measurable (mixedEmbedding.polarCoord K).symm := by rw [polarCoord_symm_eq] exact (Homeomorph.measurable _).comp (measurable_polarCoordReal_symm K) theorem normAtPlace_polarCoord_symm_of_isReal (x : realMixedSpace K) {w : InfinitePlace K} (hw : IsReal w) : normAtPlace w ((mixedEmbedding.polarCoord K).symm x) = ‖x.1 ⟨w, hw⟩‖ := by simp [normAtPlace_apply_of_isReal hw] theorem normAtPlace_polarCoord_symm_of_isComplex (x : realMixedSpace K) {w : InfinitePlace K} (hw : IsComplex w) : normAtPlace w ((mixedEmbedding.polarCoord K).symm x) = ‖(x.2 ⟨w, hw⟩).1‖ := by simp [normAtPlace_apply_of_isComplex hw] open scoped Classical in protected theorem integral_comp_polarCoord_symm {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (f : mixedSpace K → E) : ∫ x in (mixedEmbedding.polarCoord K).target, (∏ w : {w // IsComplex w}, (x.2 w).1) • f ((mixedEmbedding.polarCoord K).symm x) = ∫ x, f x := by rw [← (volume_preserving_mixedSpaceToRealMixedSpace_symm K).integral_comp (mixedSpaceToRealMixedSpace K).symm.measurableEmbedding, ← integral_comp_polarCoordReal_symm, polarCoord_target_eq_polarCoordReal_target, polarCoord_symm_eq, Function.comp_def] open scoped Classical in protected theorem lintegral_comp_polarCoord_symm (f : mixedSpace K → ℝ≥0∞) : ∫⁻ x in (mixedEmbedding.polarCoord K).target, (∏ w : {w // IsComplex w}, .ofReal (x.2 w).1) * f ((mixedEmbedding.polarCoord K).symm x) = ∫⁻ x, f x := by rw [← (volume_preserving_mixedSpaceToRealMixedSpace_symm K).lintegral_comp_emb (mixedSpaceToRealMixedSpace K).symm.measurableEmbedding, ← lintegral_comp_polarCoordReal_symm, polarCoord_target_eq_polarCoordReal_target, polarCoord_symm_eq, Function.comp_def] end mixedSpace noncomputable section polarSpace open MeasurableEquiv /-- The space `ℝ^(r₁+r₂) × ℝ^r₂`, it is homeomorph to the `realMixedSpace`, see `homeoRealMixedSpacePolarSpace`. -/ abbrev polarSpace := ((InfinitePlace K) → ℝ) × ({w : InfinitePlace K // w.IsComplex} → ℝ) open scoped Classical in /-- The measurable equivalence between the `realMixedSpace` and the `polarSpace`. It is actually an homeomorphism, see `homeoRealMixedSpacePolarSpace`, but defining it in this way makes it easier to prove that it is volume preserving, see `volume_preserving_homeoRealMixedSpacePolarSpace`. -/ def measurableEquivRealMixedSpacePolarSpace : realMixedSpace K ≃ᵐ polarSpace K := MeasurableEquiv.trans (prodCongr (refl _) (arrowProdEquivProdArrow ℝ ℝ _)) <| MeasurableEquiv.trans prodAssoc.symm <| MeasurableEquiv.trans (prodCongr (prodCongr (refl _) (arrowCongr' (Equiv.subtypeEquivRight (fun _ ↦ not_isReal_iff_isComplex.symm)) (refl _))) (refl _)) (prodCongr (piEquivPiSubtypeProd (fun _ ↦ ℝ) _).symm (refl _)) open scoped Classical in /-- The homeomorphism between the `realMixedSpace` and the `polarSpace`. -/ def homeoRealMixedSpacePolarSpace : realMixedSpace K ≃ₜ polarSpace K := { measurableEquivRealMixedSpacePolarSpace K with continuous_toFun := by change Continuous fun x : realMixedSpace K ↦ (fun w ↦ if hw : w.IsReal then x.1 ⟨w, hw⟩ else (x.2 ⟨w, not_isReal_iff_isComplex.mp hw⟩).1, fun w ↦ (x.2 w).2) refine .prodMk (continuous_pi fun w ↦ ?_) (by fun_prop) split_ifs <;> fun_prop continuous_invFun := by change Continuous fun x : polarSpace K ↦ (⟨fun w ↦ x.1 w.val, fun w ↦ ⟨x.1 w.val, x.2 w⟩⟩ : realMixedSpace K) fun_prop } open scoped Classical in theorem homeoRealMixedSpacePolarSpace_apply (x : realMixedSpace K) : homeoRealMixedSpacePolarSpace K x = ⟨fun w ↦ if hw : w.IsReal then x.1 ⟨w, hw⟩ else (x.2 ⟨w, not_isReal_iff_isComplex.mp hw⟩).1, fun w ↦ (x.2 w).2⟩ := rfl theorem homeoRealMixedSpacePolarSpace_apply_fst_ofIsReal (x : realMixedSpace K) (w : {w // IsReal w}) : (homeoRealMixedSpacePolarSpace K x).1 w.1 = x.1 w := by simp_rw [homeoRealMixedSpacePolarSpace_apply, dif_pos w.prop] theorem homeoRealMixedSpacePolarSpace_apply_fst_ofIsComplex (x : realMixedSpace K) (w : {w // IsComplex w}) : (homeoRealMixedSpacePolarSpace K x).1 w.1 = (x.2 w).1 := by simp_rw [homeoRealMixedSpacePolarSpace_apply, dif_neg (not_isReal_iff_isComplex.mpr w.prop)] theorem homeoRealMixedSpacePolarSpace_apply_snd (x : realMixedSpace K) (w : {w // IsComplex w}) : (homeoRealMixedSpacePolarSpace K x).2 w = (x.2 w).2 := rfl @[simp] theorem homeoRealMixedSpacePolarSpace_symm_apply (x : polarSpace K) : (homeoRealMixedSpacePolarSpace K).symm x = ⟨fun w ↦ x.1 w, fun w ↦ (x.1 w, x.2 w)⟩ := rfl open scoped Classical in theorem volume_preserving_homeoRealMixedSpacePolarSpace [NumberField K] : MeasurePreserving (homeoRealMixedSpacePolarSpace K) := ((MeasurePreserving.id volume).prod (volume_measurePreserving_arrowProdEquivProdArrow ℝ ℝ _)).trans <| (volume_preserving_prodAssoc.symm).trans <| (((MeasurePreserving.id volume).prod (volume_preserving_arrowCongr' _ (MeasurableEquiv.refl ℝ) (.id volume))).prod (.id volume)).trans <| ((volume_preserving_piEquivPiSubtypeProd (fun _ : InfinitePlace K ↦ ℝ) (fun w ↦ IsReal w)).symm).prod (.id volume) /-- The polar coordinate open partial homeomorphism between the mixed space `ℝ^r₁ × ℂ^r₂` and the polar space `ℝ^(r₁ + r₂) × ℝ^r₂` defined by sending `x` to `x w` or `‖x w‖` depending on whether `w` is real or complex for the first component, and to `Arg (x w)`, `w` complex, for the second component. -/ @[simps!] def polarSpaceCoord [NumberField K] : OpenPartialHomeomorph (mixedSpace K) (polarSpace K) := (mixedEmbedding.polarCoord K).transHomeomorph (homeoRealMixedSpacePolarSpace K) theorem measurable_polarSpaceCoord_symm [NumberField K] : Measurable (polarSpaceCoord K).symm := by rw [polarSpaceCoord, OpenPartialHomeomorph.transHomeomorph_symm_apply] exact (measurable_polarCoord_symm K).comp (Homeomorph.measurable _) open scoped Classical in theorem polarSpaceCoord_target' [NumberField K] : (polarSpaceCoord K).target = (Set.univ.pi fun w ↦ if w.IsReal then Set.univ else Set.Ioi 0) ×ˢ (Set.univ.pi fun _ ↦ Set.Ioo (-π) π) := by ext simp_rw [polarSpaceCoord_target, Set.mem_preimage, homeoRealMixedSpacePolarSpace_symm_apply, Set.mem_prod, Set.mem_univ, true_and, Set.mem_univ_pi, Set.mem_ite_univ_left, not_isReal_iff_isComplex, Subtype.forall, Complex.polarCoord_target, Set.mem_prod, forall_and] open scoped Classical in theorem integral_comp_polarSpaceCoord_symm [NumberField K] {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (f : mixedSpace K → E) : ∫ x in (polarSpaceCoord K).target, (∏ w : {w // IsComplex w}, x.1 w.1) • f ((polarSpaceCoord K).symm x) = ∫ x, f x := by rw [← (volume_preserving_homeoRealMixedSpacePolarSpace K).setIntegral_preimage_emb (homeoRealMixedSpacePolarSpace K).measurableEmbedding, ← mixedEmbedding.integral_comp_polarCoord_symm, polarSpaceCoord_target, ← Homeomorph.image_eq_preimage_symm, Homeomorph.preimage_image, mixedEmbedding.polarCoord_target] simp_rw [polarSpaceCoord_symm_apply, mixedEmbedding.polarCoord_symm_apply, homeoRealMixedSpacePolarSpace_apply_fst_ofIsReal, homeoRealMixedSpacePolarSpace_apply_fst_ofIsComplex, homeoRealMixedSpacePolarSpace_apply_snd] open scoped Classical in theorem lintegral_comp_polarSpaceCoord_symm [NumberField K] (f : mixedSpace K → ℝ≥0∞) : ∫⁻ x in (polarSpaceCoord K).target, (∏ w : {w // IsComplex w}, .ofReal (x.1 w.1)) * f ((polarSpaceCoord K).symm x) = ∫⁻ x, f x := by rw [← (volume_preserving_homeoRealMixedSpacePolarSpace K).setLIntegral_comp_preimage_emb (homeoRealMixedSpacePolarSpace K).measurableEmbedding, ← mixedEmbedding.lintegral_comp_polarCoord_symm, polarSpaceCoord_target, ← Homeomorph.image_eq_preimage_symm, Homeomorph.preimage_image, mixedEmbedding.polarCoord_target] simp_rw [polarSpaceCoord_symm_apply, mixedEmbedding.polarCoord_symm_apply, homeoRealMixedSpacePolarSpace_apply_fst_ofIsReal, homeoRealMixedSpacePolarSpace_apply_fst_ofIsComplex, homeoRealMixedSpacePolarSpace_apply_snd] variable {K} variable {A : Set (mixedSpace K)} theorem normAtComplexPlaces_polarSpaceCoord_symm [NumberField K] (x : polarSpace K) : normAtComplexPlaces ((polarSpaceCoord K).symm x) = normAtComplexPlaces (mixedSpaceOfRealSpace x.1) := by ext w obtain hw | hw := isReal_or_isComplex w · simp [normAtComplexPlaces_apply_isReal ⟨w, hw⟩, mixedSpaceOfRealSpace_apply] · simp [normAtComplexPlaces_apply_isComplex ⟨w, hw⟩, mixedSpaceOfRealSpace_apply] open scoped ComplexOrder Classical in private theorem volume_eq_two_pi_pow_mul_integral_aux (hA : normAtComplexPlaces ⁻¹' (normAtComplexPlaces '' A) = A) : normAtComplexPlaces '' A = (mixedSpaceOfRealSpace ⁻¹' A) ∩ Set.univ.pi fun w ↦ if w.IsReal then Set.univ else Set.Ici 0 := by have h : ∀ (x : mixedSpace K), ∀ w, IsComplex w → 0 ≤ normAtComplexPlaces x w := by intro x w hw rw [normAtComplexPlaces_apply_isComplex ⟨w, hw⟩] exact norm_nonneg _ ext x refine ⟨?_, fun ⟨hx₁, hx₂⟩ ↦ ?_⟩ · rintro ⟨a, ha, rfl⟩ refine ⟨?_, by simpa using h a⟩ rw [Set.mem_preimage, ← hA, Set.mem_preimage, normAtComplexPlaces_mixedSpaceOfRealSpace (h a)] exact Set.mem_image_of_mem _ ha · rwa [Set.mem_preimage, ← hA, Set.mem_preimage, normAtComplexPlaces_mixedSpaceOfRealSpace] at hx₁ intro w hw simpa [if_neg (not_isReal_iff_isComplex.mpr hw)] using hx₂ w (Set.mem_univ w) open scoped Classical in /-- If the measurable set `A` is norm-stable at complex places in the sense that `normAtComplexPlaces⁻¹ (normAtComplexPlaces '' A) = A`, then its volume can be computed via an integral over `normAtComplexPlaces '' A`. -/ theorem volume_eq_two_pi_pow_mul_integral [NumberField K] (hA : normAtComplexPlaces ⁻¹' (normAtComplexPlaces '' A) = A) (hm : MeasurableSet A) : volume A = .ofReal (2 * π) ^ nrComplexPlaces K * ∫⁻ x in normAtComplexPlaces '' A, ∏ w : {w // IsComplex w}, ENNReal.ofReal (x w.1) := by have hA' {x} : (A.indicator 1 x : ℝ≥0∞) = (normAtComplexPlaces '' A).indicator 1 (normAtComplexPlaces x) := by simp_rw [← Set.indicator_comp_right, Function.comp_def, Pi.one_def, hA] rw [← lintegral_indicator_one hm, ← lintegral_comp_polarSpaceCoord_symm, polarSpaceCoord_target', Measure.volume_eq_prod, setLIntegral_prod] · simp_rw [hA', normAtComplexPlaces_polarSpaceCoord_symm, lintegral_const, restrict_apply MeasurableSet.univ, Set.univ_inter, volume_pi, Measure.pi_pi, volume_Ioo, sub_neg_eq_add, ← two_mul, Finset.prod_const, Finset.card_univ, ← Set.indicator_const_mul, ← Set.indicator_comp_right, Function.comp_def, Pi.one_apply, mul_one] rw [lintegral_mul_const' _ _ (ne_of_beq_false rfl).symm, mul_comm] erw [setLIntegral_indicator (by convert hm.preimage mixedSpaceOfRealSpace.measurable)] rw [hA, volume_eq_two_pi_pow_mul_integral_aux hA] congr 1 refine setLIntegral_congr (ae_eq_set_inter (by rfl) (Measure.ae_eq_set_pi fun w _ ↦ ?_)) split_ifs exacts [ae_eq_rfl, Ioi_ae_eq_Ici] · exact (Measurable.mul (by fun_prop) <| measurable_const.indicator <| hm.preimage (measurable_polarSpaceCoord_symm K)).aemeasurable private theorem volume_eq_two_pow_mul_two_pi_pow_mul_integral_aux (hA : normAtAllPlaces ⁻¹' (normAtAllPlaces '' A) = A) : normAtAllPlaces '' A ∩ (⋂ w : {w // IsReal w}, {x | x w.1 ≠ 0}) = normAtComplexPlaces '' plusPart A := by ext x refine ⟨?_, ?_⟩ · rintro ⟨⟨a, ha, rfl⟩, ha₂⟩ refine ⟨mixedSpaceOfRealSpace (normAtAllPlaces a), ⟨?_, ?_⟩, ?_⟩ · rw [← hA, Set.mem_preimage, normAtAllPlaces_normAtAllPlaces] exact Set.mem_image_of_mem normAtAllPlaces ha · intro w refine lt_of_le_of_ne' (normAtPlace_nonneg _ _) (Set.mem_iInter.mp ha₂ w) · rw [normAtComplexPlaces_normAtAllPlaces] · rintro ⟨a, ⟨ha₁, ha₂⟩, rfl⟩ refine ⟨⟨a, ha₁, funext fun w ↦ ?_⟩, Set.mem_iInter.mpr fun w ↦ ?_⟩ · obtain hw | hw := isReal_or_isComplex w · simpa [normAtComplexPlaces_apply_isReal ⟨w, hw⟩, normAtPlace_apply_of_isReal hw] using (ha₂ ⟨w, hw⟩).le · rw [normAtAllPlaces_apply, normAtPlace_apply_of_isComplex hw, normAtComplexPlaces_apply_isComplex ⟨w, hw⟩] · simpa [Set.mem_setOf_eq, normAtComplexPlaces_apply_isReal] using (ha₂ w).ne' open scoped Classical in /-- If the measurable set `A` is norm-stable in the sense that `normAtAllPlaces⁻¹ (normAtAllPlaces '' A) = A`, then its volume can be computed via an integral over `normAtAllPlaces '' A`. -/ theorem volume_eq_two_pow_mul_two_pi_pow_mul_integral [NumberField K] (hA : normAtAllPlaces ⁻¹' (normAtAllPlaces '' A) = A) (hm : MeasurableSet A) : volume A = 2 ^ nrRealPlaces K * .ofReal (2 * π) ^ nrComplexPlaces K * ∫⁻ x in normAtAllPlaces '' A, ∏ w : {w // IsComplex w}, ENNReal.ofReal (x w.1) := by have hA₁ (x : mixedSpace K) : x ∈ A ↔ (fun w ↦ ‖x.1 w‖, x.2) ∈ A := by rw [← hA] simp_rw [Set.mem_preimage, Set.mem_image, normAtAllPlaces_norm_at_real_places] have hA₃ : normAtComplexPlaces ⁻¹' (normAtComplexPlaces '' (plusPart A)) = plusPart A := by refine subset_antisymm (fun x ⟨a, ha₁, ha₂⟩ ↦ ⟨?_, fun w ↦ ?_⟩) (Set.subset_preimage_image _ _) · rw [← hA, Set.mem_preimage, ← normAtAllPlaces_eq_of_normAtComplexPlaces_eq ha₂] exact Set.mem_image_of_mem normAtAllPlaces (Set.inter_subset_left ha₁) · have := funext_iff.mp ha₂ w rw [normAtComplexPlaces_apply_isReal, normAtComplexPlaces_apply_isReal] at this rw [← this] exact ha₁.2 w rw [volume_eq_two_pow_mul_volume_plusPart hA₁ hm, volume_eq_two_pi_pow_mul_integral hA₃ (measurableSet_plusPart hm), ← mul_assoc] refine congr_arg (_ * _ * ·) <| setLIntegral_congr ?_ rw [← volume_eq_two_pow_mul_two_pi_pow_mul_integral_aux hA] refine inter_ae_eq_left_of_ae_eq_univ <| ae_eq_univ.mpr <| Set.compl_iInter _ ▸ measure_iUnion_null_iff.mpr fun w ↦ ?_ rw [show {x : realSpace K | x w.1 ≠ 0}ᶜ = {x | x w.1 = 0} by ext; simp] exact realSpace.volume_eq_zero w.1 end polarSpace end NumberField.mixedEmbedding
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean
import Mathlib.MeasureTheory.Group.GeometryOfNumbers import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup /-! # Convex Bodies The file contains the definitions of several convex bodies lying in the mixed space `ℝ^r₁ × ℂ^r₂` associated to a number field of signature `K` and proves several existence theorems by applying *Minkowski Convex Body Theorem* to those. ## Main definitions and results * `NumberField.mixedEmbedding.convexBodyLT`: The set of points `x` such that `‖x w‖ < f w` for all infinite places `w` with `f : InfinitePlace K → ℝ≥0`. * `NumberField.mixedEmbedding.convexBodySum`: The set of points `x` such that `∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B` * `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_lt`: Let `I` be a fractional ideal of `K`. Assume that `f` is such that `minkowskiBound K I < volume (convexBodyLT K f)`, then there exists a nonzero algebraic number `a` in `I` such that `w a < f w` for all infinite places `w`. * `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_of_norm_le`: Let `I` be a fractional ideal of `K`. Assume that `B` is such that `minkowskiBound K I < volume (convexBodySum K B)` (see `convexBodySum_volume` for the computation of this volume), then there exists a nonzero algebraic number `a` in `I` such that `|Norm a| < (B / d) ^ d` where `d` is the degree of `K`. ## Tags number field, infinite places -/ variable (K : Type*) [Field K] namespace NumberField.mixedEmbedding open NumberField NumberField.InfinitePlace Module section convexBodyLT open Metric NNReal variable (f : InfinitePlace K → ℝ≥0) /-- The convex body defined by `f`: the set of points `x : E` such that `‖x w‖ < f w` for all infinite places `w`. -/ abbrev convexBodyLT : Set (mixedSpace K) := (Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } => ball 0 (f w))) ×ˢ (Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } => ball 0 (f w))) theorem convexBodyLT_mem {x : K} : mixedEmbedding K x ∈ (convexBodyLT K f) ↔ ∀ w : InfinitePlace K, w x < f w := by simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ, forall_true_left, mem_ball_zero_iff, Pi.ringHom_apply, ← Complex.norm_real, embedding_of_isReal_apply, Subtype.forall, ← forall₂_or_left, ← not_isReal_iff_isComplex, em, forall_true_left, norm_embedding_eq] theorem convexBodyLT_neg_mem (x : mixedSpace K) (hx : x ∈ (convexBodyLT K f)) : -x ∈ (convexBodyLT K f) := by simp only [Set.mem_prod, Prod.fst_neg, Set.mem_pi, Set.mem_univ, Pi.neg_apply, mem_ball_zero_iff, norm_neg, Real.norm_eq_abs, forall_true_left, Subtype.forall, Prod.snd_neg] at hx ⊢ exact hx theorem convexBodyLT_convex : Convex ℝ (convexBodyLT K f) := Convex.prod (convex_pi (fun _ _ => convex_ball _ _)) (convex_pi (fun _ _ => convex_ball _ _)) open Fintype MeasureTheory MeasureTheory.Measure ENNReal variable [NumberField K] /-- The fudge factor that appears in the formula for the volume of `convexBodyLT`. -/ noncomputable abbrev convexBodyLTFactor : ℝ≥0 := (2 : ℝ≥0) ^ nrRealPlaces K * NNReal.pi ^ nrComplexPlaces K theorem convexBodyLTFactor_ne_zero : convexBodyLTFactor K ≠ 0 := mul_ne_zero (pow_ne_zero _ two_ne_zero) (pow_ne_zero _ pi_ne_zero) theorem one_le_convexBodyLTFactor : 1 ≤ convexBodyLTFactor K := one_le_mul (one_le_pow₀ one_le_two) (one_le_pow₀ (one_le_two.trans Real.two_le_pi)) open scoped Classical in /-- The volume of `(ConvexBodyLt K f)` where `convexBodyLT K f` is the set of points `x` such that `‖x w‖ < f w` for all infinite places `w`. -/ theorem convexBodyLT_volume : volume (convexBodyLT K f) = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by calc _ = (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (2 * (f x.val))) * ∏ x : {w // InfinitePlace.IsComplex w}, ENNReal.ofReal (f x.val) ^ 2 * NNReal.pi := by simp_rw [volume_eq_prod, prod_prod, volume_pi, pi_pi, Real.volume_ball, Complex.volume_ball] _ = ((2 : ℝ≥0) ^ nrRealPlaces K * (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val))) * ((∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2) * NNReal.pi ^ nrComplexPlaces K) := by simp_rw [ofReal_mul (by simp : 0 ≤ (2 : ℝ)), Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, ofReal_ofNat, ofReal_coe_nnreal, coe_ofNat] _ = (convexBodyLTFactor K) * ((∏ x : {w // InfinitePlace.IsReal w}, .ofReal (f x.val)) * (∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2)) := by simp_rw [convexBodyLTFactor, coe_mul, ENNReal.coe_pow] ring _ = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by simp_rw [prod_eq_prod_mul_prod, coe_mul, coe_finset_prod, mult_isReal, mult_isComplex, pow_one, ENNReal.coe_pow, ofReal_coe_nnreal] variable {f} /-- This is a technical result: quite often, we want to impose conditions at all infinite places but one and choose the value at the remaining place so that we can apply `exists_ne_zero_mem_ringOfIntegers_lt`. -/ theorem adjust_f {w₁ : InfinitePlace K} (B : ℝ≥0) (hf : ∀ w, w ≠ w₁ → f w ≠ 0) : ∃ g : InfinitePlace K → ℝ≥0, (∀ w, w ≠ w₁ → g w = f w) ∧ ∏ w, (g w) ^ mult w = B := by classical let S := ∏ w ∈ Finset.univ.erase w₁, (f w) ^ mult w refine ⟨Function.update f w₁ ((B * S⁻¹) ^ (mult w₁ : ℝ)⁻¹), ?_, ?_⟩ · exact fun w hw => Function.update_of_ne hw _ f · rw [← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ w₁), Function.update_self, Finset.prod_congr rfl fun w hw => by rw [Function.update_of_ne (Finset.ne_of_mem_erase hw)], ← NNReal.rpow_natCast, ← NNReal.rpow_mul, inv_mul_cancel₀, NNReal.rpow_one, mul_assoc, inv_mul_cancel₀, mul_one] · rw [Finset.prod_ne_zero_iff] exact fun w hw => pow_ne_zero _ (hf w (Finset.ne_of_mem_erase hw)) · rw [mult]; split_ifs <;> norm_num end convexBodyLT section convexBodyLT' open Metric ENNReal NNReal variable (f : InfinitePlace K → ℝ≥0) (w₀ : {w : InfinitePlace K // IsComplex w}) open scoped Classical in /-- A version of `convexBodyLT` with an additional condition at a fixed complex place. This is needed to ensure the element constructed is not real, see for example `exists_primitive_element_lt_of_isComplex`. -/ abbrev convexBodyLT' : Set (mixedSpace K) := (Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } ↦ ball 0 (f w))) ×ˢ (Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } ↦ if w = w₀ then {x | |x.re| < 1 ∧ |x.im| < (f w : ℝ) ^ 2} else ball 0 (f w))) theorem convexBodyLT'_mem {x : K} : mixedEmbedding K x ∈ convexBodyLT' K f w₀ ↔ (∀ w : InfinitePlace K, w ≠ w₀ → w x < f w) ∧ |(w₀.val.embedding x).re| < 1 ∧ |(w₀.val.embedding x).im| < (f w₀ : ℝ) ^ 2 := by simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ, forall_true_left, Pi.ringHom_apply, mem_ball_zero_iff, ← Complex.norm_real, embedding_of_isReal_apply, norm_embedding_eq, Subtype.forall] refine ⟨fun ⟨h₁, h₂⟩ ↦ ⟨fun w h_ne ↦ ?_, ?_⟩, fun ⟨h₁, h₂⟩ ↦ ⟨fun w hw ↦ ?_, fun w hw ↦ ?_⟩⟩ · by_cases hw : IsReal w · exact norm_embedding_eq w _ ▸ h₁ w hw · specialize h₂ w (not_isReal_iff_isComplex.mp hw) rw [apply_ite (w.embedding x ∈ ·), Set.mem_setOf_eq, mem_ball_zero_iff, norm_embedding_eq] at h₂ rwa [if_neg (by exact Subtype.coe_ne_coe.1 h_ne)] at h₂ · simpa [if_true] using h₂ w₀.val w₀.prop · exact h₁ w (ne_of_isReal_isComplex hw w₀.prop) · by_cases h_ne : w = w₀ · simpa [h_ne] · rw [if_neg (by exact Subtype.coe_ne_coe.1 h_ne)] rw [mem_ball_zero_iff, norm_embedding_eq] exact h₁ w h_ne theorem convexBodyLT'_neg_mem (x : mixedSpace K) (hx : x ∈ convexBodyLT' K f w₀) : -x ∈ convexBodyLT' K f w₀ := by simp only [Set.mem_prod, Set.mem_pi, Set.mem_univ, mem_ball, dist_zero_right, Real.norm_eq_abs, true_implies, Subtype.forall, Prod.fst_neg, Pi.neg_apply, norm_neg, Prod.snd_neg] at hx ⊢ convert hx using 3 split_ifs <;> simp theorem convexBodyLT'_convex : Convex ℝ (convexBodyLT' K f w₀) := by refine Convex.prod (convex_pi (fun _ _ => convex_ball _ _)) (convex_pi (fun _ _ => ?_)) split_ifs · simp_rw [abs_lt] refine Convex.inter ((convex_halfSpace_re_gt _).inter (convex_halfSpace_re_lt _)) ((convex_halfSpace_im_gt _).inter (convex_halfSpace_im_lt _)) · exact convex_ball _ _ open MeasureTheory MeasureTheory.Measure variable [NumberField K] /-- The fudge factor that appears in the formula for the volume of `convexBodyLT'`. -/ noncomputable abbrev convexBodyLT'Factor : ℝ≥0 := (2 : ℝ≥0) ^ (nrRealPlaces K + 2) * NNReal.pi ^ (nrComplexPlaces K - 1) theorem convexBodyLT'Factor_ne_zero : convexBodyLT'Factor K ≠ 0 := mul_ne_zero (pow_ne_zero _ two_ne_zero) (pow_ne_zero _ pi_ne_zero) theorem one_le_convexBodyLT'Factor : 1 ≤ convexBodyLT'Factor K := one_le_mul (one_le_pow₀ one_le_two) (one_le_pow₀ (one_le_two.trans Real.two_le_pi)) open scoped Classical in theorem convexBodyLT'_volume : volume (convexBodyLT' K f w₀) = convexBodyLT'Factor K * ∏ w, (f w) ^ (mult w) := by have vol_box : ∀ B : ℝ≥0, volume {x : ℂ | |x.re| < 1 ∧ |x.im| < B ^ 2} = 4 * B ^ 2 := by intro B rw [← (Complex.volume_preserving_equiv_real_prod.symm).measure_preimage] · simp_rw [Set.preimage_setOf_eq, Complex.measurableEquivRealProd_symm_apply] rw [show {a : ℝ × ℝ | |a.1| < 1 ∧ |a.2| < B ^ 2} = Set.Ioo (-1 : ℝ) (1 : ℝ) ×ˢ Set.Ioo (-(B : ℝ) ^ 2) ((B : ℝ) ^ 2) by ext; simp_rw [Set.mem_setOf_eq, Set.mem_prod, Set.mem_Ioo, abs_lt]] simp_rw [volume_eq_prod, prod_prod, Real.volume_Ioo, sub_neg_eq_add, one_add_one_eq_two, ← two_mul, ofReal_mul zero_le_two, ofReal_pow (coe_nonneg B), ofReal_ofNat, ofReal_coe_nnreal, ← mul_assoc, show (2 : ℝ≥0∞) * 2 = 4 by norm_num] · refine (MeasurableSet.inter ?_ ?_).nullMeasurableSet · exact measurableSet_lt (measurable_norm.comp Complex.measurable_re) measurable_const · exact measurableSet_lt (measurable_norm.comp Complex.measurable_im) measurable_const calc _ = (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (2 * (f x.val))) * ((∏ x ∈ Finset.univ.erase w₀, ENNReal.ofReal (f x.val) ^ 2 * pi) * (4 * (f w₀) ^ 2)) := by simp_rw [volume_eq_prod, prod_prod, volume_pi, pi_pi, Real.volume_ball] rw [← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀)] congr 2 · refine Finset.prod_congr rfl (fun w' hw' ↦ ?_) rw [if_neg (Finset.ne_of_mem_erase hw'), Complex.volume_ball] · simpa only [ite_true] using vol_box (f w₀) _ = ((2 : ℝ≥0) ^ nrRealPlaces K * (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val))) * ((∏ x ∈ Finset.univ.erase w₀, ENNReal.ofReal (f x.val) ^ 2) * ↑pi ^ (nrComplexPlaces K - 1) * (4 * (f w₀) ^ 2)) := by simp_rw [ofReal_mul (by simp : 0 ≤ (2 : ℝ)), Finset.prod_mul_distrib, Finset.prod_const, Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, ofReal_ofNat, ofReal_coe_nnreal, coe_ofNat] _ = convexBodyLT'Factor K * (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val)) * (∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2) := by rw [show (4 : ℝ≥0∞) = (2 : ℝ≥0) ^ 2 by norm_num, convexBodyLT'Factor, pow_add, ← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀), ofReal_coe_nnreal] simp_rw [coe_mul, ENNReal.coe_pow] ring _ = convexBodyLT'Factor K * ∏ w, (f w) ^ (mult w) := by simp_rw [prod_eq_prod_mul_prod, coe_mul, coe_finset_prod, mult_isReal, mult_isComplex, pow_one, ENNReal.coe_pow, ofReal_coe_nnreal, mul_assoc] end convexBodyLT' section convexBodySum open ENNReal MeasureTheory Fintype open scoped Real NNReal variable [NumberField K] (B : ℝ) variable {K} /-- The function that sends `x : mixedSpace K` to `∑ w, ‖x.1 w‖ + 2 * ∑ w, ‖x.2 w‖`. It defines a norm and it used to define `convexBodySum`. -/ noncomputable abbrev convexBodySumFun (x : mixedSpace K) : ℝ := ∑ w, mult w * normAtPlace w x theorem convexBodySumFun_apply (x : mixedSpace K) : convexBodySumFun x = ∑ w, mult w * normAtPlace w x := rfl open scoped Classical in theorem convexBodySumFun_apply' (x : mixedSpace K) : convexBodySumFun x = ∑ w, ‖x.1 w‖ + 2 * ∑ w, ‖x.2 w‖ := by simp_rw [convexBodySumFun_apply, sum_eq_sum_add_sum, mult_isReal, mult_isComplex, Nat.cast_one, one_mul, Nat.cast_ofNat, normAtPlace_apply_of_isReal (Subtype.prop _), normAtPlace_apply_of_isComplex (Subtype.prop _), Finset.mul_sum] theorem convexBodySumFun_nonneg (x : mixedSpace K) : 0 ≤ convexBodySumFun x := Finset.sum_nonneg (fun _ _ => mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _)) theorem convexBodySumFun_neg (x : mixedSpace K) : convexBodySumFun (-x) = convexBodySumFun x := by simp_rw [convexBodySumFun, normAtPlace_neg] theorem convexBodySumFun_add_le (x y : mixedSpace K) : convexBodySumFun (x + y) ≤ convexBodySumFun x + convexBodySumFun y := by simp_rw [convexBodySumFun, ← Finset.sum_add_distrib, ← mul_add] exact Finset.sum_le_sum fun _ _ ↦ mul_le_mul_of_nonneg_left (normAtPlace_add_le _ x y) (Nat.cast_pos.mpr mult_pos).le theorem convexBodySumFun_smul (c : ℝ) (x : mixedSpace K) : convexBodySumFun (c • x) = |c| * convexBodySumFun x := by simp_rw [convexBodySumFun, normAtPlace_smul, ← mul_assoc, mul_comm, Finset.mul_sum, mul_assoc] theorem convexBodySumFun_eq_zero_iff (x : mixedSpace K) : convexBodySumFun x = 0 ↔ x = 0 := by rw [← forall_normAtPlace_eq_zero_iff, convexBodySumFun, Finset.sum_eq_zero_iff_of_nonneg fun _ _ ↦ mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _)] conv => enter [1, w, hw] rw [mul_left_mem_nonZeroDivisors_eq_zero_iff (mem_nonZeroDivisors_iff_ne_zero.mpr mult_coe_ne_zero)] simp_rw [Finset.mem_univ, true_implies] open scoped Classical in theorem norm_le_convexBodySumFun (x : mixedSpace K) : ‖x‖ ≤ convexBodySumFun x := by rw [norm_eq_sup'_normAtPlace] refine (Finset.sup'_le_iff _ _).mpr fun w _ ↦ ?_ rw [convexBodySumFun_apply, ← Finset.univ.add_sum_erase _ (Finset.mem_univ w)] refine le_add_of_le_of_nonneg ?_ ?_ · exact le_mul_of_one_le_left (normAtPlace_nonneg w x) one_le_mult · exact Finset.sum_nonneg (fun _ _ => mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _)) variable (K) theorem convexBodySumFun_continuous : Continuous (convexBodySumFun : mixedSpace K → ℝ) := by fun_prop /-- The convex body equal to the set of points `x : mixedSpace K` such that `∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B`. -/ abbrev convexBodySum : Set (mixedSpace K) := { x | convexBodySumFun x ≤ B } open scoped Classical in theorem convexBodySum_volume_eq_zero_of_le_zero {B} (hB : B ≤ 0) : volume (convexBodySum K B) = 0 := by obtain hB | hB := lt_or_eq_of_le hB · suffices convexBodySum K B = ∅ by rw [this, measure_empty] ext x refine ⟨fun hx => ?_, fun h => h.elim⟩ rw [Set.mem_setOf] at hx linarith [convexBodySumFun_nonneg x] · suffices convexBodySum K B = { 0 } by rw [this, measure_singleton] ext rw [convexBodySum, Set.mem_setOf_eq, Set.mem_singleton_iff, hB, ← convexBodySumFun_eq_zero_iff] exact (convexBodySumFun_nonneg _).ge_iff_eq' theorem convexBodySum_mem {x : K} : mixedEmbedding K x ∈ (convexBodySum K B) ↔ ∑ w : InfinitePlace K, (mult w) * w.val x ≤ B := by simp_rw [Set.mem_setOf_eq, convexBodySumFun, normAtPlace_apply] rfl theorem convexBodySum_neg_mem {x : mixedSpace K} (hx : x ∈ (convexBodySum K B)) : -x ∈ (convexBodySum K B) := by rw [Set.mem_setOf, convexBodySumFun_neg] exact hx theorem convexBodySum_convex : Convex ℝ (convexBodySum K B) := by refine Convex_subadditive_le (fun _ _ => convexBodySumFun_add_le _ _) (fun c x h => ?_) B convert le_of_eq (convexBodySumFun_smul c x) exact (abs_eq_self.mpr h).symm theorem convexBodySum_isBounded : Bornology.IsBounded (convexBodySum K B) := by classical refine Metric.isBounded_iff.mpr ⟨B + B, fun x hx y hy => ?_⟩ refine le_trans (norm_sub_le x y) (add_le_add ?_ ?_) · exact le_trans (norm_le_convexBodySumFun x) hx · exact le_trans (norm_le_convexBodySumFun y) hy theorem convexBodySum_compact : IsCompact (convexBodySum K B) := by classical rw [Metric.isCompact_iff_isClosed_bounded] refine ⟨?_, convexBodySum_isBounded K B⟩ convert IsClosed.preimage (convexBodySumFun_continuous K) (isClosed_Icc : IsClosed (Set.Icc 0 B)) ext simp [convexBodySumFun_nonneg] /-- The fudge factor that appears in the formula for the volume of `convexBodyLt`. -/ noncomputable abbrev convexBodySumFactor : ℝ≥0 := (2 : ℝ≥0) ^ nrRealPlaces K * (NNReal.pi / 2) ^ nrComplexPlaces K / (finrank ℚ K).factorial theorem convexBodySumFactor_ne_zero : convexBodySumFactor K ≠ 0 := by refine div_ne_zero ?_ <| Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero _) exact mul_ne_zero (pow_ne_zero _ two_ne_zero) (pow_ne_zero _ (div_ne_zero NNReal.pi_ne_zero two_ne_zero)) open MeasureTheory MeasureTheory.Measure Real in open scoped Classical in theorem convexBodySum_volume : volume (convexBodySum K B) = (convexBodySumFactor K) * (.ofReal B) ^ (finrank ℚ K) := by obtain hB | hB := le_or_gt B 0 · rw [convexBodySum_volume_eq_zero_of_le_zero K hB, ofReal_eq_zero.mpr hB, zero_pow, mul_zero] exact finrank_pos.ne' · suffices volume (convexBodySum K 1) = (convexBodySumFactor K) by rw [mul_comm] convert addHaar_smul volume B (convexBodySum K 1) · simp_rw [← Set.preimage_smul_inv₀ (ne_of_gt hB), Set.preimage_setOf_eq, convexBodySumFun, normAtPlace_smul, abs_inv, abs_eq_self.mpr (le_of_lt hB), ← mul_assoc, mul_comm, mul_assoc, ← Finset.mul_sum, inv_mul_le_iff₀ hB, mul_one] · rw [abs_pow, ofReal_pow (abs_nonneg _), abs_eq_self.mpr (le_of_lt hB), mixedEmbedding.finrank] · exact this.symm rw [MeasureTheory.measure_le_eq_lt _ ((convexBodySumFun_eq_zero_iff 0).mpr rfl) convexBodySumFun_neg convexBodySumFun_add_le (fun hx => (convexBodySumFun_eq_zero_iff _).mp hx) (fun r x => le_of_eq (convexBodySumFun_smul r x))] rw [measure_lt_one_eq_integral_div_gamma (g := fun x : (mixedSpace K) => convexBodySumFun x) volume ((convexBodySumFun_eq_zero_iff 0).mpr rfl) convexBodySumFun_neg convexBodySumFun_add_le (fun hx => (convexBodySumFun_eq_zero_iff _).mp hx) (fun r x => le_of_eq (convexBodySumFun_smul r x)) zero_lt_one] simp_rw [mixedEmbedding.finrank, div_one, Gamma_nat_eq_factorial, ofReal_div_of_pos (Nat.cast_pos.mpr (Nat.factorial_pos _)), Real.rpow_one, ofReal_natCast] suffices ∫ x : mixedSpace K, exp (-convexBodySumFun x) = (2 : ℝ) ^ nrRealPlaces K * (π / 2) ^ nrComplexPlaces K by rw [this, convexBodySumFactor, ofReal_mul (by positivity), ofReal_pow zero_le_two, ofReal_pow (by positivity), ofReal_div_of_pos zero_lt_two, ofReal_ofNat, ← NNReal.coe_real_pi, ofReal_coe_nnreal, coe_div (Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero _)), coe_mul, coe_pow, coe_pow, coe_ofNat, coe_div two_ne_zero, coe_ofNat, coe_natCast] calc _ = (∫ x : {w : InfinitePlace K // IsReal w} → ℝ, ∏ w, exp (-‖x w‖)) * (∫ x : {w : InfinitePlace K // IsComplex w} → ℂ, ∏ w, exp (-2 * ‖x w‖)) := by simp_rw [convexBodySumFun_apply', neg_add, ← neg_mul, Finset.mul_sum, ← Finset.sum_neg_distrib, exp_add, exp_sum, ← integral_prod_mul, volume_eq_prod] _ = (∫ x : ℝ, exp (-|x|)) ^ nrRealPlaces K * (∫ x : ℂ, Real.exp (-2 * ‖x‖)) ^ nrComplexPlaces K := by rw [integral_fintype_prod_volume_eq_pow (fun x => exp (-‖x‖)), integral_fintype_prod_volume_eq_pow (fun x => exp (-2 * ‖x‖))] simp_rw [norm_eq_abs] _ = (2 * Gamma (1 / 1 + 1)) ^ nrRealPlaces K * (π * (2 : ℝ) ^ (-(2 : ℝ) / 1) * Gamma (2 / 1 + 1)) ^ nrComplexPlaces K := by rw [integral_comp_abs (f := fun x => exp (-x)), ← integral_exp_neg_rpow zero_lt_one, ← Complex.integral_exp_neg_mul_rpow le_rfl zero_lt_two] simp_rw [Real.rpow_one] _ = (2 : ℝ) ^ nrRealPlaces K * (π / 2) ^ nrComplexPlaces K := by simp_rw [div_one, one_add_one_eq_two, Gamma_add_one two_ne_zero, Gamma_two, mul_one, mul_assoc, ← Real.rpow_add_one two_ne_zero, show (-2 : ℝ) + 1 = -1 by norm_num, Real.rpow_neg_one, div_eq_mul_inv] end convexBodySum section minkowski open MeasureTheory MeasureTheory.Measure Module ZSpan Real Submodule open scoped ENNReal NNReal nonZeroDivisors IntermediateField variable [NumberField K] (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) open scoped Classical in /-- The bound that appears in **Minkowski Convex Body theorem**, see `MeasureTheory.exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure`. See `NumberField.mixedEmbedding.volume_fundamentalDomain_idealLatticeBasis_eq` and `NumberField.mixedEmbedding.volume_fundamentalDomain_latticeBasis` for the computation of `volume (fundamentalDomain (idealLatticeBasis K))`. -/ noncomputable def minkowskiBound : ℝ≥0∞ := volume (fundamentalDomain (fractionalIdealLatticeBasis K I)) * (2 : ℝ≥0∞) ^ (finrank ℝ (mixedSpace K)) open scoped Classical in theorem volume_fundamentalDomain_fractionalIdealLatticeBasis : volume (fundamentalDomain (fractionalIdealLatticeBasis K I)) = .ofReal (FractionalIdeal.absNorm I.1) * volume (fundamentalDomain (latticeBasis K)) := by let e : (Module.Free.ChooseBasisIndex ℤ I) ≃ (Module.Free.ChooseBasisIndex ℤ (𝓞 K)) := by refine Fintype.equivOfCardEq ?_ rw [← finrank_eq_card_chooseBasisIndex, ← finrank_eq_card_chooseBasisIndex, fractionalIdeal_rank] rw [← fundamentalDomain_reindex (fractionalIdealLatticeBasis K I) e, measure_fundamentalDomain ((fractionalIdealLatticeBasis K I).reindex e)] · rw [show (fractionalIdealLatticeBasis K I).reindex e = (mixedEmbedding K) ∘ (basisOfFractionalIdeal K I) ∘ e.symm by ext1; simp only [Basis.coe_reindex, Function.comp_apply, fractionalIdealLatticeBasis_apply]] rw [mixedEmbedding.det_basisOfFractionalIdeal_eq_norm] theorem minkowskiBound_lt_top : minkowskiBound K I < ⊤ := by classical -- FIXME: Make `finiteness` work here exact ENNReal.mul_lt_top (fundamentalDomain_isBounded _).measure_lt_top <| ENNReal.pow_lt_top ENNReal.ofNat_lt_top theorem minkowskiBound_pos : 0 < minkowskiBound K I := by classical refine zero_lt_iff.mpr (mul_ne_zero ?_ ?_) · exact ZSpan.measure_fundamentalDomain_ne_zero _ · exact ENNReal.pow_ne_zero two_ne_zero _ variable {f : InfinitePlace K → ℝ≥0} (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) open scoped Classical in /-- Let `I` be a fractional ideal of `K`. Assume that `f : InfinitePlace K → ℝ≥0` is such that `minkowskiBound K I < volume (convexBodyLT K f)` where `convexBodyLT K f` is the set of points `x` such that `‖x w‖ < f w` for all infinite places `w` (see `convexBodyLT_volume` for the computation of this volume), then there exists a nonzero algebraic number `a` in `I` such that `w a < f w` for all infinite places `w`. -/ theorem exists_ne_zero_mem_ideal_lt (h : minkowskiBound K I < volume (convexBodyLT K f)) : ∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧ ∀ w : InfinitePlace K, w a < f w := by have h_fund := ZSpan.isAddFundamentalDomain' (fractionalIdealLatticeBasis K I) volume have : Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))).toAddSubgroup := by change Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))) infer_instance obtain ⟨⟨x, hx⟩, h_nz, h_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure h_fund (convexBodyLT_neg_mem K f) (convexBodyLT_convex K f) h rw [mem_toAddSubgroup, mem_span_fractionalIdealLatticeBasis] at hx obtain ⟨a, ha, rfl⟩ := hx exact ⟨a, ha, by simpa using h_nz, (convexBodyLT_mem K f).mp h_mem⟩ open scoped Classical in /-- A version of `exists_ne_zero_mem_ideal_lt` where the absolute value of the real part of `a` is smaller than `1` at some fixed complex place. This is useful to ensure that `a` is not real. -/ theorem exists_ne_zero_mem_ideal_lt' (w₀ : {w : InfinitePlace K // IsComplex w}) (h : minkowskiBound K I < volume (convexBodyLT' K f w₀)) : ∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧ (∀ w : InfinitePlace K, w ≠ w₀ → w a < f w) ∧ |(w₀.val.embedding a).re| < 1 ∧ |(w₀.val.embedding a).im| < (f w₀ : ℝ) ^ 2 := by have h_fund := ZSpan.isAddFundamentalDomain' (fractionalIdealLatticeBasis K I) volume have : Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))).toAddSubgroup := by change Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))) infer_instance obtain ⟨⟨x, hx⟩, h_nz, h_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure h_fund (convexBodyLT'_neg_mem K f w₀) (convexBodyLT'_convex K f w₀) h rw [mem_toAddSubgroup, mem_span_fractionalIdealLatticeBasis] at hx obtain ⟨a, ha, rfl⟩ := hx exact ⟨a, ha, by simpa using h_nz, (convexBodyLT'_mem K f w₀).mp h_mem⟩ open scoped Classical in /-- A version of `exists_ne_zero_mem_ideal_lt` for the ring of integers of `K`. -/ theorem exists_ne_zero_mem_ringOfIntegers_lt (h : minkowskiBound K ↑1 < volume (convexBodyLT K f)) : ∃ a : 𝓞 K, a ≠ 0 ∧ ∀ w : InfinitePlace K, w a < f w := by obtain ⟨_, h_mem, h_nz, h_bd⟩ := exists_ne_zero_mem_ideal_lt K ↑1 h obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem exact ⟨a, RingOfIntegers.coe_ne_zero_iff.mp h_nz, h_bd⟩ open scoped Classical in /-- A version of `exists_ne_zero_mem_ideal_lt'` for the ring of integers of `K`. -/ theorem exists_ne_zero_mem_ringOfIntegers_lt' (w₀ : {w : InfinitePlace K // IsComplex w}) (h : minkowskiBound K ↑1 < volume (convexBodyLT' K f w₀)) : ∃ a : 𝓞 K, a ≠ 0 ∧ (∀ w : InfinitePlace K, w ≠ w₀ → w a < f w) ∧ |(w₀.val.embedding a).re| < 1 ∧ |(w₀.val.embedding a).im| < (f w₀ : ℝ) ^ 2 := by obtain ⟨_, h_mem, h_nz, h_bd⟩ := exists_ne_zero_mem_ideal_lt' K ↑1 w₀ h obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem exact ⟨a, RingOfIntegers.coe_ne_zero_iff.mp h_nz, h_bd⟩ theorem exists_primitive_element_lt_of_isReal {w₀ : InfinitePlace K} (hw₀ : IsReal w₀) {B : ℝ≥0} (hB : minkowskiBound K ↑1 < convexBodyLTFactor K * B) : ∃ a : 𝓞 K, ℚ⟮(a : K)⟯ = ⊤ ∧ ∀ w : InfinitePlace K, w a < max B 1 := by classical have : minkowskiBound K ↑1 < volume (convexBodyLT K (fun w ↦ if w = w₀ then B else 1)) := by rw [convexBodyLT_volume, ← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀)] simp_rw [ite_pow, one_pow] rw [Finset.prod_ite_eq'] simp_rw [Finset.notMem_erase, ite_false, mult, hw₀, ite_true, one_mul, pow_one] exact hB obtain ⟨a, h_nz, h_le⟩ := exists_ne_zero_mem_ringOfIntegers_lt K this refine ⟨a, ?_, fun w ↦ lt_of_lt_of_le (h_le w) ?_⟩ · exact is_primitive_element_of_infinitePlace_lt h_nz (fun w h_ne ↦ by convert (if_neg h_ne) ▸ h_le w) (Or.inl hw₀) · split_ifs <;> simp theorem exists_primitive_element_lt_of_isComplex {w₀ : InfinitePlace K} (hw₀ : IsComplex w₀) {B : ℝ≥0} (hB : minkowskiBound K ↑1 < convexBodyLT'Factor K * B) : ∃ a : 𝓞 K, ℚ⟮(a : K)⟯ = ⊤ ∧ ∀ w : InfinitePlace K, w a < Real.sqrt (1 + B ^ 2) := by classical have : minkowskiBound K ↑1 < volume (convexBodyLT' K (fun w ↦ if w = w₀ then NNReal.sqrt B else 1) ⟨w₀, hw₀⟩) := by rw [convexBodyLT'_volume, ← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀)] simp_rw [ite_pow, one_pow] rw [Finset.prod_ite_eq'] simp_rw [Finset.notMem_erase, ite_false, mult, not_isReal_iff_isComplex.mpr hw₀, ite_true, ite_false, one_mul, NNReal.sq_sqrt] exact hB obtain ⟨a, h_nz, h_le, h_le₀⟩ := exists_ne_zero_mem_ringOfIntegers_lt' K ⟨w₀, hw₀⟩ this refine ⟨a, ?_, fun w ↦ ?_⟩ · exact is_primitive_element_of_infinitePlace_lt h_nz (fun w h_ne ↦ by convert if_neg h_ne ▸ h_le w h_ne) (Or.inr h_le₀.1) · by_cases h_eq : w = w₀ · rw [if_pos rfl] at h_le₀ dsimp only at h_le₀ rw [h_eq, ← norm_embedding_eq, Real.lt_sqrt (norm_nonneg _), ← Complex.re_add_im (embedding w₀ _), Complex.norm_add_mul_I, Real.sq_sqrt (by positivity)] refine add_lt_add ?_ ?_ · rw [← sq_abs, sq_lt_one_iff₀ (abs_nonneg _)] exact h_le₀.1 · rw [sq_lt_sq, NNReal.abs_eq, ← NNReal.sq_sqrt B] exact h_le₀.2 · refine lt_of_lt_of_le (if_neg h_eq ▸ h_le w h_eq) ?_ rw [NNReal.coe_one, Real.le_sqrt' zero_lt_one, one_pow] norm_num open scoped Classical in /-- Let `I` be a fractional ideal of `K`. Assume that `B : ℝ` is such that `minkowskiBound K I < volume (convexBodySum K B)` where `convexBodySum K B` is the set of points `x` such that `∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B` (see `convexBodySum_volume` for the computation of this volume), then there exists a nonzero algebraic number `a` in `I` such that `|Norm a| < (B / d) ^ d` where `d` is the degree of `K`. -/ theorem exists_ne_zero_mem_ideal_of_norm_le {B : ℝ} (h : (minkowskiBound K I) ≤ volume (convexBodySum K B)) : ∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧ |Algebra.norm ℚ (a : K)| ≤ (B / finrank ℚ K) ^ finrank ℚ K := by have hB : 0 ≤ B := by contrapose! h rw [convexBodySum_volume_eq_zero_of_le_zero K (le_of_lt h)] exact minkowskiBound_pos K I -- Some inequalities that will be useful later on have h1 : 0 < (finrank ℚ K : ℝ)⁻¹ := inv_pos.mpr (Nat.cast_pos.mpr finrank_pos) have h2 : 0 ≤ B / (finrank ℚ K) := div_nonneg hB (Nat.cast_nonneg _) have h_fund := ZSpan.isAddFundamentalDomain' (fractionalIdealLatticeBasis K I) volume have : Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))).toAddSubgroup := by change Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))) infer_instance obtain ⟨⟨x, hx⟩, h_nz, h_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_le_measure h_fund (fun _ ↦ convexBodySum_neg_mem K B) (convexBodySum_convex K B) (convexBodySum_compact K B) h rw [mem_toAddSubgroup, mem_span_fractionalIdealLatticeBasis] at hx obtain ⟨a, ha, rfl⟩ := hx refine ⟨a, ha, by simpa using h_nz, ?_⟩ rw [← rpow_natCast, ← rpow_le_rpow_iff (by simp only [Rat.cast_abs, abs_nonneg]) (rpow_nonneg h2 _) h1, ← rpow_mul h2, mul_inv_cancel₀ (Nat.cast_ne_zero.mpr (ne_of_gt finrank_pos)), rpow_one, le_div_iff₀' (Nat.cast_pos.mpr finrank_pos)] refine le_trans ?_ ((convexBodySum_mem K B).mp h_mem) rw [← le_div_iff₀' (Nat.cast_pos.mpr finrank_pos), ← sum_mult_eq, Nat.cast_sum] refine le_trans ?_ (geom_mean_le_arith_mean Finset.univ _ _ (fun _ _ => Nat.cast_nonneg _) ?_ (fun _ _ => AbsoluteValue.nonneg _ _)) · simp_rw [← prod_eq_abs_norm, rpow_natCast] exact le_of_eq rfl · rw [← Nat.cast_sum, sum_mult_eq, Nat.cast_pos] exact finrank_pos open scoped Classical in theorem exists_ne_zero_mem_ringOfIntegers_of_norm_le {B : ℝ} (h : (minkowskiBound K ↑1) ≤ volume (convexBodySum K B)) : ∃ a : 𝓞 K, a ≠ 0 ∧ |Algebra.norm ℚ (a : K)| ≤ (B / finrank ℚ K) ^ finrank ℚ K := by obtain ⟨_, h_mem, h_nz, h_bd⟩ := exists_ne_zero_mem_ideal_of_norm_le K ↑1 h obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem exact ⟨a, RingOfIntegers.coe_ne_zero_iff.mp h_nz, h_bd⟩ end minkowski end NumberField.mixedEmbedding
.lake/packages/mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/FundamentalCone.lean
import Mathlib.RingTheory.Ideal.IsPrincipal import Mathlib.NumberTheory.NumberField.Units.DirichletTheorem import Mathlib.RingTheory.ClassGroup /-! # Fundamental Cone Let `K` be a number field of signature `(r₁, r₂)`. We define an action of the units `(𝓞 K)ˣ` on the mixed space `ℝ^r₁ × ℂ^r₂` via the `mixedEmbedding`. The fundamental cone is a cone in the mixed space that is a fundamental domain for the action of `(𝓞 K)ˣ` modulo torsion. ## Main definitions and results * `NumberField.mixedEmbedding.unitSMul`: the action of `(𝓞 K)ˣ` on the mixed space defined, for `u : (𝓞 K)ˣ`, by multiplication component by component with `mixedEmbedding K u`. * `NumberField.mixedEmbedding.fundamentalCone`: a cone in the mixed space, i.e. a subset stable by multiplication by a nonzero real number, see `smul_mem_of_mem`, that is also a fundamental domain for the action of `(𝓞 K)ˣ` modulo torsion, see `exists_unit_smul_mem` and `torsion_unit_smul_mem_of_mem`. * `NumberField.mixedEmbedding.fundamentalCone.idealSet`: for `J` an integral ideal, the intersection between the fundamental cone and the `idealLattice` defined by the image of `J`. * `NumberField.mixedEmbedding.fundamentalCone.idealSetEquivNorm`: for `J` an integral ideal and `n` a natural integer, the equivalence between the elements of `idealSet K` of norm `n` and the product of the set of nonzero principal ideals of `K` divisible by `J` of norm `n` and the torsion of `K`. ## Tags number field, canonical embedding, units, principal ideals -/ variable (K : Type*) [Field K] namespace NumberField.mixedEmbedding open NumberField NumberField.InfinitePlace noncomputable section UnitSMul /-- The action of `(𝓞 K)ˣ` on the mixed space `ℝ^r₁ × ℂ^r₂` defined, for `u : (𝓞 K)ˣ`, by multiplication component by component with `mixedEmbedding K u`. -/ @[simps] instance unitSMul : SMul (𝓞 K)ˣ (mixedSpace K) where smul u x := mixedEmbedding K u * x instance : MulAction (𝓞 K)ˣ (mixedSpace K) where one_smul := fun _ ↦ by simp_rw [unitSMul_smul, Units.coe_one, map_one, one_mul] mul_smul := fun _ _ _ ↦ by simp_rw [unitSMul_smul, Units.coe_mul, map_mul, mul_assoc] instance : SMulZeroClass (𝓞 K)ˣ (mixedSpace K) where smul_zero := fun _ ↦ by simp_rw [unitSMul_smul, mul_zero] variable {K} theorem unit_smul_eq_zero (u : (𝓞 K)ˣ) (x : mixedSpace K) : u • x = 0 ↔ x = 0 := by refine ⟨fun h ↦ ?_, fun h ↦ by rw [h, smul_zero]⟩ contrapose! h obtain ⟨w, h⟩ := exists_normAtPlace_ne_zero_iff.mpr h refine exists_normAtPlace_ne_zero_iff.mp ⟨w, ?_⟩ rw [unitSMul_smul, map_mul] exact mul_ne_zero (by simp) h variable [NumberField K] theorem unit_smul_eq_iff_mul_eq {x y : 𝓞 K} {u : (𝓞 K)ˣ} : u • mixedEmbedding K x = mixedEmbedding K y ↔ u * x = y := by rw [unitSMul_smul, ← map_mul, Function.Injective.eq_iff, ← RingOfIntegers.coe_eq_algebraMap, ← map_mul, ← RingOfIntegers.ext_iff] exact mixedEmbedding_injective K theorem norm_unit_smul (u : (𝓞 K)ˣ) (x : mixedSpace K) : mixedEmbedding.norm (u • x) = mixedEmbedding.norm x := by rw [unitSMul_smul, map_mul, norm_unit, one_mul] end UnitSMul noncomputable section logMap open NumberField.Units NumberField.Units.dirichletUnitTheorem Module variable [NumberField K] {K} open Classical in /-- The map from the mixed space to `logSpace K` defined in such way that: 1) it factors the map `logEmbedding`, see `logMap_eq_logEmbedding`; 2) it is constant on the sets `{c • x | c ∈ ℝ, c ≠ 0}` if `norm x ≠ 0`, see `logMap_real_smul`. -/ def logMap (x : mixedSpace K) : logSpace K := fun w ↦ mult w.val * (Real.log (normAtPlace w.val x) - Real.log (mixedEmbedding.norm x) * (finrank ℚ K : ℝ)⁻¹) @[simp] theorem logMap_apply (x : mixedSpace K) (w : {w : InfinitePlace K // w ≠ w₀}) : logMap x w = mult w.val * (Real.log (normAtPlace w.val x) - Real.log (mixedEmbedding.norm x) * (finrank ℚ K : ℝ)⁻¹) := rfl @[simp] theorem logMap_zero : logMap (0 : mixedSpace K) = 0 := by ext; simp @[simp] theorem logMap_one : logMap (1 : mixedSpace K) = 0 := by ext; simp variable {x y : mixedSpace K} theorem logMap_mul (hx : mixedEmbedding.norm x ≠ 0) (hy : mixedEmbedding.norm y ≠ 0) : logMap (x * y) = logMap x + logMap y := by ext w simp_rw [Pi.add_apply, logMap_apply] rw [map_mul, map_mul, Real.log_mul, Real.log_mul hx hy, add_mul] · ring · exact mixedEmbedding.norm_ne_zero_iff.mp hx w · exact mixedEmbedding.norm_ne_zero_iff.mp hy w theorem logMap_apply_of_norm_eq_one (hx : mixedEmbedding.norm x = 1) (w : {w : InfinitePlace K // w ≠ w₀}) : logMap x w = mult w.val * Real.log (normAtPlace w x) := by rw [logMap_apply, hx, Real.log_one, zero_mul, sub_zero] @[deprecated (since := "2025-11-15")] alias logMap_apply_of_norm_one := logMap_apply_of_norm_eq_one @[simp] theorem logMap_eq_logEmbedding (u : (𝓞 K)ˣ) : logMap (mixedEmbedding K u) = logEmbedding K (Additive.ofMul u) := by ext; simp theorem logMap_unit_smul (u : (𝓞 K)ˣ) (hx : mixedEmbedding.norm x ≠ 0) : logMap (u • x) = logEmbedding K (Additive.ofMul u) + logMap x := by rw [unitSMul_smul, logMap_mul (by rw [norm_unit]; norm_num) hx, logMap_eq_logEmbedding] variable (x) in theorem logMap_torsion_smul {ζ : (𝓞 K)ˣ} (hζ : ζ ∈ torsion K) : logMap (ζ • x) = logMap x := by ext simp_rw [logMap_apply, unitSMul_smul, map_mul, norm_eq_norm, Units.norm, Rat.cast_one, one_mul, normAtPlace_apply, (mem_torsion K).mp hζ, one_mul] theorem logMap_real (c : ℝ) : logMap (c • (1 : mixedSpace K)) = 0 := by ext rw [logMap_apply, normAtPlace_smul, norm_smul, map_one, map_one, mul_one, mul_one, Real.log_pow, mul_comm (finrank ℚ K : ℝ) _, mul_assoc, mul_inv_cancel₀ (Nat.cast_ne_zero.mpr finrank_pos.ne'), mul_one, sub_self, mul_zero, Pi.zero_apply] theorem logMap_real_smul (hx : mixedEmbedding.norm x ≠ 0) {c : ℝ} (hc : c ≠ 0) : logMap (c • x) = logMap x := by have : mixedEmbedding.norm (c • (1 : mixedSpace K)) ≠ 0 := by rw [norm_smul, map_one, mul_one] exact pow_ne_zero _ (abs_ne_zero.mpr hc) rw [← smul_one_mul, logMap_mul this hx, logMap_real, zero_add] theorem logMap_eq_of_normAtPlace_eq (h : ∀ w, normAtPlace w x = normAtPlace w y) : logMap x = logMap y := by ext simp_rw [logMap_apply, h, norm_eq_of_normAtPlace_eq h] end logMap noncomputable section open NumberField.Units NumberField.Units.dirichletUnitTheorem variable [NumberField K] open Classical in /-- The fundamental cone is a cone in the mixed space, i.e. a subset fixed by multiplication by a nonzero real number, see `smul_mem_of_mem`, that is also a fundamental domain for the action of `(𝓞 K)ˣ` modulo torsion, see `exists_unit_smul_mem` and `torsion_smul_mem_of_mem`. -/ def fundamentalCone : Set (mixedSpace K) := logMap ⁻¹' (ZSpan.fundamentalDomain ((basisUnitLattice K).ofZLatticeBasis ℝ _)) \ {x | mixedEmbedding.norm x = 0} theorem measurableSet_fundamentalCone : MeasurableSet (fundamentalCone K) := by classical refine MeasurableSet.diff ?_ ?_ · unfold logMap refine MeasurableSet.preimage (ZSpan.fundamentalDomain_measurableSet _) <| measurable_pi_iff.mpr fun w ↦ measurable_const.mul ?_ exact (continuous_normAtPlace _).measurable.log.sub <| (mixedEmbedding.continuous_norm _).measurable.log.mul measurable_const · exact measurableSet_eq_fun (mixedEmbedding.continuous_norm K).measurable measurable_const namespace fundamentalCone variable {K} {x y : mixedSpace K} {c : ℝ} theorem norm_pos_of_mem (hx : x ∈ fundamentalCone K) : 0 < mixedEmbedding.norm x := lt_of_le_of_ne (mixedEmbedding.norm_nonneg _) (Ne.symm hx.2) theorem normAtPlace_pos_of_mem (hx : x ∈ fundamentalCone K) (w : InfinitePlace K) : 0 < normAtPlace w x := lt_of_le_of_ne (normAtPlace_nonneg _ _) (mixedEmbedding.norm_ne_zero_iff.mp (norm_pos_of_mem hx).ne' w).symm theorem mem_of_normAtPlace_eq (hx : x ∈ fundamentalCone K) (hy : ∀ w, normAtPlace w y = normAtPlace w x) : y ∈ fundamentalCone K := by refine ⟨?_, by simpa [norm_eq_of_normAtPlace_eq hy] using hx.2⟩ rw [Set.mem_preimage, logMap_eq_of_normAtPlace_eq hy] exact hx.1 theorem smul_mem_of_mem (hx : x ∈ fundamentalCone K) (hc : c ≠ 0) : c • x ∈ fundamentalCone K := by refine ⟨?_, ?_⟩ · rw [Set.mem_preimage, logMap_real_smul hx.2 hc] exact hx.1 · rw [Set.mem_setOf_eq, mixedEmbedding.norm_smul, mul_eq_zero, not_or] exact ⟨pow_ne_zero _ (abs_ne_zero.mpr hc), hx.2⟩ theorem smul_mem_iff_mem (hc : c ≠ 0) : c • x ∈ fundamentalCone K ↔ x ∈ fundamentalCone K := by refine ⟨fun h ↦ ?_, fun h ↦ smul_mem_of_mem h hc⟩ convert smul_mem_of_mem h (inv_ne_zero hc) rw [eq_inv_smul_iff₀ hc] theorem exists_unit_smul_mem (hx : mixedEmbedding.norm x ≠ 0) : ∃ u : (𝓞 K)ˣ, u • x ∈ fundamentalCone K := by classical let B := (basisUnitLattice K).ofZLatticeBasis ℝ rsuffices ⟨⟨_, ⟨u, _, rfl⟩⟩, hu⟩ : ∃ e : unitLattice K, e + logMap x ∈ ZSpan.fundamentalDomain B · exact ⟨u, by rwa [Set.mem_preimage, logMap_unit_smul u hx], by simp [hx]⟩ · obtain ⟨⟨e, h₁⟩, h₂, -⟩ := ZSpan.exist_unique_vadd_mem_fundamentalDomain B (logMap x) exact ⟨⟨e, by rwa [← Module.Basis.ofZLatticeBasis_span ℝ (unitLattice K)]⟩, h₂⟩ theorem torsion_smul_mem_of_mem (hx : x ∈ fundamentalCone K) {ζ : (𝓞 K)ˣ} (hζ : ζ ∈ torsion K) : ζ • x ∈ fundamentalCone K := by constructor · rw [Set.mem_preimage, logMap_torsion_smul _ hζ] exact hx.1 · rw [Set.mem_setOf_eq, unitSMul_smul, map_mul, norm_unit, one_mul] exact hx.2 theorem unit_smul_mem_iff_mem_torsion (hx : x ∈ fundamentalCone K) (u : (𝓞 K)ˣ) : u • x ∈ fundamentalCone K ↔ u ∈ torsion K := by classical refine ⟨fun h ↦ ?_, fun h ↦ torsion_smul_mem_of_mem hx h⟩ rw [← logEmbedding_eq_zero_iff] let B := (basisUnitLattice K).ofZLatticeBasis ℝ refine (Subtype.mk_eq_mk (h := ?_) (h' := Submodule.zero_mem _)).mp <| (ZSpan.exist_unique_vadd_mem_fundamentalDomain B (logMap x)).unique ?_ ?_ · rw [Module.Basis.ofZLatticeBasis_span ℝ (unitLattice K)] exact ⟨u, trivial, rfl⟩ · rw [AddSubmonoid.mk_vadd, vadd_eq_add, ← logMap_unit_smul _ hx.2] exact h.1 · rw [AddSubmonoid.mk_vadd, vadd_eq_add, zero_add] exact hx.1 variable (K) in /-- The intersection between the fundamental cone and the `integerLattice`. -/ def integerSet : Set (mixedSpace K) := fundamentalCone K ∩ mixedEmbedding.integerLattice K theorem mem_integerSet {a : mixedSpace K} : a ∈ integerSet K ↔ a ∈ fundamentalCone K ∧ ∃ x : 𝓞 K, mixedEmbedding K x = a := by simp only [integerSet, Set.mem_inter_iff, SetLike.mem_coe, LinearMap.mem_range, AlgHom.toLinearMap_apply, RingHom.toIntAlgHom_coe, RingHom.coe_comp, Function.comp_apply] /-- If `a` is in `integerSet`, then there is a *unique* algebraic integer in `𝓞 K` such that `mixedEmbedding K x = a`. -/ theorem existsUnique_preimage_of_mem_integerSet {a : mixedSpace K} (ha : a ∈ integerSet K) : ∃! x : 𝓞 K, mixedEmbedding K x = a := by obtain ⟨_, ⟨x, rfl⟩⟩ := mem_integerSet.mp ha refine Function.Injective.existsUnique_of_mem_range ?_ (Set.mem_range_self x) exact (mixedEmbedding_injective K).comp RingOfIntegers.coe_injective theorem ne_zero_of_mem_integerSet (a : integerSet K) : (a : mixedSpace K) ≠ 0 := by by_contra! exact a.prop.1.2 (this.symm ▸ mixedEmbedding.norm.map_zero') open scoped nonZeroDivisors /-- For `a : integerSet K`, the unique nonzero algebraic integer `x` such that its image by `mixedEmbedding` is equal to `a`. Note that we state the fact that `x ≠ 0` by saying that `x` is a nonzero divisors since we will use later on the isomorphism `Ideal.associatesNonZeroDivisorsEquivIsPrincipal`, see `integerSetEquiv`. -/ def preimageOfMemIntegerSet (a : integerSet K) : (𝓞 K)⁰ := ⟨(mem_integerSet.mp a.prop).2.choose, mem_nonZeroDivisors_of_ne_zero (by simp_rw [ne_eq, ← RingOfIntegers.coe_injective.eq_iff, ← (mixedEmbedding_injective K).eq_iff, map_zero, (mem_integerSet.mp a.prop).2.choose_spec, ne_zero_of_mem_integerSet, not_false_eq_true])⟩ @[simp] theorem mixedEmbedding_preimageOfMemIntegerSet (a : integerSet K) : mixedEmbedding K (preimageOfMemIntegerSet a : 𝓞 K) = (a : mixedSpace K) := by rw [preimageOfMemIntegerSet, (mem_integerSet.mp a.prop).2.choose_spec] theorem preimageOfMemIntegerSet_mixedEmbedding {x : (𝓞 K)} (hx : mixedEmbedding K (x : 𝓞 K) ∈ integerSet K) : preimageOfMemIntegerSet (⟨mixedEmbedding K (x : 𝓞 K), hx⟩) = x := by simp_rw [RingOfIntegers.ext_iff, ← (mixedEmbedding_injective K).eq_iff, mixedEmbedding_preimageOfMemIntegerSet] /-- If `x : mixedSpace K` is nonzero and the image of an algebraic integer, then there exists a unit such that `u • x ∈ integerSet K`. -/ theorem exists_unitSMul_mem_integerSet {x : mixedSpace K} (hx : x ≠ 0) (hx' : x ∈ mixedEmbedding K '' (Set.range (algebraMap (𝓞 K) K))) : ∃ u : (𝓞 K)ˣ, u • x ∈ integerSet K := by replace hx : mixedEmbedding.norm x ≠ 0 := (norm_eq_zero_iff' (Set.mem_range_of_mem_image (mixedEmbedding K) _ hx')).not.mpr hx obtain ⟨u, hu⟩ := exists_unit_smul_mem hx obtain ⟨_, ⟨x, rfl⟩, _, rfl⟩ := hx' exact ⟨u, mem_integerSet.mpr ⟨hu, u * x, by simp_rw [unitSMul_smul, ← map_mul]⟩⟩ /-- The set `integerSet K` is stable under the action of the torsion. -/ theorem torsion_unitSMul_mem_integerSet {x : mixedSpace K} {ζ : (𝓞 K)ˣ} (hζ : ζ ∈ torsion K) (hx : x ∈ integerSet K) : ζ • x ∈ integerSet K := by obtain ⟨a, ⟨_, rfl⟩, rfl⟩ := (mem_integerSet.mp hx).2 refine mem_integerSet.mpr ⟨torsion_smul_mem_of_mem hx.1 hζ, ⟨ζ * a, by simp⟩⟩ /-- The action of `torsion K` on `integerSet K`. -/ @[simps] instance integerSetTorsionSMul : SMul (torsion K) (integerSet K) where smul := fun ⟨ζ, hζ⟩ ⟨x, hx⟩ ↦ ⟨ζ • x, torsion_unitSMul_mem_integerSet hζ hx⟩ instance : MulAction (torsion K) (integerSet K) where one_smul := fun _ ↦ by rw [Subtype.mk_eq_mk, integerSetTorsionSMul_smul_coe, OneMemClass.coe_one, one_smul] mul_smul := fun _ _ _ ↦ by rw [Subtype.mk_eq_mk] simp_rw [integerSetTorsionSMul_smul_coe, Subgroup.coe_mul, mul_smul] /-- The `mixedEmbedding.norm` of `a : integerSet K` as a natural number, see also `intNorm_coe`. -/ def intNorm (a : integerSet K) : ℕ := (Algebra.norm ℤ (preimageOfMemIntegerSet a : 𝓞 K)).natAbs @[simp] theorem intNorm_coe (a : integerSet K) : (intNorm a : ℝ) = mixedEmbedding.norm (a : mixedSpace K) := by rw [intNorm, Nat.cast_natAbs, ← Rat.cast_intCast, Int.cast_abs, Algebra.coe_norm_int, ← norm_eq_norm, mixedEmbedding_preimageOfMemIntegerSet] /-- The norm `intNorm` lifts to a function on `integerSet K` modulo `torsion K`. -/ def quotIntNorm : Quotient (MulAction.orbitRel (torsion K) (integerSet K)) → ℕ := Quotient.lift (fun x ↦ intNorm x) fun a b ⟨u, hu⟩ ↦ by rw [← Nat.cast_inj (R := ℝ), intNorm_coe, intNorm_coe, ← hu, integerSetTorsionSMul_smul_coe, norm_unit_smul] @[simp] theorem quotIntNorm_apply (a : integerSet K) : quotIntNorm ⟦a⟧ = intNorm a := rfl variable (K) in /-- The map that sends an element of `a : integerSet K` to the associates class of its preimage in `(𝓞 K)⁰`. By quotienting by the kernel of the map, which is equal to the subgroup of torsion, we get the equivalence `integerSetQuotEquivAssociates`. -/ def integerSetToAssociates (a : integerSet K) : Associates (𝓞 K)⁰ := ⟦preimageOfMemIntegerSet a⟧ @[simp] theorem integerSetToAssociates_apply (a : integerSet K) : integerSetToAssociates K a = ⟦preimageOfMemIntegerSet a⟧ := rfl variable (K) in theorem integerSetToAssociates_surjective : Function.Surjective (integerSetToAssociates K) := by rintro ⟨x⟩ obtain ⟨u, hu⟩ : ∃ u : (𝓞 K)ˣ, u • mixedEmbedding K (x : 𝓞 K) ∈ integerSet K := by refine exists_unitSMul_mem_integerSet ?_ ⟨(x : 𝓞 K), Set.mem_range_self _, rfl⟩ exact (map_ne_zero _).mpr <| RingOfIntegers.coe_ne_zero_iff.mpr (nonZeroDivisors.coe_ne_zero _) refine ⟨⟨u • mixedEmbedding K (x : 𝓞 K), hu⟩, Quotient.sound ⟨unitsNonZeroDivisorsEquiv.symm u⁻¹, ?_⟩⟩ simp_rw [Subtype.ext_iff, RingOfIntegers.ext_iff, ← (mixedEmbedding_injective K).eq_iff, Submonoid.coe_mul, map_mul, mixedEmbedding_preimageOfMemIntegerSet, unitSMul_smul, ← map_mul, mul_comm, map_inv, val_inv_unitsNonZeroDivisorsEquiv_symm_apply_coe, Units.mul_inv_cancel_right] theorem integerSetToAssociates_eq_iff (a b : integerSet K) : integerSetToAssociates K a = integerSetToAssociates K b ↔ ∃ ζ : torsion K, ζ • a = b := by simp_rw [integerSetToAssociates_apply, Associates.quotient_mk_eq_mk, Associates.mk_eq_mk_iff_associated, Associated, mul_comm, Subtype.ext_iff, RingOfIntegers.ext_iff, ← (mixedEmbedding_injective K).eq_iff, Submonoid.coe_mul, map_mul, mixedEmbedding_preimageOfMemIntegerSet, integerSetTorsionSMul_smul_coe] refine ⟨fun ⟨u, h⟩ ↦ ⟨⟨unitsNonZeroDivisorsEquiv u, ?_⟩, by simpa using h⟩, fun ⟨⟨u, _⟩, h⟩ ↦ ⟨unitsNonZeroDivisorsEquiv.symm u, by simpa using h⟩⟩ exact (unit_smul_mem_iff_mem_torsion a.prop.1 _).mp (by simpa [h] using b.prop.1) variable (K) in /-- The equivalence between `integerSet K` modulo `torsion K` and `Associates (𝓞 K)⁰`. -/ def integerSetQuotEquivAssociates : Quotient (MulAction.orbitRel (torsion K) (integerSet K)) ≃ Associates (𝓞 K)⁰ := Equiv.ofBijective (Quotient.lift (integerSetToAssociates K) fun _ _ h ↦ ((integerSetToAssociates_eq_iff _ _).mpr h).symm) ⟨Setoid.lift_injective_iff_ker_eq_of_le _ |>.mpr <| by ext a b rw [Setoid.ker_def, eq_comm, integerSetToAssociates_eq_iff b a, MulAction.orbitRel_apply, MulAction.mem_orbit_iff], (Quot.surjective_lift _).mpr (integerSetToAssociates_surjective K)⟩ @[simp] theorem integerSetQuotEquivAssociates_apply (a : integerSet K) : integerSetQuotEquivAssociates K ⟦a⟧ = ⟦preimageOfMemIntegerSet a⟧ := rfl theorem integerSetTorsionSMul_stabilizer (a : integerSet K) : MulAction.stabilizer (torsion K) a = ⊥ := by refine (Subgroup.eq_bot_iff_forall _).mpr fun ζ hζ ↦ ?_ rwa [MulAction.mem_stabilizer_iff, Subtype.ext_iff, integerSetTorsionSMul_smul_coe, unitSMul_smul, ← mixedEmbedding_preimageOfMemIntegerSet, ← map_mul, (mixedEmbedding_injective K).eq_iff, ← map_mul, ← RingOfIntegers.ext_iff, mul_eq_right₀, Units.val_eq_one, OneMemClass.coe_eq_one] at hζ exact nonZeroDivisors.coe_ne_zero _ open Submodule Ideal variable (K) in /-- The equivalence between `integerSet K` and the product of the set of nonzero principal ideals of `K` and the torsion of `K`. -/ def integerSetEquiv : integerSet K ≃ {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.val} × torsion K := (MulAction.selfEquivSigmaOrbitsQuotientStabilizer (torsion K) (integerSet K)).trans ((Equiv.sigmaEquivProdOfEquiv (by intro _ simp_rw [integerSetTorsionSMul_stabilizer] exact QuotientGroup.quotientBot.toEquiv)).trans (Equiv.prodCongrLeft (fun _ ↦ (integerSetQuotEquivAssociates K).trans (Ideal.associatesNonZeroDivisorsEquivIsPrincipal (𝓞 K))))) @[simp] theorem integerSetEquiv_apply_fst (a : integerSet K) : ((integerSetEquiv K a).1 : Ideal (𝓞 K)) = span {(preimageOfMemIntegerSet a : 𝓞 K)} := rfl variable (K) in /-- For an integer `n`, The equivalence between the elements of `integerSet K` of norm `n` and the product of the set of nonzero principal ideals of `K` of norm `n` and the torsion of `K`. -/ def integerSetEquivNorm (n : ℕ) : {a : integerSet K // mixedEmbedding.norm (a : mixedSpace K) = n} ≃ {I : (Ideal (𝓞 K))⁰ // IsPrincipal (I : Ideal (𝓞 K)) ∧ absNorm (I : Ideal (𝓞 K)) = n} × (torsion K) := calc _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1} × torsion K // absNorm (I.1 : Ideal (𝓞 K)) = n} := Equiv.subtypeEquiv (integerSetEquiv K) fun _ ↦ by simp_rw [← intNorm_coe, intNorm, Nat.cast_inj, integerSetEquiv_apply_fst, absNorm_span_singleton] _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1} // absNorm (I.1 : Ideal (𝓞 K)) = n} × torsion K := Equiv.prodSubtypeFstEquivSubtypeProd (p := fun I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1} ↦ absNorm (I : Ideal (𝓞 K)) = n) _ ≃ {I : (Ideal (𝓞 K))⁰ // IsPrincipal (I : Ideal (𝓞 K)) ∧ absNorm (I : Ideal (𝓞 K)) = n} × (torsion K) := Equiv.prodCongrLeft fun _ ↦ (Equiv.subtypeSubtypeEquivSubtypeInter (fun I : (Ideal (𝓞 K))⁰ ↦ IsPrincipal I.1) (fun I ↦ absNorm I.1 = n)) @[simp] theorem integerSetEquivNorm_apply_fst {n : ℕ} (a : {a : integerSet K // mixedEmbedding.norm (a : mixedSpace K) = n}) : ((integerSetEquivNorm K n a).1 : Ideal (𝓞 K)) = span {(preimageOfMemIntegerSet a.val : 𝓞 K)} := by simp_rw [integerSetEquivNorm, Equiv.prodSubtypeFstEquivSubtypeProd, Equiv.trans_def, Equiv.prodCongrLeft, Equiv.trans_apply, Equiv.subtypeEquiv_apply, Equiv.coe_fn_mk, Equiv.subtypeSubtypeEquivSubtypeInter_apply_coe, integerSetEquiv_apply_fst] variable (K) /-- For `n` positive, the number of principal ideals in `𝓞 K` of norm `n` multiplied by the order of the torsion of `K` is equal to the number of elements in `integerSet K` of norm `n`. -/ theorem card_isPrincipal_norm_eq_mul_torsion (n : ℕ) : Nat.card {I : (Ideal (𝓞 K))⁰ | IsPrincipal (I : Ideal (𝓞 K)) ∧ absNorm (I : Ideal (𝓞 K)) = n} * torsionOrder K = Nat.card {a : integerSet K | mixedEmbedding.norm (a : mixedSpace K) = n} := by rw [torsionOrder, ← Nat.card_eq_fintype_card, ← Nat.card_prod] exact Nat.card_congr (integerSetEquivNorm K n).symm variable (J : (Ideal (𝓞 K))⁰) /-- The intersection between the fundamental cone and the `idealLattice` defined by the image of the integral ideal `J`. -/ def idealSet : Set (mixedSpace K) := fundamentalCone K ∩ (mixedEmbedding.idealLattice K (FractionalIdeal.mk0 K J)) variable {K J} in theorem mem_idealSet : x ∈ idealSet K J ↔ x ∈ fundamentalCone K ∧ ∃ a : (𝓞 K), (a : 𝓞 K) ∈ (J : Set (𝓞 K)) ∧ mixedEmbedding K (a : 𝓞 K) = x := by simp_rw [idealSet, Set.mem_inter_iff, idealLattice, SetLike.mem_coe, FractionalIdeal.coe_mk0, LinearMap.mem_range, LinearMap.coe_comp, LinearMap.coe_restrictScalars, coe_subtype, Function.comp_apply, AlgHom.toLinearMap_apply, RingHom.toIntAlgHom_coe, Subtype.exists, FractionalIdeal.mem_coe, FractionalIdeal.mem_coeIdeal, exists_prop', nonempty_prop, exists_exists_and_eq_and] /-- The map that sends `a : idealSet` to an element of `integerSet`. This map exists because `J` is an integral ideal. -/ def idealSetMap : idealSet K J → integerSet K := fun ⟨a, ha⟩ ↦ ⟨a, mem_integerSet.mpr ⟨(mem_idealSet.mp ha).1, (mem_idealSet.mp ha).2.choose, (mem_idealSet.mp ha).2.choose_spec.2⟩⟩ @[simp] theorem idealSetMap_apply (a : idealSet K J) : (idealSetMap K J a : mixedSpace K) = a := rfl theorem preimage_of_IdealSetMap (a : idealSet K J) : (preimageOfMemIntegerSet (idealSetMap K J a) : 𝓞 K) ∈ (J : Set (𝓞 K)) := by obtain ⟨_, ⟨x, hx₁, hx₂⟩⟩ := mem_idealSet.mp a.prop simp_rw [idealSetMap, ← hx₂, preimageOfMemIntegerSet_mixedEmbedding] exact hx₁ /-- The map `idealSetMap` is actually an equiv between `idealSet K J` and the elements of `integerSet K` whose preimage lies in `J`. -/ def idealSetEquiv : idealSet K J ≃ {a : integerSet K | (preimageOfMemIntegerSet a : 𝓞 K) ∈ (J : Set (𝓞 K))} := Equiv.ofBijective (fun a ↦ ⟨idealSetMap K J a, preimage_of_IdealSetMap K J a⟩) ⟨fun _ _ h ↦ (by simp_rw [Subtype.ext_iff, idealSetMap_apply] at h rwa [Subtype.ext_iff]), fun ⟨a, ha₂⟩ ↦ ⟨⟨a.val, mem_idealSet.mpr ⟨a.prop.1, ⟨preimageOfMemIntegerSet a, ha₂, mixedEmbedding_preimageOfMemIntegerSet a⟩⟩⟩, rfl⟩⟩ variable {K J} theorem idealSetEquiv_apply (a : idealSet K J) : (idealSetEquiv K J a : mixedSpace K) = a := rfl theorem idealSetEquiv_symm_apply (a : {a : integerSet K // (preimageOfMemIntegerSet a : 𝓞 K) ∈ (J : Set (𝓞 K)) }) : ((idealSetEquiv K J).symm a : mixedSpace K) = a := by rw [← (idealSetEquiv_apply ((idealSetEquiv K J).symm a)), Equiv.apply_symm_apply] theorem intNorm_idealSetEquiv_apply (a : idealSet K J) : intNorm (idealSetEquiv K J a).val = mixedEmbedding.norm (a : mixedSpace K) := by rw [intNorm_coe, idealSetEquiv_apply] variable (K J) /-- For an integer `n`, The equivalence between the elements of `idealSet K` of norm `n` and the product of the set of nonzero principal ideals of `K` divisible by `J` of norm `n` and the torsion of `K`. -/ def idealSetEquivNorm (n : ℕ) : {a : idealSet K J // mixedEmbedding.norm (a : mixedSpace K) = n} ≃ {I : (Ideal (𝓞 K))⁰ // (J : Ideal (𝓞 K)) ∣ I ∧ IsPrincipal (I : Ideal (𝓞 K)) ∧ absNorm (I : Ideal (𝓞 K)) = n} × (torsion K) := calc _ ≃ {a : {a : integerSet K // (preimageOfMemIntegerSet a).1 ∈ J.1} // mixedEmbedding.norm a.1.1 = n} := by convert (Equiv.subtypeEquivOfSubtype (idealSetEquiv K J).symm).symm using 3 rw [idealSetEquiv_symm_apply] _ ≃ {a : integerSet K // (preimageOfMemIntegerSet a).1 ∈ J.1 ∧ mixedEmbedding.norm a.1 = n} := Equiv.subtypeSubtypeEquivSubtypeInter (fun a : integerSet K ↦ (preimageOfMemIntegerSet a).1 ∈ J.1) (fun a ↦ mixedEmbedding.norm a.1 = n) _ ≃ {a : {a :integerSet K // mixedEmbedding.norm a.1 = n} // (preimageOfMemIntegerSet a.1).1 ∈ J.1} := ((Equiv.subtypeSubtypeEquivSubtypeInter (fun a : integerSet K ↦ mixedEmbedding.norm a.1 = n) (fun a ↦ (preimageOfMemIntegerSet a).1 ∈ J.1)).trans (Equiv.subtypeEquivRight (fun _ ↦ by simp [and_comm]))).symm _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1 ∧ absNorm I.1 = n} × (torsion K) // J.1 ∣ I.1.1} := by convert Equiv.subtypeEquivOfSubtype (p := fun I ↦ J.1 ∣ I.1) (integerSetEquivNorm K n) rw [integerSetEquivNorm_apply_fst, dvd_span_singleton] _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1 ∧ absNorm I.1 = n} // J.1 ∣ I.1} × (torsion K) := Equiv.prodSubtypeFstEquivSubtypeProd (p := fun I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1 ∧ absNorm I.1 = n} ↦ J.1 ∣ I.1) _ ≃ {I : (Ideal (𝓞 K))⁰ // (IsPrincipal I.1 ∧ absNorm I.1 = n) ∧ J.1 ∣ I.1} × (torsion K) := Equiv.prodCongrLeft fun _ ↦ (Equiv.subtypeSubtypeEquivSubtypeInter (fun I : (Ideal (𝓞 K))⁰ ↦ IsPrincipal I.1 ∧ absNorm I.1 = n) (fun I ↦ J.1 ∣ I.1)) _ ≃ {I : (Ideal (𝓞 K))⁰ // J.1 ∣ I.1 ∧ IsPrincipal I.1 ∧ absNorm I.1 = n} × (Units.torsion K) := Equiv.prodCongrLeft fun _ ↦ Equiv.subtypeEquivRight fun _ ↦ by rw [and_comm] /-- For `s : ℝ`, the number of principal nonzero ideals in `𝓞 K` divisible par `J` of norm `≤ s` multiplied by the order of the torsion of `K` is equal to the number of elements in `idealSet K J` of norm `≤ s`. -/ theorem card_isPrincipal_dvd_norm_le (s : ℝ) : Nat.card {I : (Ideal (𝓞 K))⁰ // (J : Ideal (𝓞 K)) ∣ I ∧ IsPrincipal (I : Ideal (𝓞 K)) ∧ absNorm (I : Ideal (𝓞 K)) ≤ s} * torsionOrder K = Nat.card {a : idealSet K J // mixedEmbedding.norm (a : mixedSpace K) ≤ s} := by obtain hs | hs := le_or_gt 0 s · simp_rw [← intNorm_idealSetEquiv_apply, ← Nat.le_floor_iff hs] rw [torsionOrder, ← Nat.card_eq_fintype_card, ← Nat.card_prod] refine Nat.card_congr <| @Equiv.ofFiberEquiv _ (γ := Finset.Iic ⌊s⌋₊) _ (fun I ↦ ⟨absNorm I.1.val.1, Finset.mem_Iic.mpr I.1.prop.2.2⟩) (fun a ↦ ⟨intNorm (idealSetEquiv K J a.1).1, Finset.mem_Iic.mpr a.prop⟩) fun ⟨i, hi⟩ ↦ ?_ simp_rw [Subtype.mk.injEq] calc _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // _ ∧ _ ∧ _} // absNorm I.1.1 = i} × torsion K := Equiv.prodSubtypeFstEquivSubtypeProd _ ≃ {I : (Ideal (𝓞 K))⁰ // (_ ∧ _ ∧ absNorm I.1 ≤ ⌊s⌋₊) ∧ absNorm I.1 = i} × torsion K := Equiv.prodCongrLeft fun _ ↦ (Equiv.subtypeSubtypeEquivSubtypeInter (p := fun I : (Ideal (𝓞 K))⁰ ↦ J.1 ∣ I.1 ∧ IsPrincipal I.1 ∧ absNorm I.1 ≤ ⌊s⌋₊) (q := fun I ↦ absNorm I.1 = i)) _ ≃ {I : (Ideal (𝓞 K))⁰ // J.1 ∣ I.1 ∧ IsPrincipal I.1 ∧ absNorm I.1 = i} × torsion K := Equiv.prodCongrLeft fun _ ↦ Equiv.subtypeEquivRight fun _ ↦ by aesop _ ≃ {a : idealSet K J // mixedEmbedding.norm (a : mixedSpace K) = i} := (idealSetEquivNorm K J i).symm _ ≃ {a : idealSet K J // intNorm (idealSetEquiv K J a).1 = i} := by simp_rw [← intNorm_idealSetEquiv_apply, Nat.cast_inj] rfl _ ≃ {b : {a : idealSet K J // intNorm (idealSetEquiv K J a).1 ≤ ⌊s⌋₊} // intNorm (idealSetEquiv K J b).1 = i} := (Equiv.subtypeSubtypeEquivSubtype fun h ↦ Finset.mem_Iic.mp (h ▸ hi)).symm · simp_rw [lt_iff_not_ge.mp (lt_of_lt_of_le hs (Nat.cast_nonneg _)), lt_iff_not_ge.mp (lt_of_lt_of_le hs (mixedEmbedding.norm_nonneg _)), and_false, Nat.card_of_isEmpty, zero_mul] end fundamentalCone end end NumberField.mixedEmbedding
.lake/packages/mathlib/Mathlib/FieldTheory/AbsoluteGaloisGroup.lean
import Mathlib.FieldTheory.KrullTopology import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure import Mathlib.Topology.Algebra.Group.TopologicalAbelianization /-! # The topological abelianization of the absolute Galois group. We define the absolute Galois group of a field `K` and its topological abelianization. ## Main definitions - `Field.absoluteGaloisGroup` : The Galois group of the field extension `K^al/K`, where `K^al` is an algebraic closure of `K`. - `Field.absoluteGaloisGroupAbelianization` : The topological abelianization of `Field.absoluteGaloisGroup K`, that is, the quotient of `Field.absoluteGaloisGroup K` by the topological closure of its commutator subgroup. ## Main results - `Field.absoluteGaloisGroup.commutator_closure_isNormal` : the topological closure of the commutator of `absoluteGaloisGroup` is a normal subgroup. ## Tags field, algebraic closure, galois group, abelianization -/ namespace Field variable (K : Type*) [Field K] /-! ### The absolute Galois group -/ /-- The absolute Galois group of `K`, defined as the Galois group of the field extension `K^al/K`, where `K^al` is an algebraic closure of `K`. -/ def absoluteGaloisGroup := AlgebraicClosure K ≃ₐ[K] AlgebraicClosure K local notation "G_K" => absoluteGaloisGroup noncomputable instance : Group (G_K K) := AlgEquiv.aut /-- `absoluteGaloisGroup` is a topological space with the Krull topology. -/ noncomputable instance : TopologicalSpace (G_K K) := krullTopology K (AlgebraicClosure K) /-! ### The topological abelianization of the absolute Galois group -/ instance absoluteGaloisGroup.commutator_closure_isNormal : (commutator (G_K K)).topologicalClosure.Normal := Subgroup.is_normal_topologicalClosure (commutator (G_K K)) /-- The topological abelianization of `absoluteGaloisGroup`, that is, the quotient of `absoluteGaloisGroup` by the topological closure of its commutator subgroup. -/ abbrev absoluteGaloisGroupAbelianization := TopologicalAbelianization (G_K K) local notation "G_K_ab" => absoluteGaloisGroupAbelianization end Field
.lake/packages/mathlib/Mathlib/FieldTheory/AbelRuffini.lean
import Mathlib.GroupTheory.Solvable import Mathlib.FieldTheory.PolynomialGaloisGroup import Mathlib.RingTheory.RootsOfUnity.Basic /-! # The Abel-Ruffini Theorem This file proves one direction of the Abel-Ruffini theorem, namely that if an element is solvable by radicals, then its minimal polynomial has solvable Galois group. ## Main definitions * `solvableByRad F E` : the intermediate field of solvable-by-radicals elements ## Main results * the Abel-Ruffini Theorem `solvableByRad.isSolvable'` : An irreducible polynomial with a root that is solvable by radicals has a solvable Galois group. -/ noncomputable section open Polynomial section AbelRuffini variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] theorem gal_zero_isSolvable : IsSolvable (0 : F[X]).Gal := by infer_instance theorem gal_one_isSolvable : IsSolvable (1 : F[X]).Gal := by infer_instance theorem gal_C_isSolvable (x : F) : IsSolvable (C x).Gal := by infer_instance theorem gal_X_isSolvable : IsSolvable (X : F[X]).Gal := by infer_instance theorem gal_X_sub_C_isSolvable (x : F) : IsSolvable (X - C x).Gal := by infer_instance theorem gal_X_pow_isSolvable (n : ℕ) : IsSolvable (X ^ n : F[X]).Gal := by infer_instance theorem gal_mul_isSolvable {p q : F[X]} (_ : IsSolvable p.Gal) (_ : IsSolvable q.Gal) : IsSolvable (p * q).Gal := solvable_of_solvable_injective (Gal.restrictProd_injective p q) theorem gal_prod_isSolvable {s : Multiset F[X]} (hs : ∀ p ∈ s, IsSolvable (Gal p)) : IsSolvable s.prod.Gal := by apply Multiset.induction_on' s · exact gal_one_isSolvable · intro p t hps _ ht rw [Multiset.insert_eq_cons, Multiset.prod_cons] exact gal_mul_isSolvable (hs p hps) ht theorem gal_isSolvable_of_splits {p q : F[X]} (_ : Fact (p.Splits (algebraMap F q.SplittingField))) (hq : IsSolvable q.Gal) : IsSolvable p.Gal := haveI : IsSolvable (q.SplittingField ≃ₐ[F] q.SplittingField) := hq solvable_of_surjective (AlgEquiv.restrictNormalHom_surjective q.SplittingField) theorem gal_isSolvable_tower (p q : F[X]) (hpq : p.Splits (algebraMap F q.SplittingField)) (hp : IsSolvable p.Gal) (hq : IsSolvable (q.map (algebraMap F p.SplittingField)).Gal) : IsSolvable q.Gal := by let K := p.SplittingField let L := q.SplittingField haveI : Fact (p.Splits (algebraMap F L)) := ⟨hpq⟩ let ϕ : Gal(L/K) ≃* (q.map (algebraMap F K)).Gal := (IsSplittingField.algEquiv L (q.map (algebraMap F K))).autCongr have ϕ_inj : Function.Injective ϕ.toMonoidHom := ϕ.injective haveI : IsSolvable Gal(K/F) := hp haveI : IsSolvable Gal(L/K) := solvable_of_solvable_injective ϕ_inj exact isSolvable_of_isScalarTower F p.SplittingField q.SplittingField section GalXPowSubC theorem gal_X_pow_sub_one_isSolvable (n : ℕ) : IsSolvable (X ^ n - 1 : F[X]).Gal := by by_cases hn : n = 0 · rw [hn, pow_zero, sub_self] exact gal_zero_isSolvable have hn' : 0 < n := pos_iff_ne_zero.mpr hn have hn'' : (X ^ n - 1 : F[X]) ≠ 0 := X_pow_sub_C_ne_zero hn' 1 apply isSolvable_of_comm intro σ τ ext a ha simp only [mem_rootSet_of_ne hn'', map_sub, aeval_X_pow, aeval_one, sub_eq_zero] at ha have key : ∀ σ : (X ^ n - 1 : F[X]).Gal, ∃ m : ℕ, σ a = a ^ m := by intro σ lift n to ℕ+ using hn' exact map_rootsOfUnity_eq_pow_self σ.toAlgHom (rootsOfUnity.mkOfPowEq a ha) obtain ⟨c, hc⟩ := key σ obtain ⟨d, hd⟩ := key τ rw [σ.mul_apply, τ.mul_apply, hc, map_pow, hd, map_pow, hc, ← pow_mul, pow_mul'] theorem gal_X_pow_sub_C_isSolvable_aux (n : ℕ) (a : F) (h : (X ^ n - 1 : F[X]).Splits (RingHom.id F)) : IsSolvable (X ^ n - C a).Gal := by by_cases ha : a = 0 · rw [ha, C_0, sub_zero] exact gal_X_pow_isSolvable n have ha' : algebraMap F (X ^ n - C a).SplittingField a ≠ 0 := mt ((injective_iff_map_eq_zero _).mp (RingHom.injective _) a) ha by_cases hn : n = 0 · rw [hn, pow_zero, ← C_1, ← C_sub] exact gal_C_isSolvable (1 - a) have hn' : 0 < n := pos_iff_ne_zero.mpr hn have hn'' : X ^ n - C a ≠ 0 := X_pow_sub_C_ne_zero hn' a have hn''' : (X ^ n - 1 : F[X]) ≠ 0 := X_pow_sub_C_ne_zero hn' 1 have mem_range : ∀ {c : (X ^ n - C a).SplittingField}, (c ^ n = 1 → (∃ d, algebraMap F (X ^ n - C a).SplittingField d = c)) := fun {c} hc => RingHom.mem_range.mp (minpoly.mem_range_of_degree_eq_one F c (h.def.resolve_left hn''' (minpoly.irreducible ((SplittingField.instNormal (X ^ n - C a)).isIntegral c)) (minpoly.dvd F c (by rwa [map_id, map_sub, sub_eq_zero, aeval_X_pow, aeval_one])))) apply isSolvable_of_comm intro σ τ ext b hb rw [mem_rootSet_of_ne hn'', map_sub, aeval_X_pow, aeval_C, sub_eq_zero] at hb have hb' : b ≠ 0 := by intro hb' rw [hb', zero_pow hn] at hb exact ha' hb.symm have key : ∀ σ : (X ^ n - C a).Gal, ∃ c, σ b = b * algebraMap F _ c := by intro σ have key : (σ b / b) ^ n = 1 := by rw [div_pow, ← map_pow, hb, σ.commutes, div_self ha'] obtain ⟨c, hc⟩ := mem_range key use c rw [hc, mul_div_cancel₀ (σ b) hb'] obtain ⟨c, hc⟩ := key σ obtain ⟨d, hd⟩ := key τ rw [σ.mul_apply, τ.mul_apply, hc, map_mul, τ.commutes, hd, map_mul, σ.commutes, hc, mul_assoc, mul_assoc, mul_right_inj' hb', mul_comm] theorem splits_X_pow_sub_one_of_X_pow_sub_C {F : Type*} [Field F] {E : Type*} [Field E] (i : F →+* E) (n : ℕ) {a : F} (ha : a ≠ 0) (h : (X ^ n - C a).Splits i) : (X ^ n - 1 : F[X]).Splits i := by have ha' : i a ≠ 0 := mt ((injective_iff_map_eq_zero i).mp i.injective a) ha by_cases hn : n = 0 · rw [hn, pow_zero, sub_self] exact splits_zero i have hn' : 0 < n := pos_iff_ne_zero.mpr hn have hn'' : (X ^ n - C a).degree ≠ 0 := ne_of_eq_of_ne (degree_X_pow_sub_C hn' a) (mt WithBot.coe_eq_coe.mp hn) obtain ⟨b, hb⟩ := exists_root_of_splits i h hn'' rw [eval₂_sub, eval₂_X_pow, eval₂_C, sub_eq_zero] at hb have hb' : b ≠ 0 := by intro hb' rw [hb', zero_pow hn] at hb exact ha' hb.symm let s := ((X ^ n - C a).map i).roots have hs : _ = _ * (s.map _).prod := eq_prod_roots_of_splits h rw [leadingCoeff_X_pow_sub_C hn', RingHom.map_one, C_1, one_mul] at hs have hs' : Multiset.card s = n := (natDegree_eq_card_roots h).symm.trans natDegree_X_pow_sub_C apply @splits_of_exists_multiset F E _ _ i (X ^ n - 1) (s.map fun c : E => c / b) rw [leadingCoeff_X_pow_sub_one hn', RingHom.map_one, C_1, one_mul, Multiset.map_map] have C_mul_C : C (i a⁻¹) * C (i a) = 1 := by rw [← C_mul, ← i.map_mul, inv_mul_cancel₀ ha, i.map_one, C_1] have key1 : (X ^ n - 1 : F[X]).map i = C (i a⁻¹) * ((X ^ n - C a).map i).comp (C b * X) := by rw [Polynomial.map_sub, Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, Polynomial.map_one, sub_comp, pow_comp, X_comp, C_comp, mul_pow, ← C_pow, hb, mul_sub, ← mul_assoc, C_mul_C, one_mul] have key2 : ((fun q : E[X] => q.comp (C b * X)) ∘ fun c : E => X - C c) = fun c : E => C b * (X - C (c / b)) := by ext1 c dsimp only [Function.comp_apply] rw [sub_comp, X_comp, C_comp, mul_sub, ← C_mul, mul_div_cancel₀ c hb'] rw [key1, hs, multiset_prod_comp, Multiset.map_map, key2, Multiset.prod_map_mul, Function.const_def (α := E) (y := C b), Multiset.map_const, Multiset.prod_replicate, hs', ← C_pow, hb, ← mul_assoc, C_mul_C, one_mul] rfl theorem gal_X_pow_sub_C_isSolvable (n : ℕ) (x : F) : IsSolvable (X ^ n - C x).Gal := by by_cases hx : x = 0 · rw [hx, C_0, sub_zero] exact gal_X_pow_isSolvable n apply gal_isSolvable_tower (X ^ n - 1) (X ^ n - C x) · exact splits_X_pow_sub_one_of_X_pow_sub_C _ n hx (SplittingField.splits _) · exact gal_X_pow_sub_one_isSolvable n · rw [Polynomial.map_sub, Polynomial.map_pow, map_X, map_C] apply gal_X_pow_sub_C_isSolvable_aux have key := SplittingField.splits (X ^ n - 1 : F[X]) rwa [← splits_id_iff_splits, Polynomial.map_sub, Polynomial.map_pow, map_X, Polynomial.map_one] at key end GalXPowSubC variable (F) /-- Inductive definition of solvable by radicals -/ inductive IsSolvableByRad : E → Prop | base (α : F) : IsSolvableByRad (algebraMap F E α) | add (α β : E) : IsSolvableByRad α → IsSolvableByRad β → IsSolvableByRad (α + β) | neg (α : E) : IsSolvableByRad α → IsSolvableByRad (-α) | mul (α β : E) : IsSolvableByRad α → IsSolvableByRad β → IsSolvableByRad (α * β) | inv (α : E) : IsSolvableByRad α → IsSolvableByRad α⁻¹ | rad (α : E) (n : ℕ) (hn : n ≠ 0) : IsSolvableByRad (α ^ n) → IsSolvableByRad α variable (E) /-- The intermediate field of solvable-by-radicals elements -/ def solvableByRad : IntermediateField F E where carrier := IsSolvableByRad F zero_mem' := by change IsSolvableByRad F 0 convert IsSolvableByRad.base (E := E) (0 : F); rw [RingHom.map_zero] add_mem' := by apply IsSolvableByRad.add one_mem' := by change IsSolvableByRad F 1 convert IsSolvableByRad.base (E := E) (1 : F); rw [RingHom.map_one] mul_mem' := by apply IsSolvableByRad.mul inv_mem' := IsSolvableByRad.inv algebraMap_mem' := IsSolvableByRad.base namespace solvableByRad variable {F} {E} {α : E} theorem induction (P : solvableByRad F E → Prop) (base : ∀ α : F, P (algebraMap F (solvableByRad F E) α)) (add : ∀ α β : solvableByRad F E, P α → P β → P (α + β)) (neg : ∀ α : solvableByRad F E, P α → P (-α)) (mul : ∀ α β : solvableByRad F E, P α → P β → P (α * β)) (inv : ∀ α : solvableByRad F E, P α → P α⁻¹) (rad : ∀ α : solvableByRad F E, ∀ n : ℕ, n ≠ 0 → P (α ^ n) → P α) (α : solvableByRad F E) : P α := by revert α suffices ∀ α : E, IsSolvableByRad F α → ∃ β : solvableByRad F E, ↑β = α ∧ P β by intro α obtain ⟨α₀, hα₀, Pα⟩ := this α (Subtype.mem α) convert Pα exact Subtype.ext hα₀.symm apply IsSolvableByRad.rec · exact fun α => ⟨algebraMap F (solvableByRad F E) α, rfl, base α⟩ · intro α β _ _ Pα Pβ obtain ⟨⟨α₀, hα₀, Pα⟩, β₀, hβ₀, Pβ⟩ := Pα, Pβ exact ⟨α₀ + β₀, by rw [← hα₀, ← hβ₀]; rfl, add α₀ β₀ Pα Pβ⟩ · intro α _ Pα obtain ⟨α₀, hα₀, Pα⟩ := Pα exact ⟨-α₀, by rw [← hα₀]; rfl, neg α₀ Pα⟩ · intro α β _ _ Pα Pβ obtain ⟨⟨α₀, hα₀, Pα⟩, β₀, hβ₀, Pβ⟩ := Pα, Pβ exact ⟨α₀ * β₀, by rw [← hα₀, ← hβ₀]; rfl, mul α₀ β₀ Pα Pβ⟩ · intro α _ Pα obtain ⟨α₀, hα₀, Pα⟩ := Pα exact ⟨α₀⁻¹, by rw [← hα₀]; rfl, inv α₀ Pα⟩ · intro α n hn hα Pα obtain ⟨α₀, hα₀, Pα⟩ := Pα refine ⟨⟨α, IsSolvableByRad.rad α n hn hα⟩, rfl, rad _ n hn ?_⟩ convert Pα exact Subtype.ext (Eq.trans ((solvableByRad F E).coe_pow _ n) hα₀.symm) theorem isIntegral (α : solvableByRad F E) : IsIntegral F α := by revert α apply solvableByRad.induction · exact fun _ => isIntegral_algebraMap · exact fun _ _ => IsIntegral.add · exact fun _ => IsIntegral.neg · exact fun _ _ => IsIntegral.mul · intro α hα exact IsIntegral.inv hα · intro α n hn hα obtain ⟨p, h1, h2⟩ := hα.isAlgebraic refine IsAlgebraic.isIntegral ⟨p.comp (X ^ n), ⟨fun h => h1 (leadingCoeff_eq_zero.mp ?_), by rw [aeval_comp, aeval_X_pow, h2]⟩⟩ rwa [← leadingCoeff_eq_zero, leadingCoeff_comp, leadingCoeff_X_pow, one_pow, mul_one] at h rwa [natDegree_X_pow] /-- The statement to be proved inductively -/ def P (α : solvableByRad F E) : Prop := IsSolvable (minpoly F α).Gal /-- An auxiliary induction lemma, which is generalized by `solvableByRad.isSolvable`. -/ theorem induction3 {α : solvableByRad F E} {n : ℕ} (hn : n ≠ 0) (hα : P (α ^ n)) : P α := by let p := minpoly F (α ^ n) have hp : p.comp (X ^ n) ≠ 0 := by intro h rcases comp_eq_zero_iff.mp h with h' | h' · exact minpoly.ne_zero (isIntegral (α ^ n)) h' · exact hn (by rw [← @natDegree_C F, ← h'.2, natDegree_X_pow]) apply gal_isSolvable_of_splits · exact ⟨splits_of_splits_of_dvd _ hp (SplittingField.splits (p.comp (X ^ n))) (minpoly.dvd F α (by rw [aeval_comp, aeval_X_pow, minpoly.aeval]))⟩ · refine gal_isSolvable_tower p (p.comp (X ^ n)) ?_ hα ?_ · exact Gal.splits_in_splittingField_of_comp _ _ (by rwa [natDegree_X_pow]) · obtain ⟨s, hs⟩ := (splits_iff_exists_multiset _).1 (SplittingField.splits p) rw [map_comp, Polynomial.map_pow, map_X, hs, mul_comp, C_comp] apply gal_mul_isSolvable (gal_C_isSolvable _) rw [multiset_prod_comp] apply gal_prod_isSolvable intro q hq rw [Multiset.mem_map] at hq obtain ⟨q, hq, rfl⟩ := hq rw [Multiset.mem_map] at hq obtain ⟨q, _, rfl⟩ := hq rw [sub_comp, X_comp, C_comp] exact gal_X_pow_sub_C_isSolvable n q open IntermediateField /-- An auxiliary induction lemma, which is generalized by `solvableByRad.isSolvable`. -/ theorem induction2 {α β γ : solvableByRad F E} (hγ : γ ∈ F⟮α, β⟯) (hα : P α) (hβ : P β) : P γ := by let p := minpoly F α let q := minpoly F β have hpq := Polynomial.splits_of_splits_mul _ (mul_ne_zero (minpoly.ne_zero (isIntegral α)) (minpoly.ne_zero (isIntegral β))) (SplittingField.splits (p * q)) let f : ↥F⟮α, β⟯ →ₐ[F] (p * q).SplittingField := Classical.choice <| nonempty_algHom_adjoin_of_splits <| by intro x hx simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx cases hx with rw [hx] | inl hx => exact ⟨isIntegral α, hpq.1⟩ | inr hx => exact ⟨isIntegral β, hpq.2⟩ have key : minpoly F γ = minpoly F (f ⟨γ, hγ⟩) := by refine minpoly.eq_of_irreducible_of_monic (minpoly.irreducible (isIntegral γ)) ?_ (minpoly.monic (isIntegral γ)) rw [aeval_algHom_apply, map_eq_zero] apply (algebraMap (↥F⟮α, β⟯) (solvableByRad F E)).injective simp only [map_zero, ← aeval_algebraMap_apply] exact minpoly.aeval F γ rw [P, key] refine gal_isSolvable_of_splits ⟨Normal.splits ?_ (f ⟨γ, hγ⟩)⟩ (gal_mul_isSolvable hα hβ) apply SplittingField.instNormal /-- An auxiliary induction lemma, which is generalized by `solvableByRad.isSolvable`. -/ theorem induction1 {α β : solvableByRad F E} (hβ : β ∈ F⟮α⟯) (hα : P α) : P β := induction2 (adjoin.mono F _ _ (ge_of_eq (Set.pair_eq_singleton α)) hβ) hα hα theorem isSolvable (α : solvableByRad F E) : IsSolvable (minpoly F α).Gal := by revert α apply solvableByRad.induction · exact fun α => by rw [minpoly.eq_X_sub_C (solvableByRad F E)]; exact gal_X_sub_C_isSolvable α · exact fun α β => induction2 (add_mem (subset_adjoin F _ (Set.mem_insert α _)) (subset_adjoin F _ (Set.mem_insert_of_mem α (Set.mem_singleton β)))) · exact fun α => induction1 (neg_mem (mem_adjoin_simple_self F α)) · exact fun α β => induction2 (mul_mem (subset_adjoin F _ (Set.mem_insert α _)) (subset_adjoin F _ (Set.mem_insert_of_mem α (Set.mem_singleton β)))) · exact fun α => induction1 (inv_mem (mem_adjoin_simple_self F α)) · exact fun α n => induction3 /-- **Abel-Ruffini Theorem** (one direction): An irreducible polynomial with an `IsSolvableByRad` root has solvable Galois group -/ theorem isSolvable' {α : E} {q : F[X]} (q_irred : Irreducible q) (q_aeval : aeval α q = 0) (hα : IsSolvableByRad F α) : IsSolvable q.Gal := by have : _root_.IsSolvable (q * C q.leadingCoeff⁻¹).Gal := by rw [minpoly.eq_of_irreducible q_irred q_aeval, ← show minpoly F (⟨α, hα⟩ : solvableByRad F E) = minpoly F α from (minpoly.algebraMap_eq (RingHom.injective _) _).symm] exact isSolvable ⟨α, hα⟩ refine solvable_of_surjective (Gal.restrictDvd_surjective ⟨C q.leadingCoeff⁻¹, rfl⟩ ?_) rw [mul_ne_zero_iff, Ne, Ne, C_eq_zero, inv_eq_zero] exact ⟨q_irred.ne_zero, leadingCoeff_ne_zero.mpr q_irred.ne_zero⟩ end solvableByRad end AbelRuffini
.lake/packages/mathlib/Mathlib/FieldTheory/AxGrothendieck.lean
import Mathlib.RingTheory.Algebraic.Basic import Mathlib.Data.Fintype.Pigeonhole import Mathlib.ModelTheory.Algebra.Field.IsAlgClosed import Mathlib.ModelTheory.Algebra.Ring.Definability import Mathlib.RingTheory.Polynomial.Basic /-! # Ax-Grothendieck This file proves that if `K` is an algebraically closed field, then any injective polynomial map `K^n → K^n` is also surjective. ## Main results * `ax_grothendieck_zeroLocus`: If `K` is algebraically closed, `ι` is a finite type, and `S : Set (ι → K)` is the `zeroLocus` of some ideal of `MvPolynomial ι K`, then any injective polynomial map `S → S` is also surjective on `S`. * `ax_grothendieck_univ`: Any injective polynomial map `K^n → K^n` is also surjective if `K` is an algebraically closed field. * `ax_grothendieck_of_definable`: Any injective polynomial map `S → S` is also surjective on `S` if `K` is an algebraically closed field and `S` is a definable subset of `K^n`. * `ax_grothendieck_of_locally_finite`: any injective polynomial map `R^n → R^n` is also surjective whenever `R` is an algebraic extension of a finite field. ## References The first-order theory of algebraically closed fields, along with the Lefschetz Principle and the Ax-Grothendieck Theorem were first formalized in Lean 3 by Joseph Hua [here](https://github.com/Jlh18/ModelTheoryInLean8) with the master's thesis [here](https://github.com/Jlh18/ModelTheory8Report) -/ noncomputable section open MvPolynomial Finset /-- Any injective polynomial map over an algebraic extension of a finite field is surjective. -/ theorem ax_grothendieck_of_locally_finite {ι K R : Type*} [Field K] [Finite K] [CommRing R] [Finite ι] [Algebra K R] [alg : Algebra.IsAlgebraic K R] (ps : ι → MvPolynomial ι R) (S : Set (ι → R)) (hm : S.MapsTo (fun v i => eval v (ps i)) S) (hinj : S.InjOn (fun v i => eval v (ps i))) : S.SurjOn (fun v i => eval v (ps i)) S := by have is_int : ∀ x : R, IsIntegral K x := fun x => isAlgebraic_iff_isIntegral.1 (alg.isAlgebraic x) classical intro v hvS cases nonempty_fintype ι /- `s` is the set of all coefficients of the polynomial, as well as all of the coordinates of `v`, the point I am trying to find the preimage of. -/ let s : Finset R := (Finset.biUnion (univ : Finset ι) fun i => (ps i).support.image fun x => coeff x (ps i)) ∪ (univ : Finset ι).image v have hv : ∀ i, v i ∈ Algebra.adjoin K (s : Set R) := fun j => Algebra.subset_adjoin (mem_union_right _ (mem_image.2 ⟨j, mem_univ _, rfl⟩)) have hs₁ : ∀ (i : ι) (k : ι →₀ ℕ), k ∈ (ps i).support → coeff k (ps i) ∈ Algebra.adjoin K (s : Set R) := fun i k hk => Algebra.subset_adjoin (mem_union_left _ (mem_biUnion.2 ⟨i, mem_univ _, mem_image_of_mem _ hk⟩)) have := isNoetherian_adjoin_finset s fun x _ => is_int x have : Finite (Algebra.adjoin K (s : Set R)) := Module.finite_of_finite K -- The restriction of the polynomial map, `ps`, to the subalgebra generated by `s` let S' : Set (ι → Algebra.adjoin K (s : Set R)) := (fun v => Subtype.val ∘ v) ⁻¹' S let res : S' → S' := fun x => ⟨fun i => ⟨eval (fun j : ι => (x.1 j : R)) (ps i), eval_mem (hs₁ _) fun i => (x.1 i).2⟩, hm x.2⟩ have hres_surj : Function.Surjective res := by rw [← Finite.injective_iff_surjective] intro x y hxy ext i simp only [Subtype.ext_iff, funext_iff] at hxy exact congr_fun (hinj x.2 y.2 (funext hxy)) i rcases hres_surj ⟨fun i => ⟨v i, hv i⟩, hvS⟩ with ⟨⟨w, hwS'⟩, hw⟩ refine ⟨fun i => w i, hwS', ?_⟩ simpa [Subtype.ext_iff, funext_iff] using hw end namespace FirstOrder open MvPolynomial FreeCommRing Language Field Ring BoundedFormula variable {ι α : Type*} [Finite α] {K : Type*} [Field K] [CompatibleRing K] /-- The collection of first-order formulas corresponding to the Ax-Grothendieck theorem. -/ noncomputable def genericPolyMapSurjOnOfInjOn [Finite ι] (φ : ring.Formula (α ⊕ ι)) (mons : ι → Finset (ι →₀ ℕ)) : Language.ring.Sentence := let l1 : ι → Language.ring.Formula ((Σ i : ι, mons i) ⊕ (Fin 2 × ι)) := fun i => (termOfFreeCommRing (genericPolyMap mons i)).relabel (Sum.inl ∘ Sum.map id (fun i => (0, i))) =' (termOfFreeCommRing (genericPolyMap mons i)).relabel (Sum.inl ∘ Sum.map id (fun i => (1, i))) -- p(x) = p(y) as a formula let f1 : Language.ring.Formula ((Σ i : ι, mons i) ⊕ (Fin 2 × ι)) := iInf l1 let l2 : ι → Language.ring.Formula ((Σ i : ι, mons i) ⊕ (Fin 2 × ι)) := fun i => .var (Sum.inl (Sum.inr (0, i))) =' .var (Sum.inl (Sum.inr (1, i))) -- x = y as a formula let f2 : Language.ring.Formula ((Σ i : ι, mons i) ⊕ (Fin 2 × ι)) := iInf l2 let injOn : Language.ring.Formula (α ⊕ Σ i : ι, mons i) := Formula.iAlls (Fin 2 × ι) (φ.relabel (Sum.map Sum.inl (fun i => (0, i))) ⟹ φ.relabel (Sum.map Sum.inl (fun i => (1, i))) ⟹ (f1.imp f2).relabel (fun x => (Equiv.sumAssoc _ _ _).symm (Sum.inr x))) let l3 : ι → Language.ring.Formula ((Σ i : ι, mons i) ⊕ (Fin 2 × ι)) := fun i => (termOfFreeCommRing (genericPolyMap mons i)).relabel (Sum.inl ∘ Sum.map id (fun i => (0, i))) =' .var (Sum.inl (Sum.inr (1, i))) let f3 : Language.ring.Formula ((Σ i : ι, mons i) ⊕ (Fin 2 × ι)) := iInf l3 let surjOn : Language.ring.Formula (α ⊕ Σ i : ι, mons i) := Formula.iAlls ι (Formula.imp (φ.relabel (Sum.map Sum.inl id)) <| Formula.iExs ι <| ((φ.relabel (Sum.map Sum.inl (fun i => (0, i)))) ⊓ (f3.relabel (fun x => (Equiv.sumAssoc _ _ _).symm (Sum.inr x)))).relabel (fun (i : (α ⊕ (Σ i : ι, mons i)) ⊕ (Fin 2 × ι)) => show ((α ⊕ (Σ i : ι, mons i)) ⊕ ι) ⊕ ι from Sum.elim (Sum.inl ∘ Sum.inl) (fun i => if i.1 = 0 then Sum.inr i.2 else (Sum.inl (Sum.inr i.2))) i)) let mapsTo : Language.ring.Formula (α ⊕ Σ i : ι, mons i) := Formula.iAlls ι (Formula.imp (φ.relabel (Sum.map Sum.inl id)) (φ.subst <| Sum.elim (fun a => .var (Sum.inl (Sum.inl a))) (fun i => (termOfFreeCommRing (genericPolyMap mons i)).relabel (fun i => (Equiv.sumAssoc _ _ _).symm (Sum.inr i))))) Formula.iAlls (α ⊕ Σ i : ι, mons i) ((mapsTo.imp <| injOn.imp <| surjOn).relabel Sum.inr) theorem realize_genericPolyMapSurjOnOfInjOn [Finite ι] (φ : ring.Formula (α ⊕ ι)) (mons : ι → Finset (ι →₀ ℕ)) : (K ⊨ genericPolyMapSurjOnOfInjOn φ mons) ↔ ∀ (v : α → K) (p : { p : ι → MvPolynomial ι K // (∀ i, (p i).support ⊆ mons i) }), let f : (ι → K) → (ι → K) := fun v i => eval v (p.1 i) let S : Set (ι → K) := {x | φ.Realize (Sum.elim v x)} S.MapsTo f S → S.InjOn f → S.SurjOn f S := by classical have injOnAlt : ∀ {S : Set (ι → K)} (f : (ι → K) → (ι → K)), S.InjOn f ↔ ∀ x y, x ∈ S → y ∈ S → f x = f y → x = y := by simp [Set.InjOn]; tauto simp only [Sentence.Realize, Formula.Realize, genericPolyMapSurjOnOfInjOn, Formula.relabel, Function.comp_def, Sum.map, id_eq, Equiv.sumAssoc, Equiv.coe_fn_symm_mk, Sum.elim_inr, realize_iAlls, realize_imp, realize_relabel, Fin.natAdd_zero, realize_subst, realize_iInf, realize_bdEqual, Term.realize_relabel, Equiv.forall_congr_left (Equiv.curry (Fin 2) ι K), Equiv.curry_symm_apply, Fin.forall_fin_succ_pi, Fin.forall_fin_zero_pi, realize_iExs, realize_inf, Sum.forall_sum, Set.MapsTo, Set.mem_setOf_eq, injOnAlt, funext_iff, Set.SurjOn, Set.image, Set.subset_def, Equiv.forall_congr_left (mvPolynomialSupportLEEquiv mons)] simp +singlePass only [← Sum.elim_comp_inl_inr] -- was `simp` and very slow (https://github.com/leanprover-community/mathlib4/issues/19751) simp only [Function.comp_def, Sum.elim_inl, Sum.elim_inr, Fin.castAdd_zero, Fin.cast_eq_self, Nat.add_zero, Term.realize_var, Term.realize_relabel, realize_termOfFreeCommRing, lift_genericPolyMap, Nat.reduceAdd, Fin.isValue, Function.uncurry_apply_pair, Fin.cons_zero, Fin.cons_one, ↓reduceIte, one_ne_zero] theorem ACF_models_genericPolyMapSurjOnOfInjOn_of_prime [Finite ι] {p : ℕ} (hp : p.Prime) (φ : ring.Formula (α ⊕ ι)) (mons : ι → Finset (ι →₀ ℕ)) : Theory.ACF p ⊨ᵇ genericPolyMapSurjOnOfInjOn φ mons := by classical have : Fact p.Prime := ⟨hp⟩ letI := compatibleRingOfRing (AlgebraicClosure (ZMod p)) rw [← (ACF_isComplete (Or.inl hp)).realize_sentence_iff _ (AlgebraicClosure (ZMod p)), realize_genericPolyMapSurjOnOfInjOn] rintro v ⟨f, _⟩ exact ax_grothendieck_of_locally_finite (K := ZMod p) (ι := ι) f _ theorem ACF_models_genericPolyMapSurjOnOfInjOn_of_prime_or_zero [Finite ι] {p : ℕ} (hp : p.Prime ∨ p = 0) (φ : ring.Formula (α ⊕ ι)) (mons : ι → Finset (ι →₀ ℕ)) : Theory.ACF p ⊨ᵇ genericPolyMapSurjOnOfInjOn φ mons := by rcases hp with hp | rfl · exact ACF_models_genericPolyMapSurjOnOfInjOn_of_prime hp φ mons · rw [ACF_zero_realize_iff_infinite_ACF_prime_realize] convert Set.infinite_univ (α := Nat.Primes) rw [Set.eq_univ_iff_forall] intro ⟨p, hp⟩ exact ACF_models_genericPolyMapSurjOnOfInjOn_of_prime hp φ mons end FirstOrder open FirstOrder Language Field Ring MvPolynomial variable {K ι : Type*} [Field K] [IsAlgClosed K] [Finite ι] /-- A slight generalization of the **Ax-Grothendieck** theorem If `K` is an algebraically closed field, `ι` is a finite type, and `S` is a definable subset of `ι → K`, then any injective polynomial map `S → S` is also surjective on `S`. -/ theorem ax_grothendieck_of_definable [CompatibleRing K] {c : Set K} (S : Set (ι → K)) (hS : c.Definable Language.ring S) (ps : ι → MvPolynomial ι K) : S.MapsTo (fun v i => eval v (ps i)) S → S.InjOn (fun v i => eval v (ps i)) → S.SurjOn (fun v i => eval v (ps i)) S := by letI := Fintype.ofFinite ι let p : ℕ := ringChar K rw [Set.definable_iff_finitely_definable] at hS rcases hS with ⟨c, _, hS⟩ rw [Set.definable_iff_exists_formula_sum] at hS rcases hS with ⟨φ, hφ⟩ rw [hφ] have := ACF_models_genericPolyMapSurjOnOfInjOn_of_prime_or_zero (CharP.char_is_prime_or_zero K p) φ (fun i => (ps i).support) rw [← (ACF_isComplete (CharP.char_is_prime_or_zero K p)).realize_sentence_iff _ K, realize_genericPolyMapSurjOnOfInjOn] at this exact this Subtype.val ⟨ps, fun i => Set.Subset.refl _⟩ /-- The **Ax-Grothendieck** theorem If `K` is an algebraically closed field, and `S : Set (ι → K)` is the `zeroLocus` of an ideal of the multivariable polynomial ring, then any injective polynomial map `S → S` is also surjective on `S`. -/ theorem ax_grothendieck_zeroLocus (I : Ideal (MvPolynomial ι K)) (p : ι → MvPolynomial ι K) : let S := zeroLocus K I S.MapsTo (fun v i => eval v (p i)) S → S.InjOn (fun v i => eval v (p i)) → S.SurjOn (fun v i => eval v (p i)) S := by letI := compatibleRingOfRing K intro S obtain ⟨s, rfl⟩ : I.FG := IsNoetherian.noetherian I exact ax_grothendieck_of_definable S (mvPolynomial_zeroLocus_definable s) p /-- A special case of the **Ax-Grothendieck** theorem Any injective polynomial map `K^n → K^n` is also surjective if `K` is an algebraically closed field. -/ theorem ax_grothendieck_univ (p : ι → MvPolynomial ι K) : (fun v i => eval v (p i)).Injective → (fun v i => eval v (p i)).Surjective := by simpa using ax_grothendieck_zeroLocus 0 p
.lake/packages/mathlib/Mathlib/FieldTheory/JacobsonNoether.lean
import Mathlib.Algebra.Central.Defs import Mathlib.Algebra.CharP.LinearMaps import Mathlib.Algebra.CharP.Subring import Mathlib.Algebra.GroupWithZero.Conj import Mathlib.Algebra.Lie.OfAssociative import Mathlib.FieldTheory.PurelyInseparable.Basic /-! # The Jacobson-Noether theorem This file contains a proof of the Jacobson-Noether theorem and some auxiliary lemmas. Here we discuss different cases of characteristics of the noncommutative division algebra `D` with center `k`. ## Main Results - `exists_separable_and_not_isCentral` : (Jacobson-Noether theorem) For a non-commutative algebraic division algebra `D` (with base ring being its center `k`), then there exist an element `x` of `D \ k` that is separable over its center. - `exists_separable_and_not_isCentral'` : (Jacobson-Noether theorem) For a non-commutative algebraic division algebra `D` (with base ring being a field `L`), if the center of `D` over `L` is `L`, then there exist an element `x` of `D \ L` that is separable over `L`. ## Notation - `D` is a noncommutative division algebra - `k` is the center of `D` ## Implementation Notes Mathematically, `exists_separable_and_not_isCentral` and `exists_separable_and_not_isCentral'` are equivalent. The difference however, is that the former takes `D` as the only variable and fixing `D` would forces `k`. Whereas the later takes `D` and `L` as separate variables constrained by certain relations. ## Reference * <https://ysharifi.wordpress.com/2011/09/30/the-jacobson-noether-theorem/> -/ namespace JacobsonNoether variable {D : Type*} [DivisionRing D] [Algebra.IsAlgebraic (Subring.center D) D] local notation3 "k" => Subring.center D open Polynomial LinearMap LieAlgebra /-- If `D` is a purely inseparable extension of `k` with characteristic `p`, then for every element `a` of `D`, there exists a natural number `n` such that `a ^ (p ^ n)` is contained in `k`. -/ lemma exists_pow_mem_center_of_inseparable (p : ℕ) [hchar : ExpChar D p] (a : D) (hinsep : ∀ x : D, IsSeparable k x → x ∈ k) : ∃ n, a ^ (p ^ n) ∈ k := by have := (@isPurelyInseparable_iff_pow_mem k D _ _ _ _ p (ExpChar.expChar_center_iff.2 hchar)).1 have pure : IsPurelyInseparable k D := ⟨Algebra.IsAlgebraic.isIntegral, fun x hx ↦ by rw [RingHom.mem_range, Subtype.exists] exact ⟨x, ⟨hinsep x hx, rfl⟩⟩⟩ obtain ⟨n, ⟨m, hm⟩⟩ := this pure a have := Subalgebra.range_subset (R := k) ⟨(k).toSubsemiring, fun r ↦ r.2⟩ exact ⟨n, Set.mem_of_subset_of_mem this <| Set.mem_range.2 ⟨m, hm⟩⟩ /-- If `D` is a purely inseparable extension of `k` with characteristic `p`, then for every element `a` of `D \ k`, there exists a natural number `n` **greater than 0** such that `a ^ (p ^ n)` is contained in `k`. -/ lemma exists_pow_mem_center_of_inseparable' (p : ℕ) [ExpChar D p] {a : D} (ha : a ∉ k) (hinsep : ∀ x : D, IsSeparable k x → x ∈ k) : ∃ n, 1 ≤ n ∧ a ^ (p ^ n) ∈ k := by obtain ⟨n, hn⟩ := exists_pow_mem_center_of_inseparable p a hinsep have nzero : n ≠ 0 := by rintro rfl rw [pow_zero, pow_one] at hn exact ha hn exact ⟨n, ⟨Nat.one_le_iff_ne_zero.mpr nzero, hn⟩⟩ /-- If `D` is a purely inseparable extension of `k` of characteristic `p`, then for every element `a` of `D \ k`, there exists a natural number `m` greater than 0 such that `(a * x - x * a) ^ n = 0` (as linear maps) for every `n` greater than `(p ^ m)`. -/ lemma exist_pow_eq_zero_of_le (p : ℕ) [hchar : ExpChar D p] {a : D} (ha : a ∉ k) (hinsep : ∀ x : D, IsSeparable k x → x ∈ k): ∃ m, 1 ≤ m ∧ ∀ n, p ^ m ≤ n → (ad k D a)^[n] = 0 := by obtain ⟨m, hm⟩ := exists_pow_mem_center_of_inseparable' p ha hinsep refine ⟨m, ⟨hm.1, fun n hn ↦ ?_⟩⟩ have inter : (ad k D a)^[p ^ m] = 0 := by ext x rw [ad_eq_lmul_left_sub_lmul_right, ← Module.End.pow_apply, Pi.sub_apply, sub_pow_expChar_pow_of_commute p m (commute_mulLeft_right a a), sub_apply, pow_mulLeft, mulLeft_apply, pow_mulRight, mulRight_apply, Pi.zero_apply, Subring.mem_center_iff.1 hm.2 x] exact sub_eq_zero_of_eq rfl rw [(Nat.sub_eq_iff_eq_add hn).1 rfl, Function.iterate_add, inter, Pi.comp_zero, iterate_map_zero, Function.const_zero] variable (D) in /-- Jacobson-Noether theorem: For a non-commutative division algebra `D` that is algebraic over its center `k`, there exists an element `x` of `D \ k` that is separable over `k`. -/ theorem exists_separable_and_not_isCentral (H : k ≠ (⊤ : Subring D)) : ∃ x : D, x ∉ k ∧ IsSeparable k x := by obtain ⟨p, hp⟩ := ExpChar.exists D by_contra! insep replace insep : ∀ x : D, IsSeparable k x → x ∈ k := fun x h ↦ Classical.byContradiction fun hx ↦ insep x hx h -- The element `a` below is in `D` but not in `k`. obtain ⟨a, ha⟩ := not_forall.mp <| mt (Subring.eq_top_iff' k).mpr H have ha₀ : a ≠ 0 := fun nh ↦ nh ▸ ha <| Subring.zero_mem k -- We construct another element `b` that does not commute with `a`. obtain ⟨b, hb1⟩ : ∃ b : D, ad k D a b ≠ 0 := by rw [Subring.mem_center_iff, not_forall] at ha use ha.choose change a * ha.choose - ha.choose * a ≠ 0 simpa only [ne_eq, sub_eq_zero] using Ne.symm ha.choose_spec -- We find a maximum natural number `n` such that `(a * x - x * a) ^ n b ≠ 0`. obtain ⟨n, hn, hb⟩ : ∃ n, 0 < n ∧ (ad k D a)^[n] b ≠ 0 ∧ (ad k D a)^[n+1] b = 0 := by obtain ⟨m, -, hm2⟩ := exist_pow_eq_zero_of_le p ha insep have h_exist : ∃ n, 0 < n ∧ (ad k D a)^[n+1] b = 0 := ⟨p ^ m, ⟨expChar_pow_pos D p m, by rw [hm2 (p ^ m + 1) (Nat.le_add_right _ _), Pi.zero_apply]⟩⟩ classical refine ⟨Nat.find h_exist, ⟨(Nat.find_spec h_exist).1, ?_, (Nat.find_spec h_exist).2⟩⟩ set t := (Nat.find h_exist - 1 : ℕ) with ht by_cases! h_pos : 0 < t · convert (ne_eq _ _) ▸ not_and.mp (Nat.find_min h_exist (m := t) (by cutsat)) h_pos cutsat · suffices h_find: Nat.find h_exist = 1 by rwa [h_find] rw [Nat.le_zero, ht, Nat.sub_eq_zero_iff_le] at h_pos linarith [(Nat.find_spec h_exist).1] -- We define `c` to be the value that we proved above to be non-zero. set c := (ad k D a)^[n] b with hc_def let _ : Invertible c := ⟨c⁻¹, inv_mul_cancel₀ hb.1, mul_inv_cancel₀ hb.1⟩ -- We prove that `c` commutes with `a`. have hc : a * c = c * a := by apply eq_of_sub_eq_zero rw [← mulLeft_apply (R := k), ← mulRight_apply (R := k)] suffices ad k D a c = 0 from by rw [← this]; simp [LieRing.of_associative_ring_bracket] rw [← Function.iterate_succ_apply' (ad k D a) n b, hb.2] -- We now make some computation to obtain the final equation. set d := c⁻¹ * a * (ad k D a)^[n - 1] b with hd_def have hc': c⁻¹ * a = a * c⁻¹ := by apply_fun (c⁻¹ * · * c⁻¹) at hc rw [mul_assoc, mul_assoc, mul_inv_cancel₀ hb.1, mul_one, ← mul_assoc, inv_mul_cancel₀ hb.1, one_mul] at hc exact hc have c_eq : a * (ad k D a)^[n - 1] b - (ad k D a)^[n - 1] b * a = c := by rw [hc_def, ← Nat.sub_add_cancel hn, Function.iterate_succ_apply' (ad k D a) _ b]; rfl have eq1 : c⁻¹ * a * (ad k D a)^[n - 1] b - c⁻¹ * (ad k D a)^[n - 1] b * a = 1 := by simp_rw [mul_assoc, (mul_sub_left_distrib c⁻¹ _ _).symm, c_eq, inv_mul_cancel_of_invertible] -- We show that `a` commutes with `d`. have deq : a * d - d * a = a := by nth_rw 3 [← mul_one a] rw [hd_def, ← eq1, mul_sub, mul_assoc _ _ a, sub_right_inj, hc', ← mul_assoc, ← mul_assoc, ← mul_assoc] -- This then yields a contradiction. apply_fun (a⁻¹ * · ) at deq rw [mul_sub, ← mul_assoc, inv_mul_cancel₀ ha₀, one_mul, ← mul_assoc, sub_eq_iff_eq_add] at deq obtain ⟨r, hr⟩ := exists_pow_mem_center_of_inseparable p d insep apply_fun (· ^ (p ^ r)) at deq rw [add_pow_expChar_pow_of_commute p r (Commute.one_left _), one_pow, GroupWithZero.conj_pow₀ ha₀, ← hr.comm, mul_assoc, inv_mul_cancel₀ ha₀, mul_one, right_eq_add] at deq exact one_ne_zero deq open Subring Algebra in /-- Jacobson-Noether theorem: For a non-commutative division algebra `D` that is algebraic over a field `L`, if the center of `D` coincides with `L`, then there exist an element `x` of `D \ L` that is separable over `L`. -/ theorem exists_separable_and_not_isCentral' {L D : Type*} [Field L] [DivisionRing D] [Algebra L D] [Algebra.IsAlgebraic L D] [Algebra.IsCentral L D] (hneq : (⊥ : Subalgebra L D) ≠ ⊤) : ∃ x : D, x ∉ (⊥ : Subalgebra L D) ∧ IsSeparable L x := by have hcenter : Subalgebra.center L D = ⊥ := le_bot_iff.mp IsCentral.out have ntrivial : Subring.center D ≠ ⊤ := congr(Subalgebra.toSubring $hcenter).trans_ne (Subalgebra.toSubring_injective.ne hneq) set φ := Subalgebra.equivOfEq (⊥ : Subalgebra L D) (.center L D) hcenter.symm set equiv : L ≃+* (center D) := ((botEquiv L D).symm.trans φ).toRingEquiv let _ : Algebra L (center D) := equiv.toRingHom.toAlgebra let _ : Algebra (center D) L := equiv.symm.toRingHom.toAlgebra have _ : IsScalarTower L (center D) D := .of_algebraMap_eq fun _ ↦ rfl have _ : IsScalarTower (center D) L D := .of_algebraMap_eq fun x ↦ by rw [IsScalarTower.algebraMap_apply L (center D)] congr exact (equiv.apply_symm_apply x).symm have _ : Algebra.IsAlgebraic (center D) D := .tower_top (K := L) _ obtain ⟨x, hxd, hx⟩ := exists_separable_and_not_isCentral D ntrivial exact ⟨x, ⟨by rwa [← Subalgebra.center_toSubring L, hcenter] at hxd, IsSeparable.tower_top _ hx⟩⟩ end JacobsonNoether
.lake/packages/mathlib/Mathlib/FieldTheory/Laurent.lean
import Mathlib.Algebra.Polynomial.Taylor import Mathlib.FieldTheory.RatFunc.AsPolynomial /-! # Laurent expansions of rational functions ## Main declarations * `RatFunc.laurent`: the Laurent expansion of the rational function `f` at `r`, as an `AlgHom`. * `RatFunc.laurent_injective`: the Laurent expansion at `r` is unique ## Implementation details Implemented as the quotient of two Taylor expansions, over domains. An auxiliary definition is provided first to make the construction of the `AlgHom` easier, which works on `CommRing` which are not necessarily domains. -/ universe u namespace RatFunc noncomputable section open Polynomial open scoped nonZeroDivisors variable {R : Type u} [CommRing R] (r s : R) (p q : R[X]) (f : RatFunc R) theorem taylor_mem_nonZeroDivisors (hp : p ∈ R[X]⁰) : taylor r p ∈ R[X]⁰ := by rw [mem_nonZeroDivisors_iff_right] intro x hx have : x = taylor (r - r) x := by simp rwa [this, sub_eq_add_neg, ← taylor_taylor, ← taylor_mul, LinearMap.map_eq_zero_iff _ (taylor_injective _), mul_right_mem_nonZeroDivisors_eq_zero_iff hp, LinearMap.map_eq_zero_iff _ (taylor_injective _)] at hx /-- The Laurent expansion of rational functions about a value. Auxiliary definition, usage when over integral domains should prefer `RatFunc.laurent`. -/ def laurentAux : RatFunc R →+* RatFunc R := RatFunc.mapRingHom ( { toFun := taylor r map_add' := map_add (taylor r) map_mul' := taylor_mul _ map_zero' := map_zero (taylor r) map_one' := taylor_one r } : R[X] →+* R[X]) (taylor_mem_nonZeroDivisors _) theorem laurentAux_ofFractionRing_mk (q : R[X]⁰) : laurentAux r (ofFractionRing (Localization.mk p q)) = ofFractionRing (.mk (taylor r p) ⟨taylor r q, taylor_mem_nonZeroDivisors r q q.prop⟩) := map_apply_ofFractionRing_mk _ _ _ _ variable [IsDomain R] theorem laurentAux_div : laurentAux r (algebraMap _ _ p / algebraMap _ _ q) = algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) := -- Porting note: added `by exact taylor_mem_nonZeroDivisors r` map_apply_div _ (by exact taylor_mem_nonZeroDivisors r) _ _ @[simp] theorem laurentAux_algebraMap : laurentAux r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) := by rw [← mk_one, ← mk_one, mk_eq_div, laurentAux_div, mk_eq_div, taylor_one, map_one, map_one] /-- The Laurent expansion of rational functions about a value. -/ def laurent : RatFunc R →ₐ[R] RatFunc R := RatFunc.mapAlgHom (.ofLinearMap (taylor r) (taylor_one _) (taylor_mul _)) (taylor_mem_nonZeroDivisors _) theorem laurent_div : laurent r (algebraMap _ _ p / algebraMap _ _ q) = algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) := laurentAux_div r p q @[simp] theorem laurent_algebraMap : laurent r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) := laurentAux_algebraMap _ _ @[simp] theorem laurent_X : laurent r X = X + C r := by rw [← algebraMap_X, laurent_algebraMap, taylor_X, map_add, algebraMap_C] @[simp] theorem laurent_C (x : R) : laurent r (C x) = C x := by rw [← algebraMap_C, laurent_algebraMap, taylor_C] @[simp] theorem laurent_at_zero : laurent 0 f = f := by induction f using RatFunc.induction_on; simp theorem laurent_laurent : laurent r (laurent s f) = laurent (r + s) f := by induction f using RatFunc.induction_on simp_rw [laurent_div, taylor_taylor] theorem laurent_injective : Function.Injective (laurent r) := fun _ _ h => by simpa [laurent_laurent] using congr_arg (laurent (-r)) h end end RatFunc
.lake/packages/mathlib/Mathlib/FieldTheory/SeparableDegree.lean
import Mathlib.FieldTheory.SplittingField.Construction import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure import Mathlib.FieldTheory.Separable import Mathlib.FieldTheory.Normal.Closure import Mathlib.RingTheory.AlgebraicIndependent.Adjoin import Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis import Mathlib.RingTheory.Polynomial.SeparableDegree import Mathlib.RingTheory.Polynomial.UniqueFactorization /-! # Separable degree This file contains basics about the separable degree of a field extension. ## Main definitions - `Field.Emb F E`: the type of `F`-algebra homomorphisms from `E` to the algebraic closure of `E` (the algebraic closure of `F` is usually used in the literature, but our definition has the advantage that `Field.Emb F E` lies in the same universe as `E` rather than the maximum over `F` and `E`). Usually denoted by $\operatorname{Emb}_F(E)$ in textbooks. - `Field.finSepDegree F E`: the (finite) separable degree $[E:F]_s$ of an extension `E / F` of fields, defined to be the number of `F`-algebra homomorphisms from `E` to the algebraic closure of `E`, as a natural number. It is zero if `Field.Emb F E` is not finite. Note that if `E / F` is not algebraic, then this definition makes no mathematical sense. **Remark:** the `Cardinal`-valued, potentially infinite separable degree `Field.sepDegree F E` for a general algebraic extension `E / F` is defined to be the degree of `L / F`, where `L` is the separable closure of `F` in `E`, which is not defined in this file yet. Later we will show that (`Field.finSepDegree_eq`), if `Field.Emb F E` is finite, then these two definitions coincide. If `E / F` is algebraic with infinite separable degree, we have `#(Field.Emb F E) = 2 ^ Field.sepDegree F E` instead. (See `Field.Emb.cardinal_eq_two_pow_sepDegree` in another file.) For example, if $F = \mathbb{Q}$ and $E = \mathbb{Q}( \mu_{p^\infty} )$, then $\operatorname{Emb}_F (E)$ is in bijection with $\operatorname{Gal}(E/F)$, which is isomorphic to $\mathbb{Z}_p^\times$, which is uncountable, whereas $ [E:F] $ is countable. - `Polynomial.natSepDegree`: the separable degree of a polynomial is a natural number, defined to be the number of distinct roots of it over its splitting field. ## Main results - `Field.embEquivOfEquiv`, `Field.finSepDegree_eq_of_equiv`: a random bijection between `Field.Emb F E` and `Field.Emb F K` when `E` and `K` are isomorphic as `F`-algebras. In particular, they have the same cardinality (so their `Field.finSepDegree` are equal). - `Field.embEquivOfAdjoinSplits`, `Field.finSepDegree_eq_of_adjoin_splits`: a random bijection between `Field.Emb F E` and `E →ₐ[F] K` if `E = F(S)` such that every element `s` of `S` is integral (= algebraic) over `F` and whose minimal polynomial splits in `K`. In particular, they have the same cardinality. - `Field.embEquivOfIsAlgClosed`, `Field.finSepDegree_eq_of_isAlgClosed`: a random bijection between `Field.Emb F E` and `E →ₐ[F] K` when `E / F` is algebraic and `K / F` is algebraically closed. In particular, they have the same cardinality. - `Field.embProdEmbOfIsAlgebraic`, `Field.finSepDegree_mul_finSepDegree_of_isAlgebraic`: if `K / E / F` is a field extension tower, such that `K / E` is algebraic, then there is a non-canonical bijection `Field.Emb F E × Field.Emb E K ≃ Field.Emb F K`. In particular, the separable degrees satisfy the tower law: $[E:F]_s [K:E]_s = [K:F]_s$ (see also `Module.finrank_mul_finrank`). - `Field.infinite_emb_of_transcendental`: `Field.Emb` is infinite for transcendental extensions. - `Polynomial.natSepDegree_le_natDegree`: the separable degree of a polynomial is smaller than its degree. - `Polynomial.natSepDegree_eq_natDegree_iff`: the separable degree of a non-zero polynomial is equal to its degree if and only if it is separable. - `Polynomial.natSepDegree_eq_of_splits`: if a polynomial splits over `E`, then its separable degree is equal to the number of distinct roots of it over `E`. - `Polynomial.natSepDegree_eq_of_isAlgClosed`: the separable degree of a polynomial is equal to the number of distinct roots of it over any algebraically closed field. - `Polynomial.natSepDegree_expand`: if a field `F` is of exponential characteristic `q`, then `Polynomial.expand F (q ^ n) f` and `f` have the same separable degree. - `Polynomial.HasSeparableContraction.natSepDegree_eq`: if a polynomial has separable contraction, then its separable degree is equal to its separable contraction degree. - `Irreducible.natSepDegree_dvd_natDegree`: the separable degree of an irreducible polynomial divides its degree. - `IntermediateField.finSepDegree_adjoin_simple_eq_natSepDegree`: the separable degree of `F⟮α⟯ / F` is equal to the separable degree of the minimal polynomial of `α` over `F`. - `IntermediateField.finSepDegree_adjoin_simple_eq_finrank_iff`: if `α` is algebraic over `F`, then the separable degree of `F⟮α⟯ / F` is equal to the degree of `F⟮α⟯ / F` if and only if `α` is a separable element. - `Field.finSepDegree_dvd_finrank`: the separable degree of any field extension `E / F` divides the degree of `E / F`. - `Field.finSepDegree_le_finrank`: the separable degree of a finite extension `E / F` is smaller than the degree of `E / F`. - `Field.finSepDegree_eq_finrank_iff`: if `E / F` is a finite extension, then its separable degree is equal to its degree if and only if it is a separable extension. - `IntermediateField.isSeparable_adjoin_simple_iff_isSeparable`: `F⟮x⟯ / F` is a separable extension if and only if `x` is a separable element. - `Algebra.IsSeparable.trans`: if `E / F` and `K / E` are both separable, then `K / F` is also separable. ## Tags separable degree, degree, polynomial -/ open Module Polynomial IntermediateField Field noncomputable section universe u v w variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] namespace Field /-- `Field.Emb F E` is the type of `F`-algebra homomorphisms from `E` to the algebraic closure of `E`. -/ abbrev Emb := E →ₐ[F] AlgebraicClosure E /-- If `E / F` is an algebraic extension, then the (finite) separable degree of `E / F` is the number of `F`-algebra homomorphisms from `E` to the algebraic closure of `E`, as a natural number. It is defined to be zero if there are infinitely many of them. Note that if `E / F` is not algebraic, then this definition makes no mathematical sense. -/ def finSepDegree : ℕ := Nat.card (Emb F E) instance instInhabitedEmb : Inhabited (Emb F E) := ⟨IsScalarTower.toAlgHom F E _⟩ instance instNeZeroFinSepDegree [FiniteDimensional F E] : NeZero (finSepDegree F E) := ⟨Nat.card_ne_zero.2 ⟨inferInstance, Fintype.finite <| minpoly.AlgHom.fintype _ _ _⟩⟩ /-- A random bijection between `Field.Emb F E` and `Field.Emb F K` when `E` and `K` are isomorphic as `F`-algebras. -/ def embEquivOfEquiv (i : E ≃ₐ[F] K) : Emb F E ≃ Emb F K := AlgEquiv.arrowCongr i <| AlgEquiv.symm <| by let _ : Algebra E K := i.toAlgHom.toRingHom.toAlgebra have : Algebra.IsAlgebraic E K := by constructor intro x have h := isAlgebraic_algebraMap (R := E) (A := K) (i.symm.toAlgHom x) rw [show ∀ y : E, (algebraMap E K) y = i.toAlgHom y from fun y ↦ rfl] at h simpa only [AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_coe, AlgEquiv.apply_symm_apply] using h apply AlgEquiv.restrictScalars (R := F) (S := E) exact IsAlgClosure.equivOfAlgebraic E K (AlgebraicClosure K) (AlgebraicClosure E) /-- If `E` and `K` are isomorphic as `F`-algebras, then they have the same `Field.finSepDegree` over `F`. -/ theorem finSepDegree_eq_of_equiv (i : E ≃ₐ[F] K) : finSepDegree F E = finSepDegree F K := Nat.card_congr (embEquivOfEquiv F E K i) @[simp] theorem finSepDegree_self : finSepDegree F F = 1 := by have : Cardinal.mk (Emb F F) = 1 := le_antisymm (Cardinal.le_one_iff_subsingleton.2 AlgHom.subsingleton) (Cardinal.one_le_iff_ne_zero.2 <| Cardinal.mk_ne_zero _) rw [finSepDegree, Nat.card, this, Cardinal.one_toNat] end Field namespace IntermediateField @[simp] theorem finSepDegree_bot : finSepDegree F (⊥ : IntermediateField F E) = 1 := by rw [finSepDegree_eq_of_equiv _ _ _ (botEquiv F E), finSepDegree_self] section Tower variable {F} variable [Algebra E K] [IsScalarTower F E K] @[simp] theorem finSepDegree_bot' : finSepDegree F (⊥ : IntermediateField E K) = finSepDegree F E := finSepDegree_eq_of_equiv _ _ _ ((botEquiv E K).restrictScalars F) @[simp] theorem finSepDegree_top : finSepDegree F (⊤ : IntermediateField E K) = finSepDegree F K := finSepDegree_eq_of_equiv _ _ _ ((topEquiv (F := E) (E := K)).restrictScalars F) end Tower end IntermediateField namespace Field /-- A random bijection between `Field.Emb F E` and `E →ₐ[F] K` if `E = F(S)` such that every element `s` of `S` is integral (= algebraic) over `F` and whose minimal polynomial splits in `K`. Combined with `Field.instInhabitedEmb`, it can be viewed as a stronger version of `IntermediateField.nonempty_algHom_of_adjoin_splits`. -/ def embEquivOfAdjoinSplits {S : Set E} (hS : adjoin F S = ⊤) (hK : ∀ s ∈ S, IsIntegral F s ∧ Splits (algebraMap F K) (minpoly F s)) : Emb F E ≃ (E →ₐ[F] K) := have : Algebra.IsAlgebraic F (⊤ : IntermediateField F E) := (hS ▸ isAlgebraic_adjoin (S := S) fun x hx ↦ (hK x hx).1) have halg := (topEquiv (F := F) (E := E)).isAlgebraic Classical.choice <| Function.Embedding.antisymm (halg.algHomEmbeddingOfSplits (fun _ ↦ splits_of_mem_adjoin F E (S := S) hK (hS ▸ mem_top)) _) (halg.algHomEmbeddingOfSplits (fun _ ↦ IsAlgClosed.splits_codomain _) _) /-- The `Field.finSepDegree F E` is equal to the cardinality of `E →ₐ[F] K` if `E = F(S)` such that every element `s` of `S` is integral (= algebraic) over `F` and whose minimal polynomial splits in `K`. -/ theorem finSepDegree_eq_of_adjoin_splits {S : Set E} (hS : adjoin F S = ⊤) (hK : ∀ s ∈ S, IsIntegral F s ∧ Splits (algebraMap F K) (minpoly F s)) : finSepDegree F E = Nat.card (E →ₐ[F] K) := Nat.card_congr (embEquivOfAdjoinSplits F E K hS hK) /-- A random bijection between `Field.Emb F E` and `E →ₐ[F] K` when `E / F` is algebraic and `K / F` is algebraically closed. -/ def embEquivOfIsAlgClosed [Algebra.IsAlgebraic F E] [IsAlgClosed K] : Emb F E ≃ (E →ₐ[F] K) := embEquivOfAdjoinSplits F E K (adjoin_univ F E) fun s _ ↦ ⟨Algebra.IsIntegral.isIntegral s, IsAlgClosed.splits_codomain _⟩ /-- The `Field.finSepDegree F E` is equal to the cardinality of `E →ₐ[F] K` as a natural number, when `E / F` is algebraic and `K / F` is algebraically closed. -/ @[stacks 09HJ "We use `finSepDegree` to state a more general result."] theorem finSepDegree_eq_of_isAlgClosed [Algebra.IsAlgebraic F E] [IsAlgClosed K] : finSepDegree F E = Nat.card (E →ₐ[F] K) := Nat.card_congr (embEquivOfIsAlgClosed F E K) /-- If `K / E / F` is a field extension tower, such that `K / E` is algebraic, then there is a non-canonical bijection `Field.Emb F E × Field.Emb E K ≃ Field.Emb F K`. A corollary of `algHomEquivSigma`. -/ def embProdEmbOfIsAlgebraic [Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic E K] : Emb F E × Emb E K ≃ Emb F K := let e : ∀ f : E →ₐ[F] AlgebraicClosure K, @AlgHom E K _ _ _ _ _ f.toRingHom.toAlgebra ≃ Emb E K := fun f ↦ (@embEquivOfIsAlgClosed E K _ _ _ _ _ f.toRingHom.toAlgebra).symm (algHomEquivSigma (A := F) (B := E) (C := K) (D := AlgebraicClosure K) |>.trans (Equiv.sigmaEquivProdOfEquiv e) |>.trans <| Equiv.prodCongrLeft <| fun _ : Emb E K ↦ AlgEquiv.arrowCongr (@AlgEquiv.refl F E _ _ _) <| (IsAlgClosure.equivOfAlgebraic E K (AlgebraicClosure K) (AlgebraicClosure E)).restrictScalars F).symm /-- If the field extension `E / F` is transcendental, then `Field.Emb F E` is infinite. -/ instance infinite_emb_of_transcendental [H : Algebra.Transcendental F E] : Infinite (Emb F E) := by obtain ⟨ι, x, hx⟩ := exists_isTranscendenceBasis' F E have := hx.isAlgebraic_field rw [← (embProdEmbOfIsAlgebraic F (adjoin F (Set.range x)) E).infinite_iff] refine @Prod.infinite_of_left _ _ ?_ _ rw [← (embEquivOfEquiv _ _ _ hx.1.aevalEquivField).infinite_iff] obtain ⟨i⟩ := hx.nonempty_iff_transcendental.2 H let K := FractionRing (MvPolynomial ι F) let i1 := IsScalarTower.toAlgHom F (MvPolynomial ι F) (AlgebraicClosure K) have hi1 : Function.Injective i1 := by rw [IsScalarTower.coe_toAlgHom', IsScalarTower.algebraMap_eq _ K] exact (algebraMap K (AlgebraicClosure K)).injective.comp (IsFractionRing.injective _ _) let f (n : ℕ) : Emb F K := IsFractionRing.liftAlgHom (g := i1.comp <| MvPolynomial.aeval fun i : ι ↦ MvPolynomial.X i ^ (n + 1)) <| hi1.comp <| by simpa [algebraicIndependent_iff_injective_aeval] using MvPolynomial.algebraicIndependent_polynomial_aeval_X _ fun i : ι ↦ (Polynomial.transcendental_X F).pow n.succ_pos refine Infinite.of_injective f fun m n h ↦ ?_ replace h : (MvPolynomial.X i) ^ (m + 1) = (MvPolynomial.X i) ^ (n + 1) := hi1 <| by simpa [f, -map_pow] using congr($h (algebraMap _ K (MvPolynomial.X (R := F) i))) simpa using congr(MvPolynomial.totalDegree $h) /-- If the field extension `E / F` is transcendental, then `Field.finSepDegree F E = 0`, which actually means that `Field.Emb F E` is infinite (see `Field.infinite_emb_of_transcendental`). -/ theorem finSepDegree_eq_zero_of_transcendental [Algebra.Transcendental F E] : finSepDegree F E = 0 := Nat.card_eq_zero_of_infinite /-- If `K / E / F` is a field extension tower, such that `K / E` is algebraic, then their separable degrees satisfy the tower law $[E:F]_s [K:E]_s = [K:F]_s$. See also `Module.finrank_mul_finrank`. -/ @[stacks 09HK "Part 1, `finSepDegree` variant"] theorem finSepDegree_mul_finSepDegree_of_isAlgebraic [Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic E K] : finSepDegree F E * finSepDegree E K = finSepDegree F K := by simpa only [Nat.card_prod] using Nat.card_congr (embProdEmbOfIsAlgebraic F E K) end Field namespace Polynomial variable {F E} variable (f : F[X]) open Classical in /-- The separable degree `Polynomial.natSepDegree` of a polynomial is a natural number, defined to be the number of distinct roots of it over its splitting field. This is similar to `Polynomial.natDegree` but not to `Polynomial.degree`, namely, the separable degree of `0` is `0`, not negative infinity. -/ def natSepDegree : ℕ := (f.aroots f.SplittingField).toFinset.card /-- The separable degree of a polynomial is smaller than its degree. -/ theorem natSepDegree_le_natDegree : f.natSepDegree ≤ f.natDegree := by have := f.map (algebraMap F f.SplittingField) |>.card_roots' rw [← aroots_def, natDegree_map] at this classical exact (f.aroots f.SplittingField).toFinset_card_le.trans this @[simp] theorem natSepDegree_X_sub_C (x : F) : (X - C x).natSepDegree = 1 := by simp only [natSepDegree, aroots_X_sub_C, Multiset.toFinset_singleton, Finset.card_singleton] @[simp] theorem natSepDegree_X : (X : F[X]).natSepDegree = 1 := by simp only [natSepDegree, aroots_X, Multiset.toFinset_singleton, Finset.card_singleton] /-- A constant polynomial has zero separable degree. -/ theorem natSepDegree_eq_zero (h : f.natDegree = 0) : f.natSepDegree = 0 := by linarith only [natSepDegree_le_natDegree f, h] @[simp] theorem natSepDegree_C (x : F) : (C x).natSepDegree = 0 := natSepDegree_eq_zero _ (natDegree_C _) @[simp] theorem natSepDegree_zero : (0 : F[X]).natSepDegree = 0 := by rw [← C_0, natSepDegree_C] @[simp] theorem natSepDegree_one : (1 : F[X]).natSepDegree = 0 := by rw [← C_1, natSepDegree_C] /-- A non-constant polynomial has non-zero separable degree. -/ theorem natSepDegree_ne_zero (h : f.natDegree ≠ 0) : f.natSepDegree ≠ 0 := by rw [natSepDegree, ne_eq, Finset.card_eq_zero, ← ne_eq, ← Finset.nonempty_iff_ne_empty] use rootOfSplits _ (SplittingField.splits f) (ne_of_apply_ne _ h) classical rw [Multiset.mem_toFinset, mem_aroots] exact ⟨ne_of_apply_ne _ h, map_rootOfSplits _ (SplittingField.splits f) (ne_of_apply_ne _ h)⟩ /-- A polynomial has zero separable degree if and only if it is constant. -/ theorem natSepDegree_eq_zero_iff : f.natSepDegree = 0 ↔ f.natDegree = 0 := ⟨(natSepDegree_ne_zero f).mtr, natSepDegree_eq_zero f⟩ /-- A polynomial has non-zero separable degree if and only if it is non-constant. -/ theorem natSepDegree_ne_zero_iff : f.natSepDegree ≠ 0 ↔ f.natDegree ≠ 0 := Iff.not <| natSepDegree_eq_zero_iff f /-- The separable degree of a non-zero polynomial is equal to its degree if and only if it is separable. -/ theorem natSepDegree_eq_natDegree_iff (hf : f ≠ 0) : f.natSepDegree = f.natDegree ↔ f.Separable := by classical simp_rw [← card_rootSet_eq_natDegree_iff_of_splits hf (SplittingField.splits f), rootSet_def, Finset.coe_sort_coe, Fintype.card_coe] rfl /-- If a polynomial is separable, then its separable degree is equal to its degree. -/ theorem natSepDegree_eq_natDegree_of_separable (h : f.Separable) : f.natSepDegree = f.natDegree := (natSepDegree_eq_natDegree_iff f h.ne_zero).2 h variable {f} in /-- Same as `Polynomial.natSepDegree_eq_natDegree_of_separable`, but enables the use of dot notation. -/ theorem Separable.natSepDegree_eq_natDegree (h : f.Separable) : f.natSepDegree = f.natDegree := natSepDegree_eq_natDegree_of_separable f h /-- If a polynomial splits over `E`, then its separable degree is equal to the number of distinct roots of it over `E`. -/ theorem natSepDegree_eq_of_splits [DecidableEq E] (h : f.Splits (algebraMap F E)) : f.natSepDegree = (f.aroots E).toFinset.card := by classical rw [aroots, ← (SplittingField.lift f h).comp_algebraMap, ← map_map, roots_map _ ((splits_id_iff_splits _).mpr <| SplittingField.splits f), Multiset.toFinset_map, Finset.card_image_of_injective _ (RingHom.injective _), natSepDegree] variable (E) in /-- The separable degree of a polynomial is equal to the number of distinct roots of it over any algebraically closed field. -/ theorem natSepDegree_eq_of_isAlgClosed [DecidableEq E] [IsAlgClosed E] : f.natSepDegree = (f.aroots E).toFinset.card := natSepDegree_eq_of_splits f (IsAlgClosed.splits_codomain f) theorem natSepDegree_map (f : E[X]) (i : E →+* K) : (f.map i).natSepDegree = f.natSepDegree := by classical let _ := i.toAlgebra simp_rw [show i = algebraMap E K by rfl, natSepDegree_eq_of_isAlgClosed (AlgebraicClosure K), aroots_def, map_map, ← IsScalarTower.algebraMap_eq] @[simp] theorem natSepDegree_C_mul {x : F} (hx : x ≠ 0) : (C x * f).natSepDegree = f.natSepDegree := by classical simp only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_C_mul _ hx] @[simp] theorem natSepDegree_smul_nonzero {x : F} (hx : x ≠ 0) : (x • f).natSepDegree = f.natSepDegree := by classical simp only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_smul_nonzero _ hx] @[simp] theorem natSepDegree_pow {n : ℕ} : (f ^ n).natSepDegree = if n = 0 then 0 else f.natSepDegree := by classical simp only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_pow] by_cases h : n = 0 · simp only [h, zero_smul, Multiset.toFinset_zero, Finset.card_empty, ite_true] simp only [h, Multiset.toFinset_nsmul _ n h, ite_false] theorem natSepDegree_pow_of_ne_zero {n : ℕ} (hn : n ≠ 0) : (f ^ n).natSepDegree = f.natSepDegree := by simp_rw [natSepDegree_pow, hn, ite_false] theorem natSepDegree_X_pow {n : ℕ} : (X ^ n : F[X]).natSepDegree = if n = 0 then 0 else 1 := by simp only [natSepDegree_pow, natSepDegree_X] theorem natSepDegree_X_sub_C_pow {x : F} {n : ℕ} : ((X - C x) ^ n).natSepDegree = if n = 0 then 0 else 1 := by simp only [natSepDegree_pow, natSepDegree_X_sub_C] theorem natSepDegree_C_mul_X_sub_C_pow {x y : F} {n : ℕ} (hx : x ≠ 0) : (C x * (X - C y) ^ n).natSepDegree = if n = 0 then 0 else 1 := by simp only [natSepDegree_C_mul _ hx, natSepDegree_X_sub_C_pow] theorem natSepDegree_mul (g : F[X]) : (f * g).natSepDegree ≤ f.natSepDegree + g.natSepDegree := by by_cases h : f * g = 0 · simp only [h, natSepDegree_zero, zero_le] classical simp_rw [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_mul h, Multiset.toFinset_add] exact Finset.card_union_le _ _ theorem natSepDegree_mul_eq_iff (g : F[X]) : (f * g).natSepDegree = f.natSepDegree + g.natSepDegree ↔ (f = 0 ∧ g = 0) ∨ IsCoprime f g := by by_cases h : f * g = 0 · rw [mul_eq_zero] at h wlog hf : f = 0 generalizing f g · simpa only [mul_comm, add_comm, and_comm, isCoprime_comm] using this g f h.symm (h.resolve_left hf) rw [hf, zero_mul, natSepDegree_zero, zero_add, isCoprime_zero_left, isUnit_iff, eq_comm, natSepDegree_eq_zero_iff, natDegree_eq_zero] refine ⟨fun ⟨x, h⟩ ↦ ?_, ?_⟩ · by_cases hx : x = 0 · exact .inl ⟨rfl, by rw [← h, hx, map_zero]⟩ exact .inr ⟨x, Ne.isUnit hx, h⟩ rintro (⟨-, h⟩ | ⟨x, -, h⟩) · exact ⟨0, by rw [h, map_zero]⟩ exact ⟨x, h⟩ classical simp_rw [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_mul h, Multiset.toFinset_add, Finset.card_union_eq_card_add_card, Finset.disjoint_iff_ne, Multiset.mem_toFinset, mem_aroots] rw [mul_eq_zero, not_or] at h refine ⟨fun H ↦ .inr (isCoprime_of_irreducible_dvd (not_and.2 fun _ ↦ h.2) fun u hu ⟨v, hf⟩ ⟨w, hg⟩ ↦ ?_), ?_⟩ · obtain ⟨x, hx⟩ := IsAlgClosed.exists_aeval_eq_zero (AlgebraicClosure F) _ (degree_pos_of_irreducible hu).ne' exact H x ⟨h.1, by simpa only [map_mul, hx, zero_mul] using congr(aeval x $hf)⟩ x ⟨h.2, by simpa only [map_mul, hx, zero_mul] using congr(aeval x $hg)⟩ rfl rintro (⟨rfl, rfl⟩ | hc) · exact (h.1 rfl).elim rintro x hf _ hg rfl obtain ⟨u, v, hfg⟩ := hc simpa only [map_add, map_mul, map_one, hf.2, hg.2, mul_zero, add_zero, zero_ne_one] using congr(aeval x $hfg) theorem natSepDegree_mul_of_isCoprime (g : F[X]) (hc : IsCoprime f g) : (f * g).natSepDegree = f.natSepDegree + g.natSepDegree := (natSepDegree_mul_eq_iff f g).2 (.inr hc) theorem natSepDegree_le_of_dvd (g : F[X]) (h1 : f ∣ g) (h2 : g ≠ 0) : f.natSepDegree ≤ g.natSepDegree := by classical simp_rw [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F)] exact Finset.card_le_card <| Multiset.toFinset_subset.mpr <| Multiset.Le.subset <| roots.le_of_dvd (map_ne_zero h2) <| map_dvd _ h1 /-- If a field `F` is of exponential characteristic `q`, then `Polynomial.expand F (q ^ n) f` and `f` have the same separable degree. -/ theorem natSepDegree_expand (q : ℕ) [hF : ExpChar F q] {n : ℕ} : (expand F (q ^ n) f).natSepDegree = f.natSepDegree := by obtain - | hprime := hF · simp only [one_pow, expand_one] haveI := Fact.mk hprime classical simpa only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_def, map_expand, Fintype.card_coe] using Fintype.card_eq.2 ⟨(f.map (algebraMap F (AlgebraicClosure F))).rootsExpandPowEquivRoots q n⟩ theorem natSepDegree_X_pow_char_pow_sub_C (q : ℕ) [ExpChar F q] (n : ℕ) (y : F) : (X ^ q ^ n - C y).natSepDegree = 1 := by rw [← expand_X, ← expand_C (q ^ n), ← map_sub, natSepDegree_expand, natSepDegree_X_sub_C] variable {f} in /-- If `g` is a separable contraction of `f`, then the separable degree of `f` is equal to the degree of `g`. -/ theorem IsSeparableContraction.natSepDegree_eq {g : Polynomial F} {q : ℕ} [ExpChar F q] (h : IsSeparableContraction q f g) : f.natSepDegree = g.natDegree := by obtain ⟨h1, m, h2⟩ := h rw [← h2, natSepDegree_expand, h1.natSepDegree_eq_natDegree] variable {f} in /-- If a polynomial has separable contraction, then its separable degree is equal to the degree of the given separable contraction. -/ theorem HasSeparableContraction.natSepDegree_eq {q : ℕ} [ExpChar F q] (hf : f.HasSeparableContraction q) : f.natSepDegree = hf.degree := hf.isSeparableContraction.natSepDegree_eq end Polynomial namespace Irreducible variable {F} variable {f : F[X]} /-- The separable degree of an irreducible polynomial divides its degree. -/ theorem natSepDegree_dvd_natDegree (h : Irreducible f) : f.natSepDegree ∣ f.natDegree := by obtain ⟨q, _⟩ := ExpChar.exists F have hf := h.hasSeparableContraction q rw [hf.natSepDegree_eq] exact hf.dvd_degree /-- A monic irreducible polynomial over a field `F` of exponential characteristic `q` has separable degree one if and only if it is of the form `Polynomial.expand F (q ^ n) (X - C y)` for some `n : ℕ` and `y : F`. -/ theorem natSepDegree_eq_one_iff_of_monic' (q : ℕ) [ExpChar F q] (hm : f.Monic) (hi : Irreducible f) : f.natSepDegree = 1 ↔ ∃ (n : ℕ) (y : F), f = expand F (q ^ n) (X - C y) := by refine ⟨fun h ↦ ?_, fun ⟨n, y, h⟩ ↦ ?_⟩ · obtain ⟨g, h1, n, rfl⟩ := hi.hasSeparableContraction q have h2 : g.natDegree = 1 := by rwa [natSepDegree_expand _ q, h1.natSepDegree_eq_natDegree] at h rw [((monic_expand_iff <| expChar_pow_pos F q n).mp hm).eq_X_add_C h2] exact ⟨n, -(g.coeff 0), by rw [map_neg, sub_neg_eq_add]⟩ rw [h, natSepDegree_expand _ q, natSepDegree_X_sub_C] /-- A monic irreducible polynomial over a field `F` of exponential characteristic `q` has separable degree one if and only if it is of the form `X ^ (q ^ n) - C y` for some `n : ℕ` and `y : F`. -/ theorem natSepDegree_eq_one_iff_of_monic (q : ℕ) [ExpChar F q] (hm : f.Monic) (hi : Irreducible f) : f.natSepDegree = 1 ↔ ∃ (n : ℕ) (y : F), f = X ^ q ^ n - C y := by simp_rw [hi.natSepDegree_eq_one_iff_of_monic' q hm, map_sub, expand_X, expand_C] end Irreducible namespace Polynomial namespace Monic variable {F} variable {f : F[X]} alias natSepDegree_eq_one_iff_of_irreducible' := Irreducible.natSepDegree_eq_one_iff_of_monic' alias natSepDegree_eq_one_iff_of_irreducible := Irreducible.natSepDegree_eq_one_iff_of_monic /-- If a monic polynomial of separable degree one splits, then it is of form `(X - C y) ^ m` for some non-zero natural number `m` and some element `y` of `F`. -/ theorem eq_X_sub_C_pow_of_natSepDegree_eq_one_of_splits (hm : f.Monic) (hs : f.Splits (RingHom.id F)) (h : f.natSepDegree = 1) : ∃ (m : ℕ) (y : F), m ≠ 0 ∧ f = (X - C y) ^ m := by classical have h1 := eq_prod_roots_of_monic_of_splits_id hm hs have h2 := (natSepDegree_eq_of_splits f hs).symm rw [h, aroots_def, Algebra.algebraMap_self, map_id, Multiset.toFinset_card_eq_one_iff] at h2 obtain ⟨h2, y, h3⟩ := h2 exact ⟨_, y, h2, by rwa [h3, Multiset.map_nsmul, Multiset.map_singleton, Multiset.prod_nsmul, Multiset.prod_singleton] at h1⟩ /-- If a monic irreducible polynomial over a field `F` of exponential characteristic `q` has separable degree one, then it is of the form `X ^ (q ^ n) - C y` for some natural number `n`, and some element `y` of `F`, such that either `n = 0` or `y` has no `q`-th root in `F`. -/ theorem eq_X_pow_char_pow_sub_C_of_natSepDegree_eq_one_of_irreducible (q : ℕ) [ExpChar F q] (hm : f.Monic) (hi : Irreducible f) (h : f.natSepDegree = 1) : ∃ (n : ℕ) (y : F), (n = 0 ∨ y ∉ (frobenius F q).range) ∧ f = X ^ q ^ n - C y := by obtain ⟨n, y, hf⟩ := (hm.natSepDegree_eq_one_iff_of_irreducible q hi).1 h cases id ‹ExpChar F q› with | zero => simp_rw [one_pow, pow_one] at hf ⊢ exact ⟨0, y, .inl rfl, hf⟩ | prime hq => refine ⟨n, y, (em _).imp id fun hn ⟨z, hy⟩ ↦ ?_, hf⟩ haveI := expChar_of_injective_ringHom (R := F) C_injective q rw [hf, ← Nat.succ_pred hn, pow_succ, pow_mul, ← hy, frobenius_def, map_pow, ← sub_pow_expChar] at hi exact not_irreducible_pow hq.ne_one hi /-- If a monic polynomial over a field `F` of exponential characteristic `q` has separable degree one, then it is of the form `(X ^ (q ^ n) - C y) ^ m` for some non-zero natural number `m`, some natural number `n`, and some element `y` of `F`, such that either `n = 0` or `y` has no `q`-th root in `F`. -/ theorem eq_X_pow_char_pow_sub_C_pow_of_natSepDegree_eq_one (q : ℕ) [ExpChar F q] (hm : f.Monic) (h : f.natSepDegree = 1) : ∃ (m n : ℕ) (y : F), m ≠ 0 ∧ (n = 0 ∨ y ∉ (frobenius F q).range) ∧ f = (X ^ q ^ n - C y) ^ m := by obtain ⟨p, hM, hI, hf⟩ := exists_monic_irreducible_factor _ <| not_isUnit_of_natDegree_pos _ <| Nat.pos_of_ne_zero <| (natSepDegree_ne_zero_iff _).1 (h.symm ▸ Nat.one_ne_zero) have hD := (h ▸ natSepDegree_le_of_dvd p f hf hm.ne_zero).antisymm <| Nat.pos_of_ne_zero <| (natSepDegree_ne_zero_iff _).2 hI.natDegree_pos.ne' obtain ⟨n, y, H, hp⟩ := hM.eq_X_pow_char_pow_sub_C_of_natSepDegree_eq_one_of_irreducible q hI hD have hF := finiteMultiplicity_of_degree_pos_of_monic (degree_pos_of_irreducible hI) hM hm.ne_zero classical have hne := (multiplicity_pos_of_dvd hf).ne' refine ⟨_, n, y, hne, H, ?_⟩ obtain ⟨c, hf, H⟩ := hF.exists_eq_pow_mul_and_not_dvd rw [hf, natSepDegree_mul_of_isCoprime _ c <| IsCoprime.pow_left <| (hI.isCoprime_or_dvd c).resolve_right H, natSepDegree_pow_of_ne_zero _ hne, hD, add_eq_left, natSepDegree_eq_zero_iff] at h simpa only [eq_one_of_monic_natDegree_zero ((hM.pow _).of_mul_monic_left (hf ▸ hm)) h, mul_one, ← hp] using hf /-- A monic polynomial over a field `F` of exponential characteristic `q` has separable degree one if and only if it is of the form `(X ^ (q ^ n) - C y) ^ m` for some non-zero natural number `m`, some natural number `n`, and some element `y` of `F`. -/ theorem natSepDegree_eq_one_iff (q : ℕ) [ExpChar F q] (hm : f.Monic) : f.natSepDegree = 1 ↔ ∃ (m n : ℕ) (y : F), m ≠ 0 ∧ f = (X ^ q ^ n - C y) ^ m := by refine ⟨fun h ↦ ?_, fun ⟨m, n, y, hm, h⟩ ↦ ?_⟩ · obtain ⟨m, n, y, hm, -, h⟩ := hm.eq_X_pow_char_pow_sub_C_pow_of_natSepDegree_eq_one q h exact ⟨m, n, y, hm, h⟩ simp_rw [h, natSepDegree_pow, hm, ite_false, natSepDegree_X_pow_char_pow_sub_C] end Monic end Polynomial namespace minpoly variable {F : Type u} {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E] variable (q : ℕ) [hF : ExpChar F q] {x : E} /-- The minimal polynomial of an element of `E / F` of exponential characteristic `q` has separable degree one if and only if the minimal polynomial is of the form `Polynomial.expand F (q ^ n) (X - C y)` for some `n : ℕ` and `y : F`. -/ theorem natSepDegree_eq_one_iff_eq_expand_X_sub_C : (minpoly F x).natSepDegree = 1 ↔ ∃ (n : ℕ) (y : F), minpoly F x = expand F (q ^ n) (X - C y) := by refine ⟨fun h ↦ ?_, fun ⟨n, y, h⟩ ↦ ?_⟩ · have halg : IsIntegral F x := by_contra fun h' ↦ by simp only [eq_zero h', natSepDegree_zero, zero_ne_one] at h exact (minpoly.irreducible halg).natSepDegree_eq_one_iff_of_monic' q (minpoly.monic halg) |>.1 h rw [h, natSepDegree_expand _ q, natSepDegree_X_sub_C] /-- The minimal polynomial of an element of `E / F` of exponential characteristic `q` has separable degree one if and only if the minimal polynomial is of the form `X ^ (q ^ n) - C y` for some `n : ℕ` and `y : F`. -/ theorem natSepDegree_eq_one_iff_eq_X_pow_sub_C : (minpoly F x).natSepDegree = 1 ↔ ∃ (n : ℕ) (y : F), minpoly F x = X ^ q ^ n - C y := by simp only [minpoly.natSepDegree_eq_one_iff_eq_expand_X_sub_C q, map_sub, expand_X, expand_C] /-- The minimal polynomial of an element `x` of `E / F` of exponential characteristic `q` has separable degree one if and only if `x ^ (q ^ n) ∈ F` for some `n : ℕ`. -/ theorem natSepDegree_eq_one_iff_pow_mem : (minpoly F x).natSepDegree = 1 ↔ ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by convert_to _ ↔ ∃ (n : ℕ) (y : F), Polynomial.aeval x (X ^ q ^ n - C y) = 0 · simp_rw [RingHom.mem_range, map_sub, map_pow, aeval_C, aeval_X, sub_eq_zero, eq_comm] refine ⟨fun h ↦ ?_, fun ⟨n, y, h⟩ ↦ ?_⟩ · obtain ⟨n, y, hx⟩ := (minpoly.natSepDegree_eq_one_iff_eq_X_pow_sub_C q).1 h exact ⟨n, y, hx ▸ aeval F x⟩ have hnezero := X_pow_sub_C_ne_zero (expChar_pow_pos F q n) y refine ((natSepDegree_le_of_dvd _ _ (minpoly.dvd F x h) hnezero).trans_eq <| natSepDegree_X_pow_char_pow_sub_C q n y).antisymm ?_ rw [Nat.one_le_iff_ne_zero, natSepDegree_ne_zero_iff, ← Nat.one_le_iff_ne_zero] exact minpoly.natDegree_pos <| IsAlgebraic.isIntegral ⟨_, hnezero, h⟩ /-- The minimal polynomial of an element `x` of `E / F` of exponential characteristic `q` has separable degree one if and only if the minimal polynomial is of the form `(X - x) ^ (q ^ n)` for some `n : ℕ`. -/ theorem natSepDegree_eq_one_iff_eq_X_sub_C_pow : (minpoly F x).natSepDegree = 1 ↔ ∃ n : ℕ, (minpoly F x).map (algebraMap F E) = (X - C x) ^ q ^ n := by haveI := expChar_of_injective_algebraMap (algebraMap F E).injective q haveI := expChar_of_injective_ringHom (C_injective (R := E)) q refine ⟨fun h ↦ ?_, fun ⟨n, h⟩ ↦ (natSepDegree_eq_one_iff_pow_mem q).2 ?_⟩ · obtain ⟨n, y, h⟩ := (natSepDegree_eq_one_iff_eq_X_pow_sub_C q).1 h have hx := congr_arg (Polynomial.aeval x) h.symm rw [minpoly.aeval, map_sub, map_pow, aeval_X, aeval_C, sub_eq_zero, eq_comm] at hx use n rw [h, Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, hx, map_pow, ← sub_pow_expChar_pow_of_commute _ _ (commute_X _)] apply_fun constantCoeff at h simp_rw [map_pow, map_sub, constantCoeff_apply, coeff_map, coeff_X_zero, coeff_C_zero] at h rw [zero_sub, neg_pow, neg_one_pow_expChar_pow] at h exact ⟨n, -(minpoly F x).coeff 0, by rw [map_neg, h, neg_mul, one_mul, neg_neg]⟩ end minpoly namespace IntermediateField /-- The separable degree of `F⟮α⟯ / F` is equal to the separable degree of the minimal polynomial of `α` over `F`. -/ theorem finSepDegree_adjoin_simple_eq_natSepDegree {α : E} (halg : IsAlgebraic F α) : finSepDegree F F⟮α⟯ = (minpoly F α).natSepDegree := by have : finSepDegree F F⟮α⟯ = _ := Nat.card_congr (algHomAdjoinIntegralEquiv F (K := AlgebraicClosure F⟮α⟯) halg.isIntegral) classical rw [this, Nat.card_eq_fintype_card, natSepDegree_eq_of_isAlgClosed (E := AlgebraicClosure F⟮α⟯), ← Fintype.card_coe] simp_rw [Multiset.mem_toFinset] -- The separable degree of `F⟮α⟯ / F` divides the degree of `F⟮α⟯ / F`. -- Marked as `private` because it is a special case of `finSepDegree_dvd_finrank`. private theorem finSepDegree_adjoin_simple_dvd_finrank (α : E) : finSepDegree F F⟮α⟯ ∣ finrank F F⟮α⟯ := by by_cases halg : IsAlgebraic F α · rw [finSepDegree_adjoin_simple_eq_natSepDegree F E halg, adjoin.finrank halg.isIntegral] exact (minpoly.irreducible halg.isIntegral).natSepDegree_dvd_natDegree have : finrank F F⟮α⟯ = 0 := finrank_of_infinite_dimensional fun _ ↦ halg ((AdjoinSimple.isIntegral_gen F α).1 (IsIntegral.of_finite F _)).isAlgebraic rw [this] exact dvd_zero _ /-- The separable degree of `F⟮α⟯ / F` is smaller than the degree of `F⟮α⟯ / F` if `α` is algebraic over `F`. -/ theorem finSepDegree_adjoin_simple_le_finrank (α : E) (halg : IsAlgebraic F α) : finSepDegree F F⟮α⟯ ≤ finrank F F⟮α⟯ := by haveI := adjoin.finiteDimensional halg.isIntegral exact Nat.le_of_dvd finrank_pos <| finSepDegree_adjoin_simple_dvd_finrank F E α /-- If `α` is algebraic over `F`, then the separable degree of `F⟮α⟯ / F` is equal to the degree of `F⟮α⟯ / F` if and only if `α` is a separable element. -/ theorem finSepDegree_adjoin_simple_eq_finrank_iff (α : E) (halg : IsAlgebraic F α) : finSepDegree F F⟮α⟯ = finrank F F⟮α⟯ ↔ IsSeparable F α := by rw [finSepDegree_adjoin_simple_eq_natSepDegree F E halg, adjoin.finrank halg.isIntegral, natSepDegree_eq_natDegree_iff _ (minpoly.ne_zero halg.isIntegral), IsSeparable] end IntermediateField namespace Field /-- The separable degree of any field extension `E / F` divides the degree of `E / F`. -/ theorem finSepDegree_dvd_finrank : finSepDegree F E ∣ finrank F E := by by_cases hfd : FiniteDimensional F E · rw [← finSepDegree_top F, ← finrank_top F E] refine induction_on_adjoin (fun K : IntermediateField F E ↦ finSepDegree F K ∣ finrank F K) (by simp_rw [finSepDegree_bot, IntermediateField.finrank_bot, one_dvd]) (fun L x h ↦ ?_) ⊤ simp only at h ⊢ have hdvd := mul_dvd_mul h <| finSepDegree_adjoin_simple_dvd_finrank L E x set M := L⟮x⟯ rwa [finSepDegree_mul_finSepDegree_of_isAlgebraic F L M, Module.finrank_mul_finrank F L M] at hdvd rw [finrank_of_infinite_dimensional hfd] exact dvd_zero _ /-- The separable degree of a finite extension `E / F` is smaller than the degree of `E / F`. -/ @[stacks 09HA "The inequality"] theorem finSepDegree_le_finrank [FiniteDimensional F E] : finSepDegree F E ≤ finrank F E := Nat.le_of_dvd finrank_pos <| finSepDegree_dvd_finrank F E /-- If `E / F` is a separable extension, then its separable degree is equal to its degree. When `E / F` is infinite, it means that `Field.Emb F E` has infinitely many elements. (But the cardinality of `Field.Emb F E` is not equal to `Module.rank F E` in general!) -/ theorem finSepDegree_eq_finrank_of_isSeparable [Algebra.IsSeparable F E] : finSepDegree F E = finrank F E := by wlog hfd : FiniteDimensional F E generalizing E with H · rw [finrank_of_infinite_dimensional hfd] obtain ⟨L, h, h'⟩ := exists_lt_finrank_of_infinite_dimensional hfd (finSepDegree F E) have hd := finSepDegree_mul_finSepDegree_of_isAlgebraic F L E rw [H L h] at hd by_cases hd' : finSepDegree L E = 0 · rw [← hd, hd', mul_zero] linarith only [h', hd, Nat.le_mul_of_pos_right (finrank F L) (Nat.pos_of_ne_zero hd')] rw [← finSepDegree_top F, ← finrank_top F E] refine induction_on_adjoin (fun K : IntermediateField F E ↦ finSepDegree F K = finrank F K) (by simp_rw [finSepDegree_bot, IntermediateField.finrank_bot]) (fun L x h ↦ ?_) ⊤ simp only at h ⊢ have heq : _ * _ = _ * _ := congr_arg₂ (· * ·) h <| (finSepDegree_adjoin_simple_eq_finrank_iff L E x (IsAlgebraic.of_finite L x)).2 <| IsSeparable.tower_top L (Algebra.IsSeparable.isSeparable F x) set M := L⟮x⟯ rwa [finSepDegree_mul_finSepDegree_of_isAlgebraic F L M, Module.finrank_mul_finrank F L M] at heq alias Algebra.IsSeparable.finSepDegree_eq := finSepDegree_eq_finrank_of_isSeparable /-- If `E / F` is a finite extension, then its separable degree is equal to its degree if and only if it is a separable extension. -/ @[stacks 09HA "The equality condition"] theorem finSepDegree_eq_finrank_iff [FiniteDimensional F E] : finSepDegree F E = finrank F E ↔ Algebra.IsSeparable F E := ⟨fun heq ↦ ⟨fun x ↦ by have halg := IsAlgebraic.of_finite F x refine (finSepDegree_adjoin_simple_eq_finrank_iff F E x halg).1 <| le_antisymm (finSepDegree_adjoin_simple_le_finrank F E x halg) <| le_of_not_gt fun h ↦ ?_ have := Nat.mul_lt_mul_of_lt_of_le' h (finSepDegree_le_finrank F⟮x⟯ E) Fin.pos' rw [finSepDegree_mul_finSepDegree_of_isAlgebraic F F⟮x⟯ E, Module.finrank_mul_finrank F F⟮x⟯ E] at this linarith only [heq, this]⟩, fun _ ↦ finSepDegree_eq_finrank_of_isSeparable F E⟩ end Field lemma IntermediateField.isSeparable_of_mem_isSeparable {L : IntermediateField F E} [Algebra.IsSeparable F L] {x : E} (h : x ∈ L) : IsSeparable F x := by simpa only [IsSeparable, minpoly_eq] using Algebra.IsSeparable.isSeparable F (K := L) ⟨x, h⟩ /-- `F⟮x⟯ / F` is a separable extension if and only if `x` is a separable element. As a consequence, any rational function of `x` is also a separable element. -/ theorem IntermediateField.isSeparable_adjoin_simple_iff_isSeparable {x : E} : Algebra.IsSeparable F F⟮x⟯ ↔ IsSeparable F x := by refine ⟨fun _ ↦ ?_, fun hsep ↦ ?_⟩ · exact isSeparable_of_mem_isSeparable F E <| mem_adjoin_simple_self F x · have h := IsSeparable.isIntegral hsep haveI := adjoin.finiteDimensional h rwa [← finSepDegree_eq_finrank_iff, finSepDegree_adjoin_simple_eq_finrank_iff F E x h.isAlgebraic] variable {E K} in /-- If `K / E / F` is an extension tower such that `E / F` is separable, `x : K` is separable over `E`, then it's also separable over `F`. -/ theorem IsSeparable.of_algebra_isSeparable_of_isSeparable [Algebra E K] [IsScalarTower F E K] [Algebra.IsSeparable F E] {x : K} (hsep : IsSeparable E x) : IsSeparable F x := by set f := minpoly E x with hf let E' : IntermediateField F E := adjoin F f.coeffs haveI : FiniteDimensional F E' := finiteDimensional_adjoin fun x _ ↦ Algebra.IsSeparable.isIntegral F x let g : E'[X] := f.toSubring E'.toSubring (subset_adjoin F _) have h : g.map (algebraMap E' E) = f := f.map_toSubring E'.toSubring (subset_adjoin F _) clear_value g have hx : x ∈ restrictScalars F E'⟮x⟯ := mem_adjoin_simple_self _ x have hzero : aeval x g = 0 := by simpa only [← hf, ← h, aeval_map_algebraMap] using minpoly.aeval E x have halg : IsIntegral E' x := isIntegral_trans (R := F) (A := E) _ (IsSeparable.isIntegral hsep) |>.tower_top simp only [IsSeparable, ← hf, ← h, separable_map] at hsep replace hsep := hsep.of_dvd <| minpoly.dvd E' x hzero haveI : Algebra.IsSeparable F E' := Algebra.isSeparable_tower_bot_of_isSeparable F E' E haveI := (isSeparable_adjoin_simple_iff_isSeparable _ _).2 hsep haveI := adjoin.finiteDimensional halg haveI : FiniteDimensional F E'⟮x⟯ := FiniteDimensional.trans F E' E'⟮x⟯ have := finSepDegree_mul_finSepDegree_of_isAlgebraic F E' E'⟮x⟯ rw [finSepDegree_eq_finrank_of_isSeparable F E', finSepDegree_eq_finrank_of_isSeparable E' E'⟮x⟯, Module.finrank_mul_finrank F E' E'⟮x⟯, eq_comm, finSepDegree_eq_finrank_iff F E'⟮x⟯] at this change Algebra.IsSeparable F (restrictScalars F E'⟮x⟯) at this exact isSeparable_of_mem_isSeparable F K hx /-- If `E / F` and `K / E` are both separable extensions, then `K / F` is also separable. -/ @[stacks 09HB] theorem Algebra.IsSeparable.trans [Algebra E K] [IsScalarTower F E K] [Algebra.IsSeparable F E] [Algebra.IsSeparable E K] : Algebra.IsSeparable F K := ⟨fun x ↦ IsSeparable.of_algebra_isSeparable_of_isSeparable F (Algebra.IsSeparable.isSeparable E x)⟩ /-- If `x` and `y` are both separable elements, then `F⟮x, y⟯ / F` is a separable extension. As a consequence, any rational function of `x` and `y` is also a separable element. -/ theorem IntermediateField.isSeparable_adjoin_pair_of_isSeparable {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) : Algebra.IsSeparable F F⟮x, y⟯ := by rw [← adjoin_simple_adjoin_simple] replace hy := IsSeparable.tower_top F⟮x⟯ hy rw [← isSeparable_adjoin_simple_iff_isSeparable] at hx hy exact Algebra.IsSeparable.trans F F⟮x⟯ F⟮x⟯⟮y⟯ namespace Field variable {F} /-- Any element `x` of `F` is a separable element of `E / F` when embedded into `E`. -/ theorem isSeparable_algebraMap (x : F) : IsSeparable F ((algebraMap F E) x) := by rw [IsSeparable, minpoly.algebraMap_eq (algebraMap F E).injective] exact Algebra.IsSeparable.isSeparable F x variable {E} /-- If `x` and `y` are both separable elements, then `x * y` is also a separable element. -/ theorem isSeparable_mul {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) : IsSeparable F (x * y) := haveI := isSeparable_adjoin_pair_of_isSeparable F E hx hy isSeparable_of_mem_isSeparable F E <| F⟮x, y⟯.mul_mem (subset_adjoin F _ (.inl rfl)) (subset_adjoin F _ (.inr rfl)) /-- If `x` and `y` are both separable elements, then `x + y` is also a separable element. -/ theorem isSeparable_add {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) : IsSeparable F (x + y) := haveI := isSeparable_adjoin_pair_of_isSeparable F E hx hy isSeparable_of_mem_isSeparable F E <| F⟮x, y⟯.add_mem (subset_adjoin F _ (.inl rfl)) (subset_adjoin F _ (.inr rfl)) /-- If `x` is a separable elements, then `-x` is also a separable element. -/ theorem isSeparable_neg {x : E} (hx : IsSeparable F x) : IsSeparable F (-x) := haveI := (isSeparable_adjoin_simple_iff_isSeparable F E).2 hx isSeparable_of_mem_isSeparable F E <| F⟮x⟯.neg_mem <| mem_adjoin_simple_self F x /-- If `x` and `y` are both separable elements, then `x - y` is also a separable element. -/ theorem isSeparable_sub {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) : IsSeparable F (x - y) := haveI := isSeparable_adjoin_pair_of_isSeparable F E hx hy isSeparable_of_mem_isSeparable F E <| F⟮x, y⟯.sub_mem (subset_adjoin F _ (.inl rfl)) (subset_adjoin F _ (.inr rfl)) /-- If `x` is a separable element, then `x⁻¹` is also a separable element. -/ theorem isSeparable_inv {x : E} (hx : IsSeparable F x) : IsSeparable F x⁻¹ := haveI := (isSeparable_adjoin_simple_iff_isSeparable F E).2 hx isSeparable_of_mem_isSeparable F E <| F⟮x⟯.inv_mem <| mem_adjoin_simple_self F x end Field /-- A field is a perfect field (which means that any irreducible polynomial is separable) if and only if every separable degree one polynomial splits. -/ theorem perfectField_iff_splits_of_natSepDegree_eq_one (F : Type*) [Field F] : PerfectField F ↔ ∀ f : F[X], f.natSepDegree = 1 → Factors f := by refine ⟨fun ⟨h⟩ f hf ↦ factors_iff_splits.2 <| or_iff_not_imp_left.2 fun hn g hg hd ↦ ?_, fun h ↦ ?_⟩ · have := natSepDegree_le_of_dvd g f hd hn rw [hf, (h hg).natSepDegree_eq_natDegree] at this exact (degree_eq_iff_natDegree_eq_of_pos one_pos).2 <| this.antisymm <| natDegree_pos_iff_degree_pos.2 (degree_pos_of_irreducible hg) obtain ⟨p, _⟩ := ExpChar.exists F haveI := PerfectRing.ofSurjective F p fun x ↦ by obtain ⟨y, hy⟩ := Factors.exists_eval_eq_zero (h _ (pow_one p ▸ natSepDegree_X_pow_char_pow_sub_C p 1 x)) ((degree_X_pow_sub_C (expChar_pos F p) x).symm ▸ Nat.cast_pos.2 (expChar_pos F p)).ne' exact ⟨y, by rwa [eval_sub, eval_X_pow, eval_C, sub_eq_zero] at hy⟩ exact PerfectRing.toPerfectField F p variable {E K} in theorem PerfectField.splits_of_natSepDegree_eq_one [PerfectField K] {f : E[X]} (i : E →+* K) (hf : f.natSepDegree = 1) : f.Splits i := (perfectField_iff_splits_of_natSepDegree_eq_one K).mp ‹_› _ (natSepDegree_map K f i ▸ hf)
.lake/packages/mathlib/Mathlib/FieldTheory/Perfect.lean
import Mathlib.Algebra.CharP.Basic import Mathlib.Algebra.CharP.Reduced import Mathlib.FieldTheory.KummerPolynomial import Mathlib.FieldTheory.Separable /-! # Perfect fields and rings In this file we define perfect fields, together with a generalisation to (commutative) rings in prime characteristic. ## Main definitions / statements: * `PerfectRing`: a ring of characteristic `p` (prime) is said to be perfect in the sense of Serre, if its absolute Frobenius map `x ↦ xᵖ` is bijective. * `PerfectField`: a field `K` is said to be perfect if every irreducible polynomial over `K` is separable. * `PerfectRing.toPerfectField`: a field that is perfect in the sense of Serre is a perfect field. * `PerfectField.toPerfectRing`: a perfect field of characteristic `p` (prime) is perfect in the sense of Serre. * `PerfectField.ofCharZero`: all fields of characteristic zero are perfect. * `PerfectField.ofFinite`: all finite fields are perfect. * `PerfectField.separable_iff_squarefree`: a polynomial over a perfect field is separable iff it is square-free. * `Algebra.IsAlgebraic.isSeparable_of_perfectField`, `Algebra.IsAlgebraic.perfectField`: if `L / K` is an algebraic extension, `K` is a perfect field, then `L / K` is separable, and `L` is also a perfect field. -/ open Function Polynomial /-- A perfect ring of characteristic `p` (prime) in the sense of Serre. NB: This is not related to the concept with the same name introduced by Bass (related to projective covers of modules). -/ class PerfectRing (R : Type*) (p : ℕ) [CommSemiring R] [ExpChar R p] : Prop where /-- A ring is perfect if the Frobenius map is bijective. -/ bijective_frobenius : Bijective <| frobenius R p section PerfectRing variable (R : Type*) (p m n : ℕ) [CommSemiring R] [ExpChar R p] /-- For a reduced ring, surjectivity of the Frobenius map is a sufficient condition for perfection. -/ lemma PerfectRing.ofSurjective (R : Type*) (p : ℕ) [CommRing R] [ExpChar R p] [IsReduced R] (h : Surjective <| frobenius R p) : PerfectRing R p := ⟨frobenius_inj R p, h⟩ instance PerfectRing.ofFiniteOfIsReduced (R : Type*) [CommRing R] [ExpChar R p] [Finite R] [IsReduced R] : PerfectRing R p := ofSurjective _ _ <| Finite.surjective_of_injective (frobenius_inj R p) variable [PerfectRing R p] @[simp] theorem bijective_frobenius : Bijective (frobenius R p) := PerfectRing.bijective_frobenius theorem bijective_iterateFrobenius : Bijective (iterateFrobenius R p n) := coe_iterateFrobenius R p n ▸ (bijective_frobenius R p).iterate n @[simp] theorem injective_frobenius : Injective (frobenius R p) := (bijective_frobenius R p).1 @[simp] theorem surjective_frobenius : Surjective (frobenius R p) := (bijective_frobenius R p).2 /-- The Frobenius automorphism for a perfect ring. -/ @[simps! apply] noncomputable def frobeniusEquiv : R ≃+* R := RingEquiv.ofBijective (frobenius R p) PerfectRing.bijective_frobenius @[simp] theorem coe_frobeniusEquiv : ⇑(frobeniusEquiv R p) = frobenius R p := rfl theorem frobeniusEquiv_def (x : R) : frobeniusEquiv R p x = x ^ p := rfl /-- The iterated Frobenius automorphism for a perfect ring. -/ @[simps! apply] noncomputable def iterateFrobeniusEquiv : R ≃+* R := RingEquiv.ofBijective (iterateFrobenius R p n) (bijective_iterateFrobenius R p n) @[simp] theorem coe_iterateFrobeniusEquiv : ⇑(iterateFrobeniusEquiv R p n) = iterateFrobenius R p n := rfl theorem iterateFrobeniusEquiv_def (x : R) : iterateFrobeniusEquiv R p n x = x ^ p ^ n := rfl theorem iterateFrobeniusEquiv_add_apply (x : R) : iterateFrobeniusEquiv R p (m + n) x = iterateFrobeniusEquiv R p m (iterateFrobeniusEquiv R p n x) := iterateFrobenius_add_apply R p m n x theorem iterateFrobeniusEquiv_add : iterateFrobeniusEquiv R p (m + n) = (iterateFrobeniusEquiv R p n).trans (iterateFrobeniusEquiv R p m) := RingEquiv.ext (iterateFrobeniusEquiv_add_apply R p m n) theorem iterateFrobeniusEquiv_symm_add_apply (x : R) : (iterateFrobeniusEquiv R p (m + n)).symm x = (iterateFrobeniusEquiv R p m).symm ((iterateFrobeniusEquiv R p n).symm x) := (iterateFrobeniusEquiv R p (m + n)).injective <| by rw [RingEquiv.apply_symm_apply, add_comm, iterateFrobeniusEquiv_add_apply, RingEquiv.apply_symm_apply, RingEquiv.apply_symm_apply] theorem iterateFrobeniusEquiv_symm_add : (iterateFrobeniusEquiv R p (m + n)).symm = (iterateFrobeniusEquiv R p n).symm.trans (iterateFrobeniusEquiv R p m).symm := RingEquiv.ext (iterateFrobeniusEquiv_symm_add_apply R p m n) theorem iterateFrobeniusEquiv_zero_apply (x : R) : iterateFrobeniusEquiv R p 0 x = x := by rw [iterateFrobeniusEquiv_def, pow_zero, pow_one] theorem iterateFrobeniusEquiv_one_apply (x : R) : iterateFrobeniusEquiv R p 1 x = x ^ p := by rw [iterateFrobeniusEquiv_def, pow_one] @[simp] theorem iterateFrobeniusEquiv_zero : iterateFrobeniusEquiv R p 0 = RingEquiv.refl R := RingEquiv.ext (iterateFrobeniusEquiv_zero_apply R p) @[simp] theorem iterateFrobeniusEquiv_one : iterateFrobeniusEquiv R p 1 = frobeniusEquiv R p := RingEquiv.ext (iterateFrobeniusEquiv_one_apply R p) theorem iterateFrobeniusEquiv_eq_pow : iterateFrobeniusEquiv R p n = frobeniusEquiv R p ^ n := DFunLike.ext' <| show _ = ⇑(RingAut.toPerm _ _) by rw [map_pow, Equiv.Perm.coe_pow]; exact (pow_iterate p n).symm theorem iterateFrobeniusEquiv_symm : (iterateFrobeniusEquiv R p n).symm = (frobeniusEquiv R p).symm ^ n := by rw [iterateFrobeniusEquiv_eq_pow]; exact (inv_pow _ _).symm @[simp] theorem frobeniusEquiv_symm_apply_frobenius (x : R) : (frobeniusEquiv R p).symm (frobenius R p x) = x := leftInverse_surjInv PerfectRing.bijective_frobenius x @[simp] theorem frobenius_apply_frobeniusEquiv_symm (x : R) : frobenius R p ((frobeniusEquiv R p).symm x) = x := surjInv_eq _ _ @[simp] theorem frobenius_comp_frobeniusEquiv_symm : (frobenius R p).comp (frobeniusEquiv R p).symm = RingHom.id R := by ext; simp @[simp] theorem frobeniusEquiv_symm_comp_frobenius : ((frobeniusEquiv R p).symm : R →+* R).comp (frobenius R p) = RingHom.id R := by ext; simp @[simp] theorem coe_frobenius_comp_coe_frobeniusEquiv_symm : ⇑(frobenius R p) ∘ ⇑(frobeniusEquiv R p).symm = id := by ext simp @[simp] theorem coe_frobeniusEquiv_symm_comp_coe_frobenius : ⇑(frobeniusEquiv R p).symm ∘ ⇑(frobenius R p) = id := by ext simp @[simp] theorem frobeniusEquiv_symm_pow_p (x : R) : ((frobeniusEquiv R p).symm x) ^ p = x := frobenius_apply_frobeniusEquiv_symm R p x @[simp] theorem iterate_frobeniusEquiv_symm_pow_p_pow (x : R) (n : ℕ) : ((frobeniusEquiv R p).symm ^[n]) x ^ (p ^ n) = x := by induction n generalizing x with | zero => simp | succ n ih => simp [pow_succ, pow_mul, ih] section commute variable {R S : Type*} [CommSemiring R] [CommSemiring S] (p : ℕ) [ExpChar R p] [PerfectRing R p] [ExpChar S p] [PerfectRing S p] /-- The `(frobeniusEquiv R p).symm` version of `MonoidHom.map_frobenius`. `(frobeniusEquiv R p).symm` commute with any monoid homomorphisms. -/ theorem MonoidHom.map_frobeniusEquiv_symm (f : R →* S) (x : R) : f ((frobeniusEquiv R p).symm x) = (frobeniusEquiv S p).symm (f x) := by apply_fun (frobeniusEquiv S p) simp [← MonoidHom.map_frobenius] theorem RingHom.map_frobeniusEquiv_symm (f : R →+* S) (x : R) : f ((frobeniusEquiv R p).symm x) = (frobeniusEquiv S p).symm (f x) := by apply_fun (frobeniusEquiv S p) simp [← RingHom.map_frobenius] theorem MonoidHom.map_iterate_frobeniusEquiv_symm (f : R →* S) (n : ℕ) (x : R) : f (((frobeniusEquiv R p).symm ^[n]) x) = ((frobeniusEquiv S p).symm ^[n]) (f x) := by apply_fun (frobeniusEquiv S p)^[n] · simp only [coe_frobeniusEquiv, ← map_iterate_frobenius] · rw [← Function.comp_apply (f := (⇑(frobenius R p))^[n]), ← Function.comp_apply (f := (⇑(frobenius S p))^[n]), ← Function.Commute.comp_iterate, ← Function.Commute.comp_iterate] · simp all_goals rw [← coe_frobeniusEquiv]; simp [Function.Commute, Function.Semiconj] apply Function.Injective.iterate simp theorem RingHom.map_iterate_frobeniusEquiv_symm (f : R →+* S) (n : ℕ) (x : R) : f (((frobeniusEquiv R p).symm ^[n]) x) = ((frobeniusEquiv S p).symm ^[n]) (f x) := MonoidHom.map_iterate_frobeniusEquiv_symm p (f.toMonoidHom) n x end commute theorem injective_pow_p {x y : R} (h : x ^ p = y ^ p) : x = y := (frobeniusEquiv R p).injective h lemma polynomial_expand_eq (f : R[X]) : expand R p f = (f.map (frobeniusEquiv R p).symm) ^ p := by rw [← (f.map (S := R) (frobeniusEquiv R p).symm).expand_char p, map_expand, map_map, frobenius_comp_frobeniusEquiv_symm, map_id] @[simp] theorem not_irreducible_expand (R p) [CommSemiring R] [Fact p.Prime] [CharP R p] [PerfectRing R p] (f : R[X]) : ¬ Irreducible (expand R p f) := by rw [polynomial_expand_eq] exact not_irreducible_pow (Fact.out : p.Prime).ne_one instance instPerfectRingProd (S : Type*) [CommSemiring S] [ExpChar S p] [PerfectRing S p] : PerfectRing (R × S) p where bijective_frobenius := (bijective_frobenius R p).prodMap (bijective_frobenius S p) end PerfectRing /-- A perfect field. See also `PerfectRing` for a generalisation in positive characteristic. -/ class PerfectField (K : Type*) [Field K] : Prop where /-- A field is perfect if every irreducible polynomial is separable. -/ separable_of_irreducible : ∀ {f : K[X]}, Irreducible f → f.Separable lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ) [Field K] [ExpChar K p] [PerfectRing K p] : PerfectField K := by obtain hp | ⟨hp⟩ := ‹ExpChar K p› · exact ⟨Irreducible.separable⟩ refine PerfectField.mk fun hf ↦ ?_ rcases separable_or p hf with h | ⟨-, g, -, rfl⟩ · assumption · exfalso; revert hf; haveI := Fact.mk hp; simp namespace PerfectField variable {K : Type*} [Field K] instance ofCharZero [CharZero K] : PerfectField K := ⟨Irreducible.separable⟩ instance ofFinite [Finite K] : PerfectField K := by obtain ⟨p, _instP⟩ := CharP.exists K have : Fact p.Prime := ⟨CharP.char_is_prime K p⟩ exact PerfectRing.toPerfectField K p variable [PerfectField K] /-- A perfect field of characteristic `p` (prime) is a perfect ring. -/ instance toPerfectRing (p : ℕ) [hp : ExpChar K p] : PerfectRing K p := by refine PerfectRing.ofSurjective _ _ fun y ↦ ?_ rcases hp with _ | hp · simp [frobenius] rw [← not_forall_not] apply mt (X_pow_sub_C_irreducible_of_prime hp) apply mt separable_of_irreducible simp [separable_def, isCoprime_zero_right, isUnit_iff_degree_eq_zero, derivative_X_pow, degree_X_pow_sub_C hp.pos, hp.ne_zero] theorem separable_iff_squarefree {g : K[X]} : g.Separable ↔ Squarefree g := by refine ⟨Separable.squarefree, fun sqf ↦ isCoprime_of_irreducible_dvd (sqf.ne_zero ·.1) ?_⟩ rintro p (h : Irreducible p) ⟨q, rfl⟩ (dvd : p ∣ derivative (p * q)) replace dvd : p ∣ q := by rw [derivative_mul, dvd_add_left (dvd_mul_right p _)] at dvd exact (separable_of_irreducible h).dvd_of_dvd_mul_left dvd exact (h.1 : ¬ IsUnit p) (sqf _ <| mul_dvd_mul_left _ dvd) end PerfectField /-- If `L / K` is an algebraic extension, `K` is a perfect field, then `L / K` is separable. -/ instance Algebra.IsAlgebraic.isSeparable_of_perfectField {K L : Type*} [Field K] [Field L] [Algebra K L] [Algebra.IsAlgebraic K L] [PerfectField K] : Algebra.IsSeparable K L := ⟨fun x ↦ PerfectField.separable_of_irreducible <| minpoly.irreducible (Algebra.IsIntegral.isIntegral x)⟩ /-- If `L / K` is an algebraic extension, `K` is a perfect field, then so is `L`. -/ theorem Algebra.IsAlgebraic.perfectField {K L : Type*} [Field K] [Field L] [Algebra K L] [Algebra.IsAlgebraic K L] [PerfectField K] : PerfectField L := ⟨fun {f} hf ↦ by obtain ⟨_, _, hi, h⟩ := hf.exists_dvd_monic_irreducible_of_isIntegral (K := K) exact (PerfectField.separable_of_irreducible hi).map |>.of_dvd h⟩ namespace Polynomial variable {R : Type*} [CommRing R] [IsDomain R] (p n : ℕ) [ExpChar R p] (f : R[X]) open Multiset theorem roots_expand_pow_map_iterateFrobenius_le : (expand R (p ^ n) f).roots.map (iterateFrobenius R p n) ≤ p ^ n • f.roots := by classical refine le_iff_count.2 fun r ↦ ?_ by_cases h : ∃ s, r = s ^ p ^ n · obtain ⟨s, rfl⟩ := h simp_rw [count_nsmul, count_roots, ← rootMultiplicity_expand_pow, ← count_roots, count_map, count_eq_card_filter_eq] exact card_le_card (monotone_filter_right _ fun _ h ↦ iterateFrobenius_inj R p n h) convert Nat.zero_le _ simp_rw [count_map, card_eq_zero] exact ext' fun t ↦ count_zero t ▸ count_filter_of_neg fun h' ↦ h ⟨t, h'⟩ theorem roots_expand_map_frobenius_le : (expand R p f).roots.map (frobenius R p) ≤ p • f.roots := by rw [← iterateFrobenius_one] convert ← roots_expand_pow_map_iterateFrobenius_le p 1 f <;> apply pow_one theorem roots_expand_pow_image_iterateFrobenius_subset [DecidableEq R] : (expand R (p ^ n) f).roots.toFinset.image (iterateFrobenius R p n) ⊆ f.roots.toFinset := by rw [Finset.image_toFinset, ← (roots f).toFinset_nsmul _ (expChar_pow_pos R p n).ne', toFinset_subset] exact subset_of_le (roots_expand_pow_map_iterateFrobenius_le p n f) theorem roots_expand_image_frobenius_subset [DecidableEq R] : (expand R p f).roots.toFinset.image (frobenius R p) ⊆ f.roots.toFinset := by rw [← iterateFrobenius_one] convert ← roots_expand_pow_image_iterateFrobenius_subset p 1 f apply pow_one section PerfectRing variable {p n f} variable [PerfectRing R p] theorem roots_expand_pow : (expand R (p ^ n) f).roots = p ^ n • f.roots.map (iterateFrobeniusEquiv R p n).symm := by classical refine ext' fun r ↦ ?_ rw [count_roots, rootMultiplicity_expand_pow, ← count_roots, count_nsmul, count_map, count_eq_card_filter_eq]; congr; ext exact (iterateFrobeniusEquiv R p n).eq_symm_apply.symm theorem roots_expand : (expand R p f).roots = p • f.roots.map (frobeniusEquiv R p).symm := by conv_lhs => rw [← pow_one p, roots_expand_pow, iterateFrobeniusEquiv_eq_pow, pow_one] rfl theorem roots_X_pow_char_pow_sub_C {y : R} : (X ^ p ^ n - C y).roots = p ^ n • {(iterateFrobeniusEquiv R p n).symm y} := by have H := roots_expand_pow (p := p) (n := n) (f := X - C y) rwa [roots_X_sub_C, Multiset.map_singleton, map_sub, expand_X, expand_C] at H theorem roots_X_pow_char_pow_sub_C_pow {y : R} {m : ℕ} : ((X ^ p ^ n - C y) ^ m).roots = (m * p ^ n) • {(iterateFrobeniusEquiv R p n).symm y} := by rw [roots_pow, roots_X_pow_char_pow_sub_C, mul_smul] theorem roots_X_pow_char_sub_C {y : R} : (X ^ p - C y).roots = p • {(frobeniusEquiv R p).symm y} := by have H := roots_X_pow_char_pow_sub_C (p := p) (n := 1) (y := y) rwa [pow_one, iterateFrobeniusEquiv_one] at H theorem roots_X_pow_char_sub_C_pow {y : R} {m : ℕ} : ((X ^ p - C y) ^ m).roots = (m * p) • {(frobeniusEquiv R p).symm y} := by have H := roots_X_pow_char_pow_sub_C_pow (p := p) (n := 1) (y := y) (m := m) rwa [pow_one, iterateFrobeniusEquiv_one] at H theorem roots_expand_pow_map_iterateFrobenius : (expand R (p ^ n) f).roots.map (iterateFrobenius R p n) = p ^ n • f.roots := by simp_rw [← coe_iterateFrobeniusEquiv, roots_expand_pow, Multiset.map_nsmul, Multiset.map_map, comp_apply, RingEquiv.apply_symm_apply, map_id'] theorem roots_expand_map_frobenius : (expand R p f).roots.map (frobenius R p) = p • f.roots := by simp [roots_expand, Multiset.map_nsmul] theorem roots_expand_image_iterateFrobenius [DecidableEq R] : (expand R (p ^ n) f).roots.toFinset.image (iterateFrobenius R p n) = f.roots.toFinset := by rw [Finset.image_toFinset, roots_expand_pow_map_iterateFrobenius, (roots f).toFinset_nsmul _ (expChar_pow_pos R p n).ne'] theorem roots_expand_image_frobenius [DecidableEq R] : (expand R p f).roots.toFinset.image (frobenius R p) = f.roots.toFinset := by rw [Finset.image_toFinset, roots_expand_map_frobenius, (roots f).toFinset_nsmul _ (expChar_pos R p).ne'] end PerfectRing variable [DecidableEq R] /-- If `f` is a polynomial over an integral domain `R` of characteristic `p`, then there is a map from the set of roots of `Polynomial.expand R p f` to the set of roots of `f`. It's given by `x ↦ x ^ p`, see `rootsExpandToRoots_apply`. -/ noncomputable def rootsExpandToRoots : (expand R p f).roots.toFinset ↪ f.roots.toFinset where toFun x := ⟨x ^ p, roots_expand_image_frobenius_subset p f (Finset.mem_image_of_mem _ x.2)⟩ inj' _ _ h := Subtype.ext (frobenius_inj R p <| Subtype.ext_iff.1 h) @[simp] theorem rootsExpandToRoots_apply (x) : (rootsExpandToRoots p f x : R) = x ^ p := rfl open scoped Classical in /-- If `f` is a polynomial over an integral domain `R` of characteristic `p`, then there is a map from the set of roots of `Polynomial.expand R (p ^ n) f` to the set of roots of `f`. It's given by `x ↦ x ^ (p ^ n)`, see `rootsExpandPowToRoots_apply`. -/ noncomputable def rootsExpandPowToRoots : (expand R (p ^ n) f).roots.toFinset ↪ f.roots.toFinset where toFun x := ⟨x ^ p ^ n, roots_expand_pow_image_iterateFrobenius_subset p n f (Finset.mem_image_of_mem _ x.2)⟩ inj' _ _ h := Subtype.ext (iterateFrobenius_inj R p n <| Subtype.ext_iff.1 h) @[simp] theorem rootsExpandPowToRoots_apply (x) : (rootsExpandPowToRoots p n f x : R) = x ^ p ^ n := rfl variable [PerfectRing R p] /-- If `f` is a polynomial over a perfect integral domain `R` of characteristic `p`, then there is a bijection from the set of roots of `Polynomial.expand R p f` to the set of roots of `f`. It's given by `x ↦ x ^ p`, see `rootsExpandEquivRoots_apply`. -/ noncomputable def rootsExpandEquivRoots : (expand R p f).roots.toFinset ≃ f.roots.toFinset := ((frobeniusEquiv R p).image _).trans <| .setCongr <| show _ '' setOf (· ∈ _) = setOf (· ∈ _) by classical simp_rw [← roots_expand_image_frobenius (p := p) (f := f), Finset.setOf_mem, Finset.coe_image, RingEquiv.toEquiv_eq_coe, EquivLike.coe_coe, frobeniusEquiv_apply] @[simp] theorem rootsExpandEquivRoots_apply (x) : (rootsExpandEquivRoots p f x : R) = x ^ p := rfl /-- If `f` is a polynomial over a perfect integral domain `R` of characteristic `p`, then there is a bijection from the set of roots of `Polynomial.expand R (p ^ n) f` to the set of roots of `f`. It's given by `x ↦ x ^ (p ^ n)`, see `rootsExpandPowEquivRoots_apply`. -/ noncomputable def rootsExpandPowEquivRoots (n : ℕ) : (expand R (p ^ n) f).roots.toFinset ≃ f.roots.toFinset := ((iterateFrobeniusEquiv R p n).image _).trans <| .setCongr <| show _ '' (setOf (· ∈ _)) = setOf (· ∈ _) by classical simp_rw [← roots_expand_image_iterateFrobenius (p := p) (f := f) (n := n), Finset.setOf_mem, Finset.coe_image, RingEquiv.toEquiv_eq_coe, EquivLike.coe_coe, iterateFrobeniusEquiv_apply] @[simp] theorem rootsExpandPowEquivRoots_apply (n : ℕ) (x) : (rootsExpandPowEquivRoots p f n x : R) = x ^ p ^ n := rfl end Polynomial
.lake/packages/mathlib/Mathlib/FieldTheory/IsPerfectClosure.lean
import Mathlib.FieldTheory.PurelyInseparable.Basic import Mathlib.FieldTheory.PerfectClosure /-! # `IsPerfectClosure` predicate This file contains `IsPerfectClosure` which asserts that `L` is a perfect closure of `K` under a ring homomorphism `i : K →+* L`, as well as its basic properties. ## Main definitions - `pNilradical`: given a natural number `p`, the `p`-nilradical of a ring is defined to be the nilradical if `p > 1` (`pNilradical_eq_nilradical`), and defined to be the zero ideal if `p ≤ 1` (`pNilradical_eq_bot'`). Equivalently, it is the ideal consisting of elements `x` such that `x ^ p ^ n = 0` for some `n` (`mem_pNilradical`). - `IsPRadical`: a ring homomorphism `i : K →+* L` of characteristic `p` rings is called `p`-radical, if or any element `x` of `L` there is `n : ℕ` such that `x ^ (p ^ n)` is contained in `K`, and the kernel of `i` is contained in the `p`-nilradical of `K`. A generalization of purely inseparable extension for fields. - `IsPerfectClosure`: if `i : K →+* L` is `p`-radical ring homomorphism, then it makes `L` a perfect closure of `K`, if `L` is perfect. Our definition makes it synonymous to `IsPRadical` if `PerfectRing L p` is present. A caveat is that you need to write `[PerfectRing L p] [IsPerfectClosure i p]`. This is similar to `PerfectRing` which has `ExpChar` as a prerequisite. - `PerfectRing.lift`: if a `p`-radical ring homomorphism `K →+* L` is given, `M` is a perfect ring, then any ring homomorphism `K →+* M` can be lifted to `L →+* M`. This is similar to `IsAlgClosed.lift` and `IsSepClosed.lift`. - `PerfectRing.liftEquiv`: `K →+* M` is one-to-one correspondence to `L →+* M`, given by `PerfectRing.lift`. This is a generalization to `PerfectClosure.lift`. - `IsPerfectClosure.equiv`: perfect closures of a ring are isomorphic. ## Main results - `IsPRadical.trans`: composition of `p`-radical ring homomorphisms is also `p`-radical. - `PerfectClosure.isPRadical`: the absolute perfect closure `PerfectClosure` is a `p`-radical extension over the base ring, in particular, it is a perfect closure of the base ring. - `IsPRadical.isPurelyInseparable`, `IsPurelyInseparable.isPRadical`: `p`-radical and purely inseparable are equivalent for fields. - The (relative) perfect closure `perfectClosure` is a perfect closure (inferred from `IsPurelyInseparable.isPRadical` automatically by Lean). ## Tags perfect ring, perfect closure, purely inseparable -/ open Module Polynomial IntermediateField Field noncomputable section /-- Given a natural number `p`, the `p`-nilradical of a ring is defined to be the nilradical if `p > 1` (`pNilradical_eq_nilradical`), and defined to be the zero ideal if `p ≤ 1` (`pNilradical_eq_bot'`). Equivalently, it is the ideal consisting of elements `x` such that `x ^ p ^ n = 0` for some `n` (`mem_pNilradical`). -/ def pNilradical (R : Type*) [CommSemiring R] (p : ℕ) : Ideal R := if 1 < p then nilradical R else ⊥ theorem pNilradical_le_nilradical {R : Type*} [CommSemiring R] {p : ℕ} : pNilradical R p ≤ nilradical R := by by_cases hp : 1 < p · rw [pNilradical, if_pos hp] simp_rw [pNilradical, if_neg hp, bot_le] theorem pNilradical_eq_nilradical {R : Type*} [CommSemiring R] {p : ℕ} (hp : 1 < p) : pNilradical R p = nilradical R := by rw [pNilradical, if_pos hp] theorem pNilradical_eq_bot {R : Type*} [CommSemiring R] {p : ℕ} (hp : ¬ 1 < p) : pNilradical R p = ⊥ := by rw [pNilradical, if_neg hp] theorem pNilradical_eq_bot' {R : Type*} [CommSemiring R] {p : ℕ} (hp : p ≤ 1) : pNilradical R p = ⊥ := pNilradical_eq_bot (not_lt.2 hp) theorem pNilradical_prime {R : Type*} [CommSemiring R] {p : ℕ} (hp : p.Prime) : pNilradical R p = nilradical R := pNilradical_eq_nilradical hp.one_lt theorem pNilradical_one {R : Type*} [CommSemiring R] : pNilradical R 1 = ⊥ := pNilradical_eq_bot' rfl.le theorem mem_pNilradical {R : Type*} [CommSemiring R] {p : ℕ} {x : R} : x ∈ pNilradical R p ↔ ∃ n : ℕ, x ^ p ^ n = 0 := by by_cases hp : 1 < p · rw [pNilradical_eq_nilradical hp] refine ⟨fun ⟨n, h⟩ ↦ ⟨n, ?_⟩, fun ⟨n, h⟩ ↦ ⟨p ^ n, h⟩⟩ rw [← Nat.sub_add_cancel ((n.lt_pow_self hp).le), pow_add, h, mul_zero] rw [pNilradical_eq_bot hp, Ideal.mem_bot] refine ⟨fun h ↦ ⟨0, by rw [pow_zero, pow_one, h]⟩, fun ⟨n, h⟩ ↦ ?_⟩ rcases Nat.le_one_iff_eq_zero_or_eq_one.1 (not_lt.1 hp) with hp | hp · by_cases hn : n = 0 · rwa [hn, pow_zero, pow_one] at h rw [hp, zero_pow hn, pow_zero] at h subsingleton [subsingleton_of_zero_eq_one h.symm] rwa [hp, one_pow, pow_one] at h theorem sub_mem_pNilradical_iff_pow_expChar_pow_eq {R : Type*} [CommRing R] {p : ℕ} [ExpChar R p] {x y : R} : x - y ∈ pNilradical R p ↔ ∃ n : ℕ, x ^ p ^ n = y ^ p ^ n := by simp_rw [mem_pNilradical, sub_pow_expChar_pow, sub_eq_zero] theorem pow_expChar_pow_inj_of_pNilradical_eq_bot (R : Type*) [CommRing R] (p : ℕ) [ExpChar R p] (h : pNilradical R p = ⊥) (n : ℕ) : Function.Injective fun x : R ↦ x ^ p ^ n := fun _ _ H ↦ sub_eq_zero.1 <| Ideal.mem_bot.1 <| h ▸ sub_mem_pNilradical_iff_pow_expChar_pow_eq.2 ⟨n, H⟩ theorem pNilradical_eq_bot_of_frobenius_inj (R : Type*) [CommSemiring R] (p : ℕ) [ExpChar R p] (h : Function.Injective (frobenius R p)) : pNilradical R p = ⊥ := bot_unique fun x ↦ by rw [mem_pNilradical, Ideal.mem_bot] exact fun ⟨n, _⟩ ↦ h.iterate n (by rwa [← coe_iterateFrobenius, map_zero]) theorem PerfectRing.pNilradical_eq_bot (R : Type*) [CommSemiring R] (p : ℕ) [ExpChar R p] [PerfectRing R p] : pNilradical R p = ⊥ := pNilradical_eq_bot_of_frobenius_inj R p (injective_frobenius R p) section IsPerfectClosure variable {K L M N : Type*} section CommSemiring variable [CommSemiring K] [CommSemiring L] [CommSemiring M] (i : K →+* L) (j : K →+* M) (f : L →+* M) (p : ℕ) /-- If `i : K →+* L` is a ring homomorphism of characteristic `p` rings, then it is called `p`-radical if the following conditions are satisfied: - For any element `x` of `L` there is `n : ℕ` such that `x ^ (p ^ n)` is contained in `K`. - The kernel of `i` is contained in the `p`-nilradical of `K`. It is a generalization of purely inseparable extension for fields. -/ @[mk_iff] class IsPRadical : Prop where pow_mem' : ∀ x : L, ∃ (n : ℕ) (y : K), i y = x ^ p ^ n ker_le' : RingHom.ker i ≤ pNilradical K p theorem IsPRadical.pow_mem [IsPRadical i p] (x : L) : ∃ (n : ℕ) (y : K), i y = x ^ p ^ n := pow_mem' x theorem IsPRadical.ker_le [IsPRadical i p] : RingHom.ker i ≤ pNilradical K p := ker_le' theorem IsPRadical.comap_pNilradical [IsPRadical i p] : (pNilradical L p).comap i = pNilradical K p := by refine le_antisymm (fun x h ↦ mem_pNilradical.2 ?_) (fun x h ↦ ?_) · obtain ⟨n, h⟩ := mem_pNilradical.1 <| Ideal.mem_comap.1 h obtain ⟨m, h⟩ := mem_pNilradical.1 <| ker_le i p ((map_pow i x _).symm ▸ h) exact ⟨n + m, by rwa [pow_add, pow_mul]⟩ simp only [Ideal.mem_comap, mem_pNilradical] at h ⊢ obtain ⟨n, h⟩ := h exact ⟨n, by simpa only [map_pow, map_zero] using congr(i $h)⟩ variable (K) in instance IsPRadical.of_id : IsPRadical (RingHom.id K) p where pow_mem' x := ⟨0, x, by simp⟩ ker_le' x h := by convert Ideal.zero_mem _ /-- Composition of `p`-radical ring homomorphisms is also `p`-radical. -/ theorem IsPRadical.trans [IsPRadical i p] [IsPRadical f p] : IsPRadical (f.comp i) p where pow_mem' x := by obtain ⟨n, y, hy⟩ := pow_mem f p x obtain ⟨m, z, hz⟩ := pow_mem i p y exact ⟨n + m, z, by rw [RingHom.comp_apply, hz, map_pow, hy, pow_add, pow_mul]⟩ ker_le' x h := by rw [RingHom.mem_ker, RingHom.comp_apply, ← RingHom.mem_ker] at h simpa only [← Ideal.mem_comap, comap_pNilradical] using ker_le f p h /-- If `i : K →+* L` is a `p`-radical ring homomorphism, then it makes `L` a perfect closure of `K`, if `L` is perfect. In this case the kernel of `i` is equal to the `p`-nilradical of `K` (see `IsPerfectClosure.ker_eq`). Our definition makes it synonymous to `IsPRadical` if `PerfectRing L p` is present. A caveat is that you need to write `[PerfectRing L p] [IsPerfectClosure i p]`. This is similar to `PerfectRing` which has `ExpChar` as a prerequisite. -/ @[nolint unusedArguments] abbrev IsPerfectClosure [ExpChar L p] [PerfectRing L p] := IsPRadical i p /-- If `i : K →+* L` is a ring homomorphism of exponential characteristic `p` rings, such that `L` is perfect, then the `p`-nilradical of `K` is contained in the kernel of `i`. -/ theorem RingHom.pNilradical_le_ker_of_perfectRing [ExpChar L p] [PerfectRing L p] : pNilradical K p ≤ RingHom.ker i := fun x h ↦ by obtain ⟨n, h⟩ := mem_pNilradical.1 h replace h := congr((iterateFrobeniusEquiv L p n).symm (i $h)) rwa [map_pow, ← iterateFrobenius_def, ← iterateFrobeniusEquiv_apply, RingEquiv.symm_apply_apply, map_zero, map_zero] at h variable [ExpChar L p] in theorem IsPerfectClosure.ker_eq [PerfectRing L p] [IsPerfectClosure i p] : RingHom.ker i = pNilradical K p := IsPRadical.ker_le'.antisymm (i.pNilradical_le_ker_of_perfectRing p) namespace PerfectRing /- NOTE: To define `PerfectRing.lift_aux`, only the `IsPRadical.pow_mem` is required, but not `IsPRadical.ker_le`. But in order to use typeclass, here we require the whole `IsPRadical`. -/ variable [ExpChar M p] [PerfectRing M p] [IsPRadical i p] theorem lift_aux (x : L) : ∃ y : ℕ × K, i y.2 = x ^ p ^ y.1 := by obtain ⟨n, y, h⟩ := IsPRadical.pow_mem i p x exact ⟨(n, y), h⟩ /-- If `i : K →+* L` and `j : K →+* M` are ring homomorphisms of characteristic `p` rings, such that `i` is `p`-radical (in fact only the `IsPRadical.pow_mem` is required) and `M` is a perfect ring, then one can define a map `L → M` which maps an element `x` of `L` to `y ^ (p ^ -n)` if `x ^ (p ^ n)` is equal to some element `y` of `K`. -/ def liftAux (x : L) : M := (iterateFrobeniusEquiv M p (Classical.choose (lift_aux i p x)).1).symm (j (Classical.choose (lift_aux i p x)).2) @[simp] theorem liftAux_self_apply [ExpChar L p] [PerfectRing L p] (x : L) : liftAux i i p x = x := by rw [liftAux, Classical.choose_spec (lift_aux i p x), ← iterateFrobenius_def, ← iterateFrobeniusEquiv_apply, RingEquiv.symm_apply_apply] @[simp] theorem liftAux_self [ExpChar L p] [PerfectRing L p] : liftAux i i p = id := funext (liftAux_self_apply i p) @[simp] theorem liftAux_id_apply (x : K) : liftAux (RingHom.id K) j p x = j x := by have := RingHom.id_apply _ ▸ Classical.choose_spec (lift_aux (RingHom.id K) p x) rw [liftAux, this, map_pow, ← iterateFrobenius_def, ← iterateFrobeniusEquiv_apply, RingEquiv.symm_apply_apply] @[simp] theorem liftAux_id : liftAux (RingHom.id K) j p = j := funext (liftAux_id_apply j p) end PerfectRing end CommSemiring section CommRing variable [CommRing K] [CommRing L] [CommRing M] [CommRing N] (i : K →+* L) (j : K →+* M) (k : K →+* N) (f : L →+* M) (g : L →+* N) (p : ℕ) [ExpChar M p] namespace IsPRadical /-- If `i : K →+* L` is `p`-radical, then for any ring `M` of exponential charactistic `p` whose `p`-nilradical is zero, the map `(L →+* M) → (K →+* M)` induced by `i` is injective. -/ theorem injective_comp_of_pNilradical_eq_bot [IsPRadical i p] (h : pNilradical M p = ⊥) : Function.Injective fun f : L →+* M ↦ f.comp i := fun f g heq ↦ by ext x obtain ⟨n, y, hx⟩ := IsPRadical.pow_mem i p x apply_fun _ using pow_expChar_pow_inj_of_pNilradical_eq_bot M p h n simpa only [← map_pow, ← hx] using congr($(heq) y) variable (M) /-- If `i : K →+* L` is `p`-radical, then for any reduced ring `M` of exponential charactistic `p`, the map `(L →+* M) → (K →+* M)` induced by `i` is injective. A special case of `IsPRadical.injective_comp_of_pNilradical_eq_bot` and a generalization of `IsPurelyInseparable.injective_comp_algebraMap`. -/ theorem injective_comp [IsPRadical i p] [IsReduced M] : Function.Injective fun f : L →+* M ↦ f.comp i := injective_comp_of_pNilradical_eq_bot i p <| bot_unique <| pNilradical_le_nilradical.trans (nilradical_eq_zero M).le /-- If `i : K →+* L` is `p`-radical, then for any perfect ring `M` of exponential charactistic `p`, the map `(L →+* M) → (K →+* M)` induced by `i` is injective. A special case of `IsPRadical.injective_comp_of_pNilradical_eq_bot`. -/ theorem injective_comp_of_perfect [IsPRadical i p] [PerfectRing M p] : Function.Injective fun f : L →+* M ↦ f.comp i := injective_comp_of_pNilradical_eq_bot i p (PerfectRing.pNilradical_eq_bot M p) end IsPRadical namespace PerfectRing variable [ExpChar K p] [PerfectRing M p] [IsPRadical i p] /-- If `i : K →+* L` and `j : K →+* M` are ring homomorphisms of characteristic `p` rings, such that `i` is `p`-radical, and `M` is a perfect ring, then `PerfectRing.liftAux` is well-defined. -/ theorem liftAux_apply (x : L) (n : ℕ) (y : K) (h : i y = x ^ p ^ n) : liftAux i j p x = (iterateFrobeniusEquiv M p n).symm (j y) := by rw [liftAux] have h' := Classical.choose_spec (lift_aux i p x) set n' := (Classical.choose (lift_aux i p x)).1 replace h := congr($(h.symm) ^ p ^ n') rw [← pow_mul, mul_comm, pow_mul, ← h', ← map_pow, ← map_pow, ← sub_eq_zero, ← map_sub, ← RingHom.mem_ker] at h obtain ⟨m, h⟩ := mem_pNilradical.1 (IsPRadical.ker_le i p h) refine (iterateFrobeniusEquiv M p (m + n + n')).injective ?_ conv_lhs => rw [iterateFrobeniusEquiv_add_apply, RingEquiv.apply_symm_apply] rw [add_assoc, add_comm n n', ← add_assoc, iterateFrobeniusEquiv_add_apply (m := m + n'), RingEquiv.apply_symm_apply, iterateFrobeniusEquiv_def, iterateFrobeniusEquiv_def, ← sub_eq_zero, ← map_pow, ← map_pow, ← map_sub, add_comm m, add_comm m, pow_add, pow_mul, pow_add, pow_mul, ← sub_pow_expChar_pow, h, map_zero] variable [ExpChar L p] /-- If `i : K →+* L` and `j : K →+* M` are ring homomorphisms of characteristic `p` rings, such that `i` is `p`-radical, and `M` is a perfect ring, then `PerfectRing.liftAux` is a ring homomorphism. This is similar to `IsAlgClosed.lift` and `IsSepClosed.lift`. -/ def lift : L →+* M where toFun := liftAux i j p map_one' := by simp [liftAux_apply i j p 1 0 1 (by rw [one_pow, map_one])] map_mul' x1 x2 := by obtain ⟨n1, y1, h1⟩ := IsPRadical.pow_mem i p x1 obtain ⟨n2, y2, h2⟩ := IsPRadical.pow_mem i p x2 rw [liftAux_apply i j p _ _ _ h1, liftAux_apply i j p _ _ _ h2, liftAux_apply i j p (x1 * x2) (n1 + n2) (y1 ^ p ^ n2 * y2 ^ p ^ n1) (by rw [map_mul, map_pow, map_pow, h1, h2, ← pow_mul, ← pow_add, ← pow_mul, ← pow_add, add_comm n2, mul_pow]), map_mul, map_pow, map_pow, map_mul, ← iterateFrobeniusEquiv_def] nth_rw 1 [iterateFrobeniusEquiv_symm_add_apply] rw [RingEquiv.symm_apply_apply, add_comm n1, iterateFrobeniusEquiv_symm_add_apply, ← iterateFrobeniusEquiv_def, RingEquiv.symm_apply_apply] map_zero' := by simp [liftAux_apply i j p 0 0 0 (by rw [pow_zero, pow_one, map_zero])] map_add' x1 x2 := by obtain ⟨n1, y1, h1⟩ := IsPRadical.pow_mem i p x1 obtain ⟨n2, y2, h2⟩ := IsPRadical.pow_mem i p x2 rw [liftAux_apply i j p _ _ _ h1, liftAux_apply i j p _ _ _ h2, liftAux_apply i j p (x1 + x2) (n1 + n2) (y1 ^ p ^ n2 + y2 ^ p ^ n1) (by rw [map_add, map_pow, map_pow, h1, h2, ← pow_mul, ← pow_add, ← pow_mul, ← pow_add, add_comm n2, add_pow_expChar_pow]), map_add, map_pow, map_pow, map_add, ← iterateFrobeniusEquiv_def] nth_rw 1 [iterateFrobeniusEquiv_symm_add_apply] rw [RingEquiv.symm_apply_apply, add_comm n1, iterateFrobeniusEquiv_symm_add_apply, ← iterateFrobeniusEquiv_def, RingEquiv.symm_apply_apply] theorem lift_apply (x : L) (n : ℕ) (y : K) (h : i y = x ^ p ^ n) : lift i j p x = (iterateFrobeniusEquiv M p n).symm (j y) := liftAux_apply i j p _ _ _ h @[simp] theorem lift_comp_apply (x : K) : lift i j p (i x) = j x := by rw [lift_apply i j p _ 0 x (by rw [pow_zero, pow_one]), iterateFrobeniusEquiv_zero]; rfl @[simp] theorem lift_comp : (lift i j p).comp i = j := RingHom.ext (lift_comp_apply i j p) theorem lift_self_apply [PerfectRing L p] (x : L) : lift i i p x = x := liftAux_self_apply i p x @[simp] theorem lift_self [PerfectRing L p] : lift i i p = RingHom.id L := RingHom.ext (liftAux_self_apply i p) theorem lift_id_apply (x : K) : lift (RingHom.id K) j p x = j x := liftAux_id_apply j p x @[simp] theorem lift_id : lift (RingHom.id K) j p = j := RingHom.ext (liftAux_id_apply j p) @[simp] theorem comp_lift : lift i (f.comp i) p = f := IsPRadical.injective_comp_of_perfect _ i p (lift_comp i _ p) theorem comp_lift_apply (x : L) : lift i (f.comp i) p x = f x := congr($(comp_lift i f p) x) variable (M) in /-- If `i : K →+* L` is a homomorphisms of characteristic `p` rings, such that `i` is `p`-radical, and `M` is a perfect ring of characteristic `p`, then `K →+* M` is one-to-one correspondence to `L →+* M`, given by `PerfectRing.lift`. This is a generalization to `PerfectClosure.lift`. -/ def liftEquiv : (K →+* M) ≃ (L →+* M) where toFun j := lift i j p invFun f := f.comp i left_inv f := lift_comp i f p right_inv f := comp_lift i f p theorem liftEquiv_apply : liftEquiv M i p j = lift i j p := rfl theorem liftEquiv_symm_apply : (liftEquiv M i p).symm f = f.comp i := rfl theorem liftEquiv_id_apply : liftEquiv M (RingHom.id K) p j = j := lift_id j p @[simp] theorem liftEquiv_id : liftEquiv M (RingHom.id K) p = Equiv.refl _ := Equiv.ext (liftEquiv_id_apply · p) section comp variable [ExpChar N p] [PerfectRing N p] [IsPRadical j p] @[simp] theorem lift_comp_lift : (lift j k p).comp (lift i j p) = lift i k p := IsPRadical.injective_comp_of_perfect _ i p (by ext; simp) @[simp] theorem lift_comp_lift_apply (x : L) : lift j k p (lift i j p x) = lift i k p x := congr($(lift_comp_lift i j k p) x) theorem lift_comp_lift_apply_eq_self [PerfectRing L p] (x : L) : lift j i p (lift i j p x) = x := by rw [lift_comp_lift_apply, lift_self_apply] theorem lift_comp_lift_eq_id [PerfectRing L p] : (lift j i p).comp (lift i j p) = RingHom.id L := RingHom.ext (lift_comp_lift_apply_eq_self i j p) end comp section liftEquiv_comp variable [ExpChar N p] [IsPRadical g p] [IsPRadical (g.comp i) p] @[simp] theorem lift_lift : lift g (lift i j p) p = lift (g.comp i) j p := by refine IsPRadical.injective_comp_of_perfect _ (g.comp i) p ?_ simp_rw [← RingHom.comp_assoc _ _ (lift g _ p), lift_comp] theorem lift_lift_apply (x : N) : lift g (lift i j p) p x = lift (g.comp i) j p x := congr($(lift_lift i j g p) x) @[simp] theorem liftEquiv_comp_apply : liftEquiv M g p (liftEquiv M i p j) = liftEquiv M (g.comp i) p j := lift_lift i j g p @[simp] theorem liftEquiv_trans : (liftEquiv M i p).trans (liftEquiv M g p) = liftEquiv M (g.comp i) p := Equiv.ext (liftEquiv_comp_apply i · g p) end liftEquiv_comp end PerfectRing namespace IsPerfectClosure variable [ExpChar K p] [ExpChar L p] [PerfectRing L p] [IsPerfectClosure i p] [PerfectRing M p] [IsPerfectClosure j p] /-- If `L` and `M` are both perfect closures of `K`, then there is a ring isomorphism `L ≃+* M`. This is similar to `IsAlgClosure.equiv` and `IsSepClosure.equiv`. -/ def equiv : L ≃+* M where __ := PerfectRing.lift i j p invFun := PerfectRing.liftAux j i p left_inv := PerfectRing.lift_comp_lift_apply_eq_self i j p right_inv := PerfectRing.lift_comp_lift_apply_eq_self j i p theorem equiv_toRingHom : (equiv i j p).toRingHom = PerfectRing.lift i j p := rfl @[simp] theorem equiv_symm : (equiv i j p).symm = equiv j i p := rfl theorem equiv_symm_toRingHom : (equiv i j p).symm.toRingHom = PerfectRing.lift j i p := rfl theorem equiv_apply (x : L) (n : ℕ) (y : K) (h : i y = x ^ p ^ n) : equiv i j p x = (iterateFrobeniusEquiv M p n).symm (j y) := PerfectRing.liftAux_apply i j p _ _ _ h theorem equiv_symm_apply (x : M) (n : ℕ) (y : K) (h : j y = x ^ p ^ n) : (equiv i j p).symm x = (iterateFrobeniusEquiv L p n).symm (i y) := by rw [equiv_symm, equiv_apply j i p _ _ _ h] theorem equiv_self_apply (x : L) : equiv i i p x = x := PerfectRing.liftAux_self_apply i p x @[simp] theorem equiv_self : equiv i i p = RingEquiv.refl L := RingEquiv.ext (equiv_self_apply i p) @[simp] theorem equiv_comp_apply (x : K) : equiv i j p (i x) = j x := PerfectRing.lift_comp_apply i j p x @[simp] theorem equiv_comp : RingHom.comp (equiv i j p) i = j := RingHom.ext (equiv_comp_apply i j p) section comp variable [ExpChar N p] [PerfectRing N p] [IsPerfectClosure k p] @[simp] theorem equiv_comp_equiv_apply (x : L) : equiv j k p (equiv i j p x) = equiv i k p x := PerfectRing.lift_comp_lift_apply i j k p x @[simp] theorem equiv_comp_equiv : (equiv i j p).trans (equiv j k p) = equiv i k p := RingEquiv.ext (equiv_comp_equiv_apply i j k p) theorem equiv_comp_equiv_apply_eq_self (x : L) : equiv j i p (equiv i j p x) = x := by rw [equiv_comp_equiv_apply, equiv_self_apply] theorem equiv_comp_equiv_eq_id : (equiv i j p).trans (equiv j i p) = RingEquiv.refl L := RingEquiv.ext (equiv_comp_equiv_apply_eq_self i j p) end comp end IsPerfectClosure end CommRing namespace PerfectClosure variable [CommRing K] (p : ℕ) [Fact p.Prime] [CharP K p] variable (K) /-- The absolute perfect closure `PerfectClosure` is a `p`-radical extension over the base ring. In particular, it is a perfect closure of the base ring, that is, `IsPerfectClosure (PerfectClosure.of K p) p`. -/ instance isPRadical : IsPRadical (PerfectClosure.of K p) p where pow_mem' x := PerfectClosure.induction_on x fun x ↦ ⟨x.1, x.2, by rw [← iterate_frobenius, iterate_frobenius_mk K p x.1 x.2]⟩ ker_le' x h := by rw [RingHom.mem_ker, of_apply, zero_def, mk_eq_iff] at h obtain ⟨n, h⟩ := h simp_rw [zero_add, ← coe_iterateFrobenius, map_zero] at h exact mem_pNilradical.2 ⟨n, h⟩ end PerfectClosure section Field variable [Field K] [Field L] [Algebra K L] (p : ℕ) [ExpChar K p] variable (K L) /-- If `L / K` is a `p`-radical field extension, then it is purely inseparable. -/ theorem IsPRadical.isPurelyInseparable [IsPRadical (algebraMap K L) p] : IsPurelyInseparable K L := (isPurelyInseparable_iff_pow_mem K p).2 (IsPRadical.pow_mem (algebraMap K L) p) /-- If `L / K` is a purely inseparable field extension, then it is `p`-radical. In particular, if `L` is perfect, then the (relative) perfect closure `perfectClosure K L` is a perfect closure of `K`, that is, `IsPerfectClosure (algebraMap K (perfectClosure K L)) p`. -/ instance IsPurelyInseparable.isPRadical [IsPurelyInseparable K L] : IsPRadical (algebraMap K L) p where pow_mem' := (isPurelyInseparable_iff_pow_mem K p).1 ‹_› ker_le' := (RingHom.injective_iff_ker_eq_bot _).1 (algebraMap K L).injective ▸ bot_le end Field end IsPerfectClosure
.lake/packages/mathlib/Mathlib/FieldTheory/PolynomialGaloisGroup.lean
import Mathlib.FieldTheory.Galois.Basic /-! # Galois Groups of Polynomials In this file, we introduce the Galois group of a polynomial `p` over a field `F`, defined as the automorphism group of its splitting field. We also provide some results about some extension `E` above `p.SplittingField`. ## Main definitions - `Polynomial.Gal p`: the Galois group of a polynomial p. - `Polynomial.Gal.restrict p E`: the restriction homomorphism `Gal(E/F) → gal p`. - `Polynomial.Gal.galAction p E`: the action of `gal p` on the roots of `p` in `E`. ## Main results - `Polynomial.Gal.restrict_smul`: `restrict p E` is compatible with `gal_action p E`. - `Polynomial.Gal.galActionHom_injective`: `gal p` acting on the roots of `p` in `E` is faithful. - `Polynomial.Gal.restrictProd_injective`: `gal (p * q)` embeds as a subgroup of `gal p × gal q`. - `Polynomial.Gal.card_of_separable`: For a separable polynomial, its Galois group has cardinality equal to the dimension of its splitting field over `F`. - `Polynomial.Gal.galActionHom_bijective_of_prime_degree`: An irreducible polynomial of prime degree with two non-real roots has full Galois group. ## Other results - `Polynomial.Gal.card_complex_roots_eq_card_real_add_card_not_gal_inv`: The number of complex roots equals the number of real roots plus the number of roots not fixed by complex conjugation (i.e. with some imaginary component). -/ assert_not_exists Real noncomputable section open scoped Polynomial open Module namespace Polynomial variable {F : Type*} [Field F] (p q : F[X]) (E : Type*) [Field E] [Algebra F E] /-- The Galois group of a polynomial. -/ def Gal := p.SplittingField ≃ₐ[F] p.SplittingField deriving Group, Fintype, EquivLike, AlgEquivClass namespace Gal instance applyMulSemiringAction : MulSemiringAction p.Gal p.SplittingField := AlgEquiv.applyMulSemiringAction @[ext] theorem ext {σ τ : p.Gal} (h : ∀ x ∈ p.rootSet p.SplittingField, σ x = τ x) : σ = τ := by refine AlgEquiv.ext fun x => (AlgHom.mem_equalizer σ.toAlgHom τ.toAlgHom x).mp ((SetLike.ext_iff.mp ?_ x).mpr Algebra.mem_top) rwa [eq_top_iff, ← SplittingField.adjoin_rootSet, Algebra.adjoin_le_iff] /-- If `p` splits in `F` then the `p.gal` is trivial. -/ def uniqueGalOfSplits (h : p.Splits (RingHom.id F)) : Unique p.Gal where default := 1 uniq f := AlgEquiv.ext fun x => by obtain ⟨y, rfl⟩ := Algebra.mem_bot.mp ((SetLike.ext_iff.mp ((IsSplittingField.splits_iff _ p).mp h) x).mp Algebra.mem_top) rw [AlgEquiv.commutes, AlgEquiv.commutes] instance [h : Fact (p.Splits (RingHom.id F))] : Unique p.Gal := uniqueGalOfSplits _ h.1 instance uniqueGalZero : Unique (0 : F[X]).Gal := uniqueGalOfSplits _ (splits_zero _) instance uniqueGalOne : Unique (1 : F[X]).Gal := uniqueGalOfSplits _ (splits_one _) instance uniqueGalC (x : F) : Unique (C x).Gal := uniqueGalOfSplits _ (splits_C _ _) instance uniqueGalX : Unique (X : F[X]).Gal := uniqueGalOfSplits _ (splits_X _) instance uniqueGalXSubC (x : F) : Unique (X - C x).Gal := uniqueGalOfSplits _ (splits_X_sub_C _) instance uniqueGalXPow (n : ℕ) : Unique (X ^ n : F[X]).Gal := uniqueGalOfSplits _ (splits_X_pow _ _) instance [h : Fact (p.Splits (algebraMap F E))] : Algebra p.SplittingField E := (IsSplittingField.lift p.SplittingField p h.1).toRingHom.toAlgebra instance [h : Fact (p.Splits (algebraMap F E))] : IsScalarTower F p.SplittingField E := IsScalarTower.of_algebraMap_eq fun x => ((IsSplittingField.lift p.SplittingField p h.1).commutes x).symm -- The `Algebra p.SplittingField E` instance above behaves badly when -- `E := p.SplittingField`, since it may result in a unification problem -- `IsSplittingField.lift.toRingHom.toAlgebra =?= Algebra.id`, -- which takes an extremely long time to resolve, causing timeouts. -- Since we don't really care about this definition, marking it as irreducible -- causes that unification to error out early. /-- Restrict from a superfield automorphism into a member of `gal p`. -/ def restrict [Fact (p.Splits (algebraMap F E))] : Gal(E/F) →* p.Gal := AlgEquiv.restrictNormalHom p.SplittingField theorem restrict_surjective [Fact (p.Splits (algebraMap F E))] [Normal F E] : Function.Surjective (restrict p E) := AlgEquiv.restrictNormalHom_surjective E section RootsAction /-- The function taking `rootSet p p.SplittingField` to `rootSet p E`. This is actually a bijection, see `Polynomial.Gal.mapRoots_bijective`. -/ def mapRoots [Fact (p.Splits (algebraMap F E))] : rootSet p p.SplittingField → rootSet p E := Set.MapsTo.restrict (IsScalarTower.toAlgHom F p.SplittingField E) _ _ <| rootSet_mapsTo _ theorem mapRoots_bijective [h : Fact (p.Splits (algebraMap F E))] : Function.Bijective (mapRoots p E) := by constructor · exact fun _ _ h => Subtype.ext (RingHom.injective _ (Subtype.ext_iff.mp h)) · intro y -- this is just an equality of two different ways to write the roots of `p` as an `E`-polynomial have key := roots_map (IsScalarTower.toAlgHom F p.SplittingField E : p.SplittingField →+* E) ((splits_id_iff_splits _).mpr (IsSplittingField.splits p.SplittingField p)) rw [map_map, AlgHom.comp_algebraMap] at key have hy := Subtype.mem y simp only [rootSet, Finset.mem_coe, Multiset.mem_toFinset, key, Multiset.mem_map] at hy rcases hy with ⟨x, hx1, hx2⟩ exact ⟨⟨x, (@Multiset.mem_toFinset _ (Classical.decEq _) _ _).mpr hx1⟩, Subtype.ext hx2⟩ /-- The bijection between `rootSet p p.SplittingField` and `rootSet p E`. -/ def rootsEquivRoots [Fact (p.Splits (algebraMap F E))] : rootSet p p.SplittingField ≃ rootSet p E := Equiv.ofBijective (mapRoots p E) (mapRoots_bijective p E) instance galActionAux : MulAction p.Gal (rootSet p p.SplittingField) where smul ϕ := Set.MapsTo.restrict ϕ _ _ <| rootSet_mapsTo ϕ.toAlgHom one_smul _ := by ext; rfl mul_smul _ _ _ := by ext; rfl instance smul [Fact (p.Splits (algebraMap F E))] : SMul p.Gal (rootSet p E) where smul ϕ x := rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm x) theorem smul_def [Fact (p.Splits (algebraMap F E))] (ϕ : p.Gal) (x : rootSet p E) : ϕ • x = rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm x) := rfl /-- The action of `gal p` on the roots of `p` in `E`. -/ instance galAction [Fact (p.Splits (algebraMap F E))] : MulAction p.Gal (rootSet p E) where one_smul _ := by simp only [smul_def, Equiv.apply_symm_apply, one_smul] mul_smul _ _ _ := by simp only [smul_def, Equiv.symm_apply_apply, mul_smul] lemma galAction_isPretransitive [Fact (p.Splits (algebraMap F E))] (hp : Irreducible p) : MulAction.IsPretransitive p.Gal (p.rootSet E) := by refine ⟨fun x y ↦ ?_⟩ have hx := minpoly.eq_of_irreducible hp (mem_rootSet.mp ((rootsEquivRoots p E).symm x).2).2 have hy := minpoly.eq_of_irreducible hp (mem_rootSet.mp ((rootsEquivRoots p E).symm y).2).2 obtain ⟨g, hg⟩ := (Normal.minpoly_eq_iff_mem_orbit p.SplittingField).mp (hy.symm.trans hx) exact ⟨g, (rootsEquivRoots p E).apply_eq_iff_eq_symm_apply.mpr (Subtype.ext hg)⟩ variable {p E} /-- `Polynomial.Gal.restrict p E` is compatible with `Polynomial.Gal.galAction p E`. -/ @[simp] theorem restrict_smul [Fact (p.Splits (algebraMap F E))] (ϕ : Gal(E/F)) (x : rootSet p E) : ↑(restrict p E ϕ • x) = ϕ x := by let ψ := AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F p.SplittingField E) change ↑(ψ (ψ.symm _)) = ϕ x rw [AlgEquiv.apply_symm_apply ψ] change ϕ (rootsEquivRoots p E ((rootsEquivRoots p E).symm x)) = ϕ x rw [Equiv.apply_symm_apply (rootsEquivRoots p E)] variable (p E) /-- `Polynomial.Gal.galAction` as a permutation representation -/ def galActionHom [Fact (p.Splits (algebraMap F E))] : p.Gal →* Equiv.Perm (rootSet p E) := MulAction.toPermHom _ _ theorem galActionHom_restrict [Fact (p.Splits (algebraMap F E))] (ϕ : Gal(E/F)) (x : rootSet p E) : ↑(galActionHom p E (restrict p E ϕ) x) = ϕ x := restrict_smul ϕ x /-- `gal p` embeds as a subgroup of permutations of the roots of `p` in `E`. -/ theorem galActionHom_injective [Fact (p.Splits (algebraMap F E))] : Function.Injective (galActionHom p E) := by rw [injective_iff_map_eq_one] intro ϕ hϕ ext (x hx) have key := Equiv.Perm.ext_iff.mp hϕ (rootsEquivRoots p E ⟨x, hx⟩) change rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm (rootsEquivRoots p E ⟨x, hx⟩)) = rootsEquivRoots p E ⟨x, hx⟩ at key rw [Equiv.symm_apply_apply] at key exact Subtype.ext_iff.mp (Equiv.injective (rootsEquivRoots p E) key) end RootsAction variable {p q} /-- `Polynomial.Gal.restrict`, when both fields are splitting fields of polynomials. -/ def restrictDvd (hpq : p ∣ q) : q.Gal →* p.Gal := haveI := Classical.dec (q = 0) if hq : q = 0 then 1 else @restrict F _ p _ _ _ ⟨splits_of_splits_of_dvd (algebraMap F q.SplittingField) hq (SplittingField.splits q) hpq⟩ theorem restrictDvd_def [Decidable (q = 0)] (hpq : p ∣ q) : restrictDvd hpq = if hq : q = 0 then 1 else @restrict F _ p _ _ _ ⟨splits_of_splits_of_dvd (algebraMap F q.SplittingField) hq (SplittingField.splits q) hpq⟩ := by unfold restrictDvd congr theorem restrictDvd_surjective (hpq : p ∣ q) (hq : q ≠ 0) : Function.Surjective (restrictDvd hpq) := by classical haveI := Fact.mk <| splits_of_splits_of_dvd (algebraMap F q.SplittingField) hq (SplittingField.splits q) hpq simpa only [restrictDvd_def, dif_neg hq] using restrict_surjective _ _ variable (p q) /-- The Galois group of a product maps into the product of the Galois groups. -/ def restrictProd : (p * q).Gal →* p.Gal × q.Gal := MonoidHom.prod (restrictDvd (dvd_mul_right p q)) (restrictDvd (dvd_mul_left q p)) /-- `Polynomial.Gal.restrictProd` is actually a subgroup embedding. -/ theorem restrictProd_injective : Function.Injective (restrictProd p q) := by by_cases hpq : p * q = 0 · have : Unique (p * q).Gal := by rw [hpq]; infer_instance exact fun f g _ => Eq.trans (Unique.eq_default f) (Unique.eq_default g).symm intro f g hfg classical simp only [restrictProd, restrictDvd_def] at hfg simp only [dif_neg hpq, MonoidHom.prod_apply, Prod.mk_inj] at hfg ext (x hx) rw [rootSet_def, aroots_mul hpq] at hx rcases Multiset.mem_add.mp (Multiset.mem_toFinset.mp hx) with h | h · haveI : Fact (p.Splits (algebraMap F (p * q).SplittingField)) := ⟨splits_of_splits_of_dvd _ hpq (SplittingField.splits (p * q)) (dvd_mul_right p q)⟩ have key : x = algebraMap p.SplittingField (p * q).SplittingField ((rootsEquivRoots p _).invFun ⟨x, (@Multiset.mem_toFinset _ (Classical.decEq _) _ _).mpr h⟩) := Subtype.ext_iff.mp (Equiv.apply_symm_apply (rootsEquivRoots p _) ⟨x, _⟩).symm rw [key, ← AlgEquiv.restrictNormal_commutes, ← AlgEquiv.restrictNormal_commutes] exact congr_arg _ (AlgEquiv.ext_iff.mp hfg.1 _) · haveI : Fact (q.Splits (algebraMap F (p * q).SplittingField)) := ⟨splits_of_splits_of_dvd _ hpq (SplittingField.splits (p * q)) (dvd_mul_left q p)⟩ have key : x = algebraMap q.SplittingField (p * q).SplittingField ((rootsEquivRoots q _).invFun ⟨x, (@Multiset.mem_toFinset _ (Classical.decEq _) _ _).mpr h⟩) := Subtype.ext_iff.mp (Equiv.apply_symm_apply (rootsEquivRoots q _) ⟨x, _⟩).symm rw [key, ← AlgEquiv.restrictNormal_commutes, ← AlgEquiv.restrictNormal_commutes] exact congr_arg _ (AlgEquiv.ext_iff.mp hfg.2 _) theorem mul_splits_in_splittingField_of_mul {p₁ q₁ p₂ q₂ : F[X]} (hq₁ : q₁ ≠ 0) (hq₂ : q₂ ≠ 0) (h₁ : p₁.Splits (algebraMap F q₁.SplittingField)) (h₂ : p₂.Splits (algebraMap F q₂.SplittingField)) : (p₁ * p₂).Splits (algebraMap F (q₁ * q₂).SplittingField) := by apply splits_mul · rw [← (SplittingField.lift q₁ (splits_of_splits_of_dvd (algebraMap F (q₁ * q₂).SplittingField) (mul_ne_zero hq₁ hq₂) (SplittingField.splits _) (dvd_mul_right q₁ q₂))).comp_algebraMap] exact splits_comp_of_splits _ _ h₁ · rw [← (SplittingField.lift q₂ (splits_of_splits_of_dvd (algebraMap F (q₁ * q₂).SplittingField) (mul_ne_zero hq₁ hq₂) (SplittingField.splits _) (dvd_mul_left q₂ q₁))).comp_algebraMap] exact splits_comp_of_splits _ _ h₂ /-- `p` splits in the splitting field of `p ∘ q`, for `q` non-constant. -/ theorem splits_in_splittingField_of_comp (hq : q.natDegree ≠ 0) : p.Splits (algebraMap F (p.comp q).SplittingField) := by let P : F[X] → Prop := fun r => r.Splits (algebraMap F (r.comp q).SplittingField) have key1 : ∀ {r : F[X]}, Irreducible r → P r := by intro r hr by_cases hr' : natDegree r = 0 · exact splits_of_natDegree_le_one _ (le_trans (le_of_eq hr') zero_le_one) obtain ⟨x, hx⟩ := exists_root_of_splits _ (SplittingField.splits (r.comp q)) fun h => hr' ((mul_eq_zero.mp (natDegree_comp.symm.trans (natDegree_eq_of_degree_eq_some h))).resolve_right hq) rw [← aeval_def, aeval_comp] at hx have h_normal : Normal F (r.comp q).SplittingField := SplittingField.instNormal (r.comp q) have qx_int := Normal.isIntegral h_normal (aeval x q) exact splits_of_splits_of_dvd _ (minpoly.ne_zero qx_int) (Normal.splits h_normal _) ((minpoly.irreducible qx_int).dvd_symm hr (minpoly.dvd F _ hx)) have key2 : ∀ {p₁ p₂ : F[X]}, P p₁ → P p₂ → P (p₁ * p₂) := by intro p₁ p₂ hp₁ hp₂ by_cases h₁ : p₁.comp q = 0 · rcases comp_eq_zero_iff.mp h₁ with h | h · rw [h, zero_mul] exact splits_zero _ · exact False.elim (hq (by rw [h.2, natDegree_C])) by_cases h₂ : p₂.comp q = 0 · rcases comp_eq_zero_iff.mp h₂ with h | h · rw [h, mul_zero] exact splits_zero _ · exact False.elim (hq (by rw [h.2, natDegree_C])) have key := mul_splits_in_splittingField_of_mul h₁ h₂ hp₁ hp₂ rwa [← mul_comp] at key exact WfDvdMonoid.induction_on_irreducible p (splits_zero _) (fun _ => splits_of_isUnit _) fun _ _ _ h => key2 (key1 h) /-- `Polynomial.Gal.restrict` for the composition of polynomials. -/ def restrictComp (hq : q.natDegree ≠ 0) : (p.comp q).Gal →* p.Gal := let h : Fact (Splits (algebraMap F (p.comp q).SplittingField) p) := ⟨splits_in_splittingField_of_comp p q hq⟩ @restrict F _ p _ _ _ h theorem restrictComp_surjective (hq : q.natDegree ≠ 0) : Function.Surjective (restrictComp p q hq) := by haveI : Fact (Splits (algebraMap F (SplittingField (comp p q))) p) := ⟨splits_in_splittingField_of_comp p q hq⟩ simpa only [restrictComp] using restrict_surjective _ _ variable {p q} open scoped IntermediateField /-- For a separable polynomial, its Galois group has cardinality equal to the dimension of its splitting field over `F`. -/ theorem card_of_separable (hp : p.Separable) : Nat.card p.Gal = finrank F p.SplittingField := haveI : IsGalois F p.SplittingField := IsGalois.of_separable_splitting_field hp IsGalois.card_aut_eq_finrank F p.SplittingField theorem prime_degree_dvd_card [CharZero F] (p_irr : Irreducible p) (p_deg : p.natDegree.Prime) : p.natDegree ∣ Nat.card p.Gal := by rw [Gal.card_of_separable p_irr.separable] have hp : p.degree ≠ 0 := fun h => Nat.Prime.ne_zero p_deg (natDegree_eq_zero_iff_degree_le_zero.mpr (le_of_eq h)) let α : p.SplittingField := rootOfSplits (algebraMap F p.SplittingField) (SplittingField.splits p) hp have hα : IsIntegral F α := .of_finite F α use Module.finrank F⟮α⟯ p.SplittingField suffices (minpoly F α).natDegree = p.natDegree by letI _ : AddCommGroup F⟮α⟯ := Ring.toAddCommGroup rw [← Module.finrank_mul_finrank F F⟮α⟯ p.SplittingField, IntermediateField.adjoin.finrank hα, this] suffices minpoly F α ∣ p by have key := (minpoly.irreducible hα).dvd_symm p_irr this apply le_antisymm · exact natDegree_le_of_dvd this p_irr.ne_zero · exact natDegree_le_of_dvd key (minpoly.ne_zero hα) apply minpoly.dvd F α rw [aeval_def, map_rootOfSplits _ (SplittingField.splits p) hp] end Gal end Polynomial
.lake/packages/mathlib/Mathlib/FieldTheory/KummerPolynomial.lean
import Mathlib.RingTheory.AdjoinRoot import Mathlib.RingTheory.Norm.Defs /-! # Irreducibility of X ^ p - a ## Main result - `X_pow_sub_C_irreducible_iff_of_prime`: For `p` prime, `X ^ p - C a` is irreducible iff `a` is not a `p`-power. This is not true for composite `n`. For example, `x^4+4=(x^2-2x+2)(x^2+2x+2)` but `-4` is not a 4th power. -/ universe u variable {K : Type u} [Field K] open Polynomial AdjoinRoot section Splits lemma root_X_pow_sub_C_pow (n : ℕ) (a : K) : (AdjoinRoot.root (X ^ n - C a)) ^ n = AdjoinRoot.of _ a := by rw [← sub_eq_zero, ← AdjoinRoot.eval₂_root, eval₂_sub, eval₂_C, eval₂_pow, eval₂_X] lemma root_X_pow_sub_C_ne_zero {n : ℕ} (hn : 1 < n) (a : K) : (AdjoinRoot.root (X ^ n - C a)) ≠ 0 := mk_ne_zero_of_natDegree_lt (monic_X_pow_sub_C _ (Nat.ne_zero_of_lt hn)) X_ne_zero <| by rwa [natDegree_X_pow_sub_C, natDegree_X] lemma root_X_pow_sub_C_ne_zero' {n : ℕ} {a : K} (hn : 0 < n) (ha : a ≠ 0) : (AdjoinRoot.root (X ^ n - C a)) ≠ 0 := by obtain (rfl | hn) := (Nat.succ_le_iff.mpr hn).eq_or_lt · rw [pow_one] intro e refine mk_ne_zero_of_natDegree_lt (monic_X_sub_C a) (C_ne_zero.mpr ha) (by simp) ?_ trans AdjoinRoot.mk (X - C a) (X - (X - C a)) · rw [sub_sub_cancel] · rw [map_sub, mk_self, sub_zero, mk_X, e] · exact root_X_pow_sub_C_ne_zero hn a end Splits section Irreducible lemma ne_zero_of_irreducible_X_pow_sub_C {n : ℕ} {a : K} (H : Irreducible (X ^ n - C a)) : n ≠ 0 := by rintro rfl rw [pow_zero, ← C.map_one, ← map_sub] at H exact not_irreducible_C _ H lemma ne_zero_of_irreducible_X_pow_sub_C' {n : ℕ} (hn : n ≠ 1) {a : K} (H : Irreducible (X ^ n - C a)) : a ≠ 0 := by rintro rfl rw [map_zero, sub_zero] at H exact not_irreducible_pow hn H lemma root_X_pow_sub_C_eq_zero_iff {n : ℕ} {a : K} (H : Irreducible (X ^ n - C a)) : (AdjoinRoot.root (X ^ n - C a)) = 0 ↔ a = 0 := by have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H) refine ⟨not_imp_not.mp (root_X_pow_sub_C_ne_zero' hn), ?_⟩ rintro rfl have := not_imp_not.mp (fun hn ↦ ne_zero_of_irreducible_X_pow_sub_C' hn H) rfl rw [this, pow_one, map_zero, sub_zero, ← mk_X, mk_self] lemma root_X_pow_sub_C_ne_zero_iff {n : ℕ} {a : K} (H : Irreducible (X ^ n - C a)) : (AdjoinRoot.root (X ^ n - C a)) ≠ 0 ↔ a ≠ 0 := (root_X_pow_sub_C_eq_zero_iff H).not theorem pow_ne_of_irreducible_X_pow_sub_C {n : ℕ} {a : K} (H : Irreducible (X ^ n - C a)) {m : ℕ} (hm : m ∣ n) (hm' : m ≠ 1) (b : K) : b ^ m ≠ a := by have hn : n ≠ 0 := fun e ↦ not_irreducible_C (1 - a) (by simpa only [e, pow_zero, ← C.map_one, ← map_sub] using H) obtain ⟨k, rfl⟩ := hm rintro rfl obtain ⟨q, hq⟩ := sub_dvd_pow_sub_pow (X ^ k) (C b) m rw [mul_comm, pow_mul, map_pow, hq] at H have : degree q = 0 := by simpa [isUnit_iff_degree_eq_zero, degree_X_pow_sub_C, Nat.pos_iff_ne_zero, (mul_ne_zero_iff.mp hn).2] using H.2 rfl apply_fun degree at hq simp only [this, ← pow_mul, mul_comm k m, degree_X_pow_sub_C, Nat.pos_iff_ne_zero.mpr hn, Nat.pos_iff_ne_zero.mpr (mul_ne_zero_iff.mp hn).2, degree_mul, ← map_pow, add_zero, Nat.cast_injective.eq_iff] at hq exact hm' ((mul_eq_right₀ (mul_ne_zero_iff.mp hn).2).mp hq) /-- Let `p` be a prime number. Let `K` be a field. Let `t ∈ K` be an element which does not have a `p`th root in `K`. Then the polynomial `x ^ p - t` is irreducible over `K`. -/ @[stacks 09HF "We proved the result without the condition that `K` is char p in 09HF."] theorem X_pow_sub_C_irreducible_of_prime {p : ℕ} (hp : p.Prime) {a : K} (ha : ∀ b : K, b ^ p ≠ a) : Irreducible (X ^ p - C a) := by -- First of all, We may find an irreducible factor `g` of `X ^ p - C a`. have : ¬ IsUnit (X ^ p - C a) := by rw [Polynomial.isUnit_iff_degree_eq_zero, degree_X_pow_sub_C hp.pos, Nat.cast_eq_zero] exact hp.ne_zero have ⟨g, hg, hg'⟩ := WfDvdMonoid.exists_irreducible_factor this (X_pow_sub_C_ne_zero hp.pos a) -- It suffices to show that `deg g = p`. suffices natDegree g = p from (associated_of_dvd_of_natDegree_le hg' (X_pow_sub_C_ne_zero hp.pos a) (this.trans natDegree_X_pow_sub_C.symm).ge).irreducible hg -- Suppose `deg g ≠ p`. by_contra h -- Let `r` be a root of `g`, then `N_K(r) ^ p = N_K(r ^ p) = N_K(a) = a ^ (deg g)`. have key : (Algebra.norm K (AdjoinRoot.root g)) ^ p = a ^ g.natDegree := by have := eval₂_eq_zero_of_dvd_of_eval₂_eq_zero _ _ hg' (AdjoinRoot.eval₂_root g) rw [eval₂_sub, eval₂_pow, eval₂_C, eval₂_X, sub_eq_zero] at this rw [← map_pow, this, ← AdjoinRoot.algebraMap_eq, Algebra.norm_algebraMap, (powerBasis hg.ne_zero).finrank, powerBasis_dim hg.ne_zero] -- Since `a ^ (deg g)` is a `p`-power, and `p` is coprime to `deg g`, we conclude that `a` is -- also a `p`-power, contradicting the hypothesis have : p.Coprime (natDegree g) := hp.coprime_iff_not_dvd.mpr (fun e ↦ h (((natDegree_le_of_dvd hg' (X_pow_sub_C_ne_zero hp.pos a)).trans_eq natDegree_X_pow_sub_C).antisymm (Nat.le_of_dvd (natDegree_pos_iff_degree_pos.mpr <| Polynomial.degree_pos_of_irreducible hg) e))) exact ha _ ((pow_mem_range_pow_of_coprime this.symm a).mp ⟨_, key⟩).choose_spec theorem X_pow_sub_C_irreducible_iff_of_prime {p : ℕ} (hp : p.Prime) {a : K} : Irreducible (X ^ p - C a) ↔ ∀ b, b ^ p ≠ a := ⟨(pow_ne_of_irreducible_X_pow_sub_C · dvd_rfl hp.ne_one), X_pow_sub_C_irreducible_of_prime hp⟩ end Irreducible
.lake/packages/mathlib/Mathlib/FieldTheory/Tower.lean
import Mathlib.RingTheory.Noetherian.Basic /-! # Finiteness of `IsScalarTower` We prove that given `IsScalarTower F K A`, if `A` is finite as a module over `F` then `A` is finite over `K`, and (as long as `A` is Noetherian over `F` and we have `NoZeroSMulDivisors K A`) `K` is finite over `F`. In particular these conditions hold when `A`, `F`, and `K` are fields. The formulas for the dimensions are given elsewhere by `Module.finrank_mul_finrank`. ## Tags tower law -/ universe u v w u₁ v₁ w₁ open Cardinal Submodule variable (F : Type u) (K : Type v) (A : Type w) namespace Module.Finite variable [Ring F] [Ring K] [Module F K] [AddCommGroup A] [Module K A] [NoZeroSMulDivisors K A] [Module F A] [IsNoetherian F A] [IsScalarTower F K A] in /-- In a tower of field extensions `A / K / F`, if `A / F` is finite, so is `K / F`. (In fact, it suffices that `A` is a nontrivial ring.) Note this cannot be an instance as Lean cannot infer `A`. -/ theorem left [Nontrivial A] : Module.Finite F K := let ⟨x, hx⟩ := exists_ne (0 : A) Module.Finite.of_injective (LinearMap.ringLmapEquivSelf K ℕ A |>.symm x |>.restrictScalars F) (smul_left_injective K hx) variable [Semiring F] [Semiring K] [Module F K] [AddCommMonoid A] [Module K A] [Module F A] [IsScalarTower F K A] in @[stacks 09G5] theorem right [hf : Module.Finite F A] : Module.Finite K A := let ⟨⟨b, hb⟩⟩ := hf ⟨⟨b, Submodule.restrictScalars_injective F _ _ <| by rw [Submodule.restrictScalars_top, eq_top_iff, ← hb, Submodule.span_le] exact Submodule.subset_span⟩⟩ end Module.Finite alias FiniteDimensional.left := Module.Finite.left alias FiniteDimensional.right := Module.Finite.right
.lake/packages/mathlib/Mathlib/FieldTheory/AlgebraicClosure.lean
import Mathlib.FieldTheory.Normal.Closure import Mathlib.FieldTheory.IsAlgClosed.Basic import Mathlib.FieldTheory.IntermediateField.Algebraic /-! # Relative Algebraic Closure In this file we construct the relative algebraic closure of a field extension. ## Main Definitions - `algebraicClosure F E` is the relative algebraic closure (i.e. the maximal algebraic subextension) of the field extension `E / F`, which is defined to be the integral closure of `F` in `E`. -/ noncomputable section open Polynomial FiniteDimensional IntermediateField Field variable (F E : Type*) [Field F] [Field E] [Algebra F E] variable {K : Type*} [Field K] [Algebra F K] /-- The *relative algebraic closure* of a field `F` in a field extension `E`, also called the *maximal algebraic subextension* of `E / F`, is defined to be the subalgebra `integralClosure F E` upgraded to an intermediate field (since `F` and `E` are both fields). This is exactly the intermediate field of `E / F` consisting of all integral/algebraic elements. -/ @[stacks 09GI] def algebraicClosure : IntermediateField F E := Algebra.IsAlgebraic.toIntermediateField (integralClosure F E) variable {F E} theorem algebraicClosure_toSubalgebra : (algebraicClosure F E).toSubalgebra = integralClosure F E := rfl /-- An element is contained in the algebraic closure of `F` in `E` if and only if it is an integral element. -/ theorem mem_algebraicClosure_iff' {x : E} : x ∈ algebraicClosure F E ↔ IsIntegral F x := Iff.rfl /-- An element is contained in the algebraic closure of `F` in `E` if and only if it is an algebraic element. -/ theorem mem_algebraicClosure_iff {x : E} : x ∈ algebraicClosure F E ↔ IsAlgebraic F x := isAlgebraic_iff_isIntegral.symm /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then `i x` is contained in `algebraicClosure F K` if and only if `x` is contained in `algebraicClosure F E`. -/ theorem map_mem_algebraicClosure_iff (i : E →ₐ[F] K) {x : E} : i x ∈ algebraicClosure F K ↔ x ∈ algebraicClosure F E := by simp_rw [mem_algebraicClosure_iff', ← minpoly.ne_zero_iff, minpoly.algHom_eq i i.injective] namespace algebraicClosure /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the preimage of `algebraicClosure F K` under the map `i` is equal to `algebraicClosure F E`. -/ theorem comap_eq_of_algHom (i : E →ₐ[F] K) : (algebraicClosure F K).comap i = algebraicClosure F E := by ext x exact map_mem_algebraicClosure_iff i /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the image of `algebraicClosure F E` under the map `i` is contained in `algebraicClosure F K`. -/ theorem map_le_of_algHom (i : E →ₐ[F] K) : (algebraicClosure F E).map i ≤ algebraicClosure F K := map_le_iff_le_comap.2 (comap_eq_of_algHom i).ge variable (F) in /-- If `K / E / F` is a field extension tower, such that `K / E` has no non-trivial algebraic subextensions (this means that it is purely transcendental), then the image of `algebraicClosure F E` in `K` is equal to `algebraicClosure F K`. -/ theorem map_eq_of_algebraicClosure_eq_bot [Algebra E K] [IsScalarTower F E K] (h : algebraicClosure E K = ⊥) : (algebraicClosure F E).map (IsScalarTower.toAlgHom F E K) = algebraicClosure F K := by refine le_antisymm (map_le_of_algHom _) (fun x hx ↦ ?_) obtain ⟨y, rfl⟩ := mem_bot.1 <| h ▸ mem_algebraicClosure_iff'.2 (IsIntegral.tower_top <| mem_algebraicClosure_iff'.1 hx) exact ⟨y, (map_mem_algebraicClosure_iff <| IsScalarTower.toAlgHom F E K).mp hx, rfl⟩ /-- If `i` is an `F`-algebra isomorphism of `E` and `K`, then the image of `algebraicClosure F E` under the map `i` is equal to `algebraicClosure F K`. -/ theorem map_eq_of_algEquiv (i : E ≃ₐ[F] K) : (algebraicClosure F E).map i = algebraicClosure F K := (map_le_of_algHom i.toAlgHom).antisymm (fun x h ↦ ⟨_, (map_mem_algebraicClosure_iff i.symm).2 h, by simp⟩) /-- If `E` and `K` are isomorphic as `F`-algebras, then `algebraicClosure F E` and `algebraicClosure F K` are also isomorphic as `F`-algebras. -/ def algEquivOfAlgEquiv (i : E ≃ₐ[F] K) : algebraicClosure F E ≃ₐ[F] algebraicClosure F K := (intermediateFieldMap i _).trans (equivOfEq (map_eq_of_algEquiv i)) alias _root_.AlgEquiv.algebraicClosure := algEquivOfAlgEquiv variable (F E K) /-- The algebraic closure of `F` in `E` is algebraic over `F`. -/ instance isAlgebraic : Algebra.IsAlgebraic F (algebraicClosure F E) := ⟨fun x ↦ isAlgebraic_iff.mpr x.2.isAlgebraic⟩ /-- The algebraic closure of `F` in `E` is the integral closure of `F` in `E`. -/ instance isIntegralClosure : IsIntegralClosure (algebraicClosure F E) F E := inferInstanceAs (IsIntegralClosure (integralClosure F E) F E) end algebraicClosure protected theorem Transcendental.algebraicClosure {a : E} (ha : Transcendental F a) : Transcendental (algebraicClosure F E) a := ha.extendScalars _ variable (F E K) /-- An intermediate field of `E / F` is contained in the algebraic closure of `F` in `E` if all of its elements are algebraic over `F`. -/ theorem le_algebraicClosure' {L : IntermediateField F E} (hs : ∀ x : L, IsAlgebraic F x) : L ≤ algebraicClosure F E := fun x h ↦ by simpa only [mem_algebraicClosure_iff, IsAlgebraic, ne_eq, ← aeval_algebraMap_eq_zero_iff E, Algebra.algebraMap_self, RingHom.id_apply, IntermediateField.algebraMap_apply] using hs ⟨x, h⟩ /-- An intermediate field of `E / F` is contained in the algebraic closure of `F` in `E` if it is algebraic over `F`. -/ theorem le_algebraicClosure (L : IntermediateField F E) [Algebra.IsAlgebraic F L] : L ≤ algebraicClosure F E := le_algebraicClosure' F E (Algebra.IsAlgebraic.isAlgebraic) /-- An intermediate field of `E / F` is contained in the algebraic closure of `F` in `E` if and only if it is algebraic over `F`. -/ theorem le_algebraicClosure_iff (L : IntermediateField F E) : L ≤ algebraicClosure F E ↔ Algebra.IsAlgebraic F L := ⟨fun h ↦ ⟨fun x ↦ by simpa only [IsAlgebraic, ne_eq, ← aeval_algebraMap_eq_zero_iff E, IntermediateField.algebraMap_apply, Algebra.algebraMap_self, RingHomCompTriple.comp_apply, mem_algebraicClosure_iff] using h x.2⟩, fun _ ↦ le_algebraicClosure _ _ _⟩ namespace algebraicClosure /-- The algebraic closure in `E` of the algebraic closure of `F` in `E` is equal to itself. -/ theorem algebraicClosure_eq_bot : algebraicClosure (algebraicClosure F E) E = ⊥ := bot_unique fun x hx ↦ mem_bot.2 ⟨⟨x, isIntegral_trans x (mem_algebraicClosure_iff'.1 hx)⟩, rfl⟩ /-- The normal closure in `E/F` of the algebraic closure of `F` in `E` is equal to itself. -/ theorem normalClosure_eq_self : normalClosure F (algebraicClosure F E) E = algebraicClosure F E := le_antisymm (normalClosure_le_iff.2 fun i ↦ haveI : Algebra.IsAlgebraic F i.fieldRange := (AlgEquiv.ofInjectiveField i).isAlgebraic le_algebraicClosure F E _) (le_normalClosure _) end algebraicClosure /-- If `E / F` is a field extension and `E` is algebraically closed, then the algebraic closure of `F` in `E` is equal to `F` if and only if `F` is algebraically closed. -/ theorem IsAlgClosed.algebraicClosure_eq_bot_iff [IsAlgClosed E] : algebraicClosure F E = ⊥ ↔ IsAlgClosed F := by refine ⟨fun h ↦ IsAlgClosed.of_exists_root _ fun p hmon hirr ↦ ?_, fun _ ↦ IntermediateField.eq_bot_of_isAlgClosed_of_isAlgebraic _⟩ obtain ⟨x, hx⟩ := IsAlgClosed.exists_aeval_eq_zero E p (degree_pos_of_irreducible hirr).ne' obtain ⟨x, rfl⟩ := h ▸ mem_algebraicClosure_iff'.2 (minpoly.ne_zero_iff.1 <| ne_zero_of_dvd_ne_zero hmon.ne_zero (minpoly.dvd _ x hx)) exact ⟨x, by simpa [Algebra.ofId_apply] using hx⟩ /-- `F(S) / F` is a algebraic extension if and only if all elements of `S` are algebraic elements. -/ theorem IntermediateField.isAlgebraic_adjoin_iff_isAlgebraic {S : Set E} : Algebra.IsAlgebraic F (adjoin F S) ↔ ∀ x ∈ S, IsAlgebraic F x := ((le_algebraicClosure_iff F E _).symm.trans (adjoin_le_iff.trans <| forall_congr' <| fun _ => Iff.imp Iff.rfl mem_algebraicClosure_iff)) namespace algebraicClosure /-- If `E` is algebraically closed, then the algebraic closure of `F` in `E` is an absolute algebraic closure of `F`. -/ instance isAlgClosure [IsAlgClosed E] : IsAlgClosure F (algebraicClosure F E) := ⟨(IsAlgClosed.algebraicClosure_eq_bot_iff _ E).mp (algebraicClosure_eq_bot F E), isAlgebraic F E⟩ /-- The algebraic closure of `F` in `E` is equal to `E` if and only if `E / F` is algebraic. -/ theorem eq_top_iff : algebraicClosure F E = ⊤ ↔ Algebra.IsAlgebraic F E := ⟨fun h ↦ ⟨fun _ ↦ mem_algebraicClosure_iff.1 (h ▸ mem_top)⟩, fun _ ↦ top_unique fun x _ ↦ mem_algebraicClosure_iff.2 (Algebra.IsAlgebraic.isAlgebraic x)⟩ /-- If `K / E / F` is a field extension tower, then `algebraicClosure F K` is contained in `algebraicClosure E K`. -/ theorem le_restrictScalars [Algebra E K] [IsScalarTower F E K] : algebraicClosure F K ≤ (algebraicClosure E K).restrictScalars F := fun _ h ↦ mem_algebraicClosure_iff.2 <| IsAlgebraic.tower_top E (mem_algebraicClosure_iff.1 h) /-- If `K / E / F` is a field extension tower, such that `E / F` is algebraic, then `algebraicClosure F K` is equal to `algebraicClosure E K`. -/ theorem eq_restrictScalars_of_isAlgebraic [Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic F E] : algebraicClosure F K = (algebraicClosure E K).restrictScalars F := (algebraicClosure.le_restrictScalars F E K).antisymm fun _ h ↦ isIntegral_trans _ h /-- If `K / E / F` is a field extension tower, then `E` adjoin `algebraicClosure F K` is contained in `algebraicClosure E K`. -/ theorem adjoin_le [Algebra E K] [IsScalarTower F E K] : adjoin E (algebraicClosure F K) ≤ algebraicClosure E K := adjoin_le_iff.2 <| le_restrictScalars F E K end algebraicClosure variable {F} /-- Let `E / F` be a field extension. If a polynomial `p` splits in `E`, then it splits in the relative algebraic closure of `F` in `E` already. -/ theorem Splits.algebraicClosure {p : F[X]} (h : p.Splits (algebraMap F E)) : p.Splits (algebraMap F (algebraicClosure F E)) := splits_of_splits h fun _ hx ↦ (isAlgebraic_of_mem_rootSet hx).isIntegral
.lake/packages/mathlib/Mathlib/FieldTheory/Extension.lean
import Mathlib.Data.Fintype.Order import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic /-! # Extension of field embeddings `IntermediateField.exists_algHom_of_adjoin_splits'` is the main result: if E/L/F is a tower of field extensions, K is another extension of F, and `f` is an embedding of L/F into K/F, such that the minimal polynomials of a set of generators of E/L splits in K (via `f`), then `f` extends to an embedding of E/F into K/F. ## Reference [Isaacs1980] *Roots of Polynomials in Algebraic Extensions of Fields*, The American Mathematical Monthly -/ open Polynomial namespace IntermediateField variable (F E K : Type*) [Field F] [Field E] [Field K] [Algebra F E] [Algebra F K] {S : Set E} /-- Lifts `L → K` of `F → K` -/ structure Lifts where /-- The domain of a lift. -/ carrier : IntermediateField F E /-- The lifted RingHom, expressed as an AlgHom. -/ emb : carrier →ₐ[F] K variable {F E K} namespace Lifts instance : PartialOrder (Lifts F E K) where le L₁ L₂ := ∃ h : L₁.carrier ≤ L₂.carrier, ∀ x, L₂.emb (inclusion h x) = L₁.emb x le_refl L := ⟨le_rfl, by simp⟩ le_trans L₁ L₂ L₃ := by rintro ⟨h₁₂, h₁₂'⟩ ⟨h₂₃, h₂₃'⟩ refine ⟨h₁₂.trans h₂₃, fun _ ↦ ?_⟩ rw [← inclusion_inclusion h₁₂ h₂₃, h₂₃', h₁₂'] le_antisymm := by rintro ⟨L₁, e₁⟩ ⟨L₂, e₂⟩ ⟨h₁₂, h₁₂'⟩ ⟨h₂₁, h₂₁'⟩ obtain rfl : L₁ = L₂ := h₁₂.antisymm h₂₁ congr exact AlgHom.ext h₂₁' noncomputable instance : OrderBot (Lifts F E K) where bot := ⟨⊥, (Algebra.ofId F K).comp (botEquiv F E)⟩ bot_le L := ⟨bot_le, fun x ↦ by obtain ⟨x, rfl⟩ := (botEquiv F E).symm.surjective x simp_rw [AlgHom.comp_apply, AlgHom.coe_coe, AlgEquiv.apply_symm_apply] exact L.emb.commutes x⟩ noncomputable instance : Inhabited (Lifts F E K) := ⟨⊥⟩ variable {L₁ L₂ : Lifts F E K} theorem le_iff : L₁ ≤ L₂ ↔ ∃ h : L₁.carrier ≤ L₂.carrier, L₂.emb.comp (inclusion h) = L₁.emb := by simp_rw [AlgHom.ext_iff]; rfl theorem eq_iff_le_carrier_eq : L₁ = L₂ ↔ L₁ ≤ L₂ ∧ L₁.carrier = L₂.carrier := ⟨fun eq ↦ ⟨eq.le, congr_arg _ eq⟩, fun ⟨le, eq⟩ ↦ le.antisymm ⟨eq.ge, fun x ↦ (le.2 ⟨x, _⟩).symm⟩⟩ theorem eq_iff : L₁ = L₂ ↔ ∃ h : L₁.carrier = L₂.carrier, L₂.emb.comp (inclusion h.le) = L₁.emb := by rw [eq_iff_le_carrier_eq, le_iff] exact ⟨fun h ↦ ⟨h.2, h.1.2⟩, fun h ↦ ⟨⟨h.1.le, h.2⟩, h.1⟩⟩ theorem lt_iff_le_carrier_ne : L₁ < L₂ ↔ L₁ ≤ L₂ ∧ L₁.carrier ≠ L₂.carrier := by rw [lt_iff_le_and_ne, and_congr_right]; intro h; simp_rw [Ne, eq_iff_le_carrier_eq, h, true_and] theorem lt_iff : L₁ < L₂ ↔ ∃ h : L₁.carrier < L₂.carrier, L₂.emb.comp (inclusion h.le) = L₁.emb := by rw [lt_iff_le_carrier_ne, le_iff] exact ⟨fun h ↦ ⟨h.1.1.lt_of_ne h.2, h.1.2⟩, fun h ↦ ⟨⟨h.1.le, h.2⟩, h.1.ne⟩⟩ theorem le_of_carrier_le_iSup {ι} {ρ : ι → Lifts F E K} {σ τ : Lifts F E K} (hσ : ∀ i, ρ i ≤ σ) (hτ : ∀ i, ρ i ≤ τ) (carrier_le : σ.carrier ≤ ⨆ i, (ρ i).carrier) : σ ≤ τ := le_iff.mpr ⟨carrier_le.trans (iSup_le fun i ↦ (hτ i).1), algHom_ext_of_eq_adjoin _ (carrier_le.antisymm (iSup_le fun i ↦ (hσ i).1)|>.trans <| iSup_eq_adjoin _ _) fun x hx ↦ have ⟨i, hx⟩ := Set.mem_iUnion.mp hx ((hτ i).2 ⟨x, hx⟩).trans ((hσ i).2 ⟨x, hx⟩).symm⟩ /-- `σ : L →ₐ[F] K` is an extendible lift ("extendible pair" in [Isaacs1980]) if for every intermediate field `M` that is finite-dimensional over `L`, `σ` extends to some `M →ₐ[F] K`. In our definition we only require `M` to be finitely generated over `L`, which is equivalent if the ambient field `E` is algebraic over `F` (which is the case in our main application). We also allow the domain of the extension to be an intermediate field that properly contains `M`, since one can always restrict the domain to `M`. -/ def IsExtendible (σ : Lifts F E K) : Prop := ∀ S : Finset E, ∃ τ ≥ σ, (S : Set E) ⊆ τ.carrier section Chain variable (c : Set (Lifts F E K)) (hc : IsChain (· ≤ ·) c) /-- The union of a chain of lifts. -/ noncomputable def union : Lifts F E K := let t (i : ↑(insert ⊥ c)) := i.val.carrier have hc := hc.insert fun _ _ _ ↦ .inl bot_le have dir : Directed (· ≤ ·) t := hc.directedOn.directed_val.mono_comp _ fun _ _ h ↦ h.1 ⟨iSup t, (Subalgebra.iSupLift (toSubalgebra <| t ·) dir (·.val.emb) (fun i j h ↦ AlgHom.ext fun x ↦ (hc.total i.2 j.2).elim (fun hij ↦ (hij.snd x).symm) fun hji ↦ by rw [AlgHom.comp_apply, ← inclusion] dsimp only [coe_type_toSubalgebra] rw [← hji.snd (inclusion h x), inclusion_inclusion, inclusion_self, AlgHom.id_apply x]) _ rfl).comp (Subalgebra.equivOfEq _ _ <| toSubalgebra_iSup_of_directed dir)⟩ theorem le_union ⦃σ : Lifts F E K⦄ (hσ : σ ∈ c) : σ ≤ union c hc := have hσ := Set.mem_insert_of_mem ⊥ hσ let t (i : ↑(insert ⊥ c)) := i.val.carrier ⟨le_iSup t ⟨σ, hσ⟩, fun x ↦ by dsimp only [union, AlgHom.comp_apply] exact Subalgebra.iSupLift_inclusion (K := (toSubalgebra <| t ·)) (i := ⟨σ, hσ⟩) x (le_iSup (toSubalgebra <| t ·) ⟨σ, hσ⟩)⟩ theorem carrier_union : (union c hc).carrier = ⨆ i : c, i.1.carrier := le_antisymm (iSup_le <| by rintro ⟨i, rfl | hi⟩; exacts [bot_le, le_iSup_of_le ⟨i, hi⟩ le_rfl]) <| iSup_le fun i ↦ le_iSup_of_le ⟨i, .inr i.2⟩ le_rfl /-- A chain of lifts has an upper bound. -/ theorem exists_upper_bound (c : Set (Lifts F E K)) (hc : IsChain (· ≤ ·) c) : ∃ ub, ∀ a ∈ c, a ≤ ub := ⟨_, le_union c hc⟩ theorem union_isExtendible [alg : Algebra.IsAlgebraic F E] [Nonempty c] (hext : ∀ σ ∈ c, σ.IsExtendible) : (union c hc).IsExtendible := fun S ↦ by let Ω := adjoin F (S : Set E) →ₐ[F] K have ⟨ω, hω⟩ : ∃ ω : Ω, ∀ π : c, ∃ θ ≥ π.1, ⟨_, ω⟩ ≤ θ ∧ θ.carrier = π.1.1 ⊔ adjoin F S := by by_contra!; choose π hπ using this have := finiteDimensional_adjoin (S := (S : Set E)) fun _ _ ↦ (alg.isIntegral).1 _ have ⟨π₀, hπ₀⟩ := hc.directed.finite_le π have ⟨θ, hθπ, hθ⟩ := hext _ π₀.2 S rw [← adjoin_le_iff] at hθ let θ₀ := θ.emb.comp (inclusion hθ) have := (hπ₀ θ₀).trans hθπ exact hπ θ₀ ⟨_, θ.emb.comp <| inclusion <| sup_le this.1 hθ⟩ ⟨le_sup_left, this.2⟩ ⟨le_sup_right, fun _ ↦ rfl⟩ rfl choose θ ge hθ eq using hω have : IsChain (· ≤ ·) (Set.range θ) := by simp_rw [← restrictScalars_adjoin_eq_sup, restrictScalars_adjoin] at eq rintro _ ⟨π₁, rfl⟩ _ ⟨π₂, rfl⟩ - wlog h : π₁ ≤ π₂ generalizing π₁ π₂ · exact (this _ _ <| (hc.total π₁.2 π₂.2).resolve_left h).symm refine .inl (le_iff.mpr ⟨?_, algHom_ext_of_eq_adjoin _ (eq _) ?_⟩) · rw [eq, eq]; exact adjoin.mono _ _ _ (Set.union_subset_union_left _ h.1) rintro x (hx|hx) · change (θ π₂).emb (inclusion (ge π₂).1 <| inclusion h.1 ⟨x, hx⟩) = (θ π₁).emb (inclusion (ge π₁).1 ⟨x, hx⟩) rw [(ge π₁).2, (ge π₂).2, h.2] · change (θ π₂).emb (inclusion (hθ π₂).1 ⟨x, subset_adjoin _ _ hx⟩) = (θ π₁).emb (inclusion (hθ π₁).1 ⟨x, subset_adjoin _ _ hx⟩) rw [(hθ π₁).2, (hθ π₂).2] refine ⟨union _ this, le_of_carrier_le_iSup (fun π ↦ le_union c hc π.2) (fun π ↦ (ge π).trans <| le_union _ _ ⟨_, rfl⟩) (carrier_union _ _).le, ?_⟩ simp_rw [carrier_union, iSup_range', eq] exact (subset_adjoin _ _).trans (SetLike.coe_subset_coe.mpr <| le_sup_right.trans <| le_iSup_of_le (Classical.arbitrary _) le_rfl) end Chain theorem nonempty_algHom_of_exist_lifts_finset [alg : Algebra.IsAlgebraic F E] (h : ∀ S : Finset E, ∃ σ : Lifts F E K, (S : Set E) ⊆ σ.carrier) : Nonempty (E →ₐ[F] K) := by have : (⊥ : Lifts F E K).IsExtendible := fun S ↦ have ⟨σ, hσ⟩ := h S; ⟨σ, bot_le, hσ⟩ have ⟨ϕ, hϕ⟩ := zorn_le₀ {ϕ : Lifts F E K | ϕ.IsExtendible} fun c hext hc ↦ (isEmpty_or_nonempty c).elim (fun _ ↦ ⟨⊥, this, fun ϕ hϕ ↦ isEmptyElim (⟨ϕ, hϕ⟩ : c)⟩) fun _ ↦ ⟨_, union_isExtendible c hc hext, le_union c hc⟩ suffices ϕ.carrier = ⊤ from ⟨ϕ.emb.comp <| ((equivOfEq this).trans topEquiv).symm⟩ by_contra! obtain ⟨α, -, hα⟩ := SetLike.exists_of_lt this.lt_top let _ : Algebra ϕ.carrier K := ϕ.emb.toAlgebra let Λ := ϕ.carrier⟮α⟯ →ₐ[ϕ.carrier] K have := finiteDimensional_adjoin (S := {α}) fun _ _ ↦ ((alg.tower_top ϕ.carrier).isIntegral).1 _ let L (σ : Λ) : Lifts F E K := ⟨ϕ.carrier⟮α⟯.restrictScalars F, σ.restrictScalars F⟩ have hL (σ : Λ) : ϕ < L σ := lt_iff.mpr ⟨by simpa only [L, restrictScalars_adjoin_eq_sup, left_lt_sup, adjoin_simple_le_iff], AlgHom.coe_ringHom_injective σ.comp_algebraMap⟩ have ⟨(ϕ_ext : ϕ.IsExtendible), ϕ_max⟩ := maximal_iff_forall_gt.mp hϕ simp_rw [Set.mem_setOf, IsExtendible] at ϕ_max; push_neg at ϕ_max choose S hS using fun σ : Λ ↦ ϕ_max (hL σ) classical have ⟨θ, hθϕ, hθ⟩ := ϕ_ext ({α} ∪ Finset.univ.biUnion S) simp_rw [Finset.coe_union, Set.union_subset_iff, Finset.coe_singleton, Set.singleton_subset_iff, Finset.coe_biUnion, Finset.coe_univ, Set.mem_univ, Set.iUnion_true, Set.iUnion_subset_iff] at hθ have : ϕ.carrier⟮α⟯.restrictScalars F ≤ θ.carrier := by rw [restrictScalars_adjoin_eq_sup, sup_le_iff, adjoin_simple_le_iff]; exact ⟨hθϕ.1, hθ.1⟩ exact hS ⟨(θ.emb.comp <| inclusion this).toRingHom, hθϕ.2⟩ θ ⟨this, fun _ ↦ rfl⟩ (hθ.2 _) /-- Given a lift `x` and an integral element `s : E` over `x.carrier` whose conjugates over `x.carrier` are all in `K`, we can extend the lift to a lift whose carrier contains `s`. -/ theorem exists_lift_of_splits' (x : Lifts F E K) {s : E} (h1 : IsIntegral x.carrier s) (h2 : (minpoly x.carrier s).Splits x.emb.toRingHom) : ∃ y, x ≤ y ∧ s ∈ y.carrier := have I2 := (minpoly.degree_pos h1).ne' letI : Algebra x.carrier K := x.emb.toRingHom.toAlgebra let carrier := x.carrier⟮s⟯.restrictScalars F letI : Algebra x.carrier carrier := x.carrier⟮s⟯.toSubalgebra.algebra let φ : carrier →ₐ[x.carrier] K := ((algHomAdjoinIntegralEquiv x.carrier h1).symm ⟨rootOfSplits x.emb.toRingHom h2 I2, by rw [mem_aroots, and_iff_right (minpoly.ne_zero h1)] exact map_rootOfSplits x.emb.toRingHom h2 I2⟩) ⟨⟨carrier, (@algHomEquivSigma F x.carrier carrier K _ _ _ _ _ _ _ _ (IsScalarTower.of_algebraMap_eq fun _ ↦ rfl)).symm ⟨x.emb, φ⟩⟩, ⟨fun z hz ↦ algebraMap_mem x.carrier⟮s⟯ ⟨z, hz⟩, φ.commutes⟩, mem_adjoin_simple_self x.carrier s⟩ /-- Given an integral element `s : E` over `F` whose `F`-conjugates are all in `K`, any lift can be extended to one whose carrier contains `s`. -/ theorem exists_lift_of_splits (x : Lifts F E K) {s : E} (h1 : IsIntegral F s) (h2 : (minpoly F s).Splits (algebraMap F K)) : ∃ y, x ≤ y ∧ s ∈ y.carrier := exists_lift_of_splits' x h1.tower_top <| h1.minpoly_splits_tower_top' <| by rwa [← x.emb.comp_algebraMap] at h2 end Lifts section private theorem exists_algHom_adjoin_of_splits'' {L : IntermediateField F E} (f : L →ₐ[F] K) (hK : ∀ s ∈ S, IsIntegral L s ∧ (minpoly L s).Splits f.toRingHom) : ∃ φ : adjoin L S →ₐ[F] K, φ.restrictDomain L = f := by obtain ⟨φ, hfφ, hφ⟩ := zorn_le_nonempty_Ici₀ _ (fun c _ hc _ _ ↦ Lifts.exists_upper_bound c hc) ⟨L, f⟩ le_rfl refine ⟨φ.emb.comp (inclusion <| (le_extendScalars_iff hfφ.1 <| adjoin L S).mp <| adjoin_le_iff.mpr fun s h ↦ ?_), AlgHom.ext hfφ.2⟩ letI := (inclusion hfφ.1).toAlgebra letI : SMul L φ.carrier := Algebra.toSMul have : IsScalarTower L φ.carrier E := ⟨fun x y ↦ smul_assoc x (y : E)⟩ have := φ.exists_lift_of_splits' (hK s h).1.tower_top ((hK s h).1.minpoly_splits_tower_top' ?_) · obtain ⟨y, h1, h2⟩ := this exact (hφ h1).1 h2 · convert (hK s h).2; ext; apply hfφ.2 variable {L : Type*} [Field L] [Algebra F L] [Algebra L E] [IsScalarTower F L E] (f : L →ₐ[F] K) (hK : ∀ s ∈ S, IsIntegral L s ∧ (minpoly L s).Splits f.toRingHom) include hK in theorem exists_algHom_adjoin_of_splits' : ∃ φ : adjoin L S →ₐ[F] K, φ.restrictDomain L = f := by let L' := (IsScalarTower.toAlgHom F L E).fieldRange let f' : L' →ₐ[F] K := f.comp (AlgEquiv.ofInjectiveField _).symm.toAlgHom have := exists_algHom_adjoin_of_splits'' f' (S := S) fun s hs ↦ ?_ · obtain ⟨φ, hφ⟩ := this; refine ⟨φ.comp <| inclusion (?_ : (adjoin L S).restrictScalars F ≤ (adjoin L' S).restrictScalars F), ?_⟩ · simp_rw [← SetLike.coe_subset_coe, coe_restrictScalars, adjoin_subset_adjoin_iff] exact ⟨subset_adjoin_of_subset_left S (F := L'.toSubfield) le_rfl, subset_adjoin _ _⟩ · ext x let y := (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)) x refine Eq.trans congr($hφ y) ?_ simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, AlgHom.coe_coe, Function.comp_apply, f'] exact congr_arg f (AlgEquiv.symm_apply_apply _ _) letI : Algebra L L' := (AlgEquiv.ofInjectiveField _).toRingHom.toAlgebra have : IsScalarTower L L' E := IsScalarTower.of_algebraMap_eq' rfl refine ⟨(hK s hs).1.tower_top, (hK s hs).1.minpoly_splits_tower_top' ?_⟩ convert (hK s hs).2 ext simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, RingHom.coe_comp, RingHom.coe_coe, AlgHom.coe_comp, AlgHom.coe_coe, Function.comp_apply, f'] exact congr_arg f (AlgEquiv.symm_apply_apply _ _) include hK in theorem exists_algHom_of_adjoin_splits' (hS : adjoin L S = ⊤) : ∃ φ : E →ₐ[F] K, φ.restrictDomain L = f := have ⟨φ, hφ⟩ := exists_algHom_adjoin_of_splits' f hK ⟨φ.comp (((equivOfEq hS).trans topEquiv).symm.toAlgHom.restrictScalars F), hφ⟩ theorem exists_algHom_of_splits' (hK : ∀ s : E, IsIntegral L s ∧ (minpoly L s).Splits f.toRingHom) : ∃ φ : E →ₐ[F] K, φ.restrictDomain L = f := exists_algHom_of_adjoin_splits' f (fun x _ ↦ hK x) (adjoin_univ L E) end variable (hK : ∀ s ∈ S, IsIntegral F s ∧ (minpoly F s).Splits (algebraMap F K)) (hK' : ∀ s : E, IsIntegral F s ∧ (minpoly F s).Splits (algebraMap F K)) {L : IntermediateField F E} (f : L →ₐ[F] K) (hL : L ≤ adjoin F S) {x : E} {y : K} section include hK theorem exists_algHom_adjoin_of_splits : ∃ φ : adjoin F S →ₐ[F] K, φ.comp (inclusion hL) = f := by obtain ⟨φ, hfφ, hφ⟩ := zorn_le_nonempty_Ici₀ _ (fun c _ hc _ _ ↦ Lifts.exists_upper_bound c hc) ⟨L, f⟩ le_rfl refine ⟨φ.emb.comp (inclusion <| adjoin_le_iff.mpr fun s hs ↦ ?_), ?_⟩ · rcases φ.exists_lift_of_splits (hK s hs).1 (hK s hs).2 with ⟨y, h1, h2⟩ exact (hφ h1).1 h2 · ext; apply hfφ.2 theorem nonempty_algHom_adjoin_of_splits : Nonempty (adjoin F S →ₐ[F] K) := have ⟨φ, _⟩ := exists_algHom_adjoin_of_splits hK (⊥ : Lifts F E K).emb bot_le; ⟨φ⟩ variable (hS : adjoin F S = ⊤) include hS in theorem exists_algHom_of_adjoin_splits : ∃ φ : E →ₐ[F] K, φ.comp L.val = f := have ⟨φ, hφ⟩ := exists_algHom_adjoin_of_splits hK f (hS.symm ▸ le_top) ⟨φ.comp ((equivOfEq hS).trans topEquiv).symm.toAlgHom, hφ⟩ include hS in theorem nonempty_algHom_of_adjoin_splits : Nonempty (E →ₐ[F] K) := have ⟨φ, _⟩ := exists_algHom_of_adjoin_splits hK (⊥ : Lifts F E K).emb hS; ⟨φ⟩ variable (hx : x ∈ adjoin F S) (hy : aeval y (minpoly F x) = 0) include hy theorem exists_algHom_adjoin_of_splits_of_aeval : ∃ φ : adjoin F S →ₐ[F] K, φ ⟨x, hx⟩ = y := by have := isAlgebraic_adjoin (fun s hs ↦ (hK s hs).1) have ix : IsAlgebraic F _ := Algebra.IsAlgebraic.isAlgebraic (⟨x, hx⟩ : adjoin F S) rw [isAlgebraic_iff_isIntegral, isIntegral_iff] at ix obtain ⟨φ, hφ⟩ := exists_algHom_adjoin_of_splits hK ((algHomAdjoinIntegralEquiv F ix).symm ⟨y, mem_aroots.mpr ⟨minpoly.ne_zero ix, hy⟩⟩) (adjoin_simple_le_iff.mpr hx) exact ⟨φ, (DFunLike.congr_fun hφ <| AdjoinSimple.gen F x).trans <| algHomAdjoinIntegralEquiv_symm_apply_gen F ix _⟩ include hS in theorem exists_algHom_of_adjoin_splits_of_aeval : ∃ φ : E →ₐ[F] K, φ x = y := have ⟨φ, hφ⟩ := exists_algHom_adjoin_of_splits_of_aeval hK (hS ▸ mem_top) hy ⟨φ.comp ((equivOfEq hS).trans topEquiv).symm.toAlgHom, hφ⟩ include hK' end section include hK' theorem exists_algHom_of_splits : ∃ φ : E →ₐ[F] K, φ.comp L.val = f := exists_algHom_of_adjoin_splits (fun x _ ↦ hK' x) f (adjoin_univ F E) theorem nonempty_algHom_of_splits : Nonempty (E →ₐ[F] K) := nonempty_algHom_of_adjoin_splits (fun x _ ↦ hK' x) (adjoin_univ F E) theorem exists_algHom_of_splits_of_aeval (hy : aeval y (minpoly F x) = 0) : ∃ φ : E →ₐ[F] K, φ x = y := exists_algHom_of_adjoin_splits_of_aeval (fun x _ ↦ hK' x) (adjoin_univ F E) hy end end IntermediateField section Algebra.IsAlgebraic /-- Let `K/F` be an algebraic extension of fields and `L` a field in which all the minimal polynomial over `F` of elements of `K` splits. Then, for `x ∈ K`, the images of `x` by the `F`-algebra morphisms from `K` to `L` are exactly the roots in `L` of the minimal polynomial of `x` over `F`. -/ theorem Algebra.IsAlgebraic.range_eval_eq_rootSet_minpoly_of_splits {F K : Type*} (L : Type*) [Field F] [Field K] [Field L] [Algebra F L] [Algebra F K] (hA : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) [Algebra.IsAlgebraic F K] (x : K) : (Set.range fun (ψ : K →ₐ[F] L) => ψ x) = (minpoly F x).rootSet L := by ext a rw [mem_rootSet_of_ne (minpoly.ne_zero (Algebra.IsIntegral.isIntegral x))] refine ⟨fun ⟨ψ, hψ⟩ ↦ ?_, fun ha ↦ IntermediateField.exists_algHom_of_splits_of_aeval (fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, hA x⟩) ha⟩ rw [← hψ, Polynomial.aeval_algHom_apply ψ x, minpoly.aeval, map_zero] end Algebra.IsAlgebraic
.lake/packages/mathlib/Mathlib/FieldTheory/Cardinality.lean
import Mathlib.Algebra.Field.TransferInstance import Mathlib.Algebra.Field.ULift import Mathlib.Algebra.MvPolynomial.Cardinal import Mathlib.Data.Rat.Encodable import Mathlib.FieldTheory.Finite.GaloisField import Mathlib.RingTheory.Localization.Cardinality import Mathlib.SetTheory.Cardinal.Divisibility /-! # Cardinality of Fields In this file we show all the possible cardinalities of fields. All infinite cardinals can harbour a field structure, and so can all types with prime power cardinalities, and this is sharp. ## Main statements * `Fintype.nonempty_field_iff`: A `Fintype` can be given a field structure iff its cardinality is a prime power. * `Infinite.nonempty_field` : Any infinite type can be endowed a field structure. * `Field.nonempty_iff` : There is a field structure on type iff its cardinality is a prime power. -/ local notation "‖" x "‖" => Fintype.card x open scoped Cardinal nonZeroDivisors universe u /-- A finite field has prime power cardinality. -/ theorem Fintype.isPrimePow_card_of_field {α} [Fintype α] [Field α] : IsPrimePow ‖α‖ := -- TODO: `Algebra` version of `CharP.exists`, of type `∀ p, Algebra (ZMod p) α` FiniteField.isPrimePow_card α /-- A `Fintype` can be given a field structure iff its cardinality is a prime power. -/ theorem Fintype.nonempty_field_iff {α} [Fintype α] : Nonempty (Field α) ↔ IsPrimePow ‖α‖ := by refine ⟨fun ⟨h⟩ => Fintype.isPrimePow_card_of_field, ?_⟩ rintro ⟨p, n, hp, hn, hα⟩ haveI := Fact.mk hp.nat_prime haveI : Fintype (GaloisField p n) := Fintype.ofFinite (GaloisField p n) exact ⟨(Fintype.equivOfCardEq (((Fintype.card_eq_nat_card).trans (GaloisField.card p n hn.ne')).trans hα)).symm.field⟩ theorem Fintype.not_isField_of_card_not_prime_pow {α} [Fintype α] [Ring α] : ¬IsPrimePow ‖α‖ → ¬IsField α := mt fun h => Fintype.nonempty_field_iff.mp ⟨h.toField⟩ /-- Any infinite type can be endowed a field structure. -/ theorem Infinite.nonempty_field {α : Type u} [Infinite α] : Nonempty (Field α) := by suffices #α = #(FractionRing (MvPolynomial α <| ULift.{u} ℚ)) from (Cardinal.eq.1 this).map (·.field) simp /-- There is a field structure on type if and only if its cardinality is a prime power. -/ theorem Field.nonempty_iff {α : Type u} : Nonempty (Field α) ↔ IsPrimePow #α := by rw [Cardinal.isPrimePow_iff] obtain h | h := fintypeOrInfinite α · simpa only [Cardinal.mk_fintype, Nat.cast_inj, exists_eq_left', (Cardinal.nat_lt_aleph0 _).not_ge, false_or] using Fintype.nonempty_field_iff · simpa only [← Cardinal.infinite_iff, h, true_or, iff_true] using Infinite.nonempty_field
.lake/packages/mathlib/Mathlib/FieldTheory/ChevalleyWarning.lean
import Mathlib.FieldTheory.Finite.Basic /-! # The Chevalley–Warning theorem This file contains a proof of the Chevalley–Warning theorem. Throughout most of this file, `K` denotes a finite field and `q` is notation for the cardinality of `K`. ## Main results 1. Let `f` be a multivariate polynomial in finitely many variables (`X s`, `s : σ`) such that the total degree of `f` is less than `(q-1)` times the cardinality of `σ`. Then the evaluation of `f` on all points of `σ → K` (aka `K^σ`) sums to `0`. (`sum_eval_eq_zero`) 2. The Chevalley–Warning theorem (`char_dvd_card_solutions_of_sum_lt`). Let `f i` be a finite family of multivariate polynomials in finitely many variables (`X s`, `s : σ`) such that the sum of the total degrees of the `f i` is less than the cardinality of `σ`. Then the number of common solutions of the `f i` is divisible by the characteristic of `K`. ## Notation - `K` is a finite field - `q` is notation for the cardinality of `K` - `σ` is the indexing type for the variables of a multivariate polynomial ring over `K` -/ universe u v section FiniteField open MvPolynomial open Function hiding eval open Finset FiniteField variable {K σ ι : Type*} [Fintype K] [Field K] [Fintype σ] [DecidableEq σ] local notation "q" => Fintype.card K theorem MvPolynomial.sum_eval_eq_zero (f : MvPolynomial σ K) (h : f.totalDegree < (q - 1) * Fintype.card σ) : ∑ x, eval x f = 0 := by haveI : DecidableEq K := Classical.decEq K calc ∑ x, eval x f = ∑ x : σ → K, ∑ d ∈ f.support, f.coeff d * ∏ i, x i ^ d i := by simp only [eval_eq'] _ = ∑ d ∈ f.support, ∑ x : σ → K, f.coeff d * ∏ i, x i ^ d i := sum_comm _ = 0 := sum_eq_zero ?_ intro d hd obtain ⟨i, hi⟩ : ∃ i, d i < q - 1 := f.exists_degree_lt (q - 1) h hd calc (∑ x : σ → K, f.coeff d * ∏ i, x i ^ d i) = f.coeff d * ∑ x : σ → K, ∏ i, x i ^ d i := (mul_sum ..).symm _ = 0 := (mul_eq_zero.mpr ∘ Or.inr) ?_ calc (∑ x : σ → K, ∏ i, x i ^ d i) = ∑ x₀ : { j // j ≠ i } → K, ∑ x : { x : σ → K // x ∘ (↑) = x₀ }, ∏ j, (x : σ → K) j ^ d j := (Fintype.sum_fiberwise _ _).symm _ = 0 := Fintype.sum_eq_zero _ ?_ intro x₀ let e : K ≃ { x // x ∘ ((↑) : _ → σ) = x₀ } := (Equiv.subtypeEquivCodomain _).symm calc (∑ x : { x : σ → K // x ∘ (↑) = x₀ }, ∏ j, (x : σ → K) j ^ d j) = ∑ a : K, ∏ j : σ, (e a : σ → K) j ^ d j := (e.sum_comp _).symm _ = ∑ a : K, (∏ j, x₀ j ^ d j) * a ^ d i := Fintype.sum_congr _ _ ?_ _ = (∏ j, x₀ j ^ d j) * ∑ a : K, a ^ d i := by rw [mul_sum] _ = 0 := by rw [sum_pow_lt_card_sub_one K _ hi, mul_zero] intro a let e' : { j // j = i } ⊕ { j // j ≠ i } ≃ σ := Equiv.sumCompl _ letI : Unique { j // j = i } := { default := ⟨i, rfl⟩ uniq := fun ⟨j, h⟩ => Subtype.val_injective h } calc (∏ j : σ, (e a : σ → K) j ^ d j) = (e a : σ → K) i ^ d i * ∏ j : { j // j ≠ i }, (e a : σ → K) j ^ d j := by rw [← e'.prod_comp, Fintype.prod_sum_type, univ_unique, prod_singleton]; rfl _ = a ^ d i * ∏ j : { j // j ≠ i }, (e a : σ → K) j ^ d j := by rw [Equiv.subtypeEquivCodomain_symm_apply_eq] _ = a ^ d i * ∏ j, x₀ j ^ d j := congr_arg _ (Fintype.prod_congr _ _ ?_) -- see below _ = (∏ j, x₀ j ^ d j) * a ^ d i := mul_comm _ _ -- the remaining step of the calculation above rintro ⟨j, hj⟩ change (e a : σ → K) j ^ d j = x₀ ⟨j, hj⟩ ^ d j rw [Equiv.subtypeEquivCodomain_symm_apply_ne] variable [DecidableEq K] (p : ℕ) [CharP K p] /-- The **Chevalley–Warning theorem**, finitary version. Let `(f i)` be a finite family of multivariate polynomials in finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`. Assume that the sum of the total degrees of the `f i` is less than the cardinality of `σ`. Then the number of common solutions of the `f i` is divisible by `p`. -/ theorem char_dvd_card_solutions_of_sum_lt {s : Finset ι} {f : ι → MvPolynomial σ K} (h : (∑ i ∈ s, (f i).totalDegree) < Fintype.card σ) : p ∣ Fintype.card { x : σ → K // ∀ i ∈ s, eval x (f i) = 0 } := by have hq : 0 < q - 1 := by rw [← Fintype.card_units, Fintype.card_pos_iff]; exact ⟨1⟩ let S : Finset (σ → K) := {x | ∀ i ∈ s, eval x (f i) = 0} have hS (x : σ → K) : x ∈ S ↔ ∀ i ∈ s, eval x (f i) = 0 := by simp [S] /- The polynomial `F = ∏ i ∈ s, (1 - (f i)^(q - 1))` has the nice property that it takes the value `1` on elements of `{x : σ → K // ∀ i ∈ s, (f i).eval x = 0}` while it is `0` outside that locus. Hence the sum of its values is equal to the cardinality of `{x : σ → K // ∀ i ∈ s, (f i).eval x = 0}` modulo `p`. -/ let F : MvPolynomial σ K := ∏ i ∈ s, (1 - f i ^ (q - 1)) have hF : ∀ x, eval x F = if x ∈ S then 1 else 0 := by intro x calc eval x F = ∏ i ∈ s, eval x (1 - f i ^ (q - 1)) := eval_prod s _ x _ = if x ∈ S then 1 else 0 := ?_ simp only [(eval x).map_sub, (eval x).map_pow, (eval x).map_one] split_ifs with hx · apply Finset.prod_eq_one intro i hi rw [hS] at hx rw [hx i hi, zero_pow hq.ne', sub_zero] · obtain ⟨i, hi, hx⟩ : ∃ i ∈ s, eval x (f i) ≠ 0 := by simpa [hS, not_forall, Classical.not_imp] using hx apply Finset.prod_eq_zero hi rw [pow_card_sub_one_eq_one (eval x (f i)) hx, sub_self] -- In particular, we can now show: have key : ∑ x, eval x F = Fintype.card { x : σ → K // ∀ i ∈ s, eval x (f i) = 0 } := by rw [Fintype.card_of_subtype S hS, card_eq_sum_ones, Nat.cast_sum, Nat.cast_one, ← Fintype.sum_extend_by_zero S, sum_congr rfl fun x _ => hF x] -- With these preparations under our belt, we will approach the main goal. change p ∣ Fintype.card { x // ∀ i : ι, i ∈ s → eval x (f i) = 0 } rw [← CharP.cast_eq_zero_iff K, ← key] change (∑ x, eval x F) = 0 -- We are now ready to apply the main machine, proven before. apply F.sum_eval_eq_zero -- It remains to verify the crucial assumption of this machine show F.totalDegree < (q - 1) * Fintype.card σ calc F.totalDegree ≤ ∑ i ∈ s, (1 - f i ^ (q - 1)).totalDegree := totalDegree_finset_prod s _ _ ≤ ∑ i ∈ s, (q - 1) * (f i).totalDegree := sum_le_sum fun i _ => ?_ -- see ↓ _ = (q - 1) * ∑ i ∈ s, (f i).totalDegree := (mul_sum ..).symm _ < (q - 1) * Fintype.card σ := by gcongr -- Now we prove the remaining step from the preceding calculation change (1 - f i ^ (q - 1)).totalDegree ≤ (q - 1) * (f i).totalDegree calc (1 - f i ^ (q - 1)).totalDegree ≤ max (1 : MvPolynomial σ K).totalDegree (f i ^ (q - 1)).totalDegree := totalDegree_sub _ _ _ ≤ (f i ^ (q - 1)).totalDegree := by simp _ ≤ (q - 1) * (f i).totalDegree := totalDegree_pow _ _ /-- The **Chevalley–Warning theorem**, `Fintype` version. Let `(f i)` be a finite family of multivariate polynomials in finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`. Assume that the sum of the total degrees of the `f i` is less than the cardinality of `σ`. Then the number of common solutions of the `f i` is divisible by `p`. -/ theorem char_dvd_card_solutions_of_fintype_sum_lt [Fintype ι] {f : ι → MvPolynomial σ K} (h : (∑ i, (f i).totalDegree) < Fintype.card σ) : p ∣ Fintype.card { x : σ → K // ∀ i, eval x (f i) = 0 } := by simpa using char_dvd_card_solutions_of_sum_lt p h /-- The **Chevalley–Warning theorem**, unary version. Let `f` be a multivariate polynomial in finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`. Assume that the total degree of `f` is less than the cardinality of `σ`. Then the number of solutions of `f` is divisible by `p`. See `char_dvd_card_solutions_of_sum_lt` for a version that takes a family of polynomials `f i`. -/ theorem char_dvd_card_solutions {f : MvPolynomial σ K} (h : f.totalDegree < Fintype.card σ) : p ∣ Fintype.card { x : σ → K // eval x f = 0 } := by let F : Unit → MvPolynomial σ K := fun _ => f have : (∑ i : Unit, (F i).totalDegree) < Fintype.card σ := h convert char_dvd_card_solutions_of_sum_lt p this aesop /-- The **Chevalley–Warning theorem**, binary version. Let `f₁`, `f₂` be two multivariate polynomials in finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`. Assume that the sum of the total degrees of `f₁` and `f₂` is less than the cardinality of `σ`. Then the number of common solutions of the `f₁` and `f₂` is divisible by `p`. -/ theorem char_dvd_card_solutions_of_add_lt {f₁ f₂ : MvPolynomial σ K} (h : f₁.totalDegree + f₂.totalDegree < Fintype.card σ) : p ∣ Fintype.card { x : σ → K // eval x f₁ = 0 ∧ eval x f₂ = 0 } := by let F : Bool → MvPolynomial σ K := fun b => cond b f₂ f₁ have : (∑ b : Bool, (F b).totalDegree) < Fintype.card σ := (add_comm _ _).trans_lt h simpa only [Bool.forall_bool] using char_dvd_card_solutions_of_fintype_sum_lt p this end FiniteField
.lake/packages/mathlib/Mathlib/FieldTheory/IsSepClosed.lean
import Mathlib.FieldTheory.Galois.Basic /-! # Separably Closed Field In this file we define the typeclass for separably closed fields and separable closures, and prove some of their properties. ## Main Definitions - `IsSepClosed k` is the typeclass saying `k` is a separably closed field, i.e. every separable polynomial in `k` splits. - `IsSepClosure k K` is the typeclass saying `K` is a separable closure of `k`, where `k` is a field. This means that `K` is separably closed and separable over `k`. - `IsSepClosed.lift` is a map from a separable extension `L` of `K`, into any separably closed extension `M` of `K`. - `IsSepClosure.equiv` is a proof that any two separable closures of the same field are isomorphic. - `IsSepClosure.isAlgClosure_of_perfectField`, `IsSepClosure.of_isAlgClosure_of_perfectField`: if `k` is a perfect field, then its separable closure coincides with its algebraic closure. ## Tags separable closure, separably closed ## Related - `separableClosure`: maximal separable subextension of `K/k`, consisting of all elements of `K` which are separable over `k`. - `separableClosure.isSepClosure`: if `K` is a separably closed field containing `k`, then the maximal separable subextension of `K/k` is a separable closure of `k`. - In particular, a separable closure (`SeparableClosure`) exists. - `Algebra.IsAlgebraic.isPurelyInseparable_of_isSepClosed`: an algebraic extension of a separably closed field is purely inseparable. -/ universe u v w open Polynomial variable (k : Type u) [Field k] (K : Type v) [Field K] /-- Typeclass for separably closed fields. To show `Polynomial.Splits p f` for an arbitrary ring homomorphism `f`, see `IsSepClosed.splits_codomain` and `IsSepClosed.splits_domain`. -/ class IsSepClosed : Prop where factors_of_separable : ∀ p : k[X], p.Separable → p.Factors /-- An algebraically closed field is also separably closed. -/ instance IsSepClosed.of_isAlgClosed [IsAlgClosed k] : IsSepClosed k := ⟨fun p _ ↦ IsAlgClosed.factors p⟩ variable {k} {K} theorem IsSepClosed.splits_of_separable [IsSepClosed k] (p : k[X]) (hp : p.Separable) : p.Splits (RingHom.id k) := (factors_of_separable p hp).map (RingHom.id k) /-- Every separable polynomial splits in the field extension `f : k →+* K` if `K` is separably closed. See also `IsSepClosed.splits_domain` for the case where `k` is separably closed. -/ theorem IsSepClosed.splits_codomain [IsSepClosed K] {f : k →+* K} (p : k[X]) (h : p.Separable) : p.Splits f := by convert IsSepClosed.splits_of_separable (p.map f) (Separable.map h); simp [splits_map_iff] /-- Every separable polynomial splits in the field extension `f : k →+* K` if `k` is separably closed. See also `IsSepClosed.splits_codomain` for the case where `k` is separably closed. -/ theorem IsSepClosed.splits_domain [IsSepClosed k] {f : k →+* K} (p : k[X]) (h : p.Separable) : p.Splits f := Polynomial.splits_of_splits_id _ <| IsSepClosed.splits_of_separable _ h namespace IsSepClosed theorem exists_root [IsSepClosed k] (p : k[X]) (hp : p.degree ≠ 0) (hsep : p.Separable) : ∃ x, IsRoot p x := exists_root_of_splits _ (IsSepClosed.splits_of_separable p hsep) hp /-- If `n ≥ 2` equals zero in a separably closed field `k`, `b ≠ 0`, then there exists `x` in `k` such that `a * x ^ n + b * x + c = 0`. -/ theorem exists_root_C_mul_X_pow_add_C_mul_X_add_C [IsSepClosed k] {n : ℕ} (a b c : k) (hn : (n : k) = 0) (hn' : 2 ≤ n) (hb : b ≠ 0) : ∃ x, a * x ^ n + b * x + c = 0 := by let f : k[X] := C a * X ^ n + C b * X + C c have hdeg : f.degree ≠ 0 := degree_ne_of_natDegree_ne <| by by_cases ha : a = 0 · suffices f.natDegree = 1 from this ▸ one_ne_zero simp_rw [f, ha, map_zero, zero_mul, zero_add] compute_degree! · suffices f.natDegree = n from this ▸ (lt_of_lt_of_le zero_lt_two hn').ne' simp_rw [f] have h0 : n ≠ 0 := by linarith only [hn'] have h1 : n ≠ 1 := by linarith only [hn'] have : 1 ≤ n := le_trans one_le_two hn' compute_degree! simp [h0, h1, ha] have hsep : f.Separable := separable_C_mul_X_pow_add_C_mul_X_add_C a b c hn hb.isUnit obtain ⟨x, hx⟩ := exists_root f hdeg hsep exact ⟨x, by simpa [f] using hx⟩ /-- If a separably closed field `k` is of characteristic `p`, `n ≥ 2` is such that `p ∣ n`, `b ≠ 0`, then there exists `x` in `k` such that `a * x ^ n + b * x + c = 0`. -/ theorem exists_root_C_mul_X_pow_add_C_mul_X_add_C' [IsSepClosed k] (p n : ℕ) (a b c : k) [CharP k p] (hn : p ∣ n) (hn' : 2 ≤ n) (hb : b ≠ 0) : ∃ x, a * x ^ n + b * x + c = 0 := exists_root_C_mul_X_pow_add_C_mul_X_add_C a b c ((CharP.cast_eq_zero_iff k p n).2 hn) hn' hb variable (k) in /-- A separably closed perfect field is also algebraically closed. -/ instance (priority := 100) isAlgClosed_of_perfectField [IsSepClosed k] [PerfectField k] : IsAlgClosed k := IsAlgClosed.of_exists_root k fun p _ h ↦ exists_root p ((degree_pos_of_irreducible h).ne') (PerfectField.separable_of_irreducible h) theorem exists_pow_nat_eq [IsSepClosed k] (x : k) (n : ℕ) [hn : NeZero (n : k)] : ∃ z, z ^ n = x := by have hn' : 0 < n := Nat.pos_of_ne_zero fun h => by rw [h, Nat.cast_zero] at hn exact hn.out rfl have : degree (X ^ n - C x) ≠ 0 := by rw [degree_X_pow_sub_C hn' x] exact (WithBot.coe_lt_coe.2 hn').ne' by_cases hx : x = 0 · exact ⟨0, by rw [hx, pow_eq_zero_iff hn'.ne']⟩ · obtain ⟨z, hz⟩ := exists_root _ this <| separable_X_pow_sub_C x hn.out hx use z simpa [eval_C, eval_X, eval_pow, eval_sub, IsRoot.def, sub_eq_zero] using hz theorem exists_eq_mul_self [IsSepClosed k] (x : k) [h2 : NeZero (2 : k)] : ∃ z, x = z * z := by rcases exists_pow_nat_eq x 2 with ⟨z, rfl⟩ exact ⟨z, sq z⟩ theorem roots_eq_zero_iff [IsSepClosed k] {p : k[X]} (hsep : p.Separable) : p.roots = 0 ↔ p = Polynomial.C (p.coeff 0) := by refine ⟨fun h => ?_, fun hp => by rw [hp, roots_C]⟩ rcases le_or_gt (degree p) 0 with hd | hd · exact eq_C_of_degree_le_zero hd · obtain ⟨z, hz⟩ := IsSepClosed.exists_root p hd.ne' hsep rw [← mem_roots (ne_zero_of_degree_gt hd), h] at hz simp at hz theorem exists_eval₂_eq_zero_of_injective {k : Type*} [CommSemiring k] [IsSepClosed K] (f : k →+* K) (hf : Function.Injective f) (p : k[X]) (hp : p.degree ≠ 0) (hsep : p.Separable) : ∃ x, p.eval₂ f x = 0 := let ⟨x, hx⟩ := exists_root (p.map f) (by rwa [degree_map_eq_of_injective hf]) (Separable.map hsep) ⟨x, by rwa [eval₂_eq_eval_map, ← IsRoot]⟩ theorem exists_eval₂_eq_zero {k : Type*} [CommRing k] [IsSimpleRing k] [IsSepClosed K] (f : k →+* K) (p : k[X]) (hp : p.degree ≠ 0) (hsep : p.Separable) : ∃ x, p.eval₂ f x = 0 := exists_eval₂_eq_zero_of_injective _ f.injective _ hp hsep variable (K) theorem exists_aeval_eq_zero {k : Type*} [CommSemiring k] [IsSepClosed K] [Algebra k K] [FaithfulSMul k K] (p : k[X]) (hp : p.degree ≠ 0) (hsep : p.Separable) : ∃ x : K, p.aeval x = 0 := exists_eval₂_eq_zero_of_injective _ (FaithfulSMul.algebraMap_injective ..) p hp hsep variable (k) {K} theorem of_exists_root (H : ∀ p : k[X], p.Monic → Irreducible p → Separable p → ∃ x, p.eval x = 0) : IsSepClosed k := by refine ⟨fun p hsep ↦ factors_iff_splits.mpr <| Or.inr ?_⟩ intro q hq hdvd have hlc : IsUnit (leadingCoeff q)⁻¹ := IsUnit.inv <| Ne.isUnit <| leadingCoeff_ne_zero.2 <| Irreducible.ne_zero hq have hsep' : Separable (q * C (leadingCoeff q)⁻¹) := Separable.mul (Separable.of_dvd hsep hdvd) ((separable_C _).2 hlc) (by simpa only [← isCoprime_mul_unit_right_right (isUnit_C.2 hlc) q 1, one_mul] using isCoprime_one_right (x := q)) have hirr' := hq rw [← irreducible_mul_isUnit (isUnit_C.2 hlc)] at hirr' obtain ⟨x, hx⟩ := H (q * C (leadingCoeff q)⁻¹) (monic_mul_leadingCoeff_inv hq.ne_zero) hirr' hsep' exact degree_mul_leadingCoeff_inv q hq.ne_zero ▸ degree_eq_one_of_irreducible_of_root hirr' hx theorem degree_eq_one_of_irreducible [IsSepClosed k] {p : k[X]} (hp : Irreducible p) (hsep : p.Separable) : p.degree = 1 := degree_eq_one_of_irreducible_of_splits hp (IsSepClosed.splits_codomain p hsep) variable (K) theorem algebraMap_surjective [IsSepClosed k] [Algebra k K] [Algebra.IsSeparable k K] : Function.Surjective (algebraMap k K) := by refine fun x => ⟨-(minpoly k x).coeff 0, ?_⟩ have hq : (minpoly k x).leadingCoeff = 1 := minpoly.monic (Algebra.IsSeparable.isIntegral k x) have hsep : IsSeparable k x := Algebra.IsSeparable.isSeparable k x have h : (minpoly k x).degree = 1 := degree_eq_one_of_irreducible k (minpoly.irreducible (Algebra.IsSeparable.isIntegral k x)) hsep have : aeval x (minpoly k x) = 0 := minpoly.aeval k x rw [eq_X_add_C_of_degree_eq_one h, hq, C_1, one_mul, aeval_add, aeval_X, aeval_C, add_eq_zero_iff_eq_neg] at this exact (RingHom.map_neg (algebraMap k K) ((minpoly k x).coeff 0)).symm ▸ this.symm end IsSepClosed /-- If `k` is separably closed, `K / k` is a field extension, `L / k` is an intermediate field which is separable, then `L` is equal to `k`. A corollary of `IsSepClosed.algebraMap_surjective`. -/ theorem IntermediateField.eq_bot_of_isSepClosed_of_isSeparable [IsSepClosed k] [Algebra k K] (L : IntermediateField k K) [Algebra.IsSeparable k L] : L = ⊥ := bot_unique fun x hx ↦ by obtain ⟨y, hy⟩ := IsSepClosed.algebraMap_surjective k L ⟨x, hx⟩ exact ⟨y, congr_arg (algebraMap L K) hy⟩ variable (k) (K) /-- Typeclass for an extension being a separable closure. -/ class IsSepClosure [Algebra k K] : Prop where sep_closed : IsSepClosed K separable : Algebra.IsSeparable k K /-- A separably closed field is its separable closure. -/ instance IsSepClosure.self_of_isSepClosed [IsSepClosed k] : IsSepClosure k k := ⟨by assumption, Algebra.isSeparable_self k⟩ /-- If `K` is perfect and is a separable closure of `k`, then it is also an algebraic closure of `k`. -/ instance (priority := 100) IsSepClosure.isAlgClosure_of_perfectField_top [Algebra k K] [IsSepClosure k K] [PerfectField K] : IsAlgClosure k K := haveI : IsSepClosed K := IsSepClosure.sep_closed k ⟨inferInstance, IsSepClosure.separable.isAlgebraic⟩ /-- If `k` is perfect, `K` is a separable closure of `k`, then it is also an algebraic closure of `k`. -/ instance (priority := 100) IsSepClosure.isAlgClosure_of_perfectField [Algebra k K] [IsSepClosure k K] [PerfectField k] : IsAlgClosure k K := have halg : Algebra.IsAlgebraic k K := IsSepClosure.separable.isAlgebraic haveI := halg.perfectField; inferInstance /-- If `k` is perfect, `K` is an algebraic closure of `k`, then it is also a separable closure of `k`. -/ instance (priority := 100) IsSepClosure.of_isAlgClosure_of_perfectField [Algebra k K] [IsAlgClosure k K] [PerfectField k] : IsSepClosure k K := ⟨haveI := IsAlgClosure.isAlgClosed (R := k) (K := K); inferInstance, (IsAlgClosure.isAlgebraic (R := k) (K := K)).isSeparable_of_perfectField⟩ variable {k} {K} theorem isSepClosure_iff [Algebra k K] : IsSepClosure k K ↔ IsSepClosed K ∧ Algebra.IsSeparable k K := ⟨fun h ↦ ⟨h.1, h.2⟩, fun h ↦ ⟨h.1, h.2⟩⟩ namespace IsSepClosure instance isSeparable [Algebra k K] [IsSepClosure k K] : Algebra.IsSeparable k K := IsSepClosure.separable instance (priority := 100) isGalois [Algebra k K] [IsSepClosure k K] : IsGalois k K where to_isSeparable := IsSepClosure.separable to_normal.toIsAlgebraic := inferInstance to_normal.splits' x := (IsSepClosure.sep_closed k).splits_codomain _ (Algebra.IsSeparable.isSeparable k x) end IsSepClosure namespace IsSepClosed variable {K : Type u} (L : Type v) {M : Type w} [Field K] [Field L] [Algebra K L] [Field M] [Algebra K M] [IsSepClosed M] theorem surjective_restrictDomain_of_isSeparable {E : Type*} [Field E] [Algebra K E] [Algebra L E] [IsScalarTower K L E] [Algebra.IsSeparable L E] : Function.Surjective fun φ : E →ₐ[K] M ↦ φ.restrictDomain L := fun f ↦ IntermediateField.exists_algHom_of_splits' (E := E) f fun s ↦ ⟨Algebra.IsSeparable.isIntegral L s, IsSepClosed.splits_codomain _ <| Algebra.IsSeparable.isSeparable L s⟩ variable [Algebra.IsSeparable K L] {L} /-- A (random) homomorphism from a separable extension L of K into a separably closed extension M of K. -/ noncomputable irreducible_def lift : L →ₐ[K] M := Classical.choice <| IntermediateField.nonempty_algHom_of_adjoin_splits (fun x _ ↦ ⟨Algebra.IsSeparable.isIntegral K x, splits_codomain _ (Algebra.IsSeparable.isSeparable K x)⟩) (IntermediateField.adjoin_univ K L) end IsSepClosed namespace IsSepClosure variable (K : Type u) [Field K] (L : Type v) (M : Type w) [Field L] [Field M] variable [Algebra K M] [IsSepClosure K M] variable [Algebra K L] [IsSepClosure K L] attribute [local instance] IsSepClosure.sep_closed in /-- A (random) isomorphism between two separable closures of `K`. -/ noncomputable def equiv : L ≃ₐ[K] M := AlgEquiv.ofBijective _ (Normal.toIsAlgebraic.algHom_bijective₂ (IsSepClosed.lift : L →ₐ[K] M) (IsSepClosed.lift : M →ₐ[K] L)).1 end IsSepClosure
.lake/packages/mathlib/Mathlib/FieldTheory/KummerExtension.lean
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots import Mathlib.FieldTheory.Galois.Basic import Mathlib.FieldTheory.KummerPolynomial import Mathlib.LinearAlgebra.Eigenspace.Minpoly import Mathlib.RingTheory.Norm.Basic /-! # Kummer Extensions ## Main result - `isCyclic_tfae`: Suppose `L/K` is a finite extension of dimension `n`, and `K` contains all `n`-th roots of unity. Then `L/K` is cyclic iff `L` is a splitting field of some irreducible polynomial of the form `Xⁿ - a : K[X]` iff `L = K[α]` for some `αⁿ ∈ K`. - `autEquivRootsOfUnity`: Given an instance `IsSplittingField K L (X ^ n - C a)` (perhaps via `isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top`), then the Galois group is isomorphic to `rootsOfUnity n K`, by sending `σ ↦ σ α / α` for `α ^ n = a`, and the inverse is given by `μ ↦ (α ↦ μ • α)`. - `autEquivZmod`: Furthermore, given an explicit choice `ζ` of a primitive `n`-th root of unity, the Galois group is then isomorphic to `Multiplicative (ZMod n)` whose inverse is given by `i ↦ (α ↦ ζⁱ • α)`. ## Other results Criteria for `X ^ n - C a` to be irreducible is given: - `X_pow_sub_C_irreducible_iff_of_prime_pow`: For `n = p ^ k` an odd prime power, `X ^ n - C a` is irreducible iff `a` is not a `p`-power. - `X_pow_sub_C_irreducible_iff_forall_prime_of_odd`: For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `p`-power for all prime `p ∣ n`. - `X_pow_sub_C_irreducible_iff_of_odd`: For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `d`-power for `d ∣ n` and `d ≠ 1`. TODO: criteria for even `n`. See [serge_lang_algebra] VI,§9. TODO: relate Kummer extensions of degree 2 with the class `Algebra.IsQuadraticExtension`. -/ universe u variable {K : Type u} [Field K] open Polynomial IntermediateField AdjoinRoot section Splits theorem X_pow_sub_C_splits_of_isPrimitiveRoot {n : ℕ} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (e : α ^ n = a) : (X ^ n - C a).Splits (RingHom.id _) := by cases n.eq_zero_or_pos with | inl hn => rw [hn, pow_zero, ← C.map_one, ← map_sub] exact splits_C _ _ | inr hn => rw [splits_iff_card_roots, ← nthRoots, hζ.card_nthRoots, natDegree_X_pow_sub_C, if_pos ⟨α, e⟩] -- make this private, as we only use it to prove a strictly more general version private theorem X_pow_sub_C_eq_prod' {n : ℕ} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (hn : 0 < n) (e : α ^ n = a) : (X ^ n - C a) = ∏ i ∈ Finset.range n, (X - C (ζ ^ i * α)) := by rw [eq_prod_roots_of_monic_of_splits_id (monic_X_pow_sub_C _ (Nat.pos_iff_ne_zero.mp hn)) (X_pow_sub_C_splits_of_isPrimitiveRoot hζ e), ← nthRoots, hζ.nthRoots_eq e, Multiset.map_map] rfl lemma X_pow_sub_C_eq_prod {R : Type*} [CommRing R] [IsDomain R] {n : ℕ} {ζ : R} (hζ : IsPrimitiveRoot ζ n) {α a : R} (hn : 0 < n) (e : α ^ n = a) : (X ^ n - C a) = ∏ i ∈ Finset.range n, (X - C (ζ ^ i * α)) := by let K := FractionRing R let i := algebraMap R K have h := FaithfulSMul.algebraMap_injective R K apply_fun Polynomial.map i using map_injective i h simpa only [Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, map_mul, map_pow, Polynomial.map_prod, Polynomial.map_mul] using X_pow_sub_C_eq_prod' (hζ.map_of_injective h) hn <| map_pow i α n ▸ congrArg i e end Splits section Irreducible theorem X_pow_mul_sub_C_irreducible {n m : ℕ} {a : K} (hm : Irreducible (X ^ m - C a)) (hn : ∀ (E : Type u) [Field E] [Algebra K E] (x : E) (_ : minpoly K x = X ^ m - C a), Irreducible (X ^ n - C (AdjoinSimple.gen K x))) : Irreducible (X ^ (n * m) - C a) := by have hm' : m ≠ 0 := by rintro rfl rw [pow_zero, ← C.map_one, ← map_sub] at hm exact not_irreducible_C _ hm simpa [pow_mul] using irreducible_comp (monic_X_pow_sub_C a hm') (monic_X_pow n) hm (by simpa only [Polynomial.map_pow, map_X] using hn) -- TODO: generalize to even `n` theorem X_pow_sub_C_irreducible_of_odd {n : ℕ} (hn : Odd n) {a : K} (ha : ∀ p : ℕ, p.Prime → p ∣ n → ∀ b : K, b ^ p ≠ a) : Irreducible (X ^ n - C a) := by induction n using induction_on_primes generalizing K a with | zero => simp [← Nat.not_even_iff_odd] at hn | one => simpa using irreducible_X_sub_C a | prime_mul p n hp IH => rw [mul_comm] apply X_pow_mul_sub_C_irreducible (X_pow_sub_C_irreducible_of_prime hp (ha p hp (dvd_mul_right _ _))) intro E _ _ x hx have : IsIntegral K x := not_not.mp fun h ↦ by simpa only [degree_zero, degree_X_pow_sub_C hp.pos, WithBot.natCast_ne_bot] using congr_arg degree (hx.symm.trans (dif_neg h)) apply IH (Nat.odd_mul.mp hn).2 intro q hq hqn b hb apply ha q hq (dvd_mul_of_dvd_right hqn p) (Algebra.norm _ b) rw [← map_pow, hb, ← adjoin.powerBasis_gen this, Algebra.PowerBasis.norm_gen_eq_coeff_zero_minpoly] simp [minpoly_gen, hx, hp.ne_zero.symm, (Nat.odd_mul.mp hn).1.neg_pow] theorem X_pow_sub_C_irreducible_iff_forall_prime_of_odd {n : ℕ} (hn : Odd n) {a : K} : Irreducible (X ^ n - C a) ↔ (∀ p : ℕ, p.Prime → p ∣ n → ∀ b : K, b ^ p ≠ a) := ⟨fun e _ hp hpn ↦ pow_ne_of_irreducible_X_pow_sub_C e hpn hp.ne_one, X_pow_sub_C_irreducible_of_odd hn⟩ theorem X_pow_sub_C_irreducible_iff_of_odd {n : ℕ} (hn : Odd n) {a : K} : Irreducible (X ^ n - C a) ↔ (∀ d, d ∣ n → d ≠ 1 → ∀ b : K, b ^ d ≠ a) := ⟨fun e _ ↦ pow_ne_of_irreducible_X_pow_sub_C e, fun H ↦ X_pow_sub_C_irreducible_of_odd hn fun p hp hpn ↦ (H p hpn hp.ne_one)⟩ -- TODO: generalize to `p = 2` theorem X_pow_sub_C_irreducible_of_prime_pow {p : ℕ} (hp : p.Prime) (hp' : p ≠ 2) (n : ℕ) {a : K} (ha : ∀ b : K, b ^ p ≠ a) : Irreducible (X ^ (p ^ n) - C a) := by apply X_pow_sub_C_irreducible_of_odd (hp.odd_of_ne_two hp').pow intro q hq hq' simpa [(Nat.prime_dvd_prime_iff_eq hq hp).mp (hq.dvd_of_dvd_pow hq')] using ha theorem X_pow_sub_C_irreducible_iff_of_prime_pow {p : ℕ} (hp : p.Prime) (hp' : p ≠ 2) {n} (hn : n ≠ 0) {a : K} : Irreducible (X ^ p ^ n - C a) ↔ ∀ b, b ^ p ≠ a := ⟨(pow_ne_of_irreducible_X_pow_sub_C · (dvd_pow dvd_rfl hn) hp.ne_one), X_pow_sub_C_irreducible_of_prime_pow hp hp' n⟩ end Irreducible /-! ### Galois Group of `K[n√a]` We first develop the theory for a specific `K[n√a] := AdjoinRoot (X ^ n - C a)`. The main result is the description of the Galois group: `autAdjoinRootXPowSubCEquiv`. -/ variable {n : ℕ} (hζ : (primitiveRoots n K).Nonempty) variable (a : K) (H : Irreducible (X ^ n - C a)) set_option quotPrecheck false in scoped[KummerExtension] notation3 "K[" n "√" a "]" => AdjoinRoot (Polynomial.X ^ n - Polynomial.C a) attribute [nolint docBlame] KummerExtension.«termK[_√_]» open scoped KummerExtension section AdjoinRoot include hζ H in /-- Also see `Polynomial.separable_X_pow_sub_C_unit` -/ theorem Polynomial.separable_X_pow_sub_C_of_irreducible : (X ^ n - C a).Separable := by letI := Fact.mk H letI : Algebra K K[n√a] := inferInstance have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H) by_cases hn' : n = 1 · rw [hn', pow_one]; exact separable_X_sub_C have ⟨ζ, hζ⟩ := hζ rw [mem_primitiveRoots (Nat.pos_of_ne_zero <| ne_zero_of_irreducible_X_pow_sub_C H)] at hζ rw [← separable_map (algebraMap K K[n√a]), Polynomial.map_sub, Polynomial.map_pow, map_C, map_X, AdjoinRoot.algebraMap_eq, X_pow_sub_C_eq_prod (hζ.map_of_injective (algebraMap K _).injective) hn (root_X_pow_sub_C_pow n a), separable_prod_X_sub_C_iff'] exact (hζ.map_of_injective (algebraMap K K[n√a]).injective).injOn_pow_mul (root_X_pow_sub_C_ne_zero (lt_of_le_of_ne (show 1 ≤ n from hn) (Ne.symm hn')) _) variable (n) /-- The natural embedding of the roots of unity of `K` into `Gal(K[ⁿ√a]/K)`, by sending `η ↦ (ⁿ√a ↦ η • ⁿ√a)`. Also see `autAdjoinRootXPowSubC` for the `AlgEquiv` version. -/ noncomputable def autAdjoinRootXPowSubCHom : rootsOfUnity n K →* (K[n√a] →ₐ[K] K[n√a]) where toFun η := liftAlgHom (X ^ n - C a) (Algebra.ofId _ _) (((η : Kˣ) : K) • (root _) : K[n√a]) <| by have := (mem_rootsOfUnity' _ _).mp η.prop change aeval _ _ = _ rw [map_sub, map_pow, aeval_C, aeval_X, Algebra.smul_def, mul_pow, root_X_pow_sub_C_pow, AdjoinRoot.algebraMap_eq, ← map_pow, this, map_one, one_mul, sub_self] map_one' := algHom_ext <| by simp map_mul' := fun ε η ↦ algHom_ext <| by simp [mul_smul, smul_comm ((ε : Kˣ) : K)] /-- The natural embedding of the roots of unity of `K` into `Gal(K[ⁿ√a]/K)`, by sending `η ↦ (ⁿ√a ↦ η • ⁿ√a)`. This is an isomorphism when `K` contains a primitive root of unity. See `autAdjoinRootXPowSubCEquiv`. -/ noncomputable def autAdjoinRootXPowSubC : rootsOfUnity n K →* (K[n√a] ≃ₐ[K] K[n√a]) := (AlgEquiv.algHomUnitsEquiv _ _).toMonoidHom.comp (autAdjoinRootXPowSubCHom n a).toHomUnits variable {n} lemma autAdjoinRootXPowSubC_root (η) : autAdjoinRootXPowSubC n a η (root _) = ((η : Kˣ) : K) • root _ := by dsimp [autAdjoinRootXPowSubC, autAdjoinRootXPowSubCHom, AlgEquiv.algHomUnitsEquiv] exact liftAlgHom_root _ (Algebra.ofId _ _) .. variable {a} /-- The inverse function of `autAdjoinRootXPowSubC` if `K` has all roots of unity. See `autAdjoinRootXPowSubCEquiv`. -/ noncomputable def AdjoinRootXPowSubCEquivToRootsOfUnity [NeZero n] (σ : K[n√a] ≃ₐ[K] K[n√a]) : rootsOfUnity n K := letI := Fact.mk H letI : IsDomain K[n√a] := inferInstance letI := Classical.decEq K (rootsOfUnityEquivOfPrimitiveRoots (n := n) (algebraMap K K[n√a]).injective hζ).symm (rootsOfUnity.mkOfPowEq (if a = 0 then 1 else σ (root _) / root _) (by -- The if is needed in case `n = 1` and `a = 0` and `K[n√a] = K`. split · exact one_pow _ rw [div_pow, ← map_pow] simp only [root_X_pow_sub_C_pow, ← AdjoinRoot.algebraMap_eq, AlgEquiv.commutes] rw [div_self] rwa [Ne, map_eq_zero_iff _ (algebraMap K _).injective])) /-- The equivalence between the roots of unity of `K` and `Gal(K[ⁿ√a]/K)`. -/ noncomputable def autAdjoinRootXPowSubCEquiv [NeZero n] : rootsOfUnity n K ≃* (K[n√a] ≃ₐ[K] K[n√a]) where __ := autAdjoinRootXPowSubC n a invFun := AdjoinRootXPowSubCEquivToRootsOfUnity hζ H left_inv := by intro η have := Fact.mk H have : IsDomain K[n√a] := inferInstance letI : Algebra K K[n√a] := inferInstance apply (rootsOfUnityEquivOfPrimitiveRoots (algebraMap K K[n√a]).injective hζ).injective ext simp only [AdjoinRoot.algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, autAdjoinRootXPowSubC_root, Algebra.smul_def, MulEquiv.apply_symm_apply, rootsOfUnity.val_mkOfPowEq_coe, val_rootsOfUnityEquivOfPrimitiveRoots_apply_coe, AdjoinRootXPowSubCEquivToRootsOfUnity] split_ifs with h · obtain rfl := not_imp_not.mp (fun hn ↦ ne_zero_of_irreducible_X_pow_sub_C' hn H) h have : (η : Kˣ) = 1 := (pow_one _).symm.trans η.prop simp only [this, Units.val_one, map_one] · exact mul_div_cancel_right₀ _ (root_X_pow_sub_C_ne_zero' (NeZero.pos n) h) right_inv := by intro e have := Fact.mk H letI : Algebra K K[n√a] := inferInstance apply AlgEquiv.coe_algHom_injective apply AdjoinRoot.algHom_ext simp only [AdjoinRootXPowSubCEquivToRootsOfUnity, AdjoinRoot.algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, AlgHom.coe_coe, autAdjoinRootXPowSubC_root, Algebra.smul_def] rw [rootsOfUnityEquivOfPrimitiveRoots_symm_apply, rootsOfUnity.val_mkOfPowEq_coe] split_ifs with h · obtain rfl := not_imp_not.mp (fun hn ↦ ne_zero_of_irreducible_X_pow_sub_C' hn H) h rw [(pow_one _).symm.trans (root_X_pow_sub_C_pow 1 a), one_mul, ← AdjoinRoot.algebraMap_eq, AlgEquiv.commutes] · refine div_mul_cancel₀ _ (root_X_pow_sub_C_ne_zero' (NeZero.pos n) h) lemma autAdjoinRootXPowSubCEquiv_root [NeZero n] (η) : autAdjoinRootXPowSubCEquiv hζ H η (root _) = ((η : Kˣ) : K) • root _ := autAdjoinRootXPowSubC_root a η lemma autAdjoinRootXPowSubCEquiv_symm_smul [NeZero n] (σ) : ((autAdjoinRootXPowSubCEquiv hζ H).symm σ : Kˣ) • (root _ : K[n√a]) = σ (root _) := by have := Fact.mk H simp only [autAdjoinRootXPowSubCEquiv, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, MulEquiv.symm_mk, MulEquiv.coe_mk, Equiv.coe_fn_symm_mk, AdjoinRootXPowSubCEquivToRootsOfUnity, AdjoinRoot.algebraMap_eq, rootsOfUnity.mkOfPowEq, Units.smul_def, Algebra.smul_def, rootsOfUnityEquivOfPrimitiveRoots_symm_apply, Units.val_ofPowEqOne, ite_mul, one_mul] simp_rw [← root_X_pow_sub_C_eq_zero_iff H] split_ifs with h · rw [h, map_zero] · rw [div_mul_cancel₀ _ h] end AdjoinRoot /-! ### Galois Group of `IsSplittingField K L (X ^ n - C a)` -/ section IsSplittingField variable {a} variable {L : Type*} [Field L] [Algebra K L] [IsSplittingField K L (X ^ n - C a)] include hζ in lemma isSplittingField_AdjoinRoot_X_pow_sub_C : haveI := Fact.mk H letI : Algebra K K[n√a] := inferInstance IsSplittingField K K[n√a] (X ^ n - C a) := by have := Fact.mk H letI : Algebra K K[n√a] := inferInstance constructor · rw [← splits_id_iff_splits, Polynomial.map_sub, Polynomial.map_pow, Polynomial.map_C, Polynomial.map_X] have ⟨_, hζ⟩ := hζ rw [mem_primitiveRoots (Nat.pos_of_ne_zero <| ne_zero_of_irreducible_X_pow_sub_C H)] at hζ exact X_pow_sub_C_splits_of_isPrimitiveRoot (hζ.map_of_injective (algebraMap K _).injective) (root_X_pow_sub_C_pow n a) · rw [eq_top_iff, ← AdjoinRoot.adjoinRoot_eq_top] apply Algebra.adjoin_mono have := ne_zero_of_irreducible_X_pow_sub_C H rw [Set.singleton_subset_iff, mem_rootSet_of_ne (X_pow_sub_C_ne_zero (Nat.pos_of_ne_zero this) a), aeval_def, AdjoinRoot.algebraMap_eq, AdjoinRoot.eval₂_root] variable {α : L} (hα : α ^ n = algebraMap K L a) /-- Suppose `L/K` is the splitting field of `Xⁿ - a`, then a choice of `ⁿ√a` gives an equivalence of `L` with `K[n√a]`. -/ noncomputable def adjoinRootXPowSubCEquiv (hζ : (primitiveRoots n K).Nonempty) (H : Irreducible (X ^ n - C a)) (hα : α ^ n = algebraMap K L a) : K[n√a] ≃ₐ[K] L := .ofBijective (AdjoinRoot.liftAlgHom (X ^ n - C a) (Algebra.ofId _ _) α (by simp [hα])) <| by haveI := Fact.mk H letI := isSplittingField_AdjoinRoot_X_pow_sub_C hζ H refine ⟨(liftAlgHom (X ^ n - C a) _ α _).injective, ?_⟩ rw [← AlgHom.range_eq_top, ← IsSplittingField.adjoin_rootSet _ (X ^ n - C a), eq_comm, adjoin_rootSet_eq_range, IsSplittingField.adjoin_rootSet] exact IsSplittingField.splits _ _ lemma adjoinRootXPowSubCEquiv_root : adjoinRootXPowSubCEquiv hζ H hα (root _) = α := by rw [adjoinRootXPowSubCEquiv, AlgEquiv.coe_ofBijective, liftAlgHom_root] lemma adjoinRootXPowSubCEquiv_symm_eq_root : (adjoinRootXPowSubCEquiv hζ H hα).symm α = root _ := by apply (adjoinRootXPowSubCEquiv hζ H hα).injective rw [(adjoinRootXPowSubCEquiv hζ H hα).apply_symm_apply, adjoinRootXPowSubCEquiv_root] include hζ H hα in lemma Algebra.adjoin_root_eq_top_of_isSplittingField : Algebra.adjoin K {α} = ⊤ := by apply Subalgebra.map_injective (B := K[n√a]) (f := (adjoinRootXPowSubCEquiv hζ H hα).symm) (adjoinRootXPowSubCEquiv hζ H hα).symm.injective rw [Algebra.map_top, (AlgHom.range_eq_top _).mpr (adjoinRootXPowSubCEquiv hζ H hα).symm.surjective, AlgHom.map_adjoin, Set.image_singleton, AlgHom.coe_coe, adjoinRootXPowSubCEquiv_symm_eq_root, adjoinRoot_eq_top] include hζ H hα in lemma IntermediateField.adjoin_root_eq_top_of_isSplittingField : K⟮α⟯ = ⊤ := by refine (IntermediateField.eq_adjoin_of_eq_algebra_adjoin _ _ _ ?_).symm exact (Algebra.adjoin_root_eq_top_of_isSplittingField hζ H hα).symm variable (a) (L) /-- An arbitrary choice of `ⁿ√a` in the splitting field of `Xⁿ - a`. -/ noncomputable abbrev rootOfSplitsXPowSubC (hn : 0 < n) (a : K) (L) [Field L] [Algebra K L] [IsSplittingField K L (X ^ n - C a)] : L := (rootOfSplits _ (IsSplittingField.splits L (X ^ n - C a)) (by simpa [degree_X_pow_sub_C hn] using Nat.pos_iff_ne_zero.mp hn)) lemma rootOfSplitsXPowSubC_pow [NeZero n] : (rootOfSplitsXPowSubC (NeZero.pos n) a L) ^ n = algebraMap K L a := by have := map_rootOfSplits _ (IsSplittingField.splits L (X ^ n - C a)) simp only [eval₂_sub, eval₂_X_pow, eval₂_C, sub_eq_zero] at this exact this _ variable {a} /-- Suppose `L/K` is the splitting field of `Xⁿ - a`, then `Gal(L/K)` is isomorphic to the roots of unity in `K` if `K` contains all of them. Note that this does not depend on a choice of `ⁿ√a`. -/ noncomputable def autEquivRootsOfUnity [NeZero n] : Gal(L/K) ≃* (rootsOfUnity n K) := (AlgEquiv.autCongr (adjoinRootXPowSubCEquiv hζ H (rootOfSplitsXPowSubC_pow a L)).symm).trans (autAdjoinRootXPowSubCEquiv hζ H).symm lemma autEquivRootsOfUnity_apply_rootOfSplit [NeZero n] (σ : Gal(L/K)) : σ (rootOfSplitsXPowSubC (NeZero.pos n) a L) = autEquivRootsOfUnity hζ H L σ • (rootOfSplitsXPowSubC (NeZero.pos n) a L) := by obtain ⟨η, rfl⟩ := (autEquivRootsOfUnity hζ H L).symm.surjective σ rw [MulEquiv.apply_symm_apply, autEquivRootsOfUnity] simp only [MulEquiv.symm_trans_apply, AlgEquiv.autCongr_symm, AlgEquiv.symm_symm, MulEquiv.symm_symm, AlgEquiv.autCongr_apply, AlgEquiv.trans_apply, adjoinRootXPowSubCEquiv_symm_eq_root, autAdjoinRootXPowSubCEquiv_root, map_smul, adjoinRootXPowSubCEquiv_root] rfl include hα in lemma autEquivRootsOfUnity_smul [NeZero n] (σ : Gal(L/K)) : autEquivRootsOfUnity hζ H L σ • α = σ α := by have ⟨ζ, hζ'⟩ := hζ have hn := NeZero.pos n rw [mem_primitiveRoots hn] at hζ' rw [← mem_nthRoots hn, (hζ'.map_of_injective (algebraMap K L).injective).nthRoots_eq (rootOfSplitsXPowSubC_pow a L)] at hα simp only [Multiset.mem_map, Multiset.mem_range] at hα obtain ⟨i, _, rfl⟩ := hα simp only [← map_pow, ← Algebra.smul_def, map_smul, autEquivRootsOfUnity_apply_rootOfSplit hζ H L] exact smul_comm _ _ _ /-- Suppose `L/K` is the splitting field of `Xⁿ - a`, and `ζ` is a `n`-th primitive root of unity in `K`, then `Gal(L/K)` is isomorphic to `ZMod n`. -/ noncomputable def autEquivZmod [NeZero n] {ζ : K} (hζ : IsPrimitiveRoot ζ n) : Gal(L/K) ≃* Multiplicative (ZMod n) := haveI hn := ne_zero_of_irreducible_X_pow_sub_C H (autEquivRootsOfUnity ⟨ζ, (mem_primitiveRoots <| Nat.pos_of_ne_zero hn).mpr hζ⟩ H L).trans ((MulEquiv.subgroupCongr (IsPrimitiveRoot.zpowers_eq (hζ.isUnit_unit' hn)).symm).trans (hζ.isUnit_unit' hn).zmodEquivZPowers.symm.toMultiplicativeRight) include hα in lemma autEquivZmod_symm_apply_intCast [NeZero n] {ζ : K} (hζ : IsPrimitiveRoot ζ n) (m : ℤ) : (autEquivZmod H L hζ).symm (Multiplicative.ofAdd (m : ZMod n)) α = ζ ^ m • α := by have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H) rw [← autEquivRootsOfUnity_smul ⟨ζ, (mem_primitiveRoots hn).mpr hζ⟩ H L hα] simp [MulEquiv.subgroupCongr_symm_apply, Subgroup.smul_def, Units.smul_def, autEquivZmod] include hα in lemma autEquivZmod_symm_apply_natCast [NeZero n] {ζ : K} (hζ : IsPrimitiveRoot ζ n) (m : ℕ) : (autEquivZmod H L hζ).symm (Multiplicative.ofAdd (m : ZMod n)) α = ζ ^ m • α := by simpa only [Int.cast_natCast, zpow_natCast] using autEquivZmod_symm_apply_intCast H L hα hζ m include hζ H in lemma isCyclic_of_isSplittingField_X_pow_sub_C [NeZero n] : IsCyclic Gal(L/K) := have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H) isCyclic_of_surjective _ (autEquivZmod H _ <| (mem_primitiveRoots hn).mp hζ.choose_spec).symm.surjective include hζ H in lemma isGalois_of_isSplittingField_X_pow_sub_C : IsGalois K L := IsGalois.of_separable_splitting_field (separable_X_pow_sub_C_of_irreducible hζ a H) include hζ H in lemma finrank_of_isSplittingField_X_pow_sub_C : Module.finrank K L = n := by have := Polynomial.IsSplittingField.finiteDimensional L (X ^ n - C a) have := isGalois_of_isSplittingField_X_pow_sub_C hζ H L have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H) have : NeZero n := ⟨ne_zero_of_irreducible_X_pow_sub_C H⟩ rw [← IsGalois.card_aut_eq_finrank, Nat.card_congr ((autEquivZmod H L <| (mem_primitiveRoots hn).mp hζ.choose_spec).toEquiv.trans Multiplicative.toAdd), Nat.card_zmod] end IsSplittingField /-! ### Cyclic extensions of order `n` when `K` has all `n`-th roots of unity. -/ section IsCyclic variable {L} [Field L] [Algebra K L] [FiniteDimensional K L] variable (hK : (primitiveRoots (Module.finrank K L) K).Nonempty) open Module variable (K L) include hK in /-- If `L/K` is a cyclic extension of degree `n`, and `K` contains all `n`-th roots of unity, then `L = K[α]` for some `α ^ n ∈ K`. -/ lemma exists_root_adjoin_eq_top_of_isCyclic [IsGalois K L] [IsCyclic Gal(L/K)] : ∃ (α : L), α ^ (finrank K L) ∈ Set.range (algebraMap K L) ∧ K⟮α⟯ = ⊤ := by -- Let `ζ` be an `n`-th root of unity, and `σ` be a generator of `Gal(L/K)`. have ⟨ζ, hζ⟩ := hK rw [mem_primitiveRoots finrank_pos] at hζ obtain ⟨σ, hσ⟩ := ‹IsCyclic Gal(L/K)› have hσ' := orderOf_eq_card_of_forall_mem_zpowers hσ -- Since the minimal polynomial of `σ` over `K` is `Xⁿ - 1`, -- `σ` has an eigenvector `v` with eigenvalue `ζ`. have : IsRoot (minpoly K σ.toLinearMap) ζ := by rw [IsGalois.card_aut_eq_finrank] at hσ' simpa [minpoly_algEquiv_toLinearMap σ (isOfFinOrder_of_finite σ), hσ', sub_eq_zero] using hζ.pow_eq_one obtain ⟨v, hv⟩ := (Module.End.hasEigenvalue_of_isRoot this).exists_hasEigenvector have hv' := hv.pow_apply simp_rw [← AlgEquiv.pow_toLinearMap, AlgEquiv.toLinearMap_apply] at hv' -- We claim that `v` is the desired root. refine ⟨v, ?_, ?_⟩ · -- Since `v ^ n` is fixed by `σ` (`σ (v ^ n) = ζ ^ n • v ^ n = v ^ n`), it is in `K`. rw [← IntermediateField.mem_bot, ← OrderIso.map_bot IsGalois.intermediateFieldEquivSubgroup.symm] intro ⟨σ', hσ'⟩ obtain ⟨n, rfl : σ ^ n = σ'⟩ := mem_powers_iff_mem_zpowers.mpr (hσ σ') rw [smul_pow', Submonoid.smul_def, AlgEquiv.smul_def, hv', smul_pow, ← pow_mul, mul_comm, pow_mul, hζ.pow_eq_one, one_pow, one_smul] · -- Since `σ` does not fix `K⟮α⟯`, `K⟮α⟯` is `L`. apply IsGalois.intermediateFieldEquivSubgroup.injective rw [map_top, eq_top_iff] intro σ' hσ' obtain ⟨n, rfl : σ ^ n = σ'⟩ := mem_powers_iff_mem_zpowers.mpr (hσ σ') have := hσ' ⟨v, IntermediateField.mem_adjoin_simple_self K v⟩ simp only [AlgEquiv.smul_def, hv'] at this conv_rhs at this => rw [← one_smul K v] obtain ⟨k, rfl⟩ := hζ.dvd_of_pow_eq_one n (smul_left_injective K hv.2 this) rw [pow_mul, ← IsGalois.card_aut_eq_finrank, pow_card_eq_one', one_pow] exact one_mem _ variable {K L} lemma irreducible_X_pow_sub_C_of_root_adjoin_eq_top {a : K} {α : L} (ha : α ^ (finrank K L) = algebraMap K L a) (hα : K⟮α⟯ = ⊤) : Irreducible (X ^ (finrank K L) - C a) := by have : X ^ (finrank K L) - C a = minpoly K α := by refine minpoly.unique _ _ (monic_X_pow_sub_C _ finrank_pos.ne.symm) ?_ ?_ · simp only [aeval_def, eval₂_sub, eval₂_X_pow, ha, eval₂_C, sub_self] · intro q hq hq' refine le_trans ?_ (degree_le_of_dvd (minpoly.dvd _ _ hq') hq.ne_zero) rw [degree_X_pow_sub_C finrank_pos, degree_eq_natDegree (minpoly.ne_zero (IsIntegral.of_finite K α)), ← IntermediateField.adjoin.finrank (IsIntegral.of_finite K α), hα, Nat.cast_le] exact (finrank_top K L).ge exact this ▸ minpoly.irreducible (IsIntegral.of_finite K α) include hK in lemma isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top {a : K} {α : L} (ha : α ^ (finrank K L) = algebraMap K L a) (hα : K⟮α⟯ = ⊤) : IsSplittingField K L (X ^ (finrank K L) - C a) := by constructor · rw [← splits_id_iff_splits, Polynomial.map_sub, Polynomial.map_pow, Polynomial.map_C, Polynomial.map_X] have ⟨_, hζ⟩ := hK rw [mem_primitiveRoots finrank_pos] at hζ exact X_pow_sub_C_splits_of_isPrimitiveRoot (hζ.map_of_injective (algebraMap K _).injective) ha · rw [eq_top_iff, ← IntermediateField.top_toSubalgebra, ← hα, IntermediateField.adjoin_simple_toSubalgebra_of_integral (IsIntegral.of_finite K α)] apply Algebra.adjoin_mono rw [Set.singleton_subset_iff, mem_rootSet_of_ne (X_pow_sub_C_ne_zero finrank_pos a), aeval_def, eval₂_sub, eval₂_X_pow, eval₂_C, ha, sub_self] end IsCyclic open Module in /-- Suppose `L/K` is a finite extension of dimension `n`, and `K` contains all `n`-th roots of unity. Then `L/K` is cyclic iff `L` is a splitting field of some irreducible polynomial of the form `Xⁿ - a : K[X]` iff `L = K[α]` for some `αⁿ ∈ K`. -/ lemma isCyclic_tfae (K L) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L] (hK : (primitiveRoots (Module.finrank K L) K).Nonempty) : List.TFAE [ IsGalois K L ∧ IsCyclic Gal(L/K), ∃ a : K, Irreducible (X ^ (finrank K L) - C a) ∧ IsSplittingField K L (X ^ (finrank K L) - C a), ∃ (α : L), α ^ (finrank K L) ∈ Set.range (algebraMap K L) ∧ K⟮α⟯ = ⊤] := by have : NeZero (Module.finrank K L) := NeZero.of_pos finrank_pos tfae_have 1 → 3 | ⟨inst₁, inst₂⟩ => exists_root_adjoin_eq_top_of_isCyclic K L hK tfae_have 3 → 2 | ⟨α, ⟨a, ha⟩, hα⟩ => ⟨a, irreducible_X_pow_sub_C_of_root_adjoin_eq_top ha.symm hα, isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top hK ha.symm hα⟩ tfae_have 2 → 1 | ⟨a, H, inst⟩ => ⟨isGalois_of_isSplittingField_X_pow_sub_C hK H L, isCyclic_of_isSplittingField_X_pow_sub_C hK H L⟩ tfae_finish
.lake/packages/mathlib/Mathlib/FieldTheory/NormalizedTrace.lean
import Mathlib.RingTheory.Trace.Basic /-! # Normalized trace This file defines the *normalized trace* map; that is, an `F`-linear map from the algebraic closure of `F` to `F` defined as the trace of an element from its adjoin extension divided by its degree. To avoid heavy imports, we define it here as a map from an arbitrary algebraic (equivalently integral) extension of `F`. ## Main definitions - `normalizedTrace`: the trace of an element from the simple adjoin divided by the degree; it is a non-trivial `F`-linear map from an arbitrary algebraic extension `K` to `F`. ## Main results - `normalizedTrace_intermediateField`: for a tower `K / E / F` of algebraic extensions, `normalizedTrace F E` agrees with `normalizedTrace F K` on `E`. - `normalizedTrace_trans`: for a tower `K / E / F` of algebraic extensions, the normalized trace from `K` to `E` composed with the normalized trace from `E` to `F` equals the normalized trace from `K` to `F`. - `normalizedTrace_self`: `normalizedTrace F F` is the identity map. -/ namespace Algebra variable (F K : Type*) [Field F] [Field K] [Algebra F K] open IntermediateField /- The normalized trace function from an extension `K` to the base field `F`. Note: this definition does not require the extension `K / F` to be integral (algebraic) nor the fields to be of characteristic zero. -/ private noncomputable def normalizedTraceAux (a : K) : F := (Module.finrank F F⟮a⟯ : F)⁻¹ • trace F F⟮a⟯ (AdjoinSimple.gen F a) private theorem normalizedTraceAux_def (a : K) : normalizedTraceAux F K a = (Module.finrank F F⟮a⟯ : F)⁻¹ • trace F F⟮a⟯ (AdjoinSimple.gen F a) := rfl private theorem normalizedTraceAux_map {E : Type*} [Field E] [Algebra F E] (f : E →ₐ[F] K) (a : E) : normalizedTraceAux F K (f a) = normalizedTraceAux F E a := by let e := (F⟮a⟯.equivMap f).trans (equivOfEq <| Set.image_singleton ▸ adjoin_map F {a} f) simp_rw [normalizedTraceAux, ← LinearEquiv.finrank_eq e.toLinearEquiv] congr exact trace_eq_of_algEquiv e <| AdjoinSimple.gen F a private theorem normalizedTraceAux_intermediateField {E : IntermediateField F K} (a : E) : normalizedTraceAux F K a = normalizedTraceAux F E a := normalizedTraceAux_map F K E.val a variable [CharZero F] variable {K} in private theorem normalizedTraceAux_eq_of_finiteDimensional [FiniteDimensional F K] (a : K) : normalizedTraceAux F K a = (Module.finrank F K : F)⁻¹ • trace F K a := by have h := (Nat.cast_ne_zero (R := F)).mpr <| Nat.pos_iff_ne_zero.mp <| Module.finrank_pos (R := F⟮a⟯) (M := K) rw [smul_eq_mul, mul_comm, ← div_eq_mul_inv, trace_eq_trace_adjoin F a, ← Module.finrank_mul_finrank F F⟮a⟯ K, nsmul_eq_mul, Nat.cast_mul, mul_comm, mul_div_mul_right _ _ h, div_eq_mul_inv, mul_comm, ← smul_eq_mul, normalizedTraceAux_def] variable [Algebra.IsIntegral F K] /-- The normalized trace map from an algebraic extension `K` to the base field `F`. -/ noncomputable def normalizedTrace : K →ₗ[F] F where toFun := normalizedTraceAux F K map_add' a b := by let E := F⟮a⟯ ⊔ F⟮b⟯ have : FiniteDimensional F F⟮a⟯ := adjoin.finiteDimensional (IsIntegral.isIntegral a) have : FiniteDimensional F F⟮b⟯ := adjoin.finiteDimensional (IsIntegral.isIntegral b) have ha : a ∈ E := (le_sup_left : F⟮a⟯ ≤ E) <| mem_adjoin_simple_self F a have hb : b ∈ E := (le_sup_right : F⟮b⟯ ≤ E) <| mem_adjoin_simple_self F b have hab : a + b ∈ E := IntermediateField.add_mem E ha hb let a' : E := ⟨a, ha⟩ let b' : E := ⟨b, hb⟩ let ab' : E := ⟨a + b, hab⟩ rw [normalizedTraceAux_intermediateField F K a', normalizedTraceAux_intermediateField F K b', normalizedTraceAux_intermediateField F K ab', normalizedTraceAux_eq_of_finiteDimensional F a', normalizedTraceAux_eq_of_finiteDimensional F b', normalizedTraceAux_eq_of_finiteDimensional F ab', ← smul_add, ← map_add, AddMemClass.mk_add_mk] map_smul' m a := by dsimp only [AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply] let E := F⟮a⟯ have : FiniteDimensional F F⟮a⟯ := adjoin.finiteDimensional (IsIntegral.isIntegral a) have ha : a ∈ E := mem_adjoin_simple_self F a have hma : m • a ∈ E := smul_mem E ha let a' : E := ⟨a, ha⟩ let ma' : E := ⟨m • a, hma⟩ rw [normalizedTraceAux_intermediateField F K a', normalizedTraceAux_intermediateField F K ma', normalizedTraceAux_eq_of_finiteDimensional F a', normalizedTraceAux_eq_of_finiteDimensional F ma', smul_comm, ← map_smul _ m, SetLike.mk_smul_mk] theorem normalizedTrace_def (a : K) : normalizedTrace F K a = (Module.finrank F F⟮a⟯ : F)⁻¹ • trace F F⟮a⟯ (AdjoinSimple.gen F a) := rfl variable {K} in /-- Normalized trace defined purely in terms of the degree and the next coefficient of the minimal polynomial. Could be an alternative definition but it is harder to work with linearity. -/ theorem normalizedTrace_minpoly (a : K) : normalizedTrace F K a = ((minpoly F a).natDegree : F)⁻¹ • -(minpoly F a).nextCoeff := have ha : IsIntegral F a := IsIntegral.isIntegral a IntermediateField.adjoin.finrank ha ▸ trace_adjoinSimpleGen ha ▸ normalizedTrace_def F K a variable {F} in theorem normalizedTrace_self_apply (a : F) : normalizedTrace F F a = a := by dsimp [normalizedTrace] rw [normalizedTraceAux_eq_of_finiteDimensional F a, Module.finrank_self F, Nat.cast_one, inv_one, one_smul, trace_self_apply] @[simp] theorem normalizedTrace_self : normalizedTrace F F = LinearMap.id := LinearMap.ext normalizedTrace_self_apply variable {K} in theorem normalizedTrace_eq_of_finiteDimensional_apply [FiniteDimensional F K] (a : K) : normalizedTrace F K a = (Module.finrank F K : F)⁻¹ • trace F K a := normalizedTraceAux_eq_of_finiteDimensional F a @[deprecated (since := "2025-10-22")] alias normalizedTrace_eq_of_fininteDimensional_apply := normalizedTrace_eq_of_finiteDimensional_apply theorem normalizedTrace_eq_of_finiteDimensional [FiniteDimensional F K] : normalizedTrace F K = (Module.finrank F K : F)⁻¹ • trace F K := LinearMap.ext <| normalizedTrace_eq_of_finiteDimensional_apply F @[deprecated (since := "2025-10-22")] alias normalizedTrace_eq_of_fininteDimensional := normalizedTrace_eq_of_finiteDimensional /-- The normalized trace transfers via (injective) maps. -/ @[simp] theorem normalizedTrace_map {E : Type*} [Field E] [Algebra F E] [Algebra.IsIntegral F E] (f : E →ₐ[F] K) (a : E) : normalizedTrace F K (f a) = normalizedTrace F E a := normalizedTraceAux_map F K f a /-- The normalized trace transfers via restriction to a subextension. -/ theorem normalizedTrace_intermediateField {E : IntermediateField F K} (a : E) : normalizedTrace F K a = normalizedTrace F E a := normalizedTraceAux_intermediateField F K a section IsScalarTower variable (F E K : Type*) [Field F] [Field E] [Field K] variable [Algebra F E] [Algebra E K] [Algebra F K] [IsScalarTower F E K] variable [Algebra.IsIntegral F E] [Algebra.IsIntegral F K] variable [CharZero F] @[simp] theorem normalizedTrace_algebraMap_apply (a : E) : normalizedTrace F K (algebraMap E K a) = normalizedTrace F E a := normalizedTrace_map F K (IsScalarTower.toAlgHom F E K) a @[simp] theorem normalizedTrace_algebraMap : normalizedTrace F K ∘ₗ Algebra.linearMap E K = normalizedTrace F E := LinearMap.ext <| normalizedTrace_algebraMap_apply F E K omit [Algebra.IsIntegral F E] in /-- If all the coefficients of `minpoly E a` are in `F`, then the normalized trace of `a` from `K` to `E` equals the normalized trace of `a` from `K` to `F`. -/ theorem normalizedTrace_algebraMap_of_lifts [CharZero E] [Algebra.IsIntegral E K] (a : K) (h : minpoly E a ∈ Polynomial.lifts (algebraMap F E)) : algebraMap F E (normalizedTrace F K a) = normalizedTrace E K a := by have ha : IsIntegral F a := IsIntegral.isIntegral a simp [normalizedTrace_minpoly F a, normalizedTrace_minpoly E a, ← minpoly.map_algebraMap ha h, (minpoly F a).nextCoeff_map_eq, map_mul, map_neg] /- An auxiliary result to prove `normalizedTrace_trans_apply`. It differs from `normalizedTrace_trans_apply` only by the extra assumption about finiteness of `E` over `F`. -/ private theorem normalizedTrace_trans_apply_aux [FiniteDimensional F E] [Algebra.IsIntegral E K] [CharZero E] (a : K) : normalizedTrace F E (normalizedTrace E K a) = normalizedTrace F K a := by have : FiniteDimensional E E⟮a⟯ := IntermediateField.adjoin.finiteDimensional (IsIntegral.isIntegral a) rw [normalizedTrace_def E K, inv_natCast_smul_eq (R := E) (S := F), map_smul, normalizedTrace_eq_of_finiteDimensional F E, LinearMap.smul_apply, ← smul_assoc, smul_eq_mul (a := _⁻¹), ← mul_inv, trace_trace, mul_comm, ← Nat.cast_mul, Module.finrank_mul_finrank, eq_comm] let E' := E⟮a⟯.restrictScalars F have : FiniteDimensional F E' := Module.Finite.trans E E⟮a⟯ have h_finrank_eq : Module.finrank F E⟮a⟯ = Module.finrank F E' := rfl have h_trace_eq : trace F E⟮a⟯ (AdjoinSimple.gen E a) = trace F E' (AdjoinSimple.gen E a : E') := rfl let a' : E' := AdjoinSimple.gen E a rw [h_finrank_eq, h_trace_eq, ← normalizedTrace_eq_of_finiteDimensional_apply F, ← normalizedTrace_intermediateField F K a'] congr /-- For a tower `K / E / F` of algebraic extensions, the normalized trace from `K` to `E` composed with the normalized trace from `E` to `F` equals the normalized trace from `K` to `F`. -/ theorem normalizedTrace_trans_apply [Algebra.IsIntegral E K] [CharZero E] (a : K) : normalizedTrace F E (normalizedTrace E K a) = normalizedTrace F K a := let S : Set E := (minpoly E a).coeffs let E₀ := IntermediateField.adjoin F S have : FiniteDimensional F E₀ := IntermediateField.finiteDimensional_adjoin fun x _ ↦ Algebra.IsIntegral.isIntegral x have : Algebra.IsIntegral E₀ E := IsIntegral.tower_top F have : Algebra.IsIntegral E₀ K := IsIntegral.trans E have hsub : S ⊆ (algebraMap E₀ E).range := Subalgebra.range_algebraMap E₀.toSubalgebra ▸ IntermediateField.subset_adjoin F S have hlifts := (Polynomial.lifts_iff_coeffs_subset_range _).mpr hsub (normalizedTrace_trans_apply_aux F E₀ K _ ▸ normalizedTrace_algebraMap_apply F E₀ E _ ▸ congrArg (normalizedTrace F E) (normalizedTrace_algebraMap_of_lifts E₀ E K a hlifts)).symm @[simp] theorem normalizedTrace_trans [Algebra.IsIntegral E K] [CharZero E] : normalizedTrace F E ∘ₗ normalizedTrace E K = normalizedTrace F K := LinearMap.ext <| normalizedTrace_trans_apply F E K end IsScalarTower theorem normalizedTrace_algebraMap_apply_eq_self (a : F) : normalizedTrace F K (algebraMap F K a) = a := by simp /-- The normalized trace map is a left inverse of the algebra map. -/ theorem normalizedTrace_algebraMap_eq_id : normalizedTrace F K ∘ₗ Algebra.linearMap F K = LinearMap.id := LinearMap.ext <| normalizedTrace_algebraMap_apply_eq_self F K /-- The normalized trace commutes with (injective) maps. -/ @[simp] theorem normalizedTrace_comp_algHom {E : Type*} [Field E] [Algebra F E] [Algebra.IsIntegral F E] (f : E →ₐ[F] K) : normalizedTrace F K ∘ₗ f = normalizedTrace F E := LinearMap.ext <| normalizedTrace_map F K f theorem normalizedTrace_surjective : Function.Surjective (normalizedTrace F K) := fun a ↦ ⟨algebraMap F K a, normalizedTrace_algebraMap_apply_eq_self F K a⟩ /-- The normalized trace map is non-trivial. -/ theorem normalizedTrace_ne_zero : normalizedTrace F K ≠ 0 := let ⟨a, ha⟩ := normalizedTrace_surjective F K 1 DFunLike.ne_iff.mpr <| ⟨a, ha ▸ one_ne_zero⟩ end Algebra
.lake/packages/mathlib/Mathlib/FieldTheory/SeparableClosure.lean
import Mathlib.FieldTheory.SeparableDegree import Mathlib.FieldTheory.IsSepClosed /-! # Separable closure This file contains basics about the (relative) separable closure of a field extension. ## Main definitions - `separableClosure`: the relative separable closure of `F` in `E`, or called maximal separable subextension of `E / F`, is defined to be the intermediate field of `E / F` consisting of all separable elements. - `SeparableClosure`: the absolute separable closure, defined to be the relative separable closure inside the algebraic closure. - `Field.sepDegree F E`: the (infinite) separable degree $[E:F]_s$ of an algebraic extension `E / F` of fields, defined to be the degree of `separableClosure F E / F`. Later we will show that (`Field.finSepDegree_eq`, not in this file), if `Field.Emb F E` is finite, then this coincides with `Field.finSepDegree F E`. - `Field.insepDegree F E`: the (infinite) inseparable degree $[E:F]_i$ of an algebraic extension `E / F` of fields, defined to be the degree of `E / separableClosure F E`. - `Field.finInsepDegree F E`: the finite inseparable degree $[E:F]_i$ of an algebraic extension `E / F` of fields, defined to be the degree of `E / separableClosure F E` as a natural number. It is zero if such field extension is not finite. ## Main results - `le_separableClosure_iff`: an intermediate field of `E / F` is contained in the separable closure of `F` in `E` if and only if it is separable over `F`. - `separableClosure.normalClosure_eq_self`: the normal closure of the separable closure of `F` in `E` is equal to itself. - `separableClosure.isGalois`: the separable closure in a normal extension is Galois (namely, normal and separable). - `separableClosure.isSepClosure`: the separable closure in a separably closed extension is a separable closure of the base field. - `IntermediateField.isSeparable_adjoin_iff_isSeparable`: `F(S) / F` is a separable extension if and only if all elements of `S` are separable elements. - `separableClosure.eq_top_iff`: the separable closure of `F` in `E` is equal to `E` if and only if `E / F` is separable. ## Tags separable degree, degree, separable closure -/ open Module Polynomial IntermediateField Field noncomputable section universe u v w variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] section separableClosure /-- The (relative) separable closure of `F` in `E`, or called maximal separable subextension of `E / F`, is defined to be the intermediate field of `E / F` consisting of all separable elements. The previous results prove that these elements are closed under field operations. -/ @[stacks 09HC] def separableClosure : IntermediateField F E where carrier := {x | IsSeparable F x} mul_mem' := isSeparable_mul add_mem' := isSeparable_add algebraMap_mem' := isSeparable_algebraMap E inv_mem' _ := isSeparable_inv variable {F E K} /-- An element is contained in the separable closure of `F` in `E` if and only if it is a separable element. -/ theorem mem_separableClosure_iff {x : E} : x ∈ separableClosure F E ↔ IsSeparable F x := Iff.rfl /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then `i x` is contained in `separableClosure F K` if and only if `x` is contained in `separableClosure F E`. -/ theorem map_mem_separableClosure_iff (i : E →ₐ[F] K) {x : E} : i x ∈ separableClosure F K ↔ x ∈ separableClosure F E := by simp_rw [mem_separableClosure_iff, IsSeparable, minpoly.algHom_eq i i.injective] /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the preimage of `separableClosure F K` under the map `i` is equal to `separableClosure F E`. -/ theorem separableClosure.comap_eq_of_algHom (i : E →ₐ[F] K) : (separableClosure F K).comap i = separableClosure F E := by ext x exact map_mem_separableClosure_iff i /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the image of `separableClosure F E` under the map `i` is contained in `separableClosure F K`. -/ theorem separableClosure.map_le_of_algHom (i : E →ₐ[F] K) : (separableClosure F E).map i ≤ separableClosure F K := map_le_iff_le_comap.2 (comap_eq_of_algHom i).ge variable (F) in /-- If `K / E / F` is a field extension tower, such that `K / E` has no non-trivial separable subextensions (when `K / E` is algebraic, this means that it is purely inseparable), then the image of `separableClosure F E` in `K` is equal to `separableClosure F K`. -/ theorem separableClosure.map_eq_of_separableClosure_eq_bot [Algebra E K] [IsScalarTower F E K] (h : separableClosure E K = ⊥) : (separableClosure F E).map (IsScalarTower.toAlgHom F E K) = separableClosure F K := by refine le_antisymm (map_le_of_algHom _) (fun x hx ↦ ?_) obtain ⟨y, rfl⟩ := mem_bot.1 <| h ▸ mem_separableClosure_iff.2 (IsSeparable.tower_top E <| mem_separableClosure_iff.1 hx) exact ⟨y, (map_mem_separableClosure_iff <| IsScalarTower.toAlgHom F E K).mp hx, rfl⟩ /-- If `i` is an `F`-algebra isomorphism of `E` and `K`, then the image of `separableClosure F E` under the map `i` is equal to `separableClosure F K`. -/ theorem separableClosure.map_eq_of_algEquiv (i : E ≃ₐ[F] K) : (separableClosure F E).map i = separableClosure F K := (map_le_of_algHom i.toAlgHom).antisymm (fun x h ↦ ⟨_, (map_mem_separableClosure_iff i.symm).2 h, by simp⟩) /-- If `E` and `K` are isomorphic as `F`-algebras, then `separableClosure F E` and `separableClosure F K` are also isomorphic as `F`-algebras. -/ def separableClosure.algEquivOfAlgEquiv (i : E ≃ₐ[F] K) : separableClosure F E ≃ₐ[F] separableClosure F K := (intermediateFieldMap i _).trans (equivOfEq (map_eq_of_algEquiv i)) alias AlgEquiv.separableClosure := separableClosure.algEquivOfAlgEquiv variable (F E K) /-- The separable closure of `F` in `E` is algebraic over `F`. -/ instance separableClosure.isAlgebraic : Algebra.IsAlgebraic F (separableClosure F E) := ⟨fun x ↦ isAlgebraic_iff.2 (IsSeparable.isIntegral x.2).isAlgebraic⟩ /-- The separable closure of `F` in `E` is separable over `F`. -/ @[stacks 030K "$E_{sep}/F$ is separable"] instance separableClosure.isSeparable : Algebra.IsSeparable F (separableClosure F E) := ⟨fun x ↦ by simpa only [IsSeparable, minpoly_eq] using x.2⟩ /-- An intermediate field of `E / F` is contained in the separable closure of `F` in `E` if all of its elements are separable over `F`. -/ theorem le_separableClosure' {L : IntermediateField F E} (hs : ∀ x : L, IsSeparable F x) : L ≤ separableClosure F E := fun x h ↦ by simpa only [IsSeparable, minpoly_eq] using hs ⟨x, h⟩ /-- An intermediate field of `E / F` is contained in the separable closure of `F` in `E` if it is separable over `F`. -/ theorem le_separableClosure (L : IntermediateField F E) [Algebra.IsSeparable F L] : L ≤ separableClosure F E := le_separableClosure' F E (Algebra.IsSeparable.isSeparable F) /-- An intermediate field of `E / F` is contained in the separable closure of `F` in `E` if and only if it is separable over `F`. -/ theorem le_separableClosure_iff (L : IntermediateField F E) : L ≤ separableClosure F E ↔ Algebra.IsSeparable F L := ⟨fun h ↦ ⟨fun x ↦ by simpa only [IsSeparable, minpoly_eq] using h x.2⟩, fun _ ↦ le_separableClosure _ _ _⟩ /-- The separable closure in `E` of the separable closure of `F` in `E` is equal to itself. -/ theorem separableClosure.separableClosure_eq_bot : separableClosure (separableClosure F E) E = ⊥ := bot_unique fun x hx ↦ mem_bot.2 ⟨⟨x, IsSeparable.of_algebra_isSeparable_of_isSeparable F (mem_separableClosure_iff.1 hx)⟩, rfl⟩ /-- The normal closure in `E/F` of the separable closure of `F` in `E` is equal to itself. -/ theorem separableClosure.normalClosure_eq_self : normalClosure F (separableClosure F E) E = separableClosure F E := le_antisymm (normalClosure_le_iff.2 fun i ↦ have : Algebra.IsSeparable F i.fieldRange := (AlgEquiv.Algebra.isSeparable (AlgEquiv.ofInjectiveField i)) le_separableClosure F E _) (le_normalClosure _) /-- If `E` is normal over `F`, then the separable closure of `F` in `E` is Galois (i.e. normal and separable) over `F`. -/ @[stacks 0EXK] instance separableClosure.isGalois [Normal F E] : IsGalois F (separableClosure F E) where to_isSeparable := separableClosure.isSeparable F E to_normal := by rw [← separableClosure.normalClosure_eq_self] exact normalClosure.normal F _ E /-- If `E / F` is a field extension and `E` is separably closed, then the separable closure of `F` in `E` is equal to `F` if and only if `F` is separably closed. -/ theorem IsSepClosed.separableClosure_eq_bot_iff [IsSepClosed E] : separableClosure F E = ⊥ ↔ IsSepClosed F := by refine ⟨fun h ↦ IsSepClosed.of_exists_root _ fun p _ hirr hsep ↦ ?_, fun _ ↦ IntermediateField.eq_bot_of_isSepClosed_of_isSeparable _⟩ obtain ⟨x, hx⟩ := IsSepClosed.exists_aeval_eq_zero E p (degree_pos_of_irreducible hirr).ne' hsep obtain ⟨x, rfl⟩ := h ▸ mem_separableClosure_iff.2 (hsep.of_dvd <| minpoly.dvd _ x hx) exact ⟨x, by simpa [Algebra.ofId_apply] using hx⟩ /-- If `E` is separably closed, then the separable closure of `F` in `E` is an absolute separable closure of `F`. -/ instance separableClosure.isSepClosure [IsSepClosed E] : IsSepClosure F (separableClosure F E) := ⟨(IsSepClosed.separableClosure_eq_bot_iff _ E).mp (separableClosure.separableClosure_eq_bot F E), isSeparable F E⟩ /-- The absolute separable closure is defined to be the relative separable closure inside the algebraic closure. It is indeed a separable closure (`IsSepClosure`) by `separableClosure.isSepClosure`, and it is Galois (`IsGalois`) by `separableClosure.isGalois` or `IsSepClosure.isGalois`, and every separable extension embeds into it (`IsSepClosed.lift`). -/ abbrev SeparableClosure : Type _ := separableClosure F (AlgebraicClosure F) instance SeparableClosure.isSepClosed : IsSepClosed (SeparableClosure F) := (inferInstanceAs (IsSepClosure F (SeparableClosure F))).sep_closed /-- `F(S) / F` is a separable extension if and only if all elements of `S` are separable elements. -/ theorem IntermediateField.isSeparable_adjoin_iff_isSeparable {S : Set E} : Algebra.IsSeparable F (adjoin F S) ↔ ∀ x ∈ S, IsSeparable F x := (le_separableClosure_iff F E _).symm.trans adjoin_le_iff /-- The separable closure of `F` in `E` is equal to `E` if and only if `E / F` is separable. -/ theorem separableClosure.eq_top_iff : separableClosure F E = ⊤ ↔ Algebra.IsSeparable F E := ⟨fun h ↦ ⟨fun _ ↦ mem_separableClosure_iff.1 (h ▸ mem_top)⟩, fun _ ↦ top_unique fun x _ ↦ mem_separableClosure_iff.2 (Algebra.IsSeparable.isSeparable _ x)⟩ /-- If `K / E / F` is a field extension tower, then `separableClosure F K` is contained in `separableClosure E K`. -/ theorem separableClosure.le_restrictScalars [Algebra E K] [IsScalarTower F E K] : separableClosure F K ≤ (separableClosure E K).restrictScalars F := fun _ ↦ IsSeparable.tower_top E /-- If `K / E / F` is a field extension tower, such that `E / F` is separable, then `separableClosure F K` is equal to `separableClosure E K`. -/ theorem separableClosure.eq_restrictScalars_of_isSeparable [Algebra E K] [IsScalarTower F E K] [Algebra.IsSeparable F E] : separableClosure F K = (separableClosure E K).restrictScalars F := (separableClosure.le_restrictScalars F E K).antisymm fun _ h ↦ IsSeparable.of_algebra_isSeparable_of_isSeparable F h /-- If `K / E / F` is a field extension tower, then `E` adjoin `separableClosure F K` is contained in `separableClosure E K`. -/ theorem separableClosure.adjoin_le [Algebra E K] [IsScalarTower F E K] : adjoin E (separableClosure F K) ≤ separableClosure E K := adjoin_le_iff.2 <| le_restrictScalars F E K /-- A compositum of two separable extensions is separable. -/ instance IntermediateField.isSeparable_sup (L1 L2 : IntermediateField F E) [h1 : Algebra.IsSeparable F L1] [h2 : Algebra.IsSeparable F L2] : Algebra.IsSeparable F (L1 ⊔ L2 : IntermediateField F E) := by rw [← le_separableClosure_iff] at h1 h2 ⊢ exact sup_le h1 h2 /-- A compositum of separable extensions is separable. -/ instance IntermediateField.isSeparable_iSup {ι : Type*} {t : ι → IntermediateField F E} [h : ∀ i, Algebra.IsSeparable F (t i)] : Algebra.IsSeparable F (⨆ i, t i : IntermediateField F E) := by simp_rw [← le_separableClosure_iff] at h ⊢ exact iSup_le h end separableClosure namespace Field /-- The (infinite) separable degree for a general field extension `E / F` is defined to be the degree of `separableClosure F E / F`. -/ @[stacks 030L "Part 1"] def sepDegree := Module.rank F (separableClosure F E) /-- The (infinite) inseparable degree for a general field extension `E / F` is defined to be the degree of `E / separableClosure F E`. -/ @[stacks 030L "Part 2"] def insepDegree := Module.rank (separableClosure F E) E /-- The finite inseparable degree for a general field extension `E / F` is defined to be the degree of `E / separableClosure F E` as a natural number. It is defined to be zero if such field extension is infinite. -/ def finInsepDegree : ℕ := finrank (separableClosure F E) E theorem finInsepDegree_def' : finInsepDegree F E = Cardinal.toNat (insepDegree F E) := rfl instance instNeZeroSepDegree : NeZero (sepDegree F E) := ⟨rank_pos.ne'⟩ instance instNeZeroInsepDegree : NeZero (insepDegree F E) := ⟨rank_pos.ne'⟩ instance instNeZeroFinInsepDegree [FiniteDimensional F E] : NeZero (finInsepDegree F E) := ⟨finrank_pos.ne'⟩ /-- If `E` and `K` are isomorphic as `F`-algebras, then they have the same separable degree over `F`. -/ theorem lift_sepDegree_eq_of_equiv (i : E ≃ₐ[F] K) : Cardinal.lift.{w} (sepDegree F E) = Cardinal.lift.{v} (sepDegree F K) := i.separableClosure.toLinearEquiv.lift_rank_eq /-- The same-universe version of `Field.lift_sepDegree_eq_of_equiv`. -/ theorem sepDegree_eq_of_equiv (K : Type v) [Field K] [Algebra F K] (i : E ≃ₐ[F] K) : sepDegree F E = sepDegree F K := i.separableClosure.toLinearEquiv.rank_eq /-- The separable degree multiplied by the inseparable degree is equal to the (infinite) field extension degree. -/ theorem sepDegree_mul_insepDegree : sepDegree F E * insepDegree F E = Module.rank F E := rank_mul_rank F (separableClosure F E) E theorem sepDegree_le_rank : sepDegree F E ≤ Module.rank F E := Module.rank_bot_le_rank_of_isScalarTower _ _ _ theorem insepDegree_le_rank : insepDegree F E ≤ Module.rank F E := Module.rank_top_le_rank_of_isScalarTower _ _ _ /-- If `E` and `K` are isomorphic as `F`-algebras, then they have the same inseparable degree over `F`. -/ theorem lift_insepDegree_eq_of_equiv (i : E ≃ₐ[F] K) : Cardinal.lift.{w} (insepDegree F E) = Cardinal.lift.{v} (insepDegree F K) := Algebra.lift_rank_eq_of_equiv_equiv i.separableClosure i rfl /-- The same-universe version of `Field.lift_insepDegree_eq_of_equiv`. -/ theorem insepDegree_eq_of_equiv (K : Type v) [Field K] [Algebra F K] (i : E ≃ₐ[F] K) : insepDegree F E = insepDegree F K := Algebra.rank_eq_of_equiv_equiv i.separableClosure i rfl /-- If `E` and `K` are isomorphic as `F`-algebras, then they have the same finite inseparable degree over `F`. -/ theorem finInsepDegree_eq_of_equiv (i : E ≃ₐ[F] K) : finInsepDegree F E = finInsepDegree F K := by simpa only [Cardinal.toNat_lift] using congr_arg Cardinal.toNat (lift_insepDegree_eq_of_equiv F E K i) @[simp] theorem sepDegree_self : sepDegree F F = 1 := by rw [sepDegree, Subsingleton.elim (separableClosure F F) ⊥, IntermediateField.rank_bot] @[simp] theorem insepDegree_self : insepDegree F F = 1 := by rw [insepDegree, Subsingleton.elim (separableClosure F F) ⊤, IntermediateField.rank_top] @[simp] theorem finInsepDegree_self : finInsepDegree F F = 1 := by rw [finInsepDegree_def', insepDegree_self, Cardinal.one_toNat] end Field namespace IntermediateField @[simp] theorem sepDegree_bot : sepDegree F (⊥ : IntermediateField F E) = 1 := by have := lift_sepDegree_eq_of_equiv _ _ _ (botEquiv F E) rwa [sepDegree_self, Cardinal.lift_one, ← Cardinal.lift_one.{v, u}, Cardinal.lift_inj] at this @[simp] theorem insepDegree_bot : insepDegree F (⊥ : IntermediateField F E) = 1 := by have := lift_insepDegree_eq_of_equiv _ _ _ (botEquiv F E) rwa [insepDegree_self, Cardinal.lift_one, ← Cardinal.lift_one.{v, u}, Cardinal.lift_inj] at this @[simp] theorem finInsepDegree_bot : finInsepDegree F (⊥ : IntermediateField F E) = 1 := by rw [finInsepDegree_eq_of_equiv _ _ _ (botEquiv F E), finInsepDegree_self] section Tower variable [Algebra E K] [IsScalarTower F E K] theorem lift_sepDegree_bot' : Cardinal.lift.{v} (sepDegree F (⊥ : IntermediateField E K)) = Cardinal.lift.{w} (sepDegree F E) := lift_sepDegree_eq_of_equiv _ _ _ ((botEquiv E K).restrictScalars F) theorem lift_insepDegree_bot' : Cardinal.lift.{v} (insepDegree F (⊥ : IntermediateField E K)) = Cardinal.lift.{w} (insepDegree F E) := lift_insepDegree_eq_of_equiv _ _ _ ((botEquiv E K).restrictScalars F) variable {F} @[simp] theorem finInsepDegree_bot' : finInsepDegree F (⊥ : IntermediateField E K) = finInsepDegree F E := by simpa only [Cardinal.toNat_lift] using congr_arg Cardinal.toNat (lift_insepDegree_bot' F E K) @[simp] theorem sepDegree_top : sepDegree F (⊤ : IntermediateField E K) = sepDegree F K := sepDegree_eq_of_equiv _ _ _ ((topEquiv (F := E) (E := K)).restrictScalars F) @[simp] theorem insepDegree_top : insepDegree F (⊤ : IntermediateField E K) = insepDegree F K := insepDegree_eq_of_equiv _ _ _ ((topEquiv (F := E) (E := K)).restrictScalars F) @[simp] theorem finInsepDegree_top : finInsepDegree F (⊤ : IntermediateField E K) = finInsepDegree F K := by rw [finInsepDegree_def', insepDegree_top, ← finInsepDegree_def'] variable (K : Type v) [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K] @[simp] theorem sepDegree_bot' : sepDegree F (⊥ : IntermediateField E K) = sepDegree F E := sepDegree_eq_of_equiv _ _ _ ((botEquiv E K).restrictScalars F) @[simp] theorem insepDegree_bot' : insepDegree F (⊥ : IntermediateField E K) = insepDegree F E := insepDegree_eq_of_equiv _ _ _ ((botEquiv E K).restrictScalars F) variable (F) in lemma _root_.Field.insepDegree_top_le_insepDegree_of_isScalarTower : insepDegree E K ≤ insepDegree F K := by letI := (IntermediateField.inclusion (separableClosure.le_restrictScalars F E K)).toAlgebra have : IsScalarTower (separableClosure F K) ((separableClosure E K).restrictScalars F) K := .of_algebraMap_eq' rfl exact Module.rank_top_le_rank_of_isScalarTower (separableClosure F K) ((separableClosure E K).restrictScalars F) K variable {K} in lemma _root_.Field.insepDegree_le_of_left_le {E₁ E₂ : IntermediateField F K} (H : E₁ ≤ E₂) : insepDegree E₂ K ≤ insepDegree E₁ K := by letI := (IntermediateField.inclusion H).toAlgebra have : IsScalarTower E₁ E₂ K := .of_algebraMap_eq' rfl exact insepDegree_top_le_insepDegree_of_isScalarTower _ _ _ variable (F) in lemma _root_.Field.finInsepDegree_top_le_finInsepDegree_of_isScalarTower [Module.Finite F K] : finInsepDegree E K ≤ finInsepDegree F K := by letI := (IntermediateField.inclusion (separableClosure.le_restrictScalars F E K)).toAlgebra have : IsScalarTower (separableClosure F K) ((separableClosure E K).restrictScalars F) K := .of_algebraMap_eq' rfl exact Module.finrank_top_le_finrank_of_isScalarTower (separableClosure F K) ((separableClosure E K).restrictScalars F) K variable {K} in lemma finInsepDegree_le_of_left_le {E₁ E₂ : IntermediateField F K} (H : E₁ ≤ E₂) [Module.Finite E₁ K] : finInsepDegree E₂ K ≤ finInsepDegree E₁ K := by letI := (IntermediateField.inclusion H).toAlgebra have : IsScalarTower E₁ E₂ K := .of_algebraMap_eq' rfl exact finInsepDegree_top_le_finInsepDegree_of_isScalarTower _ _ _ end Tower end IntermediateField /-- A separable extension has separable degree equal to degree. -/ theorem Algebra.IsSeparable.sepDegree_eq [Algebra.IsSeparable F E] : sepDegree F E = Module.rank F E := by rw [sepDegree, (separableClosure.eq_top_iff F E).2 ‹_›, IntermediateField.rank_top'] /-- A separable extension has inseparable degree one. -/ theorem Algebra.IsSeparable.insepDegree_eq [Algebra.IsSeparable F E] : insepDegree F E = 1 := by rw [insepDegree, (separableClosure.eq_top_iff F E).2 ‹_›, IntermediateField.rank_top] /-- A separable extension has finite inseparable degree one. -/ theorem Algebra.IsSeparable.finInsepDegree_eq [Algebra.IsSeparable F E] : finInsepDegree F E = 1 := Cardinal.one_toNat ▸ congr(Cardinal.toNat $(insepDegree_eq F E))
.lake/packages/mathlib/Mathlib/FieldTheory/Relrank.lean
import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic /-! # Relative rank of subfields and intermediate fields This file contains basics about the relative rank of subfields and intermediate fields. ## Main definitions - `Subfield.relrank A B`, `IntermediateField.relrank A B`: defined to be `[B : A ⊓ B]` as a `Cardinal`. In particular, when `A ≤ B` it is `[B : A]`, the degree of the field extension `B / A`. This is similar to `Subgroup.relIndex` but it is `Cardinal` valued. - `Subfield.relfinrank A B`, `IntermediateField.relfinrank A B`: the `Nat` version of `Subfield.relrank A B` and `IntermediateField.relrank A B`, respectively. If `B / A ⊓ B` is an infinite extension, then it is zero. This is similar to `Subgroup.relIndex`. -/ open Module Cardinal universe u v w namespace Subfield variable {E : Type v} [Field E] {L : Type w} [Field L] variable (A B C : Subfield E) /-- `Subfield.relrank A B` is defined to be `[B : A ⊓ B]` as a `Cardinal`, in particular, when `A ≤ B` it is `[B : A]`, the degree of the field extension `B / A`. This is similar to `Subgroup.relIndex` but it is `Cardinal` valued. -/ noncomputable def relrank := Module.rank ↥(A ⊓ B) (extendScalars (inf_le_right : A ⊓ B ≤ B)) /-- The `Nat` version of `Subfield.relrank`. If `B / A ⊓ B` is an infinite extension, then it is zero. -/ noncomputable def relfinrank := finrank ↥(A ⊓ B) (extendScalars (inf_le_right : A ⊓ B ≤ B)) theorem relfinrank_eq_toNat_relrank : relfinrank A B = toNat (relrank A B) := rfl variable {A B C} theorem relrank_eq_of_inf_eq (h : A ⊓ C = B ⊓ C) : relrank A C = relrank B C := by simp_rw [relrank] congr! theorem relfinrank_eq_of_inf_eq (h : A ⊓ C = B ⊓ C) : relfinrank A C = relfinrank B C := congr(toNat $(relrank_eq_of_inf_eq h)) /-- If `A ≤ B`, then `Subfield.relrank A B` is `[B : A]`. -/ theorem relrank_eq_rank_of_le (h : A ≤ B) : relrank A B = Module.rank A (extendScalars h) := by rw [relrank] have := inf_of_le_left h congr! /-- If `A ≤ B`, then `Subfield.relfinrank A B` is `[B : A]`. -/ theorem relfinrank_eq_finrank_of_le (h : A ≤ B) : relfinrank A B = finrank A (extendScalars h) := congr(toNat $(relrank_eq_rank_of_le h)) variable (A B C) theorem inf_relrank_right : relrank (A ⊓ B) B = relrank A B := relrank_eq_rank_of_le (inf_le_right : A ⊓ B ≤ B) theorem inf_relfinrank_right : relfinrank (A ⊓ B) B = relfinrank A B := congr(toNat $(inf_relrank_right A B)) theorem inf_relrank_left : relrank (A ⊓ B) A = relrank B A := by rw [inf_comm, inf_relrank_right] theorem inf_relfinrank_left : relfinrank (A ⊓ B) A = relfinrank B A := congr(toNat $(inf_relrank_left A B)) @[simp] theorem relrank_self : relrank A A = 1 := by rw [relrank_eq_rank_of_le (le_refl A), extendScalars_self, IntermediateField.rank_bot] @[simp] theorem relfinrank_self : relfinrank A A = 1 := by simp [relfinrank_eq_toNat_relrank] variable {A B} in theorem relrank_eq_one_of_le (h : B ≤ A) : relrank A B = 1 := by rw [← inf_relrank_right, inf_eq_right.2 h, relrank_self] variable {A B} in theorem relfinrank_eq_one_of_le (h : B ≤ A) : relfinrank A B = 1 := by simp [relfinrank_eq_toNat_relrank, relrank_eq_one_of_le h] variable {A B} in theorem relrank_mul_rank_top (h : A ≤ B) : relrank A B * Module.rank B E = Module.rank A E := by rw [relrank_eq_rank_of_le h] letI : Algebra A B := (inclusion h).toAlgebra haveI : IsScalarTower A B E := IsScalarTower.of_algebraMap_eq' rfl exact rank_mul_rank A B E variable {A B} in theorem relfinrank_mul_finrank_top (h : A ≤ B) : relfinrank A B * finrank B E = finrank A E := by simpa using congr(toNat $(relrank_mul_rank_top h)) @[simp] theorem relrank_top_left : relrank ⊤ A = 1 := relrank_eq_one_of_le le_top @[simp] theorem relfinrank_top_left : relfinrank ⊤ A = 1 := relfinrank_eq_one_of_le le_top @[simp] theorem relrank_top_right : relrank A ⊤ = Module.rank A E := by let _ : AddCommMonoid (⊤ : IntermediateField A E) := inferInstance rw [relrank_eq_rank_of_le (show A ≤ ⊤ from le_top), extendScalars_top, IntermediateField.topEquiv.toLinearEquiv.rank_eq] @[simp] theorem relfinrank_top_right : relfinrank A ⊤ = finrank A E := by simp [relfinrank_eq_toNat_relrank, finrank] theorem lift_relrank_map_map (f : E →+* L) : lift.{v} (relrank (A.map f) (B.map f)) = lift.{w} (relrank A B) := -- typeclass inference is slow .symm <| Algebra.lift_rank_eq_of_equiv_equiv (((A ⊓ B).equivMapOfInjective f f.injective).trans <| .subringCongr <| by rw [← map_inf]; rfl) (B.equivMapOfInjective f f.injective) rfl theorem relrank_map_map {L : Type v} [Field L] (f : E →+* L) : relrank (A.map f) (B.map f) = relrank A B := by simpa only [lift_id] using lift_relrank_map_map A B f theorem lift_relrank_comap (f : L →+* E) (B : Subfield L) : lift.{v} (relrank (A.comap f) B) = lift.{w} (relrank A (B.map f)) := (lift_relrank_map_map _ _ f).symm.trans <| congr_arg lift <| relrank_eq_of_inf_eq <| by rw [map_comap_eq, f.fieldRange_eq_map, inf_assoc, ← map_inf, top_inf_eq] theorem relrank_comap {L : Type v} [Field L] (f : L →+* E) (B : Subfield L) : relrank (A.comap f) B = relrank A (B.map f) := by simpa only [lift_id] using A.lift_relrank_comap f B theorem relfinrank_comap (f : L →+* E) (B : Subfield L) : relfinrank (A.comap f) B = relfinrank A (B.map f) := by simpa using congr(toNat $(lift_relrank_comap A f B)) theorem lift_rank_comap (f : L →+* E) : lift.{v} (Module.rank (A.comap f) L) = lift.{w} (relrank A f.fieldRange) := by simpa only [relrank_top_right, ← RingHom.fieldRange_eq_map] using lift_relrank_comap A f ⊤ theorem rank_comap {L : Type v} [Field L] (f : L →+* E) : Module.rank (A.comap f) L = relrank A f.fieldRange := by simpa only [lift_id] using A.lift_rank_comap f theorem finrank_comap (f : L →+* E) : finrank (A.comap f) L = relfinrank A f.fieldRange := by simpa using congr(toNat $(lift_rank_comap A f)) theorem relfinrank_map_map (f : E →+* L) : relfinrank (A.map f) (B.map f) = relfinrank A B := by simpa using congr(toNat $(lift_relrank_map_map A B f)) theorem lift_relrank_comap_comap_eq_lift_relrank_inf (f : L →+* E) : lift.{v} (relrank (A.comap f) (B.comap f)) = lift.{w} (relrank A (B ⊓ f.fieldRange)) := by conv_lhs => rw [← lift_relrank_map_map _ _ f, map_comap_eq, map_comap_eq] congr 1 apply relrank_eq_of_inf_eq rw [inf_assoc, inf_left_comm _ B, inf_of_le_left (le_refl _)] theorem relrank_comap_comap_eq_relrank_inf {L : Type v} [Field L] (f : L →+* E) : relrank (A.comap f) (B.comap f) = relrank A (B ⊓ f.fieldRange) := by simpa only [lift_id] using lift_relrank_comap_comap_eq_lift_relrank_inf A B f theorem relfinrank_comap_comap_eq_relfinrank_inf (f : L →+* E) : relfinrank (A.comap f) (B.comap f) = relfinrank A (B ⊓ f.fieldRange) := by simpa using congr(toNat $(lift_relrank_comap_comap_eq_lift_relrank_inf A B f)) theorem lift_relrank_comap_comap_eq_lift_relrank_of_le (f : L →+* E) (h : B ≤ f.fieldRange) : lift.{v} (relrank (A.comap f) (B.comap f)) = lift.{w} (relrank A B) := by simpa only [inf_of_le_left h] using lift_relrank_comap_comap_eq_lift_relrank_inf A B f theorem relrank_comap_comap_eq_relrank_of_le {L : Type v} [Field L] (f : L →+* E) (h : B ≤ f.fieldRange) : relrank (A.comap f) (B.comap f) = relrank A B := by simpa only [lift_id] using lift_relrank_comap_comap_eq_lift_relrank_of_le A B f h theorem relfinrank_comap_comap_eq_relfinrank_of_le (f : L →+* E) (h : B ≤ f.fieldRange) : relfinrank (A.comap f) (B.comap f) = relfinrank A B := by simpa using congr(toNat $(lift_relrank_comap_comap_eq_lift_relrank_of_le A B f h)) theorem lift_relrank_comap_comap_eq_lift_relrank_of_surjective (f : L →+* E) (h : Function.Surjective f) : lift.{v} (relrank (A.comap f) (B.comap f)) = lift.{w} (relrank A B) := lift_relrank_comap_comap_eq_lift_relrank_of_le A B f fun x _ ↦ h x theorem relrank_comap_comap_eq_relrank_of_surjective {L : Type v} [Field L] (f : L →+* E) (h : Function.Surjective f) : relrank (A.comap f) (B.comap f) = relrank A B := by simpa using lift_relrank_comap_comap_eq_lift_relrank_of_surjective A B f h theorem relfinrank_comap_comap_eq_relfinrank_of_surjective (f : L →+* E) (h : Function.Surjective f) : relfinrank (A.comap f) (B.comap f) = relfinrank A B := by simpa using congr(toNat $(lift_relrank_comap_comap_eq_lift_relrank_of_surjective A B f h)) variable {A B} in theorem relrank_dvd_rank_top_of_le (h : A ≤ B) : relrank A B ∣ Module.rank A E := dvd_of_mul_right_eq _ (relrank_mul_rank_top h) variable {A B} in theorem relfinrank_dvd_finrank_top_of_le (h : A ≤ B) : relfinrank A B ∣ finrank A E := dvd_of_mul_right_eq _ (relfinrank_mul_finrank_top h) variable {A B C} in theorem relrank_mul_relrank (h1 : A ≤ B) (h2 : B ≤ C) : relrank A B * relrank B C = relrank A C := by have h3 := h1.trans h2 rw [relrank_eq_rank_of_le h1, relrank_eq_rank_of_le h2, relrank_eq_rank_of_le h3] letI : Algebra A B := (inclusion h1).toAlgebra letI : Algebra B C := (inclusion h2).toAlgebra letI : Algebra A C := (inclusion h3).toAlgebra haveI : IsScalarTower A B C := IsScalarTower.of_algebraMap_eq' rfl exact rank_mul_rank A B C variable {A B C} in theorem relfinrank_mul_relfinrank (h1 : A ≤ B) (h2 : B ≤ C) : relfinrank A B * relfinrank B C = relfinrank A C := by simpa using congr(toNat $(relrank_mul_relrank h1 h2)) theorem relrank_inf_mul_relrank : A.relrank (B ⊓ C) * B.relrank C = (A ⊓ B).relrank C := by rw [← inf_relrank_right A (B ⊓ C), ← inf_relrank_right B C, ← inf_relrank_right (A ⊓ B) C, inf_assoc, relrank_mul_relrank inf_le_right inf_le_right] theorem relfinrank_inf_mul_relfinrank : A.relfinrank (B ⊓ C) * B.relfinrank C = (A ⊓ B).relfinrank C := by simpa using congr(toNat $(relrank_inf_mul_relrank A B C)) variable {B C} in theorem relrank_mul_relrank_eq_inf_relrank (h : B ≤ C) : relrank A B * relrank B C = (A ⊓ B).relrank C := by simpa only [inf_of_le_left h] using relrank_inf_mul_relrank A B C variable {B C} in theorem relfinrank_mul_relfinrank_eq_inf_relfinrank (h : B ≤ C) : relfinrank A B * relfinrank B C = (A ⊓ B).relfinrank C := by simpa using congr(toNat $(relrank_mul_relrank_eq_inf_relrank A h)) variable {A B} in theorem relrank_inf_mul_relrank_of_le (h : A ≤ B) : A.relrank (B ⊓ C) * B.relrank C = A.relrank C := by simpa only [inf_of_le_left h] using relrank_inf_mul_relrank A B C variable {A B} in theorem relfinrank_inf_mul_relfinrank_of_le (h : A ≤ B) : A.relfinrank (B ⊓ C) * B.relfinrank C = A.relfinrank C := by simpa using congr(toNat $(relrank_inf_mul_relrank_of_le C h)) variable {A B} in theorem relrank_dvd_of_le_left (h : A ≤ B) : B.relrank C ∣ A.relrank C := dvd_of_mul_left_eq _ (relrank_inf_mul_relrank_of_le C h) variable {A B} in theorem relfinrank_dvd_of_le_left (h : A ≤ B) : B.relfinrank C ∣ A.relfinrank C := dvd_of_mul_left_eq _ (relfinrank_inf_mul_relfinrank_of_le C h) end Subfield namespace IntermediateField variable {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] variable {L : Type w} [Field L] [Algebra F L] variable (A B C : IntermediateField F E) /-- `IntermediateField.relrank A B` is defined to be `[B : A ⊓ B]` as a `Cardinal`, in particular, when `A ≤ B` it is `[B : A]`, the degree of the field extension `B / A`. This is similar to `Subgroup.relIndex` but it is `Cardinal` valued. -/ noncomputable def relrank := A.toSubfield.relrank B.toSubfield /-- The `Nat` version of `IntermediateField.relrank`. If `B / A ⊓ B` is an infinite extension, then it is zero. -/ noncomputable def relfinrank := A.toSubfield.relfinrank B.toSubfield theorem relfinrank_eq_toNat_relrank : relfinrank A B = toNat (relrank A B) := rfl variable {A B C} theorem relrank_eq_of_inf_eq (h : A ⊓ C = B ⊓ C) : relrank A C = relrank B C := Subfield.relrank_eq_of_inf_eq congr(toSubfield $h) theorem relfinrank_eq_of_inf_eq (h : A ⊓ C = B ⊓ C) : relfinrank A C = relfinrank B C := congr(toNat $(relrank_eq_of_inf_eq h)) /-- If `A ≤ B`, then `IntermediateField.relrank A B` is `[B : A]` -/ theorem relrank_eq_rank_of_le (h : A ≤ B) : relrank A B = Module.rank A (extendScalars h) := Subfield.relrank_eq_rank_of_le h /-- If `A ≤ B`, then `IntermediateField.relrank A B` is `[B : A]` -/ theorem relfinrank_eq_finrank_of_le (h : A ≤ B) : relfinrank A B = finrank A (extendScalars h) := congr(toNat $(relrank_eq_rank_of_le h)) variable (A B C) theorem inf_relrank_right : relrank (A ⊓ B) B = relrank A B := relrank_eq_rank_of_le (inf_le_right : A ⊓ B ≤ B) theorem inf_relfinrank_right : relfinrank (A ⊓ B) B = relfinrank A B := congr(toNat $(inf_relrank_right A B)) theorem inf_relrank_left : relrank (A ⊓ B) A = relrank B A := by rw [inf_comm, inf_relrank_right] theorem inf_relfinrank_left : relfinrank (A ⊓ B) A = relfinrank B A := congr(toNat $(inf_relrank_left A B)) @[simp] theorem relrank_self : relrank A A = 1 := A.toSubfield.relrank_self @[simp] theorem relfinrank_self : relfinrank A A = 1 := A.toSubfield.relfinrank_self variable {A B} in theorem relrank_eq_one_of_le (h : B ≤ A) : relrank A B = 1 := by rw [← inf_relrank_right, inf_eq_right.2 h, relrank_self] variable {A B} in theorem relfinrank_eq_one_of_le (h : B ≤ A) : relfinrank A B = 1 := by simp [relfinrank_eq_toNat_relrank, relrank_eq_one_of_le h] theorem lift_rank_comap (f : L →ₐ[F] E) : Cardinal.lift.{v} (Module.rank (A.comap f) L) = Cardinal.lift.{w} (relrank A f.fieldRange) := A.toSubfield.lift_rank_comap f.toRingHom theorem rank_comap {L : Type v} [Field L] [Algebra F L] (f : L →ₐ[F] E) : Module.rank (A.comap f) L = relrank A f.fieldRange := by simpa only [lift_id] using A.lift_rank_comap f theorem finrank_comap (f : L →ₐ[F] E) : finrank (A.comap f) L = relfinrank A f.fieldRange := by simpa using congr(toNat $(lift_rank_comap A f)) theorem lift_relrank_comap (f : L →ₐ[F] E) (B : IntermediateField F L) : Cardinal.lift.{v} (relrank (A.comap f) B) = Cardinal.lift.{w} (relrank A (B.map f)) := A.toSubfield.lift_relrank_comap f.toRingHom B.toSubfield theorem relrank_comap {L : Type v} [Field L] [Algebra F L] (f : L →ₐ[F] E) (B : IntermediateField F L) : relrank (A.comap f) B = relrank A (B.map f) := by simpa only [lift_id] using A.lift_relrank_comap f B theorem relfinrank_comap (f : L →ₐ[F] E) (B : IntermediateField F L) : relfinrank (A.comap f) B = relfinrank A (B.map f) := by simpa using congr(toNat $(lift_relrank_comap A f B)) theorem lift_relrank_map_map (f : E →ₐ[F] L) : Cardinal.lift.{v} (relrank (A.map f) (B.map f)) = Cardinal.lift.{w} (relrank A B) := by rw [← lift_relrank_comap, comap_map] theorem relrank_map_map {L : Type v} [Field L] [Algebra F L] (f : E →ₐ[F] L) : relrank (A.map f) (B.map f) = relrank A B := by simpa only [lift_id] using lift_relrank_map_map A B f theorem relfinrank_map_map (f : E →ₐ[F] L) : relfinrank (A.map f) (B.map f) = relfinrank A B := by simpa using congr(toNat $(lift_relrank_map_map A B f)) theorem lift_relrank_comap_comap_eq_lift_relrank_inf (f : L →ₐ[F] E) : Cardinal.lift.{v} (relrank (A.comap f) (B.comap f)) = Cardinal.lift.{w} (relrank A (B ⊓ f.fieldRange)) := A.toSubfield.lift_relrank_comap_comap_eq_lift_relrank_inf B.toSubfield f.toRingHom theorem relrank_comap_comap_eq_relrank_inf {L : Type v} [Field L] [Algebra F L] (f : L →ₐ[F] E) : relrank (A.comap f) (B.comap f) = relrank A (B ⊓ f.fieldRange) := by simpa only [lift_id] using lift_relrank_comap_comap_eq_lift_relrank_inf A B f theorem relfinrank_comap_comap_eq_relfinrank_inf (f : L →ₐ[F] E) : relfinrank (A.comap f) (B.comap f) = relfinrank A (B ⊓ f.fieldRange) := by simpa using congr(toNat $(lift_relrank_comap_comap_eq_lift_relrank_inf A B f)) theorem lift_relrank_comap_comap_eq_lift_relrank_of_le (f : L →ₐ[F] E) (h : B ≤ f.fieldRange) : Cardinal.lift.{v} (relrank (A.comap f) (B.comap f)) = Cardinal.lift.{w} (relrank A B) := by simpa only [inf_of_le_left h] using lift_relrank_comap_comap_eq_lift_relrank_inf A B f theorem relrank_comap_comap_eq_relrank_of_le {L : Type v} [Field L] [Algebra F L] (f : L →ₐ[F] E) (h : B ≤ f.fieldRange) : relrank (A.comap f) (B.comap f) = relrank A B := by simpa only [lift_id] using lift_relrank_comap_comap_eq_lift_relrank_of_le A B f h theorem relfinrank_comap_comap_eq_relfinrank_of_le (f : L →ₐ[F] E) (h : B ≤ f.fieldRange) : relfinrank (A.comap f) (B.comap f) = relfinrank A B := by simpa using congr(toNat $(lift_relrank_comap_comap_eq_lift_relrank_of_le A B f h)) theorem lift_relrank_comap_comap_eq_lift_relrank_of_surjective (f : L →ₐ[F] E) (h : Function.Surjective f) : Cardinal.lift.{v} (relrank (A.comap f) (B.comap f)) = Cardinal.lift.{w} (relrank A B) := lift_relrank_comap_comap_eq_lift_relrank_of_le A B f fun x _ ↦ h x theorem relrank_comap_comap_eq_relrank_of_surjective {L : Type v} [Field L] [Algebra F L] (f : L →ₐ[F] E) (h : Function.Surjective f) : relrank (A.comap f) (B.comap f) = relrank A B := by simpa using lift_relrank_comap_comap_eq_lift_relrank_of_surjective A B f h theorem relfinrank_comap_comap_eq_relfinrank_of_surjective (f : L →ₐ[F] E) (h : Function.Surjective f) : relfinrank (A.comap f) (B.comap f) = relfinrank A B := by simpa using congr(toNat $(lift_relrank_comap_comap_eq_lift_relrank_of_surjective A B f h)) variable {A B} in theorem relrank_mul_rank_top (h : A ≤ B) : relrank A B * Module.rank B E = Module.rank A E := Subfield.relrank_mul_rank_top h variable {A B} in theorem relfinrank_mul_finrank_top (h : A ≤ B) : relfinrank A B * finrank B E = finrank A E := by simpa using congr(toNat $(relrank_mul_rank_top h)) variable {A B} in theorem rank_bot_mul_relrank (h : A ≤ B) : Module.rank F A * relrank A B = Module.rank F B := by rw [relrank_eq_rank_of_le h] letI : Algebra A B := (inclusion h).toAlgebra haveI : IsScalarTower F A B := IsScalarTower.of_algebraMap_eq' rfl exact rank_mul_rank F A B variable {A B} in theorem finrank_bot_mul_relfinrank (h : A ≤ B) : finrank F A * relfinrank A B = finrank F B := by simpa using congr(toNat $(rank_bot_mul_relrank h)) variable {A B} in theorem relrank_dvd_rank_top_of_le (h : A ≤ B) : relrank A B ∣ Module.rank A E := dvd_of_mul_right_eq _ (relrank_mul_rank_top h) variable {A B} in theorem relfinrank_dvd_finrank_top_of_le (h : A ≤ B) : relfinrank A B ∣ finrank A E := dvd_of_mul_right_eq _ (relfinrank_mul_finrank_top h) theorem relrank_dvd_rank_bot : relrank A B ∣ Module.rank F B := inf_relrank_right A B ▸ dvd_of_mul_left_eq _ (rank_bot_mul_relrank inf_le_right) theorem relfinrank_dvd_finrank_bot : relfinrank A B ∣ finrank F B := inf_relfinrank_right A B ▸ dvd_of_mul_left_eq _ (finrank_bot_mul_relfinrank inf_le_right) variable {A B C} in theorem relrank_mul_relrank (h1 : A ≤ B) (h2 : B ≤ C) : relrank A B * relrank B C = relrank A C := Subfield.relrank_mul_relrank h1 h2 variable {A B C} in theorem relfinrank_mul_relfinrank (h1 : A ≤ B) (h2 : B ≤ C) : relfinrank A B * relfinrank B C = relfinrank A C := by simpa using congr(toNat $(relrank_mul_relrank h1 h2)) theorem relrank_inf_mul_relrank : A.relrank (B ⊓ C) * B.relrank C = (A ⊓ B).relrank C := Subfield.relrank_inf_mul_relrank A.toSubfield B.toSubfield C.toSubfield theorem relfinrank_inf_mul_relfinrank : A.relfinrank (B ⊓ C) * B.relfinrank C = (A ⊓ B).relfinrank C := by simpa using congr(toNat $(relrank_inf_mul_relrank A B C)) variable {B C} in theorem relrank_mul_relrank_eq_inf_relrank (h : B ≤ C) : relrank A B * relrank B C = (A ⊓ B).relrank C := by simpa only [inf_of_le_left h] using relrank_inf_mul_relrank A B C variable {B C} in theorem relfinrank_mul_relfinrank_eq_inf_relfinrank (h : B ≤ C) : relfinrank A B * relfinrank B C = (A ⊓ B).relfinrank C := by simpa using congr(toNat $(relrank_mul_relrank_eq_inf_relrank A h)) variable {A B} in theorem relrank_inf_mul_relrank_of_le (h : A ≤ B) : A.relrank (B ⊓ C) * B.relrank C = A.relrank C := by simpa only [inf_of_le_left h] using relrank_inf_mul_relrank A B C variable {A B} in theorem relfinrank_inf_mul_relfinrank_of_le (h : A ≤ B) : A.relfinrank (B ⊓ C) * B.relfinrank C = A.relfinrank C := by simpa using congr(toNat $(relrank_inf_mul_relrank_of_le C h)) @[simp] theorem relrank_top_left : relrank ⊤ A = 1 := relrank_eq_one_of_le le_top @[simp] theorem relfinrank_top_left : relfinrank ⊤ A = 1 := relfinrank_eq_one_of_le le_top @[simp] theorem relrank_top_right : relrank A ⊤ = Module.rank A E := by rw [← relrank_mul_rank_top (show A ≤ ⊤ from le_top), IntermediateField.rank_top, mul_one] @[simp] theorem relfinrank_top_right : relfinrank A ⊤ = finrank A E := by simp [relfinrank_eq_toNat_relrank, finrank] @[simp] theorem relrank_bot_left : relrank ⊥ A = Module.rank F A := by rw [← rank_bot_mul_relrank (show ⊥ ≤ A from bot_le), IntermediateField.rank_bot, one_mul] @[simp] theorem relfinrank_bot_left : relfinrank ⊥ A = finrank F A := by simp [relfinrank_eq_toNat_relrank, finrank] @[simp] theorem relrank_bot_right : relrank A ⊥ = 1 := relrank_eq_one_of_le bot_le @[simp] theorem relfinrank_bot_right : relfinrank A ⊥ = 1 := relfinrank_eq_one_of_le bot_le variable {A B} in theorem relrank_dvd_of_le_left (h : A ≤ B) : B.relrank C ∣ A.relrank C := dvd_of_mul_left_eq _ (relrank_inf_mul_relrank_of_le C h) variable {A B} in theorem relfinrank_dvd_of_le_left (h : A ≤ B) : B.relfinrank C ∣ A.relfinrank C := dvd_of_mul_left_eq _ (relfinrank_inf_mul_relfinrank_of_le C h) end IntermediateField
.lake/packages/mathlib/Mathlib/FieldTheory/Isaacs.lean
import Mathlib.FieldTheory.Normal.Basic import Mathlib.FieldTheory.PrimitiveElement import Mathlib.GroupTheory.CosetCover /-! # Algebraic extensions are determined by their sets of minimal polynomials up to isomorphism ## Main results `Field.nonempty_algHom_of_exist_roots` says if `E/F` and `K/F` are field extensions with `E/F` algebraic, and if the minimal polynomial of every element of `E` over `F` has a root in `K`, then there exists an `F`-embedding of `E` into `K`. If `E/F` and `K/F` have the same set of minimal polynomials, then `E` and `K` are isomorphic as `F`-algebras. As a corollary: `IsAlgClosure.of_exist_roots`: if `E/F` is algebraic and every monic irreducible polynomial in `F[X]` has a root in `E`, then `E` is an algebraic closure of `F`. ## Reference [Isaacs1980] *Roots of Polynomials in Algebraic Extensions of Fields*, The American Mathematical Monthly -/ namespace Field open Polynomial IntermediateField variable {F E K : Type*} [Field F] [Field E] [Field K] [Algebra F E] [Algebra F K] variable [alg : Algebra.IsAlgebraic F E] theorem nonempty_algHom_of_exist_roots (h : ∀ x : E, ∃ y : K, aeval y (minpoly F x) = 0) : Nonempty (E →ₐ[F] K) := by refine Lifts.nonempty_algHom_of_exist_lifts_finset fun S ↦ ⟨⟨adjoin F S, ?_⟩, subset_adjoin _ _⟩ let p := (S.prod <| minpoly F).map (algebraMap F K) let K' := SplittingField p have splits s (hs : s ∈ S) : (minpoly F s).Splits (algebraMap F K') := by apply splits_of_splits_of_dvd _ (Finset.prod_ne_zero_iff.mpr fun _ _ ↦ minpoly.ne_zero <| (alg.isIntegral).1 _) ((splits_map_iff _ _).mp <| SplittingField.splits p) (Finset.dvd_prod_of_mem _ hs) let K₀ := (⊥ : IntermediateField K K').restrictScalars F let FS := adjoin F (S : Set E) let Ω := FS →ₐ[F] K' have := finiteDimensional_adjoin (S := (S : Set E)) fun _ _ ↦ (alg.isIntegral).1 _ let M (ω : Ω) := Subalgebra.toSubmodule (K₀.comap ω).toSubalgebra have : ⋃ ω : Ω, (M ω : Set FS) = Set.univ := Set.eq_univ_of_forall fun ⟨α, hα⟩ ↦ Set.mem_iUnion.mpr <| by have ⟨β, hβ⟩ := h α let ϕ : F⟮α⟯ →ₐ[F] K' := (IsScalarTower.toAlgHom _ _ _).comp ((AdjoinRoot.liftAlgHom _ _ _ hβ).comp (adjoinRootEquivAdjoin F <| (alg.isIntegral).1 _).symm.toAlgHom) have ⟨ω, hω⟩ := exists_algHom_adjoin_of_splits (fun s hs ↦ ⟨(alg.isIntegral).1 _, splits s hs⟩) ϕ (adjoin_simple_le_iff.mpr hα) refine ⟨ω, β, ((DFunLike.congr_fun hω <| AdjoinSimple.gen F α).trans ?_).symm⟩ rw [AlgHom.comp_apply, AlgHom.comp_apply, AlgEquiv.coe_algHom, adjoinRootEquivAdjoin_symm_apply_gen, AdjoinRoot.liftAlgHom_root] rfl have ω : ∃ ω : Ω, ⊤ ≤ M ω := by cases finite_or_infinite F · have ⟨α, hα⟩ := exists_primitive_element_of_finite_bot F FS have ⟨ω, hω⟩ := Set.mem_iUnion.mp (this ▸ Set.mem_univ α) exact ⟨ω, show ⊤ ≤ K₀.comap ω by rwa [← hα, adjoin_simple_le_iff]⟩ · simp_rw [top_le_iff, Subspace.exists_eq_top_of_iUnion_eq_univ this] exact ((botEquiv K K').toAlgHom.restrictScalars F).comp (ω.choose.codRestrict K₀.toSubalgebra fun x ↦ ω.choose_spec trivial) theorem nonempty_algHom_of_minpoly_eq (h : ∀ x : E, ∃ y : K, minpoly F x = minpoly F y) : Nonempty (E →ₐ[F] K) := nonempty_algHom_of_exist_roots fun x ↦ have ⟨y, hy⟩ := h x; ⟨y, by rw [hy, minpoly.aeval]⟩ theorem nonempty_algHom_of_range_minpoly_subset (h : Set.range (@minpoly F E _ _ _) ⊆ Set.range (@minpoly F K _ _ _)) : Nonempty (E →ₐ[F] K) := nonempty_algHom_of_minpoly_eq fun x ↦ have ⟨y, hy⟩ := h ⟨x, rfl⟩; ⟨y, hy.symm⟩ theorem nonempty_algEquiv_of_range_minpoly_eq (h : Set.range (@minpoly F E _ _ _) = Set.range (@minpoly F K _ _ _)) : Nonempty (E ≃ₐ[F] K) := have ⟨σ⟩ := nonempty_algHom_of_range_minpoly_subset h.le have : Algebra.IsAlgebraic F K := ⟨fun y ↦ IsIntegral.isAlgebraic <| by by_contra hy have ⟨x, hx⟩ := h.ge ⟨y, rfl⟩ rw [minpoly.eq_zero hy] at hx exact minpoly.ne_zero ((alg.isIntegral).1 x) hx⟩ have ⟨τ⟩ := nonempty_algHom_of_range_minpoly_subset h.ge ⟨.ofBijective _ (Algebra.IsAlgebraic.algHom_bijective₂ σ τ).1⟩ theorem nonempty_algHom_of_aeval_eq_zero_subset (h : {p : F[X] | ∃ x : E, aeval x p = 0} ⊆ {p | ∃ y : K, aeval y p = 0}) : Nonempty (E →ₐ[F] K) := nonempty_algHom_of_minpoly_eq fun x ↦ have ⟨y, hy⟩ := h ⟨_, minpoly.aeval F x⟩ ⟨y, (minpoly.eq_iff_aeval_minpoly_eq_zero <| (alg.isIntegral).1 x).mpr hy⟩ theorem nonempty_algEquiv_of_aeval_eq_zero_eq [Algebra.IsAlgebraic F K] (h : {p : F[X] | ∃ x : E, aeval x p = 0} = {p | ∃ y : K, aeval y p = 0}) : Nonempty (E ≃ₐ[F] K) := have ⟨σ⟩ := nonempty_algHom_of_aeval_eq_zero_subset h.le have ⟨τ⟩ := nonempty_algHom_of_aeval_eq_zero_subset h.ge ⟨.ofBijective _ (Algebra.IsAlgebraic.algHom_bijective₂ σ τ).1⟩ theorem _root_.IsAlgClosure.of_exist_roots (h : ∀ p : F[X], p.Monic → Irreducible p → ∃ x : E, aeval x p = 0) : IsAlgClosure F E := .of_splits fun p _ _ ↦ have ⟨σ⟩ := nonempty_algHom_of_exist_roots fun x : p.SplittingField ↦ have := Algebra.IsAlgebraic.isIntegral (K := F).1 x h _ (minpoly.monic this) (minpoly.irreducible this) splits_of_algHom (SplittingField.splits _) σ end Field
.lake/packages/mathlib/Mathlib/FieldTheory/CardinalEmb.lean
import Mathlib.FieldTheory.SeparableClosure import Mathlib.FieldTheory.PurelyInseparable.Basic import Mathlib.LinearAlgebra.FreeAlgebra import Mathlib.Order.Interval.Set.WithBotTop import Mathlib.Order.DirectedInverseSystem /-! # Number of embeddings of an algebraic extension of infinite separable degree ## Main results - `Field.Emb.cardinal_eq_two_pow_rank` : if `E/F` is an algebraic separable field extension of infinite degree, then `#(Field.Emb F E) = 2 ^ Module.rank F E`. This is in contrast to the case of finite degree, where `#(Field.Emb F E) = Module.rank F E`. - `Field.Emb.cardinal_eq_two_pow_sepDegree`: more generally, if `E/F` is an algebraic extension of infinite separable degree, then `#(Field.Emb F E) = 2 ^ Field.sepDegree F E`. ## Sketch of the proof We use a transfinite recursive construction that is fairly standard in set theory, but the author has not seen similar arguments elsewhere in mathlib, and some parts proved tricky to formalize. The extension `E/F` can be filtered by intermediate fields indexed by a well-order: simply put a well-order on a basis of `E/F`, and at each step, take the smallest basis element that is not contained in the intermediate field generated by all previous elements, so that they generate a strictly larger intermediate field together. This process can extend all the way to the initial ordinal `ι` of the cardinal `Module.rank F E`, because the dimension of the subalgebra generated by an infinite set cannot be greater than the cardinality of the set, and in an algebraic extension, any subalgebra is a field. This is proven as `Algebra.rank_adjoin_le` and used to show `leastExt` is a total function from `ι` to itself. It is probably mathematically the most nontrivial part of the whole argument, but turned out easy to formalize and was done the earliest. Once we have the filtration `E⟮<i⟯` for `i : ι`, we may build an embedding `E →ₐ[F] Ē` step by step. To extend an embedding `E⟮<i⟯ →ₐ[F] Ē` to the successor `E⟮<i⁺⟯`, the number of choices is equal to the (finite) separable degree of `E⟮<i⁺⟯ / E⟮<i⟯`, which is equal to its rank if `E/F` is separable. Since each extension is nontrivial, the degree is at least two (`two_le_deg`) but always finite. Intuitively, these choices multiply together to give the cardinality of `Field.Emb F E := (E →ₐ[F] Ē)`, and since the total times of choices to be made is the length of the filtration `#ι`, we conclude that `2 ^ #ι ≤ #(Field.Emb F E) ≤ ℵ₀ ^ #ι`, but for infinite `#ι` both sides are equal, so we get an equality `#(Field.Emb F E) = 2 ^ #ι = 2 ^ Module.rank F E`. To rigorize the argument we formalize the choice at step `i` as a bijection `F i⁺ ≃ F i × X i`, where `X i := Field.Emb E⟮<i⟯ E⟮<i⁺⟯`, and we formalize the combination of all choices as the Pi type `∀ i : ι, X i`. We use transfinite recursion (`SuccOrder.prelimitRecOn`) to build a bijection `Field.Emb F E ≃ ∀ i, X i` with the Pi type by successively extending bijections `F i ≃ ∀ j : Iio i, X j` using the bijections `F i⁺ ≃ F i × X i` with product types (`InverseSystem.piEquivSucc`). More details are found in the file about `InverseLimit`. Since `ι` is a limit ordinal, `Field.Emb F E ≃ (⊤ →ₐ[F] Ē)` is not actually one of the `F i` because `⊤` is not one of the `E⟮<i⟯`, so we have to adjoin a top element to `ι` (`WithTop ι`) to obtain the bijection `Field.Emb F E ≃ F ⊤ ≃ ∀ j : Iio ⊤, X j ≃ ∀ i : ι, X i = ∀ i : ι, Field.Emb E⟮<i⟯ E⟮<i⁺⟯`. To make this straightforward, it is crucial that `(↑i : WithTop ι)⁺ = ↑(i⁺)` holds definitionally. The predicate `IsSuccPrelimit` allows us to treat limits and the bottom element uniformly, and the only place the bottom element requires special treatment is in `equivLim` (the bijection between `E⟮<i⟯ →ₐ[F] Ē` and the inverse limit of `E⟮<j⟯ →ₐ[F] Ē` over `j < i`). -/ open Cardinal Module Free Set Order IntermediateField InverseSystem universe u v variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] namespace Field.Emb namespace Cardinal noncomputable section set_option quotPrecheck false /-- Index a basis of E/F using the initial ordinal of the cardinal `Module.rank F E`. -/ local notation "ι" => (Module.rank F E).ord.toType private local instance : SuccOrder ι := SuccOrder.ofLinearWellFoundedLT ι local notation i"⁺" => succ i -- Note: conflicts with `PosPart` notation /-- A basis of E/F indexed by the initial ordinal. -/ def wellOrderedBasis : Basis ι F E := (chooseBasis F E).reindex (Cardinal.eq.mp <| (mk_ord_toType _).trans <| rank_eq_card_chooseBasisIndex F E).some.symm local notation "b" => wellOrderedBasis F E local notation "Ē" => AlgebraicClosure E variable {F E} theorem adjoin_basis_eq_top : adjoin F (range b) = ⊤ := toSubalgebra_injective <| Subalgebra.toSubmodule_injective <| top_unique <| (Basis.span_eq b).ge.trans <| (Algebra.span_le_adjoin F _).trans <| algebra_adjoin_le_adjoin _ _ section Algebraic variable [rank_inf : Fact (ℵ₀ ≤ Module.rank F E)] lemma noMaxOrder_rank_toType : NoMaxOrder ι := Cardinal.noMaxOrder Fact.out attribute [local instance] noMaxOrder_rank_toType open _root_.Algebra (IsAlgebraic) variable [IsAlgebraic F E] variable (F E) in /-- `leastExt i` is defined to be the smallest `k : ι` that generates a nontrivial extension over (i.e. does not lie in) the subalgebra (= intermediate field) generated by all previous `leastExt j`, `j < i`. For cardinality reasons, such `k` always exist if `ι` is infinite. -/ def leastExt : ι → ι := wellFounded_lt.fix fun i ih ↦ let s := range fun j : Iio i ↦ b (ih j j.2) wellFounded_lt.min {k | b k ∉ adjoin F s} <| by rw [← compl_setOf, nonempty_compl]; by_contra! simp_rw [eq_univ_iff_forall, mem_setOf] at this have := adjoin_le_iff.mpr (range_subset_iff.mpr this) rw [adjoin_basis_eq_top, ← eq_top_iff] at this apply_fun Module.rank F at this refine ne_of_lt ?_ this let _ : AddCommMonoid (⊤ : IntermediateField F E) := inferInstance conv_rhs => rw [topEquiv.toLinearEquiv.rank_eq] have := mk_Iio_ord_toType i obtain eq | lt := rank_inf.out.eq_or_lt · replace this := mk_lt_aleph0_iff.mp (this.trans_eq eq.symm) have : FiniteDimensional F (adjoin F s) := finiteDimensional_adjoin fun x _ ↦ (IsAlgebraic.isAlgebraic x).isIntegral exact (Module.rank_lt_aleph0 _ _).trans_eq eq · exact (Subalgebra.equivOfEq _ _ <| adjoin_algebraic_toSubalgebra fun x _ ↦ IsAlgebraic.isAlgebraic x)|>.toLinearEquiv.rank_eq.trans_lt <| (Algebra.rank_adjoin_le _).trans_lt (max_lt (mk_range_le.trans_lt this) lt) local notation "φ" => leastExt F E section local notation "E⟮<"i"⟯" => adjoin F (b ∘ φ '' Iio i) theorem isLeast_leastExt (i : ι) : IsLeast {k | b k ∉ E⟮<i⟯} (φ i) := by rw [image_eq_range, leastExt, wellFounded_lt.fix_eq] exact ⟨wellFounded_lt.min_mem _ _, fun _ ↦ (wellFounded_lt.min_le ·)⟩ theorem strictMono_leastExt : StrictMono φ := fun i j h ↦ by have least := isLeast_leastExt (F := F) (E := E) by_contra! obtain eq | lt := this.eq_or_lt · exact (least j).1 (subset_adjoin _ _ ⟨i, h, congr_arg b eq.symm⟩) · refine ((least i).2 <| mt (adjoin.mono _ _ _ (image_mono ?_) ·) (least j).1).not_gt lt exact fun k (hk : k < i) ↦ hk.trans h theorem adjoin_image_leastExt (i : ι) : E⟮<i⟯ = adjoin F (b '' Iio (φ i)) := by refine le_antisymm (adjoin.mono _ _ _ ?_) (adjoin_le_iff.mpr ?_) · rw [image_comp]; apply image_mono; rintro _ ⟨j, hj, rfl⟩; exact strictMono_leastExt hj · rintro _ ⟨j, hj, rfl⟩; contrapose! hj; exact ((isLeast_leastExt i).2 hj).not_gt theorem iSup_adjoin_eq_top : ⨆ i : ι, E⟮<i⟯ = ⊤ := by simp_rw [adjoin_image_leastExt, eq_top_iff, ← adjoin_basis_eq_top, adjoin_le_iff] rintro _ ⟨i, rfl⟩ refine le_iSup (α := IntermediateField F E) _ (i⁺) (subset_adjoin _ _ ⟨i, ?_, rfl⟩) exact (lt_succ i).trans_le strictMono_leastExt.le_apply theorem strictMono_filtration : StrictMono (E⟮<·⟯) := fun i _ h ↦ ⟨adjoin.mono _ _ _ (image_mono <| Iio_subset_Iio h.le), fun incl ↦ (isLeast_leastExt i).1 (incl <| subset_adjoin _ _ ⟨i, h, rfl⟩)⟩ theorem filtration_succ (i : ι) : E⟮<i⁺⟯ = E⟮<i⟯⟮b (φ i)⟯.restrictScalars F := by rw [Iio_succ, ← Iio_insert, image_insert_eq, ← union_singleton, adjoin_adjoin_left]; rfl local notation "X" i => Field.Emb (E⟮<i⟯) <| E⟮<i⟯⟮b (φ i)⟯ /-- Each embedding of `E⟮<i⟯` into `Ē` extend to `#(X i)` embeddings of `E⟮<i⁺⟯`. -/ def succEquiv (i : ι) : (E⟮<i⁺⟯ →ₐ[F] Ē) ≃ (E⟮<i⟯ →ₐ[F] Ē) × X i := (((show _ ≃ₐ[F] E⟮<i⟯⟮b (φ i)⟯ from equivOfEq (filtration_succ i))).arrowCongr .refl).trans <| algHomEquivSigma (B := E⟮<i⟯).trans <| .sigmaEquivProdOfEquiv fun _ ↦ (@Field.embEquivOfIsAlgClosed _ _ _ _ _ _ _ (_) <| (Algebra.IsAlgebraic.tower_top (K := F) _).of_injective (val _) Subtype.val_injective).symm theorem succEquiv_coherence (i : ι) (f) : (succEquiv i f).1 = f.comp (Subalgebra.inclusion <| strictMono_filtration.monotone <| le_succ i) := by ext; simp [succEquiv]; rfl -- slow rfl (type checking took 11.9s) instance (i : ι) : FiniteDimensional (E⟮<i⟯) (E⟮<i⟯⟮b (φ i)⟯) := adjoin.finiteDimensional ((Algebra.IsAlgebraic.tower_top (K := F) _).isAlgebraic _).isIntegral theorem deg_lt_aleph0 (i : ι) : #(X i) < ℵ₀ := (toNat_ne_zero.mp (Field.instNeZeroFinSepDegree (E⟮<i⟯) <| E⟮<i⟯⟮b (φ i)⟯).out).2 open WithTop in /-- Extend the family `E⟮<i⟯, i : ι` by adjoining a top element. -/ @[simps!] def filtration : WithTop ι ↪o IntermediateField F E := .ofStrictMono (fun i ↦ i.recTopCoe ⊤ (E⟮<·⟯)) fun i j h ↦ by cases j · obtain ⟨i, rfl⟩ := ne_top_iff_exists.mp h.ne exact ⟨le_top, fun incl ↦ (isLeast_leastExt i).1 (incl trivial)⟩ · obtain ⟨i, rfl⟩ := ne_top_iff_exists.mp (h.trans <| coe_lt_top _).ne exact strictMono_filtration (coe_lt_coe.mp h) /-- Extend the family `X i := E⟮<i⟯ →ₐ[F] Ē` from `ι` to `WithTop ι`. -/ def factor (i : WithTop ι) : Type _ := i.recTopCoe PUnit (X ·) variable [Algebra.IsSeparable F E] -- slow (typeclass inference reasonable, type checking takes ~4s) instance (i : ι) : Algebra.IsSeparable (E⟮<i⟯) (E⟮<i⟯⟮b (φ i)⟯) := have := Algebra.isSeparable_tower_top_of_isSeparable F (E⟮<i⟯) E have : IsScalarTower (E⟮<i⟯) (E⟮<i⟯⟮b (φ i)⟯) E := .of_algebraMap_eq' rfl Algebra.isSeparable_tower_bot_of_isSeparable _ _ E open Field in theorem two_le_deg (i : ι) : 2 ≤ #(X i) := by rw [← Nat.cast_ofNat, ← toNat_le_iff_le_of_lt_aleph0 (nat_lt_aleph0 _) (deg_lt_aleph0 i), toNat_natCast, ← Nat.card, ← finSepDegree, finSepDegree_eq_finrank_of_isSeparable, Nat.succ_le] by_contra! obtain ⟨x, hx⟩ := finrank_adjoin_simple_eq_one_iff.mp (this.antisymm Module.finrank_pos) refine (isLeast_leastExt i).1 (hx ▸ ?_) exact x.2 end local notation "E⟮<"i"⟯" => filtration i variable (F E) in /-- The functor on `WithTop ι` given by embeddings of `E⟮<i⟯` into `Ē` -/ def embFunctor ⦃i j : WithTop ι⦄ (h : i ≤ j) (f : E⟮<j⟯ →ₐ[F] Ē) : E⟮<i⟯ →ₐ[F] Ē := f.comp (Subalgebra.inclusion <| filtration.monotone h) instance : InverseSystem (embFunctor F E) where map_self _ _ := rfl map_map _ _ _ _ _ _ := rfl private local instance (i : ι) : Decidable (succ i = i) := .isFalse (lt_succ i).ne' /-- Extend `succEquiv` from `ι` to `WithTop ι`. -/ def equivSucc (i : WithTop ι) : (E⟮<i⁺⟯ →ₐ[F] Ē) ≃ (E⟮<i⟯ →ₐ[F] Ē) × factor i := i.recTopCoe (((equivOfEq <| by rw [succ_top]).arrowCongr .refl).trans <| .symm <| .prodPUnit _) (succEquiv ·) theorem equivSucc_coherence (i f) : (equivSucc i f).1 = embFunctor F E (le_succ i) f := by cases i; exacts [rfl, succEquiv_coherence _ f] section Lim variable {i : WithTop (Module.rank F E).ord.toType} -- WithTop ι doesn't work theorem directed_filtration : Directed (· ≤ ·) fun j : Iio i ↦ filtration j.1 := (filtration.monotone.comp <| Subtype.mono_coe _).directed_le variable (hi : IsSuccPrelimit i) include hi open WithTop in theorem iSup_filtration : ⨆ j : Iio i, filtration j = filtration i := by cases i · rw [← range_coe, iSup_range']; exact iSup_adjoin_eq_top refine (iSup_le fun j ↦ filtration.monotone (mem_Iio.1 j.2).le).antisymm (adjoin_le_iff.2 ?_) rintro _ ⟨j, hj, rfl⟩ refine le_iSup (α := IntermediateField F E) _ ⟨j⁺, ?_⟩ (subset_adjoin F _ ?_) exacts [⟨j, lt_succ j, rfl⟩, hi.succ_lt (coe_lt_coe.mpr hj)] open WithTop lemma eq_bot_of_not_nonempty (hi : ¬ Nonempty (Iio i)) : filtration i = ⊥ := by cases i · have := mk_ne_zero_iff.mp (rank_pos.trans_eq (mk_ord_toType <| Module.rank F E).symm).ne' rw [← range_coe] at hi; exact (hi inferInstance).elim · exact bot_unique <| adjoin_le_iff.mpr fun _ ⟨j, hj, _⟩ ↦ (hi ⟨j, coe_lt_coe.mpr hj⟩).elim open Classical in /-- If `i` is a limit, the type of embeddings of `E⟮<i⟯` into `Ē` is the limit of the types of embeddings of `E⟮<j⟯` for `j < i`. -/ def equivLim : (E⟮<i⟯ →ₐ[F] Ē) ≃ limit (embFunctor F E) i where toFun f := ⟨fun j ↦ embFunctor _ _ (id j.2 : j < i).le f, fun _ _ _ ↦ rfl⟩ invFun f := if h : Nonempty (Iio i) then Subalgebra.iSupLift _ directed_filtration f.1 (fun _ _ h ↦ (f.2 <| filtration.map_rel_iff.mp h).symm) _ <| by rw [← iSup_filtration hi, toSubalgebra_iSup_of_directed directed_filtration] else (Algebra.ofId F Ē).comp ((equivOfEq (eq_bot_of_not_nonempty hi h)).trans <| botEquiv F E) left_inv f := by split_ifs with h · ext ⟨x, hx⟩ rw [← iSup_filtration hi, mem_toSubalgebra, ← SetLike.mem_coe, coe_iSup_of_directed directed_filtration, mem_iUnion] at hx rw [Subalgebra.iSupLift_of_mem _ _ (by exact hx.choose_spec)]; rfl · apply AlgHom.ext rw [((equivOfEq (eq_bot_of_not_nonempty hi h)).trans <| botEquiv F E).forall_congr_left] simp right_inv f := Subtype.ext <| funext fun j ↦ by have := Nonempty.intro j simp_rw [dif_pos this] apply Subalgebra.iSupLift_comp_inclusion theorem equivLim_coherence (x l) : (equivLim hi x).1 l = embFunctor F E (mem_Iio.mp l.2).le x := rfl end Lim /-- A bijection between `E →ₐ[F] Ē` and the product of `E⟮<i⁺⟯ →ₐ[E⟮<i⟯] Ē` over all `i : ι`. -/ def embEquivPi : Field.Emb F E ≃ ∀ i : ι, factor (F := F) (E := E) i := let e := globalEquiv (fun i _ ↦ ⟨_, equivSucc_coherence i⟩) (fun _ hi ↦ ⟨equivLim hi, fun _ _ ↦ rfl⟩) ⊤ (topEquiv.arrowCongr .refl).symm.trans <| e.trans <| .trans (.piCongrSet WithTop.range_coe.symm) <| .symm <| .piCongr (.ofInjective _ WithTop.coe_injective) fun _ ↦ .refl _ end Algebraic end end Cardinal variable {F E} theorem cardinal_eq_two_pow_rank [Algebra.IsSeparable F E] (rank_inf : ℵ₀ ≤ Module.rank F E) : #(Field.Emb F E) = 2 ^ Module.rank F E := by haveI := Fact.mk rank_inf rw [Emb.Cardinal.embEquivPi.cardinal_eq, mk_pi] apply le_antisymm · rw [← power_eq_two_power rank_inf (nat_lt_aleph0 2).le rank_inf] conv_rhs => rw [← mk_ord_toType (Module.rank F E), ← prod_const'] exact prod_le_prod _ _ fun i ↦ (Emb.Cardinal.deg_lt_aleph0 _).le · conv_lhs => rw [← mk_ord_toType (Module.rank F E), ← prod_const'] exact prod_le_prod _ _ Emb.Cardinal.two_le_deg theorem cardinal_eq_of_isSeparable [Algebra.IsSeparable F E] : #(Field.Emb F E) = (fun c ↦ if ℵ₀ ≤ c then 2 ^ c else c) (Module.rank F E) := by dsimp only; split_ifs with h · exact cardinal_eq_two_pow_rank h rw [not_le, ← IsNoetherian.iff_rank_lt_aleph0] at h rw [← Module.finrank_eq_rank, ← toNat_eq_iff Module.finrank_pos.ne', ← Nat.card, ← finSepDegree, finSepDegree_eq_finrank_of_isSeparable] theorem cardinal_eq_two_pow_sepDegree [Algebra.IsAlgebraic F E] (rank_inf : ℵ₀ ≤ sepDegree F E) : #(Field.Emb F E) = 2 ^ sepDegree F E := by rw [← cardinal_separableClosure, cardinal_eq_two_pow_rank rank_inf] rfl theorem cardinal_eq [Algebra.IsAlgebraic F E] : #(Field.Emb F E) = (fun c ↦ if ℵ₀ ≤ c then 2 ^ c else c) (sepDegree F E) := by rw [← cardinal_separableClosure, cardinal_eq_of_isSeparable]; rfl end Field.Emb
.lake/packages/mathlib/Mathlib/FieldTheory/PrimitiveElement.lean
import Mathlib.Data.Fintype.Pigeonhole import Mathlib.FieldTheory.IsAlgClosed.Basic import Mathlib.FieldTheory.SplittingField.Construction import Mathlib.RingTheory.IntegralDomain import Mathlib.RingTheory.Polynomial.UniqueFactorization /-! # Primitive Element Theorem In this file we prove the primitive element theorem. ## Main results - `Field.exists_primitive_element`: a finite separable extension `E / F` has a primitive element, i.e. there is an `α : E` such that `F⟮α⟯ = (⊤ : Subalgebra F E)`. - `Field.exists_primitive_element_iff_finite_intermediateField`: a finite extension `E / F` has a primitive element if and only if there exist only finitely many intermediate fields between `E` and `F`. ## Implementation notes In declaration names, `primitive_element` abbreviates `adjoin_simple_eq_top`: it stands for the statement `F⟮α⟯ = (⊤ : Subalgebra F E)`. We did not add an extra declaration `IsPrimitiveElement F α := F⟮α⟯ = (⊤ : Subalgebra F E)` because this requires more unfolding without much obvious benefit. ## Tags primitive element, separable field extension, separable extension, intermediate field, adjoin, exists_adjoin_simple_eq_top -/ noncomputable section open Module Polynomial IntermediateField namespace Field section PrimitiveElementFinite variable (F : Type*) [Field F] (E : Type*) [Field E] [Algebra F E] /-! ### Primitive element theorem for finite fields -/ /-- **Primitive element theorem** assuming E is finite. -/ @[stacks 09HY "second part"] theorem exists_primitive_element_of_finite_top [Finite E] : ∃ α : E, F⟮α⟯ = ⊤ := by obtain ⟨α, hα⟩ := @IsCyclic.exists_generator Eˣ _ _ use α rw [eq_top_iff] rintro x - by_cases hx : x = 0 · rw [hx] exact F⟮α.val⟯.zero_mem · obtain ⟨n, hn⟩ := Set.mem_range.mp (hα (Units.mk0 x hx)) rw [show x = α ^ n by norm_cast; rw [hn, Units.val_mk0]] exact zpow_mem (mem_adjoin_simple_self F (E := E) ↑α) n /-- Primitive element theorem for finite-dimensional extension of a finite field. -/ theorem exists_primitive_element_of_finite_bot [Finite F] [FiniteDimensional F E] : ∃ α : E, F⟮α⟯ = ⊤ := haveI : Finite E := Module.finite_of_finite F exists_primitive_element_of_finite_top F E end PrimitiveElementFinite /-! ### Primitive element theorem for infinite fields -/ section PrimitiveElementInf variable {F : Type*} [Field F] [Infinite F] {E : Type*} [Field E] (ϕ : F →+* E) (α β : E) theorem primitive_element_inf_aux_exists_c (f g : F[X]) : ∃ c : F, ∀ α' ∈ (f.map ϕ).roots, ∀ β' ∈ (g.map ϕ).roots, -(α' - α) / (β' - β) ≠ ϕ c := by classical let sf := (f.map ϕ).roots let sg := (g.map ϕ).roots classical let s := (sf.bind fun α' => sg.map fun β' => -(α' - α) / (β' - β)).toFinset let s' := s.preimage ϕ fun x _ y _ h => ϕ.injective h obtain ⟨c, hc⟩ := Infinite.exists_notMem_finset s' simp_rw [s', s, Finset.mem_preimage, Multiset.mem_toFinset, Multiset.mem_bind, Multiset.mem_map] at hc push_neg at hc exact ⟨c, hc⟩ variable (F) variable [Algebra F E] /-- This is the heart of the proof of the primitive element theorem. It shows that if `F` is infinite and `α` and `β` are separable over `F` then `F⟮α, β⟯` is generated by a single element. -/ theorem primitive_element_inf_aux [Algebra.IsSeparable F E] : ∃ γ : E, F⟮α, β⟯ = F⟮γ⟯ := by classical have hα := Algebra.IsSeparable.isIntegral F α have hβ := Algebra.IsSeparable.isIntegral F β let f := minpoly F α let g := minpoly F β let ιFE := algebraMap F E let ιEE' := algebraMap E (SplittingField (g.map ιFE)) obtain ⟨c, hc⟩ := primitive_element_inf_aux_exists_c (ιEE'.comp ιFE) (ιEE' α) (ιEE' β) f g let γ := α + c • β suffices β_in_Fγ : β ∈ F⟮γ⟯ by use γ apply le_antisymm · rw [adjoin_le_iff] have α_in_Fγ : α ∈ F⟮γ⟯ := by rw [← add_sub_cancel_right α (c • β)] exact F⟮γ⟯.sub_mem (mem_adjoin_simple_self F γ) (F⟮γ⟯.toSubalgebra.smul_mem β_in_Fγ c) rintro x (rfl | rfl) <;> assumption · rw [adjoin_simple_le_iff] have α_in_Fαβ : α ∈ F⟮α, β⟯ := subset_adjoin F {α, β} (Set.mem_insert α {β}) have β_in_Fαβ : β ∈ F⟮α, β⟯ := subset_adjoin F {α, β} (Set.mem_insert_of_mem α rfl) exact F⟮α, β⟯.add_mem α_in_Fαβ (F⟮α, β⟯.smul_mem β_in_Fαβ) classical let p := EuclideanDomain.gcd ((f.map (algebraMap F F⟮γ⟯)).comp (C (AdjoinSimple.gen F γ) - (C ↑c : F⟮γ⟯[X]) * X)) (g.map (algebraMap F F⟮γ⟯)) let h := EuclideanDomain.gcd ((f.map ιFE).comp (C γ - C (ιFE c) * X)) (g.map ιFE) have map_g_ne_zero : g.map ιFE ≠ 0 := map_ne_zero (minpoly.ne_zero hβ) have h_ne_zero : h ≠ 0 := mt EuclideanDomain.gcd_eq_zero_iff.mp (not_and.mpr fun _ => map_g_ne_zero) suffices p_linear : p.map (algebraMap F⟮γ⟯ E) = C h.leadingCoeff * (X - C β) by have finale : β = algebraMap F⟮γ⟯ E (-p.coeff 0 / p.coeff 1) := by simp [map_div₀, RingHom.map_neg, ← coeff_map, ← coeff_map, p_linear, mul_sub, coeff_C, mul_div_cancel_left₀ β (mt leadingCoeff_eq_zero.mp h_ne_zero)] rw [finale] exact Subtype.mem (-p.coeff 0 / p.coeff 1) have h_sep : h.Separable := separable_gcd_right _ (.map (Algebra.IsSeparable.isSeparable F β)) have h_root : h.eval β = 0 := by apply eval_gcd_eq_zero · rw [eval_comp, eval_sub, eval_mul, eval_C, eval_C, eval_X, eval_map, ← aeval_def, ← Algebra.smul_def, add_sub_cancel_right, minpoly.aeval] · rw [eval_map, ← aeval_def, minpoly.aeval] have h_splits : Splits ιEE' h := splits_of_splits_gcd_right ιEE' map_g_ne_zero (SplittingField.splits _) have h_roots : ∀ x ∈ (h.map ιEE').roots, x = ιEE' β := by intro x hx rw [mem_roots_map h_ne_zero] at hx specialize hc (ιEE' γ - ιEE' (ιFE c) * x) (by have f_root := root_left_of_root_gcd hx rw [eval₂_comp, eval₂_sub, eval₂_mul, eval₂_C, eval₂_C, eval₂_X, eval₂_map] at f_root exact (mem_roots_map (minpoly.ne_zero hα)).mpr f_root) specialize hc x (by rw [mem_roots_map (minpoly.ne_zero hβ), ← eval₂_map] exact root_right_of_root_gcd hx) by_contra a apply hc apply (div_eq_iff (sub_ne_zero.mpr a)).mpr simp only [γ, Algebra.smul_def, RingHom.map_add, RingHom.map_mul, RingHom.comp_apply] ring rw [← eq_X_sub_C_of_separable_of_root_eq h_sep h_root h_splits h_roots] trans EuclideanDomain.gcd (?_ : E[X]) (?_ : E[X]) · dsimp only [γ] convert (gcd_map (algebraMap F⟮γ⟯ E)).symm · simp only [map_comp, Polynomial.map_map, ← IsScalarTower.algebraMap_eq, Polynomial.map_sub, map_C, AdjoinSimple.algebraMap_gen, Polynomial.map_mul, map_X] congr -- If `F` is infinite and `E/F` has only finitely many intermediate fields, then for any -- `α` and `β` in `E`, `F⟮α, β⟯` is generated by a single element. -- Marked as private since it's a special case of -- `exists_primitive_element_of_finite_intermediateField`. private theorem primitive_element_inf_aux_of_finite_intermediateField [Finite (IntermediateField F E)] : ∃ γ : E, F⟮α, β⟯ = F⟮γ⟯ := by let f : F → IntermediateField F E := fun x ↦ F⟮α + x • β⟯ obtain ⟨x, y, hneq, heq⟩ := Finite.exists_ne_map_eq_of_infinite f use α + x • β apply le_antisymm · rw [adjoin_le_iff] have αxβ_in_K : α + x • β ∈ F⟮α + x • β⟯ := mem_adjoin_simple_self F _ have αyβ_in_K : α + y • β ∈ F⟮α + y • β⟯ := mem_adjoin_simple_self F _ dsimp [f] at * simp only [← heq] at αyβ_in_K have β_in_K := sub_mem αxβ_in_K αyβ_in_K rw [show (α + x • β) - (α + y • β) = (x - y) • β by rw [sub_smul]; abel1] at β_in_K replace β_in_K := smul_mem _ β_in_K (x := (x - y)⁻¹) rw [smul_smul, inv_mul_eq_div, div_self (sub_ne_zero.2 hneq), one_smul] at β_in_K have α_in_K : α ∈ F⟮α + x • β⟯ := by convert ← sub_mem αxβ_in_K (smul_mem _ β_in_K) apply add_sub_cancel_right rintro x (rfl | rfl) <;> assumption · rw [adjoin_simple_le_iff] have α_in_Fαβ : α ∈ F⟮α, β⟯ := subset_adjoin F {α, β} (Set.mem_insert α {β}) have β_in_Fαβ : β ∈ F⟮α, β⟯ := subset_adjoin F {α, β} (Set.mem_insert_of_mem α rfl) exact F⟮α, β⟯.add_mem α_in_Fαβ (F⟮α, β⟯.smul_mem β_in_Fαβ) end PrimitiveElementInf variable (F E : Type*) [Field F] [Field E] variable [Algebra F E] section SeparableAssumption variable [FiniteDimensional F E] [Algebra.IsSeparable F E] /-- **Primitive element theorem**: a finite separable field extension `E` of `F` has a primitive element, i.e. there is an `α ∈ E` such that `F⟮α⟯ = (⊤ : Subalgebra F E)`. -/ @[stacks 030N "The moreover part"] theorem exists_primitive_element : ∃ α : E, F⟮α⟯ = ⊤ := by rcases isEmpty_or_nonempty (Fintype F) with (F_inf | ⟨⟨F_finite⟩⟩) · let P : IntermediateField F E → Prop := fun K => ∃ α : E, F⟮α⟯ = K have base : P ⊥ := ⟨0, adjoin_zero⟩ have ih : ∀ (K : IntermediateField F E) (x : E), P K → P (K⟮x⟯.restrictScalars F) := by intro K β hK obtain ⟨α, hK⟩ := hK rw [← hK, adjoin_simple_adjoin_simple] haveI : Infinite F := isEmpty_fintype.mp F_inf obtain ⟨γ, hγ⟩ := primitive_element_inf_aux F α β exact ⟨γ, hγ.symm⟩ exact induction_on_adjoin P base ih ⊤ · exact exists_primitive_element_of_finite_bot F E /-- Alternative phrasing of primitive element theorem: a finite separable field extension has a basis `1, α, α^2, ..., α^n`. See also `exists_primitive_element`. -/ noncomputable def powerBasisOfFiniteOfSeparable : PowerBasis F E := let α := (exists_primitive_element F E).choose let pb := adjoin.powerBasis (Algebra.IsSeparable.isIntegral F α) have e : F⟮α⟯ = ⊤ := (exists_primitive_element F E).choose_spec pb.map ((IntermediateField.equivOfEq e).trans IntermediateField.topEquiv) end SeparableAssumption section FiniteIntermediateField -- TODO: show a more generalized result: [F⟮α⟯ : F⟮α ^ m⟯] = m if m > 0 and α transcendental. theorem isAlgebraic_of_adjoin_eq_adjoin {α : E} {m n : ℕ} (hneq : m ≠ n) (heq : F⟮α ^ m⟯ = F⟮α ^ n⟯) : IsAlgebraic F α := by wlog hmn : m < n · exact this F E hneq.symm heq.symm (hneq.lt_or_gt.resolve_left hmn) by_cases hm : m = 0 · rw [hm] at heq hmn simp only [pow_zero, adjoin_one] at heq obtain ⟨y, h⟩ := mem_bot.1 (heq.symm ▸ mem_adjoin_simple_self F (α ^ n)) refine ⟨X ^ n - C y, X_pow_sub_C_ne_zero hmn y, ?_⟩ simp only [map_sub, map_pow, aeval_X, aeval_C, h, sub_self] obtain ⟨r, s, h⟩ := (mem_adjoin_simple_iff F _).1 (heq ▸ mem_adjoin_simple_self F (α ^ m)) by_cases hzero : aeval (α ^ n) s = 0 · simp only [hzero, div_zero, pow_eq_zero_iff hm] at h exact h.symm ▸ isAlgebraic_zero replace hm : 0 < m := Nat.pos_of_ne_zero hm rw [eq_div_iff hzero, ← sub_eq_zero] at h replace hzero : s ≠ 0 := by rintro rfl; simp only [map_zero, not_true_eq_false] at hzero let f : F[X] := X ^ m * expand F n s - expand F n r refine ⟨f, ?_, ?_⟩ · have : f.coeff (n * s.natDegree + m) ≠ 0 := by have hn : 0 < n := by linarith only [hm, hmn] have hndvd : ¬ n ∣ n * s.natDegree + m := by rw [← Nat.dvd_add_iff_right (n.dvd_mul_right s.natDegree)] exact Nat.not_dvd_of_pos_of_lt hm hmn simp only [f, coeff_sub, coeff_X_pow_mul, s.coeff_expand_mul' hn, coeff_natDegree, coeff_expand hn r, hndvd, ite_false, sub_zero] exact leadingCoeff_ne_zero.2 hzero intro h simp only [h, coeff_zero, ne_eq, not_true_eq_false] at this · simp only [f, map_sub, map_mul, map_pow, aeval_X, expand_aeval, h] theorem isAlgebraic_of_finite_intermediateField [Finite (IntermediateField F E)] : Algebra.IsAlgebraic F E := ⟨fun α ↦ have ⟨_m, _n, hneq, heq⟩ := Finite.exists_ne_map_eq_of_infinite fun n ↦ F⟮α ^ n⟯ isAlgebraic_of_adjoin_eq_adjoin F E hneq heq⟩ theorem FiniteDimensional.of_finite_intermediateField [Finite (IntermediateField F E)] : FiniteDimensional F E := by let IF := { K : IntermediateField F E // ∃ x, K = F⟮x⟯ } have := isAlgebraic_of_finite_intermediateField F E haveI : ∀ K : IF, FiniteDimensional F K.1 := fun ⟨_, x, rfl⟩ ↦ adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral _) have hfin := finiteDimensional_iSup_of_finite (t := fun K : IF ↦ K.1) have htop : ⨆ K : IF, K.1 = ⊤ := le_top.antisymm fun x _ ↦ le_iSup (fun K : IF ↦ K.1) ⟨F⟮x⟯, x, rfl⟩ <| mem_adjoin_simple_self F x rw [htop] at hfin exact topEquiv.toLinearEquiv.finiteDimensional theorem exists_primitive_element_of_finite_intermediateField [Finite (IntermediateField F E)] (K : IntermediateField F E) : ∃ α : E, F⟮α⟯ = K := by haveI := FiniteDimensional.of_finite_intermediateField F E rcases finite_or_infinite F with (_ | _) · obtain ⟨α, h⟩ := exists_primitive_element_of_finite_bot F K exact ⟨α, by simpa only [lift_adjoin_simple, lift_top] using congr_arg lift h⟩ · apply induction_on_adjoin (fun K ↦ ∃ α : E, F⟮α⟯ = K) ⟨0, adjoin_zero⟩ rintro K β ⟨α, rfl⟩ simp_rw [adjoin_simple_adjoin_simple, eq_comm] exact primitive_element_inf_aux_of_finite_intermediateField F α β theorem FiniteDimensional.of_exists_primitive_element [Algebra.IsAlgebraic F E] (h : ∃ α : E, F⟮α⟯ = ⊤) : FiniteDimensional F E := by obtain ⟨α, hprim⟩ := h have hfin := adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral (R := F) α) rw [hprim] at hfin exact topEquiv.toLinearEquiv.finiteDimensional -- A finite simple extension has only finitely many intermediate fields theorem finite_intermediateField_of_exists_primitive_element [Algebra.IsAlgebraic F E] (h : ∃ α : E, F⟮α⟯ = ⊤) : Finite (IntermediateField F E) := by haveI := FiniteDimensional.of_exists_primitive_element F E h obtain ⟨α, hprim⟩ := h -- Let `f` be the minimal polynomial of `α ∈ E` over `F` let f : F[X] := minpoly F α let G := { g : E[X] // g.Monic ∧ g ∣ f.map (algebraMap F E) } -- Then `f` has only finitely many monic factors have hfin : Finite G := @Finite.of_fintype _ <| fintypeSubtypeMonicDvd (f.map (algebraMap F E)) <| map_ne_zero (minpoly.ne_zero_of_finite F α) -- If `K` is an intermediate field of `E/F`, let `g` be the minimal polynomial of `α` over `K` -- which is a monic factor of `f` let g : IntermediateField F E → G := fun K ↦ ⟨(minpoly K α).map (algebraMap K E), (minpoly.monic <| .of_finite K α).map _, by convert Polynomial.map_dvd (algebraMap K E) (minpoly.dvd_map_of_isScalarTower F K α) rw [Polynomial.map_map]; rfl⟩ -- The map `K ↦ g` is injective have hinj : Function.Injective g := fun K K' heq ↦ by rw [Subtype.mk.injEq] at heq apply_fun fun f : E[X] ↦ adjoin F (f.coeffs : Set E) at heq simpa only [adjoin_minpoly_coeff_of_exists_primitive_element F hprim] using heq -- Therefore there are only finitely many intermediate fields exact Finite.of_injective g hinj /-- **Steinitz theorem**: an algebraic extension `E` of `F` has a primitive element (i.e. there is an `α ∈ E` such that `F⟮α⟯ = (⊤ : Subalgebra F E)`) if and only if there exist only finitely many intermediate fields between `E` and `F`. -/ @[stacks 030N "Equivalence of (1) & (2)"] theorem exists_primitive_element_iff_finite_intermediateField : (Algebra.IsAlgebraic F E ∧ ∃ α : E, F⟮α⟯ = ⊤) ↔ Finite (IntermediateField F E) := ⟨fun ⟨_, h⟩ ↦ finite_intermediateField_of_exists_primitive_element F E h, fun _ ↦ ⟨isAlgebraic_of_finite_intermediateField F E, exists_primitive_element_of_finite_intermediateField F E _⟩⟩ end FiniteIntermediateField end Field variable (F E : Type*) [Field F] [Field E] [Algebra F E] [FiniteDimensional F E] [Algebra.IsSeparable F E] theorem AlgHom.natCard_of_splits (L : Type*) [Field L] [Algebra F L] (hL : ∀ x : E, (minpoly F x).Splits (algebraMap F L)) : Nat.card (E →ₐ[F] L) = finrank F E := (AlgHom.natCard_of_powerBasis (L := L) (Field.powerBasisOfFiniteOfSeparable F E) (Algebra.IsSeparable.isSeparable _ _) <| hL _).trans (PowerBasis.finrank _).symm @[simp] theorem AlgHom.card_of_splits (L : Type*) [Field L] [Algebra F L] (hL : ∀ x : E, (minpoly F x).Splits (algebraMap F L)) : Fintype.card (E →ₐ[F] L) = finrank F E := by rw [Fintype.card_eq_nat_card, AlgHom.natCard_of_splits F E L hL] @[simp] theorem AlgHom.card (K : Type*) [Field K] [IsAlgClosed K] [Algebra F K] : Fintype.card (E →ₐ[F] K) = finrank F E := AlgHom.card_of_splits _ _ _ (fun _ ↦ IsAlgClosed.splits_codomain _) section iff namespace Field open Module IntermediateField Polynomial Algebra Set variable (F : Type*) {E : Type*} [Field F] [Field E] [Algebra F E] [FiniteDimensional F E] theorem primitive_element_iff_minpoly_natDegree_eq (α : E) : F⟮α⟯ = ⊤ ↔ (minpoly F α).natDegree = finrank F E := by rw [← adjoin.finrank (IsIntegral.of_finite F α), ← finrank_top F E] refine ⟨fun h => ?_, fun h => eq_of_le_of_finrank_eq le_top h⟩ exact congr_arg (fun K : IntermediateField F E => finrank F K) h theorem primitive_element_iff_minpoly_degree_eq (α : E) : F⟮α⟯ = ⊤ ↔ (minpoly F α).degree = finrank F E := by rw [degree_eq_iff_natDegree_eq, primitive_element_iff_minpoly_natDegree_eq] exact minpoly.ne_zero_of_finite F α variable [Algebra.IsSeparable F E] (A : Type*) [Field A] [Algebra F A] (hA : ∀ x : E, (minpoly F x).Splits (algebraMap F A)) include hA theorem primitive_element_iff_algHom_eq_of_eval' (α : E) : F⟮α⟯ = ⊤ ↔ Function.Injective fun φ : E →ₐ[F] A ↦ φ α := by classical simp_rw [primitive_element_iff_minpoly_natDegree_eq, ← card_rootSet_eq_natDegree (K := A) (Algebra.IsSeparable.isSeparable F α) (hA _), ← toFinset_card, ← (Algebra.IsAlgebraic.of_finite F E).range_eval_eq_rootSet_minpoly_of_splits _ hA α, ← AlgHom.card_of_splits F E A hA, Fintype.card, toFinset_range, Finset.card_image_iff, Finset.coe_univ, injOn_univ] theorem primitive_element_iff_algHom_eq_of_eval (α : E) (φ : E →ₐ[F] A) : F⟮α⟯ = ⊤ ↔ ∀ ψ : E →ₐ[F] A, φ α = ψ α → φ = ψ := by refine ⟨fun h ψ hψ ↦ (Field.primitive_element_iff_algHom_eq_of_eval' F A hA α).mp h hψ, fun h ↦ eq_of_le_of_finrank_eq' le_top ?_⟩ letI : Algebra F⟮α⟯ A := (φ.comp F⟮α⟯.val).toAlgebra haveI := Algebra.isSeparable_tower_top_of_isSeparable F F⟮α⟯ E rw [IntermediateField.finrank_top, ← AlgHom.card_of_splits _ _ A, Fintype.card_eq_one_iff] · exact ⟨{ __ := φ, commutes' := fun _ ↦ rfl }, fun ψ ↦ AlgHom.restrictScalars_injective F <| Eq.symm <| h _ (ψ.commutes <| AdjoinSimple.gen F α).symm⟩ · exact fun x ↦ (IsIntegral.of_finite F x).minpoly_splits_tower_top (hA x) end Field end iff
.lake/packages/mathlib/Mathlib/FieldTheory/LinearDisjoint.lean
import Mathlib.FieldTheory.Galois.Basic import Mathlib.RingTheory.AlgebraicIndependent.RankAndCardinality import Mathlib.RingTheory.LinearDisjoint /-! # Linearly disjoint fields This file contains basics about the linearly disjoint fields. We adapt the definitions in <https://en.wikipedia.org/wiki/Linearly_disjoint>. See the file `Mathlib/LinearAlgebra/LinearDisjoint.lean` and `Mathlib/RingTheory/LinearDisjoint.lean` for details. ## Main definitions - `IntermediateField.LinearDisjoint`: an intermediate field `A` of `E / F` and an abstract field `L` between `E / F` (as a special case, two intermediate fields) are linearly disjoint over `F`, if they are linearly disjoint as subalgebras (`Subalgebra.LinearDisjoint`). ## Implementation notes The `Subalgebra.LinearDisjoint` is stated for two `Subalgebra`s. The original design of `IntermediateField.LinearDisjoint` is also stated for two `IntermediateField`s (see `IntermediateField.linearDisjoint_iff'` for the original statement). But it's probably useful if one of them can be generalized to an abstract field (see <https://github.com/leanprover-community/mathlib4/pull/9651#discussion_r1464070324>). This leads to the current design of `IntermediateField.LinearDisjoint` which is for one `IntermediateField` and one abstract field. It is not generalized to two abstract fields as this will break the dot notation. ## Main results ### Equivalent characterization of linear disjointness - `IntermediateField.LinearDisjoint.linearIndependent_left`: if `A` and `L` are linearly disjoint, then any `F`-linearly independent family on `A` remains linearly independent over `L`. - `IntermediateField.LinearDisjoint.of_basis_left`: conversely, if there exists an `F`-basis of `A` which remains linearly independent over `L`, then `A` and `L` are linearly disjoint. - `IntermediateField.LinearDisjoint.linearIndependent_right`: `IntermediateField.LinearDisjoint.linearIndependent_right'`: if `A` and `L` are linearly disjoint, then any `F`-linearly independent family on `L` remains linearly independent over `A`. - `IntermediateField.LinearDisjoint.of_basis_right`: `IntermediateField.LinearDisjoint.of_basis_right'`: conversely, if there exists an `F`-basis of `L` which remains linearly independent over `A`, then `A` and `L` are linearly disjoint. - `IntermediateField.LinearDisjoint.linearIndependent_mul`: `IntermediateField.LinearDisjoint.linearIndependent_mul'`: if `A` and `L` are linearly disjoint, then for any family of `F`-linearly independent elements `{ a_i }` of `A`, and any family of `F`-linearly independent elements `{ b_j }` of `L`, the family `{ a_i * b_j }` in `S` is also `F`-linearly independent. - `IntermediateField.LinearDisjoint.of_basis_mul`: `IntermediateField.LinearDisjoint.of_basis_mul'`: conversely, if `{ a_i }` is an `F`-basis of `A`, if `{ b_j }` is an `F`-basis of `L`, such that the family `{ a_i * b_j }` in `E` is `F`-linearly independent, then `A` and `L` are linearly disjoint. ### Equivalent characterization by `IsDomain` or `IsField` of tensor product The following results are related to the equivalent characterizations in <https://mathoverflow.net/questions/8324>. - `IntermediateField.LinearDisjoint.isDomain'`, `IntermediateField.LinearDisjoint.exists_field_of_isDomain`: if `A` and `B` are field extensions of `F`, then `A ⊗[F] B` is a domain if and only if there exists a field extension of `F` that `A` and `B` embed into with linearly disjoint images. - `IntermediateField.LinearDisjoint.isField_of_forall`, `IntermediateField.LinearDisjoint.of_isField'`: if `A` and `B` are field extensions of `F`, then `A ⊗[F] B` is a field if and only if for any field extension of `F` that `A` and `B` embed into, their images are linearly disjoint. - `Algebra.TensorProduct.isField_of_isAlgebraic`: if `E` and `K` are field extensions of `F`, one of them is algebraic, and `E ⊗[F] K` is a domain, then `E ⊗[F] K` is also a field. See `Algebra.TensorProduct.isAlgebraic_of_isField` for its converse (in an earlier file). - `IntermediateField.LinearDisjoint.isField_of_isAlgebraic`, `IntermediateField.LinearDisjoint.isField_of_isAlgebraic'`: if `A` and `B` are field extensions of `F`, one of them is algebraic, such that they are linearly disjoint (more generally, if there exists a field extension of `F` that they embed into with linearly disjoint images), then `A ⊗[F] B` is a field. ### Other main results - `IntermediateField.LinearDisjoint.symm`, `IntermediateField.linearDisjoint_comm`: linear disjointness is symmetric. - `IntermediateField.LinearDisjoint.map`: linear disjointness is preserved by algebra homomorphism. - `IntermediateField.LinearDisjoint.rank_sup`, `IntermediateField.LinearDisjoint.finrank_sup`: if `A` and `B` are linearly disjoint, then the rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`. - `IntermediateField.LinearDisjoint.of_finrank_sup`: conversely, if `A` and `B` are finite extensions, such that rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`, then `A` and `B` are linearly disjoint. - `IntermediateField.LinearDisjoint.of_finrank_coprime`: if the rank of `A` and `B` are coprime, then `A` and `B` are linearly disjoint. - `IntermediateField.LinearDisjoint.inf_eq_bot`: if `A` and `B` are linearly disjoint, then they are disjoint. - `IntermediateField.LinearDisjoint.algEquiv_of_isAlgebraic`: linear disjointness is preserved by isomorphisms, provided that one of the field is algebraic. ## Tags linearly disjoint, linearly independent, tensor product -/ open scoped TensorProduct open Module IntermediateField noncomputable section universe u v w namespace IntermediateField variable {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] variable (A B : IntermediateField F E) variable (L : Type w) [Field L] [Algebra F L] [Algebra L E] [IsScalarTower F L E] /-- If `A` is an intermediate field of `E / F`, and `E / L / F` is a field extension tower, then `A` and `L` are linearly disjoint, if they are linearly disjoint as subalgebras of `E` (`Subalgebra.LinearDisjoint`). -/ protected abbrev LinearDisjoint : Prop := A.toSubalgebra.LinearDisjoint (IsScalarTower.toAlgHom F L E).range theorem linearDisjoint_iff : A.LinearDisjoint L ↔ A.toSubalgebra.LinearDisjoint (IsScalarTower.toAlgHom F L E).range := Iff.rfl variable {A B L} /-- Two intermediate fields are linearly disjoint if and only if they are linearly disjoint as subalgebras. -/ theorem linearDisjoint_iff' : A.LinearDisjoint B ↔ A.toSubalgebra.LinearDisjoint B.toSubalgebra := by rw [linearDisjoint_iff] congr! ext; simp /-- Linear disjointness is symmetric. -/ theorem LinearDisjoint.symm (H : A.LinearDisjoint B) : B.LinearDisjoint A := linearDisjoint_iff'.2 (linearDisjoint_iff'.1 H).symm /-- Linear disjointness is symmetric. -/ theorem linearDisjoint_comm : A.LinearDisjoint B ↔ B.LinearDisjoint A := ⟨LinearDisjoint.symm, LinearDisjoint.symm⟩ section variable {L' : Type*} [Field L'] [Algebra F L'] [Algebra L' E] [IsScalarTower F L' E] /-- Linear disjointness is symmetric. -/ theorem LinearDisjoint.symm' (H : (IsScalarTower.toAlgHom F L E).fieldRange.LinearDisjoint L') : (IsScalarTower.toAlgHom F L' E).fieldRange.LinearDisjoint L := Subalgebra.LinearDisjoint.symm H /-- Linear disjointness is symmetric. -/ theorem linearDisjoint_comm' : (IsScalarTower.toAlgHom F L E).fieldRange.LinearDisjoint L' ↔ (IsScalarTower.toAlgHom F L' E).fieldRange.LinearDisjoint L := ⟨LinearDisjoint.symm', LinearDisjoint.symm'⟩ end namespace LinearDisjoint /-- Linear disjointness of intermediate fields is preserved by algebra homomorphisms. -/ theorem map (H : A.LinearDisjoint B) {K : Type*} [Field K] [Algebra F K] (f : E →ₐ[F] K) : (A.map f).LinearDisjoint (B.map f) := linearDisjoint_iff'.2 ((linearDisjoint_iff'.1 H).map f f.injective) /-- Linear disjointness of an intermediate field with a tower of field embeddings is preserved by algebra homomorphisms. -/ theorem map' (H : A.LinearDisjoint L) (K : Type*) [Field K] [Algebra F K] [Algebra L K] [IsScalarTower F L K] [Algebra E K] [IsScalarTower F E K] [IsScalarTower L E K] : (A.map (IsScalarTower.toAlgHom F E K)).LinearDisjoint L := by rw [linearDisjoint_iff] at H ⊢ have := H.map (IsScalarTower.toAlgHom F E K) (RingHom.injective _) rw [← AlgHom.range_comp] at this convert this ext; exact IsScalarTower.algebraMap_apply L E K _ /-- Linear disjointness is preserved by algebra homomorphism. -/ theorem map'' {L' : Type*} [Field L'] [Algebra F L'] [Algebra L' E] [IsScalarTower F L' E] (H : (IsScalarTower.toAlgHom F L E).fieldRange.LinearDisjoint L') (K : Type*) [Field K] [Algebra F K] [Algebra L K] [IsScalarTower F L K] [Algebra L' K] [IsScalarTower F L' K] [Algebra E K] [IsScalarTower F E K] [IsScalarTower L E K] [IsScalarTower L' E K] : (IsScalarTower.toAlgHom F L K).fieldRange.LinearDisjoint L' := by rw [linearDisjoint_iff] at H ⊢ have := H.map (IsScalarTower.toAlgHom F E K) (RingHom.injective _) simp_rw [AlgHom.fieldRange_toSubalgebra, ← AlgHom.range_comp] at this rw [AlgHom.fieldRange_toSubalgebra] convert this <;> (ext; exact IsScalarTower.algebraMap_apply _ E K _) variable (A) in theorem self_right : A.LinearDisjoint F := Subalgebra.LinearDisjoint.bot_right _ variable (A) in theorem bot_right : A.LinearDisjoint (⊥ : IntermediateField F E) := linearDisjoint_iff'.2 (Subalgebra.LinearDisjoint.bot_right _) variable (F E L) in theorem bot_left : (⊥ : IntermediateField F E).LinearDisjoint L := Subalgebra.LinearDisjoint.bot_left _ /-- If `A` and `L` are linearly disjoint, then any `F`-linearly independent family on `A` remains linearly independent over `L`. -/ theorem linearIndependent_left (H : A.LinearDisjoint L) {ι : Type*} {a : ι → A} (ha : LinearIndependent F a) : LinearIndependent L (A.val ∘ a) := (Subalgebra.LinearDisjoint.linearIndependent_left_of_flat H ha).map_of_injective_injective (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)) (AddMonoidHom.id E) (by simp) (by simp) (fun _ _ ↦ by simp_rw [Algebra.smul_def]; rfl) /-- If there exists an `F`-basis of `A` which remains linearly independent over `L`, then `A` and `L` are linearly disjoint. -/ theorem of_basis_left {ι : Type*} (a : Basis ι F A) (H : LinearIndependent L (A.val ∘ a)) : A.LinearDisjoint L := Subalgebra.LinearDisjoint.of_basis_left _ _ a <| H.map_of_surjective_injective (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)) (AddMonoidHom.id E) (AlgEquiv.surjective _) (by simp) (fun _ _ ↦ by simp_rw [Algebra.smul_def]; rfl) /-- If `A` and `B` are linearly disjoint, then any `F`-linearly independent family on `B` remains linearly independent over `A`. -/ theorem linearIndependent_right (H : A.LinearDisjoint B) {ι : Type*} {b : ι → B} (hb : LinearIndependent F b) : LinearIndependent A (B.val ∘ b) := (linearDisjoint_iff'.1 H).linearIndependent_right_of_flat hb /-- If `A` and `B` are linearly disjoint and such that `A.toSubalgebra ⊔ B.toSubalgebra = ⊤`, then any `F`-basis of `B` is also an `A`-basis of `E`. Note that the condition `A.toSubalgebra ⊔ B.toSubalgebra = ⊤` is equivalent to `A ⊔ B = ⊤` in many cases, see `IntermediateField.sup_toSubalgebra_of_isAlgebraic_right` and similar results. -/ noncomputable def basisOfBasisRight (H : A.LinearDisjoint B) (H' : A.toSubalgebra ⊔ B.toSubalgebra = ⊤) {ι : Type*} (b : Basis ι F B) : Basis ι A E := (linearDisjoint_iff'.mp H).basisOfBasisRight H' b @[simp] theorem basisOfBasisRight_apply (H : A.LinearDisjoint B) (H' : A.toSubalgebra ⊔ B.toSubalgebra = ⊤) {ι : Type*} (b : Basis ι F B) (i : ι) : H.basisOfBasisRight H' b i = algebraMap B E (b i) := (linearDisjoint_iff'.mp H).algebraMap_basisOfBasisRight_apply H' b i theorem algebraMap_basisOfBasisRight_repr_apply (H : A.LinearDisjoint B) (H' : A.toSubalgebra ⊔ B.toSubalgebra = ⊤) {ι : Type*} (b : Basis ι F B) (x : B) (i : ι) : algebraMap A E ((H.basisOfBasisRight H' b).repr x i) = algebraMap F E (b.repr x i) := (linearDisjoint_iff'.mp H).algebraMap_basisOfBasisRight_repr_apply H' b x i /-- If `A` and `B` are linearly disjoint and such that `A.toSubalgebra ⊔ B.toSubalgebra = ⊤`, then any `F`-basis of `A` is also a `B`-basis of `E`. Note that the condition `A.toSubalgebra ⊔ B.toSubalgebra = ⊤` is equivalent to `A ⊔ B = ⊤` in many cases, see `IntermediateField.sup_toSubalgebra_of_isAlgebraic_right` and similar results. -/ noncomputable def basisOfBasisLeft (H : A.LinearDisjoint B) (H' : A.toSubalgebra ⊔ B.toSubalgebra = ⊤) {ι : Type*} (b : Basis ι F A) : Basis ι B E := (linearDisjoint_iff'.mp H).basisOfBasisLeft H' b @[simp] theorem basisOfBasisLeft_apply (H : A.LinearDisjoint B) (H' : A.toSubalgebra ⊔ B.toSubalgebra = ⊤) {ι : Type*} (b : Basis ι F A) (i : ι) : H.basisOfBasisLeft H' b i = algebraMap A E (b i) := (linearDisjoint_iff'.mp H).basisOfBasisLeft_apply H' b i theorem basisOfBasisLeft_repr_apply (H : A.LinearDisjoint B) (H' : A.toSubalgebra ⊔ B.toSubalgebra = ⊤) {ι : Type*} (b : Basis ι F A) (x : A) (i : ι) : algebraMap B E ((H.basisOfBasisLeft H' b).repr x i) = algebraMap F E (b.repr x i) := (linearDisjoint_iff'.mp H).basisOfBasisLeft_repr_apply H' b x i /-- If there exists an `F`-basis of `B` which remains linearly independent over `A`, then `A` and `B` are linearly disjoint. -/ theorem of_basis_right {ι : Type*} (b : Basis ι F B) (H : LinearIndependent A (B.val ∘ b)) : A.LinearDisjoint B := linearDisjoint_iff'.2 (.of_basis_right _ _ b H) /-- If `A` and `L` are linearly disjoint, then any `F`-linearly independent family on `L` remains linearly independent over `A`. -/ theorem linearIndependent_right' (H : A.LinearDisjoint L) {ι : Type*} {b : ι → L} (hb : LinearIndependent F b) : LinearIndependent A (algebraMap L E ∘ b) := by apply Subalgebra.LinearDisjoint.linearIndependent_right_of_flat H <| hb.map' _ (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)).toLinearEquiv.ker /-- If there exists an `F`-basis of `L` which remains linearly independent over `A`, then `A` and `L` are linearly disjoint. -/ theorem of_basis_right' {ι : Type*} (b : Basis ι F L) (H : LinearIndependent A (algebraMap L E ∘ b)) : A.LinearDisjoint L := Subalgebra.LinearDisjoint.of_basis_right _ _ (b.map (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)).toLinearEquiv) H /-- If `A` and `B` are linearly disjoint, then for any `F`-linearly independent families `{ u_i }`, `{ v_j }` of `A`, `B`, the products `{ u_i * v_j }` are linearly independent over `F`. -/ theorem linearIndependent_mul (H : A.LinearDisjoint B) {κ ι : Type*} {a : κ → A} {b : ι → B} (ha : LinearIndependent F a) (hb : LinearIndependent F b) : LinearIndependent F fun (i : κ × ι) ↦ (a i.1).1 * (b i.2).1 := (linearDisjoint_iff'.1 H).linearIndependent_mul_of_flat_left ha hb /-- If `A` and `L` are linearly disjoint, then for any `F`-linearly independent families `{ u_i }`, `{ v_j }` of `A`, `L`, the products `{ u_i * v_j }` are linearly independent over `F`. -/ theorem linearIndependent_mul' (H : A.LinearDisjoint L) {κ ι : Type*} {a : κ → A} {b : ι → L} (ha : LinearIndependent F a) (hb : LinearIndependent F b) : LinearIndependent F fun (i : κ × ι) ↦ (a i.1).1 * algebraMap L E (b i.2) := by apply Subalgebra.LinearDisjoint.linearIndependent_mul_of_flat_left H ha <| hb.map' _ (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)).toLinearEquiv.ker /-- If there are `F`-bases `{ u_i }`, `{ v_j }` of `A`, `B`, such that the products `{ u_i * v_j }` are linearly independent over `F`, then `A` and `B` are linearly disjoint. -/ theorem of_basis_mul {κ ι : Type*} (a : Basis κ F A) (b : Basis ι F B) (H : LinearIndependent F fun (i : κ × ι) ↦ (a i.1).1 * (b i.2).1) : A.LinearDisjoint B := linearDisjoint_iff'.2 (.of_basis_mul _ _ a b H) /-- If there are `F`-bases `{ u_i }`, `{ v_j }` of `A`, `L`, such that the products `{ u_i * v_j }` are linearly independent over `F`, then `A` and `L` are linearly disjoint. -/ theorem of_basis_mul' {κ ι : Type*} (a : Basis κ F A) (b : Basis ι F L) (H : LinearIndependent F fun (i : κ × ι) ↦ (a i.1).1 * algebraMap L E (b i.2)) : A.LinearDisjoint L := Subalgebra.LinearDisjoint.of_basis_mul _ _ a (b.map (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)).toLinearEquiv) H theorem of_le_left {A' : IntermediateField F E} (H : A.LinearDisjoint L) (h : A' ≤ A) : A'.LinearDisjoint L := Subalgebra.LinearDisjoint.of_le_left_of_flat H h theorem of_le_right {B' : IntermediateField F E} (H : A.LinearDisjoint B) (h : B' ≤ B) : A.LinearDisjoint B' := linearDisjoint_iff'.2 ((linearDisjoint_iff'.1 H).of_le_right_of_flat h) /-- Similar to `IntermediateField.LinearDisjoint.of_le_right` but this is for abstract fields. -/ theorem of_le_right' (H : A.LinearDisjoint L) (L' : Type*) [Field L'] [Algebra F L'] [Algebra L' L] [IsScalarTower F L' L] [Algebra L' E] [IsScalarTower F L' E] [IsScalarTower L' L E] : A.LinearDisjoint L' := by refine Subalgebra.LinearDisjoint.of_le_right_of_flat H ?_ convert AlgHom.range_comp_le_range (IsScalarTower.toAlgHom F L' L) (IsScalarTower.toAlgHom F L E) ext; exact IsScalarTower.algebraMap_apply L' L E _ /-- If `A` and `B` are linearly disjoint, `A'` and `B'` are contained in `A` and `B`, respectively, then `A'` and `B'` are also linearly disjoint. -/ theorem of_le {A' B' : IntermediateField F E} (H : A.LinearDisjoint B) (hA : A' ≤ A) (hB : B' ≤ B) : A'.LinearDisjoint B' := H.of_le_left hA |>.of_le_right hB /-- Similar to `IntermediateField.LinearDisjoint.of_le` but this is for abstract fields. -/ theorem of_le' {A' : IntermediateField F E} (H : A.LinearDisjoint L) (hA : A' ≤ A) (L' : Type*) [Field L'] [Algebra F L'] [Algebra L' L] [IsScalarTower F L' L] [Algebra L' E] [IsScalarTower F L' E] [IsScalarTower L' L E] : A'.LinearDisjoint L' := H.of_le_left hA |>.of_le_right' L' /-- If `A` and `B` are linearly disjoint over `F`, then their intersection is equal to `F`. This is actually an equivalence if `A/F` and `B/F` are finite dimensional, and `A/F` is Galois, see `IntermediateField.LinearDisjoint.iff_inf_eq_bot`. -/ theorem inf_eq_bot (H : A.LinearDisjoint B) : A ⊓ B = ⊥ := toSubalgebra_injective (linearDisjoint_iff'.1 H).inf_eq_bot /-- If `A` and `A` itself are linearly disjoint over `F`, then it is equal to `F`. -/ theorem eq_bot_of_self (H : A.LinearDisjoint A) : A = ⊥ := inf_idem A ▸ H.inf_eq_bot /-- If `A` and `B` are linearly disjoint over `F`, then the rank of `A ⊔ B` is equal to the product of that of `A` and `B`. -/ theorem rank_sup (H : A.LinearDisjoint B) : Module.rank F ↥(A ⊔ B) = Module.rank F A * Module.rank F B := have h := le_sup_toSubalgebra A B (rank_sup_le A B).antisymm <| (linearDisjoint_iff'.1 H).rank_sup_of_free.ge.trans <| (Subalgebra.inclusion h).toLinearMap.rank_le_of_injective (Subalgebra.inclusion_injective h) /-- If `A` and `B` are linearly disjoint over `F`, then the `Module.finrank` of `A ⊔ B` is equal to the product of that of `A` and `B`. -/ theorem finrank_sup (H : A.LinearDisjoint B) : finrank F ↥(A ⊔ B) = finrank F A * finrank F B := by simpa only [map_mul] using congr(Cardinal.toNat $(H.rank_sup)) /-- If `A` and `B` are finite extensions of `F`, such that rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`, then `A` and `B` are linearly disjoint. -/ theorem of_finrank_sup [FiniteDimensional F A] [FiniteDimensional F B] (H : finrank F ↥(A ⊔ B) = finrank F A * finrank F B) : A.LinearDisjoint B := linearDisjoint_iff'.2 <| .of_finrank_sup_of_free (by rwa [← sup_toSubalgebra_of_left]) /-- If `A` and `B` are linearly disjoint over `F` and `A ⊔ B = E`, then the `Module.finrank` of `E` over `A` is equal to the `Module.finrank` of `B` over `F`. -/ theorem finrank_left_eq_finrank [Module.Finite F A] (h₁ : A.LinearDisjoint B) (h₂ : A ⊔ B = ⊤) : finrank A E = finrank F B := by have := h₁.finrank_sup rwa [h₂, finrank_top', ← finrank_mul_finrank F A E, mul_right_inj' finrank_pos.ne'] at this /-- If `A` and `B` are linearly disjoint over `F` and `A ⊔ B = E`, then the `Module.finrank` of `E` over `B` is equal to the `Module.finrank` of `A` over `F`. -/ theorem finrank_right_eq_finrank [Module.Finite F B] (h₁ : A.LinearDisjoint B) (h₂ : A ⊔ B = ⊤) : finrank B E = finrank F A := h₁.symm.finrank_left_eq_finrank (by rwa [sup_comm]) private theorem of_inf_eq_bot_aux [IsGalois F A] [FiniteDimensional F E] (h₁ : A ⊔ B = ⊤) (h₂ : A ⊓ B = ⊥) : A.LinearDisjoint B := by apply LinearDisjoint.of_finrank_sup rw [h₁, finrank_top', ← Module.finrank_mul_finrank F B E, mul_comm, mul_left_inj' Module.finrank_pos.ne'] have : IsGalois B E := IsGalois.sup_right A B h₁ rw [← IsGalois.card_aut_eq_finrank, ← IsGalois.card_aut_eq_finrank] exact Nat.card_congr <| Equiv.ofBijective (restrictRestrictAlgEquivMapHom _ _ _ _) ⟨restrictRestrictAlgEquivMapHom_injective _ _ h₁, restrictRestrictAlgEquivMapHom_surjective _ _ h₂⟩ /-- If `A` and `B` are finite extensions of `F`, with `A/F` Galois, such that `A ⊓ B = F`, then `A` and `B` are linearly disjoint over `F`. -/ theorem of_inf_eq_bot [IsGalois F A] [FiniteDimensional F A] [FiniteDimensional F B] (h : A ⊓ B = ⊥) : A.LinearDisjoint B := by let C : IntermediateField F E := A ⊔ B let A' : IntermediateField F C := A.restrict le_sup_left let B' : IntermediateField F C := B.restrict le_sup_right have hA : IntermediateField.map C.val A' = A := lift_restrict le_sup_left have hB : IntermediateField.map C.val B' = B := lift_restrict le_sup_right suffices A'.LinearDisjoint B' from hA ▸ hB ▸ LinearDisjoint.map this C.val have h₁ : A' ⊔ B' = ⊤ := by rw [← lift_inj, lift_top, lift_sup, lift_restrict le_sup_left, lift_restrict le_sup_right] have h₂ : A' ⊓ B' = ⊥ := by rw [← lift_inj, lift_bot, lift_inf, lift_restrict le_sup_left, lift_restrict le_sup_right, h] have : IsGalois F A' := IsGalois.of_algEquiv <| restrict_algEquiv .. exact of_inf_eq_bot_aux h₁ h₂ @[simp] theorem iff_inf_eq_bot [IsGalois F A] [FiniteDimensional F A] [FiniteDimensional F B] : A.LinearDisjoint B ↔ A ⊓ B = ⊥ := ⟨fun h ↦ inf_eq_bot h, fun h ↦ of_inf_eq_bot h⟩ /-- If `A` and `L` are linearly disjoint over `F`, one of them is algebraic, then `[L(A) : L] = [A : F]`. -/ theorem adjoin_rank_eq_rank_left_of_isAlgebraic (H : A.LinearDisjoint L) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : Module.rank L (adjoin L (A : Set E)) = Module.rank F A := by refine Eq.trans ?_ (Subalgebra.LinearDisjoint.adjoin_rank_eq_rank_left H) set L' := (IsScalarTower.toAlgHom F L E).range let i : L ≃ₐ[F] L' := AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E) have heq : (adjoin L (A : Set E)).toSubalgebra.toSubsemiring = (Algebra.adjoin L' (A : Set E)).toSubsemiring := by rw [adjoin_toSubalgebra_of_isAlgebraic _ _ halg.symm, Algebra.adjoin_toSubsemiring, Algebra.adjoin_toSubsemiring] congr 2 ext x simp only [Set.mem_range, Subtype.exists] exact ⟨fun ⟨y, h⟩ ↦ ⟨x, ⟨y, h⟩, rfl⟩, fun ⟨a, ⟨y, h1⟩, h2⟩ ↦ ⟨y, h1.trans h2⟩⟩ refine rank_eq_of_equiv_equiv i (RingEquiv.subsemiringCongr heq).toAddEquiv i.bijective fun a ⟨x, hx⟩ ↦ ?_ ext simp_rw [Algebra.smul_def] rfl theorem adjoin_rank_eq_rank_left_of_isAlgebraic_left (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F A] : Module.rank L (adjoin L (A : Set E)) = Module.rank F A := H.adjoin_rank_eq_rank_left_of_isAlgebraic (.inl ‹_›) theorem adjoin_rank_eq_rank_left_of_isAlgebraic_right (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F L] : Module.rank L (adjoin L (A : Set E)) = Module.rank F A := H.adjoin_rank_eq_rank_left_of_isAlgebraic (.inr ‹_›) /-- If `A` and `L` are linearly disjoint over `F`, one of them is algebraic, then `[L(A) : A] = [L : F]`. Note that in Lean `L(A)` is not naturally an `A`-algebra, so this result is stated in a cumbersome way. -/ theorem lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic (H : A.LinearDisjoint L) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : Cardinal.lift.{w} (Module.rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E)))) = Cardinal.lift.{v} (Module.rank F L) := by rw [(AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)).toLinearEquiv.lift_rank_eq, Cardinal.lift_inj, ← Subalgebra.LinearDisjoint.adjoin_rank_eq_rank_right H] set L' := (IsScalarTower.toAlgHom F L E).range have heq : (adjoin L (A : Set E)).toSubalgebra.toSubsemiring = (Algebra.adjoin A (L' : Set E)).toSubsemiring := by rw [adjoin_toSubalgebra_of_isAlgebraic _ _ halg.symm, Algebra.adjoin_toSubsemiring, Algebra.adjoin_toSubsemiring, Set.union_comm] congr 2 ext x simp refine rank_eq_of_equiv_equiv (RingHom.id A) (RingEquiv.subsemiringCongr heq).toAddEquiv Function.bijective_id fun ⟨a, ha⟩ ⟨x, hx⟩ ↦ ?_ ext simp_rw [Algebra.smul_def] rfl theorem lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic_left (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F A] : Cardinal.lift.{w} (Module.rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E)))) = Cardinal.lift.{v} (Module.rank F L) := H.lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic (.inl ‹_›) theorem lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic_right (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F L] : Cardinal.lift.{w} (Module.rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E)))) = Cardinal.lift.{v} (Module.rank F L) := H.lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic (.inr ‹_›) /-- If `A` is an intermediate field of `E / F`, `L` is an abstract field between `E / F`, such that they are linearly disjoint over `F`, and one of them is algebraic, then `[L : F] * [E : L(A)] = [E : A]`. -/ theorem lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic (H : A.LinearDisjoint L) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : Cardinal.lift.{v} (Module.rank F L) * Cardinal.lift.{w} (Module.rank (adjoin L (A : Set E)) E) = Cardinal.lift.{w} (Module.rank A E) := by rw [← H.lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic halg, ← Cardinal.lift_mul, Cardinal.lift_inj] exact rank_mul_rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E))) E theorem lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic_left (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F A] : Cardinal.lift.{v} (Module.rank F L) * Cardinal.lift.{w} (Module.rank (adjoin L (A : Set E)) E) = Cardinal.lift.{w} (Module.rank A E) := H.lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic (.inl ‹_›) theorem lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic_right (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F L] : Cardinal.lift.{v} (Module.rank F L) * Cardinal.lift.{w} (Module.rank (adjoin L (A : Set E)) E) = Cardinal.lift.{w} (Module.rank A E) := H.lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic (.inr ‹_›) section variable {L : Type v} [Field L] [Algebra F L] [Algebra L E] [IsScalarTower F L E] /-- The same-universe version of `IntermediateField.LinearDisjoint.lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic`. -/ theorem adjoin_rank_eq_rank_right_of_isAlgebraic (H : A.LinearDisjoint L) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : Module.rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E))) = Module.rank F L := by simpa only [Cardinal.lift_id] using H.lift_adjoin_rank_eq_lift_rank_right_of_isAlgebraic halg theorem adjoin_rank_eq_rank_right_of_isAlgebraic_left (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F A] : Module.rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E))) = Module.rank F L := H.adjoin_rank_eq_rank_right_of_isAlgebraic (.inl ‹_›) theorem adjoin_rank_eq_rank_right_of_isAlgebraic_right (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F L] : Module.rank A (extendScalars (show A ≤ (adjoin L (A : Set E)).restrictScalars F from subset_adjoin L (A : Set E))) = Module.rank F L := H.adjoin_rank_eq_rank_right_of_isAlgebraic (.inr ‹_›) /-- The same-universe version of `IntermediateField.LinearDisjoint.lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic`. -/ theorem rank_right_mul_adjoin_rank_eq_of_isAlgebraic (H : A.LinearDisjoint L) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : Module.rank F L * Module.rank (adjoin L (A : Set E)) E = Module.rank A E := by simpa only [Cardinal.lift_id] using H.lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic halg theorem rank_right_mul_adjoin_rank_eq_of_isAlgebraic_left (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F A] : Module.rank F L * Module.rank (adjoin L (A : Set E)) E = Module.rank A E := H.rank_right_mul_adjoin_rank_eq_of_isAlgebraic (.inl ‹_›) theorem rank_right_mul_adjoin_rank_eq_of_isAlgebraic_right (H : A.LinearDisjoint L) [Algebra.IsAlgebraic F L] : Module.rank F L * Module.rank (adjoin L (A : Set E)) E = Module.rank A E := H.rank_right_mul_adjoin_rank_eq_of_isAlgebraic (.inr ‹_›) end /-- If `A` and `L` have coprime degree over `F`, then they are linearly disjoint. -/ theorem of_finrank_coprime (H : (finrank F A).Coprime (finrank F L)) : A.LinearDisjoint L := letI : Field (AlgHom.range (IsScalarTower.toAlgHom F L E)) := inferInstanceAs <| Field (AlgHom.fieldRange (IsScalarTower.toAlgHom F L E)) letI : Field A.toSubalgebra := inferInstanceAs <| Field A Subalgebra.LinearDisjoint.of_finrank_coprime_of_free <| by rwa [(AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L E)).toLinearEquiv.finrank_eq] at H /-- If `A` and `L` are linearly disjoint over `F`, then `A ⊗[F] L` is a domain. -/ theorem isDomain (H : A.LinearDisjoint L) : IsDomain (A ⊗[F] L) := have : IsDomain (A ⊗[F] _) := Subalgebra.LinearDisjoint.isDomain H (Algebra.TensorProduct.congr (AlgEquiv.refl : A ≃ₐ[F] A) (AlgEquiv.ofInjective (IsScalarTower.toAlgHom F L E) (RingHom.injective _))).toMulEquiv.isDomain /-- If `A` and `B` are field extensions of `F`, there exists a field extension `E` of `F` that `A` and `B` embed into with linearly disjoint images, then `A ⊗[F] B` is a domain. -/ theorem isDomain' {A B : Type*} [Field A] [Algebra F A] [Field B] [Algebra F B] {fa : A →ₐ[F] E} {fb : B →ₐ[F] E} (H : fa.fieldRange.LinearDisjoint fb.fieldRange) : IsDomain (A ⊗[F] B) := by simp_rw [linearDisjoint_iff', AlgHom.fieldRange_toSubalgebra] at H exact H.isDomain_of_injective fa.injective fb.injective /-- If `A ⊗[F] L` is a field, then `A` and `L` are linearly disjoint over `F`. -/ theorem of_isField (H : IsField (A ⊗[F] L)) : A.LinearDisjoint L := by apply Subalgebra.LinearDisjoint.of_isField -- need these otherwise the `exact` will stuck at typeclass haveI : SMulCommClass F A A := SMulCommClass.of_commMonoid F A A haveI : SMulCommClass F A.toSubalgebra A.toSubalgebra := ‹SMulCommClass F A A› letI : Mul (A ⊗[F] L) := Algebra.TensorProduct.instMul letI : Mul (A.toSubalgebra ⊗[F] (IsScalarTower.toAlgHom F L E).range) := Algebra.TensorProduct.instMul exact Algebra.TensorProduct.congr (AlgEquiv.refl : A ≃ₐ[F] A) (AlgEquiv.ofInjective (IsScalarTower.toAlgHom F L E) (RingHom.injective _)) |>.symm.toMulEquiv.isField H /-- If `A` and `B` are field extensions of `F`, such that `A ⊗[F] B` is a field, then for any field extension of `F` that `A` and `B` embed into, their images are linearly disjoint. -/ theorem of_isField' {A : Type v} [Field A] {B : Type w} [Field B] [Algebra F A] [Algebra F B] (H : IsField (A ⊗[F] B)) {K : Type*} [Field K] [Algebra F K] (fa : A →ₐ[F] K) (fb : B →ₐ[F] K) : fa.fieldRange.LinearDisjoint fb.fieldRange := by rw [linearDisjoint_iff'] apply Subalgebra.LinearDisjoint.of_isField exact Algebra.TensorProduct.congr (AlgEquiv.ofInjective fa fa.injective) (AlgEquiv.ofInjective fb fb.injective) |>.symm.toMulEquiv.isField H variable (F) in /-- If `A` and `B` are field extensions of `F`, such that `A ⊗[F] B` is a domain, then there exists a field extension of `F` that `A` and `B` embed into with linearly disjoint images. -/ theorem exists_field_of_isDomain (A : Type v) [Field A] (B : Type w) [Field B] [Algebra F A] [Algebra F B] [IsDomain (A ⊗[F] B)] : ∃ (K : Type (max v w)) (_ : Field K) (_ : Algebra F K) (fa : A →ₐ[F] K) (fb : B →ₐ[F] K), fa.fieldRange.LinearDisjoint fb.fieldRange := have ⟨K, inst1, inst2, fa, fb, _, _, H⟩ := Subalgebra.LinearDisjoint.exists_field_of_isDomain_of_injective F A B (RingHom.injective _) (RingHom.injective _) ⟨K, inst1, inst2, fa, fb, linearDisjoint_iff'.2 H⟩ variable (F) in /-- If for any field extension `K` of `F` that `A` and `B` embed into, their images are linearly disjoint, then `A ⊗[F] B` is a field. (In the proof we choose `K` to be the quotient of `A ⊗[F] B` by a maximal ideal.) -/ theorem isField_of_forall (A : Type v) [Field A] (B : Type w) [Field B] [Algebra F A] [Algebra F B] (H : ∀ (K : Type (max v w)) [Field K] [Algebra F K], ∀ (fa : A →ₐ[F] K) (fb : B →ₐ[F] K), fa.fieldRange.LinearDisjoint fb.fieldRange) : IsField (A ⊗[F] B) := by obtain ⟨M, hM⟩ := Ideal.exists_maximal (A ⊗[F] B) apply not_imp_not.1 (Ring.ne_bot_of_isMaximal_of_not_isField hM) let K : Type (max v w) := A ⊗[F] B ⧸ M letI : Field K := Ideal.Quotient.field _ let i := IsScalarTower.toAlgHom F (A ⊗[F] B) K let fa := i.comp (Algebra.TensorProduct.includeLeft : A →ₐ[F] _) let fb := i.comp (Algebra.TensorProduct.includeRight : B →ₐ[F] _) replace H := H K fa fb simp_rw [linearDisjoint_iff', AlgHom.fieldRange_toSubalgebra, Subalgebra.linearDisjoint_iff_injective] at H have hi : i = (fa.range.mulMap fb.range).comp (Algebra.TensorProduct.congr (AlgEquiv.ofInjective fa fa.injective) (AlgEquiv.ofInjective fb fb.injective)) := by ext <;> simp [fa, fb] replace H : Function.Injective i := by simpa only [hi, AlgHom.coe_comp, AlgHom.coe_coe, EquivLike.injective_comp, fa, this, K, fb] change Function.Injective (Ideal.Quotient.mk M) at H rwa [RingHom.injective_iff_ker_eq_bot, Ideal.mk_ker] at H variable (F E) in /-- If `E` and `K` are field extensions of `F`, one of them is algebraic, such that `E ⊗[F] K` is a domain, then `E ⊗[F] K` is also a field. It is a corollary of `Subalgebra.LinearDisjoint.exists_field_of_isDomain_of_injective` and `IntermediateField.sup_toSubalgebra_of_isAlgebraic`. See `Algebra.TensorProduct.isAlgebraic_of_isField` for its converse (in an earlier file). -/ theorem _root_.Algebra.TensorProduct.isField_of_isAlgebraic (K : Type*) [Field K] [Algebra F K] [IsDomain (E ⊗[F] K)] (halg : Algebra.IsAlgebraic F E ∨ Algebra.IsAlgebraic F K) : IsField (E ⊗[F] K) := have ⟨L, _, _, fa, fb, hfa, hfb, H⟩ := Subalgebra.LinearDisjoint.exists_field_of_isDomain_of_injective F E K (RingHom.injective _) (RingHom.injective _) let f : E ⊗[F] K ≃ₐ[F] ↥(fa.fieldRange ⊔ fb.fieldRange) := Algebra.TensorProduct.congr (AlgEquiv.ofInjective fa hfa) (AlgEquiv.ofInjective fb hfb) |>.trans (Subalgebra.LinearDisjoint.mulMap H) |>.trans (Subalgebra.equivOfEq _ _ (sup_toSubalgebra_of_isAlgebraic fa.fieldRange fb.fieldRange <| by rwa [(AlgEquiv.ofInjective fa hfa).isAlgebraic_iff, (AlgEquiv.ofInjective fb hfb).isAlgebraic_iff] at halg).symm) f.toMulEquiv.isField (Field.toIsField _) /-- If `A` and `L` are linearly disjoint over `F` and one of them is algebraic, then `A ⊗[F] L` is a field. -/ theorem isField_of_isAlgebraic (H : A.LinearDisjoint L) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : IsField (A ⊗[F] L) := have := H.isDomain Algebra.TensorProduct.isField_of_isAlgebraic F A L halg /-- If `A` and `B` are field extensions of `F`, one of them is algebraic, such that there exists a field `E` that `A` and `B` embeds into with linearly disjoint images, then `A ⊗[F] B` is a field. -/ theorem isField_of_isAlgebraic' {A B : Type*} [Field A] [Algebra F A] [Field B] [Algebra F B] {fa : A →ₐ[F] E} {fb : B →ₐ[F] E} (H : fa.fieldRange.LinearDisjoint fb.fieldRange) (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F B) : IsField (A ⊗[F] B) := have := H.isDomain' Algebra.TensorProduct.isField_of_isAlgebraic F A B halg /-- If `A` and `L` are linearly disjoint, one of them is algebraic, then for any `B` and `L'` isomorphic to `A` and `L` respectively, `B` and `L'` are also linearly disjoint. -/ theorem algEquiv_of_isAlgebraic (H : A.LinearDisjoint L) {E' : Type*} [Field E'] [Algebra F E'] (B : IntermediateField F E') (L' : Type*) [Field L'] [Algebra F L'] [Algebra L' E'] [IsScalarTower F L' E'] (f1 : A ≃ₐ[F] B) (f2 : L ≃ₐ[F] L') (halg : Algebra.IsAlgebraic F A ∨ Algebra.IsAlgebraic F L) : B.LinearDisjoint L' := .of_isField ((Algebra.TensorProduct.congr f1 f2).symm.toMulEquiv.isField (H.isField_of_isAlgebraic halg)) /-- If `A` and `B` are linearly disjoint, then `trace` and `algebraMap` commutes. -/ theorem trace_algebraMap [FiniteDimensional F E] (h₁ : A.LinearDisjoint B) (h₂ : A ⊔ B = ⊤) (x : B) : Algebra.trace A E (algebraMap B E x) = algebraMap F A (Algebra.trace F B x) := by rw [linearDisjoint_iff'] at h₁ refine h₁.trace_algebraMap ?_ x simpa [sup_toSubalgebra_of_isAlgebraic_right] using congr_arg toSubalgebra h₂ /-- If `A` and `B` are linearly disjoint, then `norm` and `algebraMap` commutes. -/ theorem norm_algebraMap [FiniteDimensional F E] (h₁ : A.LinearDisjoint B) (h₂ : A ⊔ B = ⊤) (x : B) : Algebra.norm A (algebraMap B E x) = algebraMap F A (Algebra.norm F x) := by rw [linearDisjoint_iff'] at h₁ refine h₁.norm_algebraMap ?_ x simpa [sup_toSubalgebra_of_isAlgebraic_right] using congr_arg toSubalgebra h₂ end LinearDisjoint end IntermediateField
.lake/packages/mathlib/Mathlib/FieldTheory/KrullTopology.lean
import Mathlib.FieldTheory.Galois.Basic import Mathlib.Topology.Algebra.FilterBasis import Mathlib.Topology.Algebra.OpenSubgroup /-! # Krull topology We define the Krull topology on `Gal(L/K)` for an arbitrary field extension `L/K`. In order to do this, we first define a `GroupFilterBasis` on `Gal(L/K)`, whose sets are `E.fixingSubgroup` for all intermediate fields `E` with `E/K` finite dimensional. ## Main Definitions - `finiteExts K L`. Given a field extension `L/K`, this is the set of intermediate fields that are finite-dimensional over `K`. - `fixedByFinite K L`. Given a field extension `L/K`, `fixedByFinite K L` is the set of subsets `Gal(L/E)` of `Gal(L/K)`, where `E/K` is finite - `galBasis K L`. Given a field extension `L/K`, this is the filter basis on `Gal(L/K)` whose sets are `Gal(L/E)` for intermediate fields `E` with `E/K` finite. - `galGroupBasis K L`. This is the same as `galBasis K L`, but with the added structure that it is a group filter basis on `Gal(L/K)`, rather than just a filter basis. - `krullTopology K L`. Given a field extension `L/K`, this is the topology on `Gal(L/K)`, induced by the group filter basis `galGroupBasis K L`. ## Main Results - `krullTopology_t2 K L`. For an integral field extension `L/K`, the topology `krullTopology K L` is Hausdorff. - `krullTopology_totallyDisconnected K L`. For an integral field extension `L/K`, the topology `krullTopology K L` is totally disconnected. - `IntermediateField.finrank_eq_fixingSubgroup_index`: given a Galois extension `K/k` and an intermediate field `L`, the `[L : k]` as a natural number is equal to the index of the fixing subgroup of `L`. ## Notation - In docstrings, we will write `Gal(L/E)` to denote the fixing subgroup of an intermediate field `E`. That is, `Gal(L/E)` is the subgroup of `Gal(L/K)` consisting of automorphisms that fix every element of `E`. In particular, we distinguish between `Gal(L/E)` and `Gal(L/E)`, since the former is defined to be a subgroup of `Gal(L/K)`, while the latter is a group in its own right. ## Implementation Notes - `krullTopology K L` is defined as an instance for type class inference. -/ open scoped Pointwise /-- Given a field extension `L/K`, `finiteExts K L` is the set of intermediate field extensions `L/E/K` such that `E/K` is finite. -/ def finiteExts (K : Type*) [Field K] (L : Type*) [Field L] [Algebra K L] : Set (IntermediateField K L) := {E | FiniteDimensional K E} /-- Given a field extension `L/K`, `fixedByFinite K L` is the set of subsets `Gal(L/E)` of `Gal(L/K)`, where `E/K` is finite. -/ def fixedByFinite (K L : Type*) [Field K] [Field L] [Algebra K L] : Set (Subgroup Gal(L/K)) := IntermediateField.fixingSubgroup '' finiteExts K L /-- If `L/K` is a field extension, then we have `Gal(L/K) ∈ fixedByFinite K L`. -/ theorem top_fixedByFinite {K L : Type*} [Field K] [Field L] [Algebra K L] : ⊤ ∈ fixedByFinite K L := ⟨⊥, IntermediateField.instFiniteSubtypeMemBot K, IntermediateField.fixingSubgroup_bot⟩ /-- Given a field extension `L/K`, `galBasis K L` is the filter basis on `Gal(L/K)` whose sets are `Gal(L/E)` for intermediate fields `E` with `E/K` finite dimensional. -/ def galBasis (K L : Type*) [Field K] [Field L] [Algebra K L] : FilterBasis Gal(L/K) where sets := (fun g => g.carrier) '' fixedByFinite K L nonempty := ⟨⊤, ⊤, top_fixedByFinite, rfl⟩ inter_sets := by rintro _ _ ⟨_, ⟨E1, h_E1, rfl⟩, rfl⟩ ⟨_, ⟨E2, h_E2, rfl⟩, rfl⟩ have : FiniteDimensional K E1 := h_E1 have : FiniteDimensional K E2 := h_E2 refine ⟨(E1 ⊔ E2).fixingSubgroup.carrier, ⟨_, ⟨_, E1.finiteDimensional_sup E2, rfl⟩, rfl⟩, ?_⟩ exact Set.subset_inter (E1.fixingSubgroup_le le_sup_left) (E2.fixingSubgroup_le le_sup_right) /-- A subset of `Gal(L/K)` is a member of `galBasis K L` if and only if it is the underlying set of `Gal(L/E)` for some finite subextension `E/K`. -/ theorem mem_galBasis_iff (K L : Type*) [Field K] [Field L] [Algebra K L] (U : Set Gal(L/K)) : U ∈ galBasis K L ↔ U ∈ (fun g => g.carrier) '' fixedByFinite K L := Iff.rfl /-- For a field extension `L/K`, `galGroupBasis K L` is the group filter basis on `Gal(L/K)` whose sets are `Gal(L/E)` for finite subextensions `E/K`. -/ def galGroupBasis (K L : Type*) [Field K] [Field L] [Algebra K L] : GroupFilterBasis Gal(L/K) where toFilterBasis := galBasis K L one' := fun ⟨H, _, h2⟩ => h2 ▸ H.one_mem mul' {U} hU := ⟨U, hU, by rcases hU with ⟨H, _, rfl⟩ rintro x ⟨a, haH, b, hbH, rfl⟩ exact H.mul_mem haH hbH⟩ inv' {U} hU := ⟨U, hU, by rcases hU with ⟨H, _, rfl⟩ exact fun _ => H.inv_mem'⟩ conj' := by rintro σ U ⟨H, ⟨E, hE, rfl⟩, rfl⟩ let F : IntermediateField K L := E.map σ.symm.toAlgHom refine ⟨F.fixingSubgroup.carrier, ⟨⟨F.fixingSubgroup, ⟨F, ?_, rfl⟩, rfl⟩, fun g hg => ?_⟩⟩ · have : FiniteDimensional K E := hE exact IntermediateField.finiteDimensional_map σ.symm.toAlgHom change σ * g * σ⁻¹ ∈ E.fixingSubgroup rw [IntermediateField.mem_fixingSubgroup_iff] intro x hx change σ (g (σ⁻¹ x)) = x have h_in_F : σ⁻¹ x ∈ F := ⟨x, hx, by dsimp; rw [← AlgEquiv.invFun_eq_symm]; rfl⟩ have h_g_fix : g (σ⁻¹ x) = σ⁻¹ x := by rw [Subgroup.mem_carrier, IntermediateField.mem_fixingSubgroup_iff F g] at hg exact hg (σ⁻¹ x) h_in_F rw [h_g_fix] change σ (σ⁻¹ x) = x exact AlgEquiv.apply_symm_apply σ x /-- For a field extension `L/K`, `krullTopology K L` is the topological space structure on `Gal(L/K)` induced by the group filter basis `galGroupBasis K L`. -/ instance krullTopology (K L : Type*) [Field K] [Field L] [Algebra K L] : TopologicalSpace Gal(L/K) := GroupFilterBasis.topology (galGroupBasis K L) /-- For a field extension `L/K`, the Krull topology on `Gal(L/K)` makes it a topological group. -/ @[stacks 0BMJ "We define Krull topology directly without proving the universal property"] instance (K L : Type*) [Field K] [Field L] [Algebra K L] : IsTopologicalGroup Gal(L/K) := GroupFilterBasis.isTopologicalGroup (galGroupBasis K L) open scoped Topology in lemma krullTopology_mem_nhds_one_iff (K L : Type*) [Field K] [Field L] [Algebra K L] (s : Set Gal(L/K)) : s ∈ 𝓝 1 ↔ ∃ E : IntermediateField K L, FiniteDimensional K E ∧ (E.fixingSubgroup : Set Gal(L/K)) ⊆ s := by rw [GroupFilterBasis.nhds_one_eq] constructor · rintro ⟨-, ⟨-, ⟨E, fin, rfl⟩, rfl⟩, hE⟩ exact ⟨E, fin, hE⟩ · rintro ⟨E, fin, hE⟩ exact ⟨E.fixingSubgroup, ⟨E.fixingSubgroup, ⟨E, fin, rfl⟩, rfl⟩, hE⟩ open scoped Topology in lemma krullTopology_mem_nhds_one_iff_of_normal (K L : Type*) [Field K] [Field L] [Algebra K L] [Normal K L] (s : Set Gal(L/K)) : s ∈ 𝓝 1 ↔ ∃ E : IntermediateField K L, FiniteDimensional K E ∧ Normal K E ∧ (E.fixingSubgroup : Set Gal(L/K)) ⊆ s := by rw [krullTopology_mem_nhds_one_iff] refine ⟨fun ⟨E, _, hE⟩ ↦ ?_, fun ⟨E, hE⟩ ↦ ⟨E, hE.1, hE.2.2⟩⟩ use (IntermediateField.normalClosure K E L) simp only [normalClosure.is_finiteDimensional K E L, normalClosure.normal K E L, true_and] exact le_trans (E.fixingSubgroup_antitone E.le_normalClosure) hE section KrullT2 open scoped Topology Filter /-- Let `L/E/K` be a tower of fields with `E/K` finite. Then `Gal(L/E)` is an open subgroup of `Gal(L/K)`. -/ theorem IntermediateField.fixingSubgroup_isOpen {K L : Type*} [Field K] [Field L] [Algebra K L] (E : IntermediateField K L) [FiniteDimensional K E] : IsOpen (E.fixingSubgroup : Set Gal(L/K)) := by have h_basis : E.fixingSubgroup.carrier ∈ galGroupBasis K L := ⟨E.fixingSubgroup, ⟨E, ‹_›, rfl⟩, rfl⟩ have h_nhds := GroupFilterBasis.mem_nhds_one (galGroupBasis K L) h_basis exact Subgroup.isOpen_of_mem_nhds _ h_nhds /-- Given a tower of fields `L/E/K`, with `E/K` finite, the subgroup `Gal(L/E) ≤ Gal(L/K)` is closed. -/ theorem IntermediateField.fixingSubgroup_isClosed {K L : Type*} [Field K] [Field L] [Algebra K L] (E : IntermediateField K L) [FiniteDimensional K E] : IsClosed (E.fixingSubgroup : Set Gal(L/K)) := OpenSubgroup.isClosed ⟨E.fixingSubgroup, E.fixingSubgroup_isOpen⟩ /-- If `L/K` is an algebraic extension, then the Krull topology on `Gal(L/K)` is Hausdorff. -/ theorem krullTopology_t2 {K L : Type*} [Field K] [Field L] [Algebra K L] [Algebra.IsIntegral K L] : T2Space Gal(L/K) := { t2 := fun f g hfg => by let φ := f⁻¹ * g obtain ⟨x, hx⟩ := DFunLike.exists_ne hfg have hφx : φ x ≠ x := by apply ne_of_apply_ne f change f (f.symm (g x)) ≠ f x rw [AlgEquiv.apply_symm_apply f (g x), ne_comm] exact hx let E : IntermediateField K L := IntermediateField.adjoin K {x} let h_findim : FiniteDimensional K E := IntermediateField.adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral x) let H := E.fixingSubgroup have h_basis : (H : Set Gal(L/K)) ∈ galGroupBasis K L := ⟨H, ⟨E, ⟨h_findim, rfl⟩⟩, rfl⟩ have h_nhds := GroupFilterBasis.mem_nhds_one (galGroupBasis K L) h_basis rw [mem_nhds_iff] at h_nhds rcases h_nhds with ⟨W, hWH, hW_open, hW_1⟩ refine ⟨f • W, g • W, ⟨hW_open.leftCoset f, hW_open.leftCoset g, ⟨1, hW_1, mul_one _⟩, ⟨1, hW_1, mul_one _⟩, ?_⟩⟩ rw [Set.disjoint_left] rintro σ ⟨w1, hw1, h⟩ ⟨w2, hw2, rfl⟩ dsimp at h rw [eq_inv_mul_iff_mul_eq.symm, ← mul_assoc, mul_inv_eq_iff_eq_mul.symm] at h have h_in_H : w1 * w2⁻¹ ∈ H := H.mul_mem (hWH hw1) (H.inv_mem (hWH hw2)) rw [h] at h_in_H change φ ∈ E.fixingSubgroup at h_in_H rw [IntermediateField.mem_fixingSubgroup_iff] at h_in_H specialize h_in_H x have hxE : x ∈ E := by apply IntermediateField.subset_adjoin apply Set.mem_singleton exact hφx (h_in_H hxE) } end KrullT2 section TotallySeparated instance {K L : Type*} [Field K] [Field L] [Algebra K L] [Algebra.IsIntegral K L] : TotallySeparatedSpace Gal(L/K) := by rw [totallySeparatedSpace_iff_exists_isClopen] intro σ τ h_diff have hστ : σ⁻¹ * τ ≠ 1 := by rwa [Ne, inv_mul_eq_one] rcases DFunLike.exists_ne hστ with ⟨x, hx : (σ⁻¹ * τ) x ≠ x⟩ let E := IntermediateField.adjoin K ({x} : Set L) haveI := IntermediateField.adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral (R := K) x) refine ⟨σ • E.fixingSubgroup, ⟨E.fixingSubgroup_isClosed.leftCoset σ, E.fixingSubgroup_isOpen.leftCoset σ⟩, ⟨1, E.fixingSubgroup.one_mem', mul_one σ⟩, ?_⟩ simp only [Set.mem_compl_iff, mem_leftCoset_iff, SetLike.mem_coe, IntermediateField.mem_fixingSubgroup_iff, not_forall] exact ⟨x, IntermediateField.mem_adjoin_simple_self K x, hx⟩ /-- If `L/K` is an algebraic field extension, then the Krull topology on `Gal(L/K)` is totally disconnected. -/ theorem krullTopology_isTotallySeparated {K L : Type*} [Field K] [Field L] [Algebra K L] [Algebra.IsIntegral K L] : IsTotallySeparated (Set.univ : Set Gal(L/K)) := (totallySeparatedSpace_iff _).mp inferInstance end TotallySeparated instance krullTopology_discreteTopology_of_finiteDimensional (K L : Type*) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L] : DiscreteTopology Gal(L/K) := by rw [discreteTopology_iff_isOpen_singleton_one] change IsOpen ((⊥ : Subgroup Gal(L/K)) : Set Gal(L/K)) rw [← IntermediateField.fixingSubgroup_top] exact IntermediateField.fixingSubgroup_isOpen ⊤ namespace IntermediateField variable {k E : Type*} (K : Type*) [Field k] [Field E] [Field K] [Algebra k E] [Algebra k K] [Algebra E K] [IsScalarTower k E K] (L : IntermediateField k E) /-- If `K / E / k` is a field extension tower with `E / k` normal, `L` is an intermediate field of `E / k`, then the fixing subgroup of `L` viewed as an intermediate field of `K / k` is equal to the preimage of the fixing subgroup of `L` viewed as an intermediate field of `E / k` under the natural map `Aut(K / k) → Aut(E / k)` (`AlgEquiv.restrictNormalHom`). -/ theorem map_fixingSubgroup [Normal k E] : (L.map (IsScalarTower.toAlgHom k E K)).fixingSubgroup = L.fixingSubgroup.comap (AlgEquiv.restrictNormalHom (F := k) (K₁ := K) E) := by ext f simp only [Subgroup.mem_comap, mem_fixingSubgroup_iff] constructor · rintro h x hx change f.restrictNormal E x = x apply_fun _ using (algebraMap E K).injective rw [AlgEquiv.restrictNormal_commutes] exact h _ ⟨x, hx, rfl⟩ · rintro h _ ⟨x, hx, rfl⟩ replace h := congr(algebraMap E K $(show f.restrictNormal E x = x from h x hx)) rwa [AlgEquiv.restrictNormal_commutes] at h /-- If `K / E / k` is a field extension tower with `E / k` and `K / k` normal, `L` is an intermediate field of `E / k`, then the index of the fixing subgroup of `L` viewed as an intermediate field of `K / k` is equal to the index of the fixing subgroup of `L` viewed as an intermediate field of `E / k`. -/ theorem map_fixingSubgroup_index [Normal k E] [Normal k K] : (L.map (IsScalarTower.toAlgHom k E K)).fixingSubgroup.index = L.fixingSubgroup.index := by rw [L.map_fixingSubgroup K, L.fixingSubgroup.index_comap_of_surjective (AlgEquiv.restrictNormalHom_surjective _)] variable {K} in /-- If `K / k` is a Galois extension, `L` is an intermediate field of `K / k`, then `[L : k]` as a natural number is equal to the index of the fixing subgroup of `L`. -/ theorem finrank_eq_fixingSubgroup_index (L : IntermediateField k K) [IsGalois k K] : Module.finrank k L = L.fixingSubgroup.index := by wlog hnfd : FiniteDimensional k L generalizing L · rw [Module.finrank_of_infinite_dimensional hnfd] by_contra! h replace h : L.fixingSubgroup.FiniteIndex := ⟨h.symm⟩ obtain ⟨L', hfd, hL'⟩ := exists_lt_finrank_of_infinite_dimensional hnfd L.fixingSubgroup.index let i := (liftAlgEquiv L').toLinearEquiv replace hfd := i.finiteDimensional rw [i.finrank_eq, this _ hfd] at hL' exact (Subgroup.index_antitone <| fixingSubgroup_le <| IntermediateField.lift_le L').not_gt hL' let E := normalClosure k L K have hle : L ≤ E := by simpa only [fieldRange_val] using L.val.fieldRange_le_normalClosure let L' := restrict hle have h := Module.finrank_mul_finrank k ↥L' ↥E classical rw [← IsGalois.card_fixingSubgroup_eq_finrank L', ← IsGalois.card_aut_eq_finrank k E] at h rw [← L'.fixingSubgroup.index_mul_card, Nat.mul_left_inj Finite.card_pos.ne'] at h rw [(restrict_algEquiv hle).toLinearEquiv.finrank_eq, h, ← L'.map_fixingSubgroup_index K] congr 2 exact lift_restrict hle end IntermediateField
.lake/packages/mathlib/Mathlib/FieldTheory/Separable.lean
import Mathlib.Algebra.Polynomial.Expand import Mathlib.Algebra.Polynomial.Splits import Mathlib.Algebra.Squarefree.Basic import Mathlib.FieldTheory.IntermediateField.Basic import Mathlib.FieldTheory.Minpoly.Field import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.PowerBasis import Mathlib.Data.ENat.Lattice /-! # Separable polynomials We define a polynomial to be separable if it is coprime with its derivative. We prove basic properties about separable polynomials here. ## Main definitions * `Polynomial.Separable f`: a polynomial `f` is separable iff it is coprime with its derivative. * `IsSeparable K x`: an element `x` is separable over `K` iff the minimal polynomial of `x` over `K` is separable. * `Algebra.IsSeparable K L`: `L` is separable over `K` iff every element in `L` is separable over `K`. -/ universe u v w open Polynomial Finset namespace Polynomial section CommSemiring variable {R : Type u} [CommSemiring R] {S : Type v} [CommSemiring S] /-- A polynomial is separable iff it is coprime with its derivative. -/ @[stacks 09H1 "first part"] def Separable (f : R[X]) : Prop := IsCoprime f (derivative f) theorem separable_def (f : R[X]) : f.Separable ↔ IsCoprime f (derivative f) := Iff.rfl theorem separable_def' (f : R[X]) : f.Separable ↔ ∃ a b : R[X], a * f + b * (derivative f) = 1 := Iff.rfl theorem not_separable_zero [Nontrivial R] : ¬Separable (0 : R[X]) := by rintro ⟨x, y, h⟩ simp only [derivative_zero, mul_zero, add_zero, zero_ne_one] at h theorem Separable.ne_zero [Nontrivial R] {f : R[X]} (h : f.Separable) : f ≠ 0 := (not_separable_zero <| · ▸ h) @[simp] theorem separable_one : (1 : R[X]).Separable := isCoprime_one_left @[nontriviality] theorem separable_of_subsingleton [Subsingleton R] (f : R[X]) : f.Separable := by simp [Separable, IsCoprime, eq_iff_true_of_subsingleton] theorem separable_X_add_C (a : R) : (X + C a).Separable := by rw [separable_def, derivative_add, derivative_X, derivative_C, add_zero] exact isCoprime_one_right theorem separable_X : (X : R[X]).Separable := by rw [separable_def, derivative_X] exact isCoprime_one_right theorem separable_C (r : R) : (C r).Separable ↔ IsUnit r := by rw [separable_def, derivative_C, isCoprime_zero_right, isUnit_C] theorem Separable.of_mul_left {f g : R[X]} (h : (f * g).Separable) : f.Separable := by have := h.of_mul_left_left; rw [derivative_mul] at this exact IsCoprime.of_mul_right_left (IsCoprime.of_add_mul_left_right this) theorem Separable.of_mul_right {f g : R[X]} (h : (f * g).Separable) : g.Separable := by rw [mul_comm] at h exact h.of_mul_left theorem Separable.of_dvd {f g : R[X]} (hf : f.Separable) (hfg : g ∣ f) : g.Separable := by rcases hfg with ⟨f', rfl⟩ exact Separable.of_mul_left hf theorem separable_gcd_left {F : Type*} [Field F] [DecidableEq F[X]] {f : F[X]} (hf : f.Separable) (g : F[X]) : (EuclideanDomain.gcd f g).Separable := Separable.of_dvd hf (EuclideanDomain.gcd_dvd_left f g) theorem separable_gcd_right {F : Type*} [Field F] [DecidableEq F[X]] {g : F[X]} (f : F[X]) (hg : g.Separable) : (EuclideanDomain.gcd f g).Separable := Separable.of_dvd hg (EuclideanDomain.gcd_dvd_right f g) theorem Separable.isCoprime {f g : R[X]} (h : (f * g).Separable) : IsCoprime f g := by have := h.of_mul_left_left; rw [derivative_mul] at this exact IsCoprime.of_mul_right_right (IsCoprime.of_add_mul_left_right this) theorem Separable.of_pow' {f : R[X]} : ∀ {n : ℕ} (_h : (f ^ n).Separable), IsUnit f ∨ f.Separable ∧ n = 1 ∨ n = 0 | 0 => fun _h => Or.inr <| Or.inr rfl | 1 => fun h => Or.inr <| Or.inl ⟨pow_one f ▸ h, rfl⟩ | n + 2 => fun h => by rw [pow_succ, pow_succ] at h exact Or.inl (isCoprime_self.1 h.isCoprime.of_mul_left_right) theorem Separable.of_pow {f : R[X]} (hf : ¬IsUnit f) {n : ℕ} (hn : n ≠ 0) (hfs : (f ^ n).Separable) : f.Separable ∧ n = 1 := (hfs.of_pow'.resolve_left hf).resolve_right hn theorem Separable.map {p : R[X]} (h : p.Separable) {f : R →+* S} : (p.map f).Separable := let ⟨a, b, H⟩ := h ⟨a.map f, b.map f, by rw [derivative_map, ← Polynomial.map_mul, ← Polynomial.map_mul, ← Polynomial.map_add, H, Polynomial.map_one]⟩ theorem _root_.Associated.separable {f g : R[X]} (ha : Associated f g) (h : f.Separable) : g.Separable := by obtain ⟨⟨u, v, h1, h2⟩, ha⟩ := ha obtain ⟨a, b, h⟩ := h refine ⟨a * v + b * derivative v, b * v, ?_⟩ replace h := congr($h * $(h1)) have h3 := congr(derivative $(h1)) simp only [← ha, derivative_mul, derivative_one] at h3 ⊢ calc _ = (a * f + b * derivative f) * (u * v) + (b * f) * (derivative u * v + u * derivative v) := by ring1 _ = 1 := by rw [h, h3]; ring1 theorem _root_.Associated.separable_iff {f g : R[X]} (ha : Associated f g) : f.Separable ↔ g.Separable := ⟨ha.separable, ha.symm.separable⟩ theorem Separable.mul_unit {f g : R[X]} (hf : f.Separable) (hg : IsUnit g) : (f * g).Separable := (associated_mul_unit_right f g hg).separable hf theorem Separable.unit_mul {f g : R[X]} (hf : IsUnit f) (hg : g.Separable) : (f * g).Separable := (associated_unit_mul_right g f hf).separable hg theorem Separable.eval₂_derivative_ne_zero [Nontrivial S] (f : R →+* S) {p : R[X]} (h : p.Separable) {x : S} (hx : p.eval₂ f x = 0) : (derivative p).eval₂ f x ≠ 0 := by intro hx' obtain ⟨a, b, e⟩ := h apply_fun Polynomial.eval₂ f x at e simp only [eval₂_add, eval₂_mul, hx, mul_zero, hx', add_zero, eval₂_one, zero_ne_one] at e theorem Separable.aeval_derivative_ne_zero [Nontrivial S] [Algebra R S] {p : R[X]} (h : p.Separable) {x : S} (hx : aeval x p = 0) : aeval x (derivative p) ≠ 0 := h.eval₂_derivative_ne_zero (algebraMap R S) hx variable (p q : ℕ) theorem isUnit_of_self_mul_dvd_separable {p q : R[X]} (hp : p.Separable) (hq : q * q ∣ p) : IsUnit q := by obtain ⟨p, rfl⟩ := hq apply isCoprime_self.mp have : IsCoprime (q * (q * p)) (q * (derivative q * p + derivative q * p + q * derivative p)) := by simp only [← mul_assoc, mul_add] dsimp only [Separable] at hp convert hp using 1 rw [derivative_mul, derivative_mul] ring exact IsCoprime.of_mul_right_left (IsCoprime.of_mul_left_left this) theorem emultiplicity_le_one_of_separable {p q : R[X]} (hq : ¬IsUnit q) (hsep : Separable p) : emultiplicity q p ≤ 1 := by contrapose! hq apply isUnit_of_self_mul_dvd_separable hsep rw [← sq] apply pow_dvd_of_le_emultiplicity exact Order.add_one_le_of_lt hq /-- A separable polynomial is square-free. See `PerfectField.separable_iff_squarefree` for the converse when the coefficients are a perfect field. -/ theorem Separable.squarefree {p : R[X]} (hsep : Separable p) : Squarefree p := by classical rw [squarefree_iff_emultiplicity_le_one p] exact fun f => or_iff_not_imp_right.mpr fun hunit => emultiplicity_le_one_of_separable hunit hsep end CommSemiring section CommRing variable {R : Type u} [CommRing R] theorem separable_X_sub_C {x : R} : Separable (X - C x) := by simpa only [sub_eq_add_neg, C_neg] using separable_X_add_C (-x) theorem Separable.mul {f g : R[X]} (hf : f.Separable) (hg : g.Separable) (h : IsCoprime f g) : (f * g).Separable := by rw [separable_def, derivative_mul] exact ((hf.mul_right h).add_mul_left_right _).mul_left ((h.symm.mul_right hg).mul_add_right_right _) theorem separable_prod' {ι : Sort _} {f : ι → R[X]} {s : Finset ι} : (∀ x ∈ s, ∀ y ∈ s, x ≠ y → IsCoprime (f x) (f y)) → (∀ x ∈ s, (f x).Separable) → (∏ x ∈ s, f x).Separable := by classical exact Finset.induction_on s (fun _ _ => separable_one) fun a s has ih h1 h2 => by simp_rw [Finset.forall_mem_insert, forall_and] at h1 h2; rw [prod_insert has] exact h2.1.mul (ih h1.2.2 h2.2) (IsCoprime.prod_right fun i his => h1.1.2 i his <| Ne.symm <| ne_of_mem_of_not_mem his has) open scoped Function in -- required for scoped `on` notation theorem separable_prod {ι : Sort _} [Fintype ι] {f : ι → R[X]} (h1 : Pairwise (IsCoprime on f)) (h2 : ∀ x, (f x).Separable) : (∏ x, f x).Separable := separable_prod' (fun _x _hx _y _hy hxy => h1 hxy) fun x _hx => h2 x theorem Separable.inj_of_prod_X_sub_C [Nontrivial R] {ι : Sort _} {f : ι → R} {s : Finset ι} (hfs : (∏ i ∈ s, (X - C (f i))).Separable) {x y : ι} (hx : x ∈ s) (hy : y ∈ s) (hfxy : f x = f y) : x = y := by classical by_contra hxy rw [← insert_erase hx, prod_insert (notMem_erase _ _), ← insert_erase (mem_erase_of_ne_of_mem (Ne.symm hxy) hy), prod_insert (notMem_erase _ _), ← mul_assoc, hfxy, ← sq] at hfs cases (hfs.of_mul_left.of_pow (not_isUnit_X_sub_C _) two_ne_zero).2 theorem Separable.injective_of_prod_X_sub_C [Nontrivial R] {ι : Sort _} [Fintype ι] {f : ι → R} (hfs : (∏ i, (X - C (f i))).Separable) : Function.Injective f := fun _x _y hfxy => hfs.inj_of_prod_X_sub_C (mem_univ _) (mem_univ _) hfxy theorem nodup_of_separable_prod [Nontrivial R] {s : Multiset R} (hs : Separable (Multiset.map (fun a => X - C a) s).prod) : s.Nodup := by rw [Multiset.nodup_iff_ne_cons_cons] rintro a t rfl refine not_isUnit_X_sub_C a (isUnit_of_self_mul_dvd_separable hs ?_) simpa only [Multiset.map_cons, Multiset.prod_cons] using mul_dvd_mul_left _ (dvd_mul_right _ _) /-- If `IsUnit n` in a `CommRing R`, then `X ^ n - u` is separable for any unit `u`. -/ theorem separable_X_pow_sub_C_unit {n : ℕ} (u : Rˣ) (hn : IsUnit (n : R)) : Separable (X ^ n - C (u : R)) := by nontriviality R rcases n.eq_zero_or_pos with (rfl | hpos) · simp at hn apply (separable_def' (X ^ n - C (u : R))).2 obtain ⟨n', hn'⟩ := hn.exists_left_inv refine ⟨-C ↑u⁻¹, C (↑u⁻¹ : R) * C n' * X, ?_⟩ rw [derivative_sub, derivative_C, sub_zero, derivative_pow X n, derivative_X, mul_one] calc -C ↑u⁻¹ * (X ^ n - C ↑u) + C ↑u⁻¹ * C n' * X * (↑n * X ^ (n - 1)) = C (↑u⁻¹ * ↑u) - C ↑u⁻¹ * X ^ n + C ↑u⁻¹ * C (n' * ↑n) * (X * X ^ (n - 1)) := by simp only [C.map_mul, C_eq_natCast] ring _ = 1 := by simp only [Units.inv_mul, hn', C.map_one, mul_one, ← pow_succ', Nat.sub_add_cancel (show 1 ≤ n from hpos), sub_add_cancel] /-- If `n = 0` in `R` and `b` is a unit, then `a * X ^ n + b * X + c` is separable. -/ theorem separable_C_mul_X_pow_add_C_mul_X_add_C {n : ℕ} (a b c : R) (hn : (n : R) = 0) (hb : IsUnit b) : (C a * X ^ n + C b * X + C c).Separable := by set f := C a * X ^ n + C b * X + C c obtain ⟨e, hb⟩ := hb.exists_left_inv refine ⟨-derivative f, f + C e, ?_⟩ have hderiv : derivative f = C b := by simp [hn, f, map_add derivative, derivative_C, derivative_X_pow] rw [hderiv, right_distrib, ← add_assoc, neg_mul, mul_comm, neg_add_cancel, zero_add, ← map_mul, hb, map_one] /-- If `R` is of characteristic `p`, `p ∣ n` and `b` is a unit, then `a * X ^ n + b * X + c` is separable. -/ theorem separable_C_mul_X_pow_add_C_mul_X_add_C' (p n : ℕ) (a b c : R) [CharP R p] (hn : p ∣ n) (hb : IsUnit b) : (C a * X ^ n + C b * X + C c).Separable := separable_C_mul_X_pow_add_C_mul_X_add_C a b c ((CharP.cast_eq_zero_iff R p n).2 hn) hb theorem rootMultiplicity_le_one_of_separable [Nontrivial R] {p : R[X]} (hsep : Separable p) (x : R) : rootMultiplicity x p ≤ 1 := by classical by_cases hp : p = 0 · simp [hp] rw [rootMultiplicity_eq_multiplicity, if_neg hp, ← Nat.cast_le (α := ℕ∞), Nat.cast_one, ← (finiteMultiplicity_X_sub_C x hp).emultiplicity_eq_multiplicity] apply emultiplicity_le_one_of_separable (not_isUnit_X_sub_C _) hsep end CommRing section IsDomain variable {R : Type u} [CommRing R] [IsDomain R] theorem count_roots_le_one [DecidableEq R] {p : R[X]} (hsep : Separable p) (x : R) : p.roots.count x ≤ 1 := by rw [count_roots p] exact rootMultiplicity_le_one_of_separable hsep x theorem nodup_roots {p : R[X]} (hsep : Separable p) : p.roots.Nodup := by classical exact Multiset.nodup_iff_count_le_one.mpr (count_roots_le_one hsep) end IsDomain section Field variable {F : Type u} [Field F] {K : Type v} [Field K] theorem separable_iff_derivative_ne_zero {f : F[X]} (hf : Irreducible f) : f.Separable ↔ derivative f ≠ 0 := ⟨fun h1 h2 => hf.not_isUnit <| isCoprime_zero_right.1 <| h2 ▸ h1, fun h => EuclideanDomain.isCoprime_of_dvd (mt And.right h) fun g hg1 _hg2 ⟨p, hg3⟩ hg4 => let ⟨u, hu⟩ := (hf.isUnit_or_isUnit hg3).resolve_left hg1 have : f ∣ derivative f := by conv_lhs => rw [hg3, ← hu] rwa [Units.mul_right_dvd] not_lt_of_ge (natDegree_le_of_dvd this h) <| natDegree_derivative_lt <| mt derivative_of_natDegree_zero h⟩ attribute [local instance] Ideal.Quotient.field in theorem separable_map {S} [CommRing S] [Nontrivial S] (f : F →+* S) {p : F[X]} : (p.map f).Separable ↔ p.Separable := by refine ⟨fun H ↦ ?_, fun H ↦ H.map⟩ obtain ⟨m, hm⟩ := Ideal.exists_maximal S have := Separable.map H (f := Ideal.Quotient.mk m) rwa [map_map, separable_def, derivative_map, isCoprime_map] at this theorem separable_prod_X_sub_C_iff' {ι : Sort _} {f : ι → F} {s : Finset ι} : (∏ i ∈ s, (X - C (f i))).Separable ↔ ∀ x ∈ s, ∀ y ∈ s, f x = f y → x = y := ⟨fun hfs _ hx _ hy hfxy => hfs.inj_of_prod_X_sub_C hx hy hfxy, fun H => by rw [← prod_attach] exact separable_prod' (fun x _hx y _hy hxy => @pairwise_coprime_X_sub_C _ _ { x // x ∈ s } (fun x => f x) (fun x y hxy => Subtype.eq <| H x.1 x.2 y.1 y.2 hxy) _ _ hxy) fun _ _ => separable_X_sub_C⟩ theorem separable_prod_X_sub_C_iff {ι : Sort _} [Fintype ι] {f : ι → F} : (∏ i, (X - C (f i))).Separable ↔ Function.Injective f := separable_prod_X_sub_C_iff'.trans <| by simp_rw [mem_univ, true_imp_iff, Function.Injective] section CharP variable (p : ℕ) [HF : CharP F p] theorem separable_or {f : F[X]} (hf : Irreducible f) : f.Separable ∨ ¬f.Separable ∧ ∃ g : F[X], Irreducible g ∧ expand F p g = f := by classical exact if H : derivative f = 0 then by rcases p.eq_zero_or_pos with (rfl | hp) · haveI := CharP.charP_to_charZero F have := natDegree_eq_zero_of_derivative_eq_zero H have := (natDegree_pos_iff_degree_pos.mpr <| degree_pos_of_irreducible hf).ne' contradiction haveI := isLocalHom_expand F hp exact Or.inr ⟨by rw [separable_iff_derivative_ne_zero hf, Classical.not_not, H], contract p f, Irreducible.of_map (by rwa [← expand_contract p H hp.ne'] at hf), expand_contract p H hp.ne'⟩ else Or.inl <| (separable_iff_derivative_ne_zero hf).2 H theorem exists_separable_of_irreducible {f : F[X]} (hf : Irreducible f) (hp : p ≠ 0) : ∃ (n : ℕ) (g : F[X]), g.Separable ∧ expand F (p ^ n) g = f := by replace hp : p.Prime := (CharP.char_is_prime_or_zero F p).resolve_right hp induction hn : f.natDegree using Nat.strong_induction_on generalizing f with | _ N ih rcases separable_or p hf with (h | ⟨h1, g, hg, hgf⟩) · refine ⟨0, f, h, ?_⟩ rw [pow_zero, expand_one] · rcases N with - | N · rw [natDegree_eq_zero_iff_degree_le_zero, degree_le_zero_iff] at hn rw [hn, separable_C, isUnit_iff_ne_zero, Classical.not_not] at h1 have hf0 : f ≠ 0 := hf.ne_zero rw [h1, C_0] at hn exact absurd hn hf0 have hg1 : g.natDegree * p = N.succ := by rwa [← natDegree_expand, hgf] have hg2 : g.natDegree ≠ 0 := by intro this rw [this, zero_mul] at hg1 cases hg1 have hg3 : g.natDegree < N.succ := by rw [← mul_one g.natDegree, ← hg1] exact Nat.mul_lt_mul_of_pos_left hp.one_lt hg2.bot_lt rcases ih _ hg3 hg rfl with ⟨n, g, hg4, rfl⟩ refine ⟨n + 1, g, hg4, ?_⟩ rw [← hgf, expand_expand, pow_succ'] theorem isUnit_or_eq_zero_of_separable_expand {f : F[X]} (n : ℕ) (hp : 0 < p) (hf : (expand F (p ^ n) f).Separable) : IsUnit f ∨ n = 0 := by rw [or_iff_not_imp_right] rintro hn : n ≠ 0 have hf2 : derivative (expand F (p ^ n) f) = 0 := by rw [derivative_expand, Nat.cast_pow, CharP.cast_eq_zero, zero_pow hn, zero_mul, mul_zero] rw [separable_def, hf2, isCoprime_zero_right, isUnit_iff] at hf rcases hf with ⟨r, hr, hrf⟩ rw [eq_comm, expand_eq_C (pow_pos hp _)] at hrf rwa [hrf, isUnit_C] theorem unique_separable_of_irreducible {f : F[X]} (hf : Irreducible f) (hp : 0 < p) (n₁ : ℕ) (g₁ : F[X]) (hg₁ : g₁.Separable) (hgf₁ : expand F (p ^ n₁) g₁ = f) (n₂ : ℕ) (g₂ : F[X]) (hg₂ : g₂.Separable) (hgf₂ : expand F (p ^ n₂) g₂ = f) : n₁ = n₂ ∧ g₁ = g₂ := by revert g₁ g₂ wlog hn : n₁ ≤ n₂ · intro g₁ hg₁ Hg₁ g₂ hg₂ Hg₂ simpa only [eq_comm] using this p hf hp n₂ n₁ (le_of_not_ge hn) g₂ hg₂ Hg₂ g₁ hg₁ Hg₁ intro g₁ hg₁ hgf₁ g₂ hg₂ hgf₂ rw [le_iff_exists_add] at hn rcases hn with ⟨k, rfl⟩ rw [← hgf₁, pow_add, expand_mul, expand_inj (pow_pos hp n₁)] at hgf₂ subst hgf₂ subst hgf₁ rcases isUnit_or_eq_zero_of_separable_expand p k hp hg₁ with (h | rfl) · rw [isUnit_iff] at h rcases h with ⟨r, hr, rfl⟩ simp_rw [expand_C] at hf exact absurd (isUnit_C.2 hr) hf.1 · rw [add_zero, pow_zero, expand_one] constructor <;> rfl end CharP /-- If `n ≠ 0` in `F`, then `X ^ n - a` is separable for any `a ≠ 0`. -/ theorem separable_X_pow_sub_C {n : ℕ} (a : F) (hn : (n : F) ≠ 0) (ha : a ≠ 0) : Separable (X ^ n - C a) := separable_X_pow_sub_C_unit (Units.mk0 a ha) (IsUnit.mk0 (n : F) hn) /-- If `F` is of characteristic `p` and `p ∤ n`, then `X ^ n - a` is separable for any `a ≠ 0`. -/ theorem separable_X_pow_sub_C' (p n : ℕ) (a : F) [CharP F p] (hn : ¬p ∣ n) (ha : a ≠ 0) : Separable (X ^ n - C a) := separable_X_pow_sub_C a (by rwa [← CharP.cast_eq_zero_iff F p n] at hn) ha -- this can possibly be strengthened to making `separable_X_pow_sub_C_unit` a -- bi-implication, but it is nontrivial! /-- In a field `F`, `X ^ n - 1` is separable iff `↑n ≠ 0`. -/ theorem X_pow_sub_one_separable_iff {n : ℕ} : (X ^ n - 1 : F[X]).Separable ↔ (n : F) ≠ 0 := by refine ⟨?_, fun h => separable_X_pow_sub_C_unit 1 (IsUnit.mk0 _ h)⟩ rw [separable_def', derivative_sub, derivative_X_pow, derivative_one, sub_zero] -- Suppose `(n : F) = 0`, then the derivative is `0`, so `X ^ n - 1` is a unit, contradiction. rintro (h : IsCoprime _ _) hn' rw [hn', C_0, zero_mul, isCoprime_zero_right] at h exact not_isUnit_X_pow_sub_one F n h section Splits theorem card_rootSet_eq_natDegree [Algebra F K] {p : F[X]} (hsep : p.Separable) (hsplit : Splits (algebraMap F K) p) : Fintype.card (p.rootSet K) = p.natDegree := by classical simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe] rw [Multiset.toFinset_card_of_nodup (nodup_roots hsep.map), ← natDegree_eq_card_roots hsplit] /-- If a non-zero polynomial splits, then it has no repeated roots on that field if and only if it is separable. -/ theorem nodup_roots_iff_of_splits {f : F[X]} (hf : f ≠ 0) (h : f.Splits (RingHom.id F)) : f.roots.Nodup ↔ f.Separable := by classical refine ⟨(fun hnsep ↦ ?_).mtr, nodup_roots⟩ rw [Separable, ← gcd_isUnit_iff, isUnit_iff_degree_eq_zero] at hnsep obtain ⟨x, hx⟩ := exists_root_of_splits _ (splits_of_splits_of_dvd _ hf h (gcd_dvd_left f _)) hnsep simp_rw [Multiset.nodup_iff_count_le_one, not_forall, not_le] exact ⟨x, ((one_lt_rootMultiplicity_iff_isRoot_gcd hf).2 hx).trans_eq f.count_roots.symm⟩ /-- If a non-zero polynomial over `F` splits in `K`, then it has no repeated roots on `K` if and only if it is separable. -/ @[stacks 09H3 "Here we only require `f` splits instead of `K` is algebraically closed."] theorem nodup_aroots_iff_of_splits [Algebra F K] {f : F[X]} (hf : f ≠ 0) (h : f.Splits (algebraMap F K)) : (f.aroots K).Nodup ↔ f.Separable := by rw [← (algebraMap F K).id_comp, ← splits_map_iff] at h rw [nodup_roots_iff_of_splits (map_ne_zero hf) h, separable_map] theorem card_rootSet_eq_natDegree_iff_of_splits [Algebra F K] {f : F[X]} (hf : f ≠ 0) (h : f.Splits (algebraMap F K)) : Fintype.card (f.rootSet K) = f.natDegree ↔ f.Separable := by classical simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe, natDegree_eq_card_roots h, Multiset.toFinset_card_eq_card_iff_nodup, nodup_aroots_iff_of_splits hf h] variable {i : F →+* K} theorem eq_X_sub_C_of_separable_of_root_eq {x : F} {h : F[X]} (h_sep : h.Separable) (h_root : h.eval x = 0) (h_splits : Splits i h) (h_roots : ∀ y ∈ (h.map i).roots, y = i x) : h = C (leadingCoeff h) * (X - C x) := by have h_ne_zero : h ≠ 0 := by rintro rfl exact not_separable_zero h_sep apply Polynomial.eq_X_sub_C_of_splits_of_single_root i h_splits apply Finset.mk.inj · change _ = {i x} rw [Finset.eq_singleton_iff_unique_mem] constructor · apply Finset.mem_mk.mpr · rw [mem_roots (show h.map i ≠ 0 from map_ne_zero h_ne_zero)] rw [IsRoot.def, ← eval₂_eq_eval_map, eval₂_hom, h_root] exact RingHom.map_zero i · exact nodup_roots (Separable.map h_sep) · exact h_roots theorem exists_finset_of_splits (i : F →+* K) {f : F[X]} (sep : Separable f) (sp : Splits i f) : ∃ s : Finset K, f.map i = C (i f.leadingCoeff) * s.prod fun a : K => X - C a := by classical obtain ⟨s, h⟩ := (splits_iff_exists_multiset _).1 sp use s.toFinset rw [h, Finset.prod_eq_multiset_prod, ← Multiset.toFinset_eq] apply nodup_of_separable_prod apply Separable.of_mul_right rw [← h] exact sep.map end Splits theorem _root_.Irreducible.separable [CharZero F] {f : F[X]} (hf : Irreducible f) : f.Separable := by rw [separable_iff_derivative_ne_zero hf, Ne, ← degree_eq_bot, degree_derivative_eq] · rintro ⟨⟩ exact Irreducible.natDegree_pos hf end Field end Polynomial open Polynomial section CommRing variable (F L K : Type*) [CommRing F] [Ring K] [Algebra F K] -- TODO: refactor to allow transcendental extensions? -- See: https://en.wikipedia.org/wiki/Separable_extension#Separability_of_transcendental_extensions -- Note that right now a Galois extension (class `IsGalois`) is defined to be an extension which -- is separable and normal, so if the definition of separable changes here at some point -- to allow non-algebraic extensions, then the definition of `IsGalois` must also be changed. variable {K} in /-- An element `x` of an algebra `K` over a commutative ring `F` is said to be *separable*, if its minimal polynomial over `K` is separable. Note that the minimal polynomial of any element not integral over `F` is defined to be `0`, which is not a separable polynomial. -/ @[stacks 09H1 "second part"] def IsSeparable (x : K) : Prop := Polynomial.Separable (minpoly F x) /-- Typeclass for separable field extension: `K` is a separable field extension of `F` iff the minimal polynomial of every `x : K` is separable. This implies that `K/F` is an algebraic extension, because the minimal polynomial of a non-integral element is `0`, which is not separable. We define this for general (commutative) rings and only assume `F` and `K` are fields if this is needed for a proof. -/ @[mk_iff isSeparable_def, stacks 09H1 "third part"] protected class Algebra.IsSeparable : Prop where isSeparable' : ∀ x : K, IsSeparable F x variable {K} theorem Algebra.IsSeparable.isSeparable [Algebra.IsSeparable F K] : ∀ x : K, IsSeparable F x := Algebra.IsSeparable.isSeparable' variable {F} in /-- If the minimal polynomial of `x : K` over `F` is separable, then `x` is integral over `F`, because the minimal polynomial of a non-integral element is `0`, which is not separable. -/ theorem IsSeparable.isIntegral {x : K} (h : IsSeparable F x) : IsIntegral F x := by cases subsingleton_or_nontrivial F · haveI := Module.subsingleton F K exact ⟨1, monic_one, Subsingleton.elim _ _⟩ · exact of_not_not (h.ne_zero <| minpoly.eq_zero ·) theorem Algebra.IsSeparable.isIntegral [Algebra.IsSeparable F K] : ∀ x : K, IsIntegral F x := fun x ↦ _root_.IsSeparable.isIntegral (Algebra.IsSeparable.isSeparable F x) variable (K) in instance Algebra.IsSeparable.isAlgebraic [Nontrivial F] [Algebra.IsSeparable F K] : Algebra.IsAlgebraic F K := ⟨fun x ↦ (Algebra.IsSeparable.isIntegral F x).isAlgebraic⟩ variable {F} theorem Algebra.isSeparable_iff : Algebra.IsSeparable F K ↔ ∀ x : K, IsIntegral F x ∧ IsSeparable F x := ⟨fun _ x => ⟨Algebra.IsSeparable.isIntegral F x, Algebra.IsSeparable.isSeparable F x⟩, fun h => ⟨fun x => (h x).2⟩⟩ variable {L} in lemma IsSeparable.map [Ring L] [Algebra F L] {x : K} (f : K →ₐ[F] L) (hf : Function.Injective f) (H : IsSeparable F x) : IsSeparable F (f x) := by rwa [IsSeparable, minpoly.algHom_eq _ hf] variable {E : Type*} section AlgEquiv variable [Ring E] [Algebra F E] (e : K ≃ₐ[F] E) include e /-- Transfer `IsSeparable` across an `AlgEquiv`. -/ theorem AlgEquiv.isSeparable_iff {x : K} : IsSeparable F (e x) ↔ IsSeparable F x := by simp only [IsSeparable, minpoly.algEquiv_eq e x] /-- Transfer `Algebra.IsSeparable` across an `AlgEquiv`. -/ theorem AlgEquiv.Algebra.isSeparable [Algebra.IsSeparable F K] : Algebra.IsSeparable F E := ⟨fun _ ↦ e.symm.isSeparable_iff.mp (Algebra.IsSeparable.isSeparable _ _)⟩ theorem AlgEquiv.Algebra.isSeparable_iff : Algebra.IsSeparable F K ↔ Algebra.IsSeparable F E := ⟨fun _ ↦ AlgEquiv.Algebra.isSeparable e, fun _ ↦ AlgEquiv.Algebra.isSeparable e.symm⟩ end AlgEquiv section IsScalarTower variable [Field L] [Ring E] [Algebra F L] [Algebra F E] [Algebra L E] [IsScalarTower F L E] /-- If `E / L / F` is a scalar tower and `x : E` is separable over `F`, then it's also separable over `L`. -/ @[stacks 09H2 "first part"] theorem IsSeparable.tower_top {x : E} (h : IsSeparable F x) : IsSeparable L x := .of_dvd (.map h) (minpoly.dvd_map_of_isScalarTower ..) variable (F E) in /-- If `E / K / F` is an extension tower, `E` is separable over `F`, then it's also separable over `K`. -/ @[stacks 09H2 "second part"] theorem Algebra.isSeparable_tower_top_of_isSeparable [Algebra.IsSeparable F E] : Algebra.IsSeparable L E := ⟨fun x ↦ IsSeparable.tower_top _ (Algebra.IsSeparable.isSeparable F x)⟩ end IsScalarTower end CommRing section Field variable (F : Type*) [Field F] {K E E' : Type*} section IsIntegral variable [Ring K] [Algebra F K] variable {F} in theorem isSeparable_algebraMap (x : F) : IsSeparable F (algebraMap F K x) := Polynomial.Separable.of_dvd (Polynomial.separable_X_sub_C (x := x)) (minpoly.dvd F (algebraMap F K x) (by simp only [map_sub, aeval_X, aeval_C, sub_self])) instance Algebra.isSeparable_self : Algebra.IsSeparable F F := ⟨isSeparable_algebraMap⟩ variable [IsDomain K] [Algebra.IsIntegral F K] [CharZero F] theorem IsSeparable.of_integral (x : K) : IsSeparable F x := (minpoly.irreducible <| Algebra.IsIntegral.isIntegral x).separable -- See note [lower instance priority] variable (K) in /-- A integral field extension in characteristic 0 is separable. -/ protected instance (priority := 100) Algebra.IsSeparable.of_integral : Algebra.IsSeparable F K := ⟨_root_.IsSeparable.of_integral _⟩ end IsIntegral section IsScalarTower variable [Field K] [Ring E] [Algebra F K] [Algebra F E] [Algebra K E] [Nontrivial E] [IsScalarTower F K E] variable {F} in /-- If `E / K / F` is a scalar tower and `algebraMap K E x` is separable over `F`, then `x` is also separable over `F`. -/ theorem IsSeparable.tower_bot {x : K} (h : IsSeparable F (algebraMap K E x)) : IsSeparable F x := have ⟨_q, hq⟩ := minpoly.dvd F x ((aeval_algebraMap_eq_zero_iff _ _ _).mp (minpoly.aeval F ((algebraMap K E) x))) (Eq.mp (congrArg Separable hq) h).of_mul_left variable (K E) in theorem Algebra.isSeparable_tower_bot_of_isSeparable [h : Algebra.IsSeparable F E] : Algebra.IsSeparable F K := ⟨fun _ ↦ IsSeparable.tower_bot (h.isSeparable _ _)⟩ end IsScalarTower section variable [Field E] [Field E'] [Algebra F E] [Algebra F E'] (f : E →ₐ[F] E') include f variable {F} in theorem IsSeparable.of_algHom {x : E} (h : IsSeparable F (f x)) : IsSeparable F x := by let _ : Algebra E E' := RingHom.toAlgebra f.toRingHom haveI : IsScalarTower F E E' := IsScalarTower.of_algebraMap_eq fun x => (f.commutes x).symm exact h.tower_bot variable (E') in theorem Algebra.IsSeparable.of_algHom [Algebra.IsSeparable F E'] : Algebra.IsSeparable F E := ⟨fun x => (Algebra.IsSeparable.isSeparable F (f x)).of_algHom⟩ end namespace IntermediateField variable [Field K] [Algebra F K] (M : IntermediateField F K) instance isSeparable_tower_bot [Algebra.IsSeparable F K] : Algebra.IsSeparable F M := Algebra.isSeparable_tower_bot_of_isSeparable F M K instance isSeparable_tower_top [Algebra.IsSeparable F K] : Algebra.IsSeparable M K := Algebra.isSeparable_tower_top_of_isSeparable F M K end IntermediateField end Field section AlgEquiv open RingHom RingEquiv variable {A₁ B₁ A₂ B₂ : Type*} [Field A₁] [Ring B₁] [Field A₂] [Ring B₂] [Algebra A₁ B₁] [Algebra A₂ B₂] (e₁ : A₁ ≃+* A₂) (e₂ : B₁ ≃+* B₂) (he : RingHom.comp (algebraMap A₂ B₂) ↑e₁ = RingHom.comp ↑e₂ (algebraMap A₁ B₁)) include he lemma IsSeparable.of_equiv_equiv {x : B₁} (h : IsSeparable A₁ x) : IsSeparable A₂ (e₂ x) := letI := e₁.toRingHom.toAlgebra letI : Algebra A₂ B₁ := { (algebraMap A₁ B₁).comp e₁.symm.toRingHom with algebraMap := (algebraMap A₁ B₁).comp e₁.symm.toRingHom smul := fun a b ↦ ((algebraMap A₁ B₁).comp e₁.symm.toRingHom a) * b commutes' := fun r x ↦ (Algebra.commutes) (e₁.symm.toRingHom r) x smul_def' := fun _ _ ↦ rfl } haveI : IsScalarTower A₁ A₂ B₁ := IsScalarTower.of_algebraMap_eq <| fun x ↦ (algebraMap A₁ B₁).congr_arg <| id ((e₁.symm_apply_apply x).symm) let e : B₁ ≃ₐ[A₂] B₂ := { e₂ with commutes' := fun x ↦ by simpa [RingHom.algebraMap_toAlgebra] using DFunLike.congr_fun he.symm (e₁.symm x) } (AlgEquiv.isSeparable_iff e).mpr <| IsSeparable.tower_top A₂ h lemma Algebra.IsSeparable.of_equiv_equiv [Algebra.IsSeparable A₁ B₁] : Algebra.IsSeparable A₂ B₂ := ⟨fun x ↦ (e₂.apply_symm_apply x) ▸ _root_.IsSeparable.of_equiv_equiv e₁ e₂ he (Algebra.IsSeparable.isSeparable _ _)⟩ end AlgEquiv section CardAlgHom variable {R S T : Type*} [CommRing S] variable {K L F : Type*} [Field K] [Field L] [Field F] variable [Algebra K S] [Algebra K L] theorem AlgHom.natCard_of_powerBasis (pb : PowerBasis K S) (h_sep : IsSeparable K pb.gen) (h_splits : (minpoly K pb.gen).Splits (algebraMap K L)) : Nat.card (S →ₐ[K] L) = pb.dim := by classical rw [Nat.card_congr pb.liftEquiv', Nat.subtype_card _ (fun x => Multiset.mem_toFinset), ← pb.natDegree_minpoly, natDegree_eq_card_roots h_splits, Multiset.toFinset_card_of_nodup] exact nodup_roots ((separable_map (algebraMap K L)).mpr h_sep) theorem AlgHom.card_of_powerBasis (pb : PowerBasis K S) (h_sep : IsSeparable K pb.gen) (h_splits : (minpoly K pb.gen).Splits (algebraMap K L)) : @Fintype.card (S →ₐ[K] L) (PowerBasis.AlgHom.fintype pb) = pb.dim := by classical rw [Fintype.card_eq_nat_card, AlgHom.natCard_of_powerBasis pb h_sep h_splits] end CardAlgHom
.lake/packages/mathlib/Mathlib/FieldTheory/Fixed.lean
import Mathlib.Algebra.Polynomial.GroupRingAction import Mathlib.Algebra.Ring.Action.Field import Mathlib.Algebra.Ring.Action.Invariant import Mathlib.FieldTheory.Finiteness import Mathlib.FieldTheory.Normal.Defs import Mathlib.FieldTheory.Separable import Mathlib.LinearAlgebra.Dual.Lemmas import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix /-! # Fixed field under a group action. This is the basis of the Fundamental Theorem of Galois Theory. Given a (finite) group `G` that acts on a field `F`, we define `FixedPoints.subfield G F`, the subfield consisting of elements of `F` fixed_points by every element of `G`. This subfield is then normal and separable, and in addition if `G` acts faithfully on `F` then `finrank (FixedPoints.subfield G F) F = Fintype.card G`. ## Main Definitions - `FixedPoints.subfield G F`, the subfield consisting of elements of `F` fixed_points by every element of `G`, where `G` is a group that acts on `F`. -/ noncomputable section open MulAction Finset Module universe u v w variable {M : Type u} [Monoid M] variable (G : Type u) [Group G] variable (F : Type v) [Field F] [MulSemiringAction M F] [MulSemiringAction G F] (m : M) /-- The subfield of F fixed by the field endomorphism `m`. -/ def FixedBy.subfield : Subfield F where carrier := fixedBy F m zero_mem' := smul_zero m add_mem' hx hy := (smul_add m _ _).trans <| congr_arg₂ _ hx hy neg_mem' hx := (smul_neg m _).trans <| congr_arg _ hx one_mem' := smul_one m mul_mem' hx hy := (smul_mul' m _ _).trans <| congr_arg₂ _ hx hy inv_mem' x hx := (smul_inv'' m x).trans <| congr_arg _ hx section InvariantSubfields variable (M) {F} /-- A typeclass for subrings invariant under a `MulSemiringAction`. -/ class IsInvariantSubfield (S : Subfield F) : Prop where smul_mem : ∀ (m : M) {x : F}, x ∈ S → m • x ∈ S variable (S : Subfield F) instance IsInvariantSubfield.toMulSemiringAction [IsInvariantSubfield M S] : MulSemiringAction M S where smul m x := ⟨m • x.1, IsInvariantSubfield.smul_mem m x.2⟩ one_smul s := Subtype.eq <| one_smul M s.1 mul_smul m₁ m₂ s := Subtype.eq <| mul_smul m₁ m₂ s.1 smul_add m s₁ s₂ := Subtype.eq <| smul_add m s₁.1 s₂.1 smul_zero m := Subtype.eq <| smul_zero m smul_one m := Subtype.eq <| smul_one m smul_mul m s₁ s₂ := Subtype.eq <| smul_mul' m s₁.1 s₂.1 instance [IsInvariantSubfield M S] : IsInvariantSubring M S.toSubring where smul_mem := IsInvariantSubfield.smul_mem end InvariantSubfields namespace FixedPoints variable (M) -- we use `Subfield.copy` so that the underlying set is `fixedPoints M F` /-- The subfield of fixed points by a monoid action. -/ def subfield : Subfield F := Subfield.copy (⨅ m : M, FixedBy.subfield F m) (fixedPoints M F) (by ext; simp [FixedBy.subfield]) instance : IsInvariantSubfield M (FixedPoints.subfield M F) where smul_mem g x hx g' := by rw [hx, hx] instance : SMulCommClass M (FixedPoints.subfield M F) F where smul_comm m f f' := show m • (↑f * f') = f * m • f' by rw [smul_mul', f.prop m] instance smulCommClass' : SMulCommClass (FixedPoints.subfield M F) M F := SMulCommClass.symm _ _ _ @[simp] theorem smul (m : M) (x : FixedPoints.subfield M F) : m • x = x := Subtype.eq <| x.2 m -- Why is this so slow? @[simp] theorem smul_polynomial (m : M) (p : Polynomial (FixedPoints.subfield M F)) : m • p = p := Polynomial.induction_on p (fun x => by rw [Polynomial.smul_C, smul]) (fun p q ihp ihq => by rw [smul_add, ihp, ihq]) fun n x _ => by rw [smul_mul', Polynomial.smul_C, smul, smul_pow', Polynomial.smul_X] instance : Algebra (FixedPoints.subfield M F) F := by infer_instance theorem coe_algebraMap : algebraMap (FixedPoints.subfield M F) F = Subfield.subtype (FixedPoints.subfield M F) := rfl theorem linearIndependent_smul_of_linearIndependent {s : Finset F} : (LinearIndepOn (FixedPoints.subfield G F) id (s : Set F)) → LinearIndepOn F (MulAction.toFun G F) s := by classical have : IsEmpty ((∅ : Finset F) : Set F) := by simp refine Finset.induction_on s (fun _ => linearIndependent_empty_type) fun a s has ih hs => ?_ rw [coe_insert] at hs ⊢ rw [linearIndepOn_insert (mt mem_coe.1 has)] at hs rw [linearIndepOn_insert (mt mem_coe.1 has)]; refine ⟨ih hs.1, fun ha => ?_⟩ rw [Finsupp.mem_span_image_iff_linearCombination] at ha; rcases ha with ⟨l, hl, hla⟩ rw [Finsupp.linearCombination_apply_of_mem_supported F hl] at hla suffices ∀ i ∈ s, l i ∈ FixedPoints.subfield G F by replace hla := (sum_apply _ _ fun i => l i • toFun G F i).symm.trans (congr_fun hla 1) simp_rw [Pi.smul_apply, toFun_apply, one_smul] at hla refine hs.2 (hla ▸ Submodule.sum_mem _ fun c hcs => ?_) change (⟨l c, this c hcs⟩ : FixedPoints.subfield G F) • c ∈ _ exact Submodule.smul_mem _ _ <| Submodule.subset_span <| by simpa intro i his g refine eq_of_sub_eq_zero (linearIndependent_iff'.1 (ih hs.1) s.attach (fun i => g • l i - l i) ?_ ⟨i, his⟩ (mem_attach _ _) : _) refine (sum_attach s fun i ↦ (g • l i - l i) • MulAction.toFun G F i).trans ?_ ext g'; dsimp only conv_lhs => rw [sum_apply] congr · skip · ext rw [Pi.smul_apply, sub_smul, smul_eq_mul] rw [sum_sub_distrib, Pi.zero_apply, sub_eq_zero] conv_lhs => congr · skip · ext x rw [toFun_apply, ← mul_inv_cancel_left g g', mul_smul, ← smul_mul', ← toFun_apply _ x] change (∑ x ∈ s, g • (fun y => l y • MulAction.toFun G F y) x (g⁻¹ * g')) = ∑ x ∈ s, (fun y => l y • MulAction.toFun G F y) x g' rw [← smul_sum, ← sum_apply _ _ fun y => l y • toFun G F y, ← sum_apply _ _ fun y => l y • toFun G F y] rw [hla, toFun_apply, toFun_apply, smul_smul, mul_inv_cancel_left] section Fintype variable [Fintype G] (x : F) /-- `minpoly G F x` is the minimal polynomial of `(x : F)` over `FixedPoints.subfield G F`. -/ def minpoly : Polynomial (FixedPoints.subfield G F) := (prodXSubSMul G F x).toSubring (FixedPoints.subfield G F).toSubring fun _ hc g => let ⟨n, _, hn⟩ := Polynomial.mem_coeffs_iff.1 hc hn.symm ▸ prodXSubSMul.coeff G F x g n namespace minpoly theorem monic : (minpoly G F x).Monic := by simp only [minpoly] rw [Polynomial.monic_toSubring] exact prodXSubSMul.monic G F x theorem eval₂ : Polynomial.eval₂ (Subring.subtype <| (FixedPoints.subfield G F).toSubring) x (minpoly G F x) = 0 := by rw [← prodXSubSMul.eval G F x, Polynomial.eval₂_eq_eval_map] simp only [minpoly, Polynomial.map_toSubring] theorem eval₂' : Polynomial.eval₂ (Subfield.subtype <| FixedPoints.subfield G F) x (minpoly G F x) = 0 := eval₂ G F x theorem ne_one : minpoly G F x ≠ (1 : Polynomial (FixedPoints.subfield G F)) := fun H => have := eval₂ G F x (one_ne_zero : (1 : F) ≠ 0) <| by rwa [H, Polynomial.eval₂_one] at this theorem of_eval₂ (f : Polynomial (FixedPoints.subfield G F)) (hf : Polynomial.eval₂ (Subfield.subtype <| FixedPoints.subfield G F) x f = 0) : minpoly G F x ∣ f := by classical rw [← Polynomial.map_dvd_map' (Subfield.subtype <| FixedPoints.subfield G F), minpoly, ← Subfield.toSubring_subtype_eq_subtype, Polynomial.map_toSubring _ _, prodXSubSMul] refine Fintype.prod_dvd_of_coprime (Polynomial.pairwise_coprime_X_sub_C <| MulAction.injective_ofQuotientStabilizer G x) fun y => QuotientGroup.induction_on y fun g => ?_ rw [Polynomial.dvd_iff_isRoot, Polynomial.IsRoot.def, MulAction.ofQuotientStabilizer_mk, Polynomial.eval_smul', ← IsInvariantSubring.coe_subtypeHom' G (FixedPoints.subfield G F).toSubring, ← MulSemiringActionHom.coe_polynomial, ← MulSemiringActionHom.map_smul, smul_polynomial, MulSemiringActionHom.coe_polynomial, IsInvariantSubring.coe_subtypeHom', Polynomial.eval_map, Subfield.toSubring_subtype_eq_subtype, hf, smul_zero] -- Why is this so slow? theorem irreducible_aux (f g : Polynomial (FixedPoints.subfield G F)) (hf : f.Monic) (hg : g.Monic) (hfg : f * g = minpoly G F x) : f = 1 ∨ g = 1 := by have hf2 : f ∣ minpoly G F x := by rw [← hfg]; exact dvd_mul_right _ _ have hg2 : g ∣ minpoly G F x := by rw [← hfg]; exact dvd_mul_left _ _ have := eval₂ G F x rw [← hfg, Polynomial.eval₂_mul, mul_eq_zero] at this rcases this with this | this · right have hf3 : f = minpoly G F x := Polynomial.eq_of_monic_of_associated hf (monic G F x) (associated_of_dvd_dvd hf2 <| @of_eval₂ G _ F _ _ _ x f this) rwa [← mul_one (minpoly G F x), hf3, mul_right_inj' (monic G F x).ne_zero] at hfg · left have hg3 : g = minpoly G F x := Polynomial.eq_of_monic_of_associated hg (monic G F x) (associated_of_dvd_dvd hg2 <| @of_eval₂ G _ F _ _ _ x g this) rwa [← one_mul (minpoly G F x), hg3, mul_left_inj' (monic G F x).ne_zero] at hfg theorem irreducible : Irreducible (minpoly G F x) := (Polynomial.irreducible_of_monic (monic G F x) (ne_one G F x)).2 (irreducible_aux G F x) end minpoly end Fintype theorem isIntegral [Finite G] (x : F) : IsIntegral (FixedPoints.subfield G F) x := by cases nonempty_fintype G; exact ⟨minpoly G F x, minpoly.monic G F x, minpoly.eval₂ G F x⟩ section Fintype variable [Fintype G] (x : F) theorem minpoly_eq_minpoly : minpoly G F x = _root_.minpoly (FixedPoints.subfield G F) x := minpoly.eq_of_irreducible_of_monic (minpoly.irreducible G F x) (minpoly.eval₂ G F x) (minpoly.monic G F x) theorem rank_le_card : Module.rank (FixedPoints.subfield G F) F ≤ Fintype.card G := rank_le fun s hs => by simpa only [rank_fun', Cardinal.mk_coe_finset, Finset.coe_sort_coe, Cardinal.lift_natCast, Nat.cast_le] using (linearIndependent_smul_of_linearIndependent G F hs).cardinal_lift_le_rank end Fintype section Finite variable [Finite G] instance normal : Normal (FixedPoints.subfield G F) F where isAlgebraic x := (isIntegral G F x).isAlgebraic splits' x := (Polynomial.splits_id_iff_splits _).1 <| by cases nonempty_fintype G rw [← minpoly_eq_minpoly, minpoly, coe_algebraMap, ← Subfield.toSubring_subtype_eq_subtype, Polynomial.map_toSubring _ (subfield G F).toSubring, prodXSubSMul] exact Polynomial.splits_prod _ fun _ _ => Polynomial.splits_X_sub_C _ instance isSeparable : Algebra.IsSeparable (FixedPoints.subfield G F) F := by classical exact ⟨fun x => by cases nonempty_fintype G rw [IsSeparable, ← minpoly_eq_minpoly, ← Polynomial.separable_map (FixedPoints.subfield G F).subtype, minpoly, ← Subfield.toSubring_subtype_eq_subtype, Polynomial.map_toSubring _ (subfield G F).toSubring] exact Polynomial.separable_prod_X_sub_C_iff.2 (injective_ofQuotientStabilizer G x)⟩ instance : FiniteDimensional (subfield G F) F := by cases nonempty_fintype G exact IsNoetherian.iff_fg.1 (IsNoetherian.iff_rank_lt_aleph0.2 <| (rank_le_card G F).trans_lt <| Cardinal.nat_lt_aleph0 _) end Finite theorem finrank_le_card [Fintype G] : finrank (subfield G F) F ≤ Fintype.card G := by rw [← @Nat.cast_le Cardinal, finrank_eq_rank] apply rank_le_card end FixedPoints theorem linearIndependent_toLinearMap (R : Type u) (A : Type v) (B : Type w) [CommSemiring R] [Semiring A] [Algebra R A] [CommRing B] [IsDomain B] [Algebra R B] : LinearIndependent B (AlgHom.toLinearMap : (A →ₐ[R] B) → A →ₗ[R] B) := have : LinearIndependent B (LinearMap.ltoFun R A B ∘ AlgHom.toLinearMap) := ((linearIndependent_monoidHom A B).comp ((↑) : (A →ₐ[R] B) → A →* B) fun _ _ hfg => AlgHom.ext fun _ => DFunLike.ext_iff.1 hfg _ : _) this.of_comp _ theorem cardinalMk_algHom (K : Type u) (V : Type v) (W : Type w) [Field K] [Ring V] [Algebra K V] [FiniteDimensional K V] [Field W] [Algebra K W] : Cardinal.mk (V →ₐ[K] W) ≤ finrank W (V →ₗ[K] W) := (linearIndependent_toLinearMap K V W).cardinalMk_le_finrank noncomputable instance AlgEquiv.fintype (K : Type u) (V : Type v) [Field K] [Field V] [Algebra K V] [FiniteDimensional K V] : Fintype (V ≃ₐ[K] V) := Fintype.ofEquiv (V →ₐ[K] V) (algEquivEquivAlgHom K V).symm theorem finrank_algHom (K : Type u) (V : Type v) [Field K] [Field V] [Algebra K V] [FiniteDimensional K V] : Fintype.card (V →ₐ[K] V) ≤ finrank V (V →ₗ[K] V) := (linearIndependent_toLinearMap K V V).fintype_card_le_finrank theorem AlgHom.card_le {F K : Type*} [Field F] [Field K] [Algebra F K] [FiniteDimensional F K] : Fintype.card (K →ₐ[F] K) ≤ Module.finrank F K := Module.finrank_linearMap_self F K K ▸ finrank_algHom F K theorem AlgEquiv.card_le {F K : Type*} [Field F] [Field K] [Algebra F K] [FiniteDimensional F K] : Fintype.card Gal(K/F) ≤ Module.finrank F K := Fintype.ofEquiv_card (algEquivEquivAlgHom F K).toEquiv.symm ▸ AlgHom.card_le namespace FixedPoints variable (G F : Type*) [Group G] [Field F] [MulSemiringAction G F] /-- Let $F$ be a field. Let $G$ be a finite group acting faithfully on $F$. Then $[F : F^G] = |G|$. -/ @[stacks 09I3 "second part"] theorem finrank_eq_card [Fintype G] [FaithfulSMul G F] : finrank (FixedPoints.subfield G F) F = Fintype.card G := le_antisymm (FixedPoints.finrank_le_card G F) <| calc Fintype.card G ≤ Fintype.card (F →ₐ[FixedPoints.subfield G F] F) := Fintype.card_le_of_injective _ (MulSemiringAction.toAlgHom_injective _ F) _ ≤ finrank F (F →ₗ[FixedPoints.subfield G F] F) := finrank_algHom (subfield G F) F _ = finrank (FixedPoints.subfield G F) F := finrank_linearMap_self _ _ _ /-- `MulSemiringAction.toAlgHom` is bijective. -/ theorem toAlgHom_bijective [Finite G] [FaithfulSMul G F] : Function.Bijective (MulSemiringAction.toAlgHom _ _ : G → F →ₐ[subfield G F] F) := by cases nonempty_fintype G rw [Fintype.bijective_iff_injective_and_card] constructor · exact MulSemiringAction.toAlgHom_injective _ F · apply le_antisymm · exact Fintype.card_le_of_injective _ (MulSemiringAction.toAlgHom_injective _ F) · rw [← finrank_eq_card G F] exact LE.le.trans_eq (finrank_algHom _ F) (finrank_linearMap_self _ _ _) /-- Bijection between `G` and algebra endomorphisms of `F` that fix the fixed points. -/ def toAlgHomEquiv [Finite G] [FaithfulSMul G F] : G ≃ (F →ₐ[FixedPoints.subfield G F] F) := Equiv.ofBijective _ (toAlgHom_bijective G F) /-- `MulSemiringAction.toAlgAut` is bijective. -/ theorem toAlgAut_bijective [Finite G] [FaithfulSMul G F] : Function.Bijective (MulSemiringAction.toAlgAut G (FixedPoints.subfield G F) F) := by refine ⟨fun _ _ h ↦ (FixedPoints.toAlgHom_bijective G F).injective ?_, fun f ↦ ((FixedPoints.toAlgHom_bijective G F).surjective f).imp (fun _ h ↦ ?_)⟩ <;> rwa [DFunLike.ext_iff] at h ⊢ /-- Bijection between `G` and algebra automorphisms of `F` that fix the fixed points. -/ def toAlgAutMulEquiv [Finite G] [FaithfulSMul G F] : G ≃* (F ≃ₐ[FixedPoints.subfield G F] F) := MulEquiv.ofBijective _ (toAlgAut_bijective G F) /-- `MulSemiringAction.toAlgAut` is surjective. -/ theorem toAlgAut_surjective [Finite G] : Function.Surjective (MulSemiringAction.toAlgAut G (FixedPoints.subfield G F) F) := by let f : G →* F ≃ₐ[FixedPoints.subfield G F] F := MulSemiringAction.toAlgAut G (FixedPoints.subfield G F) F let Q := G ⧸ f.ker let _ : MulSemiringAction Q F := MulSemiringAction.compHom _ (QuotientGroup.kerLift f) have : FaithfulSMul Q F := ⟨by intro q₁ q₂ refine Quotient.inductionOn₂' q₁ q₂ (fun g₁ g₂ h ↦ QuotientGroup.eq.mpr ?_) rwa [MonoidHom.mem_ker, map_mul, map_inv, inv_mul_eq_one, AlgEquiv.ext_iff]⟩ intro f obtain ⟨q, hq⟩ := (toAlgAut_bijective Q F).surjective (AlgEquiv.ofRingEquiv (f := f) (fun ⟨x, hx⟩ ↦ f.commutes' ⟨x, fun g ↦ hx g⟩)) revert hq refine QuotientGroup.induction_on q (fun g hg ↦ ⟨g, ?_⟩) rwa [AlgEquiv.ext_iff] at hg ⊢ end FixedPoints
.lake/packages/mathlib/Mathlib/FieldTheory/PerfectClosure.lean
import Mathlib.Algebra.CharP.Lemmas import Mathlib.FieldTheory.Perfect /-! # The perfect closure of a characteristic `p` ring ## Main definitions - `PerfectClosure`: the perfect closure of a characteristic `p` ring, which is the smallest extension that makes frobenius surjective. - `PerfectClosure.mk K p (n, x)`: for `n : ℕ` and `x : K` this is `x ^ (p ^ -n)` viewed as an element of `PerfectClosure K p`. Every element of `PerfectClosure K p` is of this form (`PerfectClosure.mk_surjective`). - `PerfectClosure.of`: the structure map from `K` to `PerfectClosure K p`. - `PerfectClosure.lift`: given a ring `K` of characteristic `p` and a perfect ring `L` of the same characteristic, any homomorphism `K →+* L` can be lifted to `PerfectClosure K p`. ## Main results - `PerfectClosure.induction_on`: to prove a result for all elements of the perfect closure, one only needs to prove it for all elements of the form `x ^ (p ^ -n)`. - `PerfectClosure.mk_mul_mk`, `PerfectClosure.one_def`, `PerfectClosure.mk_add_mk`, `PerfectClosure.neg_mk`, `PerfectClosure.zero_def`, `PerfectClosure.mk_zero_zero`, `PerfectClosure.mk_zero`, `PerfectClosure.mk_inv`, `PerfectClosure.mk_pow`: how to do multiplication, addition, etc. on elements of form `x ^ (p ^ -n)`. - `PerfectClosure.mk_eq_iff`: when does `x ^ (p ^ -n)` equal. - `PerfectClosure.eq_iff`: same as `PerfectClosure.mk_eq_iff` but with additional assumption that `K` being reduced, hence gives a simpler criterion. - `PerfectClosure.instPerfectRing`: `PerfectClosure K p` is a perfect ring. ## Tags perfect ring, perfect closure -/ universe u v open Function section variable (K : Type u) [CommRing K] (p : ℕ) [Fact p.Prime] [CharP K p] /-- `PerfectClosure.R` is the relation `(n, x) ∼ (n + 1, x ^ p)` for `n : ℕ` and `x : K`. `PerfectClosure K p` is the quotient by this relation. -/ @[mk_iff] inductive PerfectClosure.R : ℕ × K → ℕ × K → Prop | intro : ∀ n x, PerfectClosure.R (n, x) (n + 1, frobenius K p x) /-- The perfect closure is the smallest extension that makes frobenius surjective. -/ def PerfectClosure : Type u := Quot (PerfectClosure.R K p) end namespace PerfectClosure variable (K : Type u) section Ring variable [CommRing K] (p : ℕ) [Fact p.Prime] [CharP K p] /-- `PerfectClosure.mk K p (n, x)` for `n : ℕ` and `x : K` is an element of `PerfectClosure K p`, viewed as `x ^ (p ^ -n)`. Every element of `PerfectClosure K p` is of this form (`PerfectClosure.mk_surjective`). -/ def mk (x : ℕ × K) : PerfectClosure K p := Quot.mk (R K p) x theorem mk_surjective : Function.Surjective (mk K p) := Quot.mk_surjective @[simp] theorem mk_succ_pow (m : ℕ) (x : K) : mk K p ⟨m + 1, x ^ p⟩ = mk K p ⟨m, x⟩ := Eq.symm <| Quot.sound (R.intro m x) @[simp] theorem quot_mk_eq_mk (x : ℕ × K) : (Quot.mk (R K p) x : PerfectClosure K p) = mk K p x := rfl variable {K p} /-- Lift a function `ℕ × K → L` to a function on `PerfectClosure K p`. -/ def liftOn {L : Type*} (x : PerfectClosure K p) (f : ℕ × K → L) (hf : ∀ x y, R K p x y → f x = f y) : L := Quot.liftOn x f hf @[simp] theorem liftOn_mk {L : Sort _} (f : ℕ × K → L) (hf : ∀ x y, R K p x y → f x = f y) (x : ℕ × K) : (mk K p x).liftOn f hf = f x := rfl @[elab_as_elim] theorem induction_on (x : PerfectClosure K p) {q : PerfectClosure K p → Prop} (h : ∀ x, q (mk K p x)) : q x := Quot.inductionOn x h variable (K p) private theorem mul_aux_left (x1 x2 y : ℕ × K) (H : R K p x1 x2) : mk K p (x1.1 + y.1, (frobenius K p)^[y.1] x1.2 * (frobenius K p)^[x1.1] y.2) = mk K p (x2.1 + y.1, (frobenius K p)^[y.1] x2.2 * (frobenius K p)^[x2.1] y.2) := match x1, x2, H with | _, _, R.intro n x => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← map_mul, Nat.succ_add] apply R.intro private theorem mul_aux_right (x y1 y2 : ℕ × K) (H : R K p y1 y2) : mk K p (x.1 + y1.1, (frobenius K p)^[y1.1] x.2 * (frobenius K p)^[x.1] y1.2) = mk K p (x.1 + y2.1, (frobenius K p)^[y2.1] x.2 * (frobenius K p)^[x.1] y2.2) := match y1, y2, H with | _, _, R.intro n y => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← map_mul] apply R.intro instance instMul : Mul (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => Quot.lift (fun y : ℕ × K => mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 * (frobenius K p)^[x.1] y.2)) (mul_aux_right K p x)) fun x1 x2 (H : R K p x1 x2) => funext fun e => Quot.inductionOn e fun y => mul_aux_left K p x1 x2 y H⟩ @[simp] theorem mk_mul_mk (x y : ℕ × K) : mk K p x * mk K p y = mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 * (frobenius K p)^[x.1] y.2) := rfl instance instCommMonoid : CommMonoid (PerfectClosure K p) := { (inferInstance : Mul (PerfectClosure K p)) with mul_assoc := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by apply congr_arg (Quot.mk _) simp only [mul_assoc, iterate_map_mul, ← iterate_add_apply, add_comm, add_left_comm] one := mk K p (0, 1) one_mul := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_one, iterate_zero_apply, one_mul, zero_add] mul_one := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_one, iterate_zero_apply, mul_one, add_zero] mul_comm := fun e f => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => congr_arg (Quot.mk _) <| by simp only [add_comm, mul_comm] } theorem one_def : (1 : PerfectClosure K p) = mk K p (0, 1) := rfl instance instInhabited : Inhabited (PerfectClosure K p) := ⟨1⟩ private theorem add_aux_left (x1 x2 y : ℕ × K) (H : R K p x1 x2) : mk K p (x1.1 + y.1, (frobenius K p)^[y.1] x1.2 + (frobenius K p)^[x1.1] y.2) = mk K p (x2.1 + y.1, (frobenius K p)^[y.1] x2.2 + (frobenius K p)^[x2.1] y.2) := match x1, x2, H with | _, _, R.intro n x => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← map_add, Nat.succ_add] apply R.intro private theorem add_aux_right (x y1 y2 : ℕ × K) (H : R K p y1 y2) : mk K p (x.1 + y1.1, (frobenius K p)^[y1.1] x.2 + (frobenius K p)^[x.1] y1.2) = mk K p (x.1 + y2.1, (frobenius K p)^[y2.1] x.2 + (frobenius K p)^[x.1] y2.2) := match y1, y2, H with | _, _, R.intro n y => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← map_add] apply R.intro instance instAdd : Add (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => Quot.lift (fun y : ℕ × K => mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 + (frobenius K p)^[x.1] y.2)) (add_aux_right K p x)) fun x1 x2 (H : R K p x1 x2) => funext fun e => Quot.inductionOn e fun y => add_aux_left K p x1 x2 y H⟩ @[simp] theorem mk_add_mk (x y : ℕ × K) : mk K p x + mk K p y = mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 + (frobenius K p)^[x.1] y.2) := rfl instance instNeg : Neg (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => mk K p (x.1, -x.2)) fun x y (H : R K p x y) => match x, y, H with | _, _, R.intro n x => Quot.sound <| by rw [← map_neg]; apply R.intro⟩ @[simp] theorem neg_mk (x : ℕ × K) : -mk K p x = mk K p (x.1, -x.2) := rfl instance instZero : Zero (PerfectClosure K p) := ⟨mk K p (0, 0)⟩ theorem zero_def : (0 : PerfectClosure K p) = mk K p (0, 0) := rfl /-- Prior to https://github.com/leanprover-community/mathlib4/pull/15862, this lemma was called `mk_zero_zero`. See `mk_zero_right` for the lemma used to be called `mk_zero`. -/ @[simp] theorem mk_zero : mk K p 0 = 0 := rfl @[simp] theorem mk_zero_right (n : ℕ) : mk K p (n, 0) = 0 := by induction n with | zero => rfl | succ n ih => rw [← ih] apply (Quot.sound _).symm have := R.intro (p := p) n (0 : K) rwa [map_zero] at this theorem R.sound (m n : ℕ) (x y : K) (H : (frobenius K p)^[m] x = y) : mk K p (n, x) = mk K p (m + n, y) := by subst H induction m with | zero => simp only [zero_add, iterate_zero_apply] | succ m ih => rw [ih, Nat.succ_add, iterate_succ'] apply Quot.sound apply R.intro instance instAddCommGroup : AddCommGroup (PerfectClosure K p) := { (inferInstance : Add (PerfectClosure K p)), (inferInstance : Neg (PerfectClosure K p)) with add_assoc := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by apply congr_arg (Quot.mk _) simp only [iterate_map_add, ← iterate_add_apply, add_assoc, add_comm s _] zero_add := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_zero, iterate_zero_apply, zero_add] add_zero := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_zero, iterate_zero_apply, add_zero] sub_eq_add_neg := fun _ _ => rfl neg_add_cancel := fun e => Quot.inductionOn e fun ⟨n, x⟩ => by simp only [quot_mk_eq_mk, neg_mk, mk_add_mk, iterate_map_neg, neg_add_cancel, mk_zero_right] add_comm := fun e f => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => congr_arg (Quot.mk _) <| by simp only [add_comm] nsmul := nsmulRec zsmul := zsmulRec } instance instCommRing : CommRing (PerfectClosure K p) := { instAddCommGroup K p, AddMonoidWithOne.unary, (inferInstance : CommMonoid (PerfectClosure K p)) with zero_mul := fun a => by refine Quot.inductionOn a fun ⟨m, x⟩ => ?_ rw [zero_def, quot_mk_eq_mk, mk_mul_mk] simp only [zero_add, iterate_zero, id_eq, iterate_map_zero, zero_mul, mk_zero_right] mul_zero := fun a => by refine Quot.inductionOn a fun ⟨m, x⟩ => ?_ rw [zero_def, quot_mk_eq_mk, mk_mul_mk] simp only [iterate_zero, id_eq, iterate_map_zero, mul_zero, mk_zero_right] left_distrib := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by simp only [quot_mk_eq_mk, mk_add_mk, mk_mul_mk, add_comm, add_left_comm] apply R.sound simp only [iterate_map_mul, iterate_map_add, ← iterate_add_apply, mul_add, add_comm, add_left_comm] right_distrib := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by simp only [quot_mk_eq_mk, mk_add_mk, mk_mul_mk, add_assoc, add_comm _ s, add_left_comm _ s] apply R.sound simp only [iterate_map_mul, iterate_map_add, ← iterate_add_apply, add_mul, add_comm, add_left_comm] } theorem mk_eq_iff (x y : ℕ × K) : mk K p x = mk K p y ↔ ∃ z, (frobenius K p)^[y.1 + z] x.2 = (frobenius K p)^[x.1 + z] y.2 := by constructor · intro H replace H := Quot.eqvGen_exact H induction H with | rel x y H => obtain ⟨n, x⟩ := H; exact ⟨0, rfl⟩ | refl H => exact ⟨0, rfl⟩ | symm x y H ih => obtain ⟨w, ih⟩ := ih; exact ⟨w, ih.symm⟩ | trans x y z H1 H2 ih1 ih2 => obtain ⟨z1, ih1⟩ := ih1 obtain ⟨z2, ih2⟩ := ih2 exists z2 + (y.1 + z1) rw [← add_assoc, iterate_add_apply, ih1] rw [← iterate_add_apply, add_comm, iterate_add_apply, ih2] rw [← iterate_add_apply] simp only [add_comm, add_left_comm] intro H obtain ⟨m, x⟩ := x obtain ⟨n, y⟩ := y obtain ⟨z, H⟩ := H; dsimp only at H rw [R.sound K p (n + z) m x _ rfl, R.sound K p (m + z) n y _ rfl, H] rw [add_assoc, add_comm, add_comm z] @[simp] theorem mk_pow (x : ℕ × K) (n : ℕ) : mk K p x ^ n = mk K p (x.1, x.2 ^ n) := by induction n with | zero => rw [pow_zero, pow_zero, one_def, mk_eq_iff] exact ⟨0, by simp_rw [← coe_iterateFrobenius, map_one]⟩ | succ n ih => rw [pow_succ, pow_succ, ih, mk_mul_mk, mk_eq_iff] exact ⟨0, by simp_rw [iterate_frobenius, add_zero, mul_pow, ← pow_mul, ← pow_add, mul_assoc, ← pow_add]⟩ theorem natCast (n x : ℕ) : (x : PerfectClosure K p) = mk K p (n, x) := by induction n with | zero => induction x with | zero => simp | succ x ih => simp [Nat.cast_succ, ih, one_def] | succ n ih => rw [ih]; apply Quot.sound suffices R K p (n, (x : K)) (Nat.succ n, frobenius K p (x : K)) by rwa [map_natCast] at this apply R.intro theorem intCast (x : ℤ) : (x : PerfectClosure K p) = mk K p (0, x) := by cases x <;> simp [natCast K p 0] theorem natCast_eq_iff (x y : ℕ) : (x : PerfectClosure K p) = y ↔ (x : K) = y := by constructor <;> intro H · rw [natCast K p 0, natCast K p 0, mk_eq_iff] at H obtain ⟨z, H⟩ := H simpa only [zero_add, iterate_fixed (map_natCast _ _)] using H rw [natCast K p 0, natCast K p 0, H] instance instCharP : CharP (PerfectClosure K p) p := by constructor; intro x; rw [← CharP.cast_eq_zero_iff K] rw [← Nat.cast_zero, natCast_eq_iff, Nat.cast_zero] theorem frobenius_mk (x : ℕ × K) : (frobenius (PerfectClosure K p) p : PerfectClosure K p → PerfectClosure K p) (mk K p x) = mk _ _ (x.1, x.2 ^ p) := by simp only [frobenius_def] exact mk_pow K p x p /-- Embedding of `K` into `PerfectClosure K p` -/ def of : K →+* PerfectClosure K p where toFun x := mk _ _ (0, x) map_one' := rfl map_mul' _ _ := rfl map_zero' := rfl map_add' _ _ := rfl theorem of_apply (x : K) : of K p x = mk _ _ (0, x) := rfl instance instReduced : IsReduced (PerfectClosure K p) where eq_zero x := induction_on x fun x ⟨n, h⟩ ↦ by replace h : mk K p x ^ p ^ n = 0 := by rw [← Nat.sub_add_cancel ((n.lt_pow_self (Fact.out : p.Prime).one_lt).le), pow_add, h, mul_zero] simp only [zero_def, mk_pow, mk_eq_iff, zero_add, ← coe_iterateFrobenius, map_zero] at h ⊢ obtain ⟨m, h⟩ := h exact ⟨n + m, by simpa only [iterateFrobenius_def, pow_add, pow_mul] using h⟩ instance instPerfectRing : PerfectRing (PerfectClosure K p) p where bijective_frobenius := by let f : PerfectClosure K p → PerfectClosure K p := fun e ↦ liftOn e (fun x => mk K p (x.1 + 1, x.2)) fun x y H => match x, y, H with | _, _, R.intro n x => Quot.sound (R.intro _ _) refine bijective_iff_has_inverse.mpr ⟨f, fun e ↦ induction_on e fun ⟨n, x⟩ ↦ ?_, fun e ↦ induction_on e fun ⟨n, x⟩ ↦ ?_⟩ <;> simp only [f, liftOn_mk, frobenius_mk, mk_succ_pow] @[simp] theorem iterate_frobenius_mk (n : ℕ) (x : K) : (frobenius (PerfectClosure K p) p)^[n] (mk K p ⟨n, x⟩) = of K p x := by induction n with | zero => rfl | succ n ih => rw [iterate_succ_apply, ← ih, frobenius_mk, mk_succ_pow] /-- Given a ring `K` of characteristic `p` and a perfect ring `L` of the same characteristic, any homomorphism `K →+* L` can be lifted to `PerfectClosure K p`. -/ noncomputable def lift (L : Type v) [CommSemiring L] [CharP L p] [PerfectRing L p] : (K →+* L) ≃ (PerfectClosure K p →+* L) where toFun f := { toFun := by refine fun e => liftOn e (fun x => (frobeniusEquiv L p).symm^[x.1] (f x.2)) ?_ rintro - - ⟨n, x⟩ simp [f.map_frobenius] map_one' := f.map_one map_zero' := f.map_zero map_mul' := by rintro ⟨n, x⟩ ⟨m, y⟩ simp only [quot_mk_eq_mk, liftOn_mk, f.map_iterate_frobenius, mk_mul_mk, map_mul, iterate_map_mul] have := LeftInverse.iterate (frobeniusEquiv_symm_apply_frobenius L p) rw [iterate_add_apply, this _ _, add_comm, iterate_add_apply, this _ _] map_add' := by rintro ⟨n, x⟩ ⟨m, y⟩ simp only [quot_mk_eq_mk, liftOn_mk, f.map_iterate_frobenius, mk_add_mk, map_add, iterate_map_add] have := LeftInverse.iterate (frobeniusEquiv_symm_apply_frobenius L p) rw [iterate_add_apply, this _ _, add_comm n, iterate_add_apply, this _ _] } invFun f := f.comp (of K p) right_inv f := by ext ⟨n, x⟩ simp only [quot_mk_eq_mk, RingHom.comp_apply, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, liftOn_mk] apply (injective_frobenius L p).iterate n rw [← f.map_iterate_frobenius, iterate_frobenius_mk, RightInverse.iterate (frobenius_apply_frobeniusEquiv_symm L p) n] end Ring theorem eq_iff [CommRing K] [IsReduced K] (p : ℕ) [Fact p.Prime] [CharP K p] (x y : ℕ × K) : mk K p x = mk K p y ↔ (frobenius K p)^[y.1] x.2 = (frobenius K p)^[x.1] y.2 := (mk_eq_iff K p x y).trans ⟨fun ⟨z, H⟩ => (frobenius_inj K p).iterate z <| by simpa only [add_comm, iterate_add] using H, fun H => ⟨0, H⟩⟩ instance [CommRing K] [IsReduced K] (p : ℕ) [Fact p.Prime] [CharP K p] [Nontrivial K] : Nontrivial (PerfectClosure K p) where exists_pair_ne := ⟨0, 1, fun H => zero_ne_one ((eq_iff _ _ _ _).1 H)⟩ section Field variable [Field K] (p : ℕ) [Fact p.Prime] [CharP K p] instance instInv : Inv (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => Quot.mk (R K p) (x.1, x.2⁻¹)) fun x y (H : R K p x y) => match x, y, H with | _, _, R.intro n x => Quot.sound <| by simp only [frobenius_def] rw [← inv_pow] apply R.intro⟩ @[simp] theorem mk_inv (x : ℕ × K) : (mk K p x)⁻¹ = mk K p (x.1, x.2⁻¹) := rfl instance instDivisionRing : DivisionRing (PerfectClosure K p) where mul_inv_cancel e := induction_on e fun ⟨m, x⟩ H ↦ by have := mt (eq_iff _ _ _ _).2 H rw [mk_inv, mk_mul_mk] refine (eq_iff K p _ _).2 ?_ simp only [iterate_map_one, iterate_map_zero, iterate_zero_apply, ← iterate_map_mul] at this ⊢ rw [mul_inv_cancel₀ this, iterate_map_one] inv_zero := congr_arg (Quot.mk (R K p)) (by rw [inv_zero]) nnqsmul := _ nnqsmul_def := fun _ _ => rfl qsmul := _ qsmul_def := fun _ _ => rfl instance instField : Field (PerfectClosure K p) := { (inferInstance : DivisionRing (PerfectClosure K p)), (inferInstance : CommRing (PerfectClosure K p)) with } instance instPerfectField : PerfectField (PerfectClosure K p) := PerfectRing.toPerfectField _ p end Field end PerfectClosure
.lake/packages/mathlib/Mathlib/FieldTheory/Finiteness.lean
import Mathlib.LinearAlgebra.Basis.VectorSpace import Mathlib.LinearAlgebra.Dimension.Constructions import Mathlib.LinearAlgebra.Dimension.Finite /-! # A module over a division ring is Noetherian if and only if it is finite. -/ universe u v open Cardinal Submodule Module Function namespace IsNoetherian variable {K : Type u} {V : Type v} [DivisionRing K] [AddCommGroup V] [Module K V] /-- A module over a division ring is Noetherian if and only if its dimension (as a cardinal) is strictly less than the first infinite cardinal `ℵ₀`. -/ theorem iff_rank_lt_aleph0 : IsNoetherian K V ↔ Module.rank K V < ℵ₀ := by let b := Basis.ofVectorSpace K V rw [← b.mk_eq_rank'', lt_aleph0_iff_set_finite] constructor · intro exact (Basis.ofVectorSpaceIndex.linearIndependent K V).set_finite_of_isNoetherian · intro hbfinite refine @isNoetherian_of_linearEquiv K (⊤ : Submodule K V) V _ _ _ _ _ (LinearEquiv.ofTop _ rfl) (id ?_) refine isNoetherian_of_fg_of_noetherian _ ⟨Set.Finite.toFinset hbfinite, ?_⟩ rw [Set.Finite.coe_toFinset, ← b.span_eq, Basis.coe_ofVectorSpace, Subtype.range_coe] /-- In a Noetherian module over a division ring, all bases are indexed by a finite type. -/ noncomputable def fintypeBasisIndex {ι : Type*} [IsNoetherian K V] (b : Basis ι K V) : Fintype ι := b.fintypeIndexOfRankLtAleph0 (rank_lt_aleph0 K V) /-- In a Noetherian module over a division ring, `Basis.ofVectorSpace` is indexed by a finite type. -/ noncomputable instance [IsNoetherian K V] : Fintype (Basis.ofVectorSpaceIndex K V) := fintypeBasisIndex (Basis.ofVectorSpace K V) /-- In a Noetherian module over a division ring, if a basis is indexed by a set, that set is finite. -/ theorem finite_basis_index {ι : Type*} {s : Set ι} [IsNoetherian K V] (b : Basis s K V) : s.Finite := b.finite_index_of_rank_lt_aleph0 (rank_lt_aleph0 K V) variable (K V) /-- In a Noetherian module over a division ring, there exists a finite basis. This is the indexing `Finset`. -/ noncomputable def finsetBasisIndex [IsNoetherian K V] : Finset V := (finite_basis_index (Basis.ofVectorSpace K V)).toFinset @[simp] theorem coe_finsetBasisIndex [IsNoetherian K V] : (↑(finsetBasisIndex K V) : Set V) = Basis.ofVectorSpaceIndex K V := Set.Finite.coe_toFinset _ @[simp] theorem coeSort_finsetBasisIndex [IsNoetherian K V] : (finsetBasisIndex K V : Type _) = Basis.ofVectorSpaceIndex K V := Set.Finite.coeSort_toFinset _ /-- In a Noetherian module over a division ring, there exists a finite basis. This is indexed by the `Finset` `IsNoetherian.finsetBasisIndex`. This is in contrast to the result `finite_basis_index (Basis.ofVectorSpace K V)`, which provides a set and a `Set.Finite`. -/ noncomputable def finsetBasis [IsNoetherian K V] : Basis (finsetBasisIndex K V) K V := (Basis.ofVectorSpace K V).reindex (by rw [coeSort_finsetBasisIndex]) @[simp] theorem range_finsetBasis [IsNoetherian K V] : Set.range (finsetBasis K V) = Basis.ofVectorSpaceIndex K V := by rw [finsetBasis, Basis.range_reindex, Basis.range_ofVectorSpace] variable {K V} theorem _root_.Module.card_eq_pow_finrank [Fintype K] [Fintype V] : Fintype.card V = Fintype.card K ^ Module.finrank K V := by let b := IsNoetherian.finsetBasis K V rw [Module.card_fintype b, ← Module.finrank_eq_card_basis b] theorem _root_.Module.natCard_eq_pow_finrank [Module.Finite K V] : Nat.card V = Nat.card K ^ finrank K V := by let b := IsNoetherian.finsetBasis K V rw [Nat.card_congr b.equivFun.toEquiv, Nat.card_fun, finrank_eq_nat_card_basis b] /-- A module over a division ring is Noetherian if and only if it is finitely generated. -/ theorem iff_fg : IsNoetherian K V ↔ Module.Finite K V := by constructor · intro h exact ⟨⟨finsetBasisIndex K V, by convert (finsetBasis K V).span_eq simp⟩⟩ · rintro ⟨s, hs⟩ rw [IsNoetherian.iff_rank_lt_aleph0, ← rank_top, ← hs] exact lt_of_le_of_lt (rank_span_le _) s.finite_toSet.lt_aleph0 end IsNoetherian
.lake/packages/mathlib/Mathlib/FieldTheory/Differential/Basic.lean
import Mathlib.RingTheory.Derivation.MapCoeffs import Mathlib.FieldTheory.PrimitiveElement /-! # Differential Fields This file defines the logarithmic derivative `Differential.logDeriv` and proves properties of it. This is defined algebraically, compared to `logDeriv` which is analytical. -/ namespace Differential open algebraMap Polynomial IntermediateField variable {R : Type*} [Field R] [Differential R] (a b : R) /-- The logarithmic derivative of a is a′ / a. -/ def logDeriv : R := a′ / a @[simp] lemma logDeriv_zero : logDeriv (0 : R) = 0 := by simp [logDeriv] @[simp] lemma logDeriv_one : logDeriv (1 : R) = 0 := by simp [logDeriv] lemma logDeriv_mul (ha : a ≠ 0) (hb : b ≠ 0) : logDeriv (a * b) = logDeriv a + logDeriv b := by unfold logDeriv simp [field] ring lemma logDeriv_div (ha : a ≠ 0) (hb : b ≠ 0) : logDeriv (a / b) = logDeriv a - logDeriv b := by unfold logDeriv simp [field, Derivation.leibniz_div] @[simp] lemma logDeriv_pow (n : ℕ) (a : R) : logDeriv (a ^ n) = n * logDeriv a := by induction n with | zero => simp | succ n h2 => obtain rfl | hb := eq_or_ne a 0 · simp · rw [Nat.cast_add, Nat.cast_one, add_mul, one_mul, ← h2, pow_succ, logDeriv_mul] <;> simp [hb] lemma logDeriv_eq_zero : logDeriv a = 0 ↔ a′ = 0 := ⟨fun h ↦ by simp only [logDeriv, _root_.div_eq_zero_iff] at h; rcases h with h|h <;> simp [h], fun h ↦ by unfold logDeriv at *; simp [h]⟩ lemma logDeriv_multisetProd {ι : Type*} (s : Multiset ι) {f : ι → R} (h : ∀ x ∈ s, f x ≠ 0) : logDeriv (s.map f).prod = (s.map fun x ↦ logDeriv (f x)).sum := by induction s using Multiset.induction_on · simp · rename_i h₂ simp only [Multiset.map_cons, Multiset.sum_cons, Multiset.prod_cons] rw [← h₂] · apply logDeriv_mul · simp [h] · simp_all · simp_all lemma logDeriv_prod (ι : Type*) (s : Finset ι) (f : ι → R) (h : ∀ x ∈ s, f x ≠ 0) : logDeriv (∏ x ∈ s, f x) = ∑ x ∈ s, logDeriv (f x) := logDeriv_multisetProd _ h lemma logDeriv_prod_of_eq_zero (ι : Type*) (s : Finset ι) (f : ι → R) (h : ∀ x ∈ s, f x = 0) : logDeriv (∏ x ∈ s, f x) = ∑ x ∈ s, logDeriv (f x) := by unfold logDeriv simp_all lemma logDeriv_algebraMap {F K : Type*} [Field F] [Field K] [Differential F] [Differential K] [Algebra F K] [DifferentialAlgebra F K] (a : F) : logDeriv (algebraMap F K a) = algebraMap F K (logDeriv a) := by unfold logDeriv simp [deriv_algebraMap] @[norm_cast] lemma _root_.algebraMap.coe_logDeriv {F K : Type*} [Field F] [Field K] [Differential F] [Differential K] [Algebra F K] [DifferentialAlgebra F K] (a : F) : logDeriv a = logDeriv (a : K) := (logDeriv_algebraMap a).symm variable {F : Type*} [Field F] [Differential F] [CharZero F] noncomputable instance (p : F[X]) [Fact (Irreducible p)] [Fact p.Monic] : Differential (AdjoinRoot p) where deriv := Derivation.liftOfSurjective (f := (AdjoinRoot.mk p).toIntAlgHom) AdjoinRoot.mk_surjective (d := implicitDeriv <| AdjoinRoot.modByMonicHom Fact.out <| - (aeval (AdjoinRoot.root p) (mapCoeffs p)) / (aeval (AdjoinRoot.root p) (derivative p))) (by rintro x hx simp_all only [RingHom.toIntAlgHom_apply, AdjoinRoot.mk_eq_zero] obtain ⟨q, rfl⟩ := hx simp only [Derivation.leibniz, smul_eq_mul] apply dvd_add (dvd_mul_right ..) apply dvd_mul_of_dvd_right rw [← AdjoinRoot.mk_eq_zero] unfold implicitDeriv simp only [ AdjoinRoot.aeval_eq, Derivation.coe_add, Derivation.coe_smul, Pi.add_apply, Pi.smul_apply, Derivation.restrictScalars_apply, derivative'_apply, smul_eq_mul, map_add, map_mul, AdjoinRoot.mk_leftInverse Fact.out _] rw [div_mul_cancel₀, add_neg_cancel] simp only [ne_eq, AdjoinRoot.mk_eq_zero] have : 0 < p.natDegree := Irreducible.natDegree_pos (Fact.out) apply not_dvd_of_natDegree_lt · intro nh simp [natDegree_eq_zero_of_derivative_eq_zero nh] at this apply natDegree_derivative_lt exact Nat.ne_zero_of_lt this) instance (p : F[X]) [Fact (Irreducible p)] [Fact p.Monic] : DifferentialAlgebra F (AdjoinRoot p) where deriv_algebraMap a := by change (Derivation.liftOfSurjective _ _) ((AdjoinRoot.mk p).toIntAlgHom (C a)) = _ rw [Derivation.liftOfSurjective_apply, implicitDeriv_C] rfl variable {K : Type*} [Field K] [Algebra F K] variable (F K) in /-- If `K` is a finite field extension of `F` then we can define a differential algebra on `K`, by choosing a primitive element of `K`, `k` and then using the equivalence to `AdjoinRoot (minpoly k)`. -/ @[reducible] noncomputable def differentialFiniteDimensional [FiniteDimensional F K] : Differential K := let k := (Field.exists_primitive_element F K).choose have h : F⟮k⟯ = ⊤ := (Field.exists_primitive_element F K).choose_spec have : Fact (minpoly F k).Monic := ⟨minpoly.monic (IsAlgebraic.of_finite ..).isIntegral⟩ have : Fact (Irreducible (minpoly F k)) := ⟨minpoly.irreducible (IsAlgebraic.of_finite ..).isIntegral⟩ Differential.equiv (IntermediateField.adjoinRootEquivAdjoin F (IsAlgebraic.of_finite F k).isIntegral |>.trans (IntermediateField.equivOfEq h) |>.trans IntermediateField.topEquiv).symm.toRingEquiv lemma differentialAlgebraFiniteDimensional [FiniteDimensional F K] : letI := differentialFiniteDimensional F K DifferentialAlgebra F K := by let k := (Field.exists_primitive_element F K).choose haveI h : F⟮k⟯ = ⊤ := (Field.exists_primitive_element F K).choose_spec haveI : Fact (minpoly F k).Monic := ⟨minpoly.monic (IsAlgebraic.of_finite ..).isIntegral⟩ haveI : Fact (Irreducible (minpoly F k)) := ⟨minpoly.irreducible (IsAlgebraic.of_finite ..).isIntegral⟩ apply DifferentialAlgebra.equiv /-- A finite extension of a differential field has a unique derivation which agrees with the one on the base field. -/ noncomputable def uniqueDifferentialAlgebraFiniteDimensional [FiniteDimensional F K] : Unique {_a : Differential K // DifferentialAlgebra F K} := by let default : {_a : Differential K // DifferentialAlgebra F K} := ⟨differentialFiniteDimensional F K, differentialAlgebraFiniteDimensional⟩ refine ⟨⟨default⟩, fun ⟨a, ha⟩ ↦ ?_⟩ ext x apply_fun (aeval x (mapCoeffs (minpoly F x)) + aeval x (derivative (minpoly F x)) * ·) · conv_lhs => apply (deriv_aeval_eq ..).symm conv_rhs => apply (@deriv_aeval_eq _ _ _ _ _ default.1 _ default.2 _ _).symm simp · apply (add_right_injective _).comp apply mul_right_injective₀ rw [ne_eq, ← minpoly.dvd_iff] have : 0 < (minpoly F x).natDegree := Irreducible.natDegree_pos (minpoly.irreducible (Algebra.IsIntegral.isIntegral _)) apply not_dvd_of_natDegree_lt · intro nh simp [natDegree_eq_zero_of_derivative_eq_zero nh] at this apply natDegree_derivative_lt exact Nat.ne_zero_of_lt this noncomputable instance (B : IntermediateField F K) [FiniteDimensional F B] : Differential B := differentialFiniteDimensional F B instance (B : IntermediateField F K) [FiniteDimensional F B] : DifferentialAlgebra F B := differentialAlgebraFiniteDimensional instance [Differential K] [DifferentialAlgebra F K] (B : IntermediateField F K) [FiniteDimensional F B] : DifferentialAlgebra B K where deriv_algebraMap a := by change (B.val a)′ = B.val a′ rw [algHom_deriv'] exact Subtype.val_injective end Differential
.lake/packages/mathlib/Mathlib/FieldTheory/Differential/Liouville.lean
import Mathlib.Algebra.Algebra.Field import Mathlib.Algebra.BigOperators.Field import Mathlib.FieldTheory.Differential.Basic import Mathlib.FieldTheory.Galois.Basic import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure /-! # Liouville's theorem A proof of Liouville's theorem. Follows [Rosenlicht, M. Integration in finite terms][Rosenlicht_1972]. ## Liouville field extension This file defines Liouville field extensions, which are differential field extensions which satisfy a slight generalization of Liouville's theorem. Note that this definition doesn't appear in the literature, and we introduce it as part of the formalization of Liouville's theorem. ## Main declarations - `IsLiouville`: A field extension being Liouville - `isLiouville_of_finiteDimensional`: all finite-dimensional field extensions (of a field with characteristic 0) are Liouville. -/ open Differential algebraMap IntermediateField Finset Polynomial variable (F : Type*) (K : Type*) [Field F] [Field K] [Differential F] [Differential K] variable [Algebra F K] [DifferentialAlgebra F K] /-- We say that a differential field extension `K / F` is Liouville if, whenever an element `a ∈ F` can be written as `a = v + ∑ cᵢ * logDeriv uᵢ` for `v, cᵢ, uᵢ ∈ K` and `cᵢ` constant, it can also be written in that way with `v, cᵢ, uᵢ ∈ F`. -/ class IsLiouville : Prop where isLiouville (a : F) (ι : Type) [Fintype ι] (c : ι → F) (hc : ∀ x, (c x)′ = 0) (u : ι → K) (v : K) (h : a = ∑ x, c x * logDeriv (u x) + v′) : ∃ (ι₀ : Type) (_ : Fintype ι₀) (c₀ : ι₀ → F) (_ : ∀ x, (c₀ x)′ = 0) (u₀ : ι₀ → F) (v₀ : F), a = ∑ x, c₀ x * logDeriv (u₀ x) + v₀′ instance IsLiouville.rfl : IsLiouville F F where isLiouville (a : F) (ι : Type) [Fintype ι] (c : ι → F) (hc : ∀ x, (c x)′ = 0) (u : ι → F) (v : F) (h : a = ∑ x, c x * logDeriv (u x) + v′) := ⟨ι, _, c, hc, u, v, h⟩ lemma IsLiouville.trans {A : Type*} [Field A] [Algebra K A] [Algebra F A] [Differential A] [IsScalarTower F K A] [Differential.ContainConstants F K] (inst1 : IsLiouville F K) (inst2 : IsLiouville K A) : IsLiouville F A where isLiouville (a : F) (ι : Type) [Fintype ι] (c : ι → F) (hc : ∀ x, (c x)′ = 0) (u : ι → A) (v : A) (h : a = ∑ x, c x * logDeriv (u x) + v′) := by obtain ⟨ι₀, _, c₀, hc₀, u₀, v₀, h₀⟩ := inst2.isLiouville (a : K) ι ((↑) ∘ c) (fun _ ↦ by simp only [Function.comp_apply, ← coe_deriv, coe_eq_zero_iff, hc]) ((↑) ∘ u) v (by simpa only [Function.comp_apply, ← IsScalarTower.algebraMap_apply]) have hc (x : ι₀) := mem_range_of_deriv_eq_zero F (hc₀ x) choose c₀ hc using hc apply inst1.isLiouville a ι₀ c₀ _ u₀ v₀ · rw [h₀] simp [hc] · intro apply_fun ((↑) : F → K) · simp only [coe_deriv, hc, algebraMap.coe_zero] apply hc₀ · apply FaithfulSMul.algebraMap_injective section Algebraic /- The case of Liouville's theorem for algebraic extensions. -/ variable {F K} [CharZero F] /-- If `K` is a Liouville extension of `F` and `B` is a finite-dimensional intermediate field `K / B / F`, then it's also a Liouville extension of `F`. -/ instance (B : IntermediateField F K) [FiniteDimensional F B] [inst : IsLiouville F K] : IsLiouville F B where isLiouville (a : F) (ι : Type) [Fintype ι] (c : ι → F) (hc : ∀ x, (c x)′ = 0) (u : ι → B) (v : B) (h : a = ∑ x, c x * logDeriv (u x) + v′) := by apply inst.isLiouville a ι c hc (B.val ∘ u) (B.val v) dsimp only [coe_val, Function.comp_apply] conv => rhs congr · rhs intro x rhs apply logDeriv_algebraMap (u x) · apply (deriv_algebraMap v) simp_rw [IsScalarTower.algebraMap_apply F B K] norm_cast /-- Transfer an `IsLiouville` instance using an equivalence `K ≃ₐ[F] K'`. Requires an algebraic `K'` to show that the equivalence commutes with the derivative. -/ lemma IsLiouville.equiv {K' : Type*} [Field K'] [Differential K'] [Algebra F K'] [DifferentialAlgebra F K'] [Algebra.IsAlgebraic F K'] [inst : IsLiouville F K] (e : K ≃ₐ[F] K') : IsLiouville F K' where isLiouville (a : F) (ι : Type) [Fintype ι] (c : ι → F) (hc : ∀ x, (c x)′ = 0) (u : ι → K') (v : K') (h : a = ∑ x, c x * logDeriv (u x) + v′) := by apply inst.isLiouville a ι c hc (e.symm ∘ u) (e.symm v) apply_fun e.symm at h simpa [AlgEquiv.commutes, map_add, map_sum, map_mul, logDeriv, algEquiv_deriv'] using h /-- A finite-dimensional Galois extension of `F` is a Liouville extension. This is private because it's generalized by all finite-dimensional extensions being Liouville. -/ private local instance isLiouville_of_finiteDimensional_galois [FiniteDimensional F K] [IsGalois F K] : IsLiouville F K where isLiouville (a : F) (ι : Type) [Fintype ι] (c : ι → F) (hc : ∀ x, (c x)′ = 0) (u : ι → K) (v : K) (h : a = ∑ x, c x * logDeriv (u x) + v′) := by haveI : CharZero K := charZero_of_injective_algebraMap (FaithfulSMul.algebraMap_injective F K) -- We sum `e x` over all isomorphisms `e : K ≃ₐ[F] K`. -- Because this is a Galois extension each of the relevant values will be in `F`. -- We need to divide by `Fintype.card (K ≃ₐ[F] K)` to get the original answer. let c₀ (i : ι) := (c i) / (Fintype.card (K ≃ₐ[F] K)) -- logDeriv turns sums to products, so the new `u` will be the product of the old `u` over all -- isomorphisms let u₁ (i : ι) := ∏ x : (K ≃ₐ[F] K), x (u i) -- Each of the values of u₁ are fixed by all isomorphisms. have : ∀ i, u₁ i ∈ fixedField (⊤ : Subgroup (K ≃ₐ[F] K)) := by rintro i ⟨e, _⟩ change e (u₁ i) = u₁ i simp only [u₁, map_prod] apply Fintype.prod_equiv (Equiv.mulLeft e) simp have ffb : fixedField ⊤ = ⊥ := (IsGalois.tfae.out 0 1).mp (inferInstanceAs (IsGalois F K)) simp_rw [ffb, IntermediateField.mem_bot, Set.mem_range] at this -- Therefore they are all in `F`. We use `choose` to get their values in `F`. choose u₀ hu₀ using this -- We do almost the same thing for `v₁`, just with sum instead of product. let v₁ := (∑ x : (K ≃ₐ[F] K), x v) / (Fintype.card ((K ≃ₐ[F] K))) have : v₁ ∈ fixedField (⊤ : Subgroup (K ≃ₐ[F] K)) := by rintro ⟨e, _⟩ change e v₁ = v₁ simp only [v₁, map_div₀, map_sum, map_natCast] congr 1 apply Fintype.sum_equiv (Equiv.mulLeft e) simp rw [ffb, IntermediateField.mem_bot] at this obtain ⟨v₀, hv₀⟩ := this exists ι, inferInstance, c₀, ?_, u₀, v₀ · -- We need to prove that all `c₀` are constants. -- This is true because they are the division of a constant by -- a natural number (which is also constant) intro x simp [c₀, Derivation.leibniz_div, hc] · -- Proving that this works is mostly straightforward algebraic manipulation, apply_fun (algebraMap F K) case inj => exact FaithfulSMul.algebraMap_injective F K simp only [map_add, map_sum, map_mul, ← logDeriv_algebraMap, hu₀, ← deriv_algebraMap, hv₀] unfold u₁ v₁ c₀ clear c₀ u₁ u₀ hu₀ v₁ v₀ hv₀ push_cast rw [Derivation.leibniz_div_const, smul_eq_mul, inv_mul_eq_div] case h => simp simp only [map_sum, div_mul_eq_mul_div] rw [← sum_div, ← add_div] field_simp -- Here we rewrite logDeriv (∏ x : K ≃ₐ[F] K, x (u i)) to ∑ x : K ≃ₐ[F] K, logDeriv (x (u i)) conv => enter [2, 1, 2, i, 2] equals ∑ x : K ≃ₐ[F] K, logDeriv (x (u i)) => by_cases h : u i = 0 <;> simp [logDeriv_prod, h] simp_rw [mul_sum] rw [sum_comm, ← sum_add_distrib] trans ∑ _ : (K ≃ₐ[F] K), a · simp [mul_comm] · rcongr e apply_fun e at h simp only [AlgEquiv.commutes, map_add, map_sum, map_mul] at h convert h using 2 · rcongr x simp [logDeriv, algEquiv_deriv'] · rw [algEquiv_deriv'] /-- We lift `isLiouville_of_finiteDimensional_galois` to non-Galois field extensions by using it for the normal closure then obtaining it for `F`. -/ instance isLiouville_of_finiteDimensional [FiniteDimensional F K] : IsLiouville F K := let map := IsAlgClosed.lift (M := AlgebraicClosure F) (R := F) (S := K) let K' := map.fieldRange have : FiniteDimensional F K' := LinearMap.finiteDimensional_range map.toLinearMap let K'' := normalClosure F K' (AlgebraicClosure F) let B : IntermediateField F K'' := IntermediateField.restrict (F := K') (IntermediateField.le_normalClosure ..) have kequiv : K ≃ₐ[F] ↥B := (show K ≃ₐ[F] K' from AlgEquiv.ofInjectiveField map).trans (IntermediateField.restrict_algEquiv _) IsLiouville.equiv kequiv.symm end Algebraic
.lake/packages/mathlib/Mathlib/FieldTheory/PurelyInseparable/Tower.lean
import Mathlib.FieldTheory.LinearDisjoint import Mathlib.FieldTheory.PurelyInseparable.PerfectClosure /-! # Tower law for purely inseparable extensions This file contains results related to `Field.sepDegree`, `Field.insepDegree` and the tower law. ## Main results - `Field.lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic`: the separable degrees satisfy the tower law: $[E:F]_s [K:E]_s = [K:F]_s$. - `Field.lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic`: `Field.finInsepDegree_mul_finInsepDegree_of_isAlgebraic`: the inseparable degrees satisfy the tower law: $[E:F]_i [K:E]_i = [K:F]_i$. - `IntermediateField.sepDegree_adjoin_eq_of_isAlgebraic_of_isPurelyInseparable`, `IntermediateField.sepDegree_adjoin_eq_of_isAlgebraic_of_isPurelyInseparable'`: if `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then for any subset `S` of `K` such that `F(S) / F` is algebraic, the `E(S) / E` and `F(S) / F` have the same separable degree. In particular, if `S` is an intermediate field of `K / F` such that `S / F` is algebraic, the `E(S) / E` and `S / F` have the same separable degree. - `minpoly.map_eq_of_isSeparable_of_isPurelyInseparable`: if `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then for any element `x` of `K` separable over `F`, it has the same minimal polynomials over `F` and over `E`. - `Polynomial.Separable.map_irreducible_of_isPurelyInseparable`: if `E / F` is purely inseparable, `f` is a separable irreducible polynomial over `F`, then it is also irreducible over `E`. ## Tags separable degree, degree, separable closure, purely inseparable -/ open Polynomial IntermediateField Field noncomputable section universe u v w section TowerLaw variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] variable [Algebra E K] [IsScalarTower F E K] variable {F K} in /-- If `K / E / F` is a field extension tower such that `E / F` is purely inseparable, if `{ u_i }` is a family of separable elements of `K` which is `F`-linearly independent, then it is also `E`-linearly independent. -/ theorem LinearIndependent.map_of_isPurelyInseparable_of_isSeparable [IsPurelyInseparable F E] {ι : Type*} {v : ι → K} (hsep : ∀ i : ι, IsSeparable F (v i)) (h : LinearIndependent F v) : LinearIndependent E v := by obtain ⟨q, _⟩ := ExpChar.exists F haveI := expChar_of_injective_algebraMap (algebraMap F K).injective q refine linearIndependent_iff.mpr fun l hl ↦ Finsupp.ext fun i ↦ ?_ choose f hf using fun i ↦ (isPurelyInseparable_iff_pow_mem F q).1 ‹_› (l i) let n := l.support.sup f have := (expChar_pow_pos F q n).ne' replace hf (i : ι) : l i ^ q ^ n ∈ (algebraMap F E).range := by by_cases hs : i ∈ l.support · convert pow_mem (hf i) (q ^ (n - f i)) using 1 rw [← pow_mul, ← pow_add, Nat.add_sub_of_le (Finset.le_sup hs)] exact ⟨0, by rw [map_zero, Finsupp.notMem_support_iff.1 hs, zero_pow this]⟩ choose lF hlF using hf let lF₀ := Finsupp.onFinset l.support lF fun i ↦ by contrapose! refine fun hs ↦ (injective_iff_map_eq_zero _).mp (algebraMap F E).injective _ ?_ rw [hlF, Finsupp.notMem_support_iff.1 hs, zero_pow this] replace h := linearIndependent_iff.1 (h.map_pow_expChar_pow_of_isSeparable' q n hsep) lF₀ <| by replace hl := congr($hl ^ q ^ n) rw [Finsupp.linearCombination_apply, Finsupp.sum, sum_pow_char_pow, zero_pow this] at hl rw [← hl, Finsupp.linearCombination_apply, Finsupp.onFinset_sum _ (fun _ ↦ by exact zero_smul _ _)] refine Finset.sum_congr rfl fun i _ ↦ ?_ simp_rw [Algebra.smul_def, mul_pow, IsScalarTower.algebraMap_apply F E K, hlF, map_pow] refine eq_zero_of_pow_eq_zero ((hlF _).symm.trans ?_) convert map_zero (algebraMap F E) exact congr($h i) variable {F K} in /-- If `K / E / F` is a field extension tower such that `E / F` is purely inseparable, if `S` is an intermediate field of `K / F` which is separable over `F`, then `S` and `E` are linearly disjoint over `F`. -/ theorem IntermediateField.linearDisjoint_of_isPurelyInseparable_of_isSeparable [IsPurelyInseparable F E] (S : IntermediateField F K) [Algebra.IsSeparable F S] : S.LinearDisjoint E := have ⟨ι, ⟨b⟩⟩ := Module.Basis.exists_basis F S .of_basis_left b <| b.linearIndependent.map' S.val.toLinearMap (LinearMap.ker_eq_bot_of_injective S.val.injective) |>.map_of_isPurelyInseparable_of_isSeparable E fun i ↦ by simpa only [IsSeparable, minpoly_eq] using Algebra.IsSeparable.isSeparable F (b i) namespace Field /-- If `K / E / F` is a field extension tower, such that `E / F` is purely inseparable and `K / E` is separable, then the separable degree of `K / F` is equal to the degree of `K / E`. It is a special case of `Field.lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic`, and is an intermediate result used to prove it. -/ lemma sepDegree_eq_of_isPurelyInseparable_of_isSeparable [IsPurelyInseparable F E] [Algebra.IsSeparable E K] : sepDegree F K = Module.rank E K := by have h := (separableClosure F K).linearDisjoint_of_isPurelyInseparable_of_isSeparable E |>.adjoin_rank_eq_rank_left_of_isAlgebraic_left |>.symm rwa [separableClosure.adjoin_eq_of_isAlgebraic_of_isSeparable K, rank_top'] at h /-- If `K / E / F` is a field extension tower, such that `E / F` is separable, then $[E:F] [K:E]_s = [K:F]_s$. It is a special case of `Field.lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic`, and is an intermediate result used to prove it. -/ lemma lift_rank_mul_lift_sepDegree_of_isSeparable [Algebra.IsSeparable F E] : Cardinal.lift.{w} (Module.rank F E) * Cardinal.lift.{v} (sepDegree E K) = Cardinal.lift.{v} (sepDegree F K) := by rw [sepDegree, sepDegree, separableClosure.eq_restrictScalars_of_isSeparable F E K] exact lift_rank_mul_lift_rank F E (separableClosure E K) /-- The same-universe version of `Field.lift_rank_mul_lift_sepDegree_of_isSeparable`. -/ lemma rank_mul_sepDegree_of_isSeparable (K : Type v) [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K] [Algebra.IsSeparable F E] : Module.rank F E * sepDegree E K = sepDegree F K := by simpa only [Cardinal.lift_id] using lift_rank_mul_lift_sepDegree_of_isSeparable F E K /-- If `K / E / F` is a field extension tower, such that `E / F` is separable, then $[K:F]_i = [K:E]_i$. It is a special case of `Field.lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic`, and is an intermediate result used to prove it. -/ lemma insepDegree_eq_of_isSeparable [Algebra.IsSeparable F E] : insepDegree F K = insepDegree E K := by rw [insepDegree, insepDegree, separableClosure.eq_restrictScalars_of_isSeparable F E K] rfl /-- If `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then $[K:F]_s = [K:E]_s$. It is a special case of `Field.lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic`, and is an intermediate result used to prove it. -/ lemma sepDegree_eq_of_isPurelyInseparable [IsPurelyInseparable F E] : sepDegree F K = sepDegree E K := by convert sepDegree_eq_of_isPurelyInseparable_of_isSeparable F E (separableClosure E K) haveI : IsScalarTower F (separableClosure E K) K := IsScalarTower.of_algebraMap_eq (congrFun rfl) rw [sepDegree, ← separableClosure.map_eq_of_separableClosure_eq_bot F (separableClosure.separableClosure_eq_bot E K)] exact (separableClosure F (separableClosure E K)).equivMap (IsScalarTower.toAlgHom F (separableClosure E K) K) |>.symm.toLinearEquiv.rank_eq /-- If `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then $[E:F] [K:E]_i = [K:F]_i$. It is a special case of `Field.lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic`, and is an intermediate result used to prove it. -/ lemma lift_rank_mul_lift_insepDegree_of_isPurelyInseparable [IsPurelyInseparable F E] : Cardinal.lift.{w} (Module.rank F E) * Cardinal.lift.{v} (insepDegree E K) = Cardinal.lift.{v} (insepDegree F K) := by have h := (separableClosure F K).linearDisjoint_of_isPurelyInseparable_of_isSeparable E |>.lift_rank_right_mul_lift_adjoin_rank_eq_of_isAlgebraic_left rwa [separableClosure.adjoin_eq_of_isAlgebraic] at h /-- The same-universe version of `Field.lift_rank_mul_lift_insepDegree_of_isPurelyInseparable`. -/ lemma rank_mul_insepDegree_of_isPurelyInseparable (K : Type v) [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K] [IsPurelyInseparable F E] : Module.rank F E * insepDegree E K = insepDegree F K := by simpa only [Cardinal.lift_id] using lift_rank_mul_lift_insepDegree_of_isPurelyInseparable F E K /-- If `K / E / F` is a field extension tower, such that `E / F` is algebraic, then their separable degrees satisfy the tower law: $[E:F]_s [K:E]_s = [K:F]_s$. -/ theorem lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic [Algebra.IsAlgebraic F E] : Cardinal.lift.{w} (sepDegree F E) * Cardinal.lift.{v} (sepDegree E K) = Cardinal.lift.{v} (sepDegree F K) := by have h := lift_rank_mul_lift_sepDegree_of_isSeparable F (separableClosure F E) K rwa [sepDegree_eq_of_isPurelyInseparable (separableClosure F E) E K] at h /-- The same-universe version of `Field.lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic`. -/ @[stacks 09HK "Part 1"] theorem sepDegree_mul_sepDegree_of_isAlgebraic (K : Type v) [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic F E] : sepDegree F E * sepDegree E K = sepDegree F K := by simpa only [Cardinal.lift_id] using lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic F E K /-- If `K / E / F` is a field extension tower, such that `E / F` is algebraic, then their inseparable degrees satisfy the tower law: $[E:F]_i [K:E]_i = [K:F]_i$. -/ theorem lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic [Algebra.IsAlgebraic F E] : Cardinal.lift.{w} (insepDegree F E) * Cardinal.lift.{v} (insepDegree E K) = Cardinal.lift.{v} (insepDegree F K) := by have h := lift_rank_mul_lift_insepDegree_of_isPurelyInseparable (separableClosure F E) E K rwa [← insepDegree_eq_of_isSeparable F (separableClosure F E) K] at h /-- The same-universe version of `Field.lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic`. -/ @[stacks 09HK "Part 2"] theorem insepDegree_mul_insepDegree_of_isAlgebraic (K : Type v) [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic F E] : insepDegree F E * insepDegree E K = insepDegree F K := by simpa only [Cardinal.lift_id] using lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic F E K /-- If `K / E / F` is a field extension tower, such that `E / F` is algebraic, then their inseparable degrees, as natural numbers, satisfy the tower law: $[E:F]_i [K:E]_i = [K:F]_i$. -/ @[stacks 09HK "Part 2, `finInsepDegree` variant"] theorem finInsepDegree_mul_finInsepDegree_of_isAlgebraic [Algebra.IsAlgebraic F E] : finInsepDegree F E * finInsepDegree E K = finInsepDegree F K := by simpa only [map_mul, Cardinal.toNat_lift] using congr(Cardinal.toNat $(lift_insepDegree_mul_lift_insepDegree_of_isAlgebraic F E K)) end Field variable {F K} in /-- If `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then for any subset `S` of `K` such that `F(S) / F` is algebraic, the `E(S) / E` and `F(S) / F` have the same separable degree. -/ theorem IntermediateField.sepDegree_adjoin_eq_of_isAlgebraic_of_isPurelyInseparable (S : Set K) [Algebra.IsAlgebraic F (adjoin F S)] [IsPurelyInseparable F E] : sepDegree E (adjoin E S) = sepDegree F (adjoin F S) := by set M := adjoin F S set L := adjoin E S let E' := (IsScalarTower.toAlgHom F E K).fieldRange let j : E ≃ₐ[F] E' := AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F E K) have hi : M ≤ L.restrictScalars F := by rw [restrictScalars_adjoin_of_algEquiv (E := K) j rfl, restrictScalars_adjoin] exact adjoin.mono _ _ _ Set.subset_union_right let i : M →+* L := Subsemiring.inclusion hi letI : Algebra M L := i.toAlgebra letI : SMul M L := Algebra.toSMul haveI : IsScalarTower F M L := IsScalarTower.of_algebraMap_eq (congrFun rfl) haveI : IsPurelyInseparable M L := by change IsPurelyInseparable M (extendScalars hi) obtain ⟨q, _⟩ := ExpChar.exists F have : extendScalars hi = adjoin M (E' : Set K) := restrictScalars_injective F <| by conv_lhs => rw [extendScalars_restrictScalars, restrictScalars_adjoin_of_algEquiv (E := K) j rfl, ← adjoin_self F E', adjoin_adjoin_comm] rw [this, isPurelyInseparable_adjoin_iff_pow_mem _ _ q] rintro x ⟨y, hy⟩ obtain ⟨n, z, hz⟩ := IsPurelyInseparable.pow_mem F q y refine ⟨n, algebraMap F M z, ?_⟩ rw [← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply F E K, hz, ← hy, map_pow, AlgHom.toRingHom_eq_coe, IsScalarTower.coe_toAlgHom] have h := lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic F E L rw [IsPurelyInseparable.sepDegree_eq_one F E, Cardinal.lift_one, one_mul] at h rw [Cardinal.lift_injective h, ← sepDegree_mul_sepDegree_of_isAlgebraic F M L, IsPurelyInseparable.sepDegree_eq_one M L, mul_one] variable {F K} in /-- If `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then for any intermediate field `S` of `K / F` such that `S / F` is algebraic, the `E(S) / E` and `S / F` have the same separable degree. -/ theorem IntermediateField.sepDegree_adjoin_eq_of_isAlgebraic_of_isPurelyInseparable' (S : IntermediateField F K) [Algebra.IsAlgebraic F S] [IsPurelyInseparable F E] : sepDegree E (adjoin E (S : Set K)) = sepDegree F S := by have : Algebra.IsAlgebraic F (adjoin F (S : Set K)) := by rwa [adjoin_self] have := sepDegree_adjoin_eq_of_isAlgebraic_of_isPurelyInseparable (F := F) E (S : Set K) rwa [adjoin_self] at this variable {F K} in /-- If `K / E / F` is a field extension tower, such that `E / F` is purely inseparable, then for any element `x` of `K` separable over `F`, it has the same minimal polynomials over `F` and over `E`. -/ theorem minpoly.map_eq_of_isSeparable_of_isPurelyInseparable (x : K) (hsep : IsSeparable F x) [IsPurelyInseparable F E] : (minpoly F x).map (algebraMap F E) = minpoly E x := by have hi := IsSeparable.isIntegral hsep have hi' : IsIntegral E x := IsIntegral.tower_top hi refine eq_of_monic_of_dvd_of_natDegree_le (monic hi') ((monic hi).map (algebraMap F E)) (dvd_map_of_isScalarTower F E x) (le_of_eq ?_) have hsep' := IsSeparable.tower_top E hsep haveI := (isSeparable_adjoin_simple_iff_isSeparable _ _).2 hsep haveI := (isSeparable_adjoin_simple_iff_isSeparable _ _).2 hsep' have := Algebra.IsSeparable.isAlgebraic F F⟮x⟯ rw [Polynomial.natDegree_map, ← adjoin.finrank hi, ← adjoin.finrank hi', ← finSepDegree_eq_finrank_of_isSeparable F _, ← finSepDegree_eq_finrank_of_isSeparable E _, finSepDegree_eq, finSepDegree_eq, sepDegree_adjoin_eq_of_isAlgebraic_of_isPurelyInseparable (F := F) E] variable {F} in /-- If `E / F` is a purely inseparable field extension, `f` is a separable irreducible polynomial over `F`, then it is also irreducible over `E`. -/ theorem Polynomial.Separable.map_irreducible_of_isPurelyInseparable {f : F[X]} (hsep : f.Separable) (hirr : Irreducible f) [IsPurelyInseparable F E] : Irreducible (f.map (algebraMap F E)) := by let K := AlgebraicClosure E obtain ⟨x, hx⟩ := IsAlgClosed.exists_aeval_eq_zero K f (natDegree_pos_iff_degree_pos.1 hirr.natDegree_pos).ne' have ha : Associated f (minpoly F x) := by have := isUnit_C.2 (leadingCoeff_ne_zero.2 hirr.ne_zero).isUnit.inv exact ⟨this.unit, by rw [IsUnit.unit_spec, minpoly.eq_of_irreducible hirr hx]⟩ have ha' : Associated (f.map (algebraMap F E)) ((minpoly F x).map (algebraMap F E)) := ha.map (mapRingHom (algebraMap F E)).toMonoidHom have heq := minpoly.map_eq_of_isSeparable_of_isPurelyInseparable E x (ha.separable hsep) rw [ha'.irreducible_iff, heq] exact minpoly.irreducible (Algebra.IsIntegral.isIntegral x) end TowerLaw
.lake/packages/mathlib/Mathlib/FieldTheory/PurelyInseparable/Basic.lean
import Mathlib.Algebra.CharP.IntermediateField import Mathlib.FieldTheory.SeparableClosure /-! # Basic results about purely inseparable extensions This file contains basic definitions and results about purely inseparable extensions. ## Main definitions - `IsPurelyInseparable`: typeclass for purely inseparable field extensions: an algebraic extension `E / F` is purely inseparable if and only if the minimal polynomial of every element of `E ∖ F` is not separable. ## Main results - `IsPurelyInseparable.surjective_algebraMap_of_isSeparable`, `IsPurelyInseparable.bijective_algebraMap_of_isSeparable`, `IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable`: if `E / F` is both purely inseparable and separable, then `algebraMap F E` is surjective (hence bijective). In particular, if an intermediate field of `E / F` is both purely inseparable and separable, then it is equal to `F`. - `isPurelyInseparable_iff_pow_mem`: a field extension `E / F` of exponential characteristic `q` is purely inseparable if and only if for every element `x` of `E`, there exists a natural number `n` such that `x ^ (q ^ n)` is contained in `F`. - `IsPurelyInseparable.trans`: if `E / F` and `K / E` are both purely inseparable extensions, then `K / F` is also purely inseparable. - `isPurelyInseparable_iff_natSepDegree_eq_one`: `E / F` is purely inseparable if and only if for every element `x` of `E`, its minimal polynomial has separable degree one. - `isPurelyInseparable_iff_minpoly_eq_X_pow_sub_C`: a field extension `E / F` of exponential characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal polynomial of `x` over `F` is of form `X ^ (q ^ n) - y` for some natural number `n` and some element `y` of `F`. - `isPurelyInseparable_iff_minpoly_eq_X_sub_C_pow`: a field extension `E / F` of exponential characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal polynomial of `x` over `F` is of form `(X - x) ^ (q ^ n)` for some natural number `n`. - `isPurelyInseparable_iff_finSepDegree_eq_one`: an extension is purely inseparable if and only if it has finite separable degree (`Field.finSepDegree`) one. - `IsPurelyInseparable.normal`: a purely inseparable extension is normal. - `separableClosure.isPurelyInseparable`: if `E / F` is algebraic, then `E` is purely inseparable over the separable closure of `F` in `E`. - `separableClosure_le_iff`: if `E / F` is algebraic, then an intermediate field of `E / F` contains the separable closure of `F` in `E` if and only if `E` is purely inseparable over it. - `eq_separableClosure_iff`: if `E / F` is algebraic, then an intermediate field of `E / F` is equal to the separable closure of `F` in `E` if and only if it is separable over `F`, and `E` is purely inseparable over it. - `IsPurelyInseparable.injective_comp_algebraMap`: if `E / F` is purely inseparable, then for any reduced ring `L`, the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is injective. In particular, a purely inseparable field extension is an epimorphism in the category of fields. - `IsPurelyInseparable.of_injective_comp_algebraMap`: if `L` is an algebraically closed field containing `E`, such that the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is injective, then `E / F` is purely inseparable. As a corollary, epimorphisms in the category of fields must be purely inseparable extensions. - `Field.finSepDegree_eq`: if `E / F` is algebraic, then the `Field.finSepDegree F E` is equal to `Field.sepDegree F E` as a natural number. This means that the cardinality of `Field.Emb F E` and the degree of `(separableClosure F E) / F` are both finite or infinite, and when they are finite, they coincide. - `Field.finSepDegree_mul_finInsepDegree`: the finite separable degree multiply by the finite inseparable degree is equal to the (finite) field extension degree. ## Tags separable degree, degree, separable closure, purely inseparable -/ open Module Polynomial IntermediateField Field noncomputable section universe u v w section General variable (F E : Type*) [CommRing F] [Ring E] [Algebra F E] variable (K : Type*) [Ring K] [Algebra F K] /-- Typeclass for purely inseparable field extensions: an algebraic extension `E / F` is purely inseparable if and only if the minimal polynomial of every element of `E ∖ F` is not separable. We define this for general (commutative) rings and only assume `F` and `E` are fields if this is needed for a proof. -/ class IsPurelyInseparable : Prop where isIntegral : Algebra.IsIntegral F E inseparable' (x : E) : IsSeparable F x → x ∈ (algebraMap F E).range attribute [instance] IsPurelyInseparable.isIntegral variable {E} in theorem IsPurelyInseparable.isIntegral' [IsPurelyInseparable F E] (x : E) : IsIntegral F x := Algebra.IsIntegral.isIntegral _ theorem IsPurelyInseparable.isAlgebraic [Nontrivial F] [IsPurelyInseparable F E] : Algebra.IsAlgebraic F E := inferInstance variable {E} theorem IsPurelyInseparable.inseparable [IsPurelyInseparable F E] : ∀ x : E, IsSeparable F x → x ∈ (algebraMap F E).range := IsPurelyInseparable.inseparable' variable {F} theorem isPurelyInseparable_iff : IsPurelyInseparable F E ↔ ∀ x : E, IsIntegral F x ∧ (IsSeparable F x → x ∈ (algebraMap F E).range) := ⟨fun h x ↦ ⟨h.isIntegral' _ x, h.inseparable' x⟩, fun h ↦ ⟨⟨fun x ↦ (h x).1⟩, fun x ↦ (h x).2⟩⟩ variable {K} /-- Transfer `IsPurelyInseparable` across an `AlgEquiv`. -/ theorem AlgEquiv.isPurelyInseparable (e : K ≃ₐ[F] E) [IsPurelyInseparable F K] : IsPurelyInseparable F E := by refine ⟨⟨fun _ ↦ by rw [← isIntegral_algEquiv e.symm]; exact IsPurelyInseparable.isIntegral' F _⟩, fun x h ↦ ?_⟩ rw [IsSeparable, ← minpoly.algEquiv_eq e.symm] at h simpa only [RingHom.mem_range, algebraMap_eq_apply] using IsPurelyInseparable.inseparable F _ h theorem AlgEquiv.isPurelyInseparable_iff (e : K ≃ₐ[F] E) : IsPurelyInseparable F K ↔ IsPurelyInseparable F E := ⟨fun _ ↦ e.isPurelyInseparable, fun _ ↦ e.symm.isPurelyInseparable⟩ /-- If `E / F` is an algebraic extension, `F` is separably closed, then `E / F` is purely inseparable. -/ instance Algebra.IsAlgebraic.isPurelyInseparable_of_isSepClosed {F : Type u} {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E] [Algebra.IsAlgebraic F E] [IsSepClosed F] : IsPurelyInseparable F E := ⟨inferInstance, fun x h ↦ minpoly.mem_range_of_degree_eq_one F x <| IsSepClosed.degree_eq_one_of_irreducible F (minpoly.irreducible (Algebra.IsIntegral.isIntegral _)) h⟩ variable (F E K) /-- If `E / F` is both purely inseparable and separable, then `algebraMap F E` is surjective. -/ theorem IsPurelyInseparable.surjective_algebraMap_of_isSeparable [IsPurelyInseparable F E] [Algebra.IsSeparable F E] : Function.Surjective (algebraMap F E) := fun x ↦ IsPurelyInseparable.inseparable F x (Algebra.IsSeparable.isSeparable F x) /-- If `E / F` is both purely inseparable and separable, then `algebraMap F E` is bijective. -/ theorem IsPurelyInseparable.bijective_algebraMap_of_isSeparable [Nontrivial E] [NoZeroSMulDivisors F E] [IsPurelyInseparable F E] [Algebra.IsSeparable F E] : Function.Bijective (algebraMap F E) := ⟨FaithfulSMul.algebraMap_injective F E, surjective_algebraMap_of_isSeparable F E⟩ variable {F E} in /-- If a subalgebra of `E / F` is both purely inseparable and separable, then it is equal to `F`. -/ theorem Subalgebra.eq_bot_of_isPurelyInseparable_of_isSeparable (L : Subalgebra F E) [IsPurelyInseparable F L] [Algebra.IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩ exact ⟨y, congr_arg (Subalgebra.val _) hy⟩ /-- If an intermediate field of `E / F` is both purely inseparable and separable, then it is equal to `F`. -/ theorem IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] (L : IntermediateField F E) [IsPurelyInseparable F L] [Algebra.IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩ exact ⟨y, congr_arg (algebraMap L E) hy⟩ /-- If `E / F` is purely inseparable, then the separable closure of `F` in `E` is equal to `F`. -/ theorem separableClosure.eq_bot_of_isPurelyInseparable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] [IsPurelyInseparable F E] : separableClosure F E = ⊥ := bot_unique fun x h ↦ IsPurelyInseparable.inseparable F x (mem_separableClosure_iff.1 h) /-- If `E / F` is an algebraic extension, then the separable closure of `F` in `E` is equal to `F` if and only if `E / F` is purely inseparable. -/ theorem separableClosure.eq_bot_iff {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] [Algebra.IsAlgebraic F E] : separableClosure F E = ⊥ ↔ IsPurelyInseparable F E := ⟨fun h ↦ isPurelyInseparable_iff.2 fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, fun hs ↦ by simpa only [h] using mem_separableClosure_iff.2 hs⟩, fun _ ↦ eq_bot_of_isPurelyInseparable F E⟩ instance isPurelyInseparable_self : IsPurelyInseparable F F := ⟨inferInstance, fun x _ ↦ ⟨x, rfl⟩⟩ section variable (F : Type u) {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E] variable (q : ℕ) [ExpChar F q] (x : E) /-- A field extension `E / F` of exponential characteristic `q` is purely inseparable if and only if for every element `x` of `E`, there exists a natural number `n` such that `x ^ (q ^ n)` is contained in `F`. -/ @[stacks 09HE] theorem isPurelyInseparable_iff_pow_mem : IsPurelyInseparable F E ↔ ∀ x : E, ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by rw [isPurelyInseparable_iff] refine ⟨fun h x ↦ ?_, fun h x ↦ ?_⟩ · obtain ⟨g, h1, n, h2⟩ := (minpoly.irreducible (h x).1).hasSeparableContraction q exact ⟨n, (h _).2 <| h1.of_dvd <| minpoly.dvd F _ <| by simpa only [expand_aeval, minpoly.aeval] using congr_arg (aeval x) h2⟩ have hdeg := (minpoly.natSepDegree_eq_one_iff_pow_mem q).2 (h x) have halg : IsIntegral F x := by_contra fun h' ↦ by simp only [minpoly.eq_zero h', natSepDegree_zero, zero_ne_one] at hdeg refine ⟨halg, fun hsep ↦ ?_⟩ rwa [hsep.natSepDegree_eq_natDegree, minpoly.natDegree_eq_one_iff] at hdeg theorem IsPurelyInseparable.pow_mem [IsPurelyInseparable F E] : ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := (isPurelyInseparable_iff_pow_mem F q).1 ‹_› x end end General variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] section Field /-- If `K / E / F` is a field extension tower such that `K / F` is purely inseparable, then `E / F` is also purely inseparable. -/ theorem IsPurelyInseparable.tower_bot [Algebra E K] [IsScalarTower F E K] [IsPurelyInseparable F K] : IsPurelyInseparable F E := by refine ⟨⟨fun x ↦ (isIntegral' F (algebraMap E K x)).tower_bot_of_field⟩, fun x h ↦ ?_⟩ rw [IsSeparable, ← minpoly.algebraMap_eq (algebraMap E K).injective] at h obtain ⟨y, h⟩ := inseparable F _ h exact ⟨y, (algebraMap E K).injective (h.symm ▸ (IsScalarTower.algebraMap_apply F E K y).symm)⟩ /-- If `K / E / F` is a field extension tower such that `K / F` is purely inseparable, then `K / E` is also purely inseparable. -/ theorem IsPurelyInseparable.tower_top [Algebra E K] [IsScalarTower F E K] [h : IsPurelyInseparable F K] : IsPurelyInseparable E K := by obtain ⟨q, _⟩ := ExpChar.exists F haveI := expChar_of_injective_algebraMap (algebraMap F E).injective q rw [isPurelyInseparable_iff_pow_mem _ q] at h ⊢ intro x obtain ⟨n, y, h⟩ := h x exact ⟨n, (algebraMap F E) y, h.symm ▸ (IsScalarTower.algebraMap_apply F E K y).symm⟩ /-- If `E / F` and `K / E` are both purely inseparable extensions, then `K / F` is also purely inseparable. -/ @[stacks 02JJ "See also 00GM"] theorem IsPurelyInseparable.trans [Algebra E K] [IsScalarTower F E K] [h1 : IsPurelyInseparable F E] [h2 : IsPurelyInseparable E K] : IsPurelyInseparable F K := by obtain ⟨q, _⟩ := ExpChar.exists F haveI := expChar_of_injective_algebraMap (algebraMap F E).injective q rw [isPurelyInseparable_iff_pow_mem _ q] at h1 h2 ⊢ intro x obtain ⟨n, y, h2⟩ := h2 x obtain ⟨m, z, h1⟩ := h1 y refine ⟨n + m, z, ?_⟩ rw [IsScalarTower.algebraMap_apply F E K, h1, map_pow, h2, ← pow_mul, ← pow_add] namespace IntermediateField variable (M : IntermediateField F K) instance isPurelyInseparable_tower_bot [IsPurelyInseparable F K] : IsPurelyInseparable F M := IsPurelyInseparable.tower_bot F M K instance isPurelyInseparable_tower_top [IsPurelyInseparable F K] : IsPurelyInseparable M K := IsPurelyInseparable.tower_top F M K end IntermediateField variable {E} /-- A field extension `E / F` is purely inseparable if and only if for every element `x` of `E`, its minimal polynomial has separable degree one. -/ theorem isPurelyInseparable_iff_natSepDegree_eq_one : IsPurelyInseparable F E ↔ ∀ x : E, (minpoly F x).natSepDegree = 1 := by obtain ⟨q, _⟩ := ExpChar.exists F simp_rw [isPurelyInseparable_iff_pow_mem F q, minpoly.natSepDegree_eq_one_iff_pow_mem q] theorem IsPurelyInseparable.natSepDegree_eq_one [IsPurelyInseparable F E] (x : E) : (minpoly F x).natSepDegree = 1 := (isPurelyInseparable_iff_natSepDegree_eq_one F).1 ‹_› x /-- A field extension `E / F` of exponential characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal polynomial of `x` over `F` is of form `X ^ (q ^ n) - y` for some natural number `n` and some element `y` of `F`. -/ theorem isPurelyInseparable_iff_minpoly_eq_X_pow_sub_C (q : ℕ) [hF : ExpChar F q] : IsPurelyInseparable F E ↔ ∀ x : E, ∃ (n : ℕ) (y : F), minpoly F x = X ^ q ^ n - C y := by simp_rw [isPurelyInseparable_iff_natSepDegree_eq_one, minpoly.natSepDegree_eq_one_iff_eq_X_pow_sub_C q] theorem IsPurelyInseparable.minpoly_eq_X_pow_sub_C (q : ℕ) [ExpChar F q] [IsPurelyInseparable F E] (x : E) : ∃ (n : ℕ) (y : F), minpoly F x = X ^ q ^ n - C y := (isPurelyInseparable_iff_minpoly_eq_X_pow_sub_C F q).1 ‹_› x /-- A field extension `E / F` of exponential characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal polynomial of `x` over `F` is of form `(X - x) ^ (q ^ n)` for some natural number `n`. -/ theorem isPurelyInseparable_iff_minpoly_eq_X_sub_C_pow (q : ℕ) [hF : ExpChar F q] : IsPurelyInseparable F E ↔ ∀ x : E, ∃ n : ℕ, (minpoly F x).map (algebraMap F E) = (X - C x) ^ q ^ n := by simp_rw [isPurelyInseparable_iff_natSepDegree_eq_one, minpoly.natSepDegree_eq_one_iff_eq_X_sub_C_pow q] theorem IsPurelyInseparable.minpoly_eq_X_sub_C_pow (q : ℕ) [ExpChar F q] [IsPurelyInseparable F E] (x : E) : ∃ n : ℕ, (minpoly F x).map (algebraMap F E) = (X - C x) ^ q ^ n := (isPurelyInseparable_iff_minpoly_eq_X_sub_C_pow F q).1 ‹_› x variable (E) in lemma IsPurelyInseparable.finrank_eq_pow (q : ℕ) [ExpChar F q] [IsPurelyInseparable F E] [FiniteDimensional F E] : ∃ n, finrank F E = q ^ n := by suffices ∀ (F E : Type v) [Field F] [Field E] [Algebra F E] (q : ℕ) [ExpChar F q] [IsPurelyInseparable F E] [FiniteDimensional F E], ∃ n, finrank F E = q ^ n by simpa using this (⊥ : IntermediateField F E) E q intro F E _ _ _ q _ _ _ generalize hd : finrank F E = d induction d using Nat.strongRecOn generalizing F with | ind d IH => by_cases h : (⊥ : IntermediateField F E) = ⊤ · rw [← finrank_top', ← h, IntermediateField.finrank_bot] at hd exact ⟨0, ((pow_zero q).trans hd).symm⟩ obtain ⟨x, -, hx⟩ := SetLike.exists_of_lt (lt_of_le_of_ne bot_le h:) obtain ⟨m, y, e⟩ := IsPurelyInseparable.minpoly_eq_X_pow_sub_C F q x have : finrank F F⟮x⟯ = q ^ m := by rw [adjoin.finrank (Algebra.IsIntegral.isIntegral x), e, natDegree_sub_C, natDegree_X_pow] obtain ⟨n, hn⟩ := IH _ (by rw [← hd, ← finrank_mul_finrank F F⟮x⟯, Nat.lt_mul_iff_one_lt_left finrank_pos, this] by_contra! H refine hx (finrank_adjoin_simple_eq_one_iff.mp (le_antisymm (this ▸ H) ?_)) exact Nat.one_le_iff_ne_zero.mpr Module.finrank_pos.ne') (F⟮x⟯) rfl exact ⟨m + n, by rw [← hd, ← finrank_mul_finrank F F⟮x⟯, hn, pow_add, this]⟩ variable (E) variable {F E} in /-- If an extension has finite separable degree one, then it is purely inseparable. -/ theorem isPurelyInseparable_of_finSepDegree_eq_one (hdeg : finSepDegree F E = 1) : IsPurelyInseparable F E := by by_cases H : Algebra.IsAlgebraic F E · rw [isPurelyInseparable_iff] refine fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, fun hsep ↦ ?_⟩ have := finSepDegree_mul_finSepDegree_of_isAlgebraic F F⟮x⟯ E rw [hdeg, mul_eq_one, (finSepDegree_adjoin_simple_eq_finrank_iff F E x (Algebra.IsAlgebraic.isAlgebraic x)).2 hsep, IntermediateField.finrank_eq_one_iff] at this simpa only [this.1] using mem_adjoin_simple_self F x · rw [← Algebra.transcendental_iff_not_isAlgebraic] at H simp [finSepDegree_eq_zero_of_transcendental F E] at hdeg namespace IsPurelyInseparable variable [IsPurelyInseparable F E] (R L : Type*) [CommSemiring R] [Algebra R F] [Algebra R E] /-- If `E / F` is purely inseparable, then for any reduced ring `L`, the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is injective. In particular, a purely inseparable field extension is an epimorphism in the category of fields. -/ theorem injective_comp_algebraMap [CommRing L] [IsReduced L] : Function.Injective fun f : E →+* L ↦ f.comp (algebraMap F E) := fun f g heq ↦ by ext x let q := ringExpChar F obtain ⟨n, y, h⟩ := IsPurelyInseparable.pow_mem F q x replace heq := congr($heq y) simp_rw [RingHom.comp_apply, h, map_pow] at heq nontriviality L haveI := expChar_of_injective_ringHom (f.comp (algebraMap F E)).injective q exact iterateFrobenius_inj L q n heq theorem injective_restrictDomain [CommRing L] [IsReduced L] [Algebra R L] [IsScalarTower R F E] : Function.Injective (AlgHom.restrictDomain (A := R) F (C := E) (D := L)) := fun _ _ eq ↦ AlgHom.coe_ringHom_injective <| injective_comp_algebraMap F E L <| congr_arg AlgHom.toRingHom eq instance [Field L] [PerfectField L] [Algebra F L] : Nonempty (E →ₐ[F] L) := nonempty_algHom_of_splits fun x ↦ ⟨IsPurelyInseparable.isIntegral' _ _, have ⟨q, _⟩ := ExpChar.exists F PerfectField.splits_of_natSepDegree_eq_one (algebraMap F L) ((minpoly.natSepDegree_eq_one_iff_eq_X_pow_sub_C q).mpr <| IsPurelyInseparable.minpoly_eq_X_pow_sub_C F q x)⟩ theorem bijective_comp_algebraMap [Field L] [PerfectField L] : Function.Bijective fun f : E →+* L ↦ f.comp (algebraMap F E) := ⟨injective_comp_algebraMap F E L, fun g ↦ let _ := g.toAlgebra ⟨_, (Classical.arbitrary <| E →ₐ[F] L).comp_algebraMap⟩⟩ theorem bijective_restrictDomain [Field L] [PerfectField L] [Algebra R L] [IsScalarTower R F E] : Function.Bijective (AlgHom.restrictDomain (A := R) F (C := E) (D := L)) := ⟨injective_restrictDomain F E R L, fun g ↦ let _ := g.toAlgebra let f := Classical.arbitrary (E →ₐ[F] L) ⟨f.restrictScalars R, AlgHom.coe_ringHom_injective f.comp_algebraMap⟩⟩ end IsPurelyInseparable /-- If `E / F` is purely inseparable, then for any reduced `F`-algebra `L`, there exists at most one `F`-algebra homomorphism from `E` to `L`. -/ instance instSubsingletonAlgHomOfIsPurelyInseparable [IsPurelyInseparable F E] (L : Type w) [CommRing L] [IsReduced L] [Algebra F L] : Subsingleton (E →ₐ[F] L) where allEq f g := AlgHom.coe_ringHom_injective <| IsPurelyInseparable.injective_comp_algebraMap F E L (by simp_rw [AlgHom.comp_algebraMap]) instance instUniqueAlgHomOfIsPurelyInseparable [IsPurelyInseparable F E] (L : Type w) [CommRing L] [IsReduced L] [Algebra F L] [Algebra E L] [IsScalarTower F E L] : Unique (E →ₐ[F] L) := uniqueOfSubsingleton (IsScalarTower.toAlgHom F E L) /-- If `E / F` is purely inseparable, then `Field.Emb F E` has exactly one element. -/ instance instUniqueEmbOfIsPurelyInseparable [IsPurelyInseparable F E] : Unique (Emb F E) := instUniqueAlgHomOfIsPurelyInseparable F E _ /-- A purely inseparable extension has finite separable degree one. -/ theorem IsPurelyInseparable.finSepDegree_eq_one [IsPurelyInseparable F E] : finSepDegree F E = 1 := Nat.card_unique /-- A purely inseparable extension has separable degree one. -/ theorem IsPurelyInseparable.sepDegree_eq_one [IsPurelyInseparable F E] : sepDegree F E = 1 := by rw [sepDegree, separableClosure.eq_bot_of_isPurelyInseparable, IntermediateField.rank_bot] /-- A purely inseparable extension has inseparable degree equal to degree. -/ theorem IsPurelyInseparable.insepDegree_eq [IsPurelyInseparable F E] : insepDegree F E = Module.rank F E := by rw [insepDegree, separableClosure.eq_bot_of_isPurelyInseparable, rank_bot'] /-- A purely inseparable extension has finite inseparable degree equal to degree. -/ theorem IsPurelyInseparable.finInsepDegree_eq [IsPurelyInseparable F E] : finInsepDegree F E = finrank F E := congr(Cardinal.toNat $(insepDegree_eq F E)) /-- An extension is purely inseparable if and only if it has finite separable degree one. -/ theorem isPurelyInseparable_iff_finSepDegree_eq_one : IsPurelyInseparable F E ↔ finSepDegree F E = 1 := ⟨fun _ ↦ IsPurelyInseparable.finSepDegree_eq_one F E, fun h ↦ isPurelyInseparable_of_finSepDegree_eq_one h⟩ lemma isSeparable_iff_finInsepDegree_eq_one : Algebra.IsSeparable F K ↔ finInsepDegree F K = 1 := by rw [← separableClosure.eq_top_iff, ← IntermediateField.finrank_eq_one_iff_eq_top, finInsepDegree] variable {F E} in /-- An algebraic extension is purely inseparable if and only if all of its finite-dimensional subextensions are purely inseparable. -/ theorem isPurelyInseparable_iff_fd_isPurelyInseparable [Algebra.IsAlgebraic F E] : IsPurelyInseparable F E ↔ ∀ L : IntermediateField F E, FiniteDimensional F L → IsPurelyInseparable F L := by refine ⟨fun _ _ _ ↦ IsPurelyInseparable.tower_bot F _ E, fun h ↦ isPurelyInseparable_iff.2 fun x ↦ ?_⟩ have hx : IsIntegral F x := Algebra.IsIntegral.isIntegral x refine ⟨hx, fun _ ↦ ?_⟩ obtain ⟨y, h⟩ := (h _ (adjoin.finiteDimensional hx)).inseparable' _ <| show Separable (minpoly F (AdjoinSimple.gen F x)) by rwa [minpoly_eq] exact ⟨y, congr_arg (algebraMap _ E) h⟩ /-- A purely inseparable extension is normal. -/ instance IsPurelyInseparable.normal [IsPurelyInseparable F E] : Normal F E where toIsAlgebraic := isAlgebraic F E splits' x := by obtain ⟨n, h⟩ := IsPurelyInseparable.minpoly_eq_X_sub_C_pow F (ringExpChar F) x rw [← splits_id_iff_splits, h] exact splits_pow _ (splits_X_sub_C _) _ /-- If `E / F` is algebraic, then `E` is purely inseparable over the separable closure of `F` in `E`. -/ @[stacks 030K "$E/E_{sep}$ is purely inseparable."] instance separableClosure.isPurelyInseparable [Algebra.IsAlgebraic F E] : IsPurelyInseparable (separableClosure F E) E := isPurelyInseparable_iff.2 fun x ↦ by set L := separableClosure F E refine ⟨(IsAlgebraic.tower_top L (Algebra.IsAlgebraic.isAlgebraic (R := F) x)).isIntegral, fun h ↦ ?_⟩ haveI := (isSeparable_adjoin_simple_iff_isSeparable L E).2 h haveI : Algebra.IsSeparable F (restrictScalars F L⟮x⟯) := Algebra.IsSeparable.trans F L L⟮x⟯ have hx : x ∈ restrictScalars F L⟮x⟯ := mem_adjoin_simple_self _ x exact ⟨⟨x, mem_separableClosure_iff.2 <| isSeparable_of_mem_isSeparable F E hx⟩, rfl⟩ open Cardinal in theorem Field.Emb.cardinal_separableClosure [Algebra.IsAlgebraic F E] : #(Field.Emb F <| separableClosure F E) = #(Field.Emb F E) := by rw [← (embProdEmbOfIsAlgebraic F (separableClosure F E) E).cardinal_eq, mk_prod, mk_eq_one (Emb _ E), lift_one, mul_one, lift_id] lemma finInsepDegree_eq_pow (q : ℕ) [ExpChar F q] [FiniteDimensional F E] : ∃ n, finInsepDegree F E = q ^ n := IsPurelyInseparable.finrank_eq_pow .. /-- An intermediate field of `E / F` contains the separable closure of `F` in `E` if `E` is purely inseparable over it. -/ theorem separableClosure_le (L : IntermediateField F E) [h : IsPurelyInseparable L E] : separableClosure F E ≤ L := fun x hx ↦ by obtain ⟨y, rfl⟩ := h.inseparable' _ <| IsSeparable.tower_top L (mem_separableClosure_iff.1 hx) exact y.2 /-- If `E / F` is algebraic, then an intermediate field of `E / F` contains the separable closure of `F` in `E` if and only if `E` is purely inseparable over it. -/ theorem separableClosure_le_iff [Algebra.IsAlgebraic F E] (L : IntermediateField F E) : separableClosure F E ≤ L ↔ IsPurelyInseparable L E := by refine ⟨fun h ↦ ?_, fun _ ↦ separableClosure_le F E L⟩ letI := (inclusion h).toAlgebra letI : SMul (separableClosure F E) L := Algebra.toSMul haveI : IsScalarTower (separableClosure F E) L E := IsScalarTower.of_algebraMap_eq (congrFun rfl) exact IsPurelyInseparable.tower_top (separableClosure F E) L E /-- If an intermediate field of `E / F` is separable over `F`, and `E` is purely inseparable over it, then it is equal to the separable closure of `F` in `E`. -/ theorem eq_separableClosure (L : IntermediateField F E) [Algebra.IsSeparable F L] [IsPurelyInseparable L E] : L = separableClosure F E := le_antisymm (le_separableClosure F E L) (separableClosure_le F E L) open separableClosure in /-- If `E / F` is algebraic, then an intermediate field of `E / F` is equal to the separable closure of `F` in `E` if and only if it is separable over `F`, and `E` is purely inseparable over it. -/ theorem eq_separableClosure_iff [Algebra.IsAlgebraic F E] (L : IntermediateField F E) : L = separableClosure F E ↔ Algebra.IsSeparable F L ∧ IsPurelyInseparable L E := ⟨by rintro rfl; exact ⟨isSeparable F E, isPurelyInseparable F E⟩, fun ⟨_, _⟩ ↦ eq_separableClosure F E L⟩ /-- If `L` is an algebraically closed field containing `E`, such that the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is injective, then `E / F` is purely inseparable. As a corollary, epimorphisms in the category of fields must be purely inseparable extensions. -/ theorem IsPurelyInseparable.of_injective_comp_algebraMap (L : Type w) [Field L] [IsAlgClosed L] [Nonempty (E →+* L)] (h : Function.Injective fun f : E →+* L ↦ f.comp (algebraMap F E)) : IsPurelyInseparable F E := by rw [isPurelyInseparable_iff_finSepDegree_eq_one, finSepDegree, Nat.card_eq_one_iff_unique] letI := (Classical.arbitrary (E →+* L)).toAlgebra let j : AlgebraicClosure E →ₐ[E] L := IsAlgClosed.lift exact ⟨⟨fun f g ↦ DFunLike.ext' <| j.injective.comp_left (congr_arg (⇑) <| @h (j.toRingHom.comp f) (j.toRingHom.comp g) (by ext; simp))⟩, inferInstance⟩ end Field namespace IntermediateField instance isPurelyInseparable_bot : IsPurelyInseparable F (⊥ : IntermediateField F E) := (botEquiv F E).symm.isPurelyInseparable end IntermediateField /-- If `E` is an algebraic closure of `F`, then `F` is separably closed if and only if `E / F` is purely inseparable. -/ theorem isSepClosed_iff_isPurelyInseparable_algebraicClosure [IsAlgClosure F E] : IsSepClosed F ↔ IsPurelyInseparable F E := ⟨fun _ ↦ inferInstance, fun H ↦ by haveI := IsAlgClosure.isAlgClosed F (K := E) rwa [← separableClosure.eq_bot_iff, IsSepClosed.separableClosure_eq_bot_iff] at H⟩ variable {F E} in /-- If `E / F` is an algebraic extension, `F` is separably closed, then `E` is also separably closed. -/ theorem Algebra.IsAlgebraic.isSepClosed [Algebra.IsAlgebraic F E] [IsSepClosed F] : IsSepClosed E := have : Algebra.IsAlgebraic F (AlgebraicClosure E) := .trans F E _ (isSepClosed_iff_isPurelyInseparable_algebraicClosure E _).mpr (IsPurelyInseparable.tower_top F E <| AlgebraicClosure E) namespace Field /-- If `E / F` is algebraic, then the `Field.finSepDegree F E` is equal to `Field.sepDegree F E` as a natural number. This means that the cardinality of `Field.Emb F E` and the degree of `(separableClosure F E) / F` are both finite or infinite, and when they are finite, they coincide. -/ @[stacks 09HJ "`sepDegree` is defined as the right-hand side of 09HJ"] theorem finSepDegree_eq [Algebra.IsAlgebraic F E] : finSepDegree F E = Cardinal.toNat (sepDegree F E) := by have h := finSepDegree_mul_finSepDegree_of_isAlgebraic F (separableClosure F E) E |>.symm haveI := separableClosure.isSeparable F E haveI := separableClosure.isPurelyInseparable F E rwa [finSepDegree_eq_finrank_of_isSeparable F (separableClosure F E), IsPurelyInseparable.finSepDegree_eq_one (separableClosure F E) E, mul_one] at h /-- The finite separable degree multiply by the finite inseparable degree is equal to the (finite) field extension degree. -/ theorem finSepDegree_mul_finInsepDegree : finSepDegree F E * finInsepDegree F E = finrank F E := by by_cases halg : Algebra.IsAlgebraic F E · have := congr_arg Cardinal.toNat (sepDegree_mul_insepDegree F E) rwa [Cardinal.toNat_mul, ← finSepDegree_eq F E] at this rw [finInsepDegree, finrank_of_infinite_dimensional (K := F) (V := E) fun _ ↦ halg (Algebra.IsAlgebraic.of_finite F E), finrank_of_infinite_dimensional (K := separableClosure F E) (V := E) fun _ ↦ halg (.trans _ (separableClosure F E) _), mul_zero] end Field namespace separableClosure variable [Algebra E K] [IsScalarTower F E K] {F E} /-- If `K / E / F` is a field extension tower, such that `E / F` is algebraic and `K / E` is separable, then `E` adjoin `separableClosure F K` is equal to `K`. It is a special case of `separableClosure.adjoin_eq_of_isAlgebraic`, and is an intermediate result used to prove it. -/ lemma adjoin_eq_of_isAlgebraic_of_isSeparable [Algebra.IsAlgebraic F E] [Algebra.IsSeparable E K] : adjoin E (separableClosure F K : Set K) = ⊤ := top_unique fun x _ ↦ by set S := separableClosure F K set L := adjoin E (S : Set K) have := Algebra.isSeparable_tower_top_of_isSeparable E L K let i : S →+* L := Subsemiring.inclusion fun x hx ↦ subset_adjoin E (S : Set K) hx let _ : Algebra S L := i.toAlgebra let _ : SMul S L := Algebra.toSMul have : IsScalarTower S L K := IsScalarTower.of_algebraMap_eq (congrFun rfl) have := Algebra.IsAlgebraic.trans F E K have : IsPurelyInseparable S K := separableClosure.isPurelyInseparable F K have := IsPurelyInseparable.tower_top S L K obtain ⟨y, rfl⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable L K x exact y.2 /-- If `K / E / F` is a field extension tower, such that `E / F` is algebraic, then `E` adjoin `separableClosure F K` is equal to `separableClosure E K`. -/ theorem adjoin_eq_of_isAlgebraic [Algebra.IsAlgebraic F E] : adjoin E (separableClosure F K) = separableClosure E K := by set S := separableClosure E K have h := congr_arg lift (adjoin_eq_of_isAlgebraic_of_isSeparable (F := F) S) rw [lift_top, lift_adjoin] at h haveI : IsScalarTower F S K := IsScalarTower.of_algebraMap_eq (congrFun rfl) rw [← h, ← map_eq_of_separableClosure_eq_bot F (separableClosure_eq_bot E K)] simp only [S, coe_map, IsScalarTower.coe_toAlgHom', IntermediateField.algebraMap_apply] end separableClosure section open TensorProduct section Subalgebra variable (R A : Type*) [CommSemiring R] [CommSemiring A] [Algebra R A] (p : ℕ) [ExpChar A p] /-- The perfect closure of `R` in `A` are the elements `x : A` such that `x ^ p ^ n` is in `R` for some `n`, where `p` is the exponential characteristic of `R`. -/ def Subalgebra.perfectClosure : Subalgebra R A where carrier := {x : A | ∃ n : ℕ, x ^ p ^ n ∈ (algebraMap R A).rangeS} add_mem' := by rintro x y ⟨n, hx⟩ ⟨m, hy⟩ use n + m rw [add_pow_expChar_pow, pow_add, pow_mul, mul_comm (_ ^ n), pow_mul] exact add_mem (pow_mem hx _) (pow_mem hy _) mul_mem' := by rintro x y ⟨n, hx⟩ ⟨m, hy⟩ use n + m rw [mul_pow, pow_add, pow_mul, mul_comm (_ ^ n), pow_mul] exact mul_mem (pow_mem hx _) (pow_mem hy _) algebraMap_mem' := fun x ↦ ⟨0, by rw [pow_zero, pow_one]; exact ⟨x, rfl⟩⟩ variable {R A p} theorem Subalgebra.mem_perfectClosure_iff {x : A} : x ∈ perfectClosure R A p ↔ ∃ n : ℕ, x ^ p ^ n ∈ (algebraMap R A).rangeS := Iff.rfl end Subalgebra variable {k K R : Type*} [Field k] [Field K] [Algebra k K] [CommRing R] [Algebra k R] lemma IsPurelyInseparable.exists_pow_pow_mem_range_tensorProduct_of_expChar [IsPurelyInseparable k K] (q : ℕ) [ExpChar k q] (x : R ⊗[k] K) : ∃ n, x ^ q ^ n ∈ (algebraMap R (R ⊗[k] K)).range := by nontriviality (R ⊗[k] K) obtain (hq|hq) := expChar_is_prime_or_one k q induction x with | zero => exact ⟨0, 0, by simp⟩ | add x y h h' => have : ExpChar (R ⊗[k] K) q := expChar_of_injective_ringHom (algebraMap k _).injective q simp_rw [RingHom.mem_range, ← RingHom.mem_rangeS, ← Subalgebra.mem_perfectClosure_iff] at h h' ⊢ exact add_mem h h' | tmul x y => obtain ⟨n, a, ha⟩ := IsPurelyInseparable.pow_mem k q y use n have : (x ^ q ^ n) ⊗ₜ[k] (y ^ q ^ n) = (x ^ q ^ n) ⊗ₜ[k] (1 : K) * (1 : R) ⊗ₜ[k] (y ^ q ^ n) := by rw [Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul] rw [Algebra.TensorProduct.tmul_pow, this] refine Subring.mul_mem _ ⟨x ^ q ^ n, rfl⟩ ⟨algebraMap k R a, ?_⟩ rw [← IsScalarTower.algebraMap_apply, Algebra.TensorProduct.algebraMap_apply, Algebra.TensorProduct.tmul_one_eq_one_tmul, ha] · subst hq have : CharZero k := charZero_of_expChar_one' k exact ⟨0, (Algebra.TensorProduct.includeLeft_surjective R _ <| IsPurelyInseparable.surjective_algebraMap_of_isSeparable k K) _⟩ lemma IsPurelyInseparable.exists_pow_mem_range_tensorProduct [IsPurelyInseparable k K] (x : R ⊗[k] K) : ∃ n > 0, x ^ n ∈ (algebraMap R (R ⊗[k] K)).range := by let q := ringExpChar k obtain ⟨n, hr⟩ := exists_pow_pow_mem_range_tensorProduct_of_expChar q x refine ⟨q ^ n, pow_pos ?_ _, hr⟩ obtain (hq|hq) := expChar_is_prime_or_one k q <;> simp [hq, Nat.Prime.pos] end
.lake/packages/mathlib/Mathlib/FieldTheory/PurelyInseparable/Exponent.lean
import Mathlib.FieldTheory.PurelyInseparable.Basic /-! # The exponent of purely inseparable extensions This file defines the exponent of a purely inseparable extension (if one exists) and some related results. Most results are stated using `ringExpChar K` rather than using `[ExpChar K p]` parameter because it gives cleaner API. To use the results in a context with `[ExpChar K p]`, consider using `ringExpChar.eq K p` for substitution. ## Main definitions - `IsPurelyInseparable.HasExponent`: typeclass to assert a purely inseparable field extension `L / K` has an exponent, that is a smallest natural number `e` such that `a ^ ringExpChar K ^ e ∈ K` for all `a ∈ L`. - `IsPurelyInseparable.exponent`: the exponent of a purely inseparable field extension. - `IsPurelyInseparable.elemExponent`: the exponent of an element of a purely inseparable field extension, that is the smallest natural number `e` such that `a ^ ringExpChar K ^ e ∈ K`. - `IsPurelyInseparable.iterateFrobenius`: the iterated Frobenius map (ring homomorphism) `L →+* K` for purely inseparable field extension `L / K` with exponent; for `n ≥ exponent K L`, it acts like `x ↦ x ^ p ^ n` but the codomain is the base field `K`. - `IsPurelyInseparable.iterateFrobeniusₛₗ`: version of `iterateFrobenius` as a semilinear map over a subfield `F` of `K`, w.r.t. the iterated Frobenius homomorphism on `F`. ## Tags purely inseparable -/ namespace IsPurelyInseparable variable (F K L : Type*) section Ring variable [CommRing K] [Ring L] [Algebra K L] /-- A predicate class on a ring extension saying that there is a natural number `e` such that `a ^ ringExpChar K ^ e ∈ K` for all `a ∈ L`. -/ @[mk_iff] class HasExponent : Prop where has_exponent : ∃ e, ∀ a, a ^ ringExpChar K ^ e ∈ (algebraMap K L).range /-- Version of `hasExponent_iff` using `ExpChar`. -/ theorem hasExponent_iff' (p : ℕ) [ExpChar K p] : HasExponent K L ↔ ∃ e, ∀ (a : L), a ^ p ^ e ∈ (algebraMap K L).range := ringExpChar.eq K p ▸ hasExponent_iff K L open scoped Classical in /-- The *exponent* of a purely inseparable extension is the smallest natural number `e` such that `a ^ ringExpChar K ^ e ∈ K` for all `a ∈ L`. -/ noncomputable def exponent [HasExponent K L] : ℕ := Nat.find ‹HasExponent K L›.has_exponent variable {L} open Classical in theorem exponent_def [HasExponent K L] (a : L) : a ^ ringExpChar K ^ exponent K L ∈ (algebraMap K L).range := Nat.find_spec ‹HasExponent K L›.has_exponent a /-- Version of `exponent_def` using `ExpChar`. -/ theorem exponent_def' [HasExponent K L] (p : ℕ) [ExpChar K p] (a : L) : a ^ p ^ exponent K L ∈ (algebraMap K L).range := ringExpChar.eq K p ▸ exponent_def K a variable {K} open Classical in theorem exponent_min [HasExponent K L] {e : ℕ} (h : e < exponent K L) : ∃ a, a ^ ringExpChar K ^ e ∉ (algebraMap K L).range := not_forall.mp <| Nat.find_min ‹HasExponent K L›.has_exponent h /-- Version of `exponent_min` using `ExpChar`. -/ theorem exponent_min' [HasExponent K L] (p : ℕ) [ExpChar K p] {e : ℕ} (h : e < exponent K L) : ∃ a, a ^ p ^ e ∉ (algebraMap K L).range := ringExpChar.eq K p ▸ exponent_min h end Ring section IsDomain variable [Field K] [Ring L] [IsDomain L] [Algebra K L] instance [HasExponent K L] : IsPurelyInseparable K L := let ⟨n, h⟩ := ‹HasExponent K L›.has_exponent (isPurelyInseparable_iff_pow_mem K (ringExpChar K)).mpr fun x ↦ ⟨n, h x⟩ end IsDomain section Field open Polynomial variable [Field K] [Field L] [Algebra K L] [IsPurelyInseparable K L] variable {L} open Classical in /-- The exponent of an element `a ∈ L` of a purely inseparable field extension `L / K` is the smallest natural number `e` such that `a ^ ringExpChar K ^ e ∈ K`. -/ noncomputable def elemExponent (a : L) : ℕ := Nat.find <| minpoly_eq_X_pow_sub_C K (ringExpChar K) a open Classical in variable {K} in theorem elemExponent_eq_zero_of_mem_range {a : L} (h : a ∈ (algebraMap K L).range) : elemExponent K a = 0 := by apply (Nat.find_eq_zero _).mpr rw [pow_zero, pow_one] obtain ⟨y, hy⟩ := h exact ⟨y, hy ▸ minpoly.eq_X_sub_C L y⟩ theorem elemExponent_eq_zero_of_charZero (a : L) [CharZero K] : elemExponent K a = 0 := elemExponent_eq_zero_of_mem_range <| surjective_algebraMap_of_isSeparable K L a open Classical in /-- The element `y` of the base field `K` such that `a ^ ringExpChar K ^ elemExponent K a = algebraMap K L y`. See `IsPurelyInseparable.algebraMap_elemReduct_eq`. -/ noncomputable def elemReduct (a : L) : K := Classical.choose <| Nat.find_spec <| minpoly_eq_X_pow_sub_C K (ringExpChar K) a open Classical in theorem minpoly_eq (a : L) : minpoly K a = X ^ ringExpChar K ^ elemExponent K a - C (elemReduct K a) := Classical.choose_spec <| Nat.find_spec <| minpoly_eq_X_pow_sub_C K (ringExpChar K) a open Classical in /-- Version of `minpoly_eq` using `ExpChar`. -/ theorem minpoly_eq' (p : ℕ) [ExpChar K p] (a : L) : minpoly K a = X ^ p ^ elemExponent K a - C (elemReduct K a) := ringExpChar.eq K p ▸ minpoly_eq K a /-- The degree of the minimal polynomial of an element `a ∈ L` equals `ringExpChar K ^ elemExponent K a`. -/ theorem minpoly_natDegree_eq (a : L) : (minpoly K a).natDegree = ringExpChar K ^ elemExponent K a := by rw [minpoly_eq K a, natDegree_sub_C, natDegree_pow, natDegree_X, mul_one] /-- Version of `minpoly_natDegree_eq` using `ExpChar`. -/ theorem minpoly_natDegree_eq' (p : ℕ) [ExpChar K p] (a : L) : (minpoly K a).natDegree = p ^ elemExponent K a := ringExpChar.eq K p ▸ minpoly_natDegree_eq K a theorem algebraMap_elemReduct_eq (a : L) : algebraMap K L (elemReduct K a) = a ^ ringExpChar K ^ elemExponent K a := by have := minpoly_eq K a ▸ minpoly.aeval K a rwa [map_sub, aeval_C, map_pow, aeval_X, sub_eq_zero, eq_comm] at this /-- Version of `algebraMap_elemReduct_eq` using `ExpChar`. -/ theorem algebraMap_elemReduct_eq' (p : ℕ) [ExpChar K p] (a : L) : algebraMap K L (elemReduct K a) = a ^ p ^ elemExponent K a := ringExpChar.eq K p ▸ algebraMap_elemReduct_eq K a theorem elemExponent_def (a : L) : a ^ ringExpChar K ^ elemExponent K a ∈ (algebraMap K L).range := RingHom.mem_range.mpr <| ⟨_, algebraMap_elemReduct_eq K a⟩ /-- Version of `elemExponent_def` using `ExpChar`. -/ theorem elemExponent_def' (p : ℕ) [ExpChar K p] (a : L) : a ^ p ^ elemExponent K a ∈ (algebraMap K L).range := ringExpChar.eq K p ▸ elemExponent_def K a variable {K} in theorem elemExponent_le_of_pow_mem {a : L} {n : ℕ} (h : a ^ ringExpChar K ^ n ∈ (algebraMap K L).range) : elemExponent K a ≤ n := by let ⟨p, _⟩ := ExpChar.exists K rcases ‹ExpChar K p› with _ | ⟨hp⟩ · exact elemExponent_eq_zero_of_charZero K a ▸ Nat.zero_le _ · obtain ⟨y, hy⟩ := RingHom.mem_range.mp <| h let f := X ^ ringExpChar K ^ n - C y have hf₁ : f.aeval a = 0 := by rwa [map_sub, aeval_C, aeval_X_pow, sub_eq_zero, eq_comm] have hf₂ : f.Monic := monic_X_pow_sub_C y <| Nat.pos_iff_ne_zero.mp <| expChar_pow_pos K _ _ have hf₃ : f.natDegree = ringExpChar K ^ n := by rw [natDegree_sub_C, natDegree_pow, natDegree_X, mul_one] exact (Nat.pow_le_pow_iff_right <| Nat.Prime.one_lt hp).mp <| ringExpChar.eq K p ▸ hf₃ ▸ minpoly_natDegree_eq K a ▸ natDegree_le_natDegree (minpoly.min K a hf₂ hf₁) variable {K} in /-- Version of `elemExponent_le_of_pow_mem` using `ExpChar`. -/ theorem elemExponent_le_of_pow_mem' (p : ℕ) [ExpChar K p] {a : L} {n : ℕ} (h : a ^ p ^ n ∈ (algebraMap K L).range) : elemExponent K a ≤ n := elemExponent_le_of_pow_mem (ringExpChar.eq K p ▸ h) variable {K} in theorem elemExponent_min {a : L} {n : ℕ} (h : n < elemExponent K a) : a ^ ringExpChar K ^ n ∉ (algebraMap K L).range := fun hn ↦ (Nat.not_lt_of_ge <| elemExponent_le_of_pow_mem hn) h /-- Version of `elemExponent_min` using `ExpChar`. -/ theorem elemExponent_min' (p : ℕ) [ExpChar K p] {a : L} {n : ℕ} (h : n < elemExponent K a) : a ^ p ^ n ∉ (algebraMap K L).range := ringExpChar.eq K p ▸ elemExponent_min h /-- An exponent of an element is less or equal than exponent of the extension. -/ theorem elemExponent_le_exponent [HasExponent K L] (a : L) : elemExponent K a ≤ exponent K L := elemExponent_le_of_pow_mem <| exponent_def K a variable {K} in instance hasExponent_of_finiteDimensional [IsPurelyInseparable K L] [FiniteDimensional K L] : HasExponent K L := by let ⟨p, _⟩ := ExpChar.exists K rcases ‹ExpChar K p› with _ | ⟨hp⟩ · exact ⟨0, fun a ↦ surjective_algebraMap_of_isSeparable K L _⟩ · let e := Nat.log (ringExpChar K) (Module.finrank K L) refine ⟨e, fun a ↦ ⟨elemReduct K a ^ ringExpChar K ^ (e - elemExponent K a), ?_⟩⟩ have h_elemexp_bound (a : L) : elemExponent K a ≤ e := Nat.le_log_of_pow_le (Nat.Prime.one_lt <| ringExpChar.eq K p ▸ hp) (minpoly_natDegree_eq K a ▸ minpoly.natDegree_le a) rw [RingHom.map_pow, algebraMap_elemReduct_eq, ← pow_mul, ← pow_add, Nat.add_sub_cancel' (h_elemexp_bound a)] end Field section Frobenius /- This section defines the iterated Frobenius map `x ↦ x ^ p ^ n` for a purely inseparable field extension `L / K` with exponent, with the base field `K` as a codomain, when `n ≥ exponent K L`. We define it both as a ring homomorphism and a semilinear map over a subfield `F` of `K`. Implementation note: the API exposes arguments `{n : ℕ} (hn : exponent K L ≤ n)` to define the action `x ↦ x ^ p ^ n` instead of just `(n : ℕ)` with action `x ↦ x ^ p ^ (exponent K L + n)` to avoid problems with definitional equality when using the semilinear map version. -/ variable [Field K] [Field L] [Algebra K L] [HasExponent K L] variable (p : ℕ) [ExpChar K p] private noncomputable def iterateFrobeniusAux (n : ℕ) : L → K := fun a ↦ elemReduct K a ^ p ^ (n - elemExponent K a) variable {L} in /-- Action of `iterateFrobeniusAux` on the top field. -/ private theorem algebraMap_iterateFrobeniusAux {n : ℕ} (hn : exponent K L ≤ n) (a : L) : algebraMap K L (iterateFrobeniusAux K L p n a) = a ^ p ^ n := by rw [iterateFrobeniusAux, RingHom.map_pow, algebraMap_elemReduct_eq' K p, ← pow_mul, ← pow_add, Nat.add_sub_cancel' <| (elemExponent_le_exponent K a).trans hn] section RingHom /-- Iterated Frobenius map (ring homomorphism) for purely inseparable field extension with exponent. If `n ≥ exponent K L`, it acts like `x ↦ x ^ p ^ n` but the codomain is the base field `K`. -/ noncomputable def iterateFrobenius {n : ℕ} (hn : exponent K L ≤ n) : L →+* K where toFun := iterateFrobeniusAux K L p n map_zero' := by apply (algebraMap K L).injective rw [(algebraMap K L).map_zero, algebraMap_iterateFrobeniusAux K p hn 0, zero_pow] exact Nat.pos_iff_ne_zero.mp <| expChar_pow_pos K p n map_add' a b := by have inj := (algebraMap K L).injective have : ExpChar L p := expChar_of_injective_ringHom inj p apply inj rw [(algebraMap K L).map_add, algebraMap_iterateFrobeniusAux K p hn a, algebraMap_iterateFrobeniusAux K p hn b, algebraMap_iterateFrobeniusAux K p hn (a + b), add_pow_expChar_pow a b] map_one' := by apply (algebraMap K L).injective rw [(algebraMap K L).map_one, algebraMap_iterateFrobeniusAux K p hn 1, one_pow] map_mul' a b := by apply (algebraMap K L).injective rw [(algebraMap K L).map_mul, algebraMap_iterateFrobeniusAux K p hn a, algebraMap_iterateFrobeniusAux K p hn b, algebraMap_iterateFrobeniusAux K p hn (a * b), mul_pow] variable {L} in /-- Action of `iterateFrobenius` on the top field. -/ theorem algebraMap_iterateFrobenius {n : ℕ} (hn : exponent K L ≤ n) (a : L) : algebraMap K L (iterateFrobenius K L p hn a) = a ^ p ^ n := algebraMap_iterateFrobeniusAux K p hn a variable {K} in /-- Action of `iterateFrobenius` on the bottom field. -/ theorem iterateFrobenius_algebraMap {n : ℕ} (hn : exponent K L ≤ n) (a : K) : iterateFrobenius K L p hn (algebraMap K L a) = a ^ p ^ n := by apply (algebraMap K L).injective rw [map_pow, algebraMap_iterateFrobenius K p hn] end RingHom section Semilinear variable [Field F] [Algebra F K] [Algebra F L] [IsScalarTower F K L] variable [ExpChar F p] /-- Version of `iterateFrobenius` as a semilinear map over a subfield `F` of `K`, w.r.t. the iterated Frobenius homomorphism on `F`. -/ noncomputable def iterateFrobeniusₛₗ {n : ℕ} (hn : exponent K L ≤ n) : L →ₛₗ[_root_.iterateFrobenius F p n] K where __ := iterateFrobenius K L p hn map_smul' r a := by dsimp [iterateFrobenius] rw [Algebra.smul_def _ (iterateFrobeniusAux K L p n a)] apply (algebraMap K L).injective rw [(algebraMap K L).map_mul, ← IsScalarTower.algebraMap_apply, algebraMap_iterateFrobeniusAux K p hn a, algebraMap_iterateFrobeniusAux K p hn (r • a), iterateFrobenius_def, map_pow, Algebra.smul_def, mul_pow] /-- Action of `iterateFrobeniusₛₗ` on the top field. -/ theorem algebraMap_iterateFrobeniusₛₗ {n : ℕ} (hn : exponent K L ≤ n) (a : L) : algebraMap K L (iterateFrobeniusₛₗ F K L p hn a) = a ^ p ^ n := algebraMap_iterateFrobenius K p hn a /-- Action of `iterateFrobeniusₛₗ` on the bottom field. -/ theorem iterateFrobeniusₛₗ_algebraMap {n : ℕ} (hn : exponent K L ≤ n) (a : K) : iterateFrobeniusₛₗ F K L p hn (algebraMap K L a) = a ^ p ^ n := iterateFrobenius_algebraMap L p hn a /-- Action of `iterateFrobeniusₛₗ` on the base field. -/ theorem iterateFrobeniusₛₗ_algebraMap_base {n : ℕ} (hn : exponent K L ≤ n) (a : F) : iterateFrobeniusₛₗ F K L p hn (algebraMap F L a) = (algebraMap F K a) ^ p ^ n := by apply (algebraMap K L).injective rw [← map_pow, ← IsScalarTower.algebraMap_apply, map_pow, algebraMap_iterateFrobeniusₛₗ F K L p hn] end Semilinear end Frobenius end IsPurelyInseparable
.lake/packages/mathlib/Mathlib/FieldTheory/PurelyInseparable/PerfectClosure.lean
import Mathlib.Algebra.CharP.Lemmas import Mathlib.Algebra.CharP.IntermediateField import Mathlib.FieldTheory.PurelyInseparable.Basic /-! # Basic results about relative perfect closure This file contains basic results about relative perfect closures. ## Main definitions - `perfectClosure`: the relative perfect closure of `F` in `E`, it consists of the elements `x` of `E` such that there exists a natural number `n` such that `x ^ (ringExpChar F) ^ n` is contained in `F`, where `ringExpChar F` is the exponential characteristic of `F`. It is also the maximal purely inseparable subextension of `E / F` (`le_perfectClosure_iff`). ## Main results - `le_perfectClosure_iff`: an intermediate field of `E / F` is contained in the relative perfect closure of `F` in `E` if and only if it is purely inseparable over `F`. - `perfectClosure.perfectRing`, `perfectClosure.perfectField`: if `E` is a perfect field, then the (relative) perfect closure `perfectClosure F E` is perfect. - `IntermediateField.isPurelyInseparable_adjoin_iff_pow_mem`: if `F` is of exponential characteristic `q`, then `F(S) / F` is a purely inseparable extension if and only if for any `x ∈ S`, `x ^ (q ^ n)` is contained in `F` for some `n : ℕ`. ## Tags separable degree, degree, separable closure, purely inseparable -/ open IntermediateField Module noncomputable section universe u v w variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] section perfectClosure /-- The relative perfect closure of `F` in `E`, consists of the elements `x` of `E` such that there exists a natural number `n` such that `x ^ (ringExpChar F) ^ n` is contained in `F`, where `ringExpChar F` is the exponential characteristic of `F`. It is also the maximal purely inseparable subextension of `E / F` (`le_perfectClosure_iff`). -/ @[stacks 09HH] def perfectClosure : IntermediateField F E where __ := have := expChar_of_injective_algebraMap (algebraMap F E).injective (ringExpChar F) Subalgebra.perfectClosure F E (ringExpChar F) inv_mem' := by rintro x ⟨n, hx⟩ use n; rw [inv_pow] apply inv_mem (id hx : _ ∈ (⊥ : IntermediateField F E)) variable {F E} theorem mem_perfectClosure_iff {x : E} : x ∈ perfectClosure F E ↔ ∃ n : ℕ, x ^ (ringExpChar F) ^ n ∈ (algebraMap F E).range := Iff.rfl theorem mem_perfectClosure_iff_pow_mem (q : ℕ) [ExpChar F q] {x : E} : x ∈ perfectClosure F E ↔ ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by rw [mem_perfectClosure_iff, ringExpChar.eq F q] /-- An element is contained in the relative perfect closure if and only if its minimal polynomial has separable degree one. -/ theorem mem_perfectClosure_iff_natSepDegree_eq_one {x : E} : x ∈ perfectClosure F E ↔ (minpoly F x).natSepDegree = 1 := by rw [mem_perfectClosure_iff, minpoly.natSepDegree_eq_one_iff_pow_mem (ringExpChar F)] /-- A field extension `E / F` is purely inseparable if and only if the relative perfect closure of `F` in `E` is equal to `E`. -/ theorem isPurelyInseparable_iff_perfectClosure_eq_top : IsPurelyInseparable F E ↔ perfectClosure F E = ⊤ := by rw [isPurelyInseparable_iff_pow_mem F (ringExpChar F)] exact ⟨fun H ↦ top_unique fun x _ ↦ H x, fun H _ ↦ H.ge trivial⟩ variable (F E) /-- The relative perfect closure of `F` in `E` is purely inseparable over `F`. -/ instance perfectClosure.isPurelyInseparable : IsPurelyInseparable F (perfectClosure F E) := by rw [isPurelyInseparable_iff_pow_mem F (ringExpChar F)] exact fun ⟨_, n, y, h⟩ ↦ ⟨n, y, (algebraMap _ E).injective h⟩ /-- The relative perfect closure of `F` in `E` is algebraic over `F`. -/ instance perfectClosure.isAlgebraic : Algebra.IsAlgebraic F (perfectClosure F E) := IsPurelyInseparable.isAlgebraic F _ /-- If `E / F` is separable, then the perfect closure of `F` in `E` is equal to `F`. Note that the converse is not necessarily true (see https://math.stackexchange.com/a/3009197) even when `E / F` is algebraic. -/ theorem perfectClosure.eq_bot_of_isSeparable [Algebra.IsSeparable F E] : perfectClosure F E = ⊥ := haveI := Algebra.isSeparable_tower_bot_of_isSeparable F (perfectClosure F E) E eq_bot_of_isPurelyInseparable_of_isSeparable _ /-- An intermediate field of `E / F` is contained in the relative perfect closure of `F` in `E` if it is purely inseparable over `F`. -/ theorem le_perfectClosure (L : IntermediateField F E) [h : IsPurelyInseparable F L] : L ≤ perfectClosure F E := by rw [isPurelyInseparable_iff_pow_mem F (ringExpChar F)] at h intro x hx obtain ⟨n, y, hy⟩ := h ⟨x, hx⟩ exact ⟨n, y, congr_arg (algebraMap L E) hy⟩ /-- An intermediate field of `E / F` is contained in the relative perfect closure of `F` in `E` if and only if it is purely inseparable over `F`. -/ theorem le_perfectClosure_iff (L : IntermediateField F E) : L ≤ perfectClosure F E ↔ IsPurelyInseparable F L := by refine ⟨fun h ↦ (isPurelyInseparable_iff_pow_mem F (ringExpChar F)).2 fun x ↦ ?_, fun _ ↦ le_perfectClosure F E L⟩ obtain ⟨n, y, hy⟩ := h x.2 exact ⟨n, y, (algebraMap L E).injective hy⟩ theorem separableClosure_inf_perfectClosure : separableClosure F E ⊓ perfectClosure F E = ⊥ := haveI := (le_separableClosure_iff F E _).mp (inf_le_left (b := perfectClosure F E)) haveI := (le_perfectClosure_iff F E _).mp (inf_le_right (a := separableClosure F E)) eq_bot_of_isPurelyInseparable_of_isSeparable _ section map variable {F E K} /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then `i x` is contained in `perfectClosure F K` if and only if `x` is contained in `perfectClosure F E`. -/ theorem map_mem_perfectClosure_iff (i : E →ₐ[F] K) {x : E} : i x ∈ perfectClosure F K ↔ x ∈ perfectClosure F E := by simp_rw [mem_perfectClosure_iff] refine ⟨fun ⟨n, y, h⟩ ↦ ⟨n, y, ?_⟩, fun ⟨n, y, h⟩ ↦ ⟨n, y, ?_⟩⟩ · apply_fun i using i.injective rwa [AlgHom.commutes, map_pow] simpa only [AlgHom.commutes, map_pow] using congr_arg i h /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the preimage of `perfectClosure F K` under the map `i` is equal to `perfectClosure F E`. -/ theorem perfectClosure.comap_eq_of_algHom (i : E →ₐ[F] K) : (perfectClosure F K).comap i = perfectClosure F E := by ext x exact map_mem_perfectClosure_iff i /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the image of `perfectClosure F E` under the map `i` is contained in `perfectClosure F K`. -/ theorem perfectClosure.map_le_of_algHom (i : E →ₐ[F] K) : (perfectClosure F E).map i ≤ perfectClosure F K := map_le_iff_le_comap.mpr (perfectClosure.comap_eq_of_algHom i).ge /-- If `i` is an `F`-algebra isomorphism of `E` and `K`, then the image of `perfectClosure F E` under the map `i` is equal to in `perfectClosure F K`. -/ theorem perfectClosure.map_eq_of_algEquiv (i : E ≃ₐ[F] K) : (perfectClosure F E).map i.toAlgHom = perfectClosure F K := (map_le_of_algHom i.toAlgHom).antisymm (fun x hx ↦ ⟨i.symm x, (map_mem_perfectClosure_iff i.symm.toAlgHom).2 hx, i.right_inv x⟩) /-- If `E` and `K` are isomorphic as `F`-algebras, then `perfectClosure F E` and `perfectClosure F K` are also isomorphic as `F`-algebras. -/ def perfectClosure.algEquivOfAlgEquiv (i : E ≃ₐ[F] K) : perfectClosure F E ≃ₐ[F] perfectClosure F K := (intermediateFieldMap i _).trans (equivOfEq (map_eq_of_algEquiv i)) noncomputable alias AlgEquiv.perfectClosure := perfectClosure.algEquivOfAlgEquiv end map /-- If `E` is a perfect field of exponential characteristic `p`, then the (relative) perfect closure `perfectClosure F E` is perfect. -/ instance perfectClosure.perfectRing (p : ℕ) [ExpChar E p] [PerfectRing E p] : PerfectRing (perfectClosure F E) p := .ofSurjective _ p fun x ↦ by haveI := RingHom.expChar _ (algebraMap F E).injective p obtain ⟨x', hx⟩ := surjective_frobenius E p x.1 obtain ⟨n, y, hy⟩ := (mem_perfectClosure_iff_pow_mem p).1 x.2 rw [frobenius_def] at hx rw [← hx, ← pow_mul, ← pow_succ'] at hy exact ⟨⟨x', (mem_perfectClosure_iff_pow_mem p).2 ⟨n + 1, y, hy⟩⟩, by simp_rw [frobenius_def, SubmonoidClass.mk_pow, hx]⟩ /-- If `E` is a perfect field, then the (relative) perfect closure `perfectClosure F E` is perfect. -/ instance perfectClosure.perfectField [PerfectField E] : PerfectField (perfectClosure F E) := PerfectRing.toPerfectField _ (ringExpChar E) end perfectClosure namespace IntermediateField /-- `F⟮x⟯ / F` is a purely inseparable extension if and only if the minimal polynomial of `x` has separable degree one. -/ theorem isPurelyInseparable_adjoin_simple_iff_natSepDegree_eq_one {x : E} : IsPurelyInseparable F F⟮x⟯ ↔ (minpoly F x).natSepDegree = 1 := by rw [← le_perfectClosure_iff, adjoin_simple_le_iff, mem_perfectClosure_iff_natSepDegree_eq_one] /-- If `F` is of exponential characteristic `q`, then `F⟮x⟯ / F` is a purely inseparable extension if and only if `x ^ (q ^ n)` is contained in `F` for some `n : ℕ`. -/ theorem isPurelyInseparable_adjoin_simple_iff_pow_mem (q : ℕ) [hF : ExpChar F q] {x : E} : IsPurelyInseparable F F⟮x⟯ ↔ ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by rw [← le_perfectClosure_iff, adjoin_simple_le_iff, mem_perfectClosure_iff_pow_mem q] /-- If `F` is of exponential characteristic `q`, then `F(S) / F` is a purely inseparable extension if and only if for any `x ∈ S`, `x ^ (q ^ n)` is contained in `F` for some `n : ℕ`. -/ theorem isPurelyInseparable_adjoin_iff_pow_mem (q : ℕ) [hF : ExpChar F q] {S : Set E} : IsPurelyInseparable F (adjoin F S) ↔ ∀ x ∈ S, ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by simp_rw [← le_perfectClosure_iff, adjoin_le_iff, ← mem_perfectClosure_iff_pow_mem q, Set.subset_def, SetLike.mem_coe] /-- A compositum of two purely inseparable extensions is purely inseparable. -/ instance isPurelyInseparable_sup (L1 L2 : IntermediateField F E) [h1 : IsPurelyInseparable F L1] [h2 : IsPurelyInseparable F L2] : IsPurelyInseparable F (L1 ⊔ L2 : IntermediateField F E) := by rw [← le_perfectClosure_iff] at h1 h2 ⊢ exact sup_le h1 h2 /-- A compositum of purely inseparable extensions is purely inseparable. -/ instance isPurelyInseparable_iSup {ι : Sort*} {t : ι → IntermediateField F E} [h : ∀ i, IsPurelyInseparable F (t i)] : IsPurelyInseparable F (⨆ i, t i : IntermediateField F E) := by simp_rw [← le_perfectClosure_iff] at h ⊢ exact iSup_le h /-- If `F` is a field of exponential characteristic `q`, `F(S) / F` is separable, then `F(S) = F(S ^ (q ^ n))` for any natural number `n`. -/ theorem adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable (S : Set E) [Algebra.IsSeparable F (adjoin F S)] (q : ℕ) [ExpChar F q] (n : ℕ) : adjoin F S = adjoin F ((· ^ q ^ n) '' S) := by set L := adjoin F S set M := adjoin F ((· ^ q ^ n) '' S) have hi : M ≤ L := by rw [adjoin_le_iff] rintro _ ⟨y, hy, rfl⟩ exact pow_mem (subset_adjoin F S hy) _ letI := (inclusion hi).toAlgebra haveI : Algebra.IsSeparable M (extendScalars hi) := Algebra.isSeparable_tower_top_of_isSeparable F M L haveI : IsPurelyInseparable M (extendScalars hi) := by haveI := expChar_of_injective_algebraMap (algebraMap F M).injective q rw [extendScalars_adjoin hi, isPurelyInseparable_adjoin_iff_pow_mem M _ q] exact fun x hx ↦ ⟨n, ⟨x ^ q ^ n, subset_adjoin F _ ⟨x, hx, rfl⟩⟩, rfl⟩ simpa only [extendScalars_restrictScalars, restrictScalars_bot_eq_self] using congr_arg (restrictScalars F) (extendScalars hi).eq_bot_of_isPurelyInseparable_of_isSeparable /-- If `E / F` is a separable field extension of exponential characteristic `q`, then `F(S) = F(S ^ (q ^ n))` for any subset `S` of `E` and any natural number `n`. -/ theorem adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable' [Algebra.IsSeparable F E] (S : Set E) (q : ℕ) [ExpChar F q] (n : ℕ) : adjoin F S = adjoin F ((· ^ q ^ n) '' S) := haveI := Algebra.isSeparable_tower_bot_of_isSeparable F (adjoin F S) E adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable F E S q n -- TODO: prove the converse when `F(S) / F` is finite /-- If `F` is a field of exponential characteristic `q`, `F(S) / F` is separable, then `F(S) = F(S ^ q)`. -/ theorem adjoin_eq_adjoin_pow_expChar_of_isSeparable (S : Set E) [Algebra.IsSeparable F (adjoin F S)] (q : ℕ) [ExpChar F q] : adjoin F S = adjoin F ((· ^ q) '' S) := pow_one q ▸ adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable F E S q 1 /-- If `E / F` is a separable field extension of exponential characteristic `q`, then `F(S) = F(S ^ q)` for any subset `S` of `E`. -/ theorem adjoin_eq_adjoin_pow_expChar_of_isSeparable' [Algebra.IsSeparable F E] (S : Set E) (q : ℕ) [ExpChar F q] : adjoin F S = adjoin F ((· ^ q) '' S) := pow_one q ▸ adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable' F E S q 1 -- Special cases for simple adjoin /-- If `F` is a field of exponential characteristic `q`, `a : E` is separable over `F`, then `F⟮a⟯ = F⟮a ^ q ^ n⟯` for any natural number `n`. -/ theorem adjoin_simple_eq_adjoin_pow_expChar_pow_of_isSeparable {a : E} (ha : IsSeparable F a) (q : ℕ) [ExpChar F q] (n : ℕ) : F⟮a⟯ = F⟮a ^ q ^ n⟯ := by haveI := (isSeparable_adjoin_simple_iff_isSeparable F E).mpr ha simpa using adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable F E {a} q n /-- If `E / F` is a separable field extension of exponential characteristic `q`, then `F⟮a⟯ = F⟮a ^ q ^ n⟯` for any subset `a : E` and any natural number `n`. -/ theorem adjoin_simple_eq_adjoin_pow_expChar_pow_of_isSeparable' [Algebra.IsSeparable F E] (a : E) (q : ℕ) [ExpChar F q] (n : ℕ) : F⟮a⟯ = F⟮a ^ q ^ n⟯ := by haveI := Algebra.isSeparable_tower_bot_of_isSeparable F F⟮a⟯ E simpa using adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable F E {a} q n /-- If `F` is a field of exponential characteristic `q`, `a : E` is separable over `F`, then `F⟮a⟯ = F⟮a ^ q⟯`. -/ theorem adjoin_simple_eq_adjoin_pow_expChar_of_isSeparable {a : E} (ha : IsSeparable F a) (q : ℕ) [ExpChar F q] : F⟮a⟯ = F⟮a ^ q⟯ := pow_one q ▸ adjoin_simple_eq_adjoin_pow_expChar_pow_of_isSeparable F E ha q 1 /-- If `E / F` is a separable field extension of exponential characteristic `q`, then `F⟮a⟯ = F⟮a ^ q⟯` for any `a : E`. -/ theorem adjoin_simple_eq_adjoin_pow_expChar_of_isSeparable' [Algebra.IsSeparable F E] (a : E) (q : ℕ) [ExpChar F q] : F⟮a⟯ = F⟮a ^ q⟯ := pow_one q ▸ adjoin_simple_eq_adjoin_pow_expChar_pow_of_isSeparable' F E a q 1 end IntermediateField section variable (q n : ℕ) [hF : ExpChar F q] {ι : Type*} {v : ι → E} {F E} /-- If `E / F` is a separable extension of exponential characteristic `q`, if `{ u_i }` is a family of elements of `E` which `F`-linearly spans `E`, then `{ u_i ^ (q ^ n) }` also `F`-linearly spans `E` for any natural number `n`. -/ theorem Field.span_map_pow_expChar_pow_eq_top_of_isSeparable [Algebra.IsSeparable F E] (h : Submodule.span F (Set.range v) = ⊤) : Submodule.span F (Set.range (v · ^ q ^ n)) = ⊤ := by rw [← Algebra.top_toSubmodule, ← top_toSubalgebra, ← adjoin_univ, adjoin_eq_adjoin_pow_expChar_pow_of_isSeparable' F E _ q n, adjoin_algebraic_toSubalgebra fun x _ ↦ Algebra.IsAlgebraic.isAlgebraic x, Set.image_univ, Algebra.adjoin_eq_span] have := (MonoidHom.mrange (powMonoidHom (α := E) (q ^ n))).closure_eq simp only [MonoidHom.mrange, powMonoidHom, MonoidHom.coe_mk, OneHom.coe_mk, Submonoid.coe_copy] at this rw [this] refine (Submodule.span_mono <| Set.range_comp_subset_range _ _).antisymm (Submodule.span_le.2 ?_) rw [Set.range_comp, ← Set.image_univ] haveI := expChar_of_injective_algebraMap (algebraMap F E).injective q apply h ▸ Submodule.image_span_subset_span (LinearMap.iterateFrobenius F E q n) _ /-- If `E / F` is a finite separable extension of exponential characteristic `q`, if `{ u_i }` is a family of elements of `E` which is `F`-linearly independent, then `{ u_i ^ (q ^ n) }` is also `F`-linearly independent for any natural number `n`. A special case of `LinearIndependent.map_pow_expChar_pow_of_isSeparable` and is an intermediate result used to prove it. -/ private theorem LinearIndependent.map_pow_expChar_pow_of_fd_isSeparable [FiniteDimensional F E] [Algebra.IsSeparable F E] (h : LinearIndependent F v) : LinearIndependent F (v · ^ q ^ n) := by have h' := h.linearIndepOn_id let ι' := h'.extend (Set.range v).subset_univ let b : Basis ι' F E := Basis.extend h' letI : Fintype ι' := FiniteDimensional.fintypeBasisIndex b have H := linearIndependent_of_top_le_span_of_card_eq_finrank (Field.span_map_pow_expChar_pow_eq_top_of_isSeparable q n b.span_eq).ge (Module.finrank_eq_card_basis b).symm let f (i : ι) : ι' := ⟨v i, h'.subset_extend _ ⟨i, rfl⟩⟩ convert H.comp f fun _ _ heq ↦ h.injective (by simpa only [f, Subtype.mk.injEq] using heq) simp_rw [Function.comp_apply, b] rw [Basis.extend_apply_self] /-- If `E / F` is a separable extension of exponential characteristic `q`, if `{ u_i }` is a family of elements of `E` which is `F`-linearly independent, then `{ u_i ^ (q ^ n) }` is also `F`-linearly independent for any natural number `n`. -/ theorem LinearIndependent.map_pow_expChar_pow_of_isSeparable [Algebra.IsSeparable F E] (h : LinearIndependent F v) : LinearIndependent F (v · ^ q ^ n) := by classical rw [linearIndependent_iff_finset_linearIndependent] at h ⊢ intro s let E' := adjoin F (s.image v : Set E) haveI : FiniteDimensional F E' := finiteDimensional_adjoin fun x _ ↦ Algebra.IsIntegral.isIntegral x haveI : Algebra.IsSeparable F E' := Algebra.isSeparable_tower_bot_of_isSeparable F E' E let v' (i : s) : E' := ⟨v i.1, subset_adjoin F _ (Finset.mem_image.2 ⟨i.1, i.2, rfl⟩)⟩ have h' : LinearIndependent F v' := (h s).of_comp E'.val.toLinearMap exact (h'.map_pow_expChar_pow_of_fd_isSeparable q n).map' E'.val.toLinearMap (LinearMap.ker_eq_bot_of_injective E'.val.injective) /-- If `E / F` is a field extension of exponential characteristic `q`, if `{ u_i }` is a family of separable elements of `E` which is `F`-linearly independent, then `{ u_i ^ (q ^ n) }` is also `F`-linearly independent for any natural number `n`. -/ theorem LinearIndependent.map_pow_expChar_pow_of_isSeparable' (hsep : ∀ i : ι, IsSeparable F (v i)) (h : LinearIndependent F v) : LinearIndependent F (v · ^ q ^ n) := by let E' := adjoin F (Set.range v) haveI : Algebra.IsSeparable F E' := (isSeparable_adjoin_iff_isSeparable F _).2 <| by rintro _ ⟨y, rfl⟩; exact hsep y let v' (i : ι) : E' := ⟨v i, subset_adjoin F _ ⟨i, rfl⟩⟩ have h' : LinearIndependent F v' := h.of_comp E'.val.toLinearMap exact (h'.map_pow_expChar_pow_of_isSeparable q n).map' E'.val.toLinearMap (LinearMap.ker_eq_bot_of_injective E'.val.injective) /-- If `E / F` is a separable extension of exponential characteristic `q`, if `{ u_i }` is an `F`-basis of `E`, then `{ u_i ^ (q ^ n) }` is also an `F`-basis of `E` for any natural number `n`. -/ def Module.Basis.mapPowExpCharPowOfIsSeparable [Algebra.IsSeparable F E] (b : Basis ι F E) : Basis ι F E := .mk (b.linearIndependent.map_pow_expChar_pow_of_isSeparable q n) (Field.span_map_pow_expChar_pow_eq_top_of_isSeparable q n b.span_eq).ge /-- For an extension `E / F` of exponential characteristic `q` and a separable element `a : E`, the minimal polynomial of `a ^ q ^ n` equals the minimal polynomial of `a` mapped via `(⬝ ^ q ^ n)`. -/ theorem minpoly.iterateFrobenius_of_isSeparable [ExpChar E q] (n : ℕ) {a : E} (hsep : IsSeparable F a) : minpoly F (iterateFrobenius E q n a) = (minpoly F a).map (iterateFrobenius F q n) := by have hai : IsIntegral F a := hsep.isIntegral have hapi : IsIntegral F (iterateFrobenius E q n a) := hai.pow _ symm refine Polynomial.eq_of_monic_of_dvd_of_natDegree_le (minpoly.monic hapi) (minpoly.monic hai |>.map _) (minpoly.dvd F (a ^ q ^ n) ?haeval) ?hdeg · simpa using Eq.symm <| (minpoly F a).map_aeval_eq_aeval_map (RingHom.iterateFrobenius_comm _ q n) a · rw [(minpoly F a).natDegree_map_eq_of_injective (iterateFrobenius F q n).injective, ← IntermediateField.adjoin.finrank hai, IntermediateField.adjoin_simple_eq_adjoin_pow_expChar_pow_of_isSeparable F E hsep q n, ← IntermediateField.adjoin.finrank hapi, iterateFrobenius_def] /-- For an extension `E / F` of exponential characteristic `q` and a separable element `a : E`, the minimal polynomial of `a ^ q` equals the minimal polynomial of `a` mapped via `(⬝ ^ q)`. -/ theorem minpoly.frobenius_of_isSeparable [ExpChar E q] {a : E} (hsep : IsSeparable F a) : minpoly F (frobenius E q a) = (minpoly F a).map (frobenius F q) := by simpa using minpoly.iterateFrobenius_of_isSeparable q 1 hsep end theorem perfectField_of_perfectClosure_eq_bot [h : PerfectField E] (eq : perfectClosure F E = ⊥) : PerfectField F := by let p := ringExpChar F haveI := expChar_of_injective_algebraMap (algebraMap F E).injective p haveI := PerfectRing.ofSurjective F p fun x ↦ by obtain ⟨y, h⟩ := surjective_frobenius E p (algebraMap F E x) have : y ∈ perfectClosure F E := ⟨1, x, by rw [← h, pow_one, frobenius_def, ringExpChar.eq F p]⟩ obtain ⟨z, rfl⟩ := eq ▸ this simp only [Algebra.ofId] at h exact ⟨z, (algebraMap F E).injective (by rw [RingHom.map_frobenius]; rw [h])⟩ exact PerfectRing.toPerfectField F p /-- If `E / F` is a separable extension, `E` is perfect, then `F` is also perfect. -/ theorem perfectField_of_isSeparable_of_perfectField_top [Algebra.IsSeparable F E] [PerfectField E] : PerfectField F := perfectField_of_perfectClosure_eq_bot F E (perfectClosure.eq_bot_of_isSeparable F E) /-- If `E` is an algebraic closure of `F`, then `F` is perfect if and only if `E / F` is separable. -/ theorem perfectField_iff_isSeparable_algebraicClosure [IsAlgClosure F E] : PerfectField F ↔ Algebra.IsSeparable F E := ⟨fun _ ↦ IsSepClosure.separable, fun _ ↦ haveI : IsAlgClosed E := IsAlgClosure.isAlgClosed F perfectField_of_isSeparable_of_perfectField_top F E⟩
.lake/packages/mathlib/Mathlib/FieldTheory/Finite/GaloisField.lean
import Mathlib.Algebra.Algebra.ZMod import Mathlib.FieldTheory.Finite.Basic import Mathlib.FieldTheory.Galois.Basic import Mathlib.RingTheory.Norm.Transitivity /-! # Galois fields If `p` is a prime number, and `n` a natural number, then `GaloisField p n` is defined as the splitting field of `X^(p^n) - X` over `ZMod p`. It is a finite field with `p ^ n` elements. ## Main definition * `GaloisField p n` is a field with `p ^ n` elements ## Main Results - `GaloisField.algEquivGaloisField`: Any finite field is isomorphic to some Galois field - `FiniteField.algEquivOfCardEq`: Uniqueness of finite fields : algebra isomorphism - `FiniteField.ringEquivOfCardEq`: Uniqueness of finite fields : ring isomorphism - `card_algHom_of_finrank_dvd`: if `[K:F] ∣ [L:F]` then `#(K →ₐ[F] L) = [K:F]` - `nonempty_algHom_iff_finrank_dvd`: `(K →ₐ[F] L)` is nonempty iff `[K:F] ∣ [L:F]`. This and the above result helps to classify the category of finite fields. -/ noncomputable section open Polynomial Finset open scoped Polynomial instance FiniteField.isSplittingField_sub (K F : Type*) [Field K] [Fintype K] [Field F] [Algebra F K] : IsSplittingField F K (X ^ Fintype.card K - X) where splits' := by have h : (X ^ Fintype.card K - X : K[X]).natDegree = Fintype.card K := FiniteField.X_pow_card_sub_X_natDegree_eq K Fintype.one_lt_card rw [← splits_id_iff_splits, splits_iff_card_roots, Polynomial.map_sub, Polynomial.map_pow, map_X, h, FiniteField.roots_X_pow_card_sub_X K, ← Finset.card_def, Finset.card_univ] adjoin_rootSet' := by classical trans Algebra.adjoin F ((roots (X ^ Fintype.card K - X : K[X])).toFinset : Set K) · simp only [rootSet, aroots, Polynomial.map_pow, map_X, Polynomial.map_sub] · rw [FiniteField.roots_X_pow_card_sub_X, val_toFinset, coe_univ, Algebra.adjoin_univ] theorem galois_poly_separable {K : Type*} [CommRing K] (p q : ℕ) [CharP K p] (h : p ∣ q) : Separable (X ^ q - X : K[X]) := by use 1, X ^ q - X - 1 rw [← CharP.cast_eq_zero_iff K[X] p] at h rw [derivative_sub, derivative_X_pow, derivative_X, C_eq_natCast, h] ring variable (p : ℕ) [Fact p.Prime] (n : ℕ) /-- A finite field with `p ^ n` elements. Every field with the same cardinality is (non-canonically) isomorphic to this field. -/ def GaloisField := SplittingField (X ^ p ^ n - X : (ZMod p)[X]) deriving Inhabited, Field, CharP _ p, Algebra (ZMod p), Finite, FiniteDimensional (ZMod p), IsSplittingField (ZMod p) _ (X ^ p ^ n - X) namespace GaloisField variable (p : ℕ) [h_prime : Fact p.Prime] (n : ℕ) theorem finrank {n} (h : n ≠ 0) : Module.finrank (ZMod p) (GaloisField p n) = n := by haveI : Fintype (GaloisField p n) := Fintype.ofFinite (GaloisField p n) set g_poly := (X ^ p ^ n - X : (ZMod p)[X]) have hp : 1 < p := h_prime.out.one_lt have aux : g_poly ≠ 0 := FiniteField.X_pow_card_pow_sub_X_ne_zero _ h hp have key : Fintype.card (g_poly.rootSet (GaloisField p n)) = g_poly.natDegree := card_rootSet_eq_natDegree (galois_poly_separable p _ (dvd_pow (dvd_refl p) h)) (SplittingField.splits (g_poly : (ZMod p)[X])) have nat_degree_eq : g_poly.natDegree = p ^ n := FiniteField.X_pow_card_pow_sub_X_natDegree_eq _ h hp rw [nat_degree_eq] at key suffices g_poly.rootSet (GaloisField p n) = Set.univ by simp_rw [this, ← Fintype.ofEquiv_card (Equiv.Set.univ _)] at key -- Porting note: prevents `card_eq_pow_finrank` from using a wrong instance for `Fintype` rw [@Module.card_eq_pow_finrank (K := ZMod p), ZMod.card] at key exact Nat.pow_right_injective (Nat.Prime.one_lt' p).out key rw [Set.eq_univ_iff_forall] suffices ∀ (x) (hx : x ∈ (⊤ : Subalgebra (ZMod p) (GaloisField p n))), x ∈ (X ^ p ^ n - X : (ZMod p)[X]).rootSet (GaloisField p n) by simpa rw [← SplittingField.adjoin_rootSet] simp_rw [Algebra.mem_adjoin_iff] intro x hx -- We discharge the `p = 0` separately, to avoid typeclass issues on `ZMod p`. cases p; cases hp simp only [g_poly] at aux refine Subring.closure_induction ?_ ?_ ?_ ?_ ?_ ?_ hx <;> simp_rw [mem_rootSet_of_ne aux] · rintro x (⟨r, rfl⟩ | hx) · simp only [map_sub, map_pow, aeval_X] rw [← map_pow, ZMod.pow_card_pow, sub_self] · dsimp only [GaloisField] at hx rwa [mem_rootSet_of_ne aux] at hx · rw [← coeff_zero_eq_aeval_zero'] simp only [coeff_X_pow, coeff_X_zero, sub_zero, _root_.map_eq_zero, ite_eq_right_iff, one_ne_zero, coeff_sub] intro hn exact Nat.not_lt_zero 1 (eq_zero_of_pow_eq_zero hn.symm ▸ hp) · simp · simp only [aeval_X_pow, aeval_X, map_sub, add_pow_char_pow, sub_eq_zero] intro x y _ _ hx hy rw [hx, hy] · intro x _ hx simp only [g_poly, sub_eq_zero, aeval_X_pow, aeval_X, map_sub, sub_neg_eq_add] at * rw [neg_pow, hx, neg_one_pow_char_pow] simp · simp only [aeval_X_pow, aeval_X, map_sub, mul_pow, sub_eq_zero] intro x y _ _ hx hy rw [hx, hy] theorem card (h : n ≠ 0) : Nat.card (GaloisField p n) = p ^ n := by let b := IsNoetherian.finsetBasis (ZMod p) (GaloisField p n) haveI : Fintype (GaloisField p n) := Fintype.ofFinite (GaloisField p n) rw [Nat.card_eq_fintype_card, Module.card_fintype b, ← Module.finrank_eq_card_basis b, ZMod.card, finrank p h] theorem splits_zmod_X_pow_sub_X : Splits (RingHom.id (ZMod p)) (X ^ p - X) := by have hp : 1 < p := h_prime.out.one_lt have h1 : roots (X ^ p - X : (ZMod p)[X]) = Finset.univ.val := by convert FiniteField.roots_X_pow_card_sub_X (ZMod p) exact (ZMod.card p).symm have h2 := FiniteField.X_pow_card_sub_X_natDegree_eq (ZMod p) hp -- We discharge the `p = 0` separately, to avoid typeclass issues on `ZMod p`. cases p; cases hp rw [splits_iff_card_roots, h1, ← Finset.card_def, Finset.card_univ, h2, ZMod.card] /-- A Galois field with exponent 1 is equivalent to `ZMod` -/ def equivZmodP : GaloisField p 1 ≃ₐ[ZMod p] ZMod p := have h : (X ^ p ^ 1 : (ZMod p)[X]) = X ^ Fintype.card (ZMod p) := by rw [pow_one, ZMod.card p] have inst : IsSplittingField (ZMod p) (ZMod p) (X ^ p ^ 1 - X) := by rw [h]; infer_instance (@IsSplittingField.algEquiv _ (ZMod p) _ _ _ (X ^ p ^ 1 - X : (ZMod p)[X]) inst).symm section Fintype variable {K : Type*} [Field K] [Fintype K] [Algebra (ZMod p) K] theorem _root_.FiniteField.splits_X_pow_card_sub_X : Splits (algebraMap (ZMod p) K) (X ^ Fintype.card K - X) := (FiniteField.isSplittingField_sub K (ZMod p)).splits theorem _root_.FiniteField.isSplittingField_of_card_eq (h : Fintype.card K = p ^ n) : IsSplittingField (ZMod p) K (X ^ p ^ n - X) := h ▸ FiniteField.isSplittingField_sub K (ZMod p) /-- Any finite field is (possibly noncanonically) isomorphic to some Galois field. -/ def algEquivGaloisFieldOfFintype (h : Fintype.card K = p ^ n) : K ≃ₐ[ZMod p] GaloisField p n := haveI := FiniteField.isSplittingField_of_card_eq _ _ h IsSplittingField.algEquiv _ _ end Fintype section Finite variable {K : Type*} [Field K] [Algebra (ZMod p) K] theorem _root_.FiniteField.splits_X_pow_nat_card_sub_X [Finite K] : Splits (algebraMap (ZMod p) K) (X ^ Nat.card K - X) := by haveI : Fintype K := Fintype.ofFinite K rw [Nat.card_eq_fintype_card] exact (FiniteField.isSplittingField_sub K (ZMod p)).splits theorem _root_.FiniteField.isSplittingField_of_nat_card_eq (h : Nat.card K = p ^ n) : IsSplittingField (ZMod p) K (X ^ p ^ n - X) := by haveI : Finite K := (Nat.card_pos_iff.mp (h ▸ pow_pos h_prime.1.pos n)).2 haveI : Fintype K := Fintype.ofFinite K rw [← h, Nat.card_eq_fintype_card] exact FiniteField.isSplittingField_sub K (ZMod p) instance (priority := 100) {K K' : Type*} [Field K] [Field K'] [Finite K'] [Algebra K K'] : IsGalois K K' := by cases nonempty_fintype K' obtain ⟨p, hp⟩ := CharP.exists K haveI : CharP K p := hp haveI : CharP K' p := charP_of_injective_algebraMap' K p exact IsGalois.of_separable_splitting_field (galois_poly_separable p (Fintype.card K') (let ⟨n, _, hn⟩ := FiniteField.card K' p hn.symm ▸ dvd_pow_self p n.ne_zero)) /-- Any finite field is (possibly noncanonically) isomorphic to some Galois field. -/ def algEquivGaloisField (h : Nat.card K = p ^ n) : K ≃ₐ[ZMod p] GaloisField p n := haveI := FiniteField.isSplittingField_of_nat_card_eq _ _ h IsSplittingField.algEquiv _ _ end Finite end GaloisField namespace FiniteField variable {K K' : Type*} [Field K] [Field K'] section norm variable [Algebra K K'] [Finite K'] theorem algebraMap_norm_eq_pow {x : K'} : algebraMap K K' (Algebra.norm K x) = x ^ ((Nat.card K' - 1) / (Nat.card K - 1)) := by have := Finite.of_injective _ (algebraMap K K').injective have := Fintype.ofFinite K have := Fintype.ofFinite K' simp_rw [← Fintype.card_eq_nat_card, Algebra.norm_eq_prod_automorphisms, ← (bijective_frobeniusAlgEquivOfAlgebraic_pow K K').prod_comp, AlgEquiv.coe_pow, coe_frobeniusAlgEquivOfAlgebraic, pow_iterate, Finset.prod_pow_eq_pow_sum, Fin.sum_univ_eq_sum_range, Nat.geomSum_eq Fintype.one_lt_card, ← Module.card_eq_pow_finrank] variable (K K') theorem unitsMap_norm_surjective : Function.Surjective (Units.map <| Algebra.norm K (S := K')) := have := Finite.of_injective_finite_range (algebraMap K K').injective MonoidHom.surjective_of_card_ker_le_div _ <| by simp_rw [Nat.card_units] classical have := Fintype.ofFinite K'ˣ convert IsCyclic.card_pow_eq_one_le (α := K'ˣ) <| Nat.div_pos (Nat.sub_le_sub_right (Nat.card_le_card_of_injective _ (algebraMap K K').injective) _) <| Nat.sub_pos_of_lt Finite.one_lt_card rw [← Set.ncard_coe_finset, ← SetLike.coe_sort_coe, Nat.card_coe_set_eq]; congr 1; ext simp [Units.ext_iff, ← (algebraMap K K').injective.eq_iff, algebraMap_norm_eq_pow] theorem norm_surjective : Function.Surjective (Algebra.norm K (S := K')) := fun k ↦ by obtain rfl | ne := eq_or_ne k 0 · exact ⟨0, Algebra.norm_zero ..⟩ have ⟨x, eq⟩ := unitsMap_norm_surjective K K' (Units.mk0 k ne) exact ⟨x, congr_arg (·.1) eq⟩ end norm variable [Fintype K] [Fintype K'] /-- Uniqueness of finite fields: Any two finite fields of the same cardinality are (possibly noncanonically) isomorphic -/ def algEquivOfCardEq (p : ℕ) [h_prime : Fact p.Prime] [Algebra (ZMod p) K] [Algebra (ZMod p) K'] (hKK' : Fintype.card K = Fintype.card K') : K ≃ₐ[ZMod p] K' := by have : CharP K p := by rw [← Algebra.charP_iff (ZMod p) K p]; exact ZMod.charP p have : CharP K' p := by rw [← Algebra.charP_iff (ZMod p) K' p]; exact ZMod.charP p choose n a hK using FiniteField.card K p choose n' a' hK' using FiniteField.card K' p rw [hK, hK'] at hKK' have hGalK := GaloisField.algEquivGaloisFieldOfFintype p n hK have hK'Gal := (GaloisField.algEquivGaloisFieldOfFintype p n' hK').symm rw [Nat.pow_right_injective h_prime.out.one_lt hKK'] at * exact AlgEquiv.trans hGalK hK'Gal /-- Uniqueness of finite fields: Any two finite fields of the same cardinality are (possibly noncanonically) isomorphic -/ def ringEquivOfCardEq (hKK' : Fintype.card K = Fintype.card K') : K ≃+* K' := by choose p _char_p_K using CharP.exists K choose p' _char_p'_K' using CharP.exists K' choose n hp hK using FiniteField.card K p choose n' hp' hK' using FiniteField.card K' p' have hpp' : p = p' := by by_contra hne have h2 := Nat.coprime_pow_primes n n' hp hp' hne rw [(Eq.congr hK hK').mp hKK', Nat.coprime_self, pow_eq_one_iff (PNat.ne_zero n')] at h2 exact Nat.Prime.ne_one hp' h2 rw [← hpp'] at _char_p'_K' haveI := fact_iff.2 hp letI : Algebra (ZMod p) K := ZMod.algebra _ _ letI : Algebra (ZMod p) K' := ZMod.algebra _ _ exact ↑(algEquivOfCardEq p hKK') theorem pow_finrank_eq_natCard (p : ℕ) [Fact p.Prime] (k : Type*) [AddCommGroup k] [Finite k] [Module (ZMod p) k] : p ^ Module.finrank (ZMod p) k = Nat.card k := by rw [Module.natCard_eq_pow_finrank (K := ZMod p), Nat.card_zmod] theorem pow_finrank_eq_card (p : ℕ) [Fact p.Prime] (k : Type*) [AddCommGroup k] [Fintype k] [Module (ZMod p) k] : p ^ Module.finrank (ZMod p) k = Fintype.card k := by rw [pow_finrank_eq_natCard, Fintype.card_eq_nat_card] section variable {F K L : Type*} [Field F] [Field K] [Algebra F K] [Field L] [Algebra F L] [Finite L] theorem nonempty_algHom_of_finrank_dvd (h : Module.finrank F K ∣ Module.finrank F L) : Nonempty (K →ₐ[F] L) := by have := Finite.of_injective _ (algebraMap F L).injective have := Fintype.ofFinite F have := Module.finite_of_finrank_pos (Nat.pos_of_dvd_of_pos h Module.finrank_pos) have := Module.finite_of_finite F (M := K) have := Fintype.ofFinite K have := Fintype.ofFinite L refine ⟨Polynomial.IsSplittingField.lift _ (X ^ Fintype.card K - X) ?_⟩ refine Polynomial.splits_of_splits_of_dvd _ ?_ (FiniteField.isSplittingField_sub L F).splits ?_ · exact FiniteField.X_pow_card_sub_X_ne_zero _ Fintype.one_lt_card · rw [Module.card_eq_pow_finrank (K := F), Module.card_eq_pow_finrank (K := F) (V := L)] exact dvd_pow_pow_sub_self_of_dvd h theorem natCard_algHom_of_finrank_dvd (h : Module.finrank F K ∣ Module.finrank F L) : Nat.card (K →ₐ[F] L) = Module.finrank F K := by obtain ⟨f⟩ := nonempty_algHom_of_finrank_dvd h algebraize [f.toRingHom] have := Finite.of_injective _ (algebraMap K L).injective rw [Nat.card_congr (Normal.algHomEquivAut F L K), IsGalois.card_aut_eq_finrank] theorem card_algHom_of_finrank_dvd [Finite K] (h : Module.finrank F K ∣ Module.finrank F L) : Fintype.card (K →ₐ[F] L) = Module.finrank F K := by rw [Fintype.card_eq_nat_card, natCard_algHom_of_finrank_dvd h] theorem nonempty_algHom_iff_finrank_dvd : Nonempty (K →ₐ[F] L) ↔ Module.finrank F K ∣ Module.finrank F L := by refine ⟨fun ⟨f⟩ ↦ ?_, nonempty_algHom_of_finrank_dvd⟩ algebraize [f.toRingHom] rw [← Module.finrank_mul_finrank F K L] exact dvd_mul_right _ _ end end FiniteField
.lake/packages/mathlib/Mathlib/FieldTheory/Finite/Extension.lean
import Mathlib.FieldTheory.Finite.GaloisField /-! # Extensions of finite fields In this file we develop the theory of extensions of finite fields. If `k` is a finite field (of cardinality `q = p ^ m`), then there is a unique (up to in general non-unique isomorphism) extension `l` of `k` of any given degree `n > 0`. This extension is Galois with cyclic Galois group of degree `n`, and the (arithmetic) Frobenius map `x ↦ x ^ q` is a generator. ## Main definition * `FiniteField.Extension k p n` is a non-canonically chosen extension of `k` of degree `n` (for `n > 0`). ## Main Results * `FiniteField.algEquivExtension`: any other field extension `l/k` of degree `n` is (non-uniquely) isomorphic to our chosen `FiniteField.Extension k p n`. -/ noncomputable section variable (k : Type*) [Field k] [Finite k] variable (p : ℕ) [Fact p.Prime] [CharP k p] variable (n : ℕ) [NeZero n] open Polynomial namespace FiniteField /-- Given a finite field `k` of characteristic `p`, we have a non-canoncailly chosen extension of any given degree `n > 0`. -/ def Extension [CharP k p] : Type := letI := ZMod.algebra k p GaloisField p (Module.finrank (ZMod p) k * n) deriving Field, Finite, Algebra (ZMod p), FiniteDimensional (ZMod p) theorem finrank_zmod_extension [Algebra (ZMod p) k] : Module.finrank (ZMod p) (Extension k p n) = Module.finrank (ZMod p) k * n := by letI := ZMod.algebra k p convert GaloisField.finrank p (n := Module.finrank (ZMod p) k * n) <| mul_ne_zero Module.finrank_pos.ne' <| NeZero.ne n using 4 subsingleton theorem nonempty_algHom_extension [Algebra (ZMod p) k] : Nonempty (k →ₐ[ZMod p] Extension k p n) := nonempty_algHom_of_finrank_dvd (finrank_zmod_extension k p n ▸ dvd_mul_right _ _) noncomputable instance : Algebra k (Extension k p n) := letI := ZMod.algebra k p (nonempty_algHom_extension k p n).some.toAlgebra instance : Module.Finite k (Extension k p n) := .of_finite instance [Algebra (ZMod p) k] : IsScalarTower (ZMod p) k (Extension k p n) := -- there is at most one map from `𝔽_p` to any ring .of_algebraMap_eq' <| Subsingleton.elim _ _ theorem natCard_extension : Nat.card (Extension k p n) = Nat.card k ^ n := by letI := ZMod.algebra k p rw [← pow_finrank_eq_natCard p, ← pow_finrank_eq_natCard p, finrank_zmod_extension, pow_mul] theorem finrank_extension : Module.finrank k (Extension k p n) = n := by refine Nat.pow_right_injective (Finite.one_lt_card : 2 ≤ Nat.card k) ?_ simp only [← Module.natCard_eq_pow_finrank, natCard_extension] instance : IsSplittingField k (Extension k p n) (X ^ Nat.card k ^ n - X) := by have := Fintype.ofFinite (Extension k p n) convert FiniteField.isSplittingField_sub (Extension k p n) k · rw [Fintype.card_eq_nat_card, natCard_extension] example : IsGalois k (Extension k p n) := inferInstance example : IsCyclic Gal(Extension k p n / k) := inferInstance theorem natCard_algEquiv_extension : Nat.card Gal(Extension k p n / k) = n := (IsGalois.card_aut_eq_finrank _ _).trans <| finrank_extension k p n theorem card_algEquiv_extension : Fintype.card Gal(Extension k p n / k) = n := Fintype.card_eq_nat_card.trans <| natCard_algEquiv_extension k p n /-- The Frobenius automorphism `x ↦ x ^ Nat.card k` that fixes `k`. -/ noncomputable def Extension.frob : Gal(Extension k p n / k) := haveI := Fintype.ofFinite k FiniteField.frobeniusAlgEquivOfAlgebraic _ _ @[simp] lemma Extension.frob_apply {x : Extension k p n} : frob k p n x = x ^ Nat.card k := by simp [frob, ← Nat.card_eq_fintype_card] theorem Extension.exists_frob_pow_eq (g : Gal(Extension k p n/k)) : ∃ i < n, Extension.frob k p n ^ i = g := by let := Fintype.ofFinite k obtain ⟨⟨i, hi⟩, rfl⟩ := (FiniteField.bijective_frobeniusAlgEquivOfAlgebraic_pow k (Extension k p n)).2 g refine ⟨i, ?_, by ext; simp [frob]⟩ rwa [finrank_extension] at hi /-- Given any field extension of finite fields `l/k` of degree `n`, we have a non-unique isomorphism between `l` and our chosen `Extension k p n`. -/ noncomputable def algEquivExtension (l : Type*) [Field l] [Algebra k l] (h : Module.finrank k l = n) : l ≃ₐ[k] Extension k p n := by refine Nonempty.some ?_ have : Module.Finite k l := Module.finite_of_finrank_pos <| h ▸ NeZero.pos n have : Finite l := Module.finite_of_finite k have : Fintype l := .ofFinite _ have : IsSplittingField k l (X ^ Nat.card k ^ n - X) := by rw [← h, ← Module.natCard_eq_pow_finrank, ← Fintype.card_eq_nat_card] exact FiniteField.isSplittingField_sub l k refine ⟨(IsSplittingField.algEquiv _ (X ^ (Nat.card k ^ n) - X)).trans ?_⟩ exact (IsSplittingField.algEquiv _ (X ^ (Nat.card k ^ n) - X)).symm end FiniteField
.lake/packages/mathlib/Mathlib/FieldTheory/Finite/Basic.lean
import Mathlib.Algebra.CharP.Algebra import Mathlib.Algebra.CharP.Reduced import Mathlib.Algebra.Field.ZMod import Mathlib.Data.Nat.Prime.Int import Mathlib.Data.ZMod.ValMinAbs import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix import Mathlib.FieldTheory.Finiteness import Mathlib.FieldTheory.Galois.Notation import Mathlib.FieldTheory.Perfect import Mathlib.FieldTheory.Separable import Mathlib.RingTheory.IntegralDomain /-! # Finite fields This file contains basic results about finite fields. Throughout most of this file, `K` denotes a finite field and `q` is notation for the cardinality of `K`. See `RingTheory.IntegralDomain` for the fact that the unit group of a finite field is a cyclic group, as well as the fact that every finite integral domain is a field (`Fintype.fieldOfDomain`). ## Main results 1. `Fintype.card_units`: The unit group of a finite field has cardinality `q - 1`. 2. `sum_pow_units`: The sum of `x^i`, where `x` ranges over the units of `K`, is - `q-1` if `q-1 ∣ i` - `0` otherwise 3. `FiniteField.card`: The cardinality `q` is a power of the characteristic of `K`. See `FiniteField.card'` for a variant. ## Notation Throughout most of this file, `K` denotes a finite field and `q` is notation for the cardinality of `K`. ## Implementation notes While `Fintype Kˣ` can be inferred from `Fintype K` in the presence of `DecidableEq K`, in this file we take the `Fintype Kˣ` argument directly to reduce the chance of typeclass diamonds, as `Fintype` carries data. -/ variable {K : Type*} {R : Type*} local notation "q" => Fintype.card K open Finset open scoped Polynomial namespace FiniteField section Polynomial variable [CommRing R] [IsDomain R] open Polynomial /-- The cardinality of a field is at most `n` times the cardinality of the image of a degree `n` polynomial -/ theorem card_image_polynomial_eval [DecidableEq R] [Fintype R] {p : R[X]} (hp : 0 < p.degree) : Fintype.card R ≤ natDegree p * #(univ.image fun x => eval x p) := Finset.card_le_mul_card_image _ _ (fun a _ => calc _ = #(p - C a).roots.toFinset := congr_arg card (by simp [Finset.ext_iff, ← mem_roots_sub_C hp]) _ ≤ Multiset.card (p - C a).roots := Multiset.toFinset_card_le _ _ ≤ _ := card_roots_sub_C' hp) /-- If `f` and `g` are quadratic polynomials, then the `f.eval a + g.eval b = 0` has a solution. -/ theorem exists_root_sum_quadratic [Fintype R] {f g : R[X]} (hf2 : degree f = 2) (hg2 : degree g = 2) (hR : Fintype.card R % 2 = 1) : ∃ a b, f.eval a + g.eval b = 0 := letI := Classical.decEq R suffices ¬Disjoint (univ.image fun x : R => eval x f) (univ.image fun x : R => eval x (-g)) by simp only [disjoint_left, mem_image] at this push_neg at this rcases this with ⟨x, ⟨a, _, ha⟩, ⟨b, _, hb⟩⟩ exact ⟨a, b, by rw [ha, ← hb, eval_neg, neg_add_cancel]⟩ fun hd : Disjoint _ _ => lt_irrefl (2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g))) <| calc 2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g)) ≤ 2 * Fintype.card R := Nat.mul_le_mul_left _ (Finset.card_le_univ _) _ = Fintype.card R + Fintype.card R := two_mul _ _ < natDegree f * #(univ.image fun x : R => eval x f) + natDegree (-g) * #(univ.image fun x : R => eval x (-g)) := (add_lt_add_of_lt_of_le (lt_of_le_of_ne (card_image_polynomial_eval (by rw [hf2]; decide)) (mt (congr_arg (· % 2)) (by simp [natDegree_eq_of_degree_eq_some hf2, hR]))) (card_image_polynomial_eval (by rw [degree_neg, hg2]; decide))) _ = 2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g)) := by rw [card_union_of_disjoint hd] simp [natDegree_eq_of_degree_eq_some hf2, natDegree_eq_of_degree_eq_some hg2, mul_add] end Polynomial theorem prod_univ_units_id_eq_neg_one [CommRing K] [IsDomain K] [Fintype Kˣ] : ∏ x : Kˣ, x = (-1 : Kˣ) := by classical have : (∏ x ∈ (@univ Kˣ _).erase (-1), x) = 1 := prod_involution (fun x _ => x⁻¹) (by simp) (fun a => by simp +contextual [Units.inv_eq_self_iff]) (fun a => by simp [@inv_eq_iff_eq_inv _ _ a]) (by simp) rw [← insert_erase (mem_univ (-1 : Kˣ)), prod_insert (notMem_erase _ _), this, mul_one] theorem card_cast_subgroup_card_ne_zero [Ring K] [NoZeroDivisors K] [Nontrivial K] (G : Subgroup Kˣ) [Fintype G] : (Fintype.card G : K) ≠ 0 := by let n := Fintype.card G intro nzero have ⟨p, char_p⟩ := CharP.exists K have hd : p ∣ n := (CharP.cast_eq_zero_iff K p n).mp nzero cases CharP.char_is_prime_or_zero K p with | inr pzero => exact (Fintype.card_pos).ne' <| Nat.eq_zero_of_zero_dvd <| pzero ▸ hd | inl pprime => have fact_pprime := Fact.mk pprime -- G has an element x of order p by Cauchy's theorem have ⟨x, hx⟩ := exists_prime_orderOf_dvd_card p hd -- F has an element u (= ↑↑x) of order p let u := ((x : Kˣ) : K) have hu : orderOf u = p := by rwa [orderOf_units, Subgroup.orderOf_coe] -- u ^ p = 1 implies (u - 1) ^ p = 0 and hence u = 1 ... have h : u = 1 := by rw [← sub_left_inj, sub_self 1] apply eq_zero_of_pow_eq_zero (n := p) rw [sub_pow_char_of_commute, one_pow, ← hu, pow_orderOf_eq_one, sub_self] exact Commute.one_right u -- ... meaning x didn't have order p after all, contradiction apply pprime.one_lt.ne rw [← hu, h, orderOf_one] /-- The sum of a nontrivial subgroup of the units of a field is zero. -/ theorem sum_subgroup_units_eq_zero [Ring K] [NoZeroDivisors K] {G : Subgroup Kˣ} [Fintype G] (hg : G ≠ ⊥) : ∑ x : G, (x.val : K) = 0 := by rw [Subgroup.ne_bot_iff_exists_ne_one] at hg rcases hg with ⟨a, ha⟩ -- The action of a on G as an embedding let a_mul_emb : G ↪ G := mulLeftEmbedding a -- ... and leaves G unchanged have h_unchanged : Finset.univ.map a_mul_emb = Finset.univ := by simp -- Therefore the sum of x over a G is the sum of a x over G have h_sum_map := Finset.univ.sum_map a_mul_emb fun x => ((x : Kˣ) : K) -- ... and the former is the sum of x over G. -- By algebraic manipulation, we have Σ G, x = ∑ G, a x = a ∑ G, x simp only [h_unchanged, mulLeftEmbedding_apply, Subgroup.coe_mul, Units.val_mul, ← mul_sum, a_mul_emb] at h_sum_map -- thus one of (a - 1) or ∑ G, x is zero have hzero : (((a : Kˣ) : K) - 1) = 0 ∨ ∑ x : ↥G, ((x : Kˣ) : K) = 0 := by rw [← mul_eq_zero, sub_mul, ← h_sum_map, one_mul, sub_self] apply Or.resolve_left hzero contrapose! ha ext rwa [← sub_eq_zero] /-- The sum of a subgroup of the units of a field is 1 if the subgroup is trivial and 1 otherwise -/ @[simp] theorem sum_subgroup_units [Ring K] [NoZeroDivisors K] {G : Subgroup Kˣ} [Fintype G] [Decidable (G = ⊥)] : ∑ x : G, (x.val : K) = if G = ⊥ then 1 else 0 := by by_cases G_bot : G = ⊥ · subst G_bot simp only [univ_unique, sum_singleton, ↓reduceIte, Units.val_eq_one, OneMemClass.coe_eq_one] rw [Set.default_coe_singleton] rfl · simp only [G_bot, ite_false] exact sum_subgroup_units_eq_zero G_bot @[simp] theorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K] {G : Subgroup Kˣ} [Fintype G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) : ∑ x : G, ((x : Kˣ) : K) ^ k = 0 := by rw [← Nat.card_eq_fintype_card] at k_lt_card_G nontriviality K have := NoZeroDivisors.to_isDomain K rcases (exists_pow_ne_one_of_isCyclic k_pos k_lt_card_G) with ⟨a, ha⟩ rw [Finset.sum_eq_multiset_sum] have h_multiset_map : Finset.univ.val.map (fun x : G => ((x : Kˣ) : K) ^ k) = Finset.univ.val.map (fun x : G => ((x : Kˣ) : K) ^ k * ((a : Kˣ) : K) ^ k) := by simp_rw [← mul_pow] have as_comp : (fun x : ↥G => (((x : Kˣ) : K) * ((a : Kˣ) : K)) ^ k) = (fun x : ↥G => ((x : Kˣ) : K) ^ k) ∘ fun x : ↥G => x * a := by funext x simp only [Function.comp_apply, Subgroup.coe_mul, Units.val_mul] rw [as_comp, ← Multiset.map_map] congr rw [eq_comm] exact Multiset.map_univ_val_equiv (Equiv.mulRight a) have h_multiset_map_sum : (Multiset.map (fun x : G => ((x : Kˣ) : K) ^ k) Finset.univ.val).sum = (Multiset.map (fun x : G => ((x : Kˣ) : K) ^ k * ((a : Kˣ) : K) ^ k) Finset.univ.val).sum := by rw [h_multiset_map] rw [Multiset.sum_map_mul_right] at h_multiset_map_sum have hzero : (((a : Kˣ) : K) ^ k - 1 : K) * (Multiset.map (fun i : G => (i.val : K) ^ k) Finset.univ.val).sum = 0 := by rw [sub_mul, mul_comm, ← h_multiset_map_sum, one_mul, sub_self] rw [mul_eq_zero] at hzero refine hzero.resolve_left fun h => ha ?_ ext rw [← sub_eq_zero] simp_rw [SubmonoidClass.coe_pow, Units.val_pow_eq_pow_val, OneMemClass.coe_one, Units.val_one, h] section variable [GroupWithZero K] [Fintype K] theorem pow_card_sub_one_eq_one (a : K) (ha : a ≠ 0) : a ^ (q - 1) = 1 := by calc a ^ (Fintype.card K - 1) = (Units.mk0 a ha ^ (Fintype.card K - 1) : Kˣ).1 := by rw [Units.val_pow_eq_pow_val, Units.val_mk0] _ = 1 := by classical rw [← Fintype.card_units, pow_card_eq_one] rfl theorem pow_card (a : K) : a ^ q = a := by by_cases h : a = 0; · rw [h]; apply zero_pow Fintype.card_ne_zero rw [← Nat.succ_pred_eq_of_pos Fintype.card_pos, pow_succ, Nat.pred_eq_sub_one, pow_card_sub_one_eq_one a h, one_mul] theorem pow_card_pow (n : ℕ) (a : K) : a ^ q ^ n = a := by induction n with | zero => simp | succ n ih => simp [pow_succ, pow_mul, ih, pow_card] end variable (K) [Field K] [Fintype K] /-- The cardinality `q` is a power of the characteristic of `K`. -/ @[stacks 09HY "first part"] theorem card (p : ℕ) [CharP K p] : ∃ n : ℕ+, Nat.Prime p ∧ q = p ^ (n : ℕ) := by haveI hp : Fact p.Prime := ⟨CharP.char_is_prime K p⟩ letI : Module (ZMod p) K := { (ZMod.castHom dvd_rfl K : ZMod p →+* _).toModule with } obtain ⟨n, h⟩ := VectorSpace.card_fintype (ZMod p) K rw [ZMod.card] at h refine ⟨⟨n, ?_⟩, hp.1, h⟩ apply Or.resolve_left (Nat.eq_zero_or_pos n) rintro rfl rw [pow_zero] at h have : (0 : K) = 1 := by apply Fintype.card_le_one_iff.mp (le_of_eq h) exact absurd this zero_ne_one -- this statement doesn't use `q` because we want `K` to be an explicit parameter theorem card' : ∃ (p : ℕ), CharP K p ∧ ∃ (n : ℕ+), Nat.Prime p ∧ Fintype.card K = p ^ (n : ℕ) := let ⟨p, hc⟩ := CharP.exists K ⟨p, hc, @FiniteField.card K _ _ p hc⟩ lemma isPrimePow_card : IsPrimePow (Fintype.card K) := by obtain ⟨p, _, n, hp, hn⟩ := card' K exact ⟨p, n, Nat.prime_iff.mp hp, n.prop, hn.symm⟩ theorem cast_card_eq_zero : (q : K) = 0 := by simp theorem forall_pow_eq_one_iff (i : ℕ) : (∀ x : Kˣ, x ^ i = 1) ↔ q - 1 ∣ i := by classical obtain ⟨x, hx⟩ := IsCyclic.exists_generator (α := Kˣ) rw [← Nat.card_eq_fintype_card, ← Nat.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hx, orderOf_dvd_iff_pow_eq_one] constructor · intro h; apply h · intro h y simp_rw [← mem_powers_iff_mem_zpowers] at hx rcases hx y with ⟨j, rfl⟩ rw [← pow_mul, mul_comm, pow_mul, h, one_pow] /-- The sum of `x ^ i` as `x` ranges over the units of a finite field of cardinality `q` is equal to `0` unless `(q - 1) ∣ i`, in which case the sum is `q - 1`. -/ theorem sum_pow_units [DecidableEq K] (i : ℕ) : (∑ x : Kˣ, (x ^ i : K)) = if q - 1 ∣ i then -1 else 0 := by let φ : Kˣ →* K := { toFun := fun x => x ^ i map_one' := by simp map_mul' := by simp [mul_pow] } have : Decidable (φ = 1) := by classical infer_instance calc (∑ x : Kˣ, φ x) = if φ = 1 then Fintype.card Kˣ else 0 := sum_hom_units φ _ = if q - 1 ∣ i then -1 else 0 := by suffices q - 1 ∣ i ↔ φ = 1 by simp only [this] split_ifs; swap · exact Nat.cast_zero · rw [Fintype.card_units, Nat.cast_sub, cast_card_eq_zero, Nat.cast_one, zero_sub] show 1 ≤ q; exact Fintype.card_pos_iff.mpr ⟨0⟩ rw [← forall_pow_eq_one_iff, DFunLike.ext_iff] apply forall_congr'; intro x; simp [φ, Units.ext_iff] /-- The sum of `x ^ i` as `x` ranges over a finite field of cardinality `q` is equal to `0` if `i < q - 1`. -/ theorem sum_pow_lt_card_sub_one (i : ℕ) (h : i < q - 1) : ∑ x : K, x ^ i = 0 := by by_cases hi : i = 0 · simp only [hi, nsmul_one, sum_const, pow_zero, card_univ, cast_card_eq_zero] classical have hiq : ¬q - 1 ∣ i := by contrapose! h; exact Nat.le_of_dvd (Nat.pos_of_ne_zero hi) h let φ : Kˣ ↪ K := ⟨fun x ↦ x, Units.val_injective⟩ have : univ.map φ = univ \ {0} := by ext x simpa only [mem_map, mem_univ, Function.Embedding.coeFn_mk, true_and, mem_sdiff, mem_singleton, φ] using isUnit_iff_ne_zero calc ∑ x : K, x ^ i = ∑ x ∈ univ \ {(0 : K)}, x ^ i := by rw [← sum_sdiff ({0} : Finset K).subset_univ, sum_singleton, zero_pow hi, add_zero] _ = ∑ x : Kˣ, (x ^ i : K) := by simp [φ, ← this, univ.sum_map φ] _ = 0 := by rw [sum_pow_units K i, if_neg]; exact hiq section frobenius variable (R) [CommRing R] [Algebra K R] /-- If `R` is an algebra over a finite field `K`, the Frobenius `K`-algebra endomorphism of `R` is given by raising every element of `R` to its `#K`-th power. -/ @[simps!] def frobeniusAlgHom : R →ₐ[K] R where __ := powMonoidHom q map_zero' := zero_pow Fintype.card_pos.ne' map_add' _ _ := by obtain ⟨p, _, _, hp, card_eq⟩ := card' K nontriviality R have : CharP R p := charP_of_injective_algebraMap' K p have : ExpChar R p := .prime hp simp only [OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, powMonoidHom_apply, card_eq] exact add_pow_expChar_pow .. commutes' _ := by simp [← RingHom.map_pow, pow_card] theorem coe_frobeniusAlgHom : ⇑(frobeniusAlgHom K R) = (· ^ q) := rfl /-- If `R` is a perfect ring and an algebra over a finite field `K`, the Frobenius `K`-algebra endomorphism of `R` is an automorphism. -/ @[simps!] noncomputable def frobeniusAlgEquiv (p : ℕ) [ExpChar R p] [PerfectRing R p] : R ≃ₐ[K] R := .ofBijective (frobeniusAlgHom K R) <| by obtain ⟨p', _, n, hp, card_eq⟩ := card' K rw [coe_frobeniusAlgHom, card_eq] have : ExpChar K p' := ExpChar.prime hp nontriviality R have := ExpChar.eq ‹_› (expChar_of_injective_algebraMap (algebraMap K R).injective p') subst this apply bijective_iterateFrobenius variable (L : Type*) [Field L] [Algebra K L] /-- If `L/K` is an algebraic extension of a finite field, the Frobenius `K`-algebra endomorphism of `L` is an automorphism. -/ @[simps!] noncomputable def frobeniusAlgEquivOfAlgebraic [Algebra.IsAlgebraic K L] : Gal(L/K) := (Algebra.IsAlgebraic.algEquivEquivAlgHom K L).symm (frobeniusAlgHom K L) theorem coe_frobeniusAlgEquivOfAlgebraic [Algebra.IsAlgebraic K L] : ⇑(frobeniusAlgEquivOfAlgebraic K L) = (· ^ q) := rfl lemma coe_frobeniusAlgEquivOfAlgebraic_iterate [Algebra.IsAlgebraic K L] (n : ℕ) : (⇑(frobeniusAlgEquivOfAlgebraic K L))^[n] = (· ^ (Fintype.card K ^ n)) := pow_iterate (Fintype.card K) n variable [Finite L] open Polynomial in theorem orderOf_frobeniusAlgHom : orderOf (frobeniusAlgHom K L) = Module.finrank K L := (orderOf_eq_iff Module.finrank_pos).mpr <| by have := Fintype.ofFinite L refine ⟨DFunLike.ext _ _ fun x ↦ ?_, fun m lt pos eq ↦ ?_⟩ · simp_rw [AlgHom.coe_pow, coe_frobeniusAlgHom, pow_iterate, AlgHom.one_apply, ← Module.card_eq_pow_finrank, pow_card] have := card_le_degree_of_subset_roots (R := L) (p := X ^ q ^ m - X) (Z := univ) fun x _ ↦ by simp_rw [mem_roots', IsRoot, eval_sub, eval_pow, eval_X] have := DFunLike.congr_fun eq x rw [AlgHom.coe_pow, coe_frobeniusAlgHom, pow_iterate, AlgHom.one_apply, ← sub_eq_zero] at this refine ⟨fun h ↦ ?_, this⟩ simpa [if_neg (Nat.one_lt_pow pos.ne' Fintype.one_lt_card).ne] using congr_arg (coeff · 1) h refine this.not_gt (((natDegree_sub_le ..).trans_eq ?_).trans_lt <| (Nat.pow_lt_pow_right Fintype.one_lt_card lt).trans_eq Module.card_eq_pow_finrank.symm) simp [Nat.one_le_pow _ _ Fintype.card_pos] theorem orderOf_frobeniusAlgEquivOfAlgebraic : orderOf (frobeniusAlgEquivOfAlgebraic K L) = Module.finrank K L := by simpa [orderOf_eq_iff Module.finrank_pos, DFunLike.ext_iff] using orderOf_frobeniusAlgHom K L theorem bijective_frobeniusAlgHom_pow : Function.Bijective fun n : Fin (Module.finrank K L) ↦ frobeniusAlgHom K L ^ n.1 := let e := (finCongr <| orderOf_frobeniusAlgHom K L).symm.trans <| finEquivPowers (orderOf_pos_iff.mp <| orderOf_frobeniusAlgHom K L ▸ Module.finrank_pos) (Subtype.val_injective.comp e.injective).bijective_of_nat_card_le ((card_algHom_le_finrank K L L).trans_eq <| by simp) theorem bijective_frobeniusAlgEquivOfAlgebraic_pow : Function.Bijective fun n : Fin (Module.finrank K L) ↦ frobeniusAlgEquivOfAlgebraic K L ^ n.1 := ((Algebra.IsAlgebraic.algEquivEquivAlgHom K L).bijective.of_comp_iff' _).mp <| by simpa only [Function.comp_def, map_pow] using bijective_frobeniusAlgHom_pow K L instance (K L) [Finite L] [Field K] [Field L] [Algebra K L] : IsCyclic Gal(L/K) where exists_zpow_surjective := have := Finite.of_injective _ (algebraMap K L).injective have := Fintype.ofFinite K ⟨frobeniusAlgEquivOfAlgebraic K L, fun f ↦ have ⟨n, hn⟩ := (bijective_frobeniusAlgEquivOfAlgebraic_pow K L).2 f; ⟨n, hn⟩⟩ open Polynomial in theorem minpoly_frobeniusAlgHom : minpoly K (frobeniusAlgHom K L).toLinearMap = X ^ Module.finrank K L - 1 := minpoly.eq_of_linearIndependent _ _ (leadingCoeff_X_pow_sub_one Module.finrank_pos) (LinearMap.ext fun x ↦ by simpa [sub_eq_zero, Module.End.coe_pow, orderOf_frobeniusAlgHom] using congr($(pow_orderOf_eq_one (frobeniusAlgHom K L)) x)) _ (degree_X_pow_sub_C Module.finrank_pos _) <| by simpa [← AlgHom.toEnd_apply, ← map_pow] using (linearIndependent_algHom_toLinearMap K L L |>.restrict_scalars' K).comp _ (bijective_frobeniusAlgHom_pow K L).1 end frobenius open Polynomial section variable [Fintype K] (K' : Type*) [Field K'] {p n : ℕ} theorem X_pow_card_sub_X_natDegree_eq (hp : 1 < p) : (X ^ p - X : K'[X]).natDegree = p := by have h1 : (X : K'[X]).degree < (X ^ p : K'[X]).degree := by rw [degree_X_pow, degree_X] exact mod_cast hp rw [natDegree_eq_of_degree_eq (degree_sub_eq_left_of_degree_lt h1), natDegree_X_pow] theorem X_pow_card_pow_sub_X_natDegree_eq (hn : n ≠ 0) (hp : 1 < p) : (X ^ p ^ n - X : K'[X]).natDegree = p ^ n := X_pow_card_sub_X_natDegree_eq K' <| Nat.one_lt_pow hn hp theorem X_pow_card_sub_X_ne_zero (hp : 1 < p) : (X ^ p - X : K'[X]) ≠ 0 := ne_zero_of_natDegree_gt <| calc 1 < _ := hp _ = _ := (X_pow_card_sub_X_natDegree_eq K' hp).symm theorem X_pow_card_pow_sub_X_ne_zero (hn : n ≠ 0) (hp : 1 < p) : (X ^ p ^ n - X : K'[X]) ≠ 0 := X_pow_card_sub_X_ne_zero K' <| Nat.one_lt_pow hn hp end theorem roots_X_pow_card_sub_X : roots (X ^ q - X : K[X]) = Finset.univ.val := by classical have aux : (X ^ q - X : K[X]) ≠ 0 := X_pow_card_sub_X_ne_zero K Fintype.one_lt_card have : (roots (X ^ q - X : K[X])).toFinset = Finset.univ := by rw [eq_univ_iff_forall] intro x rw [Multiset.mem_toFinset, mem_roots aux, IsRoot.def, eval_sub, eval_pow, eval_X, sub_eq_zero, pow_card] rw [← this, Multiset.toFinset_val, eq_comm, Multiset.dedup_eq_self] apply nodup_roots rw [separable_def] convert isCoprime_one_right.neg_right (R := K[X]) using 1 rw [derivative_sub, derivative_X, derivative_X_pow, Nat.cast_card_eq_zero K, C_0, zero_mul, zero_sub] variable {K} theorem frobenius_pow {p : ℕ} [Fact p.Prime] [CharP K p] {n : ℕ} (hcard : q = p ^ n) : frobenius K p ^ n = 1 := by ext x; conv_rhs => rw [RingHom.one_def, RingHom.id_apply, ← pow_card x, hcard] clear hcard induction n with | zero => simp | succ n hn => rw [pow_succ', pow_succ, pow_mul, RingHom.mul_def, RingHom.comp_apply, frobenius_def, hn] open Polynomial theorem expand_card (f : K[X]) : expand K q f = f ^ q := by obtain ⟨p, hp⟩ := CharP.exists K rcases FiniteField.card K p with ⟨⟨n, npos⟩, ⟨hp, hn⟩⟩ haveI : Fact p.Prime := ⟨hp⟩ dsimp at hn rw [hn, ← map_expand_pow_char, frobenius_pow hn, RingHom.one_def, map_id] end FiniteField namespace ZMod open FiniteField Polynomial theorem sq_add_sq (p : ℕ) [hp : Fact p.Prime] (x : ZMod p) : ∃ a b : ZMod p, a ^ 2 + b ^ 2 = x := by rcases hp.1.eq_two_or_odd with hp2 | hp_odd · subst p change Fin 2 at x fin_cases x · use 0; simp · use 0, 1; simp let f : (ZMod p)[X] := X ^ 2 let g : (ZMod p)[X] := X ^ 2 - C x obtain ⟨a, b, hab⟩ : ∃ a b, f.eval a + g.eval b = 0 := @exists_root_sum_quadratic _ _ _ _ f g (degree_X_pow 2) (degree_X_pow_sub_C (by decide) _) (by rw [ZMod.card, hp_odd]) refine ⟨a, b, ?_⟩ rw [← sub_eq_zero] simpa only [f, g, eval_C, eval_X, eval_pow, eval_sub, ← add_sub_assoc] using hab end ZMod /-- If `p` is a prime natural number and `x` is an integer number, then there exist natural numbers `a ≤ p / 2` and `b ≤ p / 2` such that `a ^ 2 + b ^ 2 ≡ x [ZMOD p]`. This is a version of `ZMod.sq_add_sq` with estimates on `a` and `b`. -/ theorem Nat.sq_add_sq_zmodEq (p : ℕ) [Fact p.Prime] (x : ℤ) : ∃ a b : ℕ, a ≤ p / 2 ∧ b ≤ p / 2 ∧ (a : ℤ) ^ 2 + (b : ℤ) ^ 2 ≡ x [ZMOD p] := by rcases ZMod.sq_add_sq p x with ⟨a, b, hx⟩ refine ⟨a.valMinAbs.natAbs, b.valMinAbs.natAbs, ZMod.natAbs_valMinAbs_le _, ZMod.natAbs_valMinAbs_le _, ?_⟩ rw [← a.coe_valMinAbs, ← b.coe_valMinAbs] at hx push_cast rw [sq_abs, sq_abs, ← ZMod.intCast_eq_intCast_iff] exact mod_cast hx /-- If `p` is a prime natural number and `x` is a natural number, then there exist natural numbers `a ≤ p / 2` and `b ≤ p / 2` such that `a ^ 2 + b ^ 2 ≡ x [MOD p]`. This is a version of `ZMod.sq_add_sq` with estimates on `a` and `b`. -/ theorem Nat.sq_add_sq_modEq (p : ℕ) [Fact p.Prime] (x : ℕ) : ∃ a b : ℕ, a ≤ p / 2 ∧ b ≤ p / 2 ∧ a ^ 2 + b ^ 2 ≡ x [MOD p] := by simpa only [← Int.natCast_modEq_iff] using Nat.sq_add_sq_zmodEq p x namespace CharP theorem sq_add_sq (R : Type*) [Ring R] [IsDomain R] (p : ℕ) [NeZero p] [CharP R p] (x : ℤ) : ∃ a b : ℕ, ((a : R) ^ 2 + (b : R) ^ 2) = x := by haveI := char_is_prime_of_pos R p obtain ⟨a, b, hab⟩ := ZMod.sq_add_sq p x refine ⟨a.val, b.val, ?_⟩ simpa using congr_arg (ZMod.castHom dvd_rfl R) hab end CharP open scoped Nat open ZMod /-- The **Fermat-Euler totient theorem**. `Nat.ModEq.pow_totient` is an alternative statement of the same theorem. -/ @[simp] theorem ZMod.pow_totient {n : ℕ} (x : (ZMod n)ˣ) : x ^ φ n = 1 := by cases n · rw [Nat.totient_zero, pow_zero] · rw [← card_units_eq_totient, pow_card_eq_one] /-- The **Fermat-Euler totient theorem**. `ZMod.pow_totient` is an alternative statement of the same theorem. -/ theorem Nat.ModEq.pow_totient {x n : ℕ} (h : Nat.Coprime x n) : x ^ φ n ≡ 1 [MOD n] := by rw [← ZMod.natCast_eq_natCast_iff] let x' : Units (ZMod n) := ZMod.unitOfCoprime _ h have := ZMod.pow_totient x' apply_fun ((fun (x : Units (ZMod n)) => (x : ZMod n)) : Units (ZMod n) → ZMod n) at this simpa only [Nat.succ_eq_add_one, Nat.cast_pow, Units.val_one, Nat.cast_one, coe_unitOfCoprime, Units.val_pow_eq_pow_val] /-- For each `n ≥ 0`, the unit group of `ZMod n` is finite. -/ instance instFiniteZModUnits : (n : ℕ) → Finite (ZMod n)ˣ | 0 => Finite.of_fintype ℤˣ | _ + 1 => inferInstance open FiniteField namespace ZMod variable {p : ℕ} [Fact p.Prime] instance : Subsingleton (Subfield (ZMod p)) := subsingleton_of_bot_eq_top <| top_unique (a := ⊥) fun n _ ↦ have := zsmul_mem (one_mem (⊥ : Subfield (ZMod p))) n.val by rwa [natCast_zsmul, Nat.smul_one_eq_cast, ZMod.natCast_zmod_val] at this theorem fieldRange_castHom_eq_bot (p : ℕ) [Fact p.Prime] [DivisionRing K] [CharP K p] : (ZMod.castHom (m := p) dvd_rfl K).fieldRange = (⊥ : Subfield K) := by rw [RingHom.fieldRange_eq_map, ← Subfield.map_bot (K := ZMod p), Subsingleton.elim ⊥] /-- A variation on Fermat's little theorem. See `ZMod.pow_card_sub_one_eq_one` -/ @[simp] theorem pow_card (x : ZMod p) : x ^ p = x := by have h := FiniteField.pow_card x; rwa [ZMod.card p] at h @[simp] theorem pow_card_pow {n : ℕ} (x : ZMod p) : x ^ p ^ n = x := by induction n with | zero => simp | succ n ih => simp [pow_succ, pow_mul, ih, pow_card] @[simp] theorem frobenius_zmod (p : ℕ) [Fact p.Prime] : frobenius (ZMod p) p = RingHom.id _ := by ext a rw [frobenius_def, ZMod.pow_card, RingHom.id_apply] -- This was a `simp` lemma, but now the LHS simplifies to `φ p`. theorem card_units (p : ℕ) [Fact p.Prime] : Fintype.card (ZMod p)ˣ = p - 1 := by rw [Fintype.card_units, card] /-- **Fermat's Little Theorem**: for every unit `a` of `ZMod p`, we have `a ^ (p - 1) = 1`. -/ theorem units_pow_card_sub_one_eq_one (p : ℕ) [Fact p.Prime] (a : (ZMod p)ˣ) : a ^ (p - 1) = 1 := by rw [← card_units p, pow_card_eq_one] /-- **Fermat's Little Theorem**: for all nonzero `a : ZMod p`, we have `a ^ (p - 1) = 1`. -/ theorem pow_card_sub_one_eq_one {a : ZMod p} (ha : a ≠ 0) : a ^ (p - 1) = 1 := by have h := FiniteField.pow_card_sub_one_eq_one a ha rwa [ZMod.card p] at h lemma pow_card_sub_one (a : ZMod p) : a ^ (p - 1) = if a ≠ 0 then 1 else 0 := by split_ifs with ha · exact pow_card_sub_one_eq_one ha · simp [of_not_not ha, (Fact.out : p.Prime).one_lt, tsub_eq_zero_iff_le] theorem orderOf_units_dvd_card_sub_one (u : (ZMod p)ˣ) : orderOf u ∣ p - 1 := orderOf_dvd_of_pow_eq_one <| units_pow_card_sub_one_eq_one _ _ theorem orderOf_dvd_card_sub_one {a : ZMod p} (ha : a ≠ 0) : orderOf a ∣ p - 1 := orderOf_dvd_of_pow_eq_one <| pow_card_sub_one_eq_one ha open Polynomial theorem expand_card (f : Polynomial (ZMod p)) : expand (ZMod p) p f = f ^ p := by have h := FiniteField.expand_card f; rwa [ZMod.card p] at h end ZMod /-- **Fermat's Little Theorem**: for all `a : ℤ` coprime to `p`, we have `a ^ (p - 1) ≡ 1 [ZMOD p]`. -/ theorem Int.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : Nat.Prime p) {n : ℤ} (hpn : IsCoprime n p) : n ^ (p - 1) ≡ 1 [ZMOD p] := by haveI : Fact p.Prime := ⟨hp⟩ have : ¬(n : ZMod p) = 0 := by rw [CharP.intCast_eq_zero_iff _ p, ← (Nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd] · exact hpn.symm simpa [← ZMod.intCast_eq_intCast_iff] using ZMod.pow_card_sub_one_eq_one this theorem Int.prime_dvd_pow_sub_one {p : ℕ} (hp : Nat.Prime p) {n : ℤ} (hpn : IsCoprime n p) : (p : ℤ) ∣ n ^ (p - 1) - 1 := (ModEq.pow_card_sub_one_eq_one hp hpn).symm.dvd theorem Int.ModEq.pow_prime_eq_self {p : ℕ} (hp : Nat.Prime p) (n : ℤ) : n ^ p ≡ n [ZMOD p] := by haveI : Fact p.Prime := ⟨hp⟩ simp [← ZMod.intCast_eq_intCast_iff] theorem Int.prime_dvd_pow_self_sub {p : ℕ} (hp : Nat.Prime p) (n : ℤ) : (p : ℤ) ∣ n ^ p - n := (ModEq.pow_prime_eq_self hp n).symm.dvd theorem Int.ModEq.pow_eq_pow {p x y : ℕ} (hp : Nat.Prime p) (h : p - 1 ∣ x - y) (hxy : y ≤ x) (hy : 0 < y) (n : ℤ) : n ^ x ≡ n ^ y [ZMOD p] := by rw [← Nat.mul_div_eq_iff_dvd] at h by_cases hn : n ≡ 0 [ZMOD p] · grw [hn, zero_pow (hy.trans_le hxy).ne', zero_pow hy.ne'] · rw [Int.modEq_zero_iff_dvd, ← (Nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd] at hn grw [← pow_sub_mul_pow n hxy, ← h, pow_mul, Int.ModEq.pow_card_sub_one_eq_one hp hn.symm, one_pow, one_mul] /-- **Fermat's Little Theorem**: for all `n : ℕ` coprime to `p`, we have `n ^ (p - 1) ≡ 1 [MOD p]`. -/ theorem Nat.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : p.Prime) {n : ℕ} (hpn : n.Coprime p) : n ^ (p - 1) ≡ 1 [MOD p] := by rw [← Int.natCast_modEq_iff, Nat.cast_pow, Nat.cast_one] exact Int.ModEq.pow_card_sub_one_eq_one hp (isCoprime_iff_coprime.mpr hpn) /-- **Fermat's Little Theorem**: for all `n : ℕ` coprime to `p`, we have `(n ^ (p - 1) - 1) % p = 0`. -/ theorem Nat.pow_card_sub_one_sub_one_mod_card {p : ℕ} (hp : p.Prime) {n : ℕ} (hpn : n.Coprime p) : (n ^ (p - 1) - 1) % p = 0 := Nat.sub_mod_eq_zero_of_mod_eq (Nat.ModEq.pow_card_sub_one_eq_one hp hpn) theorem pow_pow_modEq_one (p m a : ℕ) : (1 + p * a) ^ (p ^ m) ≡ 1 [MOD p ^ m] := by induction m with | zero => exact Nat.modEq_one | succ m hm => rw [Nat.ModEq.comm, add_comm, Nat.modEq_iff_dvd' (Nat.one_le_pow' _ _)] at hm obtain ⟨d, hd⟩ := hm rw [tsub_eq_iff_eq_add_of_le (Nat.one_le_pow' _ _), add_comm] at hd rw [pow_succ, pow_mul, hd, add_pow, Finset.sum_range_succ', pow_zero, one_mul, one_pow, one_mul, Nat.choose_zero_right, Nat.cast_one] refine Nat.ModEq.add_right 1 (Nat.modEq_zero_iff_dvd.mpr ?_) simp_rw [one_pow, mul_one, pow_succ', mul_assoc, ← Finset.mul_sum] refine mul_dvd_mul_left (p ^ m) (dvd_mul_of_dvd_right (Finset.dvd_sum fun k hk ↦ ?_) d) cases m · rw [pow_zero, pow_one, one_mul, add_comm, add_left_inj] at hd cases k <;> simp [← hd, mul_assoc, pow_succ'] · cases k <;> simp [mul_assoc, pow_succ'] theorem ZMod.eq_one_or_isUnit_sub_one {n p k : ℕ} [Fact p.Prime] (hn : n = p ^ k) (a : ZMod n) (ha : (orderOf a).Coprime n) : a = 1 ∨ IsUnit (a - 1) := by rcases eq_or_ne n 0 with rfl | hn0 · exact Or.inl (orderOf_eq_one_iff.mp ((orderOf a).coprime_zero_right.mp ha)) rcases eq_or_ne a 0 with rfl | ha0 · exact Or.inr (zero_sub (1 : ZMod n) ▸ isUnit_neg_one) have : NeZero n := ⟨hn0⟩ obtain ⟨a, rfl⟩ := ZMod.natCast_zmod_surjective a rw [← orderOf_eq_one_iff, or_iff_not_imp_right] refine fun h ↦ ha.eq_one_of_dvd ?_ rw [orderOf_dvd_iff_pow_eq_one, ← Nat.cast_pow, ← Nat.cast_one, ZMod.natCast_eq_natCast_iff, hn] replace ha0 : 1 ≤ a := by contrapose! ha0 rw [Nat.lt_one_iff.mp ha0, Nat.cast_zero] rw [← Nat.cast_one, ← Nat.cast_sub ha0, ZMod.isUnit_iff_coprime, hn] at h obtain ⟨b, hb⟩ := not_imp_comm.mp (Nat.Prime.coprime_pow_of_not_dvd Fact.out) h rw [tsub_eq_iff_eq_add_of_le ha0, add_comm] at hb exact hb ▸ pow_pow_modEq_one p k b section prime_subfield variable {F : Type*} [Field F] theorem mem_bot_iff_intCast (p : ℕ) [Fact p.Prime] (K) [DivisionRing K] [CharP K p] {x : K} : x ∈ (⊥ : Subfield K) ↔ ∃ n : ℤ, n = x := by simp [← fieldRange_castHom_eq_bot p, ZMod.intCast_surjective.exists] variable (F) (p : ℕ) [Fact p.Prime] [CharP F p] theorem Subfield.card_bot : Nat.card (⊥ : Subfield F) = p := by rw [← fieldRange_castHom_eq_bot p, ← Nat.card_eq_of_bijective _ (RingHom.rangeRestrictField_bijective _), Nat.card_zmod] /-- The prime subfield is finite. -/ def Subfield.fintypeBot : Fintype (⊥ : Subfield F) := Fintype.subtype (univ.map ⟨_, (ZMod.castHom (m := p) dvd_rfl F).injective⟩) fun _ ↦ by simp_rw [Finset.mem_map, mem_univ, true_and, ← fieldRange_castHom_eq_bot p]; rfl open Polynomial theorem Subfield.roots_X_pow_char_sub_X_bot : letI := Subfield.fintypeBot F p (X ^ p - X : (⊥ : Subfield F)[X]).roots = Finset.univ.val := by let _ := Subfield.fintypeBot F p conv_lhs => rw [← card_bot F p, ← Fintype.card_eq_nat_card] exact FiniteField.roots_X_pow_card_sub_X _ theorem Subfield.splits_bot : Splits (RingHom.id (⊥ : Subfield F)) (X ^ p - X) := by let _ := Subfield.fintypeBot F p rw [splits_iff_card_roots, roots_X_pow_char_sub_X_bot, ← Finset.card_def, Finset.card_univ, FiniteField.X_pow_card_sub_X_natDegree_eq _ (Fact.out (p := p.Prime)).one_lt, Fintype.card_eq_nat_card, card_bot F p] theorem Subfield.mem_bot_iff_pow_eq_self {x : F} : x ∈ (⊥ : Subfield F) ↔ x ^ p = x := by have := roots_X_pow_char_sub_X_bot F p ▸ Polynomial.roots_map (Subfield.subtype _) (splits_bot F p) ▸ Multiset.mem_map (b := x) simpa [sub_eq_zero, iff_comm, FiniteField.X_pow_card_sub_X_ne_zero F (Fact.out : p.Prime).one_lt] end prime_subfield namespace FiniteField variable {F : Type*} [Field F] section Finite variable [Finite F] /-- In a finite field of characteristic `2`, all elements are squares. -/ theorem isSquare_of_char_two (hF : ringChar F = 2) (a : F) : IsSquare a := have : CharP F 2 := ringChar.of_eq hF isSquare_of_charTwo' a /-- In a finite field of odd characteristic, not every element is a square. -/ theorem exists_nonsquare (hF : ringChar F ≠ 2) : ∃ a : F, ¬IsSquare a := by -- Idea: the squaring map on `F` is not injective, hence not surjective have h : ¬Function.Injective fun x : F ↦ x * x := fun h ↦ h.ne (Ring.neg_one_ne_one_of_char_ne_two hF) <| by simp simpa [Finite.injective_iff_surjective, Function.Surjective, IsSquare, eq_comm] using h end Finite variable [Fintype F] /-- The finite field `F` has even cardinality iff it has characteristic `2`. -/ theorem even_card_iff_char_two : ringChar F = 2 ↔ Fintype.card F % 2 = 0 := by rcases FiniteField.card F (ringChar F) with ⟨n, hp, h⟩ rw [h, ← Nat.even_iff, Nat.even_pow, hp.even_iff] simp theorem even_card_of_char_two (hF : ringChar F = 2) : Fintype.card F % 2 = 0 := even_card_iff_char_two.mp hF theorem odd_card_of_char_ne_two (hF : ringChar F ≠ 2) : Fintype.card F % 2 = 1 := Nat.mod_two_ne_zero.mp (mt even_card_iff_char_two.mpr hF) /-- If `F` has odd characteristic, then for nonzero `a : F`, we have that `a ^ (#F / 2) = ±1`. -/ theorem pow_dichotomy (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) : a ^ (Fintype.card F / 2) = 1 ∨ a ^ (Fintype.card F / 2) = -1 := by have h₁ := FiniteField.pow_card_sub_one_eq_one a ha rw [← Nat.two_mul_odd_div_two (FiniteField.odd_card_of_char_ne_two hF), mul_comm, pow_mul, pow_two] at h₁ exact mul_self_eq_one_iff.mp h₁ /-- A unit `a` of a finite field `F` of odd characteristic is a square if and only if `a ^ (#F / 2) = 1`. -/ theorem unit_isSquare_iff (hF : ringChar F ≠ 2) (a : Fˣ) : IsSquare a ↔ a ^ (Fintype.card F / 2) = 1 := by classical obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := Fˣ) obtain ⟨n, hn⟩ : a ∈ Submonoid.powers g := by rw [mem_powers_iff_mem_zpowers]; apply hg have hodd := Nat.two_mul_odd_div_two (FiniteField.odd_card_of_char_ne_two hF) constructor · rintro ⟨y, rfl⟩ rw [← pow_two, ← pow_mul, hodd] apply_fun Units.val using Units.val_injective push_cast exact FiniteField.pow_card_sub_one_eq_one (y : F) (Units.ne_zero y) · subst a; intro h rw [← Nat.card_eq_fintype_card] at hodd h have key : 2 * (Nat.card F / 2) ∣ n * (Nat.card F / 2) := by rw [← pow_mul] at h rw [hodd, ← Nat.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hg] apply orderOf_dvd_of_pow_eq_one h have : 0 < Nat.card F / 2 := Nat.div_pos Finite.one_lt_card (by simp) obtain ⟨m, rfl⟩ := Nat.dvd_of_mul_dvd_mul_right this key refine ⟨g ^ m, ?_⟩ dsimp rw [mul_comm, pow_mul, pow_two] /-- A non-zero `a : F` is a square if and only if `a ^ (#F / 2) = 1`. -/ theorem isSquare_iff (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) : IsSquare a ↔ a ^ (Fintype.card F / 2) = 1 := by apply (iff_congr _ (by simp [Units.ext_iff])).mp (FiniteField.unit_isSquare_iff hF (Units.mk0 a ha)) simp only [IsSquare, Units.ext_iff, Units.val_mk0, Units.val_mul] constructor · rintro ⟨y, hy⟩; exact ⟨y, hy⟩ · rintro ⟨y, rfl⟩ have hy : y ≠ 0 := by rintro rfl; simp at ha refine ⟨Units.mk0 y hy, ?_⟩; simp end FiniteField
.lake/packages/mathlib/Mathlib/FieldTheory/Finite/Trace.lean
import Mathlib.RingTheory.Trace.Basic import Mathlib.FieldTheory.Finite.GaloisField /-! # The trace and norm maps for finite fields We state several lemmas about the trace and norm maps for finite fields. ## Main Results - `trace_to_zmod_nondegenerate`: the trace map from a finite field of characteristic `p` to `ZMod p` is nondegenerate. - `algebraMap_trace_eq_sum_pow`: an explicit formula for the trace map: `trace[L/K](x) = ∑ i < [L:K], x ^ ((#K) ^ i)`. - `algebraMap_norm_eq_prod_pow`: an explicit formula for the norm map: `norm[L/K](x) = ∏ i < [L:K], x ^ ((#K) ^ i)`. ## Tags finite field, trace, norm -/ namespace FiniteField open Fintype /-- The trace map from a finite field to its prime field is nongedenerate. -/ theorem trace_to_zmod_nondegenerate (F : Type*) [Field F] [Finite F] [Algebra (ZMod (ringChar F)) F] {a : F} (ha : a ≠ 0) : ∃ b : F, Algebra.trace (ZMod (ringChar F)) F (a * b) ≠ 0 := by haveI : Fact (ringChar F).Prime := ⟨CharP.char_is_prime F _⟩ have htr := traceForm_nondegenerate (ZMod (ringChar F)) F a simp_rw [Algebra.traceForm_apply] at htr by_contra! hf exact ha (htr hf) variable (K L : Type*) [Field K] [Field L] [Finite L] [Algebra K L] (x : L) /-- An explicit formula for the trace map: `trace[L/K](x) = ∑ i < [L:K], x ^ ((#K) ^ i)`. -/ theorem algebraMap_trace_eq_sum_pow : algebraMap K L (Algebra.trace K L x) = ∑ i ∈ Finset.range (Module.finrank K L), x ^ (Nat.card K ^ i) := by have := Finite.of_injective _ (FaithfulSMul.algebraMap_injective K L) have := ofFinite K rw [trace_eq_sum_automorphisms, Finset.sum_range] exact Eq.symm <| sum_bijective _ (bijective_frobeniusAlgEquivOfAlgebraic_pow K L) _ _ <| fun i ↦ by rw [AlgEquiv.coe_pow, coe_frobeniusAlgEquivOfAlgebraic_iterate, card_eq_nat_card] /-- An explicit formula for the norm map: `norm[L/K](x) = ∏ i < [L:K], x ^ ((#K) ^ i)`. -/ theorem algebraMap_norm_eq_prod_pow : algebraMap K L (Algebra.norm K x) = ∏ i ∈ Finset.range (Module.finrank K L), x ^ (Nat.card K ^ i) := by have := Finite.of_injective _ (FaithfulSMul.algebraMap_injective K L) have := ofFinite K rw [Algebra.norm_eq_prod_automorphisms, Finset.prod_range] exact Eq.symm <| prod_bijective _ (bijective_frobeniusAlgEquivOfAlgebraic_pow K L) _ _ <| fun i ↦ by rw [AlgEquiv.coe_pow, coe_frobeniusAlgEquivOfAlgebraic_iterate, card_eq_nat_card] /-- An explicit formula for the norm map: `norm[L/K](x) = x ^ (∑ i < [L:K], (#K) ^ i)`. -/ theorem algebraMap_norm_eq_pow_sum : algebraMap K L (Algebra.norm K x) = x ^ ∑ i ∈ Finset.range (Module.finrank K L), Nat.card K ^ i := by rw [algebraMap_norm_eq_prod_pow, Finset.prod_pow_eq_pow_sum] end FiniteField
.lake/packages/mathlib/Mathlib/FieldTheory/Finite/Polynomial.lean
import Mathlib.Algebra.MvPolynomial.Expand import Mathlib.FieldTheory.Finite.Basic import Mathlib.LinearAlgebra.Dual.Lemmas import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas import Mathlib.RingTheory.MvPolynomial.Basic /-! ## Polynomials over finite fields -/ namespace MvPolynomial variable {σ : Type*} /-- A polynomial over the integers is divisible by `n : ℕ` if and only if it is zero over `ZMod n`. -/ theorem C_dvd_iff_zmod (n : ℕ) (φ : MvPolynomial σ ℤ) : C (n : ℤ) ∣ φ ↔ map (Int.castRingHom (ZMod n)) φ = 0 := C_dvd_iff_map_hom_eq_zero _ _ (CharP.intCast_eq_zero_iff (ZMod n) n) _ section frobenius variable {p : ℕ} [Fact p.Prime] theorem frobenius_zmod (f : MvPolynomial σ (ZMod p)) : frobenius _ p f = expand p f := by apply induction_on f · intro a; rw [expand_C, frobenius_def, ← C_pow, ZMod.pow_card] · simp only [map_add]; intro _ _ hf hg; rw [hf, hg] · simp only [expand_X, map_mul] intro _ _ hf; rw [hf, frobenius_def] theorem expand_zmod (f : MvPolynomial σ (ZMod p)) : expand p f = f ^ p := (frobenius_zmod _).symm end frobenius end MvPolynomial namespace MvPolynomial noncomputable section open Set LinearMap Submodule variable {K : Type*} {σ : Type*} section Indicator variable [Fintype K] [Fintype σ] /-- Over a field, this is the indicator function as an `MvPolynomial`. -/ def indicator [CommRing K] (a : σ → K) : MvPolynomial σ K := ∏ n, (1 - (X n - C (a n)) ^ (Fintype.card K - 1)) section CommRing variable [CommRing K] theorem eval_indicator_apply_eq_one (a : σ → K) : eval a (indicator a) = 1 := by nontriviality have : 0 < Fintype.card K - 1 := tsub_pos_of_lt Fintype.one_lt_card simp only [indicator, map_prod, map_sub, map_one, map_pow, eval_X, eval_C, sub_self, zero_pow this.ne', sub_zero, Finset.prod_const_one] theorem degrees_indicator (c : σ → K) : degrees (indicator c) ≤ ∑ s : σ, (Fintype.card K - 1) • {s} := by rw [indicator] classical refine degrees_prod_le.trans <| Finset.sum_le_sum fun s _ ↦ degrees_sub_le.trans ?_ rw [degrees_one, Multiset.zero_union] refine le_trans degrees_pow_le (nsmul_le_nsmul_right ?_ _) refine degrees_sub_le.trans ?_ rw [degrees_C, Multiset.union_zero] exact degrees_X' _ theorem indicator_mem_restrictDegree (c : σ → K) : indicator c ∈ restrictDegree σ K (Fintype.card K - 1) := by classical rw [mem_restrictDegree_iff_sup, indicator] intro n refine le_trans (Multiset.count_le_of_le _ <| degrees_indicator _) (le_of_eq ?_) simp_rw [← Multiset.coe_countAddMonoidHom, map_sum, AddMonoidHom.map_nsmul, Multiset.coe_countAddMonoidHom, nsmul_eq_mul, Nat.cast_id] trans · refine Finset.sum_eq_single n ?_ ?_ · intro b _ ne simp [Multiset.count_singleton, ne, if_neg (Ne.symm _)] · intro h; exact (h <| Finset.mem_univ _).elim · rw [Multiset.count_singleton_self, mul_one] end CommRing variable [Field K] theorem eval_indicator_apply_eq_zero (a b : σ → K) (h : a ≠ b) : eval a (indicator b) = 0 := by obtain ⟨i, hi⟩ : ∃ i, a i ≠ b i := by rwa [Ne, funext_iff, not_forall] at h simp only [indicator, map_prod, map_sub, map_one, map_pow, eval_X, eval_C, Finset.prod_eq_zero_iff] refine ⟨i, Finset.mem_univ _, ?_⟩ rw [FiniteField.pow_card_sub_one_eq_one, sub_self] rwa [Ne, sub_eq_zero] end Indicator section variable (K σ) /-- `MvPolynomial.eval` as a `K`-linear map. -/ @[simps] def evalₗ [CommSemiring K] : MvPolynomial σ K →ₗ[K] (σ → K) → K where toFun p e := eval e p map_add' p q := by ext x; simp map_smul' a p := by ext e; simp variable [Field K] [Fintype K] [Finite σ] theorem map_restrict_dom_evalₗ : (restrictDegree σ K (Fintype.card K - 1)).map (evalₗ K σ) = ⊤ := by cases nonempty_fintype σ refine top_unique (SetLike.le_def.2 fun e _ => mem_map.2 ?_) classical refine ⟨∑ n : σ → K, e n • indicator n, ?_, ?_⟩ · exact sum_mem fun c _ => smul_mem _ _ (indicator_mem_restrictDegree _) · ext n simp only [evalₗ_apply, map_sum, smul_eval] rw [Finset.sum_eq_single n] <;> aesop (add simp [eval_indicator_apply_eq_zero, eval_indicator_apply_eq_one, eq_comm]) end end end MvPolynomial namespace MvPolynomial open scoped Cardinal open LinearMap Submodule universe u variable (σ : Type u) (K : Type u) [Fintype K] /-- The submodule of multivariate polynomials whose degree of each variable is strictly less than the cardinality of K. -/ def R [CommRing K] : Type u := restrictDegree σ K (Fintype.card K - 1) -- The `AddCommGroup, Module K, Inhabited` instances should be constructed by a deriving handler. noncomputable instance [CommRing K] : AddCommGroup (R σ K) := inferInstanceAs (AddCommGroup (restrictDegree σ K (Fintype.card K - 1))) noncomputable instance [CommRing K] : Module K (R σ K) := inferInstanceAs (Module K (restrictDegree σ K (Fintype.card K - 1))) noncomputable instance [CommRing K] : Inhabited (R σ K) := inferInstanceAs (Inhabited (restrictDegree σ K (Fintype.card K - 1))) /-- Evaluation in the `MvPolynomial.R` subtype. -/ noncomputable def evalᵢ [CommRing K] : R σ K →ₗ[K] (σ → K) → K := (evalₗ K σ).comp (restrictDegree σ K (Fintype.card K - 1)).subtype -- TODO: would be nice to replace this by suitable decidability assumptions open Classical in noncomputable instance decidableRestrictDegree (m : ℕ) : DecidablePred (· ∈ { n : σ →₀ ℕ | ∀ i, n i ≤ m }) := by simp only [Set.mem_setOf_eq]; infer_instance variable [Field K] open Classical in theorem rank_R [Fintype σ] : Module.rank K (R σ K) = Fintype.card (σ → K) := calc Module.rank K (R σ K) = Module.rank K (↥{ s : σ →₀ ℕ | ∀ n : σ, s n ≤ Fintype.card K - 1 } →₀ K) := LinearEquiv.rank_eq (Finsupp.supportedEquivFinsupp { s : σ →₀ ℕ | ∀ n : σ, s n ≤ Fintype.card K - 1 }) _ = #{ s : σ →₀ ℕ | ∀ n : σ, s n ≤ Fintype.card K - 1 } := by rw [rank_finsupp_self'] _ = #{ s : σ → ℕ | ∀ n : σ, s n < Fintype.card K } := by refine Quotient.sound ⟨Equiv.subtypeEquiv Finsupp.equivFunOnFinite fun f => ?_⟩ refine forall_congr' fun n => le_tsub_iff_right ?_ exact Fintype.card_pos_iff.2 ⟨0⟩ _ = #(σ → { n // n < Fintype.card K }) := (@Equiv.subtypePiEquivPi σ (fun _ => ℕ) fun _ n => n < Fintype.card K).cardinal_eq _ = #(σ → Fin (Fintype.card K)) := (Equiv.arrowCongr (Equiv.refl σ) Fin.equivSubtype.symm).cardinal_eq _ = #(σ → K) := (Equiv.arrowCongr (Equiv.refl σ) (Fintype.equivFin K).symm).cardinal_eq _ = Fintype.card (σ → K) := Cardinal.mk_fintype _ instance [Finite σ] : FiniteDimensional K (R σ K) := by cases nonempty_fintype σ classical exact IsNoetherian.iff_fg.1 (IsNoetherian.iff_rank_lt_aleph0.mpr <| by simpa only [rank_R] using Cardinal.nat_lt_aleph0 (Fintype.card (σ → K))) open Classical in theorem finrank_R [Fintype σ] : Module.finrank K (R σ K) = Fintype.card (σ → K) := Module.finrank_eq_of_rank_eq (rank_R σ K) theorem range_evalᵢ [Finite σ] : range (evalᵢ σ K) = ⊤ := by rw [evalᵢ, LinearMap.range_comp, range_subtype] exact map_restrict_dom_evalₗ K σ theorem ker_evalₗ [Finite σ] : ker (evalᵢ σ K) = ⊥ := by cases nonempty_fintype σ refine (ker_eq_bot_iff_range_eq_top_of_finrank_eq_finrank ?_).mpr (range_evalᵢ σ K) classical rw [Module.finrank_fintype_fun_eq_card, finrank_R] theorem eq_zero_of_eval_eq_zero [Finite σ] (p : MvPolynomial σ K) (h : ∀ v : σ → K, eval v p = 0) (hp : p ∈ restrictDegree σ K (Fintype.card K - 1)) : p = 0 := let p' : R σ K := ⟨p, hp⟩ have : p' ∈ ker (evalᵢ σ K) := funext h show p'.1 = (0 : R σ K).1 from congr_arg _ <| by rwa [ker_evalₗ, mem_bot] at this end MvPolynomial
.lake/packages/mathlib/Mathlib/FieldTheory/SplittingField/Construction.lean
import Mathlib.Algebra.CharP.Algebra import Mathlib.FieldTheory.SplittingField.IsSplittingField import Mathlib.LinearAlgebra.Dual.Lemmas import Mathlib.RingTheory.Algebraic.Basic /-! # Splitting fields In this file we prove the existence and uniqueness of splitting fields. ## Main definitions * `Polynomial.SplittingField f`: A fixed splitting field of the polynomial `f`. ## Main statements * `Polynomial.IsSplittingField.algEquiv`: Every splitting field of a polynomial `f` is isomorphic to `SplittingField f` and thus, being a splitting field is unique up to isomorphism. ## Implementation details We construct a `SplittingFieldAux` without worrying about whether the instances satisfy nice definitional equalities. Then the actual `SplittingField` is defined to be a quotient of a `MvPolynomial` ring by the kernel of the obvious map into `SplittingFieldAux`. Because the actual `SplittingField` will be a quotient of a `MvPolynomial`, it has nice instances on it. -/ noncomputable section universe u v w variable {F : Type u} {K : Type v} {L : Type w} namespace Polynomial variable [Field K] [Field L] [Field F] open Polynomial section SplittingField open Classical in /-- Non-computably choose an irreducible factor from a polynomial. -/ def factor (f : K[X]) : K[X] := if H : ∃ g, Irreducible g ∧ g ∣ f then Classical.choose H else X theorem irreducible_factor (f : K[X]) : Irreducible (factor f) := by rw [factor] split_ifs with H · exact (Classical.choose_spec H).1 · exact irreducible_X /-- See note [fact non-instances]. -/ theorem fact_irreducible_factor (f : K[X]) : Fact (Irreducible (factor f)) := ⟨irreducible_factor f⟩ attribute [local instance] fact_irreducible_factor theorem factor_dvd_of_not_isUnit {f : K[X]} (hf1 : ¬IsUnit f) : factor f ∣ f := by by_cases hf2 : f = 0; · rw [hf2]; exact dvd_zero _ rw [factor, dif_pos (WfDvdMonoid.exists_irreducible_factor hf1 hf2)] exact (Classical.choose_spec <| WfDvdMonoid.exists_irreducible_factor hf1 hf2).2 theorem factor_dvd_of_degree_ne_zero {f : K[X]} (hf : f.degree ≠ 0) : factor f ∣ f := factor_dvd_of_not_isUnit (mt degree_eq_zero_of_isUnit hf) theorem factor_dvd_of_natDegree_ne_zero {f : K[X]} (hf : f.natDegree ≠ 0) : factor f ∣ f := factor_dvd_of_degree_ne_zero (mt natDegree_eq_of_degree_eq_some hf) lemma isCoprime_iff_aeval_ne_zero (f g : K[X]) : IsCoprime f g ↔ ∀ {A : Type v} [CommRing A] [IsDomain A] [Algebra K A] (a : A), aeval a f ≠ 0 ∨ aeval a g ≠ 0 := by refine ⟨fun h => aeval_ne_zero_of_isCoprime h, fun h => isCoprime_of_dvd _ _ ?_ fun x hx _ => ?_⟩ · replace h := @h K _ _ _ 0 contrapose! h rw [h.left, h.right, map_zero, and_self] · rintro ⟨_, rfl⟩ ⟨_, rfl⟩ replace h := not_and_or.mpr <| h <| AdjoinRoot.root x.factor simp only [AdjoinRoot.aeval_eq, AdjoinRoot.mk_eq_zero, dvd_mul_of_dvd_left <| factor_dvd_of_not_isUnit hx, true_and, not_true] at h /-- Divide a polynomial f by `X - C r` where `r` is a root of `f` in a bigger field extension. -/ def removeFactor (f : K[X]) : Polynomial (AdjoinRoot <| factor f) := map (AdjoinRoot.of f.factor) f /ₘ (X - C (AdjoinRoot.root f.factor)) theorem X_sub_C_mul_removeFactor (f : K[X]) (hf : f.natDegree ≠ 0) : (X - C (AdjoinRoot.root f.factor)) * f.removeFactor = map (AdjoinRoot.of f.factor) f := by let ⟨g, hg⟩ := factor_dvd_of_natDegree_ne_zero hf apply (mul_divByMonic_eq_iff_isRoot (R := AdjoinRoot f.factor) (a := AdjoinRoot.root f.factor)).mpr rw [IsRoot.def, eval_map, hg, eval₂_mul, ← hg, AdjoinRoot.eval₂_root, zero_mul] theorem natDegree_removeFactor (f : K[X]) : f.removeFactor.natDegree = f.natDegree - 1 := by rw [removeFactor, natDegree_divByMonic _ (monic_X_sub_C _), natDegree_map, natDegree_X_sub_C] theorem natDegree_removeFactor' {f : K[X]} {n : ℕ} (hfn : f.natDegree = n + 1) : f.removeFactor.natDegree = n := by rw [natDegree_removeFactor, hfn, n.add_sub_cancel] /-- Auxiliary construction to a splitting field of a polynomial, which removes `n` (arbitrarily-chosen) factors. It constructs the type, proves that is a field and algebra over the base field. Uses recursion on the degree. -/ def SplittingFieldAuxAux (n : ℕ) : ∀ {K : Type u} [Field K], K[X] → Σ (L : Type u) (_ : Field L), Algebra K L := -- Porting note: added motive Nat.recOn (motive := fun (_x : ℕ) => ∀ {K : Type u} [_inst_4 : Field K], K[X] → Σ (L : Type u) (_ : Field L), Algebra K L) n (fun {K} _ _ => ⟨K, inferInstance, inferInstance⟩) fun _ ih _ _ f => let ⟨L, fL, _⟩ := ih f.removeFactor ⟨L, fL, (RingHom.comp (algebraMap _ _) (AdjoinRoot.of f.factor)).toAlgebra⟩ /-- Auxiliary construction to a splitting field of a polynomial, which removes `n` (arbitrarily-chosen) factors. It is the type constructed in `SplittingFieldAuxAux`. -/ def SplittingFieldAux (n : ℕ) {K : Type u} [Field K] (f : K[X]) : Type u := (SplittingFieldAuxAux n f).1 instance SplittingFieldAux.field (n : ℕ) {K : Type u} [Field K] (f : K[X]) : Field (SplittingFieldAux n f) := (SplittingFieldAuxAux n f).2.1 instance (n : ℕ) {K : Type u} [Field K] (f : K[X]) : Inhabited (SplittingFieldAux n f) := ⟨0⟩ instance SplittingFieldAux.algebra (n : ℕ) {K : Type u} [Field K] (f : K[X]) : Algebra K (SplittingFieldAux n f) := (SplittingFieldAuxAux n f).2.2 namespace SplittingFieldAux theorem succ (n : ℕ) (f : K[X]) : SplittingFieldAux (n + 1) f = SplittingFieldAux n f.removeFactor := rfl instance algebra''' {n : ℕ} {f : K[X]} : Algebra (AdjoinRoot f.factor) (SplittingFieldAux n f.removeFactor) := SplittingFieldAux.algebra n _ instance algebra' {n : ℕ} {f : K[X]} : Algebra (AdjoinRoot f.factor) (SplittingFieldAux n.succ f) := SplittingFieldAux.algebra''' instance algebra'' {n : ℕ} {f : K[X]} : Algebra K (SplittingFieldAux n f.removeFactor) := RingHom.toAlgebra (RingHom.comp (algebraMap _ _) (AdjoinRoot.of f.factor)) instance scalar_tower' {n : ℕ} {f : K[X]} : IsScalarTower K (AdjoinRoot f.factor) (SplittingFieldAux n f.removeFactor) := IsScalarTower.of_algebraMap_eq fun _ => rfl theorem algebraMap_succ (n : ℕ) (f : K[X]) : algebraMap K (SplittingFieldAux (n + 1) f) = (algebraMap (AdjoinRoot f.factor) (SplittingFieldAux n f.removeFactor)).comp (AdjoinRoot.of f.factor) := rfl protected theorem splits (n : ℕ) : ∀ {K : Type u} [Field K], ∀ (f : K[X]) (_hfn : f.natDegree = n), Splits (algebraMap K <| SplittingFieldAux n f) f := Nat.recOn (motive := fun n => ∀ {K : Type u} [Field K], ∀ (f : K[X]) (_hfn : f.natDegree = n), Splits (algebraMap K <| SplittingFieldAux n f) f) n (fun {_} _ _ hf => splits_of_degree_le_one _ (le_trans degree_le_natDegree <| hf.symm ▸ WithBot.coe_le_coe.2 zero_le_one)) fun n ih {K} _ f hf => by rw [← splits_id_iff_splits, algebraMap_succ, ← map_map, splits_id_iff_splits, ← X_sub_C_mul_removeFactor f fun h => by rw [h] at hf; cases hf] exact splits_mul _ (splits_X_sub_C _) (ih _ (natDegree_removeFactor' hf)) theorem adjoin_rootSet (n : ℕ) : ∀ {K : Type u} [Field K], ∀ (f : K[X]) (_hfn : f.natDegree = n), Algebra.adjoin K (f.rootSet (SplittingFieldAux n f)) = ⊤ := Nat.recOn (motive := fun n => ∀ {K : Type u} [Field K], ∀ (f : K[X]) (_hfn : f.natDegree = n), Algebra.adjoin K (f.rootSet (SplittingFieldAux n f)) = ⊤) n (fun {_} _ _ _hf => Algebra.eq_top_iff.2 fun x => Subalgebra.range_le _ ⟨x, rfl⟩) fun n ih {K} _ f hfn => by have hndf : f.natDegree ≠ 0 := by intro h; rw [h] at hfn; cases hfn have hfn0 : f ≠ 0 := by intro h; rw [h] at hndf; exact hndf rfl have hmf0 : map (algebraMap K (SplittingFieldAux n.succ f)) f ≠ 0 := map_ne_zero hfn0 classical rw [rootSet_def, aroots_def] rw [algebraMap_succ, ← map_map, ← X_sub_C_mul_removeFactor _ hndf, Polynomial.map_mul] at hmf0 ⊢ rw [roots_mul hmf0, Polynomial.map_sub, map_X, map_C, roots_X_sub_C, Multiset.toFinset_add, Finset.coe_union, Multiset.toFinset_singleton, Finset.coe_singleton, Algebra.adjoin_union_eq_adjoin_adjoin, ← Set.image_singleton] -- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644 erw [Algebra.adjoin_algebraMap K (SplittingFieldAux n f.removeFactor)] rw [AdjoinRoot.adjoinRoot_eq_top, Algebra.map_top] -- Porting note: was `rw` erw [IsScalarTower.adjoin_range_toAlgHom K (AdjoinRoot f.factor) (SplittingFieldAux n f.removeFactor) (f.removeFactor.rootSet (SplittingFieldAux n f.removeFactor))] rw [ih _ (natDegree_removeFactor' hfn), Subalgebra.restrictScalars_top] instance (f : K[X]) : IsSplittingField K (SplittingFieldAux f.natDegree f) f := ⟨SplittingFieldAux.splits _ _ rfl, SplittingFieldAux.adjoin_rootSet _ _ rfl⟩ end SplittingFieldAux /-- A splitting field of a polynomial. -/ @[stacks 09HV "The construction of the splitting field."] def SplittingField (f : K[X]) := MvPolynomial (SplittingFieldAux f.natDegree f) K ⧸ RingHom.ker (MvPolynomial.aeval (R := K) id).toRingHom deriving Inhabited, CommRing, Algebra K namespace SplittingField variable (f : K[X]) variable {S : Type*} [DistribSMul S K] [IsScalarTower S K K] in deriving instance SMul S for SplittingField f variable {R : Type*} [CommSemiring R] [Algebra R K] in deriving instance Algebra R, IsScalarTower R K for SplittingField f /-- The algebra equivalence with `SplittingFieldAux`, which we will use to construct the field structure. -/ def algEquivSplittingFieldAux (f : K[X]) : SplittingField f ≃ₐ[K] SplittingFieldAux f.natDegree f := Ideal.quotientKerAlgEquivOfSurjective fun x => ⟨MvPolynomial.X x, by simp⟩ instance instGroupWithZero : GroupWithZero (SplittingField f) := let e := algEquivSplittingFieldAux f { inv := fun a ↦ e.symm (e a)⁻¹ inv_zero := by simp mul_inv_cancel := fun a ha ↦ e.injective <| by simp [EmbeddingLike.map_ne_zero_iff.2 ha] __ := e.surjective.nontrivial } instance instField : Field (SplittingField f) where __ := inferInstanceAs <| CommRing (SplittingField f) __ := instGroupWithZero f nnratCast q := algebraMap K _ q ratCast q := algebraMap K _ q nnqsmul := (· • ·) qsmul := (· • ·) nnratCast_def q := by change algebraMap K _ _ = _; simp_rw [NNRat.cast_def, map_div₀, map_natCast] ratCast_def q := by change algebraMap K _ _ = _; rw [Rat.cast_def, map_div₀, map_intCast, map_natCast] nnqsmul_def q x := Quotient.inductionOn x fun p ↦ congr_arg Quotient.mk'' <| by ext; simp [MvPolynomial.algebraMap_eq, NNRat.smul_def] qsmul_def q x := Quotient.inductionOn x fun p ↦ congr_arg Quotient.mk'' <| by ext; simp [MvPolynomial.algebraMap_eq, Rat.smul_def] instance instCharZero [CharZero K] : CharZero (SplittingField f) := charZero_of_injective_algebraMap (algebraMap K _).injective instance instCharP (p : ℕ) [CharP K p] : CharP (SplittingField f) p := charP_of_injective_algebraMap (algebraMap K _).injective p instance instExpChar (p : ℕ) [ExpChar K p] : ExpChar (SplittingField f) p := expChar_of_injective_algebraMap (algebraMap K _).injective p instance _root_.Polynomial.IsSplittingField.splittingField (f : K[X]) : IsSplittingField K (SplittingField f) f := IsSplittingField.of_algEquiv _ f (algEquivSplittingFieldAux f).symm @[stacks 09HU "Splitting part"] protected theorem splits : Splits (algebraMap K (SplittingField f)) f := IsSplittingField.splits f.SplittingField f variable [Algebra K L] (hb : Splits (algebraMap K L) f) /-- Embeds the splitting field into any other field that splits the polynomial. -/ def lift : SplittingField f →ₐ[K] L := IsSplittingField.lift f.SplittingField f hb theorem adjoin_rootSet : Algebra.adjoin K (f.rootSet (SplittingField f)) = ⊤ := Polynomial.IsSplittingField.adjoin_rootSet _ f end SplittingField end SplittingField namespace IsSplittingField variable (K L) variable [Algebra K L] variable {K} instance (f : K[X]) : FiniteDimensional K f.SplittingField := finiteDimensional f.SplittingField f instance [Finite K] (f : K[X]) : Finite f.SplittingField := Module.finite_of_finite K instance (f : K[X]) : NoZeroSMulDivisors K f.SplittingField := inferInstance /-- Any splitting field is isomorphic to `SplittingFieldAux f`. -/ def algEquiv (f : K[X]) [h : IsSplittingField K L f] : L ≃ₐ[K] SplittingField f := AlgEquiv.ofBijective (lift L f <| splits (SplittingField f) f) <| have := finiteDimensional L f ((Algebra.IsAlgebraic.of_finite K L).algHom_bijective₂ _ <| lift _ f h.1).1 end IsSplittingField end Polynomial
.lake/packages/mathlib/Mathlib/FieldTheory/SplittingField/IsSplittingField.lean
import Mathlib.FieldTheory.IntermediateField.Adjoin.Algebra import Mathlib.LinearAlgebra.Dimension.FreeAndStrongRankCondition import Mathlib.RingTheory.Adjoin.Field /-! # Splitting fields This file introduces the notion of a splitting field of a polynomial and provides an embedding from a splitting field to any field that splits the polynomial. A polynomial `f : K[X]` splits over a field extension `L` of `K` if it is zero or all of its irreducible factors over `L` have degree `1`. A field extension of `K` of a polynomial `f : K[X]` is called a splitting field if it is the smallest field extension of `K` such that `f` splits. ## Main definitions * `Polynomial.IsSplittingField`: A predicate on a field to be a splitting field of a polynomial `f`. ## Main statements * `Polynomial.IsSplittingField.lift`: An embedding of a splitting field of the polynomial `f` into another field such that `f` splits. -/ noncomputable section universe u v w variable {F : Type u} (K : Type v) (L : Type w) namespace Polynomial variable [Field K] [Field L] [Field F] [Algebra K L] /-- Typeclass characterising splitting fields. -/ @[stacks 09HV "Predicate version"] class IsSplittingField (f : K[X]) : Prop where splits' : Splits (algebraMap K L) f adjoin_rootSet' : Algebra.adjoin K (f.rootSet L : Set L) = ⊤ namespace IsSplittingField variable {K} theorem splits (f : K[X]) [IsSplittingField K L f] : Splits (algebraMap K L) f := splits' theorem adjoin_rootSet (f : K[X]) [IsSplittingField K L f] : Algebra.adjoin K (f.rootSet L : Set L) = ⊤ := adjoin_rootSet' section ScalarTower variable [Algebra F K] [Algebra F L] [IsScalarTower F K L] instance map (f : F[X]) [IsSplittingField F L f] : IsSplittingField K L (f.map <| algebraMap F K) := ⟨by rw [splits_map_iff, ← IsScalarTower.algebraMap_eq]; exact splits L f, Subalgebra.restrictScalars_injective F <| by rw [rootSet, aroots, map_map, ← IsScalarTower.algebraMap_eq, Subalgebra.restrictScalars_top, eq_top_iff, ← adjoin_rootSet L f, Algebra.adjoin_le_iff] exact fun x hx => @Algebra.subset_adjoin K _ _ _ _ _ _ hx⟩ theorem splits_iff (f : K[X]) [IsSplittingField K L f] : Splits (RingHom.id K) f ↔ (⊤ : Subalgebra K L) = ⊥ := ⟨fun h => by rw [eq_bot_iff, ← adjoin_rootSet L f, rootSet, aroots, roots_map (algebraMap K L) h, Algebra.adjoin_le_iff] intro y hy classical rw [Multiset.toFinset_map, Finset.mem_coe, Finset.mem_image] at hy obtain ⟨x : K, -, hxy : algebraMap K L x = y⟩ := hy rw [← hxy] exact SetLike.mem_coe.2 <| Subalgebra.algebraMap_mem _ _, fun h => @RingEquiv.toRingHom_refl K _ ▸ RingEquiv.self_trans_symm (RingEquiv.ofBijective _ <| Algebra.bijective_algebraMap_iff.2 h) ▸ by rw [RingEquiv.toRingHom_trans] exact splits_comp_of_splits _ _ (splits L f)⟩ theorem IsScalarTower.splits (f : F[X]) [IsSplittingField K L (mapAlg F K f)] : Splits (RingHom.id L) (mapAlg F L f) := by rw [mapAlg_comp K L f, mapAlg_eq_map, splits_id_iff_splits] apply IsSplittingField.splits theorem mul (f g : F[X]) (hf : f ≠ 0) (hg : g ≠ 0) [IsSplittingField F K f] [IsSplittingField K L (g.map <| algebraMap F K)] : IsSplittingField F L (f * g) := ⟨(IsScalarTower.algebraMap_eq F K L).symm ▸ splits_mul _ (splits_comp_of_splits _ _ (splits K f)) ((splits_map_iff _ _).1 (splits L <| g.map <| algebraMap F K)), by classical rw [rootSet, aroots_mul (mul_ne_zero hf hg), Multiset.toFinset_add, Finset.coe_union, Algebra.adjoin_union_eq_adjoin_adjoin, aroots_def, aroots_def, IsScalarTower.algebraMap_eq F K L, ← map_map, roots_map (algebraMap K L) ((splits_id_iff_splits <| algebraMap F K).2 <| splits K f), Multiset.toFinset_map, Finset.coe_image, Algebra.adjoin_algebraMap, ← rootSet, adjoin_rootSet, Algebra.map_top, IsScalarTower.adjoin_range_toAlgHom, ← map_map, ← rootSet, adjoin_rootSet, Subalgebra.restrictScalars_top]⟩ end ScalarTower open Classical in /-- Splitting field of `f` embeds into any field that splits `f`. -/ def lift [Algebra K F] (f : K[X]) [IsSplittingField K L f] (hf : Splits (algebraMap K F) f) : L →ₐ[K] F := if hf0 : f = 0 then (Algebra.ofId K F).comp <| (Algebra.botEquiv K L : (⊥ : Subalgebra K L) →ₐ[K] K).comp <| by rw [← (splits_iff L f).1 (show f.Splits (RingHom.id K) from hf0.symm ▸ splits_zero _)] exact Algebra.toTop else AlgHom.comp (by rw [← adjoin_rootSet L f] exact Classical.choice (lift_of_splits _ fun y hy => have : aeval y f = 0 := (eval₂_eq_eval_map _).trans <| (mem_roots <| map_ne_zero hf0).1 (Multiset.mem_toFinset.mp hy) ⟨IsAlgebraic.isIntegral ⟨f, hf0, this⟩, splits_of_splits_of_dvd _ hf0 hf <| minpoly.dvd _ _ this⟩)) Algebra.toTop theorem finiteDimensional (f : K[X]) [IsSplittingField K L f] : FiniteDimensional K L := by classical exact ⟨@Algebra.top_toSubmodule K L _ _ _ ▸ adjoin_rootSet L f ▸ fg_adjoin_of_finite (Finset.finite_toSet _) fun y hy ↦ if hf : f = 0 then by rw [hf, rootSet_zero] at hy; cases hy else IsAlgebraic.isIntegral ⟨f, hf, (mem_rootSet'.mp hy).2⟩⟩ theorem IsScalarTower.isAlgebraic [Algebra F K] [Algebra F L] [Algebra.IsAlgebraic F K] [IsScalarTower F K L] (f : K[X]) [IsSplittingField K L f] : Algebra.IsAlgebraic F L := by have : FiniteDimensional K L := IsSplittingField.finiteDimensional L f exact Algebra.IsAlgebraic.trans F K L theorem of_algEquiv [Algebra K F] (p : K[X]) (f : F ≃ₐ[K] L) [IsSplittingField K F p] : IsSplittingField K L p := by constructor · rw [← f.toAlgHom.comp_algebraMap] exact splits_comp_of_splits _ _ (splits F p) · rw [← (AlgHom.range_eq_top f.toAlgHom).mpr f.surjective, adjoin_rootSet_eq_range (splits F p), adjoin_rootSet F p] theorem adjoin_rootSet_eq_range [Algebra K F] (f : K[X]) [IsSplittingField K L f] (i : L →ₐ[K] F) : Algebra.adjoin K (rootSet f F) = i.range := (Polynomial.adjoin_rootSet_eq_range (splits L f) i).mpr (adjoin_rootSet L f) end IsSplittingField end Polynomial open Polynomial variable {K L} [Field K] [Field L] [Algebra K L] {p : K[X]} {F : IntermediateField K L} theorem IntermediateField.splits_of_splits (h : p.Splits (algebraMap K L)) (hF : ∀ x ∈ p.rootSet L, x ∈ F) : p.Splits (algebraMap K F) := by classical simp_rw [← F.fieldRange_val, rootSet_def, Finset.mem_coe, Multiset.mem_toFinset] at hF exact splits_of_comp _ F.val.toRingHom h hF theorem IntermediateField.splits_iff_mem (h : p.Splits (algebraMap K L)) : p.Splits (algebraMap K F) ↔ ∀ x ∈ p.rootSet L, x ∈ F := by refine ⟨?_, IntermediateField.splits_of_splits h⟩ intro hF rw [← Polynomial.image_rootSet hF F.val, Set.forall_mem_image] exact fun x _ ↦ x.2 theorem IsIntegral.mem_intermediateField_of_minpoly_splits {x : L} (int : IsIntegral K x) {F : IntermediateField K L} (h : Splits (algebraMap K F) (minpoly K x)) : x ∈ F := by rw [← F.fieldRange_val]; exact int.mem_range_algebraMap_of_minpoly_splits h /-- Characterize `IsSplittingField` with `IntermediateField.adjoin` instead of `Algebra.adjoin`. -/ theorem isSplittingField_iff_intermediateField : p.IsSplittingField K L ↔ p.Splits (algebraMap K L) ∧ IntermediateField.adjoin K (p.rootSet L) = ⊤ := by rw [← IntermediateField.toSubalgebra_injective.eq_iff, IntermediateField.adjoin_algebraic_toSubalgebra fun _ ↦ isAlgebraic_of_mem_rootSet] exact ⟨fun ⟨spl, adj⟩ ↦ ⟨spl, adj⟩, fun ⟨spl, adj⟩ ↦ ⟨spl, adj⟩⟩ -- Note: p.Splits (algebraMap F E) also works theorem IntermediateField.isSplittingField_iff : p.IsSplittingField K F ↔ p.Splits (algebraMap K F) ∧ F = adjoin K (p.rootSet L) := by suffices _ → (Algebra.adjoin K (p.rootSet F) = ⊤ ↔ F = adjoin K (p.rootSet L)) by exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩ rw [← toSubalgebra_injective.eq_iff, adjoin_algebraic_toSubalgebra fun x ↦ isAlgebraic_of_mem_rootSet] refine fun hp ↦ (adjoin_rootSet_eq_range hp F.val).symm.trans ?_ rw [← F.range_val, eq_comm] theorem IntermediateField.adjoin_rootSet_isSplittingField (hp : p.Splits (algebraMap K L)) : p.IsSplittingField K (adjoin K (p.rootSet L)) := isSplittingField_iff.mpr ⟨splits_of_splits hp fun _ hx ↦ subset_adjoin K (p.rootSet L) hx, rfl⟩ theorem Polynomial.isSplittingField_C (a : K) : Polynomial.IsSplittingField K K (C a) where splits' := by simp adjoin_rootSet' := by simp
.lake/packages/mathlib/Mathlib/FieldTheory/MvRatFunc/Rank.lean
import Mathlib.Algebra.MvPolynomial.Cardinal import Mathlib.RingTheory.Algebraic.LinearIndependent import Mathlib.RingTheory.Algebraic.MvPolynomial import Mathlib.RingTheory.Localization.Cardinality import Mathlib.RingTheory.MvPolynomial /-! # Rank of multivariate rational function field -/ noncomputable section universe u v open Cardinal in theorem MvRatFunc.rank_eq_max_lift {σ : Type u} {F : Type v} [Field F] [Nonempty σ] : Module.rank F (FractionRing (MvPolynomial σ F)) = lift.{u} #F ⊔ lift.{v} #σ ⊔ ℵ₀ := by let R := MvPolynomial σ F let K := FractionRing R refine ((rank_le_card _ _).trans ?_).antisymm ?_ · rw [FractionRing.cardinalMk, MvPolynomial.cardinalMk_eq_max_lift] have hinj := IsFractionRing.injective R K have h1 := (IsScalarTower.toAlgHom F R K).toLinearMap.rank_le_of_injective hinj rw [MvPolynomial.rank_eq_lift, mk_finsupp_nat, lift_max, lift_aleph0, max_le_iff] at h1 obtain ⟨i⟩ := ‹Nonempty σ› have hx : Transcendental F (algebraMap R K (MvPolynomial.X i)) := (transcendental_algebraMap_iff hinj).2 (MvPolynomial.transcendental_X F i) have h2 := hx.linearIndependent_sub_inv.cardinal_lift_le_rank rw [lift_id'.{v, u}, lift_umax.{v, u}] at h2 exact max_le (max_le h2 h1.1) h1.2
.lake/packages/mathlib/Mathlib/FieldTheory/IsAlgClosed/Classification.lean
import Mathlib.Algebra.Algebra.ZMod import Mathlib.Algebra.Field.ZMod import Mathlib.Algebra.MvPolynomial.Cardinal import Mathlib.FieldTheory.IsAlgClosed.Basic import Mathlib.RingTheory.Algebraic.Cardinality import Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis /-! # Classification of Algebraically closed fields This file contains results related to classifying algebraically closed fields. ## Main statements * `IsAlgClosed.equivOfTranscendenceBasis` Two algebraically closed fields with the same characteristic and the same cardinality of transcendence basis are isomorphic. * `IsAlgClosed.ringEquivOfCardinalEqOfCharEq` Two uncountable algebraically closed fields are isomorphic if they have the same characteristic and the same cardinality. -/ universe u v w open scoped Cardinal Polynomial open Cardinal namespace IsAlgClosed section Classification noncomputable section variable {R L K : Type*} [CommRing R] variable [Field K] [Algebra R K] variable [Field L] [Algebra R L] variable {ι : Type*} (v : ι → K) variable {κ : Type*} (w : κ → L) variable (hv : AlgebraicIndependent R v) theorem isAlgClosure_of_transcendence_basis [IsAlgClosed K] (hv : IsTranscendenceBasis R v) : IsAlgClosure (Algebra.adjoin R (Set.range v)) K := letI := RingHom.domain_nontrivial (algebraMap R K) { isAlgClosed := by infer_instance isAlgebraic := hv.isAlgebraic } variable (hw : AlgebraicIndependent R w) /-- setting `R` to be `ZMod (ringChar R)` this result shows that if two algebraically closed fields have equipotent transcendence bases and the same characteristic then they are isomorphic. -/ def equivOfTranscendenceBasis [IsAlgClosed K] [IsAlgClosed L] (e : ι ≃ κ) (hv : IsTranscendenceBasis R v) (hw : IsTranscendenceBasis R w) : K ≃+* L := by letI := isAlgClosure_of_transcendence_basis v hv letI := isAlgClosure_of_transcendence_basis w hw have e : Algebra.adjoin R (Set.range v) ≃+* Algebra.adjoin R (Set.range w) := by refine hv.1.aevalEquiv.symm.toRingEquiv.trans ?_ refine (AlgEquiv.ofAlgHom (MvPolynomial.rename e) (MvPolynomial.rename e.symm) ?_ ?_).toRingEquiv.trans ?_ · ext; simp · ext; simp exact hw.1.aevalEquiv.toRingEquiv exact IsAlgClosure.equivOfEquiv K L e end end Classification section Cardinal variable {R : Type u} {K : Type v} [CommRing R] [Field K] [Algebra R K] [IsAlgClosed K] variable {ι : Type w} (v : ι → K) variable {K' : Type u} [Field K'] [Algebra R K'] [IsAlgClosed K'] variable {ι' : Type u} (v' : ι' → K') /-- The cardinality of an algebraically closed `R`-algebra is less than or equal to the maximum of the cardinality of `R`, the cardinality of a transcendence basis and `ℵ₀` For a simpler, but less universe-polymorphic statement, see `IsAlgClosed.cardinal_le_max_transcendence_basis'` -/ theorem cardinal_le_max_transcendence_basis (hv : IsTranscendenceBasis R v) : Cardinal.lift.{max u w} #K ≤ max (max (Cardinal.lift.{max v w} #R) (Cardinal.lift.{max u v} #ι)) ℵ₀ := calc Cardinal.lift.{max u w} #K ≤ Cardinal.lift.{max u w} (max #(Algebra.adjoin R (Set.range v)) ℵ₀) := by letI := isAlgClosure_of_transcendence_basis v hv simpa using Algebra.IsAlgebraic.cardinalMk_le_max (Algebra.adjoin R (Set.range v)) K _ = Cardinal.lift.{v} (max #(MvPolynomial ι R) ℵ₀) := by rw [lift_max, ← Cardinal.lift_mk_eq.2 ⟨hv.1.aevalEquiv.toEquiv⟩, lift_aleph0, ← lift_aleph0.{max u v w, max u w}, ← lift_max, lift_umax.{max u w, v}] _ ≤ Cardinal.lift.{v} (max (max (max (Cardinal.lift #R) (Cardinal.lift #ι)) ℵ₀) ℵ₀) := lift_le.2 (max_le_max MvPolynomial.cardinalMk_le_max_lift le_rfl) _ = _ := by simp /-- The cardinality of an algebraically closed `R`-algebra is less than or equal to the maximum of the cardinality of `R`, the cardinality of a transcendence basis and `ℵ₀` A less-universe polymorphic, but simpler statement of `IsAlgClosed.cardinal_le_max_transcendence_basis` -/ theorem cardinal_le_max_transcendence_basis' (hv : IsTranscendenceBasis R v') : #K' ≤ max (max #R #ι') ℵ₀ := by simpa using cardinal_le_max_transcendence_basis v' hv /-- If `K` is an uncountable algebraically closed field, then its cardinality is the same as that of a transcendence basis. For a simpler, but less universe-polymorphic statement, see `IsAlgClosed.cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt'` -/ theorem cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt [Nontrivial R] (hv : IsTranscendenceBasis R v) (hR : #R ≤ ℵ₀) (hK : ℵ₀ < #K) : Cardinal.lift.{w} #K = Cardinal.lift.{v} #ι := have : ℵ₀ ≤ Cardinal.lift.{max u v} #ι := le_of_not_gt fun h => not_le_of_gt (show ℵ₀ < Cardinal.lift.{max u w} #K by simpa) <| calc Cardinal.lift.{max u w, v} #K ≤ max (max (Cardinal.lift.{max v w, u} #R) (Cardinal.lift.{max u v, w} #ι)) ℵ₀ := cardinal_le_max_transcendence_basis v hv _ ≤ _ := max_le (max_le (by simpa) (by simpa using le_of_lt h)) le_rfl suffices Cardinal.lift.{max u w} #K = Cardinal.lift.{max u v} #ι from Cardinal.lift_injective.{u, max v w} (by simpa) le_antisymm (calc Cardinal.lift.{max u w} #K ≤ max (max (Cardinal.lift.{max v w} #R) (Cardinal.lift.{max u v} #ι)) ℵ₀ := cardinal_le_max_transcendence_basis v hv _ = Cardinal.lift #ι := by rw [max_eq_left, max_eq_right] · exact le_trans (by simpa using hR) this · exact le_max_of_le_right this) (lift_mk_le.2 ⟨⟨v, hv.1.injective⟩⟩) /-- If `K` is an uncountable algebraically closed field, then its cardinality is the same as that of a transcendence basis. This is a simpler, but less general statement of `cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt`. -/ theorem cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt' [Nontrivial R] (hv : IsTranscendenceBasis R v') (hR : #R ≤ ℵ₀) (hK : ℵ₀ < #K') : #K' = #ι' := by simpa using cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt v' hv hR hK end Cardinal variable {K : Type u} {L : Type v} [Field K] [Field L] [IsAlgClosed K] [IsAlgClosed L] /-- Two uncountable algebraically closed fields of characteristic zero are isomorphic if they have the same cardinality. -/ theorem ringEquiv_of_equiv_of_charZero [CharZero K] [CharZero L] (hK : ℵ₀ < #K) (hKL : Nonempty (K ≃ L)) : Nonempty (K ≃+* L) := by obtain ⟨s, hs⟩ := exists_isTranscendenceBasis ℤ K obtain ⟨t, ht⟩ := exists_isTranscendenceBasis ℤ L have hL : ℵ₀ < #L := by rwa [← aleph0_lt_lift.{v, u}, ← lift_mk_eq'.2 hKL, aleph0_lt_lift] have : Cardinal.lift.{v} #s = Cardinal.lift.{u} #t := by rw [← lift_injective (cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt _ hs (le_of_eq mk_int) hK), ← lift_injective (cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt _ ht (le_of_eq mk_int) hL)] exact Cardinal.lift_mk_eq'.2 hKL obtain ⟨e⟩ := Cardinal.lift_mk_eq'.1 this exact ⟨equivOfTranscendenceBasis _ _ e hs ht⟩ private theorem ringEquiv_of_Cardinal_eq_of_charP (p : ℕ) [Fact p.Prime] [CharP K p] [CharP L p] (hK : ℵ₀ < #K) (hKL : Nonempty (K ≃ L)) : Nonempty (K ≃+* L) := by letI : Algebra (ZMod p) K := ZMod.algebra _ _ letI : Algebra (ZMod p) L := ZMod.algebra _ _ obtain ⟨s, hs⟩ := exists_isTranscendenceBasis (ZMod p) K obtain ⟨t, ht⟩ := exists_isTranscendenceBasis (ZMod p) L have hL : ℵ₀ < #L := by rwa [← aleph0_lt_lift.{v, u}, ← lift_mk_eq'.2 hKL, aleph0_lt_lift] have : Cardinal.lift.{v} #s = Cardinal.lift.{u} #t := by rw [← lift_injective (cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt _ hs (le_of_lt (lt_aleph0_of_finite _)) hK), ← lift_injective (cardinal_eq_cardinal_transcendence_basis_of_aleph0_lt _ ht (le_of_lt (lt_aleph0_of_finite _)) hL)] exact Cardinal.lift_mk_eq'.2 hKL obtain ⟨e⟩ := Cardinal.lift_mk_eq'.1 this exact ⟨equivOfTranscendenceBasis _ _ e hs ht⟩ /-- Two uncountable algebraically closed fields are isomorphic if they have the same cardinality and the same characteristic. -/ theorem ringEquiv_of_equiv_of_char_eq (p : ℕ) [CharP K p] [CharP L p] (hK : ℵ₀ < #K) (hKL : Nonempty (K ≃ L)) : Nonempty (K ≃+* L) := by rcases CharP.char_is_prime_or_zero K p with (hp | hp) · haveI : Fact p.Prime := ⟨hp⟩ exact ringEquiv_of_Cardinal_eq_of_charP p hK hKL · simp only [hp] at * letI : CharZero K := CharP.charP_to_charZero K letI : CharZero L := CharP.charP_to_charZero L exact ringEquiv_of_equiv_of_charZero hK hKL end IsAlgClosed
.lake/packages/mathlib/Mathlib/FieldTheory/IsAlgClosed/AlgebraicClosure.lean
import Mathlib.Algebra.CharP.Algebra import Mathlib.Data.Multiset.Fintype import Mathlib.FieldTheory.IsAlgClosed.Basic import Mathlib.FieldTheory.SplittingField.Construction /-! # Algebraic Closure In this file we construct the algebraic closure of a field ## Main Definitions - `AlgebraicClosure k` is an algebraic closure of `k` (in the same universe). It is constructed by taking the polynomial ring generated by indeterminates $X_{f,1}, \dots, X_{f,\deg f}$ corresponding to roots of monic irreducible polynomials `f` with coefficients in `k`, and quotienting out by a maximal ideal containing every $f - \prod_i (X - X_{f,i})$. The proof follows https://kconrad.math.uconn.edu/blurbs/galoistheory/algclosureshorter.pdf. ## Tags algebraic closure, algebraically closed -/ universe u v w noncomputable section open Polynomial variable (k : Type u) [Field k] namespace AlgebraicClosure /-- The subtype of monic polynomials. -/ def Monics : Type u := {f : k[X] // f.Monic} /-- `Vars k` provides `n` variables $X_{f,1}, \dots, X_{f,n}$ for each monic polynomial `f : k[X]` of degree `n`. -/ def Vars : Type u := Σ f : Monics k, Fin f.1.natDegree variable {k} in /-- Given a monic polynomial `f : k[X]`, `subProdXSubC f` is the polynomial $f - \prod_i (X - X_{f,i})$. -/ def subProdXSubC (f : Monics k) : (MvPolynomial (Vars k) k)[X] := f.1.map (algebraMap _ _) - ∏ i : Fin f.1.natDegree, (X - C (MvPolynomial.X ⟨f, i⟩)) /-- The span of all coefficients of `subProdXSubC f` as `f` ranges all polynomials in `k[X]`. -/ def spanCoeffs : Ideal (MvPolynomial (Vars k) k) := Ideal.span <| Set.range fun fn : Monics k × ℕ ↦ (subProdXSubC fn.1).coeff fn.2 variable {k} /-- If a monic polynomial `f : k[X]` splits in `K`, then it has as many roots (counting multiplicity) as its degree. -/ def finEquivRoots {K} [Field K] [DecidableEq K] {i : k →+* K} {f : Monics k} (hf : f.1.Splits i) : Fin f.1.natDegree ≃ (f.1.map i).roots.toEnumFinset := .symm <| Finset.equivFinOfCardEq <| by rwa [← splits_id_iff_splits, splits_iff_card_roots, ← Multiset.card_toEnumFinset, f.2.natDegree_map] at hf lemma Monics.splits_finsetProd {s : Finset (Monics k)} {f : Monics k} (hf : f ∈ s) : f.1.Splits (algebraMap k (SplittingField (∏ f ∈ s, f.1))) := (splits_prod_iff _ fun j _ ↦ j.2.ne_zero).1 (SplittingField.splits _) _ hf open Classical in /-- Given a finite set of monic polynomials, construct an algebra homomorphism to the splitting field of the product of the polynomials sending indeterminates $X_{f_i}$ to the distinct roots of `f`. -/ def toSplittingField (s : Finset (Monics k)) : MvPolynomial (Vars k) k →ₐ[k] SplittingField (∏ f ∈ s, f.1) := MvPolynomial.aeval fun fi ↦ if hf : fi.1 ∈ s then (finEquivRoots (Monics.splits_finsetProd hf) fi.2).1.1 else 37 theorem toSplittingField_coeff {s : Finset (Monics k)} {f} (h : f ∈ s) (n) : toSplittingField s ((subProdXSubC f).coeff n) = 0 := by classical simp_rw [← AlgHom.coe_toRingHom, ← coeff_map, subProdXSubC, Polynomial.map_sub, Polynomial.map_prod, Polynomial.map_sub, map_X, map_C, toSplittingField, AlgHom.coe_toRingHom, MvPolynomial.aeval_X, dif_pos h, ← (finEquivRoots (Monics.splits_finsetProd h)).symm.prod_comp, Equiv.apply_symm_apply] rw [Finset.prod_coe_sort (f := fun x : _ × ℕ ↦ X - C x.1), (Multiset.toEnumFinset _) |>.prod_eq_multiset_prod, ← Function.comp_def (X - C ·) Prod.fst, ← Multiset.map_map, Multiset.map_toEnumFinset_fst, map_map, AlgHom.comp_algebraMap] conv in map _ _ => rw [eq_prod_roots_of_splits (Monics.splits_finsetProd h)] rw [f.2, map_one, C_1, one_mul, sub_self, coeff_zero] variable (k) theorem spanCoeffs_ne_top : spanCoeffs k ≠ ⊤ := by rw [Ideal.ne_top_iff_one, spanCoeffs, Ideal.span, ← Set.image_univ, Finsupp.mem_span_image_iff_linearCombination] rintro ⟨v, _, hv⟩ classical replace hv := congr_arg (toSplittingField <| v.support.image Prod.fst) hv rw [map_one, Finsupp.linearCombination_apply, Finsupp.sum, map_sum, Finset.sum_eq_zero] at hv · exact zero_ne_one hv intro j hj rw [smul_eq_mul, map_mul, toSplittingField_coeff (Finset.mem_image_of_mem _ hj), mul_zero] /-- A random maximal ideal that contains `spanEval k` -/ def maxIdeal : Ideal (MvPolynomial (Vars k) k) := Classical.choose <| Ideal.exists_le_maximal _ <| spanCoeffs_ne_top k instance maxIdeal.isMaximal : (maxIdeal k).IsMaximal := (Classical.choose_spec <| Ideal.exists_le_maximal _ <| spanCoeffs_ne_top k).1 theorem le_maxIdeal : spanCoeffs k ≤ maxIdeal k := (Classical.choose_spec <| Ideal.exists_le_maximal _ <| spanCoeffs_ne_top k).2 end AlgebraicClosure open AlgebraicClosure in /-- The canonical algebraic closure of a field, the direct limit of adding roots to the field for each polynomial over the field. -/ @[stacks 09GT] def AlgebraicClosure : Type u := MvPolynomial (Vars k) k ⧸ maxIdeal k namespace AlgebraicClosure instance instCommRing : CommRing (AlgebraicClosure k) := Ideal.Quotient.commRing _ instance instInhabited : Inhabited (AlgebraicClosure k) := ⟨37⟩ instance {S : Type*} [DistribSMul S k] [IsScalarTower S k k] : SMul S (AlgebraicClosure k) := Submodule.Quotient.instSMul' _ instance instAlgebra {R : Type*} [CommSemiring R] [Algebra R k] : Algebra R (AlgebraicClosure k) := Ideal.Quotient.algebra _ instance {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S] [Algebra S k] [Algebra R k] [IsScalarTower R S k] : IsScalarTower R S (AlgebraicClosure k) := Ideal.Quotient.isScalarTower _ _ _ instance instGroupWithZero : GroupWithZero (AlgebraicClosure k) where __ := Ideal.Quotient.field _ instance instField : Field (AlgebraicClosure k) where __ := instCommRing _ __ := instGroupWithZero _ nnqsmul := (· • ·) qsmul := (· • ·) nnratCast q := algebraMap k _ q ratCast q := algebraMap k _ q nnratCast_def q := by change algebraMap k _ _ = _; simp_rw [NNRat.cast_def, map_div₀, map_natCast] ratCast_def q := by change algebraMap k _ _ = _; rw [Rat.cast_def, map_div₀, map_intCast, map_natCast] nnqsmul_def q x := Quotient.inductionOn x fun p ↦ congr_arg Quotient.mk'' <| by ext; simp [MvPolynomial.algebraMap_eq, NNRat.smul_def] qsmul_def q x := Quotient.inductionOn x fun p ↦ congr_arg Quotient.mk'' <| by ext; simp [MvPolynomial.algebraMap_eq, Rat.smul_def] theorem Monics.map_eq_prod {f : Monics k} : f.1.map (algebraMap k (AlgebraicClosure k)) = ∏ i, map (Ideal.Quotient.mk <| maxIdeal k) (X - C (MvPolynomial.X ⟨f, i⟩)) := by ext dsimp [AlgebraicClosure] rw [← Ideal.Quotient.mk_comp_algebraMap, ← map_map, ← Polynomial.map_prod, ← sub_eq_zero, ← coeff_sub, ← Polynomial.map_sub, ← subProdXSubC, coeff_map, Ideal.Quotient.eq_zero_iff_mem] refine le_maxIdeal _ (Ideal.subset_span ⟨⟨f, _⟩, rfl⟩) instance isAlgebraic : Algebra.IsAlgebraic k (AlgebraicClosure k) := ⟨fun z => IsIntegral.isAlgebraic <| by let ⟨p, hp⟩ := Ideal.Quotient.mk_surjective z rw [← hp] induction p using MvPolynomial.induction_on generalizing z with | C => exact isIntegral_algebraMap | add _ _ ha hb => exact (ha _ rfl).add (hb _ rfl) | mul_X p fi ih => rw [map_mul] refine (ih _ rfl).mul ⟨_, fi.1.2, ?_⟩ simp_rw [← eval_map, Monics.map_eq_prod, eval_prod, Polynomial.map_sub, eval_sub] apply Finset.prod_eq_zero (Finset.mem_univ fi.2) rw [map_C] -- The `erw` is needed here because the `R` in `eval` is `AlgebraicClosure k`, -- but this has been unfolded in the arguments of `eval`. erw [eval_C] simp⟩ instance : IsAlgClosure k (AlgebraicClosure k) := .of_splits fun f hf _ ↦ by rw [show f = (⟨f, hf⟩ : Monics k) from rfl, ← splits_id_iff_splits, Monics.map_eq_prod] exact splits_prod _ fun _ _ ↦ (splits_id_iff_splits _).mpr (splits_X_sub_C _) instance isAlgClosed : IsAlgClosed (AlgebraicClosure k) := IsAlgClosure.isAlgClosed k instance [CharZero k] : CharZero (AlgebraicClosure k) := charZero_of_injective_algebraMap (RingHom.injective (algebraMap k (AlgebraicClosure k))) instance {p : ℕ} [CharP k p] : CharP (AlgebraicClosure k) p := charP_of_injective_algebraMap (RingHom.injective (algebraMap k (AlgebraicClosure k))) p instance {L : Type*} [Field k] [Field L] [Algebra k L] [Algebra.IsAlgebraic k L] : IsAlgClosure k (AlgebraicClosure L) where isAlgebraic := .trans k L _ isAlgClosed := inferInstance end AlgebraicClosure namespace IntermediateField variable {K L : Type*} [Field K] [Field L] [Algebra K L] (E : IntermediateField K L) instance [Algebra.IsAlgebraic K E] : IsAlgClosure K (AlgebraicClosure E) := ⟨AlgebraicClosure.isAlgClosed E, Algebra.IsAlgebraic.trans K E (AlgebraicClosure E)⟩ theorem AdjoinSimple.normal_algebraicClosure {x : L} (hx : IsIntegral K x) : Normal K (AlgebraicClosure K⟮x⟯) := have : Algebra.IsAlgebraic K K⟮x⟯ := isAlgebraic_adjoin_simple hx IsAlgClosure.normal _ _ theorem AdjoinDouble.normal_algebraicClosure {x y : L} (hx : IsIntegral K x) (hy : IsIntegral K y) : Normal K (AlgebraicClosure K⟮x, y⟯) := have : Algebra.IsAlgebraic K K⟮x, y⟯ := isAlgebraic_adjoin_pair hx hy IsAlgClosure.normal _ _ end IntermediateField
.lake/packages/mathlib/Mathlib/FieldTheory/IsAlgClosed/Basic.lean
import Mathlib.FieldTheory.Extension import Mathlib.FieldTheory.Normal.Defs import Mathlib.FieldTheory.Perfect import Mathlib.RingTheory.Localization.Integral /-! # Algebraically Closed Field In this file we define the typeclass for algebraically closed fields and algebraic closures, and prove some of their properties. ## Main Definitions - `IsAlgClosed k` is the typeclass saying `k` is an algebraically closed field, i.e. every polynomial in `k` splits. - `IsAlgClosure R K` is the typeclass saying `K` is an algebraic closure of `R`, where `R` is a commutative ring. This means that the map from `R` to `K` is injective, and `K` is algebraically closed and algebraic over `R` - `IsAlgClosed.lift` is a map from an algebraic extension `L` of `R`, into any algebraically closed extension of `R`. - `IsAlgClosure.equiv` is a proof that any two algebraic closures of the same field are isomorphic. ## Tags algebraic closure, algebraically closed ## Main results - `IsAlgClosure.of_splits`: if `K / k` is algebraic, and every monic irreducible polynomial over `k` splits in `K`, then `K` is algebraically closed (in fact an algebraic closure of `k`). For the stronger fact that only requires every such polynomial has a root in `K`, see `IsAlgClosure.of_exist_roots`. Reference: <https://kconrad.math.uconn.edu/blurbs/galoistheory/algclosure.pdf>, Theorem 2 -/ universe u v w open Polynomial variable (k : Type u) [Field k] /-- Typeclass for algebraically closed fields. To show `Polynomial.Splits p f` for an arbitrary ring homomorphism `f`, see `IsAlgClosed.splits_codomain` and `IsAlgClosed.splits_domain`. -/ @[stacks 09GR "The definition of `IsAlgClosed` in mathlib is 09GR (4)"] class IsAlgClosed : Prop where factors : ∀ p : k[X], p.Factors /-- Every polynomial splits in the field extension `f : K →+* k` if `k` is algebraically closed. See also `IsAlgClosed.splits_domain` for the case where `K` is algebraically closed. -/ theorem IsAlgClosed.splits_codomain {k K : Type*} [Field k] [IsAlgClosed k] [CommRing K] {f : K →+* k} (p : K[X]) : p.Splits f := IsAlgClosed.factors (p.map f) /-- Every polynomial splits in the field extension `f : K →+* k` if `K` is algebraically closed. See also `IsAlgClosed.splits_codomain` for the case where `k` is algebraically closed. -/ theorem IsAlgClosed.splits_domain {k K : Type*} [Field k] [IsAlgClosed k] [Field K] {f : k →+* K} (p : k[X]) : p.Splits f := (IsAlgClosed.factors p).map f namespace IsAlgClosed variable {k} theorem splits [IsAlgClosed k] (p : k[X]) : p.Splits (RingHom.id k) := (IsAlgClosed.factors p).map (RingHom.id k) /-- If `k` is algebraically closed, then every nonconstant polynomial has a root. -/ @[stacks 09GR "(4) ⟹ (3)"] theorem exists_root [IsAlgClosed k] (p : k[X]) (hp : p.degree ≠ 0) : ∃ x, IsRoot p x := exists_root_of_splits _ (IsAlgClosed.splits p) hp theorem exists_pow_nat_eq [IsAlgClosed k] (x : k) {n : ℕ} (hn : 0 < n) : ∃ z, z ^ n = x := by have : degree (X ^ n - C x) ≠ 0 := by rw [degree_X_pow_sub_C hn x] exact ne_of_gt (WithBot.coe_lt_coe.2 hn) obtain ⟨z, hz⟩ := exists_root (X ^ n - C x) this use z simp only [eval_C, eval_X, eval_pow, eval_sub, IsRoot.def] at hz exact sub_eq_zero.1 hz theorem exists_eq_mul_self [IsAlgClosed k] (x : k) : ∃ z, x = z * z := by rcases exists_pow_nat_eq x zero_lt_two with ⟨z, rfl⟩ exact ⟨z, sq z⟩ theorem roots_eq_zero_iff [IsAlgClosed k] {p : k[X]} : p.roots = 0 ↔ p = Polynomial.C (p.coeff 0) := by refine ⟨fun h => ?_, fun hp => by rw [hp, roots_C]⟩ rcases le_or_gt (degree p) 0 with hd | hd · exact eq_C_of_degree_le_zero hd · obtain ⟨z, hz⟩ := IsAlgClosed.exists_root p hd.ne' rw [← mem_roots (ne_zero_of_degree_gt hd), h] at hz simp at hz theorem roots_eq_zero_iff_natDegree_eq_zero [IsAlgClosed k] {p : k[X]} : p.roots = 0 ↔ p.natDegree = 0 := roots_eq_zero_iff.trans eq_C_coeff_zero_iff_natDegree_eq_zero theorem roots_eq_zero_iff_degree_nonpos [IsAlgClosed k] {p : k[X]} : p.roots = 0 ↔ p.degree ≤ 0 := roots_eq_zero_iff_natDegree_eq_zero.trans natDegree_eq_zero_iff_degree_le_zero theorem card_roots_eq_natDegree [IsAlgClosed k] {p : k[X]} : p.roots.card = p.natDegree := by have ⟨_, _, hdeg, hroots⟩ := exists_prod_multiset_X_sub_C_mul p simp [← hdeg, roots_eq_zero_iff_natDegree_eq_zero.mp hroots] theorem card_roots_map_eq_natDegree_of_leadingCoeff_ne_zero {A B : Type*} [Semiring A] [Field B] [IsAlgClosed B] {f : A →+* B} {p : A[X]} (hf : f p.leadingCoeff ≠ 0) : (p.map f).roots.card = p.natDegree := natDegree_map_of_leadingCoeff_ne_zero _ hf ▸ card_roots_eq_natDegree theorem card_roots_map_eq_natDegree_of_isUnit_leadingCoeff {A B : Type*} [Semiring A] [Field B] [IsAlgClosed B] (f : A →+* B) {p : A[X]} (h : IsUnit p.leadingCoeff) : (p.map f).roots.card = p.natDegree := natDegree_map_eq_of_isUnit_leadingCoeff f h ▸ card_roots_eq_natDegree theorem card_roots_map_eq_natDegree_of_injective {A B : Type*} [Semiring A] [Field B] [IsAlgClosed B] {f : A →+* B} (p : A[X]) (hf : Function.Injective f) : (p.map f).roots.card = p.natDegree := natDegree_map_eq_of_injective hf _ ▸ card_roots_eq_natDegree theorem card_roots_map_eq_natDegree_from_simpleRing {A B : Type*} [Ring A] [IsSimpleRing A] [Field B] [IsAlgClosed B] (f : A →+* B) (p : A[X]) : (p.map f).roots.card = p.natDegree := natDegree_map f ▸ card_roots_eq_natDegree theorem card_aroots_eq_natDegree_of_leadingCoeff_ne_zero {A B : Type*} [CommRing A] [Field B] [IsAlgClosed B] [Algebra A B] {p : A[X]} (hf : algebraMap A B p.leadingCoeff ≠ 0) : (p.aroots B).card = p.natDegree := card_roots_map_eq_natDegree_of_leadingCoeff_ne_zero hf theorem card_aroots_eq_natDegree_of_isUnit_leadingCoeff {A B : Type*} [CommRing A] [Field B] [IsAlgClosed B] [Algebra A B] {p : A[X]} (h : IsUnit p.leadingCoeff) : (p.aroots B).card = p.natDegree := card_roots_map_eq_natDegree_of_isUnit_leadingCoeff _ h theorem card_aroots_eq_natDegree {A B : Type*} [CommRing A] [Field B] [IsAlgClosed B] [Algebra A B] [FaithfulSMul A B] {p : A[X]} : (p.aroots B).card = p.natDegree := card_roots_map_eq_natDegree_of_injective _ <| FaithfulSMul.algebraMap_injective _ _ theorem dvd_iff_roots_le_roots [IsAlgClosed k] {p q : k[X]} (hp : p ≠ 0) (hq : q ≠ 0) : p ∣ q ↔ p.roots ≤ q.roots := Splits.dvd_iff_roots_le_roots (splits _) hp hq theorem associated_iff_roots_eq_roots [IsAlgClosed k] {p q : k[X]} (hp : p ≠ 0) (hq : q ≠ 0) : Associated p q ↔ p.roots = q.roots := ⟨Associated.roots_eq, fun h ↦ associated_of_dvd_dvd (dvd_iff_roots_le_roots hp hq |>.mpr <| le_of_eq h) (dvd_iff_roots_le_roots hq hp |>.mpr <| le_of_eq h.symm)⟩ theorem exists_eval₂_eq_zero_of_injective {R : Type*} [Semiring R] [IsAlgClosed k] (f : R →+* k) (hf : Function.Injective f) (p : R[X]) (hp : p.degree ≠ 0) : ∃ x, p.eval₂ f x = 0 := let ⟨x, hx⟩ := exists_root (p.map f) (by rwa [degree_map_eq_of_injective hf]) ⟨x, by rwa [eval₂_eq_eval_map, ← IsRoot]⟩ theorem exists_eval₂_eq_zero {R : Type*} [Ring R] [IsSimpleRing R] [IsAlgClosed k] (f : R →+* k) (p : R[X]) (hp : p.degree ≠ 0) : ∃ x, p.eval₂ f x = 0 := exists_eval₂_eq_zero_of_injective _ f.injective _ hp variable (k) theorem exists_aeval_eq_zero_of_injective {R : Type*} [CommSemiring R] [IsAlgClosed k] [Algebra R k] (hinj : Function.Injective (algebraMap R k)) (p : R[X]) (hp : p.degree ≠ 0) : ∃ x : k, aeval x p = 0 := exists_eval₂_eq_zero_of_injective (algebraMap R k) hinj p hp theorem exists_aeval_eq_zero {R : Type*} [CommSemiring R] [IsAlgClosed k] [Algebra R k] [FaithfulSMul R k] (p : R[X]) (hp : p.degree ≠ 0) : ∃ x : k, p.aeval x = 0 := exists_aeval_eq_zero_of_injective _ (FaithfulSMul.algebraMap_injective ..) _ hp /-- If every nonconstant polynomial over `k` has a root, then `k` is algebraically closed. -/ @[stacks 09GR "(3) ⟹ (4)"] theorem of_exists_root (H : ∀ p : k[X], p.Monic → Irreducible p → ∃ x, p.eval x = 0) : IsAlgClosed k := by refine ⟨fun p ↦ factors_iff_splits.mpr <| Or.inr ?_⟩ intro q hq _ have : Irreducible (q * C (leadingCoeff q)⁻¹) := by classical rw [← coe_normUnit_of_ne_zero hq.ne_zero] exact (associated_normalize _).irreducible hq obtain ⟨x, hx⟩ := H (q * C (leadingCoeff q)⁻¹) (monic_mul_leadingCoeff_inv hq.ne_zero) this exact degree_mul_leadingCoeff_inv q hq.ne_zero ▸ degree_eq_one_of_irreducible_of_root this hx theorem of_ringEquiv (k' : Type u) [Field k'] (e : k ≃+* k') [IsAlgClosed k] : IsAlgClosed k' := by apply IsAlgClosed.of_exists_root intro p hmp hp have hpe : degree (p.map e.symm.toRingHom) ≠ 0 := by rw [degree_map] exact ne_of_gt (degree_pos_of_irreducible hp) rcases IsAlgClosed.exists_root (k := k) (p.map e.symm.toRingHom) hpe with ⟨x, hx⟩ use e x rw [IsRoot] at hx apply e.symm.injective rw [map_zero, ← hx] clear hx hpe hp hmp induction p using Polynomial.induction_on <;> simp_all /-- If `k` is algebraically closed, then every irreducible polynomial over `k` is linear. -/ @[stacks 09GR "(4) ⟹ (2)"] theorem degree_eq_one_of_irreducible [IsAlgClosed k] {p : k[X]} (hp : Irreducible p) : p.degree = 1 := degree_eq_one_of_irreducible_of_splits hp (IsAlgClosed.splits_codomain _) theorem algebraMap_bijective_of_isIntegral {k K : Type*} [Field k] [Ring K] [IsDomain K] [hk : IsAlgClosed k] [Algebra k K] [Algebra.IsIntegral k K] : Function.Bijective (algebraMap k K) := by refine ⟨RingHom.injective _, fun x ↦ ⟨-(minpoly k x).coeff 0, ?_⟩⟩ have hq : (minpoly k x).leadingCoeff = 1 := minpoly.monic (Algebra.IsIntegral.isIntegral x) have h : (minpoly k x).degree = 1 := degree_eq_one_of_irreducible k (minpoly.irreducible (Algebra.IsIntegral.isIntegral x)) have : aeval x (minpoly k x) = 0 := minpoly.aeval k x rw [eq_X_add_C_of_degree_eq_one h, hq, C_1, one_mul, aeval_add, aeval_X, aeval_C, add_eq_zero_iff_eq_neg] at this exact (RingHom.map_neg (algebraMap k K) ((minpoly k x).coeff 0)).symm ▸ this.symm theorem ringHom_bijective_of_isIntegral {k K : Type*} [Field k] [CommRing K] [IsDomain K] [IsAlgClosed k] (f : k →+* K) (hf : f.IsIntegral) : Function.Bijective f := let _ : Algebra k K := f.toAlgebra have : Algebra.IsIntegral k K := ⟨hf⟩ algebraMap_bijective_of_isIntegral end IsAlgClosed /-- If `k` is algebraically closed, `K / k` is a field extension, `L / k` is an intermediate field which is algebraic, then `L` is equal to `k`. A corollary of `IsAlgClosed.algebraMap_surjective_of_isAlgebraic`. -/ @[stacks 09GQ "The result is the definition of algebraically closedness in Stacks Project. \ This statement is 09GR (4) ⟹ (1)."] theorem IntermediateField.eq_bot_of_isAlgClosed_of_isAlgebraic {k K : Type*} [Field k] [Field K] [IsAlgClosed k] [Algebra k K] (L : IntermediateField k K) [Algebra.IsAlgebraic k L] : L = ⊥ := bot_unique fun x hx ↦ by obtain ⟨y, hy⟩ := (IsAlgClosed.algebraMap_bijective_of_isIntegral (k := k)).2 (⟨x, hx⟩ : L) exact ⟨y, congr_arg (algebraMap L K) hy⟩ lemma Polynomial.isCoprime_iff_aeval_ne_zero_of_isAlgClosed (K : Type v) [Field K] [IsAlgClosed K] [Algebra k K] (p q : k[X]) : IsCoprime p q ↔ ∀ a : K, aeval a p ≠ 0 ∨ aeval a q ≠ 0 := by refine ⟨fun h => aeval_ne_zero_of_isCoprime h, fun h => isCoprime_of_dvd _ _ ?_ fun x hu h0 => ?_⟩ · replace h := h 0 contrapose! h rw [h.left, h.right, map_zero, and_self] · rintro ⟨_, rfl⟩ ⟨_, rfl⟩ obtain ⟨a, ha : _ = _⟩ := IsAlgClosed.exists_root (x.map <| algebraMap k K) <| by simpa only [degree_map] using (ne_of_lt <| degree_pos_of_ne_zero_of_nonunit h0 hu).symm exact not_and_or.mpr (h a) (by simp_rw [map_mul, ← eval_map_algebraMap, ha, zero_mul, true_and]) /-- Typeclass for an extension being an algebraic closure. -/ @[stacks 09GS] class IsAlgClosure (R : Type u) (K : Type v) [CommRing R] [Field K] [Algebra R K] [NoZeroSMulDivisors R K] : Prop where isAlgClosed : IsAlgClosed K isAlgebraic : Algebra.IsAlgebraic R K attribute [instance] IsAlgClosure.isAlgebraic theorem isAlgClosure_iff (K : Type v) [Field K] [Algebra k K] : IsAlgClosure k K ↔ IsAlgClosed K ∧ Algebra.IsAlgebraic k K := ⟨fun h => ⟨h.1, h.2⟩, fun h => ⟨h.1, h.2⟩⟩ instance (priority := 100) IsAlgClosure.normal (R K : Type*) [Field R] [Field K] [Algebra R K] [IsAlgClosure R K] : Normal R K where toIsAlgebraic := IsAlgClosure.isAlgebraic splits' _ := @IsAlgClosed.splits_codomain _ _ _ (IsAlgClosure.isAlgClosed R) _ _ _ instance (priority := 100) IsAlgClosure.separable (R K : Type*) [Field R] [Field K] [Algebra R K] [IsAlgClosure R K] [CharZero R] : Algebra.IsSeparable R K := ⟨fun _ => (minpoly.irreducible (Algebra.IsIntegral.isIntegral _)).separable⟩ instance IsAlgClosed.instIsAlgClosure (F : Type*) [Field F] [IsAlgClosed F] : IsAlgClosure F F where isAlgClosed := ‹_› isAlgebraic := .of_finite F F theorem IsAlgClosure.of_splits {R K} [CommRing R] [IsDomain R] [Field K] [Algebra R K] [Algebra.IsIntegral R K] [NoZeroSMulDivisors R K] (h : ∀ p : R[X], p.Monic → Irreducible p → p.Splits (algebraMap R K)) : IsAlgClosure R K where isAlgebraic := inferInstance isAlgClosed := .of_exists_root _ fun _p _ p_irred ↦ have ⟨g, monic, irred, dvd⟩ := p_irred.exists_dvd_monic_irreducible_of_isIntegral (K := R) exists_root_of_splits _ (splits_of_splits_of_dvd _ (map_monic_ne_zero monic) ((splits_id_iff_splits _).mpr <| h g monic irred) dvd) <| degree_ne_of_natDegree_ne p_irred.natDegree_pos.ne' namespace IsAlgClosed variable {K : Type u} [Field K] {L : Type v} {M : Type w} [Field L] [Algebra K L] [Field M] [Algebra K M] [IsAlgClosed M] /-- If E/L/K is a tower of field extensions with E/L algebraic, and if M is an algebraically closed extension of K, then any embedding of L/K into M/K extends to an embedding of E/K. Known as the extension lemma in https://math.stackexchange.com/a/687914. -/ theorem surjective_restrictDomain_of_isAlgebraic {E : Type*} [Field E] [Algebra K E] [Algebra L E] [IsScalarTower K L E] [Algebra.IsAlgebraic L E] : Function.Surjective fun φ : E →ₐ[K] M ↦ φ.restrictDomain L := fun f ↦ IntermediateField.exists_algHom_of_splits' (E := E) f fun s ↦ ⟨Algebra.IsIntegral.isIntegral s, IsAlgClosed.splits_codomain _⟩ variable [Algebra.IsAlgebraic K L] (K L M) /-- Less general version of `lift`. -/ private noncomputable irreducible_def liftAux : L →ₐ[K] M := Classical.choice <| IntermediateField.nonempty_algHom_of_adjoin_splits (fun x _ ↦ ⟨Algebra.IsIntegral.isIntegral x, splits_codomain (minpoly K x)⟩) (IntermediateField.adjoin_univ K L) variable {R : Type u} [CommRing R] variable {S : Type v} [CommRing S] [IsDomain S] [Algebra R S] [Algebra R M] [NoZeroSMulDivisors R S] [NoZeroSMulDivisors R M] [Algebra.IsAlgebraic R S] variable {M} private instance FractionRing.isAlgebraic : letI : IsDomain R := (FaithfulSMul.algebraMap_injective R S).isDomain _ letI : Algebra (FractionRing R) (FractionRing S) := FractionRing.liftAlgebra R _ Algebra.IsAlgebraic (FractionRing R) (FractionRing S) := by letI : IsDomain R := (FaithfulSMul.algebraMap_injective R S).isDomain _ letI : Algebra (FractionRing R) (FractionRing S) := FractionRing.liftAlgebra R _ have := FractionRing.isScalarTower_liftAlgebra R (FractionRing S) have := (IsFractionRing.isAlgebraic_iff' R S (FractionRing S)).1 inferInstance constructor intro exact (IsFractionRing.isAlgebraic_iff R (FractionRing R) (FractionRing S)).1 (Algebra.IsAlgebraic.isAlgebraic _) /-- A (random) homomorphism from an algebraic extension of R into an algebraically closed extension of R. -/ @[stacks 09GU] noncomputable irreducible_def lift : S →ₐ[R] M := by letI : IsDomain R := (FaithfulSMul.algebraMap_injective R S).isDomain _ letI := FractionRing.liftAlgebra R M letI := FractionRing.liftAlgebra R (FractionRing S) have := FractionRing.isScalarTower_liftAlgebra R M have := FractionRing.isScalarTower_liftAlgebra R (FractionRing S) let f : FractionRing S →ₐ[FractionRing R] M := liftAux (FractionRing R) (FractionRing S) M exact (f.restrictScalars R).comp ((Algebra.ofId S (FractionRing S)).restrictScalars R) theorem nonempty_algEquiv_or_of_finrank_eq_two {F F' : Type*} (E : Type*) [Field F] [Field F'] [Field E] [Algebra F F'] [Algebra F E] [Algebra.IsAlgebraic F E] [IsAlgClosed F'] (h : Module.finrank F F' = 2) : Nonempty (E ≃ₐ[F] F) ∨ Nonempty (E ≃ₐ[F] F') := by have emb : E →ₐ[F] F' := lift have e := AlgEquiv.ofInjectiveField emb have := Subalgebra.isSimpleOrder_of_finrank h obtain h | h := IsSimpleOrder.eq_bot_or_eq_top emb.range <;> rw [h] at e exacts [.inl ⟨e.trans <| Algebra.botEquiv ..⟩, .inr ⟨e.trans Subalgebra.topEquiv⟩] noncomputable instance (priority := 100) perfectRing (p : ℕ) [Fact p.Prime] [CharP k p] [IsAlgClosed k] : PerfectRing k p := PerfectRing.ofSurjective k p fun _ => IsAlgClosed.exists_pow_nat_eq _ <| NeZero.pos p noncomputable instance (priority := 100) perfectField [IsAlgClosed k] : PerfectField k := by obtain _ | ⟨p, _, _⟩ := CharP.exists' k exacts [.ofCharZero, PerfectRing.toPerfectField k p] /-- Algebraically closed fields are infinite since `Xⁿ⁺¹ - 1` is separable when `#K = n` -/ instance (priority := 500) {K : Type*} [Field K] [IsAlgClosed K] : Infinite K := by apply Infinite.of_not_fintype intro hfin set n := Fintype.card K set f := (X : K[X]) ^ (n + 1) - 1 have hfsep : Separable f := separable_X_pow_sub_C 1 (by simp [n]) one_ne_zero apply Nat.not_succ_le_self (Fintype.card K) have hroot : n.succ = Fintype.card (f.rootSet K) := by rw [card_rootSet_eq_natDegree hfsep (IsAlgClosed.splits_domain _)] unfold f rw [← C_1, natDegree_X_pow_sub_C] rw [hroot] exact Fintype.card_le_of_injective _ Subtype.coe_injective end IsAlgClosed namespace IsAlgClosure section variable (R : Type u) [CommRing R] (L : Type v) (M : Type w) [Field L] [Field M] variable [Algebra R M] [NoZeroSMulDivisors R M] [IsAlgClosure R M] variable [Algebra R L] [NoZeroSMulDivisors R L] [IsAlgClosure R L] attribute [local instance] IsAlgClosure.isAlgClosed in /-- A (random) isomorphism between two algebraic closures of `R`. -/ @[stacks 09GV] noncomputable def equiv : L ≃ₐ[R] M := AlgEquiv.ofBijective _ (IsAlgClosure.isAlgebraic.algHom_bijective₂ (IsAlgClosed.lift : L →ₐ[R] M) (IsAlgClosed.lift : M →ₐ[R] L)).1 end variable (K : Type*) (J : Type*) (R : Type u) (S : Type*) (L : Type v) (M : Type w) [Field K] [Field J] [CommRing R] [CommRing S] [Field L] [Field M] [Algebra R M] [NoZeroSMulDivisors R M] [IsAlgClosure R M] [Algebra K M] [IsAlgClosure K M] [Algebra S L] [NoZeroSMulDivisors S L] [IsAlgClosure S L] section EquivOfAlgebraic variable [Algebra R S] [Algebra R L] [IsScalarTower R S L] variable [Algebra K J] [Algebra J L] [IsAlgClosure J L] [Algebra K L] [IsScalarTower K J L] /-- If `J` is an algebraic extension of `K` and `L` is an algebraic closure of `J`, then it is also an algebraic closure of `K`. -/ theorem ofAlgebraic [Algebra.IsAlgebraic K J] : IsAlgClosure K L := ⟨IsAlgClosure.isAlgClosed J, .trans K J L⟩ /-- A (random) isomorphism between an algebraic closure of `R` and an algebraic closure of an algebraic extension of `R` -/ noncomputable def equivOfAlgebraic' [Nontrivial S] [NoZeroSMulDivisors R S] [Algebra.IsAlgebraic R L] : L ≃ₐ[R] M := by have : NoZeroSMulDivisors R L := NoZeroSMulDivisors.trans_faithfulSMul R S L have : IsAlgClosure R L := { isAlgClosed := IsAlgClosure.isAlgClosed S isAlgebraic := ‹_› } exact IsAlgClosure.equiv _ _ _ /-- A (random) isomorphism between an algebraic closure of `K` and an algebraic closure of an algebraic extension of `K` -/ noncomputable def equivOfAlgebraic [Algebra.IsAlgebraic K J] : L ≃ₐ[K] M := have := Algebra.IsAlgebraic.trans K J L equivOfAlgebraic' K J _ _ end EquivOfAlgebraic section EquivOfEquiv variable {R S} /-- Used in the definition of `equivOfEquiv` -/ noncomputable def equivOfEquivAux (hSR : S ≃+* R) : { e : L ≃+* M // e.toRingHom.comp (algebraMap S L) = (algebraMap R M).comp hSR.toRingHom } := by letI : Algebra R S := RingHom.toAlgebra hSR.symm.toRingHom letI : Algebra S R := RingHom.toAlgebra hSR.toRingHom have : IsDomain S := (FaithfulSMul.algebraMap_injective S L).isDomain _ letI : Algebra R L := RingHom.toAlgebra ((algebraMap S L).comp (algebraMap R S)) haveI : IsScalarTower R S L := .of_algebraMap_eq fun _ => rfl haveI : IsScalarTower S R L := .of_algebraMap_eq (by simp [RingHom.algebraMap_toAlgebra]) have : FaithfulSMul R S := (faithfulSMul_iff_algebraMap_injective R S).mpr hSR.symm.injective have : Algebra.IsAlgebraic R L := (IsAlgClosure.isAlgebraic.extendScalars (show Function.Injective (algebraMap S R) from hSR.injective)) refine ⟨equivOfAlgebraic' R S L M, ?_⟩ ext x simp only [RingEquiv.toRingHom_eq_coe, Function.comp_apply, RingHom.coe_comp, AlgEquiv.coe_ringEquiv, RingEquiv.coe_toRingHom] conv_lhs => rw [← hSR.symm_apply_apply x] change equivOfAlgebraic' R S L M (algebraMap R L (hSR x)) = _ rw [AlgEquiv.commutes] /-- Algebraic closure of isomorphic fields are isomorphic -/ noncomputable def equivOfEquiv (hSR : S ≃+* R) : L ≃+* M := equivOfEquivAux L M hSR @[simp] theorem equivOfEquiv_comp_algebraMap (hSR : S ≃+* R) : (↑(equivOfEquiv L M hSR) : L →+* M).comp (algebraMap S L) = (algebraMap R M).comp hSR := (equivOfEquivAux L M hSR).2 @[simp] theorem equivOfEquiv_algebraMap (hSR : S ≃+* R) (s : S) : equivOfEquiv L M hSR (algebraMap S L s) = algebraMap R M (hSR s) := RingHom.ext_iff.1 (equivOfEquiv_comp_algebraMap L M hSR) s @[simp] theorem equivOfEquiv_symm_algebraMap (hSR : S ≃+* R) (r : R) : (equivOfEquiv L M hSR).symm (algebraMap R M r) = algebraMap S L (hSR.symm r) := (equivOfEquiv L M hSR).injective (by simp) @[simp] theorem equivOfEquiv_symm_comp_algebraMap (hSR : S ≃+* R) : ((equivOfEquiv L M hSR).symm : M →+* L).comp (algebraMap R M) = (algebraMap S L).comp hSR.symm := RingHom.ext_iff.2 (equivOfEquiv_symm_algebraMap L M hSR) end EquivOfEquiv end IsAlgClosure section Algebra.IsAlgebraic variable {F K : Type*} (A : Type*) [Field F] [Field K] [Field A] [Algebra F K] [Algebra F A] [Algebra.IsAlgebraic F K] /-- Let `A` be an algebraically closed field and let `x ∈ K`, with `K/F` an algebraic extension of fields. Then the images of `x` by the `F`-algebra morphisms from `K` to `A` are exactly the roots in `A` of the minimal polynomial of `x` over `F`. -/ theorem Algebra.IsAlgebraic.range_eval_eq_rootSet_minpoly [IsAlgClosed A] (x : K) : (Set.range fun ψ : K →ₐ[F] A ↦ ψ x) = (minpoly F x).rootSet A := range_eval_eq_rootSet_minpoly_of_splits A (fun _ ↦ IsAlgClosed.splits_codomain _) x /-- All `F`-embeddings of a field `K` into another field `A` factor through any intermediate field of `A/F` in which the minimal polynomial of elements of `K` splits. -/ @[simps] def IntermediateField.algHomEquivAlgHomOfSplits (L : IntermediateField F A) (hL : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) : (K →ₐ[F] L) ≃ (K →ₐ[F] A) where toFun := L.val.comp invFun f := f.codRestrict _ fun x ↦ ((Algebra.IsIntegral.isIntegral x).map f).mem_intermediateField_of_minpoly_splits <| by rw [minpoly.algHom_eq f f.injective]; exact hL x theorem IntermediateField.algHomEquivAlgHomOfSplits_apply_apply (L : IntermediateField F A) (hL : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) (f : K →ₐ[F] L) (x : K) : algHomEquivAlgHomOfSplits A L hL f x = algebraMap L A (f x) := rfl /-- All `F`-embeddings of a field `K` into another field `A` factor through any subextension of `A/F` in which the minimal polynomial of elements of `K` splits. -/ noncomputable def Algebra.IsAlgebraic.algHomEquivAlgHomOfSplits (L : Type*) [Field L] [Algebra F L] [Algebra L A] [IsScalarTower F L A] (hL : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) : (K →ₐ[F] L) ≃ (K →ₐ[F] A) := (AlgEquiv.refl.arrowCongr (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F L A))).trans <| IntermediateField.algHomEquivAlgHomOfSplits A (IsScalarTower.toAlgHom F L A).fieldRange fun x ↦ splits_of_algHom (hL x) (AlgHom.rangeRestrict _) theorem Algebra.IsAlgebraic.algHomEquivAlgHomOfSplits_apply_apply (L : Type*) [Field L] [Algebra F L] [Algebra L A] [IsScalarTower F L A] (hL : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) (f : K →ₐ[F] L) (x : K) : Algebra.IsAlgebraic.algHomEquivAlgHomOfSplits A L hL f x = algebraMap L A (f x) := rfl end Algebra.IsAlgebraic /-- Over an algebraically closed field of characteristic zero a necessary and sufficient condition for the set of roots of a nonzero polynomial `f` to be a subset of the set of roots of `g` is that `f` divides `f.derivative * g`. Over an integral domain, this is a sufficient but not necessary condition. See `isRoot_of_isRoot_of_dvd_derivative_mul` -/ theorem Polynomial.isRoot_of_isRoot_iff_dvd_derivative_mul {K : Type*} [Field K] [IsAlgClosed K] [CharZero K] {f g : K[X]} (hf0 : f ≠ 0) : (∀ x, IsRoot f x → IsRoot g x) ↔ f ∣ f.derivative * g := by refine ⟨?_, isRoot_of_isRoot_of_dvd_derivative_mul hf0⟩ by_cases hg0 : g = 0 · simp [hg0] by_cases hdf0 : derivative f = 0 · rw [eq_C_of_derivative_eq_zero hdf0] simp only [derivative_C, zero_mul, dvd_zero, implies_true] have hdg : f.derivative * g ≠ 0 := mul_ne_zero hdf0 hg0 classical rw [IsAlgClosed.dvd_iff_roots_le_roots hf0 hdg, Multiset.le_iff_count] simp only [count_roots, rootMultiplicity_mul hdg] refine forall_imp fun a => ?_ by_cases haf : f.eval a = 0 · have h0 : 0 < f.rootMultiplicity a := (rootMultiplicity_pos hf0).2 haf rw [derivative_rootMultiplicity_of_root haf] intro h calc rootMultiplicity a f = rootMultiplicity a f - 1 + 1 := (Nat.sub_add_cancel (Nat.succ_le_iff.1 h0)).symm _ ≤ rootMultiplicity a f - 1 + rootMultiplicity a g := add_le_add le_rfl (Nat.succ_le_iff.1 ((rootMultiplicity_pos hg0).2 (h haf))) · simp [haf, rootMultiplicity_eq_zero haf]
.lake/packages/mathlib/Mathlib/FieldTheory/IsAlgClosed/Spectrum.lean
import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum import Mathlib.FieldTheory.IsAlgClosed.Basic /-! # Spectrum mapping theorem This file develops proves the spectral mapping theorem for polynomials over algebraically closed fields. In particular, if `a` is an element of a `𝕜`-algebra `A` where `𝕜` is a field, and `p : 𝕜[X]` is a polynomial, then the spectrum of `Polynomial.aeval a p` contains the image of the spectrum of `a` under `(fun k ↦ Polynomial.eval k p)`. When `𝕜` is algebraically closed, these are in fact equal (assuming either that the spectrum of `a` is nonempty or the polynomial has positive degree), which is the **spectral mapping theorem**. In addition, this file contains the fact that every element of a finite-dimensional nontrivial algebra over an algebraically closed field has nonempty spectrum. In particular, this is used in `Module.End.exists_eigenvalue` to show that every linear map from a vector space to itself has an eigenvalue. ## Main statements * `spectrum.subset_polynomial_aeval`, `spectrum.map_polynomial_aeval_of_degree_pos`, `spectrum.map_polynomial_aeval_of_nonempty`: variations on the **spectral mapping theorem**. * `spectrum.nonempty_of_isAlgClosed_of_finiteDimensional`: the spectrum is nonempty for any element of a nontrivial finite-dimensional algebra over an algebraically closed field. ## Notation * `σ a` : `spectrum R a` of `a : A` -/ namespace spectrum open Set Polynomial open scoped Pointwise Polynomial universe u v section ScalarRing variable {R : Type u} {A : Type v} variable [CommRing R] [Ring A] [Algebra R A] local notation "σ" => spectrum R local notation "↑ₐ" => algebraMap R A theorem exists_mem_of_not_isUnit_aeval_prod [IsDomain R] {p : R[X]} {a : A} (h : ¬IsUnit (aeval a (Multiset.map (fun x : R => X - C x) p.roots).prod)) : ∃ k : R, k ∈ σ a ∧ eval k p = 0 := by rw [← Multiset.prod_toList, map_list_prod] at h replace h := mt List.prod_isUnit h simp only [not_forall, exists_prop, aeval_C, Multiset.mem_toList, List.mem_map, aeval_X, exists_exists_and_eq_and, Multiset.mem_map, map_sub] at h rcases h with ⟨r, r_mem, r_nu⟩ exact ⟨r, by rwa [mem_iff, ← IsUnit.sub_iff], (mem_roots'.1 r_mem).2⟩ end ScalarRing section ScalarField variable {𝕜 : Type u} {A : Type v} variable [Field 𝕜] [Ring A] [Algebra 𝕜 A] local notation "σ" => spectrum 𝕜 local notation "↑ₐ" => algebraMap 𝕜 A open Polynomial /-- Half of the spectral mapping theorem for polynomials. We prove it separately because it holds over any field, whereas `spectrum.map_polynomial_aeval_of_degree_pos` and `spectrum.map_polynomial_aeval_of_nonempty` need the field to be algebraically closed. -/ theorem subset_polynomial_aeval (a : A) (p : 𝕜[X]) : (eval · p) '' σ a ⊆ σ (aeval a p) := by rintro _ ⟨k, hk, rfl⟩ let q := C (eval k p) - p have hroot : IsRoot q k := by simp only [q, eval_C, eval_sub, sub_self, IsRoot.def] rw [← mul_div_eq_iff_isRoot, ← neg_mul_neg, neg_sub] at hroot have aeval_q_eq : ↑ₐ (eval k p) - aeval a p = aeval a q := by simp only [q, aeval_C, map_sub] rw [mem_iff, aeval_q_eq, ← hroot, aeval_mul] have hcomm := (Commute.all (C k - X) (-(q / (X - C k)))).map (aeval a : 𝕜[X] →ₐ[𝕜] A) apply mt fun h => (hcomm.isUnit_mul_iff.mp h).1 simpa only [aeval_X, aeval_C, map_sub] using hk /-- The *spectral mapping theorem* for polynomials. Note: the assumption `degree p > 0` is necessary in case `σ a = ∅`, for then the left-hand side is `∅` and the right-hand side, assuming `[Nontrivial A]`, is `{k}` where `p = Polynomial.C k`. -/ theorem map_polynomial_aeval_of_degree_pos [IsAlgClosed 𝕜] (a : A) (p : 𝕜[X]) (hdeg : 0 < degree p) : σ (aeval a p) = (eval · p) '' σ a := by -- handle the easy direction via `spectrum.subset_polynomial_aeval` refine Set.eq_of_subset_of_subset (fun k hk => ?_) (subset_polynomial_aeval a p) -- write `C k - p` product of linear factors and a constant; show `C k - p ≠ 0`. have hprod := eq_prod_roots_of_splits_id (IsAlgClosed.splits (C k - p)) have h_ne : C k - p ≠ 0 := ne_zero_of_degree_gt <| by rwa [degree_sub_eq_right_of_degree_lt (lt_of_le_of_lt degree_C_le hdeg)] have lead_ne := leadingCoeff_ne_zero.mpr h_ne have lead_unit := (Units.map ↑ₐ.toMonoidHom (Units.mk0 _ lead_ne)).isUnit /- leading coefficient is a unit so product of linear factors is not a unit; apply `exists_mem_of_not_is_unit_aeval_prod`. -/ have p_a_eq : aeval a (C k - p) = ↑ₐ k - aeval a p := by simp only [aeval_C, map_sub] rw [mem_iff, ← p_a_eq, hprod, aeval_mul, ((Commute.all _ _).map (aeval a : 𝕜[X] →ₐ[𝕜] A)).isUnit_mul_iff, aeval_C] at hk replace hk := exists_mem_of_not_isUnit_aeval_prod (not_and.mp hk lead_unit) rcases hk with ⟨r, r_mem, r_ev⟩ exact ⟨r, r_mem, symm (by simpa [eval_sub, eval_C, sub_eq_zero] using r_ev)⟩ /-- In this version of the spectral mapping theorem, we assume the spectrum is nonempty instead of assuming the degree of the polynomial is positive. -/ theorem map_polynomial_aeval_of_nonempty [IsAlgClosed 𝕜] (a : A) (p : 𝕜[X]) (hnon : (σ a).Nonempty) : σ (aeval a p) = (fun k => eval k p) '' σ a := by nontriviality A refine Or.elim (le_or_gt (degree p) 0) (fun h => ?_) (map_polynomial_aeval_of_degree_pos a p) rw [eq_C_of_degree_le_zero h] simp only [eval_C, aeval_C, scalar_eq, Set.Nonempty.image_const hnon] /-- A specialization of `spectrum.subset_polynomial_aeval` to monic monomials for convenience. -/ theorem pow_image_subset (a : A) (n : ℕ) : (fun x => x ^ n) '' σ a ⊆ σ (a ^ n) := by simpa only [eval_X_pow, aeval_X_pow] using subset_polynomial_aeval a (X ^ n : 𝕜[X]) theorem pow_mem_pow (a : A) (n : ℕ) {k : 𝕜} (hk : k ∈ σ a) : k ^ n ∈ σ (a ^ n) := pow_image_subset a n ⟨k, ⟨hk, rfl⟩⟩ /-- A specialization of `spectrum.map_polynomial_aeval_of_nonempty` to monic monomials for convenience. -/ theorem map_pow_of_pos [IsAlgClosed 𝕜] (a : A) {n : ℕ} (hn : 0 < n) : σ (a ^ n) = (· ^ n) '' σ a := by simpa only [aeval_X_pow, eval_X_pow] using map_polynomial_aeval_of_degree_pos a (X ^ n : 𝕜[X]) (by rwa [degree_X_pow, Nat.cast_pos]) /-- A specialization of `spectrum.map_polynomial_aeval_of_nonempty` to monic monomials for convenience. -/ theorem map_pow_of_nonempty [IsAlgClosed 𝕜] {a : A} (ha : (σ a).Nonempty) (n : ℕ) : σ (a ^ n) = (· ^ n) '' σ a := by simpa only [aeval_X_pow, eval_X_pow] using map_polynomial_aeval_of_nonempty a (X ^ n) ha variable (𝕜) -- We will use this both to show eigenvalues exist, and to prove Schur's lemma. /-- Every element `a` in a nontrivial finite-dimensional algebra `A` over an algebraically closed field `𝕜` has non-empty spectrum. -/ theorem nonempty_of_isAlgClosed_of_finiteDimensional [IsAlgClosed 𝕜] [Nontrivial A] [I : FiniteDimensional 𝕜 A] (a : A) : (σ a).Nonempty := by obtain ⟨p, ⟨h_mon, h_eval_p⟩⟩ := isIntegral_of_noetherian (IsNoetherian.iff_fg.2 I) a have nu : ¬IsUnit (aeval a p) := by rw [← aeval_def] at h_eval_p; rw [h_eval_p]; simp rw [eq_prod_roots_of_monic_of_splits_id h_mon (IsAlgClosed.splits p)] at nu obtain ⟨k, hk, _⟩ := exists_mem_of_not_isUnit_aeval_prod nu exact ⟨k, hk⟩ end ScalarField end spectrum open Polynomial in theorem IsIdempotentElem.spectrum_subset (𝕜 : Type*) {A : Type*} [Field 𝕜] [Ring A] [Algebra 𝕜 A] {p : A} (hp : IsIdempotentElem p) : spectrum 𝕜 p ⊆ {0, 1} := by nontriviality A apply Set.image_subset_iff.mp (spectrum.subset_polynomial_aeval p (X ^ 2 - X)) |>.trans refine fun a ha => eq_zero_or_one_of_sq_eq_self ?_ simpa [pow_two p, hp.eq, sub_eq_zero] using ha open Unitization in theorem IsIdempotentElem.quasispectrum_subset {𝕜 A : Type*} [Field 𝕜] [NonUnitalRing A] [Module 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A] {p : A} (hp : IsIdempotentElem p) : quasispectrum 𝕜 p ⊆ {0, 1} := quasispectrum_eq_spectrum_inr' 𝕜 𝕜 p ▸ (hp.inr _ |>.spectrum_subset _)
.lake/packages/mathlib/Mathlib/FieldTheory/Minpoly/MinpolyDiv.lean
import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed import Mathlib.FieldTheory.PrimitiveElement import Mathlib.FieldTheory.IsAlgClosed.Basic /-! # Results about `minpoly R x / (X - C x)` ## Main definition - `minpolyDiv`: The polynomial `minpoly R x / (X - C x)`. We used the contents of this file to describe the dual basis of a powerbasis under the trace form. See `traceForm_dualBasis_powerBasis_eq`. ## Main results - `span_coeff_minpolyDiv`: The coefficients of `minpolyDiv` spans `R<x>`. -/ open Polynomial Module variable (R K) {L S} [CommRing R] [Field K] [Field L] [CommRing S] [Algebra R S] [Algebra K L] variable (x : S) /-- `minpolyDiv R x : S[X]` for `x : S` is the polynomial `minpoly R x / (X - C x)`. -/ noncomputable def minpolyDiv : S[X] := (minpoly R x).map (algebraMap R S) /ₘ (X - C x) lemma minpolyDiv_spec : minpolyDiv R x * (X - C x) = (minpoly R x).map (algebraMap R S) := by delta minpolyDiv rw [mul_comm, mul_divByMonic_eq_iff_isRoot, IsRoot, eval_map, ← aeval_def, minpoly.aeval] lemma coeff_minpolyDiv (i) : coeff (minpolyDiv R x) i = algebraMap R S (coeff (minpoly R x) (i + 1)) + coeff (minpolyDiv R x) (i + 1) * x := by rw [← coeff_map, ← minpolyDiv_spec R x]; simp [mul_sub] variable {R x} lemma minpolyDiv_eq_zero (hx : ¬IsIntegral R x) : minpolyDiv R x = 0 := by delta minpolyDiv minpoly rw [dif_neg hx, Polynomial.map_zero, zero_divByMonic] lemma eval_minpolyDiv_self : (minpolyDiv R x).eval x = aeval x (derivative <| minpoly R x) := by rw [aeval_def, ← eval_map, ← derivative_map, ← minpolyDiv_spec R x]; simp lemma minpolyDiv_eval_eq_zero_of_ne_of_aeval_eq_zero [IsDomain S] {y} (hxy : y ≠ x) (hy : aeval y (minpoly R x) = 0) : (minpolyDiv R x).eval y = 0 := by rw [aeval_def, ← eval_map, ← minpolyDiv_spec R x] at hy simp only [eval_mul, eval_sub, eval_X, eval_C, mul_eq_zero] at hy exact hy.resolve_right (by rwa [sub_eq_zero]) lemma eval₂_minpolyDiv_of_eval₂_eq_zero {T} [CommRing T] [IsDomain T] [DecidableEq T] {x y} (σ : S →+* T) (hy : eval₂ (σ.comp (algebraMap R S)) y (minpoly R x) = 0) : eval₂ σ y (minpolyDiv R x) = if σ x = y then σ (aeval x (derivative <| minpoly R x)) else 0 := by split_ifs with h · rw [← h, eval₂_hom, eval_minpolyDiv_self] · rw [← eval₂_map, ← minpolyDiv_spec] at hy simpa [sub_eq_zero, Ne.symm h] using hy lemma eval₂_minpolyDiv_self {T} [CommRing T] [Algebra R T] [IsDomain T] [DecidableEq T] (x : S) (σ₁ σ₂ : S →ₐ[R] T) : eval₂ σ₁ (σ₂ x) (minpolyDiv R x) = if σ₁ x = σ₂ x then σ₁ (aeval x (derivative <| minpoly R x)) else 0 := by apply eval₂_minpolyDiv_of_eval₂_eq_zero rw [AlgHom.comp_algebraMap, ← σ₂.comp_algebraMap, ← eval₂_map, ← RingHom.coe_coe, eval₂_hom, eval_map, ← aeval_def, minpoly.aeval, map_zero] lemma eval_minpolyDiv_of_aeval_eq_zero [IsDomain S] [DecidableEq S] {y} (hy : aeval y (minpoly R x) = 0) : (minpolyDiv R x).eval y = if x = y then aeval x (derivative <| minpoly R x) else 0 := by rw [eval, eval₂_minpolyDiv_of_eval₂_eq_zero, RingHom.id_apply, RingHom.id_apply] simpa [aeval_def] using hy lemma coeff_minpolyDiv_mem_adjoin (x : S) (i) : coeff (minpolyDiv R x) i ∈ Algebra.adjoin R {x} := by by_contra H have : ∀ j, coeff (minpolyDiv R x) (i + j) ∉ Algebra.adjoin R {x} := by intro j; induction j with | zero => exact H | succ j IH => intro H; apply IH rw [coeff_minpolyDiv] refine add_mem ?_ (mul_mem H (Algebra.self_mem_adjoin_singleton R x)) exact Subalgebra.algebraMap_mem _ _ apply this (natDegree (minpolyDiv R x) + 1) rw [coeff_eq_zero_of_natDegree_lt] · exact zero_mem _ · cutsat section IsIntegral variable (hx : IsIntegral R x) include hx lemma minpolyDiv_ne_zero [Nontrivial S] : minpolyDiv R x ≠ 0 := by intro e have := minpolyDiv_spec R x rw [e, zero_mul] at this exact ((minpoly.monic hx).map (algebraMap R S)).ne_zero this.symm lemma minpolyDiv_monic : Monic (minpolyDiv R x) := by nontriviality S have := congr_arg leadingCoeff (minpolyDiv_spec R x) rw [leadingCoeff_mul', ((minpoly.monic hx).map (algebraMap R S)).leadingCoeff] at this · simpa using this · simpa using minpolyDiv_ne_zero hx lemma natDegree_minpolyDiv_succ [Nontrivial S] : natDegree (minpolyDiv R x) + 1 = natDegree (minpoly R x) := by rw [← (minpoly.monic hx).natDegree_map (algebraMap R S), ← minpolyDiv_spec, natDegree_mul'] · simp · simpa using minpolyDiv_ne_zero hx lemma natDegree_minpolyDiv_lt [Nontrivial S] : natDegree (minpolyDiv R x) < natDegree (minpoly R x) := by rw [← natDegree_minpolyDiv_succ hx] exact Nat.lt_succ_self _ lemma minpolyDiv_eq_of_isIntegrallyClosed [IsDomain R] [IsIntegrallyClosed R] [IsDomain S] [Algebra R K] [Algebra K S] [IsScalarTower R K S] [IsFractionRing R K] : minpolyDiv R x = minpolyDiv K x := by delta minpolyDiv rw [IsScalarTower.algebraMap_eq R K S, ← map_map, ← minpoly.isIntegrallyClosed_eq_field_fractions' _ hx] lemma coeff_minpolyDiv_sub_pow_mem_span {i} (hi : i ≤ natDegree (minpolyDiv R x)) : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) - x ^ i ∈ Submodule.span R ((x ^ ·) '' Set.Iio i) := by induction i with | zero => simp [(minpolyDiv_monic hx).leadingCoeff] | succ i IH => rw [coeff_minpolyDiv, add_sub_assoc, pow_succ, ← sub_mul, Algebra.algebraMap_eq_smul_one] refine add_mem ?_ ?_ · apply Submodule.smul_mem apply Submodule.subset_span exact ⟨0, Nat.zero_lt_succ _, pow_zero _⟩ · rw [← tsub_tsub, tsub_add_cancel_of_le (le_tsub_of_add_le_left (b := 1) hi)] apply SetLike.le_def.mp ?_ (Submodule.mul_mem_mul (IH ((Nat.le_succ _).trans hi)) (Submodule.mem_span_singleton_self x)) rw [Submodule.span_mul_span, Set.mul_singleton, Set.image_image] apply Submodule.span_mono rintro _ ⟨j, hj, rfl⟩ rw [Set.mem_Iio] at hj exact ⟨j + 1, Nat.add_lt_of_lt_sub hj, pow_succ x j⟩ lemma span_coeff_minpolyDiv : Submodule.span R (Set.range (coeff (minpolyDiv R x))) = Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by nontriviality S classical apply le_antisymm · rw [Submodule.span_le] rintro _ ⟨i, rfl⟩ apply coeff_minpolyDiv_mem_adjoin · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _), Submodule.span_le] simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff] intro i induction i using Nat.strongRecOn with | ind i hi => ?_ intro hi' have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x))) := Submodule.subset_span (Set.mem_range_self _) rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this] refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_) · rw [Submodule.span_le, Set.image_subset_iff] intro j (hj : j < i) exact hi j hj (lt_trans hj hi') · rwa [← natDegree_minpolyDiv_succ hx, Set.mem_Iio, Nat.lt_succ_iff] at hi' end IsIntegral lemma natDegree_minpolyDiv : natDegree (minpolyDiv R x) = natDegree (minpoly R x) - 1 := by nontriviality S by_cases hx : IsIntegral R x · rw [← natDegree_minpolyDiv_succ hx]; rfl · rw [minpolyDiv_eq_zero hx, minpoly.eq_zero hx]; rfl section PowerBasis variable {K} lemma sum_smul_minpolyDiv_eq_X_pow (E) [Field E] [Algebra K E] [IsAlgClosed E] [FiniteDimensional K L] [Algebra.IsSeparable K L] {x : L} (hxL : Algebra.adjoin K {x} = ⊤) {r : ℕ} (hr : r < finrank K L) : ∑ σ : L →ₐ[K] E, ((x ^ r / aeval x (derivative <| minpoly K x)) • minpolyDiv K x).map σ = (X ^ r : E[X]) := by classical rw [← sub_eq_zero] have : Function.Injective (fun σ : L →ₐ[K] E ↦ σ x) := fun _ _ h => AlgHom.ext_of_adjoin_eq_top hxL (fun _ hx ↦ hx ▸ h) apply Polynomial.eq_zero_of_natDegree_lt_card_of_eval_eq_zero _ this · intro σ simp only [Polynomial.map_smul, map_div₀, map_pow, RingHom.coe_coe, eval_sub, eval_finset_sum, eval_smul, eval_map, eval₂_minpolyDiv_self, this.eq_iff, smul_eq_mul, mul_ite, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true, eval_X_pow] rw [sub_eq_zero, div_mul_cancel₀] rw [ne_eq, map_eq_zero_iff σ σ.toRingHom.injective] exact (Algebra.IsSeparable.isSeparable _ _).aeval_derivative_ne_zero (minpoly.aeval _ _) · refine (Polynomial.natDegree_sub_le _ _).trans_lt (max_lt ((Polynomial.natDegree_sum_le _ _).trans_lt ?_) ?_) · simp only [Polynomial.map_smul, map_div₀, map_pow, RingHom.coe_coe, Function.comp_apply, Finset.mem_univ, forall_true_left, Finset.fold_max_lt, AlgHom.card] refine ⟨finrank_pos, ?_⟩ intro σ exact ((Polynomial.natDegree_smul_le _ _).trans natDegree_map_le).trans_lt ((natDegree_minpolyDiv_lt (Algebra.IsIntegral.isIntegral x)).trans_le (minpoly.natDegree_le _)) · rwa [natDegree_pow, natDegree_X, mul_one, AlgHom.card] end PowerBasis
.lake/packages/mathlib/Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean
import Mathlib.RingTheory.AdjoinRoot import Mathlib.FieldTheory.Minpoly.Field import Mathlib.RingTheory.Polynomial.GaussLemma /-! # Minimal polynomials over a GCD monoid This file specializes the theory of minpoly to the case of an algebra over a GCD monoid. ## Main results * `minpoly.isIntegrallyClosed_eq_field_fractions`: For integrally closed domains, the minimal polynomial over the ring is the same as the minimal polynomial over the fraction field. * `minpoly.isIntegrallyClosed_dvd`: For integrally closed domains, the minimal polynomial divides any primitive polynomial that has the integral element as root. * `IsIntegrallyClosed.Minpoly.unique`: The minimal polynomial of an element `x` is uniquely characterized by its defining property: if there is another monic polynomial of minimal degree that has `x` as a root, then this polynomial is equal to the minimal polynomial of `x`. -/ open Polynomial Set Function minpoly namespace minpoly variable {R S : Type*} [CommRing R] [CommRing S] [IsDomain R] [Algebra R S] section variable (K L : Type*) [Field K] [Algebra R K] [IsFractionRing R K] [CommRing L] [Nontrivial L] [Algebra R L] [Algebra S L] [Algebra K L] [IsScalarTower R K L] [IsScalarTower R S L] variable [IsIntegrallyClosed R] /-- For integrally closed domains, the minimal polynomial over the ring is the same as the minimal polynomial over the fraction field. See `minpoly.isIntegrallyClosed_eq_field_fractions'` if `S` is already a `K`-algebra. -/ theorem isIntegrallyClosed_eq_field_fractions [IsDomain S] {s : S} (hs : IsIntegral R s) : minpoly K (algebraMap S L s) = (minpoly R s).map (algebraMap R K) := by refine (eq_of_irreducible_of_monic ?_ ?_ ?_).symm · exact ((monic hs).irreducible_iff_irreducible_map_fraction_map).1 (irreducible hs) · rw [aeval_map_algebraMap, aeval_algebraMap_apply, aeval, map_zero] · exact (monic hs).map _ /-- For integrally closed domains, the minimal polynomial over the ring is the same as the minimal polynomial over the fraction field. Compared to `minpoly.isIntegrallyClosed_eq_field_fractions`, this version is useful if the element is in a ring that is already a `K`-algebra. -/ theorem isIntegrallyClosed_eq_field_fractions' [IsDomain S] [Algebra K S] [IsScalarTower R K S] {s : S} (hs : IsIntegral R s) : minpoly K s = (minpoly R s).map (algebraMap R K) := by let L := FractionRing S rw [← isIntegrallyClosed_eq_field_fractions K L hs, algebraMap_eq (IsFractionRing.injective S L)] end variable [IsDomain S] [NoZeroSMulDivisors R S] variable [IsIntegrallyClosed R] /-- For integrally closed rings, the minimal polynomial divides any polynomial that has the integral element as root. See also `minpoly.dvd` which relaxes the assumptions on `S` in exchange for stronger assumptions on `R`. -/ theorem isIntegrallyClosed_dvd {s : S} (hs : IsIntegral R s) {p : R[X]} (hp : Polynomial.aeval s p = 0) : minpoly R s ∣ p := by let K := FractionRing R let L := FractionRing S let _ : Algebra K L := FractionRing.liftAlgebra R L have : minpoly K (algebraMap S L s) ∣ map (algebraMap R K) (p %ₘ minpoly R s) := by rw [map_modByMonic _ (minpoly.monic hs), modByMonic_eq_sub_mul_div] · refine dvd_sub (minpoly.dvd K (algebraMap S L s) ?_) ?_ · rw [← map_aeval_eq_aeval_map, hp, map_zero] rw [← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq] apply dvd_mul_of_dvd_left rw [isIntegrallyClosed_eq_field_fractions K L hs] exact Monic.map _ (minpoly.monic hs) rw [isIntegrallyClosed_eq_field_fractions _ _ hs, map_dvd_map (algebraMap R K) (IsFractionRing.injective R K) (minpoly.monic hs)] at this rw [← modByMonic_eq_zero_iff_dvd (minpoly.monic hs)] exact Polynomial.eq_zero_of_dvd_of_degree_lt this (degree_modByMonic_lt p <| minpoly.monic hs) theorem isIntegrallyClosed_dvd_iff {s : S} (hs : IsIntegral R s) (p : R[X]) : Polynomial.aeval s p = 0 ↔ minpoly R s ∣ p := ⟨fun hp => isIntegrallyClosed_dvd hs hp, fun hp => by simpa only [RingHom.mem_ker, RingHom.coe_comp, coe_evalRingHom, coe_mapRingHom, Function.comp_apply, eval_map, ← aeval_def] using aeval_eq_zero_of_dvd_aeval_eq_zero hp (minpoly.aeval R s)⟩ theorem ker_eval {s : S} (hs : IsIntegral R s) : RingHom.ker ((Polynomial.aeval s).toRingHom : R[X] →+* S) = Ideal.span ({minpoly R s} : Set R[X]) := by ext p simp_rw [RingHom.mem_ker, AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, isIntegrallyClosed_dvd_iff hs, ← Ideal.mem_span_singleton] /-- If an element `x` is a root of a nonzero polynomial `p`, then the degree of `p` is at least the degree of the minimal polynomial of `x`. See also `minpoly.degree_le_of_ne_zero` which relaxes the assumptions on `S` in exchange for stronger assumptions on `R`. -/ theorem IsIntegrallyClosed.degree_le_of_ne_zero {s : S} {p : R[X]} (hp0 : p ≠ 0) (hp : Polynomial.aeval s p = 0) : degree (minpoly R s) ≤ degree p := by by_cases! hs : ¬IsIntegral R s · simp [minpoly, hs] rw [degree_eq_natDegree (minpoly.ne_zero hs), degree_eq_natDegree hp0] norm_cast exact natDegree_le_of_dvd ((isIntegrallyClosed_dvd_iff hs _).mp hp) hp0 /-- The minimal polynomial of an element `x` is uniquely characterized by its defining property: if there is another monic polynomial of minimal degree that has `x` as a root, then this polynomial is equal to the minimal polynomial of `x`. See also `minpoly.unique` which relaxes the assumptions on `S` in exchange for stronger assumptions on `R`. -/ theorem _root_.IsIntegrallyClosed.minpoly.unique {s : S} {P : R[X]} (hmo : P.Monic) (hP : Polynomial.aeval s P = 0) (Pmin : ∀ Q : R[X], Q.Monic → Polynomial.aeval s Q = 0 → degree P ≤ degree Q) : P = minpoly R s := by have hs : IsIntegral R s := ⟨P, hmo, hP⟩ symm; apply eq_of_sub_eq_zero by_contra hnz refine IsIntegrallyClosed.degree_le_of_ne_zero (s := s) hnz (by simp [hP]) |>.not_gt ?_ refine degree_sub_lt ?_ (ne_zero hs) ?_ · exact le_antisymm (min R s hmo hP) (Pmin (minpoly R s) (monic hs) (aeval R s)) · rw [(monic hs).leadingCoeff, hmo.leadingCoeff] theorem IsIntegrallyClosed.unique_of_degree_le_degree_minpoly {s : S} {p : R[X]} (hmo : p.Monic) (hp : p.aeval s = 0) (pmin : p.degree ≤ (minpoly R s).degree) : p = minpoly R s := IsIntegrallyClosed.minpoly.unique hmo hp fun _ qm hq ↦ pmin.trans <| min _ _ qm hq theorem IsIntegrallyClosed.isIntegral_iff_leadingCoeff_dvd {s : S} {p : R[X]} (hp : p.aeval s = 0) (h₀ : p ≠ 0) (pmin : ∀ q : R[X], q.Monic → q.aeval s = 0 → p.degree ≤ q.degree) : IsIntegral R s ↔ C p.leadingCoeff ∣ p := by refine ⟨fun hInt ↦ ?_, fun ⟨q, hMul⟩ ↦ minpoly.ne_zero_iff.mp ?_⟩ · use minpoly R s have ⟨q, hMul⟩ := isIntegrallyClosed_dvd hInt hp suffices q.degree ≤ 0 by simp [degree_le_zero_iff.mp this ▸ hMul, minpoly.monic hInt, mul_comm] apply WithBot.le_of_add_le_add_left <| Polynomial.degree_ne_bot.mpr <| minpoly.ne_zero hInt convert pmin _ (minpoly.monic hInt) (minpoly.aeval ..) · rw [hMul, degree_mul] · rw [add_zero] · convert right_ne_zero_of_mul <| hMul ▸ h₀ refine IsIntegrallyClosed.minpoly.unique ?_ ?_ ?_ |>.symm · have := hMul ▸ leadingCoeff_mul .. |>.symm simp only [leadingCoeff_C, ne_eq, leadingCoeff_eq_zero, h₀, not_false_eq_true, mul_eq_left₀] at this exact this · have := congrArg (Polynomial.aeval s) hMul simp only [hp, h₀, map_mul, aeval_C, zero_eq_mul, FaithfulSMul.algebraMap_eq_zero_iff, leadingCoeff_eq_zero, false_or] at this exact this · exact (hMul ▸ degree_C_mul <| by simp [h₀]) ▸ pmin theorem prime_of_isIntegrallyClosed {x : S} (hx : IsIntegral R x) : Prime (minpoly R x) := by refine ⟨(minpoly.monic hx).ne_zero, ⟨fun h_contra => (ne_of_lt (minpoly.degree_pos hx)) (degree_eq_zero_of_isUnit h_contra).symm, fun a b h => or_iff_not_imp_left.mpr fun h' => ?_⟩⟩ rw [← minpoly.isIntegrallyClosed_dvd_iff hx] at h' h ⊢ rw [aeval_mul] at h exact eq_zero_of_ne_zero_of_mul_left_eq_zero h' h noncomputable section AdjoinRoot open Algebra Polynomial AdjoinRoot variable {x : S} theorem ToAdjoin.injective (hx : IsIntegral R x) : Function.Injective (Minpoly.toAdjoin R x) := by refine (injective_iff_map_eq_zero _).2 fun P₁ hP₁ => ?_ obtain ⟨P, rfl⟩ := mk_surjective P₁ simpa [← Subalgebra.coe_eq_zero, isIntegrallyClosed_dvd_iff hx, ← aeval_def] using hP₁ /-- The algebra isomorphism `AdjoinRoot (minpoly R x) ≃ₐ[R] adjoin R x` -/ def equivAdjoin (hx : IsIntegral R x) : AdjoinRoot (minpoly R x) ≃ₐ[R] adjoin R ({x} : Set S) := AlgEquiv.ofBijective (Minpoly.toAdjoin R x) ⟨minpoly.ToAdjoin.injective hx, Minpoly.toAdjoin.surjective R x⟩ @[simp] theorem equivAdjoin_toAlgHom (hx : IsIntegral R x) : equivAdjoin hx = Minpoly.toAdjoin R x := rfl @[simp] theorem coe_equivAdjoin (hx : IsIntegral R x) : ⇑(equivAdjoin hx) = Minpoly.toAdjoin R x := rfl @[deprecated (since := "2025-07-21")] alias equivAdjoin_apply := coe_equivAdjoin /-- The `PowerBasis` of `adjoin R {x}` given by `x`. See `Algebra.adjoin.powerBasis` for a version over a field. -/ def _root_.Algebra.adjoin.powerBasis' (hx : IsIntegral R x) : PowerBasis R (Algebra.adjoin R ({x} : Set S)) := PowerBasis.map (AdjoinRoot.powerBasis' (minpoly.monic hx)) (minpoly.equivAdjoin hx) @[simp] theorem _root_.Algebra.adjoin.powerBasis'_dim (hx : IsIntegral R x) : (Algebra.adjoin.powerBasis' hx).dim = (minpoly R x).natDegree := rfl @[simp] theorem _root_.Algebra.adjoin.powerBasis'_gen (hx : IsIntegral R x) : (adjoin.powerBasis' hx).gen = ⟨x, SetLike.mem_coe.1 <| subset_adjoin <| mem_singleton x⟩ := by rw [Algebra.adjoin.powerBasis', PowerBasis.map_gen, AdjoinRoot.powerBasis'_gen, equivAdjoin, AlgEquiv.ofBijective_apply, Minpoly.toAdjoin, liftAlgHom_root] /-- If `x` generates `S` over `R` and is integral over `R`, then it defines a power basis. See `PowerBasis.ofAdjoinEqTop` for a version over a field. -/ noncomputable def _root_.PowerBasis.ofAdjoinEqTop' {x : S} (hx : IsIntegral R x) (hx' : adjoin R {x} = ⊤) : PowerBasis R S := (adjoin.powerBasis' hx).map ((Subalgebra.equivOfEq _ _ hx').trans Subalgebra.topEquiv) example {x : S} (B : PowerBasis R S) (hint : IsIntegral R x) (hx : B.gen ∈ Algebra.adjoin R {x}) : PowerBasis R S := by apply PowerBasis.ofAdjoinEqTop' hint exact PowerBasis.adjoin_eq_top_of_gen_mem_adjoin hx @[deprecated "Use in combination with `PowerBasis.adjoin_eq_top_of_gen_mem_adjoin` to recover the \ deprecated definition" (since := "2025-09-28")] alias _root_.PowerBasis.ofGenMemAdjoin' := _root_.PowerBasis.ofAdjoinEqTop' @[simp] theorem _root_.PowerBasis.ofAdjoinEqTop'_dim {x : S} (hx : IsIntegral R x) (hx' : adjoin R {x} = ⊤) : (PowerBasis.ofAdjoinEqTop' hx hx').dim = (minpoly R x).natDegree := rfl @[simp] theorem _root_.PowerBasis.ofAdjoinEqTop'_gen {x : S} (hx : IsIntegral R x) (hx' : adjoin R {x} = ⊤) : (PowerBasis.ofAdjoinEqTop' hx hx').gen = x := by simp [PowerBasis.ofAdjoinEqTop'] @[deprecated "Use in combination with `PowerBasis.adjoin_eq_top_of_gen_mem_adjoin` to recover the \ deprecated definition" (since := "2025-09-28")] alias _root_.PowerBasis.ofGenMemAdjoin'_dim := _root_.PowerBasis.ofAdjoinEqTop'_dim @[deprecated "Use in combination with `PowerBasis.adjoin_eq_top_of_gen_mem_adjoin` to recover the \ deprecated definition" (since := "2025-09-28")] alias _root_.PowerBasis.ofGenMemAdjoin'_gen := _root_.PowerBasis.ofAdjoinEqTop'_gen end AdjoinRoot section Subring variable {K L : Type*} [Field K] [Field L] [Algebra K L] variable (A : Subring K) [IsIntegrallyClosed A] [IsFractionRing A K] -- Implementation note: `inferInstance` does not work for these. instance : Algebra A (integralClosure A L) := Subalgebra.algebra (integralClosure A L) instance : SMul A (integralClosure A L) := Algebra.toSMul instance : IsScalarTower A ((integralClosure A L)) L := IsScalarTower.subalgebra' A L L (integralClosure A L) /-- The minimal polynomial of `x : L` over `K` agrees with its minimal polynomial over the integrally closed subring `A`. -/ theorem ofSubring (x : integralClosure A L) : Polynomial.map (algebraMap A K) (minpoly A x) = minpoly K (x : L) := eq_comm.mpr (isIntegrallyClosed_eq_field_fractions K L (IsIntegralClosure.isIntegral A L x)) end Subring end minpoly
.lake/packages/mathlib/Mathlib/FieldTheory/Minpoly/Basic.lean
import Mathlib.RingTheory.IntegralClosure.IsIntegral.Basic /-! # Minimal polynomials This file defines the minimal polynomial of an element `x` of an `A`-algebra `B`, under the assumption that x is integral over `A`, and derives some basic properties such as irreducibility under the assumption `B` is a domain. -/ open Polynomial Set Function variable {A B B' : Type*} section MinPolyDef variable (A) [CommRing A] [Ring B] [Algebra A B] open scoped Classical in /-- Suppose `x : B`, where `B` is an `A`-algebra. The minimal polynomial `minpoly A x` of `x` is a monic polynomial with coefficients in `A` of smallest degree that has `x` as its root, if such exists (`IsIntegral A x`) or zero otherwise. For example, if `V` is a `𝕜`-vector space for some field `𝕜` and `f : V →ₗ[𝕜] V` then the minimal polynomial of `f` is `minpoly 𝕜 f`. -/ @[stacks 09GM] noncomputable def minpoly (x : B) : A[X] := if hx : IsIntegral A x then degree_lt_wf.min _ hx else 0 end MinPolyDef namespace minpoly section Ring variable [CommRing A] [Ring B] [Ring B'] [Algebra A B] [Algebra A B'] variable {x : B} /-- A minimal polynomial is monic. -/ theorem monic (hx : IsIntegral A x) : Monic (minpoly A x) := by delta minpoly rw [dif_pos hx] exact (degree_lt_wf.min_mem _ hx).1 /-- A minimal polynomial is nonzero. -/ theorem ne_zero [Nontrivial A] (hx : IsIntegral A x) : minpoly A x ≠ 0 := (monic hx).ne_zero theorem eq_zero (hx : ¬IsIntegral A x) : minpoly A x = 0 := dif_neg hx theorem ne_zero_iff [Nontrivial A] : minpoly A x ≠ 0 ↔ IsIntegral A x := ⟨fun h => of_not_not <| eq_zero.mt h, ne_zero⟩ theorem algHom_eq (f : B →ₐ[A] B') (hf : Function.Injective f) (x : B) : minpoly A (f x) = minpoly A x := by classical simp_rw [minpoly, isIntegral_algHom_iff _ hf, ← Polynomial.aeval_def, aeval_algHom, AlgHom.comp_apply, _root_.map_eq_zero_iff f hf] theorem algebraMap_eq {B} [CommRing B] [Algebra A B] [Algebra B B'] [IsScalarTower A B B'] (h : Function.Injective (algebraMap B B')) (x : B) : minpoly A (algebraMap B B' x) = minpoly A x := algHom_eq (IsScalarTower.toAlgHom A B B') h x @[simp] theorem algEquiv_eq (f : B ≃ₐ[A] B') (x : B) : minpoly A (f x) = minpoly A x := algHom_eq (f : B →ₐ[A] B') f.injective x variable (A x) /-- An element is a root of its minimal polynomial. -/ @[simp] theorem aeval : aeval x (minpoly A x) = 0 := by delta minpoly split_ifs with hx · exact (degree_lt_wf.min_mem _ hx).2 · exact aeval_zero _ /-- Given any `f : B →ₐ[A] B'` and any `x : L`, the minimal polynomial of `x` vanishes at `f x`. -/ @[simp] theorem aeval_algHom (f : B →ₐ[A] B') (x : B) : (Polynomial.aeval (f x)) (minpoly A x) = 0 := by rw [Polynomial.aeval_algHom, AlgHom.coe_comp, comp_apply, aeval, map_zero] /-- A minimal polynomial is not `1`. -/ theorem ne_one [Nontrivial B] : minpoly A x ≠ 1 := by intro h refine (one_ne_zero : (1 : B) ≠ 0) ?_ simpa using congr_arg (Polynomial.aeval x) h theorem map_ne_one [Nontrivial B] {R : Type*} [Semiring R] [Nontrivial R] (f : A →+* R) : (minpoly A x).map f ≠ 1 := by by_cases hx : IsIntegral A x · exact mt ((monic hx).eq_one_of_map_eq_one f) (ne_one A x) · rw [eq_zero hx, Polynomial.map_zero] exact zero_ne_one /-- A minimal polynomial is not a unit. -/ theorem not_isUnit [Nontrivial B] : ¬IsUnit (minpoly A x) := by haveI : Nontrivial A := (algebraMap A B).domain_nontrivial by_cases hx : IsIntegral A x · exact mt (monic hx).eq_one_of_isUnit (ne_one A x) · rw [eq_zero hx] exact not_isUnit_zero theorem mem_range_of_degree_eq_one (hx : (minpoly A x).degree = 1) : x ∈ (algebraMap A B).range := by have h : IsIntegral A x := by by_contra h rw [eq_zero h, degree_zero, ← WithBot.coe_one] at hx exact ne_of_lt (show ⊥ < ↑1 from WithBot.bot_lt_coe 1) hx have key := minpoly.aeval A x rw [eq_X_add_C_of_degree_eq_one hx, (minpoly.monic h).leadingCoeff, C_1, one_mul, aeval_add, aeval_C, aeval_X, ← eq_neg_iff_add_eq_zero, ← RingHom.map_neg] at key exact ⟨-(minpoly A x).coeff 0, key.symm⟩ /-- The defining property of the minimal polynomial of an element `x`: it is the monic polynomial with smallest degree that has `x` as its root. -/ theorem min {p : A[X]} (pmonic : p.Monic) (hp : Polynomial.aeval x p = 0) : degree (minpoly A x) ≤ degree p := by delta minpoly; split_ifs with hx · exact le_of_not_gt (degree_lt_wf.not_lt_min _ hx ⟨pmonic, hp⟩) · simp only [degree_zero, bot_le] theorem unique' {p : A[X]} (hm : p.Monic) (hp : Polynomial.aeval x p = 0) (hl : ∀ q : A[X], degree q < degree p → q = 0 ∨ Polynomial.aeval x q ≠ 0) : p = minpoly A x := by nontriviality A have hx : IsIntegral A x := ⟨p, hm, hp⟩ obtain h | h := hl _ ((minpoly A x).degree_modByMonic_lt hm) swap · exact (h <| (aeval_modByMonic_eq_self_of_root hm hp).trans <| aeval A x).elim obtain ⟨r, hr⟩ := (modByMonic_eq_zero_iff_dvd hm).1 h rw [hr] have hlead := congr_arg leadingCoeff hr rw [mul_comm, leadingCoeff_mul_monic hm, (monic hx).leadingCoeff] at hlead have : natDegree r ≤ 0 := by have hr0 : r ≠ 0 := by rintro rfl exact ne_zero hx (mul_zero p ▸ hr) apply_fun natDegree at hr rw [hm.natDegree_mul' hr0] at hr apply Nat.le_of_add_le_add_left rw [add_zero] exact hr.symm.trans_le (natDegree_le_natDegree <| min A x hm hp) rw [eq_C_of_natDegree_le_zero this, ← Nat.eq_zero_of_le_zero this, ← leadingCoeff, ← hlead, C_1, mul_one] open Polynomial in /-- If a monic polynomial `p : A[X]` of degree `n` annihilates an element `x` in an `A`-algebra `B`, such that `{xⁱ | 0 ≤ i < n}` is linearly independent over `A`, then `p` is the minimal polynomial of `x` over `A`. -/ theorem eq_of_linearIndependent {p : A[X]} (monic : p.Monic) (hp0 : p.aeval x = 0) (n : ℕ) (hpn : p.degree = n) (ind : LinearIndependent A fun i : Fin n ↦ x ^ i.val) : minpoly A x = p := .symm <| unique' _ _ monic hp0 fun q lt ↦ or_iff_not_imp_left.mpr fun ne hq ↦ ne <| ext fun i ↦ by rw [q.as_sum_range' _ ((natDegree_lt_iff_degree_lt ne).mpr (hpn ▸ lt))] at hq obtain lt | le := lt_or_ge i n · simpa using Fintype.linearIndependent_iff.mp ind (q.coeff ·) (by simpa [Finset.sum_range, Algebra.smul_def] using hq) ⟨i, lt⟩ · exact coeff_eq_zero_of_degree_lt ((hpn ▸ lt).trans_le <| WithBot.coe_le_coe.mpr le) @[nontriviality] theorem subsingleton [Subsingleton B] : minpoly A x = 1 := by nontriviality A have := minpoly.min A x monic_one (Subsingleton.elim _ _) rw [degree_one] at this rcases le_or_gt (minpoly A x).degree 0 with h | h · rwa [(monic ⟨1, monic_one, by simp [eq_iff_true_of_subsingleton]⟩ : (minpoly A x).Monic).degree_le_zero_iff_eq_one] at h · exact (this.not_gt h).elim end Ring section CommRing variable [CommRing A] section Ring variable [Ring B] [Algebra A B] variable {x : B} /-- The degree of a minimal polynomial, as a natural number, is positive. -/ theorem natDegree_pos [Nontrivial B] (hx : IsIntegral A x) : 0 < natDegree (minpoly A x) := by rw [pos_iff_ne_zero] intro ndeg_eq_zero have eq_one : minpoly A x = 1 := by rw [eq_C_of_natDegree_eq_zero ndeg_eq_zero] convert C_1 (R := A) simpa only [ndeg_eq_zero.symm] using (monic hx).leadingCoeff simpa only [eq_one, map_one, one_ne_zero] using aeval A x /-- The degree of a minimal polynomial is positive. -/ theorem degree_pos [Nontrivial B] (hx : IsIntegral A x) : 0 < degree (minpoly A x) := natDegree_pos_iff_degree_pos.mp (natDegree_pos hx) section variable [Nontrivial B] open Polynomial in theorem degree_eq_one_iff : (minpoly A x).degree = 1 ↔ x ∈ (algebraMap A B).range := by refine ⟨minpoly.mem_range_of_degree_eq_one _ _, ?_⟩ rintro ⟨x, rfl⟩ haveI := Module.nontrivial A B exact (degree_X_sub_C x ▸ minpoly.min A (algebraMap A B x) (monic_X_sub_C x) (by simp)).antisymm (Nat.WithBot.add_one_le_of_lt <| minpoly.degree_pos isIntegral_algebraMap) theorem natDegree_eq_one_iff : (minpoly A x).natDegree = 1 ↔ x ∈ (algebraMap A B).range := by rw [← Polynomial.degree_eq_iff_natDegree_eq_of_pos zero_lt_one] exact degree_eq_one_iff theorem two_le_natDegree_iff (int : IsIntegral A x) : 2 ≤ (minpoly A x).natDegree ↔ x ∉ (algebraMap A B).range := by rw [iff_not_comm, ← natDegree_eq_one_iff, not_le] exact ⟨fun h ↦ h.trans_lt one_lt_two, fun h ↦ by linarith only [minpoly.natDegree_pos int, h]⟩ theorem two_le_natDegree_subalgebra {B} [CommRing B] [Algebra A B] [Nontrivial B] {S : Subalgebra A B} {x : B} (int : IsIntegral S x) : 2 ≤ (minpoly S x).natDegree ↔ x ∉ S := by rw [two_le_natDegree_iff int, Iff.not] apply Set.ext_iff.mp Subtype.range_val_subtype end /-- If `B/A` is an injective ring extension, and `a` is an element of `A`, then the minimal polynomial of `algebraMap A B a` is `X - C a`. -/ theorem eq_X_sub_C_of_algebraMap_inj (a : A) (hf : Function.Injective (algebraMap A B)) : minpoly A (algebraMap A B a) = X - C a := by nontriviality A refine (unique' A _ (monic_X_sub_C a) ?_ ?_).symm · rw [map_sub, aeval_C, aeval_X, sub_self] simp_rw [or_iff_not_imp_left] intro q hl h0 rw [← natDegree_lt_natDegree_iff h0, natDegree_X_sub_C, Nat.lt_one_iff] at hl rw [eq_C_of_natDegree_eq_zero hl] at h0 ⊢ rwa [aeval_C, map_ne_zero_iff _ hf, ← C_ne_zero] end Ring section IsDomain variable [Ring B] [Algebra A B] variable {x : B} /-- If `a` strictly divides the minimal polynomial of `x`, then `x` cannot be a root for `a`. -/ theorem aeval_ne_zero_of_dvdNotUnit_minpoly {a : A[X]} (hx : IsIntegral A x) (hamonic : a.Monic) (hdvd : DvdNotUnit a (minpoly A x)) : Polynomial.aeval x a ≠ 0 := by refine fun ha => (min A x hamonic ha).not_gt (degree_lt_degree ?_) obtain ⟨_, c, hu, he⟩ := hdvd have hcm := hamonic.of_mul_monic_left (he.subst <| monic hx) rw [he, hamonic.natDegree_mul hcm] -- TODO: port Nat.lt_add_of_zero_lt_left from lean3 core apply lt_add_of_pos_right refine (lt_of_not_ge fun h => hu ?_) rw [eq_C_of_natDegree_le_zero h, ← Nat.eq_zero_of_le_zero h, ← leadingCoeff, hcm.leadingCoeff, C_1] exact isUnit_one variable [IsDomain A] [IsDomain B] /-- A minimal polynomial is irreducible. -/ theorem irreducible (hx : IsIntegral A x) : Irreducible (minpoly A x) := by refine (irreducible_of_monic (monic hx) <| ne_one A x).2 fun f g hf hg he => ?_ rw [← hf.isUnit_iff, ← hg.isUnit_iff] by_contra! h have heval := congr_arg (Polynomial.aeval x) he rw [aeval A x, aeval_mul, mul_eq_zero] at heval rcases heval with heval | heval · exact aeval_ne_zero_of_dvdNotUnit_minpoly hx hf ⟨hf.ne_zero, g, h.2, he.symm⟩ heval · refine aeval_ne_zero_of_dvdNotUnit_minpoly hx hg ⟨hg.ne_zero, f, h.1, ?_⟩ heval rw [mul_comm, he] end IsDomain end CommRing end minpoly
.lake/packages/mathlib/Mathlib/FieldTheory/Minpoly/ConjRootClass.lean
import Mathlib.FieldTheory.Minpoly.IsConjRoot /-! # Conjugate root classes In this file, we define the `ConjRootClass` of a field extension `L / K` as the quotient of `L` by the relation `IsConjRoot K`. -/ variable (K L S : Type*) [Field K] [Field L] [Field S] variable [Algebra K L] [Algebra K S] [Algebra L S] [IsScalarTower K L S] /-- `ConjRootClass K L` is the quotient of `L` by the relation `IsConjRoot K`. -/ def ConjRootClass := Quotient (α := L) (IsConjRoot.setoid K L) namespace ConjRootClass variable {L} /-- The canonical quotient map from a field `K` into the `ConjRootClass` of the field extension `L / K`. -/ def mk (x : L) : ConjRootClass K L := ⟦x⟧ @[simp] theorem mk_def {x : L} : ⟦x⟧ = mk K x := rfl instance : Zero (ConjRootClass K L) := ⟨mk K 0⟩ @[elab_as_elim, cases_eliminator, induction_eliminator] lemma ind {motive : ConjRootClass K L → Prop} (h : ∀ x : L, motive (mk K x)) (c : ConjRootClass K L) : motive c := Quotient.ind h c variable {K} @[simp] theorem mk_eq_mk {x y : L} : mk K x = mk K y ↔ IsConjRoot K x y := Quotient.eq @[simp] theorem mk_zero : mk K (0 : L) = 0 := rfl @[simp] theorem mk_eq_zero_iff (x : L) : mk K x = 0 ↔ x = 0 := by rw [eq_comm (b := 0), ← mk_zero, mk_eq_mk, isConjRoot_zero_iff_eq_zero] instance [Normal K L] [DecidableEq L] [Fintype Gal(L/K)] : DecidableEq (ConjRootClass K L) := Quotient.decidableEq (d := IsConjRoot.decidable) /-- `c.carrier` is the set of conjugates represented by `c`. -/ def carrier (c : ConjRootClass K L) : Set L := mk K ⁻¹' {c} @[simp] theorem mem_carrier {x : L} {c : ConjRootClass K L} : x ∈ c.carrier ↔ mk K x = c := Iff.rfl @[simp] theorem carrier_zero : (0 : ConjRootClass K L).carrier = {0} := by ext; rw [mem_carrier, mk_eq_zero_iff, Set.mem_singleton_iff] theorem carrier_inj : Function.Injective (carrier (K := K) (L := L)) := by intro x y H induction x with | h x => ?_ induction y with | h y => ?_ simp_rw [Set.ext_iff, mem_carrier] at H rw [← H] instance : Neg (ConjRootClass K L) where neg := Quotient.map (fun x ↦ -x) (fun _ _ ↦ IsConjRoot.neg) theorem mk_neg (x : L) : - mk K x = mk K (-x) := rfl instance : InvolutiveNeg (ConjRootClass K L) where neg_neg c := by induction c; rw [mk_neg, mk_neg, neg_neg] @[simp] theorem carrier_neg (c : ConjRootClass K L) : carrier (- c) = - carrier c := by ext simp [mem_carrier, ← mk_neg, neg_eq_iff_eq_neg] theorem exists_mem_carrier_add_eq_zero (x y : ConjRootClass K L) : (∃ᵉ (a ∈ x.carrier) (b ∈ y.carrier), a + b = 0) ↔ x = -y := by simp_rw [mem_carrier] constructor · rintro ⟨a, rfl, b, rfl, h⟩ rw [mk_neg, mk_eq_mk, add_eq_zero_iff_eq_neg.mp h] · rintro rfl induction y with | h y => exact ⟨-y, mk_neg y, y, rfl, neg_add_cancel _⟩ instance [Normal K L] [DecidableEq L] [Fintype Gal(L/K)] (c : ConjRootClass K L) : DecidablePred (· ∈ c.carrier) := fun x ↦ decidable_of_iff (mk K x = c) (by simp) instance [Normal K L] [DecidableEq L] [Fintype Gal(L/K)] (c : ConjRootClass K L) : Fintype c.carrier := Quotient.recOnSubsingleton c fun x => .ofFinset ((Finset.univ (α := Gal(L/K))).image (· x)) (fun _ ↦ by simp [← isConjRoot_iff_exists_algEquiv, ← mk_eq_mk]) open Polynomial /-- `c.minpoly` is the minimal polynomial of the conjugates. -/ protected noncomputable def minpoly : ConjRootClass K L → K[X] := Quotient.lift (minpoly K) fun _ _ ↦ id @[simp] theorem minpoly_mk (x : L) : (mk K x).minpoly = minpoly K x := rfl @[simp] theorem minpoly_inj {c d : ConjRootClass K L} : c.minpoly = d.minpoly ↔ c = d := by induction c induction d simp [isConjRoot_def] theorem minpoly_injective : Function.Injective (ConjRootClass.minpoly (K := K) (L := L)) := fun _ _ ↦ minpoly_inj.mp theorem splits_minpoly [n : Normal K L] (c : ConjRootClass K L) : Splits (algebraMap K L) c.minpoly := by induction c rw [minpoly_mk] exact n.splits _ section IsAlgebraic variable [Algebra.IsAlgebraic K L] theorem monic_minpoly (c : ConjRootClass K L) : c.minpoly.Monic := by induction c rw [minpoly_mk] exact minpoly.monic (Algebra.IsIntegral.isIntegral _) theorem minpoly_ne_zero (c : ConjRootClass K L) : c.minpoly ≠ 0 := c.monic_minpoly.ne_zero theorem irreducible_minpoly (c : ConjRootClass K L) : Irreducible c.minpoly := by induction c rw [minpoly_mk] exact minpoly.irreducible (Algebra.IsIntegral.isIntegral _) theorem aeval_minpoly_iff (x : L) (c : ConjRootClass K L) : aeval x c.minpoly = 0 ↔ mk K x = c := by induction c simpa [← isConjRoot_iff_aeval_eq_zero (Algebra.IsIntegral.isIntegral _)] using comm theorem rootSet_minpoly_eq_carrier (c : ConjRootClass K L) : c.minpoly.rootSet L = c.carrier := by ext x rw [mem_carrier, mem_rootSet, aeval_minpoly_iff x c] simp [c.minpoly_ne_zero] end IsAlgebraic section IsSeparable variable [Algebra.IsSeparable K L] theorem separable_minpoly (c : ConjRootClass K L) : Separable c.minpoly := by induction c exact Algebra.IsSeparable.isSeparable K _ theorem nodup_aroots_minpoly (c : ConjRootClass K L) : (c.minpoly.aroots L).Nodup := nodup_roots c.separable_minpoly.map theorem aroots_minpoly_eq_carrier_val (c : ConjRootClass K L) [Fintype c.carrier] : c.minpoly.aroots L = c.carrier.toFinset.1 := by classical simp_rw [← rootSet_minpoly_eq_carrier, rootSet_def, Finset.toFinset_coe, Multiset.toFinset_val, c.nodup_aroots_minpoly.dedup] theorem carrier_eq_mk_aroots_minpoly (c : ConjRootClass K L) [Fintype c.carrier] : c.carrier.toFinset = ⟨c.minpoly.aroots L, c.nodup_aroots_minpoly⟩ := by simp only [aroots_minpoly_eq_carrier_val] theorem minpoly.map_eq_prod [Normal K L] (c : ConjRootClass K L) [Fintype c.carrier] : c.minpoly.map (algebraMap K L) = ∏ x ∈ c.carrier.toFinset, (X - C x) := by classical simp_rw [← rootSet_minpoly_eq_carrier, Finset.prod_eq_multiset_prod, rootSet_def, Finset.toFinset_coe, Multiset.toFinset_val] rw [Multiset.dedup_eq_self.mpr (nodup_roots c.separable_minpoly.map), prod_multiset_X_sub_C_of_monic_of_roots_card_eq (c.monic_minpoly.map _)] rw [← splits_iff_card_roots, splits_id_iff_splits] exact c.splits_minpoly end IsSeparable end ConjRootClass
.lake/packages/mathlib/Mathlib/FieldTheory/Minpoly/Field.lean
import Mathlib.Algebra.Polynomial.FieldDivision import Mathlib.Algebra.Polynomial.Lifts import Mathlib.FieldTheory.Minpoly.Basic import Mathlib.RingTheory.Algebraic.Integral import Mathlib.RingTheory.LocalRing.Basic /-! # Minimal polynomials on an algebra over a field This file specializes the theory of minpoly to the setting of field extensions and derives some well-known properties, amongst which the fact that minimal polynomials are irreducible, and uniquely determined by their defining property. -/ open Polynomial Set Function minpoly namespace minpoly variable {A B : Type*} variable (A) [Field A] section Ring variable [Ring B] [Algebra A B] (x : B) /-- If an element `x` is a root of a nonzero polynomial `p`, then the degree of `p` is at least the degree of the minimal polynomial of `x`. See also `minpoly.IsIntegrallyClosed.degree_le_of_ne_zero` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ theorem degree_le_of_ne_zero {p : A[X]} (pnz : p ≠ 0) (hp : Polynomial.aeval x p = 0) : degree (minpoly A x) ≤ degree p := calc degree (minpoly A x) ≤ degree (p * C (leadingCoeff p)⁻¹) := min A x (monic_mul_leadingCoeff_inv pnz) (by simp [hp]) _ = degree p := degree_mul_leadingCoeff_inv p pnz theorem ne_zero_of_finite (e : B) [FiniteDimensional A B] : minpoly A e ≠ 0 := minpoly.ne_zero <| .of_finite A _ /-- The minimal polynomial of an element `x` is uniquely characterized by its defining property: if there is another monic polynomial of minimal degree that has `x` as a root, then this polynomial is equal to the minimal polynomial of `x`. See also `minpoly.IsIntegrallyClosed.Minpoly.unique` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ theorem unique {p : A[X]} (pmonic : p.Monic) (hp : Polynomial.aeval x p = 0) (pmin : ∀ q : A[X], q.Monic → Polynomial.aeval x q = 0 → degree p ≤ degree q) : p = minpoly A x := by have hx : IsIntegral A x := ⟨p, pmonic, hp⟩ symm; apply eq_of_sub_eq_zero by_contra hnz apply degree_le_of_ne_zero A x hnz (by simp [hp]) |>.not_gt apply degree_sub_lt _ (minpoly.ne_zero hx) · rw [(monic hx).leadingCoeff, pmonic.leadingCoeff] · exact le_antisymm (min A x pmonic hp) (pmin (minpoly A x) (monic hx) (aeval A x)) theorem unique_of_degree_le_degree_minpoly {p : A[X]} (pmonic : p.Monic) (hp : p.aeval x = 0) (pmin : p.degree ≤ (minpoly A x).degree) : p = minpoly A x := unique _ _ pmonic hp fun _ qm hq ↦ pmin.trans <| min _ _ qm hq /-- If an element `x` is a root of a polynomial `p`, then the minimal polynomial of `x` divides `p`. See also `minpoly.isIntegrallyClosed_dvd` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ theorem dvd {p : A[X]} (hp : Polynomial.aeval x p = 0) : minpoly A x ∣ p := by by_cases hp0 : p = 0 · simp only [hp0, dvd_zero] have hx : IsIntegral A x := IsAlgebraic.isIntegral ⟨p, hp0, hp⟩ rw [← modByMonic_eq_zero_iff_dvd (monic hx)] by_contra hnz apply degree_le_of_ne_zero A x hnz ((aeval_modByMonic_eq_self_of_root (monic hx) (aeval _ _)).trans hp) |>.not_gt exact degree_modByMonic_lt _ (monic hx) variable {A x} in lemma dvd_iff {p : A[X]} : minpoly A x ∣ p ↔ Polynomial.aeval x p = 0 := ⟨fun ⟨q, hq⟩ ↦ by rw [hq, map_mul, aeval, zero_mul], minpoly.dvd A x⟩ theorem isRadical [IsReduced B] : IsRadical (minpoly A x) := fun n p dvd ↦ by rw [dvd_iff] at dvd ⊢; rw [map_pow] at dvd; exact IsReduced.eq_zero _ ⟨n, dvd⟩ theorem dvd_map_of_isScalarTower (A K : Type*) {R : Type*} [CommRing A] [Field K] [Ring R] [Algebra A K] [Algebra A R] [Algebra K R] [IsScalarTower A K R] (x : R) : minpoly K x ∣ (minpoly A x).map (algebraMap A K) := by refine minpoly.dvd K x ?_ rw [aeval_map_algebraMap, minpoly.aeval] theorem dvd_map_of_isScalarTower' (R : Type*) {S : Type*} (K L : Type*) [CommRing R] [CommRing S] [Field K] [Ring L] [Algebra R S] [Algebra R K] [Algebra S L] [Algebra K L] [Algebra R L] [IsScalarTower R K L] [IsScalarTower R S L] (s : S) : minpoly K (algebraMap S L s) ∣ map (algebraMap R K) (minpoly R s) := by apply minpoly.dvd K (algebraMap S L s) rw [← map_aeval_eq_aeval_map, minpoly.aeval, map_zero] rw [← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq] /-- If `y` is a conjugate of `x` over a field `K`, then it is a conjugate over a subring `R`. -/ theorem aeval_of_isScalarTower (R : Type*) {K T U : Type*} [CommRing R] [Field K] [CommRing T] [Algebra R K] [Algebra K T] [Algebra R T] [IsScalarTower R K T] [CommSemiring U] [Algebra K U] [Algebra R U] [IsScalarTower R K U] (x : T) (y : U) (hy : Polynomial.aeval y (minpoly K x) = 0) : Polynomial.aeval y (minpoly R x) = 0 := aeval_map_algebraMap K y (minpoly R x) ▸ eval₂_eq_zero_of_dvd_of_eval₂_eq_zero (algebraMap K U) y (minpoly.dvd_map_of_isScalarTower R K x) hy /-- If a subfield `F` of `E` contains all the coefficients of `minpoly E a`, then `minpoly F a` maps to `minpoly E a` via `algebraMap F E`. -/ theorem map_algebraMap {F E A : Type*} [Field F] [Field E] [CommRing A] [Algebra F E] [Algebra E A] [Algebra F A] [IsScalarTower F E A] {a : A} (ha : IsIntegral F a) (h : minpoly E a ∈ lifts (algebraMap F E)) : (minpoly F a).map (algebraMap F E) = minpoly E a := by refine eq_of_monic_of_dvd_of_natDegree_le (minpoly.monic ha.tower_top) ((algebraMap F E).injective.monic_map_iff.mp <| minpoly.monic ha) (minpoly.dvd E a (by simp)) ?_ obtain ⟨g, hg, hgdeg, hgmon⟩ := lifts_and_natDegree_eq_and_monic h (minpoly.monic ha.tower_top) rw [natDegree_map, ← hgdeg] refine natDegree_le_of_dvd (minpoly.dvd F a ?_) hgmon.ne_zero rw [← aeval_map_algebraMap A, IsScalarTower.algebraMap_eq F E A, ← coe_mapRingHom, ← mapRingHom_comp, RingHom.comp_apply, coe_mapRingHom, coe_mapRingHom, hg, aeval_map_algebraMap, minpoly.aeval] /-- See also `minpoly.ker_eval` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ @[simp] lemma ker_aeval_eq_span_minpoly : RingHom.ker (Polynomial.aeval x) = A[X] ∙ minpoly A x := by ext p simp_rw [RingHom.mem_ker, ← minpoly.dvd_iff, Submodule.mem_span_singleton, dvd_iff_exists_eq_mul_left, smul_eq_mul, eq_comm (a := p)] variable {A x} theorem eq_of_irreducible_of_monic [Nontrivial B] {p : A[X]} (hp1 : Irreducible p) (hp2 : Polynomial.aeval x p = 0) (hp3 : p.Monic) : p = minpoly A x := let ⟨_, hq⟩ := dvd A x hp2 eq_of_monic_of_associated hp3 (monic ⟨p, ⟨hp3, hp2⟩⟩) <| mul_one (minpoly A x) ▸ hq.symm ▸ Associated.mul_left _ (associated_one_iff_isUnit.2 <| (hp1.isUnit_or_isUnit hq).resolve_left <| not_isUnit A x) theorem eq_iff_aeval_eq_zero [Nontrivial B] {p : A[X]} (irr : Irreducible p) (monic : p.Monic) : p = minpoly A x ↔ Polynomial.aeval x p = 0 := ⟨(· ▸ aeval A x), (eq_of_irreducible_of_monic irr · monic)⟩ theorem eq_iff_aeval_minpoly_eq_zero [IsDomain B] {C} [Ring C] [Algebra A C] [Nontrivial C] {b : B} (h : IsIntegral A b) {c : C} : minpoly A b = minpoly A c ↔ Polynomial.aeval c (minpoly A b) = 0 := eq_iff_aeval_eq_zero (irreducible h) (monic h) theorem eq_of_irreducible [Nontrivial B] {p : A[X]} (hp1 : Irreducible p) (hp2 : Polynomial.aeval x p = 0) : p * C p.leadingCoeff⁻¹ = minpoly A x := by have : p.leadingCoeff ≠ 0 := leadingCoeff_ne_zero.mpr hp1.ne_zero apply eq_of_irreducible_of_monic · exact Associated.irreducible ⟨⟨C p.leadingCoeff⁻¹, C p.leadingCoeff, by rwa [← C_mul, inv_mul_cancel₀, C_1], by rwa [← C_mul, mul_inv_cancel₀, C_1]⟩, rfl⟩ hp1 · rw [aeval_mul, hp2, zero_mul] · rwa [Polynomial.Monic, leadingCoeff_mul, leadingCoeff_C, mul_inv_cancel₀] theorem add_algebraMap {B : Type*} [CommRing B] [Algebra A B] (x : B) (a : A) : minpoly A (x + algebraMap A B a) = (minpoly A x).comp (X - C a) := by by_cases hx : IsIntegral A x · refine (minpoly.unique _ _ ((minpoly.monic hx).comp_X_sub_C _) ?_ fun q qmo hq => ?_).symm · simp [aeval_comp] · have : (Polynomial.aeval x) (q.comp (X + C a)) = 0 := by simpa [aeval_comp] using hq have H := minpoly.min A x (qmo.comp_X_add_C _) this rw [degree_eq_natDegree qmo.ne_zero, degree_eq_natDegree ((minpoly.monic hx).comp_X_sub_C _).ne_zero, natDegree_comp, natDegree_X_sub_C, mul_one] rwa [degree_eq_natDegree (minpoly.ne_zero hx), degree_eq_natDegree (qmo.comp_X_add_C _).ne_zero, natDegree_comp, natDegree_X_add_C, mul_one] at H · rw [minpoly.eq_zero hx, minpoly.eq_zero, zero_comp] refine fun h ↦ hx ?_ simpa only [add_sub_cancel_right] using IsIntegral.sub h (isIntegral_algebraMap (x := a)) theorem sub_algebraMap {B : Type*} [CommRing B] [Algebra A B] (x : B) (a : A) : minpoly A (x - algebraMap A B a) = (minpoly A x).comp (X + C a) := by simpa [sub_eq_add_neg] using add_algebraMap x (-a) theorem neg {B : Type*} [Ring B] [Algebra A B] (x : B) : minpoly A (- x) = (-1) ^ (natDegree (minpoly A x)) * (minpoly A x).comp (- X) := by by_cases hx : IsIntegral A x · refine (minpoly.unique _ _ ((minpoly.monic hx).neg_one_pow_natDegree_mul_comp_neg_X) ?_ fun q qmo hq => ?_).symm · simp [aeval_comp] · have : (Polynomial.aeval x) ((-1) ^ q.natDegree * q.comp (- X)) = 0 := by simpa [aeval_comp] using hq have H := minpoly.min A x qmo.neg_one_pow_natDegree_mul_comp_neg_X this have n1 := ((minpoly.monic hx).neg_one_pow_natDegree_mul_comp_neg_X).ne_zero have n2 := qmo.neg_one_pow_natDegree_mul_comp_neg_X.ne_zero rw [degree_eq_natDegree qmo.ne_zero, degree_eq_natDegree n1, natDegree_mul (by simp) (right_ne_zero_of_mul n1), natDegree_comp] rw [degree_eq_natDegree (minpoly.ne_zero hx), degree_eq_natDegree qmo.neg_one_pow_natDegree_mul_comp_neg_X.ne_zero, natDegree_mul (by simp) (right_ne_zero_of_mul n2), natDegree_comp] at H simpa using H · rw [minpoly.eq_zero hx, minpoly.eq_zero, zero_comp] · simp only [natDegree_zero, pow_zero, mul_zero] · exact IsIntegral.neg_iff.not.mpr hx theorem map_eq_of_equiv_equiv {R S T : Type*} [CommRing R] [IsDomain R] [Ring S] [Ring T] [IsDomain S] [IsDomain T] [Algebra R S] [Algebra A T] [Algebra.IsIntegral R S] {f : R ≃+* A} {g : S ≃+* T} (hcomp : (algebraMap A T).comp f = (g : S →+* T).comp (algebraMap R S)) (x : S) : map f (minpoly R x) = minpoly A (g x) := by refine minpoly.eq_of_irreducible_of_monic ?_ ?_ ?_ · rw [← mapEquiv_apply, MulEquiv.irreducible_iff] exact minpoly.irreducible (Algebra.IsIntegral.isIntegral x) · simpa using (map_aeval_eq_aeval_map hcomp (minpoly R x) x).symm · exact (monic (Algebra.IsIntegral.isIntegral x)).map _ section AlgHomFintype open scoped Classical in /-- A technical finiteness result. -/ noncomputable def Fintype.subtypeProd {E : Type*} {X : Set E} (hX : X.Finite) {L : Type*} (F : E → Multiset L) : Fintype (∀ x : X, { l : L // l ∈ F x }) := @Pi.instFintype _ _ _ (Finite.fintype hX) _ variable (F E K : Type*) [Field F] [Ring E] [CommRing K] [IsDomain K] [Algebra F E] [Algebra F K] [FiniteDimensional F E] /-- Function from Hom_K(E,L) to pi type Π (x : basis), roots of min poly of x -/ def rootsOfMinPolyPiType (φ : E →ₐ[F] K) (x : range (Module.finBasis F E : _ → E)) : { l : K // l ∈ (minpoly F x.1).aroots K } := ⟨φ x, by rw [mem_roots_map (minpoly.ne_zero_of_finite F x.val), ← aeval_def, aeval_algHom_apply, minpoly.aeval, map_zero]⟩ theorem aux_inj_roots_of_min_poly : Injective (rootsOfMinPolyPiType F E K) := by intro f g h -- needs explicit coercion on the RHS suffices (f : E →ₗ[F] K) = (g : E →ₗ[F] K) by rwa [DFunLike.ext'_iff] at this ⊢ rw [funext_iff] at h exact LinearMap.ext_on (Module.finBasis F E).span_eq fun e he => Subtype.ext_iff.mp (h ⟨e, he⟩) /-- Given field extensions `E/F` and `K/F`, with `E/F` finite, there are finitely many `F`-algebra homomorphisms `E →ₐ[K] K`. -/ noncomputable instance AlgHom.fintype : Fintype (E →ₐ[F] K) := @Fintype.ofInjective _ _ (Fintype.subtypeProd (finite_range (Module.finBasis F E)) fun e => (minpoly F e).aroots K) _ (aux_inj_roots_of_min_poly F E K) end AlgHomFintype variable (B) [Nontrivial B] /-- If `B/K` is a nontrivial algebra over a field, and `x` is an element of `K`, then the minimal polynomial of `algebraMap K B x` is `X - C x`. -/ theorem eq_X_sub_C (a : A) : minpoly A (algebraMap A B a) = X - C a := eq_X_sub_C_of_algebraMap_inj a (algebraMap A B).injective theorem eq_X_sub_C' (a : A) : minpoly A a = X - C a := eq_X_sub_C A a variable (A) /-- The minimal polynomial of `0` is `X`. -/ @[simp] theorem zero : minpoly A (0 : B) = X := by simpa only [add_zero, C_0, sub_eq_add_neg, neg_zero, RingHom.map_zero] using eq_X_sub_C B (0 : A) /-- The minimal polynomial of `1` is `X - 1`. -/ @[simp] theorem one : minpoly A (1 : B) = X - 1 := by simpa only [RingHom.map_one, C_1, sub_eq_add_neg] using eq_X_sub_C B (1 : A) end Ring section IsDomain variable [Ring B] [IsDomain B] [Algebra A B] variable {A} {x : B} /-- A minimal polynomial is prime. -/ theorem prime (hx : IsIntegral A x) : Prime (minpoly A x) := by refine ⟨minpoly.ne_zero hx, not_isUnit A x, ?_⟩ rintro p q ⟨d, h⟩ have : Polynomial.aeval x (p * q) = 0 := by simp [h, aeval A x] replace : Polynomial.aeval x p = 0 ∨ Polynomial.aeval x q = 0 := by simpa exact Or.imp (dvd A x) (dvd A x) this /-- If `L/K` is a field extension and an element `y` of `K` is a root of the minimal polynomial of an element `x ∈ L`, then `y` maps to `x` under the field embedding. -/ theorem root {x : B} (hx : IsIntegral A x) {y : A} (h : IsRoot (minpoly A x) y) : algebraMap A B y = x := by have key : minpoly A x = X - C y := eq_of_monic_of_associated (monic hx) (monic_X_sub_C y) (associated_of_dvd_dvd ((irreducible_X_sub_C y).dvd_symm (irreducible hx) (dvd_iff_isRoot.2 h)) (dvd_iff_isRoot.2 h)) have := aeval A x rwa [key, map_sub, aeval_X, aeval_C, sub_eq_zero, eq_comm] at this /-- The constant coefficient of the minimal polynomial of `x` is `0` if and only if `x = 0`. -/ @[simp] theorem coeff_zero_eq_zero (hx : IsIntegral A x) : coeff (minpoly A x) 0 = 0 ↔ x = 0 := by constructor · intro h have zero_root := zero_isRoot_of_coeff_zero_eq_zero h rw [← root hx zero_root] exact RingHom.map_zero _ · rintro rfl simp /-- The minimal polynomial of a nonzero element has nonzero constant coefficient. -/ theorem coeff_zero_ne_zero (hx : IsIntegral A x) (h : x ≠ 0) : coeff (minpoly A x) 0 ≠ 0 := by contrapose! h simpa only [hx, coeff_zero_eq_zero] using h end IsDomain end minpoly section AlgHom variable {K L} [Field K] [CommRing L] [IsDomain L] [Algebra K L] /-- The minimal polynomial (over `K`) of `σ : L ≃ₐ[K] L` is `X ^ (orderOf σ) - 1`. -/ lemma minpoly_algEquiv_toLinearMap (σ : L ≃ₐ[K] L) (hσ : IsOfFinOrder σ) : minpoly K σ.toLinearMap = X ^ (orderOf σ) - C 1 := by refine (minpoly.unique _ _ (monic_X_pow_sub_C _ hσ.orderOf_pos.ne.symm) ?_ ?_).symm · simp [← AlgEquiv.pow_toLinearMap, pow_orderOf_eq_one] · intro q hq hs rw [degree_eq_natDegree hq.ne_zero, degree_X_pow_sub_C hσ.orderOf_pos, Nat.cast_le, ← not_lt] intro H rw [aeval_eq_sum_range' H, ← Fin.sum_univ_eq_sum_range] at hs simp_rw [← AlgEquiv.pow_toLinearMap] at hs apply hq.ne_zero simpa using Fintype.linearIndependent_iff.mp (((linearIndependent_algHom_toLinearMap' K L L).comp _ AlgEquiv.coe_algHom_injective).comp _ (Subtype.val_injective.comp ((finEquivPowers hσ).injective))) (q.coeff ∘ (↑)) hs ⟨_, H⟩ /-- The minimal polynomial (over `K`) of `σ : Gal(L/K)` is `X ^ (orderOf σ) - 1`. -/ lemma minpoly_algHom_toLinearMap (σ : L →ₐ[K] L) (hσ : IsOfFinOrder σ) : minpoly K σ.toLinearMap = X ^ (orderOf σ) - C 1 := by have : orderOf σ = orderOf (AlgEquiv.algHomUnitsEquiv _ _ hσ.unit) := by rw [← MonoidHom.coe_coe, orderOf_injective, ← orderOf_units, IsOfFinOrder.val_unit] exact (AlgEquiv.algHomUnitsEquiv K L).injective rw [this, ← minpoly_algEquiv_toLinearMap] · apply congr_arg ext simp · rwa [← orderOf_pos_iff, ← this, orderOf_pos_iff] end AlgHom
.lake/packages/mathlib/Mathlib/FieldTheory/Minpoly/IsConjRoot.lean
import Mathlib.FieldTheory.Extension import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic import Mathlib.FieldTheory.Minpoly.Basic import Mathlib.FieldTheory.Normal.Defs /-! # Conjugate roots Given two elements `x` and `y` of some `K`-algebra, these two elements are *conjugate roots* over `K` if they have the same minimal polynomial over `K`. ## Main definitions * `IsConjRoot`: `IsConjRoot K x y` means `y` is a conjugate root of `x` over `K`. ## Main results * `isConjRoot_iff_exists_algEquiv`: Let `L / K` be a normal field extension. For any two elements `x` and `y` in `L`, `IsConjRoot K x y` is equivalent to the existence of an algebra equivalence `σ : Gal(L/K)` such that `y = σ x`. * `notMem_iff_exists_ne_and_isConjRoot`: Let `L / K` be a field extension. If `x` is a separable element over `K` and the minimal polynomial of `x` splits in `L`, then `x` is not in the `K` iff there exists a different conjugate root of `x` in `L` over `K`. ## TODO * Move `IsConjRoot` to earlier files and refactor the theorems in field theory using `IsConjRoot`. * Prove `IsConjRoot.smul`, if `x` and `y` are conjugate roots, then so are `r • x` and `r • y`. ## Tags conjugate root, minimal polynomial -/ open Polynomial minpoly IntermediateField variable {R K L S A B : Type*} [CommRing R] [CommRing S] [Ring A] [Ring B] [Field K] [Field L] variable [Algebra R S] [Algebra R A] [Algebra R B] variable [Algebra K S] [Algebra K L] [Algebra K A] [Algebra L S] variable (R) in /-- We say that `y` is a conjugate root of `x` over `K` if the minimal polynomial of `x` is the same as the minimal polynomial of `y`. -/ def IsConjRoot (x y : A) : Prop := minpoly R x = minpoly R y /-- The definition of conjugate roots. -/ theorem isConjRoot_def {x y : A} : IsConjRoot R x y ↔ minpoly R x = minpoly R y := Iff.rfl namespace IsConjRoot /-- Every element is a conjugate root of itself. -/ @[refl] theorem refl {x : A} : IsConjRoot R x x := rfl /-- If `y` is a conjugate root of `x`, then `x` is also a conjugate root of `y`. -/ @[symm] theorem symm {x y : A} (h : IsConjRoot R x y) : IsConjRoot R y x := Eq.symm h /-- If `y` is a conjugate root of `x` and `z` is a conjugate root of `y`, then `z` is a conjugate root of `x`. -/ @[trans] theorem trans {x y z : A} (h₁ : IsConjRoot R x y) (h₂ : IsConjRoot R y z) : IsConjRoot R x z := Eq.trans h₁ h₂ variable (R A) in /-- The setoid structure on `A` defined by the equivalence relation of `IsConjRoot R · ·`. -/ def setoid : Setoid A where r := IsConjRoot R iseqv := ⟨fun _ => refl, symm, trans⟩ /-- Let `p` be the minimal polynomial of `x`. If `y` is a conjugate root of `x`, then `p y = 0`. -/ theorem aeval_eq_zero {x y : A} (h : IsConjRoot R x y) : aeval y (minpoly R x) = 0 := h ▸ minpoly.aeval R y /-- Let `r` be an element of the base ring. If `y` is a conjugate root of `x`, then `y + r` is a conjugate root of `x + r`. -/ theorem add_algebraMap {x y : S} (r : K) (h : IsConjRoot K x y) : IsConjRoot K (x + algebraMap K S r) (y + algebraMap K S r) := by rw [isConjRoot_def, minpoly.add_algebraMap x r, minpoly.add_algebraMap y r, h] /-- Let `r` be an element of the base ring. If `y` is a conjugate root of `x`, then `y - r` is a conjugate root of `x - r`. -/ theorem sub_algebraMap {x y : S} (r : K) (h : IsConjRoot K x y) : IsConjRoot K (x - algebraMap K S r) (y - algebraMap K S r) := by simpa only [sub_eq_add_neg, map_neg] using add_algebraMap (-r) h /-- If `y` is a conjugate root of `x`, then `-y` is a conjugate root of `-x`. -/ theorem neg {x y : S} (h : IsConjRoot K x y) : IsConjRoot K (-x) (-y) := by rw [isConjRoot_def, minpoly.neg x, minpoly.neg y, h] end IsConjRoot open IsConjRoot /-- A variant of `isConjRoot_algHom_iff`, only assuming `Function.Injective f`, instead of `DivisionRing A`. If `y` is a conjugate root of `x` and `f` is an injective `R`-algebra homomorphism, then `f y` is a conjugate root of `f x`. -/ theorem isConjRoot_algHom_iff_of_injective {x y : A} {f : A →ₐ[R] B} (hf : Function.Injective f) : IsConjRoot R (f x) (f y) ↔ IsConjRoot R x y := by rw [isConjRoot_def, isConjRoot_def, algHom_eq f hf, algHom_eq f hf] /-- If `y` is a conjugate root of `x` in some division ring and `f` is a `R`-algebra homomorphism, then `f y` is a conjugate root of `f x`. -/ theorem isConjRoot_algHom_iff {A} [DivisionRing A] [Algebra R A] [Nontrivial B] {x y : A} (f : A →ₐ[R] B) : IsConjRoot R (f x) (f y) ↔ IsConjRoot R x y := isConjRoot_algHom_iff_of_injective f.injective /-- Let `p` be the minimal polynomial of an integral element `x`. If `p y` = 0, then `y` is a conjugate root of `x`. -/ theorem isConjRoot_of_aeval_eq_zero [IsDomain A] {x y : A} (hx : IsIntegral K x) (h : aeval y (minpoly K x) = 0) : IsConjRoot K x y := minpoly.eq_of_irreducible_of_monic (minpoly.irreducible hx) h (minpoly.monic hx) /-- Let `p` be the minimal polynomial of an integral element `x`. Then `y` is a conjugate root of `x` if and only if `p y = 0`. -/ theorem isConjRoot_iff_aeval_eq_zero [IsDomain A] {x y : A} (h : IsIntegral K x) : IsConjRoot K x y ↔ aeval y (minpoly K x) = 0 := ⟨IsConjRoot.aeval_eq_zero, isConjRoot_of_aeval_eq_zero h⟩ /-- Let `s` be an `R`-algebra isomorphism. Then `s x` is a conjugate root of `x`. -/ @[simp] theorem isConjRoot_of_algEquiv (x : A) (s : A ≃ₐ[R] A) : IsConjRoot R x (s x) := Eq.symm (minpoly.algEquiv_eq s x) /-- A variant of `isConjRoot_of_algEquiv`. Let `s` be an `R`-algebra isomorphism. Then `x` is a conjugate root of `s x`. -/ @[simp] theorem isConjRoot_of_algEquiv' (x : A) (s : A ≃ₐ[R] A) : IsConjRoot R (s x) x := (minpoly.algEquiv_eq s x) /-- Let `s₁` and `s₂` be two `R`-algebra isomorphisms. Then `s₂ x` is a conjugate root of `s₁ x`. -/ @[simp] theorem isConjRoot_of_algEquiv₂ (x : A) (s₁ s₂ : A ≃ₐ[R] A) : IsConjRoot R (s₁ x) (s₂ x) := isConjRoot_def.mpr <| (minpoly.algEquiv_eq s₂ x) ▸ (minpoly.algEquiv_eq s₁ x) /-- Let `L / K` be a normal field extension. For any two elements `x` and `y` in `L`, if `y` is a conjugate root of `x`, then there exists a `K`-automorphism `σ : Gal(L/K)` such that `σ y = x`. -/ theorem IsConjRoot.exists_algEquiv [Normal K L] {x y : L} (h : IsConjRoot K x y) : ∃ σ : Gal(L/K), σ y = x := by obtain ⟨σ, hσ⟩ := exists_algHom_of_splits_of_aeval (normal_iff.mp inferInstance) (h ▸ minpoly.aeval K x) exact ⟨AlgEquiv.ofBijective σ (σ.normal_bijective _ _ _), hσ⟩ /-- Let `L / K` be a normal field extension. For any two elements `x` and `y` in `L`, `y` is a conjugate root of `x` if and only if there exists a `K`-automorphism `σ : Gal(L/K)` such that `σ y = x`. -/ theorem isConjRoot_iff_exists_algEquiv [Normal K L] {x y : L} : IsConjRoot K x y ↔ ∃ σ : Gal(L/K), σ y = x := ⟨exists_algEquiv, fun ⟨_, h⟩ => h ▸ (isConjRoot_of_algEquiv _ _).symm⟩ /-- Let `L / K` be a normal field extension. For any two elements `x` and `y` in `L`, `y` is a conjugate root of `x` if and only if `x` and `y` falls in the same orbit of the action of Galois group. -/ theorem isConjRoot_iff_orbitRel [Normal K L] {x y : L} : IsConjRoot K x y ↔ MulAction.orbitRel Gal(L/K) L x y:= (isConjRoot_iff_exists_algEquiv) variable [IsDomain S] /-- Let `S / L / K` be a tower of extensions. For any two elements `y` and `x` in `S`, if `y` is a conjugate root of `x` over `L`, then `y` is also a conjugate root of `x` over `K`. -/ theorem IsConjRoot.of_isScalarTower [IsScalarTower K L S] {x y : S} (hx : IsIntegral K x) (h : IsConjRoot L x y) : IsConjRoot K x y := isConjRoot_of_aeval_eq_zero hx <| minpoly.aeval_of_isScalarTower K x y (aeval_eq_zero h) /-- `y` is a conjugate root of `x` over `K` if and only if `y` is a root of the minimal polynomial of `x`. This is variant of `isConjRoot_iff_aeval_eq_zero`. -/ theorem isConjRoot_iff_mem_minpoly_aroots {x y : S} (h : IsIntegral K x) : IsConjRoot K x y ↔ y ∈ (minpoly K x).aroots S := by rw [Polynomial.mem_aroots, isConjRoot_iff_aeval_eq_zero h] simp only [iff_and_self] exact fun _ => minpoly.ne_zero h /-- `y` is a conjugate root of `x` over `K` if and only if `y` is a root of the minimal polynomial of `x`. This is variant of `isConjRoot_iff_aeval_eq_zero`. -/ theorem isConjRoot_iff_mem_minpoly_rootSet {x y : S} (h : IsIntegral K x) : IsConjRoot K x y ↔ y ∈ (minpoly K x).rootSet S := (isConjRoot_iff_mem_minpoly_aroots h).trans (by simp [rootSet]) namespace IsConjRoot instance decidable [Normal K L] [DecidableEq L] [Fintype Gal(L/K)] (x y : L) : Decidable (IsConjRoot K x y) := decidable_of_iff _ isConjRoot_iff_exists_algEquiv.symm instance : IsEquiv L (IsConjRoot K) := letI := IsConjRoot.setoid K L inferInstanceAs <| IsEquiv L (· ≈ ·) /-- If `y` is a conjugate root of an integral element `x` over `R`, then `y` is also integral over `R`. -/ theorem isIntegral {x y : A} (hx : IsIntegral R x) (h : IsConjRoot R x y) : IsIntegral R y := ⟨minpoly R x, minpoly.monic hx, h ▸ minpoly.aeval R y⟩ /-- A variant of `IsConjRoot.eq_of_isConjRoot_algebraMap`, only assuming `Nontrivial R`, `NoZeroSMulDivisors R A` and `Function.Injective (algebraMap R A)` instead of `Field R`. If `x` is a conjugate root of some element `algebraMap R S r` in the image of the base ring, then `x = algebraMap R S r`. -/ theorem eq_algebraMap_of_injective [Nontrivial R] [NoZeroSMulDivisors R S] {r : R} {x : S} (h : IsConjRoot R (algebraMap R S r) x) (hf : Function.Injective (algebraMap R S)) : x = algebraMap R S r := by rw [IsConjRoot, minpoly.eq_X_sub_C_of_algebraMap_inj _ hf] at h have : x ∈ (X - C r).aroots S := by rw [mem_aroots] simp [X_sub_C_ne_zero, h ▸ minpoly.aeval R x] simpa [aroots_X_sub_C] using this /-- If `x` is a conjugate root of some element `algebraMap R S r` in the image of the base ring, then `x = algebraMap R S r`. -/ theorem eq_algebraMap {r : K} {x : S} (h : IsConjRoot K (algebraMap K S r) x) : x = algebraMap K S r := eq_algebraMap_of_injective h (algebraMap K S).injective /-- A variant of `IsConjRoot.eq_zero`, only assuming `Nontrivial R`, `NoZeroSMulDivisors R A` and `Function.Injective (algebraMap R A)` instead of `Field R`. If `x` is a conjugate root of `0`, then `x = 0`. -/ theorem eq_zero_of_injective [Nontrivial R] [NoZeroSMulDivisors R S] {x : S} (h : IsConjRoot R 0 x) (hf : Function.Injective (algebraMap R S)) : x = 0 := (algebraMap R S).map_zero ▸ (eq_algebraMap_of_injective ((algebraMap R S).map_zero ▸ h) hf) /-- If `x` is a conjugate root of `0`, then `x = 0`. -/ theorem eq_zero {x : S} (h : IsConjRoot K 0 x) : x = 0 := eq_zero_of_injective h (algebraMap K S).injective end IsConjRoot /-- A variant of `IsConjRoot.eq_of_isConjRoot_algebraMap`, only assuming `Nontrivial R`, `NoZeroSMulDivisors R A` and `Function.Injective (algebraMap R A)` instead of `Field R`. If `x` is a conjugate root of some element `algebraMap R S r` in the image of the base ring, then `x = algebraMap R S r`. -/ theorem isConjRoot_iff_eq_algebraMap_of_injective [Nontrivial R] [NoZeroSMulDivisors R S] {r : R} {x : S} (hf : Function.Injective (algebraMap R S)) : IsConjRoot R (algebraMap R S r) x ↔ x = algebraMap R S r := ⟨fun h => eq_algebraMap_of_injective h hf, fun h => h.symm ▸ rfl⟩ /-- An element `x` is a conjugate root of some element `algebraMap R S r` in the image of the base ring if and only if `x = algebraMap R S r`. -/ @[simp] theorem isConjRoot_iff_eq_algebraMap {r : K} {x : S} : IsConjRoot K (algebraMap K S r) x ↔ x = algebraMap K S r := isConjRoot_iff_eq_algebraMap_of_injective (algebraMap K S).injective /-- A variant of `isConjRoot_iff_eq_algebraMap`. an element `algebraMap R S r` in the image of the base ring is a conjugate root of an element `x` if and only if `x = algebraMap R S r`. -/ @[simp] theorem isConjRoot_iff_eq_algebraMap' {r : K} {x : S} : IsConjRoot K x (algebraMap K S r) ↔ x = algebraMap K S r := eq_comm.trans <| isConjRoot_iff_eq_algebraMap_of_injective (algebraMap K S).injective /-- A variant of `IsConjRoot.iff_eq_zero`, only assuming `Nontrivial R`, `NoZeroSMulDivisors R A` and `Function.Injective (algebraMap R A)` instead of `Field R`. `x` is a conjugate root of `0` if and only if `x = 0`. -/ theorem isConjRoot_zero_iff_eq_zero_of_injective [Nontrivial R] {x : S} [NoZeroSMulDivisors R S] (hf : Function.Injective (algebraMap R S)) : IsConjRoot R 0 x ↔ x = 0 := ⟨fun h => eq_zero_of_injective h hf, fun h => h.symm ▸ rfl⟩ /-- `x` is a conjugate root of `0` if and only if `x = 0`. -/ @[simp] theorem isConjRoot_zero_iff_eq_zero {x : S} : IsConjRoot K 0 x ↔ x = 0 := isConjRoot_zero_iff_eq_zero_of_injective (algebraMap K S).injective /-- A variant of `IsConjRoot.iff_eq_zero`. `0` is a conjugate root of `x` if and only if `x = 0`. -/ @[simp] theorem isConjRoot_zero_iff_eq_zero' {x : S} : IsConjRoot K x 0 ↔ x = 0 := eq_comm.trans <| isConjRoot_zero_iff_eq_zero_of_injective (algebraMap K S).injective namespace IsConjRoot /-- A variant of `IsConjRoot.ne_zero`, only assuming `Nontrivial R`, `NoZeroSMulDivisors R A` and `Function.Injective (algebraMap R A)` instead of `Field R`. If `y` is a conjugate root of a nonzero element `x`, then `y` is not zero. -/ theorem ne_zero_of_injective [Nontrivial R] [NoZeroSMulDivisors R S] {x y : S} (hx : x ≠ 0) (h : IsConjRoot R x y) (hf : Function.Injective (algebraMap R S)) : y ≠ 0 := fun g => hx (eq_zero_of_injective (g ▸ h.symm) hf) /-- If `y` is a conjugate root of a nonzero element `x`, then `y` is not zero. -/ theorem ne_zero {x y : S} (hx : x ≠ 0) (h : IsConjRoot K x y) : y ≠ 0 := ne_zero_of_injective hx h (algebraMap K S).injective end IsConjRoot /-- Let `L / K` be a field extension. If `x` is a separable element over `K` and the minimal polynomial of `x` splits in `L`, then `x` is not in `K` if and only if there exists a conjugate root of `x` over `K` in `L` which is not equal to `x` itself. -/ theorem notMem_iff_exists_ne_and_isConjRoot {x : L} (h : IsSeparable K x) (sp : (minpoly K x).Splits (algebraMap K L)) : x ∉ (⊥ : Subalgebra K L) ↔ ∃ y : L, x ≠ y ∧ IsConjRoot K x y := by calc _ ↔ 2 ≤ (minpoly K x).natDegree := (minpoly.two_le_natDegree_iff h.isIntegral).symm _ ↔ 2 ≤ Fintype.card ((minpoly K x).rootSet L) := (Polynomial.card_rootSet_eq_natDegree h sp) ▸ Iff.rfl _ ↔ Nontrivial ((minpoly K x).rootSet L) := Fintype.one_lt_card_iff_nontrivial _ ↔ ∃ y : ((minpoly K x).rootSet L), ↑y ≠ x := (nontrivial_iff_exists_ne ⟨x, mem_rootSet.mpr ⟨minpoly.ne_zero h.isIntegral, minpoly.aeval K x⟩⟩).trans ⟨fun ⟨y, hy⟩ => ⟨y, Subtype.coe_ne_coe.mpr hy⟩, fun ⟨y, hy⟩ => ⟨y, Subtype.coe_ne_coe.mp hy⟩⟩ _ ↔ _ := ⟨fun ⟨⟨y, hy⟩, hne⟩ => ⟨y, ⟨hne.symm, (isConjRoot_iff_mem_minpoly_rootSet h.isIntegral).mpr hy⟩⟩, fun ⟨y, hne, hy⟩ => ⟨⟨y, (isConjRoot_iff_mem_minpoly_rootSet h.isIntegral).mp hy⟩, hne.symm⟩⟩ @[deprecated (since := "2025-05-23")] alias not_mem_iff_exists_ne_and_isConjRoot := notMem_iff_exists_ne_and_isConjRoot
.lake/packages/mathlib/Mathlib/FieldTheory/Normal/Closure.lean
import Mathlib.RingTheory.SimpleRing.Basic import Mathlib.FieldTheory.Normal.Basic import Mathlib.Order.Closure import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix /-! # Normal closures ## Main definitions Given field extensions `K/F` and `L/F`, the predicate `IsNormalClosure F K L` says that the minimal polynomial of every element of `K` over `F` splits in `L`, and that `L` is generated by the roots of such minimal polynomials. These conditions uniquely characterize `L/F` up to `F`-algebra isomorphisms (`IsNormalClosure.equiv`). The explicit construction `IntermediateField.normalClosure F K L` of a field extension `K/F` inside another field extension `L/F` is the smallest intermediate field of `L/F` that contains the image of every `F`-algebra embedding `K →ₐ[F] L`. It satisfies the `IsNormalClosure` predicate if `L/F` satisfies the abovementioned splitting condition, in particular if `L/K/F` form a tower and `L/F` is normal. -/ open IntermediateField IsScalarTower Polynomial variable (F K L : Type*) [Field F] [Field K] [Field L] [Algebra F K] [Algebra F L] /-- `L/F` is a normal closure of `K/F` if the minimal polynomial of every element of `K` over `F` splits in `L`, and `L` is generated by roots of such minimal polynomials over `F`. (Since the minimal polynomial of a transcendental element is 0, the normal closure of `K/F` is the same as the normal closure over `F` of the algebraic closure of `F` in `K`.) -/ @[stacks 0BMF "Predicate version"] class IsNormalClosure : Prop where splits (x : K) : (minpoly F x).Splits (algebraMap F L) adjoin_rootSet : ⨆ x : K, adjoin F ((minpoly F x).rootSet L) = ⊤ /- TODO: show `IsNormalClosure F K L ↔ IsNormalClosure F (integralClosure F K) L`; we can't state this yet because `integralClosure F K` needs to have a `Field` instance. -/ /-- The normal closure of `K/F` in `L/F`. -/ @[stacks 0BMF] noncomputable def IntermediateField.normalClosure : IntermediateField F L := ⨆ f : K →ₐ[F] L, f.fieldRange lemma normalClosure_def : normalClosure F K L = ⨆ f : K →ₐ[F] L, f.fieldRange := rfl variable {F K L} /-- A normal closure is always normal. -/ lemma IsNormalClosure.normal [h : IsNormalClosure F K L] : Normal F L := Normal.of_algEquiv topEquiv (h := h.adjoin_rootSet ▸ IntermediateField.normal_iSup (h := fun _ ↦ Normal.of_isSplittingField (hFEp := adjoin_rootSet_isSplittingField <| h.splits _))) lemma normalClosure_le_iff {K' : IntermediateField F L} : normalClosure F K L ≤ K' ↔ ∀ f : K →ₐ[F] L, f.fieldRange ≤ K' := iSup_le_iff lemma AlgHom.fieldRange_le_normalClosure (f : K →ₐ[F] L) : f.fieldRange ≤ normalClosure F K L := le_iSup AlgHom.fieldRange f namespace Algebra.IsAlgebraic variable [Algebra.IsAlgebraic F K] lemma normalClosure_le_iSup_adjoin : normalClosure F K L ≤ ⨆ x : K, IntermediateField.adjoin F ((minpoly F x).rootSet L) := iSup_le fun f _ ⟨x, hx⟩ ↦ le_iSup (α := IntermediateField F L) _ x <| IntermediateField.subset_adjoin F _ <| by rw [mem_rootSet_of_ne (minpoly.ne_zero (Algebra.IsIntegral.isIntegral x)), ← hx, AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, aeval_algHom_apply, minpoly.aeval, map_zero] variable (splits : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) include splits in lemma normalClosure_eq_iSup_adjoin_of_splits : normalClosure F K L = ⨆ x : K, IntermediateField.adjoin F ((minpoly F x).rootSet L) := normalClosure_le_iSup_adjoin.antisymm <| iSup_le fun x ↦ IntermediateField.adjoin_le_iff.mpr fun _ hy ↦ let ⟨φ, hφ⟩ := IntermediateField.exists_algHom_of_splits_of_aeval (fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, splits x⟩) (mem_rootSet.mp hy).2 le_iSup AlgHom.fieldRange φ ⟨x, hφ⟩ /-- If `K/F` is algebraic, the "generated by roots" condition in IsNormalClosure can be replaced by "generated by images of embeddings". -/ lemma isNormalClosure_iff : IsNormalClosure F K L ↔ (∀ x : K, (minpoly F x).Splits (algebraMap F L)) ∧ normalClosure F K L = ⊤ := by refine ⟨fun ⟨splits, h⟩ ↦ ⟨splits, ?_⟩, fun ⟨splits, h⟩ ↦ ⟨splits, ?_⟩⟩ <;> simpa only [normalClosure_eq_iSup_adjoin_of_splits splits] using h -- TODO: IntermediateField.isNormalClosure_iff similar to IntermediateField.isSplittingField_iff include splits in /-- `normalClosure F K L` is a valid normal closure if `K/F` is algebraic and all minimal polynomials of `K/F` splits in `L/F`. -/ lemma isNormalClosure_normalClosure : IsNormalClosure F K (normalClosure F K L) := by rw [isNormalClosure_iff]; constructor · rw [normalClosure_eq_iSup_adjoin_of_splits splits] exact fun x ↦ splits_of_splits (splits x) ((IntermediateField.subset_adjoin F _).trans <| SetLike.coe_subset_coe.mpr <| by apply le_iSup _ x) simp_rw [normalClosure, ← top_le_iff] refine fun x _ ↦ ((⨆ f : K →ₐ[F] L, f.fieldRange).val).injective.mem_set_image |>.mp ?_ rw [AlgHom.toRingHom_eq_coe, RingHom.coe_coe, coe_val, ← IntermediateField.coe_val, ← IntermediateField.coe_map, IntermediateField.map_iSup] refine (iSup_le fun f ↦ ?_ : normalClosure F K L ≤ _) x.2 refine le_iSup_of_le (f.codRestrict _ fun x ↦ f.fieldRange_le_normalClosure ⟨x, rfl⟩) ?_ rw [AlgHom.map_fieldRange, val, AlgHom.val_comp_codRestrict] end Algebra.IsAlgebraic /-- A normal closure of `K/F` embeds into any `L/F` where the minimal polynomials of `K/F` splits. -/ noncomputable def IsNormalClosure.lift [h : IsNormalClosure F K L] {L'} [Field L'] [Algebra F L'] (splits : ∀ x : K, (minpoly F x).Splits (algebraMap F L')) : L →ₐ[F] L' := by have := h.adjoin_rootSet; rw [← gc.l_iSup] at this refine Nonempty.some <| nonempty_algHom_of_adjoin_splits (fun x hx ↦ ⟨isAlgebraic_iff_isIntegral.mp ((h.normal).isAlgebraic x), ?_⟩) this obtain ⟨y, hx⟩ := Set.mem_iUnion.mp hx by_cases iy : IsIntegral F y · exact splits_of_splits_of_dvd _ (minpoly.ne_zero iy) (splits y) (minpoly.dvd F x (mem_rootSet.mp hx).2) · simp [minpoly.eq_zero iy] at hx /-- Normal closures of `K/F` are unique up to F-algebra isomorphisms. -/ noncomputable def IsNormalClosure.equiv {L'} [Field L'] [Algebra F L'] [h : IsNormalClosure F K L] [h' : IsNormalClosure F K L'] : L ≃ₐ[F] L' := have := h.normal AlgEquiv.ofBijective _ <| And.left <| Normal.toIsAlgebraic.algHom_bijective₂ (IsNormalClosure.lift fun _ : K ↦ h'.splits _) (IsNormalClosure.lift fun _ : K ↦ h.splits _) variable (F K L) instance isNormalClosure_normalClosure [ne : Nonempty (K →ₐ[F] L)] [h : Normal F L] : IsNormalClosure F K (normalClosure F K L) := by have ⟨φ⟩ := ne apply (h.toIsAlgebraic.of_injective φ φ.injective).isNormalClosure_normalClosure simp_rw [← minpoly.algHom_eq _ φ.injective] exact fun _ ↦ h.splits _ theorem normalClosure_eq_iSup_adjoin' [ne : Nonempty (K →ₐ[F] L)] [h : Normal F L] : normalClosure F K L = ⨆ x : K, adjoin F ((minpoly F x).rootSet L) := by have ⟨φ⟩ := ne refine h.toIsAlgebraic.of_injective φ φ.injective |>.normalClosure_eq_iSup_adjoin_of_splits fun x ↦ ?_ rw [← minpoly.algHom_eq _ φ.injective] apply h.splits theorem normalClosure_eq_iSup_adjoin [Algebra K L] [IsScalarTower F K L] [Normal F L] : normalClosure F K L = ⨆ x : K, adjoin F ((minpoly F x).rootSet L) := normalClosure_eq_iSup_adjoin' (ne := ⟨IsScalarTower.toAlgHom F K L⟩) namespace normalClosure /-- All `F`-`AlgHom`s from `K` to `L` factor through the normal closure of `K/F` in `L/F`. -/ noncomputable def algHomEquiv : (K →ₐ[F] normalClosure F K L) ≃ (K →ₐ[F] L) where toFun := (normalClosure F K L).val.comp invFun f := f.codRestrict _ fun x ↦ f.fieldRange_le_normalClosure ⟨x, rfl⟩ @[stacks 0BMG "(1) normality."] instance normal [h : Normal F L] : Normal F (normalClosure F K L) := by obtain _ | φ := isEmpty_or_nonempty (K →ₐ[F] L) · rw [normalClosure, iSup_of_empty]; exact Normal.of_algEquiv (botEquiv F L).symm · exact (isNormalClosure_normalClosure F K L).normal @[stacks 0BMG "When `L` is normal over `K`, this agrees with 0BMG (1) finiteness."] instance is_finiteDimensional [FiniteDimensional F K] : FiniteDimensional F (normalClosure F K L) := by haveI : ∀ f : K →ₐ[F] L, FiniteDimensional F f.fieldRange := fun f ↦ f.toLinearMap.finiteDimensional_range apply IntermediateField.finiteDimensional_iSup_of_finite variable [Algebra K L] [IsScalarTower F K L] noncomputable instance algebra : Algebra K (normalClosure F K L) := IntermediateField.algebra' { ⨆ f : K →ₐ[F] L, f.fieldRange with algebraMap_mem' := fun r ↦ (toAlgHom F K L).fieldRange_le_normalClosure ⟨r, rfl⟩ } instance : IsScalarTower F K (normalClosure F K L) := by apply of_algebraMap_eq' ext x exact algebraMap_apply F K L x instance : IsScalarTower K (normalClosure F K L) L := of_algebraMap_eq' rfl lemma restrictScalars_eq : (toAlgHom K (normalClosure F K L) L).fieldRange.restrictScalars F = normalClosure F K L := SetLike.ext' Subtype.range_val end normalClosure variable {F K L} open Cardinal in /-- An extension `L/F` in which every minimal polynomial of `K/F` splits is maximal with respect to `F`-embeddings of `K`, in the sense that `K →ₐ[F] L` achieves maximal cardinality. We construct an explicit injective function from an arbitrary `K →ₐ[F] L'` into `K →ₐ[F] L`, using an embedding of `normalClosure F K L'` into `L`. -/ noncomputable def Algebra.IsAlgebraic.algHomEmbeddingOfSplits [Algebra.IsAlgebraic F K] (h : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) (L' : Type*) [Field L'] [Algebra F L'] : (K →ₐ[F] L') ↪ (K →ₐ[F] L) := let φ : ↑(⨆ x : K, IntermediateField.adjoin F ((minpoly F x).rootSet L')) →ₐ[F] L := Nonempty.some <| by rw [← gc.l_iSup] refine nonempty_algHom_adjoin_of_splits fun x hx ↦ ?_ obtain ⟨y, hx⟩ := Set.mem_iUnion.mp hx refine ⟨isAlgebraic_iff_isIntegral.mp (isAlgebraic_of_mem_rootSet hx), ?_⟩ by_cases iy : IsIntegral F y · exact splits_of_splits_of_dvd _ (minpoly.ne_zero iy) (h y) (minpoly.dvd F x (mem_rootSet.mp hx).2) · simp [minpoly.eq_zero iy] at hx let φ' := (φ.comp <| inclusion normalClosure_le_iSup_adjoin) { toFun := φ'.comp ∘ (normalClosure.algHomEquiv F K L').symm inj' := fun _ _ h ↦ (normalClosure.algHomEquiv F K L').symm.injective <| by rw [DFunLike.ext'_iff] at h ⊢ exact φ'.injective.comp_left h } namespace IntermediateField variable (K K' : IntermediateField F L) lemma le_normalClosure : K ≤ normalClosure F K L := K.fieldRange_val.symm.trans_le K.val.fieldRange_le_normalClosure lemma normalClosure_of_normal [Normal F K] : normalClosure F K L = K := by simp only [normalClosure_def, AlgHom.fieldRange_of_normal, iSup_const] variable [Normal F L] lemma normalClosure_def' : normalClosure F K L = ⨆ f : L →ₐ[F] L, K.map f := by refine (normalClosure_def F K L).trans (le_antisymm (iSup_le (fun f ↦ ?_)) (iSup_le (fun f ↦ ?_))) · exact le_iSup_of_le (f.liftNormal L) (fun b ⟨a, h⟩ ↦ ⟨a, a.2, h ▸ f.liftNormal_commutes L a⟩) · exact le_iSup_of_le (f.comp K.val) (fun b ⟨a, h⟩ ↦ ⟨⟨a, h.1⟩, h.2⟩) lemma normalClosure_def'' : normalClosure F K L = ⨆ f : Gal(L/F), K.map f := by refine (normalClosure_def' K).trans (le_antisymm (iSup_le (fun f ↦ ?_)) (iSup_le (fun f ↦ ?_))) · exact le_iSup_of_le (f.restrictNormal' L) (fun b ⟨a, h⟩ ↦ ⟨a, h.1, h.2 ▸ f.restrictNormal_commutes L a⟩) · exact le_iSup_of_le f le_rfl lemma normalClosure_mono (h : K ≤ K') : normalClosure F K L ≤ normalClosure F K' L := by rw [normalClosure_def', normalClosure_def'] exact iSup_mono (fun f ↦ map_mono f h) variable (F L) /-- `normalClosure` as a `ClosureOperator`. -/ @[simps] noncomputable def closureOperator : ClosureOperator (IntermediateField F L) where toFun := fun K ↦ normalClosure F K L monotone' := fun K K' ↦ normalClosure_mono K K' le_closure' := le_normalClosure idempotent' := fun K ↦ normalClosure_of_normal (normalClosure F K L) variable {K : IntermediateField F L} {F L} lemma normal_iff_normalClosure_eq : Normal F K ↔ normalClosure F K L = K := ⟨@normalClosure_of_normal (K := K), fun h ↦ h ▸ normalClosure.normal F K L⟩ lemma normal_iff_normalClosure_le : Normal F K ↔ normalClosure F K L ≤ K := normal_iff_normalClosure_eq.trans (le_normalClosure K).ge_iff_eq'.symm lemma normal_iff_forall_fieldRange_le : Normal F K ↔ ∀ σ : K →ₐ[F] L, σ.fieldRange ≤ K := by rw [normal_iff_normalClosure_le, normalClosure_def, iSup_le_iff] lemma normal_iff_forall_map_le : Normal F K ↔ ∀ σ : L →ₐ[F] L, K.map σ ≤ K := by rw [normal_iff_normalClosure_le, normalClosure_def', iSup_le_iff] lemma normal_iff_forall_map_le' : Normal F K ↔ ∀ σ : Gal(L/F), K.map ↑σ ≤ K := by rw [normal_iff_normalClosure_le, normalClosure_def'', iSup_le_iff] /-- If `L/K/F` is a field tower where `L/F` is normal, then `K` is normal over `F` if and only if `σ(K) = K` for every `σ ∈ K →ₐ[F] L`. -/ @[stacks 09HQ "stronger version replacing an algebraic closure by a normal extension"] lemma normal_iff_forall_fieldRange_eq : Normal F K ↔ ∀ σ : K →ₐ[F] L, σ.fieldRange = K := ⟨@AlgHom.fieldRange_of_normal (E := K), normal_iff_forall_fieldRange_le.2 ∘ fun h σ ↦ (h σ).le⟩ lemma normal_iff_forall_map_eq : Normal F K ↔ ∀ σ : L →ₐ[F] L, K.map σ = K := ⟨fun h σ ↦ (K.fieldRange_val ▸ AlgHom.map_fieldRange K.val σ).trans (normal_iff_forall_fieldRange_eq.1 h _), fun h ↦ normal_iff_forall_map_le.2 (fun σ ↦ (h σ).le)⟩ lemma normal_iff_forall_map_eq' : Normal F K ↔ ∀ σ : Gal(L/F), K.map ↑σ = K := ⟨fun h σ ↦ normal_iff_forall_map_eq.1 h σ, fun h ↦ normal_iff_forall_map_le'.2 (fun σ ↦ (h σ).le)⟩ @[simp] lemma normalClosure_map_eq (K : IntermediateField F L) (σ : L →ₐ[F] L) : normalClosure F (K.map σ) L = normalClosure F K L := by have (σ : Gal(L/F)) : normalClosure F (K.map (σ : L →ₐ[F] L)) L = normalClosure F K L := by simp_rw [normalClosure_def'', map_map] exact (Equiv.mulRight σ).iSup_congr fun _ ↦ rfl exact this ((Algebra.IsAlgebraic.algEquivEquivAlgHom _ _).symm σ) @[simp] theorem normalClosure_le_iff_of_normal {K₁ K₂ : IntermediateField F L} [Normal F K₂] : normalClosure F K₁ L ≤ K₂ ↔ K₁ ≤ K₂ := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · rw [normalClosure_le_iff] at h simpa only [fieldRange_val] using h K₁.val · rw [← normalClosure_of_normal K₂] exact normalClosure_mono K₁ K₂ h end IntermediateField
.lake/packages/mathlib/Mathlib/FieldTheory/Normal/Basic.lean
import Mathlib.FieldTheory.Extension import Mathlib.FieldTheory.Normal.Defs import Mathlib.GroupTheory.Solvable import Mathlib.FieldTheory.SplittingField.Construction /-! # Normal field extensions In this file we prove that for a finite extension, being normal is the same as being a splitting field (`Normal.of_isSplittingField` and `Normal.exists_isSplittingField`). ## Additional Results * `Algebra.IsQuadraticExtension.normal`: the instance that a quadratic extension, given as a class `Algebra.IsQuadraticExtension`, is normal. -/ noncomputable section open Polynomial IsScalarTower variable (F K : Type*) [Field F] [Field K] [Algebra F K] theorem Normal.exists_isSplittingField [h : Normal F K] [FiniteDimensional F K] : ∃ p : F[X], IsSplittingField F K p := by classical let s := Module.Basis.ofVectorSpace F K refine ⟨∏ x, minpoly F (s x), splits_prod _ fun x _ => h.splits (s x), Subalgebra.toSubmodule.injective ?_⟩ rw [Algebra.top_toSubmodule, eq_top_iff, ← s.span_eq, Submodule.span_le, Set.range_subset_iff] refine fun x => Algebra.subset_adjoin (Multiset.mem_toFinset.mpr <| (mem_roots <| mt (Polynomial.map_eq_zero <| algebraMap F K).1 <| Finset.prod_ne_zero_iff.2 fun x _ => ?_).2 ?_) · exact minpoly.ne_zero (h.isIntegral (s x)) rw [IsRoot.def, eval_map, ← aeval_def, map_prod] exact Finset.prod_eq_zero (Finset.mem_univ _) (minpoly.aeval _ _) section NormalTower variable (E : Type*) [Field E] [Algebra F E] [Algebra K E] [IsScalarTower F K E] variable {E F} open IntermediateField @[stacks 09HU "Normal part"] theorem Normal.of_isSplittingField (p : F[X]) [hFEp : IsSplittingField F E p] : Normal F E := by rcases eq_or_ne p 0 with (rfl | hp) · have := hFEp.adjoin_rootSet rw [rootSet_zero, Algebra.adjoin_empty] at this exact Normal.of_algEquiv (AlgEquiv.ofBijective (Algebra.ofId F E) (Algebra.bijective_algebraMap_iff.2 this.symm)) refine normal_iff.mpr fun x ↦ ?_ haveI : FiniteDimensional F E := IsSplittingField.finiteDimensional E p have hx := IsIntegral.of_finite F x let L := (p * minpoly F x).SplittingField have hL := splits_of_splits_mul' _ ?_ (SplittingField.splits (p * minpoly F x)) · let j : E →ₐ[F] L := IsSplittingField.lift E p hL.1 refine ⟨hx, splits_of_comp _ (j : E →+* L) (j.comp_algebraMap ▸ hL.2) fun a ha ↦ ?_⟩ rw [j.comp_algebraMap] at ha letI : Algebra F⟮x⟯ L := ((algHomAdjoinIntegralEquiv F hx).symm ⟨a, ha⟩).toRingHom.toAlgebra let j' : E →ₐ[F⟮x⟯] L := IsSplittingField.lift E (p.map (algebraMap F F⟮x⟯)) ?_ · change a ∈ j.range rw [← IsSplittingField.adjoin_rootSet_eq_range E p j, IsSplittingField.adjoin_rootSet_eq_range E p (j'.restrictScalars F)] exact ⟨x, (j'.commutes _).trans (algHomAdjoinIntegralEquiv_symm_apply_gen F hx _)⟩ · rw [splits_map_iff, ← IsScalarTower.algebraMap_eq]; exact hL.1 · rw [Polynomial.map_ne_zero_iff (algebraMap F L).injective, mul_ne_zero_iff] exact ⟨hp, minpoly.ne_zero hx⟩ instance Polynomial.SplittingField.instNormal (p : F[X]) : Normal F p.SplittingField := Normal.of_isSplittingField p end NormalTower namespace IntermediateField /-- A compositum of normal extensions is normal. -/ instance normal_iSup {ι : Type*} (t : ι → IntermediateField F K) [h : ∀ i, Normal F (t i)] : Normal F (⨆ i, t i : IntermediateField F K) := by refine { toIsAlgebraic := isAlgebraic_iSup fun i => (h i).1, splits' := fun x => ?_ } obtain ⟨s, hx⟩ := exists_finset_of_mem_supr'' (fun i => (h i).1) x.2 let E : IntermediateField F K := ⨆ i ∈ s, adjoin F ((minpoly F (i.2 :)).rootSet K) have hF : Normal F E := by haveI : IsSplittingField F E (∏ i ∈ s, minpoly F i.snd) := by refine isSplittingField_iSup ?_ fun i _ => adjoin_rootSet_isSplittingField ?_ · exact Finset.prod_ne_zero_iff.mpr fun i _ => minpoly.ne_zero ((h i.1).isIntegral i.2) · exact Polynomial.splits_comp_of_splits _ (algebraMap (t i.1) K) ((h i.1).splits i.2) apply Normal.of_isSplittingField (∏ i ∈ s, minpoly F i.2) have hE : E ≤ ⨆ i, t i := by refine iSup_le fun i => iSup_le fun _ => le_iSup_of_le i.1 ?_ rw [adjoin_le_iff, ← image_rootSet ((h i.1).splits i.2) (t i.1).val] exact fun _ ⟨a, _, h⟩ => h ▸ a.2 have := hF.splits ⟨x, hx⟩ rw [minpoly_eq, Subtype.coe_mk, ← minpoly_eq] at this exact Polynomial.splits_comp_of_splits _ (inclusion hE).toRingHom this /-- If a set of algebraic elements in a field extension `K/F` have minimal polynomials that split in another extension `L/F`, then all minimal polynomials in the intermediate field generated by the set also split in `L/F`. -/ @[stacks 0BR3 "first part"] theorem splits_of_mem_adjoin {L} [Field L] [Algebra F L] {S : Set K} (splits : ∀ x ∈ S, IsIntegral F x ∧ (minpoly F x).Splits (algebraMap F L)) {x : K} (hx : x ∈ adjoin F S) : (minpoly F x).Splits (algebraMap F L) := by let E : IntermediateField F L := ⨆ x : S, adjoin F ((minpoly F x.val).rootSet L) have normal : Normal F E := normal_iSup (h := fun x ↦ Normal.of_isSplittingField (hFEp := adjoin_rootSet_isSplittingField (splits x x.2).2)) have : ∀ x ∈ S, (minpoly F x).Splits (algebraMap F E) := fun x hx ↦ splits_of_splits (splits x hx).2 fun y hy ↦ (le_iSup _ ⟨x, hx⟩ : _ ≤ E) (subset_adjoin F _ <| by exact hy) obtain ⟨φ⟩ := nonempty_algHom_adjoin_of_splits fun x hx ↦ ⟨(splits x hx).1, this x hx⟩ convert splits_comp_of_splits _ E.val.toRingHom (normal.splits <| φ ⟨x, hx⟩) rw [minpoly.algHom_eq _ φ.injective, ← minpoly.algHom_eq _ (adjoin F S).val.injective, val_mk] instance normal_sup (E E' : IntermediateField F K) [Normal F E] [Normal F E'] : Normal F (E ⊔ E' : IntermediateField F K) := iSup_bool_eq (f := Bool.rec E' E) ▸ normal_iSup (h := by rintro (_ | _) <;> infer_instance) /-- An intersection of normal extensions is normal. -/ @[stacks 09HP] instance normal_iInf {ι : Type*} [hι : Nonempty ι] (t : ι → IntermediateField F K) [h : ∀ i, Normal F (t i)] : Normal F (⨅ i, t i : IntermediateField F K) := by refine { toIsAlgebraic := ?_, splits' := fun x => ?_ } · let f := inclusion (iInf_le t hι.some) exact Algebra.IsAlgebraic.of_injective f f.injective · have hx : ∀ i, Splits (algebraMap F (t i)) (minpoly F x) := by intro i rw [← minpoly.algHom_eq (inclusion (iInf_le t i)) (inclusion (iInf_le t i)).injective] exact (h i).splits' (inclusion (iInf_le t i) x) simp only [splits_iff_mem (splits_of_isScalarTower K (hx hι.some))] at hx ⊢ rintro y hy - ⟨-, ⟨i, rfl⟩, rfl⟩ exact hx i y hy @[stacks 09HP] instance normal_inf (E E' : IntermediateField F K) [Normal F E] [Normal F E'] : Normal F (E ⊓ E' : IntermediateField F K) := iInf_bool_eq (f := Bool.rec E' E) ▸ normal_iInf (h := by rintro (_ | _) <;> infer_instance) end IntermediateField variable {F} {K} variable {K₁ K₂ K₃ : Type*} [Field K₁] [Field K₂] [Field K₃] [Algebra F K₁] [Algebra F K₂] [Algebra F K₃] (ϕ : K₁ →ₐ[F] K₂) (χ : K₁ ≃ₐ[F] K₂) (ψ : K₂ →ₐ[F] K₃) (ω : K₂ ≃ₐ[F] K₃) section Restrict variable (E : Type*) [Field E] [Algebra F E] [Algebra E K₁] [Algebra E K₂] [Algebra E K₃] [IsScalarTower F E K₁] [IsScalarTower F E K₂] [IsScalarTower F E K₃] theorem AlgHom.fieldRange_of_normal {E : IntermediateField F K} [Normal F E] (f : E →ₐ[F] K) : f.fieldRange = E := by let g := f.restrictNormal' E rw [← show E.val.comp ↑g = f from DFunLike.ext_iff.mpr (f.restrictNormal_commutes E), ← AlgHom.map_fieldRange, AlgEquiv.fieldRange_eq_top g, ← AlgHom.fieldRange_eq_map, IntermediateField.fieldRange_val] end Restrict section lift variable (E : Type*) [Field E] [Algebra F E] [Algebra K₁ E] [Algebra K₂ E] [IsScalarTower F K₁ E] [IsScalarTower F K₂ E] /-- If `E/Kᵢ/F` are towers of fields with `E/F` normal then we can lift an algebra homomorphism `ϕ : K₁ →ₐ[F] K₂` to `ϕ.liftNormal E : E →ₐ[F] E`. -/ @[stacks 0BME "Part 2"] noncomputable def AlgHom.liftNormal [h : Normal F E] : E →ₐ[F] E := @AlgHom.restrictScalars F K₁ E E _ _ _ _ _ _ ((IsScalarTower.toAlgHom F K₂ E).comp ϕ).toRingHom.toAlgebra _ _ _ _ <| Nonempty.some <| @IntermediateField.nonempty_algHom_of_adjoin_splits _ _ _ _ _ _ _ ((IsScalarTower.toAlgHom F K₂ E).comp ϕ).toRingHom.toAlgebra _ (fun x _ ↦ ⟨(h.out x).1.tower_top, splits_of_splits_of_dvd _ (map_ne_zero (minpoly.ne_zero (h.out x).1)) (by rw [splits_map_iff, ← IsScalarTower.algebraMap_eq] exact (h.out x).2) (minpoly.dvd_map_of_isScalarTower F K₁ x)⟩) (IntermediateField.adjoin_univ _ _) @[simp] theorem AlgHom.liftNormal_commutes [Normal F E] (x : K₁) : ϕ.liftNormal E (algebraMap K₁ E x) = algebraMap K₂ E (ϕ x) := -- We have to specify one `Algebra` instance by unification, not synthesis. @AlgHom.commutes K₁ E E _ _ _ _ (_) _ _ @[simp] theorem AlgHom.restrict_liftNormal (ϕ : K₁ →ₐ[F] K₁) [Normal F K₁] [Normal F E] : (ϕ.liftNormal E).restrictNormal K₁ = ϕ := AlgHom.ext fun x => (algebraMap K₁ E).injective (Eq.trans (AlgHom.restrictNormal_commutes _ K₁ x) (ϕ.liftNormal_commutes E x)) /-- If `E/Kᵢ/F` are towers of fields with `E/F` normal then we can lift an algebra isomorphism `ϕ : K₁ ≃ₐ[F] K₂` to `ϕ.liftNormal E : Gal(E/F)`. -/ noncomputable def AlgEquiv.liftNormal [Normal F E] : Gal(E/F) := AlgEquiv.ofBijective (χ.toAlgHom.liftNormal E) (AlgHom.normal_bijective F E E _) @[simp] theorem AlgEquiv.liftNormal_commutes [Normal F E] (x : K₁) : χ.liftNormal E (algebraMap K₁ E x) = algebraMap K₂ E (χ x) := χ.toAlgHom.liftNormal_commutes E x @[simp] theorem AlgEquiv.restrict_liftNormal (χ : K₁ ≃ₐ[F] K₁) [Normal F K₁] [Normal F E] : (χ.liftNormal E).restrictNormal K₁ = χ := AlgEquiv.ext fun x => (algebraMap K₁ E).injective (Eq.trans (AlgEquiv.restrictNormal_commutes _ K₁ x) (χ.liftNormal_commutes E x)) /-- The group homomorphism given by restricting an algebra isomorphism to a normal subfield is surjective. -/ theorem AlgEquiv.restrictNormalHom_surjective [Normal F K₁] [Normal F E] : Function.Surjective (AlgEquiv.restrictNormalHom K₁ : Gal(E/F) → K₁ ≃ₐ[F] K₁) := fun χ => ⟨χ.liftNormal E, χ.restrict_liftNormal E⟩ open IntermediateField in theorem Normal.minpoly_eq_iff_mem_orbit [h : Normal F E] {x y : E} : minpoly F x = minpoly F y ↔ x ∈ MulAction.orbit Gal(E/F) y := by refine ⟨fun he ↦ ?_, fun ⟨f, he⟩ ↦ he ▸ minpoly.algEquiv_eq f y⟩ obtain ⟨φ, hφ⟩ := exists_algHom_of_splits_of_aeval (normal_iff.mp h) (he ▸ minpoly.aeval F x) exact ⟨AlgEquiv.ofBijective φ (φ.normal_bijective F E E), hφ⟩ variable (F K₁) theorem isSolvable_of_isScalarTower [Normal F K₁] [h1 : IsSolvable (K₁ ≃ₐ[F] K₁)] [h2 : IsSolvable (E ≃ₐ[K₁] E)] : IsSolvable Gal(E/F) := by let f : (E ≃ₐ[K₁] E) →* Gal(E/F) := { toFun := fun ϕ => AlgEquiv.ofAlgHom (ϕ.toAlgHom.restrictScalars F) (ϕ.symm.toAlgHom.restrictScalars F) (AlgHom.ext fun x => ϕ.apply_symm_apply x) (AlgHom.ext fun x => ϕ.symm_apply_apply x) map_one' := AlgEquiv.ext fun _ => rfl map_mul' := fun _ _ => AlgEquiv.ext fun _ => rfl } refine solvable_of_ker_le_range f (AlgEquiv.restrictNormalHom K₁) fun ϕ hϕ => ⟨{ ϕ with commutes' := fun x => ?_ }, AlgEquiv.ext fun _ => rfl⟩ exact Eq.trans (ϕ.restrictNormal_commutes K₁ x).symm (congr_arg _ (AlgEquiv.ext_iff.mp hϕ x)) end lift namespace minpoly variable {K L : Type _} [Field K] [Field L] [Algebra K L] open AlgEquiv IntermediateField /-- If `x : L` is a root of `minpoly K y`, then we can find `(σ : Gal(L/K))` with `σ x = y`. That is, `x` and `y` are Galois conjugates. -/ theorem exists_algEquiv_of_root [Normal K L] {x y : L} (hy : IsAlgebraic K y) (h_ev : (Polynomial.aeval x) (minpoly K y) = 0) : ∃ σ : Gal(L/K), σ x = y := by have hx : IsAlgebraic K x := ⟨minpoly K y, ne_zero hy.isIntegral, h_ev⟩ set f : K⟮x⟯ ≃ₐ[K] K⟮y⟯ := algEquiv hx (eq_of_root hy h_ev) have hxy : (liftNormal f L) ((algebraMap (↥K⟮x⟯) L) (AdjoinSimple.gen K x)) = y := by rw [liftNormal_commutes f L, algEquiv_apply, AdjoinSimple.algebraMap_gen K y] exact ⟨(liftNormal f L), hxy⟩ /-- If `x : L` is a root of `minpoly K y`, then we can find `(σ : Gal(L/K))` with `σ y = x`. That is, `x` and `y` are Galois conjugates. -/ theorem exists_algEquiv_of_root' [Normal K L] {x y : L} (hy : IsAlgebraic K y) (h_ev : (Polynomial.aeval x) (minpoly K y) = 0) : ∃ σ : Gal(L/K), σ y = x := by obtain ⟨σ, hσ⟩ := exists_algEquiv_of_root hy h_ev use σ.symm rw [← hσ, symm_apply_apply] end minpoly /-- A quadratic extension is normal. -/ instance Algebra.IsQuadraticExtension.normal (F K : Type*) [Field F] [Field K] [Algebra F K] [IsQuadraticExtension F K] : Normal F K where splits' := by intro x obtain h | h := le_iff_lt_or_eq.mp (finrank_eq_two F K ▸ minpoly.natDegree_le x) · exact splits_of_natDegree_le_one _ (by rwa [Nat.le_iff_lt_add_one]) · exact splits_of_natDegree_eq_two _ h (minpoly.aeval F x)
.lake/packages/mathlib/Mathlib/FieldTheory/Normal/Defs.lean
import Mathlib.Algebra.Polynomial.Splits import Mathlib.FieldTheory.Galois.Notation import Mathlib.FieldTheory.IntermediateField.Basic import Mathlib.FieldTheory.Minpoly.Field /-! # Normal field extensions In this file we define normal field extensions. ## Main Definitions - `Normal F K` where `K` is a field extension of `F`. -/ noncomputable section open Polynomial IsScalarTower variable (F K : Type*) [Field F] [Field K] [Algebra F K] /-- Typeclass for normal field extensions: an algebraic extension of fields `K/F` is *normal* if the minimal polynomial of every element `x` in `K` splits in `K`, i.e. every `F`-conjugate of `x` is in `K`. -/ @[stacks 09HM] class Normal : Prop extends Algebra.IsAlgebraic F K where splits' (x : K) : Splits (algebraMap F K) (minpoly F x) variable {F K} theorem Normal.isIntegral (_ : Normal F K) (x : K) : IsIntegral F x := Algebra.IsIntegral.isIntegral x theorem Normal.splits (_ : Normal F K) (x : K) : Splits (algebraMap F K) (minpoly F x) := Normal.splits' x theorem normal_iff : Normal F K ↔ ∀ x : K, IsIntegral F x ∧ Splits (algebraMap F K) (minpoly F x) := ⟨fun h x => ⟨h.isIntegral x, h.splits x⟩, fun h => { isAlgebraic := fun x => (h x).1.isAlgebraic splits' := fun x => (h x).2 }⟩ theorem Normal.out : Normal F K → ∀ x : K, IsIntegral F x ∧ Splits (algebraMap F K) (minpoly F x) := normal_iff.1 variable (F K) instance normal_self : Normal F F where isAlgebraic := fun _ => isIntegral_algebraMap.isAlgebraic splits' := fun x => (minpoly.eq_X_sub_C' x).symm ▸ splits_X_sub_C _ section NormalTower variable (E : Type*) [Field E] [Algebra F E] [Algebra K E] [IsScalarTower F K E] @[stacks 09HN] theorem Normal.tower_top_of_normal [h : Normal F E] : Normal K E := normal_iff.2 fun x => by obtain ⟨hx, hhx⟩ := h.out x rw [algebraMap_eq F K E] at hhx exact ⟨hx.tower_top, Polynomial.splits_of_splits_of_dvd (algebraMap K E) (Polynomial.map_ne_zero (minpoly.ne_zero hx)) ((Polynomial.splits_map_iff (algebraMap F K) (algebraMap K E)).mpr hhx) (minpoly.dvd_map_of_isScalarTower F K x)⟩ theorem AlgHom.normal_bijective [h : Normal F E] (ϕ : E →ₐ[F] K) : Function.Bijective ϕ := h.toIsAlgebraic.bijective_of_isScalarTower' ϕ variable {E F} variable {E' : Type*} [Field E'] [Algebra F E'] theorem Normal.of_algEquiv [h : Normal F E] (f : E ≃ₐ[F] E') : Normal F E' := by rw [normal_iff] at h ⊢ intro x; specialize h (f.symm x) rw [← f.apply_symm_apply x, minpoly.algEquiv_eq, ← f.toAlgHom.comp_algebraMap] exact ⟨h.1.map f, splits_comp_of_splits _ _ h.2⟩ theorem AlgEquiv.transfer_normal (f : E ≃ₐ[F] E') : Normal F E ↔ Normal F E' := ⟨fun _ ↦ Normal.of_algEquiv f, fun _ ↦ Normal.of_algEquiv f.symm⟩ theorem Normal.of_equiv_equiv {M N : Type*} [Field N] [Field M] [Algebra M N] [Algebra.IsAlgebraic F E] [h : Normal F E] {f : F ≃+* M} {g : E ≃+* N} (hcomp : (algebraMap M N).comp f = (g : E →+* N).comp (algebraMap F E)) : Normal M N := by rw [normal_iff] at h ⊢ intro x rw [← g.apply_symm_apply x] refine ⟨(h (g.symm x)).1.map_of_comp_eq _ _ hcomp, ?_⟩ rw [← minpoly.map_eq_of_equiv_equiv hcomp, Polynomial.splits_map_iff, hcomp] exact Polynomial.splits_comp_of_splits _ _ (h (g.symm x)).2 end NormalTower namespace IntermediateField variable {F K} variable {L : Type*} [Field L] [Algebra F L] [Algebra K L] [IsScalarTower F K L] @[simp] theorem restrictScalars_normal {E : IntermediateField K L} : Normal F (E.restrictScalars F) ↔ Normal F E := Iff.rfl end IntermediateField variable {F} {K} variable {K₁ K₂ K₃ : Type*} [Field K₁] [Field K₂] [Field K₃] [Algebra F K₁] [Algebra F K₂] [Algebra F K₃] (ϕ : K₁ →ₐ[F] K₂) (χ : K₁ ≃ₐ[F] K₂) (ψ : K₂ →ₐ[F] K₃) (ω : K₂ ≃ₐ[F] K₃) section Restrict variable (E : Type*) [Field E] [Algebra F E] [Algebra E K₁] [Algebra E K₂] [Algebra E K₃] [IsScalarTower F E K₁] [IsScalarTower F E K₂] [IsScalarTower F E K₃] /-- Restrict algebra homomorphism to image of normal subfield -/ def AlgHom.restrictNormalAux [h : Normal F E] : (toAlgHom F E K₁).range →ₐ[F] (toAlgHom F E K₂).range where toFun x := ⟨ϕ x, by suffices (toAlgHom F E K₁).range.map ϕ ≤ _ by exact this ⟨x, Subtype.mem x, rfl⟩ rintro x ⟨y, ⟨z, hy⟩, hx⟩ rw [← hx, ← hy] apply minpoly.mem_range_of_degree_eq_one E refine Or.resolve_left (h.splits z).def (minpoly.ne_zero (h.isIntegral z)) (minpoly.irreducible ?_) (minpoly.dvd E _ (by simp [aeval_algHom_apply])) simp only [AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom] suffices IsIntegral F _ by exact this.tower_top exact ((h.isIntegral z).map <| toAlgHom F E K₁).map ϕ⟩ map_zero' := Subtype.ext (map_zero _) map_one' := Subtype.ext (map_one _) map_add' x y := Subtype.ext <| by simp map_mul' x y := Subtype.ext <| by simp commutes' x := Subtype.ext (ϕ.commutes x) /-- Restrict algebra homomorphism to normal subfield. -/ @[stacks 0BME "Part 1"] def AlgHom.restrictNormal [Normal F E] : E →ₐ[F] E := ((AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F E K₂)).symm.toAlgHom.comp (ϕ.restrictNormalAux E)).comp (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F E K₁)).toAlgHom /-- Restrict algebra homomorphism to normal subfield (`AlgEquiv` version) -/ def AlgHom.restrictNormal' [Normal F E] : Gal(E/F) := AlgEquiv.ofBijective (AlgHom.restrictNormal ϕ E) (AlgHom.normal_bijective F E E _) @[simp] theorem AlgHom.restrictNormal_commutes [Normal F E] (x : E) : algebraMap E K₂ (ϕ.restrictNormal E x) = ϕ (algebraMap E K₁ x) := Subtype.ext_iff.mp (AlgEquiv.apply_symm_apply (AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F E K₂)) (ϕ.restrictNormalAux E ⟨IsScalarTower.toAlgHom F E K₁ x, x, rfl⟩)) theorem AlgHom.restrictNormal_comp [Normal F E] : (ψ.restrictNormal E).comp (ϕ.restrictNormal E) = (ψ.comp ϕ).restrictNormal E := AlgHom.ext fun _ => (algebraMap E K₃).injective (by simp only [AlgHom.comp_apply, AlgHom.restrictNormal_commutes]) /-- Restrict algebra isomorphism to a normal subfield -/ def AlgEquiv.restrictNormal [Normal F E] : Gal(E/F) := AlgHom.restrictNormal' χ.toAlgHom E @[simp] theorem AlgEquiv.restrictNormal_commutes [Normal F E] (x : E) : algebraMap E K₂ (χ.restrictNormal E x) = χ (algebraMap E K₁ x) := χ.toAlgHom.restrictNormal_commutes E x theorem AlgEquiv.restrictNormal_trans [Normal F E] : (χ.trans ω).restrictNormal E = (χ.restrictNormal E).trans (ω.restrictNormal E) := AlgEquiv.ext fun _ => (algebraMap E K₃).injective (by simp only [AlgEquiv.trans_apply, AlgEquiv.restrictNormal_commutes]) /-- Restriction to a normal subfield as a group homomorphism -/ def AlgEquiv.restrictNormalHom [Normal F E] : Gal(K₁/F) →* Gal(E/F) := MonoidHom.mk' (fun χ => χ.restrictNormal E) fun ω χ => χ.restrictNormal_trans ω E lemma AlgEquiv.restrictNormalHom_apply (L : IntermediateField F K₁) [Normal F L] (σ : Gal(K₁/F)) (x : L) : restrictNormalHom L σ x = σ x := AlgEquiv.restrictNormal_commutes σ L x variable (F K₁) /-- If `K₁/E/F` is a tower of fields with `E/F` normal then `AlgHom.restrictNormal'` is an equivalence. -/ @[simps, stacks 0BR4] def Normal.algHomEquivAut [Normal F E] : (E →ₐ[F] K₁) ≃ Gal(E/F) where toFun σ := AlgHom.restrictNormal' σ E invFun σ := (IsScalarTower.toAlgHom F E K₁).comp σ.toAlgHom left_inv σ := by ext simp [AlgHom.restrictNormal'] right_inv σ := by ext simp only [AlgHom.restrictNormal', AlgEquiv.toAlgHom_eq_coe, AlgEquiv.coe_ofBijective] apply FaithfulSMul.algebraMap_injective E K₁ rw [AlgHom.restrictNormal_commutes] simp end Restrict section lift /-- The group homomorphism given by restricting an algebra isomorphism to itself is the identity map. -/ @[simp] theorem AlgEquiv.restrictNormalHom_id (F K : Type*) [Field F] [Field K] [Algebra F K] [Normal F K] : AlgEquiv.restrictNormalHom K = MonoidHom.id Gal(K/F) := by ext f x dsimp only [restrictNormalHom, MonoidHom.mk'_apply, MonoidHom.id_apply] apply (algebraMap K K).injective rw [AlgEquiv.restrictNormal_commutes] simp only [Algebra.algebraMap_self, RingHom.id_apply] namespace IsScalarTower /-- In a scalar tower `K₃/K₂/K₁/F` with `K₁` and `K₂` are normal over `F`, the group homomorphism given by the restriction of algebra isomorphisms of `K₃` to `K₁` is equal to the composition of the group homomorphism given by the restricting an algebra isomorphism of `K₃` to `K₂` and the group homomorphism given by the restricting an algebra isomorphism of `K₂` to `K₁` -/ theorem AlgEquiv.restrictNormalHom_comp (F K₁ K₂ K₃ : Type*) [Field F] [Field K₁] [Field K₂] [Field K₃] [Algebra F K₁] [Algebra F K₂] [Algebra F K₃] [Algebra K₁ K₂] [Algebra K₁ K₃] [Algebra K₂ K₃] [IsScalarTower F K₁ K₃] [IsScalarTower F K₁ K₂] [IsScalarTower F K₂ K₃] [IsScalarTower K₁ K₂ K₃] [Normal F K₁] [Normal F K₂] : AlgEquiv.restrictNormalHom K₁ = (AlgEquiv.restrictNormalHom K₁).comp (AlgEquiv.restrictNormalHom (F := F) (K₁ := K₃) K₂) := by ext f x apply (algebraMap K₁ K₃).injective rw [IsScalarTower.algebraMap_eq K₁ K₂ K₃] simp only [AlgEquiv.restrictNormalHom, MonoidHom.mk'_apply, RingHom.coe_comp, Function.comp_apply, ← algebraMap_apply, AlgEquiv.restrictNormal_commutes, MonoidHom.coe_comp] theorem AlgEquiv.restrictNormalHom_comp_apply (K₁ K₂ : Type*) {F K₃ : Type*} [Field F] [Field K₁] [Field K₂] [Field K₃] [Algebra F K₁] [Algebra F K₂] [Algebra F K₃] [Algebra K₁ K₂] [Algebra K₁ K₃] [Algebra K₂ K₃] [IsScalarTower F K₁ K₃] [IsScalarTower F K₁ K₂] [IsScalarTower F K₂ K₃] [IsScalarTower K₁ K₂ K₃] [Normal F K₁] [Normal F K₂] (f : K₃ ≃ₐ[F] K₃) : AlgEquiv.restrictNormalHom K₁ f = (AlgEquiv.restrictNormalHom K₁) (AlgEquiv.restrictNormalHom K₂ f) := by rw [IsScalarTower.AlgEquiv.restrictNormalHom_comp F K₁ K₂ K₃, MonoidHom.comp_apply] end IsScalarTower end lift
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/Abelian.lean
import Mathlib.FieldTheory.Galois.Infinite /-! # Abelian extensions In this file, we define the typeclass of abelian extensions and provide some basic API. -/ variable (K L M : Type*) [Field K] [Field L] [Algebra K L] variable [Field M] [Algebra K M] [Algebra L M] [IsScalarTower K L M] /-- The class of abelian extensions, defined as galois extensions whose galois group is commutative. -/ class IsAbelianGalois (K L : Type*) [Field K] [Field L] [Algebra K L] : Prop extends IsGalois K L, IsMulCommutative Gal(L/K) lemma IsAbelianGalois.tower_bot [IsAbelianGalois K M] : IsAbelianGalois K L := have : IsGalois K L := ((AlgEquiv.ofBijective (IsScalarTower.toAlgHom K L M).rangeRestrict ⟨RingHom.injective _, AlgHom.rangeRestrict_surjective _⟩).transfer_galois (E' := (IsScalarTower.toAlgHom K L M).fieldRange)).mpr ((InfiniteGalois.normal_iff_isGalois _).mp inferInstance) { is_comm.comm x y := by obtain ⟨x, rfl⟩ := AlgEquiv.restrictNormalHom_surjective M x obtain ⟨y, rfl⟩ := AlgEquiv.restrictNormalHom_surjective M y rw [← map_mul, ← map_mul, mul_comm] } lemma IsAbelianGalois.tower_top [IsAbelianGalois K M] : IsAbelianGalois L M := have : IsGalois L M := .tower_top_of_isGalois K L M { is_comm.comm x y := AlgEquiv.restrictScalars_injective K (mul_comm (x.restrictScalars K) (y.restrictScalars K)) } variable {K L M} in omit [IsScalarTower K L M] [Algebra L M] in lemma IsAbelianGalois.of_algHom (f : L →ₐ[K] M) [IsAbelianGalois K M] : IsAbelianGalois K L := letI := f.toRingHom.toAlgebra haveI := IsScalarTower.of_algebraMap_eq' f.comp_algebraMap.symm .tower_bot K L M instance [IsAbelianGalois K L] (K' : IntermediateField K L) : IsAbelianGalois K K' := .tower_bot K K' L instance (K L : Type*) [Field K] [Field L] [Algebra K L] [IsAbelianGalois K L] (K' : IntermediateField K L) : IsAbelianGalois K' L := .tower_top K _ L instance : IsAbelianGalois K K where is_comm.comm _ _ := Subsingleton.elim _ _ instance : IsAbelianGalois K (⊥ : IntermediateField K L) := .of_algHom (IntermediateField.botEquiv K L).toAlgHom lemma IsAbelianGalois.of_isCyclic [IsGalois K L] [IsCyclic Gal(L/K)] : IsAbelianGalois K L where is_comm := letI := IsCyclic.commGroup (α := L ≃ₐ[K] L); inferInstance
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/Basic.lean
import Mathlib.FieldTheory.Fixed import Mathlib.FieldTheory.Normal.Closure import Mathlib.FieldTheory.PrimitiveElement import Mathlib.GroupTheory.GroupAction.FixingSubgroup /-! # Galois Extensions In this file we define Galois extensions as extensions which are both separable and normal. ## Main definitions - `IsGalois F E` where `E` is an extension of `F` - `fixedField H` where `H : Subgroup Gal(E/F)` - `fixingSubgroup K` where `K : IntermediateField F E` - `intermediateFieldEquivSubgroup` where `E/F` is finite dimensional and Galois ## Main results - `IntermediateField.fixingSubgroup_fixedField` : If `E/F` is finite dimensional (but not necessarily Galois) then `fixingSubgroup (fixedField H) = H` - `IsGalois.fixedField_fixingSubgroup`: If `E/F` is finite dimensional and Galois then `fixedField (fixingSubgroup K) = K` Together, these two results prove the Galois correspondence. - `IsGalois.tfae` : Equivalent characterizations of a Galois extension of finite degree ## Additional results - Instances for `Algebra.IsQuadraticExtension`: a quadratic extension is Galois (if separable) with cyclic and thus abelian Galois group. -/ open scoped Polynomial IntermediateField open Module AlgEquiv IntermediateField section variable (F : Type*) [Field F] (E : Type*) [Field E] [Algebra F E] /-- A field extension E/F is Galois if it is both separable and normal. Note that in mathlib a separable extension of fields is by definition algebraic. -/ @[stacks 09I0] class IsGalois : Prop where [to_isSeparable : Algebra.IsSeparable F E] [to_normal : Normal F E] variable {F E} theorem isGalois_iff : IsGalois F E ↔ Algebra.IsSeparable F E ∧ Normal F E := ⟨fun h => ⟨h.1, h.2⟩, fun h => { to_isSeparable := h.1 to_normal := h.2 }⟩ attribute [instance 100] IsGalois.to_isSeparable IsGalois.to_normal -- see Note [lower instance priority] variable (F E) namespace IsGalois instance self : IsGalois F F := ⟨⟩ variable {E} theorem integral [IsGalois F E] (x : E) : IsIntegral F x := to_normal.isIntegral x theorem separable [IsGalois F E] (x : E) : IsSeparable F x := Algebra.IsSeparable.isSeparable F x theorem splits [IsGalois F E] (x : E) : (minpoly F x).Splits (algebraMap F E) := Normal.splits' x variable (E) /-- Let $E$ be a field. Let $G$ be a finite group acting on $E$. Then the extension $E / E^G$ is Galois. -/ @[stacks 09I3 "first part"] instance of_fixed_field (G : Type*) [Group G] [Finite G] [MulSemiringAction G E] : IsGalois (FixedPoints.subfield G E) E := ⟨⟩ theorem IntermediateField.AdjoinSimple.card_aut_eq_finrank [FiniteDimensional F E] {α : E} (hα : IsIntegral F α) (h_sep : IsSeparable F α) (h_splits : (minpoly F α).Splits (algebraMap F F⟮α⟯)) : Nat.card Gal(F⟮α⟯/F) = finrank F F⟮α⟯ := by rw [IntermediateField.adjoin.finrank hα] rw [← IntermediateField.card_algHom_adjoin_integral F hα h_sep h_splits] exact Nat.card_congr (algEquivEquivAlgHom F F⟮α⟯) /-- Let $E / F$ be a finite extension of fields. If $E$ is Galois over $F$, then $|\text{Aut}(E/F)| = [E : F]$. -/ @[stacks 09I1 "'only if' part"] theorem card_aut_eq_finrank [FiniteDimensional F E] [IsGalois F E] : Nat.card Gal(E/F) = finrank F E := by obtain ⟨α, hα⟩ := Field.exists_primitive_element F E let iso : F⟮α⟯ ≃ₐ[F] E := { toFun := fun e => e.val invFun := fun e => ⟨e, by rw [hα]; exact IntermediateField.mem_top⟩ map_mul' := fun _ _ => rfl map_add' := fun _ _ => rfl commutes' := fun _ => rfl } have H : IsIntegral F α := IsGalois.integral F α have h_sep : IsSeparable F α := IsGalois.separable F α have h_splits : (minpoly F α).Splits (algebraMap F E) := IsGalois.splits F α replace h_splits : Polynomial.Splits (algebraMap F F⟮α⟯) (minpoly F α) := by simpa using Polynomial.splits_comp_of_splits (algebraMap F E) iso.symm.toAlgHom.toRingHom h_splits rw [← LinearEquiv.finrank_eq iso.toLinearEquiv] rw [← IntermediateField.AdjoinSimple.card_aut_eq_finrank F E H h_sep h_splits] apply Nat.card_congr exact Equiv.mk (fun ϕ => iso.trans (ϕ.trans iso.symm)) fun ϕ => iso.symm.trans (ϕ.trans iso) /-- A galois extension with finite galois group is finite dimensional. The dimension is then equal to the order of the galois group via `IsGalois.card_aut_eq_finrank`. -/ lemma finiteDimensional_of_finite [IsGalois F E] [Finite Gal(E/F)] : FiniteDimensional F E := by by_contra H obtain ⟨K, h₁, h₂⟩ := exists_lt_finrank_of_infinite_dimensional H (Nat.card Gal(E/F)) let K' := normalClosure F K E have : IsGalois F K' := ⟨⟩ have := Nat.card_le_card_of_surjective _ (AlgEquiv.restrictNormalHom_surjective (F := F) (K₁ := K') (E := E)) rw [IsGalois.card_aut_eq_finrank] at this exact (this.trans_lt h₂).not_ge (finrank_le_of_le_right K.le_normalClosure) end IsGalois end section IsGaloisTower variable (F K E : Type*) [Field F] [Field K] [Field E] {E' : Type*} [Field E'] [Algebra F E'] variable [Algebra F K] [Algebra F E] [Algebra K E] [IsScalarTower F K E] /-- Let $E / K / F$ be a tower of field extensions. If $E$ is Galois over $F$, then $E$ is Galois over $K$. -/ @[stacks 09I2] theorem IsGalois.tower_top_of_isGalois [IsGalois F E] : IsGalois K E := { to_isSeparable := Algebra.isSeparable_tower_top_of_isSeparable F K E to_normal := Normal.tower_top_of_normal F K E } variable {F E} -- see Note [lower instance priority] instance (priority := 100) IsGalois.tower_top_intermediateField (K : IntermediateField F E) [IsGalois F E] : IsGalois K E := IsGalois.tower_top_of_isGalois F K E theorem isGalois_iff_isGalois_bot : IsGalois (⊥ : IntermediateField F E) E ↔ IsGalois F E := by constructor · intro h exact IsGalois.tower_top_of_isGalois (⊥ : IntermediateField F E) F E · intro h; infer_instance theorem IsGalois.of_algEquiv [IsGalois F E] (f : E ≃ₐ[F] E') : IsGalois F E' := { to_isSeparable := Algebra.IsSeparable.of_algHom F E f.symm to_normal := Normal.of_algEquiv f } theorem AlgEquiv.transfer_galois (f : E ≃ₐ[F] E') : IsGalois F E ↔ IsGalois F E' := ⟨fun _ => IsGalois.of_algEquiv f, fun _ => IsGalois.of_algEquiv f.symm⟩ theorem isGalois_iff_isGalois_top : IsGalois F (⊤ : IntermediateField F E) ↔ IsGalois F E := (IntermediateField.topEquiv : (⊤ : IntermediateField F E) ≃ₐ[F] E).transfer_galois instance isGalois_bot : IsGalois F (⊥ : IntermediateField F E) := (IntermediateField.botEquiv F E).transfer_galois.mpr (IsGalois.self F) theorem IsGalois.of_equiv_equiv {M N : Type*} [Field N] [Field M] [Algebra M N] [Algebra.IsAlgebraic F E] [h : IsGalois F E] {f : F ≃+* M} {g : E ≃+* N} (hcomp : (algebraMap M N).comp f = (g : E →+* N).comp (algebraMap F E)) : IsGalois M N := isGalois_iff.mpr ⟨Algebra.IsSeparable.of_equiv_equiv f g hcomp, Normal.of_equiv_equiv hcomp⟩ end IsGaloisTower section GaloisCorrespondence variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] variable (H : Subgroup Gal(E/F)) (K : IntermediateField F E) /-- The intermediate field of fixed points fixed by a monoid action that commutes with the `F`-action on `E`. -/ def FixedPoints.intermediateField (M : Type*) [Monoid M] [MulSemiringAction M E] [SMulCommClass M F E] : IntermediateField F E := { FixedPoints.subfield M E with carrier := MulAction.fixedPoints M E algebraMap_mem' := fun a g => smul_algebraMap g a } @[simp] lemma FixedPoints.mem_intermediateField_iff {M : Type*} [Monoid M] [MulSemiringAction M E] [SMulCommClass M F E] {x : E} : x ∈ FixedPoints.intermediateField (F := F) M ↔ ∀ m : M, m • x = x := .rfl namespace IntermediateField /-- The intermediate field fixed by a subgroup. -/ def fixedField : IntermediateField F E := FixedPoints.intermediateField H @[simp] lemma mem_fixedField_iff (x) : x ∈ fixedField H ↔ ∀ f ∈ H, f x = x := by change x ∈ MulAction.fixedPoints H E ↔ _ simp only [MulAction.mem_fixedPoints, Subtype.forall, Subgroup.mk_smul, AlgEquiv.smul_def] @[simp] lemma fixedField_bot : fixedField (⊥ : Subgroup Gal(E/F)) = ⊤ := by ext simp theorem finrank_fixedField_eq_card [FiniteDimensional F E] : finrank (fixedField H) E = Nat.card H := by have := Fintype.ofFinite H rw [Nat.card_eq_fintype_card] exact FixedPoints.finrank_eq_card H E /-- The subgroup fixing an intermediate field. -/ nonrec def fixingSubgroup : Subgroup Gal(E/F) := fixingSubgroup Gal(E/F) (K : Set E) theorem le_iff_le : K ≤ fixedField H ↔ H ≤ fixingSubgroup K := ⟨fun h g hg x => h (Subtype.mem x) ⟨g, hg⟩, fun h x hx g => h (Subtype.mem g) ⟨x, hx⟩⟩ /-- The map `K ↦ Gal(E/K)` is inclusion-reversing. -/ theorem fixingSubgroup_le {K1 K2 : IntermediateField F E} (h12 : K1 ≤ K2) : K2.fixingSubgroup ≤ K1.fixingSubgroup := fun _ hσ ⟨x, hx⟩ ↦ hσ ⟨x, h12 hx⟩ @[deprecated (since := "2025-05-02")] alias fixingSubgroup.antimono := fixingSubgroup_le theorem fixedField_le {H1 H2 : Subgroup Gal(E/F)} (h12 : H1 ≤ H2) : fixedField H2 ≤ fixedField H1 := fun _ hσ ⟨x, hx⟩ ↦ hσ ⟨x, h12 hx⟩ lemma fixingSubgroup_antitone : Antitone (@fixingSubgroup F _ E _ _) := fun _ _ ↦ fixingSubgroup_le @[deprecated (since := "2025-05-02")] alias fixingSubgroup_anti := fixingSubgroup_antitone lemma fixedField_antitone : Antitone (@fixedField F _ E _ _) := fun _ _ ↦ fixedField_le @[simp] lemma mem_fixingSubgroup_iff (σ) : σ ∈ fixingSubgroup K ↔ ∀ x ∈ K, σ x = x := _root_.mem_fixingSubgroup_iff _ @[simp] lemma fixingSubgroup_top : fixingSubgroup (⊤ : IntermediateField F E) = ⊥ := by ext simp [DFunLike.ext_iff] @[simp] lemma fixingSubgroup_bot : fixingSubgroup (⊥ : IntermediateField F E) = ⊤ := by ext simp [mem_bot] theorem fixingSubgroup_sup {K L : IntermediateField F E} : (K ⊔ L).fixingSubgroup = K.fixingSubgroup ⊓ L.fixingSubgroup := by ext φ exact ⟨fun h ↦ ⟨fixingSubgroup_antitone le_sup_left h, fixingSubgroup_antitone le_sup_right h⟩, by simp [← Subgroup.zpowers_le, ← IntermediateField.le_iff_le]⟩ /-- The fixing subgroup of `K : IntermediateField F E` is isomorphic to `Gal(E/K)`. -/ def fixingSubgroupEquiv : fixingSubgroup K ≃* Gal(E/K) where toFun ϕ := { AlgEquiv.toRingEquiv (ϕ : Gal(E/F)) with commutes' := ϕ.mem } invFun ϕ := ⟨ϕ.restrictScalars _, ϕ.commutes⟩ map_mul' _ _ := by ext; rfl theorem fixingSubgroup_fixedField [FiniteDimensional F E] : fixingSubgroup (fixedField H) = H := by have H_le : H ≤ fixingSubgroup (fixedField H) := (le_iff_le _ _).mp le_rfl classical suffices Nat.card H = Nat.card (fixingSubgroup (fixedField H)) by exact SetLike.coe_injective (Set.eq_of_inclusion_surjective ((Nat.bijective_iff_injective_and_card (Set.inclusion H_le)).mpr ⟨Set.inclusion_injective H_le, this⟩).2).symm apply Nat.card_congr refine (FixedPoints.toAlgHomEquiv H E).trans ?_ refine (algEquivEquivAlgHom (fixedField H) E).toEquiv.symm.trans ?_ exact (fixingSubgroupEquiv (fixedField H)).toEquiv.symm /-- A subgroup is isomorphic to the Galois group of its fixed field. -/ def subgroupEquivAlgEquiv [FiniteDimensional F E] (H : Subgroup Gal(E/F)) : H ≃* Gal(E/IntermediateField.fixedField H) := (MulEquiv.subgroupCongr (fixingSubgroup_fixedField H).symm).trans (fixingSubgroupEquiv _) instance fixedField.smul : SMul K (fixedField (fixingSubgroup K)) where smul x y := ⟨x * y, fun ϕ => by rw [smul_mul', show ϕ • (x : E) = ↑x from ϕ.2 x, show ϕ • (y : E) = ↑y from y.2 ϕ]⟩ instance fixedField.algebra : Algebra K (fixedField (fixingSubgroup K)) where algebraMap := { toFun x := ⟨x, fun ϕ => Subtype.mem ϕ x⟩ map_zero' := rfl map_add' _ _ := rfl map_one' := rfl map_mul' _ _ := rfl } commutes' _ _ := mul_comm _ _ smul_def' _ _ := rfl instance fixedField.isScalarTower : IsScalarTower K (fixedField (fixingSubgroup K)) E := ⟨fun _ _ _ => mul_assoc _ _ _⟩ end IntermediateField namespace IsGalois theorem fixedField_fixingSubgroup [FiniteDimensional F E] [h : IsGalois F E] : IntermediateField.fixedField (IntermediateField.fixingSubgroup K) = K := by have K_le : K ≤ IntermediateField.fixedField (IntermediateField.fixingSubgroup K) := (IntermediateField.le_iff_le _ _).mpr le_rfl suffices finrank K E = finrank (IntermediateField.fixedField (IntermediateField.fixingSubgroup K)) E by exact (IntermediateField.eq_of_le_of_finrank_eq' K_le this).symm classical rw [IntermediateField.finrank_fixedField_eq_card, Nat.card_congr (IntermediateField.fixingSubgroupEquiv K).toEquiv] exact (card_aut_eq_finrank K E).symm @[simp] lemma fixedField_top [IsGalois F E] [FiniteDimensional F E] : fixedField (⊤ : Subgroup Gal(E/F)) = ⊥ := by rw [← fixingSubgroup_bot, fixedField_fixingSubgroup] theorem mem_bot_iff_fixed [IsGalois F E] [FiniteDimensional F E] (x : E) : x ∈ (⊥ : IntermediateField F E) ↔ ∀ f : Gal(E/F), f x = x := by rw [← fixedField_top, mem_fixedField_iff] simp only [Subgroup.mem_top, forall_const] theorem mem_range_algebraMap_iff_fixed [IsGalois F E] [FiniteDimensional F E] (x : E) : x ∈ Set.range (algebraMap F E) ↔ ∀ f : Gal(E/F), f x = x := mem_bot_iff_fixed x theorem card_fixingSubgroup_eq_finrank [FiniteDimensional F E] [IsGalois F E] : Nat.card (IntermediateField.fixingSubgroup K) = finrank K E := by conv_rhs => rw [← fixedField_fixingSubgroup K, IntermediateField.finrank_fixedField_eq_card] /-- The Galois correspondence from intermediate fields to subgroups. -/ @[stacks 09DW] def intermediateFieldEquivSubgroup [FiniteDimensional F E] [IsGalois F E] : IntermediateField F E ≃o (Subgroup Gal(E/F))ᵒᵈ where toFun := IntermediateField.fixingSubgroup invFun := IntermediateField.fixedField left_inv K := fixedField_fixingSubgroup K right_inv H := IntermediateField.fixingSubgroup_fixedField H map_rel_iff' {K L} := by rw [← fixedField_fixingSubgroup L, IntermediateField.le_iff_le, fixedField_fixingSubgroup L] rfl /-- The Galois correspondence as a `GaloisInsertion`. -/ def galoisInsertionIntermediateFieldSubgroup [FiniteDimensional F E] : GaloisInsertion (OrderDual.toDual ∘ (IntermediateField.fixingSubgroup : IntermediateField F E → Subgroup Gal(E/F))) ((IntermediateField.fixedField : Subgroup Gal(E/F) → IntermediateField F E) ∘ OrderDual.toDual) where choice K _ := IntermediateField.fixingSubgroup K gc K H := (IntermediateField.le_iff_le H K).symm le_l_u H := le_of_eq (IntermediateField.fixingSubgroup_fixedField H).symm choice_eq _ _ := rfl /-- The Galois correspondence as a `GaloisCoinsertion`. -/ def galoisCoinsertionIntermediateFieldSubgroup [FiniteDimensional F E] [IsGalois F E] : GaloisCoinsertion (OrderDual.toDual ∘ (IntermediateField.fixingSubgroup : IntermediateField F E → Subgroup Gal(E/F))) ((IntermediateField.fixedField : Subgroup Gal(E/F) → IntermediateField F E) ∘ OrderDual.toDual) := OrderIso.toGaloisCoinsertion intermediateFieldEquivSubgroup end IsGalois section /-In this section we prove that the normal subgroups correspond to the Galois subextensions in the Galois correspondence and its related results. -/ variable {K L : Type*} [Field K] [Field L] [Algebra K L] open IntermediateField open scoped Pointwise lemma IntermediateField.restrictNormalHom_ker (E : IntermediateField K L) [Normal K E] : (restrictNormalHom E).ker = E.fixingSubgroup := by simp only [Subgroup.ext_iff, MonoidHom.mem_ker, AlgEquiv.ext_iff, one_apply, Subtype.ext_iff, restrictNormalHom_apply, Subtype.forall, mem_fixingSubgroup_iff, implies_true] namespace IsGalois variable (E : IntermediateField K L) /-- If `H` is a normal Subgroup of `Gal(L / K)`, then `fixedField H` is Galois over `K`. -/ instance of_fixedField_normal_subgroup [IsGalois K L] (H : Subgroup Gal(L/K)) [hn : Subgroup.Normal H] : IsGalois K (fixedField H) where to_isSeparable := Algebra.isSeparable_tower_bot_of_isSeparable K (fixedField H) L to_normal := by apply normal_iff_forall_map_le'.mpr rintro σ x ⟨a, ha, rfl⟩ τ exact (symm_apply_eq σ).mp (ha ⟨σ⁻¹ * τ * σ, Subgroup.Normal.conj_mem' hn τ.1 τ.2 σ⟩) /-- If `H` is a normal Subgroup of `Gal(L / K)`, then `Gal(fixedField H / K)` is isomorphic to `Gal(L / K) ⧸ H`. -/ noncomputable def normalAutEquivQuotient [FiniteDimensional K L] [IsGalois K L] (H : Subgroup Gal(L/K)) [Subgroup.Normal H] : Gal(L/K) ⧸ H ≃* Gal(fixedField H/K) := (QuotientGroup.quotientMulEquivOfEq ((fixingSubgroup_fixedField H).symm.trans (fixedField H).restrictNormalHom_ker.symm)).trans <| QuotientGroup.quotientKerEquivOfSurjective (restrictNormalHom (fixedField H)) <| restrictNormalHom_surjective L lemma normalAutEquivQuotient_apply [FiniteDimensional K L] [IsGalois K L] (H : Subgroup Gal(L/K)) [Subgroup.Normal H] (σ : Gal(L/K)) : normalAutEquivQuotient H σ = (restrictNormalHom (fixedField H)) σ := rfl open scoped Pointwise @[simp] theorem map_fixingSubgroup (σ : Gal(L/K)) : (E.map σ).fixingSubgroup = (MulAut.conj σ) • E.fixingSubgroup := by ext τ simp only [coe_map, AlgHom.coe_coe, Set.mem_image, SetLike.mem_coe, AlgEquiv.smul_def, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, Subgroup.mem_pointwise_smul_iff_inv_smul_mem, ← symm_apply_eq, IntermediateField.fixingSubgroup, mem_fixingSubgroup_iff] rfl /-- Let `E` be an intermediateField of a Galois extension `L / K`. If `E / K` is Galois extension, then `E.fixingSubgroup` is a normal subgroup of `Gal(L / K)`. -/ instance fixingSubgroup_normal_of_isGalois [IsGalois K L] [IsGalois K E] : E.fixingSubgroup.Normal := by apply Subgroup.Normal.of_conjugate_fixed (fun σ ↦ ?_) rw [← map_fixingSubgroup, normal_iff_forall_map_eq'.mp inferInstance σ] end IsGalois end end GaloisCorrespondence section GaloisEquivalentDefinitions variable (F : Type*) [Field F] (E : Type*) [Field E] [Algebra F E] namespace IsGalois theorem is_separable_splitting_field [FiniteDimensional F E] [IsGalois F E] : ∃ p : F[X], p.Separable ∧ p.IsSplittingField F E := by obtain ⟨α, h1⟩ := Field.exists_primitive_element F E use minpoly F α, separable F α, IsGalois.splits F α rw [eq_top_iff, ← IntermediateField.top_toSubalgebra, ← h1] rw [IntermediateField.adjoin_simple_toSubalgebra_of_integral (integral F α)] apply Algebra.adjoin_mono rw [Set.singleton_subset_iff, Polynomial.mem_rootSet] exact ⟨minpoly.ne_zero (integral F α), minpoly.aeval _ _⟩ theorem of_fixedField_eq_bot [FiniteDimensional F E] (h : IntermediateField.fixedField (⊤ : Subgroup Gal(E/F)) = ⊥) : IsGalois F E := by rw [← isGalois_iff_isGalois_bot, ← h] classical exact IsGalois.of_fixed_field E (⊤ : Subgroup Gal(E/F)) /-- Let $E / F$ be a finite extension of fields. If $|\text{Aut}(E/F)| = [E : F]$, then $E$ is Galois over $F$. -/ @[stacks 09I1 "'if' part"] theorem of_card_aut_eq_finrank [FiniteDimensional F E] (h : Nat.card Gal(E/F) = finrank F E) : IsGalois F E := by apply of_fixedField_eq_bot have p : 0 < finrank (IntermediateField.fixedField (⊤ : Subgroup Gal(E/F))) E := finrank_pos classical rw [← IntermediateField.finrank_eq_one_iff, ← mul_left_inj' (ne_of_lt p).symm, finrank_mul_finrank, ← h, one_mul, IntermediateField.finrank_fixedField_eq_card] apply Nat.card_congr exact { toFun := fun g => ⟨g, Subgroup.mem_top g⟩, invFun := (↑) } variable {F} {E} variable {p : F[X]} theorem of_separable_splitting_field_aux [hFE : FiniteDimensional F E] [sp : p.IsSplittingField F E] (hp : p.Separable) (K : Type*) [Field K] [Algebra F K] [Algebra K E] [IsScalarTower F K E] {x : E} (hx : x ∈ p.aroots E) : Nat.card (K⟮x⟯.restrictScalars F →ₐ[F] E) = Nat.card (K →ₐ[F] E) * finrank K K⟮x⟯ := by have h : IsIntegral K x := (isIntegral_of_noetherian (IsNoetherian.iff_fg.2 hFE) x).tower_top have h1 : p ≠ 0 := fun hp => by rw [hp, Polynomial.aroots_zero] at hx exact Multiset.notMem_zero x hx have h2 : minpoly K x ∣ p.map (algebraMap F K) := by apply minpoly.dvd rw [Polynomial.aeval_def, Polynomial.eval₂_map, ← Polynomial.eval_map, ← IsScalarTower.algebraMap_eq] exact (Polynomial.mem_roots (Polynomial.map_ne_zero h1)).mp hx let key_equiv : (K⟮x⟯.restrictScalars F →ₐ[F] E) ≃ Σ f : K →ₐ[F] E, @AlgHom K K⟮x⟯ E _ _ _ _ (RingHom.toAlgebra f) := by change (K⟮x⟯ →ₐ[F] E) ≃ Σ f : K →ₐ[F] E, _ exact algHomEquivSigma haveI : ∀ f : K →ₐ[F] E, Finite (@AlgHom K K⟮x⟯ E _ _ _ _ (RingHom.toAlgebra f)) := fun f => by have := Finite.of_equiv _ key_equiv apply Finite.of_injective (Sigma.mk f) fun _ _ H => eq_of_heq (Sigma.ext_iff.mp H).2 have : FiniteDimensional F K := FiniteDimensional.left F K E rw [Nat.card_congr key_equiv, Nat.card_sigma, IntermediateField.adjoin.finrank h, Nat.card_eq_fintype_card] apply Finset.sum_const_nat intro f _ rw [← @IntermediateField.card_algHom_adjoin_integral K _ E _ _ x E _ (RingHom.toAlgebra f) h] · exact Polynomial.Separable.of_dvd ((Polynomial.separable_map (algebraMap F K)).mpr hp) h2 · refine Polynomial.splits_of_splits_of_dvd _ (Polynomial.map_ne_zero h1) ?_ h2 rw [Polynomial.splits_map_iff, ← IsScalarTower.algebraMap_eq] exact sp.splits theorem of_separable_splitting_field [sp : p.IsSplittingField F E] (hp : p.Separable) : IsGalois F E := by haveI hFE : FiniteDimensional F E := Polynomial.IsSplittingField.finiteDimensional E p letI := Classical.decEq E let s := p.rootSet E have adjoin_root : IntermediateField.adjoin F s = ⊤ := by apply IntermediateField.toSubalgebra_injective rw [IntermediateField.top_toSubalgebra, ← top_le_iff, ← sp.adjoin_rootSet] apply IntermediateField.algebra_adjoin_le_adjoin let P : IntermediateField F E → Prop := fun K => Nat.card (K →ₐ[F] E) = finrank F K suffices P (IntermediateField.adjoin F s) by rw [adjoin_root] at this apply of_card_aut_eq_finrank rw [← Eq.trans this (LinearEquiv.finrank_eq IntermediateField.topEquiv.toLinearEquiv)] exact Nat.card_congr ((algEquivEquivAlgHom F E).toEquiv.trans (IntermediateField.topEquiv.symm.arrowCongr AlgEquiv.refl)) apply IntermediateField.induction_on_adjoin_finset _ P · have key := IntermediateField.card_algHom_adjoin_integral F (K := E) (show IsIntegral F (0 : E) from isIntegral_zero) rw [IsSeparable, minpoly.zero, Polynomial.natDegree_X] at key specialize key Polynomial.separable_X (Polynomial.splits_X (algebraMap F E)) rw [← @Subalgebra.finrank_bot F E _ _ _, ← IntermediateField.bot_toSubalgebra] at key refine Eq.trans ?_ key apply Nat.card_congr rw [IntermediateField.adjoin_zero] intro K x hx hK simp only [P] at * rw [of_separable_splitting_field_aux hp K (Multiset.mem_toFinset.mp hx), hK, finrank_mul_finrank] symm refine LinearEquiv.finrank_eq ?_ rfl /-- Equivalent characterizations of a Galois extension of finite degree. -/ theorem tfae [FiniteDimensional F E] : List.TFAE [ IsGalois F E, IntermediateField.fixedField (⊤ : Subgroup Gal(E/F)) = ⊥, Nat.card Gal(E/F) = finrank F E, ∃ p : F[X], p.Separable ∧ p.IsSplittingField F E] := by tfae_have 1 → 2 := fun h ↦ OrderIso.map_bot (@intermediateFieldEquivSubgroup F _ E _ _ _ h).symm tfae_have 1 → 3 := fun _ ↦ card_aut_eq_finrank F E tfae_have 1 → 4 := fun _ ↦ is_separable_splitting_field F E tfae_have 2 → 1 := of_fixedField_eq_bot F E tfae_have 3 → 1 := of_card_aut_eq_finrank F E tfae_have 4 → 1 := fun ⟨h, hp1, _⟩ ↦ of_separable_splitting_field hp1 tfae_finish /-- If `K/F` is a finite Galois extension, then for any extension `L/F`, the extension `KL/L` is also Galois. -/ theorem sup_right (K L : IntermediateField F E) [IsGalois F K] [FiniteDimensional F K] (h : K ⊔ L = ⊤) : IsGalois L E := by obtain ⟨T, hT₁, hT₂⟩ := IsGalois.is_separable_splitting_field F K let T' := T.map (algebraMap F L) suffices T'.IsSplittingField L E from IsGalois.of_separable_splitting_field (p := T') hT₁.map rw [isSplittingField_iff_intermediateField] at hT₂ ⊢ constructor · rw [Polynomial.splits_map_iff, ← IsScalarTower.algebraMap_eq] exact Polynomial.splits_of_algHom hT₂.1 (IsScalarTower.toAlgHom _ _ _) · have h' : T'.rootSet E = T.rootSet E := by simp [Set.ext_iff, Polynomial.mem_rootSet', T'] rw [← lift_inj, lift_adjoin, ← coe_val, T.image_rootSet hT₂.1] at hT₂ rw [← restrictScalars_eq_top_iff (K := F), restrictScalars_adjoin, adjoin_union, adjoin_self, h', hT₂.2, lift_top, sup_comm, h] end IsGalois end GaloisEquivalentDefinitions section normalClosure variable (k K F : Type*) [Field k] [Field K] [Field F] [Algebra k K] [Algebra k F] [Algebra K F] [IsScalarTower k K F] [IsGalois k F] /-- Let $F / K / k$ be a tower of field extensions. If $F$ is Galois over $k$, then the normal closure of $K$ over $k$ in $F$ is Galois over $k$. -/ @[stacks 0EXM] instance IsGalois.normalClosure : IsGalois k (normalClosure k K F) where to_isSeparable := Algebra.isSeparable_tower_bot_of_isSeparable k _ F end normalClosure section IsAlgClosure instance (priority := 100) IsAlgClosure.isGalois (k K : Type*) [Field k] [Field K] [Algebra k K] [IsAlgClosure k K] [CharZero k] : IsGalois k K where end IsAlgClosure section restrictRestrictAlgEquivMapHom namespace IntermediateField /-- The map from the `Gal(E/L)` to `Gal(K/F)` where `E/L/F` and `E/K/F` are two towers of extensions induced by the restriction to `K`. Note that we do require `K/F` to be normal but not `E/L`. If this is the case (and everything is finite dimensional) and `K ∩ L = F` then this map is surjective, see `IntermediateField.restrictRestrictMapHom_surjective`. This map is injective if the compositum of `K` and `L` is `E`, see `IntermediateField.restrictRestrictAlgEquivMapHom_injective`. -/ noncomputable def restrictRestrictAlgEquivMapHom (F K L E : Type*) [Field F] [Field K] [Field L] [Field E] [Algebra F K] [Algebra F L] [Algebra F E] [Algebra K E] [Algebra L E] [IsScalarTower F K E] [IsScalarTower F L E] [Normal F K] : Gal(E/L) →* Gal(K/F) := (AlgEquiv.restrictNormalHom K).comp (MulSemiringAction.toAlgAut Gal(E/L) F E) variable {F E : Type*} [Field F] [Field E] [Algebra F E] (K L : IntermediateField F E) [Normal F K] @[simp] theorem restrictRestrictAlgEquivMapHom_apply (φ : Gal(E/L)) (x : K) : restrictRestrictAlgEquivMapHom F K L E φ x = φ x := by simp [restrictRestrictAlgEquivMapHom, AlgEquiv.restrictNormalHom_apply] theorem restrictRestrictAlgEquivMapHom_injective (h : K ⊔ L = ⊤) : Function.Injective (restrictRestrictAlgEquivMapHom F K L E) := by refine (injective_iff_map_eq_one _).mpr fun φ hφ ↦ ?_ suffices h : MulSemiringAction.toAlgAut Gal(E/L) F E φ = 1 by rwa [AlgEquiv.ext_iff] at h ⊢ rw [← Subgroup.mem_bot, ← fixingSubgroup_top, ← h, fixingSubgroup_sup] exact ⟨fun x ↦ (hφ ▸ restrictRestrictAlgEquivMapHom_apply K L φ x).symm, φ.commutes⟩ theorem restrictRestrictAlgEquivMapHom_surjective [FiniteDimensional F K] [FiniteDimensional L E] [IsGalois L E] (h : K ⊓ L = ⊥) : Function.Surjective (restrictRestrictAlgEquivMapHom F K L E) := by suffices fixedField (restrictRestrictAlgEquivMapHom F K L E).range = ⊥ from MonoidHom.range_eq_top.mp <| fixingSubgroup_fixedField (restrictRestrictAlgEquivMapHom F K L E).range ▸ this ▸ fixingSubgroup_bot refine eq_bot_iff.mpr fun ⟨x, hx₁⟩ hx₂ ↦ ?_ obtain ⟨⟨y, hy⟩, rfl⟩ : x ∈ Set.range (algebraMap L E) := by refine mem_bot.mp <| (IsGalois.mem_bot_iff_fixed _).mpr fun φ ↦ ?_ rw [← restrictRestrictAlgEquivMapHom_apply K L φ ⟨x, hx₁⟩] rw [mem_fixedField_iff] at hx₂ exact congr_arg ((↑) : K → E) <| hx₂ (restrictRestrictAlgEquivMapHom F K L E φ) ⟨φ, rfl⟩ obtain ⟨z, rfl⟩ : y ∈ (⊥ : IntermediateField F E) := h ▸ mem_inf.mpr ⟨hx₁, hy⟩ exact mem_bot.mp ⟨z, rfl⟩ end IntermediateField end restrictRestrictAlgEquivMapHom namespace Algebra variable (F K : Type*) [Field F] [Field K] [Algebra F K] [IsQuadraticExtension F K] /-- A quadratic separable extension is Galois. -/ instance IsQuadraticExtension.isGalois [Algebra.IsSeparable F K] : IsGalois F K where /-- A quadratic extension has cyclic Galois group. -/ instance IsQuadraticExtension.isCyclic : IsCyclic Gal(K/F) := by have := finrank_eq_two F K ▸ AlgEquiv.card_le rw [← Nat.card_eq_fintype_card] at this interval_cases h : Nat.card Gal(K/F) · simp_all · exact @isCyclic_of_subsingleton _ _ (Finite.card_le_one_iff_subsingleton.mp h.le) · exact isCyclic_of_prime_card h /-- A quadratic extension has abelian Galois group. -/ instance IsQuadraticExtension.isMulCommutative_galoisGroup : IsMulCommutative Gal(K/F) := ⟨IsCyclic.commutative⟩ end Algebra
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/Notation.lean
import Mathlib.Algebra.Algebra.Equiv import Lean.PrettyPrinter.Delaborator.Basic /-! # Notation for Galois group The Galois group `Gal(L/K)` is implemented via `L ≃ₐ[K] L` in mathlib. We provide such a notation in this file. Although this notation works for all automorphism groups of algebras, we should only use this notation when `L/K` is an extension of fields. -/ section Notation /-- Notation for `Gal(L/K) := L ≃ₐ[K] L`. `L ≃ₐ[K] L` will pretty-print as `Gal(L/K)` when `L` and `K` are both fields. Although this notation works for all automorphism groups of algebras, we should only use this notation when `L/K` is an extension of fields. -/ /- We use a precedence of 100 here to avoid `L` capturing `/` as the infix notation for division, which has precedence 70. -/ macro "Gal(" L:term:100 "/" K:term ")" : term => `($L ≃ₐ[$K] $L) open Lean PrettyPrinter.Delaborator SubExpr in /-- Pretty printer for the `Gal(L/K)` notation. -/ @[app_delab AlgEquiv] partial def delabGal : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do -- After Lean 4.19 the pretty printer clears local instances, so we re-add them here. -- TODO: remove this once the behavior changes. -- See [Zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Bug.3F.20Local.20instances.20not.20populated.20during.20delaboration/with/544850819). Meta.withLocalInstances (← getLCtx).decls.toList.reduceOption do guard <| (← getExpr).isAppOfArity ``AlgEquiv 8 let [u, v, _] := (← getExpr).getAppFn'.constLevels! | failure let #[R, A, B, _, _, _, _, _] := (← getExpr).getAppArgs | failure guard (A == B) -- We require that A = B syntactically, not merely defeq. let some _ ← Meta.synthInstance? (.app (.const ``Field [u]) R) | failure let some _ ← Meta.synthInstance? (.app (.const ``Field [v]) A) | failure `(Gal($(← withNaryArg 1 <| delab)/$(← withNaryArg 0 <| delab))) end Notation
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/Profinite.lean
import Mathlib.FieldTheory.KrullTopology import Mathlib.FieldTheory.Galois.GaloisClosure import Mathlib.Topology.Algebra.Category.ProfiniteGrp.Basic /-! # Galois Group as a profinite group In this file, we prove that given a field extension `K/k`, there is a continuous isomorphism between `Gal(K/k)` and the limit of `Gal(L/k)`, where `L` is a finite Galois intermediate field ordered by inverse inclusion, thus making `Gal(K/k)` profinite as a limit of finite groups. ## Main definitions and results In a field extension `K/k` * `finGaloisGroup L` : The (finite) Galois group `Gal(L/k)` associated to a `L : FiniteGaloisIntermediateField k K` `L`. * `finGaloisGroupMap` : For `FiniteGaloisIntermediateField` s `L₁` and `L₂` with `L₂ ≤ L₁` giving the restriction of `Gal(L₁/k)` to `Gal(L₂/k)` * `finGaloisGroupFunctor` : The functor from `FiniteGaloisIntermediateField` (ordered by reverse inclusion) to `FiniteGrp`, mapping each `FiniteGaloisIntermediateField L` to `Gal (L/k)`. * `InfiniteGalois.algEquivToLimit` : The homomorphism from `Gal(K/k)` to `limit (asProfiniteGaloisGroupFunctor k K)`, induced by the projections from `Gal(K/k)` to any `Gal(L/k)` where `L` is a `FiniteGaloisIntermediateField`. * `InfiniteGalois.limitToAlgEquiv` : The inverse of `InfiniteGalois.algEquivToLimit`, in which the elements of `Gal(K/k)` are constructed pointwise. * `InfiniteGalois.mulEquivToLimit` : The mulEquiv obtained from combining the above two. * `InfiniteGalois.mulEquivToLimit_continuous` : The inverse of `InfiniteGalois.mulEquivToLimit` is continuous. * `InfiniteGalois.continuousMulEquivToLimit` :The `ContinuousMulEquiv` between `Gal(K/k)` and `limit (asProfiniteGaloisGroupFunctor k K)` given by `InfiniteGalois.mulEquivToLimit` * `InfiniteGalois.ProfiniteGalGrp` : `Gal(K/k)` as a profinite group as there is a `ContinuousMulEquiv` to a `ProfiniteGrp` given above. * `InfiniteGalois.restrictNormalHomContinuous` : Any `restrictNormalHom` is continuous. -/ open CategoryTheory Opposite variable {k K : Type*} [Field k] [Field K] [Algebra k K] section Profinite /-- The (finite) Galois group `Gal(L / k)` associated to a `L : FiniteGaloisIntermediateField k K` `L`. -/ def FiniteGaloisIntermediateField.finGaloisGroup (L : FiniteGaloisIntermediateField k K) : FiniteGrp := letI := AlgEquiv.fintype k L FiniteGrp.of Gal(L/k) /-- For `FiniteGaloisIntermediateField` s `L₁` and `L₂` with `L₂ ≤ L₁` the restriction homomorphism from `Gal(L₁/k)` to `Gal(L₂/k)` -/ noncomputable def finGaloisGroupMap {L₁ L₂ : (FiniteGaloisIntermediateField k K)ᵒᵖ} (le : L₁ ⟶ L₂) : L₁.unop.finGaloisGroup ⟶ L₂.unop.finGaloisGroup := haveI : Normal k L₂.unop := IsGalois.to_normal letI : Algebra L₂.unop L₁.unop := RingHom.toAlgebra (Subsemiring.inclusion <| leOfHom le.1) haveI : IsScalarTower k L₂.unop L₁.unop := IsScalarTower.of_algebraMap_eq (congrFun rfl) FiniteGrp.ofHom (AlgEquiv.restrictNormalHom L₂.unop) namespace finGaloisGroupMap @[simp] lemma map_id (L : (FiniteGaloisIntermediateField k K)ᵒᵖ) : (finGaloisGroupMap (𝟙 L)) = 𝟙 L.unop.finGaloisGroup := ConcreteCategory.ext (AlgEquiv.restrictNormalHom_id _ _) @[simp] lemma map_comp {L₁ L₂ L₃ : (FiniteGaloisIntermediateField k K)ᵒᵖ} (f : L₁ ⟶ L₂) (g : L₂ ⟶ L₃) : finGaloisGroupMap (f ≫ g) = finGaloisGroupMap f ≫ finGaloisGroupMap g := by iterate 2 induction L₁ with | _ L₁ => ?_ induction L₂ with | _ L₂ => ?_ induction L₃ with | _ L₃ => ?_ algebraize [Subsemiring.inclusion g.unop.le, Subsemiring.inclusion f.unop.le, Subsemiring.inclusion (g.unop.le.trans f.unop.le)] have : IsScalarTower k L₂ L₁ := IsScalarTower.of_algebraMap_eq' rfl have : IsScalarTower k L₃ L₁ := IsScalarTower.of_algebraMap_eq' rfl have : IsScalarTower k L₃ L₂ := IsScalarTower.of_algebraMap_eq' rfl have : IsScalarTower L₃ L₂ L₁ := IsScalarTower.of_algebraMap_eq' rfl ext : 1 apply IsScalarTower.AlgEquiv.restrictNormalHom_comp k L₃ L₂ L₁ end finGaloisGroupMap variable (k K) in /-- The functor from `FiniteGaloisIntermediateField` (ordered by reverse inclusion) to `FiniteGrp`, mapping each `FiniteGaloisIntermediateField` `L` to `Gal (L/k)` -/ noncomputable def finGaloisGroupFunctor : (FiniteGaloisIntermediateField k K)ᵒᵖ ⥤ FiniteGrp where obj L := L.unop.finGaloisGroup map := finGaloisGroupMap map_id := finGaloisGroupMap.map_id map_comp := finGaloisGroupMap.map_comp open FiniteGaloisIntermediateField ProfiniteGrp variable {k K : Type*} [Field k] [Field K] [Algebra k K] namespace InfiniteGalois variable (k K) in /-- The composition of `finGaloisGroupFunctor` with the forgetful functor from `FiniteGrp` to `ProfiniteGrp`. -/ noncomputable abbrev asProfiniteGaloisGroupFunctor : (FiniteGaloisIntermediateField k K)ᵒᵖ ⥤ ProfiniteGrp := (finGaloisGroupFunctor k K) ⋙ forget₂ FiniteGrp ProfiniteGrp variable (k K) in /-- The homomorphism from `Gal(K/k)` to `lim Gal(L/k)` where `L` is a `FiniteGaloisIntermediateField k K` ordered by inverse inclusion. It is induced by the canonical projections from `Gal(K/k)` to `Gal(L/k)`. -/ noncomputable def algEquivToLimit : Gal(K/k) →* limit (asProfiniteGaloisGroupFunctor k K) where toFun σ := { val := fun L ↦ σ.restrictNormalHom L.unop property := fun {L₁ L₂} π ↦ by algebraize [Subsemiring.inclusion π.1.le] have : IsScalarTower k L₂.unop L₁.unop := IsScalarTower.of_algebraMap_eq (congrFun rfl) have : IsScalarTower L₂.unop L₁.unop K := IsScalarTower.of_algebraMap_eq (congrFun rfl) apply (IsScalarTower.AlgEquiv.restrictNormalHom_comp_apply L₂.unop L₁.unop σ).symm } map_one' := by simp only [map_one] rfl map_mul' x y := by simp only [map_mul] rfl theorem restrictNormalHom_continuous (L : IntermediateField k K) [Normal k L] : Continuous (AlgEquiv.restrictNormalHom (F := k) (K₁ := K) L) := by apply continuous_of_continuousAt_one _ (continuousAt_def.mpr _ ) intro N hN rw [map_one, krullTopology_mem_nhds_one_iff] at hN obtain ⟨L', _, hO⟩ := hN have := Module.Finite.equiv <| AlgEquiv.toLinearEquiv <| IntermediateField.liftAlgEquiv L' apply mem_nhds_iff.mpr use (IntermediateField.lift L').fixingSubgroup constructor · intro x hx apply hO simp only [SetLike.mem_coe, IntermediateField.mem_fixingSubgroup_iff] at hx ⊢ intro y hy have := AlgEquiv.restrictNormal_commutes x L y dsimp at this rw [hx y.1 ((IntermediateField.mem_lift y).mpr hy)] at this exact SetLike.coe_eq_coe.mp this · exact ⟨IntermediateField.fixingSubgroup_isOpen (IntermediateField.lift L'), congrFun rfl⟩ lemma algEquivToLimit_continuous : Continuous (algEquivToLimit k K) := by rw [continuous_induced_rng] refine continuous_pi (fun L ↦ ?_) convert restrictNormalHom_continuous L.unop.1 exact (DiscreteTopology.eq_bot (α := L.unop ≃ₐ[k] L.unop)).symm /-- The projection map from `lim Gal(L/k)` to a specific `Gal(L/k)`. -/ noncomputable def proj (L : FiniteGaloisIntermediateField k K) : limit (asProfiniteGaloisGroupFunctor k K) →* Gal(L/k) where toFun g := g.val (op L) map_one' := rfl map_mul' _ _ := rfl lemma finGaloisGroupFunctor_map_proj_eq_proj (g : limit (asProfiniteGaloisGroupFunctor k K)) {L₁ L₂ : FiniteGaloisIntermediateField k K} (h : L₁ ⟶ L₂) : (finGaloisGroupFunctor k K).map h.op (proj L₂ g) = proj L₁ g := g.prop h.op lemma proj_of_le (L : FiniteGaloisIntermediateField k K) (g : limit (asProfiniteGaloisGroupFunctor k K)) (x : L) (L' : FiniteGaloisIntermediateField k K) (h : L ≤ L') : (proj L g x).val = (proj L' g ⟨x, h x.2⟩).val := by induction L with | _ L => ?_ induction L' with | _ L' => ?_ letI : Algebra L L' := RingHom.toAlgebra (Subsemiring.inclusion h) letI : IsScalarTower k L L' := IsScalarTower.of_algebraMap_eq (congrFun rfl) rw [← finGaloisGroupFunctor_map_proj_eq_proj g h.hom] change (algebraMap L' K (algebraMap L L' (AlgEquiv.restrictNormal (proj (mk L') g) L x))) = _ rw [AlgEquiv.restrictNormal_commutes (proj (mk L') g) L] rfl lemma proj_adjoin_singleton_val [IsGalois k K] (g : limit (asProfiniteGaloisGroupFunctor k K)) (x : K) (y : adjoin k {x}) (L : FiniteGaloisIntermediateField k K) (h : x ∈ L.toIntermediateField) : (proj (adjoin k {x}) g y).val = (proj L g ⟨y, adjoin_simple_le_iff.mpr h y.2⟩).val := proj_of_le _ g y _ _ /-- A function from `K` to `K` defined pointwise using a family of compatible elements of `Gal(L/k)` where `L` is a `FiniteGaloisIntermediateField` -/ private noncomputable def toAlgEquivAux [IsGalois k K] (g : limit (asProfiniteGaloisGroupFunctor k K)) : K → K := fun x ↦ (proj (adjoin k {x}) g ⟨x, subset_adjoin _ _ (by simp only [Set.mem_singleton_iff])⟩).val lemma toAlgEquivAux_eq_proj_of_mem [IsGalois k K] (g : limit (asProfiniteGaloisGroupFunctor k K)) (x : K) (L : FiniteGaloisIntermediateField k K) (hx : x ∈ L.toIntermediateField) : toAlgEquivAux g x = (proj L g ⟨x, hx⟩).val := proj_adjoin_singleton_val g _ _ L hx lemma mk_toAlgEquivAux [IsGalois k K] (g : limit (asProfiniteGaloisGroupFunctor k K)) (x : K) (L : FiniteGaloisIntermediateField k K) (hx' : toAlgEquivAux g x ∈ L.toIntermediateField) (hx : x ∈ L.toIntermediateField) : (⟨toAlgEquivAux g x, hx'⟩ : L.toIntermediateField) = proj L g ⟨x, hx⟩ := by rw [Subtype.eq_iff, Subtype.coe_mk, toAlgEquivAux_eq_proj_of_mem] lemma toAlgEquivAux_eq_liftNormal [IsGalois k K] (g : limit (asProfiniteGaloisGroupFunctor k K)) (x : K) (L : FiniteGaloisIntermediateField k K) (hx : x ∈ L.toIntermediateField) : toAlgEquivAux g x = (proj L g).liftNormal K x := by rw [toAlgEquivAux_eq_proj_of_mem g x L hx] exact (AlgEquiv.liftNormal_commutes (proj L g) _ ⟨x, hx⟩).symm /-- `toAlgEquivAux` as an `AlgEquiv`. It is done by using above lifting lemmas on bigger `FiniteGaloisIntermediateField`. -/ @[simps] noncomputable def limitToAlgEquiv [IsGalois k K] (g : limit (asProfiniteGaloisGroupFunctor k K)) : Gal(K/k) where toFun := toAlgEquivAux g invFun := toAlgEquivAux g⁻¹ left_inv x := by let L := adjoin k {x, toAlgEquivAux g x} have hx : x ∈ L.1 := subset_adjoin _ _ (Set.mem_insert x {toAlgEquivAux g x}) have hx' : toAlgEquivAux g x ∈ L.1 := subset_adjoin _ _ (Set.mem_insert_of_mem x rfl) simp only [toAlgEquivAux_eq_proj_of_mem _ _ L hx', map_inv, AlgEquiv.aut_inv, mk_toAlgEquivAux g x L hx' hx, AlgEquiv.symm_apply_apply] right_inv x := by let L := adjoin k {x, toAlgEquivAux g⁻¹ x} have hx : x ∈ L.1 := subset_adjoin _ _ (Set.mem_insert x {toAlgEquivAux g⁻¹ x}) have hx' : toAlgEquivAux g⁻¹ x ∈ L.1 := subset_adjoin _ _ (Set.mem_insert_of_mem x rfl) simp only [toAlgEquivAux_eq_proj_of_mem _ _ L hx', mk_toAlgEquivAux g⁻¹ x L hx' hx, map_inv, AlgEquiv.aut_inv, AlgEquiv.apply_symm_apply] map_mul' x y := by have hx : x ∈ (adjoin k {x, y}).1 := subset_adjoin _ _ (Set.mem_insert x {y}) have hy : y ∈ (adjoin k {x, y}).1 := subset_adjoin _ _ (Set.mem_insert_of_mem x rfl) rw [toAlgEquivAux_eq_liftNormal g x (adjoin k {x, y}) hx, toAlgEquivAux_eq_liftNormal g y (adjoin k {x, y}) hy, toAlgEquivAux_eq_liftNormal g (x * y) (adjoin k {x, y}) (mul_mem hx hy), map_mul] map_add' x y := by have hx : x ∈ (adjoin k {x, y}).1 := subset_adjoin _ _ (Set.mem_insert x {y}) have hy : y ∈ (adjoin k {x, y}).1 := subset_adjoin _ _ (Set.mem_insert_of_mem x rfl) simp only [toAlgEquivAux_eq_liftNormal g x (adjoin k {x, y}) hx, toAlgEquivAux_eq_liftNormal g y (adjoin k {x, y}) hy, toAlgEquivAux_eq_liftNormal g (x + y) (adjoin k {x, y}) (add_mem hx hy), map_add] commutes' x := by simp only [toAlgEquivAux_eq_liftNormal g _ ⊥ (algebraMap_mem _ x), AlgEquiv.commutes] variable (k K) in /-- `algEquivToLimit` as a `MulEquiv`. -/ noncomputable def mulEquivToLimit [IsGalois k K] : Gal(K/k) ≃* limit (asProfiniteGaloisGroupFunctor k K) where toFun := algEquivToLimit k K map_mul' := map_mul _ invFun := limitToAlgEquiv left_inv := fun f ↦ AlgEquiv.ext fun x ↦ AlgEquiv.restrictNormal_commutes f (adjoin k {x}).1 ⟨x, _⟩ right_inv := fun g ↦ by apply Subtype.val_injective ext L change (limitToAlgEquiv g).restrictNormal _ = _ ext x have : ((limitToAlgEquiv g).restrictNormal L.unop) x = (limitToAlgEquiv g) x.1 := by exact AlgEquiv.restrictNormal_commutes (limitToAlgEquiv g) L.unop x simp_rw [this] exact proj_adjoin_singleton_val _ _ _ _ x.2 open scoped Topology in lemma krullTopology_mem_nhds_one_iff_of_isGalois [IsGalois k K] (A : Set Gal(K/k)) : A ∈ 𝓝 1 ↔ ∃ (L : FiniteGaloisIntermediateField k K), (L.fixingSubgroup : Set _) ⊆ A := by rw [krullTopology_mem_nhds_one_iff_of_normal] exact ⟨fun ⟨L, _, hL, hsub⟩ ↦ ⟨{ toIntermediateField := L, isGalois := ⟨⟩ }, hsub⟩, fun ⟨L, hL⟩ ↦ ⟨L, inferInstance, inferInstance, hL⟩⟩ lemma isOpen_mulEquivToLimit_image_fixingSubgroup [IsGalois k K] (L : FiniteGaloisIntermediateField k K) : IsOpen (mulEquivToLimit k K '' L.fixingSubgroup) := by let fix1 : Set (Π L, (asProfiniteGaloisGroupFunctor k K).obj L) := {f | f (op L) = 1} suffices mulEquivToLimit k K '' L.1.fixingSubgroup = Set.preimage Subtype.val fix1 by rw [this] exact (isOpen_induced <| (continuous_apply (op L)).isOpen_preimage {1} trivial) ext x obtain ⟨σ, rfl⟩ := (mulEquivToLimit k K).surjective x simpa using FiniteGaloisIntermediateField.mem_fixingSubgroup_iff _ _ lemma mulEquivToLimit_symm_continuous [IsGalois k K] : Continuous (mulEquivToLimit k K).symm := by apply continuous_of_continuousAt_one _ (continuousAt_def.mpr _ ) simp only [map_one, krullTopology_mem_nhds_one_iff_of_isGalois, ← MulEquiv.coe_toEquiv_symm, ← MulEquiv.toEquiv_eq_coe, ← (mulEquivToLimit k K).image_eq_preimage_symm] intro H ⟨L, le⟩ rw [mem_nhds_iff] use mulEquivToLimit k K '' L.1.fixingSubgroup simp only [isOpen_mulEquivToLimit_image_fixingSubgroup L] simpa [one_mem] using Set.image_subset_iff.mp (Set.image_mono le) variable (k K) /-- The `ContinuousMulEquiv` between `Gal(K/k)` and `lim Gal(L/k)` where `L` is a `FiniteGaloisIntermediateField` ordered by inverse inclusion, obtained from `InfiniteGalois.mulEquivToLimit` -/ noncomputable def continuousMulEquivToLimit [IsGalois k K] : Gal(K/k) ≃ₜ* limit (asProfiniteGaloisGroupFunctor k K) where toMulEquiv := mulEquivToLimit k K continuous_toFun := algEquivToLimit_continuous continuous_invFun := mulEquivToLimit_symm_continuous instance [IsGalois k K] : CompactSpace Gal(K/k) := (continuousMulEquivToLimit k K).symm.compactSpace /-- `Gal(K/k)` as a profinite group as there is a `ContinuousMulEquiv` to a `ProfiniteGrp` given above -/ noncomputable def profiniteGalGrp [IsGalois k K] : ProfiniteGrp := ProfiniteGrp.of Gal(K/k) /-- The categorical isomorphism between `profiniteGalGrp` and `lim Gal(L/k)` where `L` is a `FiniteGaloisIntermediateField` ordered by inverse inclusion -/ noncomputable def profiniteGalGrpIsoLimit [IsGalois k K] : profiniteGalGrp k K ≅ limit (asProfiniteGaloisGroupFunctor k K) := ContinuousMulEquiv.toProfiniteGrpIso (continuousMulEquivToLimit k K) end InfiniteGalois end Profinite
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean
import Mathlib.FieldTheory.Galois.Infinite import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.Invariant.Basic /-! # Predicate for Galois Groups Given an action of a group `G` on an extension of fields `L/K`, we introduce a predicate `IsGaloisGroup G K L` saying that `G` acts faithfully on `L` with fixed field `K`. In particular, we do not assume that `L` is an algebraic extension of `K`. ## Implementation notes We actually define `IsGaloisGroup G A B` for extensions of rings `B/A`, with the same definition (faithful action on `B` with fixed ring `A`). This definition turns out to axiomatize a common setup in algebraic number theory where a Galois group `Gal(L/K)` acts on an extension of subrings `B/A` (e.g., rings of integers). In particular, there are theorems in algebraic number theory that naturally assume `[IsGaloisGroup G A B]` and whose statements would otherwise require assuming `(K L : Type*) [Field K] [Field L] [Algebra K L] [IsGalois K L]` (along with predicates relating `K` and `L` to the rings `A` and `B`) despite `K` and `L` not appearing in the conclusion. Unfortunately, this definition of `IsGaloisGroup G A B` for extensions of rings `B/A` is nonstandard and clashes with other notions such as the étale fundamental group. In particular, if `G` is finite and `A` is integrally closed, then `IsGaloisGroup G A B` is equivalent to `B/A` being integral and the fields of fractions `Frac(B)/Frac(A)` being Galois with Galois group `G` (see `IsGaloisGroup.iff_isFractionRing`), rather than `B/A` being étale for instance. But in the absence of a more suitable name, the utility of the predicate `IsGaloisGroup G A B` for extensions of rings `B/A` seems to outweigh these terminological issues. -/ section CommRing variable (G A B : Type*) [Group G] [CommSemiring A] [Semiring B] [Algebra A B] [MulSemiringAction G B] /-- `G` is a Galois group for `L/K` if the action of `G` on `L` is faithful with fixed field `K`. In particular, we do not assume that `L` is an algebraic extension of `K`. See the implementation notes in this file for the meaning of this definition in the case of rings. -/ class IsGaloisGroup where faithful : FaithfulSMul G B commutes : SMulCommClass G A B isInvariant : Algebra.IsInvariant A B G attribute [instance low] IsGaloisGroup.commutes IsGaloisGroup.isInvariant end CommRing section Field variable (G A B K L : Type*) [Group G] [CommRing A] [CommRing B] [MulSemiringAction G B] [Algebra A B] [Field K] [Field L] [Algebra K L] [Algebra A K] [Algebra B L] [Algebra A L] [IsFractionRing A K] [IsFractionRing B L] [IsScalarTower A K L] [IsScalarTower A B L] [MulSemiringAction G L] [SMulDistribClass G B L] /-- `IsGaloisGroup` for rings implies `IsGaloisGroup` for their fraction fields. -/ theorem IsGaloisGroup.to_isFractionRing [Finite G] [hGAB : IsGaloisGroup G A B] : IsGaloisGroup G K L := by have hc (a : A) : (algebraMap K L) (algebraMap A K a) = (algebraMap B L) (algebraMap A B a) := by simp_rw [← IsScalarTower.algebraMap_apply] refine ⟨⟨fun h ↦ ?_⟩, ⟨fun g x y ↦ ?_⟩, ⟨fun x h ↦ ?_⟩⟩ · have := hGAB.faithful exact eq_of_smul_eq_smul fun y ↦ by simpa [← algebraMap.coe_smul'] using h (algebraMap B L y) · obtain ⟨a, b, hb, rfl⟩ := IsFractionRing.div_surjective (A := A) x obtain ⟨c, d, hd, rfl⟩ := IsFractionRing.div_surjective (A := B) y simp [Algebra.smul_def, smul_mul', smul_div₀', hc, ← algebraMap.coe_smul'] · have := hGAB.isInvariant.isIntegral have : Nontrivial A := (IsFractionRing.nontrivial_iff_nontrivial A K).mpr inferInstance have : Nontrivial B := (IsFractionRing.nontrivial_iff_nontrivial B L).mpr inferInstance obtain ⟨x, y, hy, rfl⟩ := IsFractionRing.div_surjective (A := B) x have hy' : algebraMap B L y ≠ 0 := by simpa using nonZeroDivisors.ne_zero hy obtain ⟨b, a, ha, hb⟩ := (Algebra.IsAlgebraic.isAlgebraic (R := A) y).exists_smul_eq_mul x hy rw [mul_comm, Algebra.smul_def, mul_comm] at hb replace ha : (algebraMap B L) (algebraMap A B a) ≠ 0 := by simpa [← hc] have hxy : algebraMap B L x / algebraMap B L y = algebraMap B L b / algebraMap B L (algebraMap A B a) := by rw [div_eq_div_iff hy' ha, ← map_mul, hb, map_mul] obtain ⟨b, rfl⟩ := hGAB.isInvariant.isInvariant b (by simpa [ha, hxy, smul_div₀', ← algebraMap.coe_smul'] using h) use algebraMap A K b / algebraMap A K a simp [hc, div_eq_div_iff ha hy', ← map_mul, ← map_mul, hb] /-- If `B` is an integral extension of an integrally closed domain `A`, then `IsGaloisGroup` for their fraction fields implies `IsGaloisGroup` for these rings. -/ theorem IsGaloisGroup.of_isFractionRing [hGKL : IsGaloisGroup G K L] [IsIntegrallyClosed A] [Algebra.IsIntegral A B] : IsGaloisGroup G A B := by have hc (a : A) : (algebraMap K L) (algebraMap A K a) = (algebraMap B L) (algebraMap A B a) := by simp_rw [← IsScalarTower.algebraMap_apply] refine ⟨⟨fun h ↦ ?_⟩, ⟨fun g x y ↦ IsFractionRing.injective B L ?_⟩, ⟨fun x h ↦ ?_⟩⟩ · have := hGKL.faithful refine eq_of_smul_eq_smul fun (y : L) ↦ ?_ obtain ⟨a, b, hb, rfl⟩ := IsFractionRing.div_surjective (A := B) y simp only [smul_div₀', ← algebraMap.coe_smul', h] · simp [Algebra.smul_def, algebraMap.coe_smul', ← hc] · obtain ⟨b, hb⟩ := hGKL.isInvariant.isInvariant (algebraMap B L x) (by simpa [← algebraMap.coe_smul']) have hx : IsIntegral A (algebraMap B L x) := (Algebra.IsIntegral.isIntegral x).algebraMap rw [← hb, isIntegral_algebraMap_iff (algebraMap K L).injective, IsIntegrallyClosedIn.isIntegral_iff] at hx obtain ⟨a, rfl⟩ := hx exact ⟨a, by rwa [hc, IsFractionRing.coe_inj] at hb⟩ /-- If `G` is finite and `A` is integrally closed then `IsGaloisGroup G A B` is equivalent to `B/A` being integral and the fields of fractions `Frac(B)/Frac(A)` being Galois with Galois group `G`. -/ theorem IsGaloisGroup.iff_isFractionRing [Finite G] [IsIntegrallyClosed A] : IsGaloisGroup G A B ↔ Algebra.IsIntegral A B ∧ IsGaloisGroup G K L := ⟨fun h ↦ ⟨h.isInvariant.isIntegral, h.to_isFractionRing G A B K L⟩, fun ⟨_, h⟩ ↦ h.of_isFractionRing G A B K L⟩ open NumberField instance (K L : Type*) [Field K] [Field L] [NumberField K] [NumberField L] [Algebra K L] (G : Type*) [Group G] [MulSemiringAction G L] [IsGaloisGroup G K L] : IsGaloisGroup G (𝓞 K) (𝓞 L) := IsGaloisGroup.of_isFractionRing G (𝓞 K) (𝓞 L) K L instance (L : Type*) [Field L] [NumberField L] (G : Type*) [Group G] [MulSemiringAction G L] [IsGaloisGroup G ℚ L] : IsGaloisGroup G ℤ (𝓞 L) := IsGaloisGroup.of_isFractionRing G ℤ (𝓞 L) ℚ L end Field variable (G H K L : Type*) [Group G] [Group H] [Field K] [Field L] [Algebra K L] [MulSemiringAction G L] [MulSemiringAction H L] namespace IsGaloisGroup attribute [instance low] commutes isInvariant theorem fixedPoints_eq_bot [IsGaloisGroup G K L] : FixedPoints.intermediateField G = (⊥ : IntermediateField K L) := by rw [eq_bot_iff] exact Algebra.IsInvariant.isInvariant /-- If `G` is a finite Galois group for `L/K`, then `L/K` is a Galois extension. -/ theorem isGalois [Finite G] [IsGaloisGroup G K L] : IsGalois K L := by rw [← isGalois_iff_isGalois_bot, ← fixedPoints_eq_bot G] exact IsGalois.of_fixed_field L G /-- If `L/K` is a Galois extension, then `Gal(L/K)` is a Galois group for `L/K`. -/ instance of_isGalois [IsGalois K L] : IsGaloisGroup Gal(L/K) K L where faithful := inferInstance commutes := inferInstance isInvariant := ⟨fun x ↦ (InfiniteGalois.mem_bot_iff_fixed x).mpr⟩ theorem card_eq_finrank [IsGaloisGroup G K L] : Nat.card G = Module.finrank K L := by rcases fintypeOrInfinite G with _ | hG · have : FaithfulSMul G L := faithful K rw [← IntermediateField.finrank_bot', ← fixedPoints_eq_bot G, Nat.card_eq_fintype_card] exact (FixedPoints.finrank_eq_card G L).symm · rw [Nat.card_eq_zero_of_infinite, eq_comm] contrapose! hG have : FiniteDimensional K L := FiniteDimensional.of_finrank_pos (Nat.zero_lt_of_ne_zero hG) exact Finite.of_injective (MulSemiringAction.toAlgAut G K L) (fun _ _ ↦ (faithful K).eq_of_smul_eq_smul ∘ DFunLike.ext_iff.mp) theorem finiteDimensional [Finite G] [IsGaloisGroup G K L] : FiniteDimensional K L := FiniteDimensional.of_finrank_pos (card_eq_finrank G K L ▸ Nat.card_pos) /-- If `G` is a finite Galois group for `L/K`, then `G` is isomorphic to `Gal(L/K)`. -/ @[simps!] noncomputable def mulEquivAlgEquiv [IsGaloisGroup G K L] [Finite G] : G ≃* Gal(L/K) := MulEquiv.ofBijective (MulSemiringAction.toAlgAut G K L) (by have := isGalois G K L have := finiteDimensional G K L rw [Nat.bijective_iff_injective_and_card, card_eq_finrank G K L, IsGalois.card_aut_eq_finrank K L] exact ⟨fun _ _ ↦ (faithful K).eq_of_smul_eq_smul ∘ DFunLike.ext_iff.mp, rfl⟩) /-- If `G` and `H` are finite Galois groups for `L/K`, then `G` is isomorphic to `H`. -/ noncomputable def mulEquivCongr [IsGaloisGroup G K L] [Finite G] [IsGaloisGroup H K L] [Finite H] : G ≃* H := (mulEquivAlgEquiv G K L).trans (mulEquivAlgEquiv H K L).symm @[simp] theorem mulEquivCongr_apply_smul [IsGaloisGroup G K L] [Finite G] [IsGaloisGroup H K L] [Finite H] (g : G) (x : L) : mulEquivCongr G H K L g • x = g • x := AlgEquiv.ext_iff.mp ((mulEquivAlgEquiv H K L).apply_symm_apply (mulEquivAlgEquiv G K L g)) x end IsGaloisGroup
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/Infinite.lean
import Mathlib.FieldTheory.KrullTopology import Mathlib.FieldTheory.Galois.GaloisClosure import Mathlib.Topology.Algebra.Group.ClosedSubgroup /-! # The Fundamental Theorem of Infinite Galois Theory In this file, we prove the fundamental theorem of infinite Galois theory and the special case for open subgroups and normal subgroups. We first verify that `IntermediateField.fixingSubgroup` and `IntermediateField.fixedField` are inverses of each other between intermediate fields and closed subgroups of the Galois group. ## Main definitions and results In `K/k`, for any intermediate field `L` : * `fixingSubgroup_isClosed` : the subgroup fixing `L` (`Gal(K/L)`) is closed. * `fixedField_fixingSubgroup` : the field fixed by the subgroup fixing `L` is equal to `L` itself. For any subgroup `H` of `Gal(K/k)` : * `restrict_fixedField` : For a Galois intermediate field `M`, the fixed field of the image of `H` restricted to `M` is equal to the fixed field of `H` intersected with `M`. * `fixingSubgroup_fixedField` : If `H` is closed, the fixing subgroup of the fixed field of `H` is equal to `H` itself. The fundamental theorem of infinite Galois theory : * `IntermediateFieldEquivClosedSubgroup` : The order equivalence is given by mapping any intermediate field `L` to the subgroup fixing `L`, and the inverse maps any closed subgroup of `Gal(K/k)` `H` to the fixed field of `H`. The composition is equal to the identity as described in the lemmas above, and compatibility with the order follows easily. Special cases : * `isOpen_iff_finite` : The fixing subgroup of an intermediate field `L` is open if and only if `L` is finite-dimensional. * `normal_iff_isGalois` : The fixing subgroup of an intermediate field `L` is normal if and only if `L` is Galois. -/ variable {k K : Type*} [Field k] [Field K] [Algebra k K] namespace InfiniteGalois open Pointwise FiniteGaloisIntermediateField AlgEquiv --Note: The `adjoin`s below are `FiniteGaloisIntermediateField.adjoin` lemma fixingSubgroup_isClosed (L : IntermediateField k K) [IsGalois k K] : IsClosed (L.fixingSubgroup : Set Gal(K/k)) where isOpen_compl := isOpen_iff_mem_nhds.mpr fun σ h => by apply mem_nhds_iff.mpr rcases Set.not_subset.mp ((mem_fixingSubgroup_iff Gal(K/k)).not.mp h) with ⟨y, yL, ne⟩ use σ • ((adjoin k {y}).1.fixingSubgroup : Set Gal(K/k)) constructor · intro f hf rcases (Set.mem_smul_set.mp hf) with ⟨g, hg, eq⟩ simp only [Set.mem_compl_iff, SetLike.mem_coe, ← eq] apply (mem_fixingSubgroup_iff Gal(K/k)).not.mpr push_neg use y simp only [yL, smul_eq_mul, AlgEquiv.smul_def, AlgEquiv.mul_apply, ne_eq, true_and] have : g y = y := (mem_fixingSubgroup_iff Gal(K/k)).mp hg y <| adjoin_simple_le_iff.mp le_rfl simpa only [this, ne_eq, AlgEquiv.smul_def] using ne · simp only [(IntermediateField.fixingSubgroup_isOpen (adjoin k {y}).1).smul σ, true_and] use 1 simp only [SetLike.mem_coe, smul_eq_mul, mul_one, and_true, Subgroup.one_mem] lemma fixedField_fixingSubgroup (L : IntermediateField k K) [IsGalois k K] : IntermediateField.fixedField L.fixingSubgroup = L := by apply le_antisymm · intro x hx rw [IntermediateField.mem_fixedField_iff] at hx have mem : x ∈ (adjoin L {x}).1 := subset_adjoin _ _ rfl have : IntermediateField.fixedField (⊤ : Subgroup ((adjoin L {x}) ≃ₐ[L] (adjoin L {x}))) = ⊥ := (IsGalois.tfae.out 0 1).mp (by infer_instance) have : ⟨x, mem⟩ ∈ (⊥ : IntermediateField L (adjoin L {x})) := by rw [← this, IntermediateField.mem_fixedField_iff] intro f _ rcases restrictNormalHom_surjective K f with ⟨σ,hσ⟩ apply Subtype.val_injective rw [← hσ, restrictNormalHom_apply (adjoin L {x}).1 σ ⟨x, mem⟩] have := hx ((IntermediateField.fixingSubgroupEquiv L).symm σ) simpa only [SetLike.coe_mem, true_implies] rcases IntermediateField.mem_bot.mp this with ⟨y, hy⟩ obtain ⟨rfl⟩ : y = x := congrArg Subtype.val hy exact y.2 · exact (IntermediateField.le_iff_le L.fixingSubgroup L).mpr le_rfl lemma fixedField_bot [IsGalois k K] : IntermediateField.fixedField (⊤ : Subgroup Gal(K/k)) = ⊥ := by rw [← IntermediateField.fixingSubgroup_bot, fixedField_fixingSubgroup] theorem mem_bot_iff_fixed [IsGalois k K] (x : K) : x ∈ (⊥ : IntermediateField k K) ↔ ∀ (f : Gal(K/k)), f x = x := by simp [← fixedField_bot, IntermediateField.mem_fixedField_iff] open IntermediateField in /-- For a subgroup `H` of `Gal(K/k)`, the fixed field of the image of `H` under the restriction to a normal intermediate field `E` is equal to the fixed field of `H` in `K` intersecting with `E`. -/ lemma restrict_fixedField (H : Subgroup Gal(K/k)) (L : IntermediateField k K) [Normal k L] : fixedField H ⊓ L = lift (fixedField (Subgroup.map (restrictNormalHom L) H)) := by apply SetLike.ext' ext x refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · have xL := h.out.2 apply (mem_lift (⟨x, xL⟩ : L)).mpr simp only [mem_fixedField_iff, Subgroup.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro σ hσ apply Subtype.val_injective dsimp only nth_rw 2 [← (h.out.1 ⟨σ, hσ⟩)] exact AlgEquiv.restrictNormal_commutes σ L ⟨x, xL⟩ · have xL := lift_le _ h apply (mem_lift (⟨x, xL⟩ : L)).mp at h simp only [mem_fixedField_iff, Subgroup.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] at h simp only [coe_inf, Set.mem_inter_iff, SetLike.mem_coe, mem_fixedField_iff, xL, and_true] intro σ hσ have : ((restrictNormalHom L σ) ⟨x, xL⟩).1 = x := by rw [h σ hσ] nth_rw 2 [← this] exact (AlgEquiv.restrictNormal_commutes σ L ⟨x, xL⟩).symm open IntermediateField in lemma fixingSubgroup_fixedField (H : ClosedSubgroup Gal(K/k)) [IsGalois k K] : (IntermediateField.fixedField H).fixingSubgroup = H.1 := by apply le_antisymm _ ((IntermediateField.le_iff_le H.toSubgroup (IntermediateField.fixedField H.toSubgroup)).mp le_rfl) intro σ hσ by_contra h have nhds : H.carrierᶜ ∈ nhds σ := H.isClosed'.isOpen_compl.mem_nhds h rw [GroupFilterBasis.nhds_eq (x₀ := σ) (galGroupBasis k K)] at nhds rcases nhds with ⟨b, ⟨gp, ⟨L, hL, eq'⟩, eq⟩, sub⟩ rw [← eq'] at eq have := hL.out let L' : FiniteGaloisIntermediateField k K := { normalClosure k L K with finiteDimensional := normalClosure.is_finiteDimensional k L K isGalois := IsGalois.normalClosure k L K } have compl : σ • L'.1.fixingSubgroup.carrier ⊆ H.carrierᶜ := by rintro φ ⟨τ, hτ, muleq⟩ have sub' : σ • b ⊆ H.carrierᶜ := Set.smul_set_subset_iff.mpr sub apply sub' simp only [← muleq, ← eq] apply Set.smul_mem_smul_set exact (L.fixingSubgroup_le (IntermediateField.le_normalClosure L) hτ) have fix : ∀ x ∈ IntermediateField.fixedField H.toSubgroup ⊓ ↑L', σ x = x := fun x hx ↦ ((mem_fixingSubgroup_iff Gal(K/k)).mp hσ) x hx.1 rw [restrict_fixedField H.1 L'.1] at fix have : (restrictNormalHom L') σ ∈ (Subgroup.map (restrictNormalHom L') H.1) := by rw [← IntermediateField.fixingSubgroup_fixedField (Subgroup.map (restrictNormalHom L') H.1)] apply (mem_fixingSubgroup_iff (L' ≃ₐ[k] L')).mpr intro y hy apply Subtype.val_injective simp only [AlgEquiv.smul_def, restrictNormalHom_apply L'.1 σ y, fix y.1 ((IntermediateField.mem_lift y).mpr hy)] rcases this with ⟨h, mem, eq⟩ have : h ∈ σ • L'.1.fixingSubgroup.carrier := by use σ⁻¹ * h simp only [Subsemigroup.mem_carrier, Submonoid.mem_toSubsemigroup, Subgroup.mem_toSubmonoid, smul_eq_mul, mul_inv_cancel_left, and_true] apply (mem_fixingSubgroup_iff Gal(K/k)).mpr intro y hy simp only [AlgEquiv.smul_def, AlgEquiv.mul_apply] have : ((restrictNormalHom L') h ⟨y,hy⟩).1 = ((restrictNormalHom L') σ ⟨y,hy⟩).1 := by rw [eq] rw [restrictNormalHom_apply L'.1 h ⟨y, hy⟩, restrictNormalHom_apply L'.1 σ ⟨y, hy⟩] at this simp only [this, ← AlgEquiv.mul_apply, inv_mul_cancel, one_apply] absurd compl apply Set.not_subset.mpr use h simpa only [this, Set.mem_compl_iff, Subsemigroup.mem_carrier, Submonoid.mem_toSubsemigroup, Subgroup.mem_toSubmonoid, not_not, true_and] using mem /-- The Galois correspondence from intermediate fields to closed subgroups. -/ def IntermediateFieldEquivClosedSubgroup [IsGalois k K] : IntermediateField k K ≃o (ClosedSubgroup Gal(K/k))ᵒᵈ where toFun L := ⟨L.fixingSubgroup, fixingSubgroup_isClosed L⟩ invFun H := IntermediateField.fixedField H.1 left_inv L := fixedField_fixingSubgroup L right_inv H := by simp_rw [fixingSubgroup_fixedField H] rfl map_rel_iff' {K L} := by rw [← fixedField_fixingSubgroup L, IntermediateField.le_iff_le, fixedField_fixingSubgroup L] rfl /-- The Galois correspondence as a `GaloisInsertion` -/ def GaloisInsertionIntermediateFieldClosedSubgroup [IsGalois k K] : GaloisInsertion (OrderDual.toDual ∘ fun (E : IntermediateField k K) ↦ (⟨E.fixingSubgroup, fixingSubgroup_isClosed E⟩ : ClosedSubgroup Gal(K/k))) ((fun (H : ClosedSubgroup Gal(K/k)) ↦ IntermediateField.fixedField H) ∘ OrderDual.toDual) := OrderIso.toGaloisInsertion IntermediateFieldEquivClosedSubgroup /-- The Galois correspondence as a `GaloisCoinsertion` -/ def GaloisCoinsertionIntermediateFieldSubgroup [IsGalois k K] : GaloisCoinsertion (OrderDual.toDual ∘ fun (E : IntermediateField k K) ↦ E.fixingSubgroup) ((fun (H : Subgroup Gal(K/k)) ↦ IntermediateField.fixedField H) ∘ OrderDual.toDual) where choice H _ := IntermediateField.fixedField H gc E H := (IntermediateField.le_iff_le H E).symm u_l_le K := le_of_eq (fixedField_fixingSubgroup K) choice_eq _ _ := rfl open IntermediateField in theorem isOpen_iff_finite (L : IntermediateField k K) [IsGalois k K] : IsOpen L.fixingSubgroup.carrier ↔ FiniteDimensional k L := by refine ⟨fun h ↦ ?_, fun h ↦ IntermediateField.fixingSubgroup_isOpen L⟩ have : (IntermediateFieldEquivClosedSubgroup.toFun L).carrier ∈ nhds 1 := IsOpen.mem_nhds h (congrFun rfl) rw [GroupFilterBasis.nhds_one_eq] at this rcases this with ⟨S, ⟨gp, ⟨M, hM, eq'⟩, eq⟩, sub⟩ rw [← eq, ← eq'] at sub have := hM.out let L' : FiniteGaloisIntermediateField k K := { normalClosure k M K with finiteDimensional := normalClosure.is_finiteDimensional k M K isGalois := IsGalois.normalClosure k M K } have : L ≤ L'.1 := by apply le_trans _ (IntermediateField.le_normalClosure M) rw [← fixedField_fixingSubgroup M, IntermediateField.le_iff_le] exact sub let _ : Algebra L L'.1 := RingHom.toAlgebra (IntermediateField.inclusion this) exact FiniteDimensional.left k L L'.1 theorem normal_iff_isGalois (L : IntermediateField k K) [IsGalois k K] : L.fixingSubgroup.Normal ↔ IsGalois k L := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · let g (x : K) := L.fixingSubgroup.map (restrictNormalHom (adjoin k {x})) let f (x : L) : IntermediateField k K := IntermediateField.lift <| IntermediateField.fixedField <| g x.1 have (x : K) : (g x).Normal := Subgroup.Normal.map h (restrictNormalHom (adjoin k {x})) (restrictNormalHom_surjective K) have (l : L) : Normal k (f l) := Normal.of_algEquiv <| IntermediateField.liftAlgEquiv <| IntermediateField.fixedField (g l.1) have n : Normal k ↥(⨆ l : L, f l) := IntermediateField.normal_iSup k K f have : (⨆ l : L, f l) = L := by apply le_antisymm · apply iSup_le intro l simpa only [f, g, ← restrict_fixedField L.fixingSubgroup (adjoin k {l.1}), fixedField_fixingSubgroup L] using inf_le_left · intro l hl apply le_iSup f ⟨l, hl⟩ simpa only [f, g, ← restrict_fixedField L.fixingSubgroup (adjoin k {l}), fixedField_fixingSubgroup L, IntermediateField.mem_inf, hl, true_and] using adjoin_simple_le_iff.mp le_rfl rw [this] at n constructor · simpa only [IntermediateFieldEquivClosedSubgroup, RelIso.coe_fn_mk, Equiv.coe_fn_mk, ← L.restrictNormalHom_ker] using MonoidHom.normal_ker (restrictNormalHom L) theorem isOpen_and_normal_iff_finite_and_isGalois (L : IntermediateField k K) [IsGalois k K] : IsOpen L.fixingSubgroup.carrier ∧ L.fixingSubgroup.Normal ↔ FiniteDimensional k L ∧ IsGalois k L := by rw [isOpen_iff_finite, normal_iff_isGalois] end InfiniteGalois
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/NormalBasis.lean
import Mathlib.Algebra.Module.PID import Mathlib.Algebra.MvPolynomial.Funext import Mathlib.Algebra.Polynomial.Module.AEval import Mathlib.FieldTheory.Finite.Basic import Mathlib.FieldTheory.Galois.Basic import Mathlib.LinearAlgebra.AnnihilatingPolynomial import Mathlib.LinearAlgebra.Matrix.Nondegenerate /-! # The normal basis theorem We prove the normal basis theorem `IsGalois.normalBasis`: every finite Galois extension has a basis that is an orbit under the Galois group action. The proof follows [ConradLinearChar] Keith Conrad, *Linear Independence of Characters*. -/ variable (K L : Type*) [Field K] [Field L] [Algebra K L] open Polynomial FiniteField Module Submodule LinearMap in -- [ConradLinearChar] Theorem 3.7. private theorem exists_linearIndependent_algEquiv_apply_of_finite [Finite L] : ∃ x : L, LinearIndependent K fun σ : Gal(L/K) ↦ σ x := by have := Finite.of_injective _ (algebraMap K L).injective have := Fintype.ofFinite K /- Since `K[X]` is a PID and `L` is a finitely generated `K[X]`-module (with `X` acting as the Frobenius automorphism), there exists `x : L` whose `K[X]`-annihilator is equal to the `K[X]`-annihilator of `L`, which is generated by `X ^ [L : K] - 1`. -/ obtain ⟨x, hx⟩ := exists_ker_toSpanSingleton_eq_annihilator K[X] (AEval' (frobeniusAlgHom K L).toLinearMap) obtain ⟨x, rfl⟩ := (AEval'.of _).surjective x use x rw [← span_minpoly_eq_annihilator, minpoly_frobeniusAlgHom, eq_comm] at hx rw [← linearIndependent_equiv ((finCongr <| natDegree_X_pow_sub_C (R := K)).trans <| .ofBijective _ <| bijective_frobeniusAlgEquivOfAlgebraic_pow K L)] /- Therefore, `{Frⁱ | 0 ≤ i < [L : K]}` is linearly independent, which implies that `{Frⁱ(x) | 0 ≤ i < [L : K]}` is also linearly independent. -/ convert (AdjoinRoot.powerBasis (X_pow_sub_C_ne_zero Module.finrank_pos 1)).basis.linearIndependent |>.map' ((AEval'.of _).symm.toLinearMap ∘ₗ (liftQ _ _ hx.le).restrictScalars K) <| by exact congr($(ker_liftQ_eq_bot' _ _ hx).restrictScalars K) ext i simp_rw [Equiv.coe_trans, Function.comp_apply, finCongr_apply, Equiv.ofBijective_apply, AlgEquiv.coe_pow, AdjoinRoot.powerBasis, AdjoinRoot.powerBasisAux, Basis.coe_mk, coe_comp, LinearEquiv.coe_coe, LinearMap.coe_restrictScalars] refine (LinearEquiv.eq_symm_apply _).mpr (.symm <| (liftQ_apply ..).trans ?_) rw [toSpanSingleton_apply, AEval'.X_pow_smul_of, End.smul_def, End.coe_pow] rfl variable [FiniteDimensional K L] -- [ConradLinearChar] Theorem 3.6. private theorem exists_linearIndependent_algEquiv_apply_of_infinite [Infinite K] : ∃ x : L, LinearIndependent K fun σ : Gal(L/K) ↦ σ x := by classical /- Choose a basis `e` of `L` over `K` and form the matrix `M` with entries `∑ₖ i⁻¹j(eₖ)Xₖ` where `i,j ∈ Gal(L/K)` and `Xₖ`s are independent variables. -/ have e := Module.Free.chooseBasis K L let M : Matrix Gal(L/K) Gal(L/K) (MvPolynomial _ L) := .of fun i j ↦ ∑ k, i.symm (j (e k)) • .X k /- By [ConradLinearChar] Lemma 3.4, there exists `{xₖ} ⊆ L` such that `∑ₖ j(eₖ)xₖ = 1` if `j = 1` and `∑ₖ j(eₖ)xₖ = 0` otherwise. -/ have hq : Submodule.span L (Set.range fun k (j : Gal(L/K)) ↦ j (e k)) = ⊤ := by apply span_flip_eq_top_iff_linearIndependent.mpr <| ((linearIndependent_algHom_toLinearMap K L L).comp _ (algEquivEquivAlgHom K L).injective).map' _ (e.constr L).symm.ker /- If we evaluate `M` at `Xₖ = xₖ`, the determinant of `M` evaluates to 1. -/ obtain ⟨c, hc⟩ : ∃ c : _ → L, M.det.eval c = 1 := by obtain ⟨g, hg⟩ := (Submodule.mem_span_range_iff_exists_fun _).mp (hq ▸ Submodule.mem_top (x := Pi.single 1 1)) simp_rw [RingHom.map_det] refine ⟨g, congr(Matrix.det $(?_)).trans Matrix.det_one⟩ ext i j simpa [M, Pi.single_apply, inv_mul_eq_one, mul_comm, Matrix.one_apply] using congr($hg (i⁻¹ * j)) /- Therefore `det M` is nonzero. -/ have hM : M.det ≠ 0 := fun h0 ↦ by simpa [hc] using congr(($h0).eval c) /- Since `K` is infinite, we may evaluate `det M` at some point with coordinates in `K` and get a nonzero value. The coordinates give rise to an element of `L` via the basis `e`. -/ obtain ⟨b, hb⟩ : ∃ b : _ → K, M.det.eval (algebraMap K L ∘ b) ≠ 0 := by by_contra! h refine hM (MvPolynomial.funext_set _ (fun _ ↦ Set.infinite_range_of_injective (algebraMap K L).injective) fun x hx ↦ ?_) obtain ⟨x, rfl⟩ := Set.range_piMap _ ▸ hx simpa using h x /- This element of `L` is exactly what we want: we simply need to show the first row of the evaluated matrix is `K`-linearly independent. But since the other rows are obtained from the first row by applying a `K`-endomorphism, it suffices to show that the columns are linearly independent, which follows from the nonzeroness of the evaluated determinant. -/ refine ⟨∑ k, b k • e k, Fintype.linearIndependent_iff.mpr fun a ha ↦ funext_iff.mp <| (algebraMap K L).injective.comp_left ?_⟩ simp_rw [Function.comp_def, map_zero] rw [RingHom.map_det, RingHom.mapMatrix_apply] at hb refine Matrix.eq_zero_of_mulVec_eq_zero hb (funext fun i ↦ i.injective ?_) simp_rw [M, Pi.zero_apply, map_zero, ← ha] simp [Algebra.smul_def, Matrix.mulVec_eq_sum, mul_comm] theorem exists_linearIndependent_algEquiv_apply : ∃ x : L, LinearIndependent K fun σ : Gal(L/K) ↦ σ x := by obtain h | h := finite_or_infinite K · have := Module.finite_of_finite K (M := L) exact exists_linearIndependent_algEquiv_apply_of_finite K L · exact exists_linearIndependent_algEquiv_apply_of_infinite K L namespace IsGalois variable [IsGalois K L] /-- Given a finite Galois extension `L/K`, `normalBasis K L` is a basis of `L` over `K` that is an orbit under the Galois group action. -/ noncomputable def normalBasis : Module.Basis Gal(L/K) K L := basisOfLinearIndependentOfCardEqFinrank (exists_linearIndependent_algEquiv_apply K L).choose_spec (Fintype.card_eq_nat_card.trans <| card_aut_eq_finrank K L) variable {K L} theorem normalBasis_apply (e : Gal(L/K)) : normalBasis K L e = e (normalBasis K L 1) := by rw [normalBasis, coe_basisOfLinearIndependentOfCardEqFinrank, AlgEquiv.one_apply] end IsGalois
.lake/packages/mathlib/Mathlib/FieldTheory/Galois/GaloisClosure.lean
import Mathlib.FieldTheory.Normal.Closure import Mathlib.FieldTheory.SeparableClosure /-! # Main definitions and results In a field extension `K/k` * `FiniteGaloisIntermediateField` : The type of intermediate fields of `K/k` that are finite and Galois over `k` * `adjoin` : The finite Galois intermediate field obtained from the normal closure of adjoining a finite `s : Set K` to `k`. ## TODO * `FiniteGaloisIntermediateField` should be a `ConditionallyCompleteLattice` but isn't proved yet. -/ open IntermediateField variable (k K : Type*) [Field k] [Field K] [Algebra k K] /-- The type of intermediate fields of `K/k` that are finite and Galois over `k` -/ structure FiniteGaloisIntermediateField extends IntermediateField k K where [finiteDimensional : FiniteDimensional k toIntermediateField] [isGalois : IsGalois k toIntermediateField] namespace FiniteGaloisIntermediateField instance : Coe (FiniteGaloisIntermediateField k K) (IntermediateField k K) where coe := toIntermediateField instance : CoeSort (FiniteGaloisIntermediateField k K) (Type _) where coe L := L.toIntermediateField instance (L : FiniteGaloisIntermediateField k K) : FiniteDimensional k L := L.finiteDimensional instance (L : FiniteGaloisIntermediateField k K) : IsGalois k L := L.isGalois variable {k K} lemma val_injective : Function.Injective (toIntermediateField (k := k) (K := K)) := by rintro ⟨⟩ ⟨⟩ eq simpa only [mk.injEq] using eq /-- Turns the collection of finite Galois IntermediateFields of `K/k` into a lattice. -/ instance (L₁ L₂ : IntermediateField k K) [IsGalois k L₁] [IsGalois k L₂] : IsGalois k ↑(L₁ ⊔ L₂) where instance (L₁ L₂ : IntermediateField k K) [FiniteDimensional k L₁] : FiniteDimensional k ↑(L₁ ⊓ L₂) := .of_injective (IntermediateField.inclusion (E := L₁ ⊓ L₂) (F := L₁) inf_le_left).toLinearMap (IntermediateField.inclusion (E := L₁ ⊓ L₂) (F := L₁) inf_le_left).toRingHom.injective instance (L₁ L₂ : IntermediateField k K) [FiniteDimensional k L₂] : FiniteDimensional k ↑(L₁ ⊓ L₂) := .of_injective (IntermediateField.inclusion (E := L₁ ⊓ L₂) (F := L₂) inf_le_right).toLinearMap (IntermediateField.inclusion (E := L₁ ⊓ L₂) (F := L₂) inf_le_right).injective instance (L₁ L₂ : IntermediateField k K) [Algebra.IsSeparable k L₁] : Algebra.IsSeparable k ↑(L₁ ⊓ L₂) := .of_algHom _ _ (IntermediateField.inclusion inf_le_left) instance (L₁ L₂ : IntermediateField k K) [Algebra.IsSeparable k L₂] : Algebra.IsSeparable k ↑(L₁ ⊓ L₂) := .of_algHom _ _ (IntermediateField.inclusion inf_le_right) instance (L₁ L₂ : IntermediateField k K) [IsGalois k L₁] [IsGalois k L₂] : IsGalois k ↑(L₁ ⊓ L₂) where instance : Max (FiniteGaloisIntermediateField k K) where max L₁ L₂ := .mk <| L₁ ⊔ L₂ instance : Min (FiniteGaloisIntermediateField k K) where min L₁ L₂ := .mk <| L₁ ⊓ L₂ instance : Lattice (FiniteGaloisIntermediateField k K) := val_injective.lattice _ (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) instance : OrderBot (FiniteGaloisIntermediateField k K) where bot := .mk ⊥ bot_le _ := bot_le (α := IntermediateField _ _) @[simp] lemma le_iff (L₁ L₂ : FiniteGaloisIntermediateField k K) : L₁ ≤ L₂ ↔ L₁.toIntermediateField ≤ L₂.toIntermediateField := Iff.rfl variable (k) in /-- The minimal (finite) Galois intermediate field containing a finite set `s : Set K` in a Galois extension `K/k` defined as the normal closure of the field obtained by adjoining the set `s : Set K` to `k`. -/ noncomputable def adjoin [IsGalois k K] (s : Set K) [Finite s] : FiniteGaloisIntermediateField k K := { normalClosure k (IntermediateField.adjoin k (s : Set K)) K with finiteDimensional := letI : FiniteDimensional k (IntermediateField.adjoin k (s : Set K)) := IntermediateField.finiteDimensional_adjoin <| fun z _ => IsAlgebraic.isIntegral (Algebra.IsAlgebraic.isAlgebraic z) normalClosure.is_finiteDimensional k (IntermediateField.adjoin k (s : Set K)) K isGalois := IsGalois.normalClosure k (IntermediateField.adjoin k (s : Set K)) K } @[simp] lemma adjoin_val [IsGalois k K] (s : Set K) [Finite s] : (FiniteGaloisIntermediateField.adjoin k s) = normalClosure k (IntermediateField.adjoin k s) K := rfl variable (k) in lemma subset_adjoin [IsGalois k K] (s : Set K) [Finite s] : s ⊆ (adjoin k s).toIntermediateField := (IntermediateField.subset_adjoin k s).trans (IntermediateField.le_normalClosure _) theorem adjoin_simple_le_iff [IsGalois k K] {x : K} {L : FiniteGaloisIntermediateField k K} : adjoin k {x} ≤ L ↔ x ∈ L.toIntermediateField := by simp only [le_iff, adjoin_val, IntermediateField.normalClosure_le_iff_of_normal, IntermediateField.adjoin_le_iff, Set.singleton_subset_iff, SetLike.mem_coe] @[simp] theorem adjoin_map [IsGalois k K] (f : K →ₐ[k] K) (s : Set K) [Finite s] : adjoin k (f '' s) = adjoin k s := by apply val_injective; dsimp [adjoin_val] rw [← IntermediateField.adjoin_map, IntermediateField.normalClosure_map_eq] @[simp] theorem adjoin_simple_map_algHom [IsGalois k K] (f : K →ₐ[k] K) (x : K) : adjoin k {f x} = adjoin k {x} := by simpa only [Set.image_singleton] using adjoin_map f { x } @[simp] theorem adjoin_simple_map_algEquiv [IsGalois k K] (f : Gal(K/k)) (x : K) : adjoin k {f x} = adjoin k {x} := adjoin_simple_map_algHom (f : K →ₐ[k] K) x nonrec lemma mem_fixingSubgroup_iff (α : Gal(K/k)) (L : FiniteGaloisIntermediateField k K) : α ∈ L.fixingSubgroup ↔ α.restrictNormalHom L = 1 := by simp [IntermediateField.fixingSubgroup, mem_fixingSubgroup_iff, AlgEquiv.ext_iff, Subtype.ext_iff, AlgEquiv.restrictNormalHom_apply] end FiniteGaloisIntermediateField
.lake/packages/mathlib/Mathlib/FieldTheory/RatFunc/AsPolynomial.lean
import Mathlib.FieldTheory.RatFunc.Basic import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.DedekindDomain.AdicValuation import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content /-! # Generalities on the polynomial structure of rational functions * Main evaluation properties * Study of the X-adic valuation ## Main definitions - `RatFunc.C` is the constant polynomial - `RatFunc.X` is the indeterminate - `RatFunc.eval` evaluates a rational function given a value for the indeterminate - `idealX` is the principal ideal generated by `X` in the ring of polynomials over a field K, regarded as an element of the height-one-spectrum. -/ noncomputable section universe u variable {K : Type u} namespace RatFunc section Eval open scoped nonZeroDivisors Polynomial open RatFunc /-! ### Polynomial structure: `C`, `X`, `eval` -/ section Domain variable [CommRing K] [IsDomain K] /-- `RatFunc.C a` is the constant rational function `a`. -/ def C : K →+* RatFunc K := algebraMap _ _ @[simp] theorem algebraMap_eq_C : algebraMap K (RatFunc K) = C := rfl @[simp] theorem algebraMap_C (a : K) : algebraMap K[X] (RatFunc K) (Polynomial.C a) = C a := rfl @[simp] theorem algebraMap_comp_C : (algebraMap K[X] (RatFunc K)).comp Polynomial.C = C := rfl theorem smul_eq_C_mul (r : K) (x : RatFunc K) : r • x = C r * x := by rw [Algebra.smul_def, algebraMap_eq_C] theorem C_injective : Function.Injective (RatFunc.C (K := K)) := by rw [← algebraMap_comp_C, RingHom.coe_comp] exact Function.Injective.comp (algebraMap_injective K) (Polynomial.C_injective) /-- `RatFunc.X` is the polynomial variable (aka indeterminate). -/ def X : RatFunc K := algebraMap K[X] (RatFunc K) Polynomial.X @[simp] theorem algebraMap_X : algebraMap K[X] (RatFunc K) Polynomial.X = X := rfl @[simp] theorem algebraMap_monomial (n : ℕ) (a : K) : algebraMap K[X] (RatFunc K) (Polynomial.monomial n a) = C a * X ^ n := by simp [← Polynomial.C_mul_X_pow_eq_monomial] @[simp] theorem aeval_X_left_eq_algebraMap (p : K[X]) : p.aeval (X : RatFunc K) = algebraMap K[X] (RatFunc K) p := by induction p using Polynomial.induction_on' <;> simp_all end Domain section Field variable [Field K] @[simp] theorem num_C (c : K) : num (C c) = Polynomial.C c := num_algebraMap _ @[simp] theorem denom_C (c : K) : denom (C c) = 1 := denom_algebraMap _ @[simp] theorem num_X : num (X : RatFunc K) = Polynomial.X := num_algebraMap _ @[simp] theorem denom_X : denom (X : RatFunc K) = 1 := denom_algebraMap _ theorem X_ne_zero : (X : RatFunc K) ≠ 0 := RatFunc.algebraMap_ne_zero Polynomial.X_ne_zero variable {L : Type u} [Field L] /-- Evaluate a rational function `p` given a ring hom `f` from the scalar field to the target and a value `x` for the variable in the target. Fractions are reduced by clearing common denominators before evaluating: `eval id 1 ((X^2 - 1) / (X - 1)) = eval id 1 (X + 1) = 2`, not `0 / 0 = 0`. -/ def eval (f : K →+* L) (a : L) (p : RatFunc K) : L := (num p).eval₂ f a / (denom p).eval₂ f a variable {f : K →+* L} {a : L} theorem eval_eq_zero_of_eval₂_denom_eq_zero {x : RatFunc K} (h : Polynomial.eval₂ f a (denom x) = 0) : eval f a x = 0 := by rw [eval, h, div_zero] theorem eval₂_denom_ne_zero {x : RatFunc K} (h : eval f a x ≠ 0) : Polynomial.eval₂ f a (denom x) ≠ 0 := mt eval_eq_zero_of_eval₂_denom_eq_zero h variable (f a) @[simp] theorem eval_C {c : K} : eval f a (C c) = f c := by simp [eval] @[simp] theorem eval_X : eval f a X = a := by simp [eval] @[simp] theorem eval_zero : eval f a 0 = 0 := by simp [eval] @[simp] theorem eval_one : eval f a 1 = 1 := by simp [eval] @[simp] theorem eval_algebraMap {S : Type*} [CommSemiring S] [Algebra S K[X]] (p : S) : eval f a (algebraMap _ _ p) = (algebraMap _ K[X] p).eval₂ f a := by simp [eval, IsScalarTower.algebraMap_apply S K[X] (RatFunc K)] /-- `eval` is an additive homomorphism except when a denominator evaluates to `0`. Counterexample: `eval _ 1 (X / (X-1)) + eval _ 1 (-1 / (X-1)) = 0` `... ≠ 1 = eval _ 1 ((X-1) / (X-1))`. See also `RatFunc.eval₂_denom_ne_zero` to make the hypotheses simpler but less general. -/ theorem eval_add {x y : RatFunc K} (hx : Polynomial.eval₂ f a (denom x) ≠ 0) (hy : Polynomial.eval₂ f a (denom y) ≠ 0) : eval f a (x + y) = eval f a x + eval f a y := by unfold eval by_cases hxy : Polynomial.eval₂ f a (denom (x + y)) = 0 · have := Polynomial.eval₂_eq_zero_of_dvd_of_eval₂_eq_zero f a (denom_add_dvd x y) hxy rw [Polynomial.eval₂_mul] at this cases mul_eq_zero.mp this <;> contradiction rw [div_add_div _ _ hx hy, eq_div_iff (mul_ne_zero hx hy), div_eq_mul_inv, mul_right_comm, ← div_eq_mul_inv, div_eq_iff hxy] simp only [← Polynomial.eval₂_mul, ← Polynomial.eval₂_add] congr 1 apply num_denom_add /-- `eval` is a multiplicative homomorphism except when a denominator evaluates to `0`. Counterexample: `eval _ 0 X * eval _ 0 (1/X) = 0 ≠ 1 = eval _ 0 1 = eval _ 0 (X * 1/X)`. See also `RatFunc.eval₂_denom_ne_zero` to make the hypotheses simpler but less general. -/ theorem eval_mul {x y : RatFunc K} (hx : Polynomial.eval₂ f a (denom x) ≠ 0) (hy : Polynomial.eval₂ f a (denom y) ≠ 0) : eval f a (x * y) = eval f a x * eval f a y := by unfold eval by_cases hxy : Polynomial.eval₂ f a (denom (x * y)) = 0 · have := Polynomial.eval₂_eq_zero_of_dvd_of_eval₂_eq_zero f a (denom_mul_dvd x y) hxy rw [Polynomial.eval₂_mul] at this cases mul_eq_zero.mp this <;> contradiction rw [div_mul_div_comm, eq_div_iff (mul_ne_zero hx hy), div_eq_mul_inv, mul_right_comm, ← div_eq_mul_inv, div_eq_iff hxy] repeat' rw [← Polynomial.eval₂_mul] congr 1 apply num_denom_mul end Field end Eval section Algebra variable [CommRing K] [IsDomain K] lemma transcendental_X : Transcendental K (X : RatFunc K) := by rw [← RatFunc.algebraMap_X, transcendental_algebraMap_iff (algebraMap_injective K)] exact Polynomial.transcendental_X K end Algebra end RatFunc section AdicValuation variable (K : Type*) [Field K] namespace Polynomial section HeightOneSpectrum open IsDedekindDomain.HeightOneSpectrum WithZero /-- This is the principal ideal generated by `X` in the ring of polynomials over a field K, regarded as an element of the height-one-spectrum. -/ def idealX : IsDedekindDomain.HeightOneSpectrum K[X] where asIdeal := Ideal.span {X} isPrime := by rw [Ideal.span_singleton_prime]; exacts [Polynomial.prime_X, Polynomial.X_ne_zero] ne_bot := by rw [ne_eq, Ideal.span_singleton_eq_bot]; exact Polynomial.X_ne_zero @[simp] theorem idealX_span : (idealX K).asIdeal = Ideal.span {X} := rfl @[simp] theorem valuation_X_eq_neg_one : (idealX K).valuation (RatFunc K) RatFunc.X = exp (-1 : ℤ) := by rw [← RatFunc.algebraMap_X, valuation_of_algebraMap, intValuation_singleton _ (Polynomial.X_ne_zero) (idealX_span K)] theorem valuation_of_mk (f : Polynomial K) {g : Polynomial K} (hg : g ≠ 0) : (Polynomial.idealX K).valuation _ (RatFunc.mk f g) = (Polynomial.idealX K).intValuation f / (Polynomial.idealX K).intValuation g := by simp only [RatFunc.mk_eq_mk' _ hg, valuation_of_mk'] end HeightOneSpectrum section TrivialOnConstants variable {Γ : Type*} [LinearOrderedCommGroupWithZero Γ] section Algebra variable (L : Type*) [Field L] [Algebra K L] {v : Valuation L Γ} (hv : ∀ a : K, a ≠ 0 → v (algebraMap K L a) = 1) include hv lemma valuation_aeval_monomial_eq_valuation_pow (w : L) (n : ℕ) {a : K} (ha : a ≠ 0) : v ((monomial n a).aeval w) = (v w) ^ n := by simp [← C_mul_X_pow_eq_monomial, map_mul, map_pow, one_mul, hv a ha] theorem valuation_aeval_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X (w : L) (hpos : 1 < v w) {p : Polynomial K} (hp : p ≠ 0) : v (p.aeval w) = v w ^ p.natDegree := by rw [← valuation_aeval_monomial_eq_valuation_pow _ _ hv _ _ ((leadingCoeff_ne_zero).mpr hp)] nth_rw 1 [as_sum_range p, map_sum] apply Valuation.map_sum_eq_of_lt _ (by simp) intro i hi simp only [Finset.mem_sdiff, Finset.mem_range, Nat.lt_add_one_iff, Finset.mem_singleton, ← lt_iff_le_and_ne] at hi simp only [← C_mul_X_pow_eq_monomial, map_mul, aeval_C, map_pow, aeval_X, coeff_natDegree] by_cases h0 : (p.coeff i) = 0 · simp [h0, map_zero, zero_mul, one_mul, hv p.leadingCoeff ((leadingCoeff_ne_zero).mpr hp), pow_pos (lt_trans zero_lt_one hpos) p.natDegree] · simp [one_mul, hv p.leadingCoeff ((leadingCoeff_ne_zero).mpr hp), hv _ h0, one_mul, pow_lt_pow_right₀ hpos hi] end Algebra variable {v : Valuation (RatFunc K) Γ} (hv : ∀ a : K, a ≠ 0 → v (C a) = 1) open Valuation include hv /-- If a valuation `v` is trivial on constants then for every `n : ℕ` the valuation of `(monomial n a)` is equal to `(v RatFunc.X) ^ n`. -/ lemma valuation_monomial_eq_valuation_X_pow (n : ℕ) {a : K} (ha : a ≠ 0) : v (monomial n a) = v RatFunc.X ^ n := by simp_all [RatFunc.coePolynomial, ← C_mul_X_pow_eq_monomial] /-- If a valuation `v` is trivial on constants and `1 < v RatFunc.X` then for every polynomial `p`, `v p = v RatFunc.X ^ p.natDegree`. Note: The condition `1 < v RatFunc.X` is typically satisfied by the valuation at infinity. -/ theorem valuation_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X (hlt : 1 < v RatFunc.X) {p : K[X]} (hp : p ≠ 0) : v p = v RatFunc.X ^ p.natDegree := by convert valuation_aeval_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X K (RatFunc K) hv RatFunc.X hlt hp ext p nth_rw 1 [RatFunc.X, ← aeval_X_left_apply p (R := K)] exact (aeval_algebraMap_apply (RatFunc K) X p).symm /-- If a valuation `v` is trivial on constants and `v RatFunc.X ≤ 1` then for every polynomial `p`, `v p ≤ 1`. -/ theorem valuation_le_one_of_valuation_X_le_one (hle : v RatFunc.X ≤ 1) (p : K[X]) : v p ≤ 1 := by rw [as_sum_range p, RatFunc.coePolynomial, map_sum] apply map_sum_le v intro i by_cases h0 : p.coeff i = 0 · simp_all · rw [← RatFunc.coePolynomial] simp_all [valuation_monomial_eq_valuation_X_pow, pow_le_one'] /-- If a valuation `v` is trivial on constants then for every `n : ℕ` the valuation of `1 / (monomial n a)` (as an element of the field of rational functions) is equal to `(v RatFunc.X) ^ (- n)`. -/ lemma valuation_inv_monomial_eq_valuation_X_zpow (n : ℕ) {a : K} (ha : a ≠ 0) : v (1 / monomial n a) = v RatFunc.X ^ (- (n : ℤ)) := by simpa using valuation_monomial_eq_valuation_X_pow _ hv n ha end TrivialOnConstants end Polynomial namespace RatFunc open scoped WithZero open Polynomial instance : Valued (RatFunc K) ℤᵐ⁰ := Valued.mk' ((idealX K).valuation _) @[simp] theorem v_def {x : RatFunc K} : Valued.v x = (idealX K).valuation _ x := rfl end RatFunc end AdicValuation
.lake/packages/mathlib/Mathlib/FieldTheory/RatFunc/Basic.lean
import Mathlib.Algebra.CharP.Algebra import Mathlib.FieldTheory.RatFunc.Defs import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.Algebraic.Integral /-! # The field structure of rational functions ## Main definitions Working with rational functions as polynomials: - `RatFunc.instField` provides a field structure You can use `IsFractionRing` API to treat `RatFunc` as the field of fractions of polynomials: * `algebraMap K[X] (RatFunc K)` maps polynomials to rational functions * `IsFractionRing.algEquiv` maps other fields of fractions of `K[X]` to `RatFunc K`. In particular: * `FractionRing.algEquiv K[X] (RatFunc K)` maps the generic field of fraction construction to `RatFunc K`. Combine this with `AlgEquiv.restrictScalars` to change the `FractionRing K[X] ≃ₐ[K[X]] RatFunc K` to `FractionRing K[X] ≃ₐ[K] RatFunc K`. Working with rational functions as fractions: - `RatFunc.num` and `RatFunc.denom` give the numerator and denominator. These values are chosen to be coprime and such that `RatFunc.denom` is monic. Lifting homomorphisms of polynomials to other types, by mapping and dividing, as long as the homomorphism retains the non-zero-divisor property: - `RatFunc.liftMonoidWithZeroHom` lifts a `K[X] →*₀ G₀` to a `RatFunc K →*₀ G₀`, where `[CommRing K] [CommGroupWithZero G₀]` - `RatFunc.liftRingHom` lifts a `K[X] →+* L` to a `RatFunc K →+* L`, where `[CommRing K] [Field L]` - `RatFunc.liftAlgHom` lifts a `K[X] →ₐ[S] L` to a `RatFunc K →ₐ[S] L`, where `[CommRing K] [Field L] [CommSemiring S] [Algebra S K[X]] [Algebra S L]` This is satisfied by injective homs. We also have lifting homomorphisms of polynomials to other polynomials, with the same condition on retaining the non-zero-divisor property across the map: - `RatFunc.map` lifts `K[X] →* R[X]` when `[CommRing K] [CommRing R]` - `RatFunc.mapRingHom` lifts `K[X] →+* R[X]` when `[CommRing K] [CommRing R]` - `RatFunc.mapAlgHom` lifts `K[X] →ₐ[S] R[X]` when `[CommRing K] [IsDomain K] [CommRing R] [IsDomain R]` -/ universe u v noncomputable section open scoped nonZeroDivisors Polynomial variable {K : Type u} namespace RatFunc section Field variable [CommRing K] /-- The zero rational function. -/ protected irreducible_def zero : RatFunc K := ⟨0⟩ instance : Zero (RatFunc K) := ⟨RatFunc.zero⟩ theorem ofFractionRing_zero : (ofFractionRing 0 : RatFunc K) = 0 := zero_def.symm /-- Addition of rational functions. -/ protected irreducible_def add : RatFunc K → RatFunc K → RatFunc K | ⟨p⟩, ⟨q⟩ => ⟨p + q⟩ instance : Add (RatFunc K) := ⟨RatFunc.add⟩ theorem ofFractionRing_add (p q : FractionRing K[X]) : ofFractionRing (p + q) = ofFractionRing p + ofFractionRing q := (add_def _ _).symm /-- Subtraction of rational functions. -/ protected irreducible_def sub : RatFunc K → RatFunc K → RatFunc K | ⟨p⟩, ⟨q⟩ => ⟨p - q⟩ instance : Sub (RatFunc K) := ⟨RatFunc.sub⟩ theorem ofFractionRing_sub (p q : FractionRing K[X]) : ofFractionRing (p - q) = ofFractionRing p - ofFractionRing q := (sub_def _ _).symm /-- Additive inverse of a rational function. -/ protected irreducible_def neg : RatFunc K → RatFunc K | ⟨p⟩ => ⟨-p⟩ instance : Neg (RatFunc K) := ⟨RatFunc.neg⟩ theorem ofFractionRing_neg (p : FractionRing K[X]) : ofFractionRing (-p) = -ofFractionRing p := (neg_def _).symm /-- The multiplicative unit of rational functions. -/ protected irreducible_def one : RatFunc K := ⟨1⟩ instance : One (RatFunc K) := ⟨RatFunc.one⟩ theorem ofFractionRing_one : (ofFractionRing 1 : RatFunc K) = 1 := one_def.symm /-- Multiplication of rational functions. -/ protected irreducible_def mul : RatFunc K → RatFunc K → RatFunc K | ⟨p⟩, ⟨q⟩ => ⟨p * q⟩ instance : Mul (RatFunc K) := ⟨RatFunc.mul⟩ theorem ofFractionRing_mul (p q : FractionRing K[X]) : ofFractionRing (p * q) = ofFractionRing p * ofFractionRing q := (mul_def _ _).symm section IsDomain variable [IsDomain K] /-- Division of rational functions. -/ protected irreducible_def div : RatFunc K → RatFunc K → RatFunc K | ⟨p⟩, ⟨q⟩ => ⟨p / q⟩ instance : Div (RatFunc K) := ⟨RatFunc.div⟩ theorem ofFractionRing_div (p q : FractionRing K[X]) : ofFractionRing (p / q) = ofFractionRing p / ofFractionRing q := (div_def _ _).symm /-- Multiplicative inverse of a rational function. -/ protected irreducible_def inv : RatFunc K → RatFunc K | ⟨p⟩ => ⟨p⁻¹⟩ instance : Inv (RatFunc K) := ⟨RatFunc.inv⟩ theorem ofFractionRing_inv (p : FractionRing K[X]) : ofFractionRing p⁻¹ = (ofFractionRing p)⁻¹ := (inv_def _).symm -- Auxiliary lemma for the `Field` instance theorem mul_inv_cancel : ∀ {p : RatFunc K}, p ≠ 0 → p * p⁻¹ = 1 | ⟨p⟩, h => by have : p ≠ 0 := fun hp => h <| by rw [hp, ofFractionRing_zero] simpa only [← ofFractionRing_inv, ← ofFractionRing_mul, ← ofFractionRing_one, ofFractionRing.injEq] using mul_inv_cancel₀ this end IsDomain section SMul variable {R : Type*} /-- Scalar multiplication of rational functions. -/ protected irreducible_def smul [SMul R (FractionRing K[X])] : R → RatFunc K → RatFunc K | r, ⟨p⟩ => ⟨r • p⟩ instance [SMul R (FractionRing K[X])] : SMul R (RatFunc K) := ⟨RatFunc.smul⟩ theorem ofFractionRing_smul [SMul R (FractionRing K[X])] (c : R) (p : FractionRing K[X]) : ofFractionRing (c • p) = c • ofFractionRing p := (smul_def _ _).symm theorem toFractionRing_smul [SMul R (FractionRing K[X])] (c : R) (p : RatFunc K) : toFractionRing (c • p) = c • toFractionRing p := by cases p rw [← ofFractionRing_smul] theorem smul_eq_C_smul (x : RatFunc K) (r : K) : r • x = Polynomial.C r • x := by obtain ⟨x⟩ := x induction x using Localization.induction_on rw [← ofFractionRing_smul, ← ofFractionRing_smul, Localization.smul_mk, Localization.smul_mk, smul_eq_mul, Polynomial.smul_eq_C_mul] section IsDomain variable [IsDomain K] variable [Monoid R] [DistribMulAction R K[X]] variable [IsScalarTower R K[X] K[X]] theorem mk_smul (c : R) (p q : K[X]) : RatFunc.mk (c • p) q = c • RatFunc.mk p q := by letI : SMulZeroClass R (FractionRing K[X]) := inferInstance by_cases hq : q = 0 · rw [hq, mk_zero, mk_zero, ← ofFractionRing_smul, smul_zero] · rw [mk_eq_localization_mk _ hq, mk_eq_localization_mk _ hq, ← Localization.smul_mk, ← ofFractionRing_smul] instance : IsScalarTower R K[X] (RatFunc K) := ⟨fun c p q => q.induction_on' fun q r _ => by rw [← mk_smul, smul_assoc, mk_smul, mk_smul]⟩ end IsDomain end SMul variable (K) instance [Subsingleton K] : Subsingleton (RatFunc K) := toFractionRing_injective.subsingleton instance : Inhabited (RatFunc K) := ⟨0⟩ instance instNontrivial [Nontrivial K] : Nontrivial (RatFunc K) := ofFractionRing_injective.nontrivial /-- `RatFunc K` is isomorphic to the field of fractions of `K[X]`, as rings. This is an auxiliary definition; `simp`-normal form is `IsLocalization.algEquiv`. -/ @[simps apply] def toFractionRingRingEquiv : RatFunc K ≃+* FractionRing K[X] where toFun := toFractionRing invFun := ofFractionRing map_add' := fun ⟨_⟩ ⟨_⟩ => by simp [← ofFractionRing_add] map_mul' := fun ⟨_⟩ ⟨_⟩ => by simp [← ofFractionRing_mul] end Field section TacticInterlude /-- Solve equations for `RatFunc K` by working in `FractionRing K[X]`. -/ macro "frac_tac" : tactic => `(tactic| · repeat (rintro (⟨⟩ : RatFunc _)) try simp only [← ofFractionRing_zero, ← ofFractionRing_add, ← ofFractionRing_sub, ← ofFractionRing_neg, ← ofFractionRing_one, ← ofFractionRing_mul, ← ofFractionRing_div, ← ofFractionRing_inv, add_assoc, zero_add, add_zero, mul_assoc, mul_zero, mul_one, mul_add, inv_zero, add_comm, add_left_comm, mul_comm, mul_left_comm, sub_eq_add_neg, div_eq_mul_inv, add_mul, zero_mul, one_mul, neg_mul, mul_neg, add_neg_cancel]) /-- Solve equations for `RatFunc K` by applying `RatFunc.induction_on`. -/ macro "smul_tac" : tactic => `(tactic| repeat (first | rintro (⟨⟩ : RatFunc _) | intro) <;> simp_rw [← ofFractionRing_smul] <;> simp only [add_comm, mul_comm, zero_smul, succ_nsmul, zsmul_eq_mul, mul_add, mul_one, mul_zero, neg_add, mul_neg, Int.cast_zero, Int.cast_add, Int.cast_one, Int.cast_negSucc, Int.cast_natCast, Nat.cast_succ, Localization.mk_zero, Localization.add_mk_self, Localization.neg_mk, ofFractionRing_zero, ← ofFractionRing_add, ← ofFractionRing_neg]) end TacticInterlude section CommRing variable (K) [CommRing K] /-- `RatFunc K` is a commutative monoid. This is an intermediate step on the way to the full instance `RatFunc.instCommRing`. -/ def instCommMonoid : CommMonoid (RatFunc K) where mul_assoc := by frac_tac mul_comm := by frac_tac one_mul := by frac_tac mul_one := by frac_tac npow := npowRec /-- `RatFunc K` is an additive commutative group. This is an intermediate step on the way to the full instance `RatFunc.instCommRing`. -/ def instAddCommGroup : AddCommGroup (RatFunc K) where add_assoc := by frac_tac add_comm := by frac_tac zero_add := by frac_tac add_zero := by frac_tac neg_add_cancel := by frac_tac sub_eq_add_neg := by frac_tac nsmul := (· • ·) nsmul_zero := by smul_tac nsmul_succ _ := by smul_tac zsmul := (· • ·) zsmul_zero' := by smul_tac zsmul_succ' _ := by smul_tac zsmul_neg' _ := by smul_tac instance instCommRing : CommRing (RatFunc K) := { instCommMonoid K, instAddCommGroup K with zero_mul := by frac_tac mul_zero := by frac_tac left_distrib := by frac_tac right_distrib := by frac_tac npow := npowRec } variable {K} section LiftHom open RatFunc variable {G₀ L R S F : Type*} [CommGroupWithZero G₀] [Field L] [CommRing R] [CommRing S] variable [FunLike F R[X] S[X]] open scoped Classical in /-- Lift a monoid homomorphism that maps polynomials `φ : R[X] →* S[X]` to a `RatFunc R →* RatFunc S`, on the condition that `φ` maps non-zero-divisors to non-zero-divisors, by mapping both the numerator and denominator and quotienting them. -/ def map [MonoidHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) : RatFunc R →* RatFunc S where toFun f := RatFunc.liftOn f (fun n d => if h : φ d ∈ S[X]⁰ then ofFractionRing (Localization.mk (φ n) ⟨φ d, h⟩) else 0) fun {p q p' q'} hq hq' h => by simp only [Submonoid.mem_comap.mp (hφ hq), Submonoid.mem_comap.mp (hφ hq'), dif_pos, ofFractionRing.injEq, Localization.mk_eq_mk_iff] refine Localization.r_of_eq ?_ simpa only [map_mul] using congr_arg φ h map_one' := by simp_rw [← ofFractionRing_one, ← Localization.mk_one, liftOn_ofFractionRing_mk, OneMemClass.coe_one, map_one, OneMemClass.one_mem, dite_true, ofFractionRing.injEq, Localization.mk_one, Localization.mk_eq_monoidOf_mk', Submonoid.LocalizationMap.mk'_self] map_mul' x y := by obtain ⟨x⟩ := x; obtain ⟨y⟩ := y cases x using Localization.induction_on with | _ pq cases y using Localization.induction_on with | _ p'q' obtain ⟨p, q⟩ := pq obtain ⟨p', q'⟩ := p'q' have hq : φ q ∈ S[X]⁰ := hφ q.prop have hq' : φ q' ∈ S[X]⁰ := hφ q'.prop have hqq' : φ ↑(q * q') ∈ S[X]⁰ := by simpa using Submonoid.mul_mem _ hq hq' simp_rw [← ofFractionRing_mul, Localization.mk_mul, liftOn_ofFractionRing_mk, dif_pos hq, dif_pos hq', dif_pos hqq', ← ofFractionRing_mul, Submonoid.coe_mul, map_mul, Localization.mk_mul, Submonoid.mk_mul_mk] theorem map_apply_ofFractionRing_mk [MonoidHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) (n : R[X]) (d : R[X]⁰) : map φ hφ (ofFractionRing (Localization.mk n d)) = ofFractionRing (Localization.mk (φ n) ⟨φ d, hφ d.prop⟩) := by simp only [map, MonoidHom.coe_mk, OneHom.coe_mk, liftOn_ofFractionRing_mk, Submonoid.mem_comap.mp (hφ d.2), ↓reduceDIte] theorem map_injective [MonoidHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) (hf : Function.Injective φ) : Function.Injective (map φ hφ) := by rintro ⟨x⟩ ⟨y⟩ h induction x using Localization.induction_on induction y using Localization.induction_on simpa only [map_apply_ofFractionRing_mk, ofFractionRing_injective.eq_iff, Localization.mk_eq_mk_iff, Localization.r_iff_exists, mul_cancel_left_coe_nonZeroDivisors, exists_const, ← map_mul, hf.eq_iff] using h /-- Lift a ring homomorphism that maps polynomials `φ : R[X] →+* S[X]` to a `RatFunc R →+* RatFunc S`, on the condition that `φ` maps non-zero-divisors to non-zero-divisors, by mapping both the numerator and denominator and quotienting them. -/ def mapRingHom [RingHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) : RatFunc R →+* RatFunc S := { map φ hφ with map_zero' := by simp_rw [MonoidHom.toFun_eq_coe, ← ofFractionRing_zero, ← Localization.mk_zero (1 : R[X]⁰), ← Localization.mk_zero (1 : S[X]⁰), map_apply_ofFractionRing_mk, map_zero, Localization.mk_eq_mk', IsLocalization.mk'_zero] map_add' := by rintro ⟨x⟩ ⟨y⟩ induction x using Localization.induction_on induction y using Localization.induction_on · simp only [← ofFractionRing_add, Localization.add_mk, map_add, map_mul, MonoidHom.toFun_eq_coe, map_apply_ofFractionRing_mk, Submonoid.coe_mul, -- We have to specify `S[X]⁰` to `mk_mul_mk`, otherwise it will try to rewrite -- the wrong occurrence. Submonoid.mk_mul_mk S[X]⁰] } theorem coe_mapRingHom_eq_coe_map [RingHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) : (mapRingHom φ hφ : RatFunc R → RatFunc S) = map φ hφ := rfl -- TODO: Generalize to `FunLike` classes, /-- Lift a monoid with zero homomorphism `R[X] →*₀ G₀` to a `RatFunc R →*₀ G₀` on the condition that `φ` maps non-zero-divisors to non-zero-divisors, by mapping both the numerator and denominator and quotienting them. -/ def liftMonoidWithZeroHom (φ : R[X] →*₀ G₀) (hφ : R[X]⁰ ≤ G₀⁰.comap φ) : RatFunc R →*₀ G₀ where toFun f := RatFunc.liftOn f (fun p q => φ p / φ q) fun {p q p' q'} hq hq' h => by cases subsingleton_or_nontrivial R · rw [Subsingleton.elim p q, Subsingleton.elim p' q, Subsingleton.elim q' q] rw [div_eq_div_iff, ← map_mul, mul_comm p, h, map_mul, mul_comm] <;> exact nonZeroDivisors.ne_zero (hφ ‹_›) map_one' := by simp_rw [← ofFractionRing_one, ← Localization.mk_one, liftOn_ofFractionRing_mk, OneMemClass.coe_one, map_one, div_one] map_mul' x y := by obtain ⟨x⟩ := x obtain ⟨y⟩ := y cases x using Localization.induction_on cases y using Localization.induction_on rw [← ofFractionRing_mul, Localization.mk_mul] simp only [liftOn_ofFractionRing_mk, div_mul_div_comm, map_mul, Submonoid.coe_mul] map_zero' := by simp_rw [← ofFractionRing_zero, ← Localization.mk_zero (1 : R[X]⁰), liftOn_ofFractionRing_mk, map_zero, zero_div] theorem liftMonoidWithZeroHom_apply_ofFractionRing_mk (φ : R[X] →*₀ G₀) (hφ : R[X]⁰ ≤ G₀⁰.comap φ) (n : R[X]) (d : R[X]⁰) : liftMonoidWithZeroHom φ hφ (ofFractionRing (Localization.mk n d)) = φ n / φ d := liftOn_ofFractionRing_mk _ _ _ _ theorem liftMonoidWithZeroHom_injective [Nontrivial R] (φ : R[X] →*₀ G₀) (hφ : Function.Injective φ) (hφ' : R[X]⁰ ≤ G₀⁰.comap φ := nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _ hφ) : Function.Injective (liftMonoidWithZeroHom φ hφ') := by rintro ⟨x⟩ ⟨y⟩ cases x using Localization.induction_on cases y using Localization.induction_on with | _ a' simp_rw [liftMonoidWithZeroHom_apply_ofFractionRing_mk] intro h congr 1 refine Localization.mk_eq_mk_iff.mpr (Localization.r_of_eq (M := R[X]) ?_) have := mul_eq_mul_of_div_eq_div _ _ ?_ ?_ h · rwa [← map_mul, ← map_mul, hφ.eq_iff, mul_comm, mul_comm a'.fst] at this all_goals exact map_ne_zero_of_mem_nonZeroDivisors _ hφ (SetLike.coe_mem _) /-- Lift an injective ring homomorphism `R[X] →+* L` to a `RatFunc R →+* L` by mapping both the numerator and denominator and quotienting them. -/ def liftRingHom (φ : R[X] →+* L) (hφ : R[X]⁰ ≤ L⁰.comap φ) : RatFunc R →+* L := { liftMonoidWithZeroHom φ.toMonoidWithZeroHom hφ with map_add' := fun x y => by simp only [ZeroHom.toFun_eq_coe, MonoidWithZeroHom.toZeroHom_coe] cases subsingleton_or_nontrivial R · rw [Subsingleton.elim (x + y) y, Subsingleton.elim x 0, map_zero, zero_add] obtain ⟨x⟩ := x obtain ⟨y⟩ := y cases x using Localization.induction_on with | _ pq cases y using Localization.induction_on with | _ p'q' obtain ⟨p, q⟩ := pq obtain ⟨p', q'⟩ := p'q' rw [← ofFractionRing_add, Localization.add_mk] simp only [RingHom.toMonoidWithZeroHom_eq_coe, liftMonoidWithZeroHom_apply_ofFractionRing_mk] rw [div_add_div, div_eq_div_iff] · rw [mul_comm _ p, mul_comm _ p', mul_comm _ (φ p'), add_comm] simp only [map_add, map_mul, Submonoid.coe_mul] all_goals try simp only [← map_mul, ← Submonoid.coe_mul] exact nonZeroDivisors.ne_zero (hφ (SetLike.coe_mem _)) } theorem liftRingHom_apply_ofFractionRing_mk (φ : R[X] →+* L) (hφ : R[X]⁰ ≤ L⁰.comap φ) (n : R[X]) (d : R[X]⁰) : liftRingHom φ hφ (ofFractionRing (Localization.mk n d)) = φ n / φ d := liftMonoidWithZeroHom_apply_ofFractionRing_mk _ hφ _ _ theorem liftRingHom_injective [Nontrivial R] (φ : R[X] →+* L) (hφ : Function.Injective φ) (hφ' : R[X]⁰ ≤ L⁰.comap φ := nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _ hφ) : Function.Injective (liftRingHom φ hφ') := liftMonoidWithZeroHom_injective _ hφ end LiftHom variable (K) @[stacks 09FK] instance instField [IsDomain K] : Field (RatFunc K) where inv_zero := by frac_tac div_eq_mul_inv := by frac_tac mul_inv_cancel _ := mul_inv_cancel zpow := zpowRec nnqsmul := _ nnqsmul_def := fun _ _ => rfl qsmul := _ qsmul_def := fun _ _ => rfl section IsFractionRing /-! ### `RatFunc` as field of fractions of `Polynomial` -/ section IsDomain variable [IsDomain K] instance (R : Type*) [CommSemiring R] [Algebra R K[X]] : Algebra R (RatFunc K) where algebraMap := { toFun x := RatFunc.mk (algebraMap _ _ x) 1 map_add' x y := by simp only [mk_one', RingHom.map_add, ofFractionRing_add] map_mul' x y := by simp only [mk_one', RingHom.map_mul, ofFractionRing_mul] map_one' := by simp only [mk_one', RingHom.map_one, ofFractionRing_one] map_zero' := by simp only [mk_one', RingHom.map_zero, ofFractionRing_zero] } smul_def' c x := by induction x using RatFunc.induction_on' with | _ p q hq rw [RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, mk_one', ← mk_smul, mk_def_of_ne (c • p) hq, mk_def_of_ne p hq, ← ofFractionRing_mul, IsLocalization.mul_mk'_eq_mk'_of_mul, Algebra.smul_def] commutes' _ _ := mul_comm _ _ variable {K} /-- The coercion from polynomials to rational functions, implemented as the algebra map from a domain to its field of fractions -/ @[coe] def coePolynomial (P : Polynomial K) : RatFunc K := algebraMap _ _ P instance : Coe (Polynomial K) (RatFunc K) := ⟨coePolynomial⟩ theorem mk_one (x : K[X]) : RatFunc.mk x 1 = algebraMap _ _ x := rfl theorem ofFractionRing_algebraMap (x : K[X]) : ofFractionRing (algebraMap _ (FractionRing K[X]) x) = algebraMap _ _ x := by rw [← mk_one, mk_one'] variable (K) in /-- The equivalence between `RatFunc K` and the field of fractions of `K[X]` -/ @[simps! apply] def toFractionRingAlgEquiv (R : Type*) [CommSemiring R] [Algebra R K[X]] : RatFunc K ≃ₐ[R] FractionRing K[X] where __ := RatFunc.toFractionRingRingEquiv K commutes' r := by change (RatFunc.mk (algebraMap R K[X] r) 1).toFractionRing = _ rw [mk_one']; rfl @[simp] theorem mk_eq_div (p q : K[X]) : RatFunc.mk p q = algebraMap _ _ p / algebraMap _ _ q := by simp only [mk_eq_div', ofFractionRing_div, ofFractionRing_algebraMap] @[simp] theorem div_smul {R} [Monoid R] [DistribMulAction R K[X]] [IsScalarTower R K[X] K[X]] (c : R) (p q : K[X]) : algebraMap _ (RatFunc K) (c • p) / algebraMap _ _ q = c • (algebraMap _ _ p / algebraMap _ _ q) := by rw [← mk_eq_div, mk_smul, mk_eq_div] theorem algebraMap_apply {R : Type*} [CommSemiring R] [Algebra R K[X]] (x : R) : algebraMap R (RatFunc K) x = algebraMap _ _ (algebraMap R K[X] x) / algebraMap K[X] _ 1 := by rw [← mk_eq_div] rfl theorem map_apply_div_ne_zero {R F : Type*} [CommRing R] [IsDomain R] [FunLike F K[X] R[X]] [MonoidHomClass F K[X] R[X]] (φ : F) (hφ : K[X]⁰ ≤ R[X]⁰.comap φ) (p q : K[X]) (hq : q ≠ 0) : map φ hφ (algebraMap _ _ p / algebraMap _ _ q) = algebraMap _ _ (φ p) / algebraMap _ _ (φ q) := by have hq' : φ q ≠ 0 := nonZeroDivisors.ne_zero (hφ (mem_nonZeroDivisors_iff_ne_zero.mpr hq)) simp only [← mk_eq_div, mk_eq_localization_mk _ hq, map_apply_ofFractionRing_mk, mk_eq_localization_mk _ hq'] @[simp] theorem map_apply_div {R F : Type*} [CommRing R] [IsDomain R] [FunLike F K[X] R[X]] [MonoidWithZeroHomClass F K[X] R[X]] (φ : F) (hφ : K[X]⁰ ≤ R[X]⁰.comap φ) (p q : K[X]) : map φ hφ (algebraMap _ _ p / algebraMap _ _ q) = algebraMap _ _ (φ p) / algebraMap _ _ (φ q) := by rcases eq_or_ne q 0 with (rfl | hq) · have : (0 : RatFunc K) = algebraMap K[X] _ 0 / algebraMap K[X] _ 1 := by simp rw [map_zero, map_zero, map_zero, div_zero, div_zero, this, map_apply_div_ne_zero, map_one, map_one, div_one, map_zero, map_zero] exact one_ne_zero exact map_apply_div_ne_zero _ _ _ _ hq theorem liftMonoidWithZeroHom_apply_div {L : Type*} [CommGroupWithZero L] (φ : MonoidWithZeroHom K[X] L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (p q : K[X]) : liftMonoidWithZeroHom φ hφ (algebraMap _ _ p / algebraMap _ _ q) = φ p / φ q := by rcases eq_or_ne q 0 with (rfl | hq) · simp only [div_zero, map_zero] simp only [← mk_eq_div, mk_eq_localization_mk _ hq, liftMonoidWithZeroHom_apply_ofFractionRing_mk] @[simp] theorem liftMonoidWithZeroHom_apply_div' {L : Type*} [CommGroupWithZero L] (φ : MonoidWithZeroHom K[X] L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (p q : K[X]) : liftMonoidWithZeroHom φ hφ (algebraMap _ _ p) / liftMonoidWithZeroHom φ hφ (algebraMap _ _ q) = φ p / φ q := by rw [← map_div₀, liftMonoidWithZeroHom_apply_div] theorem liftRingHom_apply_div {L : Type*} [Field L] (φ : K[X] →+* L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (p q : K[X]) : liftRingHom φ hφ (algebraMap _ _ p / algebraMap _ _ q) = φ p / φ q := liftMonoidWithZeroHom_apply_div _ hφ _ _ @[simp] theorem liftRingHom_apply_div' {L : Type*} [Field L] (φ : K[X] →+* L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (p q : K[X]) : liftRingHom φ hφ (algebraMap _ _ p) / liftRingHom φ hφ (algebraMap _ _ q) = φ p / φ q := liftMonoidWithZeroHom_apply_div' _ hφ _ _ variable (K) theorem ofFractionRing_comp_algebraMap : ofFractionRing ∘ algebraMap K[X] (FractionRing K[X]) = algebraMap _ _ := funext ofFractionRing_algebraMap theorem algebraMap_injective : Function.Injective (algebraMap K[X] (RatFunc K)) := by rw [← ofFractionRing_comp_algebraMap] exact ofFractionRing_injective.comp (IsFractionRing.injective _ _) variable {K} section LiftAlgHom variable {L R S : Type*} [Field L] [CommRing R] [IsDomain R] [CommSemiring S] [Algebra S K[X]] [Algebra S L] [Algebra S R[X]] (φ : K[X] →ₐ[S] L) (hφ : K[X]⁰ ≤ L⁰.comap φ) /-- Lift an algebra homomorphism that maps polynomials `φ : K[X] →ₐ[S] R[X]` to a `RatFunc K →ₐ[S] RatFunc R`, on the condition that `φ` maps non-zero-divisors to non-zero-divisors, by mapping both the numerator and denominator and quotienting them. -/ def mapAlgHom (φ : K[X] →ₐ[S] R[X]) (hφ : K[X]⁰ ≤ R[X]⁰.comap φ) : RatFunc K →ₐ[S] RatFunc R := { mapRingHom φ hφ with commutes' := fun r => by simp_rw [RingHom.toFun_eq_coe, coe_mapRingHom_eq_coe_map, algebraMap_apply r, map_apply_div, map_one, AlgHom.commutes] } theorem coe_mapAlgHom_eq_coe_map (φ : K[X] →ₐ[S] R[X]) (hφ : K[X]⁰ ≤ R[X]⁰.comap φ) : (mapAlgHom φ hφ : RatFunc K → RatFunc R) = map φ hφ := rfl /-- Lift an injective algebra homomorphism `K[X] →ₐ[S] L` to a `RatFunc K →ₐ[S] L` by mapping both the numerator and denominator and quotienting them. -/ def liftAlgHom : RatFunc K →ₐ[S] L := { liftRingHom φ.toRingHom hφ with commutes' := fun r => by simp_rw [RingHom.toFun_eq_coe, AlgHom.toRingHom_eq_coe, algebraMap_apply r, liftRingHom_apply_div, AlgHom.coe_toRingHom, map_one, div_one, AlgHom.commutes] } theorem liftAlgHom_apply_ofFractionRing_mk (n : K[X]) (d : K[X]⁰) : liftAlgHom φ hφ (ofFractionRing (Localization.mk n d)) = φ n / φ d := liftMonoidWithZeroHom_apply_ofFractionRing_mk _ hφ _ _ theorem liftAlgHom_injective (φ : K[X] →ₐ[S] L) (hφ : Function.Injective φ) (hφ' : K[X]⁰ ≤ L⁰.comap φ := nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _ hφ) : Function.Injective (liftAlgHom φ hφ') := liftMonoidWithZeroHom_injective _ hφ @[simp] theorem liftAlgHom_apply_div' (p q : K[X]) : liftAlgHom φ hφ (algebraMap _ _ p) / liftAlgHom φ hφ (algebraMap _ _ q) = φ p / φ q := liftMonoidWithZeroHom_apply_div' _ hφ _ _ theorem liftAlgHom_apply_div (p q : K[X]) : liftAlgHom φ hφ (algebraMap _ _ p / algebraMap _ _ q) = φ p / φ q := liftMonoidWithZeroHom_apply_div _ hφ _ _ end LiftAlgHom variable (K) /-- `RatFunc K` is the field of fractions of the polynomials over `K`. -/ instance : IsFractionRing K[X] (RatFunc K) where map_units y := by rw [← ofFractionRing_algebraMap] exact (toFractionRingRingEquiv K).symm.toRingHom.isUnit_map (IsLocalization.map_units _ y) exists_of_eq {x y} := by rw [← ofFractionRing_algebraMap, ← ofFractionRing_algebraMap] exact fun h ↦ IsLocalization.exists_of_eq ((toFractionRingRingEquiv K).symm.injective h) surj := by rintro ⟨z⟩ convert IsLocalization.surj K[X]⁰ z simp only [← ofFractionRing_algebraMap, ← ofFractionRing_mul, ofFractionRing.injEq] variable {K} theorem algebraMap_ne_zero {x : K[X]} (hx : x ≠ 0) : algebraMap K[X] (RatFunc K) x ≠ 0 := by simpa @[simp] theorem liftOn_div {P : Sort v} (p q : K[X]) (f : K[X] → K[X] → P) (f0 : ∀ p, f p 0 = f 0 1) (H' : ∀ {p q p' q'} (_hq : q ≠ 0) (_hq' : q' ≠ 0), q' * p = q * p' → f p q = f p' q') (H : ∀ {p q p' q'} (_hq : q ∈ K[X]⁰) (_hq' : q' ∈ K[X]⁰), q' * p = q * p' → f p q = f p' q' := fun {_ _ _ _} hq hq' h => H' (nonZeroDivisors.ne_zero hq) (nonZeroDivisors.ne_zero hq') h) : (RatFunc.liftOn (algebraMap _ (RatFunc K) p / algebraMap _ _ q)) f @H = f p q := by rw [← mk_eq_div, liftOn_mk _ _ f f0 @H'] @[simp] theorem liftOn'_div {P : Sort v} (p q : K[X]) (f : K[X] → K[X] → P) (f0 : ∀ p, f p 0 = f 0 1) (H) : (RatFunc.liftOn' (algebraMap _ (RatFunc K) p / algebraMap _ _ q)) f @H = f p q := by rw [RatFunc.liftOn', liftOn_div _ _ _ f0] apply liftOn_condition_of_liftOn'_condition H /-- Induction principle for `RatFunc K`: if `f p q : P (p / q)` for all `p q : K[X]`, then `P` holds on all elements of `RatFunc K`. See also `induction_on'`, which is a recursion principle defined in terms of `RatFunc.mk`. -/ protected theorem induction_on {P : RatFunc K → Prop} (x : RatFunc K) (f : ∀ (p q : K[X]) (_ : q ≠ 0), P (algebraMap _ (RatFunc K) p / algebraMap _ _ q)) : P x := x.induction_on' fun p q hq => by simpa using f p q hq theorem ofFractionRing_mk' (x : K[X]) (y : K[X]⁰) : ofFractionRing (IsLocalization.mk' _ x y) = IsLocalization.mk' (RatFunc K) x y := by rw [IsFractionRing.mk'_eq_div, IsFractionRing.mk'_eq_div, ← mk_eq_div', ← mk_eq_div] theorem mk_eq_mk' (f : Polynomial K) {g : Polynomial K} (hg : g ≠ 0) : RatFunc.mk f g = IsLocalization.mk' (RatFunc K) f ⟨g, mem_nonZeroDivisors_iff_ne_zero.2 hg⟩ := by simp only [mk_eq_div, IsFractionRing.mk'_eq_div] @[simp] theorem ofFractionRing_eq : (ofFractionRing : FractionRing K[X] → RatFunc K) = IsLocalization.algEquiv K[X]⁰ _ _ := funext fun x => Localization.induction_on x fun x => by simp only [Localization.mk_eq_mk'_apply, ofFractionRing_mk', IsLocalization.algEquiv_apply, IsLocalization.map_mk', RingHom.id_apply] @[simp] theorem toFractionRing_eq : (toFractionRing : RatFunc K → FractionRing K[X]) = IsLocalization.algEquiv K[X]⁰ _ _ := funext fun ⟨x⟩ => Localization.induction_on x fun x => by simp only [Localization.mk_eq_mk'_apply, ofFractionRing_mk', IsLocalization.algEquiv_apply, IsLocalization.map_mk', RingHom.id_apply] @[simp] theorem toFractionRingRingEquiv_symm_eq : (toFractionRingRingEquiv K).symm = (IsLocalization.algEquiv K[X]⁰ _ _).toRingEquiv := by ext x simp [toFractionRingRingEquiv, ofFractionRing_eq] section lift /- As `RatFunc R` is a one-field-struct, we need to specialize the following instances of `FractionRing`. -/ variable (R L : Type*) [CommRing R] [Field L] [IsDomain R] [Algebra R[X] L] [FaithfulSMul R[X] L] /-- `FractionRing.liftAlgebra` specialized to `RatFunc R`. This is a scoped instance because it creates a diamond when `L = RatFunc R`. -/ scoped instance liftAlgebra : Algebra (RatFunc R) L := RingHom.toAlgebra (IsFractionRing.lift (FaithfulSMul.algebraMap_injective R[X] _)) /-- `FractionRing.isScalarTower_liftAlgebra` specialized to `RatFunc R`. -/ instance isScalarTower_liftAlgebra : IsScalarTower R[X] (RatFunc R) L := IsScalarTower.of_algebraMap_eq fun x => (IsFractionRing.lift_algebraMap (FaithfulSMul.algebraMap_injective R[X] L) x).symm attribute [local instance] Polynomial.algebra /-- `FractionRing.instFaithfulSMul` specialized to `RatFunc R`. -/ instance faithfulSMul (K E : Type*) [Field K] [Field E] [Algebra K E] [FaithfulSMul K E] : FaithfulSMul K[X] (RatFunc E) := (faithfulSMul_iff_algebraMap_injective ..).mpr <| (IsFractionRing.injective E[X] _).comp (Polynomial.map_injective _ <| FaithfulSMul.algebraMap_injective K E) section rank attribute [local instance] Polynomial.algebra variable (k K : Type*) [Field k] [Field K] [Algebra k K] [Algebra.IsAlgebraic k K] theorem rank_ratFunc_ratFunc : Module.rank (RatFunc k) (RatFunc K) = Module.rank k K := by rw [Algebra.IsAlgebraic.rank_of_isFractionRing k[X] (RatFunc k) K[X] (RatFunc K), rank_polynomial_polynomial] theorem finrank_ratFunc_ratFunc : Module.finrank (RatFunc k) (RatFunc K) = Module.finrank k K := by by_cases hf : Module.Finite (RatFunc k) (RatFunc K) · have hrank := rank_ratFunc_ratFunc k K rw [← Module.finrank_eq_rank] at hrank exact (Module.finrank_eq_of_rank_eq hrank.symm).symm · have hf' : ¬ Module.Finite k K := by rwa [← Module.rank_lt_aleph0_iff, ← rank_ratFunc_ratFunc, Module.rank_lt_aleph0_iff] rw [Module.finrank_of_not_finite hf, Module.finrank_of_not_finite hf'] end rank end lift section IsScalarTower /-- Let `RatFunc A / A[X] / R / R₀` be a tower. If `A[X] / R / R₀` is a scalar tower then so is `RatFunc A / R / R₀`. -/ instance (R₀ R A : Type*) [CommSemiring R₀] [CommSemiring R] [CommRing A] [IsDomain A] [Algebra R₀ A[X]] [SMul R₀ R] [Algebra R A[X]] [IsScalarTower R₀ R A[X]] : IsScalarTower R₀ R (RatFunc A) := IsScalarTower.to₁₂₄ _ _ A[X] _ /-- Let `K / RatFunc A / A[X] / R` be a tower. If `K / A[X] / R` is a scalar tower then so is `K / RatFunc A / R`. -/ instance (R A K : Type*) [CommRing A] [IsDomain A] [Field K] [Algebra A[X] K] [FaithfulSMul A[X] K] [CommSemiring R] [Algebra R A[X]] [SMul R K] [IsScalarTower R A[X] K] : IsScalarTower R (RatFunc A) K := IsScalarTower.to₁₃₄ _ A[X] _ _ /-- Let `K / k / RatFunc A / A[X]` be a tower. If `K / k / A[X]` is a scalar tower then so is `K / k / RatFunc A`. -/ instance (A k K : Type*) [CommRing A] [IsDomain A] [Field k] [Field K] [Algebra A[X] k] [Algebra A[X] K] [SMul k K] [FaithfulSMul A[X] k] [FaithfulSMul A[X] K] [IsScalarTower A[X] k K] : IsScalarTower (RatFunc A) k K where smul_assoc a b c := by induction a using RatFunc.induction_on with | f p q hq => rw [← smul_right_inj hq] simp_rw [← smul_assoc, Algebra.smul_def q] field_simp [hq] simp end IsScalarTower end IsDomain end IsFractionRing end CommRing section NumDenom /-! ### Numerator and denominator -/ open GCDMonoid Polynomial variable [Field K] open scoped Classical in /-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field, normalized such that the denominator is monic. -/ def numDenom (x : RatFunc K) : K[X] × K[X] := x.liftOn' (fun p q => if q = 0 then ⟨0, 1⟩ else let r := gcd p q ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r), Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩) (by intro p q a hq ha dsimp rw [if_neg hq, if_neg (mul_ne_zero ha hq)] have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha' simp only [Prod.ext_iff, gcd_mul_left, normalize_apply a, Polynomial.coe_normUnit, mul_assoc, CommGroupWithZero.coe_normUnit _ ha'] have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add] exact hdeg have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p := (C_mul_dvd hainv).mpr (gcd_dvd_left p q) have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q := (C_mul_dvd hainv).mpr (gcd_dvd_right p q) rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq, leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul, Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ← mul_assoc, ← Polynomial.C_mul] constructor <;> congr <;> rw [inv_div, mul_comm, mul_div_assoc, ← mul_assoc, inv_inv, mul_inv_cancel₀ ha', one_mul, inv_div]) open scoped Classical in @[simp] theorem numDenom_div (p : K[X]) {q : K[X]} (hq : q ≠ 0) : numDenom (algebraMap _ _ p / algebraMap _ _ q) = (Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q), Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (q / gcd p q)) := by rw [numDenom, liftOn'_div, if_neg hq] intro p rw [if_pos rfl, if_neg (one_ne_zero' K[X])] simp /-- `RatFunc.num` is the numerator of a rational function, normalized such that the denominator is monic. -/ def num (x : RatFunc K) : K[X] := x.numDenom.1 open scoped Classical in private theorem num_div' (p : K[X]) {q : K[X]} (hq : q ≠ 0) : num (algebraMap _ _ p / algebraMap _ _ q) = Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) := by rw [num, numDenom_div _ hq] @[simp] theorem num_zero : num (0 : RatFunc K) = 0 := by convert num_div' (0 : K[X]) one_ne_zero <;> simp open scoped Classical in @[simp] theorem num_div (p q : K[X]) : num (algebraMap _ _ p / algebraMap _ _ q) = Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) := by by_cases hq : q = 0 · simp [hq] · exact num_div' p hq @[simp] theorem num_one : num (1 : RatFunc K) = 1 := by convert num_div (1 : K[X]) 1 <;> simp @[simp] theorem num_algebraMap (p : K[X]) : num (algebraMap _ _ p) = p := by convert num_div p 1 <;> simp theorem num_div_dvd (p : K[X]) {q : K[X]} (hq : q ≠ 0) : num (algebraMap _ _ p / algebraMap _ _ q) ∣ p := by classical rw [num_div _ q, C_mul_dvd] · exact EuclideanDomain.div_dvd_of_dvd (gcd_dvd_left p q) · simpa only [Ne, inv_eq_zero, Polynomial.leadingCoeff_eq_zero] using right_div_gcd_ne_zero hq open scoped Classical in /-- A version of `num_div_dvd` with the LHS in simp normal form -/ @[simp] theorem num_div_dvd' (p : K[X]) {q : K[X]} (hq : q ≠ 0) : C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) ∣ p := by simpa using num_div_dvd p hq /-- `RatFunc.denom` is the denominator of a rational function, normalized such that it is monic. -/ def denom (x : RatFunc K) : K[X] := x.numDenom.2 open scoped Classical in @[simp] theorem denom_div (p : K[X]) {q : K[X]} (hq : q ≠ 0) : denom (algebraMap _ _ p / algebraMap _ _ q) = Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (q / gcd p q) := by rw [denom, numDenom_div _ hq] theorem monic_denom (x : RatFunc K) : (denom x).Monic := by classical induction x using RatFunc.induction_on with | f p q hq => rw [denom_div p hq, mul_comm] exact Polynomial.monic_mul_leadingCoeff_inv (right_div_gcd_ne_zero hq) theorem denom_ne_zero (x : RatFunc K) : denom x ≠ 0 := (monic_denom x).ne_zero @[simp] theorem denom_zero : denom (0 : RatFunc K) = 1 := by convert denom_div (0 : K[X]) one_ne_zero <;> simp @[simp] theorem denom_one : denom (1 : RatFunc K) = 1 := by convert denom_div (1 : K[X]) one_ne_zero <;> simp @[simp] theorem denom_algebraMap (p : K[X]) : denom (algebraMap _ (RatFunc K) p) = 1 := by convert denom_div p one_ne_zero <;> simp @[simp] theorem denom_div_dvd (p q : K[X]) : denom (algebraMap _ _ p / algebraMap _ _ q) ∣ q := by classical by_cases hq : q = 0 · simp [hq] rw [denom_div _ hq, C_mul_dvd] · exact EuclideanDomain.div_dvd_of_dvd (gcd_dvd_right p q) · simpa only [Ne, inv_eq_zero, Polynomial.leadingCoeff_eq_zero] using right_div_gcd_ne_zero hq @[simp] theorem num_div_denom (x : RatFunc K) : algebraMap _ _ (num x) / algebraMap _ _ (denom x) = x := by classical induction x using RatFunc.induction_on with | _ p q hq have q_div_ne_zero : q / gcd p q ≠ 0 := right_div_gcd_ne_zero hq rw [num_div p q, denom_div p hq, RingHom.map_mul, RingHom.map_mul, mul_div_mul_left, div_eq_div_iff, ← RingHom.map_mul, ← RingHom.map_mul, mul_comm _ q, ← EuclideanDomain.mul_div_assoc, ← EuclideanDomain.mul_div_assoc, mul_comm] · apply gcd_dvd_right · apply gcd_dvd_left · exact algebraMap_ne_zero q_div_ne_zero · exact algebraMap_ne_zero hq · refine algebraMap_ne_zero (mt Polynomial.C_eq_zero.mp ?_) exact inv_ne_zero (Polynomial.leadingCoeff_ne_zero.mpr q_div_ne_zero) theorem isCoprime_num_denom (x : RatFunc K) : IsCoprime x.num x.denom := by classical induction x using RatFunc.induction_on with | _ p q hq rw [num_div, denom_div _ hq] exact (isCoprime_mul_unit_left ((leadingCoeff_ne_zero.2 <| right_div_gcd_ne_zero hq).isUnit.inv.map C) _ _).2 (isCoprime_div_gcd_div_gcd hq) @[simp] theorem num_eq_zero_iff {x : RatFunc K} : num x = 0 ↔ x = 0 := ⟨fun h => by rw [← num_div_denom x, h, RingHom.map_zero, zero_div], fun h => h.symm ▸ num_zero⟩ theorem num_ne_zero {x : RatFunc K} (hx : x ≠ 0) : num x ≠ 0 := mt num_eq_zero_iff.mp hx theorem num_mul_eq_mul_denom_iff {x : RatFunc K} {p q : K[X]} (hq : q ≠ 0) : x.num * q = p * x.denom ↔ x = algebraMap _ _ p / algebraMap _ _ q := by rw [← (algebraMap_injective K).eq_iff, eq_div_iff (algebraMap_ne_zero hq)] conv_rhs => rw [← num_div_denom x] rw [RingHom.map_mul, RingHom.map_mul, div_eq_mul_inv, mul_assoc, mul_comm (Inv.inv _), ← mul_assoc, ← div_eq_mul_inv, div_eq_iff] exact algebraMap_ne_zero (denom_ne_zero x) theorem num_denom_add (x y : RatFunc K) : (x + y).num * (x.denom * y.denom) = (x.num * y.denom + x.denom * y.num) * (x + y).denom := (num_mul_eq_mul_denom_iff (mul_ne_zero (denom_ne_zero x) (denom_ne_zero y))).mpr <| by conv_lhs => rw [← num_div_denom x, ← num_div_denom y] rw [div_add_div, RingHom.map_mul, RingHom.map_add, RingHom.map_mul, RingHom.map_mul] · exact algebraMap_ne_zero (denom_ne_zero x) · exact algebraMap_ne_zero (denom_ne_zero y) theorem num_denom_neg (x : RatFunc K) : (-x).num * x.denom = -x.num * (-x).denom := by rw [num_mul_eq_mul_denom_iff (denom_ne_zero x), map_neg, neg_div, num_div_denom] theorem num_denom_mul (x y : RatFunc K) : (x * y).num * (x.denom * y.denom) = x.num * y.num * (x * y).denom := (num_mul_eq_mul_denom_iff (mul_ne_zero (denom_ne_zero x) (denom_ne_zero y))).mpr <| by conv_lhs => rw [← num_div_denom x, ← num_div_denom y, div_mul_div_comm, ← RingHom.map_mul, ← RingHom.map_mul] theorem num_dvd {x : RatFunc K} {p : K[X]} (hp : p ≠ 0) : num x ∣ p ↔ ∃ q : K[X], q ≠ 0 ∧ x = algebraMap _ _ p / algebraMap _ _ q := by constructor · rintro ⟨q, rfl⟩ obtain ⟨_hx, hq⟩ := mul_ne_zero_iff.mp hp use denom x * q rw [RingHom.map_mul, RingHom.map_mul, ← div_mul_div_comm, div_self, mul_one, num_div_denom] · exact ⟨mul_ne_zero (denom_ne_zero x) hq, rfl⟩ · exact algebraMap_ne_zero hq · rintro ⟨q, hq, rfl⟩ exact num_div_dvd p hq theorem denom_dvd {x : RatFunc K} {q : K[X]} (hq : q ≠ 0) : denom x ∣ q ↔ ∃ p : K[X], x = algebraMap _ _ p / algebraMap _ _ q := by constructor · rintro ⟨p, rfl⟩ obtain ⟨_hx, hp⟩ := mul_ne_zero_iff.mp hq use num x * p rw [RingHom.map_mul, RingHom.map_mul, ← div_mul_div_comm, div_self, mul_one, num_div_denom] exact algebraMap_ne_zero hp · rintro ⟨p, rfl⟩ exact denom_div_dvd p q theorem num_mul_dvd (x y : RatFunc K) : num (x * y) ∣ num x * num y := by by_cases hx : x = 0 · simp [hx] by_cases hy : y = 0 · simp [hy] rw [num_dvd (mul_ne_zero (num_ne_zero hx) (num_ne_zero hy))] refine ⟨x.denom * y.denom, mul_ne_zero (denom_ne_zero x) (denom_ne_zero y), ?_⟩ rw [RingHom.map_mul, RingHom.map_mul, ← div_mul_div_comm, num_div_denom, num_div_denom] theorem denom_mul_dvd (x y : RatFunc K) : denom (x * y) ∣ denom x * denom y := by rw [denom_dvd (mul_ne_zero (denom_ne_zero x) (denom_ne_zero y))] refine ⟨x.num * y.num, ?_⟩ rw [RingHom.map_mul, RingHom.map_mul, ← div_mul_div_comm, num_div_denom, num_div_denom] theorem denom_add_dvd (x y : RatFunc K) : denom (x + y) ∣ denom x * denom y := by rw [denom_dvd (mul_ne_zero (denom_ne_zero x) (denom_ne_zero y))] refine ⟨x.num * y.denom + x.denom * y.num, ?_⟩ rw [RingHom.map_mul, RingHom.map_add, RingHom.map_mul, RingHom.map_mul, ← div_add_div, num_div_denom, num_div_denom] · exact algebraMap_ne_zero (denom_ne_zero x) · exact algebraMap_ne_zero (denom_ne_zero y) theorem map_denom_ne_zero {L F : Type*} [Zero L] [FunLike F K[X] L] [ZeroHomClass F K[X] L] (φ : F) (hφ : Function.Injective φ) (f : RatFunc K) : φ f.denom ≠ 0 := fun H => (denom_ne_zero f) ((map_eq_zero_iff φ hφ).mp H) theorem map_apply {R F : Type*} [CommRing R] [IsDomain R] [FunLike F K[X] R[X]] [MonoidHomClass F K[X] R[X]] (φ : F) (hφ : K[X]⁰ ≤ R[X]⁰.comap φ) (f : RatFunc K) : map φ hφ f = algebraMap _ _ (φ f.num) / algebraMap _ _ (φ f.denom) := by rw [← num_div_denom f, map_apply_div_ne_zero, num_div_denom f] exact denom_ne_zero _ theorem liftMonoidWithZeroHom_apply {L : Type*} [CommGroupWithZero L] (φ : K[X] →*₀ L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (f : RatFunc K) : liftMonoidWithZeroHom φ hφ f = φ f.num / φ f.denom := by rw [← num_div_denom f, liftMonoidWithZeroHom_apply_div, num_div_denom] theorem liftRingHom_apply {L : Type*} [Field L] (φ : K[X] →+* L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (f : RatFunc K) : liftRingHom φ hφ f = φ f.num / φ f.denom := liftMonoidWithZeroHom_apply _ hφ _ theorem liftAlgHom_apply {L S : Type*} [Field L] [CommSemiring S] [Algebra S K[X]] [Algebra S L] (φ : K[X] →ₐ[S] L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (f : RatFunc K) : liftAlgHom φ hφ f = φ f.num / φ f.denom := liftMonoidWithZeroHom_apply _ hφ _ theorem num_mul_denom_add_denom_mul_num_ne_zero {x y : RatFunc K} (hxy : x + y ≠ 0) : x.num * y.denom + x.denom * y.num ≠ 0 := by intro h_zero have h := num_denom_add x y rw [h_zero, zero_mul] at h exact (mul_ne_zero (num_ne_zero hxy) (mul_ne_zero x.denom_ne_zero y.denom_ne_zero)) h end NumDenom section Char instance [Field K] {p : ℕ} [CharP K p] : CharP (RatFunc K) p := charP_of_injective_algebraMap' K p instance [Field K] {p : ℕ} [ExpChar K p] : ExpChar (RatFunc K) p := ExpChar.of_injective_algebraMap' K p instance [Field K] [CharZero K] : CharZero (RatFunc K) := Algebra.charZero_of_charZero K _ end Char end RatFunc
.lake/packages/mathlib/Mathlib/FieldTheory/RatFunc/Defs.lean
import Mathlib.Algebra.Polynomial.Basic import Mathlib.Algebra.Ring.NonZeroDivisors import Mathlib.RingTheory.Localization.FractionRing /-! # The field of rational functions Files in this folder define the field `RatFunc K` of rational functions over a field `K`, show it is the field of fractions of `K[X]` and provide the main results concerning it. This file contains the basic definition. For connections with Laurent Series, see `Mathlib/RingTheory/LaurentSeries.lean`. ## Main definitions We provide a set of recursion and induction principles: - `RatFunc.liftOn`: define a function by mapping a fraction of polynomials `p/q` to `f p q`, if `f` is well-defined in the sense that `p/q = p'/q' → f p q = f p' q'`. - `RatFunc.liftOn'`: define a function by mapping a fraction of polynomials `p/q` to `f p q`, if `f` is well-defined in the sense that `f (a * p) (a * q) = f p' q'`. - `RatFunc.induction_on`: if `P` holds on `p / q` for all polynomials `p q`, then `P` holds on all rational functions ## Implementation notes To provide good API encapsulation and speed up unification problems, `RatFunc` is defined as a structure, and all operations are `@[irreducible] def`s We need a couple of maps to set up the `Field` and `IsFractionRing` structure, namely `RatFunc.ofFractionRing`, `RatFunc.toFractionRing`, `RatFunc.mk` and `RatFunc.toFractionRingRingEquiv`. All these maps get `simp`ed to bundled morphisms like `algebraMap K[X] (RatFunc K)` and `IsLocalization.algEquiv`. There are separate lifts and maps of homomorphisms, to provide routes of lifting even when the codomain is not a field or even an integral domain. ## References * [Kleiman, *Misconceptions about $K_X$*][kleiman1979] * https://freedommathdance.blogspot.com/2012/11/misconceptions-about-kx.html * https://stacks.math.columbia.edu/tag/01X1 -/ noncomputable section open scoped nonZeroDivisors Polynomial universe u v variable (K : Type u) /-- `RatFunc K` is `K(X)`, the field of rational functions over `K`. The inclusion of polynomials into `RatFunc` is `algebraMap K[X] (RatFunc K)`, the maps between `RatFunc K` and another field of fractions of `K[X]`, especially `FractionRing K[X]`, are given by `IsLocalization.algEquiv`. -/ structure RatFunc [CommRing K] : Type u where ofFractionRing :: /-- the coercion to the fraction ring of the polynomial ring -/ toFractionRing : FractionRing K[X] namespace RatFunc section CommRing variable {K} variable [CommRing K] section Rec /-! ### Constructing `RatFunc`s and their induction principles -/ theorem ofFractionRing_injective : Function.Injective (ofFractionRing : _ → RatFunc K) := fun _ _ => ofFractionRing.inj theorem toFractionRing_injective : Function.Injective (toFractionRing : _ → FractionRing K[X]) | ⟨x⟩, ⟨y⟩, xy => by subst xy; rfl @[simp] lemma toFractionRing_inj {x y : RatFunc K} : toFractionRing x = toFractionRing y ↔ x = y := toFractionRing_injective.eq_iff /-- Non-dependent recursion principle for `RatFunc K`: To construct a term of `P : Sort*` out of `x : RatFunc K`, it suffices to provide a constructor `f : Π (p q : K[X]), P` and a proof that `f p q = f p' q'` for all `p q p' q'` such that `q' * p = q * p'` where both `q` and `q'` are not zero divisors, stated as `q ∉ K[X]⁰`, `q' ∉ K[X]⁰`. If considering `K` as an integral domain, this is the same as saying that we construct a value of `P` for such elements of `RatFunc K` by setting `liftOn (p / q) f _ = f p q`. When `[IsDomain K]`, one can use `RatFunc.liftOn'`, which has the stronger requirement of `∀ {p q a : K[X]} (hq : q ≠ 0) (ha : a ≠ 0), f (a * p) (a * q) = f p q)`. -/ protected irreducible_def liftOn {P : Sort v} (x : RatFunc K) (f : K[X] → K[X] → P) (H : ∀ {p q p' q'} (_hq : q ∈ K[X]⁰) (_hq' : q' ∈ K[X]⁰), q' * p = q * p' → f p q = f p' q') : P := Localization.liftOn (toFractionRing x) (fun p q => f p q) fun {_ _ q q'} h => H q.2 q'.2 (let ⟨⟨_, _⟩, mul_eq⟩ := Localization.r_iff_exists.mp h mul_cancel_left_coe_nonZeroDivisors.mp mul_eq) theorem liftOn_ofFractionRing_mk {P : Sort v} (n : K[X]) (d : K[X]⁰) (f : K[X] → K[X] → P) (H : ∀ {p q p' q'} (_hq : q ∈ K[X]⁰) (_hq' : q' ∈ K[X]⁰), q' * p = q * p' → f p q = f p' q') : RatFunc.liftOn (ofFractionRing (Localization.mk n d)) f @H = f n d := by rw [RatFunc.liftOn] exact Localization.liftOn_mk _ _ _ _ theorem liftOn_condition_of_liftOn'_condition {P : Sort v} {f : K[X] → K[X] → P} (H : ∀ {p q a} (_ : q ≠ 0) (_ha : a ≠ 0), f (a * p) (a * q) = f p q) ⦃p q p' q' : K[X]⦄ (hq : q ≠ 0) (hq' : q' ≠ 0) (h : q' * p = q * p') : f p q = f p' q' := calc f p q = f (q' * p) (q' * q) := (H hq hq').symm _ = f (q * p') (q * q') := by rw [h, mul_comm q'] _ = f p' q' := H hq' hq section IsDomain variable [IsDomain K] /-- `RatFunc.mk (p q : K[X])` is `p / q` as a rational function. If `q = 0`, then `mk` returns 0. This is an auxiliary definition used to define an `Algebra` structure on `RatFunc`; the `simp` normal form of `mk p q` is `algebraMap _ _ p / algebraMap _ _ q`. -/ protected irreducible_def mk (p q : K[X]) : RatFunc K := ofFractionRing (algebraMap _ _ p / algebraMap _ _ q) theorem mk_eq_div' (p q : K[X]) : RatFunc.mk p q = ofFractionRing (algebraMap _ _ p / algebraMap _ _ q) := by rw [RatFunc.mk] theorem mk_zero (p : K[X]) : RatFunc.mk p 0 = ofFractionRing (0 : FractionRing K[X]) := by rw [mk_eq_div', RingHom.map_zero, div_zero] theorem mk_coe_def (p : K[X]) (q : K[X]⁰) : RatFunc.mk p q = ofFractionRing (IsLocalization.mk' _ p q) := by simp only [mk_eq_div', ← Localization.mk_eq_mk', FractionRing.mk_eq_div] theorem mk_def_of_mem (p : K[X]) {q} (hq : q ∈ K[X]⁰) : RatFunc.mk p q = ofFractionRing (IsLocalization.mk' (FractionRing K[X]) p ⟨q, hq⟩) := by simp only [← mk_coe_def] theorem mk_def_of_ne (p : K[X]) {q : K[X]} (hq : q ≠ 0) : RatFunc.mk p q = ofFractionRing (IsLocalization.mk' (FractionRing K[X]) p ⟨q, mem_nonZeroDivisors_iff_ne_zero.mpr hq⟩) := mk_def_of_mem p _ theorem mk_eq_localization_mk (p : K[X]) {q : K[X]} (hq : q ≠ 0) : RatFunc.mk p q = ofFractionRing (Localization.mk p ⟨q, mem_nonZeroDivisors_iff_ne_zero.mpr hq⟩) := by rw [mk_def_of_ne _ hq, Localization.mk_eq_mk'] theorem mk_one' (p : K[X]) : RatFunc.mk p 1 = ofFractionRing (algebraMap _ _ p) := by rw [← IsLocalization.mk'_one (M := K[X]⁰) (FractionRing K[X]) p, ← mk_coe_def, Submonoid.coe_one] theorem mk_eq_mk {p q p' q' : K[X]} (hq : q ≠ 0) (hq' : q' ≠ 0) : RatFunc.mk p q = RatFunc.mk p' q' ↔ p * q' = p' * q := by rw [mk_def_of_ne _ hq, mk_def_of_ne _ hq', ofFractionRing_injective.eq_iff, IsLocalization.mk'_eq_iff_eq', (IsFractionRing.injective K[X] (FractionRing K[X])).eq_iff] theorem liftOn_mk {P : Sort v} (p q : K[X]) (f : K[X] → K[X] → P) (f0 : ∀ p, f p 0 = f 0 1) (H' : ∀ {p q p' q'} (_hq : q ≠ 0) (_hq' : q' ≠ 0), q' * p = q * p' → f p q = f p' q') (H : ∀ {p q p' q'} (_hq : q ∈ K[X]⁰) (_hq' : q' ∈ K[X]⁰), q' * p = q * p' → f p q = f p' q' := fun {_ _ _ _} hq hq' h => H' (nonZeroDivisors.ne_zero hq) (nonZeroDivisors.ne_zero hq') h) : (RatFunc.mk p q).liftOn f @H = f p q := by by_cases hq : q = 0 · subst hq simp only [mk_zero, f0, ← Localization.mk_zero 1, liftOn_ofFractionRing_mk, Submonoid.coe_one] · simp only [mk_eq_localization_mk _ hq, liftOn_ofFractionRing_mk] /-- Non-dependent recursion principle for `RatFunc K`: if `f p q : P` for all `p q`, such that `f (a * p) (a * q) = f p q`, then we can find a value of `P` for all elements of `RatFunc K` by setting `lift_on' (p / q) f _ = f p q`. The value of `f p 0` for any `p` is never used and in principle this may be anything, although many usages of `lift_on'` assume `f p 0 = f 0 1`. -/ protected irreducible_def liftOn' {P : Sort v} (x : RatFunc K) (f : K[X] → K[X] → P) (H : ∀ {p q a} (_hq : q ≠ 0) (_ha : a ≠ 0), f (a * p) (a * q) = f p q) : P := x.liftOn f fun {_p _q _p' _q'} hq hq' => liftOn_condition_of_liftOn'_condition (@H) (nonZeroDivisors.ne_zero hq) (nonZeroDivisors.ne_zero hq') theorem liftOn'_mk {P : Sort v} (p q : K[X]) (f : K[X] → K[X] → P) (f0 : ∀ p, f p 0 = f 0 1) (H : ∀ {p q a} (_hq : q ≠ 0) (_ha : a ≠ 0), f (a * p) (a * q) = f p q) : (RatFunc.mk p q).liftOn' f @H = f p q := by rw [RatFunc.liftOn', RatFunc.liftOn_mk _ _ _ f0] apply liftOn_condition_of_liftOn'_condition H /-- Induction principle for `RatFunc K`: if `f p q : P (RatFunc.mk p q)` for all `p q`, then `P` holds on all elements of `RatFunc K`. See also `induction_on`, which is a recursion principle defined in terms of `algebraMap`. -/ @[elab_as_elim] protected theorem induction_on' {P : RatFunc K → Prop} : ∀ (x : RatFunc K) (_pq : ∀ (p q : K[X]) (_ : q ≠ 0), P (RatFunc.mk p q)), P x | ⟨x⟩, f => Localization.induction_on x fun ⟨p, q⟩ => by simpa only [mk_coe_def, Localization.mk_eq_mk'] using f p q (mem_nonZeroDivisors_iff_ne_zero.mp q.2) end IsDomain end Rec end CommRing end RatFunc
.lake/packages/mathlib/Mathlib/FieldTheory/RatFunc/Degree.lean
import Mathlib.FieldTheory.RatFunc.AsPolynomial import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content /-! # The degree of rational functions ## Main definitions We define the degree of a rational function, with values in `ℤ`: - `intDegree` is the degree of a rational function, defined as the difference between the `natDegree` of its numerator and the `natDegree` of its denominator. In particular, `intDegree 0 = 0`. -/ noncomputable section universe u variable {K : Type u} namespace RatFunc section IntDegree open Polynomial variable [Field K] /-- `intDegree x` is the degree of the rational function `x`, defined as the difference between the `natDegree` of its numerator and the `natDegree` of its denominator. In particular, `intDegree 0 = 0`. -/ def intDegree (x : RatFunc K) : ℤ := natDegree x.num - natDegree x.denom @[simp] theorem intDegree_zero : intDegree (0 : RatFunc K) = 0 := by rw [intDegree, num_zero, natDegree_zero, denom_zero, natDegree_one, sub_self] @[simp] theorem intDegree_one : intDegree (1 : RatFunc K) = 0 := by rw [intDegree, num_one, denom_one, sub_self] @[simp] theorem intDegree_C (k : K) : intDegree (C k) = 0 := by rw [intDegree, num_C, natDegree_C, denom_C, natDegree_one, sub_self] @[simp] theorem intDegree_X : intDegree (X : RatFunc K) = 1 := by rw [intDegree, num_X, Polynomial.natDegree_X, denom_X, Polynomial.natDegree_one, Int.ofNat_one, Int.ofNat_zero, sub_zero] @[simp] theorem intDegree_polynomial {p : K[X]} : intDegree (algebraMap K[X] (RatFunc K) p) = natDegree p := by rw [intDegree, RatFunc.num_algebraMap, RatFunc.denom_algebraMap, Polynomial.natDegree_one, Int.ofNat_zero, sub_zero] theorem intDegree_mul {x y : RatFunc K} (hx : x ≠ 0) (hy : y ≠ 0) : intDegree (x * y) = intDegree x + intDegree y := by simp only [intDegree, add_sub, sub_add, sub_sub_eq_add_sub, sub_sub, sub_eq_sub_iff_add_eq_add] norm_cast rw [← Polynomial.natDegree_mul x.denom_ne_zero y.denom_ne_zero, ← Polynomial.natDegree_mul (RatFunc.num_ne_zero (mul_ne_zero hx hy)) (mul_ne_zero x.denom_ne_zero y.denom_ne_zero), ← Polynomial.natDegree_mul (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy), ← Polynomial.natDegree_mul (mul_ne_zero (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy)) (x * y).denom_ne_zero, RatFunc.num_denom_mul] @[simp] theorem intDegree_inv (x : RatFunc K) : intDegree (x⁻¹) = - intDegree x := by by_cases hx : x = 0 <;> simp [hx, eq_neg_iff_add_eq_zero, ← intDegree_mul (inv_ne_zero hx) hx] @[simp] theorem intDegree_neg (x : RatFunc K) : intDegree (-x) = intDegree x := by by_cases hx : x = 0 · rw [hx, neg_zero] · rw [intDegree, intDegree, ← natDegree_neg x.num] exact natDegree_sub_eq_of_prod_eq (num_ne_zero (neg_ne_zero.mpr hx)) (denom_ne_zero (-x)) (neg_ne_zero.mpr (num_ne_zero hx)) (denom_ne_zero x) (num_denom_neg x) theorem intDegree_add {x y : RatFunc K} (hxy : x + y ≠ 0) : (x + y).intDegree = (x.num * y.denom + x.denom * y.num).natDegree - (x.denom * y.denom).natDegree := natDegree_sub_eq_of_prod_eq (num_ne_zero hxy) (x + y).denom_ne_zero (num_mul_denom_add_denom_mul_num_ne_zero hxy) (mul_ne_zero x.denom_ne_zero y.denom_ne_zero) (num_denom_add x y) theorem natDegree_num_mul_right_sub_natDegree_denom_mul_left_eq_intDegree {x : RatFunc K} (hx : x ≠ 0) {s : K[X]} (hs : s ≠ 0) : ((x.num * s).natDegree : ℤ) - (s * x.denom).natDegree = x.intDegree := by apply natDegree_sub_eq_of_prod_eq (mul_ne_zero (num_ne_zero hx) hs) (mul_ne_zero hs x.denom_ne_zero) (num_ne_zero hx) x.denom_ne_zero rw [mul_assoc] theorem intDegree_add_le {x y : RatFunc K} (hy : y ≠ 0) (hxy : x + y ≠ 0) : intDegree (x + y) ≤ max (intDegree x) (intDegree y) := by by_cases hx : x = 0 · simp [hx] rw [intDegree_add hxy, ← natDegree_num_mul_right_sub_natDegree_denom_mul_left_eq_intDegree hx y.denom_ne_zero, mul_comm y.denom, ← natDegree_num_mul_right_sub_natDegree_denom_mul_left_eq_intDegree hy x.denom_ne_zero, le_max_iff, sub_le_sub_iff_right, Int.ofNat_le, sub_le_sub_iff_right, Int.ofNat_le, ← le_max_iff, mul_comm y.num] exact natDegree_add_le _ _ end IntDegree end RatFunc