import Lib.CM.Sigma.Basic import Lib.ClassField.Places.Ideles /-! # Principal ideal powers, S-units and a class number bound For every ideal `I` of a ring of integers of a number field some power `I ^ n` with `n ≠ 0` is principal. For ideals of norm greater than 1 the generators can be chosen large at every complex embedding. ## Main definitions and results * `New.ThetaTori.exists_pow_eq_span_inv_lt`: for an ideal of norm greater than 1, some power is principal with a non-unit generator of arbitrarily large absolute value at every complex embedding. * `New.SUnit.dirichlet_unit_theorem`: for a finite set `S` of finite places of a number field `K`, the `S`-units are finitely generated of rank `#S + #(infinite places) - 1`. This follows from Mathlib's unit theorem and the finiteness of the class number, in the form `New.exists_valuation_eq_exp_mul`. Valuations are multiplicative, with values in `ℤᵐ⁰`, and a uniformiser has valuation `exp (-1)`. * `New.eq_zero_of_forall_norm_lt_one`: an algebraic integer of absolute value below `1` at every infinite place is `0`. Here `Φ v`, from an instance of `New.PlaceEmbedding`, is a chosen complex embedding that induces the infinite place `v`. * `New.classNumber_le`: a number field of degree `n` and discriminant `d` has class number at most `(2 ^ n * |d|) ^ (n + 1)`. Minkowski's bound is at most `2 ^ n * |d|` (`New.minkowski_bound_le_two_pow_mul_discr`), so each class has an integral ideal of norm `k ≤ 2 ^ n * |d|` as a member. Such an ideal is generated by `k` and one more element, and the proof counts the possible pairs. * `New.conj_mem_quadInt`: for a prime `d ≡ 7` mod `8`, the ring `New.quadInt d`, the image of the ring of integers of ℚ(√−d) in ℂ, is stable under complex conjugation. ## Relation to the literature Dirichlet's `S`-unit theorem is deduced from the unit theorem in Mathlib, and the class number bound is a crude explicit form of the finiteness of the class number, deduced from Minkowski's bound in Mathlib. -/ /-! ## Principal powers of ideals of a ring of integers -/ open NumberField in /-- For every ideal `I` of the ring of integers of a number field, some power `I ^ n` with `n ≠ 0` is principal. -/ lemma New.exists_ideal_pow_eq_span_singleton {F : Type*} [Field F] [NumberField F] (I : Ideal (𝓞 F)) : ∃ n ≠ (0 : ℕ), ∃ y : 𝓞 F, I ^ n = Ideal.span {y} := by rcases eq_or_ne I 0 with rfl | hI · exact ⟨1, one_ne_zero, 0, by simp⟩ -- the class of `I` has trivial `n`-th power, where `n` is the class number let J : nonZeroDivisors (Ideal (𝓞 F)) := ⟨I, mem_nonZeroDivisors_of_ne_zero hI⟩ have h_one : ClassGroup.mk0 (J ^ classNumber F) = 1 := by simp [classNumber] exact ⟨_, classNumber_ne_zero F, ((ClassGroup.mk0_eq_one_iff _).mp h_one).principal⟩ /-! ## Generators of ideal powers large at every complex embedding -/ open NumberField mixedEmbedding fundamentalCone Ideal Algebra in /-- If `I` is an ideal of norm greater than 1 in the ring of integers of a number field `K` and `r > 0`, some power of `I` is generated by a non-unit `a` with `‖σ a‖⁻¹ < r` for every complex embedding `σ` of `K`. -/ lemma New.ThetaTori.exists_pow_eq_span_inv_lt {K : Type*} [Field K] [NumberField K] {I : Ideal (𝓞 K)} {r : ℝ} (hI : 1 < absNorm I) (hr : 0 < r) : ∃ a : 𝓞 K, (∃ k : ℕ, I ^ k = span {a}) ∧ ¬IsUnit a ∧ ∀ σ : K →+* ℂ, ‖σ a‖⁻¹ < r := by classical -- The points of norm at most `1` in the fundamental cone are bounded by some `C`. Take a -- generator `a` of a power of `I` with norm above `(C / r) ^ [K : ℚ]`, move `a⁻¹` into the cone -- by a unit `u` and scale it by `C / r`: the result has norm at most `1`. obtain ⟨C, hC_pos, hC⟩ : ∃ C > (0 : ℝ), ∀ x ∈ normLeOne K, ∀ v : InfinitePlace K, normAtPlace v x < C := by simpa only [norm_eq_sup'_normAtPlace, Finset.sup'_lt_iff, Finset.mem_univ, true_imp_iff] using (isBounded_normLeOne K).exists_pos_norm_lt obtain ⟨m, hm⟩ := pow_unbounded_of_one_lt ⌈|C / r| ^ Module.finrank ℚ K⌉₊ hI obtain ⟨k, hk, a, ha⟩ := exists_ideal_pow_eq_span_singleton (I ^ m) have h_big : ⌈|C / r| ^ Module.finrank ℚ K⌉₊ < absNorm (span {a}) := by grw [hm, ← ha, map_pow, map_pow, ← Nat.le_self_pow hk] have ha_ne : a ≠ 0 := fun ha_zero ↦ by simp [ha_zero] at h_big obtain ⟨u, hu⟩ := exists_unit_smul_mem (x := mixedEmbedding K (a : K)⁻¹) (by simpa) have h_norm : mixedEmbedding.norm ((C / r) • u • mixedEmbedding K (a : K)⁻¹) ≤ 1 := calc _ = |C / r| ^ Module.finrank ℚ K / absNorm (span {a}) := by simp [div_eq_mul_inv, ← coe_norm_int a, Algebra.norm_inv, mixedEmbedding.norm_smul] _ ≤ 1 := div_le_one_of_le₀ (Nat.ceil_le.1 h_big.le) (by positivity) refine ⟨↑u⁻¹ * a, ⟨m * k, ?_⟩, fun h_unit ↦ h_big.not_ge ?_, fun σ ↦ ?_⟩ · rw [pow_mul, ha, span_singleton_mul_left_unit u⁻¹.isUnit] · -- a unit has norm `1`, while the ceiling is positive rw [span_singleton_eq_top.2 (IsUnit.mul_iff.mp h_unit).2, absNorm_top, Nat.one_le_ceil_iff] positivity · have h_lt : normAtPlace (.mk σ) ((C / r) • u • mixedEmbedding K (a : K)⁻¹) < C := hC _ ⟨smul_mem_of_mem hu (div_pos hC_pos hr).ne', h_norm⟩ _ -- this reads `C / r * ‖σ (u * a⁻¹)‖ < C`, and `u * a⁻¹` is the inverse of `u⁻¹ * a` simpa [normAtPlace_smul, hC_pos, hr, ha_ne, abs_of_pos, mul_comm, field] using h_lt /-! ## The ring of integers of an imaginary quadratic field in ℂ The ring `New.quadInt d` (the integers of K = ℚ(√−d), inside ℂ) contains ω = `New.quadGen d` = (1 + i√d)/2 and is stable under complex conjugation; ω + ω̄ = 1. For membership in `quadInt d`, d is assumed to be a prime ≡ 7 mod 8 (`New.PrimeSevenModEight`). -/ namespace New lemma conj_quadGen {d : ℕ} : starRingEnd ℂ (quadGen d) = 1 - quadGen d := by simp [quadGen, map_ofNat] ring variable {d : ℕ} [PrimeSevenModEight d] /-- For a prime d ≡ 7 mod 8, ω = (1 + i√d)/2 lies in the image of the ring of integers of ℚ(√−d) in ℂ: it is the image of the algebraic integer `New.QuadField.betaK d` of ℚ(√−d). -/ lemma CMLattice.quadGen_mem_quadInt : quadGen d ∈ quadInt d := ⟨QuadField.betaK d, rfl⟩ /-- For a prime d ≡ 7 mod 8 (`PrimeSevenModEight d`), the image `quadInt d` in ℂ of the ring of integers of ℚ(√−d) is stable under complex conjugation. -/ lemma conj_mem_quadInt {x : ℂ} (hx : x ∈ quadInt d) : starRingEnd ℂ x ∈ quadInt d := by obtain ⟨a, rfl⟩ := hx -- the embedding into ℂ takes `star` to complex conjugation exact ⟨star a, by aesop⟩ end New /-! ## Dirichlet's S-unit theorem -/ namespace New open NumberField IsDedekindDomain Module WithZero Algebra Units Subgroup variable {K : Type*} [Field K] [NumberField K] {S : Set (FinPlace K)} /-- Let `S` be a finite set of finite places of `K`. There is `n ≠ 0` such that for every family of integers `e v`, `v ∈ S`, some `S`-unit has valuation `exp (n * e v)` at each `v ∈ S`. -/ lemma exists_valuation_eq_exp_mul (hS : S.Finite) : ∃ n ≠ (0 : ℕ), ∀ e : S → ℤ, ∃ x : S.unit K, ∀ v : S, (v : FinPlace K).valuation K ((x : Kˣ) : K) = exp (n * e v) := by -- Take for `n` the class number. Extend `e` by zero and choose an idele `a` with these -- valuations; its `n`-th power has the valuations of an element of `K`, which is an `S`-unit. refine ⟨classNumber K, classNumber_ne_zero K, fun e ↦ ?_⟩ let e₀ : FinPlace K → ℤ := Subtype.val.extend e 0 have h_supp : e₀.support ⊆ S := Function.support_extend_zero_subset.trans (by simp) obtain ⟨a, ha⟩ := exists_idele_eq_uniformizer_zpow e₀ (hS.subset h_supp) obtain ⟨x, hx⟩ : ∃ x : Kˣ, ∀ w ∉ (∅ : Set (FinPlace K)), w.valuation K x.val = Valued.v ((a ^ classNumber K).val w) := exists_valuation_eq_of_mem_sup (pow_classNumber_mem_principal_sup a) have h_val (w : FinPlace K) : w.valuation K x.val = exp (classNumber K * e₀ w) := by simp [hx w (Set.notMem_empty w), ha, ← exp_nsmul, ← exp_zsmul] have hx_unit : x ∈ S.unit K := fun w hw ↦ by simp [h_val, e₀, Function.extend_apply', hw] exact ⟨⟨x, hx_unit⟩, by simp [h_val, e₀]⟩ /-- Dirichlet's `S`-unit theorem: for a finite set `S` of finite places (nonzero primes of `𝓞 K`), the group of `S`-units is finitely generated, and its rank plus one is `#S` plus the number of infinite places. -/ lemma SUnit.dirichlet_unit_theorem (hS : S.Finite) : Module.Finite ℤ (Additive (S.unit K)) ∧ finrank ℤ (Additive (S.unit K)) + 1 = S.ncard + Fintype.card (InfinitePlace K) := by -- The valuations at `S` map the `S`-units to `ℤ^S`. The kernel is the unit group of `𝓞 K`, and -- the image has full rank by the finiteness of the class number. have : Fintype S := hS.fintype -- `g` sends an `S`-unit to the logarithms of its valuations at the places in `S`. let g : Additive (S.unit K) →ₗ[ℤ] S → ℤ := AddMonoidHom.toIntLinearMap <| .mk' (fun x v ↦ log ((v : FinPlace K).valuation K ((x.toMul : Kˣ) : K))) fun x y ↦ by ext; simp [log_mul] -- The kernel is the group of `∅`-units, since an `S`-unit has valuation `1` outside `S`. have h_ker : ((∅ : Set (FinPlace K)).unit K).subgroupOf (S.unit K) = g.ker.toAddSubgroup.toSubgroup' := by ext x have h_outside : x.1 ∈ Set.unit ∅ K ↔ ∀ v ∈ S, v.valuation K x.1 = 1 := ⟨fun hx v _ ↦ hx v (Set.notMem_empty v), fun hx v _ ↦ (em (v ∈ S)).elim (hx v) (x.2 v)⟩ simpa [funext_iff, g, ← exp_inj (M := ℤ), mem_subgroupOf] using h_outside let kerEquivEmpty : g.ker.toAddSubgroup.toSubgroup' ≃* (∅ : Set (FinPlace K)).unit K := (MulEquiv.subgroupCongr h_ker.symm).trans (subgroupOfEquivOfLe fun x hx v _ ↦ hx v (Set.notMem_empty v)) -- The `∅`-integers are `𝓞 K`, so the `∅`-units and hence the kernel form the unit group of `𝓞 K`. let integerEquiv : (∅ : Set (FinPlace K)).integer K ≃ₐ[𝓞 K] 𝓞 K := (Subalgebra.equivOfEq _ _ (integer_empty (𝓞 K) K)).trans (botEquivOfInjective Subtype.val_injective) let unitEquiv : (∅ : Set (FinPlace K)).unit K ≃* (𝓞 K)ˣ := (Set.unitEquivUnitsInteger ∅ K).trans (mapEquiv integerEquiv.toMulEquiv) let e : g.ker ≃ₗ[ℤ] Additive (𝓞 K)ˣ := (kerEquivEmpty.trans unitEquiv).toAdditive.toIntLinearEquiv -- The group is an extension of a subgroup of `ℤ^S` by the finitely generated unit group. have h_finite : Module.Finite ℤ (Additive (S.unit K)) := (isNoetherian_of_range_eq_ker (g.ker.subtype ∘ₗ e.symm.toLinearMap) g (by simp)).finite have h_range : finrank ℤ g.range = finrank ℤ (S → ℤ) := by refine g.range.finrank_le.eq_of_not_lt fun h_lt ↦ ?_ -- Otherwise some `z` has no nonzero multiple in the image; but `c • z` is the image of an -- `S`-unit. obtain ⟨z, hz⟩ := g.range.exists_of_finrank_lt h_lt obtain ⟨c, hc, h_exists⟩ := exists_valuation_eq_exp_mul hS obtain ⟨x, hx⟩ := h_exists z have hx_image : g (.ofMul x) = (c : ℤ) • z := funext fun v ↦ by simp [g, hx v] exact hz c (mod_cast hc) ⟨.ofMul x, hx_image⟩ -- Rank–nullity and Dirichlet's unit theorem. have h_rank_nullity : finrank ℤ (Additive (S.unit K)) = finrank ℤ g.range + finrank ℤ g.ker := by rw [← g.ker.finrank_quotient_add_finrank, g.quotKerEquivRange.finrank_eq] have h_card : finrank ℤ (S → ℤ) = S.ncard := by simp refine ⟨h_finite, ?_⟩ rw [h_rank_nullity, h_range, h_card, e.finrank_eq, finrank_eq, rank, add_assoc, Nat.sub_add_cancel Fintype.card_pos] end New /-! ## Nonzero algebraic integers are large at some infinite place -/ open NumberField in /-- Let `x` be an algebraic integer in a number field `E`, each infinite place `v` of which comes with a chosen complex embedding `Φ v` inducing it (`PlaceEmbedding E`). If `‖Φ v x‖ < 1` for every infinite place `v`, then `x = 0`. -/ lemma New.eq_zero_of_forall_norm_lt_one {E : Type*} [Field E] [NumberField E] [PlaceEmbedding E] {x : E} (hx_int : IsIntegral ℤ x) (h_small : ∀ v : InfinitePlace E, ‖Φ v x‖ < 1) : x = 0 := by have h_embedding (σ : E →+* ℂ) : ‖σ x‖ < 1 := by rw [← InfinitePlace.apply σ x, ← PlaceEmbedding.mk_Φ (.mk σ), InfinitePlace.apply] exact h_small (.mk σ) have h_house : house x < 1 := by simpa [house, pi_norm_lt_iff] using h_embedding exact by_contra fun hx ↦ (one_le_house_of_isIntegral hx_int hx).not_gt h_house /-! ## A crude upper bound for the class number -/ section ClassNumberBound open NumberField Ideal Module Set Real Nat /-- For a number field of degree `n` and discriminant `d`, Minkowski's bound on the norm of an ideal in a given class is at most `2 ^ n * |d|`. -/ lemma New.minkowski_bound_le_two_pow_mul_discr (F : Type*) [Field F] [NumberField F] : (4 / π) ^ InfinitePlace.nrComplexPlaces F * ((finrank ℚ F) ! / (finrank ℚ F : ℝ) ^ finrank ℚ F * √|(discr F : ℝ)|) ≤ 2 ^ finrank ℚ F * |(discr F : ℝ)| := by set n : ℕ := finrank ℚ F have h_places : InfinitePlace.nrComplexPlaces F ≤ n := by grind [InfinitePlace.card_add_two_mul_card_eq_rank F] have h_pi : 4 / π ≤ 2 := (div_le_iff₀ pi_pos).2 (by linarith [two_le_pi]) have h_factorial : (n ! : ℝ) / (n : ℝ) ^ n ≤ 1 := div_le_one_of_le₀ (mod_cast factorial_le_pow n) (by positivity) have h_discr : √|(discr F : ℝ)| ≤ |(discr F : ℝ)| := sqrt_le_self_iff.2 (mod_cast Or.inr (Int.one_le_abs (discr_ne_zero F))) grw [h_pi, h_factorial, h_discr, one_mul, pow_le_pow_right₀ one_le_two h_places] /-- A number field of degree `n` and discriminant `d` has class number at most `(2 ^ n * |d|) ^ (n + 1)`. This is a crude consequence of Minkowski's bound on the smallest norm of an integral ideal in each ideal class. -/ lemma New.classNumber_le (F : Type*) [Field F] [NumberField F] : classNumber F ≤ (2 ^ finrank ℚ F * (discr F).natAbs) ^ (finrank ℚ F + 1) := by -- By Minkowski each class holds an ideal `I` of norm `k ≤ B`, and `I = (k, α)` where only `α` -- modulo `k` matters. There are at most `B * B ^ n` pairs `(k, α mod k)`. set n : ℕ := finrank ℚ F set B : ℕ := 2 ^ n * (discr F).natAbs with hB have hk_ne_zero (k : Ioc 0 B) : (k : 𝓞 F) ≠ 0 := Nat.cast_ne_zero.2 k.2.1.ne' have (k : Ioc 0 B) : Finite (𝓞 F ⧸ span {(k : 𝓞 F)}) := finiteQuotientOfFreeOfNeBot _ (by simp [hk_ne_zero k]) -- `cls (k, α mod k)` is the class of the ideal `(k, α)`. let cls (x : Σ k : Ioc 0 B, 𝓞 F ⧸ span {(k : 𝓞 F)}) : ClassGroup (𝓞 F) := .mk0 ⟨span {↑x.1} ⊔ span {x.2.out}, mem_nonZeroDivisors_of_ne_zero (by simp [hk_ne_zero x.1])⟩ have h_surj : cls.Surjective := fun C ↦ by obtain ⟨I, rfl, hI⟩ := exists_ideal_in_class_of_norm_le C set k : ℕ := absNorm I.1 have h_pos : 0 < k := absNorm_pos_of_nonZeroDivisors I have h_le : k ≤ B := by rify [hB] exact hI.trans (minkowski_bound_le_two_pow_mul_discr F) obtain ⟨α, hα⟩ : ∃ α : 𝓞 F, span {(k : 𝓞 F)} ⊔ span {α} = I.1 := IsDedekindDomain.exists_sup_span_eq I.1.span_singleton_absNorm_le (by simpa using h_pos.ne') -- a lift of `α mod k` generates, together with `k`, the same ideal as `α` and `k` have h_lift : span {(k : 𝓞 F)} ⊔ span {(Ideal.Quotient.mk (span {(k : 𝓞 F)}) α).out} = I.1 := by simp [← hα, ← comap_map_quotientMk, map_span] exact ⟨⟨⟨k, h_pos, h_le⟩, Ideal.Quotient.mk _ α⟩, by simp [cls, h_lift]⟩ calc classNumber F = Nat.card (ClassGroup (𝓞 F)) := card_eq_fintype_card.symm _ ≤ Nat.card (Σ k : Ioc 0 B, 𝓞 F ⧸ span {(k : 𝓞 F)}) := card_le_card_of_surjective cls h_surj _ = ∑ k : Ioc 0 B, (k : ℕ) ^ n := by simp only [card_sigma, ← Submodule.cardQuot_apply, ← absNorm_apply, absNorm_span_natCast, RingOfIntegers.rank, n] _ ≤ ∑ k : Ioc 0 B, B ^ n := Finset.sum_le_sum fun k _ ↦ Nat.pow_le_pow_left k.2.2 n _ = B ^ (n + 1) := by simp [_root_.pow_succ'] end ClassNumberBound