import Mathlib.RingTheory.Unramified.Basic /-! # Unramified Congruence Neighborhood -/ namespace OAI.AlgebraicGeometry.Resolution.Blowups.UnramifiedCongruenceNeighborhood.Construction noncomputable section section /-! Open equalizer neighborhoods for two maps from an unramified algebra. -/ open scoped TensorProduct variable {P R S : Type*} [CommRing P] [CommRing R] [CommRing S] [Algebra P R] [Algebra P S] [Algebra.EssFiniteType P R] [Algebra.FormallyUnramified P R] /-- The ideal of differences of two maps from an unramified algebra is generated by one idempotent: their equalizer is open and closed. -/ theorem unramified_differenceIdeal_idempotent (f g : R →ₐ[P] S) : ∃ e : S, IsIdempotentElem e ∧ Ideal.span (Set.range (fun x : R => g x - f x)) = Ideal.span {e} := by let ψ : R ⊗[P] R →ₐ[P] S := Algebra.TensorProduct.lift f g (fun _ _ => Commute.all _ _) have hmap : (KaehlerDifferential.ideal P R).map ψ.toRingHom = Ideal.span (Set.range (fun x : R => g x - f x)) := by rw [← KaehlerDifferential.span_range_eq_ideal, Ideal.map_span, ← Set.range_comp] congr 1 funext x simp [ψ, Function.comp_def] obtain ⟨e, he, hsp⟩ : ∃ e : R ⊗[P] R, IsIdempotentElem e ∧ KaehlerDifferential.ideal P R = Ideal.span {e} := (Ideal.isIdempotentElem_iff_of_fg _ (KaehlerDifferential.ideal_fg P R)).mp ((Ideal.cotangent_subsingleton_iff _).mp (inferInstanceAs (Subsingleton (KaehlerDifferential P R)))) refine ⟨ψ e, ?_, ?_⟩ · change ψ e * ψ e = ψ e rw [← map_mul, he.eq] · rw [hsp, Ideal.map_span, Set.image_singleton] at hmap exact hmap.symm /-- If the two maps agree at a prime, a single element outside that prime annihilates all their differences. This constructs an open equalizer neighborhood. -/ theorem unramified_equalizer_neighborhood (f g : R →ₐ[P] S) (q : Ideal S) [q.IsPrime] (hq : ∀ x : R, g x - f x ∈ q) : ∃ s : S, s ∉ q ∧ ∀ x : R, s * (g x - f x) = 0 := by obtain ⟨e, he, hsp⟩ := unramified_differenceIdeal_idempotent f g have heq : e ∈ q := by have hle : Ideal.span (Set.range (fun x : R => g x - f x)) ≤ q := Ideal.span_le.mpr (by rintro _ ⟨x, rfl⟩; exact hq x) rw [hsp] at hle exact hle (Ideal.mem_span_singleton_self e) refine ⟨1 - e, ?_, ?_⟩ · intro hs have h := q.add_mem hs heq rw [sub_add_cancel] at h have hprime : q.IsPrime := inferInstance exact hprime.ne_top (Ideal.eq_top_of_isUnit_mem q h isUnit_one) · intro x have hx : g x - f x ∈ Ideal.span {e} := by rw [← hsp] exact Ideal.subset_span (Set.mem_range_self x) obtain ⟨a, ha⟩ := Ideal.mem_span_singleton.mp hx rw [ha, ← mul_assoc, he.one_sub_mul_self, zero_mul] end /-! Selecting the equalizer branch modulo an ideal on an actual principal open. -/ variable {P R S : Type*} [CommRing P] [CommRing R] [CommRing S] [Algebra P R] [Algebra.EssFiniteType P R] [Algebra.FormallyUnramified P R] /-- Agreement on the coordinate algebra modulo `I`, and at the selected point on the whole algebra, extends to agreement modulo `I` on a principal neighborhood. -/ theorem unramified_congruence_neighborhood (f g : R →+* S) (I q : Ideal S) [q.IsPrime] (hIq : I ≤ q) (hbase : ∀ p : P, g (algebraMap P R p) - f (algebraMap P R p) ∈ I) (hq : ∀ x : R, g x - f x ∈ q) : ∃ s : S, s ∉ q ∧ ∀ x : R, s * (g x - f x) ∈ I := by let Q : S →+* S ⧸ I := Ideal.Quotient.mk I let : Algebra P (S ⧸ I) := ((Q.comp f).comp (algebraMap P R)).toAlgebra let fP : R →ₐ[P] S ⧸ I := { Q.comp f with commutes' := fun _ => rfl } let gP : R →ₐ[P] S ⧸ I := { Q.comp g with commutes' := fun p => Ideal.Quotient.eq.mpr (hbase p) } let qbar : Ideal (S ⧸ I) := q.map Q let : qbar.IsPrime := Ideal.isPrime_map_quotientMk_of_isPrime hIq have hqbar : ∀ x : R, gP x - fP x ∈ qbar := by intro x change Q (g x) - Q (f x) ∈ q.map Q rw [← map_sub] exact Ideal.mem_map_of_mem Q (hq x) obtain ⟨sbar, hsbar, hzero⟩ := unramified_equalizer_neighborhood fP gP qbar hqbar obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective sbar refine ⟨s, ?_, ?_⟩ · intro hs exact hsbar (Ideal.mem_map_of_mem Q hs) · intro x apply Ideal.Quotient.eq_zero_iff_mem.mp rw [map_mul, map_sub] exact hzero x /-- The constructed principal localization has the required congruence for every section, not only for the coordinate generators. -/ theorem unramified_congruence_principal_open (f g : R →+* S) (I q : Ideal S) [q.IsPrime] (hIq : I ≤ q) (hbase : ∀ p : P, g (algebraMap P R p) - f (algebraMap P R p) ∈ I) (hq : ∀ x : R, g x - f x ∈ q) : ∃ s : S, s ∉ q ∧ ∀ x : R, algebraMap S (Localization.Away s) (g x - f x) ∈ I.map (algebraMap S (Localization.Away s)) := by obtain ⟨s, hs, hann⟩ := unramified_congruence_neighborhood f g I q hIq hbase hq refine ⟨s, hs, ?_⟩ intro x have h := Ideal.mem_map_of_mem (algebraMap S (Localization.Away s)) (hann x) rw [map_mul] at h exact (Ideal.unit_mul_mem_iff_mem _ (IsLocalization.Away.algebraMap_isUnit s)).mp h end end OAI.AlgebraicGeometry.Resolution.Blowups.UnramifiedCongruenceNeighborhood.Construction