import Mathlib.RingTheory.Etale.Field import Mathlib.RingTheory.AlgebraicIndependent.Defs import Mathlib.FieldTheory.IntermediateField.Adjoin.Algebra /-! # Transcendence Etale -/ namespace OAI.AlgebraicGeometry.Foundations.Scheme.TranscendenceEtale noncomputable section /-! # Formal etaleness over a separating polynomial coordinate algebra An algebraically independent family identifies its polynomial algebra with its generated subalgebra. Passing to the generated intermediate field is a localization, and a separable extension of that field is formally etale. -/ universe u /-- The polynomial-algebra structure defined by evaluation at a specified family of elements. -/ abbrev polynomialEvaluationAlgebra (k : Type*) {K ι : Type*} [CommSemiring k] [CommSemiring K] [Algebra k K] (v : ι → K) : Algebra (MvPolynomial ι k) K := (MvPolynomial.aeval v).toRingHom.toAlgebra /-- The evaluation algebra has the expected scalar tower over the original coefficient semiring. -/ theorem polynomialEvaluation_isScalarTower (k : Type*) {K ι : Type*} [CommSemiring k] [CommSemiring K] [Algebra k K] (v : ι → K) : letI := polynomialEvaluationAlgebra k v IsScalarTower k (MvPolynomial ι k) K := by let := polynomialEvaluationAlgebra k v apply IsScalarTower.of_algebraMap_eq intro c exact ((MvPolynomial.aeval v).commutes c).symm /-- A ring isomorphism is formally etale for its induced algebra structure. -/ theorem formallyEtale_ringEquiv {R S : Type*} [CommRing R] [CommRing S] (e : R ≃+* S) : e.toRingHom.FormallyEtale := by let : Algebra R S := e.toRingHom.toAlgebra change Algebra.FormallyEtale R S let e' : R ≃ₐ[R] S := { e with commutes' := fun _ => rfl } exact Algebra.FormallyEtale.of_equiv e' open scoped IntermediateField.algebraAdjoinAdjoin in /-- A field separable over the field generated by an algebraically independent family is formally etale over the polynomial algebra evaluated at that family. -/ theorem formallyEtale_polynomialEvaluation {k K ι : Type u} [Field k] [Field K] [Algebra k K] {v : ι → K} (hv : AlgebraicIndependent k v) [Algebra.IsSeparable (IntermediateField.adjoin k (Set.range v)) K] : letI := polynomialEvaluationAlgebra k v Algebra.FormallyEtale (MvPolynomial ι k) K := by change (MvPolynomial.aeval (R := k) v).toRingHom.FormallyEtale let A := Algebra.adjoin k (Set.range v) let F := IntermediateField.adjoin k (Set.range v) have hPA : hv.aevalEquiv.toRingHom.FormallyEtale := formallyEtale_ringEquiv hv.aevalEquiv.toRingEquiv have hAF : (algebraMap A F).FormallyEtale := RingHom.formallyEtale_algebraMap.mpr (Algebra.FormallyEtale.of_isLocalization (nonZeroDivisors A)) have hFK : (algebraMap F K).FormallyEtale := RingHom.formallyEtale_algebraMap.mpr (Algebra.FormallyEtale.of_isSeparable F K) have hc := (hPA.comp hAF).comp hFK have hcomp : (algebraMap F K).comp ((algebraMap A F).comp hv.aevalEquiv.toRingHom) = (MvPolynomial.aeval v).toRingHom := by apply RingHom.ext intro p change algebraMap F K (algebraMap A F (hv.aevalEquiv p)) = MvPolynomial.aeval v p rw [← IsScalarTower.algebraMap_apply A F K] exact hv.algebraMap_aevalEquiv p simpa only [hcomp] using hc end end OAI.AlgebraicGeometry.Foundations.Scheme.TranscendenceEtale