/- Copyright (c) 2024 Brendan Murphy. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Brendan Murphy This file has been modified. -/ import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic import Mathlib.RingTheory.Nakayama import Mathlib.RingTheory.Regular.IsSMulRegular /-! # Sequence Basic -/ namespace OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic noncomputable section open _root_.Ideal open _root_.Submodule universe u v open scoped Pointwise variable {R S M M₂ M₃ M₄ : Type*} namespace Ideal variable [Semiring R] [Semiring S] /-- The ideal generated by a list of elements. -/ abbrev ofList (rs : List R) := span { r | r ∈ rs } @[simp] lemma ofList_nil : (ofList [] : Ideal R) = ⊥ := have : { r | r ∈ [] } = ∅ := Set.eq_empty_of_forall_notMem (fun _ => List.not_mem_nil) Eq.trans (congrArg span this) _root_.Ideal.span_empty @[simp] lemma ofList_append (rs₁ rs₂ : List R) : ofList (rs₁ ++ rs₂) = ofList rs₁ ⊔ ofList rs₂ := have : { r | r ∈ rs₁ ++ rs₂ } = _ := Set.ext (fun _ => List.mem_append) Eq.trans (congrArg span this) (_root_.Ideal.span_union _ _) lemma ofList_singleton (r : R) : ofList [r] = span {r} := congrArg span (Set.ext fun _ => List.mem_singleton) @[simp] lemma ofList_cons (r : R) (rs : List R) : ofList (r::rs) = span {r} ⊔ ofList rs := Eq.trans (ofList_append [r] rs) (congrArg (· ⊔ _) (ofList_singleton r)) @[simp] lemma map_ofList (f : R →+* S) (rs : List R) : map f (ofList rs) = ofList (rs.map f) := Eq.trans (map_span f { r | r ∈ rs }) <| congrArg span <| Set.ext (fun _ => List.mem_map.symm) lemma ofList_cons_smul {R} [CommSemiring R] (r : R) (rs : List R) {M} [AddCommMonoid M] [Module R M] (N : Submodule R M) : ofList (r :: rs) • N = r • N ⊔ ofList rs • N := by rw [ofList_cons, Submodule.sup_smul, Submodule.ideal_span_singleton_smul] end Ideal namespace Submodule variable (M) [CommRing R] [AddCommGroup M] [AddCommGroup M₂] [Module R M] [Module R M₂] (r : R) (rs : List R) /-- The equivalence between M ⧸ (r₀, r₁, …, rₙ)M and (M ⧸ r₀M) ⧸ (r₁, …, rₙ) (M ⧸ r₀M). -/ def quotOfListConsSMulTopEquivQuotSMulTopInner : (M ⧸ (SequenceBasic.Ideal.ofList (r :: rs) • ⊤ : Submodule R M)) ≃ₗ[R] QuotSMulTop r M ⧸ (SequenceBasic.Ideal.ofList rs • ⊤ : Submodule R (QuotSMulTop r M)) := quotEquivOfEq _ _ (SequenceBasic.Ideal.ofList_cons_smul r rs ⊤) ≪≫ₗ (quotientQuotientEquivQuotientSup (r • ⊤) (SequenceBasic.Ideal.ofList rs • ⊤)).symm ≪≫ₗ quotEquivOfEq _ _ (by rw [map_smul'', _root_.Submodule.map_top, range_mkQ]) /-- The equivalence between M ⧸ (r₀, r₁, …, rₙ)M and (M ⧸ (r₁, …, rₙ)) ⧸ r₀ (M ⧸ (r₁, …, rₙ)). -/ def quotOfListConsSMulTopEquivQuotSMulTopOuter : (M ⧸ (SequenceBasic.Ideal.ofList (r :: rs) • ⊤ : Submodule R M)) ≃ₗ[R] QuotSMulTop r (M ⧸ (SequenceBasic.Ideal.ofList rs • ⊤ : Submodule R M)) := quotEquivOfEq _ _ (Eq.trans (SequenceBasic.Ideal.ofList_cons_smul r rs ⊤) (sup_comm _ _)) ≪≫ₗ (quotientQuotientEquivQuotientSup (SequenceBasic.Ideal.ofList rs • ⊤) (r • ⊤)).symm ≪≫ₗ quotEquivOfEq _ _ (by rw [_root_.Submodule.map_pointwise_smul, _root_.Submodule.map_top, range_mkQ]) variable {M} lemma quotOfListConsSMulTopEquivQuotSMulTopInner_naturality (f : M →ₗ[R] M₂) : (quotOfListConsSMulTopEquivQuotSMulTopInner M₂ r rs).toLinearMap ∘ₗ mapQ _ _ _ (smul_top_le_comap_smul_top (SequenceBasic.Ideal.ofList (r :: rs)) f) = mapQ _ _ _ (smul_top_le_comap_smul_top _ (QuotSMulTop.map r f)) ∘ₗ (quotOfListConsSMulTopEquivQuotSMulTopInner M r rs).toLinearMap := quot_hom_ext _ _ _ fun _ => rfl lemma top_eq_ofList_cons_smul_iff : (⊤ : Submodule R M) = SequenceBasic.Ideal.ofList (r :: rs) • ⊤ ↔ (⊤ : Submodule R (QuotSMulTop r M)) = SequenceBasic.Ideal.ofList rs • ⊤ := by exact (eq_comm.trans (_root_.Submodule.Quotient.subsingleton_iff (p := SequenceBasic.Ideal.ofList (r :: rs) • (⊤ : Submodule R M))).symm).trans ((quotOfListConsSMulTopEquivQuotSMulTopInner M r rs).toEquiv.subsingleton_congr.trans ((_root_.Submodule.Quotient.subsingleton_iff (p := SequenceBasic.Ideal.ofList rs • (⊤ : Submodule R (QuotSMulTop r M)))).trans eq_comm)) end Submodule namespace RingTheory.Sequence open scoped TensorProduct List open Function QuotSMulTop variable (S M) section Definitions /- In theory, regularity of `rs: List α` on `M` makes sense as soon as `[Monoid α]`, `[AddCommGroup M]`, and `[DistribMulAction α M]`. Instead of `Ideal.ofList (rs.take i) • (⊤: Submodule R M)` we use `⨆ (j: Fin i), rs[j] • (⊤: AddSubgroup M)`. However it's not clear that this is a useful generalization. If we add the assumption `[SMulCommClass α α M]` this is essentially the same as focusing on the commutative ring case, by passing to the monoid ring `ℤ[abelianization of α]`. -/ variable [CommRing R] [AddCommGroup M] [Module R M] /-- A sequence `[r₁, …, rₙ]` is weakly regular on `M` iff `rᵢ` is regular on `M⧸(r₁, …, rᵢ₋₁)M` for all `1 ≤ i ≤ n`. -/ @[mk_iff] structure IsWeaklyRegular (rs : List R) : Prop where regular_mod_prev : ∀ i (h : i < rs.length), IsSMulRegular (M ⧸ (SequenceBasic.Ideal.ofList (rs.take i) • ⊤ : Submodule R M)) rs[i] lemma isWeaklyRegular_iff_Fin (rs : List R) : IsWeaklyRegular M rs ↔ ∀ (i : Fin rs.length), IsSMulRegular (M ⧸ (SequenceBasic.Ideal.ofList (rs.take i) • ⊤ : Submodule R M)) rs[i] := Iff.trans (isWeaklyRegular_iff M rs) (Iff.symm Fin.forall_iff) /-- A weakly regular sequence `rs` on `M` is regular if also `M/rsM ≠ 0`. -/ @[mk_iff] structure IsRegular (rs : List R) : Prop extends IsWeaklyRegular M rs where top_ne_smul : (⊤ : Submodule R M) ≠ SequenceBasic.Ideal.ofList rs • ⊤ end Definitions section Congr variable {S M} [CommRing R] [CommRing S] [AddCommGroup M] [AddCommGroup M₂] [Module R M] [Module S M₂] {σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] open DistribMulAction AddSubgroup in private lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.AddHom.map_smul_top_toAddSubgroup_of_surjective {f : M →+ M₂} {as : List R} {bs : List S} (hf : Function.Surjective f) (h : List.Forall₂ (fun r s => ∀ x, f (r • x) = s • f x) as bs) : (SequenceBasic.Ideal.ofList as • ⊤ : Submodule R M).toAddSubgroup.map f = (SequenceBasic.Ideal.ofList bs • ⊤ : Submodule S M₂).toAddSubgroup := by induction h with | nil => convert! AddSubgroup.map_bot f using 1 <;> rw [SequenceBasic.Ideal.ofList_nil, bot_smul, bot_toAddSubgroup] | @cons r s _ _ h _ ih => conv => congr <;> rw [SequenceBasic.Ideal.ofList_cons, sup_smul, sup_toAddSubgroup, ideal_span_singleton_smul, _root_.Submodule.pointwise_smul_toAddSubgroup, top_toAddSubgroup, AddSubgroup.pointwise_smul_def] let a : M →+ M := toAddMonoidEnd R M r let b : M₂ →+ M₂ := toAddMonoidEnd S M₂ s have hab : f.comp a = b.comp f := by ext x exact h x rw [AddSubgroup.map_sup, ih] congr 1 change AddSubgroup.map f (AddSubgroup.map a ⊤) = AddSubgroup.map b ⊤ calc AddSubgroup.map f (AddSubgroup.map a ⊤) = AddSubgroup.map (f.comp a) ⊤ := AddSubgroup.map_map _ _ _ _ = AddSubgroup.map (b.comp f) ⊤ := congrArg (fun k : M →+ M₂ => AddSubgroup.map k ⊤) hab _ = AddSubgroup.map b (AddSubgroup.map f ⊤) := (AddSubgroup.map_map _ _ _).symm _ = AddSubgroup.map b ⊤ := congrArg (AddSubgroup.map b) (AddSubgroup.map_top_of_surjective f hf) lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.AddEquiv.isWeaklyRegular_congr {e : M ≃+ M₂} {as bs} (h : List.Forall₂ (fun (r : R) (s : S) => ∀ x, e (r • x) = s • e x) as bs) : IsWeaklyRegular M as ↔ IsWeaklyRegular M₂ bs := by conv => congr <;> rw [isWeaklyRegular_iff_Fin] let e' i : (M ⧸ (SequenceBasic.Ideal.ofList (as.take i) • ⊤ : Submodule R M)) ≃+ M₂ ⧸ (SequenceBasic.Ideal.ofList (bs.take i) • ⊤ : Submodule S M₂) := QuotientAddGroup.congr _ _ e <| AddHom.map_smul_top_toAddSubgroup_of_surjective e.surjective <| List.forall₂_take i h refine (finCongr h.length_eq).forall_congr @fun _ => (e' _).isSMulRegular_congr ?_ exact (mkQ_surjective _).forall.mpr fun _ => congrArg (mkQ _) (h.get _ _ _) lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.LinearEquiv.isWeaklyRegular_congr' (e : M ≃ₛₗ[σ] M₂) (rs : List R) : IsWeaklyRegular M rs ↔ IsWeaklyRegular M₂ (rs.map σ) := SequenceBasic.AddEquiv.isWeaklyRegular_congr (e := e.toAddEquiv) <| List.forall₂_map_right_iff.mpr <| List.forall₂_same.mpr fun r _ x => e.map_smul' r x lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.LinearEquiv.isWeaklyRegular_congr [Module R M₂] (e : M ≃ₗ[R] M₂) (rs : List R) : IsWeaklyRegular M rs ↔ IsWeaklyRegular M₂ rs := Iff.trans (LinearEquiv.isWeaklyRegular_congr' e rs) <| iff_of_eq <| congrArg _ rs.map_id lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.AddEquiv.isRegular_congr {e : M ≃+ M₂} {as bs} (h : List.Forall₂ (fun (r : R) (s : S) => ∀ x, e (r • x) = s • e x) as bs) : IsRegular M as ↔ IsRegular M₂ bs := by conv => congr <;> rw [isRegular_iff, ne_comm, ← _root_.Submodule.Quotient.nontrivial_iff] let e' := QuotientAddGroup.congr _ _ e <| AddHom.map_smul_top_toAddSubgroup_of_surjective e.surjective h exact and_congr (SequenceBasic.AddEquiv.isWeaklyRegular_congr (e := e) h) e'.nontrivial_congr lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.LinearEquiv.isRegular_congr' (e : M ≃ₛₗ[σ] M₂) (rs : List R) : IsRegular M rs ↔ IsRegular M₂ (rs.map σ) := SequenceBasic.AddEquiv.isRegular_congr (e := e.toAddEquiv) <| List.forall₂_map_right_iff.mpr <| List.forall₂_same.mpr fun r _ x => e.map_smul' r x lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.LinearEquiv.isRegular_congr [Module R M₂] (e : M ≃ₗ[R] M₂) (rs : List R) : IsRegular M rs ↔ IsRegular M₂ rs := Iff.trans (LinearEquiv.isRegular_congr' e rs) <| iff_of_eq <| congrArg _ rs.map_id end Congr lemma isWeaklyRegular_map_algebraMap_iff [CommRing R] [CommRing S] [Algebra R S] [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M] (rs : List R) : IsWeaklyRegular M (rs.map (algebraMap R S)) ↔ IsWeaklyRegular M rs := SequenceBasic.AddEquiv.isWeaklyRegular_congr (e := AddEquiv.refl M) <| List.forall₂_map_left_iff.mpr <| List.forall₂_same.mpr fun r _ => algebraMap_smul S r variable [CommRing R] [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃] [AddCommGroup M₄] [Module R M] [Module R M₂] [Module R M₃] [Module R M₄] @[simp] lemma isWeaklyRegular_cons_iff (r : R) (rs : List R) : IsWeaklyRegular M (r :: rs) ↔ IsSMulRegular M r ∧ IsWeaklyRegular (QuotSMulTop r M) rs := have := Eq.trans (congrArg (· • ⊤) SequenceBasic.Ideal.ofList_nil) (bot_smul ⊤) let e i := SequenceBasic.Submodule.quotOfListConsSMulTopEquivQuotSMulTopInner M r (rs.take i) Iff.trans (isWeaklyRegular_iff_Fin _ _) <| Iff.trans Fin.forall_iff_succ <| and_congr ((quotEquivOfEqBot _ this).isSMulRegular_congr r) <| Iff.trans (forall_congr' fun i => (e i).isSMulRegular_congr (rs.get i)) (isWeaklyRegular_iff_Fin _ _).symm lemma isWeaklyRegular_cons_iff' (r : R) (rs : List R) : IsWeaklyRegular M (r :: rs) ↔ IsSMulRegular M r ∧ IsWeaklyRegular (QuotSMulTop r M) (rs.map (Ideal.Quotient.mk (Ideal.span {r}))) := Iff.trans (isWeaklyRegular_cons_iff M r rs) <| and_congr_right' <| Iff.symm <| isWeaklyRegular_map_algebraMap_iff (R ⧸ Ideal.span {r}) _ rs @[simp] lemma isRegular_cons_iff (r : R) (rs : List R) : IsRegular M (r :: rs) ↔ IsSMulRegular M r ∧ IsRegular (QuotSMulTop r M) rs := by rw [isRegular_iff, isRegular_iff, isWeaklyRegular_cons_iff M r rs, ne_eq, SequenceBasic.Submodule.top_eq_ofList_cons_smul_iff, and_assoc] lemma isRegular_cons_iff' (r : R) (rs : List R) : IsRegular M (r :: rs) ↔ IsSMulRegular M r ∧ IsRegular (QuotSMulTop r M) (rs.map (Ideal.Quotient.mk (Ideal.span {r}))) := by conv => congr <;> rw [isRegular_iff, ne_eq] rw [isWeaklyRegular_cons_iff', ← restrictScalars_inj R (R ⧸ _), ← SequenceBasic.Ideal.map_ofList, ← Ideal.Quotient.algebraMap_eq, Ideal.smul_restrictScalars, restrictScalars_top, SequenceBasic.Submodule.top_eq_ofList_cons_smul_iff, and_assoc] variable {M} namespace IsWeaklyRegular variable (R M) in @[simp] lemma nil : IsWeaklyRegular M ([] : List R) := .mk (False.elim <| Nat.not_lt_zero · ·) end IsWeaklyRegular lemma isRegular_iff_isWeaklyRegular_of_subset_jacobson_annihilator [Nontrivial M] [Module.Finite R M] {rs : List R} (h : ∀ r ∈ rs, r ∈ Ideal.jacobson (Module.annihilator R M)) : IsRegular M rs ↔ IsWeaklyRegular M rs := Iff.trans (isRegular_iff M rs) <| and_iff_left <| top_ne_ideal_smul_of_le_jacobson_annihilator <| Ideal.span_le.mpr h lemma _root_.OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic.IsLocalRing.isRegular_iff_isWeaklyRegular_of_subset_maximalIdeal [IsLocalRing R] [Nontrivial M] [Module.Finite R M] {rs : List R} (h : ∀ r ∈ rs, r ∈ IsLocalRing.maximalIdeal R) : IsRegular M rs ↔ IsWeaklyRegular M rs := have H h' := bot_ne_top.symm <| annihilator_eq_top_iff.mp <| Eq.trans annihilator_top h' isRegular_iff_isWeaklyRegular_of_subset_jacobson_annihilator fun r hr => IsLocalRing.jacobson_eq_maximalIdeal (Module.annihilator R M) H ▸ h r hr end RingTheory.Sequence end end OAI.AlgebraicGeometry.AbelianModuli.HilbertConstruction.Regular.SequenceBasic