import Mathlib import Definitions.Def_Mathlib_RingTheory_LocalRing_Defs import Definitions.Def_Deformations_Deformations_Lemmas set_option autoImplicit false open Function IsLocalRing variable (π“ž : Type*) [CommRing π“ž] local notation3:max "𝓴" π“ž:max => (IsLocalRing.ResidueField π“ž) variable (A : Type*) [CommRing A] [Algebra π“ž A] [IsLocalRing A] class IsResidueAlgebra : Prop where isSurjective' : Surjective (algebraMap π“ž (𝓴 A)) namespace IsResidueAlgebra variable [IsResidueAlgebra π“ž A] lemma algebraMap_surjective : Surjective (algebraMap π“ž (𝓴 A)) := isSurjective' variable [IsLocalRing π“ž] [IsLocalHom (algebraMap π“ž A)] in lemma algebraMap_bijective : Bijective (algebraMap (𝓴 π“ž) (𝓴 A)) := by have hsurj1 := IsLocalRing.residue_surjective (R := π“ž) have hsurj2 := IsResidueAlgebra.algebraMap_surjective π“ž A exact ⟨(algebraMap (𝓴 π“ž) (𝓴 A)).injective, (Function.Surjective.of_comp_iff (algebraMap (𝓴 π“ž) (𝓴 A)) hsurj1).mp hsurj2⟩ variable [IsLocalRing π“ž] [IsLocalHom (algebraMap π“ž A)] in noncomputable def algEquiv : 𝓴 π“ž ≃ₐ[π“ž] 𝓴 A := .ofBijective (IsScalarTower.toAlgHom _ _ _) (algebraMap_bijective _ _) instance [IsLocalRing π“ž] : IsResidueAlgebra π“ž π“ž := ⟨IsLocalRing.residue_surjective⟩ section Quotient instance (I : Ideal A) [Nontrivial (A β§Έ I)] : IsResidueAlgebra π“ž (A β§Έ I) where isSurjective' := have : IsLocalHom (Ideal.Quotient.mk I) := .of_surjective _ Ideal.Quotient.mk_surjective (IsLocalRing.ResidueField.map_surjective _ Ideal.Quotient.mk_surjective).comp (IsResidueAlgebra.algebraMap_surjective π“ž A) end Quotient section Relative variable {π“ž A} variable {B : Type*} [CommRing B] [Algebra π“ž B] [IsLocalRing B] [IsResidueAlgebra π“ž B] omit [IsLocalRing A] [IsResidueAlgebra π“ž A] in lemma of_restrictScalars [Algebra A B] [IsScalarTower π“ž A B] : IsResidueAlgebra A B where isSurjective' := by refine .of_comp (g := algebraMap π“ž A) ?_ rw [← RingHom.coe_comp, ← IsScalarTower.algebraMap_eq] exact IsResidueAlgebra.algebraMap_surjective _ _ end Relative open IsLocalRing variable {A} lemma exists_sub_mem_maximalIdeal (r : A) : βˆƒ a, r - algebraMap π“ž A a ∈ maximalIdeal _ := by obtain ⟨a, ha⟩ := IsResidueAlgebra.algebraMap_surjective π“ž _ (residue _ r) refine ⟨a, ?_⟩ rw [← Ideal.Quotient.eq] exact ha.symm noncomputable def preimage (r : A) : π“ž := (exists_sub_mem_maximalIdeal π“ž r).choose lemma preimage_spec (r : A) : r - algebraMap π“ž A (preimage π“ž r) ∈ maximalIdeal _ := (exists_sub_mem_maximalIdeal π“ž r).choose_spec lemma residue_preimage (r : A) : residue _ (algebraMap _ _ (preimage π“ž r)) = residue _ r := (Ideal.Quotient.eq.mpr (preimage_spec π“ž r)).symm variable [IsLocalRing π“ž] [IsLocalHom (algebraMap π“ž A)] in lemma residue_preimage_eq_iff {r : A} {a} : residue _ (preimage π“ž r) = a ↔ residue _ r = ResidueField.map (algebraMap π“ž A) a := by rw [← (IsResidueAlgebra.algebraMap_bijective π“ž A).1.eq_iff] erw [ResidueField.map_residue] rw [residue_preimage] rfl end IsResidueAlgebra