source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/RingTheory/FreeCommRing.lean | import Mathlib.Algebra.MvPolynomial.Equiv
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Logic.Equiv.Functor
import Mathlib.RingTheory.FreeRing
/-!
# Free commutative rings
The theory of the free commutative ring generated by a type `α`.
It is isomorphic to the polynomial ring over ℤ with variables
in `α`
## Main definitions
* `FreeCommRing α` : the free commutative ring on a type α
* `lift (f : α → R)` : the ring hom `FreeCommRing α →+* R` induced by functoriality from `f`.
* `map (f : α → β)` : the ring hom `FreeCommRing α →*+ FreeCommRing β` induced by
functoriality from f.
## Main results
`FreeCommRing` has functorial properties (it is an adjoint to the forgetful functor).
In this file we have:
* `of : α → FreeCommRing α`
* `lift (f : α → R) : FreeCommRing α →+* R`
* `map (f : α → β) : FreeCommRing α →+* FreeCommRing β`
* `freeCommRingEquivMvPolynomialInt : FreeCommRing α ≃+* MvPolynomial α ℤ` :
`FreeCommRing α` is isomorphic to a polynomial ring.
## Implementation notes
`FreeCommRing α` is implemented not using `MvPolynomial` but
directly as the free abelian group on `Multiset α`, the type
of monomials in this free commutative ring.
## Tags
free commutative ring, free ring
-/
assert_not_exists Cardinal
noncomputable section
open Polynomial
universe u v
variable (α : Type u)
/--
If `α` is a type, then `FreeCommRing α` is the free commutative ring generated by `α`.
This is a commutative ring equipped with a function `FreeCommRing.of : α → FreeCommRing α` which has
the following universal property: if `R` is any commutative ring, and `f : α → R` is any function,
then this function is the composite of `FreeCommRing.of` and a unique ring homomorphism
`FreeCommRing.lift f : FreeCommRing α →+* R`.
A typical element of `FreeCommRing α` is a `ℤ`-linear combination of
formal products of elements of `α`.
For example if `x` and `y` are terms of type `α` then `3 * x * x * y - 2 * x * y + 1` is a
"typical" element of `FreeCommRing α`. In particular if `α` is empty
then `FreeCommRing α` is isomorphic to `ℤ`, and if `α` has one term `t`
then `FreeCommRing α` is isomorphic to the polynomial ring `ℤ[t]`.
One can think of `FreeRing α` as the free polynomial ring
with coefficients in the integers and variables indexed by `α`.
-/
def FreeCommRing (α : Type u) : Type u :=
FreeAbelianGroup <| Multiplicative <| Multiset α
deriving CommRing, Inhabited
namespace FreeCommRing
variable {α}
/-- The canonical map from `α` to the free commutative ring on `α`. -/
def of (x : α) : FreeCommRing α :=
FreeAbelianGroup.of <| Multiplicative.ofAdd ({x} : Multiset α)
theorem of_injective : Function.Injective (of : α → FreeCommRing α) :=
FreeAbelianGroup.of_injective.comp fun _ _ =>
(Multiset.coe_eq_coe.trans List.singleton_perm_singleton).mp
@[simp]
theorem of_ne_zero (x : α) : of x ≠ 0 := FreeAbelianGroup.of_ne_zero _
@[simp]
theorem zero_ne_of (x : α) : 0 ≠ of x := FreeAbelianGroup.zero_ne_of _
@[simp]
theorem of_ne_one (x : α) : of x ≠ 1 :=
FreeAbelianGroup.of_injective.ne <| Multiset.singleton_ne_zero _
@[simp]
theorem one_ne_of (x : α) : 1 ≠ of x :=
FreeAbelianGroup.of_injective.ne <| Multiset.zero_ne_singleton _
lemma of_cons (a : α) (m : Multiset α) : (FreeAbelianGroup.of (Multiplicative.ofAdd (a ::ₘ m))) =
@HMul.hMul _ (FreeCommRing α) (FreeCommRing α) _ (of a)
(FreeAbelianGroup.of (Multiplicative.ofAdd m)) := by
dsimp [FreeCommRing]
rw [← Multiset.singleton_add, ofAdd_add,
of, FreeAbelianGroup.of_mul_of]
@[elab_as_elim, induction_eliminator]
protected theorem induction_on {motive : FreeCommRing α → Prop} (z : FreeCommRing α)
(neg_one : motive (-1)) (of : ∀ b, motive (of b))
(add : ∀ x y, motive x → motive y → motive (x + y))
(mul : ∀ x y, motive x → motive y → motive (x * y)) : motive z :=
have neg : ∀ x, motive x → motive (-x) := fun x ih => neg_one_mul x ▸ mul _ _ neg_one ih
have one : motive 1 := neg_neg (1 : FreeCommRing α) ▸ neg _ neg_one
FreeAbelianGroup.induction_on z (neg_add_cancel (1 : FreeCommRing α) ▸ add _ _ neg_one one)
(fun m => Multiset.induction_on m one fun a _ ih => mul (FreeCommRing.of a) _ (of a) ih)
(fun _ ih => neg _ ih) add
section lift
variable {R : Type v} [CommRing R] (f : α → R)
/-- A helper to implement `lift`. This is essentially `FreeCommMonoid.lift`, but this does not
currently exist. -/
private def liftToMultiset : (α → R) ≃ (Multiplicative (Multiset α) →* R) where
toFun f :=
{ toFun := fun s => (s.toAdd.map f).prod
map_mul' := fun x y =>
calc
_ = Multiset.prod (Multiset.map f x + Multiset.map f y) := by
rw [← Multiset.map_add]
rfl
_ = _ := Multiset.prod_add _ _
map_one' := rfl }
invFun F x := F (Multiplicative.ofAdd ({x} : Multiset α))
left_inv f := funext fun x => show (Multiset.map f {x}).prod = _ by simp
right_inv F := MonoidHom.ext fun x =>
let F' := F.toAdditiveRight
let x' := x.toAdd
show (Multiset.map (fun a => F' {a}) x').sum = F' x' by
rw [← Function.comp_def (fun x => F' x) (fun x => {x}), ← Multiset.map_map,
← AddMonoidHom.map_multiset_sum]
exact DFunLike.congr_arg F (Multiset.sum_map_singleton x')
/-- Lift a map `α → R` to an additive group homomorphism `FreeCommRing α → R`. -/
def lift : (α → R) ≃ (FreeCommRing α →+* R) :=
Equiv.trans liftToMultiset FreeAbelianGroup.liftMonoid
@[simp]
theorem lift_of (x : α) : lift f (of x) = f x :=
(FreeAbelianGroup.lift_apply_of _ _).trans <| mul_one _
@[simp]
theorem lift_comp_of (f : FreeCommRing α →+* R) : lift (f ∘ of) = f :=
RingHom.ext fun x =>
FreeCommRing.induction_on x (by rw [RingHom.map_neg, RingHom.map_one, f.map_neg, f.map_one])
(lift_of _) (fun x y ihx ihy => by rw [RingHom.map_add, f.map_add, ihx, ihy])
fun x y ihx ihy => by rw [RingHom.map_mul, f.map_mul, ihx, ihy]
@[ext 1100]
theorem hom_ext ⦃f g : FreeCommRing α →+* R⦄ (h : ∀ x, f (of x) = g (of x)) : f = g :=
lift.symm.injective (funext h)
end lift
variable {β : Type v} (f : α → β)
/-- A map `f : α → β` produces a ring homomorphism `FreeCommRing α →+* FreeCommRing β`. -/
def map : FreeCommRing α →+* FreeCommRing β :=
lift <| of ∘ f
@[simp]
theorem map_of (x : α) : map f (of x) = of (f x) :=
lift_of _ _
/-- `is_supported x s` means that all monomials showing up in `x` have variables in `s`. -/
def IsSupported (x : FreeCommRing α) (s : Set α) : Prop :=
x ∈ Subring.closure (of '' s)
section IsSupported
variable {x y : FreeCommRing α} {s t : Set α}
theorem isSupported_upwards (hs : IsSupported x s) (hst : s ⊆ t) : IsSupported x t :=
Subring.closure_mono (Set.monotone_image hst) hs
theorem isSupported_add (hxs : IsSupported x s) (hys : IsSupported y s) : IsSupported (x + y) s :=
Subring.add_mem _ hxs hys
theorem isSupported_neg (hxs : IsSupported x s) : IsSupported (-x) s :=
Subring.neg_mem _ hxs
theorem isSupported_sub (hxs : IsSupported x s) (hys : IsSupported y s) : IsSupported (x - y) s :=
Subring.sub_mem _ hxs hys
theorem isSupported_mul (hxs : IsSupported x s) (hys : IsSupported y s) : IsSupported (x * y) s :=
Subring.mul_mem _ hxs hys
theorem isSupported_zero : IsSupported 0 s :=
Subring.zero_mem _
theorem isSupported_one : IsSupported 1 s :=
Subring.one_mem _
theorem isSupported_int {i : ℤ} {s : Set α} : IsSupported (↑i) s :=
Int.induction_on i isSupported_zero
(fun i hi => by rw [Int.cast_add, Int.cast_one]; exact isSupported_add hi isSupported_one)
fun i hi => by rw [Int.cast_sub, Int.cast_one]; exact isSupported_sub hi isSupported_one
end IsSupported
/-- The restriction map from `FreeCommRing α` to `FreeCommRing s` where `s : Set α`, defined
by sending all variables not in `s` to zero. -/
def restriction (s : Set α) [DecidablePred (· ∈ s)] : FreeCommRing α →+* FreeCommRing s :=
lift (fun a => if H : a ∈ s then of ⟨a, H⟩ else 0)
section Restriction
variable (s : Set α) [DecidablePred (· ∈ s)] (x y : FreeCommRing α)
@[simp]
theorem restriction_of (p) : restriction s (of p) = if H : p ∈ s then of ⟨p, H⟩ else 0 :=
lift_of _ _
end Restriction
theorem isSupported_of {p} {s : Set α} : IsSupported (of p) s ↔ p ∈ s :=
suffices IsSupported (of p) s → p ∈ s from ⟨this, fun hps => Subring.subset_closure ⟨p, hps, rfl⟩⟩
fun hps : IsSupported (of p) s => by
classical
haveI := Classical.decPred s
have : ∀ x, IsSupported x s →
∃ n : ℤ, lift (fun a => if a ∈ s then (0 : ℤ[X]) else Polynomial.X) x = n := by
intro x hx
refine Subring.InClosure.recOn hx ?_ ?_ ?_ ?_
· use 1
rw [RingHom.map_one]
norm_cast
· use -1
rw [RingHom.map_neg, RingHom.map_one, Int.cast_neg, Int.cast_one]
· rintro _ ⟨z, hzs, rfl⟩ _ _
use 0
rw [RingHom.map_mul, lift_of, if_pos hzs, zero_mul]
norm_cast
· rintro x y ⟨q, hq⟩ ⟨r, hr⟩
refine ⟨q + r, ?_⟩
rw [RingHom.map_add, hq, hr]
norm_cast
specialize this (of p) hps
rw [lift_of] at this
split_ifs at this with h
· exact h
exfalso
apply Ne.symm Int.zero_ne_one
rcases this with ⟨w, H⟩
rw [← Polynomial.C_eq_intCast] at H
have : Polynomial.X.coeff 1 = (Polynomial.C ↑w).coeff 1 := by rw [H]; rfl
rwa [Polynomial.coeff_C, if_neg (one_ne_zero : 1 ≠ 0), Polynomial.coeff_X, if_pos rfl] at this
theorem map_subtype_val_restriction {x} (s : Set α) [DecidablePred (· ∈ s)]
(hxs : IsSupported x s) : map (↑) (restriction s x) = x := by
refine Subring.InClosure.recOn hxs ?_ ?_ ?_ ?_
· rw [RingHom.map_one]
rfl
· rw [map_neg, map_one]
rfl
· rintro _ ⟨p, hps, rfl⟩ n ih
rw [RingHom.map_mul, restriction_of, dif_pos hps, RingHom.map_mul, map_of, ih]
· intro x y ihx ihy
rw [RingHom.map_add, RingHom.map_add, ihx, ihy]
theorem exists_finite_support (x : FreeCommRing α) : ∃ s : Set α, Set.Finite s ∧ IsSupported x s :=
FreeCommRing.induction_on x ⟨∅, Set.finite_empty, isSupported_neg isSupported_one⟩
(fun p => ⟨{p}, Set.finite_singleton p, isSupported_of.2 <| Set.mem_singleton _⟩)
(fun _ _ ⟨s, hfs, hxs⟩ ⟨t, hft, hxt⟩ =>
⟨s ∪ t, hfs.union hft,
isSupported_add (isSupported_upwards hxs Set.subset_union_left)
(isSupported_upwards hxt Set.subset_union_right)⟩)
fun _ _ ⟨s, hfs, hxs⟩ ⟨t, hft, hxt⟩ =>
⟨s ∪ t, hfs.union hft,
isSupported_mul (isSupported_upwards hxs Set.subset_union_left)
(isSupported_upwards hxt Set.subset_union_right)⟩
theorem exists_finset_support (x : FreeCommRing α) : ∃ s : Finset α, IsSupported x ↑s :=
let ⟨s, hfs, hxs⟩ := exists_finite_support x
⟨hfs.toFinset, by rwa [Set.Finite.coe_toFinset]⟩
end FreeCommRing
namespace FreeRing
open Function
/-- The canonical ring homomorphism from the free ring generated by `α` to the free commutative ring
generated by `α`. -/
def toFreeCommRing {α} : FreeRing α →+* FreeCommRing α :=
FreeRing.lift FreeCommRing.of
/-- The coercion defined by the canonical ring homomorphism from the free ring generated by `α` to
the free commutative ring generated by `α`. -/
@[coe] def castFreeCommRing {α} : FreeRing α → FreeCommRing α := toFreeCommRing
instance FreeCommRing.instCoe : Coe (FreeRing α) (FreeCommRing α) :=
⟨castFreeCommRing⟩
/-- The natural map `FreeRing α → FreeCommRing α`, as a `RingHom`. -/
def coeRingHom : FreeRing α →+* FreeCommRing α :=
toFreeCommRing
@[simp, norm_cast]
protected theorem coe_zero : ↑(0 : FreeRing α) = (0 : FreeCommRing α) := rfl
@[simp, norm_cast]
protected theorem coe_one : ↑(1 : FreeRing α) = (1 : FreeCommRing α) := rfl
variable {α}
@[simp]
protected theorem coe_of (a : α) : ↑(FreeRing.of a) = FreeCommRing.of a :=
FreeRing.lift_of _ _
@[simp, norm_cast]
protected theorem coe_neg (x : FreeRing α) : ↑(-x) = -(x : FreeCommRing α) := by
rw [castFreeCommRing, map_neg]
@[simp, norm_cast]
protected theorem coe_add (x y : FreeRing α) : ↑(x + y) = (x : FreeCommRing α) + y :=
(FreeRing.lift _).map_add _ _
@[simp, norm_cast]
protected theorem coe_sub (x y : FreeRing α) : ↑(x - y) = (x : FreeCommRing α) - y := by
rw [castFreeCommRing, map_sub]
@[simp, norm_cast]
protected theorem coe_mul (x y : FreeRing α) : ↑(x * y) = (x : FreeCommRing α) * y :=
(FreeRing.lift _).map_mul _ _
variable (α)
protected theorem coe_surjective : Surjective ((↑) : FreeRing α → FreeCommRing α) := fun x => by
induction x with
| neg_one => use -1; rfl
| of b => exact ⟨FreeRing.of b, rfl⟩
| add _ _ hx hy =>
rcases hx with ⟨x, rfl⟩; rcases hy with ⟨y, rfl⟩
exact ⟨x + y, (FreeRing.lift _).map_add _ _⟩
| mul _ _ hx hy =>
rcases hx with ⟨x, rfl⟩; rcases hy with ⟨y, rfl⟩
exact ⟨x * y, (FreeRing.lift _).map_mul _ _⟩
theorem coe_eq : ((↑) : FreeRing α → FreeCommRing α) =
@Functor.map FreeAbelianGroup _ _ _ fun l : List α => (l : Multiset α) := by
funext x
dsimp [castFreeCommRing, toFreeCommRing, FreeRing.lift, FreeRing, FreeAbelianGroup.liftMonoid_coe,
Functor.map]
rw [← AddMonoidHom.coe_coe]
apply FreeAbelianGroup.lift_unique; intro L
simp only [AddMonoidHom.coe_coe, comp_apply, FreeAbelianGroup.lift_apply_of]
exact
FreeMonoid.recOn L rfl fun hd tl ih => by
rw [(FreeMonoid.lift _).map_mul, FreeMonoid.lift_eval_of, ih]
conv_lhs => reduce
rfl
/-- If α has size at most 1 then the natural map from the free ring on `α` to the
free commutative ring on `α` is an isomorphism of rings. -/
def subsingletonEquivFreeCommRing [Subsingleton α] : FreeRing α ≃+* FreeCommRing α :=
RingEquiv.ofBijective (coeRingHom _) (by
have : (coeRingHom _ : FreeRing α → FreeCommRing α) =
Functor.mapEquiv FreeAbelianGroup (Multiset.subsingletonEquiv α) :=
coe_eq α
rw [this]
apply Equiv.bijective)
instance instCommRing [Subsingleton α] : CommRing (FreeRing α) :=
{ inferInstanceAs (Ring (FreeRing α)) with
mul_comm := fun x y => by
rw [← (subsingletonEquivFreeCommRing α).symm_apply_apply (y * x),
(subsingletonEquivFreeCommRing α).map_mul, mul_comm,
← (subsingletonEquivFreeCommRing α).map_mul,
(subsingletonEquivFreeCommRing α).symm_apply_apply] }
end FreeRing
/-- The free commutative ring on `α` is isomorphic to the polynomial ring over ℤ with
variables in `α` -/
def freeCommRingEquivMvPolynomialInt : FreeCommRing α ≃+* MvPolynomial α ℤ :=
RingEquiv.ofHomInv (FreeCommRing.lift <| (fun a => MvPolynomial.X a : α → MvPolynomial α ℤ))
(MvPolynomial.eval₂Hom (Int.castRingHom (FreeCommRing α)) FreeCommRing.of)
(by ext; simp) (by ext <;> simp)
/-- The free commutative ring on the empty type is isomorphic to `ℤ`. -/
def freeCommRingPemptyEquivInt : FreeCommRing PEmpty.{u + 1} ≃+* ℤ :=
RingEquiv.trans (freeCommRingEquivMvPolynomialInt _) (MvPolynomial.isEmptyRingEquiv _ PEmpty)
/-- The free commutative ring on a type with one term is isomorphic to `ℤ[X]`. -/
def freeCommRingPunitEquivPolynomialInt : FreeCommRing PUnit.{u + 1} ≃+* ℤ[X] :=
(freeCommRingEquivMvPolynomialInt _).trans (MvPolynomial.pUnitAlgEquiv ℤ).toRingEquiv
open FreeRing
/-- The free ring on the empty type is isomorphic to `ℤ`. -/
def freeRingPemptyEquivInt : FreeRing PEmpty.{u + 1} ≃+* ℤ :=
RingEquiv.trans (subsingletonEquivFreeCommRing _) freeCommRingPemptyEquivInt
/-- The free ring on a type with one term is isomorphic to `ℤ[X]`. -/
def freeRingPunitEquivPolynomialInt : FreeRing PUnit.{u + 1} ≃+* ℤ[X] :=
RingEquiv.trans (subsingletonEquivFreeCommRing _) freeCommRingPunitEquivPolynomialInt |
.lake/packages/mathlib/Mathlib/RingTheory/PowerBasis.lean | import Mathlib.FieldTheory.Minpoly.Field
import Mathlib.LinearAlgebra.SModEq.Basic
import Mathlib.RingTheory.Ideal.BigOperators
/-!
# Power basis
This file defines a structure `PowerBasis R S`, giving a basis of the
`R`-algebra `S` as a finite list of powers `1, x, ..., x^n`.
For example, if `x` is algebraic over a ring/field, adjoining `x`
gives a `PowerBasis` structure generated by `x`.
## Definitions
* `PowerBasis R A`: a structure containing an `x` and an `n` such that
`1, x, ..., x^n` is a basis for the `R`-algebra `A` (viewed as an `R`-module).
* `finrank (hf : f ≠ 0) : Module.finrank K (AdjoinRoot f) = f.natDegree`,
the dimension of `AdjoinRoot f` equals the degree of `f`
* `PowerBasis.lift (pb : PowerBasis R S)`: if `y : S'` satisfies the same
equations as `pb.gen`, this is the map `S →ₐ[R] S'` sending `pb.gen` to `y`
* `PowerBasis.equiv`: if two power bases satisfy the same equations, they are
equivalent as algebras
## Implementation notes
Throughout this file, `R`, `S`, `A`, `B` ... are `CommRing`s, and `K`, `L`, ... are `Field`s.
`S` is an `R`-algebra, `B` is an `A`-algebra, `L` is a `K`-algebra.
## Tags
power basis, powerbasis
-/
open Finsupp Module Polynomial
variable {R S T : Type*} [CommRing R] [Ring S] [Algebra R S]
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
variable {K : Type*} [Field K]
/-- `pb : PowerBasis R S` states that `1, pb.gen, ..., pb.gen ^ (pb.dim - 1)`
is a basis for the `R`-algebra `S` (viewed as `R`-module).
This is a structure, not a class, since the same algebra can have many power bases.
For the common case where `S` is defined by adjoining an integral element to `R`,
the canonical power basis is given by `{Algebra,IntermediateField}.adjoin.powerBasis`.
-/
structure PowerBasis (R S : Type*) [CommRing R] [Ring S] [Algebra R S] where
gen : S
dim : ℕ
basis : Basis (Fin dim) R S
basis_eq_pow : ∀ (i), basis i = gen ^ (i : ℕ)
-- this is usually not needed because of `basis_eq_pow` but can be needed in some cases;
-- in such circumstances, add it manually using `@[simps dim gen basis]`.
initialize_simps_projections PowerBasis (-basis)
namespace PowerBasis
@[simp]
theorem coe_basis (pb : PowerBasis R S) : ⇑pb.basis = fun i : Fin pb.dim => pb.gen ^ (i : ℕ) :=
funext pb.basis_eq_pow
/-- Cannot be an instance because `PowerBasis` cannot be a class. -/
theorem finite (pb : PowerBasis R S) : Module.Finite R S := .of_basis pb.basis
/--
Construct a power basis from a basis consisting of powers of an element.
-/
protected def _root_.Module.Basis.PowerBasis {ι : Type*} [Fintype ι] (B : Basis ι R S) {x : S}
(e : ι ≃ Fin (Fintype.card ι)) (hx : ∀ i, B i = x ^ (e i : ℕ)) :
PowerBasis R S := ⟨x, Fintype.card ι, B.reindex e, fun i ↦ by simp [hx]⟩
@[simp]
theorem _root_.Module.Basis.PowerBasis_gen {ι : Type*} [Fintype ι] (B : Basis ι R S) {x : S}
(e : ι ≃ Fin (Fintype.card ι)) (hx : ∀ i, B i = x ^ (e i : ℕ)) :
(B.PowerBasis e hx).gen = x := rfl
theorem finrank [StrongRankCondition R] (pb : PowerBasis R S) :
Module.finrank R S = pb.dim := by
rw [Module.finrank_eq_card_basis pb.basis, Fintype.card_fin]
theorem mem_span_pow' {x y : S} {d : ℕ} :
y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : ℕ)) ↔
∃ f : R[X], f.degree < d ∧ y = aeval x f := by
have : (Set.range fun i : Fin d => x ^ (i : ℕ)) = (fun i : ℕ => x ^ i) '' ↑(Finset.range d) := by
ext n
simp_rw [Set.mem_range, Set.mem_image, Finset.mem_coe, Finset.mem_range]
exact ⟨fun ⟨⟨i, hi⟩, hy⟩ => ⟨i, hi, hy⟩, fun ⟨i, hi, hy⟩ => ⟨⟨i, hi⟩, hy⟩⟩
simp only [this, mem_span_image_iff_linearCombination, degree_lt_iff_coeff_zero,
exists_iff_exists_finsupp, coeff, aeval_def, eval₂_eq_sum, Polynomial.sum,
mem_supported', linearCombination, Finsupp.sum, Algebra.smul_def,
LinearMap.id_coe, id, not_lt, Finsupp.coe_lsum, LinearMap.coe_smulRight,
Finset.mem_range, Finset.mem_coe]
simp_rw [@eq_comm _ y]
exact Iff.rfl
theorem mem_span_pow {x y : S} {d : ℕ} (hd : d ≠ 0) :
y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : ℕ)) ↔
∃ f : R[X], f.natDegree < d ∧ y = aeval x f := by
rw [mem_span_pow']
constructor <;>
· rintro ⟨f, h, hy⟩
refine ⟨f, ?_, hy⟩
by_cases hf : f = 0
· simp only [hf, natDegree_zero, degree_zero] at h ⊢
first | exact lt_of_le_of_ne (Nat.zero_le d) hd.symm | exact WithBot.bot_lt_coe d
simpa [degree_eq_natDegree hf] using h
theorem dim_ne_zero [Nontrivial S] (pb : PowerBasis R S) : pb.dim ≠ 0 := fun h =>
not_nonempty_iff.mpr (h.symm ▸ Fin.isEmpty : IsEmpty (Fin pb.dim)) pb.basis.index_nonempty
theorem dim_pos [Nontrivial S] (pb : PowerBasis R S) : 0 < pb.dim :=
Nat.pos_of_ne_zero pb.dim_ne_zero
theorem exists_eq_aeval [Nontrivial S] (pb : PowerBasis R S) (y : S) :
∃ f : R[X], f.natDegree < pb.dim ∧ y = aeval pb.gen f :=
(mem_span_pow pb.dim_ne_zero).mp (by simpa using pb.basis.mem_span y)
theorem exists_eq_aeval' (pb : PowerBasis R S) (y : S) : ∃ f : R[X], y = aeval pb.gen f := by
nontriviality S
obtain ⟨f, _, hf⟩ := exists_eq_aeval pb y
exact ⟨f, hf⟩
theorem algHom_ext {S' : Type*} [Semiring S'] [Algebra R S'] (pb : PowerBasis R S)
⦃f g : S →ₐ[R] S'⦄ (h : f pb.gen = g pb.gen) : f = g := by
ext x
obtain ⟨f, rfl⟩ := pb.exists_eq_aeval' x
rw [← Polynomial.aeval_algHom_apply, ← Polynomial.aeval_algHom_apply, h]
open Ideal Finset Submodule in
theorem exists_smodEq (pb : PowerBasis A B) (b : B) :
∃ a, SModEq (Ideal.span ({pb.gen})) b (algebraMap A B a) := by
rcases subsingleton_or_nontrivial B
· exact ⟨0, by rw [SModEq, Subsingleton.eq_zero b, map_zero]⟩
refine ⟨pb.basis.repr b ⟨0, pb.dim_pos⟩, ?_⟩
have H := pb.basis.sum_repr b
rw [← insert_erase (mem_univ ⟨0, pb.dim_pos⟩), sum_insert (notMem_erase _ _)] at H
rw [SModEq, ← add_zero (algebraMap _ _ _), Quotient.mk_add]
nth_rewrite 1 [← H]
rw [Quotient.mk_add]
congr 1
· simp [Algebra.algebraMap_eq_smul_one ((pb.basis.repr b) _)]
· rw [Quotient.mk_zero, Quotient.mk_eq_zero, coe_basis]
refine sum_mem _ (fun i hi ↦ ?_)
rw [Algebra.smul_def']
refine Ideal.mul_mem_left _ _ <| Ideal.pow_mem_of_mem _ (Ideal.subset_span (by simp)) _ <|
Nat.pos_of_ne_zero <| fun h ↦ notMem_erase i univ <| Fin.eq_mk_iff_val_eq.2 h ▸ hi
open Submodule.Quotient in
theorem exists_gen_dvd_sub (pb : PowerBasis A B) (b : B) : ∃ a, pb.gen ∣ b - algebraMap A B a := by
simpa [← Ideal.mem_span_singleton, ← mk_eq_zero, mk_sub, sub_eq_zero] using pb.exists_smodEq b
section minpoly
variable [Algebra A S]
/-- `pb.minpolyGen` is the minimal polynomial for `pb.gen`. -/
noncomputable def minpolyGen (pb : PowerBasis A S) : A[X] :=
X ^ pb.dim - ∑ i : Fin pb.dim, C (pb.basis.repr (pb.gen ^ pb.dim) i) * X ^ (i : ℕ)
theorem aeval_minpolyGen (pb : PowerBasis A S) : aeval pb.gen (minpolyGen pb) = 0 := by
simp_rw [minpolyGen, map_sub, map_sum, map_mul, map_pow, aeval_C, ← Algebra.smul_def, aeval_X]
refine sub_eq_zero.mpr ((pb.basis.linearCombination_repr (pb.gen ^ pb.dim)).symm.trans ?_)
rw [Finsupp.linearCombination_apply, Finsupp.sum_fintype] <;>
simp only [pb.coe_basis, zero_smul, imp_true_iff]
theorem minpolyGen_monic (pb : PowerBasis A S) : Monic (minpolyGen pb) := by
nontriviality A
apply (monic_X_pow _).sub_of_left _
rw [degree_X_pow]
exact degree_sum_fin_lt _
theorem dim_le_natDegree_of_root (pb : PowerBasis A S) {p : A[X]} (ne_zero : p ≠ 0)
(root : aeval pb.gen p = 0) : pb.dim ≤ p.natDegree := by
refine le_of_not_gt fun hlt => ne_zero ?_
rw [p.as_sum_range' _ hlt, Finset.sum_range]
refine Fintype.sum_eq_zero _ fun i => ?_
simp_rw [aeval_eq_sum_range' hlt, Finset.sum_range, ← pb.basis_eq_pow] at root
have := Fintype.linearIndependent_iff.1 pb.basis.linearIndependent _ root
rw [this, monomial_zero_right]
theorem dim_le_degree_of_root (h : PowerBasis A S) {p : A[X]} (ne_zero : p ≠ 0)
(root : aeval h.gen p = 0) : ↑h.dim ≤ p.degree := by
rw [degree_eq_natDegree ne_zero]
exact WithBot.coe_le_coe.2 (h.dim_le_natDegree_of_root ne_zero root)
theorem degree_minpolyGen [Nontrivial A] (pb : PowerBasis A S) :
degree (minpolyGen pb) = pb.dim := by
unfold minpolyGen
rw [degree_sub_eq_left_of_degree_lt] <;> rw [degree_X_pow]
apply degree_sum_fin_lt
theorem natDegree_minpolyGen [Nontrivial A] (pb : PowerBasis A S) :
natDegree (minpolyGen pb) = pb.dim :=
natDegree_eq_of_degree_eq_some pb.degree_minpolyGen
@[simp]
theorem minpolyGen_eq (pb : PowerBasis A S) : pb.minpolyGen = minpoly A pb.gen := by
nontriviality A
refine minpoly.unique' A _ pb.minpolyGen_monic pb.aeval_minpolyGen fun q hq =>
or_iff_not_imp_left.2 fun hn0 h0 => ?_
exact (pb.dim_le_degree_of_root hn0 h0).not_gt (pb.degree_minpolyGen ▸ hq)
theorem isIntegral_gen (pb : PowerBasis A S) : IsIntegral A pb.gen :=
⟨minpolyGen pb, minpolyGen_monic pb, aeval_minpolyGen pb⟩
@[simp]
theorem degree_minpoly [Nontrivial A] (pb : PowerBasis A S) :
degree (minpoly A pb.gen) = pb.dim := by rw [← minpolyGen_eq, degree_minpolyGen]
@[simp]
theorem natDegree_minpoly [Nontrivial A] (pb : PowerBasis A S) :
(minpoly A pb.gen).natDegree = pb.dim := by rw [← minpolyGen_eq, natDegree_minpolyGen]
protected theorem leftMulMatrix (pb : PowerBasis A S) : Algebra.leftMulMatrix pb.basis pb.gen =
@Matrix.of (Fin pb.dim) (Fin pb.dim) _ fun i j =>
if ↑j + 1 = pb.dim then -pb.minpolyGen.coeff ↑i else if (i : ℕ) = j + 1 then 1 else 0 := by
cases subsingleton_or_nontrivial A; · subsingleton
rw [Algebra.leftMulMatrix_apply, ← LinearEquiv.eq_symm_apply, LinearMap.toMatrix_symm]
refine pb.basis.ext fun k => ?_
simp_rw [Matrix.toLin_self, Matrix.of_apply, pb.basis_eq_pow]
apply (pow_succ' _ _).symm.trans
split_ifs with h
· simp_rw [h, neg_smul, Finset.sum_neg_distrib, eq_neg_iff_add_eq_zero]
convert pb.aeval_minpolyGen
rw [add_comm, aeval_eq_sum_range, Finset.sum_range_succ, ← leadingCoeff,
pb.minpolyGen_monic.leadingCoeff, one_smul, natDegree_minpolyGen, Finset.sum_range]
· rw [Fintype.sum_eq_single (⟨(k : ℕ) + 1, lt_of_le_of_ne k.2 h⟩ : Fin pb.dim), if_pos, one_smul]
· rfl
intro x hx
rw [if_neg, zero_smul]
apply mt Fin.ext hx
end minpoly
section Equiv
variable [Algebra A S] {S' : Type*} [Ring S'] [Algebra A S']
theorem constr_pow_aeval (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0)
(f : A[X]) : pb.basis.constr A (fun i => y ^ (i : ℕ)) (aeval pb.gen f) = aeval y f := by
cases subsingleton_or_nontrivial A
· rw [(Subsingleton.elim _ _ : f = 0), aeval_zero, map_zero, aeval_zero]
rw [← aeval_modByMonic_eq_self_of_root (minpoly.monic pb.isIntegral_gen) (minpoly.aeval _ _), ←
@aeval_modByMonic_eq_self_of_root _ _ _ _ _ f _ (minpoly.monic pb.isIntegral_gen) y hy]
by_cases hf : f %ₘ minpoly A pb.gen = 0
· simp only [hf, map_zero]
have : (f %ₘ minpoly A pb.gen).natDegree < pb.dim := by
rw [← pb.natDegree_minpoly]
apply natDegree_lt_natDegree hf
exact degree_modByMonic_lt _ (minpoly.monic pb.isIntegral_gen)
rw [aeval_eq_sum_range' this, aeval_eq_sum_range' this, map_sum]
refine Finset.sum_congr rfl fun i (hi : i ∈ Finset.range pb.dim) => ?_
rw [Finset.mem_range] at hi
rw [LinearMap.map_smul]
congr
rw [← Fin.val_mk hi, ← pb.basis_eq_pow ⟨i, hi⟩, Basis.constr_basis]
theorem constr_pow_gen (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0) :
pb.basis.constr A (fun i => y ^ (i : ℕ)) pb.gen = y := by
convert pb.constr_pow_aeval hy X <;> rw [aeval_X]
theorem constr_pow_algebraMap (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0)
(x : A) : pb.basis.constr A (fun i => y ^ (i : ℕ)) (algebraMap A S x) = algebraMap A S' x := by
convert pb.constr_pow_aeval hy (C x) <;> rw [aeval_C]
theorem constr_pow_mul (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0)
(x x' : S) : pb.basis.constr A (fun i => y ^ (i : ℕ)) (x * x') =
pb.basis.constr A (fun i => y ^ (i : ℕ)) x * pb.basis.constr A (fun i => y ^ (i : ℕ)) x' := by
obtain ⟨f, rfl⟩ := pb.exists_eq_aeval' x
obtain ⟨g, rfl⟩ := pb.exists_eq_aeval' x'
simp only [← aeval_mul, pb.constr_pow_aeval hy]
/-- `pb.lift y hy` is the algebra map sending `pb.gen` to `y`,
where `hy` states the higher powers of `y` are the same as the higher powers of `pb.gen`.
See `PowerBasis.liftEquiv` for a bundled equiv sending `⟨y, hy⟩` to the algebra map.
-/
noncomputable def lift (pb : PowerBasis A S) (y : S') (hy : aeval y (minpoly A pb.gen) = 0) :
S →ₐ[A] S' :=
{ pb.basis.constr A fun i => y ^ (i : ℕ) with
map_one' := by convert pb.constr_pow_algebraMap hy 1 using 2 <;> rw [RingHom.map_one]
map_zero' := by convert pb.constr_pow_algebraMap hy 0 using 2 <;> rw [RingHom.map_zero]
map_mul' := pb.constr_pow_mul hy
commutes' := pb.constr_pow_algebraMap hy }
@[simp]
theorem lift_gen (pb : PowerBasis A S) (y : S') (hy : aeval y (minpoly A pb.gen) = 0) :
pb.lift y hy pb.gen = y :=
pb.constr_pow_gen hy
@[simp]
theorem lift_aeval (pb : PowerBasis A S) (y : S') (hy : aeval y (minpoly A pb.gen) = 0) (f : A[X]) :
pb.lift y hy (aeval pb.gen f) = aeval y f :=
pb.constr_pow_aeval hy f
/-- `pb.liftEquiv` states that roots of the minimal polynomial of `pb.gen` correspond to
maps sending `pb.gen` to that root.
This is the bundled equiv version of `PowerBasis.lift`.
If the codomain of the `AlgHom`s is an integral domain, then the roots form a multiset,
see `liftEquiv'` for the corresponding statement.
-/
@[simps]
noncomputable def liftEquiv (pb : PowerBasis A S) :
(S →ₐ[A] S') ≃ { y : S' // aeval y (minpoly A pb.gen) = 0 } where
toFun f := ⟨f pb.gen, by rw [aeval_algHom_apply, minpoly.aeval, map_zero]⟩
invFun y := pb.lift y y.2
left_inv _ := pb.algHom_ext <| lift_gen _ _ _
right_inv y := Subtype.ext <| lift_gen _ _ y.prop
/-- `pb.liftEquiv'` states that elements of the root set of the minimal
polynomial of `pb.gen` correspond to maps sending `pb.gen` to that root. -/
@[simps! -fullyApplied]
noncomputable def liftEquiv' [IsDomain B] (pb : PowerBasis A S) :
(S →ₐ[A] B) ≃ { y : B // y ∈ (minpoly A pb.gen).aroots B } :=
pb.liftEquiv.trans ((Equiv.refl _).subtypeEquiv fun x => by
rw [Equiv.refl_apply, mem_roots_iff_aeval_eq_zero]
· simp
· exact map_monic_ne_zero (minpoly.monic pb.isIntegral_gen))
/-- There are finitely many algebra homomorphisms `S →ₐ[A] B` if `S` is of the form `A[x]`
and `B` is an integral domain. -/
noncomputable def AlgHom.fintype [IsDomain B] (pb : PowerBasis A S) : Fintype (S →ₐ[A] B) :=
letI := Classical.decEq B
Fintype.ofEquiv _ pb.liftEquiv'.symm
/-- `pb.equivOfRoot pb' h₁ h₂` is an equivalence of algebras with the same power basis,
where "the same" means that `pb` is a root of `pb'`s minimal polynomial and vice versa.
See also `PowerBasis.equivOfMinpoly` which takes the hypothesis that the
minimal polynomials are identical.
-/
@[simps! -isSimp apply]
noncomputable def equivOfRoot (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h₁ : aeval pb.gen (minpoly A pb'.gen) = 0) (h₂ : aeval pb'.gen (minpoly A pb.gen) = 0) :
S ≃ₐ[A] S' :=
AlgEquiv.ofAlgHom (pb.lift pb'.gen h₂) (pb'.lift pb.gen h₁)
(by
ext x
obtain ⟨f, hf, rfl⟩ := pb'.exists_eq_aeval' x
simp)
(by
ext x
obtain ⟨f, hf, rfl⟩ := pb.exists_eq_aeval' x
simp)
@[simp]
theorem equivOfRoot_aeval (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h₁ : aeval pb.gen (minpoly A pb'.gen) = 0) (h₂ : aeval pb'.gen (minpoly A pb.gen) = 0)
(f : A[X]) : pb.equivOfRoot pb' h₁ h₂ (aeval pb.gen f) = aeval pb'.gen f :=
pb.lift_aeval _ h₂ _
@[simp]
theorem equivOfRoot_gen (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h₁ : aeval pb.gen (minpoly A pb'.gen) = 0) (h₂ : aeval pb'.gen (minpoly A pb.gen) = 0) :
pb.equivOfRoot pb' h₁ h₂ pb.gen = pb'.gen :=
pb.lift_gen _ h₂
@[simp]
theorem equivOfRoot_symm (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h₁ : aeval pb.gen (minpoly A pb'.gen) = 0) (h₂ : aeval pb'.gen (minpoly A pb.gen) = 0) :
(pb.equivOfRoot pb' h₁ h₂).symm = pb'.equivOfRoot pb h₂ h₁ :=
rfl
/-- `pb.equivOfMinpoly pb' h` is an equivalence of algebras with the same power basis,
where "the same" means that they have identical minimal polynomials.
See also `PowerBasis.equivOfRoot` which takes the hypothesis that each generator is a root of the
other basis' minimal polynomial; `PowerBasis.equivOfRoot` is more general if `A` is not a field.
-/
@[simps! -isSimp apply]
noncomputable def equivOfMinpoly (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h : minpoly A pb.gen = minpoly A pb'.gen) : S ≃ₐ[A] S' :=
pb.equivOfRoot pb' (h ▸ minpoly.aeval _ _) (h.symm ▸ minpoly.aeval _ _)
@[simp]
theorem equivOfMinpoly_aeval (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h : minpoly A pb.gen = minpoly A pb'.gen) (f : A[X]) :
pb.equivOfMinpoly pb' h (aeval pb.gen f) = aeval pb'.gen f :=
pb.equivOfRoot_aeval pb' _ _ _
@[simp]
theorem equivOfMinpoly_gen (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h : minpoly A pb.gen = minpoly A pb'.gen) : pb.equivOfMinpoly pb' h pb.gen = pb'.gen :=
pb.equivOfRoot_gen pb' _ _
@[simp]
theorem equivOfMinpoly_symm (pb : PowerBasis A S) (pb' : PowerBasis A S')
(h : minpoly A pb.gen = minpoly A pb'.gen) :
(pb.equivOfMinpoly pb' h).symm = pb'.equivOfMinpoly pb h.symm :=
rfl
end Equiv
end PowerBasis
open PowerBasis
/-- Useful lemma to show `x` generates a power basis:
the powers of `x` less than the degree of `x`'s minimal polynomial are linearly independent. -/
theorem linearIndependent_pow [Algebra K S] (x : S) :
LinearIndependent K fun i : Fin (minpoly K x).natDegree => x ^ (i : ℕ) := by
by_cases h : IsIntegral K x; swap
· rw [minpoly.eq_zero h, natDegree_zero]
exact linearIndependent_empty_type
refine Fintype.linearIndependent_iff.2 fun g hg i => ?_
simp only at hg
simp_rw [Algebra.smul_def, ← aeval_monomial, ← map_sum] at hg
apply (fun hn0 => (minpoly.degree_le_of_ne_zero K x (mt (fun h0 => ?_) hn0) hg).not_gt).mtr
· simp_rw [← C_mul_X_pow_eq_monomial]
exact (degree_eq_natDegree <| minpoly.ne_zero h).symm ▸ degree_sum_fin_lt _
· apply_fun lcoeff K i at h0
simp_rw [map_sum, lcoeff_apply, coeff_monomial, Fin.val_eq_val, Finset.sum_ite_eq'] at h0
exact (if_pos <| Finset.mem_univ _).symm.trans h0
theorem IsIntegral.mem_span_pow [Nontrivial R] {x y : S} (hx : IsIntegral R x)
(hy : ∃ f : R[X], y = aeval x f) :
y ∈ Submodule.span R (Set.range fun i : Fin (minpoly R x).natDegree => x ^ (i : ℕ)) := by
obtain ⟨f, rfl⟩ := hy
apply mem_span_pow'.mpr _
have := minpoly.monic hx
refine ⟨f %ₘ minpoly R x, (degree_modByMonic_lt _ this).trans_le degree_le_natDegree, ?_⟩
conv_lhs => rw [← modByMonic_add_div f this]
simp only [add_zero, zero_mul, minpoly.aeval, aeval_add, map_mul]
namespace PowerBasis
section Map
variable {S' : Type*} [CommRing S'] [Algebra R S']
/-- `PowerBasis.map pb (e : S ≃ₐ[R] S')` is the power basis for `S'` generated by `e pb.gen`. -/
@[simps dim gen basis]
noncomputable def map (pb : PowerBasis R S) (e : S ≃ₐ[R] S') : PowerBasis R S' where
dim := pb.dim
basis := pb.basis.map e.toLinearEquiv
gen := e pb.gen
basis_eq_pow i := by rw [Basis.map_apply, pb.basis_eq_pow, e.toLinearEquiv_apply, map_pow]
variable [Algebra A S] [Algebra A S']
theorem minpolyGen_map (pb : PowerBasis A S) (e : S ≃ₐ[A] S') :
(pb.map e).minpolyGen = pb.minpolyGen := by
simp
@[simp]
theorem equivOfRoot_map (pb : PowerBasis A S) (e : S ≃ₐ[A] S') (h₁ h₂) :
pb.equivOfRoot (pb.map e) h₁ h₂ = e := by
ext x
obtain ⟨f, rfl⟩ := pb.exists_eq_aeval' x
simp [aeval_algEquiv]
@[simp]
theorem equivOfMinpoly_map (pb : PowerBasis A S) (e : S ≃ₐ[A] S')
(h : minpoly A pb.gen = minpoly A (pb.map e).gen) : pb.equivOfMinpoly (pb.map e) h = e :=
pb.equivOfRoot_map _ _ _
end Map
section Adjoin
open Algebra
theorem adjoin_gen_eq_top (B : PowerBasis R S) : adjoin R ({B.gen} : Set S) = ⊤ := by
rw [← toSubmodule_eq_top, _root_.eq_top_iff, ← B.basis.span_eq, Submodule.span_le]
rintro x ⟨i, rfl⟩
rw [B.basis_eq_pow i]
exact Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton _)) _
theorem adjoin_eq_top_of_gen_mem_adjoin {B : PowerBasis R S} {x : S}
(hx : B.gen ∈ adjoin R ({x} : Set S)) : adjoin R ({x} : Set S) = ⊤ := by
rw [_root_.eq_top_iff, ← B.adjoin_gen_eq_top]
refine adjoin_le ?_
simp [hx]
end Adjoin
end PowerBasis |
.lake/packages/mathlib/Mathlib/RingTheory/FiniteType.lean | import Mathlib.Algebra.FreeAlgebra
import Mathlib.RingTheory.Adjoin.Polynomial
import Mathlib.RingTheory.Adjoin.Tower
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Noetherian.Orzech
/-!
# Finiteness conditions in commutative algebra
In this file we define a notion of finiteness that is common in commutative algebra.
## Main declarations
- `Algebra.FiniteType`, `RingHom.FiniteType`, `AlgHom.FiniteType`
all of these express that some object is finitely generated *as algebra* over some base ring.
-/
open Function (Surjective)
open Polynomial
section ModuleAndAlgebra
universe uR uS uA uB uM uN
variable (R : Type uR) (S : Type uS) (A : Type uA) (B : Type uB) (M : Type uM) (N : Type uN)
/-- An algebra over a commutative semiring is of `FiniteType` if it is finitely generated
over the base ring as algebra. -/
class Algebra.FiniteType [CommSemiring R] [Semiring A] [Algebra R A] : Prop where
out : (⊤ : Subalgebra R A).FG
namespace Module
variable [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
namespace Finite
open Submodule Set
variable {R S M N}
section Algebra
-- see Note [lower instance priority]
instance (priority := 100) finiteType {R : Type*} (A : Type*) [CommSemiring R] [Semiring A]
[Algebra R A] [hRA : Module.Finite R A] : Algebra.FiniteType R A :=
⟨Subalgebra.fg_of_submodule_fg hRA.1⟩
end Algebra
end Finite
end Module
namespace Algebra
variable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]
variable [Algebra R S] [Algebra R A] [Algebra R B]
variable [AddCommMonoid M] [Module R M]
variable [AddCommMonoid N] [Module R N]
namespace FiniteType
@[deprecated inferInstance (since := "2025-07-12")]
theorem self : FiniteType R R := inferInstance
theorem of_restrictScalars_finiteType [Algebra S A] [IsScalarTower R S A] [hA : FiniteType R A] :
FiniteType S A := by
obtain ⟨s, hS⟩ := hA.out
refine ⟨⟨s, eq_top_iff.2 fun b => ?_⟩⟩
have le : adjoin R (s : Set A) ≤ Subalgebra.restrictScalars R (adjoin S s) := by
apply (Algebra.adjoin_le _ : adjoin R (s : Set A) ≤ Subalgebra.restrictScalars R (adjoin S ↑s))
simp only [Subalgebra.coe_restrictScalars]
exact Algebra.subset_adjoin
exact le (eq_top_iff.1 hS b)
variable {R S A B}
theorem of_surjective [FiniteType R A] (f : A →ₐ[R] B) (hf : Surjective f) : FiniteType R B :=
⟨by
convert ‹FiniteType R A›.1.map f
simpa only [map_top f, @eq_comm _ ⊤, eq_top_iff, AlgHom.mem_range] using hf⟩
theorem equiv (hRA : FiniteType R A) (e : A ≃ₐ[R] B) : FiniteType R B :=
hRA.of_surjective e e.surjective
theorem trans [Algebra S A] [IsScalarTower R S A] (hRS : FiniteType R S) (hSA : FiniteType S A) :
FiniteType R A :=
⟨fg_trans' hRS.1 hSA.1⟩
instance quotient (R : Type*) {S : Type*} [CommSemiring R] [CommRing S] [Algebra R S] (I : Ideal S)
[h : Algebra.FiniteType R S] : Algebra.FiniteType R (S ⧸ I) :=
Algebra.FiniteType.trans h inferInstance
instance [FiniteType R S] : FiniteType R S[X] := by
refine .trans ‹_› ⟨{Polynomial.X}, ?_⟩
rw [Finset.coe_singleton]
exact Polynomial.adjoin_X
@[deprecated inferInstance (since := "2025-07-12")]
protected theorem polynomial : FiniteType R R[X] := inferInstance
instance {ι : Type*} [Finite ι] [FiniteType R S] : FiniteType R (MvPolynomial ι S) := by
classical
cases nonempty_fintype ι
refine .trans ‹_› ⟨Finset.univ.image MvPolynomial.X, ?_⟩
rw [Finset.coe_image, Finset.coe_univ, Set.image_univ]
exact MvPolynomial.adjoin_range_X
@[deprecated inferInstance (since := "2025-07-12")]
protected theorem mvPolynomial (ι : Type*) [Finite ι] : FiniteType R (MvPolynomial ι R) :=
inferInstance
instance {ι : Type*} [Finite ι] [FiniteType R S] : FiniteType R (FreeAlgebra S ι) := by
classical
cases nonempty_fintype ι
refine .trans ‹_› ⟨Finset.univ.image (FreeAlgebra.ι _), ?_⟩
rw [Finset.coe_image, Finset.coe_univ, Set.image_univ]
exact FreeAlgebra.adjoin_range_ι ..
@[deprecated inferInstance (since := "2025-07-12")]
protected theorem freeAlgebra (ι : Type*) [Finite ι] : FiniteType R (FreeAlgebra R ι) :=
inferInstance
/-- An algebra is finitely generated if and only if it is a quotient
of a free algebra whose variables are indexed by a finset. -/
theorem iff_quotient_freeAlgebra :
FiniteType R A ↔
∃ (s : Finset A) (f : FreeAlgebra R s →ₐ[R] A), Surjective f := by
constructor
· rintro ⟨s, hs⟩
refine ⟨s, FreeAlgebra.lift _ (↑), ?_⟩
rw [← Set.range_eq_univ, ← AlgHom.coe_range, ← adjoin_range_eq_range_freeAlgebra_lift,
Subtype.range_coe_subtype, Finset.setOf_mem, hs, coe_top]
· rintro ⟨s, f, hsur⟩
exact .of_surjective f hsur
/-- A commutative algebra is finitely generated if and only if it is a quotient
of a polynomial ring whose variables are indexed by a finset. -/
theorem iff_quotient_mvPolynomial :
FiniteType R S ↔
∃ (s : Finset S) (f : MvPolynomial { x // x ∈ s } R →ₐ[R] S), Surjective f := by
constructor
· rintro ⟨s, hs⟩
use s, MvPolynomial.aeval (↑)
intro x
have hrw : (↑s : Set S) = fun x : S => x ∈ s.val := rfl
rw [← Set.mem_range, ← AlgHom.coe_range, ← adjoin_eq_range]
simp_rw [← hrw, hs]
exact Set.mem_univ x
· rintro ⟨s, f, hsur⟩
exact .of_surjective f hsur
/-- An algebra is finitely generated if and only if it is a quotient
of a polynomial ring whose variables are indexed by a fintype. -/
theorem iff_quotient_freeAlgebra' : FiniteType R A ↔
∃ (ι : Type uA) (_ : Fintype ι) (f : FreeAlgebra R ι →ₐ[R] A), Surjective f := by
constructor
· rw [iff_quotient_freeAlgebra]
rintro ⟨s, f, hsur⟩
use { x : A // x ∈ s }, inferInstance, f
· rintro ⟨ι, hfintype, f, hsur⟩
letI : Fintype ι := hfintype
exact .of_surjective f hsur
/-- A commutative algebra is finitely generated if and only if it is a quotient
of a polynomial ring whose variables are indexed by a fintype. -/
theorem iff_quotient_mvPolynomial' : FiniteType R S ↔
∃ (ι : Type uS) (_ : Fintype ι) (f : MvPolynomial ι R →ₐ[R] S), Surjective f := by
constructor
· rw [iff_quotient_mvPolynomial]
rintro ⟨s, f, hsur⟩
use { x : S // x ∈ s }, inferInstance, f
· rintro ⟨ι, hfintype, f, hsur⟩
letI : Fintype ι := hfintype
exact .of_surjective f hsur
/-- A commutative algebra is finitely generated if and only if it is a quotient of a polynomial ring
in `n` variables. -/
theorem iff_quotient_mvPolynomial'' :
FiniteType R S ↔ ∃ (n : ℕ) (f : MvPolynomial (Fin n) R →ₐ[R] S), Surjective f := by
constructor
· rw [iff_quotient_mvPolynomial']
rintro ⟨ι, hfintype, f, hsur⟩
have equiv := MvPolynomial.renameEquiv R (Fintype.equivFin ι)
exact ⟨Fintype.card ι, AlgHom.comp f equiv.symm.toAlgHom, by simpa using hsur⟩
· rintro ⟨n, f, hsur⟩
exact .of_surjective f hsur
instance prod [hA : FiniteType R A] [hB : FiniteType R B] : FiniteType R (A × B) :=
⟨by rw [← Subalgebra.prod_top]; exact hA.1.prod hB.1⟩
theorem isNoetherianRing (R S : Type*) [CommRing R] [CommRing S] [Algebra R S]
[h : Algebra.FiniteType R S] [IsNoetherianRing R] : IsNoetherianRing S := by
obtain ⟨s, hs⟩ := h.1
apply
isNoetherianRing_of_surjective (MvPolynomial s R) S
(MvPolynomial.aeval (↑) : MvPolynomial s R →ₐ[R] S).toRingHom
rw [← Set.range_eq_univ, AlgHom.toRingHom_eq_coe, RingHom.coe_coe, ← AlgHom.coe_range,
← Algebra.adjoin_range_eq_range_aeval, Subtype.range_coe_subtype, Finset.setOf_mem, hs]
rfl
theorem _root_.Subalgebra.fg_iff_finiteType (S : Subalgebra R A) : S.FG ↔ Algebra.FiniteType R S :=
S.fg_top.symm.trans ⟨fun h => ⟨h⟩, fun h => h.out⟩
lemma adjoin_of_finite {A : Type*} [CommSemiring A] [Algebra R A] {t : Set A} (h : Set.Finite t) :
FiniteType R (Algebra.adjoin R t) := by
rw [← Subalgebra.fg_iff_finiteType]
exact ⟨h.toFinset, by simp⟩
end FiniteType
end Algebra
end ModuleAndAlgebra
namespace RingHom
variable {A B C : Type*} [CommRing A] [CommRing B] [CommRing C]
/-- A ring morphism `A →+* B` is of `FiniteType` if `B` is finitely generated as `A`-algebra. -/
@[algebraize]
def FiniteType (f : A →+* B) : Prop :=
@Algebra.FiniteType A B _ _ f.toAlgebra
lemma finiteType_algebraMap [Algebra A B] :
(algebraMap A B).FiniteType ↔ Algebra.FiniteType A B := by
rw [FiniteType, toAlgebra_algebraMap]
namespace Finite
theorem finiteType {f : A →+* B} (hf : f.Finite) : FiniteType f :=
@Module.Finite.finiteType _ _ _ _ f.toAlgebra hf
end Finite
namespace FiniteType
variable (A) in
theorem id : FiniteType (RingHom.id A) := by simp [FiniteType]; infer_instance
theorem comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.FiniteType) (hg : Surjective g) :
(g.comp f).FiniteType := by
algebraize_only [f, g.comp f]
exact ‹Algebra.FiniteType _ _›.of_surjective
{ g with
toFun := g
commutes' := fun a => rfl }
hg
theorem of_surjective (f : A →+* B) (hf : Surjective f) : f.FiniteType := by
rw [← f.comp_id]
exact (id A).comp_surjective hf
theorem comp {g : B →+* C} {f : A →+* B} (hg : g.FiniteType) (hf : f.FiniteType) :
(g.comp f).FiniteType := by
algebraize_only [f, g, g.comp f]
exact Algebra.FiniteType.trans hf hg
theorem of_finite {f : A →+* B} (hf : f.Finite) : f.FiniteType :=
@Module.Finite.finiteType _ _ _ _ f.toAlgebra hf
alias _root_.RingHom.Finite.to_finiteType := of_finite
theorem of_comp_finiteType {f : A →+* B} {g : B →+* C} (h : (g.comp f).FiniteType) :
g.FiniteType := by
algebraize [f, g, g.comp f]
exact Algebra.FiniteType.of_restrictScalars_finiteType A B C
end FiniteType
end RingHom
namespace AlgHom
variable {R A B C : Type*} [CommRing R]
variable [CommRing A] [CommRing B] [CommRing C]
variable [Algebra R A] [Algebra R B] [Algebra R C]
/-- An algebra morphism `A →ₐ[R] B` is of `FiniteType` if it is of finite type as ring morphism.
In other words, if `B` is finitely generated as `A`-algebra. -/
def FiniteType (f : A →ₐ[R] B) : Prop :=
f.toRingHom.FiniteType
namespace Finite
theorem finiteType {f : A →ₐ[R] B} (hf : f.Finite) : FiniteType f :=
RingHom.Finite.finiteType hf
end Finite
namespace FiniteType
variable (R A)
theorem id : FiniteType (AlgHom.id R A) :=
RingHom.FiniteType.id A
variable {R A}
theorem comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.FiniteType) (hf : f.FiniteType) :
(g.comp f).FiniteType :=
RingHom.FiniteType.comp hg hf
theorem comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.FiniteType) (hg : Surjective g) :
(g.comp f).FiniteType :=
RingHom.FiniteType.comp_surjective hf hg
theorem of_surjective (f : A →ₐ[R] B) (hf : Surjective f) : f.FiniteType :=
RingHom.FiniteType.of_surjective f.toRingHom hf
theorem of_comp_finiteType {f : A →ₐ[R] B} {g : B →ₐ[R] C} (h : (g.comp f).FiniteType) :
g.FiniteType :=
RingHom.FiniteType.of_comp_finiteType h
end FiniteType
end AlgHom
@[deprecated (since := "2025-08-12")] alias algebraMap_finiteType_iff_algebra_finiteType :=
RingHom.finiteType_algebraMap
section MonoidAlgebra
variable {R : Type*} {M : Type*}
namespace AddMonoidAlgebra
open Algebra AddSubmonoid Submodule
section Span
section Semiring
variable [CommSemiring R] [AddMonoid M]
/-- An element of `R[M]` is in the subalgebra generated by its support. -/
theorem mem_adjoin_support (f : R[M]) : f ∈ adjoin R (of' R M '' f.support) := by
suffices span R (of' R M '' f.support) ≤
Subalgebra.toSubmodule (adjoin R (of' R M '' f.support)) by
exact this (mem_span_support f)
rw [Submodule.span_le]
exact subset_adjoin
/-- If a set `S` generates, as algebra, `R[M]`, then the set of supports of
elements of `S` generates `R[M]`. -/
theorem support_gen_of_gen {S : Set R[M]} (hS : Algebra.adjoin R S = ⊤) :
Algebra.adjoin R (⋃ f ∈ S, of' R M '' (f.support : Set M)) = ⊤ := by
refine le_antisymm le_top ?_
rw [← hS, adjoin_le_iff]
intro f hf
have hincl :
of' R M '' f.support ⊆ ⋃ (g : R[M]) (_ : g ∈ S), of' R M '' g.support := by
intro s hs
exact Set.mem_iUnion₂.2 ⟨f, ⟨hf, hs⟩⟩
exact adjoin_mono hincl (mem_adjoin_support f)
/-- If a set `S` generates, as algebra, `R[M]`, then the image of the union of
the supports of elements of `S` generates `R[M]`. -/
theorem support_gen_of_gen' {S : Set R[M]} (hS : Algebra.adjoin R S = ⊤) :
Algebra.adjoin R (of' R M '' ⋃ f ∈ S, (f.support : Set M)) = ⊤ := by
suffices (of' R M '' ⋃ f ∈ S, (f.support : Set M)) = ⋃ f ∈ S, of' R M '' (f.support : Set M) by
rw [this]
exact support_gen_of_gen hS
simp only [Set.image_iUnion]
end Semiring
section Ring
variable [CommRing R] [AddMonoid M]
/-- If `R[M]` is of finite type, then there is a `G : Finset M` such that its
image generates, as algebra, `R[M]`. -/
theorem exists_finset_adjoin_eq_top [h : FiniteType R R[M]] :
∃ G : Finset M, Algebra.adjoin R (of' R M '' G) = ⊤ := by
obtain ⟨S, hS⟩ := h
letI : DecidableEq M := Classical.decEq M
use Finset.biUnion S fun f => f.support
have : (Finset.biUnion S fun f => f.support : Set M) = ⋃ f ∈ S, (f.support : Set M) := by
simp only [Finset.set_biUnion_coe, Finset.coe_biUnion]
rw [this]
exact support_gen_of_gen' hS
/-- The image of an element `m : M` in `R[M]` belongs the submodule generated by
`S : Set M` if and only if `m ∈ S`. -/
theorem of'_mem_span [Nontrivial R] {m : M} {S : Set M} :
of' R M m ∈ span R (of' R M '' S) ↔ m ∈ S := by
refine ⟨fun h => ?_, fun h => Submodule.subset_span <| Set.mem_image_of_mem (of R M) h⟩
unfold of' at h
rw [← Finsupp.supported_eq_span_single, Finsupp.mem_supported,
Finsupp.support_single_ne_zero _ (one_ne_zero' R)] at h
simpa using h
/--
If the image of an element `m : M` in `R[M]` belongs the submodule generated by
the closure of some `S : Set M` then `m ∈ closure S`. -/
theorem mem_closure_of_mem_span_closure [Nontrivial R] {m : M} {S : Set M}
(h : of' R M m ∈ span R (Submonoid.closure (of' R M '' S) : Set R[M])) :
m ∈ closure S := by
suffices Multiplicative.ofAdd m ∈ Submonoid.closure (Multiplicative.toAdd ⁻¹' S) by
simpa [← toSubmonoid_closure]
let S' := @Submonoid.closure (Multiplicative M) Multiplicative.mulOneClass S
have h' : Submonoid.map (of R M) S' = Submonoid.closure ((fun x : M => (of R M) x) '' S) :=
MonoidHom.map_mclosure _ _
rw [Set.image_congr' (show ∀ x, of' R M x = of R M x from fun x => of'_eq_of x), ← h'] at h
simpa using of'_mem_span.1 h
end Ring
end Span
/-- If a set `S` generates an additive monoid `M`, then the image of `M` generates, as algebra,
`R[M]`. -/
theorem mvPolynomial_aeval_of_surjective_of_closure [AddCommMonoid M] [CommSemiring R] {S : Set M}
(hS : closure S = ⊤) :
Function.Surjective
(MvPolynomial.aeval fun s : S => of' R M ↑s : MvPolynomial S R → R[M]) := by
intro f
induction f using induction_on with
| hM m =>
have : m ∈ closure S := hS.symm ▸ mem_top _
refine AddSubmonoid.closure_induction (fun m hm => ?_) ?_ ?_ this
· exact ⟨MvPolynomial.X ⟨m, hm⟩, MvPolynomial.aeval_X _ _⟩
· exact ⟨1, map_one _⟩
· rintro m₁ m₂ _ _ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩
exact
⟨P₁ * P₂, by
rw [map_mul, hP₁, hP₂, of_apply, of_apply, of_apply, single_mul_single,
one_mul]; rfl⟩
| hadd f g ihf ihg =>
rcases ihf with ⟨P, rfl⟩
rcases ihg with ⟨Q, rfl⟩
exact ⟨P + Q, map_add _ _ _⟩
| hsmul r f ih =>
rcases ih with ⟨P, rfl⟩
exact ⟨r • P, map_smul _ _ _⟩
variable [AddMonoid M]
/-- If a set `S` generates an additive monoid `M`, then the image of `M` generates, as algebra,
`R[M]`. -/
theorem freeAlgebra_lift_of_surjective_of_closure [CommSemiring R] {S : Set M}
(hS : closure S = ⊤) :
Function.Surjective
(FreeAlgebra.lift R fun s : S => of' R M ↑s : FreeAlgebra R S → R[M]) := by
intro f
induction f using induction_on with
| hM m =>
have : m ∈ closure S := hS.symm ▸ mem_top _
refine AddSubmonoid.closure_induction (fun m hm => ?_) ?_ ?_ this
· exact ⟨FreeAlgebra.ι R ⟨m, hm⟩, FreeAlgebra.lift_ι_apply _ _⟩
· exact ⟨1, map_one _⟩
· rintro m₁ m₂ _ _ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩
exact
⟨P₁ * P₂, by
rw [map_mul, hP₁, hP₂, of_apply, of_apply, of_apply, single_mul_single,
one_mul]; rfl⟩
| hadd f g ihf ihg =>
rcases ihf with ⟨P, rfl⟩
rcases ihg with ⟨Q, rfl⟩
exact ⟨P + Q, map_add _ _ _⟩
| hsmul r f ih =>
rcases ih with ⟨P, rfl⟩
exact ⟨r • P, map_smul _ _ _⟩
variable (R M)
/-- If an additive monoid `M` is finitely generated then `R[M]` is of finite
type. -/
instance finiteType_of_fg [CommRing R] [h : AddMonoid.FG M] :
FiniteType R R[M] := by
obtain ⟨S, hS⟩ := h.fg_top
exact .of_surjective
(FreeAlgebra.lift R fun s : (S : Set M) => of' R M ↑s)
(freeAlgebra_lift_of_surjective_of_closure hS)
variable {R M}
/-- An additive monoid `M` is finitely generated if and only if `R[M]` is of
finite type. -/
theorem finiteType_iff_fg [CommRing R] [Nontrivial R] :
FiniteType R R[M] ↔ AddMonoid.FG M := by
refine ⟨fun h => ?_, fun h => @AddMonoidAlgebra.finiteType_of_fg _ _ _ _ h⟩
obtain ⟨S, hS⟩ := @exists_finset_adjoin_eq_top R M _ _ h
refine AddMonoid.fg_def.2 ⟨S, (eq_top_iff' _).2 fun m => ?_⟩
have hm : of' R M m ∈ Subalgebra.toSubmodule (adjoin R (of' R M '' ↑S)) := by
simp only [hS, top_toSubmodule, Submodule.mem_top]
rw [adjoin_eq_span] at hm
exact mem_closure_of_mem_span_closure hm
/-- If `R[M]` is of finite type then `M` is finitely generated. -/
theorem fg_of_finiteType [CommRing R] [Nontrivial R] [h : FiniteType R R[M]] :
AddMonoid.FG M :=
finiteType_iff_fg.1 h
/-- An additive group `G` is finitely generated if and only if `R[G]` is of
finite type. -/
theorem finiteType_iff_group_fg {G : Type*} [AddGroup G] [CommRing R] [Nontrivial R] :
FiniteType R R[G] ↔ AddGroup.FG G := by
simpa [AddGroup.fg_iff_addMonoid_fg] using finiteType_iff_fg
end AddMonoidAlgebra
namespace MonoidAlgebra
open Algebra Submonoid Submodule
section Span
section Semiring
variable [CommSemiring R] [Monoid M]
/-- An element of `MonoidAlgebra R M` is in the subalgebra generated by its support. -/
theorem mem_adjoin_support (f : MonoidAlgebra R M) : f ∈ adjoin R (of R M '' f.support) := by
suffices span R (of R M '' f.support) ≤ Subalgebra.toSubmodule (adjoin R (of R M '' f.support)) by
exact this (mem_span_support f)
rw [Submodule.span_le]
exact subset_adjoin
/-- If a set `S` generates, as algebra, `MonoidAlgebra R M`, then the set of supports of elements
of `S` generates `MonoidAlgebra R M`. -/
theorem support_gen_of_gen {S : Set (MonoidAlgebra R M)} (hS : Algebra.adjoin R S = ⊤) :
Algebra.adjoin R (⋃ f ∈ S, of R M '' (f.support : Set M)) = ⊤ := by
refine le_antisymm le_top ?_
rw [← hS, adjoin_le_iff]
intro f hf
have hincl : (of R M '' f.support) ⊆
⋃ (g : MonoidAlgebra R M) (H : g ∈ S), (of R M '' g.support) := by
intro s hs
exact Set.mem_iUnion₂.2 ⟨f, ⟨hf, hs⟩⟩
exact adjoin_mono hincl (mem_adjoin_support f)
/-- If a set `S` generates, as algebra, `MonoidAlgebra R M`, then the image of the union of the
supports of elements of `S` generates `MonoidAlgebra R M`. -/
theorem support_gen_of_gen' {S : Set (MonoidAlgebra R M)} (hS : Algebra.adjoin R S = ⊤) :
Algebra.adjoin R (of R M '' ⋃ f ∈ S, (f.support : Set M)) = ⊤ := by
suffices (of R M '' ⋃ f ∈ S, (f.support : Set M)) = ⋃ f ∈ S, of R M '' (f.support : Set M) by
rw [this]
exact support_gen_of_gen hS
simp only [Set.image_iUnion]
end Semiring
section Ring
variable [CommRing R] [Monoid M]
/-- If `MonoidAlgebra R M` is of finite type, then there is a `G : Finset M` such that its image
generates, as algebra, `MonoidAlgebra R M`. -/
theorem exists_finset_adjoin_eq_top [h : FiniteType R (MonoidAlgebra R M)] :
∃ G : Finset M, Algebra.adjoin R (of R M '' G) = ⊤ := by
obtain ⟨S, hS⟩ := h
letI : DecidableEq M := Classical.decEq M
use Finset.biUnion S fun f => f.support
have : (Finset.biUnion S fun f => f.support : Set M) = ⋃ f ∈ S, (f.support : Set M) := by
simp only [Finset.set_biUnion_coe, Finset.coe_biUnion]
rw [this]
exact support_gen_of_gen' hS
/-- The image of an element `m : M` in `MonoidAlgebra R M` belongs the submodule generated by
`S : Set M` if and only if `m ∈ S`. -/
theorem of_mem_span_of_iff [Nontrivial R] {m : M} {S : Set M} :
of R M m ∈ span R (of R M '' S) ↔ m ∈ S := by
refine ⟨fun h => ?_, fun h => Submodule.subset_span <| Set.mem_image_of_mem (of R M) h⟩
dsimp [of] at h
rw [← Finsupp.supported_eq_span_single, Finsupp.mem_supported,
Finsupp.support_single_ne_zero _ (one_ne_zero' R)] at h
simpa using h
/--
If the image of an element `m : M` in `MonoidAlgebra R M` belongs the submodule generated by the
closure of some `S : Set M` then `m ∈ closure S`. -/
theorem mem_closure_of_mem_span_closure [Nontrivial R] {m : M} {S : Set M}
(h : of R M m ∈ span R (Submonoid.closure (of R M '' S) : Set (MonoidAlgebra R M))) :
m ∈ closure S := by
rw [← MonoidHom.map_mclosure] at h
simpa using of_mem_span_of_iff.1 h
end Ring
end Span
/-- If a set `S` generates a monoid `M`, then the image of `M` generates, as algebra,
`MonoidAlgebra R M`. -/
theorem mvPolynomial_aeval_of_surjective_of_closure [CommMonoid M] [CommSemiring R] {S : Set M}
(hS : closure S = ⊤) :
Function.Surjective
(MvPolynomial.aeval fun s : S => of R M ↑s : MvPolynomial S R → MonoidAlgebra R M) := by
intro f
induction f using induction_on with
| hM m =>
have : m ∈ closure S := hS.symm ▸ mem_top _
refine Submonoid.closure_induction (fun m hm => ?_) ?_ ?_ this
· exact ⟨MvPolynomial.X ⟨m, hm⟩, MvPolynomial.aeval_X _ _⟩
· exact ⟨1, map_one _⟩
· rintro m₁ m₂ _ _ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩
exact
⟨P₁ * P₂, by
rw [map_mul, hP₁, hP₂, of_apply, of_apply, of_apply, single_mul_single, one_mul]⟩
| hadd f g ihf ihg =>
rcases ihf with ⟨P, rfl⟩; rcases ihg with ⟨Q, rfl⟩
exact ⟨P + Q, map_add _ _ _⟩
| hsmul r f ih =>
rcases ih with ⟨P, rfl⟩
exact ⟨r • P, map_smul _ _ _⟩
variable [Monoid M]
/-- If a set `S` generates an additive monoid `M`, then the image of `M` generates, as algebra,
`R[M]`. -/
theorem freeAlgebra_lift_of_surjective_of_closure [CommSemiring R] {S : Set M}
(hS : closure S = ⊤) :
Function.Surjective
(FreeAlgebra.lift R fun s : S => of R M ↑s : FreeAlgebra R S → MonoidAlgebra R M) := by
intro f
induction f using induction_on with
| hM m =>
have : m ∈ closure S := hS.symm ▸ mem_top _
refine Submonoid.closure_induction (fun m hm => ?_) ?_ ?_ this
· exact ⟨FreeAlgebra.ι R ⟨m, hm⟩, FreeAlgebra.lift_ι_apply _ _⟩
· exact ⟨1, map_one _⟩
· rintro m₁ m₂ _ _ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩
exact
⟨P₁ * P₂, by
rw [map_mul, hP₁, hP₂, of_apply, of_apply, of_apply, single_mul_single, one_mul]⟩
| hadd f g ihf ihg =>
rcases ihf with ⟨P, rfl⟩
rcases ihg with ⟨Q, rfl⟩
exact ⟨P + Q, map_add _ _ _⟩
| hsmul r f ih =>
rcases ih with ⟨P, rfl⟩
exact ⟨r • P, map_smul _ _ _⟩
/-- If a monoid `M` is finitely generated then `MonoidAlgebra R M` is of finite type. -/
instance finiteType_of_fg [CommRing R] [Monoid.FG M] : FiniteType R (MonoidAlgebra R M) :=
(AddMonoidAlgebra.finiteType_of_fg R (Additive M)).equiv (toAdditiveAlgEquiv R M).symm
/-- A monoid `M` is finitely generated if and only if `MonoidAlgebra R M` is of finite type. -/
theorem finiteType_iff_fg [CommRing R] [Nontrivial R] :
FiniteType R (MonoidAlgebra R M) ↔ Monoid.FG M :=
⟨fun h =>
Monoid.fg_iff_add_fg.2 <|
AddMonoidAlgebra.finiteType_iff_fg.1 <| h.equiv <| toAdditiveAlgEquiv R M,
fun h => @MonoidAlgebra.finiteType_of_fg _ _ _ _ h⟩
/-- If `MonoidAlgebra R M` is of finite type then `M` is finitely generated. -/
theorem fg_of_finiteType [CommRing R] [Nontrivial R] [h : FiniteType R (MonoidAlgebra R M)] :
Monoid.FG M :=
finiteType_iff_fg.1 h
/-- A group `G` is finitely generated if and only if `R[G]` is of finite type. -/
theorem finiteType_iff_group_fg {G : Type*} [Group G] [CommRing R] [Nontrivial R] :
FiniteType R (MonoidAlgebra R G) ↔ Group.FG G := by
simpa [Group.fg_iff_monoid_fg] using finiteType_iff_fg
end MonoidAlgebra
end MonoidAlgebra
section Orzech
open Submodule Module Module.Finite in
/-- Any commutative ring `R` satisfies the `OrzechProperty`, that is, for any finitely generated
`R`-module `M`, any surjective homomorphism `f : N →ₗ[R] M` from a submodule `N` of `M` to `M`
is injective.
This is a consequence of Noetherian case
(`IsNoetherian.injective_of_surjective_of_injective`), which requires that `M` is a
Noetherian module, but allows `R` to be non-commutative. The reduction of this result to
Noetherian case is adapted from <https://math.stackexchange.com/a/1066110>:
suppose `{ m_j }` is a finite set of generator of `M`, for any `n : N` one can write
`i n = ∑ j, b_j * m_j` for `{ b_j }` in `R`, here `i : N →ₗ[R] M` is the standard inclusion.
We can choose `{ n_j }` which are preimages of `{ m_j }` under `f`, and can choose
`{ c_jl }` in `R` such that `i n_j = ∑ l, c_jl * m_l` for each `j`.
Now let `A` be the subring of `R` generated by `{ b_j }` and `{ c_jl }`, then it is
Noetherian. Let `N'` be the `A`-submodule of `N` generated by `n` and `{ n_j }`,
`M'` be the `A`-submodule of `M` generated by `{ m_j }`,
then it's easy to see that `i` and `f` restrict to `N' →ₗ[A] M'`,
and the restricted version of `f` is surjective, hence by Noetherian case,
it is also injective, in particular, if `f n = 0`, then `n = 0`.
See also Orzech's original paper: *Onto endomorphisms are isomorphisms* [orzech1971]. -/
instance (priority := 100) CommRing.orzechProperty
(R : Type*) [CommRing R] : OrzechProperty R := by
refine ⟨fun {M} _ _ _ {N} f hf ↦ ?_⟩
letI := addCommMonoidToAddCommGroup R (M := M)
letI := addCommMonoidToAddCommGroup R (M := N)
let i := N.subtype
let hi : Function.Injective i := N.injective_subtype
refine LinearMap.ker_eq_bot.1 <| LinearMap.ker_eq_bot'.2 fun n hn ↦ ?_
obtain ⟨k, mj, hmj⟩ := exists_fin (R := R) (M := M)
rw [← surjective_piEquiv_apply_iff] at hmj
obtain ⟨b, hb⟩ := hmj (i n)
choose nj hnj using fun j ↦ hf (mj j)
choose c hc using fun j ↦ hmj (i (nj j))
let A := Subring.closure (Set.range b ∪ Set.range c.uncurry)
let N' := span A ({n} ∪ Set.range nj)
let M' := span A (Set.range mj)
haveI : IsNoetherianRing A := is_noetherian_subring_closure _
(.union (Set.finite_range _) (Set.finite_range _))
haveI : Module.Finite A M' := span_of_finite A (Set.finite_range _)
refine congr($((LinearMap.ker_eq_bot'.1 <| LinearMap.ker_eq_bot.2 <|
IsNoetherian.injective_of_surjective_of_injective
((i.restrictScalars A).restrict fun x hx ↦ ?_ : N' →ₗ[A] M')
((f.restrictScalars A).restrict fun x hx ↦ ?_ : N' →ₗ[A] M')
(fun _ _ h ↦ injective_subtype _ (hi congr(($h).1)))
fun ⟨x, hx⟩ ↦ ?_) ⟨n, (subset_span (by simp))⟩ (Subtype.val_injective hn)).1)
· induction hx using span_induction with
| mem x hx =>
change i x ∈ M'
simp only [Set.singleton_union, Set.mem_insert_iff, Set.mem_range] at hx
rcases hx with hx | ⟨j, rfl⟩
· rw [hx, ← hb, piEquiv_apply_apply]
refine Submodule.sum_mem _ fun j _ ↦ ?_
let b' : A := ⟨b j, Subring.subset_closure (by simp)⟩
rw [show b j • mj j = b' • mj j from rfl]
exact smul_mem _ _ (subset_span (by simp))
· rw [← hc, piEquiv_apply_apply]
refine Submodule.sum_mem _ fun j' _ ↦ ?_
let c' : A := ⟨c j j', Subring.subset_closure
(by simp [show ∃ a b, c a b = c j j' from ⟨j, j', rfl⟩])⟩
rw [show c j j' • mj j' = c' • mj j' from rfl]
exact smul_mem _ _ (subset_span (by simp))
| zero => simp
| add x _ y _ hx hy => rw [map_add]; exact add_mem hx hy
| smul a x _ hx => rw [map_smul]; exact smul_mem _ _ hx
· induction hx using span_induction with
| mem x hx =>
change f x ∈ M'
simp only [Set.singleton_union, Set.mem_insert_iff, Set.mem_range] at hx
rcases hx with hx | ⟨j, rfl⟩
· rw [hx, hn]; exact zero_mem _
· exact subset_span (by simp [hnj])
| zero => simp
| add x _ y _ hx hy => rw [map_add]; exact add_mem hx hy
| smul a x _ hx => rw [map_smul]; exact smul_mem _ _ hx
suffices x ∈ LinearMap.range ((f.restrictScalars A).domRestrict N') by
obtain ⟨a, ha⟩ := this
exact ⟨a, Subtype.val_injective ha⟩
induction hx using span_induction with
| mem x hx =>
obtain ⟨j, rfl⟩ := hx
exact ⟨⟨nj j, subset_span (by simp)⟩, hnj j⟩
| zero => exact zero_mem _
| add x y _ _ hx hy => exact add_mem hx hy
| smul a x _ hx => exact smul_mem _ a hx
end Orzech |
.lake/packages/mathlib/Mathlib/RingTheory/Complex.lean | import Mathlib.LinearAlgebra.Complex.Module
import Mathlib.RingTheory.Norm.Defs
import Mathlib.RingTheory.Trace.Defs
/-! # Lemmas about `Algebra.trace` and `Algebra.norm` on `ℂ` -/
open Complex
theorem Algebra.leftMulMatrix_complex (z : ℂ) :
Algebra.leftMulMatrix Complex.basisOneI z = !![z.re, -z.im; z.im, z.re] := by
ext i j
rw [Algebra.leftMulMatrix_eq_repr_mul, Complex.coe_basisOneI_repr, Complex.coe_basisOneI, mul_re,
mul_im, Matrix.of_apply]
fin_cases j <;> dsimp only [Fin.zero_eta, Fin.mk_one, Matrix.cons_val]
· simp only [one_re, mul_one, one_im, mul_zero,
sub_zero, zero_add]
fin_cases i <;> rfl
· simp only [I_re, mul_zero, I_im,
mul_one, zero_sub, add_zero]
fin_cases i <;> rfl
theorem Algebra.trace_complex_apply (z : ℂ) : Algebra.trace ℝ ℂ z = 2 * z.re := by
rw [Algebra.trace_eq_matrix_trace Complex.basisOneI, Algebra.leftMulMatrix_complex,
Matrix.trace_fin_two]
exact (two_mul _).symm
theorem Algebra.norm_complex_apply (z : ℂ) : Algebra.norm ℝ z = Complex.normSq z := by
rw [Algebra.norm_eq_matrix_det Complex.basisOneI, Algebra.leftMulMatrix_complex,
Matrix.det_fin_two, normSq_apply]
simp
theorem Algebra.norm_complex_eq : Algebra.norm ℝ = normSq.toMonoidHom :=
MonoidHom.ext Algebra.norm_complex_apply |
.lake/packages/mathlib/Mathlib/RingTheory/MvPolynomial.lean | import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.LinearAlgebra.Dimension.StrongRankCondition
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
import Mathlib.RingTheory.MvPolynomial.Basic
/-!
# Multivariate polynomials over fields
This file contains basic facts about multivariate polynomials over fields, for example that the
dimension of the space of multivariate polynomials over a field is equal to the cardinality of
finitely supported functions from the indexing set to `ℕ`.
-/
noncomputable section
open Set LinearMap Submodule
universe u v
namespace MvPolynomial
variable (σ : Type u) (K : Type v)
theorem quotient_mk_comp_C_injective [Field K] (I : Ideal (MvPolynomial σ K)) (hI : I ≠ ⊤) :
Function.Injective ((Ideal.Quotient.mk I).comp MvPolynomial.C) := by
refine (injective_iff_map_eq_zero _).2 fun x hx => ?_
rw [RingHom.comp_apply, Ideal.Quotient.eq_zero_iff_mem] at hx
refine _root_.by_contradiction fun hx0 => absurd (I.eq_top_iff_one.2 ?_) hI
have := I.mul_mem_left (MvPolynomial.C x⁻¹) hx
rwa [← MvPolynomial.C.map_mul, inv_mul_cancel₀ hx0, MvPolynomial.C_1] at this
variable {σ K} [CommRing K] [Nontrivial K]
open Cardinal
theorem rank_eq_lift : Module.rank K (MvPolynomial σ K) = lift.{v} #(σ →₀ ℕ) := by
rw [← Cardinal.lift_inj, ← (basisMonomials σ K).mk_eq_rank, lift_lift, lift_umax.{u,v}]
theorem rank_eq {σ : Type v} : Module.rank K (MvPolynomial σ K) = #(σ →₀ ℕ) := by
rw [← Cardinal.lift_inj, ← (basisMonomials σ K).mk_eq_rank]
theorem finrank_eq_zero [Nonempty σ] : Module.finrank K (MvPolynomial σ K) = 0 :=
(basisMonomials σ K).linearIndependent.finrank_eq_zero_of_infinite
omit [Nontrivial K] in
theorem finrank_eq_one [IsEmpty σ] : Module.finrank K (MvPolynomial σ K) = 1 :=
Module.rank_eq_one_iff_finrank_eq_one.mp <| by
cases subsingleton_or_nontrivial K <;> simp [rank_eq_lift]
end MvPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Generators.lean | import Mathlib.RingTheory.Extension.Generators
deprecated_module (since := "2025-05-11") |
.lake/packages/mathlib/Mathlib/RingTheory/Grassmannian.lean | import Mathlib.RingTheory.Spectrum.Prime.FreeLocus
/-!
# Grassmannians
## Main definitions
- `Module.Grassmannian`: `G(k, M; R)` is the `k`ᵗʰ Grassmannian of the `R`-module `M`. It is defined
to be the set of submodules of `M` whose **quotient** is locally free of rank `k`. Note that there
is another convention in literature where the `k`ᵗʰ Grassmannian would instead be `k`-dimensional
subspaces of a given vector space over a field. See implementation notes below.
## Implementation notes
In the literature, two conventions exist:
1. The `k`ᵗʰ Grassmannian parametrises `k`-dimensional **subspaces** of a given finite-dimensional
vector space over a field.
2. The `k`ᵗʰ Grassmannian parametrises **quotients** that are locally free of rank `k`, of a given
module over a ring.
For the purposes of Algebraic Geometry, the first definition here cannot be generalised to obtain
a scheme to represent the functor, which is why the second definition is the one chosen by
[Grothendieck, EGA I.9.7.3][grothendieck-1971] (Springer edition only), and in EGA V.11
(unpublished).
The first definition in the stated generality (i.e. over a field `F`, and finite-dimensional vector
space `V`) can be recovered from the second definition by noting that `k`-dimensional subspaces of
`V` are canonically equivalent to `(n-k)`-dimensional quotients of `V`, and also to `k`-dimensional
quotients of `V*`, the dual of `V`. In symbols, this means that the first definition is equivalent
to `G(n - k, V; F)` and also to `G(k, V →ₗ[F] F; F)`, where `n` is the dimension of `V`.
## TODO
- Define and recover the subspace-definition (i.e. the first definition above).
- Define the functor `Module.Grassmannian.functor R M k` that sends an `R`-algebra `A` to the set
`G(k, A ⊗[R] M; A)`.
- Define `chart x` indexed by `x : Fin k → M` as a subtype consisting of those
`N ∈ G(k, A ⊗[R] M; A)` such that the composition `R^k → M → M⧸N` is an isomorphism.
- Define `chartFunctor x` to turn `chart x` into a subfunctor of `Module.Grassmannian.functor`. This
will correspond to an affine open chart in the Grassmannian.
- Grassmannians for schemes and quasi-coherent sheaf of modules.
- Representability of `Module.Grassmannian.functor R M k`.
-/
universe u v w
namespace Module
variable (R : Type u) [CommRing R] (M : Type v) [AddCommGroup M] [Module R M] (k : ℕ)
/-- `G(k, M; R)` is the `k`ᵗʰ Grassmannian of the `R`-module `M`. It is defined to be the set of
submodules of `M` whose quotient is locally free of rank `k`. Note that there is another convention
in literature where instead the submodule is required to have rank `k`. See the module docstring
of `RingTheory.Grassmannian`. -/
@[stacks 089R] structure Grassmannian extends Submodule R M where
finite_quotient : Module.Finite R (M ⧸ toSubmodule)
projective_quotient : Projective R (M ⧸ toSubmodule)
rankAtStalk_eq : ∀ p, rankAtStalk (R := R) (M ⧸ toSubmodule) p = k
attribute [instance] Grassmannian.finite_quotient Grassmannian.projective_quotient
namespace Grassmannian
@[inherit_doc] scoped notation "G(" k ", " M "; " R ")" => Grassmannian R M k
variable {R M k}
instance : CoeOut G(k, M; R) (Submodule R M) :=
⟨toSubmodule⟩
@[ext] lemma ext {N₁ N₂ : G(k, M; R)} (h : (N₁ : Submodule R M) = N₂) : N₁ = N₂ := by
cases N₁; cases N₂; congr 1
end Grassmannian
end Module |
.lake/packages/mathlib/Mathlib/RingTheory/RingHomProperties.lean | import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.Algebra.Category.Ring.Colimits
import Mathlib.CategoryTheory.Iso
import Mathlib.CategoryTheory.MorphismProperty.Limits
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.IsTensorProduct
/-!
# Properties of ring homomorphisms
We provide the basic framework for talking about properties of ring homomorphisms.
The following meta-properties of predicates on ring homomorphisms are defined
* `RingHom.RespectsIso`: `P` respects isomorphisms if `P f → P (e ≫ f)` and
`P f → P (f ≫ e)`, where `e` is an isomorphism.
* `RingHom.StableUnderComposition`: `P` is stable under composition if `P f → P g → P (f ≫ g)`.
* `RingHom.IsStableUnderBaseChange`: `P` is stable under base change if `P (S ⟶ Y)`
implies `P (X ⟶ X ⊗[S] Y)`.
-/
universe u
open CategoryTheory Opposite CategoryTheory.Limits TensorProduct
namespace RingHom
variable {P Q : ∀ {R S : Type u} [CommRing R] [CommRing S] (_ : R →+* S), Prop}
section RespectsIso
variable (P) in
/-- A property `RespectsIso` if it still holds when composed with an isomorphism -/
def RespectsIso : Prop :=
(∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
∀ (f : R →+* S) (e : S ≃+* T) (_ : P f), P (e.toRingHom.comp f)) ∧
∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
∀ (f : S →+* T) (e : R ≃+* S) (_ : P f), P (f.comp e.toRingHom)
theorem RespectsIso.cancel_left_isIso (hP : RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S)
(g : S ⟶ T) [IsIso f] : P (g.hom.comp f.hom) ↔ P g.hom :=
⟨fun H => by
convert hP.2 (f ≫ g).hom (asIso f).symm.commRingCatIsoToRingEquiv H
simp [← CommRingCat.hom_comp], hP.2 g.hom (asIso f).commRingCatIsoToRingEquiv⟩
theorem RespectsIso.cancel_right_isIso (hP : RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S)
(g : S ⟶ T) [IsIso g] : P (g.hom.comp f.hom) ↔ P f.hom :=
⟨fun H => by
convert hP.1 (f ≫ g).hom (asIso g).symm.commRingCatIsoToRingEquiv H
simp [← CommRingCat.hom_comp],
hP.1 f.hom (asIso g).commRingCatIsoToRingEquiv⟩
theorem RespectsIso.isLocalization_away_iff (hP : RingHom.RespectsIso @P) {R S : Type u}
(R' S' : Type u) [CommRing R] [CommRing S] [CommRing R'] [CommRing S'] [Algebra R R']
[Algebra S S'] (f : R →+* S) (r : R) [IsLocalization.Away r R'] [IsLocalization.Away (f r) S'] :
P (Localization.awayMap f r) ↔ P (IsLocalization.Away.map R' S' f r) := by
let e₁ : R' ≃+* Localization.Away r :=
(IsLocalization.algEquiv (Submonoid.powers r) _ _).toRingEquiv
let e₂ : Localization.Away (f r) ≃+* S' :=
(IsLocalization.algEquiv (Submonoid.powers (f r)) _ _).toRingEquiv
refine (hP.cancel_left_isIso e₁.toCommRingCatIso.hom (CommRingCat.ofHom _)).symm.trans ?_
refine (hP.cancel_right_isIso (CommRingCat.ofHom _) e₂.toCommRingCatIso.hom).symm.trans ?_
rw [← eq_iff_iff]
congr 1
-- Porting note: Here, the proof used to have a huge `simp` involving `[anonymous]`, which didn't
-- work out anymore. The issue seemed to be that it couldn't handle a term in which Ring
-- homomorphisms were repeatedly casted to the bundled category and back. Here we resolve the
-- problem by converting the goal to a more straightforward form.
let e := (e₂ : Localization.Away (f r) →+* S').comp
(((IsLocalization.map (Localization.Away (f r)) f
(by rintro x ⟨n, rfl⟩; use n; simp : Submonoid.powers r ≤ Submonoid.comap f
(Submonoid.powers (f r)))) : Localization.Away r →+* Localization.Away (f r)).comp
(e₁ : R' →+* Localization.Away r))
suffices e = IsLocalization.Away.map R' S' f r by
convert this
apply IsLocalization.ringHom_ext (Submonoid.powers r) _
ext1 x
dsimp [e, e₁, e₂, IsLocalization.Away.map]
simp only [IsLocalization.map_eq, id_apply, RingHomCompTriple.comp_apply]
lemma RespectsIso.and (hP : RespectsIso P) (hQ : RespectsIso Q) :
RespectsIso (fun f ↦ P f ∧ Q f) := by
refine ⟨?_, ?_⟩
· introv hf
exact ⟨hP.1 f e hf.1, hQ.1 f e hf.2⟩
· introv hf
exact ⟨hP.2 f e hf.1, hQ.2 f e hf.2⟩
end RespectsIso
section StableUnderComposition
variable (P) in
/-- A property is `StableUnderComposition` if the composition of two such morphisms
still falls in the class. -/
def StableUnderComposition : Prop :=
∀ ⦃R S T⦄ [CommRing R] [CommRing S] [CommRing T],
∀ (f : R →+* S) (g : S →+* T) (_ : P f) (_ : P g), P (g.comp f)
theorem StableUnderComposition.respectsIso (hP : RingHom.StableUnderComposition @P)
(hP' : ∀ {R S : Type u} [CommRing R] [CommRing S] (e : R ≃+* S), P e.toRingHom) :
RingHom.RespectsIso @P := by
constructor
· introv H
apply hP
exacts [H, hP' e]
· introv H
apply hP
exacts [hP' e, H]
lemma StableUnderComposition.and (hP : StableUnderComposition P) (hQ : StableUnderComposition Q) :
StableUnderComposition (fun f ↦ P f ∧ Q f) := by
introv R hf hg
exact ⟨hP f g hf.1 hg.1, hQ f g hf.2 hg.2⟩
end StableUnderComposition
section IsStableUnderBaseChange
variable (P) in
/-- A morphism property `P` is `IsStableUnderBaseChange` if `P(S →+* A)` implies
`P(B →+* A ⊗[S] B)`. -/
def IsStableUnderBaseChange : Prop :=
∀ (R S R' S') [CommRing R] [CommRing S] [CommRing R'] [CommRing S'],
∀ [Algebra R S] [Algebra R R'] [Algebra R S'] [Algebra S S'] [Algebra R' S'],
∀ [IsScalarTower R S S'] [IsScalarTower R R' S'],
∀ [Algebra.IsPushout R S R' S'], P (algebraMap R S) → P (algebraMap R' S')
theorem IsStableUnderBaseChange.mk (h₁ : RespectsIso @P)
(h₂ : ∀ ⦃R S T⦄ [CommRing R] [CommRing S] [CommRing T] [Algebra R S] [Algebra R T],
P (algebraMap R T) → P (algebraMap S (S ⊗[R] T))) :
IsStableUnderBaseChange @P := by
introv R h H
let e := h.symm.1.equiv
let f' := Algebra.TensorProduct.productMap (IsScalarTower.toAlgHom R R' S')
(IsScalarTower.toAlgHom R S S')
have hef (x : _) : e x = f' x := by
suffices e.toLinearMap.restrictScalars R = f'.toLinearMap from congr($this x)
exact ext' fun x y ↦ by simp [e, f', IsBaseChange.equiv_tmul, Algebra.smul_def]
have hemul (x y : _) : e (x * y) = e x * e y := by simp_rw [hef, map_mul]
convert h₁.1 _ { e with map_mul' := hemul } (h₂ H)
ext x
simp [e, h.symm.1.equiv_tmul, Algebra.smul_def]
attribute [local instance] Algebra.TensorProduct.rightAlgebra
theorem IsStableUnderBaseChange.pushout_inl (hP : RingHom.IsStableUnderBaseChange @P)
(hP' : RingHom.RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S) (g : R ⟶ T) (H : P g.hom) :
P (pushout.inl _ _ : S ⟶ pushout f g).hom := by
letI := f.hom.toAlgebra
letI := g.hom.toAlgebra
rw [← show _ = pushout.inl f g from
colimit.isoColimitCocone_ι_inv ⟨_, CommRingCat.pushoutCoconeIsColimit R S T⟩ WalkingSpan.left,
CommRingCat.hom_comp, hP'.cancel_right_isIso]
dsimp only [CommRingCat.pushoutCocone_inl, PushoutCocone.ι_app_left]
apply hP R T S (S ⊗[R] T)
exact H
lemma IsStableUnderBaseChange.and (hP : IsStableUnderBaseChange P)
(hQ : IsStableUnderBaseChange Q) :
IsStableUnderBaseChange (fun f ↦ P f ∧ Q f) := by
introv R _ h
exact ⟨hP R S R' S' h.1, hQ R S R' S' h.2⟩
end IsStableUnderBaseChange
section ToMorphismProperty
variable (P) in
/-- The categorical `MorphismProperty` associated to a property of ring homs expressed
non-categorical terms. -/
def toMorphismProperty : MorphismProperty CommRingCat := fun _ _ f ↦ P f.hom
lemma toMorphismProperty_respectsIso_iff :
RespectsIso P ↔ (toMorphismProperty P).RespectsIso := by
refine ⟨fun h ↦ MorphismProperty.RespectsIso.mk _ ?_ ?_, fun h ↦ ⟨?_, ?_⟩⟩
· intro X Y Z e f hf
exact h.right f.hom e.commRingCatIsoToRingEquiv hf
· intro X Y Z e f hf
exact h.left f.hom e.commRingCatIsoToRingEquiv hf
· intro X Y Z _ _ _ f e hf
exact MorphismProperty.RespectsIso.postcomp (toMorphismProperty P)
e.toCommRingCatIso.hom (CommRingCat.ofHom f) hf
· intro X Y Z _ _ _ f e
exact MorphismProperty.RespectsIso.precomp (toMorphismProperty P)
e.toCommRingCatIso.hom (CommRingCat.ofHom f)
lemma isStableUnderCobaseChange_toMorphismProperty_iff :
(toMorphismProperty P).IsStableUnderCobaseChange ↔ IsStableUnderBaseChange P := by
refine ⟨fun h R S R' S' _ _ _ _ _ _ _ _ _ _ _ hsq hRS ↦ ?_,
fun h ↦ ⟨fun {R} S R' S' f g f' g' hsq hf ↦ ?_⟩⟩
· rw [← CommRingCat.isPushout_iff_isPushout] at hsq
exact h.1 (f := CommRingCat.ofHom (algebraMap R S)) hsq.flip hRS
· algebraize [f.hom, g.hom, f'.hom, g'.hom, f'.hom.comp g.hom]
have : IsScalarTower R S S' := .of_algebraMap_eq fun x ↦ congr($(hsq.1.1).hom x)
have : Algebra.IsPushout R S R' S' := (CommRingCat.isPushout_iff_isPushout.mp hsq).symm
exact h (R := R) (S := S) _ _ hf
/-- Variant of `MorphismProperty.arrow_mk_iso_iff` specialized to morphism properties in
`CommRingCat` given by ring hom properties. -/
lemma RespectsIso.arrow_mk_iso_iff (hQ : RingHom.RespectsIso P) {A B A' B' : CommRingCat}
{f : A ⟶ B} {g : A' ⟶ B'} (e : Arrow.mk f ≅ Arrow.mk g) :
P f.hom ↔ P g.hom := by
have : (toMorphismProperty P).RespectsIso := by
rwa [← toMorphismProperty_respectsIso_iff]
change toMorphismProperty P _ ↔ toMorphismProperty P _
rw [MorphismProperty.arrow_mk_iso_iff (toMorphismProperty P) e]
end ToMorphismProperty
section Descent
variable (Q : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
variable (R S T : Type u) [CommRing R] [CommRing S] [Algebra R S] [CommRing T] [Algebra R T]
variable (P) in
/-- A property of ring homomorphisms `Q` codescends along `Q'` if whenever
`R' →+* R' ⊗[R] S` satisfies `Q` and `R →+* R'` satisfies `Q'`, then `R →+* S` satisfies `Q`. -/
def CodescendsAlong : Prop :=
∀ ⦃R S R' S' : Type u⦄ [CommRing R] [CommRing S] [CommRing R'] [CommRing S'],
∀ [Algebra R S] [Algebra R R'] [Algebra R S'] [Algebra S S'] [Algebra R' S'],
∀ [IsScalarTower R S S'] [IsScalarTower R R' S'],
∀ [Algebra.IsPushout R S R' S'],
Q (algebraMap R R') → P (algebraMap R' S') → P (algebraMap R S)
lemma CodescendsAlong.mk (h₁ : RespectsIso P)
(h₂ : ∀ ⦃R S T⦄ [CommRing R] [CommRing S] [CommRing T],
∀ [Algebra R S] [Algebra R T],
Q (algebraMap R S) → P (algebraMap S (S ⊗[R] T)) → P (algebraMap R T)) :
CodescendsAlong P Q := by
introv R h hQ H
let e := h.symm.equiv
have : (e.symm : _ →+* _).comp (algebraMap R' S') = algebraMap R' (R' ⊗[R] S) := by
ext r
simp [e]
apply h₂ hQ
rw [← this]
exact h₁.1 _ _ H
lemma CodescendsAlong.algebraMap_tensorProduct (hPQ : CodescendsAlong P Q)
(h : Q (algebraMap R S)) (H : P (algebraMap S (S ⊗[R] T))) :
P (algebraMap R T) :=
let _ : Algebra T (S ⊗[R] T) := Algebra.TensorProduct.rightAlgebra
hPQ h H
lemma CodescendsAlong.includeRight (hPQ : CodescendsAlong P Q) (h : Q (algebraMap R T))
(H : P ((Algebra.TensorProduct.includeRight.toRingHom : T →+* S ⊗[R] T))) :
P (algebraMap R S) := by
let _ : Algebra T (S ⊗[R] T) := Algebra.TensorProduct.rightAlgebra
apply hPQ h H
variable {Q} {P' : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
lemma CodescendsAlong.and (hP : CodescendsAlong P Q) (hP' : CodescendsAlong P' Q) :
CodescendsAlong (fun f ↦ P f ∧ P' f) Q :=
fun _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ h₁ h₂ ↦ ⟨hP h₁ h₂.1, hP' h₁ h₂.2⟩
end Descent
end RingHom |
.lake/packages/mathlib/Mathlib/RingTheory/NormalClosure.lean | import Mathlib.RingTheory.DedekindDomain.IntegralClosure
/-!
# Normal closure of an extension of domains
We define the normal closure of an extension of domains `R ⊆ S` as a domain `T` such that
`R ⊆ S ⊆ T` and the extension `Frac T / Frac R` is Galois, and prove several instances about it.
Under the hood, `T` is defined as the `integralClosure` of `S` inside the
`IntermediateField.normalClosure` of the extension `Frac S / Frac R` inside the `AlgebraicClosure`
of `Frac S`. In particular, if `S` is a Dedekind domain, then `T` is also a Dedekind domain.
## Technical notes
* Many instances are proved about the `IntermediateField.normalClosure` of the extension
`Frac S / Frac R` inside the `AlgebraicClosure` of `Frac S`. However these are only needed for the
construction of `T` and to prove some results about it. Therefore, these instances are local.
* `Ring.NormalClosure` is defined as a type rather than a `Subalgebra` for performance reasons
(and thus we need to provide explicit instances for it). Although defining it as a `Subalgebra`
does not cause timeouts in this file, it does slow down considerably its compilation and
does trigger timeouts in applications.
-/
namespace Ring
noncomputable section NormalClosure
variable (R S : Type*) [CommRing R] [CommRing S] [IsDomain R] [IsDomain S]
[Algebra R S] [NoZeroSMulDivisors R S]
/--
We register this specific instance as a local instance rather than making
`FractionRing.liftAlgebra` a local instance because the latter causes timeouts since
it is too general.
-/
local instance : Algebra (FractionRing R) (FractionRing S) := FractionRing.liftAlgebra _ _
local notation3 "K" => FractionRing R
local notation3 "L" => FractionRing S
local notation3 "E" => IntermediateField.normalClosure (FractionRing R) (FractionRing S)
(AlgebraicClosure (FractionRing S))
/--
This is a local instance since it is only used in this file to construct `Ring.NormalClosure`.
-/
local instance : Algebra S E := ((algebraMap L E).comp (algebraMap S L)).toAlgebra
local instance : IsScalarTower S L E := IsScalarTower.of_algebraMap_eq' rfl
/--
The normal closure of an extension of domains `R ⊆ S`. It is defined as a domain `T` such that
`R ⊆ S ⊆ T` and `Frac T / Frac R` is Galois. -/
def NormalClosure : Type _ := integralClosure S E
local notation3 "T" => NormalClosure R S
instance : CommRing T := inferInstanceAs (CommRing (integralClosure S E))
instance : IsDomain T := inferInstanceAs (IsDomain (integralClosure S E))
instance : Nontrivial T := inferInstanceAs (Nontrivial (integralClosure S E))
instance : Algebra S T := inferInstanceAs (Algebra S (integralClosure S E))
/--
This is a local instance since it is only used in this file to construct `Ring.NormalClosure`.
-/
local instance : Algebra T E := inferInstanceAs (Algebra (integralClosure S E) E)
instance : Algebra R T := ((algebraMap S T).comp (algebraMap R S)).toAlgebra
local instance : IsScalarTower S T E :=
inferInstanceAs (IsScalarTower S (integralClosure S E) E)
local instance : IsIntegralClosure T S E := integralClosure.isIntegralClosure S E
instance : IsScalarTower R S T := IsScalarTower.of_algebraMap_eq' rfl
local instance : IsScalarTower R L E := IsScalarTower.to₁₃₄ R K L E
local instance : IsScalarTower R S E := IsScalarTower.to₁₂₄ R S L E
local instance : IsScalarTower R T E := IsScalarTower.to₁₃₄ R S T E
local instance : FaithfulSMul S E := (faithfulSMul_iff_algebraMap_injective S E).mpr <|
(FaithfulSMul.algebraMap_injective L E).comp (FaithfulSMul.algebraMap_injective S L)
instance : NoZeroSMulDivisors S T := Subalgebra.noZeroSMulDivisors_bot (integralClosure S E)
instance : FaithfulSMul R T :=
(faithfulSMul_iff_algebraMap_injective R T).mpr <|
(FaithfulSMul.algebraMap_injective S T).comp (FaithfulSMul.algebraMap_injective R S)
variable [Module.Finite R S]
local instance : FiniteDimensional L E := Module.Finite.right K L E
local instance : IsFractionRing T E :=
integralClosure.isFractionRing_of_finite_extension L E
instance : IsIntegrallyClosed T :=
integralClosure.isIntegrallyClosedOfFiniteExtension L
variable [PerfectField (FractionRing R)]
local instance : Algebra.IsSeparable L E :=
Algebra.isSeparable_tower_top_of_isSeparable K L E
instance : IsGalois K (FractionRing T) := by
refine IsGalois.of_equiv_equiv (F := K) («E» := E) (f := (FractionRing.algEquiv R K).symm)
(g := (FractionRing.algEquiv T E).symm) ?_
ext
simpa using IsFractionRing.algEquiv_commutes (FractionRing.algEquiv R K).symm
(FractionRing.algEquiv T E).symm _
variable [IsDedekindDomain S]
instance : Module.Finite S T :=
IsIntegralClosure.finite S L E T
instance : Module.Finite R T :=
Module.Finite.trans S T
instance : IsDedekindDomain T :=
integralClosure.isDedekindDomain S L E
end Ring.NormalClosure |
.lake/packages/mathlib/Mathlib/RingTheory/LinearDisjoint.lean | import Mathlib.Algebra.Algebra.Subalgebra.MulOpposite
import Mathlib.Algebra.Algebra.Subalgebra.Rank
import Mathlib.Algebra.Polynomial.Basis
import Mathlib.LinearAlgebra.LinearDisjoint
import Mathlib.LinearAlgebra.TensorProduct.Subalgebra
import Mathlib.RingTheory.Adjoin.Dimension
import Mathlib.RingTheory.Algebraic.Basic
import Mathlib.RingTheory.IntegralClosure.Algebra.Defs
import Mathlib.RingTheory.IntegralClosure.IsIntegral.Basic
import Mathlib.RingTheory.Norm.Defs
import Mathlib.RingTheory.TensorProduct.Nontrivial
import Mathlib.RingTheory.Trace.Defs
/-!
# Linearly disjoint subalgebras
This file contains basics about linearly disjoint subalgebras.
We adapt the definitions in <https://en.wikipedia.org/wiki/Linearly_disjoint>.
See the file `Mathlib/LinearAlgebra/LinearDisjoint.lean` for details.
## Main definitions
- `Subalgebra.LinearDisjoint`: two subalgebras are linearly disjoint, if they are
linearly disjoint as submodules (`Submodule.LinearDisjoint`).
- `Subalgebra.LinearDisjoint.mulMap`: if two subalgebras `A` and `B` of `S / R` are
linearly disjoint, then there is `A ⊗[R] B ≃ₐ[R] A ⊔ B` induced by multiplication in `S`.
## Main results
### Equivalent characterization of linear disjointness
- `Subalgebra.LinearDisjoint.linearIndependent_left_of_flat`:
if `A` and `B` are linearly disjoint, and if `B` is a flat `R`-module, then for any family of
`R`-linearly independent elements of `A`, they are also `B`-linearly independent.
- `Subalgebra.LinearDisjoint.of_basis_left_op`:
conversely, if a basis of `A` is also `B`-linearly independent, then `A` and `B` are
linearly disjoint.
- `Subalgebra.LinearDisjoint.linearIndependent_right_of_flat`:
if `A` and `B` are linearly disjoint, and if `A` is a flat `R`-module, then for any family of
`R`-linearly independent elements of `B`, they are also `A`-linearly independent.
- `Subalgebra.LinearDisjoint.of_basis_right`:
conversely, if a basis of `B` is also `A`-linearly independent,
then `A` and `B` are linearly disjoint.
- `Subalgebra.LinearDisjoint.linearIndependent_mul_of_flat`:
if `A` and `B` are linearly disjoint, and if one of `A` and `B` is flat, then for any family of
`R`-linearly independent elements `{ a_i }` of `A`, and any family of
`R`-linearly independent elements `{ b_j }` of `B`, the family `{ a_i * b_j }` in `S` is
also `R`-linearly independent.
- `Subalgebra.LinearDisjoint.of_basis_mul`:
conversely, if `{ a_i }` is an `R`-basis of `A`, if `{ b_j }` is an `R`-basis of `B`,
such that the family `{ a_i * b_j }` in `S` is `R`-linearly independent,
then `A` and `B` are linearly disjoint.
### Equivalent characterization by `IsDomain` or `IsField` of tensor product
The following results are related to the equivalent characterizations in
<https://mathoverflow.net/questions/8324>.
- `Subalgebra.LinearDisjoint.isDomain_of_injective`,
`Subalgebra.LinearDisjoint.exists_field_of_isDomain_of_injective`:
under some flatness and injectivity conditions, if `A` and `B` are `R`-algebras, then `A ⊗[R] B`
is a domain if and only if there exists an `R`-algebra which is a field that `A` and `B`
embed into with linearly disjoint images.
- `Subalgebra.LinearDisjoint.of_isField`, `Subalgebra.LinearDisjoint.of_isField'`:
if `A ⊗[R] B` is a field, then `A` and `B` are linearly disjoint, moreover, for any
`R`-algebra `S` and injections of `A` and `B` into `S`, their images are linearly disjoint.
- `Algebra.TensorProduct.not_isField_of_transcendental`,
`Algebra.TensorProduct.isAlgebraic_of_isField`:
if `A` and `B` are flat `R`-algebras, both of them are transcendental, then `A ⊗[R] B` cannot
be a field, equivalently, if `A ⊗[R] B` is a field, then one of them is algebraic.
### Other main results
- `Subalgebra.LinearDisjoint.symm_of_commute`, `Subalgebra.linearDisjoint_comm_of_commute`:
linear disjointness is symmetric under some commutative conditions.
- `Subalgebra.LinearDisjoint.map`:
linear disjointness is preserved by injective algebra homomorphisms.
- `Subalgebra.LinearDisjoint.bot_left`, `Subalgebra.LinearDisjoint.bot_right`:
the image of `R` in `S` is linearly disjoint with any other subalgebras.
- `Subalgebra.LinearDisjoint.sup_free_of_free`: the compositum of two linearly disjoint
subalgebras is a free module, if two subalgebras are also free modules.
- `Subalgebra.LinearDisjoint.rank_sup_of_free`,
`Subalgebra.LinearDisjoint.finrank_sup_of_free`:
if subalgebras `A` and `B` are linearly disjoint and they are
free modules, then the rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`.
- `Subalgebra.LinearDisjoint.of_finrank_sup_of_free`:
conversely, if `A` and `B` are subalgebras which are free modules of finite rank,
such that rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`,
then `A` and `B` are linearly disjoint.
- `Subalgebra.LinearDisjoint.adjoin_rank_eq_rank_left`:
`Subalgebra.LinearDisjoint.adjoin_rank_eq_rank_right`:
if `A` and `B` are linearly disjoint, if `A` is free and `B` is flat (resp. `B` is free and
`A` is flat), then `[B[A] : B] = [A : R]` (resp. `[A[B] : A] = [B : R]`).
See also `Subalgebra.adjoin_rank_le`.
- `Subalgebra.LinearDisjoint.of_finrank_coprime_of_free`:
if the rank of `A` and `B` are coprime, and they satisfy some freeness condition,
then `A` and `B` are linearly disjoint.
- `Subalgebra.LinearDisjoint.inf_eq_bot_of_commute`, `Subalgebra.LinearDisjoint.inf_eq_bot`:
if `A` and `B` are linearly disjoint, under suitable technical conditions, they are disjoint.
The results with name containing "of_commute" also have corresponding specialized versions
assuming `S` is commutative.
## Tags
linearly disjoint, linearly independent, tensor product
-/
open Module
open scoped TensorProduct
noncomputable section
universe u v w
namespace Subalgebra
variable {R : Type u} {S : Type v}
section Semiring
variable [CommSemiring R] [Semiring S] [Algebra R S]
variable (A B : Subalgebra R S)
/-- If `A` and `B` are subalgebras of `S / R`,
then `A` and `B` are linearly disjoint, if they are linearly disjoint as submodules of `S`. -/
protected abbrev LinearDisjoint : Prop := (toSubmodule A).LinearDisjoint (toSubmodule B)
theorem linearDisjoint_iff : A.LinearDisjoint B ↔ (toSubmodule A).LinearDisjoint (toSubmodule B) :=
Iff.rfl
variable {A B}
@[nontriviality]
theorem LinearDisjoint.of_subsingleton [Subsingleton R] : A.LinearDisjoint B :=
Submodule.LinearDisjoint.of_subsingleton
@[nontriviality]
theorem LinearDisjoint.of_subsingleton_top [Subsingleton S] : A.LinearDisjoint B :=
Submodule.LinearDisjoint.of_subsingleton_top
/-- Linear disjointness is symmetric if elements in the module commute. -/
theorem LinearDisjoint.symm_of_commute (H : A.LinearDisjoint B)
(hc : ∀ (a : A) (b : B), Commute a.1 b.1) : B.LinearDisjoint A :=
Submodule.LinearDisjoint.symm_of_commute H hc
/-- Linear disjointness is symmetric if elements in the module commute. -/
theorem linearDisjoint_comm_of_commute
(hc : ∀ (a : A) (b : B), Commute a.1 b.1) : A.LinearDisjoint B ↔ B.LinearDisjoint A :=
⟨fun H ↦ H.symm_of_commute hc, fun H ↦ H.symm_of_commute fun _ _ ↦ (hc _ _).symm⟩
namespace LinearDisjoint
/-- Linear disjointness is preserved by injective algebra homomorphisms. -/
theorem map (H : A.LinearDisjoint B) {T : Type w} [Semiring T] [Algebra R T]
(f : S →ₐ[R] T) (hf : Function.Injective f) : (A.map f).LinearDisjoint (B.map f) :=
Submodule.LinearDisjoint.map H f hf
variable (A B)
/-- The image of `R` in `S` is linearly disjoint with any other subalgebras. -/
theorem bot_left : (⊥ : Subalgebra R S).LinearDisjoint B := by
rw [Subalgebra.LinearDisjoint, Algebra.toSubmodule_bot]
exact Submodule.LinearDisjoint.one_left _
/-- The image of `R` in `S` is linearly disjoint with any other subalgebras. -/
theorem bot_right : A.LinearDisjoint ⊥ := by
rw [Subalgebra.LinearDisjoint, Algebra.toSubmodule_bot]
exact Submodule.LinearDisjoint.one_right _
variable (R) in
/-- Images of two `R`-algebras `A` and `B` in `A ⊗[R] B` are linearly disjoint. -/
theorem include_range (A : Type v) [Semiring A] (B : Type w) [Semiring B]
[Algebra R A] [Algebra R B] :
(Algebra.TensorProduct.includeLeft : A →ₐ[R] A ⊗[R] B).range.LinearDisjoint
(Algebra.TensorProduct.includeRight : B →ₐ[R] A ⊗[R] B).range := by
rw [Subalgebra.LinearDisjoint, Submodule.linearDisjoint_iff]
change Function.Injective <|
Submodule.mulMap (LinearMap.range Algebra.TensorProduct.includeLeft)
(LinearMap.range Algebra.TensorProduct.includeRight)
rw [← Algebra.TensorProduct.linearEquivIncludeRange_symm_toLinearMap]
exact LinearEquiv.injective _
end LinearDisjoint
end Semiring
section CommSemiring
variable [CommSemiring R] [CommSemiring S] [Algebra R S]
variable {A B : Subalgebra R S}
/-- Linear disjointness is symmetric in a commutative ring. -/
theorem LinearDisjoint.symm (H : A.LinearDisjoint B) : B.LinearDisjoint A :=
H.symm_of_commute fun _ _ ↦ mul_comm _ _
/-- Linear disjointness is symmetric in a commutative ring. -/
theorem linearDisjoint_comm : A.LinearDisjoint B ↔ B.LinearDisjoint A :=
⟨LinearDisjoint.symm, LinearDisjoint.symm⟩
/-- Two subalgebras `A`, `B` in a commutative ring are linearly disjoint if and only if
`Subalgebra.mulMap A B` is injective. -/
theorem linearDisjoint_iff_injective : A.LinearDisjoint B ↔ Function.Injective (A.mulMap B) := by
rw [linearDisjoint_iff, Submodule.linearDisjoint_iff]
rfl
namespace LinearDisjoint
variable (H : A.LinearDisjoint B)
/-- If `A` and `B` are subalgebras in a commutative algebra `S` over `R`, and if they are
linearly disjoint, then there is the natural isomorphism
`A ⊗[R] B ≃ₐ[R] A ⊔ B` induced by multiplication in `S`. -/
protected def mulMap :=
(AlgEquiv.ofInjective (A.mulMap B) H.injective).trans (equivOfEq _ _ (mulMap_range A B))
@[simp]
theorem val_mulMap_tmul (a : A) (b : B) : (H.mulMap (a ⊗ₜ[R] b) : S) = a.1 * b.1 := rfl
/--
If `A` and `B` are linearly disjoint subalgebras in a commutative algebra `S` over `R`
such that `A ⊔ B = S`, then this is the natural isomorphism
`A ⊗[R] B ≃ₐ[A] S` induced by multiplication in `S`.
-/
noncomputable def mulMapLeftOfSupEqTop (H' : A ⊔ B = ⊤) :
A ⊗[R] B ≃ₐ[A] S :=
(AlgEquiv.ofInjective (Algebra.TensorProduct.productLeftAlgHom
(Algebra.ofId A S) B.val) H.injective).trans ((Subalgebra.equivOfEq _ _ (by
apply Subalgebra.restrictScalars_injective R
rw [restrictScalars_top, ← H']
exact mulMap_range A B)).trans Subalgebra.topEquiv)
@[simp]
theorem mulMapLeftOfSupEqTop_tmul (H' : A ⊔ B = ⊤) (a : A) (b : B) :
H.mulMapLeftOfSupEqTop H' (a ⊗ₜ[R] b) = (a : S) * (b : S) := rfl
/--
If `A` and `B` are linearly disjoint subalgebras in a commutative algebra `S` over `R`
such that `A ⊔ B = S`, then any `R`-basis of `B` is also an `A`-basis of `S`.
-/
noncomputable def basisOfBasisRight (H' : A ⊔ B = ⊤) {ι : Type*} (b : Basis ι R B) :
Basis ι A S :=
(b.baseChange A).map (H.mulMapLeftOfSupEqTop H').toLinearEquiv
@[simp]
theorem algebraMap_basisOfBasisRight_apply (H' : A ⊔ B = ⊤) {ι : Type*} (b : Basis ι R B) (i : ι) :
H.basisOfBasisRight H' b i = algebraMap B S (b i) := by
simp [basisOfBasisRight]
@[simp]
theorem mulMapLeftOfSupEqTop_symm_apply (H' : A ⊔ B = ⊤) (x : B) :
(H.mulMapLeftOfSupEqTop H').symm x = 1 ⊗ₜ[R] x :=
(H.mulMapLeftOfSupEqTop H').symm_apply_eq.mpr (by simp)
theorem algebraMap_basisOfBasisRight_repr_apply (H' : A ⊔ B = ⊤) {ι : Type*} (b : Basis ι R B)
(x : B) (i : ι) :
algebraMap A S ((H.basisOfBasisRight H' b).repr x i) = algebraMap R S (b.repr x i) := by
simp [basisOfBasisRight, Algebra.algebraMap_eq_smul_one]
theorem leftMulMatrix_basisOfBasisRight_algebraMap (H' : A ⊔ B = ⊤) {ι : Type*} [Fintype ι]
[DecidableEq ι] (b : Basis ι R B) (x : B) :
Algebra.leftMulMatrix (H.basisOfBasisRight H' b) (algebraMap B S x) =
RingHom.mapMatrix (algebraMap R A) (Algebra.leftMulMatrix b x) := by
ext
simp [Algebra.leftMulMatrix_eq_repr_mul, ← H.algebraMap_basisOfBasisRight_repr_apply H']
/--
If `A` and `B` are subalgebras in a commutative algebra `S` over `R`, and if they are
linearly disjoint and such that `A ⊔ B = S`, then any `R`-basis of `A` is also a `B`-basis of `S`.
-/
noncomputable def basisOfBasisLeft (H' : A ⊔ B = ⊤) {ι : Type*} (b : Basis ι R A) :
Basis ι B S :=
(b.baseChange B).map (H.symm.mulMapLeftOfSupEqTop (by rwa [sup_comm])).toLinearEquiv
@[simp]
theorem basisOfBasisLeft_apply (H' : A ⊔ B = ⊤) {ι : Type*} (b : Basis ι R A) (i : ι) :
H.basisOfBasisLeft H' b i = algebraMap A S (b i) :=
H.symm.algebraMap_basisOfBasisRight_apply (by rwa [sup_comm]) b i
theorem basisOfBasisLeft_repr_apply (H' : A ⊔ B = ⊤) {ι : Type*} (b : Basis ι R A)
(x : A) (i : ι) :
algebraMap B S ((H.basisOfBasisLeft H' b).repr x i) = algebraMap R S (b.repr x i) :=
H.symm.algebraMap_basisOfBasisRight_repr_apply (by rwa [sup_comm]) b x i
include H in
/-- If `A` and `B` are subalgebras in a commutative algebra `S` over `R`, and if they are
linearly disjoint, and if they are free `R`-modules, then `A ⊔ B` is also a free `R`-module. -/
theorem sup_free_of_free [Module.Free R A] [Module.Free R B] : Module.Free R ↥(A ⊔ B) :=
Module.Free.of_equiv H.mulMap.toLinearEquiv
include H in
/-- If `A` and `B` are subalgebras in a domain `S` over `R`, and if they are
linearly disjoint, then `A ⊗[R] B` is also a domain. -/
theorem isDomain [IsDomain S] : IsDomain (A ⊗[R] B) :=
H.injective.isDomain (A.mulMap B).toRingHom
/-- If `A` and `B` are `R`-algebras, such that there exists a domain `S` over `R`
such that `A` and `B` inject into it and their images are linearly disjoint,
then `A ⊗[R] B` is also a domain. -/
theorem isDomain_of_injective [IsDomain S] {A B : Type*} [Semiring A] [Semiring B]
[Algebra R A] [Algebra R B] {fa : A →ₐ[R] S} {fb : B →ₐ[R] S}
(hfa : Function.Injective fa) (hfb : Function.Injective fb)
(H : fa.range.LinearDisjoint fb.range) : IsDomain (A ⊗[R] B) :=
have := H.isDomain
(Algebra.TensorProduct.congr
(AlgEquiv.ofInjective fa hfa) (AlgEquiv.ofInjective fb hfb)).toMulEquiv.isDomain
end LinearDisjoint
end CommSemiring
section Ring
namespace LinearDisjoint
variable [CommRing R] [Ring S] [Algebra R S]
variable (A B : Subalgebra R S)
lemma mulLeftMap_ker_eq_bot_iff_linearIndependent_op {ι : Type*} (a : ι → A) :
LinearMap.ker (Submodule.mulLeftMap (M := toSubmodule A) (toSubmodule B) a) = ⊥ ↔
LinearIndependent B.op (MulOpposite.op ∘ A.val ∘ a) := by
simp_rw [LinearIndependent, LinearMap.ker_eq_bot]
let i : (ι →₀ B) →ₗ[R] S := Submodule.mulLeftMap (M := toSubmodule A) (toSubmodule B) a
let j : (ι →₀ B) →ₗ[R] S := (MulOpposite.opLinearEquiv _).symm.toLinearMap ∘ₗ
(Finsupp.linearCombination B.op (MulOpposite.op ∘ A.val ∘ a)).restrictScalars R ∘ₗ
(Finsupp.mapRange.linearEquiv (linearEquivOp B)).toLinearMap
suffices i = j by
change Function.Injective i ↔ _
simp_rw [this, j, LinearMap.coe_comp, LinearEquiv.coe_coe, EquivLike.comp_injective,
EquivLike.injective_comp, LinearMap.coe_restrictScalars]
ext
simp only [LinearMap.coe_comp, Function.comp_apply, Finsupp.lsingle_apply, coe_val,
Finsupp.mapRange.linearEquiv_toLinearMap, LinearEquiv.coe_coe,
MulOpposite.coe_opLinearEquiv_symm, LinearMap.coe_restrictScalars,
Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Finsupp.linearCombination_single,
MulOpposite.unop_smul, MulOpposite.unop_op, i, j]
exact Submodule.mulLeftMap_apply_single _ _ _
variable {A B} in
/-- If `A` and `B` are linearly disjoint, if `B` is a flat `R`-module, then for any family of
`R`-linearly independent elements of `A`, they are also `B`-linearly independent
in the opposite ring. -/
theorem linearIndependent_left_op_of_flat (H : A.LinearDisjoint B) [Module.Flat R B]
{ι : Type*} {a : ι → A} (ha : LinearIndependent R a) :
LinearIndependent B.op (MulOpposite.op ∘ A.val ∘ a) := by
have h := Submodule.LinearDisjoint.linearIndependent_left_of_flat H ha
rwa [mulLeftMap_ker_eq_bot_iff_linearIndependent_op] at h
/-- If a basis of `A` is also `B`-linearly independent in the opposite ring,
then `A` and `B` are linearly disjoint. -/
theorem of_basis_left_op {ι : Type*} (a : Basis ι R A)
(H : LinearIndependent B.op (MulOpposite.op ∘ A.val ∘ a)) :
A.LinearDisjoint B := by
rw [← mulLeftMap_ker_eq_bot_iff_linearIndependent_op] at H
exact Submodule.LinearDisjoint.of_basis_left _ _ a H
lemma mulRightMap_ker_eq_bot_iff_linearIndependent {ι : Type*} (b : ι → B) :
LinearMap.ker (Submodule.mulRightMap (toSubmodule A) (N := toSubmodule B) b) = ⊥ ↔
LinearIndependent A (B.val ∘ b) := by
simp_rw [LinearIndependent, LinearMap.ker_eq_bot]
let i : (ι →₀ A) →ₗ[R] S := Submodule.mulRightMap (toSubmodule A) (N := toSubmodule B) b
let j : (ι →₀ A) →ₗ[R] S := (Finsupp.linearCombination A (B.val ∘ b)).restrictScalars R
suffices i = j by change Function.Injective i ↔ Function.Injective j; rw [this]
ext
simp only [LinearMap.coe_comp, Function.comp_apply, Finsupp.lsingle_apply, coe_val,
LinearMap.coe_restrictScalars, Finsupp.linearCombination_single, i, j]
exact Submodule.mulRightMap_apply_single _ _ _
variable {A B} in
/-- If `A` and `B` are linearly disjoint, if `A` is a flat `R`-module, then for any family of
`R`-linearly independent elements of `B`, they are also `A`-linearly independent. -/
theorem linearIndependent_right_of_flat (H : A.LinearDisjoint B) [Module.Flat R A]
{ι : Type*} {b : ι → B} (hb : LinearIndependent R b) :
LinearIndependent A (B.val ∘ b) := by
have h := Submodule.LinearDisjoint.linearIndependent_right_of_flat H hb
rwa [mulRightMap_ker_eq_bot_iff_linearIndependent] at h
/-- If a basis of `B` is also `A`-linearly independent, then `A` and `B` are linearly disjoint. -/
theorem of_basis_right {ι : Type*} (b : Basis ι R B)
(H : LinearIndependent A (B.val ∘ b)) : A.LinearDisjoint B := by
rw [← mulRightMap_ker_eq_bot_iff_linearIndependent] at H
exact Submodule.LinearDisjoint.of_basis_right _ _ b H
variable {A B} in
/-- If `A` and `B` are linearly disjoint and their elements commute, if `B` is a flat `R`-module,
then for any family of `R`-linearly independent elements of `A`,
they are also `B`-linearly independent. -/
theorem linearIndependent_left_of_flat_of_commute (H : A.LinearDisjoint B) [Module.Flat R B]
{ι : Type*} {a : ι → A} (ha : LinearIndependent R a)
(hc : ∀ (a : A) (b : B), Commute a.1 b.1) : LinearIndependent B (A.val ∘ a) :=
(H.symm_of_commute hc).linearIndependent_right_of_flat ha
/-- If a basis of `A` is also `B`-linearly independent, if elements in `A` and `B` commute,
then `A` and `B` are linearly disjoint. -/
theorem of_basis_left_of_commute {ι : Type*} (a : Basis ι R A)
(H : LinearIndependent B (A.val ∘ a)) (hc : ∀ (a : A) (b : B), Commute a.1 b.1) :
A.LinearDisjoint B :=
(of_basis_right B A a H).symm_of_commute fun _ _ ↦ (hc _ _).symm
variable {A B} in
/-- If `A` and `B` are linearly disjoint, if `A` is flat, then for any family of
`R`-linearly independent elements `{ a_i }` of `A`, and any family of
`R`-linearly independent elements `{ b_j }` of `B`, the family `{ a_i * b_j }` in `S` is
also `R`-linearly independent. -/
theorem linearIndependent_mul_of_flat_left (H : A.LinearDisjoint B) [Module.Flat R A]
{κ ι : Type*} {a : κ → A} {b : ι → B} (ha : LinearIndependent R a)
(hb : LinearIndependent R b) : LinearIndependent R fun (i : κ × ι) ↦ (a i.1).1 * (b i.2).1 :=
Submodule.LinearDisjoint.linearIndependent_mul_of_flat_left H ha hb
variable {A B} in
/-- If `A` and `B` are linearly disjoint, if `B` is flat, then for any family of
`R`-linearly independent elements `{ a_i }` of `A`, and any family of
`R`-linearly independent elements `{ b_j }` of `B`, the family `{ a_i * b_j }` in `S` is
also `R`-linearly independent. -/
theorem linearIndependent_mul_of_flat_right (H : A.LinearDisjoint B) [Module.Flat R B]
{κ ι : Type*} {a : κ → A} {b : ι → B} (ha : LinearIndependent R a)
(hb : LinearIndependent R b) : LinearIndependent R fun (i : κ × ι) ↦ (a i.1).1 * (b i.2).1 :=
Submodule.LinearDisjoint.linearIndependent_mul_of_flat_right H ha hb
variable {A B} in
/-- If `A` and `B` are linearly disjoint, if one of `A` and `B` is flat, then for any family of
`R`-linearly independent elements `{ a_i }` of `A`, and any family of
`R`-linearly independent elements `{ b_j }` of `B`, the family `{ a_i * b_j }` in `S` is
also `R`-linearly independent. -/
theorem linearIndependent_mul_of_flat (H : A.LinearDisjoint B)
(hf : Module.Flat R A ∨ Module.Flat R B)
{κ ι : Type*} {a : κ → A} {b : ι → B} (ha : LinearIndependent R a)
(hb : LinearIndependent R b) : LinearIndependent R fun (i : κ × ι) ↦ (a i.1).1 * (b i.2).1 :=
Submodule.LinearDisjoint.linearIndependent_mul_of_flat H hf ha hb
/-- If `{ a_i }` is an `R`-basis of `A`, if `{ b_j }` is an `R`-basis of `B`,
such that the family `{ a_i * b_j }` in `S` is `R`-linearly independent,
then `A` and `B` are linearly disjoint. -/
theorem of_basis_mul {κ ι : Type*} (a : Basis κ R A) (b : Basis ι R B)
(H : LinearIndependent R fun (i : κ × ι) ↦ (a i.1).1 * (b i.2).1) : A.LinearDisjoint B :=
Submodule.LinearDisjoint.of_basis_mul _ _ a b H
variable {A B}
section
variable (H : A.LinearDisjoint B)
include H
theorem of_le_left_of_flat {A' : Subalgebra R S}
(h : A' ≤ A) [Module.Flat R B] : A'.LinearDisjoint B :=
Submodule.LinearDisjoint.of_le_left_of_flat H h
theorem of_le_right_of_flat {B' : Subalgebra R S}
(h : B' ≤ B) [Module.Flat R A] : A.LinearDisjoint B' :=
Submodule.LinearDisjoint.of_le_right_of_flat H h
theorem of_le_of_flat_right {A' B' : Subalgebra R S}
(ha : A' ≤ A) (hb : B' ≤ B) [Module.Flat R B] [Module.Flat R A'] :
A'.LinearDisjoint B' := (H.of_le_left_of_flat ha).of_le_right_of_flat hb
theorem of_le_of_flat_left {A' B' : Subalgebra R S}
(ha : A' ≤ A) (hb : B' ≤ B) [Module.Flat R A] [Module.Flat R B'] :
A'.LinearDisjoint B' := (H.of_le_right_of_flat hb).of_le_left_of_flat ha
theorem rank_inf_eq_one_of_commute_of_flat_of_inj (hf : Module.Flat R A ∨ Module.Flat R B)
(hc : ∀ (a b : ↥(A ⊓ B)), Commute a.1 b.1)
(hinj : Function.Injective (algebraMap R S)) : Module.rank R ↥(A ⊓ B) = 1 := by
nontriviality R
refine le_antisymm (Submodule.LinearDisjoint.rank_inf_le_one_of_commute_of_flat H hf hc) ?_
have : Cardinal.lift.{u} (Module.rank R (⊥ : Subalgebra R S)) =
Cardinal.lift.{v} (Module.rank R R) :=
lift_rank_range_of_injective (Algebra.linearMap R S) hinj
rw [Module.rank_self, Cardinal.lift_one, Cardinal.lift_eq_one] at this
rw [← this]
change Module.rank R (toSubmodule (⊥ : Subalgebra R S)) ≤
Module.rank R (toSubmodule (A ⊓ B))
exact Submodule.rank_mono (bot_le : (⊥ : Subalgebra R S) ≤ A ⊓ B)
theorem rank_inf_eq_one_of_commute_of_flat_left_of_inj [Module.Flat R A]
(hc : ∀ (a b : ↥(A ⊓ B)), Commute a.1 b.1)
(hinj : Function.Injective (algebraMap R S)) : Module.rank R ↥(A ⊓ B) = 1 :=
H.rank_inf_eq_one_of_commute_of_flat_of_inj (Or.inl ‹_›) hc hinj
theorem rank_inf_eq_one_of_commute_of_flat_right_of_inj [Module.Flat R B]
(hc : ∀ (a b : ↥(A ⊓ B)), Commute a.1 b.1)
(hinj : Function.Injective (algebraMap R S)) : Module.rank R ↥(A ⊓ B) = 1 :=
H.rank_inf_eq_one_of_commute_of_flat_of_inj (Or.inr ‹_›) hc hinj
end
theorem rank_eq_one_of_commute_of_flat_of_self_of_inj (H : A.LinearDisjoint A) [Module.Flat R A]
(hc : ∀ (a b : A), Commute a.1 b.1)
(hinj : Function.Injective (algebraMap R S)) : Module.rank R A = 1 := by
rw [← inf_of_le_left (le_refl A)] at hc ⊢
exact H.rank_inf_eq_one_of_commute_of_flat_left_of_inj hc hinj
end LinearDisjoint
end Ring
section CommRing
namespace LinearDisjoint
variable [CommRing R] [CommRing S] [Algebra R S]
variable {A B : Subalgebra R S}
/--
If `A` and `B` are subalgebras in a commutative algebra `S` over `R`, and if they are
linearly disjoint and such that `A ⊔ B = S`, then `trace` and `algebraMap` commutes.
-/
theorem trace_algebraMap (H : A.LinearDisjoint B) (H' : A ⊔ B = ⊤) [Module.Free R B]
[Module.Finite R B] (x : B) :
Algebra.trace A S (algebraMap B S x) = algebraMap R A (Algebra.trace R B x) := by
simp_rw [Algebra.trace_eq_matrix_trace (Module.Free.chooseBasis R B),
Algebra.trace_eq_matrix_trace (H.basisOfBasisRight H' (Module.Free.chooseBasis R B)),
Matrix.trace, map_sum, leftMulMatrix_basisOfBasisRight_algebraMap, RingHom.mapMatrix_apply,
Matrix.diag_apply, Matrix.map_apply]
/--
If `A` and `B` are subalgebras in a commutative algebra `S` over `R`, and if they are
linearly disjoint and such that `A ⊔ B = S`, then `norm` and `algebraMap` commutes.
-/
theorem norm_algebraMap (H : A.LinearDisjoint B) (H' : A ⊔ B = ⊤) [Module.Free R B]
[Module.Finite R B] (x : B) :
Algebra.norm A (algebraMap B S x) = algebraMap R A (Algebra.norm R x) := by
simp_rw [Algebra.norm_eq_matrix_det (Module.Free.chooseBasis R B),
Algebra.norm_eq_matrix_det (H.basisOfBasisRight H' (Module.Free.chooseBasis R B)),
leftMulMatrix_basisOfBasisRight_algebraMap, RingHom.map_det]
/-- In a commutative ring, if `A` and `B` are linearly disjoint, if `B` is a flat `R`-module,
then for any family of `R`-linearly independent elements of `A`,
they are also `B`-linearly independent. -/
theorem linearIndependent_left_of_flat (H : A.LinearDisjoint B) [Module.Flat R B]
{ι : Type*} {a : ι → A} (ha : LinearIndependent R a) : LinearIndependent B (A.val ∘ a) :=
H.linearIndependent_left_of_flat_of_commute ha fun _ _ ↦ mul_comm _ _
variable (A B) in
/-- In a commutative ring, if a basis of `A` is also `B`-linearly independent,
then `A` and `B` are linearly disjoint. -/
theorem of_basis_left {ι : Type*} (a : Basis ι R A)
(H : LinearIndependent B (A.val ∘ a)) : A.LinearDisjoint B :=
of_basis_left_of_commute A B a H fun _ _ ↦ mul_comm _ _
variable (R) in
/-- If `A` and `B` are flat algebras over `R`, such that `A ⊗[R] B` is a domain, and such that
the algebra maps are injective, then there exists an `R`-algebra `K` that is a field that `A`
and `B` inject into with linearly disjoint images. Note: `K` can chosen to be the
fraction field of `A ⊗[R] B`, but here we hide this fact. -/
theorem exists_field_of_isDomain_of_injective (A : Type v) [CommRing A] (B : Type w) [CommRing B]
[Algebra R A] [Algebra R B] [Module.Flat R A] [Module.Flat R B] [IsDomain (A ⊗[R] B)]
(ha : Function.Injective (algebraMap R A)) (hb : Function.Injective (algebraMap R B)) :
∃ (K : Type (max v w)) (_ : Field K) (_ : Algebra R K) (fa : A →ₐ[R] K) (fb : B →ₐ[R] K),
Function.Injective fa ∧ Function.Injective fb ∧ fa.range.LinearDisjoint fb.range :=
let K := FractionRing (A ⊗[R] B)
let i := IsScalarTower.toAlgHom R (A ⊗[R] B) K
have hi : Function.Injective i := IsFractionRing.injective (A ⊗[R] B) K
⟨K, inferInstance, inferInstance,
i.comp Algebra.TensorProduct.includeLeft,
i.comp Algebra.TensorProduct.includeRight,
hi.comp (Algebra.TensorProduct.includeLeft_injective hb),
hi.comp (Algebra.TensorProduct.includeRight_injective ha), by
simpa only [AlgHom.range_comp] using (include_range R A B).map i hi⟩
/-- If `A ⊗[R] B` is a field, then `A` and `B` are linearly disjoint. -/
theorem of_isField (H : IsField (A ⊗[R] B)) : A.LinearDisjoint B := by
nontriviality S
rw [linearDisjoint_iff_injective]
letI : Field (A ⊗[R] B) := H.toField
-- need this otherwise `RingHom.injective` does not work
letI : NonAssocRing (A ⊗[R] B) := Ring.toNonAssocRing
exact RingHom.injective _
/-- If `A ⊗[R] B` is a field, then for any `R`-algebra `S`
and injections of `A` and `B` into `S`, their images are linearly disjoint. -/
theorem of_isField' {A : Type v} [Ring A] {B : Type w} [Ring B]
[Algebra R A] [Algebra R B] (H : IsField (A ⊗[R] B))
(fa : A →ₐ[R] S) (fb : B →ₐ[R] S) (hfa : Function.Injective fa) (hfb : Function.Injective fb) :
fa.range.LinearDisjoint fb.range := by
apply of_isField
exact Algebra.TensorProduct.congr (AlgEquiv.ofInjective fa hfa)
(AlgEquiv.ofInjective fb hfb) |>.symm.toMulEquiv.isField H
-- need to be in this file since it uses linearly disjoint
open Cardinal Polynomial in
variable (R) in
/-- If `A` and `B` are flat `R`-algebras, both of them are transcendental, then `A ⊗[R] B` cannot
be a field. -/
theorem _root_.Algebra.TensorProduct.not_isField_of_transcendental
(A : Type v) [CommRing A] (B : Type w) [CommRing B] [Algebra R A] [Algebra R B]
[Module.Flat R A] [Module.Flat R B] [Algebra.Transcendental R A] [Algebra.Transcendental R B] :
¬IsField (A ⊗[R] B) := fun H ↦ by
letI := H.toField
obtain ⟨a, hta⟩ := ‹Algebra.Transcendental R A›
obtain ⟨b, htb⟩ := ‹Algebra.Transcendental R B›
have ha : Function.Injective (algebraMap R A) := Algebra.injective_of_transcendental
have hb : Function.Injective (algebraMap R B) := Algebra.injective_of_transcendental
let fa : A →ₐ[R] A ⊗[R] B := Algebra.TensorProduct.includeLeft
let fb : B →ₐ[R] A ⊗[R] B := Algebra.TensorProduct.includeRight
have hfa : Function.Injective fa := Algebra.TensorProduct.includeLeft_injective hb
have hfb : Function.Injective fb := Algebra.TensorProduct.includeRight_injective ha
haveI := hfa.isDomain fa.toRingHom
haveI := hfb.isDomain fb.toRingHom
haveI := ha.isDomain _
haveI : Module.Flat R (toSubmodule fa.range) :=
.of_linearEquiv (AlgEquiv.ofInjective fa hfa).symm.toLinearEquiv
have key1 : Module.rank R ↥(fa.range ⊓ fb.range) ≤ 1 :=
(include_range R A B).rank_inf_le_one_of_flat_left
let ga : R[X] →ₐ[R] A := aeval a
let gb : R[X] →ₐ[R] B := aeval b
let gab := fa.comp ga
replace hta : Function.Injective ga := transcendental_iff_injective.1 hta
replace htb : Function.Injective gb := transcendental_iff_injective.1 htb
have htab : Function.Injective gab := hfa.comp hta
algebraize_only [ga.toRingHom, gb.toRingHom]
let f := Algebra.TensorProduct.mapOfCompatibleSMul R[X] R A B
haveI := Algebra.TensorProduct.nontrivial_of_algebraMap_injective_of_isDomain R[X] A B hta htb
have hf : Function.Injective f := RingHom.injective _
have key2 : gab.range ≤ fa.range ⊓ fb.range := by
simp_rw [gab, ga, ← aeval_algHom]
rw [Algebra.TensorProduct.includeLeft_apply, ← Algebra.adjoin_singleton_eq_range_aeval]
simp_rw [Algebra.adjoin_le_iff, Set.singleton_subset_iff, Algebra.coe_inf, Set.mem_inter_iff,
AlgHom.coe_range, Set.mem_range]
refine ⟨⟨a, by simp [fa]⟩, ⟨b, hf ?_⟩⟩
simp_rw [fb, Algebra.TensorProduct.includeRight_apply, f,
Algebra.TensorProduct.mapOfCompatibleSMul_tmul]
convert ← (TensorProduct.smul_tmul (R := R[X]) (R' := R[X]) (M := A) (N := B) X 1 1).symm <;>
(simp_rw [Algebra.smul_def, mul_one]; exact aeval_X _)
have key3 := (Subalgebra.inclusion key2).comp (AlgEquiv.ofInjective gab htab).toAlgHom
|>.toLinearMap.lift_rank_le_of_injective
((Subalgebra.inclusion_injective key2).comp (AlgEquiv.injective _))
have := lift_uzero.{u} _ ▸ (basisMonomials R).mk_eq_rank.symm
simp only [this, mk_eq_aleph0, lift_aleph0, aleph0_le_lift] at key3
exact (key3.trans key1).not_gt one_lt_aleph0
variable (R) in
/-- If `A` and `B` are flat `R`-algebras, such that `A ⊗[R] B` is a field, then one of `A` and `B`
is algebraic over `R`. -/
theorem _root_.Algebra.TensorProduct.isAlgebraic_of_isField
(A : Type v) [CommRing A] (B : Type w) [CommRing B] [Algebra R A] [Algebra R B]
[Module.Flat R A] [Module.Flat R B] (H : IsField (A ⊗[R] B)) :
Algebra.IsAlgebraic R A ∨ Algebra.IsAlgebraic R B := by
by_contra! h
simp_rw [← Algebra.transcendental_iff_not_isAlgebraic] at h
obtain ⟨_, _⟩ := h
exact Algebra.TensorProduct.not_isField_of_transcendental R A B H
variable (H : A.LinearDisjoint B)
include H in
theorem rank_inf_eq_one_of_flat_of_inj (hf : Module.Flat R A ∨ Module.Flat R B)
(hinj : Function.Injective (algebraMap R S)) : Module.rank R ↥(A ⊓ B) = 1 :=
H.rank_inf_eq_one_of_commute_of_flat_of_inj hf (fun _ _ ↦ mul_comm _ _) hinj
include H in
theorem rank_inf_eq_one_of_flat_left_of_inj [Module.Flat R A]
(hinj : Function.Injective (algebraMap R S)) : Module.rank R ↥(A ⊓ B) = 1 :=
H.rank_inf_eq_one_of_commute_of_flat_left_of_inj (fun _ _ ↦ mul_comm _ _) hinj
include H in
theorem rank_inf_eq_one_of_flat_right_of_inj [Module.Flat R B]
(hinj : Function.Injective (algebraMap R S)) : Module.rank R ↥(A ⊓ B) = 1 :=
H.rank_inf_eq_one_of_commute_of_flat_right_of_inj (fun _ _ ↦ mul_comm _ _) hinj
theorem rank_eq_one_of_flat_of_self_of_inj (H : A.LinearDisjoint A) [Module.Flat R A]
(hinj : Function.Injective (algebraMap R S)) : Module.rank R A = 1 :=
H.rank_eq_one_of_commute_of_flat_of_self_of_inj (fun _ _ ↦ mul_comm _ _) hinj
include H in
/-- In a commutative ring, if subalgebras `A` and `B` are linearly disjoint and they are
free modules, then the rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`. -/
theorem rank_sup_of_free [Module.Free R A] [Module.Free R B] :
Module.rank R ↥(A ⊔ B) = Module.rank R A * Module.rank R B := by
nontriviality R
rw [← rank_tensorProduct', H.mulMap.toLinearEquiv.rank_eq]
include H in
/-- In a commutative ring, if subalgebras `A` and `B` are linearly disjoint and they are
free modules, then the rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`. -/
theorem finrank_sup_of_free [Module.Free R A] [Module.Free R B] :
Module.finrank R ↥(A ⊔ B) = Module.finrank R A * Module.finrank R B := by
simpa only [map_mul] using congr(Cardinal.toNat $(H.rank_sup_of_free))
/-- In a commutative ring, if `A` and `B` are subalgebras which are free modules of finite rank,
such that rank of `A ⊔ B` is equal to the product of the rank of `A` and `B`,
then `A` and `B` are linearly disjoint. -/
theorem of_finrank_sup_of_free [Module.Free R A] [Module.Free R B]
[Module.Finite R A] [Module.Finite R B]
(H : Module.finrank R ↥(A ⊔ B) = Module.finrank R A * Module.finrank R B) :
A.LinearDisjoint B := by
nontriviality R
rw [← Module.finrank_tensorProduct] at H
obtain ⟨j, hj⟩ := exists_linearIndependent_of_le_finrank H.ge
rw [LinearIndependent] at hj
let j' := Finsupp.linearCombination R j ∘ₗ
(LinearEquiv.ofFinrankEq (A ⊗[R] B) _ (by simp)).toLinearMap
replace hj : Function.Injective j' := by simpa [j']
have hf : Function.Surjective (mulMap' A B).toLinearMap := mulMap'_surjective A B
haveI := Subalgebra.finite_sup A B
rw [linearDisjoint_iff, Submodule.linearDisjoint_iff]
exact Subtype.val_injective.comp (OrzechProperty.injective_of_surjective_of_injective j' _ hj hf)
include H in
/-- If `A` and `B` are linearly disjoint, if `A` is free and `B` is flat,
then `[B[A] : B] = [A : R]`. See also `Subalgebra.adjoin_rank_le`. -/
theorem adjoin_rank_eq_rank_left [Module.Free R A] [Module.Flat R B]
[Nontrivial R] [Nontrivial S] :
Module.rank B (Algebra.adjoin B (A : Set S)) = Module.rank R A := by
rw [← rank_toSubmodule, Module.Free.rank_eq_card_chooseBasisIndex R A,
A.adjoin_eq_span_basis B (Module.Free.chooseBasis R A)]
change Module.rank B (Submodule.span B (Set.range (A.val ∘ Module.Free.chooseBasis R A))) = _
have := H.linearIndependent_left_of_flat (Module.Free.chooseBasis R A).linearIndependent
rw [rank_span this, Cardinal.mk_range_eq _ this.injective]
include H in
/-- If `A` and `B` are linearly disjoint, if `B` is free and `A` is flat,
then `[A[B] : A] = [B : R]`. See also `Subalgebra.adjoin_rank_le`. -/
theorem adjoin_rank_eq_rank_right [Module.Free R B] [Module.Flat R A]
[Nontrivial R] [Nontrivial S] :
Module.rank A (Algebra.adjoin A (B : Set S)) = Module.rank R B :=
H.symm.adjoin_rank_eq_rank_left
/-- If the rank of `A` and `B` are coprime, and they satisfy some freeness condition,
then `A` and `B` are linearly disjoint. -/
theorem of_finrank_coprime_of_free [Module.Free R A] [Module.Free R B]
[Module.Free A (Algebra.adjoin A (B : Set S))] [Module.Free B (Algebra.adjoin B (A : Set S))]
(H : (Module.finrank R A).Coprime (Module.finrank R B)) : A.LinearDisjoint B := by
nontriviality R
by_cases h1 : Module.finrank R A = 0
· rw [h1, Nat.coprime_zero_left] at H
rw [eq_bot_of_finrank_one H]
exact bot_right _
by_cases h2 : Module.finrank R B = 0
· rw [h2, Nat.coprime_zero_right] at H
rw [eq_bot_of_finrank_one H]
exact bot_left _
haveI := Module.finite_of_finrank_pos (Nat.pos_of_ne_zero h1)
haveI := Module.finite_of_finrank_pos (Nat.pos_of_ne_zero h2)
haveI := finite_sup A B
have : Module.finrank R A ≤ Module.finrank R ↥(A ⊔ B) :=
LinearMap.finrank_le_finrank_of_injective <|
Submodule.inclusion_injective (show toSubmodule A ≤ toSubmodule (A ⊔ B) by simp)
exact of_finrank_sup_of_free <| (finrank_sup_le_of_free A B).antisymm <|
Nat.le_of_dvd (lt_of_lt_of_le (Nat.pos_of_ne_zero h1) this) <| H.mul_dvd_of_dvd_of_dvd
(finrank_left_dvd_finrank_sup_of_free A B) (finrank_right_dvd_finrank_sup_of_free A B)
variable (A B)
/-- If `A/R` is integral, such that `A'` and `B` are linearly disjoint for all subalgebras `A'`
of `A` which are finitely generated `R`-modules, then `A` and `B` are linearly disjoint. -/
theorem of_linearDisjoint_finite_left [Algebra.IsIntegral R A]
(H : ∀ A' : Subalgebra R S, A' ≤ A → [Module.Finite R A'] → A'.LinearDisjoint B) :
A.LinearDisjoint B := by
rw [linearDisjoint_iff, Submodule.linearDisjoint_iff]
intro x y hxy
obtain ⟨M', hM, hf, h⟩ :=
TensorProduct.exists_finite_submodule_left_of_setFinite' {x, y} (Set.toFinite _)
obtain ⟨s, hs⟩ := Module.Finite.iff_fg.1 hf
have hs' : (s : Set S) ⊆ A := by rwa [← hs, Submodule.span_le] at hM
let A' := Algebra.adjoin R (s : Set S)
have hf' : Submodule.FG (toSubmodule A') := fg_adjoin_of_finite s.finite_toSet fun x hx ↦
(isIntegral_algHom_iff A.val Subtype.val_injective).2
(Algebra.IsIntegral.isIntegral (R := R) (A := A) ⟨x, hs' hx⟩)
replace hf' : Module.Finite R A' := Module.Finite.iff_fg.2 hf'
have hA : toSubmodule A' ≤ toSubmodule A := Algebra.adjoin_le_iff.2 hs'
replace h : {x, y} ⊆ (LinearMap.range (LinearMap.rTensor (toSubmodule B)
(Submodule.inclusion hA)) : Set _) := fun _ hx ↦ by
have : Submodule.inclusion hM = Submodule.inclusion hA ∘ₗ Submodule.inclusion
(show M' ≤ toSubmodule A' by
rw [← hs, Submodule.span_le]; exact Algebra.adjoin_le_iff.1 (le_refl _)) := rfl
rw [this, LinearMap.rTensor_comp] at h
exact LinearMap.range_comp_le_range _ _ (h hx)
obtain ⟨x', hx'⟩ := h (show x ∈ {x, y} by simp)
obtain ⟨y', hy'⟩ := h (show y ∈ {x, y} by simp)
rw [← hx', ← hy']; congr
exact (H A' hA).injective (by simp [← Submodule.mulMap_comp_rTensor _ hA, hx', hy', hxy])
/-- If `B/R` is integral, such that `A` and `B'` are linearly disjoint for all subalgebras `B'`
of `B` which are finitely generated `R`-modules, then `A` and `B` are linearly disjoint. -/
theorem of_linearDisjoint_finite_right [Algebra.IsIntegral R B]
(H : ∀ B' : Subalgebra R S, B' ≤ B → [Module.Finite R B'] → A.LinearDisjoint B') :
A.LinearDisjoint B :=
(of_linearDisjoint_finite_left B A fun B' hB' _ ↦ (H B' hB').symm).symm
variable {A B}
/-- If `A/R` and `B/R` are integral, such that any finite subalgebras in `A` and `B` are
linearly disjoint, then `A` and `B` are linearly disjoint. -/
theorem of_linearDisjoint_finite
[Algebra.IsIntegral R A] [Algebra.IsIntegral R B]
(H : ∀ (A' B' : Subalgebra R S), A' ≤ A → B' ≤ B →
[Module.Finite R A'] → [Module.Finite R B'] → A'.LinearDisjoint B') :
A.LinearDisjoint B :=
of_linearDisjoint_finite_left A B fun _ hA' _ ↦
of_linearDisjoint_finite_right _ B fun _ hB' _ ↦ H _ _ hA' hB'
end LinearDisjoint
end CommRing
section FieldAndRing
namespace LinearDisjoint
variable [Field R] [Ring S] [Algebra R S]
variable {A B : Subalgebra R S}
theorem inf_eq_bot_of_commute (H : A.LinearDisjoint B)
(hc : ∀ (a b : ↥(A ⊓ B)), Commute a.1 b.1) : A ⊓ B = ⊥ :=
eq_bot_of_rank_le_one (Submodule.LinearDisjoint.rank_inf_le_one_of_commute_of_flat_left H hc)
theorem eq_bot_of_commute_of_self (H : A.LinearDisjoint A)
(hc : ∀ (a b : A), Commute a.1 b.1) : A = ⊥ := by
rw [← inf_of_le_left (le_refl A)] at hc ⊢
exact H.inf_eq_bot_of_commute hc
end LinearDisjoint
end FieldAndRing
section FieldAndCommRing
namespace LinearDisjoint
variable [Field R] [CommRing S] [Algebra R S]
variable {A B : Subalgebra R S}
theorem inf_eq_bot (H : A.LinearDisjoint B) : A ⊓ B = ⊥ :=
H.inf_eq_bot_of_commute fun _ _ ↦ mul_comm _ _
theorem eq_bot_of_self (H : A.LinearDisjoint A) : A = ⊥ :=
H.eq_bot_of_commute_of_self fun _ _ ↦ mul_comm _ _
end LinearDisjoint
end FieldAndCommRing
end Subalgebra |
.lake/packages/mathlib/Mathlib/RingTheory/IsAdjoinRoot.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed
import Mathlib.RingTheory.PowerBasis
/-!
# A predicate on adjoining roots of polynomial
This file defines a predicate `IsAdjoinRoot S f`, which states that the ring `S` can be
constructed by adjoining a specified root of the polynomial `f : R[X]` to `R`.
This predicate is useful when the same ring can be generated by adjoining the root of different
polynomials, and you want to vary which polynomial you're considering.
The results in this file are intended to mirror those in `RingTheory.AdjoinRoot`,
in order to provide an easier way to translate results from one to the other.
## Motivation
`AdjoinRoot` presents one construction of a ring `R[α]`. However, it is possible to obtain
rings of this form in many ways, such as `NumberField.ringOfIntegers ℚ(√-5)`,
or `Algebra.adjoin R {α, α^2}`, or `IntermediateField.adjoin R {α, 2 - α}`,
or even if we want to view `ℂ` as adjoining a root of `X^2 + 1` to `ℝ`.
## Main definitions
The two main predicates in this file are:
* `IsAdjoinRoot S f`: `S` is generated by adjoining a specified root of `f : R[X]` to `R`
* `IsAdjoinRootMonic S f`: `S` is generated by adjoining a root of the monic polynomial
`f : R[X]` to `R`
Using `IsAdjoinRoot` to map into `S`:
* `IsAdjoinRoot.map`: inclusion from `R[X]` to `S`
* `IsAdjoinRoot.root`: the specific root adjoined to `R` to give `S`
Using `IsAdjoinRoot` to map out of `S`:
* `IsAdjoinRoot.repr`: choose a non-unique representative in `R[X]`
* `IsAdjoinRoot.lift`, `IsAdjoinRoot.liftHom`: lift a morphism `R →+* T` to `S →+* T`
* `IsAdjoinRootMonic.modByMonicHom`: a unique representative in `R[X]` if `f` is monic
## Main results
* `AdjoinRoot.isAdjoinRoot` and `AdjoinRoot.isAdjoinRootMonic`:
`AdjoinRoot` satisfies the conditions on `IsAdjoinRoot`(`Monic`)
* `IsAdjoinRootMonic.powerBasis`: the `root` generates a power basis on `S` over `R`
* `IsAdjoinRoot.algEquiv`: algebra isomorphism showing adjoining a root gives a unique ring
up to isomorphism
* `IsAdjoinRoot.ofAlgEquiv`: transfer `IsAdjoinRoot` across an algebra isomorphism
* `IsAdjoinRootMonic.minpoly_eq`: the minimal polynomial of the adjoined root of `f` is equal to
`f`, if `f` is irreducible and monic, and `R` is a GCD domain
-/
open Module Polynomial
noncomputable section
universe u v
-- This class doesn't really make sense on a predicate
/-- `IsAdjoinRoot S f` states that the ring `S` can be constructed by adjoining a specified root
of the polynomial `f : R[X]` to `R`.
Compare `PowerBasis R S`, which does not explicitly specify which polynomial we adjoin a root of
(in particular `f` does not need to be the minimal polynomial of the root we adjoin),
and `AdjoinRoot` which constructs a new type.
This is not a typeclass because the choice of root given `S` and `f` is not unique.
-/
structure IsAdjoinRoot {R : Type u} (S : Type v) [CommSemiring R] [Semiring S] [Algebra R S]
(f : R[X]) : Type max u v where
map : R[X] →ₐ[R] S
map_surjective : Function.Surjective map
ker_map : RingHom.ker map = Ideal.span {f}
-- This class doesn't really make sense on a predicate
/-- `IsAdjoinRootMonic S f` states that the ring `S` can be constructed by adjoining a specified
root of the monic polynomial `f : R[X]` to `R`.
As long as `f` is monic, there is a well-defined representation of elements of `S` as polynomials
in `R[X]` of degree lower than `deg f` (see `modByMonicHom` and `coeff`). In particular,
we have `IsAdjoinRootMonic.powerBasis`.
Bundling `Monic` into this structure is very useful when working with explicit `f`s such as
`X^2 - C a * X - C b` since it saves you carrying around the proofs of monicity.
-/
structure IsAdjoinRootMonic {R : Type u} (S : Type v) [CommSemiring R] [Semiring S] [Algebra R S]
(f : R[X]) extends IsAdjoinRoot S f where
monic : Monic f
@[deprecated (since := "2025-07-26")] alias IsAdjoinRootMonic.Monic := IsAdjoinRootMonic.monic
section Ring
variable {R : Type u} {S : Type v} [CommRing R] [Ring S] {f : R[X]} [Algebra R S]
namespace IsAdjoinRoot
variable (h : IsAdjoinRoot S f)
/-- `(h : IsAdjoinRoot S f).root` is the root of `f` that can be adjoined to generate `S`. -/
def root : S := h.map X
set_option linter.unusedSectionVars false in
include h in
@[deprecated "use Algebra.subsingleton" (since := "2025-09-10")]
theorem subsingleton [Subsingleton R] : Subsingleton S := by
have := h; exact Algebra.subsingleton R S
theorem algebraMap_apply (x : R) :
algebraMap R S x = h.map (Polynomial.C x) := AlgHom.algebraMap_eq_apply h.map rfl
theorem mem_ker_map {p} : p ∈ RingHom.ker h.map ↔ f ∣ p := by
rw [h.ker_map, Ideal.mem_span_singleton]
@[simp]
theorem map_eq_zero_iff {p} : h.map p = 0 ↔ f ∣ p := by simpa using h.mem_ker_map
@[simp]
theorem map_X : h.map X = h.root := rfl
@[simp]
theorem map_self : h.map f = 0 := by simp
@[simp]
theorem aeval_root_eq_map : aeval h.root = h.map := by ext; simp
@[deprecated (since := "2025-07-23")] alias aeval_eq := aeval_root_eq_map
theorem aeval_root_self : aeval h.root f = 0 := by simp
@[deprecated (since := "2025-07-23")] alias aeval_root := aeval_root_self
theorem adjoin_root_eq_top : Algebra.adjoin R {h.root} = ⊤ := by
rw [Algebra.adjoin_singleton_eq_range_aeval, AlgHom.range_eq_top, aeval_root_eq_map]
exact h.map_surjective
/-- Extensionality of the `IsAdjoinRoot` structure itself. See `IsAdjoinRootMonic.ext_elem`
for extensionality of the ring elements. -/
theorem ext_map (h' : IsAdjoinRoot S f) (eq : ∀ x, h.map x = h'.map x) : h = h' := by
cases h; cases h'; congr
exact AlgHom.ext eq
/-- Extensionality of the `IsAdjoinRoot` structure itself. See `IsAdjoinRootMonic.ext_elem`
for extensionality of the ring elements. -/
@[ext]
theorem ext (h' : IsAdjoinRoot S f) (eq : h.root = h'.root) : h = h' :=
h.ext_map h' (fun x => by rw [← h.aeval_root_eq_map, ← h'.aeval_root_eq_map, eq])
/-- Choose an arbitrary representative so that `h.map (h.repr x) = x`.
If `f` is monic, use `IsAdjoinRootMonic.modByMonicHom` for a unique choice of representative.
-/
def repr (x : S) : R[X] := (h.map_surjective x).choose
@[simp]
theorem map_repr (x : S) : h.map (h.repr x) = x := (h.map_surjective x).choose_spec
/-- `repr` preserves zero, up to multiples of `f` -/
theorem repr_zero_mem_span : h.repr 0 ∈ Ideal.span ({f} : Set R[X]) := by simp [← h.ker_map]
/-- `repr` preserves addition, up to multiples of `f` -/
theorem repr_add_sub_repr_add_repr_mem_span (x y : S) :
h.repr (x + y) - (h.repr x + h.repr y) ∈ Ideal.span ({f} : Set R[X]) := by simp [← h.ker_map]
section Equiv
variable {T : Type*} [Ring T] [Algebra R T]
/-- Algebra isomorphism with `R[X]/(f)`. -/
def adjoinRootAlgEquiv : AdjoinRoot f ≃ₐ[R] S :=
(Ideal.quotientEquivAlgOfEq R h.ker_map.symm).trans <|
Ideal.quotientKerAlgEquivOfSurjective h.map_surjective
@[simp]
theorem adjoinRootAlgEquiv_apply_mk (g : R[X]) :
h.adjoinRootAlgEquiv (AdjoinRoot.mk f g) = h.map g := rfl
theorem adjoinRootAlgEquiv_apply_eq_map (a : AdjoinRoot f) :
h.adjoinRootAlgEquiv a = h.map (AdjoinRoot.mk_surjective a).choose := by
rw (occs := [1]) [← (AdjoinRoot.mk_surjective a).choose_spec, adjoinRootAlgEquiv_apply_mk]
theorem adjoinRootAlgEquiv_symm_apply_eq_mk (a : S) :
h.adjoinRootAlgEquiv.symm a = AdjoinRoot.mk f (h.repr a) := by
rw (occs := [1]) [AlgEquiv.symm_apply_eq, ← h.map_repr a, adjoinRootAlgEquiv_apply_mk]
@[simp]
theorem adjoinRootAlgEquiv_apply_root : h.adjoinRootAlgEquiv (AdjoinRoot.root f) = h.root := rfl
@[simp]
theorem adjoinRootAlgEquiv_symm_apply_root : h.adjoinRootAlgEquiv.symm h.root = AdjoinRoot.root f :=
(AlgEquiv.symm_apply_eq h.adjoinRootAlgEquiv).mpr rfl
variable (h' : IsAdjoinRoot T f)
/-- Adjoining a root gives a unique algebra up to isomorphism.
This is the converse of `IsAdjoinRoot.ofAlgEquiv`: this turns an `IsAdjoinRoot` into an
`AlgEquiv`, and `IsAdjoinRoot.ofAlgEquiv` turns an `AlgEquiv` into an `IsAdjoinRoot`.
-/
def algEquiv : S ≃ₐ[R] T := h.adjoinRootAlgEquiv.symm.trans h'.adjoinRootAlgEquiv
@[deprecated (since := "2025-08-13")] noncomputable alias aequiv := algEquiv
theorem algEquiv_def : h.algEquiv h' = h.adjoinRootAlgEquiv.symm.trans h'.adjoinRootAlgEquiv := rfl
@[simp]
theorem algEquiv_root : h.algEquiv h' h.root = h'.root := by simp [algEquiv_def]
@[deprecated (since := "2025-08-13")] alias aequiv_root := algEquiv_root
@[simp]
theorem algEquiv_map : AlgHom.comp (h.algEquiv h') h.map = h'.map := by
ext; simp
@[deprecated (since := "2025-08-13")] alias aequiv_map := algEquiv_map
@[simp]
theorem algEquiv_apply_map (z : R[X]) : h.algEquiv h' (h.map z) = h'.map z := by
rw [← h.algEquiv_map h']; simp [-algEquiv_map]
@[simp] theorem algEquiv_self : h.algEquiv h = AlgEquiv.refl := by ext; simp [algEquiv_def]
@[deprecated (since := "2025-08-13")] alias aequiv_self := algEquiv_self
@[simp] theorem algEquiv_symm : (h.algEquiv h').symm = h'.algEquiv h := rfl
@[deprecated (since := "2025-08-13")] alias aequiv_symm := algEquiv_symm
@[simp]
theorem algEquiv_algEquiv {U : Type*} [Ring U] [Algebra R U] (h'' : IsAdjoinRoot U f) (x) :
(h'.algEquiv h'') (h.algEquiv h' x) = h.algEquiv h'' x := by simp [algEquiv_def]
@[deprecated (since := "2025-08-13")] alias aequiv_aequiv := algEquiv_algEquiv
@[simp]
theorem algEquiv_trans {U : Type*} [Ring U] [Algebra R U] (h'' : IsAdjoinRoot U f) :
(h.algEquiv h').trans (h'.algEquiv h'') = h.algEquiv h'' := by ext; simp
@[deprecated (since := "2025-08-13")] alias aequiv_trans := algEquiv_trans
/-- Transfer `IsAdjoinRoot` across an algebra isomorphism.
This is the converse of `IsAdjoinRoot.algEquiv`: this turns an `AlgEquiv` into an `IsAdjoinRoot`,
and `IsAdjoinRoot.algEquiv` turns an `IsAdjoinRoot` into an `AlgEquiv`.
-/
@[simps! map_apply]
def ofAlgEquiv (e : S ≃ₐ[R] T) : IsAdjoinRoot T f where
map := (e : S →ₐ[R] T).comp h.map
map_surjective := e.surjective.comp h.map_surjective
ker_map := by ext; simp [Ideal.mem_span_singleton]
@[deprecated (since := "2025-08-13")] alias ofEquiv := ofAlgEquiv
@[simp] theorem ofAlgEquiv_root (e : S ≃ₐ[R] T) : (h.ofAlgEquiv e).root = e h.root := rfl
@[deprecated (since := "2025-08-13")] alias ofEquiv_root := ofAlgEquiv_root
@[simp]
theorem algEquiv_ofAlgEquiv {U : Type*} [Ring U] [Algebra R U] (e : T ≃ₐ[R] U) :
h.algEquiv (h'.ofAlgEquiv e) = (h.algEquiv h').trans e := by
ext a
simp [algEquiv_def, AlgEquiv.trans_apply, adjoinRootAlgEquiv_apply_eq_map, ofAlgEquiv_map_apply]
@[deprecated (since := "2025-08-13")] alias aequiv_ofEquiv := algEquiv_ofAlgEquiv
@[simp]
theorem ofAlgEquiv_algEquiv {U : Type*} [Ring U] [Algebra R U] (h'' : IsAdjoinRoot U f)
(e : S ≃ₐ[R] T) : (h.ofAlgEquiv e).algEquiv h'' = e.symm.trans (h.algEquiv h'') := by
ext a
simp_rw [algEquiv_def, AlgEquiv.trans_apply, EmbeddingLike.apply_eq_iff_eq,
AlgEquiv.symm_apply_eq, adjoinRootAlgEquiv_apply_eq_map, ofAlgEquiv_map_apply,
← adjoinRootAlgEquiv_apply_eq_map, AlgEquiv.apply_symm_apply]
@[deprecated (since := "2025-08-13")] alias ofEquiv_aequiv := ofAlgEquiv_algEquiv
end Equiv
section lift
variable {T : Type*} [CommRing T] {i : R →+* T} {x : T}
section
variable (hx : f.eval₂ i x = 0)
include hx
/-- Auxiliary lemma for `IsAdjoinRoot.lift` -/
theorem eval₂_repr_eq_eval₂_of_map_eq (z : S) (w : R[X])
(hzw : h.map w = z) : (h.repr z).eval₂ i x = w.eval₂ i x := by
rw [eq_comm, ← sub_eq_zero, ← h.map_repr z, ← map_sub, h.map_eq_zero_iff] at hzw
obtain ⟨y, hy⟩ := hzw
rw [← sub_eq_zero, ← eval₂_sub, hy, eval₂_mul, hx, zero_mul]
variable (i x)
-- To match `AdjoinRoot.lift`
/-- Lift a ring homomorphism `R →+* T` to `S →+* T` by specifying a root `x` of `f` in `T`,
where `S` is given by adjoining a root of `f` to `R`. -/
def lift (hx : f.eval₂ i x = 0) : S →+* T where
toFun z := (h.repr z).eval₂ i x
map_zero' := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ _ (map_zero _)]
map_add' z w := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ (h.repr z + h.repr w)]
map_one' := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ _ (map_one _)]
map_mul' z w := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ (h.repr z * h.repr w)]
variable {i x}
@[simp]
theorem lift_map (z : R[X]) : h.lift i x hx (h.map z) = z.eval₂ i x := by
simp [lift, h.eval₂_repr_eq_eval₂_of_map_eq hx _ _ rfl]
@[simp]
theorem lift_root : h.lift i x hx h.root = x := by
rw [← h.map_X, lift_map, eval₂_X]
@[simp]
theorem lift_algebraMap (a : R) : h.lift i x hx (algebraMap R S a) = i a := by
simp [h.algebraMap_apply]
/-- Auxiliary lemma for `apply_eq_lift` -/
theorem apply_eq_lift (g : S →+* T) (hmap : ∀ a, g (algebraMap R S a) = i a)
(hroot : g h.root = x) (a : S) : g a = h.lift i x hx a := by
rw [← h.map_repr a, Polynomial.as_sum_range_C_mul_X_pow (h.repr a)]
simp [← h.algebraMap_apply, *]
/-- Unicity of `lift`: a map that agrees on `R` and `h.root` agrees with `lift` everywhere. -/
theorem eq_lift (g : S →+* T) (hmap : ∀ a, g (algebraMap R S a) = i a) (hroot : g h.root = x) :
g = h.lift i x hx := RingHom.ext (h.apply_eq_lift hx g hmap hroot)
end
variable [Algebra R T] (hx' : aeval x f = 0)
variable (x) in
-- To match `AdjoinRoot.liftHom`
/-- Lift the algebra map `R → T` to `S →ₐ[R] T` by specifying a root `x` of `f` in `T`,
where `S` is given by adjoining a root of `f` to `R`. -/
def liftHom : S →ₐ[R] T :=
{ h.lift (algebraMap R T) x hx' with commutes' a := h.lift_algebraMap hx' a }
@[simp]
theorem coe_liftHom : (h.liftHom x hx' : S →+* T) = h.lift (algebraMap R T) x hx' := rfl
theorem lift_algebraMap_apply (z : S) : h.lift (algebraMap R T) x hx' z = h.liftHom x hx' z := rfl
@[simp]
theorem liftHom_map (z : R[X]) : h.liftHom x hx' (h.map z) = aeval x z := by
rw [← lift_algebraMap_apply, lift_map, aeval_def]
@[simp]
theorem liftHom_root : h.liftHom x hx' h.root = x := by rw [← lift_algebraMap_apply, lift_root]
/-- Unicity of `liftHom`: a map that agrees on `h.root` agrees with `liftHom` everywhere. -/
theorem eq_liftHom (g : S →ₐ[R] T) (hroot : g h.root = x) : g = h.liftHom x hx' :=
AlgHom.ext (h.apply_eq_lift hx' g g.commutes hroot)
end lift
theorem isAlgebraic_root (hf : f ≠ 0) : IsAlgebraic R h.root := ⟨f, by simp [hf]⟩
end IsAdjoinRoot
namespace AdjoinRoot
variable (f)
/-- `AdjoinRoot f` is indeed given by adjoining a root of `f`. -/
protected def isAdjoinRoot : IsAdjoinRoot (AdjoinRoot f) f where
map := AdjoinRoot.mkₐ f
map_surjective := Ideal.Quotient.mkₐ_surjective _ _
ker_map := by ext; simp [Ideal.mem_span_singleton]
/-- `AdjoinRoot f` is indeed given by adjoining a root of `f`. If `f` is monic this is more
powerful than `AdjoinRoot.isAdjoinRoot`. -/
protected def isAdjoinRootMonic (hf : Monic f) : IsAdjoinRootMonic (AdjoinRoot f) f where
__ := AdjoinRoot.isAdjoinRoot f
monic := hf
@[simp]
theorem isAdjoinRootMonic_toAdjoinRoot (hf : Monic f) :
(AdjoinRoot.isAdjoinRootMonic f hf).toIsAdjoinRoot = AdjoinRoot.isAdjoinRoot f := rfl
theorem isAdjoinRoot_map_eq_mkₐ : (AdjoinRoot.isAdjoinRoot f).map = AdjoinRoot.mkₐ f := rfl
@[deprecated (since := "2025-08-07")] alias isAdjoinRoot_map_eq_mk := isAdjoinRoot_map_eq_mkₐ
@[deprecated "Use `simp` and `isAdjoinRoot_map_eq_mkₐ` instead" (since := "2025-08-07")]
theorem isAdjoinRootMonic_map_eq_mk (hf : f.Monic) :
(AdjoinRoot.isAdjoinRootMonic f hf).map = AdjoinRoot.mk f := by
simp [isAdjoinRoot_map_eq_mkₐ]
@[simp]
theorem isAdjoinRoot_root_eq_root : (AdjoinRoot.isAdjoinRoot f).root = AdjoinRoot.root f := by
simp [AdjoinRoot.isAdjoinRoot, IsAdjoinRoot.root]
@[deprecated "Use `simp` instead" (since := "2025-08-07")]
theorem isAdjoinRootMonic_root_eq_root (hf : Monic f) :
(AdjoinRoot.isAdjoinRootMonic f hf).root = AdjoinRoot.root f := by simp
end AdjoinRoot
/-- If `S` is `R`-isomorphic to `R[X]/(f)`, then `S` is given by adjoining a root of `f`. -/
abbrev IsAdjoinRoot.ofAdjoinRootEquiv (e : AdjoinRoot f ≃ₐ[R] S) : IsAdjoinRoot S f :=
ofAlgEquiv (AdjoinRoot.isAdjoinRoot f) e
namespace IsAdjoinRootMonic
variable (h : IsAdjoinRootMonic S f)
open IsAdjoinRoot
theorem map_modByMonic (g : R[X]) : h.map (g %ₘ f) = h.map g := by
rw [← RingHom.sub_mem_ker_iff, mem_ker_map, modByMonic_eq_sub_mul_div _ h.monic, sub_right_comm,
sub_self, zero_sub, dvd_neg]
exact ⟨_, rfl⟩
theorem modByMonic_repr_map (g : R[X]) : h.repr (h.map g) %ₘ f = g %ₘ f :=
modByMonic_eq_of_dvd_sub h.monic <| by rw [← h.mem_ker_map, RingHom.sub_mem_ker_iff, map_repr]
/-- `IsAdjoinRoot.modByMonicHom` sends the equivalence class of `f` mod `g` to `f %ₘ g`. -/
def modByMonicHom : S →ₗ[R] R[X] where
toFun x := h.repr x %ₘ f
map_add' x y := by
conv_lhs =>
rw [← h.map_repr x, ← h.map_repr y, ← map_add, h.modByMonic_repr_map, add_modByMonic]
map_smul' c x := by
rw [RingHom.id_apply, ← h.map_repr x, Algebra.smul_def, h.algebraMap_apply, ← map_mul,
h.modByMonic_repr_map, ← smul_eq_C_mul, smul_modByMonic, h.map_repr]
@[simp]
theorem modByMonicHom_map (g : R[X]) : h.modByMonicHom (h.map g) = g %ₘ f :=
h.modByMonic_repr_map g
@[simp]
theorem map_modByMonicHom (x : S) : h.map (h.modByMonicHom x) = x := by
simp [modByMonicHom, map_modByMonic, map_repr]
@[simp]
theorem modByMonicHom_root_pow {n : ℕ} (hdeg : n < natDegree f) :
h.modByMonicHom (h.root ^ n) = X ^ n := by
nontriviality R
rw [← h.map_X, ← map_pow, modByMonicHom_map, modByMonic_eq_self_iff h.monic, degree_X_pow]
contrapose! hdeg
simpa [natDegree_le_iff_degree_le] using hdeg
@[simp]
theorem modByMonicHom_root (hdeg : 1 < natDegree f) : h.modByMonicHom h.root = X := by
simpa using modByMonicHom_root_pow h hdeg
/-- The basis on `S` generated by powers of `h.root`.
Auxiliary definition for `IsAdjoinRootMonic.powerBasis`. -/
def basis : Basis (Fin (natDegree f)) R S :=
Basis.ofRepr
{ toFun x := (h.modByMonicHom x).toFinsupp.comapDomain _ Fin.val_injective.injOn
invFun g := h.map (ofFinsupp (g.mapDomain Fin.val))
left_inv x := by
nontriviality R using Algebra.subsingleton R S
simp only
rw [Finsupp.mapDomain_comapDomain, Polynomial.eta, h.map_modByMonicHom x]
· exact Fin.val_injective
intro i hi
refine Set.mem_range.mpr ⟨⟨i, ?_⟩, rfl⟩
contrapose! hi
simp only [Polynomial.toFinsupp_apply, Classical.not_not, Finsupp.mem_support_iff, Ne,
modByMonicHom, LinearMap.coe_mk, Finset.mem_coe]
obtain rfl | hf := eq_or_ne f 1
· simp
· exact coeff_eq_zero_of_natDegree_lt <| (natDegree_modByMonic_lt _ h.monic hf).trans_le hi
right_inv g := by
nontriviality R
ext i
simp only [h.modByMonicHom_map, Finsupp.comapDomain_apply, Polynomial.toFinsupp_apply]
rw [(Polynomial.modByMonic_eq_self_iff h.monic).mpr, Polynomial.coeff]
· rw [Finsupp.mapDomain_apply Fin.val_injective]
rw [degree_eq_natDegree h.monic.ne_zero, degree_lt_iff_coeff_zero]
intro m hm
rw [Polynomial.coeff]
rw [Finsupp.mapDomain_notin_range]
rw [Set.mem_range, not_exists]
rintro i rfl
exact i.prop.not_ge hm
map_add' := by simp [Finsupp.comapDomain_add_of_injective Fin.val_injective]
map_smul' := by simp [Finsupp.comapDomain_smul_of_injective Fin.val_injective] }
@[simp]
theorem basis_apply (i) : h.basis i = h.root ^ (i : ℕ) :=
Basis.apply_eq_iff.mpr <| by simp [IsAdjoinRootMonic.basis]
include h in
theorem deg_pos [Nontrivial S] : 0 < natDegree f := by
rcases h.basis.index_nonempty with ⟨⟨i, hi⟩⟩
exact Nat.zero_lt_of_lt hi
include h in
theorem deg_ne_zero [Nontrivial S] : natDegree f ≠ 0 := h.deg_pos.ne'
/-- If `f` is monic, the powers of `h.root` form a basis. -/
@[simps! gen dim basis]
def powerBasis : PowerBasis R S where
gen := h.root
dim := natDegree f
basis := h.basis
basis_eq_pow := h.basis_apply
@[simp]
theorem basis_repr (x : S) (i : Fin (natDegree f)) :
h.basis.repr x i = (h.modByMonicHom x).coeff (i : ℕ) := by
simp [IsAdjoinRootMonic.basis, toFinsupp_apply]
theorem basis_one (hdeg : 1 < natDegree f) : h.basis ⟨1, hdeg⟩ = h.root := by
rw [h.basis_apply, Fin.val_mk, pow_one]
include h in
theorem finite : Module.Finite R S := (powerBasis h).finite
include h in
theorem finrank [StrongRankCondition R] : Module.finrank R S = f.natDegree :=
(powerBasis h).finrank
/--
See `finrank_quotient_span_eq_natDegree` for a more general version over a field.
-/
theorem _root_.finrank_quotient_span_eq_natDegree' [StrongRankCondition R] (hf : f.Monic) :
Module.finrank R (R[X] ⧸ Ideal.span {f}) = f.natDegree :=
(AdjoinRoot.isAdjoinRootMonic _ hf).finrank
/-- `IsAdjoinRootMonic.liftPolyₗ` lifts a linear map on polynomials to a linear map on `S`. -/
@[simps!]
def liftPolyₗ {T : Type*} [AddCommGroup T] [Module R T] (g : R[X] →ₗ[R] T) : S →ₗ[R] T :=
g.comp h.modByMonicHom
/-- `IsAdjoinRootMonic.coeff h x i` is the `i`th coefficient of the representative of `x : S`.
-/
def coeff : S →ₗ[R] ℕ → R :=
h.liftPolyₗ
{ toFun := Polynomial.coeff
map_add' p q := funext (Polynomial.coeff_add p q)
map_smul' c p := funext (Polynomial.coeff_smul c p) }
theorem coeff_apply_lt (z : S) (i : ℕ) (hi : i < natDegree f) :
h.coeff z i = h.basis.repr z ⟨i, hi⟩ := by
simp [coeff]
theorem coeff_apply_coe (z : S) (i : Fin (natDegree f)) : h.coeff z i = h.basis.repr z i :=
h.coeff_apply_lt z i i.prop
theorem coeff_apply_le (z : S) (i : ℕ) (hi : natDegree f ≤ i) : h.coeff z i = 0 := by
simp only [coeff, liftPolyₗ_apply, LinearMap.coe_mk, AddHom.coe_mk]
nontriviality R
exact
Polynomial.coeff_eq_zero_of_degree_lt
((degree_modByMonic_lt _ h.monic).trans_le (Polynomial.degree_le_of_natDegree_le hi))
theorem coeff_apply (z : S) (i : ℕ) :
h.coeff z i = if hi : i < natDegree f then h.basis.repr z ⟨i, hi⟩ else 0 := by
split_ifs with hi
· exact h.coeff_apply_lt z i hi
· exact h.coeff_apply_le z i (le_of_not_gt hi)
theorem coeff_root_pow {n} (hn : n < natDegree f) : h.coeff (h.root ^ n) = Pi.single n 1 := by
ext i
rw [coeff_apply]
split_ifs with hi
· calc
h.basis.repr (h.root ^ n) ⟨i, _⟩ = h.basis.repr (h.basis ⟨n, hn⟩) ⟨i, hi⟩ := by
rw [h.basis_apply, Fin.val_mk]
_ = Pi.single (M := fun _ => R) ((⟨n, hn⟩ : Fin _) : ℕ) (1 : (fun _ => R) n)
↑(⟨i, _⟩ : Fin _) := by
rw [h.basis.repr_self, ← Finsupp.single_eq_pi_single,
Finsupp.single_apply_left Fin.val_injective]
_ = Pi.single (M := fun _ => R) n 1 i := by rw [Fin.val_mk, Fin.val_mk]
· rw [Pi.single_eq_of_ne]
rintro rfl
simp [hi] at hn
theorem coeff_one [Nontrivial S] : h.coeff 1 = Pi.single 0 1 := by
rw [← h.coeff_root_pow h.deg_pos, pow_zero]
theorem coeff_root (hdeg : 1 < natDegree f) : h.coeff h.root = Pi.single 1 1 := by
rw [← h.coeff_root_pow hdeg, pow_one]
theorem coeff_algebraMap [Nontrivial S] (x : R) : h.coeff (algebraMap R S x) = Pi.single 0 x := by
ext i
rw [Algebra.algebraMap_eq_smul_one, map_smul, coeff_one, Pi.smul_apply, smul_eq_mul]
refine (Pi.apply_single (fun _ y => x * y) ?_ 0 1 i).trans (by simp)
simp
theorem ext_elem ⦃x y : S⦄ (hxy : ∀ i < natDegree f, h.coeff x i = h.coeff y i) : x = y :=
EquivLike.injective h.basis.equivFun <|
funext fun i => by
rw [Basis.equivFun_apply, ← h.coeff_apply_coe, Basis.equivFun_apply, ← h.coeff_apply_coe,
hxy i i.prop]
theorem ext_elem_iff {x y : S} : x = y ↔ ∀ i < natDegree f, h.coeff x i = h.coeff y i :=
⟨fun hxy _ _=> hxy ▸ rfl, fun hxy => h.ext_elem hxy⟩
theorem coeff_injective : Function.Injective h.coeff := fun _ _ hxy =>
h.ext_elem fun _ _ => hxy ▸ rfl
theorem isIntegral_root : IsIntegral R h.root := ⟨f, h.monic, h.aeval_root_self⟩
end IsAdjoinRootMonic
end Ring
section CommRing
variable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S] {f : R[X]}
namespace IsAdjoinRoot
variable (h : IsAdjoinRoot S f)
section lift
@[simp]
theorem lift_self_apply (x : S) : h.lift (algebraMap R S) h.root h.aeval_root_self x = x := by
rw [← h.map_repr x, lift_map, ← aeval_def, h.aeval_root_eq_map]
theorem lift_self : h.lift (algebraMap R S) h.root h.aeval_root_self = RingHom.id S :=
RingHom.ext h.lift_self_apply
end lift
section mkOfAdjoinEqTop
variable [IsDomain R] [IsDomain S] [NoZeroSMulDivisors R S] [IsIntegrallyClosed R]
{α : S} {hα : IsIntegral R α} {hα₂ : Algebra.adjoin R {α} = ⊤}
variable (hα hα₂) in
/-- If `α` generates `S` as an algebra, then `S` is given by adjoining a root of `minpoly R α`. -/
def mkOfAdjoinEqTop : IsAdjoinRoot S (minpoly R α) where
map := aeval α
map_surjective := by
rw [← Set.range_eq_univ, ← AlgHom.coe_range, ← Algebra.adjoin_singleton_eq_range_aeval,
hα₂, Algebra.coe_top]
ker_map := by
ext
simpa [Ideal.mem_span_singleton] using minpoly.isIntegrallyClosed_dvd_iff hα _
variable (hα hα₂) in
/-- If `α` generates `S` as an algebra, then `S` is given by adjoining a root of `minpoly R α`. -/
abbrev _root_.IsAdjoinRootMonic.mkOfAdjoinEqTop : IsAdjoinRootMonic S (minpoly R α) where
__ := IsAdjoinRoot.mkOfAdjoinEqTop hα hα₂
monic := minpoly.monic hα
@[simp]
theorem mkOfAdjoinEqTop_root : (IsAdjoinRoot.mkOfAdjoinEqTop hα hα₂).root = α := by
simp [IsAdjoinRoot.mkOfAdjoinEqTop, IsAdjoinRoot.root]
end mkOfAdjoinEqTop
section Equiv
variable {T : Type*} [CommRing T] [Algebra R T] (h' : IsAdjoinRoot T f) {U : Type*} [CommRing U]
@[simp]
theorem lift_algEquiv (i : R →+* U) (x hx z) :
h'.lift i x hx (h.algEquiv h' z) = h.lift i x hx z := by rw [← h.map_repr z]; simp [- map_repr]
@[deprecated (since := "2025-08-13")] alias lift_aequiv := lift_algEquiv
@[simp]
theorem liftHom_algEquiv [Algebra R U] (x : U) (hx z) :
h'.liftHom x hx (h.algEquiv h' z) = h.liftHom x hx z := h.lift_algEquiv h' _ _ hx _
@[deprecated (since := "2025-08-13")] alias liftHom_aequiv := liftHom_algEquiv
end Equiv
end IsAdjoinRoot
namespace IsAdjoinRootMonic
variable (h : IsAdjoinRootMonic S f)
theorem minpoly_eq [IsDomain R] [IsDomain S] [NoZeroSMulDivisors R S] [IsIntegrallyClosed R]
(hirr : Irreducible f) : minpoly R h.root = f :=
let ⟨q, hq⟩ := minpoly.isIntegrallyClosed_dvd h.isIntegral_root h.aeval_root_self
symm <|
eq_of_monic_of_associated h.monic (minpoly.monic h.isIntegral_root) <| by
convert
Associated.mul_left (minpoly R h.root) <|
associated_one_iff_isUnit.2 <|
(hirr.isUnit_or_isUnit hq).resolve_left <| minpoly.not_isUnit R h.root
rw [mul_one]
end IsAdjoinRootMonic
section Algebra
open AdjoinRoot IsAdjoinRoot minpoly PowerBasis IsAdjoinRootMonic Algebra
theorem Algebra.adjoin.powerBasis'_minpoly_gen [IsDomain R] [IsDomain S] [NoZeroSMulDivisors R S]
[IsIntegrallyClosed R] {x : S} (hx' : IsIntegral R x) :
minpoly R x = minpoly R (Algebra.adjoin.powerBasis' hx').gen := by
have := isDomain_of_prime (prime_of_isIntegrallyClosed hx')
have :=
noZeroSMulDivisors_of_prime_of_degree_ne_zero (prime_of_isIntegrallyClosed hx')
(degree_pos hx').ne'
rw [← minpolyGen_eq, adjoin.powerBasis', minpolyGen_map, minpolyGen_eq,
AdjoinRoot.powerBasis'_gen, ← isAdjoinRoot_root_eq_root _,
← isAdjoinRootMonic_toAdjoinRoot _ (monic hx'),
minpoly_eq (AdjoinRoot.isAdjoinRootMonic _ (monic hx')) (irreducible hx')]
end Algebra
end CommRing
section Field
open scoped IntermediateField
variable {F E : Type*} [Field F] [Field E] [Algebra F E] {f : F[X]}
namespace IsAdjoinRoot
theorem primitive_element_root (h : IsAdjoinRoot E f) : F⟮h.root⟯ = ⊤ :=
IntermediateField.adjoin_eq_top_of_algebra F {h.root} (adjoin_root_eq_top h)
/-- If `α` is primitive in `E/f`, then `E` is given by adjoining a root of `minpoly F α`. -/
abbrev mkOfPrimitiveElement {α : E} (hα : IsIntegral F α) (hα₂ : F⟮α⟯ = ⊤) :
IsAdjoinRoot E (minpoly F α) :=
mkOfAdjoinEqTop hα (Algebra.adjoin_eq_top_of_primitive_element hα hα₂)
/-- If `α` is primitive in `E/f`, then `E` is given by adjoining a root of `minpoly F α`. -/
abbrev _root_.IsAdjoinRootMonic.mkOfPrimitiveElement
{α : E} (hα : IsIntegral F α) (hα₂ : F⟮α⟯ = ⊤) : IsAdjoinRootMonic E (minpoly F α) where
__ := IsAdjoinRoot.mkOfPrimitiveElement hα hα₂
monic := minpoly.monic hα
end IsAdjoinRoot
end Field |
.lake/packages/mathlib/Mathlib/RingTheory/QuotSMulTop.lean | import Mathlib.LinearAlgebra.DFinsupp
import Mathlib.LinearAlgebra.TensorProduct.Quotient
import Mathlib.LinearAlgebra.TensorProduct.RightExactness
/-!
# Reducing a module modulo an element of the ring
Given a commutative ring `R` and an element `r : R`, the association
`M ↦ M ⧸ rM` extends to a functor on the category of `R`-modules. This functor
is isomorphic to the functor of tensoring by `R ⧸ (r)` on either side, but can
be more convenient to work with since we can work with quotient types instead
of fiddling with simple tensors.
## Tags
module, commutative algebra
-/
open scoped Pointwise
variable {R} [CommRing R] (r : R) (M : Type*) {M' M''}
[AddCommGroup M] [Module R M] [AddCommGroup M'] [Module R M']
[AddCommGroup M''] [Module R M'']
/-- An abbreviation for `M⧸rM` that keeps us from having to write
`(⊤ : Submodule R M)` over and over to satisfy the typechecker. -/
abbrev QuotSMulTop := M ⧸ r • (⊤ : Submodule R M)
namespace QuotSMulTop
open Submodule Function TensorProduct
/-- If `M'` is isomorphic to `M''` as `R`-modules, then `M'⧸rM'` is isomorphic to `M''⧸rM''`. -/
protected def congr (e : M' ≃ₗ[R] M'') : QuotSMulTop r M' ≃ₗ[R] QuotSMulTop r M'' :=
Submodule.Quotient.equiv (r • ⊤) (r • ⊤) e <|
(Submodule.map_pointwise_smul r _ e.toLinearMap).trans (by simp)
/-- Reducing a module modulo `r` is the same as left tensoring with `R/(r)`. -/
noncomputable def equivQuotTensor :
QuotSMulTop r M ≃ₗ[R] (R ⧸ Ideal.span {r}) ⊗[R] M :=
quotEquivOfEq _ _ (ideal_span_singleton_smul _ _).symm ≪≫ₗ
(quotTensorEquivQuotSMul M _).symm
/-- Reducing a module modulo `r` is the same as right tensoring with `R/(r)`. -/
noncomputable def equivTensorQuot :
QuotSMulTop r M ≃ₗ[R] M ⊗[R] (R ⧸ Ideal.span {r}) :=
quotEquivOfEq _ _ (ideal_span_singleton_smul _ _).symm ≪≫ₗ
(tensorQuotEquivQuotSMul M _).symm
variable {M}
/-- The action of the functor `QuotSMulTop r` on morphisms. -/
def map : (M →ₗ[R] M') →ₗ[R] QuotSMulTop r M →ₗ[R] QuotSMulTop r M' :=
Submodule.mapQLinear _ _ ∘ₗ LinearMap.id.codRestrict _ fun _ =>
map_le_iff_le_comap.mp <| le_of_eq_of_le (map_pointwise_smul _ _ _) <|
smul_mono_right r le_top
@[simp]
lemma map_apply_mk (f : M →ₗ[R] M') (x : M) :
map r f (Submodule.Quotient.mk x) =
(Submodule.Quotient.mk (f x) : QuotSMulTop r M') := rfl
-- weirdly expensive to typecheck the type here?
lemma map_comp_mkQ (f : M →ₗ[R] M') :
map r f ∘ₗ mkQ (r • ⊤) = mkQ (r • ⊤) ∘ₗ f := by
ext; rfl
variable (M)
@[simp]
lemma map_id : map r (LinearMap.id : M →ₗ[R] M) = .id :=
DFunLike.ext _ _ <| (mkQ_surjective _).forall.mpr fun _ => rfl
variable {M}
@[simp]
lemma map_comp (g : M' →ₗ[R] M'') (f : M →ₗ[R] M') :
map r (g ∘ₗ f) = map r g ∘ₗ map r f :=
DFunLike.ext _ _ <| (mkQ_surjective _).forall.mpr fun _ => rfl
lemma equivQuotTensor_naturality_mk (f : M →ₗ[R] M') (x : M) :
equivQuotTensor r M' (map r f (Submodule.Quotient.mk x)) =
f.lTensor (R ⧸ Ideal.span {r})
(equivQuotTensor r M (Submodule.Quotient.mk x)) :=
(LinearMap.lTensor_tmul (R ⧸ Ideal.span {r}) f 1 x).symm
lemma equivQuotTensor_naturality (f : M →ₗ[R] M') :
equivQuotTensor r M' ∘ₗ map r f =
f.lTensor (R ⧸ Ideal.span {r}) ∘ₗ equivQuotTensor r M :=
quot_hom_ext _ _ _ (equivQuotTensor_naturality_mk r f)
lemma equivTensorQuot_naturality_mk (f : M →ₗ[R] M') (x : M) :
equivTensorQuot r M' (map r f (Submodule.Quotient.mk x)) =
f.rTensor (R ⧸ Ideal.span {r})
(equivTensorQuot r M (Submodule.Quotient.mk x)) :=
(LinearMap.rTensor_tmul (R ⧸ Ideal.span {r}) f 1 x).symm
lemma equivTensorQuot_naturality (f : M →ₗ[R] M') :
equivTensorQuot r M' ∘ₗ map r f =
f.rTensor (R ⧸ Ideal.span {r}) ∘ₗ equivTensorQuot r M :=
quot_hom_ext _ _ _ (equivTensorQuot_naturality_mk r f)
lemma map_surjective {f : M →ₗ[R] M'} (hf : Surjective f) : Surjective (map r f) :=
have H₁ := (mkQ_surjective (r • ⊤ : Submodule R M')).comp hf
@Surjective.of_comp _ _ _ _ (mkQ (r • ⊤ : Submodule R M)) <| by
rwa [← LinearMap.coe_comp, map_comp_mkQ, LinearMap.coe_comp]
lemma map_exact {f : M →ₗ[R] M'} {g : M' →ₗ[R] M''}
(hfg : Exact f g) (hg : Surjective g) : Exact (map r f) (map r g) :=
(Exact.iff_of_ladder_linearEquiv (equivQuotTensor_naturality r f).symm
(equivQuotTensor_naturality r g).symm).mp
(lTensor_exact (R ⧸ Ideal.span {r}) hfg hg)
variable (M M')
/-- Tensoring on the left and applying `QuotSMulTop · r` commute. -/
noncomputable def tensorQuotSMulTopEquivQuotSMulTop :
M ⊗[R] QuotSMulTop r M' ≃ₗ[R] QuotSMulTop r (M ⊗[R] M') :=
(equivTensorQuot r M').lTensor M ≪≫ₗ
(TensorProduct.assoc R M M' (R ⧸ Ideal.span {r})).symm ≪≫ₗ
(equivTensorQuot r (M ⊗[R] M')).symm
/-- Tensoring on the right and applying `QuotSMulTop · r` commute. -/
noncomputable def quotSMulTopTensorEquivQuotSMulTop :
QuotSMulTop r M' ⊗[R] M ≃ₗ[R] QuotSMulTop r (M' ⊗[R] M) :=
(equivQuotTensor r M').rTensor M ≪≫ₗ
TensorProduct.assoc R (R ⧸ Ideal.span {r}) M' M ≪≫ₗ
(equivQuotTensor r (M' ⊗[R] M)).symm
/-- Let `R` be a commutative ring, `M` be an `R`-module, `S` be an `R`-algebra, then
`S ⊗[R] (M/rM)` is isomorphic to `(S ⊗[R] M)⧸r(S ⊗[R] M)` as `S`-modules. -/
noncomputable def algebraMapTensorEquivTensorQuotSMulTop (S : Type*) [CommRing S] [Algebra R S] :
QuotSMulTop ((algebraMap R S) r) (S ⊗[R] M) ≃ₗ[S] S ⊗[R] QuotSMulTop r M :=
Submodule.quotEquivOfEq _ _ (by simp [Ideal.map_span, ideal_span_singleton_smul]) ≪≫ₗ
tensorQuotMapSMulEquivTensorQuot M S (Ideal.span {r}) ≪≫ₗ
(Submodule.quotEquivOfEq _ _ (ideal_span_singleton_smul r _)).baseChange R S _ _
end QuotSMulTop |
.lake/packages/mathlib/Mathlib/RingTheory/ChainOfDivisors.lean | import Mathlib.Algebra.GCDMonoid.Basic
import Mathlib.Algebra.IsPrimePow
import Mathlib.RingTheory.UniqueFactorizationDomain.Multiplicity
import Mathlib.Order.Atoms
import Mathlib.Order.Hom.Bounded
/-!
# Chains of divisors
The results in this file show that in the monoid `Associates M` of a `UniqueFactorizationMonoid`
`M`, an element `a` is an n-th prime power iff its set of divisors is a strictly increasing chain
of length `n + 1`, meaning that we can find a strictly increasing bijection between `Fin (n + 1)`
and the set of factors of `a`.
## Main results
- `DivisorChain.exists_chain_of_prime_pow` : existence of a chain for prime powers.
- `DivisorChain.is_prime_pow_of_has_chain` : elements that have a chain are prime powers.
- `multiplicity_prime_eq_multiplicity_image_by_factor_orderIso` : if there is a
monotone bijection `d` between the set of factors of `a : Associates M` and the set of factors of
`b : Associates N` then for any prime `p ∣ a`, `multiplicity p a = multiplicity (d p) b`.
- `multiplicity_eq_multiplicity_factor_dvd_iso_of_mem_normalizedFactors` : if there is a bijection
between the set of factors of `a : M` and `b : N` then for any prime `p ∣ a`,
`multiplicity p a = multiplicity (d p) b`
## TODO
- Create a structure for chains of divisors.
- Simplify proof of `mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors` using
`mem_normalizedFactors_factor_order_iso_of_mem_normalizedFactors` or vice versa.
-/
assert_not_exists Field
variable {M : Type*} [CancelCommMonoidWithZero M]
theorem Associates.isAtom_iff {p : Associates M} (h₁ : p ≠ 0) : IsAtom p ↔ Irreducible p :=
⟨fun hp =>
⟨by simpa only [Associates.isUnit_iff_eq_one] using hp.1, fun a b h =>
(hp.le_iff.mp ⟨_, h⟩).casesOn (fun ha => Or.inl (a.isUnit_iff_eq_one.mpr ha)) fun ha =>
Or.inr
(show IsUnit b by
rw [ha] at h
apply isUnit_of_associated_mul (show Associated (p * b) p by conv_rhs => rw [h]) h₁)⟩,
fun hp =>
⟨by simpa only [Associates.isUnit_iff_eq_one, Associates.bot_eq_one] using hp.1,
fun b ⟨⟨a, hab⟩, hb⟩ =>
(hp.isUnit_or_isUnit hab).casesOn
(fun hb => show b = ⊥ by rwa [Associates.isUnit_iff_eq_one, ← Associates.bot_eq_one] at hb)
fun ha =>
absurd
(show p ∣ b from
⟨(ha.unit⁻¹ : Units _), by rw [hab, mul_assoc, IsUnit.mul_val_inv ha, mul_one]⟩)
hb⟩⟩
open UniqueFactorizationMonoid Irreducible Associates
namespace DivisorChain
theorem exists_chain_of_prime_pow {p : Associates M} {n : ℕ} (hn : n ≠ 0) (hp : Prime p) :
∃ c : Fin (n + 1) → Associates M,
c 1 = p ∧ StrictMono c ∧ ∀ {r : Associates M}, r ≤ p ^ n ↔ ∃ i, r = c i := by
refine ⟨fun i => p ^ (i : ℕ), ?_, fun n m h => ?_, @fun y => ⟨fun h => ?_, ?_⟩⟩
· dsimp only
rw [Fin.coe_ofNat_eq_mod, Nat.mod_eq_of_lt, pow_one]
exact Nat.lt_succ_of_le (Nat.one_le_iff_ne_zero.mpr hn)
· exact Associates.dvdNotUnit_iff_lt.mp
⟨pow_ne_zero n hp.ne_zero, p ^ (m - n : ℕ),
not_isUnit_of_not_isUnit_dvd hp.not_unit (dvd_pow dvd_rfl (Nat.sub_pos_of_lt h).ne'),
(pow_mul_pow_sub p h.le).symm⟩
· obtain ⟨i, i_le, hi⟩ := (dvd_prime_pow hp n).1 h
rw [associated_iff_eq] at hi
exact ⟨⟨i, Nat.lt_succ_of_le i_le⟩, hi⟩
· rintro ⟨i, rfl⟩
exact ⟨p ^ (n - i : ℕ), (pow_mul_pow_sub p (Nat.succ_le_succ_iff.mp i.2)).symm⟩
theorem element_of_chain_not_isUnit_of_index_ne_zero {n : ℕ} {i : Fin (n + 1)} (i_pos : i ≠ 0)
{c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) : ¬IsUnit (c i) :=
DvdNotUnit.not_unit
(Associates.dvdNotUnit_iff_lt.2
(h₁ <| show (0 : Fin (n + 1)) < i from Fin.pos_iff_ne_zero.mpr i_pos))
theorem first_of_chain_isUnit {q : Associates M} {n : ℕ} {c : Fin (n + 1) → Associates M}
(h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) : IsUnit (c 0) := by
obtain ⟨i, hr⟩ := h₂.mp Associates.one_le
rw [Associates.isUnit_iff_eq_one, ← Associates.le_one_iff, hr]
exact h₁.monotone (Fin.zero_le i)
/-- The second element of a chain is irreducible. -/
theorem second_of_chain_is_irreducible {q : Associates M} {n : ℕ} (hn : n ≠ 0)
{c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i)
(hq : q ≠ 0) : Irreducible (c 1) := by
rcases n with - | n; · contradiction
refine (Associates.isAtom_iff (ne_zero_of_dvd_ne_zero hq (h₂.2 ⟨1, rfl⟩))).mp ⟨?_, fun b hb => ?_⟩
· exact ne_bot_of_gt (h₁ (show (0 : Fin (n + 2)) < 1 from Fin.one_pos))
obtain ⟨⟨i, hi⟩, rfl⟩ := h₂.1 (hb.le.trans (h₂.2 ⟨1, rfl⟩))
cases i
· exact (Associates.isUnit_iff_eq_one _).mp (first_of_chain_isUnit h₁ @h₂)
· simpa [Fin.lt_iff_val_lt_val] using h₁.lt_iff_lt.mp hb
theorem eq_second_of_chain_of_prime_dvd {p q r : Associates M} {n : ℕ} (hn : n ≠ 0)
{c : Fin (n + 1) → Associates M} (h₁ : StrictMono c)
(h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hp : Prime p) (hr : r ∣ q) (hp' : p ∣ r) :
p = c 1 := by
rcases n with - | n
· contradiction
obtain ⟨i, rfl⟩ := h₂.1 (dvd_trans hp' hr)
refine congr_arg c (eq_of_le_of_not_lt' ?_ fun hi => ?_)
· rw [Fin.le_iff_val_le_val, Fin.val_one, Nat.succ_le_iff, ← Fin.val_zero (n.succ + 1), ←
Fin.lt_iff_val_lt_val, Fin.pos_iff_ne_zero]
rintro rfl
exact hp.not_unit (first_of_chain_isUnit h₁ @h₂)
obtain rfl | ⟨j, rfl⟩ := i.eq_zero_or_eq_succ
· cases hi
refine
not_irreducible_of_not_unit_dvdNotUnit
(DvdNotUnit.not_unit
(Associates.dvdNotUnit_iff_lt.2 (h₁ (show (0 : Fin (n + 2)) < j.castSucc from ?_))))
?_ hp.irreducible
· simpa using Fin.lt_def.mp hi
· refine Associates.dvdNotUnit_iff_lt.2 (h₁ ?_)
simpa only [Fin.coe_eq_castSucc] using Fin.lt_succ
theorem card_subset_divisors_le_length_of_chain {q : Associates M} {n : ℕ}
{c : Fin (n + 1) → Associates M} (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) {m : Finset (Associates M)}
(hm : ∀ r, r ∈ m → r ≤ q) : m.card ≤ n + 1 := by
classical
have mem_image : ∀ r : Associates M, r ≤ q → r ∈ Finset.univ.image c := by
intro r hr
obtain ⟨i, hi⟩ := h₂.1 hr
exact Finset.mem_image.2 ⟨i, Finset.mem_univ _, hi.symm⟩
rw [← Finset.card_fin (n + 1)]
exact (Finset.card_le_card fun x hx => mem_image x <| hm x hx).trans Finset.card_image_le
variable [UniqueFactorizationMonoid M]
theorem element_of_chain_eq_pow_second_of_chain {q r : Associates M} {n : ℕ} (hn : n ≠ 0)
{c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i)
(hr : r ∣ q) (hq : q ≠ 0) : ∃ i : Fin (n + 1), r = c 1 ^ (i : ℕ) := by
classical
let i := Multiset.card (normalizedFactors r)
have hi : normalizedFactors r = Multiset.replicate i (c 1) := by
apply Multiset.eq_replicate_of_mem
intro b hb
refine
eq_second_of_chain_of_prime_dvd hn h₁ (@fun r' => h₂) (prime_of_normalized_factor b hb) hr
(dvd_of_mem_normalizedFactors hb)
have H : r = c 1 ^ i := by
have := UniqueFactorizationMonoid.prod_normalizedFactors (ne_zero_of_dvd_ne_zero hq hr)
rw [associated_iff_eq, hi, Multiset.prod_replicate] at this
rw [this]
refine ⟨⟨i, ?_⟩, H⟩
have : (Finset.univ.image fun m : Fin (i + 1) => c 1 ^ (m : ℕ)).card = i + 1 := by
conv_rhs => rw [← Finset.card_fin (i + 1)]
cases n
· contradiction
rw [Finset.card_image_iff]
refine Set.injOn_of_injective (fun m m' h => Fin.ext ?_)
refine
pow_injective_of_not_isUnit (element_of_chain_not_isUnit_of_index_ne_zero (by simp) h₁) ?_ h
exact Irreducible.ne_zero (second_of_chain_is_irreducible hn h₁ (@h₂) hq)
suffices H' : ∀ r ∈ Finset.univ.image fun m : Fin (i + 1) => c 1 ^ (m : ℕ), r ≤ q by
simp only [← Nat.succ_le_iff, Nat.succ_eq_add_one, ← this]
apply card_subset_divisors_le_length_of_chain (@h₂) H'
simp only [Finset.mem_image]
rintro r ⟨a, _, rfl⟩
refine dvd_trans ?_ hr
use c 1 ^ (i - (a : ℕ))
rw [pow_mul_pow_sub (c 1)]
· exact H
· exact Nat.succ_le_succ_iff.mp a.2
theorem eq_pow_second_of_chain_of_has_chain {q : Associates M} {n : ℕ} (hn : n ≠ 0)
{c : Fin (n + 1) → Associates M} (h₁ : StrictMono c)
(h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hq : q ≠ 0) : q = c 1 ^ n := by
classical
obtain ⟨i, hi'⟩ := element_of_chain_eq_pow_second_of_chain hn h₁ (@fun r => h₂) (dvd_refl q) hq
convert hi'
refine (Nat.lt_succ_iff.1 i.prop).antisymm' (Nat.le_of_succ_le_succ ?_)
calc
n + 1 = (Finset.univ : Finset (Fin (n + 1))).card := (Finset.card_fin _).symm
_ = (Finset.univ.image c).card := (Finset.card_image_iff.mpr h₁.injective.injOn).symm
_ ≤ (Finset.univ.image fun m : Fin (i + 1) => c 1 ^ (m : ℕ)).card :=
(Finset.card_le_card ?_)
_ ≤ (Finset.univ : Finset (Fin (i + 1))).card := Finset.card_image_le
_ = i + 1 := Finset.card_fin _
intro r hr
obtain ⟨j, -, rfl⟩ := Finset.mem_image.1 hr
have := h₂.2 ⟨j, rfl⟩
rw [hi'] at this
have h := (dvd_prime_pow (show Prime (c 1) from ?_) i).1 this
· rcases h with ⟨u, hu, hu'⟩
refine Finset.mem_image.mpr ⟨⟨u, Nat.lt_succ_of_le hu⟩, Finset.mem_univ _, ?_⟩
rwa [associated_iff_eq, eq_comm] at hu'
· rw [← irreducible_iff_prime]
exact second_of_chain_is_irreducible hn h₁ (@h₂) hq
theorem isPrimePow_of_has_chain {q : Associates M} {n : ℕ} (hn : n ≠ 0)
{c : Fin (n + 1) → Associates M} (h₁ : StrictMono c)
(h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hq : q ≠ 0) : IsPrimePow q :=
⟨c 1, n, irreducible_iff_prime.mp (second_of_chain_is_irreducible hn h₁ (@h₂) hq),
zero_lt_iff.mpr hn, (eq_pow_second_of_chain_of_has_chain hn h₁ (@h₂) hq).symm⟩
end DivisorChain
variable {N : Type*} [CancelCommMonoidWithZero N]
theorem factor_orderIso_map_one_eq_bot {m : Associates M} {n : Associates N}
(d : { l : Associates M // l ≤ m } ≃o { l : Associates N // l ≤ n }) :
(d ⟨1, one_dvd m⟩ : Associates N) = 1 := by
letI : OrderBot { l : Associates M // l ≤ m } := Subtype.orderBot bot_le
letI : OrderBot { l : Associates N // l ≤ n } := Subtype.orderBot bot_le
simp only [← Associates.bot_eq_one, Subtype.mk_bot, bot_le, Subtype.coe_eq_bot_iff]
letI : BotHomClass ({ l // l ≤ m } ≃o { l // l ≤ n }) _ _ := OrderIsoClass.toBotHomClass
exact map_bot d
theorem coe_factor_orderIso_map_eq_one_iff {m u : Associates M} {n : Associates N} (hu' : u ≤ m)
(d : Set.Iic m ≃o Set.Iic n) : (d ⟨u, hu'⟩ : Associates N) = 1 ↔ u = 1 :=
⟨fun hu => by
rw [show u = (d.symm ⟨d ⟨u, hu'⟩, (d ⟨u, hu'⟩).prop⟩) by
simp only [Subtype.coe_eta, OrderIso.symm_apply_apply, Subtype.coe_mk]]
conv_rhs => rw [← factor_orderIso_map_one_eq_bot d.symm]
congr, fun hu => by
simp_rw [hu]
conv_rhs => rw [← factor_orderIso_map_one_eq_bot d]
rfl⟩
section
variable [UniqueFactorizationMonoid N] [UniqueFactorizationMonoid M]
open DivisorChain
theorem pow_image_of_prime_by_factor_orderIso_dvd
{m p : Associates M} {n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m)
(d : Set.Iic m ≃o Set.Iic n) {s : ℕ} (hs' : p ^ s ≤ m) :
(d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : Associates N) ^ s ≤ n := by
by_cases hs : s = 0
· simp [← Associates.bot_eq_one, hs]
suffices (d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : Associates N) ^ s =
(d ⟨p ^ s, hs'⟩) by
rw [this]
apply Subtype.prop (d ⟨p ^ s, hs'⟩)
obtain ⟨c₁, rfl, hc₁', hc₁''⟩ := exists_chain_of_prime_pow hs (prime_of_normalized_factor p hp)
let c₂ : Fin (s + 1) → Associates N := fun t => d ⟨c₁ t, le_trans (hc₁''.2 ⟨t, by simp⟩) hs'⟩
have c₂_def : ∀ t, c₂ t = d ⟨c₁ t, _⟩ := fun t => rfl
rw [← c₂_def]
refine (eq_pow_second_of_chain_of_has_chain hs (fun t u h => ?_)
(@fun r => ⟨@fun hr => ?_, ?_⟩) ?_).symm
· rw [c₂_def, c₂_def, Subtype.coe_lt_coe, d.lt_iff_lt, Subtype.mk_lt_mk, hc₁'.lt_iff_lt]
exact h
· have : r ≤ n := hr.trans (d ⟨c₁ 1 ^ s, _⟩).2
suffices d.symm ⟨r, this⟩ ≤ ⟨c₁ 1 ^ s, hs'⟩ by
obtain ⟨i, hi⟩ := hc₁''.1 this
use i
simp only [c₂_def, ← hi, d.apply_symm_apply, Subtype.coe_eta, Subtype.coe_mk]
conv_rhs => rw [← d.symm_apply_apply ⟨c₁ 1 ^ s, hs'⟩]
rw [d.symm.le_iff_le]
simpa only [← Subtype.coe_le_coe, Subtype.coe_mk] using hr
· rintro ⟨i, hr⟩
rw [hr, c₂_def, Subtype.coe_le_coe, d.le_iff_le]
simpa [Subtype.mk_le_mk] using hc₁''.2 ⟨i, rfl⟩
exact ne_zero_of_dvd_ne_zero hn (Subtype.prop (d ⟨c₁ 1 ^ s, _⟩))
theorem map_prime_of_factor_orderIso {m p : Associates M} {n : Associates N} (hn : n ≠ 0)
(hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) :
Prime (d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : Associates N) := by
rw [← irreducible_iff_prime]
refine (Associates.isAtom_iff <|
ne_zero_of_dvd_ne_zero hn (d ⟨p, _⟩).prop).mp ⟨?_, fun b hb => ?_⟩
· rw [Ne, ← Associates.isUnit_iff_eq_bot, Associates.isUnit_iff_eq_one,
coe_factor_orderIso_map_eq_one_iff _ d]
rintro rfl
exact (prime_of_normalized_factor 1 hp).not_unit isUnit_one
· have : b ≤ n := le_trans (le_of_lt hb) (d ⟨p, dvd_of_mem_normalizedFactors hp⟩).prop
obtain ⟨x, hx⟩ := d.surjective ⟨b, this⟩
rw [← Subtype.coe_mk (p := (· ≤ n)) b this, ← hx] at hb
letI : OrderBot { l : Associates M // l ≤ m } := Subtype.orderBot bot_le
letI : OrderBot { l : Associates N // l ≤ n } := Subtype.orderBot bot_le
suffices x = ⊥ by
rw [this, OrderIso.map_bot d] at hx
refine (Subtype.mk_eq_bot_iff ?_ _).mp hx.symm
simp
obtain ⟨a, ha⟩ := x
rw [Subtype.mk_eq_bot_iff]
· exact
((Associates.isAtom_iff <| Prime.ne_zero <| prime_of_normalized_factor p hp).mpr <|
irreducible_of_normalized_factor p hp).right
a (Subtype.mk_lt_mk.mp <| d.lt_iff_lt.mp hb)
simp
theorem mem_normalizedFactors_factor_orderIso_of_mem_normalizedFactors {m p : Associates M}
{n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) :
(d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : Associates N) ∈ normalizedFactors n := by
obtain ⟨q, hq, hq'⟩ :=
exists_mem_normalizedFactors_of_dvd hn (map_prime_of_factor_orderIso hn hp d).irreducible
(d ⟨p, dvd_of_mem_normalizedFactors hp⟩).prop
rw [associated_iff_eq] at hq'
rwa [hq']
theorem emultiplicity_prime_le_emultiplicity_image_by_factor_orderIso {m p : Associates M}
{n : Associates N} (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) :
emultiplicity p m ≤ emultiplicity (↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩)) n := by
by_cases hn : n = 0
· simp [hn]
by_cases hm : m = 0
· simp [hm] at hp
rw [FiniteMultiplicity.of_prime_left (prime_of_normalized_factor p hp) hm
|>.emultiplicity_eq_multiplicity, ← pow_dvd_iff_le_emultiplicity]
apply pow_image_of_prime_by_factor_orderIso_dvd hn hp d (pow_multiplicity_dvd ..)
theorem emultiplicity_prime_eq_emultiplicity_image_by_factor_orderIso {m p : Associates M}
{n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) :
emultiplicity p m = emultiplicity (↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩)) n := by
refine le_antisymm (emultiplicity_prime_le_emultiplicity_image_by_factor_orderIso hp d) ?_
suffices emultiplicity (↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩)) n ≤
emultiplicity (↑(d.symm (d ⟨p, dvd_of_mem_normalizedFactors hp⟩))) m by
rw [d.symm_apply_apply ⟨p, dvd_of_mem_normalizedFactors hp⟩, Subtype.coe_mk] at this
exact this
letI := Classical.decEq (Associates N)
simpa only [Subtype.coe_eta] using
emultiplicity_prime_le_emultiplicity_image_by_factor_orderIso
(mem_normalizedFactors_factor_orderIso_of_mem_normalizedFactors hn hp d) d.symm
end
variable [Subsingleton Mˣ] [Subsingleton Nˣ]
/-- The order isomorphism between the factors of `mk m` and the factors of `mk n` induced by a
bijection between the factors of `m` and the factors of `n` that preserves `∣`. -/
@[simps]
def mkFactorOrderIsoOfFactorDvdEquiv {m : M} {n : N} {d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }}
(hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ (l' : M)) :
Set.Iic (Associates.mk m) ≃o Set.Iic (Associates.mk n) where
toFun l :=
⟨Associates.mk
(d
⟨associatesEquivOfUniqueUnits ↑l, by
obtain ⟨x, hx⟩ := l
rw [Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, out_dvd_iff]
exact hx⟩),
mk_le_mk_iff_dvd.mpr (Subtype.prop (d ⟨associatesEquivOfUniqueUnits ↑l, _⟩))⟩
invFun l :=
⟨Associates.mk
(d.symm
⟨associatesEquivOfUniqueUnits ↑l, by
obtain ⟨x, hx⟩ := l
rw [Subtype.coe_mk, associatesEquivOfUniqueUnits_apply, out_dvd_iff]
exact hx⟩),
mk_le_mk_iff_dvd.mpr (Subtype.prop (d.symm ⟨associatesEquivOfUniqueUnits ↑l, _⟩))⟩
left_inv := fun ⟨l, hl⟩ => by
simp only [Subtype.coe_eta, Equiv.symm_apply_apply, Subtype.coe_mk,
associatesEquivOfUniqueUnits_apply, mk_out, out_mk, normalize_eq]
right_inv := fun ⟨l, hl⟩ => by
simp only [Subtype.coe_eta, Equiv.apply_symm_apply, Subtype.coe_mk,
associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq, mk_out]
map_rel_iff' := by
rintro ⟨a, ha⟩ ⟨b, hb⟩
simp only [Equiv.coe_fn_mk, Subtype.mk_le_mk, Associates.mk_le_mk_iff_dvd, hd,
associatesEquivOfUniqueUnits_apply, out_dvd_iff, mk_out]
variable [UniqueFactorizationMonoid M] [UniqueFactorizationMonoid N]
theorem mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors {m p : M} {n : N} (hm : m ≠ 0)
(hn : n ≠ 0) (hp : p ∈ normalizedFactors m) {d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }}
(hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ (l' : M)) :
↑(d ⟨p, dvd_of_mem_normalizedFactors hp⟩) ∈ normalizedFactors n := by
suffices
Prime (d ⟨associatesEquivOfUniqueUnits (associatesEquivOfUniqueUnits.symm p), by
simp [dvd_of_mem_normalizedFactors hp]⟩ : N) by
simp only [associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq,
associatesEquivOfUniqueUnits_symm_apply] at this
obtain ⟨q, hq, hq'⟩ :=
exists_mem_normalizedFactors_of_dvd hn this.irreducible
(d ⟨p, by apply dvd_of_mem_normalizedFactors; convert hp⟩).prop
rwa [associated_iff_eq.mp hq']
have :
Associates.mk
(d ⟨associatesEquivOfUniqueUnits (associatesEquivOfUniqueUnits.symm p), by
simp only [dvd_of_mem_normalizedFactors hp, associatesEquivOfUniqueUnits_apply,
out_mk, normalize_eq, associatesEquivOfUniqueUnits_symm_apply]⟩ : N) =
↑(mkFactorOrderIsoOfFactorDvdEquiv hd
⟨associatesEquivOfUniqueUnits.symm p, by
simp only [associatesEquivOfUniqueUnits_symm_apply]
exact mk_dvd_mk.mpr (dvd_of_mem_normalizedFactors hp)⟩) := by
rw [mkFactorOrderIsoOfFactorDvdEquiv_apply_coe]
rw [← Associates.prime_mk, this]
letI := Classical.decEq (Associates M)
refine map_prime_of_factor_orderIso (mk_ne_zero.mpr hn) ?_ _
obtain ⟨q, hq, hq'⟩ :=
exists_mem_normalizedFactors_of_dvd (mk_ne_zero.mpr hm)
(prime_mk.mpr (prime_of_normalized_factor p (by convert hp))).irreducible
(mk_le_mk_of_dvd (dvd_of_mem_normalizedFactors hp))
simpa only [associated_iff_eq.mp hq', associatesEquivOfUniqueUnits_symm_apply] using hq
theorem emultiplicity_factor_dvd_iso_eq_emultiplicity_of_mem_normalizedFactors {m p : M} {n : N}
(hm : m ≠ 0) (hn : n ≠ 0) (hp : p ∈ normalizedFactors m)
{d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }} (hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ l') :
emultiplicity (d ⟨p, dvd_of_mem_normalizedFactors hp⟩ : N) n = emultiplicity p m := by
apply Eq.symm
suffices emultiplicity (Associates.mk p) (Associates.mk m) = emultiplicity (Associates.mk
↑(d ⟨associatesEquivOfUniqueUnits (associatesEquivOfUniqueUnits.symm p), by
simp [dvd_of_mem_normalizedFactors hp]⟩)) (Associates.mk n) by
simpa only [emultiplicity_mk_eq_emultiplicity, associatesEquivOfUniqueUnits_symm_apply,
associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq] using this
have : Associates.mk (d ⟨associatesEquivOfUniqueUnits (associatesEquivOfUniqueUnits.symm p), by
simp only [dvd_of_mem_normalizedFactors hp, associatesEquivOfUniqueUnits_symm_apply,
associatesEquivOfUniqueUnits_apply, out_mk, normalize_eq]⟩ : N) =
↑(mkFactorOrderIsoOfFactorDvdEquiv hd ⟨associatesEquivOfUniqueUnits.symm p, by
rw [associatesEquivOfUniqueUnits_symm_apply]
exact mk_le_mk_of_dvd (dvd_of_mem_normalizedFactors hp)⟩) := by
rw [mkFactorOrderIsoOfFactorDvdEquiv_apply_coe]
rw [this]
refine
emultiplicity_prime_eq_emultiplicity_image_by_factor_orderIso (mk_ne_zero.mpr hn) ?_
(mkFactorOrderIsoOfFactorDvdEquiv hd)
obtain ⟨q, hq, hq'⟩ :=
exists_mem_normalizedFactors_of_dvd (mk_ne_zero.mpr hm)
(prime_mk.mpr (prime_of_normalized_factor p hp)).irreducible
(mk_le_mk_of_dvd (dvd_of_mem_normalizedFactors hp))
rwa [associated_iff_eq.mp hq'] |
.lake/packages/mathlib/Mathlib/RingTheory/Prime.lean | import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Order.Group.Unbundled.Abs
import Mathlib.Algebra.Prime.Defs
import Mathlib.Algebra.Ring.Units
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
/-!
# Prime elements in rings
This file contains lemmas about prime elements of commutative rings.
-/
section CancelCommMonoidWithZero
variable {R : Type*} [CancelCommMonoidWithZero R]
open Finset
/-- If `x * y = a * ∏ i ∈ s, p i` where `p i` is always prime, then
`x` and `y` can both be written as a divisor of `a` multiplied by
a product over a subset of `s` -/
theorem mul_eq_mul_prime_prod {α : Type*} [DecidableEq α] {x y a : R} {s : Finset α} {p : α → R}
(hp : ∀ i ∈ s, Prime (p i)) (hx : x * y = a * ∏ i ∈ s, p i) :
∃ (t u : Finset α) (b c : R),
t ∪ u = s ∧ Disjoint t u ∧ a = b * c ∧ (x = b * ∏ i ∈ t, p i) ∧ y = c * ∏ i ∈ u, p i := by
induction s using Finset.induction generalizing x y a with
| empty => exact ⟨∅, ∅, x, y, by simp [hx]⟩
| insert i s his ih =>
rw [prod_insert his, ← mul_assoc] at hx
have hpi : Prime (p i) := hp i (mem_insert_self _ _)
rcases ih (fun i hi ↦ hp i (mem_insert_of_mem hi)) hx with
⟨t, u, b, c, htus, htu, hbc, rfl, rfl⟩
have hit : i ∉ t := fun hit ↦ his (htus ▸ mem_union_left _ hit)
have hiu : i ∉ u := fun hiu ↦ his (htus ▸ mem_union_right _ hiu)
obtain ⟨d, rfl⟩ | ⟨d, rfl⟩ : p i ∣ b ∨ p i ∣ c := hpi.dvd_or_dvd ⟨a, by rw [← hbc, mul_comm]⟩
· rw [mul_assoc, mul_comm a, mul_right_inj' hpi.ne_zero] at hbc
exact ⟨insert i t, u, d, c, by rw [insert_union, htus], disjoint_insert_left.2 ⟨hiu, htu⟩, by
simp [hbc, prod_insert hit, mul_comm, mul_left_comm]⟩
· rw [← mul_assoc, mul_right_comm b, mul_left_inj' hpi.ne_zero] at hbc
exact ⟨t, insert i u, b, d, by rw [union_insert, htus], disjoint_insert_right.2 ⟨hit, htu⟩, by
simp [← hbc, prod_insert hiu, mul_comm, mul_left_comm]⟩
/-- If `x * y = a * p ^ n` where `p` is prime, then `x` and `y` can both be written
as the product of a power of `p` and a divisor of `a`. -/
theorem mul_eq_mul_prime_pow {x y a p : R} {n : ℕ} (hp : Prime p) (hx : x * y = a * p ^ n) :
∃ (i j : ℕ) (b c : R), i + j = n ∧ a = b * c ∧ x = b * p ^ i ∧ y = c * p ^ j := by
rcases mul_eq_mul_prime_prod (fun _ _ ↦ hp)
(show x * y = a * (range n).prod fun _ ↦ p by simpa) with
⟨t, u, b, c, htus, htu, rfl, rfl, rfl⟩
exact ⟨#t, #u, b, c, by rw [← card_union_of_disjoint htu, htus, card_range], by simp⟩
end CancelCommMonoidWithZero
section CommRing
variable {α : Type*} [CommRing α]
theorem Prime.neg {p : α} (hp : Prime p) : Prime (-p) := by
obtain ⟨h1, h2, h3⟩ := hp
exact ⟨neg_ne_zero.mpr h1, by rwa [IsUnit.neg_iff], by simpa [neg_dvd] using h3⟩
theorem Prime.abs [LinearOrder α] {p : α} (hp : Prime p) : Prime (abs p) := by
obtain h | h := abs_choice p <;> rw [h]
· exact hp
· exact hp.neg
end CommRing |
.lake/packages/mathlib/Mathlib/RingTheory/FinitePresentation.lean | import Mathlib.Data.Finite.Sum
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Finiteness.Ideal
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.MvPolynomial.Tower
/-!
# Finiteness conditions in commutative algebra
In this file we define several notions of finiteness that are common in commutative algebra.
## Main declarations
- `Module.Finite`, `RingHom.Finite`, `AlgHom.Finite`
all of these express that some object is finitely generated *as module* over some base ring.
- `Algebra.FiniteType`, `RingHom.FiniteType`, `AlgHom.FiniteType`
all of these express that some object is finitely generated *as algebra* over some base ring.
- `Algebra.FinitePresentation`, `RingHom.FinitePresentation`, `AlgHom.FinitePresentation`
all of these express that some object is finitely presented *as algebra* over some base ring.
-/
open Function (Surjective)
open Polynomial
section ModuleAndAlgebra
universe w₁ w₂ w₃
variable (R : Type w₁) (A : Type w₂) (B : Type w₃)
/-- An algebra over a commutative semiring is `Algebra.FinitePresentation` if it is the quotient of
a polynomial ring in `n` variables by a finitely generated ideal. -/
class Algebra.FinitePresentation [CommSemiring R] [Semiring A] [Algebra R A] : Prop where
out : ∃ (n : ℕ) (f : MvPolynomial (Fin n) R →ₐ[R] A), Surjective f ∧ (RingHom.ker f.toRingHom).FG
namespace Algebra
variable [CommRing R] [CommRing A] [Algebra R A] [CommRing B] [Algebra R B]
namespace FiniteType
variable {R A B}
/-- A finitely presented algebra is of finite type. -/
instance of_finitePresentation [FinitePresentation R A] : FiniteType R A := by
obtain ⟨n, f, hf⟩ := FinitePresentation.out (R := R) (A := A)
apply FiniteType.iff_quotient_mvPolynomial''.2
exact ⟨n, f, hf.1⟩
end FiniteType
namespace FinitePresentation
variable {R A B}
/-- An algebra over a Noetherian ring is finitely generated if and only if it is finitely
presented. -/
theorem of_finiteType [IsNoetherianRing R] : FiniteType R A ↔ FinitePresentation R A := by
refine ⟨fun h => ?_, fun hfp => Algebra.FiniteType.of_finitePresentation⟩
obtain ⟨n, f, hf⟩ := Algebra.FiniteType.iff_quotient_mvPolynomial''.1 h
refine ⟨n, f, hf, ?_⟩
exact (inferInstance : IsNoetherianRing (MvPolynomial (Fin n) R)).noetherian
(RingHom.ker f.toRingHom)
/-- If `e : A ≃ₐ[R] B` and `A` is finitely presented, then so is `B`. -/
theorem equiv [FinitePresentation R A] (e : A ≃ₐ[R] B) : FinitePresentation R B := by
obtain ⟨n, f, hf⟩ := FinitePresentation.out (R := R) (A := A)
use n, AlgHom.comp (↑e) f
constructor
· rw [AlgHom.coe_comp]
exact Function.Surjective.comp e.surjective hf.1
suffices (RingHom.ker (AlgHom.comp (e : A →ₐ[R] B) f).toRingHom) = RingHom.ker f.toRingHom by
rw [this]
exact hf.2
have hco : (AlgHom.comp (e : A →ₐ[R] B) f).toRingHom = RingHom.comp (e.toRingEquiv : A ≃+* B)
f.toRingHom := by
have h : (AlgHom.comp (e : A →ₐ[R] B) f).toRingHom =
e.toAlgHom.toRingHom.comp f.toRingHom := rfl
have h1 : ↑e.toRingEquiv = e.toAlgHom.toRingHom := rfl
rw [h, h1]
rw [RingHom.ker_eq_comap_bot, hco, ← Ideal.comap_comap, ← RingHom.ker_eq_comap_bot,
RingHom.ker_coe_equiv (AlgEquiv.toRingEquiv e), RingHom.ker_eq_comap_bot]
variable (R)
/-- The ring of polynomials in finitely many variables is finitely presented. -/
private lemma mvPolynomial_aux (ι : Type*) [Finite ι] :
FinitePresentation R (MvPolynomial ι R) where
out := by
cases nonempty_fintype ι
let eqv := (MvPolynomial.renameEquiv R <| Fintype.equivFin ι).symm
exact
⟨Fintype.card ι, eqv, eqv.surjective,
((RingHom.injective_iff_ker_eq_bot _).1 eqv.injective).symm ▸ Submodule.fg_bot⟩
variable {R}
/-- The quotient of a finitely presented algebra by a finitely generated ideal is finitely
presented. -/
protected theorem quotient {I : Ideal A} (h : I.FG) [FinitePresentation R A] :
FinitePresentation R (A ⧸ I) where
out := by
obtain ⟨n, f, hf⟩ := FinitePresentation.out (R := R) (A := A)
refine ⟨n, (Ideal.Quotient.mkₐ R I).comp f, ?_, ?_⟩
· exact (Ideal.Quotient.mkₐ_surjective R I).comp hf.1
· refine Ideal.fg_ker_comp _ _ hf.2 ?_ hf.1
simp [h]
/-- If `f : A →ₐ[R] B` is surjective with finitely generated kernel and `A` is finitely presented,
then so is `B`. -/
theorem of_surjective {f : A →ₐ[R] B} (hf : Function.Surjective f)
(hker : (RingHom.ker f.toRingHom).FG)
[FinitePresentation R A] : FinitePresentation R B :=
letI : FinitePresentation R (A ⧸ RingHom.ker f) := FinitePresentation.quotient hker
equiv (Ideal.quotientKerAlgEquivOfSurjective hf)
theorem iff :
FinitePresentation R A ↔
∃ (n : _) (I : Ideal (MvPolynomial (Fin n) R)) (_ : (_ ⧸ I) ≃ₐ[R] A), I.FG := by
constructor
· rintro ⟨n, f, hf⟩
exact ⟨n, RingHom.ker f.toRingHom, Ideal.quotientKerAlgEquivOfSurjective hf.1, hf.2⟩
· rintro ⟨n, I, e, hfg⟩
letI := (FinitePresentation.mvPolynomial_aux R _).quotient hfg
exact equiv e
/-- An algebra is finitely presented if and only if it is a quotient of a polynomial ring whose
variables are indexed by a fintype by a finitely generated ideal. -/
theorem iff_quotient_mvPolynomial' :
FinitePresentation R A ↔
∃ (ι : Type*) (_ : Fintype ι) (f : MvPolynomial ι R →ₐ[R] A),
Surjective f ∧ (RingHom.ker f.toRingHom).FG := by
constructor
· rintro ⟨n, f, hfs, hfk⟩
set ulift_var := MvPolynomial.renameEquiv R Equiv.ulift
refine
⟨ULift (Fin n), inferInstance, f.comp ulift_var.toAlgHom, hfs.comp ulift_var.surjective,
Ideal.fg_ker_comp _ _ ?_ hfk ulift_var.surjective⟩
simpa using Submodule.fg_bot
· rintro ⟨ι, hfintype, f, hf⟩
have equiv := MvPolynomial.renameEquiv R (Fintype.equivFin ι)
use Fintype.card ι, f.comp equiv.symm, hf.1.comp (AlgEquiv.symm equiv).surjective
refine Ideal.fg_ker_comp (S := MvPolynomial ι R) (A := A) _ f ?_ hf.2 equiv.symm.surjective
simpa using Submodule.fg_bot
universe v in
/-- If `A` is a finitely presented `R`-algebra, then `MvPolynomial (Fin n) A` is finitely presented
as `R`-algebra. -/
theorem mvPolynomial_of_finitePresentation [FinitePresentation R A] (ι : Type v) [Finite ι] :
FinitePresentation R (MvPolynomial ι A) := by
have hfp : FinitePresentation R A := inferInstance
rw [iff_quotient_mvPolynomial'] at hfp ⊢
classical
-- Make universe level `v` explicit so it matches that of `ι`
obtain ⟨(ι' : Type v), _, f, hf_surj, hf_ker⟩ := hfp
let g := (MvPolynomial.mapAlgHom f).comp (MvPolynomial.sumAlgEquiv R ι ι').toAlgHom
cases nonempty_fintype (ι ⊕ ι')
refine
⟨ι ⊕ ι', by infer_instance, g,
(MvPolynomial.map_surjective f.toRingHom hf_surj).comp (AlgEquiv.surjective _),
Ideal.fg_ker_comp _ _ ?_ ?_ (AlgEquiv.surjective _)⟩
· rw [AlgEquiv.toAlgHom_eq_coe, AlgEquiv.toAlgHom_toRingHom, AlgHom.ker_coe_equiv]
exact Submodule.fg_bot
· rw [AlgHom.toRingHom_eq_coe, MvPolynomial.mapAlgHom_coe_ringHom, MvPolynomial.ker_map]
exact hf_ker.map MvPolynomial.C
variable (R A B)
/-- If `A` is an `R`-algebra and `S` is an `A`-algebra, both finitely presented, then `S` is
finitely presented as `R`-algebra. -/
theorem trans [Algebra A B] [IsScalarTower R A B] [FinitePresentation R A]
[FinitePresentation A B] : FinitePresentation R B := by
have hfpB : FinitePresentation A B := inferInstance
obtain ⟨n, I, e, hfg⟩ := iff.1 hfpB
letI : FinitePresentation R (MvPolynomial (Fin n) A ⧸ I) :=
(mvPolynomial_of_finitePresentation _).quotient hfg
exact equiv (e.restrictScalars R)
/-- The ring of polynomials in finitely many variables is finitely presented. -/
protected instance mvPolynomial [FinitePresentation R A] (ι : Type*) [Finite ι] :
FinitePresentation R (MvPolynomial ι A) :=
have := FinitePresentation.mvPolynomial_aux A ι; .trans _ A _
/-- `R` is finitely presented as `R`-algebra. -/
instance self : FinitePresentation R R :=
have := FinitePresentation.mvPolynomial_aux R Empty
equiv (MvPolynomial.isEmptyAlgEquiv R Empty)
/-- `R[X]` is finitely presented as `R`-algebra. -/
instance polynomial [FinitePresentation R A] : FinitePresentation R A[X] :=
letI := FinitePresentation.mvPolynomial R A Unit
have := equiv (MvPolynomial.pUnitAlgEquiv.{_, 0} A)
.trans _ A _
open MvPolynomial
-- TODO: extract out helper lemmas and tidy proof.
@[stacks 0561]
theorem of_restrict_scalars_finitePresentation [Algebra A B] [IsScalarTower R A B]
[FinitePresentation.{w₁, w₃} R B] [FiniteType R A] :
FinitePresentation.{w₂, w₃} A B := by
classical
obtain ⟨n, f, hf, s, hs⟩ := FinitePresentation.out (R := R) (A := B)
letI RX := MvPolynomial (Fin n) R
letI AX := MvPolynomial (Fin n) A
refine ⟨n, MvPolynomial.aeval (f ∘ X), ?_, ?_⟩
· rw [← AlgHom.range_eq_top, ← Algebra.adjoin_range_eq_range_aeval,
Set.range_comp f MvPolynomial.X, eq_top_iff, ← @adjoin_adjoin_of_tower R A B,
adjoin_image, adjoin_range_X, Algebra.map_top, (AlgHom.range_eq_top _).mpr hf]
exact fun {x} => subset_adjoin ⟨⟩
· obtain ⟨t, ht⟩ := FiniteType.out (R := R) (A := A)
have := fun i : t => hf (algebraMap A B i)
choose t' ht' using this
have ht'' : Algebra.adjoin R (algebraMap A AX '' t ∪ Set.range (X : _ → AX)) = ⊤ := by
rw [adjoin_union_eq_adjoin_adjoin, ← Subalgebra.restrictScalars_top R (A := AX)
(S := { x // x ∈ adjoin R ((algebraMap A AX) '' t) })]
refine congrArg (Subalgebra.restrictScalars R) ?_
rw [adjoin_algebraMap, ht]
apply Subalgebra.restrictScalars_injective R
rw [← adjoin_restrictScalars, adjoin_range_X, Subalgebra.restrictScalars_top,
Subalgebra.restrictScalars_top]
letI g : t → AX := fun x => MvPolynomial.C (x : A) - map (algebraMap R A) (t' x)
refine ⟨s.image (map (algebraMap R A)) ∪ t.attach.image g, ?_⟩
rw [Finset.coe_union, Finset.coe_image, Finset.coe_image, Finset.attach_eq_univ,
Finset.coe_univ, Set.image_univ]
let s₀ := (MvPolynomial.map (algebraMap R A)) '' s ∪ Set.range g
let I := RingHom.ker (MvPolynomial.aeval (R := A) (f ∘ MvPolynomial.X))
change Ideal.span s₀ = I
have leI : Ideal.span ((MvPolynomial.map (algebraMap R A)) '' s ∪ Set.range g) ≤
RingHom.ker (MvPolynomial.aeval (R := A) (f ∘ MvPolynomial.X)) := by
rw [Ideal.span_le]
rintro _ (⟨x, hx, rfl⟩ | ⟨⟨x, hx⟩, rfl⟩) <;>
rw [SetLike.mem_coe, RingHom.mem_ker]
· rw [MvPolynomial.aeval_map_algebraMap (R := R) (A := A), ← aeval_unique]
have := Ideal.subset_span hx
rwa [hs] at this
· rw [map_sub, MvPolynomial.aeval_map_algebraMap, ← aeval_unique,
MvPolynomial.aeval_C, ht', Subtype.coe_mk, sub_self]
apply leI.antisymm
intro x hx
rw [RingHom.mem_ker] at hx
let s₀ := (MvPolynomial.map (algebraMap R A)) '' ↑s ∪ Set.range g
change x ∈ Ideal.span s₀
have : x ∈ (MvPolynomial.map (algebraMap R A) : _ →+* AX).range.toAddSubmonoid ⊔
(Ideal.span s₀).toAddSubmonoid := by
have : x ∈ (⊤ : Subalgebra R AX) := trivial
rw [← ht''] at this
refine adjoin_induction ?_ ?_ ?_ ?_ this
· rintro _ (⟨x, hx, rfl⟩ | ⟨i, rfl⟩)
· rw [MvPolynomial.algebraMap_eq, ← sub_add_cancel (MvPolynomial.C x)
(map (algebraMap R A) (t' ⟨x, hx⟩)), add_comm]
apply AddSubmonoid.add_mem_sup
· exact Set.mem_range_self _
· apply Ideal.subset_span
apply Set.mem_union_right
exact Set.mem_range_self _
· apply AddSubmonoid.mem_sup_left
exact ⟨X i, map_X _ _⟩
· intro r
apply AddSubmonoid.mem_sup_left
exact ⟨C r, map_C _ _⟩
· intro _ _ _ _ h₁ h₂
exact add_mem h₁ h₂
· intro x₁ x₂ _ _ h₁ h₂
obtain ⟨_, ⟨p₁, rfl⟩, q₁, hq₁, rfl⟩ := AddSubmonoid.mem_sup.mp h₁
obtain ⟨_, ⟨p₂, rfl⟩, q₂, hq₂, rfl⟩ := AddSubmonoid.mem_sup.mp h₂
rw [add_mul, mul_add, add_assoc, ← map_mul]
apply AddSubmonoid.add_mem_sup
· exact Set.mem_range_self _
· refine add_mem (Ideal.mul_mem_left _ _ hq₂) (Ideal.mul_mem_right _ _ hq₁)
obtain ⟨_, ⟨p, rfl⟩, q, hq, rfl⟩ := AddSubmonoid.mem_sup.mp this
rw [map_add, aeval_map_algebraMap, ← aeval_unique, show MvPolynomial.aeval (f ∘ X) q = 0
from leI hq, add_zero] at hx
suffices Ideal.span (s : Set RX) ≤ (Ideal.span s₀).comap (MvPolynomial.map <| algebraMap R A) by
refine add_mem ?_ hq
rw [hs] at this
exact this hx
rw [Ideal.span_le]
intro x hx
apply Ideal.subset_span
apply Set.mem_union_left
exact Set.mem_image_of_mem _ hx
variable {R A B}
-- TODO: extract out helper lemmas and tidy proof.
/-- This is used to prove the strictly stronger `ker_fg_of_surjective`. Use it instead. -/
theorem ker_fg_of_mvPolynomial {n : ℕ} (f : MvPolynomial (Fin n) R →ₐ[R] A)
(hf : Function.Surjective f) [FinitePresentation R A] : (RingHom.ker f.toRingHom).FG := by
classical
obtain ⟨m, f', hf', s, hs⟩ := FinitePresentation.out (R := R) (A := A)
let RXn := MvPolynomial (Fin n) R
let RXm := MvPolynomial (Fin m) R
have := fun i : Fin n => hf' (f <| X i)
choose g hg using this
have := fun i : Fin m => hf (f' <| X i)
choose h hh using this
let aeval_h : RXm →ₐ[R] RXn := aeval h
let g' : Fin n → RXn := fun i => X i - aeval_h (g i)
refine ⟨Finset.univ.image g' ∪ s.image aeval_h, ?_⟩
simp only [Finset.coe_image, Finset.coe_union, Finset.coe_univ, Set.image_univ]
have hh' : ∀ x, f (aeval_h x) = f' x := by
intro x
rw [← f.coe_toRingHom, map_aeval]
simp_rw [AlgHom.coe_toRingHom, hh]
rw [AlgHom.comp_algebraMap, ← aeval_eq_eval₂Hom,
-- Porting note: added line below
← funext fun i => Function.comp_apply (f := ↑f') (g := MvPolynomial.X),
← aeval_unique]
let s' := Set.range g' ∪ aeval_h '' s
have leI : Ideal.span s' ≤ RingHom.ker f.toRingHom := by
rw [Ideal.span_le]
rintro _ (⟨i, rfl⟩ | ⟨x, hx, rfl⟩)
· change f (g' i) = 0
rw [map_sub, ← hg, hh', sub_self]
· change f (aeval_h x) = 0
rw [hh']
change x ∈ RingHom.ker f'.toRingHom
rw [← hs]
exact Ideal.subset_span hx
apply leI.antisymm
intro x hx
have : x ∈ aeval_h.range.toAddSubmonoid ⊔ (Ideal.span s').toAddSubmonoid := by
have : x ∈ adjoin R (Set.range X : Set RXn) := by
rw [adjoin_range_X]
trivial
refine adjoin_induction ?_ ?_ ?_ ?_ this
· rintro _ ⟨i, rfl⟩
rw [← sub_add_cancel (X i) (aeval h (g i)), add_comm]
apply AddSubmonoid.add_mem_sup
· exact Set.mem_range_self _
· apply Submodule.subset_span
apply Set.mem_union_left
exact Set.mem_range_self _
· intro r
apply AddSubmonoid.mem_sup_left
exact ⟨C r, aeval_C _ _⟩
· intro _ _ _ _ h₁ h₂
exact add_mem h₁ h₂
· intro p₁ p₂ _ _ h₁ h₂
obtain ⟨_, ⟨x₁, rfl⟩, y₁, hy₁, rfl⟩ := AddSubmonoid.mem_sup.mp h₁
obtain ⟨_, ⟨x₂, rfl⟩, y₂, hy₂, rfl⟩ := AddSubmonoid.mem_sup.mp h₂
rw [mul_add, add_mul, add_assoc, ← map_mul]
apply AddSubmonoid.add_mem_sup
· exact Set.mem_range_self _
· exact add_mem (Ideal.mul_mem_right _ _ hy₁) (Ideal.mul_mem_left _ _ hy₂)
obtain ⟨_, ⟨x, rfl⟩, y, hy, rfl⟩ := AddSubmonoid.mem_sup.mp this
refine add_mem ?_ hy
simp only [RXn, RingHom.mem_ker, AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, map_add,
show f y = 0 from leI hy, add_zero, hh'] at hx
suffices Ideal.span (s : Set RXm) ≤ (Ideal.span s').comap aeval_h by
apply this
rwa [hs]
rw [Ideal.span_le]
intro x hx
apply Submodule.subset_span
apply Set.mem_union_right
exact Set.mem_image_of_mem _ hx
/-- If `f : A →ₐ[R] B` is a surjection between finitely-presented `R`-algebras, then the kernel of
`f` is finitely generated. -/
theorem ker_fG_of_surjective (f : A →ₐ[R] B) (hf : Function.Surjective f)
[FinitePresentation R A] [FinitePresentation R B] : (RingHom.ker f.toRingHom).FG := by
obtain ⟨n, g, hg, _⟩ := FinitePresentation.out (R := R) (A := A)
convert (ker_fg_of_mvPolynomial (f.comp g) (hf.comp hg)).map g.toRingHom
simp_rw [RingHom.ker_eq_comap_bot, AlgHom.toRingHom_eq_coe, AlgHom.comp_toRingHom]
rw [← Ideal.comap_comap, Ideal.map_comap_of_surjective (g : MvPolynomial (Fin n) R →+* A) hg]
end FinitePresentation
end Algebra
end ModuleAndAlgebra
namespace RingHom
variable {A B C : Type*} [CommRing A] [CommRing B] [CommRing C]
/-- A ring morphism `A →+* B` is of `RingHom.FinitePresentation` if `B` is finitely presented as
`A`-algebra. -/
@[algebraize]
def FinitePresentation (f : A →+* B) : Prop :=
@Algebra.FinitePresentation A B _ _ f.toAlgebra
@[simp]
lemma finitePresentation_algebraMap [Algebra A B] :
(algebraMap A B).FinitePresentation ↔ Algebra.FinitePresentation A B := by
rw [RingHom.FinitePresentation, toAlgebra_algebraMap]
namespace FiniteType
theorem of_finitePresentation {f : A →+* B} (hf : f.FinitePresentation) : f.FiniteType :=
@Algebra.FiniteType.of_finitePresentation A B _ _ f.toAlgebra hf
end FiniteType
namespace FinitePresentation
variable (A) in
theorem id : FinitePresentation (RingHom.id A) :=
Algebra.FinitePresentation.self A
theorem comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.FinitePresentation) (hg : Surjective g)
(hker : (RingHom.ker g).FG) : (g.comp f).FinitePresentation := by
algebraize [f, g.comp f]
exact Algebra.FinitePresentation.of_surjective
(f :=
{ g with
toFun := g
commutes' := fun _ => rfl })
hg hker
theorem of_surjective (f : A →+* B) (hf : Surjective f) (hker : (RingHom.ker f).FG) :
f.FinitePresentation := by
rw [← f.comp_id]
exact (id A).comp_surjective hf hker
theorem of_finiteType [IsNoetherianRing A] {f : A →+* B} : f.FiniteType ↔ f.FinitePresentation :=
@Algebra.FinitePresentation.of_finiteType A B _ _ f.toAlgebra _
theorem comp {g : B →+* C} {f : A →+* B} (hg : g.FinitePresentation) (hf : f.FinitePresentation) :
(g.comp f).FinitePresentation := by
algebraize [f, g, g.comp f]
exact Algebra.FinitePresentation.trans A B C
theorem of_comp_finiteType (f : A →+* B) {g : B →+* C} (hg : (g.comp f).FinitePresentation)
(hf : f.FiniteType) : g.FinitePresentation := by
algebraize [f, g, g.comp f]
exact Algebra.FinitePresentation.of_restrict_scalars_finitePresentation A B C
end FinitePresentation
end RingHom
namespace RingHom.FinitePresentation
universe u v
open Polynomial
/-- Induction principle for finitely presented ring homomorphisms.
For a property to hold for all finitely presented ring homs, it suffices for it to hold for
`Polynomial.C : R → R[X]`, surjective ring homs with finitely generated kernels, and to be closed
under composition.
Note that to state this conveniently for ring homs between rings of different universes, we carry
around two predicates `P` and `Q`, which should be "the same" apart from universes:
* `P`, for ring homs `(R : Type u) → (S : Type u)`.
* `Q`, for ring homs `(R : Type u) → (S : Type v)`.
-/
lemma polynomial_induction
(P : ∀ (R : Type u) [CommRing R] (S : Type u) [CommRing S], (R →+* S) → Prop)
(Q : ∀ (R : Type u) [CommRing R] (S : Type v) [CommRing S], (R →+* S) → Prop)
(polynomial : ∀ (R) [CommRing R], P R R[X] C)
(fg_ker : ∀ (R : Type u) [CommRing R] (S : Type v) [CommRing S] (f : R →+* S),
Surjective f → (ker f).FG → Q R S f)
(comp : ∀ (R) [CommRing R] (S) [CommRing S] (T) [CommRing T] (f : R →+* S) (g : S →+* T),
P R S f → Q S T g → Q R T (g.comp f))
{R : Type u} {S : Type v} [CommRing R] [CommRing S] (f : R →+* S) (hf : f.FinitePresentation) :
Q R S f := by
letI := f.toAlgebra
obtain ⟨n, g, hg, hg'⟩ := hf
let g' := g.toRingHom
change Surjective g' at hg
change (ker g').FG at hg'
have : g'.comp MvPolynomial.C = f := g.comp_algebraMap
clear_value g'
subst this
clear g
induction n generalizing R S with
| zero =>
refine fg_ker _ _ _ (hg.comp (MvPolynomial.C_surjective (Fin 0))) ?_
rw [← comap_ker]
convert hg'.map (MvPolynomial.isEmptyRingEquiv R (Fin 0)).toRingHom using 1
simp only [RingEquiv.toRingHom_eq_coe]
exact Ideal.comap_symm (MvPolynomial.isEmptyRingEquiv R (Fin 0))
| succ n IH =>
let e : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] MvPolynomial (Fin n) R[X] :=
(MvPolynomial.renameEquiv R (finSuccEquiv n)).trans (MvPolynomial.optionEquivRight R (Fin n))
have he : (ker (g'.comp <| RingHomClass.toRingHom e.symm)).FG := by
rw [← RingHom.comap_ker]
convert hg'.map e.toAlgHom.toRingHom using 1
exact Ideal.comap_symm e.toRingEquiv
have := IH (R := R[X]) (S := S) (g'.comp e.symm) (hg.comp e.symm.surjective) he
convert comp _ _ _ _ _ (polynomial _) this using 1
rw [comp_assoc, comp_assoc]
congr 1 with r
simp [e]
end RingHom.FinitePresentation
namespace AlgHom
variable {R A B C : Type*} [CommRing R]
variable [CommRing A] [CommRing B] [CommRing C]
variable [Algebra R A] [Algebra R B] [Algebra R C]
/-- An algebra morphism `A →ₐ[R] B` is of `AlgHom.FinitePresentation` if it is of finite
presentation as ring morphism. In other words, if `B` is finitely presented as `A`-algebra. -/
def FinitePresentation (f : A →ₐ[R] B) : Prop :=
f.toRingHom.FinitePresentation
namespace FiniteType
theorem of_finitePresentation {f : A →ₐ[R] B} (hf : f.FinitePresentation) : f.FiniteType :=
RingHom.FiniteType.of_finitePresentation hf
end FiniteType
namespace FinitePresentation
variable (R A)
theorem id : FinitePresentation (AlgHom.id R A) :=
RingHom.FinitePresentation.id A
variable {R A}
theorem comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.FinitePresentation)
(hf : f.FinitePresentation) : (g.comp f).FinitePresentation :=
RingHom.FinitePresentation.comp hg hf
theorem comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.FinitePresentation)
(hg : Surjective g) (hker : (RingHom.ker g.toRingHom).FG) : (g.comp f).FinitePresentation :=
RingHom.FinitePresentation.comp_surjective hf hg hker
theorem of_surjective (f : A →ₐ[R] B) (hf : Surjective f) (hker : (RingHom.ker f.toRingHom).FG) :
f.FinitePresentation := by
-- Porting note: added `convert`
convert RingHom.FinitePresentation.of_surjective f hf hker
theorem of_finiteType [IsNoetherianRing A] {f : A →ₐ[R] B} : f.FiniteType ↔ f.FinitePresentation :=
RingHom.FinitePresentation.of_finiteType
nonrec theorem of_comp_finiteType (f : A →ₐ[R] B) {g : B →ₐ[R] C}
(h : (g.comp f).FinitePresentation) (h' : f.FiniteType) : g.FinitePresentation :=
h.of_comp_finiteType _ h'
end FinitePresentation
end AlgHom |
.lake/packages/mathlib/Mathlib/RingTheory/ReesAlgebra.lean | import Mathlib.RingTheory.Ideal.BigOperators
import Mathlib.RingTheory.FiniteType
/-!
# Rees algebra
The Rees algebra of an ideal `I` is the subalgebra `R[It]` of `R[t]` defined as `R[It] = ⨁ₙ Iⁿ tⁿ`.
This is used to prove the Artin-Rees lemma, and will potentially enable us to calculate some
blowup in the future.
## Main definition
- `reesAlgebra` : The Rees algebra of an ideal `I`, defined as a subalgebra of `R[X]`.
- `adjoin_monomial_eq_reesAlgebra` : The Rees algebra is generated by the degree one elements.
- `reesAlgebra.fg` : The Rees algebra of a f.g. ideal is of finite type. In particular, this
implies that the rees algebra over a Noetherian ring is still Noetherian.
-/
universe u v
variable {R M : Type u} [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R)
open Polynomial
/-- The Rees algebra of an ideal `I`, defined as the subalgebra of `R[X]` whose `i`-th coefficient
falls in `I ^ i`. -/
def reesAlgebra : Subalgebra R R[X] where
carrier := { f | ∀ i, f.coeff i ∈ I ^ i }
mul_mem' hf hg i := by
rw [coeff_mul]
apply Ideal.sum_mem
rintro ⟨j, k⟩ e
rw [← Finset.mem_antidiagonal.mp e, pow_add]
exact Ideal.mul_mem_mul (hf j) (hg k)
one_mem' i := by
rw [coeff_one]
split_ifs with h
· subst h
simp
· simp
add_mem' hf hg i := by
rw [coeff_add]
exact Ideal.add_mem _ (hf i) (hg i)
zero_mem' _ := Ideal.zero_mem _
algebraMap_mem' r i := by
rw [algebraMap_apply, coeff_C]
split_ifs with h
· subst h
simp
· simp
theorem mem_reesAlgebra_iff (f : R[X]) : f ∈ reesAlgebra I ↔ ∀ i, f.coeff i ∈ I ^ i :=
Iff.rfl
theorem mem_reesAlgebra_iff_support (f : R[X]) :
f ∈ reesAlgebra I ↔ ∀ i ∈ f.support, f.coeff i ∈ I ^ i := by
apply forall_congr'
intro a
rw [mem_support_iff, Iff.comm, Classical.imp_iff_right_iff, Ne, ← imp_iff_not_or]
exact fun e => e.symm ▸ (I ^ a).zero_mem
theorem reesAlgebra.monomial_mem {I : Ideal R} {i : ℕ} {r : R} :
monomial i r ∈ reesAlgebra I ↔ r ∈ I ^ i := by
simp +contextual [mem_reesAlgebra_iff_support, coeff_monomial, ←
imp_iff_not_or]
theorem monomial_mem_adjoin_monomial {I : Ideal R} {n : ℕ} {r : R} (hr : r ∈ I ^ n) :
monomial n r ∈ Algebra.adjoin R (Submodule.map (monomial 1 : R →ₗ[R] R[X]) I : Set R[X]) := by
induction n generalizing r with
| zero => exact Subalgebra.algebraMap_mem _ _
| succ n hn =>
rw [pow_succ'] at hr
refine Submodule.smul_induction_on hr ?_ ?_
· intro r hr s hs
rw [add_comm n 1, smul_eq_mul, ← monomial_mul_monomial]
exact Subalgebra.mul_mem _ (Algebra.subset_adjoin (Set.mem_image_of_mem _ hr)) (hn hs)
· intro x y hx hy
rw [map_add]
exact Subalgebra.add_mem _ hx hy
theorem adjoin_monomial_eq_reesAlgebra :
Algebra.adjoin R (Submodule.map (monomial 1 : R →ₗ[R] R[X]) I : Set R[X]) = reesAlgebra I := by
apply le_antisymm
· apply Algebra.adjoin_le _
rintro _ ⟨r, hr, rfl⟩
exact reesAlgebra.monomial_mem.mpr (by rwa [pow_one])
· intro p hp
rw [p.as_sum_support]
apply Subalgebra.sum_mem _ _
rintro i -
exact monomial_mem_adjoin_monomial (hp i)
variable {I}
theorem reesAlgebra.fg (hI : I.FG) : (reesAlgebra I).FG := by
classical
obtain ⟨s, hs⟩ := hI
rw [← adjoin_monomial_eq_reesAlgebra, ← hs]
use s.image (monomial 1)
rw [Finset.coe_image]
change
_ =
Algebra.adjoin R
(Submodule.map (monomial 1 : R →ₗ[R] R[X]) (Submodule.span R ↑s) : Set R[X])
rw [Submodule.map_span, Algebra.adjoin_span]
instance [IsNoetherianRing R] : Algebra.FiniteType R (reesAlgebra I) :=
⟨(reesAlgebra I).fg_top.mpr (reesAlgebra.fg <| IsNoetherian.noetherian I)⟩
instance [IsNoetherianRing R] : IsNoetherianRing (reesAlgebra I) :=
Algebra.FiniteType.isNoetherianRing R _ |
.lake/packages/mathlib/Mathlib/RingTheory/Lasker.lean | import Mathlib.Order.Irreducible
import Mathlib.RingTheory.Ideal.Colon
import Mathlib.RingTheory.Ideal.IsPrimary
import Mathlib.RingTheory.Noetherian.Defs
/-!
# Lasker ring
## Main declarations
- `IsLasker`: A ring `R` satisfies `IsLasker R` when any `I : Ideal R` can be decomposed into
finitely many primary ideals.
- `IsLasker.minimal`: Any `I : Ideal R` in a ring `R` satisfying `IsLasker R` can be
decomposed into primary ideals, such that the decomposition is minimal:
each primary ideal is necessary, and each primary ideal has an independent radical.
- `Ideal.isLasker`: Every Noetherian commutative ring is a Lasker ring.
## Implementation details
There is a generalization for submodules that needs to be implemented.
Also, one needs to prove that the radicals of minimal decompositions are independent of the
precise decomposition.
-/
section IsLasker
variable (R : Type*) [CommSemiring R]
/-- A ring `R` satisfies `IsLasker R` when any `I : Ideal R` can be decomposed into
finitely many primary ideals. -/
def IsLasker : Prop :=
∀ I : Ideal R, ∃ s : Finset (Ideal R), s.inf id = I ∧ ∀ ⦃J⦄, J ∈ s → J.IsPrimary
variable {R}
namespace Ideal
lemma decomposition_erase_inf [DecidableEq (Ideal R)] {I : Ideal R}
{s : Finset (Ideal R)} (hs : s.inf id = I) :
∃ t : Finset (Ideal R), t ⊆ s ∧ t.inf id = I ∧ (∀ ⦃J⦄, J ∈ t → ¬ (t.erase J).inf id ≤ J) := by
induction s using Finset.eraseInduction with
| H s IH =>
by_cases! H : ∀ J ∈ s, ¬ (s.erase J).inf id ≤ J
· exact ⟨s, Finset.Subset.rfl, hs, H⟩
obtain ⟨J, hJ, hJ'⟩ := H
refine (IH _ hJ ?_).imp
fun t ↦ And.imp_left (fun ht ↦ ht.trans (Finset.erase_subset _ _))
rw [← Finset.insert_erase hJ] at hs
simp [← hs, hJ']
open scoped Function -- required for scoped `on` notation
lemma isPrimary_decomposition_pairwise_ne_radical {I : Ideal R}
{s : Finset (Ideal R)} (hs : s.inf id = I) (hs' : ∀ ⦃J⦄, J ∈ s → J.IsPrimary) :
∃ t : Finset (Ideal R), t.inf id = I ∧ (∀ ⦃J⦄, J ∈ t → J.IsPrimary) ∧
(t : Set (Ideal R)).Pairwise ((· ≠ ·) on radical) := by
classical
refine ⟨(s.image (fun J ↦ {I ∈ s | I.radical = J.radical})).image fun t ↦ t.inf id,
?_, ?_, ?_⟩
· ext
grind [Finset.inf_image, Submodule.mem_finsetInf]
· simp only [Finset.mem_image, exists_exists_and_eq_and, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro J hJ
refine isPrimary_finset_inf (i := J) ?_ ?_ (by simp)
· simp [hJ]
· simp only [Finset.mem_filter, id_eq, and_imp]
intro y hy
simp [hs' hy]
· intro I hI J hJ hIJ
simp only [Finset.coe_image, Set.mem_image, Finset.mem_coe, exists_exists_and_eq_and] at hI hJ
obtain ⟨I', hI', hI⟩ := hI
obtain ⟨J', hJ', hJ⟩ := hJ
simp only [Function.onFun, ne_eq]
contrapose! hIJ
suffices I'.radical = J'.radical by
rw [← hI, ← hJ, this]
· rw [← hI, radical_finset_inf (i := I') (by simp [hI']) (by simp), id_eq] at hIJ
rw [hIJ, ← hJ, radical_finset_inf (i := J') (by simp [hJ']) (by simp), id_eq]
lemma exists_minimal_isPrimary_decomposition_of_isPrimary_decomposition [DecidableEq (Ideal R)]
{I : Ideal R} {s : Finset (Ideal R)} (hs : s.inf id = I) (hs' : ∀ ⦃J⦄, J ∈ s → J.IsPrimary) :
∃ t : Finset (Ideal R), t.inf id = I ∧ (∀ ⦃J⦄, J ∈ t → J.IsPrimary) ∧
((t : Set (Ideal R)).Pairwise ((· ≠ ·) on radical)) ∧
(∀ ⦃J⦄, J ∈ t → ¬ (t.erase J).inf id ≤ J) := by
obtain ⟨t, ht, ht', ht''⟩ := isPrimary_decomposition_pairwise_ne_radical hs hs'
obtain ⟨u, hut, hu, hu'⟩ := decomposition_erase_inf ht
exact ⟨u, hu, fun _ hi ↦ ht' (hut hi), ht''.mono hut, hu'⟩
lemma IsLasker.minimal [DecidableEq (Ideal R)] (h : IsLasker R) (I : Ideal R) :
∃ t : Finset (Ideal R), t.inf id = I ∧ (∀ ⦃J⦄, J ∈ t → J.IsPrimary) ∧
((t : Set (Ideal R)).Pairwise ((· ≠ ·) on radical)) ∧
(∀ ⦃J⦄, J ∈ t → ¬ (t.erase J).inf id ≤ J) := by
obtain ⟨s, hs, hs'⟩ := h I
exact exists_minimal_isPrimary_decomposition_of_isPrimary_decomposition hs hs'
end Ideal
end IsLasker
namespace Ideal
section Noetherian
variable {R : Type*} [CommRing R] [IsNoetherianRing R]
lemma _root_.InfIrred.isPrimary {I : Ideal R} (h : InfIrred I) : I.IsPrimary := by
rw [Ideal.isPrimary_iff]
refine ⟨h.ne_top, fun {a b} hab ↦ ?_⟩
let f : ℕ → Ideal R := fun n ↦ (I.colon (span {b ^ n}))
have hf : Monotone f := by
intro n m hnm
simp_rw [f]
exact (Submodule.colon_mono le_rfl (Ideal.span_singleton_le_span_singleton.mpr
(pow_dvd_pow b hnm)))
obtain ⟨n, hn⟩ := monotone_stabilizes_iff_noetherian.mpr ‹_› ⟨f, hf⟩
rcases h with ⟨-, h⟩
specialize @h (I.colon (span {b ^ n})) (I + (span {b ^ n})) ?_
· refine le_antisymm (fun r ↦ ?_) (le_inf (fun _ ↦ ?_) ?_)
· simp only [Submodule.add_eq_sup, sup_comm I, mem_inf, mem_colon_singleton,
mem_span_singleton_sup, and_imp, forall_exists_index]
rintro hrb t s hs rfl
refine add_mem ?_ hs
have := hn (n + n) (by simp)
simp only [OrderHom.coe_mk, f] at this
rw [add_mul, mul_assoc, ← pow_add] at hrb
rwa [← mem_colon_singleton, this, mem_colon_singleton,
← Ideal.add_mem_iff_left _ (Ideal.mul_mem_right _ _ hs)]
· simpa only [mem_colon_singleton] using mul_mem_right _ _
· simp
rcases h with (h | h)
· replace h : I = I.colon (span {b}) := by
rcases eq_or_ne n 0 with rfl | hn'
· simpa [f] using hn 1 zero_le_one
refine le_antisymm ?_ (h.le.trans' (Submodule.colon_mono le_rfl ?_))
· intro
simpa only [mem_colon_singleton] using mul_mem_right _ _
· exact span_singleton_le_span_singleton.mpr (dvd_pow_self b hn')
rw [← mem_colon_singleton, ← h] at hab
exact Or.inl hab
· rw [← h]
refine Or.inr ⟨n, ?_⟩
simpa using mem_sup_right (mem_span_singleton_self _)
variable (R) in
/-- The Lasker--Noether theorem: every ideal in a Noetherian ring admits a decomposition into
primary ideals. -/
lemma isLasker : IsLasker R := fun I ↦
(exists_infIrred_decomposition I).imp fun _ h ↦ h.imp_right fun h' _ ht ↦ (h' ht).isPrimary
end Noetherian
end Ideal |
.lake/packages/mathlib/Mathlib/RingTheory/ZMod.lean | import Mathlib.Algebra.Squarefree.Basic
import Mathlib.Algebra.EuclideanDomain.Int
import Mathlib.Data.ZMod.Basic
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# Ring-theoretic facts about `ZMod n`
We collect a few facts about `ZMod n` that need some ring theory to be proved/stated.
## Main statements
* `ZMod.ker_intCastRingHom`: the ring homomorphism `ℤ → ZMod n` has kernel generated by `n`.
* `ZMod.ringHom_eq_of_ker_eq`: two ring homomorphisms into `ZMod n` with equal kernels are equal.
* `isReduced_zmod`: `ZMod n` is reduced for all squarefree `n`.
-/
/-- The ring homomorphism `ℤ → ZMod n` has kernel generated by `n`. -/
theorem ZMod.ker_intCastRingHom (n : ℕ) :
RingHom.ker (Int.castRingHom (ZMod n)) = Ideal.span ({(n : ℤ)} : Set ℤ) := by
ext
rw [Ideal.mem_span_singleton, RingHom.mem_ker, Int.coe_castRingHom,
ZMod.intCast_zmod_eq_zero_iff_dvd]
/-- Two ring homomorphisms into `ZMod n` with equal kernels are equal. -/
theorem ZMod.ringHom_eq_of_ker_eq {n : ℕ} {R : Type*} [Ring R] (f g : R →+* ZMod n)
(h : RingHom.ker f = RingHom.ker g) : f = g := by
have := f.liftOfRightInverse_comp _ (ZMod.ringHom_rightInverse f) ⟨g, le_of_eq h⟩
rw [Subtype.coe_mk] at this
rw [← this, RingHom.ext_zmod (f.liftOfRightInverse _ _ ⟨g, _⟩) _, RingHom.id_comp]
/-- `ZMod n` is reduced iff `n` is square-free (or `n=0`). -/
@[simp]
theorem isReduced_zmod {n : ℕ} : IsReduced (ZMod n) ↔ Squarefree n ∨ n = 0 := by
rw [← RingHom.ker_isRadical_iff_reduced_of_surjective
(ZMod.ringHom_surjective <| Int.castRingHom <| ZMod n),
ZMod.ker_intCastRingHom, ← isRadical_iff_span_singleton, isRadical_iff_squarefree_or_zero,
Int.squarefree_natCast, Nat.cast_eq_zero]
instance {n : ℕ} [Fact <| Squarefree n] : IsReduced (ZMod n) :=
isReduced_zmod.2 <| Or.inl <| Fact.out |
.lake/packages/mathlib/Mathlib/RingTheory/Binomial.lean | import Mathlib.Algebra.Algebra.Rat
import Mathlib.Algebra.Group.Torsion
import Mathlib.Algebra.Module.Rat
import Mathlib.Algebra.Polynomial.Smeval
import Mathlib.Algebra.Ring.NegOnePow
import Mathlib.Data.NNRat.Order
import Mathlib.GroupTheory.GroupAction.Ring
import Mathlib.RingTheory.Polynomial.Pochhammer
import Mathlib.Tactic.Field
import Mathlib.Tactic.Module
/-!
# Binomial rings
In this file we introduce the binomial property as a mixin, and define the `multichoose`
and `choose` functions generalizing binomial coefficients.
According to our main reference [elliott2006binomial] (which lists many equivalent conditions), a
binomial ring is a torsion-free commutative ring `R` such that for any `x ∈ R` and any `k ∈ ℕ`, the
product `x(x-1)⋯(x-k+1)` is divisible by `k!`. The torsion-free condition lets us divide by `k!`
unambiguously, so we get uniquely defined binomial coefficients.
The defining condition doesn't require commutativity or associativity, and we get a theory with
essentially the same power by replacing subtraction with addition. Thus, we consider any additive
commutative monoid with a notion of natural number exponents in which multiplication by positive
integers is injective, and demand that the evaluation of the ascending Pochhammer polynomial
`X(X+1)⋯(X+(k-1))` at any element is divisible by `k!`. The quotient is called `multichoose r k`,
because for `r` a natural number, it is the number of multisets of cardinality `k` taken from a type
of cardinality `n`.
## Definitions
* `BinomialRing`: a mixin class specifying a suitable `multichoose` function.
* `Ring.multichoose`: the quotient of an ascending Pochhammer evaluation by a factorial.
* `Ring.choose`: the quotient of a descending Pochhammer evaluation by a factorial.
## Results
* Basic results with choose and multichoose, e.g., `choose_zero_right`
* Relations between choose and multichoose, negated input.
* Fundamental recursion: `choose_succ_succ`
* Chu-Vandermonde identity: `add_choose_eq`
* Pochhammer API
## References
* [J. Elliott, *Binomial rings, integer-valued polynomials, and λ-rings*][elliott2006binomial]
## TODO
Further results in Elliot's paper:
* A CommRing is binomial if and only if it admits a λ-ring structure with trivial Adams operations.
* The free commutative binomial ring on a set `X` is the ring of integer-valued polynomials in the
variables `X`. (also, noncommutative version?)
* Given a commutative binomial ring `A` and an `A`-algebra `B` that is complete with respect to an
ideal `I`, formal exponentiation induces an `A`-module structure on the multiplicative subgroup
`1 + I`.
-/
open Function Polynomial
/-- A binomial ring is a ring for which ascending Pochhammer evaluations are uniquely divisible by
suitable factorials. We define this notion as a mixin for additive commutative monoids with natural
number powers, but retain the ring name. We introduce `Ring.multichoose` as the uniquely defined
quotient. -/
class BinomialRing (R : Type*) [AddCommMonoid R] [Pow R ℕ] where
-- This base class has been demoted to a field, to avoid creating
-- an expensive global instance.
[toIsAddTorsionFree : IsAddTorsionFree R]
/-- A multichoose function, giving the quotient of Pochhammer evaluations by factorials. -/
multichoose : R → ℕ → R
/-- The `n`th ascending Pochhammer polynomial evaluated at any element is divisible by `n!` -/
factorial_nsmul_multichoose (r : R) (n : ℕ) :
n.factorial • multichoose r n = (ascPochhammer ℕ n).smeval r
-- This is only a local instance as it otherwise causes significant slow downs
-- to every call to `grind` involving a ring. Please do not make it a global instance.
-- (~1500 heartbeats measured on `nightly-testing-2025-09-09`.)
attribute [local instance] BinomialRing.toIsAddTorsionFree
section Multichoose
namespace Ring
variable {R : Type*} [AddCommMonoid R] [Pow R ℕ] [BinomialRing R]
/-- The multichoose function is the quotient of ascending Pochhammer evaluation by the corresponding
factorial. When applied to natural numbers, `multichoose k n` describes choosing a multiset of `n`
items from a type of size `k`, i.e., choosing with replacement. -/
def multichoose (r : R) (n : ℕ) : R := BinomialRing.multichoose r n
@[simp]
theorem multichoose_eq_multichoose (r : R) (n : ℕ) :
BinomialRing.multichoose r n = multichoose r n := rfl
theorem factorial_nsmul_multichoose_eq_ascPochhammer (r : R) (n : ℕ) :
n.factorial • multichoose r n = (ascPochhammer ℕ n).smeval r :=
BinomialRing.factorial_nsmul_multichoose r n
@[simp]
theorem multichoose_zero_right' (r : R) : multichoose r 0 = r ^ 0 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero 0),
factorial_nsmul_multichoose_eq_ascPochhammer, ascPochhammer_zero, smeval_one, Nat.factorial]
theorem multichoose_zero_right [MulOneClass R] [NatPowAssoc R]
(r : R) : multichoose r 0 = 1 := by
rw [multichoose_zero_right', npow_zero]
@[simp]
theorem multichoose_one_right' (r : R) : multichoose r 1 = r ^ 1 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero 1),
factorial_nsmul_multichoose_eq_ascPochhammer, ascPochhammer_one, smeval_X, Nat.factorial_one,
one_smul]
theorem multichoose_one_right [MulOneClass R] [NatPowAssoc R] (r : R) : multichoose r 1 = r := by
rw [multichoose_one_right', npow_one]
variable {R : Type*} [NonAssocSemiring R] [Pow R ℕ] [NatPowAssoc R] [BinomialRing R]
@[simp]
theorem multichoose_zero_succ (k : ℕ) : multichoose (0 : R) (k + 1) = 0 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero (k + 1)),
factorial_nsmul_multichoose_eq_ascPochhammer, smul_zero, ascPochhammer_succ_left,
smeval_X_mul, zero_mul]
theorem ascPochhammer_succ_succ (r : R) (k : ℕ) :
smeval (ascPochhammer ℕ (k + 1)) (r + 1) = Nat.factorial (k + 1) • multichoose (r + 1) k +
smeval (ascPochhammer ℕ (k + 1)) r := by
nth_rw 1 [ascPochhammer_succ_right, ascPochhammer_succ_left, mul_comm (ascPochhammer ℕ k)]
simp only [smeval_mul, smeval_comp, smeval_add, smeval_X]
rw [Nat.factorial, mul_smul, factorial_nsmul_multichoose_eq_ascPochhammer]
simp only [smeval_one, npow_one, npow_zero, one_smul]
rw [← C_eq_natCast, smeval_C, npow_zero, add_assoc, add_mul, add_comm 1, @nsmul_one, add_mul]
rw [← @nsmul_eq_mul, @add_rotate', @succ_nsmul, add_assoc]
simp_all only [Nat.cast_id, nsmul_eq_mul, one_mul]
theorem multichoose_succ_succ (r : R) (k : ℕ) :
multichoose (r + 1) (k + 1) = multichoose r (k + 1) + multichoose (r + 1) k := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero (k + 1))]
simp only [factorial_nsmul_multichoose_eq_ascPochhammer, smul_add]
rw [add_comm (smeval (ascPochhammer ℕ (k + 1)) r), ascPochhammer_succ_succ r k]
@[simp]
theorem multichoose_one (k : ℕ) : multichoose (1 : R) k = 1 := by
induction k with
| zero => exact multichoose_zero_right 1
| succ n ih =>
rw [show (1 : R) = 0 + 1 by exact (@zero_add R _ 1).symm, multichoose_succ_succ,
multichoose_zero_succ, zero_add, zero_add, ih]
theorem multichoose_two (k : ℕ) : multichoose (2 : R) k = k + 1 := by
induction k with
| zero =>
rw [multichoose_zero_right, Nat.cast_zero, zero_add]
| succ n ih =>
rw [one_add_one_eq_two.symm, multichoose_succ_succ, multichoose_one, one_add_one_eq_two, ih,
Nat.cast_succ, add_comm]
attribute [local instance] BinomialRing.toIsAddTorsionFree in
lemma map_multichoose {R S F : Type*} [Ring R] [Ring S] [BinomialRing R] [BinomialRing S]
[FunLike F R S] [RingHomClass F R S] (f : F) (a : R) (n : ℕ) :
f (Ring.multichoose a n) = Ring.multichoose (f a) n := by
apply nsmul_right_injective n.factorial_ne_zero
simp only [← map_nsmul, Ring.factorial_nsmul_multichoose_eq_ascPochhammer,
← Polynomial.eval₂_smulOneHom_eq_smeval, Polynomial.hom_eval₂, ← RingHom.coe_coe f]
congr
exact Subsingleton.elim _ _
end Ring
end Multichoose
section Pochhammer
namespace Polynomial
@[simp]
theorem ascPochhammer_smeval_cast (R : Type*) [Semiring R] {S : Type*} [NonAssocSemiring S]
[Pow S ℕ] [Module R S] [IsScalarTower R S S] [NatPowAssoc S]
(x : S) (n : ℕ) : (ascPochhammer R n).smeval x = (ascPochhammer ℕ n).smeval x := by
induction n with
| zero => simp only [ascPochhammer_zero, smeval_one, one_smul]
| succ n hn =>
simp only [ascPochhammer_succ_right, mul_add, smeval_add, smeval_mul_X, ← Nat.cast_comm]
simp only [← C_eq_natCast, smeval_C_mul, hn, Nat.cast_smul_eq_nsmul R n]
simp only [nsmul_eq_mul, Nat.cast_id]
variable {R : Type*}
theorem ascPochhammer_smeval_eq_eval [Semiring R] (r : R) (n : ℕ) :
(ascPochhammer ℕ n).smeval r = (ascPochhammer R n).eval r := by
rw [eval_eq_smeval, ascPochhammer_smeval_cast R]
variable [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R]
theorem descPochhammer_smeval_eq_ascPochhammer (r : R) (n : ℕ) :
(descPochhammer ℤ n).smeval r = (ascPochhammer ℕ n).smeval (r - n + 1) := by
induction n with
| zero => simp only [descPochhammer_zero, ascPochhammer_zero, smeval_one, npow_zero]
| succ n ih =>
rw [Nat.cast_succ, sub_add, add_sub_cancel_right, descPochhammer_succ_right, smeval_mul, ih,
ascPochhammer_succ_left, X_mul, smeval_mul_X, smeval_comp, smeval_sub, ← C_eq_natCast,
smeval_add, smeval_one, smeval_C]
simp only [smeval_X, npow_one, npow_zero, zsmul_one, Int.cast_natCast, one_smul]
theorem descPochhammer_smeval_eq_descFactorial (n k : ℕ) :
(descPochhammer ℤ k).smeval (n : R) = n.descFactorial k := by
induction k with
| zero =>
rw [descPochhammer_zero, Nat.descFactorial_zero, Nat.cast_one, smeval_one, npow_zero, one_smul]
| succ k ih =>
rw [descPochhammer_succ_right, Nat.descFactorial_succ, smeval_mul, ih, mul_comm, Nat.cast_mul,
smeval_sub, smeval_X, smeval_natCast, npow_one, npow_zero, nsmul_one]
by_cases! h : n < k
· simp only [Nat.descFactorial_eq_zero_iff_lt.mpr h, Nat.cast_zero, zero_mul]
· rw [Nat.cast_sub h]
theorem ascPochhammer_smeval_neg_eq_descPochhammer (r : R) (k : ℕ) :
(ascPochhammer ℕ k).smeval (-r) = Int.negOnePow k • (descPochhammer ℤ k).smeval r := by
induction k with
| zero => simp
| succ k ih =>
simp only [ascPochhammer_succ_right, smeval_mul, ih, descPochhammer_succ_right, sub_eq_add_neg]
have h : (X + (k : ℕ[X])).smeval (-r) = -(X + (-k : ℤ[X])).smeval r := by
simp [smeval_natCast, add_comm]
rw [h, ← neg_mul_comm, Int.natCast_add, Int.natCast_one, Int.negOnePow_succ, Units.neg_smul,
Units.smul_def, Units.smul_def, ← smul_mul_assoc, neg_mul]
end Polynomial
end Pochhammer
section Basic_Instances
open Polynomial
instance Nat.instBinomialRing : BinomialRing ℕ where
multichoose := Nat.multichoose
factorial_nsmul_multichoose r n := by
rw [smul_eq_mul, Nat.multichoose_eq r n, ← Nat.descFactorial_eq_factorial_mul_choose,
← eval_eq_smeval r (ascPochhammer ℕ n), ascPochhammer_nat_eq_descFactorial]
/-- The multichoose function for integers. -/
def Int.multichoose (n : ℤ) (k : ℕ) : ℤ :=
match n with
| ofNat n => (Nat.choose (n + k - 1) k : ℤ)
| negSucc n => Int.negOnePow k * Nat.choose (n + 1) k
instance Int.instBinomialRing : BinomialRing ℤ where
multichoose := Int.multichoose
factorial_nsmul_multichoose r k := by
rw [Int.multichoose.eq_def, nsmul_eq_mul]
cases r with
| ofNat n =>
simp only [Int.ofNat_eq_coe, Int.ofNat_mul_out]
rw [← Nat.descFactorial_eq_factorial_mul_choose, smeval_at_natCast, ← eval_eq_smeval n,
ascPochhammer_nat_eq_descFactorial]
| negSucc n =>
simp only
rw [mul_comm, mul_assoc, ← Nat.cast_mul, mul_comm _ (k.factorial),
← Nat.descFactorial_eq_factorial_mul_choose, ← descPochhammer_smeval_eq_descFactorial,
← Int.neg_ofNat_succ, ascPochhammer_smeval_neg_eq_descPochhammer]
norm_cast
attribute [local instance] IsAddTorsionFree.of_module_nnrat
noncomputable instance {R : Type*} [AddCommMonoid R] [Module ℚ≥0 R] [Pow R ℕ] : BinomialRing R where
multichoose r n := (n.factorial : ℚ≥0)⁻¹ • Polynomial.smeval (ascPochhammer ℕ n) r
factorial_nsmul_multichoose r n := by
match_scalars
field
end Basic_Instances
section Neg
namespace Ring
open Polynomial
variable {R : Type*} [NonAssocRing R] [Pow R ℕ] [BinomialRing R]
@[simp]
theorem smeval_ascPochhammer_self_neg : ∀ n : ℕ,
smeval (ascPochhammer ℕ n) (-n : ℤ) = (-1) ^ n * n.factorial
| 0 => by
rw [Nat.cast_zero, neg_zero, ascPochhammer_zero, Nat.factorial_zero, smeval_one, pow_zero,
one_smul, pow_zero, Nat.cast_one, one_mul]
| n + 1 => by
rw [ascPochhammer_succ_left, smeval_X_mul, smeval_comp, smeval_add, smeval_X, smeval_one,
pow_zero, pow_one, one_smul, Nat.cast_add, Nat.cast_one, neg_add_rev, neg_add_cancel_comm,
smeval_ascPochhammer_self_neg n, ← mul_assoc, mul_comm _ ((-1) ^ n),
show (-1 + -↑n = (-1 : ℤ) * (n + 1)) by cutsat, ← mul_assoc, pow_add, pow_one,
Nat.factorial, Nat.cast_mul, ← mul_assoc, Nat.cast_succ]
@[simp]
theorem smeval_ascPochhammer_succ_neg (n : ℕ) :
smeval (ascPochhammer ℕ (n + 1)) (-n : ℤ) = 0 := by
rw [ascPochhammer_succ_right, smeval_mul, smeval_add, smeval_X, ← C_eq_natCast, smeval_C,
pow_zero, pow_one, Nat.cast_id, nsmul_eq_mul, mul_one, neg_add_cancel, mul_zero]
theorem smeval_ascPochhammer_neg_add (n : ℕ) : ∀ k : ℕ,
smeval (ascPochhammer ℕ (n + k + 1)) (-n : ℤ) = 0
| 0 => by
rw [add_zero, smeval_ascPochhammer_succ_neg]
| k + 1 => by
rw [ascPochhammer_succ_right, smeval_mul, ← add_assoc, smeval_ascPochhammer_neg_add n k,
zero_mul]
@[simp]
theorem smeval_ascPochhammer_neg_of_lt {n k : ℕ} (h : n < k) :
smeval (ascPochhammer ℕ k) (-n : ℤ) = 0 := by
rw [show k = n + (k - n - 1) + 1 by cutsat, smeval_ascPochhammer_neg_add]
theorem smeval_ascPochhammer_nat_cast {R} [NonAssocSemiring R] [Pow R ℕ] [NatPowAssoc R] (n k : ℕ) :
smeval (ascPochhammer ℕ k) (n : R) = smeval (ascPochhammer ℕ k) n := by
rw [smeval_at_natCast (ascPochhammer ℕ k) n]
theorem multichoose_neg_self (n : ℕ) : multichoose (-n : ℤ) n = (-1) ^ n := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero _),
factorial_nsmul_multichoose_eq_ascPochhammer, smeval_ascPochhammer_self_neg, nsmul_eq_mul,
Nat.cast_comm]
@[simp]
theorem multichoose_neg_succ (n : ℕ) : multichoose (-n : ℤ) (n + 1) = 0 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero _),
factorial_nsmul_multichoose_eq_ascPochhammer, smeval_ascPochhammer_succ_neg, smul_zero]
theorem multichoose_neg_add (n k : ℕ) : multichoose (-n : ℤ) (n + k + 1) = 0 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero (n + k + 1)),
factorial_nsmul_multichoose_eq_ascPochhammer, smeval_ascPochhammer_neg_add, smul_zero]
@[simp]
theorem multichoose_neg_of_lt (n k : ℕ) (h : n < k) : multichoose (-n : ℤ) k = 0 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero k),
factorial_nsmul_multichoose_eq_ascPochhammer, smeval_ascPochhammer_neg_of_lt h, smul_zero]
theorem multichoose_succ_neg_natCast [NatPowAssoc R] (n : ℕ) :
multichoose (-n : R) (n + 1) = 0 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero (n + 1)), smul_zero,
factorial_nsmul_multichoose_eq_ascPochhammer, smeval_neg_nat,
smeval_ascPochhammer_succ_neg n, Int.cast_zero]
theorem smeval_ascPochhammer_int_ofNat {R} [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R] (r : R) :
∀ n : ℕ, smeval (ascPochhammer ℤ n) r = smeval (ascPochhammer ℕ n) r
| 0 => by
simp only [ascPochhammer_zero, smeval_one]
| n + 1 => by
simp only [ascPochhammer_succ_right, smeval_mul]
rw [smeval_ascPochhammer_int_ofNat r n]
simp only [smeval_add, smeval_X, ← C_eq_natCast, smeval_C, natCast_zsmul, nsmul_eq_mul,
Nat.cast_id]
end Ring
end Neg
section Choose
namespace Ring
open Polynomial
variable {R : Type*}
section
/-- The binomial coefficient `choose r n` generalizes the natural number `Nat.choose` function,
interpreted in terms of choosing without replacement. -/
def choose [AddCommGroupWithOne R] [Pow R ℕ] [BinomialRing R] (r : R) (n : ℕ) : R :=
multichoose (r - n + 1) n
variable [NonAssocRing R] [Pow R ℕ] [BinomialRing R]
theorem descPochhammer_eq_factorial_smul_choose [NatPowAssoc R] (r : R) (n : ℕ) :
(descPochhammer ℤ n).smeval r = n.factorial • choose r n := by
rw [choose, factorial_nsmul_multichoose_eq_ascPochhammer, descPochhammer_eq_ascPochhammer,
smeval_comp, add_comm_sub, smeval_add, smeval_X, npow_one]
have h : smeval (1 - n : Polynomial ℤ) r = 1 - n := by
rw [← C_eq_natCast, ← C_1, ← C_sub, smeval_C]
simp only [npow_zero, zsmul_one, Int.cast_sub, Int.cast_one, Int.cast_natCast]
rw [h, ascPochhammer_smeval_cast, add_comm_sub]
theorem choose_natCast [NatPowAssoc R] (n k : ℕ) : choose (n : R) k = Nat.choose n k := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero k),
← descPochhammer_eq_factorial_smul_choose, nsmul_eq_mul, ← Nat.cast_mul,
← Nat.descFactorial_eq_factorial_mul_choose, ← descPochhammer_smeval_eq_descFactorial]
@[simp]
theorem choose_zero_right' (r : R) : choose r 0 = (r + 1) ^ 0 := by
dsimp only [choose]
rw [← nsmul_right_inj (Nat.factorial_ne_zero 0)]
simp
theorem choose_zero_right [NatPowAssoc R] (r : R) : choose r 0 = 1 := by
rw [choose_zero_right', npow_zero]
@[simp]
theorem choose_zero_succ (R) [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R] [BinomialRing R]
(n : ℕ) : choose (0 : R) (n + 1) = 0 := by
rw [choose, Nat.cast_succ, zero_sub, neg_add, neg_add_cancel_right, multichoose_succ_neg_natCast]
theorem choose_zero_pos (R) [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R] [BinomialRing R]
{k : ℕ} (h_pos : 0 < k) : choose (0 : R) k = 0 := by
rw [← Nat.succ_pred_eq_of_pos h_pos, choose_zero_succ]
theorem choose_zero_ite (R) [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R] [BinomialRing R]
(k : ℕ) : choose (0 : R) k = if k = 0 then 1 else 0 := by
split_ifs with hk
· rw [hk, choose_zero_right]
· rw [choose_zero_pos R <| Nat.pos_of_ne_zero hk]
@[simp]
theorem choose_one_right' (r : R) : choose r 1 = r ^ 1 := by
rw [choose, Nat.cast_one, sub_add_cancel, multichoose_one_right']
theorem choose_one_right [NatPowAssoc R] (r : R) : choose r 1 = r := by
rw [choose_one_right', npow_one]
theorem choose_neg [NatPowAssoc R] (r : R) (n : ℕ) :
choose (-r) n = Int.negOnePow n • choose (r + n - 1) n := by
apply (nsmul_right_inj (Nat.factorial_ne_zero n)).mp
rw [← descPochhammer_eq_factorial_smul_choose, smul_comm,
← descPochhammer_eq_factorial_smul_choose, descPochhammer_smeval_eq_ascPochhammer,
show (-r - n + 1) = -(r + n - 1) by abel, ascPochhammer_smeval_neg_eq_descPochhammer]
theorem descPochhammer_succ_succ_smeval {R} [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R]
(r : R) (k : ℕ) : smeval (descPochhammer ℤ (k + 1)) (r + 1) =
(k + 1) • smeval (descPochhammer ℤ k) r + smeval (descPochhammer ℤ (k + 1)) r := by
nth_rw 1 [descPochhammer_succ_left]
rw [descPochhammer_succ_right, mul_comm (descPochhammer ℤ k)]
simp only [smeval_comp, smeval_sub, smeval_mul, smeval_X, smeval_one, npow_one,
npow_zero, one_smul, add_sub_cancel_right, sub_mul, add_mul, add_smul, one_mul]
rw [← C_eq_natCast, smeval_C, npow_zero, add_comm (k • smeval (descPochhammer ℤ k) r) _,
add_assoc, add_comm (k • smeval (descPochhammer ℤ k) r) _, ← add_assoc, ← add_sub_assoc,
nsmul_eq_mul, zsmul_one, Int.cast_natCast, sub_add_cancel, add_comm]
theorem choose_succ_succ [NatPowAssoc R] (r : R) (k : ℕ) :
choose (r + 1) (k + 1) = choose r k + choose r (k + 1) := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero (k + 1))]
simp only [smul_add, ← descPochhammer_eq_factorial_smul_choose]
rw [Nat.factorial_succ, mul_smul,
← descPochhammer_eq_factorial_smul_choose r, descPochhammer_succ_succ_smeval r k]
@[deprecated (since := "2025-08-17")] alias choose_eq_nat_choose := choose_natCast
theorem choose_smul_choose [NatPowAssoc R] (r : R) {n k : ℕ} (hkn : k ≤ n) :
(Nat.choose n k) • choose r n = choose r k * choose (r - k) (n - k) := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero n),
nsmul_left_comm, ← descPochhammer_eq_factorial_smul_choose,
← Nat.choose_mul_factorial_mul_factorial hkn, ← smul_mul_smul_comm,
← descPochhammer_eq_factorial_smul_choose, mul_nsmul',
← descPochhammer_eq_factorial_smul_choose, smul_mul_assoc]
nth_rw 2 [← Nat.sub_add_cancel hkn]
rw [add_comm, ← descPochhammer_mul, smeval_mul, smeval_comp, smeval_sub, smeval_X,
← C_eq_natCast, smeval_C, npow_one, npow_zero, zsmul_one, Int.cast_natCast, nsmul_eq_mul]
theorem choose_add_smul_choose [NatPowAssoc R] (r : R) (n k : ℕ) :
(Nat.choose (n + k) k) • choose (r + k) (n + k) = choose (r + k) k * choose r n := by
rw [choose_smul_choose (r + k) (Nat.le_add_left k n), Nat.add_sub_cancel,
add_sub_cancel_right]
end
theorem choose_eq_smul [Field R] [CharZero R] {a : R} {n : ℕ} :
Ring.choose a n = (n.factorial : R)⁻¹ • (descPochhammer ℤ n).smeval a := by
rw [Ring.descPochhammer_eq_factorial_smul_choose, ← Nat.cast_smul_eq_nsmul R, inv_smul_smul₀]
simpa using Nat.factorial_ne_zero n
open Finset
/-- Pochhammer version of Chu-Vandermonde identity -/
theorem descPochhammer_smeval_add [Ring R] {r s : R} (k : ℕ) (h : Commute r s) :
(descPochhammer ℤ k).smeval (r + s) = ∑ ij ∈ antidiagonal k,
Nat.choose k ij.1 * ((descPochhammer ℤ ij.1).smeval r * (descPochhammer ℤ ij.2).smeval s) := by
induction k with
| zero => simp
| succ k ih =>
rw [descPochhammer_succ_right, mul_comm, smeval_mul, sum_antidiagonal_choose_succ_mul
fun i j => ((descPochhammer ℤ i).smeval r * (descPochhammer ℤ j).smeval s),
← sum_add_distrib, smeval_sub, smeval_X, smeval_natCast, pow_zero, pow_one, ih, mul_sum]
refine sum_congr rfl ?_
intro ij hij -- try to move `descPochhammer`s to right, gather multipliers.
have hdx : (descPochhammer ℤ ij.1).smeval r * (X - (ij.2 : ℤ[X])).smeval s =
(X - (ij.2 : ℤ[X])).smeval s * (descPochhammer ℤ ij.1).smeval r := by
refine (commute_iff_eq ((descPochhammer ℤ ij.1).smeval r)
((X - (ij.2 : ℤ[X])).smeval s)).mp ?_
exact smeval_commute ℤ (descPochhammer ℤ ij.1) (X - (ij.2 : ℤ[X])) h
rw [descPochhammer_succ_right, mul_comm, smeval_mul, descPochhammer_succ_right, mul_comm,
smeval_mul, ← mul_assoc ((descPochhammer ℤ ij.1).smeval r), hdx]
simp only [mul_assoc _ ((descPochhammer ℤ ij.1).smeval r) _,
← mul_assoc _ _ (((descPochhammer ℤ ij.1).smeval r) * _)]
have hl : (r + s - k • 1) * (k.choose ij.1) = (k.choose ij.1) * (X - (ij.2 : ℤ[X])).smeval s +
↑(k.choose ij.2) * (X - (ij.1 : ℤ[X])).smeval r := by
simp only [smeval_sub, smeval_X, pow_one, smeval_natCast, pow_zero]
rw [← Nat.choose_symm_of_eq_add (List.Nat.mem_antidiagonal.mp hij).symm,
(List.Nat.mem_antidiagonal.mp hij).symm, ← mul_add, Nat.cast_comm, add_smul]
abel_nf
rw [hl, ← add_mul]
/-- The Chu-Vandermonde identity for binomial rings -/
theorem add_choose_eq [Ring R] [BinomialRing R] {r s : R} (k : ℕ) (h : Commute r s) :
choose (r + s) k =
∑ ij ∈ antidiagonal k, choose r ij.1 * choose s ij.2 := by
rw [← nsmul_right_inj (Nat.factorial_ne_zero k),
← descPochhammer_eq_factorial_smul_choose, smul_sum, descPochhammer_smeval_add _ h]
refine sum_congr rfl ?_
intro x hx
rw [← Nat.choose_mul_factorial_mul_factorial (antidiagonal.fst_le hx),
tsub_eq_of_eq_add_rev (List.Nat.mem_antidiagonal.mp hx).symm, mul_assoc, nsmul_eq_mul,
Nat.cast_mul, Nat.cast_mul, ← mul_assoc _ (x.1.factorial : R), mul_assoc _ (x.2.factorial : R),
← mul_assoc (x.2.factorial : R), Nat.cast_commute x.2.factorial,
mul_assoc _ (x.2.factorial : R), ← nsmul_eq_mul x.2.factorial]
simp [mul_assoc, descPochhammer_eq_factorial_smul_choose]
lemma map_choose {R S F : Type*} [Ring R] [Ring S] [BinomialRing R] [BinomialRing S]
[FunLike F R S] [RingHomClass F R S] (f : F) (a : R) (n : ℕ) :
f (Ring.choose a n) = Ring.choose (f a) n := by
simpa using Ring.map_multichoose f (a - n + 1) n
end Ring
end Choose |
.lake/packages/mathlib/Mathlib/RingTheory/OrzechProperty.lean | import Mathlib.Algebra.Module.TransferInstance
import Mathlib.RingTheory.Finiteness.Cardinality
/-!
# Orzech property of rings
In this file we define the following property of rings:
- `OrzechProperty R` is a type class stating that `R` satisfies the following property:
for any finitely generated `R`-module `M`, any surjective homomorphism `f : N → M`
from a submodule `N` of `M` to `M` is injective.
It was introduced in papers by Orzech [orzech1971], Djoković [djokovic1973] and
Ribenboim [ribenboim1971], under the names `Π`-ring or `Π₁`-ring.
It implies the strong rank condition (that is, the existence of an injective linear map
`(Fin n → R) →ₗ[R] (Fin m → R)` implies `n ≤ m`)
if the ring is nontrivial (see `Mathlib/LinearAlgebra/InvariantBasisNumber.lean`).
It's proved in the above papers that
- a left-Noetherian ring (not necessarily commutative) satisfies the `OrzechProperty`,
which in particular includes the division ring case
(see `Mathlib/RingTheory/Noetherian.lean`);
- a commutative ring satisfies the `OrzechProperty`
(see `Mathlib/RingTheory/FiniteType.lean`).
## References
* [Orzech, Morris. *Onto endomorphisms are isomorphisms*][orzech1971]
* [Djoković, D. Ž. *Epimorphisms of modules which must be isomorphisms*][djokovic1973]
* [Ribenboim, Paulo.
*Épimorphismes de modules qui sont nécessairement des isomorphismes*][ribenboim1971]
## Tags
free module, rank, Orzech property, (strong) rank condition, invariant basis number, IBN
-/
universe u v w
open Function
variable (R : Type u) [Semiring R]
/-- A ring `R` satisfies the Orzech property, if for any finitely generated `R`-module `M`,
any surjective homomorphism `f : N → M` from a submodule `N` of `M` to `M` is injective.
NOTE: In the definition we need to assume that `M` has the same universe level as `R`, but it
in fact implies the universe polymorphic versions
`OrzechProperty.injective_of_surjective_of_injective`
and `OrzechProperty.injective_of_surjective_of_submodule`. -/
@[mk_iff]
class OrzechProperty : Prop where
injective_of_surjective_of_submodule' : ∀ {M : Type u} [AddCommMonoid M] [Module R M]
[Module.Finite R M] {N : Submodule R M} (f : N →ₗ[R] M), Surjective f → Injective f
namespace OrzechProperty
variable {R}
variable [OrzechProperty R] {M : Type v} [AddCommMonoid M] [Module R M] [Module.Finite R M]
theorem injective_of_surjective_of_injective
{N : Type w} [AddCommMonoid N] [Module R N]
(i f : N →ₗ[R] M) (hi : Injective i) (hf : Surjective f) : Injective f := by
obtain ⟨n, g, hg⟩ := Module.Finite.exists_fin' R M
haveI := small_of_surjective hg
letI := Equiv.addCommMonoid (equivShrink M).symm
letI := Equiv.module R (equivShrink M).symm
let j : Shrink.{u} M ≃ₗ[R] M := Equiv.linearEquiv R (equivShrink M).symm
haveI := Module.Finite.equiv j.symm
let i' := j.symm.toLinearMap ∘ₗ i
replace hi : Injective i' := by simpa [i'] using hi
let f' := j.symm.toLinearMap ∘ₗ f ∘ₗ (LinearEquiv.ofInjective i' hi).symm.toLinearMap
replace hf : Surjective f' := by simpa [f'] using hf
simpa [f'] using injective_of_surjective_of_submodule' f' hf
theorem injective_of_surjective_of_submodule
{N : Submodule R M} (f : N →ₗ[R] M) (hf : Surjective f) : Injective f :=
injective_of_surjective_of_injective N.subtype f N.injective_subtype hf
theorem injective_of_surjective_endomorphism
(f : M →ₗ[R] M) (hf : Surjective f) : Injective f :=
injective_of_surjective_of_injective _ f (LinearEquiv.refl _ _).injective hf
theorem bijective_of_surjective_endomorphism
(f : M →ₗ[R] M) (hf : Surjective f) : Bijective f :=
⟨injective_of_surjective_endomorphism f hf, hf⟩
end OrzechProperty |
.lake/packages/mathlib/Mathlib/RingTheory/MatrixAlgebra.lean | import Mathlib.Algebra.Star.StarAlgHom
import Mathlib.Data.Matrix.Basis
import Mathlib.Data.Matrix.Composition
import Mathlib.LinearAlgebra.Matrix.Kronecker
import Mathlib.RingTheory.TensorProduct.Maps
/-!
# Algebra isomorphisms between tensor products and matrices
## Main definitions
* `matrixEquivTensor : Matrix n n A ≃ₐ[R] (A ⊗[R] Matrix n n R)`.
* `Matrix.kroneckerTMulAlgEquiv :
Matrix m m A ⊗[R] Matrix n n B ≃ₐ[S] Matrix (m × n) (m × n) (A ⊗[R] B)`,
where the forward map is the (tensor-ified) Kronecker product.
-/
open TensorProduct Algebra.TensorProduct Matrix
variable {l m n p : Type*} {R S A B M N : Type*}
section Module
variable [CommSemiring R] [Semiring S] [Semiring A] [Semiring B] [AddCommMonoid M] [AddCommMonoid N]
variable [Algebra R S] [Algebra R A] [Algebra R B] [Module R M] [Module S M] [Module R N]
variable [IsScalarTower R S M]
variable [Fintype l] [Fintype m] [Fintype n] [Fintype p]
variable [DecidableEq l] [DecidableEq m] [DecidableEq n] [DecidableEq p]
open Kronecker
variable (l m n p R S A M N)
attribute [local ext] ext_linearMap
/-- `Matrix.kroneckerTMul` as a linear equivalence, when the two arguments are tensored. -/
def kroneckerTMulLinearEquiv :
Matrix l m M ⊗[R] Matrix n p N ≃ₗ[S] Matrix (l × n) (m × p) (M ⊗[R] N) :=
.ofLinear
(AlgebraTensorModule.lift <| kroneckerTMulBilinear R S)
(Matrix.liftLinear R fun ii jj =>
AlgebraTensorModule.map (singleLinearMap S ii.1 jj.1) (singleLinearMap R ii.2 jj.2))
(by
ext : 4
simp [single_kroneckerTMul_single])
(by
ext : 5
simp [single_kroneckerTMul_single])
@[simp]
theorem kroneckerTMulLinearEquiv_tmul (a : Matrix l m M) (b : Matrix n p N) :
kroneckerTMulLinearEquiv l m n p R S M N (a ⊗ₜ b) = a ⊗ₖₜ b := rfl
@[simp]
theorem kroneckerTMulLinearEquiv_symm_kroneckerTMul (a : Matrix l m M) (b : Matrix n p N) :
(kroneckerTMulLinearEquiv l m n p R S M N).symm (a ⊗ₖₜ b) = a ⊗ₜ b := by
simp [LinearEquiv.symm_apply_eq]
@[simp]
theorem kroneckerTMulAlgEquiv_symm_single_tmul
(ia : l) (ja : m) (ib : n) (jb : p) (a : M) (b : N) :
(kroneckerTMulLinearEquiv l m n p R S M N).symm (single (ia, ib) (ja, jb) (a ⊗ₜ b)) =
single ia ja a ⊗ₜ single ib jb b := by
rw [LinearEquiv.symm_apply_eq, kroneckerTMulLinearEquiv_tmul,
single_kroneckerTMul_single]
@[deprecated (since := "2025-05-05")]
alias kroneckerTMulAlgEquiv_symm_stdBasisMatrix_tmul := kroneckerTMulAlgEquiv_symm_single_tmul
@[simp]
theorem kroneckerTMulLinearEquiv_one [Module S A] [IsScalarTower R S A] :
kroneckerTMulLinearEquiv m m n n R S A B 1 = 1 := by simp [Algebra.TensorProduct.one_def]
/-- Note this can't be stated for rectangular matrices because there is no
`HMul (TensorProduct R _ _) (TensorProduct R _ _) (TensorProduct R _ _)` instance. -/
@[simp]
theorem kroneckerTMulLinearEquiv_mul [Module S A] [IsScalarTower R S A] :
∀ x y : Matrix m m A ⊗[R] Matrix n n B,
kroneckerTMulLinearEquiv m m n n R S A B (x * y) =
kroneckerTMulLinearEquiv m m n n R S A B x * kroneckerTMulLinearEquiv m m n n R S A B y :=
(kroneckerTMulLinearEquiv m m n n R S A B).toLinearMap.restrictScalars R |>.map_mul_iff.2 <| by
ext : 10
simp [single_kroneckerTMul_single, mul_kroneckerTMul_mul]
/-- `Matrix.kronecker` as a linear equivalence, when the two arguments are tensored. -/
def kroneckerLinearEquiv : Matrix l m R ⊗[R] Matrix n p R ≃ₗ[R] Matrix (l × n) (m × p) R :=
(kroneckerTMulLinearEquiv l m n p R R R R).trans (TensorProduct.lid R R).mapMatrix
variable {l m n p R}
@[simp] theorem kroneckerLinearEquiv_tmul (x : Matrix l m R) (y : Matrix n p R) :
kroneckerLinearEquiv l m n p R (x ⊗ₜ y) = x ⊗ₖ y := rfl
@[simp] theorem kroneckerLinearEquiv_symm_kronecker (x : Matrix l m R) (y : Matrix n p R) :
(kroneckerLinearEquiv l m n p R).symm (x ⊗ₖ y) = x ⊗ₜ y := by simp [LinearEquiv.symm_apply_eq]
end Module
variable [CommSemiring R]
variable [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
variable (n R A)
namespace MatrixEquivTensor
/-- (Implementation detail).
The function underlying `(A ⊗[R] Matrix n n R) →ₐ[R] Matrix n n A`,
as an `R`-bilinear map.
-/
def toFunBilinear : A →ₗ[R] Matrix n n R →ₗ[R] Matrix n n A :=
(Algebra.lsmul R R (Matrix n n A)).toLinearMap.compl₂ (Algebra.linearMap R A).mapMatrix
@[simp]
theorem toFunBilinear_apply (a : A) (m : Matrix n n R) :
toFunBilinear n R A a m = a • m.map (algebraMap R A) :=
rfl
/-- (Implementation detail).
The function underlying `(A ⊗[R] Matrix n n R) →ₐ[R] Matrix n n A`,
as an `R`-linear map.
-/
def toFunLinear : A ⊗[R] Matrix n n R →ₗ[R] Matrix n n A :=
TensorProduct.lift (toFunBilinear n R A)
variable [DecidableEq n] [Fintype n]
/-- The function `(A ⊗[R] Matrix n n R) →ₐ[R] Matrix n n A`, as an algebra homomorphism.
-/
def toFunAlgHom : A ⊗[R] Matrix n n R →ₐ[R] Matrix n n A :=
algHomOfLinearMapTensorProduct (toFunLinear n R A)
(by
intros
simp_rw [toFunLinear, lift.tmul, toFunBilinear_apply, Matrix.map_mul]
ext
dsimp
simp_rw [Matrix.mul_apply, Matrix.smul_apply, Matrix.map_apply, smul_eq_mul, Finset.mul_sum,
_root_.mul_assoc, Algebra.left_comm])
(by
simp_rw [toFunLinear, lift.tmul, toFunBilinear_apply,
Matrix.map_one (algebraMap R A) (map_zero _) (map_one _), one_smul])
@[simp]
theorem toFunAlgHom_apply (a : A) (m : Matrix n n R) :
toFunAlgHom n R A (a ⊗ₜ m) = a • m.map (algebraMap R A) := rfl
/-- (Implementation detail.)
The bare function `Matrix n n A → A ⊗[R] Matrix n n R`.
(We don't need to show that it's an algebra map, thankfully --- just that it's an inverse.)
-/
def invFun (M : Matrix n n A) : A ⊗[R] Matrix n n R :=
∑ p : n × n, M p.1 p.2 ⊗ₜ single p.1 p.2 1
@[simp]
theorem invFun_zero : invFun n R A 0 = 0 := by simp [invFun]
@[simp]
theorem invFun_add (M N : Matrix n n A) :
invFun n R A (M + N) = invFun n R A M + invFun n R A N := by
simp [invFun, add_tmul, Finset.sum_add_distrib]
@[simp]
theorem invFun_smul (a : A) (M : Matrix n n A) :
invFun n R A (a • M) = a ⊗ₜ 1 * invFun n R A M := by
simp [invFun, Finset.mul_sum]
@[simp]
theorem invFun_algebraMap (M : Matrix n n R) : invFun n R A (M.map (algebraMap R A)) = 1 ⊗ₜ M := by
dsimp [invFun]
simp only [Algebra.algebraMap_eq_smul_one, smul_tmul, ← tmul_sum]
congr
conv_rhs => rw [matrix_eq_sum_single M]
convert Finset.sum_product (β := Matrix n n R) ..; simp
theorem right_inv (M : Matrix n n A) : (toFunAlgHom n R A) (invFun n R A M) = M := by
simp only [invFun, map_sum, toFunAlgHom_apply]
convert Finset.sum_product (β := Matrix n n A) ..
conv_lhs => rw [matrix_eq_sum_single M]
refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => Matrix.ext fun a b => ?_
dsimp [single]
split_ifs <;> aesop
theorem left_inv (M : A ⊗[R] Matrix n n R) : invFun n R A (toFunAlgHom n R A M) = M := by
induction M with
| zero => simp
| tmul a m => simp
| add x y hx hy =>
rw [map_add]
conv_rhs => rw [← hx, ← hy, ← invFun_add]
/-- (Implementation detail)
The equivalence, ignoring the algebra structure, `(A ⊗[R] Matrix n n R) ≃ Matrix n n A`.
-/
def equiv : A ⊗[R] Matrix n n R ≃ Matrix n n A where
toFun := toFunAlgHom n R A
invFun := invFun n R A
left_inv := left_inv n R A
right_inv := right_inv n R A
end MatrixEquivTensor
variable [Fintype n] [DecidableEq n]
/-- The `R`-algebra isomorphism `Matrix n n A ≃ₐ[R] (A ⊗[R] Matrix n n R)`.
-/
def matrixEquivTensor : Matrix n n A ≃ₐ[R] A ⊗[R] Matrix n n R :=
AlgEquiv.symm { MatrixEquivTensor.toFunAlgHom n R A, MatrixEquivTensor.equiv n R A with }
open MatrixEquivTensor
@[simp]
theorem matrixEquivTensor_apply (M : Matrix n n A) :
matrixEquivTensor n R A M = ∑ p : n × n, M p.1 p.2 ⊗ₜ single p.1 p.2 1 :=
rfl
-- High priority, to go before `matrixEquivTensor_apply`
@[simp high]
theorem matrixEquivTensor_apply_single (i j : n) (x : A) :
matrixEquivTensor n R A (single i j x) = x ⊗ₜ single i j 1 := by
have t : ∀ p : n × n, i = p.1 ∧ j = p.2 ↔ p = (i, j) := by aesop
simp [ite_tmul, t, single]
@[deprecated (since := "2025-05-05")]
alias matrixEquivTensor_apply_stdBasisMatrix := matrixEquivTensor_apply_single
@[simp]
theorem matrixEquivTensor_apply_symm (a : A) (M : Matrix n n R) :
(matrixEquivTensor n R A).symm (a ⊗ₜ M) = a • M.map (algebraMap R A) :=
rfl
namespace Matrix
open scoped Kronecker
variable (m) (S B)
variable [CommSemiring S] [Algebra R S] [Algebra S A] [IsScalarTower R S A]
variable [Fintype m] [DecidableEq m]
/-- `Matrix.kroneckerTMul` as an algebra equivalence, when the two arguments are tensored. -/
def kroneckerTMulAlgEquiv :
Matrix m m A ⊗[R] Matrix n n B ≃ₐ[S] Matrix (m × n) (m × n) (A ⊗[R] B) :=
.ofLinearEquiv (kroneckerTMulLinearEquiv m m n n R S A B)
(kroneckerTMulLinearEquiv_one _ _ _ _ _)
(kroneckerTMulLinearEquiv_mul _ _ _ _ _)
variable {m n A B}
@[simp]
theorem kroneckerTMulAlgEquiv_apply (x : Matrix m m A ⊗[R] Matrix n n B) :
(kroneckerTMulAlgEquiv m n R S A B) x = kroneckerTMulLinearEquiv m m n n R S A B x :=
rfl
@[simp]
theorem kroneckerTMulAlgEquiv_symm_apply (x : Matrix (m × n) (m × n) (A ⊗[R] B)) :
(kroneckerTMulAlgEquiv m n R S A B).symm x =
(kroneckerTMulLinearEquiv m m n n R S A B).symm x :=
rfl
section StarRing
variable [StarRing R] [StarAddMonoid A] [StarAddMonoid B] [StarModule R A] [StarModule R B]
variable (m n A B) in
/-- `Matrix.kroneckerTMul` as a ⋆-algebra equivalence, when the two arguments are tensored. -/
def kroneckerTMulStarAlgEquiv :
Matrix m m A ⊗[R] Matrix n n B ≃⋆ₐ[S] Matrix (m × n) (m × n) (A ⊗[R] B) :=
.ofAlgEquiv (kroneckerTMulAlgEquiv m n R S A B)
fun x ↦ x.induction_on (by simp)
(by simp [star_eq_conjTranspose, conjTranspose_kroneckerTMul])
(by simp_all)
@[simp] theorem toAlgEquiv_kroneckerTMulStarAlgEquiv :
(kroneckerTMulStarAlgEquiv m n R S A B).toAlgEquiv =
kroneckerTMulAlgEquiv m n R S A B := rfl
@[simp] theorem kroneckerTMulStarAlgEquiv_apply (x : Matrix m m A ⊗[R] Matrix n n B) :
(kroneckerTMulStarAlgEquiv m n R S A B) x =
kroneckerTMulLinearEquiv m m n n R S A B x :=
rfl
@[simp] theorem kroneckerTMulStarAlgEquiv_symm_apply (x : Matrix (m × n) (m × n) (A ⊗[R] B)) :
(kroneckerTMulStarAlgEquiv m n R S A B).symm x =
(kroneckerTMulLinearEquiv m m n n R S A B).symm x :=
rfl
end StarRing
variable (m n) in
/-- `Matrix.kronecker` as an algebra equivalence, when the two arguments are tensored. -/
def kroneckerAlgEquiv : (Matrix m m R ⊗[R] Matrix n n R) ≃ₐ[R] Matrix (m × n) (m × n) R :=
(kroneckerTMulAlgEquiv m n R R R R).trans (Algebra.TensorProduct.lid R R).mapMatrix
@[simp] theorem toLinearEquiv_kroneckerAlgEquiv :
(kroneckerAlgEquiv m n R).toLinearEquiv = kroneckerLinearEquiv m m n n R := rfl
@[simp] theorem kroneckerAlgEquiv_apply (x : Matrix m m R ⊗ Matrix n n R) :
kroneckerAlgEquiv m n R x = kroneckerLinearEquiv m m n n R x := rfl
@[simp] theorem kroneckerAlgEquiv_symm_apply (x : Matrix (m × n) (m × n) R) :
(kroneckerAlgEquiv m n R).symm x = (kroneckerLinearEquiv m m n n R).symm x := rfl
variable (m n) in
/-- `Matrix.kronecker` as a ⋆-algebra equivalence, when the two arguments are tensored. -/
def kroneckerStarAlgEquiv [StarRing R] :
(Matrix m m R ⊗[R] Matrix n n R) ≃⋆ₐ[R] Matrix (m × n) (m × n) R :=
.ofAlgEquiv (kroneckerAlgEquiv m n R)
fun x ↦ x.induction_on (by simp)
(by simp [star_eq_conjTranspose, conjTranspose_kronecker])
(by simp_all)
@[simp] theorem toAlgEquiv_kroneckerStarAlgEquiv [StarRing R] :
(kroneckerStarAlgEquiv m n R).toAlgEquiv = kroneckerAlgEquiv m n R := rfl
@[simp] theorem kroneckerStarAlgEquiv_apply [StarRing R] (x : Matrix m m R ⊗ Matrix n n R) :
kroneckerStarAlgEquiv m n R x = kroneckerLinearEquiv m m n n R x := rfl
@[simp] theorem kroneckerStarAlgEquiv_symm_apply [StarRing R] (x : Matrix (m × n) (m × n) R) :
(kroneckerStarAlgEquiv m n R).symm x = (kroneckerLinearEquiv m m n n R).symm x := rfl
end Matrix |
.lake/packages/mathlib/Mathlib/RingTheory/LaurentSeries.lean | import Mathlib.Data.Int.Interval
import Mathlib.FieldTheory.RatFunc.AsPolynomial
import Mathlib.RingTheory.Binomial
import Mathlib.RingTheory.HahnSeries.PowerSeries
import Mathlib.RingTheory.HahnSeries.Summable
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.PowerSeries.Trunc
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.Topology.UniformSpace.DiscreteUniformity
/-!
# Laurent Series
In this file we define `LaurentSeries R`, the formal Laurent series over `R`, here an *arbitrary*
type with a zero. They are denoted `R⸨X⸩`.
## Main Definitions
* Defines `LaurentSeries` as an abbreviation for `HahnSeries ℤ`.
* Defines `hasseDeriv` of a Laurent series with coefficients in a module over a ring.
* Provides a coercion from power series `R⟦X⟧` into `R⸨X⸩` given by `HahnSeries.ofPowerSeries`.
* Defines `LaurentSeries.powerSeriesPart`
* Defines the localization map `LaurentSeries.of_powerSeries_localization` which evaluates to
`HahnSeries.ofPowerSeries`.
* Embedding of rational functions into Laurent series, provided as a coercion, utilizing
the underlying `RatFunc.coeAlgHom`.
* Study of the `X`-Adic valuation on the ring of Laurent series over a field
* In `LaurentSeries.uniformContinuous_coeff` we show that sending a Laurent series to its `d`th
coefficient is uniformly continuous, ensuring that it sends a Cauchy filter `ℱ` in `K⸨X⸩`
to a Cauchy filter in `K`: since this latter is given the discrete topology, this provides an
element `LaurentSeries.Cauchy.coeff ℱ d` in `K` that serves as `d`th coefficient of the Laurent
series to which the filter `ℱ` converges.
## Main Results
* Basic properties of Hasse derivatives
### About the `X`-Adic valuation:
* The (integral) valuation of a power series is the order of the first non-zero coefficient, see
`LaurentSeries.intValuation_le_iff_coeff_lt_eq_zero`.
* The valuation of a Laurent series is the order of the first non-zero coefficient, see
`LaurentSeries.valuation_le_iff_coeff_lt_eq_zero`.
* Every Laurent series of valuation less than `(1 : ℤᵐ⁰)` comes from a power series, see
`LaurentSeries.val_le_one_iff_eq_coe`.
* The uniform space of `LaurentSeries` over a field is complete, formalized in the instance
`instLaurentSeriesComplete`.
* The field of rational functions is dense in `LaurentSeries`: this is the declaration
`LaurentSeries.coe_range_dense` and relies principally upon `LaurentSeries.exists_ratFunc_val_lt`,
stating that for every Laurent series `f` and every `γ : ℤᵐ⁰` one can find a rational function `Q`
such that the `X`-adic valuation `v` satisfies `v (f - Q) < γ`.
* In `LaurentSeries.valuation_compare` we prove that the extension of the `X`-adic valuation from
`RatFunc K` up to its abstract completion coincides, modulo the isomorphism with `K⸨X⸩`, with the
`X`-adic valuation on `K⸨X⸩`.
* The two declarations `LaurentSeries.mem_integers_of_powerSeries` and
`LaurentSeries.exists_powerSeries_of_memIntegers` show that an element in the completion of
`RatFunc K` is in the unit ball if and only if it comes from a power series through the
isomorphism `LaurentSeriesRingEquiv`.
* `LaurentSeries.powerSeriesAlgEquiv` is the `K`-algebra isomorphism between `K⟦X⟧`
and the unit ball inside the `X`-adic completion of `RatFunc K`.
## Implementation details
* Since `LaurentSeries` is just an abbreviation of `HahnSeries ℤ R`, the definition of the
coefficients is given in terms of `HahnSeries.coeff` and this forces sometimes to go
back-and-forth from `X : R⸨X⸩` to `single 1 1 : HahnSeries ℤ R`.
* To prove the isomorphism between the `X`-adic completion of `RatFunc K` and `K⸨X⸩` we construct
two completions of `RatFunc K`: the first (`LaurentSeries.ratfuncAdicComplPkg`) is its abstract
uniform completion; the second (`LaurentSeries.LaurentSeriesPkg`) is simply `K⸨X⸩`, once we prove
that it is complete and contains `RatFunc K` as a dense subspace. The isomorphism is the
comparison equivalence, expressing the mathematical idea that the completion "is unique". It is
`LaurentSeries.comparePkg`.
* For applications to `K⟦X⟧` it is actually more handy to use the *inverse* of the above
equivalence: `LaurentSeries.LaurentSeriesAlgEquiv` is the *topological, algebra equivalence*
`K⸨X⸩ ≃ₐ[K] RatFuncAdicCompl K`.
* In order to compare `K⟦X⟧` with the valuation subring in the `X`-adic completion of
`RatFunc K` we consider its alias `LaurentSeries.powerSeries_as_subring` as a subring of `K⸨X⸩`,
that is itself clearly isomorphic (via the inverse of `LaurentSeries.powerSeriesEquivSubring`)
to `K⟦X⟧`.
-/
universe u
open scoped PowerSeries
open HahnSeries Polynomial
noncomputable section
/-- `LaurentSeries R` is the type of formal Laurent series with coefficients in `R`, denoted `R⸨X⸩`.
It is implemented as a `HahnSeries` with value group `ℤ`.
-/
abbrev LaurentSeries (R : Type u) [Zero R] :=
HahnSeries ℤ R
variable {R : Type*}
namespace LaurentSeries
section
/-- `R⸨X⸩` is notation for `LaurentSeries R`. -/
scoped notation:9000 R "⸨X⸩" => LaurentSeries R
end
section HasseDeriv
/-- The Hasse derivative of Laurent series, as a linear map. -/
def hasseDeriv (R : Type*) {V : Type*} [AddCommGroup V] [Semiring R] [Module R V] (k : ℕ) :
V⸨X⸩ →ₗ[R] V⸨X⸩ where
toFun f := HahnSeries.ofSuppBddBelow (fun (n : ℤ) => (Ring.choose (n + k) k) • f.coeff (n + k))
(forallLTEqZero_supp_BddBelow _ (f.order - k : ℤ)
(fun _ h_lt ↦ by rw [coeff_eq_zero_of_lt_order <| lt_sub_iff_add_lt.mp h_lt, smul_zero]))
map_add' f g := by
ext
simp only [ofSuppBddBelow, coeff_add', Pi.add_apply, smul_add]
map_smul' r f := by
ext
simp only [ofSuppBddBelow, HahnSeries.coeff_smul, RingHom.id_apply, smul_comm r]
variable [Semiring R] {V : Type*} [AddCommGroup V] [Module R V]
@[simp]
theorem hasseDeriv_coeff (k : ℕ) (f : LaurentSeries V) (n : ℤ) :
(hasseDeriv R k f).coeff n = Ring.choose (n + k) k • f.coeff (n + k) :=
rfl
@[simp]
theorem hasseDeriv_zero : hasseDeriv R 0 = LinearMap.id (M := LaurentSeries V) := by
ext f n
simp
theorem hasseDeriv_single_add (k : ℕ) (n : ℤ) (x : V) :
hasseDeriv R k (single (n + k) x) = single n ((Ring.choose (n + k) k) • x) := by
ext m
dsimp only [hasseDeriv_coeff]
by_cases h : m = n
· simp [h]
· simp [h, show m + k ≠ n + k by cutsat]
@[simp]
theorem hasseDeriv_single (k : ℕ) (n : ℤ) (x : V) :
hasseDeriv R k (single n x) = single (n - k) ((Ring.choose n k) • x) := by
rw [← Int.sub_add_cancel n k, hasseDeriv_single_add, Int.sub_add_cancel n k]
theorem hasseDeriv_comp_coeff (k l : ℕ) (f : LaurentSeries V) (n : ℤ) :
(hasseDeriv R k (hasseDeriv R l f)).coeff n =
((Nat.choose (k + l) k) • hasseDeriv R (k + l) f).coeff n := by
rw [coeff_nsmul]
simp only [hasseDeriv_coeff, Pi.smul_apply, Nat.cast_add]
rw [smul_smul, mul_comm, ← Ring.choose_add_smul_choose (n + k), add_assoc, Nat.choose_symm_add,
smul_assoc]
@[simp]
theorem hasseDeriv_comp (k l : ℕ) (f : LaurentSeries V) :
hasseDeriv R k (hasseDeriv R l f) = (k + l).choose k • hasseDeriv R (k + l) f := by
ext n
simp [hasseDeriv_comp_coeff k l f n]
/-- The derivative of a Laurent series. -/
def derivative (R : Type*) {V : Type*} [AddCommGroup V] [Semiring R] [Module R V] :
LaurentSeries V →ₗ[R] LaurentSeries V :=
hasseDeriv R 1
@[simp]
theorem derivative_apply (f : LaurentSeries V) : derivative R f = hasseDeriv R 1 f := by
exact rfl
theorem derivative_iterate (k : ℕ) (f : LaurentSeries V) :
(derivative R)^[k] f = k.factorial • (hasseDeriv R k f) := by
ext n
induction k generalizing f with
| zero => simp
| succ k ih =>
rw [Function.iterate_succ, Function.comp_apply, ih, derivative_apply, hasseDeriv_comp,
Nat.choose_symm_add, Nat.choose_one_right, Nat.factorial, mul_nsmul]
@[simp]
theorem derivative_iterate_coeff (k : ℕ) (f : LaurentSeries V) (n : ℤ) :
((derivative R)^[k] f).coeff n = (descPochhammer ℤ k).smeval (n + k) • f.coeff (n + k) := by
rw [derivative_iterate, coeff_nsmul, Pi.smul_apply, hasseDeriv_coeff,
Ring.descPochhammer_eq_factorial_smul_choose, smul_assoc]
end HasseDeriv
section Semiring
variable [Semiring R]
instance : Coe R⟦X⟧ R⸨X⸩ :=
⟨HahnSeries.ofPowerSeries ℤ R⟩
@[simp]
theorem coeff_coe_powerSeries (x : R⟦X⟧) (n : ℕ) :
HahnSeries.coeff (x : R⸨X⸩) n = PowerSeries.coeff n x := by
rw [ofPowerSeries_apply_coeff]
/-- This is a power series that can be multiplied by an integer power of `X` to give our
Laurent series. If the Laurent series is nonzero, `powerSeriesPart` has a nonzero
constant term. -/
def powerSeriesPart (x : R⸨X⸩) : R⟦X⟧ :=
PowerSeries.mk fun n => x.coeff (x.order + n)
@[simp]
theorem powerSeriesPart_coeff (x : R⸨X⸩) (n : ℕ) :
PowerSeries.coeff n x.powerSeriesPart = x.coeff (x.order + n) :=
PowerSeries.coeff_mk _ _
@[simp]
theorem powerSeriesPart_zero : powerSeriesPart (0 : R⸨X⸩) = 0 := by
ext
simp [(PowerSeries.coeff _).map_zero] -- Note: this doesn't get picked up any more
@[simp]
theorem powerSeriesPart_eq_zero (x : R⸨X⸩) : x.powerSeriesPart = 0 ↔ x = 0 := by
constructor
· contrapose!
simp only [ne_eq]
intro h
rw [PowerSeries.ext_iff, not_forall]
refine ⟨0, ?_⟩
simp [coeff_order_ne_zero h]
· rintro rfl
simp
@[simp]
theorem single_order_mul_powerSeriesPart (x : R⸨X⸩) :
(single x.order 1 : R⸨X⸩) * x.powerSeriesPart = x := by
ext n
rw [← sub_add_cancel n x.order, coeff_single_mul_add, sub_add_cancel, one_mul]
by_cases h : x.order ≤ n
· rw [Int.eq_natAbs_of_nonneg (sub_nonneg_of_le h), coeff_coe_powerSeries,
powerSeriesPart_coeff, ← Int.eq_natAbs_of_nonneg (sub_nonneg_of_le h),
add_sub_cancel]
· rw [ofPowerSeries_apply, embDomain_notin_range]
· contrapose! h
exact order_le_of_coeff_ne_zero h.symm
· contrapose! h
simp only [Set.mem_range, RelEmbedding.coe_mk, Function.Embedding.coeFn_mk] at h
cutsat
theorem ofPowerSeries_powerSeriesPart (x : R⸨X⸩) :
ofPowerSeries ℤ R x.powerSeriesPart = single (-x.order) 1 * x := by
refine Eq.trans ?_ (congr rfl x.single_order_mul_powerSeriesPart)
rw [← mul_assoc, single_mul_single, neg_add_cancel, mul_one, ← C_apply, C_one, one_mul]
theorem X_order_mul_powerSeriesPart {n : ℕ} {f : R⸨X⸩} (hn : n = f.order) :
(PowerSeries.X ^ n * f.powerSeriesPart : R⟦X⟧) = f := by
simp only [map_mul, map_pow, ofPowerSeries_X, single_pow, nsmul_eq_mul, mul_one, one_pow, hn,
single_order_mul_powerSeriesPart]
end Semiring
instance [CommSemiring R] : Algebra R⟦X⟧ R⸨X⸩ := (HahnSeries.ofPowerSeries ℤ R).toAlgebra
@[simp]
theorem coe_algebraMap [CommSemiring R] :
⇑(algebraMap R⟦X⟧ R⸨X⸩) = HahnSeries.ofPowerSeries ℤ R :=
rfl
/-- The localization map from power series to Laurent series. -/
@[simps (rhsMd := .all) +simpRhs]
instance of_powerSeries_localization [CommRing R] :
IsLocalization (Submonoid.powers (PowerSeries.X : R⟦X⟧)) R⸨X⸩ where
map_units := by
rintro ⟨_, n, rfl⟩
refine ⟨⟨single (n : ℤ) 1, single (-n : ℤ) 1, ?_, ?_⟩, ?_⟩
· simp
· simp
· dsimp; rw [ofPowerSeries_X_pow]
surj z := by
by_cases! h : 0 ≤ z.order
· refine ⟨⟨PowerSeries.X ^ Int.natAbs z.order * powerSeriesPart z, 1⟩, ?_⟩
simp only [RingHom.map_one, mul_one, RingHom.map_mul, coe_algebraMap, ofPowerSeries_X_pow,
Submonoid.coe_one]
rw [Int.natAbs_of_nonneg h, single_order_mul_powerSeriesPart]
· refine ⟨⟨powerSeriesPart z, PowerSeries.X ^ Int.natAbs z.order, ⟨_, rfl⟩⟩, ?_⟩
simp only [coe_algebraMap, ofPowerSeries_powerSeriesPart]
rw [mul_comm _ z]
refine congr rfl ?_
rw [ofPowerSeries_X_pow, Int.ofNat_natAbs_of_nonpos]
exact h.le
exists_of_eq {x y} := by
rw [coe_algebraMap, ofPowerSeries_injective.eq_iff]
rintro rfl
exact ⟨1, rfl⟩
instance {K : Type*} [Field K] : IsFractionRing K⟦X⟧ K⸨X⸩ :=
IsLocalization.of_le (Submonoid.powers (PowerSeries.X : K⟦X⟧)) _
(powers_le_nonZeroDivisors_of_noZeroDivisors PowerSeries.X_ne_zero) fun _ hf =>
isUnit_of_mem_nonZeroDivisors <| map_mem_nonZeroDivisors _ HahnSeries.ofPowerSeries_injective hf
end LaurentSeries
namespace PowerSeries
open LaurentSeries
variable {R' : Type*} [Semiring R] [Ring R'] (f g : R⟦X⟧) (f' g' : R'⟦X⟧)
@[norm_cast]
theorem coe_zero : ((0 : R⟦X⟧) : R⸨X⸩) = 0 :=
(ofPowerSeries ℤ R).map_zero
@[norm_cast]
theorem coe_one : ((1 : R⟦X⟧) : R⸨X⸩) = 1 :=
(ofPowerSeries ℤ R).map_one
@[norm_cast]
theorem coe_add : ((f + g : R⟦X⟧) : R⸨X⸩) = f + g :=
(ofPowerSeries ℤ R).map_add _ _
@[norm_cast]
theorem coe_sub : ((f' - g' : R'⟦X⟧) : R'⸨X⸩) = f' - g' :=
(ofPowerSeries ℤ R').map_sub _ _
@[norm_cast]
theorem coe_neg : ((-f' : R'⟦X⟧) : R'⸨X⸩) = -f' :=
(ofPowerSeries ℤ R').map_neg _
@[norm_cast]
theorem coe_mul : ((f * g : R⟦X⟧) : R⸨X⸩) = f * g :=
(ofPowerSeries ℤ R).map_mul _ _
theorem coeff_coe (i : ℤ) :
((f : R⟦X⟧) : R⸨X⸩).coeff i =
if i < 0 then 0 else PowerSeries.coeff i.natAbs f := by
cases i
· rw [Int.ofNat_eq_coe, coeff_coe_powerSeries, if_neg (Int.natCast_nonneg _).not_gt,
Int.natAbs_natCast]
· rw [ofPowerSeries_apply, embDomain_notin_image_support, if_pos (Int.negSucc_lt_zero _)]
simp only [not_exists, RelEmbedding.coe_mk, Set.mem_image, not_and, Function.Embedding.coeFn_mk,
Ne, toPowerSeries_symm_apply_coeff, mem_support, imp_true_iff,
not_false_iff, reduceCtorEq]
theorem coe_C (r : R) : ((C r : R⟦X⟧) : R⸨X⸩) = HahnSeries.C r :=
ofPowerSeries_C _
theorem coe_X : ((X : R⟦X⟧) : R⸨X⸩) = single 1 1 :=
ofPowerSeries_X
@[simp, norm_cast]
theorem coe_smul {S : Type*} [Semiring S] [Module R S] (r : R) (x : S⟦X⟧) :
((r • x : S⟦X⟧) : S⸨X⸩) = r • (ofPowerSeries ℤ S x) := by
ext
simp [coeff_coe, coeff_smul, smul_ite]
@[norm_cast]
theorem coe_pow (n : ℕ) : ((f ^ n : R⟦X⟧) : R⸨X⸩) = (ofPowerSeries ℤ R f) ^ n :=
(ofPowerSeries ℤ R).map_pow _ _
end PowerSeries
namespace RatFunc
open scoped LaurentSeries
variable {F : Type u} [Field F] (p q : F[X]) (f g : RatFunc F)
instance : FaithfulSMul F[X] F⸨X⸩ := by
refine (faithfulSMul_iff_algebraMap_injective F[X] F⸨X⸩).mpr ?_
exact algebraMap_hahnSeries_injective ℤ
instance coeToLaurentSeries : Coe (RatFunc F) F⸨X⸩ :=
⟨algebraMap (RatFunc F) F⸨X⸩⟩
theorem coe_coe (P : Polynomial F) : ((P : F⟦X⟧) : F⸨X⸩) = (P : RatFunc F) := by
simp [coePolynomial, coe_def, ← IsScalarTower.algebraMap_apply]
-- Porting note: removed `norm_cast` because "badly shaped lemma, rhs can't start with coe"
-- even though `single 1 1` is a bundled function application, not a "real" coercion
@[simp]
theorem coe_X : ((X : RatFunc F) : F⸨X⸩) = single 1 1 := by
simp [← algebraMap_X, ← IsScalarTower.algebraMap_apply F[X] (RatFunc F) F⸨X⸩]
theorem single_one_eq_pow {R : Type*} [Semiring R] (n : ℕ) :
single (n : ℤ) (1 : R) = single (1 : ℤ) 1 ^ n := by
simp
@[deprecated HahnSeries.inv_single (since := "2025-11-07")]
theorem single_inv (d : ℤ) {α : F} (hα : α ≠ 0) :
single (-d) (α⁻¹ : F) = (single (d : ℤ) (α : F))⁻¹ := by
apply eq_inv_of_mul_eq_one_right
simp [hα]
theorem single_zpow (n : ℤ) :
single (n : ℤ) (1 : F) = single (1 : ℤ) 1 ^ n := by
match n with
| (n : ℕ) => apply single_one_eq_pow
| -(n + 1 : ℕ) =>
rw [← Nat.cast_one, ← inv_one, ← HahnSeries.inv_single, zpow_neg,
← Nat.cast_one, Nat.cast_one,
inv_inj, zpow_natCast, single_one_eq_pow, inv_one]
theorem algebraMap_apply_div :
algebraMap (RatFunc F) F⸨X⸩ (algebraMap _ _ p / algebraMap _ _ q) =
algebraMap F[X] F⸨X⸩ p / algebraMap _ _ q := by
simp only [map_div₀, IsScalarTower.algebraMap_apply F[X] (RatFunc F) F⸨X⸩]
end RatFunc
section AdicValuation
open scoped WithZero
variable (K : Type*) [Field K]
namespace PowerSeries
/-- The prime ideal `(X)` of `K⟦X⟧`, when `K` is a field, as a term of the `HeightOneSpectrum`. -/
def idealX : IsDedekindDomain.HeightOneSpectrum K⟦X⟧ where
asIdeal := Ideal.span {X}
isPrime := PowerSeries.span_X_isPrime
ne_bot := by rw [ne_eq, Ideal.span_singleton_eq_bot]; exact X_ne_zero
open IsDedekindDomain.HeightOneSpectrum RatFunc WithZero
variable {K}
/- The `X`-adic valuation of a polynomial equals the `X`-adic valuation of
its coercion to `K⟦X⟧`. -/
theorem intValuation_eq_of_coe (P : K[X]) :
(Polynomial.idealX K).intValuation P = (idealX K).intValuation (P : K⟦X⟧) := by
by_cases hP : P = 0
· rw [hP, Valuation.map_zero, Polynomial.coe_zero, Valuation.map_zero]
rw [intValuation_if_neg _ hP, intValuation_if_neg _ <| (by simp [hP])]
simp only [idealX_span, exp_neg, inv_inj, exp_inj, Nat.cast_inj]
have span_ne_zero :
(Ideal.span {P} : Ideal K[X]) ≠ 0 ∧ (Ideal.span {Polynomial.X} : Ideal K[X]) ≠ 0 := by
simp only [Ideal.zero_eq_bot, ne_eq, Ideal.span_singleton_eq_bot, hP, Polynomial.X_ne_zero,
not_false_iff, and_self_iff]
have span_ne_zero' :
(Ideal.span {↑P} : Ideal K⟦X⟧) ≠ 0 ∧ ((idealX K).asIdeal : Ideal K⟦X⟧) ≠ 0 := by
simp only [Ideal.zero_eq_bot, ne_eq, Ideal.span_singleton_eq_bot, coe_eq_zero_iff, hP,
not_false_eq_true, true_and, (idealX K).3]
classical
rw [count_associates_factors_eq (span_ne_zero).1
(Ideal.span_singleton_prime Polynomial.X_ne_zero |>.mpr prime_X) (span_ne_zero).2,
count_associates_factors_eq]
on_goal 1 => convert (normalized_count_X_eq_of_coe hP).symm
exacts [count_span_normalizedFactors_eq_of_normUnit hP Polynomial.normUnit_X prime_X,
count_span_normalizedFactors_eq_of_normUnit (by simp [hP]) normUnit_X X_prime,
span_ne_zero'.1, (idealX K).isPrime, span_ne_zero'.2]
/-- The integral valuation of the power series `X : K⟦X⟧` equals `(ofAdd -1) : ℤᵐ⁰`. -/
@[simp]
theorem intValuation_X : (idealX K).intValuation X = exp (-1 : ℤ) := by
rw [← Polynomial.coe_X, ← intValuation_eq_of_coe]
exact intValuation_singleton _ Polynomial.X_ne_zero (idealX_span _)
end PowerSeries
namespace RatFunc
open IsDedekindDomain.HeightOneSpectrum PowerSeries
open scoped LaurentSeries
theorem valuation_eq_LaurentSeries_valuation (P : RatFunc K) :
(Polynomial.idealX K).valuation _ P = (PowerSeries.idealX K).valuation K⸨X⸩ P := by
refine RatFunc.induction_on' P ?_
intro f g h
rw [Polynomial.valuation_of_mk K f h, RatFunc.mk_eq_mk' f h, Eq.comm]
convert @valuation_of_mk' K⟦X⟧ _ _ K⸨X⸩ _ _ _ (PowerSeries.idealX K) f
⟨g, mem_nonZeroDivisors_iff_ne_zero.2 <| (by simp [h])⟩
· simp [← IsScalarTower.algebraMap_apply K[X] (RatFunc K) K⸨X⸩]
exacts [intValuation_eq_of_coe _, intValuation_eq_of_coe _]
end RatFunc
namespace LaurentSeries
open IsDedekindDomain.HeightOneSpectrum PowerSeries RatFunc WithZero
instance : Valued K⸨X⸩ ℤᵐ⁰ := Valued.mk' ((PowerSeries.idealX K).valuation _)
lemma valuation_def : (Valued.v : Valuation K⸨X⸩ ℤᵐ⁰) = (PowerSeries.idealX K).valuation _ := rfl
@[simp]
lemma valuation_coe_ratFunc (f : RatFunc K) :
Valued.v (f : K⸨X⸩) = Valued.v f := by
simp [valuation_def, ← valuation_eq_LaurentSeries_valuation]
theorem valuation_X_pow (s : ℕ) :
Valued.v (((X : K⟦X⟧) : K⸨X⸩) ^ s) = exp (-(s : ℤ)) := by
rw [map_pow, valuation_def, ← LaurentSeries.coe_algebraMap,
valuation_of_algebraMap, intValuation_X, ← exp_nsmul, smul_neg, nsmul_one]
theorem valuation_single_zpow (s : ℤ) :
Valued.v (HahnSeries.single s (1 : K) : K⸨X⸩) = exp (-(s : ℤ)) := by
obtain s | s := s
· rw [Int.ofNat_eq_coe, ← HahnSeries.ofPowerSeries_X_pow, PowerSeries.coe_pow, valuation_X_pow]
· rw [Int.negSucc_eq, ← inv_inj, ← map_inv₀, inv_single, neg_neg, ← Int.natCast_succ, inv_one,
← HahnSeries.ofPowerSeries_X_pow, PowerSeries.coe_pow, valuation_X_pow, exp_neg]
/- The coefficients of a power series vanish in degree strictly less than its valuation. -/
theorem coeff_zero_of_lt_intValuation {n d : ℕ} {f : K⟦X⟧}
(H : Valued.v (f : K⸨X⸩) ≤ exp (-d : ℤ)) :
n < d → coeff n f = 0 := by
intro hnd
apply (PowerSeries.X_pow_dvd_iff).mp _ n hnd
rwa [← LaurentSeries.coe_algebraMap, valuation_def, valuation_of_algebraMap,
intValuation_le_pow_iff_dvd (PowerSeries.idealX K) f d, PowerSeries.idealX,
Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd] at H
/- The valuation of a power series is the order of the first non-zero coefficient. -/
theorem intValuation_le_iff_coeff_lt_eq_zero {d : ℕ} (f : K⟦X⟧) :
Valued.v (f : K⸨X⸩) ≤ exp (-d : ℤ) ↔
∀ n : ℕ, n < d → coeff n f = 0 := by
have : PowerSeries.X ^ d ∣ f ↔ ∀ n : ℕ, n < d → (PowerSeries.coeff n) f = 0 :=
⟨PowerSeries.X_pow_dvd_iff.mp, PowerSeries.X_pow_dvd_iff.mpr⟩
rw [← this, ← LaurentSeries.coe_algebraMap, valuation_def, valuation_of_algebraMap,
← span_singleton_dvd_span_singleton_iff_dvd, ← Ideal.span_singleton_pow]
apply intValuation_le_pow_iff_dvd
/- The coefficients of a Laurent series vanish in degree strictly less than its valuation. -/
theorem coeff_zero_of_lt_valuation {n D : ℤ} {f : K⸨X⸩}
(H : Valued.v f ≤ exp (-D)) : n < D → f.coeff n = 0 := by
intro hnd
by_cases! h_n_ord : n < f.order
· exact coeff_eq_zero_of_lt_order h_n_ord
set F := powerSeriesPart f with hF
by_cases! ord_nonpos : f.order ≤ 0
· obtain ⟨s, hs⟩ := Int.exists_eq_neg_ofNat ord_nonpos
obtain ⟨m, hm⟩ := Int.eq_ofNat_of_zero_le (neg_le_iff_add_nonneg.mp (hs ▸ h_n_ord))
obtain ⟨d, hd⟩ := Int.eq_ofNat_of_zero_le (a := D + s) (by cutsat)
rw [eq_add_neg_of_add_eq hm, add_comm, ← hs, ← powerSeriesPart_coeff]
apply (intValuation_le_iff_coeff_lt_eq_zero K F).mp _ m (by linarith)
rw [hF, ofPowerSeries_powerSeriesPart f, hs, neg_neg, ← hd, neg_add_rev, exp_add, map_mul,
← ofPowerSeries_X_pow s, PowerSeries.coe_pow, valuation_X_pow K s]
gcongr
· obtain ⟨s, hs⟩ := Int.exists_eq_neg_ofNat (Int.neg_nonpos_of_nonneg (le_of_lt ord_nonpos))
obtain ⟨m, hm⟩ := Int.eq_ofNat_of_zero_le (a := n - s) (by omega)
obtain ⟨d, hd⟩ := Int.eq_ofNat_of_zero_le (a := D - s) (by cutsat)
rw [(sub_eq_iff_eq_add).mp hm, add_comm, ← neg_neg (s : ℤ), ← hs, neg_neg,
← powerSeriesPart_coeff]
apply (intValuation_le_iff_coeff_lt_eq_zero K F).mp _ m (by linarith)
rw [hF, ofPowerSeries_powerSeriesPart f, map_mul, ← hd, hs, neg_sub, sub_eq_add_neg,
exp_add, valuation_single_zpow, neg_neg]
gcongr
/- The valuation of a Laurent series is the order of the first non-zero coefficient. -/
theorem valuation_le_iff_coeff_lt_eq_zero {D : ℤ} {f : K⸨X⸩} :
Valued.v f ≤ exp (-D : ℤ) ↔ ∀ n : ℤ, n < D → f.coeff n = 0 := by
refine ⟨fun hnD n hn => coeff_zero_of_lt_valuation K hnD hn, fun h_val_f => ?_⟩
let F := powerSeriesPart f
by_cases! ord_nonpos : f.order ≤ 0
· obtain ⟨s, hs⟩ := Int.exists_eq_neg_ofNat ord_nonpos
rw [← f.single_order_mul_powerSeriesPart, hs, map_mul, valuation_single_zpow, neg_neg, mul_comm,
← le_mul_inv_iff₀, exp_neg, ← mul_inv, ← exp_add, ← exp_neg]
· by_cases! hDs : D + s ≤ 0
· apply le_trans ((PowerSeries.idealX K).valuation_le_one F)
rwa [← log_le_iff_le_exp one_ne_zero, le_neg, log_one, neg_zero]
· obtain ⟨d, hd⟩ := Int.eq_ofNat_of_zero_le hDs.le
rw [hd]
apply (intValuation_le_iff_coeff_lt_eq_zero K F).mpr
intro n hn
rw [powerSeriesPart_coeff f n, hs]
apply h_val_f
cutsat
· simp [ne_eq, zero_lt_iff]
· obtain ⟨s, hs⟩ := Int.exists_eq_neg_ofNat <| neg_nonpos_of_nonneg ord_nonpos.le
rw [neg_inj] at hs
rw [← f.single_order_mul_powerSeriesPart, hs, map_mul, valuation_single_zpow, mul_comm,
← le_mul_inv_iff₀, ← exp_neg, ← exp_add, neg_neg]
· by_cases! hDs : D - s ≤ 0
· apply le_trans ((PowerSeries.idealX K).valuation_le_one F)
rw [← log_le_iff_le_exp one_ne_zero, log_one]
cutsat
· obtain ⟨d, hd⟩ := Int.eq_ofNat_of_zero_le hDs.le
rw [← neg_neg (-D + ↑s), ← sub_eq_neg_add, neg_sub, hd]
apply (intValuation_le_iff_coeff_lt_eq_zero K F).mpr
intro n hn
rw [powerSeriesPart_coeff f n, hs]
apply h_val_f (s + n)
cutsat
· simp [ne_eq, zero_lt_iff]
theorem valuation_le_iff_coeff_lt_log_eq_zero {D : ℤᵐ⁰} (hD : D ≠ 0) {f : K⸨X⸩} :
Valued.v f ≤ D ↔ ∀ n : ℤ, n < -log D → f.coeff n = 0 := by
cases D
· simp_all
· rename_i D
cases D
rename_i D
rw [← exp, ← neg_neg D, valuation_le_iff_coeff_lt_eq_zero, log_exp, neg_neg]
/- Two Laurent series whose difference has small valuation have the same coefficients for
small enough indices. -/
theorem eq_coeff_of_valuation_sub_lt {d n : ℤ} {f g : K⸨X⸩}
(H : Valued.v (g - f) ≤ exp (-d)) : n < d → g.coeff n = f.coeff n := by
by_cases triv : g = f
· exact fun _ => by rw [triv]
· intro hn
apply eq_of_sub_eq_zero
rw [← HahnSeries.coeff_sub]
apply coeff_zero_of_lt_valuation K H hn
/- Every Laurent series of valuation less than `(1 : ℤᵐ⁰)` comes from a power series. -/
theorem val_le_one_iff_eq_coe (f : K⸨X⸩) : Valued.v f ≤ (1 : ℤᵐ⁰) ↔
∃ F : K⟦X⟧, F = f := by
rw [valuation_le_iff_coeff_lt_log_eq_zero _ one_ne_zero, log_one, neg_zero]
refine ⟨fun h => ⟨PowerSeries.mk fun n => f.coeff n, ?_⟩, ?_⟩
on_goal 1 => ext (_ | n)
· simp only [Int.ofNat_eq_coe, coeff_coe_powerSeries, coeff_mk]
on_goal 1 => simp only [h (Int.negSucc n) (Int.negSucc_lt_zero n)]
on_goal 2 => rintro ⟨F, rfl⟩ _ _
all_goals
apply HahnSeries.embDomain_notin_range
simp only [Nat.coe_castAddMonoidHom, RelEmbedding.coe_mk, Function.Embedding.coeFn_mk,
Set.mem_range, not_exists, reduceCtorEq]
intro
· simp only [not_false_eq_true]
· cutsat
end LaurentSeries
end AdicValuation
namespace LaurentSeries
variable {K : Type*} [Field K]
section Complete
open Filter WithZero PowerSeries
/- Sending a Laurent series to its `d`-th coefficient is uniformly continuous (independently of the
uniformity with which `K` is endowed). -/
theorem uniformContinuous_coeff {uK : UniformSpace K} (d : ℤ) :
UniformContinuous fun f : K⸨X⸩ ↦ f.coeff d := by
refine uniformContinuous_iff_eventually.mpr fun S hS ↦ eventually_iff_exists_mem.mpr ?_
let γ : (ℤᵐ⁰)ˣ := Units.mk0 (exp (-(d + 1))) coe_ne_zero
use {P | Valued.v (P.snd - P.fst) < ↑γ}
refine ⟨(Valued.hasBasis_uniformity K⸨X⸩ ℤᵐ⁰).mem_of_mem (by tauto), fun P hP ↦ ?_⟩
rw [eq_coeff_of_valuation_sub_lt K (le_of_lt hP) (lt_add_one _)]
exact mem_uniformity_of_eq hS rfl
/-- Since extracting coefficients is uniformly continuous, every Cauchy filter in
`K⸨X⸩` gives rise to a Cauchy filter in `K` for every `d : ℤ`, and such Cauchy filter
in `K` converges to a principal filter -/
def Cauchy.coeff {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) : ℤ → K :=
let _ : UniformSpace K := ⊥
fun d ↦ DiscreteUniformity.cauchyConst <| hℱ.map (uniformContinuous_coeff d)
theorem Cauchy.coeff_tendsto {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) (D : ℤ) :
Tendsto (fun f : K⸨X⸩ ↦ f.coeff D) ℱ (𝓟 {coeff hℱ D}) :=
let _ : UniformSpace K := ⊥
le_of_eq <| DiscreteUniformity.eq_pure_cauchyConst
(hℱ.map (uniformContinuous_coeff D)) ▸ (principal_singleton _).symm
/- For every Cauchy filter of Laurent series, there is a `N` such that the `n`-th coefficient
vanishes for all `n ≤ N` and almost all series in the filter. This is an auxiliary lemma used
to construct the limit of the Cauchy filter as a Laurent series, ensuring that the support of the
limit is `PWO`.
The result is true also for more general Hahn Series indexed over a partially ordered group `Γ`
beyond the special case `Γ = ℤ`, that corresponds to Laurent Series: nevertheless the proof below
does not generalise, as it relies on the study of the `X`-adic valuation attached to the height-one
prime `X`, and this is peculiar to the one-variable setting. In the future we should prove this
result in full generality and deduce the case `Γ = ℤ` from that one. -/
lemma Cauchy.exists_lb_eventual_support {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) :
∃ N, ∀ᶠ f : K⸨X⸩ in ℱ, ∀ n < N, f.coeff n = (0 : K) := by
let entourage : Set (K⸨X⸩ × K⸨X⸩) := {P : K⸨X⸩ × K⸨X⸩ | Valued.v (P.snd - P.fst) < 1}
let ζ := Units.mk0 (G₀ := ℤᵐ⁰) _ (coe_ne_zero (a := 1))
obtain ⟨S, ⟨hS, ⟨T, ⟨hT, H⟩⟩⟩⟩ := mem_prod_iff.mp <| Filter.le_def.mp hℱ.2 entourage
<| (Valued.hasBasis_uniformity K⸨X⸩ ℤᵐ⁰).mem_of_mem (i := ζ) (by tauto)
obtain ⟨f, hf⟩ := forall_mem_nonempty_iff_neBot.mpr hℱ.1 (S ∩ T) (inter_mem_iff.mpr ⟨hS, hT⟩)
obtain ⟨N, hN⟩ : ∃ N : ℤ, ∀ g : K⸨X⸩,
Valued.v (g - f) ≤ 1 → ∀ n < N, g.coeff n = 0 := by
by_cases hf : f = 0
· refine ⟨0, fun x hg ↦ ?_⟩
rw [hf, sub_zero] at hg
exact (valuation_le_iff_coeff_lt_eq_zero K).mp hg
· refine ⟨min (f.2.isWF.min (HahnSeries.support_nonempty_iff.mpr hf)) 0 - 1, fun _ hg n hn ↦ ?_⟩
rw [eq_coeff_of_valuation_sub_lt K hg (d := 0)]
· exact Function.notMem_support.mp fun h ↦
f.2.isWF.not_lt_min (HahnSeries.support_nonempty_iff.mpr hf) h
<| lt_trans hn <| Int.sub_one_lt_iff.mpr <| min_le_left _ _
exact lt_of_lt_of_le hn <| le_of_lt (Int.sub_one_lt_of_le <| min_le_right _ _)
use N
apply mem_of_superset (inter_mem hS hT)
intro g hg
have h_prod : (f, g) ∈ S ×ˢ T := by simp [hf.1, hg.2]
refine hN g (le_of_lt ?_)
simpa using H h_prod
/- The support of `Cauchy.coeff` has a lower bound. -/
theorem Cauchy.exists_lb_support {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) :
∃ N, ∀ n, n < N → coeff hℱ n = 0 := by
let _ : UniformSpace K := ⊥
obtain ⟨N, hN⟩ := exists_lb_eventual_support hℱ
refine ⟨N, fun n hn ↦ Ultrafilter.eq_of_le_pure (hℱ.map (uniformContinuous_coeff n)).1
((principal_singleton _).symm ▸ coeff_tendsto _ _) ?_⟩
simp only [pure_zero, nonpos_iff]
apply Filter.mem_of_superset hN (fun _ ha ↦ ha _ hn)
/- The support of `Cauchy.coeff` is bounded below -/
theorem Cauchy.coeff_support_bddBelow {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) :
BddBelow (coeff hℱ).support := by
refine ⟨(exists_lb_support hℱ).choose, fun d hd ↦ ?_⟩
by_contra hNd
exact hd ((exists_lb_support hℱ).choose_spec d (not_le.mp hNd))
/-- To any Cauchy filter ℱ of `K⸨X⸩`, we can attach a laurent series that is the limit
of the filter. Its `d`-th coefficient is defined as the limit of `Cauchy.coeff hℱ d`, which is
again Cauchy but valued in the discrete space `K`. That sufficiently negative coefficients vanish
follows from `Cauchy.coeff_support_bddBelow` -/
def Cauchy.limit {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) : K⸨X⸩ :=
HahnSeries.mk (coeff hℱ) <| Set.IsWF.isPWO (coeff_support_bddBelow _).wellFoundedOn_lt
/- The following lemma shows that for every `d` smaller than the minimum between the integers
produced in `Cauchy.exists_lb_eventual_support` and `Cauchy.exists_lb_support`, for almost all
series in `ℱ` the `d`th coefficient coincides with the `d`th coefficient of `Cauchy.coeff hℱ`. -/
theorem Cauchy.exists_lb_coeff_ne {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) :
∃ N, ∀ᶠ f : K⸨X⸩ in ℱ, ∀ d < N, coeff hℱ d = f.coeff d := by
obtain ⟨⟨N₁, hN₁⟩, ⟨N₂, hN₂⟩⟩ := exists_lb_eventual_support hℱ, exists_lb_support hℱ
refine ⟨min N₁ N₂, ℱ.3 hN₁ fun _ hf d hd ↦ ?_⟩
rw [hf d (lt_of_lt_of_le hd (min_le_left _ _)), hN₂ d (lt_of_lt_of_le hd (min_le_right _ _))]
/- Given a Cauchy filter `ℱ` in the Laurent Series and a bound `D`, for almost all series in the
filter the coefficients below `D` coincide with `Cauchy.coeff hℱ`. -/
theorem Cauchy.coeff_eventually_equal {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ) {D : ℤ} :
∀ᶠ f : K⸨X⸩ in ℱ, ∀ d, d < D → coeff hℱ d = f.coeff d := by
-- `φ` sends `d` to the set of Laurent Series having `d`th coefficient equal to `ℱ.coeff`.
let φ : ℤ → Set K⸨X⸩ := fun d ↦ {f | coeff hℱ d = f.coeff d}
have intersec₁ :
(⋂ n ∈ Set.Iio D, φ n) ⊆ {x : K⸨X⸩ | ∀ d : ℤ, d < D → coeff hℱ d = x.coeff d} := by
intro _ hf
simpa only [Set.mem_iInter] using hf
-- The goal is now to show that the intersection of all `φ d` (for `d < D`) is in `ℱ`.
let ℓ := (exists_lb_coeff_ne hℱ).choose
let N := max ℓ D
have intersec₂ : ⋂ n ∈ Set.Iio D, φ n ⊇ (⋂ n ∈ Set.Iio ℓ, φ n) ∩ (⋂ n ∈ Set.Icc ℓ N, φ n) := by
simp only [Set.mem_Iio, Set.mem_Icc, Set.subset_iInter_iff]
intro i hi x hx
simp only [Set.mem_inter_iff, Set.mem_iInter, and_imp] at hx
by_cases! H : i < ℓ
exacts [hx.1 _ H, hx.2 _ H <| le_of_lt <| lt_max_of_lt_right hi]
suffices (⋂ n ∈ Set.Iio ℓ, φ n) ∩ (⋂ n ∈ Set.Icc ℓ N, φ n) ∈ ℱ by
exact ℱ.sets_of_superset this <| intersec₂.trans intersec₁
/- To show that the intersection we have in sight is in `ℱ`, we use that it contains a double
intersection (an infinite and a finite one): by general properties of filters, we are reduced
to show that both terms are in `ℱ`, which is easy in light of their definition. -/
· simp only [Set.mem_Iio, inter_mem_iff]
constructor
· have := (exists_lb_coeff_ne hℱ).choose_spec
rw [Filter.eventually_iff] at this
convert this
ext
simp only [Set.mem_iInter, Set.mem_setOf_eq]; rfl
· rw [biInter_mem (Set.finite_Icc ℓ N)]
intro _ _
apply coeff_tendsto hℱ
simp only [principal_singleton, mem_pure]; rfl
open scoped Topology
/- The main result showing that the Cauchy filter tends to the `Cauchy.limit` -/
theorem Cauchy.eventually_mem_nhds {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ)
{U : Set K⸨X⸩} (hU : U ∈ 𝓝 (Cauchy.limit hℱ)) : ∀ᶠ f in ℱ, f ∈ U := by
obtain ⟨γ, hU₁⟩ := Valued.mem_nhds.mp hU
suffices ∀ᶠ f in ℱ, f ∈ {y : K⸨X⸩ | Valued.v (y - limit hℱ) < ↑γ} by
apply this.mono fun _ hf ↦ hU₁ hf
set D := -(log γ - 1) with hD₀
have hD : exp (-D) < γ := by
rw [← lt_log_iff_exp_lt (by simp), hD₀]
simp
apply coeff_eventually_equal (D := D) hℱ |>.mono
intro _ hf
apply lt_of_le_of_lt (valuation_le_iff_coeff_lt_eq_zero K |>.mpr _) hD
intro n hn
rw [HahnSeries.coeff_sub, sub_eq_zero, eq_comm]
exact hf _ hn
/- Laurent Series with coefficients in a field are complete w.r.t. the `X`-adic valuation -/
instance instLaurentSeriesComplete : CompleteSpace K⸨X⸩ :=
⟨fun hℱ ↦ ⟨Cauchy.limit hℱ, fun _ hS ↦ Cauchy.eventually_mem_nhds hℱ hS⟩⟩
end Complete
section Dense
open scoped Multiplicative
open LaurentSeries PowerSeries IsDedekindDomain.HeightOneSpectrum WithZero RatFunc
theorem exists_Polynomial_intValuation_lt (F : K⟦X⟧) (η : ℤᵐ⁰ˣ) :
∃ P : K[X], (PowerSeries.idealX K).intValuation (F - P) < η := by
by_cases! h_neg : 1 < η
· use 0
simpa using (intValuation_le_one (PowerSeries.idealX K) F).trans_lt h_neg
· rw [← Units.val_le_val, Units.val_one, ← WithZero.coe_one, ← coe_unzero η.ne_zero,
coe_le_coe, ← Multiplicative.toAdd_le, toAdd_one] at h_neg
obtain ⟨d, hd⟩ := Int.exists_eq_neg_ofNat h_neg
use F.trunc (d + 1)
have : Valued.v ((ofPowerSeries ℤ K) (F - (trunc (d + 1) F))) ≤
(Multiplicative.ofAdd (-(d + 1 : ℤ))) := by
apply (intValuation_le_iff_coeff_lt_eq_zero K _).mpr
simpa only [map_sub, sub_eq_zero, Polynomial.coeff_coe, coeff_trunc] using
fun _ h ↦ (if_pos h).symm
rw [neg_add, ofAdd_add, ← hd, ofAdd_toAdd, WithZero.coe_mul, coe_unzero,
← coe_algebraMap] at this
rw [← valuation_of_algebraMap (K := K⸨X⸩) (PowerSeries.idealX K) (F - F.trunc (d + 1))]
apply lt_of_le_of_lt this
rw [← mul_one (η : ℤᵐ⁰), mul_assoc, one_mul]
gcongr
· exact zero_lt_iff.2 η.ne_zero
rw [← WithZero.coe_one, coe_lt_coe, ofAdd_neg, Right.inv_lt_one_iff, ← ofAdd_zero,
Multiplicative.ofAdd_lt]
exact Int.zero_lt_one
/-- For every Laurent series `f` and every `γ : ℤᵐ⁰` one can find a rational function `Q` such
that the `X`-adic valuation `v` satisfies `v (f - Q) < γ`. -/
theorem exists_ratFunc_val_lt (f : K⸨X⸩) (γ : ℤᵐ⁰ˣ) :
∃ Q : RatFunc K, Valued.v (f - Q) < γ := by
set F := f.powerSeriesPart with hF
by_cases! ord_nonpos : f.order < 0
· set η : ℤᵐ⁰ˣ := Units.mk0 (exp f.order) coe_ne_zero
with hη
obtain ⟨P, hP⟩ := exists_Polynomial_intValuation_lt F (η * γ)
use RatFunc.X ^ f.order * (P : RatFunc K)
have F_mul := f.ofPowerSeries_powerSeriesPart
obtain ⟨s, hs⟩ := Int.exists_eq_neg_ofNat (le_of_lt ord_nonpos)
rw [← hF, hs, neg_neg, ← ofPowerSeries_X_pow s, ← inv_mul_eq_iff_eq_mul₀] at F_mul
· have : (algebraMap (RatFunc K) K⸨X⸩) 1 = 1 := by exact algebraMap.coe_one
rw [hs, ← F_mul, PowerSeries.coe_pow, PowerSeries.coe_X, map_mul, zpow_neg,
zpow_natCast, inv_eq_one_div (RatFunc.X ^ s), map_div₀, map_pow,
RatFunc.coe_X]
simp only [map_one]
rw [← inv_eq_one_div, ← mul_sub, map_mul, map_inv₀,
← PowerSeries.coe_X, valuation_X_pow, ← hs, ← RatFunc.coe_coe, ← PowerSeries.coe_sub,
← coe_algebraMap, adicValued_apply, valuation_of_algebraMap,
← Units.val_mk0 (a := exp f.order) exp_ne_zero, ← hη]
apply inv_mul_lt_of_lt_mul₀
rwa [← Units.val_mul]
· simp only [PowerSeries.coe_pow, pow_ne_zero, PowerSeries.coe_X, ne_eq,
single_eq_zero_iff, one_ne_zero, not_false_iff]
· obtain ⟨s, hs⟩ := Int.exists_eq_neg_ofNat (Int.neg_nonpos_of_nonneg ord_nonpos)
obtain ⟨P, hP⟩ := exists_Polynomial_intValuation_lt (PowerSeries.X ^ s * F) γ
use P
rw [← X_order_mul_powerSeriesPart (neg_inj.1 hs).symm, ← RatFunc.coe_coe,
← PowerSeries.coe_sub, ← coe_algebraMap, adicValued_apply, valuation_of_algebraMap]
exact hP
theorem coe_range_dense : DenseRange ((↑) : RatFunc K → K⸨X⸩) := by
rw [denseRange_iff_closure_range]
ext f
simp only [UniformSpace.mem_closure_iff_symm_ball, Set.mem_univ, iff_true, Set.Nonempty,
Set.mem_inter_iff, Set.mem_range, exists_exists_eq_and]
intro V hV h_symm
rw [uniformity_eq_comap_neg_add_nhds_zero_swapped] at hV
obtain ⟨T, hT₀, hT₁⟩ := hV
obtain ⟨γ, hγ⟩ := Valued.mem_nhds_zero.mp hT₀
obtain ⟨P, _⟩ := exists_ratFunc_val_lt f γ
use P
apply hT₁
apply hγ
simpa only [add_comm, ← sub_eq_add_neg, gt_iff_lt, Set.mem_setOf_eq]
end Dense
section Comparison
open RatFunc AbstractCompletion IsDedekindDomain.HeightOneSpectrum WithZero
lemma exists_ratFunc_eq_v (x : K⸨X⸩) : ∃ f : RatFunc K, Valued.v f = Valued.v x := by
by_cases hx : Valued.v x = 0
· use 0
simp [hx]
use RatFunc.X ^ (-log (Valued.v x))
rw [zpow_neg, map_inv₀, map_zpow₀, v_def, valuation_X_eq_neg_one, ← exp_zsmul, ← exp_neg]
simp [exp_log, hx]
theorem inducing_coe : IsUniformInducing ((↑) : RatFunc K → K⸨X⸩) := by
rw [isUniformInducing_iff, Filter.comap]
ext S
simp only [Filter.mem_mk, Set.mem_setOf_eq, uniformity_eq_comap_nhds_zero,
Filter.mem_comap]
constructor
· rintro ⟨T, ⟨⟨R, ⟨hR, pre_R⟩⟩, pre_T⟩⟩
obtain ⟨d, hd⟩ := Valued.mem_nhds.mp hR
use {P : RatFunc K | Valued.v P < ↑d}
simp only [Valued.mem_nhds, sub_zero]
refine ⟨⟨d, by rfl⟩, subset_trans (fun _ _ ↦ pre_R ?_) pre_T⟩
apply hd
simp only [sub_zero, Set.mem_setOf_eq]
rw [← map_sub, valuation_def, ← valuation_eq_LaurentSeries_valuation]
assumption
· rintro ⟨_, ⟨hT, pre_T⟩⟩
obtain ⟨d, hd⟩ := Valued.mem_nhds.mp hT
let X := {f : K⸨X⸩ | Valued.v f < ↑d}
refine ⟨(fun x : K⸨X⸩ × K⸨X⸩ ↦ x.snd - x.fst) ⁻¹' X, ⟨X, ?_⟩, ?_⟩
· refine ⟨?_, Set.Subset.refl _⟩
· simp only [Valued.mem_nhds, sub_zero]
use d
· refine subset_trans (fun _ _ ↦ ?_) pre_T
apply hd
rw [Set.mem_setOf_eq, sub_zero, v_def, valuation_eq_LaurentSeries_valuation,
map_sub]
assumption
theorem continuous_coe : Continuous ((↑) : RatFunc K → K⸨X⸩) :=
(isUniformInducing_iff'.1 (inducing_coe)).1.continuous
/-- The `X`-adic completion as an abstract completion of `RatFunc K` -/
abbrev ratfuncAdicComplPkg : AbstractCompletion (RatFunc K) :=
UniformSpace.Completion.cPkg
variable (K)
/-- Having established that the `K⸨X⸩` is complete and contains `RatFunc K` as a dense
subspace, it gives rise to an abstract completion of `RatFunc K`. -/
noncomputable def LaurentSeriesPkg : AbstractCompletion (RatFunc K) where
space := K⸨X⸩
coe := (↑)
uniformStruct := inferInstance
complete := inferInstance
separation := inferInstance
isUniformInducing := inducing_coe
dense := coe_range_dense
instance : TopologicalSpace (LaurentSeriesPkg K).space :=
(LaurentSeriesPkg K).uniformStruct.toTopologicalSpace
@[simp]
theorem LaurentSeries_coe (x : RatFunc K) : (LaurentSeriesPkg K).coe x = (x : K⸨X⸩) :=
rfl
/-- Reinterpret the extension of `coe : RatFunc K → K⸨X⸩` as a ring homomorphism -/
abbrev extensionAsRingHom :=
UniformSpace.Completion.extensionHom (algebraMap (RatFunc K) (K⸨X⸩))
/-- An abbreviation for the `X`-adic completion of `RatFunc K` -/
abbrev RatFuncAdicCompl := adicCompletion (RatFunc K) (idealX K)
/- The two instances below make `comparePkg` and `comparePkg_eq_extension` slightly faster. -/
instance : UniformSpace (RatFuncAdicCompl K) := inferInstance
instance : UniformSpace K⸨X⸩ := inferInstance
/-- The uniform space isomorphism between two abstract completions of `ratfunc K` -/
abbrev comparePkg : RatFuncAdicCompl K ≃ᵤ K⸨X⸩ :=
compareEquiv ratfuncAdicComplPkg (LaurentSeriesPkg K)
lemma comparePkg_eq_extension (x : UniformSpace.Completion (RatFunc K)) :
(comparePkg K).toFun x = (extensionAsRingHom K (continuous_coe)).toFun x := rfl
/-- The uniform space equivalence between two abstract completions of `ratfunc K` as a ring
equivalence: this will be the *inverse* of the fundamental one. -/
abbrev ratfuncAdicComplRingEquiv : RatFuncAdicCompl K ≃+* K⸨X⸩ :=
{ comparePkg K with
map_mul' := by
intro x y
rw [comparePkg_eq_extension, (extensionAsRingHom K (continuous_coe)).map_mul']
rfl
map_add' := by
intro x y
rw [comparePkg_eq_extension, (extensionAsRingHom K (continuous_coe)).map_add']
rfl }
/-- The uniform space equivalence between two abstract completions of `ratfunc K` as a ring
equivalence: it goes from `K⸨X⸩` to `RatFuncAdicCompl K` -/
abbrev LaurentSeriesRingEquiv : K⸨X⸩ ≃+* RatFuncAdicCompl K :=
(ratfuncAdicComplRingEquiv K).symm
@[simp]
lemma LaurentSeriesRingEquiv_def (f : K⟦X⟧) :
(LaurentSeriesRingEquiv K) f = (LaurentSeriesPkg K).compare ratfuncAdicComplPkg (f : K⸨X⸩) :=
rfl
@[simp]
theorem ratfuncAdicComplRingEquiv_apply (x : RatFuncAdicCompl K) :
ratfuncAdicComplRingEquiv K x = ratfuncAdicComplPkg.compare (LaurentSeriesPkg K) x := rfl
theorem coe_X_compare :
(ratfuncAdicComplRingEquiv K) ((RatFunc.X : RatFunc K) : RatFuncAdicCompl K) =
((PowerSeries.X : K⟦X⟧) : K⸨X⸩) := by
rw [PowerSeries.coe_X, ← RatFunc.coe_X, ← LaurentSeries_coe, ← compare_coe]
rfl
theorem algebraMap_apply (a : K) : algebraMap K K⸨X⸩ a = HahnSeries.C a := by
simp [RingHom.algebraMap_toAlgebra]
instance : Algebra K (RatFuncAdicCompl K) :=
RingHom.toAlgebra ((LaurentSeriesRingEquiv K).toRingHom.comp HahnSeries.C)
/-- The algebra equivalence between `K⸨X⸩` and the `X`-adic completion of `RatFunc X` -/
def LaurentSeriesAlgEquiv : K⸨X⸩ ≃ₐ[K] RatFuncAdicCompl K :=
AlgEquiv.ofRingEquiv (f := LaurentSeriesRingEquiv K)
(fun a ↦ by simp [RingHom.algebraMap_toAlgebra])
open Filter WithZero
open scoped WithZeroTopology Topology Multiplicative
theorem valuation_LaurentSeries_equal_extension :
(LaurentSeriesPkg K).isDenseInducing.extend Valued.v = (Valued.v : K⸨X⸩ → ℤᵐ⁰) := by
apply IsDenseInducing.extend_unique
· intro x
rw [v_def, valuation_eq_LaurentSeries_valuation K x]
rfl
· exact Valued.continuous_valuation (K := K⸨X⸩)
theorem tendsto_valuation (a : (idealX K).adicCompletion (RatFunc K)) :
Tendsto (Valued.v : RatFunc K → ℤᵐ⁰) (comap (↑) (𝓝 a)) (𝓝 (Valued.v a : ℤᵐ⁰)) := by
have := Valued.is_topological_valuation (R := (idealX K).adicCompletion (RatFunc K))
by_cases ha : a = 0
· rw [tendsto_def]
intro S hS
rw [ha, map_zero, WithZeroTopology.hasBasis_nhds_zero.1 S] at hS
obtain ⟨γ, γ_ne_zero, γ_le⟩ := hS
use {t | Valued.v t < γ}
constructor
· rw [ha, this]
use Units.mk0 γ γ_ne_zero
rw [Units.val_mk0]
· refine Set.Subset.trans (fun a _ ↦ ?_) (Set.preimage_mono γ_le)
rwa [Set.mem_preimage, Set.mem_Iio, ← Valued.valuedCompletion_apply a]
· rw [WithZeroTopology.tendsto_of_ne_zero ((Valuation.ne_zero_iff Valued.v).mpr ha),
Filter.eventually_comap, Filter.Eventually, Valued.mem_nhds]
use Units.mk0 (Valued.v a) (by simp [ha])
simp only [Units.val_mk0, v_def, Set.setOf_subset_setOf]
rintro y val_y b rfl
simp [← Valuation.map_eq_of_sub_lt _ val_y]
/- The extension of the `X`-adic valuation from `RatFunc K` up to its abstract completion coincides,
modulo the isomorphism with `K⸨X⸩`, with the `X`-adic valuation on `K⸨X⸩`. -/
theorem valuation_compare (f : K⸨X⸩) :
(Valued.v : (RatFuncAdicCompl K) → ℤᵐ⁰)
(AbstractCompletion.compare (LaurentSeriesPkg K) ratfuncAdicComplPkg f) =
Valued.v f := by
rw [← valuation_LaurentSeries_equal_extension, ← compare_comp_eq_compare
(pkg := ratfuncAdicComplPkg) (cont_f := Valued.continuous_valuation)]
· rfl
exact (tendsto_valuation K)
section PowerSeries
/-- In order to compare `K⟦X⟧` with the valuation subring in the `X`-adic completion of
`RatFunc K` we consider its alias as a subring of `K⸨X⸩`. -/
abbrev powerSeries_as_subring : Subring K⸨X⸩ :=
Subring.map (HahnSeries.ofPowerSeries ℤ K) ⊤
/-- The ring `K⟦X⟧` is isomorphic to the subring `powerSeries_as_subring K` -/
abbrev powerSeriesEquivSubring : K⟦X⟧ ≃+* powerSeries_as_subring K :=
((Subring.topEquiv).symm).trans (Subring.equivMapOfInjective ⊤ (ofPowerSeries ℤ K)
ofPowerSeries_injective)
lemma powerSeriesEquivSubring_apply (f : K⟦X⟧) :
powerSeriesEquivSubring K f =
⟨HahnSeries.ofPowerSeries ℤ K f, Subring.mem_map.mpr ⟨f, trivial, rfl⟩⟩ :=
rfl
lemma powerSeriesEquivSubring_coe_apply (f : K⟦X⟧) :
(powerSeriesEquivSubring K f : K⸨X⸩) = ofPowerSeries ℤ K f :=
rfl
/- Through the isomorphism `LaurentSeriesRingEquiv`, power series land in the unit ball inside the
completion of `RatFunc K`. -/
theorem mem_integers_of_powerSeries (F : K⟦X⟧) :
(LaurentSeriesRingEquiv K) F ∈ (idealX K).adicCompletionIntegers (RatFunc K) := by
simp only [mem_adicCompletionIntegers, LaurentSeriesRingEquiv_def,
valuation_compare, val_le_one_iff_eq_coe]
exact ⟨F, rfl⟩
/- Conversely, all elements in the unit ball inside the completion of `RatFunc K` come from a power
series through the isomorphism `LaurentSeriesRingEquiv`. -/
theorem exists_powerSeries_of_memIntegers {x : RatFuncAdicCompl K}
(hx : x ∈ (idealX K).adicCompletionIntegers (RatFunc K)) :
∃ F : K⟦X⟧, (LaurentSeriesRingEquiv K) F = x := by
set f := (ratfuncAdicComplRingEquiv K) x with hf
have H_x : (LaurentSeriesPkg K).compare ratfuncAdicComplPkg ((ratfuncAdicComplRingEquiv K) x) =
x := congr_fun (inverse_compare (LaurentSeriesPkg K) ratfuncAdicComplPkg) x
rw [mem_adicCompletionIntegers, ← H_x] at hx
obtain ⟨F, hF⟩ := (val_le_one_iff_eq_coe K f).mp (valuation_compare _ f ▸ hx)
exact ⟨F, by rw [hF, hf, RingEquiv.symm_apply_apply]⟩
theorem powerSeries_ext_subring :
Subring.map (LaurentSeriesRingEquiv K).toRingHom (powerSeries_as_subring K) =
((idealX K).adicCompletionIntegers (RatFunc K)).toSubring := by
ext x
refine ⟨fun ⟨f, ⟨F, _, coe_F⟩, hF⟩ ↦ ?_, fun H ↦ ?_⟩
· simp only [ValuationSubring.mem_toSubring, ← hF, ← coe_F]
apply mem_integers_of_powerSeries
· obtain ⟨F, hF⟩ := exists_powerSeries_of_memIntegers K H
simp only [Subring.mem_map]
exact ⟨F, ⟨F, trivial, rfl⟩, hF⟩
/-- The ring isomorphism between `K⟦X⟧` and the unit ball inside the `X`-adic completion of
`RatFunc K`. -/
abbrev powerSeriesRingEquiv : K⟦X⟧ ≃+* (idealX K).adicCompletionIntegers (RatFunc K) :=
((powerSeriesEquivSubring K).trans (LaurentSeriesRingEquiv K).subringMap).trans
<| RingEquiv.subringCongr (powerSeries_ext_subring K)
lemma powerSeriesRingEquiv_coe_apply (f : K⟦X⟧) :
powerSeriesRingEquiv K f = LaurentSeriesRingEquiv K (f : K⸨X⸩) :=
rfl
lemma LaurentSeriesRingEquiv_mem_valuationSubring (f : K⟦X⟧) :
LaurentSeriesRingEquiv K f ∈ Valued.v.valuationSubring := by
simp only [Valuation.mem_valuationSubring_iff]
rw [LaurentSeriesRingEquiv_def, valuation_compare, val_le_one_iff_eq_coe]
use f
lemma algebraMap_C_mem_adicCompletionIntegers (x : K) :
((LaurentSeriesRingEquiv K).toRingHom.comp HahnSeries.C) x ∈
adicCompletionIntegers (RatFunc K) (idealX K) := by
have : HahnSeries.C x = ofPowerSeries ℤ K (PowerSeries.C x) := by
simp [C_apply, ofPowerSeries_C]
simp only [RingHom.comp_apply, RingEquiv.toRingHom_eq_coe, RingHom.coe_coe, this]
apply LaurentSeriesRingEquiv_mem_valuationSubring
instance : Algebra K ((idealX K).adicCompletionIntegers (RatFunc K)) :=
RingHom.toAlgebra <|
((LaurentSeriesRingEquiv K).toRingHom.comp HahnSeries.C).codRestrict _
(algebraMap_C_mem_adicCompletionIntegers K)
/-- The algebra isomorphism between `K⟦X⟧` and the unit ball inside the `X`-adic completion of
`RatFunc K`. -/
def powerSeriesAlgEquiv : K⟦X⟧ ≃ₐ[K] (idealX K).adicCompletionIntegers (RatFunc K) := by
apply AlgEquiv.ofRingEquiv (f := powerSeriesRingEquiv K)
intro a
rw [PowerSeries.algebraMap_eq, RingHom.algebraMap_toAlgebra, ← Subtype.coe_inj,
powerSeriesRingEquiv_coe_apply,
RingHom.codRestrict_apply _ _ (algebraMap_C_mem_adicCompletionIntegers K)]
simp
end PowerSeries
end Comparison
end LaurentSeries |
.lake/packages/mathlib/Mathlib/RingTheory/PrincipalIdealDomainOfPrime.lean | import Mathlib.RingTheory.Ideal.Oka
import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# Principal ideal domains and prime ideals
## Main results
- `IsPrincipalIdealRing.of_prime`: a ring where all prime ideals are principal is a principal ideal
ring.
-/
variable {R : Type*} [CommSemiring R]
namespace Ideal
/-- `Submodule.IsPrincipal` is an Oka predicate. -/
theorem isOka_isPrincipal : IsOka (Submodule.IsPrincipal (R := R)) where
top := top_isPrincipal
oka {I a} := by
intro ⟨x, hx⟩ ⟨y, hy⟩
refine ⟨x * y, le_antisymm ?_ ?_⟩ <;> rw [submodule_span_eq] at *
· intro i hi
have hisup : i ∈ I ⊔ span {a} := mem_sup_left hi
have hasup : a ∈ I ⊔ span {a} := mem_sup_right (mem_span_singleton_self a)
rw [hx, mem_span_singleton'] at hisup hasup
obtain ⟨u, rfl⟩ := hisup
obtain ⟨v, rfl⟩ := hasup
obtain ⟨z, rfl⟩ : ∃ z, z * y = u := by
rw [← mem_span_singleton', ← hy, mem_colon_singleton, mul_comm v, ← mul_assoc]
exact mul_mem_right _ _ hi
exact mem_span_singleton'.2 ⟨z, by rw [mul_assoc, mul_comm y]⟩
· rw [← span_singleton_mul_span_singleton, ← hx, Ideal.sup_mul, sup_le_iff,
span_singleton_mul_span_singleton, mul_comm a, span_singleton_le_iff_mem]
exact ⟨mul_le_right, mem_colon_singleton.1 <| hy ▸ mem_span_singleton_self y⟩
end Ideal
open Ideal
/-- If all prime ideals in a commutative ring are principal, so are all other ideals. -/
theorem IsPrincipalIdealRing.of_prime (H : ∀ P : Ideal R, P.IsPrime → P.IsPrincipal) :
IsPrincipalIdealRing R := by
refine ⟨isOka_isPrincipal.forall_of_forall_prime (fun I hI ↦ exists_maximal_not_isPrincipal ?_) H⟩
rw [isPrincipalIdealRing_iff, not_forall]
exact ⟨I, hI⟩
/-- If all prime ideals in a commutative ring that are not `(0)` are principal,
so are all other ideals. -/
theorem IsPrincipalIdealRing.of_prime_ne_bot
(H : ∀ P : Ideal R, P.IsPrime → P ≠ ⊥ → P.IsPrincipal) :
IsPrincipalIdealRing R :=
.of_prime fun P hp ↦ (eq_or_ne P ⊥).elim (· ▸ inferInstance) <| H _ hp |
.lake/packages/mathlib/Mathlib/RingTheory/Idempotents.lean | import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Ring.GeomSum
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Nilpotent.Defs
/-!
## Idempotents in rings
The predicate `IsIdempotentElem` is defined for general monoids in `Algebra/Ring/Idempotents.lean`.
In this file we provide various results regarding idempotent elements in rings.
## Main definitions
- `OrthogonalIdempotents`:
A family `{ eᵢ }` of idempotent elements is orthogonal if `eᵢ * eⱼ = 0` for all `i ≠ j`.
- `CompleteOrthogonalIdempotents`:
A family `{ eᵢ }` of orthogonal idempotent elements is complete if `∑ eᵢ = 1`.
## Main results
- `CompleteOrthogonalIdempotents.lift_of_isNilpotent_ker`:
If the kernel of `f : R →+* S` consists of nilpotent elements, and `{ eᵢ }` is a family of
complete orthogonal idempotents in the range of `f`, then `{ eᵢ }` is the image of some
complete orthogonal idempotents in `R`.
- `existsUnique_isIdempotentElem_eq_of_ker_isNilpotent`:
If `R` is commutative and the kernel of `f : R →+* S` consists of nilpotent elements,
then every idempotent in the range of `f` lifts to a unique idempotent in `R`.
- `CompleteOrthogonalIdempotents.bijective_pi`:
If `R` is commutative, then a family `{ eᵢ }` of complete orthogonal idempotent elements induces
a ring isomorphism `R ≃ ∏ R ⧸ ⟨1 - eᵢ⟩`.
-/
section Semiring
variable {R S : Type*} [Semiring R] [Semiring S] (f : R →+* S)
variable {I : Type*} (e : I → R)
/-- A family `{ eᵢ }` of idempotent elements is orthogonal if `eᵢ * eⱼ = 0` for all `i ≠ j`. -/
@[mk_iff]
structure OrthogonalIdempotents : Prop where
idem : ∀ i, IsIdempotentElem (e i)
ortho : Pairwise (e · * e · = 0)
variable {e}
lemma OrthogonalIdempotents.mul_eq [DecidableEq I] (he : OrthogonalIdempotents e) (i j) :
e i * e j = if i = j then e i else 0 := by
split
· simp [*, (he.idem j).eq]
· exact he.ortho ‹_›
lemma OrthogonalIdempotents.iff_mul_eq [DecidableEq I] :
OrthogonalIdempotents e ↔ ∀ i j, e i * e j = if i = j then e i else 0 :=
⟨mul_eq, fun H ↦ ⟨fun i ↦ by simpa using H i i, fun i j e ↦ by simpa [e] using H i j⟩⟩
lemma OrthogonalIdempotents.isIdempotentElem_sum (he : OrthogonalIdempotents e) {s : Finset I} :
IsIdempotentElem (∑ i ∈ s, e i) := by
classical
simp [IsIdempotentElem, Finset.sum_mul, Finset.mul_sum, he.mul_eq]
lemma OrthogonalIdempotents.mul_sum_of_mem (he : OrthogonalIdempotents e)
{i : I} {s : Finset I} (h : i ∈ s) : e i * ∑ j ∈ s, e j = e i := by
classical
simp [Finset.mul_sum, he.mul_eq, h]
lemma OrthogonalIdempotents.mul_sum_of_notMem (he : OrthogonalIdempotents e)
{i : I} {s : Finset I} (h : i ∉ s) : e i * ∑ j ∈ s, e j = 0 := by
classical
simp [Finset.mul_sum, he.mul_eq, h]
@[deprecated (since := "2025-05-23")]
alias OrthogonalIdempotents.mul_sum_of_not_mem := OrthogonalIdempotents.mul_sum_of_notMem
lemma OrthogonalIdempotents.map (he : OrthogonalIdempotents e) :
OrthogonalIdempotents (f ∘ e) := by
classical
simp [iff_mul_eq, he.mul_eq, ← map_mul f, apply_ite f]
lemma OrthogonalIdempotents.map_injective_iff (hf : Function.Injective f) :
OrthogonalIdempotents (f ∘ e) ↔ OrthogonalIdempotents e := by
classical
simp [iff_mul_eq, ← hf.eq_iff, apply_ite]
lemma OrthogonalIdempotents.embedding (he : OrthogonalIdempotents e) {J} (i : J ↪ I) :
OrthogonalIdempotents (e ∘ i) := by
classical
simp [iff_mul_eq, he.mul_eq]
lemma OrthogonalIdempotents.equiv {J} (i : J ≃ I) :
OrthogonalIdempotents (e ∘ i) ↔ OrthogonalIdempotents e := by
classical
simp [iff_mul_eq, i.forall_congr_left]
lemma OrthogonalIdempotents.unique [Unique I] :
OrthogonalIdempotents e ↔ IsIdempotentElem (e default) := by
simp only [orthogonalIdempotents_iff, Unique.forall_iff, Subsingleton.pairwise, and_true]
lemma OrthogonalIdempotents.option (he : OrthogonalIdempotents e) [Fintype I] (x)
(hx : IsIdempotentElem x) (hx₁ : x * ∑ i, e i = 0) (hx₂ : (∑ i, e i) * x = 0) :
OrthogonalIdempotents (Option.elim · x e) where
idem i := i.rec hx he.idem
ortho i j ne := by
classical
rcases i with - | i <;> rcases j with - | j
· cases ne rfl
· simpa only [mul_assoc, Finset.sum_mul, he.mul_eq, Finset.sum_ite_eq', Finset.mem_univ,
↓reduceIte, zero_mul] using congr_arg (· * e j) hx₁
· simpa only [Option.elim_some, Option.elim_none, ← mul_assoc, Finset.mul_sum, he.mul_eq,
Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte, mul_zero] using congr_arg (e i * ·) hx₂
· exact he.ortho (Option.some_inj.ne.mp ne)
variable [Fintype I]
/--
A family `{ eᵢ }` of idempotent elements is complete orthogonal if
1. (orthogonal) `eᵢ * eⱼ = 0` for all `i ≠ j`.
2. (complete) `∑ eᵢ = 1`
-/
@[mk_iff]
structure CompleteOrthogonalIdempotents (e : I → R) : Prop extends OrthogonalIdempotents e where
complete : ∑ i, e i = 1
/-- If a family is complete orthogonal, it consists of idempotents. -/
lemma CompleteOrthogonalIdempotents.iff_ortho_complete :
CompleteOrthogonalIdempotents e ↔ Pairwise (e · * e · = 0) ∧ ∑ i, e i = 1 := by
rw [completeOrthogonalIdempotents_iff, orthogonalIdempotents_iff, and_assoc, and_iff_right_of_imp]
intro ⟨ortho, complete⟩ i
apply_fun (e i * ·) at complete
rwa [Finset.mul_sum, Finset.sum_eq_single i (fun _ _ ne ↦ ortho ne.symm) (by simp at ·), mul_one]
at complete
lemma CompleteOrthogonalIdempotents.pair_iff'ₛ {x y : R} :
CompleteOrthogonalIdempotents ![x, y] ↔ x * y = 0 ∧ y * x = 0 ∧ x + y = 1 := by
simp [iff_ortho_complete, Pairwise, Fin.forall_fin_two, and_assoc]
lemma CompleteOrthogonalIdempotents.pair_iffₛ {R} [CommSemiring R] {x y : R} :
CompleteOrthogonalIdempotents ![x, y] ↔ x * y = 0 ∧ x + y = 1 := by
rw [pair_iff'ₛ, and_left_comm, and_iff_right_of_imp]; exact (mul_comm x y ▸ ·.1)
lemma CompleteOrthogonalIdempotents.unique_iff [Unique I] :
CompleteOrthogonalIdempotents e ↔ e default = 1 := by
rw [completeOrthogonalIdempotents_iff, OrthogonalIdempotents.unique, Fintype.sum_unique,
and_iff_right_iff_imp]
exact (· ▸ IsIdempotentElem.one)
lemma CompleteOrthogonalIdempotents.single {I : Type*} [Fintype I] [DecidableEq I]
(R : I → Type*) [∀ i, Semiring (R i)] :
CompleteOrthogonalIdempotents (Pi.single (M := R) · 1) := by
refine ⟨⟨by simp [IsIdempotentElem, ← Pi.single_mul], ?_⟩, Finset.univ_sum_single 1⟩
intro i j hij
ext k
by_cases hi : i = k
· subst hi; simp [hij]
· simp [hi]
lemma CompleteOrthogonalIdempotents.map (he : CompleteOrthogonalIdempotents e) :
CompleteOrthogonalIdempotents (f ∘ e) where
__ := he.toOrthogonalIdempotents.map f
complete := by simp only [Function.comp_apply, ← map_sum, he.complete, map_one]
lemma CompleteOrthogonalIdempotents.map_injective_iff (hf : Function.Injective f) :
CompleteOrthogonalIdempotents (f ∘ e) ↔ CompleteOrthogonalIdempotents e := by
simp [completeOrthogonalIdempotents_iff, ← hf.eq_iff,
OrthogonalIdempotents.map_injective_iff f hf]
lemma CompleteOrthogonalIdempotents.equiv {J} [Fintype J] (i : J ≃ I) :
CompleteOrthogonalIdempotents (e ∘ i) ↔ CompleteOrthogonalIdempotents e := by
simp only [completeOrthogonalIdempotents_iff, OrthogonalIdempotents.equiv, Function.comp_apply,
Fintype.sum_equiv i _ e (fun _ ↦ rfl)]
@[nontriviality]
lemma CompleteOrthogonalIdempotents.of_subsingleton [Subsingleton R] :
CompleteOrthogonalIdempotents e :=
⟨⟨fun _ ↦ Subsingleton.elim _ _, fun _ _ _ ↦ Subsingleton.elim _ _⟩, Subsingleton.elim _ _⟩
end Semiring
section Ring
variable {R S : Type*} [Ring R] [Ring S] (f : R →+* S)
theorem isIdempotentElem_one_sub_one_sub_pow_pow
(x : R) (n : ℕ) (hx : (x - x ^ 2) ^ n = 0) :
IsIdempotentElem (1 - (1 - x ^ n) ^ n) := by
have : (x - x ^ 2) ^ n ∣ (1 - (1 - x ^ n) ^ n) - (1 - (1 - x ^ n) ^ n) ^ 2 := by
conv_rhs => rw [pow_two, ← mul_one_sub, sub_sub_cancel]
nth_rw 1 3 [← one_pow n]
rw [← (Commute.one_left x).mul_geom_sum₂, ← (Commute.one_left (1 - x ^ n)).mul_geom_sum₂]
simp only [sub_sub_cancel, one_pow, one_mul]
rw [Commute.mul_pow, Commute.mul_mul_mul_comm, ← Commute.mul_pow, mul_one_sub, ← pow_two]
· exact ⟨_, rfl⟩
· simp
· refine .pow_right (.sub_right (.one_right _) (.sum_left _ _ _ fun _ _ ↦ .pow_left ?_ _)) _
simp
· exact .sub_left (.one_left _) (.sum_right _ _ _ fun _ _ ↦ .pow_right rfl _)
rwa [hx, zero_dvd_iff, sub_eq_zero, eq_comm, pow_two] at this
theorem exists_isIdempotentElem_mul_eq_zero_of_ker_isNilpotent_aux
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
(e₁ : S) (he : e₁ ∈ f.range) (he₁ : IsIdempotentElem e₁)
(e₂ : R) (he₂ : IsIdempotentElem e₂) (he₁e₂ : e₁ * f e₂ = 0) :
∃ e' : R, IsIdempotentElem e' ∧ f e' = e₁ ∧ e' * e₂ = 0 := by
obtain ⟨e₁, rfl⟩ := he
cases subsingleton_or_nontrivial R
· exact ⟨_, Subsingleton.elim _ _, rfl, Subsingleton.elim _ _⟩
let a := e₁ - e₁ * e₂
have ha : f a = f e₁ := by rw [map_sub, map_mul, he₁e₂, sub_zero]
have ha' : a * e₂ = 0 := by rw [sub_mul, mul_assoc, he₂.eq, sub_self]
have hx' : a - a ^ 2 ∈ RingHom.ker f := by
simp [RingHom.mem_ker, pow_two, ha, he₁.eq]
obtain ⟨n, hn⟩ := h _ hx'
refine ⟨_, isIdempotentElem_one_sub_one_sub_pow_pow _ _ hn, ?_, ?_⟩
· rcases n with - | n
· simp at hn
simp only [map_sub, map_one, map_pow, ha, he₁.pow_succ_eq,
he₁.one_sub.pow_succ_eq, sub_sub_cancel]
· obtain ⟨k, hk⟩ := (Commute.one_left (MulOpposite.op <| 1 - a ^ n)).sub_dvd_pow_sub_pow n
apply_fun MulOpposite.unop at hk
have : 1 - (1 - a ^ n) ^ n = MulOpposite.unop k * a ^ n := by simpa using hk
rw [this, mul_assoc]
rcases n with - | n
· simp at hn
rw [pow_succ, mul_assoc, ha', mul_zero, mul_zero]
/-- Orthogonal idempotents lift along nil ideals. -/
theorem exists_isIdempotentElem_mul_eq_zero_of_ker_isNilpotent
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
(e₁ : S) (he : e₁ ∈ f.range) (he₁ : IsIdempotentElem e₁)
(e₂ : R) (he₂ : IsIdempotentElem e₂) (he₁e₂ : e₁ * f e₂ = 0) (he₂e₁ : f e₂ * e₁ = 0) :
∃ e' : R, IsIdempotentElem e' ∧ f e' = e₁ ∧ e' * e₂ = 0 ∧ e₂ * e' = 0 := by
obtain ⟨e', h₁, rfl, h₂⟩ := exists_isIdempotentElem_mul_eq_zero_of_ker_isNilpotent_aux
f h e₁ he he₁ e₂ he₂ he₁e₂
refine ⟨(1 - e₂) * e', ?_, ?_, ?_, ?_⟩
· rw [IsIdempotentElem, mul_assoc, ← mul_assoc e', mul_sub, mul_one, h₂, sub_zero, h₁.eq]
· rw [map_mul, map_sub, map_one, sub_mul, one_mul, he₂e₁, sub_zero]
· rw [mul_assoc, h₂, mul_zero]
· rw [← mul_assoc, mul_sub, mul_one, he₂.eq, sub_self, zero_mul]
/-- Idempotents lift along nil ideals. -/
theorem exists_isIdempotentElem_eq_of_ker_isNilpotent (h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
(e : S) (he : e ∈ f.range) (he' : IsIdempotentElem e) :
∃ e' : R, IsIdempotentElem e' ∧ f e' = e := by
simpa using exists_isIdempotentElem_mul_eq_zero_of_ker_isNilpotent f h e he he' 0 .zero (by simp)
lemma OrthogonalIdempotents.lift_of_isNilpotent_ker_aux
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
{n} {e : Fin n → S} (he : OrthogonalIdempotents e) (he' : ∀ i, e i ∈ f.range) :
∃ e' : Fin n → R, OrthogonalIdempotents e' ∧ f ∘ e' = e := by
induction n with
| zero => refine ⟨0, ⟨finZeroElim, finZeroElim⟩, funext finZeroElim⟩
| succ n IH =>
obtain ⟨e', h₁, h₂⟩ := IH (he.embedding (Fin.succEmb n)) (fun i ↦ he' _)
have h₂' (i) : f (e' i) = e i.succ := congr_fun h₂ i
obtain ⟨e₀, h₃, h₄, h₅, h₆⟩ :=
exists_isIdempotentElem_mul_eq_zero_of_ker_isNilpotent f h _ (he' 0) (he.idem 0) _
h₁.isIdempotentElem_sum
(by simp [Finset.mul_sum, h₂', he.mul_eq, eq_comm])
(by simp [Finset.sum_mul, h₂', he.mul_eq])
refine ⟨_, (h₁.option _ h₃ h₅ h₆).embedding (finSuccEquiv n).toEmbedding, funext fun i ↦ ?_⟩
obtain ⟨_ | i, rfl⟩ := (finSuccEquiv n).symm.surjective i <;> simp [*]
variable {I : Type*} {e : I → R}
/-- A family of orthogonal idempotents lift along nil ideals. -/
lemma OrthogonalIdempotents.lift_of_isNilpotent_ker [Finite I]
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
{e : I → S} (he : OrthogonalIdempotents e) (he' : ∀ i, e i ∈ f.range) :
∃ e' : I → R, OrthogonalIdempotents e' ∧ f ∘ e' = e := by
cases nonempty_fintype I
obtain ⟨e', h₁, h₂⟩ := lift_of_isNilpotent_ker_aux f h
(he.embedding (Fintype.equivFin I).symm.toEmbedding) (fun _ ↦ he' _)
refine ⟨_, h₁.embedding (Fintype.equivFin I).toEmbedding,
by ext x; simpa using congr_fun h₂ (Fintype.equivFin I x)⟩
lemma CompleteOrthogonalIdempotents.pair_iff {x y : R} :
CompleteOrthogonalIdempotents ![x, y] ↔ IsIdempotentElem x ∧ y = 1 - x := by
rw [pair_iff'ₛ, ← eq_sub_iff_add_eq', ← and_assoc, and_congr_left_iff]
rintro rfl
simp [mul_sub, sub_mul, IsIdempotentElem, sub_eq_zero, eq_comm]
lemma CompleteOrthogonalIdempotents.of_isIdempotentElem {e : R} (he : IsIdempotentElem e) :
CompleteOrthogonalIdempotents ![e, 1 - e] :=
pair_iff.mpr ⟨he, rfl⟩
variable [Fintype I]
lemma CompleteOrthogonalIdempotents.option (he : OrthogonalIdempotents e) :
CompleteOrthogonalIdempotents (Option.elim · (1 - ∑ i, e i) e) where
__ := he.option _ he.isIdempotentElem_sum.one_sub
(by simp [sub_mul, he.isIdempotentElem_sum.eq]) (by simp [mul_sub, he.isIdempotentElem_sum.eq])
complete := by
rw [Fintype.sum_option]
exact sub_add_cancel _ _
lemma CompleteOrthogonalIdempotents.lift_of_isNilpotent_ker_aux
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
{n} {e : Fin n → S} (he : CompleteOrthogonalIdempotents e) (he' : ∀ i, e i ∈ f.range) :
∃ e' : Fin n → R, CompleteOrthogonalIdempotents e' ∧ f ∘ e' = e := by
cases subsingleton_or_nontrivial R
· choose e' he' using he'
exact ⟨e', .of_subsingleton, funext he'⟩
cases subsingleton_or_nontrivial S
· obtain ⟨n, hn⟩ := h 1 (Subsingleton.elim _ _)
simp at hn
rcases n with - | n
· simpa using he.complete
obtain ⟨e', h₁, h₂⟩ := OrthogonalIdempotents.lift_of_isNilpotent_ker f h he.1 he'
refine ⟨_, (equiv (finSuccEquiv n)).mpr
(CompleteOrthogonalIdempotents.option (h₁.embedding (Fin.succEmb _))), funext fun i ↦ ?_⟩
have (i : _) : f (e' i) = e i := congr_fun h₂ i
cases i using Fin.cases with
| zero => simp [this, Fin.sum_univ_succ, ← he.complete]
| succ i => simp [this]
/-- A system of complete orthogonal idempotents lift along nil ideals. -/
lemma CompleteOrthogonalIdempotents.lift_of_isNilpotent_ker
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
{e : I → S} (he : CompleteOrthogonalIdempotents e) (he' : ∀ i, e i ∈ f.range) :
∃ e' : I → R, CompleteOrthogonalIdempotents e' ∧ f ∘ e' = e := by
obtain ⟨e', h₁, h₂⟩ := lift_of_isNilpotent_ker_aux f h
((equiv (Fintype.equivFin I).symm).mpr he) (fun _ ↦ he' _)
refine ⟨_, ((equiv (Fintype.equivFin I)).mpr h₁),
by ext x; simpa using congr_fun h₂ (Fintype.equivFin I x)⟩
theorem eq_of_isNilpotent_sub_of_isIdempotentElem_of_commute {e₁ e₂ : R}
(he₁ : IsIdempotentElem e₁) (he₂ : IsIdempotentElem e₂) (H : IsNilpotent (e₁ - e₂))
(H' : Commute e₁ e₂) :
e₁ = e₂ := by
have : (e₁ - e₂) ^ 3 = (e₁ - e₂) := by
simp only [pow_succ, pow_zero, mul_sub, one_mul, sub_mul, he₁.eq, he₂.eq,
H'.eq, mul_assoc]
simp only [← mul_assoc, he₂.eq]
abel
obtain ⟨n, hn⟩ := H
have : (e₁ - e₂) ^ (2 * n + 1) = (e₁ - e₂) := by
clear hn; induction n <;> simp [mul_add, add_assoc, pow_add _ (2 * _) 3, ← pow_succ, *]
rwa [pow_succ, two_mul, pow_add, hn, zero_mul, zero_mul, eq_comm, sub_eq_zero] at this
theorem CompleteOrthogonalIdempotents.of_ker_isNilpotent_of_isMulCentral
(h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
(he : ∀ i, IsIdempotentElem (e i))
(he' : ∀ i, IsMulCentral (e i))
(he'' : CompleteOrthogonalIdempotents (f ∘ e)) :
CompleteOrthogonalIdempotents e := by
obtain ⟨e', h₁, h₂⟩ := lift_of_isNilpotent_ker f h he'' (fun _ ↦ ⟨_, rfl⟩)
obtain rfl : e = e' := by
ext i
refine eq_of_isNilpotent_sub_of_isIdempotentElem_of_commute
(he _) (h₁.idem _) (h _ ?_) ((he' i).comm _)
simpa [RingHom.mem_ker, sub_eq_zero] using congr_fun h₂.symm i
exact h₁
end Ring
section CommRing
variable {R S : Type*} [CommRing R] [Ring S] (f : R →+* S)
theorem eq_of_isNilpotent_sub_of_isIdempotentElem {e₁ e₂ : R}
(he₁ : IsIdempotentElem e₁) (he₂ : IsIdempotentElem e₂) (H : IsNilpotent (e₁ - e₂)) :
e₁ = e₂ :=
eq_of_isNilpotent_sub_of_isIdempotentElem_of_commute he₁ he₂ H (.all _ _)
@[stacks 00J9]
theorem existsUnique_isIdempotentElem_eq_of_ker_isNilpotent (h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
(e : S) (he : e ∈ f.range) (he' : IsIdempotentElem e) :
∃! e' : R, IsIdempotentElem e' ∧ f e' = e := by
obtain ⟨e', he₂, rfl⟩ := exists_isIdempotentElem_eq_of_ker_isNilpotent f h e he he'
exact ⟨e', ⟨he₂, rfl⟩, fun x ⟨hx, hx'⟩ ↦
eq_of_isNilpotent_sub_of_isIdempotentElem hx he₂
(h _ (by rw [RingHom.mem_ker, map_sub, hx', sub_self]))⟩
/-- A family of orthogonal idempotents induces an surjection `R ≃+* ∏ R ⧸ ⟨1 - eᵢ⟩` -/
lemma OrthogonalIdempotents.surjective_pi {I : Type*} [Finite I] {e : I → R}
(he : OrthogonalIdempotents e) :
Function.Surjective (Pi.ringHom fun i ↦ Ideal.Quotient.mk (Ideal.span {1 - e i})) := by
suffices Pairwise fun i j ↦ IsCoprime (Ideal.span {1 - e i}) (Ideal.span {1 - e j}) by
intro x
obtain ⟨x, rfl⟩ := Ideal.quotientInfToPiQuotient_surj this x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
exact ⟨x, by ext i; simp [Ideal.quotientInfToPiQuotient]⟩
intro i j hij
rw [Ideal.isCoprime_span_singleton_iff]
exact ⟨1, e i, by simp [mul_sub, he.ortho hij]⟩
lemma OrthogonalIdempotents.prod_one_sub {I : Type*} {e : I → R}
(he : OrthogonalIdempotents e) (s : Finset I) :
∏ i ∈ s, (1 - e i) = 1 - ∑ i ∈ s, e i := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s has ih =>
simp [ih, sub_mul, mul_sub, he.mul_sum_of_notMem has, sub_sub]
variable {I : Type*} [Fintype I] {e : I → R}
theorem CompleteOrthogonalIdempotents.of_ker_isNilpotent (h : ∀ x ∈ RingHom.ker f, IsNilpotent x)
(he : ∀ i, IsIdempotentElem (e i))
(he' : CompleteOrthogonalIdempotents (f ∘ e)) :
CompleteOrthogonalIdempotents e :=
of_ker_isNilpotent_of_isMulCentral f h he
(fun _ ↦ Semigroup.mem_center_iff.mpr (mul_comm · _)) he'
lemma CompleteOrthogonalIdempotents.prod_one_sub
(he : CompleteOrthogonalIdempotents e) :
∏ i, (1 - e i) = 0 := by
rw [he.1.prod_one_sub, he.complete, sub_self]
lemma CompleteOrthogonalIdempotents.of_prod_one_sub
(he : OrthogonalIdempotents e) (he' : ∏ i, (1 - e i) = 0) :
CompleteOrthogonalIdempotents e where
__ := he
complete := by rwa [he.prod_one_sub, sub_eq_zero, eq_comm] at he'
/-- A family of complete orthogonal idempotents induces an isomorphism `R ≃+* ∏ R ⧸ ⟨1 - eᵢ⟩` -/
lemma CompleteOrthogonalIdempotents.bijective_pi (he : CompleteOrthogonalIdempotents e) :
Function.Bijective (Pi.ringHom fun i ↦ Ideal.Quotient.mk (Ideal.span {1 - e i})) := by
classical
refine ⟨?_, he.1.surjective_pi⟩
rw [injective_iff_map_eq_zero]
intro x hx
simp [funext_iff, Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton] at hx
suffices ∀ s : Finset I, (∏ i ∈ s, (1 - e i)) * x = x by
rw [← this Finset.univ, he.prod_one_sub, zero_mul]
refine fun s ↦ Finset.induction_on s (by simp) ?_
intro a s has e'
suffices (1 - e a) * x = x by simp [has, mul_assoc, e', this]
obtain ⟨c, rfl⟩ := hx a
rw [← mul_assoc, (he.idem a).one_sub.eq]
lemma CompleteOrthogonalIdempotents.bijective_pi' (he : CompleteOrthogonalIdempotents (1 - e ·)) :
Function.Bijective (Pi.ringHom fun i ↦ Ideal.Quotient.mk (Ideal.span {e i})) := by
obtain ⟨e', rfl, h⟩ : ∃ e' : I → R, (e' = e) ∧ Function.Bijective (Pi.ringHom fun i ↦
Ideal.Quotient.mk (Ideal.span {e' i})) := ⟨_, funext (by simp), he.bijective_pi⟩
exact h
lemma RingHom.pi_bijective_of_isIdempotentElem (e : I → R)
(he : ∀ i, IsIdempotentElem (e i))
(he₁ : ∀ i j, i ≠ j → (1 - e i) * (1 - e j) = 0) (he₂ : ∏ i, e i = 0) :
Function.Bijective (Pi.ringHom fun i ↦ Ideal.Quotient.mk (Ideal.span {e i})) :=
(CompleteOrthogonalIdempotents.of_prod_one_sub
⟨fun i ↦ (he i).one_sub, he₁⟩ (by simpa using he₂)).bijective_pi'
lemma RingHom.prod_bijective_of_isIdempotentElem {e f : R} (he : IsIdempotentElem e)
(hf : IsIdempotentElem f) (hef₁ : e + f = 1) (hef₂ : e * f = 0) :
Function.Bijective ((Ideal.Quotient.mk <| Ideal.span {e}).prod
(Ideal.Quotient.mk <| Ideal.span {f})) := by
let o (i : Fin 2) : R := match i with
| 0 => e
| 1 => f
change Function.Bijective
(piFinTwoEquiv _ ∘ Pi.ringHom (fun i : Fin 2 ↦ Ideal.Quotient.mk (Ideal.span {o i})))
rw [(Equiv.bijective _).of_comp_iff']
apply pi_bijective_of_isIdempotentElem
· intro i
fin_cases i <;> simpa [o]
· intro i j hij
fin_cases i <;> fin_cases j <;> simp at hij ⊢ <;>
simp [o, mul_comm, hef₂, ← hef₁]
· simpa
variable (R) in
/-- If `e` and `f` are idempotent elements such that `e + f = 1` and `e * f = 0`,
`S` is isomorphic as an `R`-algebra to `S ⧸ (e) × S ⧸ (f)`. -/
@[simps! -isSimp apply, simps! apply_fst apply_snd]
noncomputable def AlgEquiv.prodQuotientOfIsIdempotentElem
{S : Type*} [CommRing S] [Algebra R S] {e f : S} (he : IsIdempotentElem e)
(hf : IsIdempotentElem f) (hef₁ : e + f = 1) (hef₂ : e * f = 0) :
S ≃ₐ[R] (S ⧸ Ideal.span {e}) × S ⧸ Ideal.span {f} :=
AlgEquiv.ofBijective ((Ideal.Quotient.mkₐ _ _).prod (Ideal.Quotient.mkₐ _ _)) <|
RingHom.prod_bijective_of_isIdempotentElem he hf hef₁ hef₂
end CommRing
section corner
variable {R : Type*} (e : R)
namespace Subsemigroup
variable [Semigroup R]
/-- The corner associated to an element `e` in a semigroup
is the subsemigroup of all elements of the form `e * r * e`. -/
def corner : Subsemigroup R where
carrier := Set.range (e * · * e)
mul_mem' := by rintro _ _ ⟨a, rfl⟩ ⟨b, rfl⟩; exact ⟨a * e * e * b, by simp_rw [mul_assoc]⟩
variable {e} (idem : IsIdempotentElem e)
include idem
lemma mem_corner_iff {r : R} : r ∈ corner e ↔ e * r = r ∧ r * e = r :=
⟨by rintro ⟨r, rfl⟩; simp_rw [← mul_assoc, idem.eq, mul_assoc, idem.eq, true_and],
(⟨r, by simp_rw [·]⟩)⟩
lemma mem_corner_iff_mul_left (hc : IsMulCentral e) {r : R} : r ∈ corner e ↔ e * r = r := by
rw [mem_corner_iff idem, and_iff_left_of_imp]; intro; rwa [← hc.comm]
lemma mem_corner_iff_mul_right (hc : IsMulCentral e) {r : R} : r ∈ corner e ↔ r * e = r := by
rw [mem_corner_iff_mul_left idem hc, hc.comm]
lemma mem_corner_iff_mem_range_mul_left (hc : IsMulCentral e) {r : R} :
r ∈ corner e ↔ r ∈ Set.range (e * ·) := by
simp_rw [corner, mem_mk, Set.mem_range, ← (hc.comm _).eq, ← mul_assoc, idem.eq]
lemma mem_corner_iff_mem_range_mul_right (hc : IsMulCentral e) {r : R} :
r ∈ corner e ↔ r ∈ Set.range (· * e) := by
simp_rw [mem_corner_iff_mem_range_mul_left idem hc, (hc.comm _).eq]
/-- The corner associated to an idempotent `e` in a semiring without 1
is the semiring with `e` as 1 consisting of all element of the form `e * r * e`. -/
@[nolint unusedArguments]
def _root_.IsIdempotentElem.Corner (_ : IsIdempotentElem e) : Type _ := Subsemigroup.corner e
end Subsemigroup
/-- The corner associated to an element `e` in a semiring without 1
is the subsemiring without 1 of all elements of the form `e * r * e`. -/
def NonUnitalSubsemiring.corner [NonUnitalSemiring R] : NonUnitalSubsemiring R where
__ := Subsemigroup.corner e
add_mem' := by rintro _ _ ⟨a, rfl⟩ ⟨b, rfl⟩; exact ⟨a + b, by simp_rw [mul_add, add_mul]⟩
zero_mem' := ⟨0, by simp_rw [mul_zero, zero_mul]⟩
/-- The corner associated to an element `e` in a ring without `
is the subring without 1 of all elements of the form `e * r * e`. -/
def NonUnitalRing.corner [NonUnitalRing R] : NonUnitalSubring R where
__ := NonUnitalSubsemiring.corner e
neg_mem' := by rintro _ ⟨a, rfl⟩; exact ⟨-a, by simp_rw [mul_neg, neg_mul]⟩
instance [NonUnitalSemiring R] (idem : IsIdempotentElem e) : Semiring idem.Corner where
__ : NonUnitalSemiring (NonUnitalSubsemiring.corner e) := inferInstance
one := ⟨e, e, by simp_rw [idem.eq]⟩
one_mul r := Subtype.ext ((Subsemigroup.mem_corner_iff idem).mp r.2).1
mul_one r := Subtype.ext ((Subsemigroup.mem_corner_iff idem).mp r.2).2
instance [NonUnitalCommSemiring R] (idem : IsIdempotentElem e) : CommSemiring idem.Corner where
__ : NonUnitalCommSemiring (NonUnitalSubsemiring.corner e) := inferInstance
__ : Semiring idem.Corner := inferInstance
instance [NonUnitalRing R] (idem : IsIdempotentElem e) : Ring idem.Corner where
__ : NonUnitalRing (NonUnitalRing.corner e) := inferInstance
__ : Semiring idem.Corner := inferInstance
instance [NonUnitalCommRing R] (idem : IsIdempotentElem e) : CommRing idem.Corner where
__ : NonUnitalCommRing (NonUnitalRing.corner e) := inferInstance
__ : Semiring idem.Corner := inferInstance
variable {I : Type*} [Fintype I] {e : I → R}
/-- A complete orthogonal family of central idempotents in a semiring
give rise to a direct product decomposition. -/
def CompleteOrthogonalIdempotents.ringEquivOfIsMulCentral [Semiring R]
(he : CompleteOrthogonalIdempotents e) (hc : ∀ i, IsMulCentral (e i)) :
R ≃+* Π i, (he.idem i).Corner where
toFun r i := ⟨_, r, rfl⟩
invFun r := ∑ i, (r i).1
left_inv r := by
simp_rw [((hc _).comm _).eq, mul_assoc, (he.idem _).eq, ← Finset.mul_sum, he.complete, mul_one]
right_inv r := funext fun i ↦ Subtype.ext <| by
simp_rw [Finset.mul_sum, Finset.sum_mul]
rw [Finset.sum_eq_single i _ (by simp at ·)]
· have ⟨r', eq⟩ := (r i).2
rw [← eq]; simp_rw [← mul_assoc, (he.idem i).eq, mul_assoc, (he.idem i).eq]
· intro j _ ne; have ⟨r', eq⟩ := (r j).2
rw [← eq]; simp_rw [← mul_assoc, he.ortho ne.symm, zero_mul]
map_mul' r₁ r₂ := funext fun i ↦ Subtype.ext <|
calc e i * (r₁ * r₂) * e i
_ = e i * (r₁ * e i * r₂) * e i := by
simp_rw [← ((hc i).comm r₁).eq, ← mul_assoc, (he.idem i).eq]
_ = e i * r₁ * e i * (e i * r₂ * e i) := by
conv in (r₁ * _ * r₂) => rw [← (he.idem i).eq]
simp_rw [mul_assoc]
map_add' r₁ r₂ := funext fun i ↦ Subtype.ext <| by simpa [mul_add] using add_mul ..
/-- A complete orthogonal family of idempotents in a commutative semiring
give rise to a direct product decomposition. -/
def CompleteOrthogonalIdempotents.ringEquivOfComm [CommSemiring R]
(he : CompleteOrthogonalIdempotents e) : R ≃+* Π i, (he.idem i).Corner :=
he.ringEquivOfIsMulCentral fun _ ↦ Semigroup.mem_center_iff.mpr fun _ ↦ mul_comm ..
end corner |
.lake/packages/mathlib/Mathlib/RingTheory/Nullstellensatz.lean | import Mathlib.RingTheory.Jacobson.Ring
import Mathlib.FieldTheory.IsAlgClosed.Basic
import Mathlib.RingTheory.Spectrum.Prime.Basic
/-!
# Nullstellensatz
This file establishes a version of Hilbert's classical Nullstellensatz for `MvPolynomial`s.
The main statement of the theorem is `MvPolynomial.vanishingIdeal_zeroLocus_eq_radical`.
The statement is in terms of new definitions `vanishingIdeal` and `zeroLocus`.
Mathlib already has versions of these in terms of the prime spectrum of a ring,
but those are not well-suited for expressing this result.
Suggestions for better ways to state this theorem or organize things are welcome.
The machinery around `vanishingIdeal` and `zeroLocus` is also minimal, I only added lemmas
directly needed in this proof, since I'm not sure if they are the right approach.
-/
open Ideal
noncomputable section
namespace MvPolynomial
variable {k K : Type*} [Field k] [Field K] [Algebra k K]
variable {σ : Type*}
variable (K) in
/-- Set of points that are zeroes of all polynomials in an ideal -/
def zeroLocus (I : Ideal (MvPolynomial σ k)) : Set (σ → K) :=
{x : σ → K | ∀ p ∈ I, aeval x p = 0}
@[simp]
theorem mem_zeroLocus_iff {I : Ideal (MvPolynomial σ k)} {x : σ → K} :
x ∈ zeroLocus K I ↔ ∀ p ∈ I, aeval x p = 0 :=
Iff.rfl
theorem zeroLocus_anti_mono {I J : Ideal (MvPolynomial σ k)} (h : I ≤ J) :
zeroLocus K J ≤ zeroLocus K I := fun _ hx p hp => hx p <| h hp
@[simp]
theorem zeroLocus_bot : zeroLocus K (⊥ : Ideal (MvPolynomial σ k)) = ⊤ :=
eq_top_iff.2 fun x _ _ hp => Trans.trans (congr_arg (aeval x) (mem_bot.1 hp)) (eval x).map_zero
@[simp]
theorem zeroLocus_top : zeroLocus K (⊤ : Ideal (MvPolynomial σ k)) = ⊥ :=
eq_bot_iff.2 fun x hx => one_ne_zero
((aeval (R := k) x).map_one ▸ hx 1 Submodule.mem_top : (1 : K) = 0)
variable (k) in
/-- Ideal of polynomials with common zeroes at all elements of a set -/
def vanishingIdeal (V : Set (σ → K)) : Ideal (MvPolynomial σ k) where
carrier := {p | ∀ x ∈ V, aeval x p = 0}
zero_mem' _ _ := RingHom.map_zero _
add_mem' {p q} hp hq x hx := by simp only [hq x hx, hp x hx, add_zero, map_add]
smul_mem' p q hq x hx := by
simp only [hq x hx, Algebra.id.smul_eq_mul, mul_zero, map_mul]
@[simp]
theorem mem_vanishingIdeal_iff {V : Set (σ → K)} {p : MvPolynomial σ k} :
p ∈ vanishingIdeal k V ↔ ∀ x ∈ V, aeval x p = 0 :=
Iff.rfl
theorem vanishingIdeal_anti_mono {A B : Set (σ → K)} (h : A ≤ B) :
vanishingIdeal k B ≤ vanishingIdeal k A := fun _ hp x hx => hp x <| h hx
theorem vanishingIdeal_empty : vanishingIdeal k (∅ : Set (σ → K)) = ⊤ :=
le_antisymm le_top fun _ _ x hx => absurd hx (Set.notMem_empty x)
theorem le_vanishingIdeal_zeroLocus (I : Ideal (MvPolynomial σ k)) :
I ≤ vanishingIdeal k (zeroLocus K I) := fun p hp _ hx => hx p hp
theorem zeroLocus_vanishingIdeal_le (V : Set (σ → K)) : V ≤ zeroLocus K (vanishingIdeal k V) :=
fun V hV _ hp => hp V hV
theorem zeroLocus_vanishingIdeal_galoisConnection :
@GaloisConnection (Ideal (MvPolynomial σ k)) (Set (σ → K))ᵒᵈ _ _
(zeroLocus K) (vanishingIdeal k) :=
GaloisConnection.monotone_intro (fun _ _ ↦ vanishingIdeal_anti_mono)
(fun _ _ ↦ zeroLocus_anti_mono) le_vanishingIdeal_zeroLocus zeroLocus_vanishingIdeal_le
theorem le_zeroLocus_iff_le_vanishingIdeal {V : Set (σ → K)} {I : Ideal (MvPolynomial σ k)} :
V ≤ zeroLocus K I ↔ I ≤ vanishingIdeal k V :=
zeroLocus_vanishingIdeal_galoisConnection.le_iff_le
theorem zeroLocus_span (S : Set (MvPolynomial σ k)) :
zeroLocus K (Ideal.span S) = { x | ∀ p ∈ S, aeval x p = 0 } :=
eq_of_forall_le_iff fun _ => le_zeroLocus_iff_le_vanishingIdeal.trans <|
Ideal.span_le.trans forall₂_swap
theorem mem_vanishingIdeal_singleton_iff (x : σ → K) (p : MvPolynomial σ k) :
p ∈ (vanishingIdeal k {x} : Ideal (MvPolynomial σ k)) ↔ aeval x p = 0 :=
⟨fun h => h x rfl, fun hpx _ hy => hy.symm ▸ hpx⟩
instance {x : σ → K} : (vanishingIdeal k {x} : Ideal (MvPolynomial σ k)).IsPrime := by
convert RingHom.ker_isPrime (aeval (R := k) x)
ext; simp
instance {x : σ → K} : (vanishingIdeal K {x} : Ideal (MvPolynomial σ K)).IsMaximal := by
convert RingHom.ker_isMaximal_of_surjective (aeval (R := K) x) ?_
· ext; simp
· intro z; use C z; simp
theorem radical_le_vanishingIdeal_zeroLocus (I : Ideal (MvPolynomial σ k)) :
I.radical ≤ vanishingIdeal k (zeroLocus K I) := by
intro p hp x hx
rw [← mem_vanishingIdeal_singleton_iff]
rw [radical_eq_sInf] at hp
refine
(mem_sInf.mp hp)
⟨le_trans (le_vanishingIdeal_zeroLocus I)
(vanishingIdeal_anti_mono fun y hy => hy.symm ▸ hx),
inferInstance⟩
/-- The point in the prime spectrum associated to a given point -/
def pointToPoint (x : σ → K) : PrimeSpectrum (MvPolynomial σ k) :=
⟨(vanishingIdeal k {x} : Ideal (MvPolynomial σ k)), by infer_instance⟩
@[simp]
theorem vanishingIdeal_pointToPoint (V : Set (σ → K)) :
PrimeSpectrum.vanishingIdeal (pointToPoint '' V) = MvPolynomial.vanishingIdeal k V :=
le_antisymm
(fun _ hp x hx =>
(((PrimeSpectrum.mem_vanishingIdeal _ _).1 hp) ⟨vanishingIdeal k {x}, by infer_instance⟩
(⟨x, hx, rfl⟩ : _))
x rfl)
fun _ hp =>
(PrimeSpectrum.mem_vanishingIdeal _ _).2 fun _ hI =>
let ⟨x, hx⟩ := hI
hx.2 ▸ fun _ hx' => (Set.mem_singleton_iff.1 hx').symm ▸ hp x hx.1
theorem pointToPoint_zeroLocus_le (I : Ideal (MvPolynomial σ K)) :
pointToPoint (k := K) '' MvPolynomial.zeroLocus K I ≤ PrimeSpectrum.zeroLocus I := fun J hJ =>
let ⟨_, hx⟩ := hJ
(le_trans (le_vanishingIdeal_zeroLocus (K := K) I)
(hx.2 ▸ vanishingIdeal_anti_mono (Set.singleton_subset_iff.2 hx.1)) :
I ≤ J.asIdeal)
variable [IsAlgClosed K] [Finite σ]
variable (K) in
theorem eq_vanishingIdeal_singleton_of_isMaximal {I : Ideal (MvPolynomial σ k)} (hI : I.IsMaximal) :
∃ x : σ → K, I = vanishingIdeal k {x} := by
let : Field (MvPolynomial σ k ⧸ I) := Quotient.field I
have : Algebra.IsAlgebraic k (MvPolynomial σ k ⧸ I) := by
rw [Algebra.isAlgebraic_iff_isIntegral, ← algebraMap_isIntegral_iff]
exact MvPolynomial.comp_C_integral_of_surjective_of_isJacobsonRing
(Ideal.Quotient.mk I) Ideal.Quotient.mk_surjective
let φ : (MvPolynomial σ k ⧸ I) →ₐ[k] K := IsAlgClosed.lift
let x : σ → K := fun s => φ (Ideal.Quotient.mk I (X s))
have : aeval x = φ.comp (Quotient.mkₐ k I) := by ext; simp [x]
use x
simp [Ideal.ext_iff, this, Ideal.Quotient.eq_zero_iff_mem]
theorem isMaximal_iff_eq_vanishingIdeal_singleton {I : Ideal (MvPolynomial σ K)} :
I.IsMaximal ↔ ∃ x : σ → K, I = vanishingIdeal K {x} :=
⟨eq_vanishingIdeal_singleton_of_isMaximal K,
fun ⟨_, hx⟩ => hx ▸ inferInstance⟩
/-- Main statement of the Nullstellensatz -/
@[simp]
theorem vanishingIdeal_zeroLocus_eq_radical (I : Ideal (MvPolynomial σ k)) :
vanishingIdeal k (zeroLocus K I) = I.radical := by
refine le_antisymm ?_ (radical_le_vanishingIdeal_zeroLocus _)
rw [I.radical_eq_jacobson]
apply le_sInf
rintro J ⟨hJI, hJ⟩
obtain ⟨x, hx⟩ := eq_vanishingIdeal_singleton_of_isMaximal K hJ
refine hx.symm ▸ vanishingIdeal_anti_mono fun y hy p hp => ?_
rw [← mem_vanishingIdeal_singleton_iff, Set.mem_singleton_iff.1 hy, ← hx]
exact hJI hp
@[simp high] -- This needs to fire before `vanishingIdeal_zeroLocus_eq_radical`
theorem IsPrime.vanishingIdeal_zeroLocus (P : Ideal (MvPolynomial σ k)) [h : P.IsPrime] :
vanishingIdeal k (zeroLocus K P) = P :=
Trans.trans (vanishingIdeal_zeroLocus_eq_radical P) h.radical
end MvPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/DualNumber.lean | import Mathlib.Algebra.DualNumber
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.RingTheory.Nilpotent.Defs
/-!
# Algebraic properties of dual numbers
## Main results
* `DualNumber.instLocalRing`: The dual numbers over a field `K` form a local ring.
* `DualNumber.instPrincipalIdealRing`: The dual numbers over a field `K` form a principal ideal
ring.
-/
namespace TrivSqZeroExt
variable {R M : Type*}
section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M]
lemma isNilpotent_iff_isNilpotent_fst {x : TrivSqZeroExt R M} :
IsNilpotent x ↔ IsNilpotent x.fst := by
constructor <;> rintro ⟨n, hn⟩
· refine ⟨n, ?_⟩
rw [← fst_pow, hn, fst_zero]
· refine ⟨n * 2, ?_⟩
rw [pow_mul]
ext
· rw [fst_pow, fst_pow, hn, zero_pow two_ne_zero, fst_zero]
· rw [pow_two, snd_mul, fst_pow, hn, MulOpposite.op_zero, zero_smul, zero_smul, zero_add,
snd_zero]
@[simp]
lemma isNilpotent_inl_iff (r : R) : IsNilpotent (.inl r : TrivSqZeroExt R M) ↔ IsNilpotent r := by
rw [isNilpotent_iff_isNilpotent_fst, fst_inl]
@[simp]
lemma isNilpotent_inr (x : M) : IsNilpotent (.inr x : TrivSqZeroExt R M) := by
refine ⟨2, by simp [pow_two]⟩
end Semiring
lemma isUnit_or_isNilpotent_of_isMaximal_isNilpotent [CommSemiring R] [AddCommGroup M]
[Module R M] [Module Rᵐᵒᵖ M] [IsCentralScalar R M]
(h : ∀ I : Ideal R, I.IsMaximal → IsNilpotent I)
(a : TrivSqZeroExt R M) :
IsUnit a ∨ IsNilpotent a := by
rw [isUnit_iff_isUnit_fst, isNilpotent_iff_isNilpotent_fst]
refine (em _).imp_right fun ha ↦ ?_
obtain ⟨I, hI, haI⟩ := exists_max_ideal_of_mem_nonunits (mem_nonunits_iff.mpr ha)
refine (h _ hI).imp fun n hn ↦ ?_
exact hn.le (Ideal.pow_mem_pow haI _)
lemma isUnit_or_isNilpotent [DivisionSemiring R] [AddCommGroup M]
[Module R M] [Module Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M]
(a : TrivSqZeroExt R M) :
IsUnit a ∨ IsNilpotent a := by
simp [isUnit_iff_isUnit_fst, isNilpotent_iff_isNilpotent_fst, em']
end TrivSqZeroExt
namespace DualNumber
variable {R : Type*}
lemma fst_eq_zero_iff_eps_dvd [Semiring R] {x : R[ε]} :
x.fst = 0 ↔ ε ∣ x := by
simp_rw [dvd_def, TrivSqZeroExt.ext_iff, TrivSqZeroExt.fst_mul, TrivSqZeroExt.snd_mul,
fst_eps, snd_eps, zero_mul, zero_smul, zero_add, MulOpposite.smul_eq_mul_unop,
MulOpposite.unop_op, one_mul, exists_and_left, iff_self_and]
intro
exact ⟨.inl x.snd, rfl⟩
lemma isNilpotent_eps [Semiring R] :
IsNilpotent (ε : R[ε]) :=
TrivSqZeroExt.isNilpotent_inr 1
open TrivSqZeroExt
lemma isNilpotent_iff_eps_dvd [DivisionSemiring R] {x : R[ε]} :
IsNilpotent x ↔ ε ∣ x := by
simp only [isNilpotent_iff_isNilpotent_fst, isNilpotent_iff_eq_zero, fst_eq_zero_iff_eps_dvd]
section Field
variable {K : Type*}
instance [DivisionRing K] : IsLocalRing K[ε] where
isUnit_or_isUnit_of_add_one {a b} h := by
rw [add_comm, ← eq_sub_iff_add_eq] at h
rcases eq_or_ne (fst a) 0 with ha|ha <;>
simp [isUnit_iff_isUnit_fst, h, ha]
lemma ideal_trichotomy [DivisionRing K] (I : Ideal K[ε]) :
I = ⊥ ∨ I = .span {ε} ∨ I = ⊤ := by
refine (eq_or_ne I ⊥).imp_right fun hb ↦ ?_
refine (eq_or_ne I ⊤).symm.imp_left fun ht ↦ ?_
have hd : ∀ x ∈ I, ε ∣ x := by
intro x hxI
rcases isUnit_or_isNilpotent x with hx | hx
· exact absurd (Ideal.eq_top_of_isUnit_mem _ hxI hx) ht
· rwa [← isNilpotent_iff_eps_dvd]
have hd' : ∀ x ∈ I, x ≠ 0 → ∃ r, ε = r * x := by
intro x hxI hx0
obtain ⟨r, rfl⟩ := hd _ hxI
have : ε * r = (fst r) • ε := by ext <;> simp
rw [this] at hxI hx0 ⊢
have hr : fst r ≠ 0 := by
contrapose! hx0
simp [hx0]
refine ⟨r⁻¹, ?_⟩
simp [TrivSqZeroExt.ext_iff, inv_mul_cancel₀ hr]
refine le_antisymm ?_ ?_ <;> intro x <;>
simp_rw [Ideal.mem_span_singleton', (commute_eps_right _).eq, eq_comm, ← dvd_def]
· intro hx
simp_rw [hd _ hx]
· intro hx
obtain ⟨p, rfl⟩ := hx
obtain ⟨y, hyI, hy0⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hb
obtain ⟨r, hr⟩ := hd' _ hyI hy0
rw [(commute_eps_left _).eq, hr, ← mul_assoc]
exact Ideal.mul_mem_left _ _ hyI
lemma isMaximal_span_singleton_eps [DivisionRing K] :
(Ideal.span {ε} : Ideal K[ε]).IsMaximal := by
refine ⟨?_, fun I hI ↦ ?_⟩
· simp [ne_eq, Ideal.eq_top_iff_one, Ideal.mem_span_singleton', TrivSqZeroExt.ext_iff]
· rcases ideal_trichotomy I with rfl | rfl | rfl <;>
first | simp at hI | simp
lemma maximalIdeal_eq_span_singleton_eps [Field K] :
IsLocalRing.maximalIdeal K[ε] = Ideal.span {ε} :=
(IsLocalRing.eq_maximalIdeal isMaximal_span_singleton_eps).symm
instance [DivisionRing K] : IsPrincipalIdealRing K[ε] where
principal I := by
rcases ideal_trichotomy I with rfl | rfl | rfl
· exact bot_isPrincipal
· exact ⟨_, rfl⟩
· exact top_isPrincipal
lemma exists_mul_left_or_mul_right [DivisionRing K] (a b : K[ε]) :
∃ c, a * c = b ∨ b * c = a := by
rcases isUnit_or_isNilpotent a with ha | ha
· lift a to K[ε]ˣ using ha
exact ⟨a⁻¹ * b, by simp⟩
rcases isUnit_or_isNilpotent b with hb | hb
· lift b to K[ε]ˣ using hb
exact ⟨b⁻¹ * a, by simp⟩
rw [isNilpotent_iff_eps_dvd] at ha hb
obtain ⟨x, rfl⟩ := ha
obtain ⟨y, rfl⟩ := hb
suffices ∃ c, fst x * fst c = fst y ∨ fst y * fst c = fst x by
simpa [TrivSqZeroExt.ext_iff] using this
rcases eq_or_ne (fst x) 0 with hx | hx
· refine ⟨ε, Or.inr ?_⟩
simp [hx]
refine ⟨inl ((fst x)⁻¹ * fst y), ?_⟩
simp [← mul_assoc, mul_inv_cancel₀ hx]
end Field
end DualNumber |
.lake/packages/mathlib/Mathlib/RingTheory/FreeRing.lean | import Mathlib.Algebra.FreeMonoid.Basic
import Mathlib.GroupTheory.FreeAbelianGroup
/-!
# Free rings
The theory of the free ring over a type.
## Main definitions
* `FreeRing α` : the free (not commutative in general) ring over a type.
* `lift (f : α → R)` : the ring hom `FreeRing α →+* R` induced by `f`.
* `map (f : α → β)` : the ring hom `FreeRing α →+* FreeRing β` induced by `f`.
## Implementation details
`FreeRing α` is implemented as the free abelian group over the free monoid on `α`.
## Tags
free ring
-/
universe u v
/--
If `α` is a type, then `FreeRing α` is the free ring generated by `α`.
This is a ring equipped with a function `FreeRing.of : α → FreeRing α` which has
the following universal property: if `R` is any ring, and `f : α → R` is any function,
then this function is the composite of `FreeRing.of` and a unique ring homomorphism
`FreeRing.lift f : FreeRing α →+* R`.
A typical element of `FreeRing α` is a `ℤ`-linear combination of
formal products of elements of `α`.
For example if `x` and `y` are terms of type `α` then `3 * x * y * x - 2 * y * x + 1` is a
"typical" element of `FreeRing α`. In particular if `α` is empty
then `FreeRing α` is isomorphic to `ℤ`, and if `α` has one term `t`
then `FreeRing α` is isomorphic to the polynomial ring `ℤ[t]`.
If `α` has two or more terms then `FreeRing α` is not commutative.
One can think of `FreeRing α` as the free non-commutative polynomial ring
with coefficients in the integers and variables indexed by `α`.
-/
def FreeRing (α : Type u) : Type u :=
FreeAbelianGroup <| FreeMonoid α
instance (α : Type u) : Ring (FreeRing α) :=
FreeAbelianGroup.ring _
instance (α : Type u) : Inhabited (FreeRing α) := by
dsimp only [FreeRing]
infer_instance
instance (α : Type u) : Nontrivial (FreeRing α) :=
inferInstanceAs <| Nontrivial (FreeAbelianGroup _)
namespace FreeRing
variable {α : Type u}
/-- The canonical map from α to `FreeRing α`. -/
def of (x : α) : FreeRing α :=
FreeAbelianGroup.of (FreeMonoid.of x)
theorem of_injective : Function.Injective (of : α → FreeRing α) :=
FreeAbelianGroup.of_injective.comp FreeMonoid.of_injective
@[simp]
theorem of_ne_zero (x : α) : of x ≠ 0 := FreeAbelianGroup.of_ne_zero _
@[simp]
theorem zero_ne_of (x : α) : 0 ≠ of x := FreeAbelianGroup.zero_ne_of _
@[simp]
theorem of_ne_one (x : α) : of x ≠ 1 := FreeAbelianGroup.of_injective.ne <| FreeMonoid.of_ne_one _
@[simp]
theorem one_ne_of (x : α) : 1 ≠ of x := FreeAbelianGroup.of_injective.ne <| FreeMonoid.one_ne_of _
@[elab_as_elim, induction_eliminator]
protected theorem induction_on {C : FreeRing α → Prop} (z : FreeRing α) (hn1 : C (-1))
(hb : ∀ b, C (of b)) (ha : ∀ x y, C x → C y → C (x + y)) (hm : ∀ x y, C x → C y → C (x * y)) :
C z :=
have hn : ∀ x, C x → C (-x) := fun x ih => neg_one_mul x ▸ hm _ _ hn1 ih
have h1 : C 1 := neg_neg (1 : FreeRing α) ▸ hn _ hn1
FreeAbelianGroup.induction_on z (neg_add_cancel (1 : FreeRing α) ▸ ha _ _ hn1 h1)
(fun m => List.recOn m h1 fun a _ ih => hm _ _ (hb a) ih)
(fun _ ih => hn _ ih) ha
section lift
variable {R : Type v} [Ring R] (f : α → R)
/-- The ring homomorphism `FreeRing α →+* R` induced from a map `α → R`. -/
def lift : (α → R) ≃ (FreeRing α →+* R) :=
FreeMonoid.lift.trans FreeAbelianGroup.liftMonoid
@[simp]
theorem lift_of (x : α) : lift f (of x) = f x :=
congr_fun (lift.left_inv f) x
@[simp]
theorem lift_comp_of (f : FreeRing α →+* R) : lift (f ∘ of) = f :=
lift.right_inv f
@[ext]
theorem hom_ext ⦃f g : FreeRing α →+* R⦄ (h : ∀ x, f (of x) = g (of x)) : f = g :=
lift.symm.injective (funext h)
end lift
variable {β : Type v} (f : α → β)
/-- The canonical ring homomorphism `FreeRing α →+* FreeRing β` generated by a map `α → β`. -/
def map : FreeRing α →+* FreeRing β :=
lift <| of ∘ f
@[simp]
theorem map_of (x : α) : map f (of x) = of (f x) :=
lift_of _ _
end FreeRing |
.lake/packages/mathlib/Mathlib/RingTheory/EssentialFiniteness.lean | import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Localization.Defs
import Mathlib.RingTheory.TensorProduct.Basic
/-!
# Essentially of finite type algebras
## Main results
- `Algebra.EssFiniteType`: The class of essentially of finite type algebras. An `R`-algebra is
essentially of finite type if it is the localization of an algebra of finite type.
- `Algebra.EssFiniteType.algHom_ext`: The algebra homomorphisms out from an algebra essentially of
finite type is determined by its values on a finite set.
-/
open scoped TensorProduct
namespace Algebra
variable (R S T : Type*) [CommRing R] [CommRing S] [CommRing T]
variable [Algebra R S] [Algebra R T]
/--
An `R`-algebra is essentially of finite type if
it is the localization of an algebra of finite type.
See `essFiniteType_iff_exists_subalgebra`.
-/
class EssFiniteType : Prop where
cond : ∃ s : Finset S,
IsLocalization ((IsUnit.submonoid S).comap (algebraMap (adjoin R (s : Set S)) S)) S
/-- Let `S` be an `R`-algebra essentially of finite type, this is a choice of a finset `s ⊆ S`
such that `S` is the localization of `R[s]`. -/
noncomputable
def EssFiniteType.finset [h : EssFiniteType R S] : Finset S := h.cond.choose
/-- A choice of a subalgebra of finite type in an essentially of finite type algebra, such that
its localization is the whole ring. -/
noncomputable
abbrev EssFiniteType.subalgebra [EssFiniteType R S] : Subalgebra R S :=
Algebra.adjoin R (finset R S : Set S)
lemma EssFiniteType.adjoin_mem_finset [EssFiniteType R S] :
adjoin R { x : subalgebra R S | x.1 ∈ finset R S } = ⊤ := adjoin_adjoin_coe_preimage
instance [EssFiniteType R S] : Algebra.FiniteType R (EssFiniteType.subalgebra R S) := by
constructor
rw [Subalgebra.fg_top, EssFiniteType.subalgebra]
exact ⟨_, rfl⟩
/-- A submonoid of `EssFiniteType.subalgebra R S`, whose localization is the whole algebra `S`. -/
noncomputable
def EssFiniteType.submonoid [EssFiniteType R S] : Submonoid (EssFiniteType.subalgebra R S) :=
((IsUnit.submonoid S).comap (algebraMap (EssFiniteType.subalgebra R S) S))
instance EssFiniteType.isLocalization [h : EssFiniteType R S] :
IsLocalization (EssFiniteType.submonoid R S) S :=
h.cond.choose_spec
lemma essFiniteType_cond_iff (σ : Finset S) :
IsLocalization ((IsUnit.submonoid S).comap (algebraMap (adjoin R (σ : Set S)) S)) S ↔
(∀ s : S, ∃ t ∈ Algebra.adjoin R (σ : Set S),
IsUnit t ∧ s * t ∈ Algebra.adjoin R (σ : Set S)) := by
constructor <;> intro hσ
· intro s
obtain ⟨⟨⟨x, hx⟩, ⟨t, ht⟩, ht'⟩, h⟩ := hσ.2 s
exact ⟨t, ht, ht', h ▸ hx⟩
· constructor
· exact fun y ↦ y.prop
· intro s
obtain ⟨t, ht, ht', h⟩ := hσ s
exact ⟨⟨⟨_, h⟩, ⟨t, ht⟩, ht'⟩, rfl⟩
· intro x y e
exact ⟨1, by simpa using Subtype.ext e⟩
lemma essFiniteType_iff :
EssFiniteType R S ↔ ∃ (σ : Finset S),
(∀ s : S, ∃ t ∈ Algebra.adjoin R (σ : Set S),
IsUnit t ∧ s * t ∈ Algebra.adjoin R (σ : Set S)) := by
simp_rw [← essFiniteType_cond_iff]
constructor <;> exact fun ⟨a, b⟩ ↦ ⟨a, b⟩
instance EssFiniteType.of_finiteType [FiniteType R S] : EssFiniteType R S := by
obtain ⟨s, hs⟩ := ‹FiniteType R S›
rw [essFiniteType_iff]
exact ⟨s, fun _ ↦ by simpa only [hs, mem_top, and_true, true_and] using ⟨1, isUnit_one⟩⟩
variable {R} in
lemma EssFiniteType.of_isLocalization (M : Submonoid R) [IsLocalization M S] :
EssFiniteType R S := by
rw [essFiniteType_iff]
use ∅
simp only [Finset.coe_empty, Algebra.adjoin_empty, Algebra.mem_bot,
Set.mem_range, exists_exists_eq_and]
intro s
obtain ⟨⟨x, t⟩, e⟩ := IsLocalization.surj M s
exact ⟨_, IsLocalization.map_units S t, x, e.symm⟩
lemma EssFiniteType.of_id : EssFiniteType R R := inferInstance
section
variable [Algebra S T] [IsScalarTower R S T]
lemma EssFiniteType.aux (σ : Subalgebra R S)
(hσ : ∀ s : S, ∃ t ∈ σ, IsUnit t ∧ s * t ∈ σ)
(τ : Set T) (t : T) (ht : t ∈ Algebra.adjoin S τ) :
∃ s ∈ σ, IsUnit s ∧ s • t ∈ σ.map (IsScalarTower.toAlgHom R S T) ⊔ Algebra.adjoin R τ := by
refine Algebra.adjoin_induction ?_ ?_ ?_ ?_ ht
· intro t ht
exact ⟨1, Subalgebra.one_mem _, isUnit_one,
(one_smul S t).symm ▸ Algebra.mem_sup_right (Algebra.subset_adjoin ht)⟩
· intro s
obtain ⟨s', hs₁, hs₂, hs₃⟩ := hσ s
refine ⟨_, hs₁, hs₂, Algebra.mem_sup_left ?_⟩
rw [Algebra.smul_def, ← map_mul, mul_comm]
exact ⟨_, hs₃, rfl⟩
· rintro x y - - ⟨sx, hsx, hsx', hsx''⟩ ⟨sy, hsy, hsy', hsy''⟩
refine ⟨_, σ.mul_mem hsx hsy, hsx'.mul hsy', ?_⟩
rw [smul_add, mul_smul, mul_smul, Algebra.smul_def sx (sy • y), smul_comm,
Algebra.smul_def sy (sx • x)]
apply add_mem (mul_mem _ hsx'') (mul_mem _ hsy'') <;>
exact Algebra.mem_sup_left ⟨_, ‹_›, rfl⟩
· rintro x y - - ⟨sx, hsx, hsx', hsx''⟩ ⟨sy, hsy, hsy', hsy''⟩
refine ⟨_, σ.mul_mem hsx hsy, hsx'.mul hsy', ?_⟩
rw [mul_smul, ← smul_eq_mul, smul_comm sy x, ← smul_assoc, smul_eq_mul]
exact mul_mem hsx'' hsy''
lemma EssFiniteType.comp [h₁ : EssFiniteType R S] [h₂ : EssFiniteType S T] :
EssFiniteType R T := by
rw [essFiniteType_iff] at h₁ h₂ ⊢
classical
obtain ⟨s, hs⟩ := h₁
obtain ⟨t, ht⟩ := h₂
use s.image (IsScalarTower.toAlgHom R S T) ∪ t
simp only [Finset.coe_union, Finset.coe_image, Algebra.adjoin_union, Algebra.adjoin_image]
intro x
obtain ⟨y, hy₁, hy₂, hy₃⟩ := ht x
obtain ⟨t₁, h₁, h₂, h₃⟩ := EssFiniteType.aux _ _ _ _ hs _ y hy₁
obtain ⟨t₂, h₄, h₅, h₆⟩ := EssFiniteType.aux _ _ _ _ hs _ _ hy₃
refine ⟨t₂ • t₁ • y, ?_, ?_, ?_⟩
· rw [Algebra.smul_def]
exact mul_mem (Algebra.mem_sup_left ⟨_, h₄, rfl⟩) h₃
· rw [Algebra.smul_def, Algebra.smul_def]
exact (h₅.map _).mul ((h₂.map _).mul hy₂)
· rw [← mul_smul, mul_comm, smul_mul_assoc, mul_comm, mul_comm y, mul_smul, Algebra.smul_def]
exact mul_mem (Algebra.mem_sup_left ⟨_, h₁, rfl⟩) h₆
open EssFiniteType in
lemma essFiniteType_iff_exists_subalgebra : EssFiniteType R S ↔
∃ (S₀ : Subalgebra R S) (M : Submonoid S₀), FiniteType R S₀ ∧ IsLocalization M S := by
refine ⟨fun h ↦ ⟨subalgebra R S, submonoid R S, inferInstance, inferInstance⟩, ?_⟩
rintro ⟨S₀, M, _, _⟩
letI := of_isLocalization S M
exact comp R S₀ S
instance EssFiniteType.baseChange [h : EssFiniteType R S] : EssFiniteType T (T ⊗[R] S) := by
classical
rw [essFiniteType_iff] at h ⊢
obtain ⟨σ, hσ⟩ := h
use σ.image Algebra.TensorProduct.includeRight
intro s
induction s using TensorProduct.induction_on with
| zero => exact ⟨1, one_mem _, isUnit_one, by simp⟩
| tmul x y =>
obtain ⟨t, h₁, h₂, h₃⟩ := hσ y
have H (x : S) (hx : x ∈ Algebra.adjoin R (σ : Set S)) :
1 ⊗ₜ[R] x ∈ Algebra.adjoin T
((σ.image Algebra.TensorProduct.includeRight : Finset (T ⊗[R] S)) : Set (T ⊗[R] S)) := by
have : Algebra.TensorProduct.includeRight x ∈
(Algebra.adjoin R (σ : Set S)).map (Algebra.TensorProduct.includeRight (A := T)) :=
Subalgebra.mem_map.mpr ⟨_, hx, rfl⟩
rw [← Algebra.adjoin_adjoin_of_tower R]
apply Algebra.subset_adjoin
simpa [← Algebra.adjoin_image] using this
refine ⟨Algebra.TensorProduct.includeRight t, H _ h₁, h₂.map _, ?_⟩
simp only [Algebra.TensorProduct.includeRight_apply, Algebra.TensorProduct.tmul_mul_tmul,
mul_one]
rw [← mul_one x, ← smul_eq_mul, ← TensorProduct.smul_tmul']
apply Subalgebra.smul_mem
exact H _ h₃
| add x y hx hy =>
obtain ⟨tx, hx₁, hx₂, hx₃⟩ := hx
obtain ⟨ty, hy₁, hy₂, hy₃⟩ := hy
refine ⟨_, mul_mem hx₁ hy₁, hx₂.mul hy₂, ?_⟩
rw [add_mul, ← mul_assoc, mul_comm tx ty, ← mul_assoc]
exact add_mem (mul_mem hx₃ hy₁) (mul_mem hy₃ hx₁)
lemma EssFiniteType.of_comp [h : EssFiniteType R T] : EssFiniteType S T := by
rw [essFiniteType_iff] at h ⊢
classical
obtain ⟨σ, hσ⟩ := h
use σ
intro x
obtain ⟨y, hy₁, hy₂, hy₃⟩ := hσ x
simp_rw [← Algebra.adjoin_adjoin_of_tower R (S := S) (σ : Set T)]
exact ⟨y, Algebra.subset_adjoin hy₁, hy₂, Algebra.subset_adjoin hy₃⟩
lemma EssFiniteType.comp_iff [EssFiniteType R S] :
EssFiniteType R T ↔ EssFiniteType S T :=
⟨fun _ ↦ of_comp R S T, fun _ ↦ comp R S T⟩
instance [EssFiniteType R S] (I : Ideal S) : EssFiniteType R (S ⧸ I) :=
.comp R S _
instance [EssFiniteType R S] (M : Submonoid S) : EssFiniteType R (Localization M) :=
have : EssFiniteType S (Localization M) := .of_isLocalization _ M
.comp R S _
end
variable {R S} in
lemma EssFiniteType.algHom_ext [EssFiniteType R S]
(f g : S →ₐ[R] T) (H : ∀ s ∈ finset R S, f s = g s) : f = g := by
suffices f.toRingHom = g.toRingHom by ext; exact RingHom.congr_fun this _
apply IsLocalization.ringHom_ext (EssFiniteType.submonoid R S)
suffices f.comp (IsScalarTower.toAlgHom R _ S) = g.comp (IsScalarTower.toAlgHom R _ S) by
ext; exact AlgHom.congr_fun this _
apply AlgHom.ext_of_adjoin_eq_top (s := { x | x.1 ∈ finset R S })
· exact adjoin_mem_finset R S
· rintro ⟨x, hx⟩ hx'; exact H x hx'
end Algebra
namespace RingHom
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T] {f : R →+* S}
/-- A ring hom is essentially of finite type if it is the composition of a localization map
and a ring hom of finite type. See `Algebra.EssFiniteType`. -/
@[algebraize Algebra.EssFiniteType]
def EssFiniteType (f : R →+* S) : Prop :=
letI := f.toAlgebra
Algebra.EssFiniteType R S
/-- A choice of "essential generators" for a ring hom essentially of finite type.
See `Algebra.EssFiniteType.ext`. -/
noncomputable
def EssFiniteType.finset (hf : f.EssFiniteType) : Finset S :=
letI := f.toAlgebra
haveI : Algebra.EssFiniteType R S := hf
Algebra.EssFiniteType.finset R S
lemma FiniteType.essFiniteType (hf : f.FiniteType) : f.EssFiniteType := by
algebraize [f]
change Algebra.EssFiniteType R S
infer_instance
lemma EssFiniteType.ext (hf : f.EssFiniteType) {g₁ g₂ : S →+* T}
(h₁ : g₁.comp f = g₂.comp f) (h₂ : ∀ x ∈ hf.finset, g₁ x = g₂ x) : g₁ = g₂ := by
algebraize [f, g₁.comp f]
ext x
exact DFunLike.congr_fun (Algebra.EssFiniteType.algHom_ext T
⟨g₁, fun _ ↦ rfl⟩ ⟨g₂, DFunLike.congr_fun h₁.symm⟩ h₂) x
end RingHom |
.lake/packages/mathlib/Mathlib/RingTheory/Radical.lean | import Mathlib.Algebra.EuclideanDomain.Basic
import Mathlib.Algebra.Order.Group.Finset
import Mathlib.RingTheory.Coprime.Lemmas
import Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors
import Mathlib.RingTheory.UniqueFactorizationDomain.Nat
import Mathlib.RingTheory.Nilpotent.Basic
import Mathlib.Data.Nat.PrimeFin
import Mathlib.Algebra.Squarefree.Basic
/-!
# Radical of an element of a unique factorization normalization monoid
This file defines a radical of an element `a` of a unique factorization normalization
monoid, which is defined as a product of normalized prime factors of `a` without duplication.
This is different from the radical of an ideal.
## Main declarations
- `radical`: The radical of an element `a` in a unique factorization monoid is the product of
its prime factors.
- `radical_eq_of_associated`: If `a` and `b` are associates, i.e. `a * u = b` for some unit `u`,
then `radical a = radical b`.
- `radical_unit_mul`: Multiplying unit does not change the radical.
- `radical_dvd_self`: `radical a` divides `a`.
- `radical_pow`: `radical (a ^ n) = radical a` for any `n ≥ 1`
- `radical_of_prime`: Radical of a prime element is equal to its normalization
- `radical_pow_of_prime`: Radical of a power of prime element is equal to its normalization
- `radical_mul`: Radical is multiplicative for two relatively prime elements.
- `radical_prod`: Radical is multiplicative for finitely many relatively prime elements.
### For unique factorization domains
### For Euclidean domains
- `EuclideanDomain.divRadical`: For an element `a` in an Euclidean domain, `a / radical a`.
- `EuclideanDomain.divRadical_mul`: `divRadical` of a product is the product of `divRadical`s.
- `IsCoprime.divRadical`: `divRadical` of coprime elements are coprime.
## For natural numbers
- `UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors`: The prime factors of a natural number
are the same as the prime factors defined in `Nat.primeFactors`.
- `Nat.radical_le_self`: The radical of a natural number is less than or equal to the number itself.
- `Nat.two_le_radical`: If a natural number is at least 2, then its radical is at least 2.
## TODO
- Make a comparison with `Ideal.radical`. Especially, for principal ideal,
`Ideal.radical (Ideal.span {a}) = Ideal.span {radical a}`.
-/
noncomputable section
namespace UniqueFactorizationMonoid
-- `CancelCommMonoidWithZero` is required by `UniqueFactorizationMonoid`
variable {M : Type*} [CancelCommMonoidWithZero M] [NormalizationMonoid M]
[UniqueFactorizationMonoid M] {a b u : M}
open scoped Classical in
/-- The finite set of prime factors of an element in a unique factorization monoid. -/
def primeFactors (a : M) : Finset M :=
(normalizedFactors a).toFinset
lemma mem_primeFactors : a ∈ primeFactors b ↔ a ∈ normalizedFactors b := by
simp only [primeFactors, Multiset.mem_toFinset]
theorem _root_.Associated.primeFactors_eq {a b : M} (h : Associated a b) :
primeFactors a = primeFactors b := by
unfold primeFactors
rw [h.normalizedFactors_eq]
@[simp] lemma primeFactors_zero : primeFactors (0 : M) = ∅ := by simp [primeFactors]
@[simp] lemma primeFactors_one : primeFactors (1 : M) = ∅ := by simp [primeFactors]
lemma pairwise_primeFactors_isRelPrime :
Set.Pairwise (primeFactors a : Set M) IsRelPrime := by
obtain rfl | ha₀ := eq_or_ne a 0
· simp
intro x hx y hy hxy
simp only [Finset.mem_coe, mem_primeFactors, mem_normalizedFactors_iff' ha₀] at hx hy
rw [hx.1.isRelPrime_iff_not_dvd]
contrapose! hxy
have : Associated x y := hx.1.associated_of_dvd hy.1 hxy
exact this.eq_of_normalized hx.2.1 hy.2.1
theorem primeFactors_pow (a : M) {n : ℕ} (hn : n ≠ 0) : primeFactors (a ^ n) = primeFactors a := by
simp_rw [primeFactors, normalizedFactors_pow, Multiset.toFinset_nsmul _ _ hn]
@[simp]
theorem primeFactors_pow' (a : M) {n : ℕ} [NeZero n] : primeFactors (a ^ n) = primeFactors a :=
primeFactors_pow a NeZero.out
lemma normalizedFactors_nodup (ha : IsRadical a) : (normalizedFactors a).Nodup := by
obtain rfl | ha₀ := eq_or_ne a 0
· simp
rwa [← squarefree_iff_nodup_normalizedFactors ha₀, ← isRadical_iff_squarefree_of_ne_zero ha₀]
/--
If `x` is a unit, then the finset of prime factors of `x` is empty.
The converse is true with a nonzero assumption, see `primeFactors_eq_empty_iff`.
-/
lemma primeFactors_of_isUnit (h : IsUnit a) : primeFactors a = ∅ := by
classical
rw [primeFactors, normalizedFactors_of_isUnit h, Multiset.toFinset_zero]
/--
The finset of prime factors of `x` is empty if and only if `x` is a unit.
The converse is true without the nonzero assumption, see `primeFactors_of_isUnit`.
-/
theorem primeFactors_eq_empty_iff (ha : a ≠ 0) : primeFactors a = ∅ ↔ IsUnit a := by
classical
rw [primeFactors, Multiset.toFinset_eq_empty, normalizedFactors_eq_zero_iff ha]
lemma primeFactors_val_eq_normalizedFactors (ha : IsRadical a) :
(primeFactors a).val = normalizedFactors a := by
classical
rw [primeFactors, Multiset.toFinset_val, Multiset.dedup_eq_self]
exact normalizedFactors_nodup ha
-- Note that the non-zero assumptions are necessary here.
theorem primeFactors_mul_eq_union [DecidableEq M] (ha : a ≠ 0) (hb : b ≠ 0) :
primeFactors (a * b) = primeFactors a ∪ primeFactors b := by
ext p
simp [mem_normalizedFactors_iff', mem_primeFactors, ha, hb]
/-- Relatively prime elements have disjoint prime factors (as finsets). -/
theorem disjoint_primeFactors (hc : IsRelPrime a b) :
Disjoint (primeFactors a) (primeFactors b) := by
classical
exact Multiset.disjoint_toFinset.mpr (disjoint_normalizedFactors hc)
theorem primeFactors_mul_eq_disjUnion (hc : IsRelPrime a b) :
primeFactors (a * b) =
(primeFactors a).disjUnion (primeFactors b) (disjoint_primeFactors hc) := by
obtain rfl | ha := eq_or_ne a 0
· rw [isRelPrime_zero_left] at hc
simp only [zero_mul, primeFactors_zero, Finset.empty_disjUnion, primeFactors_of_isUnit hc]
obtain rfl | hb := eq_or_ne b 0
· rw [isRelPrime_zero_right] at hc
simp only [mul_zero, primeFactors_zero, primeFactors_of_isUnit hc, Finset.disjUnion_empty]
classical
rw [Finset.disjUnion_eq_union, primeFactors_mul_eq_union ha hb]
/--
Radical of an element `a` in a unique factorization monoid is the product of
the prime factors of `a`.
-/
def radical (a : M) : M :=
(primeFactors a).prod id
@[simp] theorem radical_zero : radical (0 : M) = 1 := by simp [radical]
@[deprecated (since := "2025-05-31")] alias radical_zero_eq := radical_zero
@[simp] theorem radical_one : radical (1 : M) = 1 := by simp [radical]
@[deprecated (since := "2025-05-31")] alias radical_one_eq := radical_one
theorem radical_eq_of_associated (h : Associated a b) : radical a = radical b := by
rw [radical, radical, Associated.primeFactors_eq h]
lemma radical_associated (ha : IsRadical a) (ha' : a ≠ 0) :
Associated (radical a) a := by
rw [radical, ← Finset.prod_val, primeFactors_val_eq_normalizedFactors ha]
exact prod_normalizedFactors ha'
/-- If `a` is a radical element, then it divides its radical. -/
lemma _root_.IsRadical.dvd_radical (ha : IsRadical a) (ha' : a ≠ 0) : a ∣ radical a :=
(radical_associated ha ha').dvd'
theorem radical_of_isUnit (h : IsUnit a) : radical a = 1 :=
(radical_eq_of_associated (associated_one_iff_isUnit.mpr h)).trans radical_one
theorem radical_mul_of_isUnit_left (h : IsUnit u) : radical (u * a) = radical a :=
radical_eq_of_associated (associated_unit_mul_left _ _ h)
theorem radical_mul_of_isUnit_right (h : IsUnit u) : radical (a * u) = radical a :=
radical_eq_of_associated (associated_mul_unit_left _ _ h)
theorem radical_pow (a : M) {n : ℕ} (hn : n ≠ 0) : radical (a ^ n) = radical a := by
simp_rw [radical, primeFactors_pow a hn]
theorem radical_dvd_self : radical a ∣ a := by
classical
by_cases ha : a = 0
· rw [ha]
apply dvd_zero
· rw [radical, ← Finset.prod_val, ← (prod_normalizedFactors ha).dvd_iff_dvd_right]
apply Multiset.prod_dvd_prod_of_le
rw [primeFactors, Multiset.toFinset_val]
apply Multiset.dedup_le
theorem radical_of_prime (ha : Prime a) : radical a = normalize a := by
rw [radical, primeFactors]
rw [normalizedFactors_irreducible ha.irreducible]
simp only [Multiset.toFinset_singleton, id, Finset.prod_singleton]
theorem radical_pow_of_prime (ha : Prime a) {n : ℕ} (hn : n ≠ 0) :
radical (a ^ n) = normalize a := by
rw [radical_pow a hn]
exact radical_of_prime ha
@[simp] theorem radical_ne_zero [Nontrivial M] : radical a ≠ 0 := by
rw [radical, ← Finset.prod_val]
apply Multiset.prod_ne_zero
rw [primeFactors]
simp only [Multiset.toFinset_val, Multiset.mem_dedup]
exact zero_notMem_normalizedFactors _
/--
An irreducible `a` divides the radical of `b` if and only if it divides `b` itself.
Note this generalises to radical elements `a`, see `UniqueFactorizationMonoid.dvd_radical_iff`.
-/
lemma dvd_radical_iff_of_irreducible (ha : Irreducible a) (hb : b ≠ 0) :
a ∣ radical b ↔ a ∣ b := by
constructor
· intro ha
exact ha.trans radical_dvd_self
· intro ha'
obtain ⟨c, hc, hc'⟩ := exists_mem_normalizedFactors_of_dvd hb ha ha'
exact hc'.dvd.trans (Finset.dvd_prod_of_mem _ (by simpa [mem_primeFactors] using hc))
lemma isRadical_radical : IsRadical (radical a) := by
intro n p ha
rw [radical]
apply Finset.prod_dvd_of_isRelPrime
· exact pairwise_primeFactors_isRelPrime
intro i hi
simp only [mem_primeFactors] at hi
have : i ∣ radical a := by
rw [dvd_radical_iff_of_irreducible]
· exact dvd_of_mem_normalizedFactors hi
· exact irreducible_of_normalized_factor i hi
· rintro rfl
simp only [normalizedFactors_zero, Multiset.notMem_zero] at hi
exact (prime_of_normalized_factor i hi).isRadical n p (this.trans ha)
lemma squarefree_radical : Squarefree (radical a) := by
nontriviality M
exact isRadical_radical.squarefree (by simp [radical_ne_zero])
@[simp] lemma primeFactors_radical : primeFactors (radical a) = primeFactors a := by
obtain rfl | ha₀ := eq_or_ne a 0
· simp [primeFactors]
have : Nontrivial M := ⟨a, 0, ha₀⟩
ext p
simp +contextual [mem_primeFactors, mem_normalizedFactors_iff',
dvd_radical_iff_of_irreducible, ha₀]
lemma radical_eq_iff_primeFactors_eq :
radical a = radical b ↔ primeFactors a = primeFactors b :=
⟨fun h => by rw [← primeFactors_radical, h]; exact primeFactors_radical,
fun h => by simp [radical, h]⟩
@[deprecated "This lemma is deprecated in favor of using `radical_eq_iff_primeFactors_eq.mpr`. "
(since := "2025-11-09")]
lemma radical_eq_of_primeFactors_eq (h : primeFactors a = primeFactors b) :
radical a = radical b := radical_eq_iff_primeFactors_eq.mpr h
theorem radical_eq_one_iff : radical a = 1 ↔ a = 0 ∨ IsUnit a := by
refine ⟨?_, (Or.elim · (by simp +contextual) radical_of_isUnit)⟩
intro h
rw [or_iff_not_imp_left]
intro ha
have : primeFactors a = ∅ := by rw [← primeFactors_radical, h, primeFactors_one]
rwa [primeFactors_eq_empty_iff ha] at this
@[simp]
lemma radical_radical : radical (radical a) = radical a :=
radical_eq_iff_primeFactors_eq.mpr primeFactors_radical
lemma radical_dvd_radical_iff_normalizedFactors_subset_normalizedFactors :
radical a ∣ radical b ↔ normalizedFactors a ⊆ normalizedFactors b := by
obtain rfl | ha₀ := eq_or_ne a 0
· simp
have : Nontrivial M := ⟨a, 0, ha₀⟩
rw [dvd_iff_normalizedFactors_le_normalizedFactors radical_ne_zero radical_ne_zero,
Multiset.le_iff_subset (normalizedFactors_nodup isRadical_radical)]
simp only [Multiset.subset_iff, ← mem_primeFactors, primeFactors_radical]
lemma radical_dvd_radical_iff_primeFactors_subset_primeFactors :
radical a ∣ radical b ↔ primeFactors a ⊆ primeFactors b := by
classical
rw [radical_dvd_radical_iff_normalizedFactors_subset_normalizedFactors, primeFactors,
primeFactors, Multiset.toFinset_subset]
/-- If `a` divides `b`, then the radical of `a` divides the radical of `b`. The theorem requires
that `b ≠ 0`, since `radical 0 = 1` but `a ∣ 0` holds for every `a`. -/
lemma radical_dvd_radical (h : a ∣ b) (hb₀ : b ≠ 0) : radical a ∣ radical b := by
obtain rfl | ha₀ := eq_or_ne a 0
· simp
rw [dvd_iff_normalizedFactors_le_normalizedFactors ha₀ hb₀] at h
rw [radical_dvd_radical_iff_normalizedFactors_subset_normalizedFactors]
exact Multiset.subset_of_le h
/--
If `a` is a radical element, then `a` divides the radical of `b` if and only if it divides `b`.
Note the forward implication holds without the `b ≠ 0` assumption via `radical_dvd_self`.
-/
lemma dvd_radical_iff (ha : IsRadical a) (hb₀ : b ≠ 0) : a ∣ radical b ↔ a ∣ b := by
refine ⟨fun ha' ↦ ha'.trans radical_dvd_self, fun hab ↦ ?_⟩
obtain rfl | ha₀ := eq_or_ne a 0
· simp_all
· exact (ha.dvd_radical ha₀).trans (radical_dvd_radical hab hb₀)
theorem radical_dvd_iff_primeFactors_subset (hb : b ≠ 0) :
radical a ∣ b ↔ primeFactors a ⊆ primeFactors b := by
rw [← dvd_radical_iff isRadical_radical hb,
radical_dvd_radical_iff_primeFactors_subset_primeFactors]
/-- Radical is multiplicative for relatively prime elements. -/
theorem radical_mul (hc : IsRelPrime a b) :
radical (a * b) = radical a * radical b := by
simp_rw [radical]
rw [primeFactors_mul_eq_disjUnion hc, Finset.prod_disjUnion (disjoint_primeFactors hc)]
theorem radical_prod {ι : Type*} {f : ι → M} (s : Finset ι)
(h : Set.Pairwise (s : Set ι) (Function.onFun IsRelPrime f)) :
radical (∏ i ∈ s, f i) = ∏ i ∈ s, radical (f i) := by
induction s using Finset.cons_induction with
| empty => simp
| cons i s his ih =>
simp only [Finset.prod_cons]
rw [Finset.coe_cons,
Set.pairwise_insert_of_symmetric_of_notMem (symmetric_isRelPrime.comap _) (by simpa)] at h
rw [radical_mul, ih h.1]
exact IsRelPrime.prod_right h.2
theorem radical_mul_dvd : radical (a * b) ∣ radical a * radical b := by
classical
obtain rfl | ha := eq_or_ne a 0
· simp
obtain rfl | hb := eq_or_ne b 0
· simp
nontriviality M
simp [radical_dvd_iff_primeFactors_subset, primeFactors_mul_eq_union,
primeFactors_mul_eq_union ha hb, primeFactors_radical]
theorem radical_prod_dvd {ι : Type*} {s : Finset ι} {f : ι → M} :
radical (∏ i ∈ s, f i) ∣ ∏ i ∈ s, radical (f i) := by
induction s using Finset.cons_induction with
| empty => simp
| cons i s h ih =>
simp only [Finset.prod_cons]
exact radical_mul_dvd.trans (mul_dvd_mul_left _ ih)
end UniqueFactorizationMonoid
open UniqueFactorizationMonoid
/-! Theorems for UFDs -/
namespace UniqueFactorizationDomain
variable {R : Type*} [CommRing R] [IsDomain R] [NormalizationMonoid R]
[UniqueFactorizationMonoid R] {a b : R}
/-- Coprime elements have disjoint prime factors (as multisets). -/
@[deprecated "UniqueFactorizationMonoid.disjoint_normalizedFactors, IsCoprime.isRelPrime"
(since := "2025-05-31")]
theorem disjoint_normalizedFactors (hc : IsCoprime a b) :
Disjoint (normalizedFactors a) (normalizedFactors b) :=
UniqueFactorizationMonoid.disjoint_normalizedFactors hc.isRelPrime
/-- Coprime elements have disjoint prime factors (as finsets). -/
@[deprecated "UniqueFactorizationMonoid.disjoint_primeFactors, IsCoprime.isRelPrime"
(since := "2025-05-31")]
theorem disjoint_primeFactors (hc : IsCoprime a b) :
Disjoint (primeFactors a) (primeFactors b) :=
UniqueFactorizationMonoid.disjoint_primeFactors hc.isRelPrime
set_option linter.deprecated false in
@[deprecated "UniqueFactorizationMonoid.primeFactors_mul_eq_disjUnion, IsCoprime.isRelPrime"
(since := "2025-05-31")]
theorem mul_primeFactors_disjUnion
(hc : IsCoprime a b) : primeFactors (a * b) =
(primeFactors a).disjUnion (primeFactors b) (disjoint_primeFactors hc) :=
UniqueFactorizationMonoid.primeFactors_mul_eq_disjUnion hc.isRelPrime
/-- Radical is multiplicative for coprime elements. -/
@[deprecated "UniqueFactorizationMonoid.radical_mul, IsCoprime.isRelPrime" (since := "2025-05-31")]
theorem radical_mul (hc : IsCoprime a b) :
radical (a * b) = radical a * radical b :=
UniqueFactorizationMonoid.radical_mul hc.isRelPrime
@[simp]
theorem radical_neg : radical (-a) = radical a :=
radical_eq_of_associated Associated.rfl.neg_left
theorem radical_neg_one : radical (-1 : R) = 1 := by simp
end UniqueFactorizationDomain
open UniqueFactorizationDomain
namespace EuclideanDomain
variable {E : Type*} [EuclideanDomain E] [NormalizationMonoid E] [UniqueFactorizationMonoid E]
{a b u x : E}
/-- Division of an element by its radical in an Euclidean domain. -/
def divRadical (a : E) : E := a / radical a
theorem radical_mul_divRadical : radical a * divRadical a = a := by
rw [divRadical, ← EuclideanDomain.mul_div_assoc _ radical_dvd_self,
mul_div_cancel_left₀ _ radical_ne_zero]
theorem divRadical_mul_radical : divRadical a * radical a = a := by
rw [mul_comm]
exact radical_mul_divRadical
theorem divRadical_ne_zero (ha : a ≠ 0) : divRadical a ≠ 0 := by
rw [← radical_mul_divRadical (a := a)] at ha
exact right_ne_zero_of_mul ha
theorem divRadical_isUnit (hu : IsUnit u) : IsUnit (divRadical u) := by
rwa [divRadical, radical_of_isUnit hu, EuclideanDomain.div_one]
theorem eq_divRadical (h : radical a * x = a) : x = divRadical a := by
apply EuclideanDomain.eq_div_of_mul_eq_left radical_ne_zero
rwa [mul_comm]
theorem divRadical_mul (hab : IsCoprime a b) :
divRadical (a * b) = divRadical a * divRadical b := by
symm; apply eq_divRadical
rw [UniqueFactorizationMonoid.radical_mul hab.isRelPrime]
rw [mul_mul_mul_comm, radical_mul_divRadical, radical_mul_divRadical]
theorem divRadical_dvd_self (a : E) : divRadical a ∣ a :=
⟨radical a, divRadical_mul_radical.symm⟩
theorem _root_.IsCoprime.divRadical {a b : E} (h : IsCoprime a b) :
IsCoprime (divRadical a) (divRadical b) := by
rw [← radical_mul_divRadical (a := a)] at h
rw [← radical_mul_divRadical (a := b)] at h
exact h.of_mul_left_right.of_mul_right_right
end EuclideanDomain
section Nat
lemma UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors :
primeFactors = Nat.primeFactors := by
ext n : 1
rw [primeFactors, Nat.factors_eq, Nat.primeFactors]
-- this convert is necessary because of the different DecidableEq instances
convert List.toFinset_coe _
namespace Nat
@[simp] theorem radical_le_self_iff {n : ℕ} : radical n ≤ n ↔ n ≠ 0 :=
⟨by aesop, fun h ↦ Nat.le_of_dvd (by cutsat) radical_dvd_self⟩
@[simp] theorem two_le_radical_iff {n : ℕ} : 2 ≤ radical n ↔ 2 ≤ n := by
refine ⟨?_, ?_⟩
· match n with | 0 | 1 | _ + 2 => simp
· intro hn
obtain ⟨p, hp, hpn⟩ := Nat.exists_prime_and_dvd (show n ≠ 1 by cutsat)
trans p
· apply hp.two_le
· apply Nat.le_of_dvd (Nat.pos_of_ne_zero radical_ne_zero)
rwa [dvd_radical_iff_of_irreducible hp.prime.irreducible (by cutsat)]
@[simp] theorem one_lt_radical_iff {n : ℕ} : 1 < radical n ↔ 1 < n := two_le_radical_iff
@[simp] theorem radical_le_one_iff {n : ℕ} : radical n ≤ 1 ↔ n ≤ 1 := by
simpa only [not_lt] using one_lt_radical_iff.not
theorem radical_pos (n : ℕ) : 0 < radical n := pos_of_ne_zero radical_ne_zero
end Nat
end Nat |
.lake/packages/mathlib/Mathlib/RingTheory/SimpleRing/Matrix.lean | import Mathlib.LinearAlgebra.Matrix.Ideal
import Mathlib.RingTheory.SimpleRing.Basic
/-!
The matrix ring over a simple ring is simple
-/
namespace IsSimpleRing
variable (ι A : Type*) [Ring A] [Fintype ι] [Nonempty ι]
instance matrix [IsSimpleRing A] : IsSimpleRing (Matrix ι ι A) where
simple := letI := Classical.decEq ι; TwoSidedIdeal.orderIsoMatrix |>.symm.isSimpleOrder
end IsSimpleRing |
.lake/packages/mathlib/Mathlib/RingTheory/SimpleRing/Basic.lean | import Mathlib.RingTheory.SimpleRing.Defs
import Mathlib.Algebra.Ring.Opposite
import Mathlib.RingTheory.TwoSidedIdeal.Kernel
/-! # Basic Properties of Simple rings
A ring `R` is **simple** if it has only two two-sided ideals, namely `⊥` and `⊤`.
## Main results
- `IsSimpleRing.nontrivial`: simple rings are non-trivial.
- `DivisionRing.isSimpleRing`: division rings are simple.
- `RingHom.injective`: every ring homomorphism from a simple ring to a nontrivial ring is injective.
- `IsSimpleRing.iff_injective_ringHom`: a ring is simple iff every ring homomorphism to a nontrivial
ring is injective.
-/
assert_not_exists Finset
variable (R : Type*) [NonUnitalNonAssocRing R]
namespace IsSimpleRing
variable {R}
instance [IsSimpleRing R] : Nontrivial R := by
obtain ⟨x, _, hx⟩ := SetLike.exists_of_lt (bot_lt_top : (⊥ : TwoSidedIdeal R) < ⊤)
use x, 0, hx
lemma one_mem_of_ne_bot {A : Type*} [NonAssocRing A] [IsSimpleRing A] (I : TwoSidedIdeal A)
(hI : I ≠ ⊥) : (1 : A) ∈ I :=
(eq_bot_or_eq_top I).resolve_left hI ▸ ⟨⟩
lemma one_mem_of_ne_zero_mem {A : Type*} [NonAssocRing A] [IsSimpleRing A] (I : TwoSidedIdeal A)
{x : A} (hx : x ≠ 0) (hxI : x ∈ I) : (1 : A) ∈ I :=
one_mem_of_ne_bot I (by rintro rfl; exact hx hxI)
lemma of_eq_bot_or_eq_top [Nontrivial R] (h : ∀ I : TwoSidedIdeal R, I = ⊥ ∨ I = ⊤) :
IsSimpleRing R where
simple.eq_bot_or_eq_top := h
instance _root_.DivisionRing.isSimpleRing (A : Type*) [DivisionRing A] : IsSimpleRing A :=
.of_eq_bot_or_eq_top <| fun I ↦ by
rw [or_iff_not_imp_left, ← I.one_mem_iff]
intro H
obtain ⟨x, hx1, hx2 : x ≠ 0⟩ := SetLike.exists_of_lt (bot_lt_iff_ne_bot.mpr H : ⊥ < I)
simpa [inv_mul_cancel₀ hx2] using I.mul_mem_left x⁻¹ _ hx1
lemma injective_ringHom_or_subsingleton_codomain
{R S : Type*} [NonAssocRing R] [IsSimpleRing R] [NonAssocSemiring S]
(f : R →+* S) : Function.Injective f ∨ Subsingleton S :=
simple.eq_bot_or_eq_top (TwoSidedIdeal.ker f) |>.imp (TwoSidedIdeal.ker_eq_bot _ |>.1)
(fun h => subsingleton_iff_zero_eq_one.1 <| by
have mem : 1 ∈ TwoSidedIdeal.ker f := h.symm ▸ TwoSidedIdeal.mem_top _
rwa [TwoSidedIdeal.mem_ker, map_one, eq_comm] at mem)
protected theorem _root_.RingHom.injective
{R S : Type*} [NonAssocRing R] [IsSimpleRing R] [NonAssocSemiring S] [Nontrivial S]
(f : R →+* S) : Function.Injective f :=
injective_ringHom_or_subsingleton_codomain f |>.resolve_right fun r => not_subsingleton _ r
universe u in
lemma iff_injective_ringHom_or_subsingleton_codomain (R : Type u) [NonAssocRing R] [Nontrivial R] :
IsSimpleRing R ↔
∀ {S : Type u} [NonAssocSemiring S] (f : R →+* S), Function.Injective f ∨ Subsingleton S where
mp _ _ _ := injective_ringHom_or_subsingleton_codomain
mpr H := of_eq_bot_or_eq_top fun I => H I.ringCon.mk' |>.imp
(fun h => le_antisymm
(fun _ hx => TwoSidedIdeal.ker_eq_bot _ |>.2 h ▸ I.ker_ringCon_mk'.symm ▸ hx) bot_le)
(fun h => le_antisymm le_top fun x _ => I.mem_iff _ |>.2 (Quotient.eq'.1 (h.elim x 0)))
universe u in
lemma iff_injective_ringHom (R : Type u) [NonAssocRing R] [Nontrivial R] :
IsSimpleRing R ↔
∀ {S : Type u} [NonAssocSemiring S] [Nontrivial S] (f : R →+* S), Function.Injective f :=
iff_injective_ringHom_or_subsingleton_codomain R |>.trans <|
⟨fun H _ _ _ f => H f |>.resolve_right (by simpa [not_subsingleton_iff_nontrivial]),
fun H S _ f => subsingleton_or_nontrivial S |>.recOn Or.inr fun _ => Or.inl <| H f⟩
instance [IsSimpleRing R] : IsSimpleRing Rᵐᵒᵖ := ⟨TwoSidedIdeal.opOrderIso.symm.isSimpleOrder⟩
end IsSimpleRing |
.lake/packages/mathlib/Mathlib/RingTheory/SimpleRing/Congr.lean | import Mathlib.RingTheory.SimpleRing.Basic
import Mathlib.RingTheory.TwoSidedIdeal.Operations
/-!
# Simpleness is preserved by ring isomorphism/surjective ring homomorphisms
If `R` is a simple (non-assoc) ring and there exists surjective `f : R →+* S` where `S` is
nontrivial, then `S` is also simple.
If `R` is a simple (non-unital non-assoc) ring then any ring isomorphic to `R` is also simple.
-/
namespace IsSimpleRing
lemma of_surjective {R S : Type*} [NonAssocRing R] [NonAssocRing S] [Nontrivial S]
(f : R →+* S) (h : IsSimpleRing R) (hf : Function.Surjective f) : IsSimpleRing S where
simple := OrderIso.isSimpleOrder (RingEquiv.ofBijective f
⟨RingHom.injective f, hf⟩).symm.mapTwoSidedIdeal
lemma of_ringEquiv {R S : Type*} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
(f : R ≃+* S) (h : IsSimpleRing R) : IsSimpleRing S where
simple := OrderIso.isSimpleOrder f.symm.mapTwoSidedIdeal
end IsSimpleRing
open TwoSidedIdeal in
theorem isSimpleRing_iff_isTwoSided_imp {R : Type*} [Ring R] :
IsSimpleRing R ↔ Nontrivial R ∧ ∀ I : Ideal R, I.IsTwoSided → I = ⊥ ∨ I = ⊤ := by
let e := orderIsoIsTwoSided (R := R)
simp_rw [isSimpleRing_iff, isSimpleOrder_iff, orderIsoRingCon.toEquiv.nontrivial_congr,
RingCon.nontrivial_iff, e.forall_congr_left, Subtype.forall, ← e.injective.eq_iff]
simp [e, Subtype.ext_iff] |
.lake/packages/mathlib/Mathlib/RingTheory/SimpleRing/Defs.lean | import Mathlib.RingTheory.TwoSidedIdeal.Lattice
import Mathlib.Order.Atoms
/-! # Simple rings
A ring `R` is **simple** if it has only two two-sided ideals, namely `⊥` and `⊤`.
## Main definitions
- `IsSimpleRing`: a predicate expressing that a ring is simple.
-/
/--
A ring `R` is **simple** if it has only two two-sided ideals, namely `⊥` and `⊤`.
-/
@[mk_iff] class IsSimpleRing (R : Type*) [NonUnitalNonAssocRing R] : Prop where
simple : IsSimpleOrder (TwoSidedIdeal R)
attribute [instance] IsSimpleRing.simple |
.lake/packages/mathlib/Mathlib/RingTheory/SimpleRing/Field.lean | import Mathlib.RingTheory.SimpleRing.Basic
import Mathlib.Algebra.Ring.Subring.Basic
import Mathlib.Algebra.Field.Equiv
/-!
# Simple ring and fields
## Main results
- `IsSimpleRing.center_isField`: the center of a simple ring is a field.
- `isSimpleRing_iff_isField`: a commutative ring is simple if and only if it is a field.
-/
namespace IsSimpleRing
open TwoSidedIdeal in
lemma isField_center (A : Type*) [Ring A] [IsSimpleRing A] : IsField (Subring.center A) where
exists_pair_ne := ⟨0, 1, zero_ne_one⟩
mul_comm := mul_comm
mul_inv_cancel := by
rintro ⟨x, hx1⟩ hx2
rw [Subring.mem_center_iff] at hx1
replace hx2 : x ≠ 0 := by simpa [Subtype.ext_iff] using hx2
-- Todo: golf the following `let` once `TwoSidedIdeal.span` is defined
let I := TwoSidedIdeal.mk' (Set.range (x * ·)) ⟨0, by simp⟩
(by rintro _ _ ⟨x, rfl⟩ ⟨y, rfl⟩; exact ⟨x + y, mul_add _ _ _⟩)
(by rintro _ ⟨x, rfl⟩; exact ⟨-x, by simp⟩)
(by rintro a _ ⟨c, rfl⟩; exact ⟨a * c, by dsimp; rw [← mul_assoc, ← hx1, mul_assoc]⟩)
(by rintro _ b ⟨a, rfl⟩; exact ⟨a * b, by dsimp; rw [← mul_assoc, ← hx1, mul_assoc]⟩)
have mem : 1 ∈ I := one_mem_of_ne_zero_mem I hx2 (by simpa [I, mem_mk'] using ⟨1, by simp⟩)
simp only [TwoSidedIdeal.mem_mk', Set.mem_range, I] at mem
obtain ⟨y, hy⟩ := mem
refine ⟨⟨y, Subring.mem_center_iff.2 fun a ↦ ?_⟩, by ext; exact hy⟩
calc a * y
_ = (x * y) * a * y := by rw [hy, one_mul]
_ = (y * x) * a * y := by rw [hx1]
_ = y * (x * a) * y := by rw [mul_assoc y x a]
_ = y * (a * x) * y := by rw [hx1]
_ = y * ((a * x) * y) := by rw [mul_assoc]
_ = y * (a * (x * y)) := by rw [mul_assoc a x y]
_ = y * a := by rw [hy, mul_one]
end IsSimpleRing
lemma isSimpleRing_iff_isField (A : Type*) [CommRing A] : IsSimpleRing A ↔ IsField A :=
⟨fun _ ↦ Subring.topEquiv.symm.toMulEquiv.isField <| by
rw [← Subring.center_eq_top A]; exact IsSimpleRing.isField_center A,
fun h ↦ letI := h.toField; inferInstance⟩ |
.lake/packages/mathlib/Mathlib/RingTheory/SimpleRing/Principal.lean | import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.RingTheory.SimpleRing.Field
import Mathlib.RingTheory.TwoSidedIdeal.Operations
/-!
# A commutative simple ring is a principal ideal domain
Indeed, it is a field.
-/
variable {R : Type*} [CommRing R] [IsSimpleRing R]
instance : IsSimpleOrder (Ideal R) := TwoSidedIdeal.orderIsoIdeal.symm.isSimpleOrder
instance IsPrincipalIdealRing.of_isSimpleRing :
IsPrincipalIdealRing R :=
((isSimpleRing_iff_isField _).mp ‹_›).isPrincipalIdealRing
instance IsDomain.of_isSimpleRing :
IsDomain R :=
((isSimpleRing_iff_isField _).mp ‹_›).isDomain |
.lake/packages/mathlib/Mathlib/RingTheory/NonUnitalSubring/Basic.lean | import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Algebra.Group.Submonoid.BigOperators
import Mathlib.GroupTheory.Subsemigroup.Center
import Mathlib.RingTheory.NonUnitalSubring.Defs
import Mathlib.RingTheory.NonUnitalSubsemiring.Basic
/-!
# `NonUnitalSubring`s
Let `R` be a non-unital ring.
We prove that non-unital subrings are a complete lattice, and that you can `map` (pushforward) and
`comap` (pull back) them along ring homomorphisms.
We define the `closure` construction from `Set R` to `NonUnitalSubring R`, sending a subset of
`R` to the non-unital subring it generates, and prove that it is a Galois insertion.
## Main definitions
Notation used here:
`(R : Type u) [NonUnitalRing R] (S : Type u) [NonUnitalRing S] (f g : R →ₙ+* S)`
`(A : NonUnitalSubring R) (B : NonUnitalSubring S) (s : Set R)`
* `instance : CompleteLattice (NonUnitalSubring R)` : the complete lattice structure on the
non-unital subrings.
* `NonUnitalSubring.center` : the center of a non-unital ring `R`.
* `NonUnitalSubring.closure` : non-unital subring closure of a set, i.e., the smallest
non-unital subring that includes the set.
* `NonUnitalSubring.gi` : `closure : Set M → NonUnitalSubring M` and coercion
`coe : NonUnitalSubring M → Set M`
form a `GaloisInsertion`.
* `comap f B : NonUnitalSubring A` : the preimage of a non-unital subring `B` along the
non-unital ring homomorphism `f`
* `map f A : NonUnitalSubring B` : the image of a non-unital subring `A` along the
non-unital ring homomorphism `f`.
* `Prod A B : NonUnitalSubring (R × S)` : the product of non-unital subrings
* `f.range : NonUnitalSubring B` : the range of the non-unital ring homomorphism `f`.
* `eq_locus f g : NonUnitalSubring R` : given non-unital ring homomorphisms `f g : R →ₙ+* S`,
the non-unital subring of `R` where `f x = g x`
## Implementation notes
A non-unital subring is implemented as a `NonUnitalSubsemiring` which is also an
additive subgroup.
Lattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although
`∈` is defined as membership of a non-unital subring's underlying set.
## Tags
non-unital subring
-/
universe u v w
section Basic
variable {R : Type u} {S : Type v} [NonUnitalNonAssocRing R]
namespace NonUnitalSubring
variable (s : NonUnitalSubring R)
/-- Sum of a list of elements in a non-unital subring is in the non-unital subring. -/
protected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.sum ∈ s :=
list_sum_mem
/-- Sum of a multiset of elements in a `NonUnitalSubring` of a `NonUnitalRing` is
in the `NonUnitalSubring`. -/
protected theorem multiset_sum_mem {R} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)
(m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.sum ∈ s :=
multiset_sum_mem _
/-- Sum of elements in a `NonUnitalSubring` of a `NonUnitalRing` indexed by a `Finset`
is in the `NonUnitalSubring`. -/
protected theorem sum_mem {R : Type*} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)
{ι : Type*} {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∑ i ∈ t, f i) ∈ s :=
sum_mem h
/-! ## top -/
/-- The non-unital subring `R` of the ring `R`. -/
instance : Top (NonUnitalSubring R) :=
⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubgroup R) with }⟩
@[simp]
theorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubring R) :=
Set.mem_univ x
@[simp]
theorem coe_top : ((⊤ : NonUnitalSubring R) : Set R) = Set.univ :=
rfl
/-- The ring equiv between the top element of `NonUnitalSubring R` and `R`. -/
@[simps!]
def topEquiv : (⊤ : NonUnitalSubring R) ≃+* R := NonUnitalSubsemiring.topEquiv
end NonUnitalSubring
end Basic
section Hom
namespace NonUnitalSubring
variable {F : Type w} {R : Type u} {S : Type v} {T : Type*}
[NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] [NonUnitalNonAssocRing T]
[FunLike F R S] [NonUnitalRingHomClass F R S] (s : NonUnitalSubring R)
/-! ## comap -/
/-- The preimage of a `NonUnitalSubring` along a ring homomorphism is a `NonUnitalSubring`. -/
def comap {F : Type w} {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
[FunLike F R S] [NonUnitalRingHomClass F R S] (f : F) (s : NonUnitalSubring S) :
NonUnitalSubring R :=
{ s.toSubsemigroup.comap (f : R →ₙ* S), s.toAddSubgroup.comap (f : R →+ S) with
carrier := f ⁻¹' s.carrier }
@[simp]
theorem coe_comap (s : NonUnitalSubring S) (f : F) : (s.comap f : Set R) = f ⁻¹' s :=
rfl
@[simp]
theorem mem_comap {s : NonUnitalSubring S} {f : F} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=
Iff.rfl
theorem comap_comap (s : NonUnitalSubring T) (g : S →ₙ+* T) (f : R →ₙ+* S) :
(s.comap g).comap f = s.comap (g.comp f) :=
rfl
/-! ## map -/
/-- The image of a `NonUnitalSubring` along a ring homomorphism is a `NonUnitalSubring`. -/
def map {F : Type w} {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
[FunLike F R S] [NonUnitalRingHomClass F R S] (f : F) (s : NonUnitalSubring R) :
NonUnitalSubring S :=
{ s.toSubsemigroup.map (f : R →ₙ* S), s.toAddSubgroup.map (f : R →+ S) with
carrier := f '' s.carrier }
@[simp]
theorem coe_map (f : F) (s : NonUnitalSubring R) : (s.map f : Set S) = f '' s :=
rfl
@[simp]
theorem mem_map {f : F} {s : NonUnitalSubring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=
Set.mem_image _ _ _
@[simp]
theorem map_id : s.map (NonUnitalRingHom.id R) = s :=
SetLike.coe_injective <| Set.image_id _
theorem map_map (g : S →ₙ+* T) (f : R →ₙ+* S) : (s.map f).map g = s.map (g.comp f) :=
SetLike.coe_injective <| Set.image_image _ _ _
theorem map_le_iff_le_comap {f : F} {s : NonUnitalSubring R} {t : NonUnitalSubring S} :
s.map f ≤ t ↔ s ≤ t.comap f :=
Set.image_subset_iff
theorem gc_map_comap (f : F) :
GaloisConnection (map f : NonUnitalSubring R → NonUnitalSubring S) (comap f) := fun _S _T =>
map_le_iff_le_comap
/-- A `NonUnitalSubring` is isomorphic to its image under an injective function -/
noncomputable def equivMapOfInjective (f : F) (hf : Function.Injective (f : R → S)) :
s ≃+* s.map f :=
{
Equiv.Set.image f s
hf with
map_mul' := fun _ _ => Subtype.ext (map_mul f _ _)
map_add' := fun _ _ => Subtype.ext (map_add f _ _) }
@[simp]
theorem coe_equivMapOfInjective_apply (f : F) (hf : Function.Injective f) (x : s) :
(equivMapOfInjective s f hf x : S) = f x :=
rfl
end NonUnitalSubring
namespace NonUnitalRingHom
variable {R : Type u} {S : Type v} {T : Type*}
[NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] [NonUnitalNonAssocRing T]
(g : S →ₙ+* T) (f : R →ₙ+* S)
/-! ## range -/
/-- The range of a ring homomorphism, as a `NonUnitalSubring` of the target.
See Note [range copy pattern]. -/
def range {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
(f : R →ₙ+* S) : NonUnitalSubring S :=
((⊤ : NonUnitalSubring R).map f).copy (Set.range f) Set.image_univ.symm
@[simp]
theorem coe_range : (f.range : Set S) = Set.range f :=
rfl
@[simp]
theorem mem_range {f : R →ₙ+* S} {y : S} : y ∈ f.range ↔ ∃ x, f x = y :=
Iff.rfl
theorem range_eq_map (f : R →ₙ+* S) : f.range = NonUnitalSubring.map f ⊤ := by ext; simp
theorem mem_range_self (f : R →ₙ+* S) (x : R) : f x ∈ f.range :=
mem_range.mpr ⟨x, rfl⟩
theorem map_range : f.range.map g = (g.comp f).range := by
simpa only [range_eq_map] using (⊤ : NonUnitalSubring R).map_map g f
/-- The range of a ring homomorphism is a fintype, if the domain is a fintype.
Note: this instance can form a diamond with `Subtype.fintype` in the
presence of `Fintype S`. -/
instance fintypeRange [Fintype R] [DecidableEq S] (f : R →ₙ+* S) : Fintype (range f) :=
Set.fintypeRange f
end NonUnitalRingHom
namespace NonUnitalSubring
section Order
variable {R : Type u} [NonUnitalNonAssocRing R]
/-! ## bot -/
instance : Bot (NonUnitalSubring R) :=
⟨(0 : R →ₙ+* R).range⟩
instance : Inhabited (NonUnitalSubring R) :=
⟨⊥⟩
theorem coe_bot : ((⊥ : NonUnitalSubring R) : Set R) = {0} :=
(NonUnitalRingHom.coe_range (0 : R →ₙ+* R)).trans (@Set.range_const R R _ 0)
theorem mem_bot {x : R} : x ∈ (⊥ : NonUnitalSubring R) ↔ x = 0 :=
show x ∈ ((⊥ : NonUnitalSubring R) : Set R) ↔ x = 0 by rw [coe_bot, Set.mem_singleton_iff]
/-! ## inf -/
/-- The inf of two `NonUnitalSubring`s is their intersection. -/
instance : Min (NonUnitalSubring R) :=
⟨fun s t =>
{ s.toSubsemigroup ⊓ t.toSubsemigroup, s.toAddSubgroup ⊓ t.toAddSubgroup with
carrier := s ∩ t }⟩
@[simp]
theorem coe_inf (p p' : NonUnitalSubring R) :
((p ⊓ p' : NonUnitalSubring R) : Set R) = (p : Set R) ∩ p' :=
rfl
@[simp]
theorem mem_inf {p p' : NonUnitalSubring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=
Iff.rfl
instance : InfSet (NonUnitalSubring R) :=
⟨fun s =>
NonUnitalSubring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, NonUnitalSubring.toSubsemigroup t)
(⨅ t ∈ s, NonUnitalSubring.toAddSubgroup t) (by simp) (by simp)⟩
@[simp, norm_cast]
theorem coe_sInf (S : Set (NonUnitalSubring R)) :
((sInf S : NonUnitalSubring R) : Set R) = ⋂ s ∈ S, ↑s :=
rfl
theorem mem_sInf {S : Set (NonUnitalSubring R)} {x : R} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p :=
Set.mem_iInter₂
@[simp, norm_cast]
theorem coe_iInf {ι : Sort*} {S : ι → NonUnitalSubring R} : (↑(⨅ i, S i) : Set R) = ⋂ i, S i := by
simp only [iInf, coe_sInf, Set.biInter_range]
theorem mem_iInf {ι : Sort*} {S : ι → NonUnitalSubring R} {x : R} :
(x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i := by simp only [iInf, mem_sInf, Set.forall_mem_range]
@[simp]
theorem sInf_toSubsemigroup (s : Set (NonUnitalSubring R)) :
(sInf s).toSubsemigroup = ⨅ t ∈ s, NonUnitalSubring.toSubsemigroup t :=
mk'_toSubsemigroup _ _
@[simp]
theorem sInf_toAddSubgroup (s : Set (NonUnitalSubring R)) :
(sInf s).toAddSubgroup = ⨅ t ∈ s, NonUnitalSubring.toAddSubgroup t :=
mk'_toAddSubgroup _ _
/-- `NonUnitalSubring`s of a ring form a complete lattice. -/
instance : CompleteLattice (NonUnitalSubring R) :=
{ completeLatticeOfInf (NonUnitalSubring R) fun _s =>
IsGLB.of_image (@fun _ _ : NonUnitalSubring R => SetLike.coe_subset_coe)
isGLB_biInf with
bot := ⊥
bot_le := fun s _x hx => (mem_bot.mp hx).symm ▸ zero_mem s
top := ⊤
le_top := fun _ _ _ => trivial
inf := (· ⊓ ·)
inf_le_left := fun _ _ _ => And.left
inf_le_right := fun _ _ _ => And.right
le_inf := fun _s _t₁ _t₂ h₁ h₂ _x hx => ⟨h₁ hx, h₂ hx⟩ }
theorem eq_top_iff' (A : NonUnitalSubring R) : A = ⊤ ↔ ∀ x : R, x ∈ A :=
eq_top_iff.trans ⟨fun h m => h <| mem_top m, fun h m _ => h m⟩
end Order
/-! ## Center of a ring -/
section Center
variable {R : Type u}
section NonUnitalNonAssocRing
variable (R) [NonUnitalNonAssocRing R]
/-- The center of a ring `R` is the set of elements that commute with everything in `R` -/
def center : NonUnitalSubring R :=
{ NonUnitalSubsemiring.center R with
neg_mem' := Set.neg_mem_center }
theorem coe_center : ↑(center R) = Set.center R :=
rfl
@[simp]
theorem center_toNonUnitalSubsemiring :
(center R).toNonUnitalSubsemiring = NonUnitalSubsemiring.center R :=
rfl
/-- The center is commutative and associative. -/
instance center.instNonUnitalCommRing : NonUnitalCommRing (center R) :=
{ NonUnitalSubsemiring.center.instNonUnitalCommSemiring R,
inferInstanceAs <| NonUnitalNonAssocRing (center R) with }
variable {R}
/-- The center of isomorphic (not necessarily unital or associative) rings are isomorphic. -/
@[simps!] def centerCongr {S} [NonUnitalNonAssocRing S] (e : R ≃+* S) : center R ≃+* center S :=
NonUnitalSubsemiring.centerCongr e
/-- The center of a (not necessarily unital or associative) ring
is isomorphic to the center of its opposite. -/
@[simps!] def centerToMulOpposite : center R ≃+* center Rᵐᵒᵖ :=
NonUnitalSubsemiring.centerToMulOpposite
end NonUnitalNonAssocRing
section NonUnitalRing
variable [NonUnitalRing R]
-- no instance diamond, unlike the unital version
example : (center.instNonUnitalCommRing _).toNonUnitalRing =
NonUnitalSubringClass.toNonUnitalRing (center R) := by
with_reducible_and_instances rfl
theorem mem_center_iff {z : R} : z ∈ center R ↔ ∀ g, g * z = z * g := Subsemigroup.mem_center_iff
instance decidableMemCenter [DecidableEq R] [Fintype R] : DecidablePred (· ∈ center R) := fun _ =>
decidable_of_iff' _ mem_center_iff
@[simp]
theorem center_eq_top (R) [NonUnitalCommRing R] : center R = ⊤ :=
SetLike.coe_injective (Set.center_eq_univ R)
end NonUnitalRing
end Center
/-! ## `NonUnitalSubring` closure of a subset -/
variable {F : Type w} {R : Type u} {S : Type v}
[NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
[FunLike F R S] [NonUnitalRingHomClass F R S]
/-- The `NonUnitalSubring` generated by a set. -/
def closure (s : Set R) : NonUnitalSubring R :=
sInf {S | s ⊆ S}
theorem mem_closure {x : R} {s : Set R} : x ∈ closure s ↔ ∀ S : NonUnitalSubring R, s ⊆ S → x ∈ S :=
mem_sInf
/-- The `NonUnitalSubring` generated by a set includes the set. -/
@[simp, aesop safe 20 (rule_sets := [SetLike])]
theorem subset_closure {s : Set R} : s ⊆ closure s := fun _x hx => mem_closure.2 fun _S hS => hS hx
@[aesop 80% (rule_sets := [SetLike])]
theorem mem_closure_of_mem {s : Set R} {x : R} (hx : x ∈ s) : x ∈ closure s := subset_closure hx
theorem notMem_of_notMem_closure {s : Set R} {P : R} (hP : P ∉ closure s) : P ∉ s := fun h =>
hP (subset_closure h)
@[deprecated (since := "2025-05-23")] alias not_mem_of_not_mem_closure := notMem_of_notMem_closure
/-- A `NonUnitalSubring` `t` includes `closure s` if and only if it includes `s`. -/
@[simp]
theorem closure_le {s : Set R} {t : NonUnitalSubring R} : closure s ≤ t ↔ s ⊆ t :=
⟨Set.Subset.trans subset_closure, fun h => sInf_le h⟩
/-- `NonUnitalSubring` closure of a set is monotone in its argument: if `s ⊆ t`,
then `closure s ≤ closure t`. -/
@[gcongr]
theorem closure_mono ⦃s t : Set R⦄ (h : s ⊆ t) : closure s ≤ closure t :=
closure_le.2 <| Set.Subset.trans h subset_closure
theorem closure_eq_of_le {s : Set R} {t : NonUnitalSubring R} (h₁ : s ⊆ t) (h₂ : t ≤ closure s) :
closure s = t :=
le_antisymm (closure_le.2 h₁) h₂
/-- An induction principle for closure membership. If `p` holds for `0`, `1`, and all elements
of `s`, and is preserved under addition, negation, and multiplication, then `p` holds for all
elements of the closure of `s`. -/
@[elab_as_elim]
theorem closure_induction {s : Set R} {p : (x : R) → x ∈ closure s → Prop}
(mem : ∀ (x) (hx : x ∈ s), p x (subset_closure hx)) (zero : p 0 (zero_mem _))
(add : ∀ x y hx hy, p x hx → p y hy → p (x + y) (add_mem hx hy))
(neg : ∀ x hx, p x hx → p (-x) (neg_mem hx))
(mul : ∀ x y hx hy, p x hx → p y hy → p (x * y) (mul_mem hx hy))
{x} (hx : x ∈ closure s) : p x hx :=
let K : NonUnitalSubring R :=
{ carrier := { x | ∃ hx, p x hx }
mul_mem' := fun ⟨_, hpx⟩ ⟨_, hpy⟩ ↦ ⟨_, mul _ _ _ _ hpx hpy⟩
add_mem' := fun ⟨_, hpx⟩ ⟨_, hpy⟩ ↦ ⟨_, add _ _ _ _ hpx hpy⟩
neg_mem' := fun ⟨_, hpx⟩ ↦ ⟨_, neg _ _ hpx⟩
zero_mem' := ⟨_, zero⟩ }
closure_le (t := K) |>.mpr (fun y hy ↦ ⟨subset_closure hy, mem y hy⟩) hx |>.elim fun _ ↦ id
/-- An induction principle for closure membership, for predicates with two arguments. -/
@[elab_as_elim]
theorem closure_induction₂ {s : Set R} {p : (x y : R) → x ∈ closure s → y ∈ closure s → Prop}
(mem_mem : ∀ (x) (y) (hx : x ∈ s) (hy : y ∈ s), p x y (subset_closure hx) (subset_closure hy))
(zero_left : ∀ x hx, p 0 x (zero_mem _) hx) (zero_right : ∀ x hx, p x 0 hx (zero_mem _))
(neg_left : ∀ x y hx hy, p x y hx hy → p (-x) y (neg_mem hx) hy)
(neg_right : ∀ x y hx hy, p x y hx hy → p x (-y) hx (neg_mem hy))
(add_left : ∀ x y z hx hy hz, p x z hx hz → p y z hy hz → p (x + y) z (add_mem hx hy) hz)
(add_right : ∀ x y z hx hy hz, p x y hx hy → p x z hx hz → p x (y + z) hx (add_mem hy hz))
(mul_left : ∀ x y z hx hy hz, p x z hx hz → p y z hy hz → p (x * y) z (mul_mem hx hy) hz)
(mul_right : ∀ x y z hx hy hz, p x y hx hy → p x z hx hz → p x (y * z) hx (mul_mem hy hz))
{x y : R} (hx : x ∈ closure s) (hy : y ∈ closure s) :
p x y hx hy := by
induction hy using closure_induction with
| mem z hz => induction hx using closure_induction with
| mem _ h => exact mem_mem _ _ h hz
| zero => exact zero_left _ _
| mul _ _ _ _ h₁ h₂ => exact mul_left _ _ _ _ _ _ h₁ h₂
| add _ _ _ _ h₁ h₂ => exact add_left _ _ _ _ _ _ h₁ h₂
| neg _ _ h => exact neg_left _ _ _ _ h
| zero => exact zero_right x hx
| mul _ _ _ _ h₁ h₂ => exact mul_right _ _ _ _ _ _ h₁ h₂
| add _ _ _ _ h₁ h₂ => exact add_right _ _ _ _ _ _ h₁ h₂
| neg _ _ h => exact neg_right _ _ _ _ h
theorem mem_closure_iff {s : Set R} {x} :
x ∈ closure s ↔ x ∈ AddSubgroup.closure (Subsemigroup.closure s : Set R) :=
⟨fun h => by
induction h using closure_induction with
| mem _ hx => exact AddSubgroup.subset_closure (Subsemigroup.subset_closure hx)
| zero => exact zero_mem _
| add _ _ _ _ hx hy => exact add_mem hx hy
| neg x _ hx => exact neg_mem hx
| mul _ _ _hx _hy hx hy =>
clear _hx _hy
induction hx, hy using AddSubgroup.closure_induction₂ with
| mem _ _ hx hy => exact AddSubgroup.subset_closure (mul_mem hx hy)
| zero_left => simp
| zero_right => simp
| add_left _ _ _ _ _ _ h₁ h₂ => simpa [add_mul] using add_mem h₁ h₂
| add_right _ _ _ _ _ _ h₁ h₂ => simpa [mul_add] using add_mem h₁ h₂
| neg_left _ _ _ _ h => simpa [neg_mul] using neg_mem h
| neg_right _ _ _ _ h => simpa [mul_neg] using neg_mem h,
fun h => by
induction h using AddSubgroup.closure_induction with
| mem _ hx => induction hx using Subsemigroup.closure_induction with
| mem _ h => exact subset_closure h
| mul _ _ _ _ h₁ h₂ => exact mul_mem h₁ h₂
| zero => exact zero_mem _
| add _ _ _ _ h₁ h₂ => exact add_mem h₁ h₂
| neg _ _ h => exact neg_mem h⟩
/-- If all elements of `s : Set A` commute pairwise, then `closure s` is a commutative ring. -/
def closureNonUnitalCommRingOfComm {R : Type u} [NonUnitalRing R] {s : Set R}
(hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) : NonUnitalCommRing (closure s) :=
{ (closure s).toNonUnitalRing with
mul_comm := fun ⟨x, hx⟩ ⟨y, hy⟩ => by
ext
simp only [MulMemClass.mk_mul_mk]
induction hx, hy using closure_induction₂ with
| mem_mem x y hx hy => exact hcomm x hx y hy
| zero_left x _ => exact Commute.zero_left x
| zero_right x _ => exact Commute.zero_right x
| mul_left _ _ _ _ _ _ h₁ h₂ => exact Commute.mul_left h₁ h₂
| mul_right _ _ _ _ _ _ h₁ h₂ => exact Commute.mul_right h₁ h₂
| add_left _ _ _ _ _ _ h₁ h₂ => exact Commute.add_left h₁ h₂
| add_right _ _ _ _ _ _ h₁ h₂ => exact Commute.add_right h₁ h₂
| neg_left _ _ _ _ h => exact Commute.neg_left h
| neg_right _ _ _ _ h => exact Commute.neg_right h }
variable (R) in
/-- `closure` forms a Galois insertion with the coercion to set. -/
protected def gi : GaloisInsertion (@closure R _) SetLike.coe where
choice s _ := closure s
gc _s _t := closure_le
le_l_u _s := subset_closure
choice_eq _s _h := rfl
/-- Closure of a `NonUnitalSubring` `S` equals `S`. -/
@[simp]
theorem closure_eq (s : NonUnitalSubring R) : closure (s : Set R) = s :=
(NonUnitalSubring.gi R).l_u_eq s
@[simp]
theorem closure_empty : closure (∅ : Set R) = ⊥ :=
(NonUnitalSubring.gi R).gc.l_bot
@[simp]
theorem closure_univ : closure (Set.univ : Set R) = ⊤ :=
@coe_top R _ ▸ closure_eq ⊤
theorem closure_union (s t : Set R) : closure (s ∪ t) = closure s ⊔ closure t :=
(NonUnitalSubring.gi R).gc.l_sup
theorem closure_iUnion {ι} (s : ι → Set R) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=
(NonUnitalSubring.gi R).gc.l_iSup
theorem closure_sUnion (s : Set (Set R)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=
(NonUnitalSubring.gi R).gc.l_sSup
theorem map_sup (s t : NonUnitalSubring R) (f : F) : (s ⊔ t).map f = s.map f ⊔ t.map f :=
(gc_map_comap f).l_sup
theorem map_iSup {ι : Sort*} (f : F) (s : ι → NonUnitalSubring R) :
(iSup s).map f = ⨆ i, (s i).map f :=
(gc_map_comap f).l_iSup
theorem map_inf (s t : NonUnitalSubring R) (f : F) (hf : Function.Injective f) :
(s ⊓ t).map f = s.map f ⊓ t.map f := SetLike.coe_injective (Set.image_inter hf)
theorem map_iInf {ι : Sort*} [Nonempty ι] (f : F) (hf : Function.Injective f)
(s : ι → NonUnitalSubring R) : (iInf s).map f = ⨅ i, (s i).map f := by
apply SetLike.coe_injective
simpa using (Set.injOn_of_injective hf).image_iInter_eq (s := SetLike.coe ∘ s)
theorem comap_inf (s t : NonUnitalSubring S) (f : F) : (s ⊓ t).comap f = s.comap f ⊓ t.comap f :=
(gc_map_comap f).u_inf
theorem comap_iInf {ι : Sort*} (f : F) (s : ι → NonUnitalSubring S) :
(iInf s).comap f = ⨅ i, (s i).comap f :=
(gc_map_comap f).u_iInf
@[simp]
theorem map_bot (f : R →ₙ+* S) : (⊥ : NonUnitalSubring R).map f = ⊥ :=
(gc_map_comap f).l_bot
@[simp]
theorem comap_top (f : R →ₙ+* S) : (⊤ : NonUnitalSubring S).comap f = ⊤ :=
(gc_map_comap f).u_top
/-- Given `NonUnitalSubring`s `s`, `t` of rings `R`, `S` respectively, `s.prod t` is `s ×ˢ t`
as a `NonUnitalSubring` of `R × S`. -/
def prod (s : NonUnitalSubring R) (t : NonUnitalSubring S) : NonUnitalSubring (R × S) :=
{ s.toSubsemigroup.prod t.toSubsemigroup, s.toAddSubgroup.prod t.toAddSubgroup with
carrier := s ×ˢ t }
@[norm_cast]
theorem coe_prod (s : NonUnitalSubring R) (t : NonUnitalSubring S) :
(s.prod t : Set (R × S)) = (s : Set R) ×ˢ t :=
rfl
theorem mem_prod {s : NonUnitalSubring R} {t : NonUnitalSubring S} {p : R × S} :
p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t :=
Iff.rfl
@[mono]
theorem prod_mono ⦃s₁ s₂ : NonUnitalSubring R⦄ (hs : s₁ ≤ s₂) ⦃t₁ t₂ : NonUnitalSubring S⦄
(ht : t₁ ≤ t₂) : s₁.prod t₁ ≤ s₂.prod t₂ :=
Set.prod_mono hs ht
theorem prod_mono_right (s : NonUnitalSubring R) :
Monotone fun t : NonUnitalSubring S => s.prod t :=
prod_mono (le_refl s)
theorem prod_mono_left (t : NonUnitalSubring S) : Monotone fun s : NonUnitalSubring R => s.prod t :=
fun _s₁ _s₂ hs => prod_mono hs (le_refl t)
theorem prod_top (s : NonUnitalSubring R) :
s.prod (⊤ : NonUnitalSubring S) = s.comap (NonUnitalRingHom.fst R S) :=
ext fun x => by simp [mem_prod]
theorem top_prod (s : NonUnitalSubring S) :
(⊤ : NonUnitalSubring R).prod s = s.comap (NonUnitalRingHom.snd R S) :=
ext fun x => by simp [mem_prod]
@[simp]
theorem top_prod_top : (⊤ : NonUnitalSubring R).prod (⊤ : NonUnitalSubring S) = ⊤ :=
(top_prod _).trans <| comap_top _
/-- Product of `NonUnitalSubring`s is isomorphic to their product as rings. -/
def prodEquiv (s : NonUnitalSubring R) (t : NonUnitalSubring S) : s.prod t ≃+* s × t :=
{ Equiv.Set.prod (s : Set R) (t : Set S) with
map_mul' := fun _ _ => rfl
map_add' := fun _ _ => rfl }
/-- The underlying set of a non-empty directed Sup of `NonUnitalSubring`s is just a union of the
`NonUnitalSubring`s. Note that this fails without the directedness assumption (the union of two
`NonUnitalSubring`s is typically not a `NonUnitalSubring`) -/
theorem mem_iSup_of_directed {ι} [hι : Nonempty ι] {S : ι → NonUnitalSubring R}
(hS : Directed (· ≤ ·) S) {x : R} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by
refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩
let U : NonUnitalSubring R :=
NonUnitalSubring.mk' (⋃ i, (S i : Set R)) (⨆ i, (S i).toSubsemigroup) (⨆ i, (S i).toAddSubgroup)
(Subsemigroup.coe_iSup_of_directed hS) (AddSubgroup.coe_iSup_of_directed hS)
suffices ⨆ i, S i ≤ U by simpa [U] using @this x
exact iSup_le fun i x hx ↦ Set.mem_iUnion.2 ⟨i, hx⟩
theorem coe_iSup_of_directed {ι} [Nonempty ι] {S : ι → NonUnitalSubring R}
(hS : Directed (· ≤ ·) S) : ((⨆ i, S i : NonUnitalSubring R) : Set R) = ⋃ i, S i :=
Set.ext fun x ↦ by simp [mem_iSup_of_directed hS]
theorem mem_sSup_of_directedOn {S : Set (NonUnitalSubring R)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) {x : R} : x ∈ sSup S ↔ ∃ s ∈ S, x ∈ s := by
haveI : Nonempty S := Sne.to_subtype
simp only [sSup_eq_iSup', mem_iSup_of_directed hS.directed_val, SetCoe.exists,
exists_prop]
theorem coe_sSup_of_directedOn {S : Set (NonUnitalSubring R)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) : (↑(sSup S) : Set R) = ⋃ s ∈ S, ↑s :=
Set.ext fun x => by simp [mem_sSup_of_directedOn Sne hS]
theorem mem_map_equiv {f : R ≃+* S} {K : NonUnitalSubring R} {x : S} :
x ∈ K.map (f : R →ₙ+* S) ↔ f.symm x ∈ K :=
@Set.mem_image_equiv _ _ (K : Set R) f.toEquiv x
theorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : NonUnitalSubring R) :
K.map (f : R →ₙ+* S) = K.comap f.symm :=
SetLike.coe_injective (f.toEquiv.image_eq_preimage_symm K)
theorem comap_equiv_eq_map_symm (f : R ≃+* S) (K : NonUnitalSubring S) :
K.comap (f : R →ₙ+* S) = K.map f.symm :=
(map_equiv_eq_comap_symm f.symm K).symm
end NonUnitalSubring
namespace NonUnitalRingHom
variable {R : Type u} {S : Type v}
[NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
open NonUnitalSubring
/-- Restriction of a ring homomorphism to its range interpreted as a `NonUnitalSubring`.
This is the bundled version of `Set.rangeFactorization`. -/
def rangeRestrict (f : R →ₙ+* S) : R →ₙ+* f.range :=
NonUnitalRingHom.codRestrict f f.range fun x => ⟨x, rfl⟩
@[simp]
theorem coe_rangeRestrict (f : R →ₙ+* S) (x : R) : (f.rangeRestrict x : S) = f x :=
rfl
theorem rangeRestrict_surjective (f : R →ₙ+* S) : Function.Surjective f.rangeRestrict :=
fun ⟨_y, hy⟩ =>
let ⟨x, hx⟩ := mem_range.mp hy
⟨x, Subtype.ext hx⟩
theorem range_eq_top {f : R →ₙ+* S} :
f.range = (⊤ : NonUnitalSubring S) ↔ Function.Surjective f :=
SetLike.ext'_iff.trans <| Iff.trans (by rw [coe_range, coe_top]) Set.range_eq_univ
/-- The range of a surjective ring homomorphism is the whole of the codomain. -/
@[simp]
theorem range_eq_top_of_surjective (f : R →ₙ+* S) (hf : Function.Surjective f) :
f.range = (⊤ : NonUnitalSubring S) :=
range_eq_top.2 hf
/-- The `NonUnitalSubring` of elements `x : R` such that `f x = g x`, i.e.,
the equalizer of f and g as a `NonUnitalSubring` of R -/
def eqLocus (f g : R →ₙ+* S) : NonUnitalSubring R :=
{ (f : R →ₙ* S).eqLocus g, (f : R →+ S).eqLocus g with carrier := {x | f x = g x} }
@[simp]
theorem mem_eqLocus {f g : R →ₙ+* S} {x : R} : x ∈ f.eqLocus g ↔ f x = g x := Iff.rfl
@[simp]
theorem eqLocus_same (f : R →ₙ+* S) : f.eqLocus f = ⊤ :=
SetLike.ext fun _ => eq_self_iff_true _
/-- If two ring homomorphisms are equal on a set, then they are equal on its
`NonUnitalSubring` closure. -/
theorem eqOn_set_closure {f g : R →ₙ+* S} {s : Set R} (h : Set.EqOn f g s) :
Set.EqOn f g (closure s) :=
show closure s ≤ f.eqLocus g from closure_le.2 h
theorem eq_of_eqOn_set_top {f g : R →ₙ+* S} (h : Set.EqOn f g (⊤ : NonUnitalSubring R)) : f = g :=
ext fun _x => h trivial
theorem eq_of_eqOn_set_dense {s : Set R} (hs : closure s = ⊤) {f g : R →ₙ+* S} (h : s.EqOn f g) :
f = g :=
eq_of_eqOn_set_top <| hs ▸ eqOn_set_closure h
theorem closure_preimage_le (f : R →ₙ+* S) (s : Set S) : closure (f ⁻¹' s) ≤ (closure s).comap f :=
closure_le.2 fun _x hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx
/-- The image under a ring homomorphism of the `NonUnitalSubring` generated by a set equals
the `NonUnitalSubring` generated by the image of the set. -/
theorem map_closure (f : R →ₙ+* S) (s : Set R) : (closure s).map f = closure (f '' s) :=
Set.image_preimage.l_comm_of_u_comm (gc_map_comap f) (NonUnitalSubring.gi S).gc
(NonUnitalSubring.gi R).gc fun _ ↦ rfl
end NonUnitalRingHom
namespace NonUnitalSubring
variable {R : Type u} {S : Type v}
[NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
open NonUnitalRingHom
@[simp]
theorem range_subtype (s : NonUnitalSubring R) : (NonUnitalSubringClass.subtype s).range = s :=
SetLike.coe_injective <| (coe_srange _).trans Subtype.range_coe
theorem range_fst : NonUnitalRingHom.srange (fst R S) = ⊤ :=
NonUnitalSubsemiring.range_fst
theorem range_snd : NonUnitalRingHom.srange (snd R S) = ⊤ :=
NonUnitalSubsemiring.range_snd
end NonUnitalSubring
namespace RingEquiv
variable {R : Type u} {S : Type v} [NonUnitalRing R] [NonUnitalRing S] {s t : NonUnitalSubring R}
/-- Makes the identity isomorphism from a proof two `NonUnitalSubring`s of a multiplicative
monoid are equal. -/
def nonUnitalSubringCongr (h : s = t) : s ≃+* t :=
{
Equiv.setCongr <| congr_arg _ h with
map_mul' := fun _ _ => rfl
map_add' := fun _ _ => rfl }
/-- Restrict a ring homomorphism with a left inverse to a ring isomorphism to its
`RingHom.range`. -/
def ofLeftInverse' {g : S → R} {f : R →ₙ+* S} (h : Function.LeftInverse g f) : R ≃+* f.range :=
{ f.rangeRestrict with
toFun := fun x => f.rangeRestrict x
invFun := fun x => (g ∘ NonUnitalSubringClass.subtype f.range) x
left_inv := h
right_inv := fun x =>
Subtype.ext <|
let ⟨x', hx'⟩ := NonUnitalRingHom.mem_range.mp x.prop
show f (g x) = x by rw [← hx', h x'] }
@[simp]
theorem ofLeftInverse'_apply {g : S → R} {f : R →ₙ+* S} (h : Function.LeftInverse g f) (x : R) :
↑(ofLeftInverse' h x) = f x :=
rfl
@[simp]
theorem ofLeftInverse'_symm_apply {g : S → R} {f : R →ₙ+* S} (h : Function.LeftInverse g f)
(x : f.range) : (ofLeftInverse' h).symm x = g x :=
rfl
end RingEquiv
namespace NonUnitalSubring
variable {F : Type w} {R : Type u} {S : Type v}
[NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
[FunLike F R S] [NonUnitalRingHomClass F R S]
theorem closure_preimage_le (f : F) (s : Set S) :
closure ((f : R → S) ⁻¹' s) ≤ (closure s).comap f :=
closure_le.2 fun _x hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx
end NonUnitalSubring
end Hom |
.lake/packages/mathlib/Mathlib/RingTheory/NonUnitalSubring/Defs.lean | import Mathlib.Algebra.Group.Subgroup.Defs
import Mathlib.RingTheory.NonUnitalSubsemiring.Defs
import Mathlib.Tactic.FastInstance
/-!
# `NonUnitalSubring`s
Let `R` be a non-unital ring. This file defines the "bundled" non-unital subring type
`NonUnitalSubring R`, a type whose terms correspond to non-unital subrings of `R`.
This is the preferred way to talk about non-unital subrings in mathlib.
## Main definitions
Notation used here:
`(R : Type u) [NonUnitalRing R] (S : Type u) [NonUnitalRing S] (f g : R →ₙ+* S)`
`(A : NonUnitalSubring R) (B : NonUnitalSubring S) (s : Set R)`
* `NonUnitalSubring R` : the type of non-unital subrings of a ring `R`.
## Implementation notes
A non-unital subring is implemented as a `NonUnitalSubsemiring` which is also an
additive subgroup.
Lattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although
`∈` is defined as membership of a non-unital subring's underlying set.
## Tags
non-unital subring
-/
assert_not_exists RelIso
universe u v w
section Basic
variable {R : Type u} {S : Type v} [NonUnitalNonAssocRing R]
section NonUnitalSubringClass
/-- `NonUnitalSubringClass S R` states that `S` is a type of subsets `s ⊆ R` that
are both a multiplicative submonoid and an additive subgroup. -/
class NonUnitalSubringClass (S : Type*) (R : Type u) [NonUnitalNonAssocRing R] [SetLike S R] : Prop
extends NonUnitalSubsemiringClass S R, NegMemClass S R where
-- See note [lower instance priority]
instance (priority := 100) NonUnitalSubringClass.addSubgroupClass (S : Type*) (R : Type u)
[SetLike S R] [NonUnitalNonAssocRing R] [h : NonUnitalSubringClass S R] :
AddSubgroupClass S R :=
{ h with }
variable [SetLike S R] [hSR : NonUnitalSubringClass S R] (s : S)
namespace NonUnitalSubringClass
-- Prefer subclasses of `NonUnitalRing` over subclasses of `NonUnitalSubringClass`.
/-- A non-unital subring of a non-unital ring inherits a non-unital ring structure -/
instance (priority := 75) toNonUnitalNonAssocRing : NonUnitalNonAssocRing s := fast_instance%
Subtype.val_injective.nonUnitalNonAssocRing _ rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
-- Prefer subclasses of `NonUnitalRing` over subclasses of `NonUnitalSubringClass`.
/-- A non-unital subring of a non-unital ring inherits a non-unital ring structure -/
instance (priority := 75) toNonUnitalRing {R : Type*} [NonUnitalRing R] [SetLike S R]
[NonUnitalSubringClass S R] (s : S) : NonUnitalRing s := fast_instance%
Subtype.val_injective.nonUnitalRing _ rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
-- Prefer subclasses of `NonUnitalRing` over subclasses of `NonUnitalSubringClass`.
/-- A non-unital subring of a `NonUnitalCommRing` is a `NonUnitalCommRing`. -/
instance (priority := 75) toNonUnitalCommRing {R} [NonUnitalCommRing R] [SetLike S R]
[NonUnitalSubringClass S R] : NonUnitalCommRing s := fast_instance%
Subtype.val_injective.nonUnitalCommRing _ rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
/-- The natural non-unital ring hom from a non-unital subring of a non-unital ring `R` to `R`. -/
def subtype (s : S) : s →ₙ+* R :=
{ NonUnitalSubsemiringClass.subtype s,
AddSubgroupClass.subtype s with
toFun := Subtype.val }
variable {s} in
@[simp]
theorem subtype_apply (x : s) : subtype s x = x :=
rfl
theorem subtype_injective : Function.Injective (subtype s) :=
Subtype.coe_injective
@[simp]
theorem coe_subtype : (subtype s : s → R) = Subtype.val :=
rfl
end NonUnitalSubringClass
end NonUnitalSubringClass
/-- `NonUnitalSubring R` is the type of non-unital subrings of `R`. A non-unital subring of `R`
is a subset `s` that is a multiplicative subsemigroup and an additive subgroup. Note in particular
that it shares the same 0 as R. -/
structure NonUnitalSubring (R : Type u) [NonUnitalNonAssocRing R] extends
NonUnitalSubsemiring R, AddSubgroup R
/-- Reinterpret a `NonUnitalSubring` as a `NonUnitalSubsemiring`. -/
add_decl_doc NonUnitalSubring.toNonUnitalSubsemiring
/-- Reinterpret a `NonUnitalSubring` as an `AddSubgroup`. -/
add_decl_doc NonUnitalSubring.toAddSubgroup
namespace NonUnitalSubring
/-- The underlying submonoid of a `NonUnitalSubring`. -/
def toSubsemigroup (s : NonUnitalSubring R) : Subsemigroup R :=
{ s.toNonUnitalSubsemiring.toSubsemigroup with carrier := s.carrier }
instance : SetLike (NonUnitalSubring R) R where
coe s := s.carrier
coe_injective' p q h := by cases p; cases q; congr; exact SetLike.coe_injective h
/-- The actual `NonUnitalSubring` obtained from an element of a `NonUnitalSubringClass`. -/
@[simps]
def ofClass {S R : Type*} [NonUnitalNonAssocRing R] [SetLike S R] [NonUnitalSubringClass S R]
(s : S) : NonUnitalSubring R where
carrier := s
add_mem' := add_mem
zero_mem' := zero_mem _
mul_mem' := mul_mem
neg_mem' := neg_mem
instance (priority := 100) : CanLift (Set R) (NonUnitalSubring R) (↑)
(fun s ↦ 0 ∈ s ∧ (∀ {x y}, x ∈ s → y ∈ s → x + y ∈ s) ∧
(∀ {x y}, x ∈ s → y ∈ s → x * y ∈ s) ∧ ∀ {x}, x ∈ s → -x ∈ s) where
prf s h :=
⟨ { carrier := s
zero_mem' := h.1
add_mem' := h.2.1
mul_mem' := h.2.2.1
neg_mem' := h.2.2.2 },
rfl ⟩
instance : NonUnitalSubringClass (NonUnitalSubring R) R where
zero_mem s := s.zero_mem'
add_mem {s} := s.add_mem'
mul_mem {s} := s.mul_mem'
neg_mem {s} := s.neg_mem'
theorem mem_carrier {s : NonUnitalSubring R} {x : R} : x ∈ s.toNonUnitalSubsemiring ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem mem_mk {S : NonUnitalSubsemiring R} {x : R} (h) :
x ∈ (⟨S, h⟩ : NonUnitalSubring R) ↔ x ∈ S :=
Iff.rfl
@[simp]
theorem coe_set_mk (S : NonUnitalSubsemiring R) (h) :
((⟨S, h⟩ : NonUnitalSubring R) : Set R) = S :=
rfl
@[simp]
theorem mk_le_mk {S S' : NonUnitalSubsemiring R} (h h') :
(⟨S, h⟩ : NonUnitalSubring R) ≤ (⟨S', h'⟩ : NonUnitalSubring R) ↔ S ≤ S' :=
Iff.rfl
/-- Two non-unital subrings are equal if they have the same elements. -/
@[ext]
theorem ext {S T : NonUnitalSubring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=
SetLike.ext h
/-- Copy of a non-unital subring with a new `carrier` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (S : NonUnitalSubring R) (s : Set R) (hs : s = ↑S) : NonUnitalSubring R :=
{ S.toNonUnitalSubsemiring.copy s hs with
carrier := s
neg_mem' := hs.symm ▸ S.neg_mem' }
@[simp]
theorem coe_copy (S : NonUnitalSubring R) (s : Set R) (hs : s = ↑S) : (S.copy s hs : Set R) = s :=
rfl
theorem copy_eq (S : NonUnitalSubring R) (s : Set R) (hs : s = ↑S) : S.copy s hs = S :=
SetLike.coe_injective hs
theorem toNonUnitalSubsemiring_injective :
Function.Injective (toNonUnitalSubsemiring : NonUnitalSubring R → NonUnitalSubsemiring R)
| _r, _s, h => ext (SetLike.ext_iff.mp h :)
@[mono]
theorem toNonUnitalSubsemiring_strictMono :
StrictMono (toNonUnitalSubsemiring : NonUnitalSubring R → NonUnitalSubsemiring R) := fun _ _ =>
id
@[mono]
theorem toNonUnitalSubsemiring_mono :
Monotone (toNonUnitalSubsemiring : NonUnitalSubring R → NonUnitalSubsemiring R) :=
toNonUnitalSubsemiring_strictMono.monotone
theorem toAddSubgroup_injective :
Function.Injective (toAddSubgroup : NonUnitalSubring R → AddSubgroup R)
| _r, _s, h => ext (SetLike.ext_iff.mp h :)
@[mono]
theorem toAddSubgroup_strictMono :
StrictMono (toAddSubgroup : NonUnitalSubring R → AddSubgroup R) := fun _ _ => id
@[mono]
theorem toAddSubgroup_mono : Monotone (toAddSubgroup : NonUnitalSubring R → AddSubgroup R) :=
toAddSubgroup_strictMono.monotone
theorem toSubsemigroup_injective :
Function.Injective (toSubsemigroup : NonUnitalSubring R → Subsemigroup R)
| _r, _s, h => ext (SetLike.ext_iff.mp h :)
@[mono]
theorem toSubsemigroup_strictMono :
StrictMono (toSubsemigroup : NonUnitalSubring R → Subsemigroup R) := fun _ _ => id
@[mono]
theorem toSubsemigroup_mono : Monotone (toSubsemigroup : NonUnitalSubring R → Subsemigroup R) :=
toSubsemigroup_strictMono.monotone
/-- Construct a `NonUnitalSubring R` from a set `s`, a subsemigroup `sm`, and an additive
subgroup `sa` such that `x ∈ s ↔ x ∈ sm ↔ x ∈ sa`. -/
protected def mk' (s : Set R) (sm : Subsemigroup R) (sa : AddSubgroup R) (hm : ↑sm = s)
(ha : ↑sa = s) : NonUnitalSubring R :=
{ sm.copy s hm.symm, sa.copy s ha.symm with }
@[simp]
theorem coe_mk' {s : Set R} {sm : Subsemigroup R} (hm : ↑sm = s) {sa : AddSubgroup R}
(ha : ↑sa = s) : (NonUnitalSubring.mk' s sm sa hm ha : Set R) = s :=
rfl
@[simp]
theorem mem_mk' {s : Set R} {sm : Subsemigroup R} (hm : ↑sm = s) {sa : AddSubgroup R} (ha : ↑sa = s)
{x : R} : x ∈ NonUnitalSubring.mk' s sm sa hm ha ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem mk'_toSubsemigroup {s : Set R} {sm : Subsemigroup R} (hm : ↑sm = s) {sa : AddSubgroup R}
(ha : ↑sa = s) : (NonUnitalSubring.mk' s sm sa hm ha).toSubsemigroup = sm :=
SetLike.coe_injective hm.symm
@[simp]
theorem mk'_toAddSubgroup {s : Set R} {sm : Subsemigroup R} (hm : ↑sm = s) {sa : AddSubgroup R}
(ha : ↑sa = s) : (NonUnitalSubring.mk' s sm sa hm ha).toAddSubgroup = sa :=
SetLike.coe_injective ha.symm
end NonUnitalSubring
namespace NonUnitalSubring
variable (s : NonUnitalSubring R)
/-- A non-unital subring contains the ring's 0. -/
protected theorem zero_mem : (0 : R) ∈ s :=
zero_mem _
/-- A non-unital subring is closed under multiplication. -/
protected theorem mul_mem {x y : R} : x ∈ s → y ∈ s → x * y ∈ s :=
mul_mem
/-- A non-unital subring is closed under addition. -/
protected theorem add_mem {x y : R} : x ∈ s → y ∈ s → x + y ∈ s :=
add_mem
/-- A non-unital subring is closed under negation. -/
protected theorem neg_mem {x : R} : x ∈ s → -x ∈ s :=
neg_mem
/-- A non-unital subring is closed under subtraction -/
protected theorem sub_mem {x y : R} (hx : x ∈ s) (hy : y ∈ s) : x - y ∈ s :=
sub_mem hx hy
/-- A non-unital subring of a non-unital ring inherits a non-unital ring structure -/
instance toNonUnitalRing {R : Type*} [NonUnitalRing R] (s : NonUnitalSubring R) :
NonUnitalRing s := fast_instance%
Subtype.coe_injective.nonUnitalRing _ rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
protected theorem zsmul_mem {x : R} (hx : x ∈ s) (n : ℤ) : n • x ∈ s :=
zsmul_mem hx n
@[simp, norm_cast]
theorem val_add (x y : s) : (↑(x + y) : R) = ↑x + ↑y :=
rfl
@[simp, norm_cast]
theorem val_neg (x : s) : (↑(-x) : R) = -↑x :=
rfl
@[simp, norm_cast]
theorem val_mul (x y : s) : (↑(x * y) : R) = ↑x * ↑y :=
rfl
@[simp, norm_cast]
theorem val_zero : ((0 : s) : R) = 0 :=
rfl
theorem coe_eq_zero_iff {x : s} : (x : R) = 0 ↔ x = 0 := by
simp
/-- A non-unital subring of a `NonUnitalCommRing` is a `NonUnitalCommRing`. -/
instance toNonUnitalCommRing {R} [NonUnitalCommRing R] (s : NonUnitalSubring R) :
NonUnitalCommRing s := fast_instance%
Subtype.coe_injective.nonUnitalCommRing _ rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
/-! ## Partial order -/
@[simp]
theorem mem_toSubsemigroup {s : NonUnitalSubring R} {x : R} : x ∈ s.toSubsemigroup ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem coe_toSubsemigroup (s : NonUnitalSubring R) : (s.toSubsemigroup : Set R) = s :=
rfl
theorem mem_toAddSubgroup {s : NonUnitalSubring R} {x : R} : x ∈ s.toAddSubgroup ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem coe_toAddSubgroup (s : NonUnitalSubring R) : (s.toAddSubgroup : Set R) = s :=
rfl
@[simp]
theorem mem_toNonUnitalSubsemiring {s : NonUnitalSubring R} {x : R} :
x ∈ s.toNonUnitalSubsemiring ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem coe_toNonUnitalSubsemiring (s : NonUnitalSubring R) :
(s.toNonUnitalSubsemiring : Set R) = s :=
rfl
end NonUnitalSubring
end Basic
section Hom
namespace NonUnitalSubring
variable {R : Type u} [NonUnitalNonAssocRing R]
open NonUnitalRingHom
/-- The ring homomorphism associated to an inclusion of `NonUnitalSubring`s. -/
def inclusion {S T : NonUnitalSubring R} (h : S ≤ T) : S →ₙ+* T :=
NonUnitalRingHom.codRestrict (NonUnitalSubringClass.subtype S) _ fun x => h x.2
end NonUnitalSubring
end Hom |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/TorsionFree.lean | import Mathlib.Algebra.Module.Torsion.Basic
import Mathlib.RingTheory.DedekindDomain.Dvr
import Mathlib.RingTheory.Flat.Localization
import Mathlib.RingTheory.Flat.Tensor
import Mathlib.RingTheory.Ideal.IsPrincipal
/-!
# Relationships between flatness and torsionfreeness.
We show that flat implies torsion-free, and that they're the same
concept for rings satisfying a certain property, including Dedekind
domains and valuation rings.
## Main theorems
* `Module.Flat.isSMulRegular_of_nonZeroDivisors`: Scalar multiplication by a nonzerodivisor of `R`
is injective on a flat `R`-module.
* `Module.Flat.torsion_eq_bot`: `Torsion R M = ⊥` if `M` is a flat `R`-module.
* `Module.Flat.flat_iff_torsion_eq_bot_of_valuationRing_localized_maximal`: if localizing `R` at
the complement of any maximal ideal is a valuation ring then `Torsion R M = ⊥` iff `M` is a
flat `R`-module.
-/
-- TODO: Add definition and properties of Prüfer domains.
-- TODO: Use `IsTorsionFree`.
open Function (Injective Surjective)
open LinearMap (lsmul rTensor lTensor)
open Submodule (IsPrincipal torsion)
open TensorProduct
namespace Module.Flat
section Semiring
variable {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
open LinearMap in
/-- Scalar multiplication `m ↦ r • m` by a regular `r` is injective on a flat module. -/
lemma isSMulRegular_of_isRegular {r : R} (hr : IsRegular r) [Flat R M] :
IsSMulRegular M r := by
-- `r ∈ R⁰` implies that `toSpanSingleton R R r`, i.e. `(r * ⬝) : R → R` is injective
-- Flatness implies that corresponding map `R ⊗[R] M →ₗ[R] R ⊗[R] M` is injective
have h := Flat.rTensor_preserves_injective_linearMap (M := M)
(toSpanSingleton R R r) <| hr.right
-- But precomposing and postcomposing with the isomorphism `M ≃ₗ[R] (R ⊗[R] M)`
-- we get a map `M →ₗ[R] M` which is just `(r • ·)`.
have h2 : (fun (x : M) ↦ r • x) = ((TensorProduct.lid R M) ∘ₗ
(rTensor M (toSpanSingleton R R r)) ∘ₗ
(TensorProduct.lid R M).symm) := by ext; simp
-- Hence `(r • ·) : M → M` is also injective
rw [IsSMulRegular, h2]
simp [h, LinearEquiv.injective]
end Semiring
section Ring
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
open scoped nonZeroDivisors
open LinearMap in
/-- Scalar multiplication `m ↦ r • m` by a nonzerodivisor `r` is injective on a flat module. -/
lemma isSMulRegular_of_nonZeroDivisors {r : R} (hr : r ∈ R⁰) [Flat R M] : IsSMulRegular M r := by
apply isSMulRegular_of_isRegular
exact le_nonZeroDivisors_iff_isRegular.mp (le_refl R⁰) ⟨r, hr⟩
/-- Flat modules have no torsion. -/
theorem torsion_eq_bot [Flat R M] : torsion R M = ⊥ := by
rw [eq_bot_iff]
-- indeed the definition of torsion means "annihiliated by a nonzerodivisor"
rintro m ⟨⟨r, hr⟩, h⟩
-- and we just showed that 0 is the only element with this property
exact isSMulRegular_of_nonZeroDivisors hr (by simpa using h)
/-- If `R` is Bezout then an `R`-module is flat iff it has no torsion. -/
@[stacks 0539 "Generalized valuation ring to Bezout domain"]
theorem flat_iff_torsion_eq_bot_of_isBezout [IsBezout R] [IsDomain R] :
Flat R M ↔ torsion R M = ⊥ := by
-- one way is true in general
refine ⟨fun _ ↦ torsion_eq_bot, ?_⟩
-- now assume R is a Bezout domain and M is a torsionfree R-module
intro htors
-- we need to show that if I is an ideal of R then the natural map I ⊗ M → M is injective
rw [iff_lift_lsmul_comp_subtype_injective]
rintro I hFG
-- If I = 0 this is obvious because I ⊗ M is a subsingleton (i.e. has ≤1 element)
obtain (rfl | h) := eq_or_ne I ⊥
· rintro x y -
apply Subsingleton.elim
· -- If I ≠ 0 then I ≅ R because R is Bezout and I is finitely generated
have hprinc : I.IsPrincipal := IsBezout.isPrincipal_of_FG I hFG
have : IsPrincipal.generator I ≠ 0 := by
rwa [ne_eq, ← IsPrincipal.eq_bot_iff_generator_eq_zero]
apply Function.Injective.of_comp_right _
(LinearEquiv.rTensor M (Ideal.isoBaseOfIsPrincipal h)).surjective
rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp, LinearEquiv.coe_rTensor, rTensor,
lift_comp_map, LinearMap.compl₂_id, LinearMap.comp_assoc,
Ideal.subtype_isoBaseOfIsPrincipal_eq_mul, LinearMap.lift_lsmul_mul_eq_lsmul_lift_lsmul,
LinearMap.coe_comp]
rw [← Submodule.noZeroSMulDivisors_iff_torsion_eq_bot] at htors
refine Function.Injective.comp (LinearMap.lsmul_injective this) ?_
rw [← Equiv.injective_comp (TensorProduct.lid R M).symm.toEquiv]
convert Function.injective_id
ext
simp
/-- If every localization of `R` at a maximal ideal is a valuation ring then an `R`-module
is flat iff it has no torsion. -/
theorem flat_iff_torsion_eq_bot_of_valuationRing_localization_isMaximal [IsDomain R]
(h : ∀ (P : Ideal R), [P.IsMaximal] → ValuationRing (Localization P.primeCompl)) :
Flat R M ↔ torsion R M = ⊥ := by
refine ⟨fun _ ↦ Flat.torsion_eq_bot, fun h ↦ ?_⟩
apply flat_of_localized_maximal
intro P hP
rw [← Submodule.noZeroSMulDivisors_iff_torsion_eq_bot] at h
rw [← flat_iff_of_isLocalization (Localization P.primeCompl) P.primeCompl,
Flat.flat_iff_torsion_eq_bot_of_isBezout, ← Submodule.noZeroSMulDivisors_iff_torsion_eq_bot]
infer_instance
/-- If `R` is a Dedekind domain then an `R`-module is flat iff it has no torsion. -/
@[stacks 0AUW "(1)"]
theorem _root_.IsDedekindDomain.flat_iff_torsion_eq_bot [IsDedekindDomain R] :
Flat R M ↔ torsion R M = ⊥ := by
apply flat_iff_torsion_eq_bot_of_valuationRing_localization_isMaximal
exact fun P ↦ inferInstance
instance [IsDedekindDomain R] [NoZeroSMulDivisors R M] : Flat R M := by
rw [IsDedekindDomain.flat_iff_torsion_eq_bot,
← Submodule.noZeroSMulDivisors_iff_torsion_eq_bot]
infer_instance
end Ring
end Module.Flat |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/EquationalCriterion.lean | import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.LinearAlgebra.TensorProduct.Vanishing
import Mathlib.RingTheory.Flat.Tensor
/-! # The equational criterion for flatness
Let $M$ be a module over a commutative ring $R$. Let us say that a relation
$\sum_{i \in \iota} f_i x_i = 0$ in $M$ is *trivial* (`Module.IsTrivialRelation`) if there exist a
finite index type $\kappa$ = `Fin k`, elements $(y_j)_{j \in \kappa}$ of $M$,
and elements $(a_{ij})_{i \in \iota, j \in \kappa}$ of $R$ such that for all $i$,
$$x_i = \sum_j a_{ij} y_j$$
and for all $j$,
$$\sum_i f_i a_{ij} = 0.$$
The *equational criterion for flatness* [Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK)
(`Module.Flat.iff_forall_isTrivialRelation`) states that $M$ is flat if and only if every relation
in $M$ is trivial.
The equational criterion for flatness can be stated in the following form
(`Module.Flat.iff_forall_exists_factorization`). Let $M$ be an $R$-module. Then the following two
conditions are equivalent:
* $M$ is flat.
* For finite free modules $R^l$, all elements $f \in R^l$, and all linear maps
$x \colon R^l \to M$ such that $x(f) = 0$, there exist a finite free module $R^k$ and
linear maps $a \colon R^l \to R^k$ and $y \colon R^k \to M$ such
that $x = y \circ a$ and $a(f) = 0$.
Of course, the module $R^l$ in this statement can be replaced by an arbitrary free module
(`Module.Flat.exists_factorization_of_apply_eq_zero_of_free`).
We also have the following strengthening of the equational criterion for flatness
(`Module.Flat.exists_factorization_of_comp_eq_zero_of_free`): Let $M$ be a
flat module. Let $K$ and $N$ be finite $R$-modules with $N$ free, and let $f \colon K \to N$ and
$x \colon N \to M$ be linear maps such that $x \circ f = 0$. Then there exist a finite free module
$R^k$ and linear maps $a \colon N \to R^k$ and $y \colon R^k \to M$ such
that $x = y \circ a$ and $a \circ f = 0$. We recover the usual equational criterion for flatness if
$K = R$ and $N = R^l$. This is used in the proof of Lazard's theorem.
We conclude that every linear map from a finitely presented module to a flat module factors
through a finite free module (`Module.Flat.exists_factorization_of_isFinitelyPresented`), and
every finitely presented flat module is projective (`Module.Flat.projective_of_finitePresentation`).
## References
* [Stacks: Flat modules and flat ring maps](https://stacks.math.columbia.edu/tag/00H9)
* [Stacks: Characterizing flatness](https://stacks.math.columbia.edu/tag/058C)
-/
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
open LinearMap TensorProduct Finsupp
namespace Module
variable {ι : Type*} [Fintype ι] (f : ι → R) (x : ι → M)
/-- The proposition that the relation $\sum_i f_i x_i = 0$ in $M$ is trivial.
That is, there exist a finite index type $\kappa$ = `Fin k`, elements
$(y_j)_{j \in \kappa}$ of $M$, and elements $(a_{ij})_{i \in \iota, j \in \kappa}$ of $R$
such that for all $i$,
$$x_i = \sum_j a_{ij} y_j$$
and for all $j$,
$$\sum_i f_i a_{ij} = 0.$$
By `Module.sum_smul_eq_zero_of_isTrivialRelation`, this condition implies $\sum_i f_i x_i = 0$. -/
abbrev IsTrivialRelation : Prop :=
∃ (k : ℕ) (a : ι → Fin k → R) (y : Fin k → M),
(∀ i, x i = ∑ j, a i j • y j) ∧ ∀ j, ∑ i, f i * a i j = 0
variable {f x}
/-- `Module.IsTrivialRelation` is equivalent to the predicate `TensorProduct.VanishesTrivially`
defined in `Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean`. -/
theorem isTrivialRelation_iff_vanishesTrivially :
IsTrivialRelation f x ↔ VanishesTrivially R f x := by
simp only [IsTrivialRelation, VanishesTrivially, smul_eq_mul, mul_comm]
theorem _root_.Equiv.isTrivialRelation_comp {κ} [Fintype κ] (e : κ ≃ ι) :
IsTrivialRelation (f ∘ e) (x ∘ e) ↔ IsTrivialRelation f x := by
simp_rw [isTrivialRelation_iff_vanishesTrivially, e.vanishesTrivially_comp]
/-- If the relation given by $(f_i)_{i \in \iota}$ and $(x_i)_{i \in \iota}$ is trivial, then
$\sum_i f_i x_i$ is actually equal to $0$. -/
theorem sum_smul_eq_zero_of_isTrivialRelation (h : IsTrivialRelation f x) :
∑ i, f i • x i = 0 := by
simpa using
congr_arg (TensorProduct.lid R M) <|
sum_tmul_eq_zero_of_vanishesTrivially R (isTrivialRelation_iff_vanishesTrivially.mp h)
end Module
namespace Module.Flat
variable (R M) in
/-- **Equational criterion for flatness**, combined form.
Let $M$ be a module over a commutative ring $R$. The following are equivalent:
* $M$ is flat.
* For all ideals $I \subseteq R$, the map $I \otimes M \to M$ is injective.
* Every $\sum_i f_i \otimes x_i$ that vanishes in $R \otimes M$ vanishes trivially.
* Every relation $\sum_i f_i x_i = 0$ in $M$ is trivial.
* For all finite free modules $R^l$, all elements $f \in R^l$, and all linear maps
$x \colon R^l \to M$ such that $x(f) = 0$, there exist a finite free module $R^k$ and
linear maps $a \colon R^l \to R^k$ and $y \colon R^k \to M$ such
that $x = y \circ a$ and $a(f) = 0$.
-/
@[stacks 00HK, stacks 058D "(1) ↔ (2)"]
theorem tfae_equational_criterion : List.TFAE [
Flat R M,
∀ I : Ideal R, Function.Injective (rTensor M I.subtype),
∀ {l : ℕ} {f : Fin l → R} {x : Fin l → M}, ∑ i, f i ⊗ₜ x i = (0 : R ⊗[R] M) →
VanishesTrivially R f x,
∀ {l : ℕ} {f : Fin l → R} {x : Fin l → M}, ∑ i, f i • x i = 0 → IsTrivialRelation f x,
∀ {l : ℕ} {f : Fin l →₀ R} {x : (Fin l →₀ R) →ₗ[R] M}, x f = 0 →
∃ (k : ℕ) (a : (Fin l →₀ R) →ₗ[R] (Fin k →₀ R)) (y : (Fin k →₀ R) →ₗ[R] M),
x = y ∘ₗ a ∧ a f = 0] := by
classical
tfae_have 1 ↔ 2 := iff_rTensor_injective'
tfae_have 3 ↔ 2 := forall_vanishesTrivially_iff_forall_rTensor_injective R
tfae_have 3 ↔ 4 := by
simp [(TensorProduct.lid R M).injective.eq_iff.symm, isTrivialRelation_iff_vanishesTrivially]
tfae_have 4 → 5
| h₄, l, f, x, hfx => by
let f' : Fin l → R := f
let x' : Fin l → M := fun i ↦ x (single i 1)
have := calc
∑ i, f' i • x' i
_ = ∑ i, f i • x (single i 1) := rfl
_ = x (∑ i, f i • Finsupp.single i 1) := by simp_rw [map_sum, map_smul]
_ = x f := by simp_rw [smul_single, smul_eq_mul, mul_one, univ_sum_single]
_ = 0 := hfx
obtain ⟨k, a', y', ⟨ha'y', ha'⟩⟩ := h₄ this
use k
use Finsupp.linearCombination R (fun i ↦ equivFunOnFinite.symm (a' i))
use Finsupp.linearCombination R y'
constructor
· apply Finsupp.basisSingleOne.ext
intro i
simpa [linearCombination_apply, sum_fintype, Finsupp.single_apply] using ha'y' i
· ext j
simp only [linearCombination_apply, zero_smul, implies_true, sum_fintype, finset_sum_apply]
exact ha' j
tfae_have 5 → 4
| h₅, l, f, x, hfx => by
let f' : Fin l →₀ R := equivFunOnFinite.symm f
let x' : (Fin l →₀ R) →ₗ[R] M := Finsupp.linearCombination R x
have : x' f' = 0 := by simpa [x', f', linearCombination_apply, sum_fintype] using hfx
obtain ⟨k, a', y', ha'y', ha'⟩ := h₅ this
refine ⟨k, fun i ↦ a' (single i 1), fun j ↦ y' (single j 1), fun i ↦ ?_, fun j ↦ ?_⟩
· simpa [x', ← map_smul, ← map_sum, smul_single] using
LinearMap.congr_fun ha'y' (Finsupp.single i 1)
· simp_rw [← smul_eq_mul, ← Finsupp.smul_apply, ← map_smul, ← finset_sum_apply, ← map_sum,
smul_single, smul_eq_mul, mul_one,
← (fun _ ↦ equivFunOnFinite_symm_apply_toFun _ _ : ∀ x, f' x = f x), univ_sum_single]
simpa using DFunLike.congr_fun ha' j
tfae_finish
/-- **Equational criterion for flatness**:
a module $M$ is flat if and only if every relation $\sum_i f_i x_i = 0$ in $M$ is trivial. -/
@[stacks 00HK]
theorem iff_forall_isTrivialRelation : Flat R M ↔ ∀ {l : ℕ} {f : Fin l → R} {x : Fin l → M},
∑ i, f i • x i = 0 → IsTrivialRelation f x :=
(tfae_equational_criterion R M).out 0 3
/-- **Equational criterion for flatness**, forward direction.
If $M$ is flat, then every relation $\sum_i f_i x_i = 0$ in $M$ is trivial. -/
@[stacks 00HK]
theorem isTrivialRelation_of_sum_smul_eq_zero [Flat R M] {ι : Type*} [Fintype ι] {f : ι → R}
{x : ι → M} (h : ∑ i, f i • x i = 0) : IsTrivialRelation f x :=
(Fintype.equivFin ι).symm.isTrivialRelation_comp.mp <| iff_forall_isTrivialRelation.mp ‹_› <| by
simpa only [← (Fintype.equivFin ι).symm.sum_comp] using h
/-- **Equational criterion for flatness**, backward direction.
If every relation $\sum_i f_i x_i = 0$ in $M$ is trivial, then $M$ is flat. -/
@[stacks 00HK]
theorem of_forall_isTrivialRelation (hfx : ∀ {l : ℕ} {f : Fin l → R} {x : Fin l → M},
∑ i, f i • x i = 0 → IsTrivialRelation f x) : Flat R M :=
iff_forall_isTrivialRelation.mpr hfx
/-- **Equational criterion for flatness**, alternate form.
A module $M$ is flat if and only if for all finite free modules $R^l$,
all $f \in R^l$, and all linear maps $x \colon R^l \to M$ such that $x(f) = 0$, there
exist a finite free module $R^k$ and linear maps $a \colon R^l \to R^k$ and
$y \colon R^k \to M$ such that $x = y \circ a$ and $a(f) = 0$. -/
@[stacks 058D "(1) ↔ (2)"]
theorem iff_forall_exists_factorization : Flat R M ↔
∀ {l : ℕ} {f : Fin l →₀ R} {x : (Fin l →₀ R) →ₗ[R] M}, x f = 0 →
∃ (k : ℕ) (a : (Fin l →₀ R) →ₗ[R] (Fin k →₀ R)) (y : (Fin k →₀ R) →ₗ[R] M),
x = y ∘ₗ a ∧ a f = 0 := (tfae_equational_criterion R M).out 0 4
/-- **Equational criterion for flatness**, backward direction, alternate form.
Let $M$ be a module over a commutative ring $R$. Suppose that for all finite free modules $R^l$,
all $f \in R^l$, and all linear maps $x \colon R^l \to M$ such that $x(f) = 0$, there
exist a finite free module $R^k$ and linear maps $a \colon R^l \to R^k$ and
$y \colon R^k \to M$ such that $x = y \circ a$ and $a(f) = 0$. Then $M$ is flat. -/
@[stacks 058D "(2) → (1)"]
theorem of_forall_exists_factorization
(h : ∀ {l : ℕ} {f : Fin l →₀ R} {x : (Fin l →₀ R) →ₗ[R] M}, x f = 0 →
∃ (k : ℕ) (a : (Fin l →₀ R) →ₗ[R] (Fin k →₀ R)) (y : (Fin k →₀ R) →ₗ[R] M),
x = y ∘ₗ a ∧ a f = 0) : Flat R M := iff_forall_exists_factorization.mpr h
/-- **Equational criterion for flatness**, forward direction, second alternate form.
Let $M$ be a flat module over a commutative ring $R$. Let $N$ be a finite free module over $R$,
let $f \in N$, and let $x \colon N \to M$ be a linear map such that $x(f) = 0$. Then there exist a
finite free module $R^k$ and linear maps $a \colon N \to R^k$ and
$y \colon R^k \to M$ such that $x = y \circ a$ and $a(f) = 0$. -/
@[stacks 058D "(1) → (2)"]
theorem exists_factorization_of_apply_eq_zero_of_free [Flat R M] {N : Type*} [AddCommGroup N]
[Module R N] [Free R N] [Module.Finite R N] {f : N} {x : N →ₗ[R] M} (h : x f = 0) :
∃ (k : ℕ) (a : N →ₗ[R] (Fin k →₀ R)) (y : (Fin k →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0 :=
have e := ((Module.Free.chooseBasis R N).reindex (Fintype.equivFin _)).repr.symm
have ⟨k, a, y, hya, haf⟩ := iff_forall_exists_factorization.mp ‹Flat R M›
(f := e.symm f) (x := x ∘ₗ e) (by simpa using h)
⟨k, a ∘ₗ e.symm, y, by rwa [← comp_assoc, LinearEquiv.eq_comp_toLinearMap_symm], haf⟩
private theorem exists_factorization_of_comp_eq_zero_of_free_aux [Flat R M] {K : Type*} {n : ℕ}
[AddCommGroup K] [Module R K] [Module.Finite R K] {f : K →ₗ[R] Fin n →₀ R}
{x : (Fin n →₀ R) →ₗ[R] M} (h : x ∘ₗ f = 0) :
∃ (k : ℕ) (a : (Fin n →₀ R) →ₗ[R] (Fin k →₀ R)) (y : (Fin k →₀ R) →ₗ[R] M),
x = y ∘ₗ a ∧ a ∘ₗ f = 0 := by
have (K' : Submodule R K) (hK' : K'.FG) : ∃ (k : ℕ) (a : (Fin n →₀ R) →ₗ[R] (Fin k →₀ R))
(y : (Fin k →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ K' ≤ LinearMap.ker (a ∘ₗ f) := by
revert n
apply Submodule.fg_induction (N := K') (hN := hK')
· intro k n f x hfx
have : x (f k) = 0 := by simpa using LinearMap.congr_fun hfx k
simpa using exists_factorization_of_apply_eq_zero_of_free this
· intro K₁ K₂ ih₁ ih₂ n f x hfx
obtain ⟨k₁, a₁, y₁, rfl, ha₁⟩ := ih₁ hfx
have : y₁ ∘ₗ (a₁ ∘ₗ f) = 0 := by rw [← comp_assoc, hfx]
obtain ⟨k₂, a₂, y₂, rfl, ha₂⟩ := ih₂ this
use k₂, a₂ ∘ₗ a₁, y₂
simp_rw [comp_assoc]
exact ⟨trivial, sup_le (ha₁.trans (ker_le_ker_comp _ _)) ha₂⟩
convert this ⊤ Finite.fg_top
simp only [top_le_iff, ker_eq_top]
/-- Let $M$ be a flat module. Let $K$ and $N$ be finite $R$-modules with $N$
free, and let $f \colon K \to N$ and $x \colon N \to M$ be linear maps such that
$x \circ f = 0$. Then there exist a finite free module $R^k$ and linear maps
$a \colon N \to R^k$ and $y \colon R^k \to M$ such that $x = y \circ a$ and
$a \circ f = 0$. -/
@[stacks 058D "(1) → (4)"]
theorem exists_factorization_of_comp_eq_zero_of_free [Flat R M] {K N : Type*} [AddCommGroup K]
[Module R K] [Module.Finite R K] [AddCommGroup N] [Module R N] [Free R N] [Module.Finite R N]
{f : K →ₗ[R] N} {x : N →ₗ[R] M} (h : x ∘ₗ f = 0) :
∃ (k : ℕ) (a : N →ₗ[R] (Fin k →₀ R)) (y : (Fin k →₀ R) →ₗ[R] M),
x = y ∘ₗ a ∧ a ∘ₗ f = 0 :=
have e := ((Module.Free.chooseBasis R N).reindex (Fintype.equivFin _)).repr.symm
have ⟨k, a, y, hya, haf⟩ := exists_factorization_of_comp_eq_zero_of_free_aux
(f := e.symm ∘ₗ f) (x := x ∘ₗ e.toLinearMap) (by ext; simpa [comp_assoc] using congr($h _))
⟨k, a ∘ₗ e.symm, y, by rwa [← comp_assoc, LinearEquiv.eq_comp_toLinearMap_symm], by
rwa [comp_assoc]⟩
/-- Every homomorphism from a finitely presented module to a flat module factors through a finite
free module. -/
@[stacks 058E "only if"]
theorem exists_factorization_of_isFinitelyPresented [Flat R M] {P : Type*} [AddCommGroup P]
[Module R P] [FinitePresentation R P] (h₁ : P →ₗ[R] M) :
∃ (k : ℕ) (h₂ : P →ₗ[R] (Fin k →₀ R)) (h₃ : (Fin k →₀ R) →ₗ[R] M), h₁ = h₃ ∘ₗ h₂ := by
have ⟨_, K, ϕ, hK⟩ := FinitePresentation.exists_fin R P
haveI : Module.Finite R K := Module.Finite.iff_fg.mpr hK
have : (h₁ ∘ₗ ϕ.symm ∘ₗ K.mkQ) ∘ₗ K.subtype = 0 := by
simp_rw [comp_assoc, (LinearMap.exact_subtype_mkQ K).linearMap_comp_eq_zero, comp_zero]
obtain ⟨k, a, y, hay, ha⟩ := exists_factorization_of_comp_eq_zero_of_free this
use k, (K.liftQ a (by rwa [← range_le_ker_iff, Submodule.range_subtype] at ha)) ∘ₗ ϕ, y
apply (cancel_right ϕ.symm.surjective).mp
apply (cancel_right K.mkQ_surjective).mp
simpa [comp_assoc]
@[stacks 00NX "(1) → (2)"]
theorem projective_of_finitePresentation [Flat R M] [FinitePresentation R M] : Projective R M :=
have ⟨_, f, g, eq⟩ := exists_factorization_of_isFinitelyPresented (.id (R := R) (M := M))
.of_split f g eq.symm
end Module.Flat |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/Basic.lean | import Mathlib.Algebra.Colimit.TensorProduct
import Mathlib.Algebra.Module.Projective
import Mathlib.LinearAlgebra.TensorProduct.RightExactness
import Mathlib.RingTheory.Finiteness.Small
import Mathlib.RingTheory.IsTensorProduct
import Mathlib.RingTheory.TensorProduct.Finite
import Mathlib.RingTheory.Adjoin.FGBaseChange
/-!
# Flat modules
A module `M` over a commutative semiring `R` is *mono-flat* if for all monomorphisms of modules
(i.e., injective linear maps) `N →ₗ[R] P`, the canonical map `N ⊗ M → P ⊗ M` is injective
(cf. [Katsov2004], [KatsovNam2011]).
To show a module is mono-flat, it suffices to check inclusions of finitely generated
submodules `N` into finitely generated modules `P`, and `P` can be further assumed to lie in
the same universe as `R`.
`M` is flat if `· ⊗ M` preserves finite limits (equivalently, pullbacks, or equalizers).
If `R` is a ring, an `R`-module `M` is flat if and only if it is mono-flat, and to show
a module is flat, it suffices to check inclusions of finitely generated ideals into `R`.
See <https://stacks.math.columbia.edu/tag/00HD>.
Currently, `Module.Flat` is defined to be equivalent to mono-flatness over a semiring.
It is left as a TODO item to introduce the genuine flatness over semirings and rename
the current `Module.Flat` to `Module.MonoFlat`.
## Main declaration
* `Module.Flat`: the predicate asserting that an `R`-module `M` is flat.
## Main theorems
* `Module.Flat.of_retract`: retracts of flat modules are flat
* `Module.Flat.of_linearEquiv`: modules linearly equivalent to a flat modules are flat
* `Module.Flat.directSum`: arbitrary direct sums of flat modules are flat
* `Module.Flat.of_free`: free modules are flat
* `Module.Flat.of_projective`: projective modules are flat
* `Module.Flat.preserves_injective_linearMap`: If `M` is a flat module then tensoring with `M`
preserves injectivity of linear maps. This lemma is fully universally polymorphic in all
arguments, i.e. `R`, `M` and linear maps `N → N'` can all have different universe levels.
* `Module.Flat.iff_rTensor_preserves_injective_linearMap`: a module is flat iff tensoring modules
in the higher universe preserves injectivity .
* `Module.Flat.lTensor_exact`: If `M` is a flat module then tensoring with `M` is an exact
functor. This lemma is fully universally polymorphic in all arguments, i.e.
`R`, `M` and linear maps `N → N' → N''` can all have different universe levels.
* `Module.Flat.iff_lTensor_exact`: a module is flat iff tensoring modules
in the higher universe is an exact functor.
## TODO
* Generalize flatness to noncommutative semirings.
-/
assert_not_exists AddCircle
universe v' u v w
open TensorProduct
namespace Module
open Function (Surjective)
open LinearMap Submodule DirectSum
section Semiring
/-! ### Flatness over a semiring -/
variable {R : Type u} {M : Type v} {N P Q : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
[AddCommMonoid N] [Module R N] [AddCommMonoid P] [Module R P] [AddCommMonoid Q] [Module R Q]
theorem _root_.LinearMap.rTensor_injective_of_fg {f : N →ₗ[R] P}
(h : ∀ (N' : Submodule R N) (P' : Submodule R P),
N'.FG → P'.FG → ∀ h : N' ≤ P'.comap f, Function.Injective ((f.restrict h).rTensor M)) :
Function.Injective (f.rTensor M) := fun x y eq ↦ by
have ⟨N', Nfg, sub⟩ := Submodule.exists_fg_le_subset_range_rTensor_subtype {x, y} (by simp)
obtain ⟨x, rfl⟩ := sub (.inl rfl)
obtain ⟨y, rfl⟩ := sub (.inr rfl)
simp_rw [← rTensor_comp_apply, show f ∘ₗ N'.subtype = (N'.map f).subtype ∘ₗ f.submoduleMap N'
from rfl, rTensor_comp_apply] at eq
have ⟨P', Pfg, le, eq⟩ := (Nfg.map _).exists_rTensor_fg_inclusion_eq eq
simp_rw [← rTensor_comp_apply] at eq
rw [h _ _ Nfg Pfg (map_le_iff_le_comap.mp le) eq]
lemma _root_.LinearMap.rTensor_injective_iff_subtype {f : N →ₗ[R] P} (hf : Function.Injective f)
(e : P ≃ₗ[R] Q) : Function.Injective (f.rTensor M) ↔
Function.Injective ((range <| e.toLinearMap ∘ₗ f).subtype.rTensor M) := by
simp_rw [← EquivLike.injective_comp <| (LinearEquiv.ofInjective (e.toLinearMap ∘ₗ f)
(e.injective.comp hf)).rTensor M, ← EquivLike.comp_injective _ (e.rTensor M),
← LinearEquiv.coe_coe, ← coe_comp, LinearEquiv.coe_rTensor, ← rTensor_comp]
rfl
variable (R M) in
/-- An `R`-module `M` is flat if for every finitely generated submodule `N` of every
finitely generated `R`-module `P` in the same universe as `R`,
the canonical map `N ⊗ M → P ⊗ M` is injective. This implies the same is true for
arbitrary `R`-modules `N` and `P` and injective linear maps `N →ₗ[R] P`, see
`Flat.rTensor_preserves_injective_linearMap`. To show a module over a ring `R` is flat, it
suffices to consider the case `P = R`, see `Flat.iff_rTensor_injective`. -/
@[mk_iff] class Flat : Prop where
out ⦃P : Type u⦄ [AddCommMonoid P] [Module R P] [Module.Finite R P] (N : Submodule R P) : N.FG →
Function.Injective (N.subtype.rTensor M)
namespace Flat
/-- If `M` is a flat module, then `f ⊗ 𝟙 M` is injective for all injective linear maps `f`. -/
theorem rTensor_preserves_injective_linearMap [Flat R M] (f : N →ₗ[R] P)
(hf : Function.Injective f) : Function.Injective (f.rTensor M) := by
refine rTensor_injective_of_fg fun N P Nfg Pfg le ↦ ?_
rw [← Finite.iff_fg] at Nfg Pfg
have := Finite.small R P
let se := (Shrink.linearEquiv R P).symm
have := Module.Finite.equiv se
rw [rTensor_injective_iff_subtype (fun _ _ ↦ (Subtype.ext <| hf <| Subtype.ext_iff.mp ·)) se]
exact (flat_iff R M).mp ‹_› _ (Finite.iff_fg.mp inferInstance)
/-- If `M` is a flat module, then `𝟙 M ⊗ f` is injective for all injective linear maps `f`. -/
theorem lTensor_preserves_injective_linearMap [Flat R M] (f : N →ₗ[R] P)
(hf : Function.Injective f) : Function.Injective (f.lTensor M) :=
(f.lTensor_inj_iff_rTensor_inj M).2 (rTensor_preserves_injective_linearMap f hf)
/-- `M` is flat if and only if `f ⊗ 𝟙 M` is injective whenever `f` is an injective linear map
in a universe that `R` fits in. -/
lemma iff_rTensor_preserves_injective_linearMapₛ [Small.{v'} R] : Flat R M ↔
∀ ⦃N N' : Type v'⦄ [AddCommMonoid N] [AddCommMonoid N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.rTensor M) :=
⟨by introv _; apply rTensor_preserves_injective_linearMap, fun h ↦ ⟨fun P _ _ _ _ _ ↦ by
have := Finite.small.{v'} R P
rw [rTensor_injective_iff_subtype Subtype.val_injective (Shrink.linearEquiv R P).symm]
exact h _ Subtype.val_injective⟩⟩
/-- `M` is flat if and only if `𝟙 M ⊗ f` is injective whenever `f` is an injective linear map
in a universe that `R` fits in. -/
lemma iff_lTensor_preserves_injective_linearMapₛ [Small.{v'} R] : Flat R M ↔
∀ ⦃N N' : Type v'⦄ [AddCommMonoid N] [AddCommMonoid N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.lTensor M) := by
simp_rw [iff_rTensor_preserves_injective_linearMapₛ, LinearMap.lTensor_inj_iff_rTensor_inj]
/-- An easier-to-use version of `Module.flat_iff`, with finiteness conditions removed. -/
lemma iff_rTensor_injectiveₛ : Flat R M ↔ ∀ ⦃P : Type u⦄ [AddCommMonoid P] [Module R P]
(N : Submodule R P), Function.Injective (N.subtype.rTensor M) :=
⟨fun _ _ _ _ _ ↦ rTensor_preserves_injective_linearMap _ Subtype.val_injective,
fun h ↦ ⟨fun _ _ _ _ _ _ ↦ h _⟩⟩
lemma iff_lTensor_injectiveₛ : Flat R M ↔ ∀ ⦃P : Type u⦄ [AddCommMonoid P] [Module R P]
(N : Submodule R P), Function.Injective (N.subtype.lTensor M) := by
simp_rw [iff_rTensor_injectiveₛ, LinearMap.lTensor_inj_iff_rTensor_inj]
instance instSubalgebraToSubmodule {S : Type v} [Semiring S] [Algebra R S]
(A : Subalgebra R S) [Flat R A] : Flat R A.toSubmodule := ‹Flat R A›
instance self : Flat R R where
out _ _ _ _ I _ := by
rw [← (TensorProduct.rid R I).symm.injective_comp, ← (TensorProduct.rid R _).comp_injective]
convert Subtype.coe_injective using 1
ext; simp
/-- A retract of a flat `R`-module is flat. -/
lemma of_retract [f : Flat R M] (i : N →ₗ[R] M) (r : M →ₗ[R] N) (h : r.comp i = LinearMap.id) :
Flat R N := by
rw [iff_rTensor_injectiveₛ] at *
refine fun P _ _ Q ↦ .of_comp (f := lTensor P i) ?_
rw [← coe_comp, lTensor_comp_rTensor, ← rTensor_comp_lTensor, coe_comp]
refine (f Q).comp (Function.RightInverse.injective (g := lTensor Q r) fun x ↦ ?_)
simp [← comp_apply, ← lTensor_comp, h]
/-- A `R`-module linearly equivalent to a flat `R`-module is flat. -/
lemma of_linearEquiv [Flat R M] (e : N ≃ₗ[R] M) : Flat R N :=
of_retract e.toLinearMap e.symm (by simp)
/-- If an `R`-module `M` is linearly equivalent to another `R`-module `N`, then `M` is flat
if and only if `N` is flat. -/
lemma equiv_iff (e : M ≃ₗ[R] N) : Flat R M ↔ Flat R N :=
⟨fun _ ↦ of_linearEquiv e.symm, fun _ ↦ of_linearEquiv e⟩
instance ulift [Flat R M] : Flat R (ULift.{v'} M) :=
of_linearEquiv ULift.moduleEquiv
-- Making this an instance causes an infinite sequence `M → ULift M → ULift (ULift M) → ...`.
lemma of_ulift [Flat R (ULift.{v'} M)] : Flat R M :=
of_linearEquiv ULift.moduleEquiv.symm
instance shrink [Small.{v'} M] [Flat R M] : Flat R (Shrink.{v'} M) :=
of_linearEquiv (Shrink.linearEquiv R M)
-- Making this an instance causes an infinite sequence `M → Shrink M → Shrink (Shrink M) → ...`.
lemma of_shrink [Small.{v'} M] [Flat R (Shrink.{v'} M)] : Flat R M :=
of_linearEquiv (Shrink.linearEquiv R M).symm
section DirectSum
variable {ι : Type v} {M : ι → Type w} [Π i, AddCommMonoid (M i)] [Π i, Module R (M i)]
theorem directSum_iff : Flat R (⨁ i, M i) ↔ ∀ i, Flat R (M i) := by
classical
simp_rw [iff_rTensor_injectiveₛ, ← EquivLike.comp_injective _ (directSumRight R _ _),
← LinearEquiv.coe_coe, ← coe_comp, directSumRight_comp_rTensor, coe_comp, LinearEquiv.coe_coe,
EquivLike.injective_comp, lmap_injective]
constructor <;> (intro h; intros; apply h)
theorem dfinsupp_iff : Flat R (Π₀ i, M i) ↔ ∀ i, Flat R (M i) := directSum_iff ..
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum [∀ i, Flat R (M i)] : Flat R (⨁ i, M i) := directSum_iff.mpr ‹_›
instance dfinsupp [∀ i, Flat R (M i)] : Flat R (Π₀ i, M i) := dfinsupp_iff.mpr ‹_›
end DirectSum
/-- Free `R`-modules over discrete types are flat. -/
instance finsupp (ι : Type v) : Flat R (ι →₀ R) := by
classical exact of_linearEquiv (finsuppLEquivDirectSum R R ι)
instance of_projective [Projective R M] : Flat R M :=
have ⟨e, he⟩:= Module.projective_def'.mp ‹_›
of_retract _ _ he
instance of_free [Free R M] : Flat R M := inferInstance
instance {S} [CommSemiring S] [Algebra R S] [Module S M] [IsScalarTower R S M]
[Flat S M] [Flat R N] : Flat S (M ⊗[R] N) :=
iff_rTensor_injectiveₛ.mpr fun P _ _ I ↦ by
letI := RestrictScalars.moduleOrig R S P
change Submodule S (RestrictScalars R S P) at I
change Function.Injective (rTensor _ I.subtype)
simpa [AlgebraTensorModule.rTensor_tensor] using
rTensor_preserves_injective_linearMap (.restrictScalars R <| I.subtype.rTensor M)
(rTensor_preserves_injective_linearMap _ I.injective_subtype)
example [Flat R M] [Flat R N] : Flat R (M ⊗[R] N) := inferInstance
theorem linearIndependent_one_tmul {S} [Semiring S] [Algebra R S] [Flat R S] {ι} {v : ι → M}
(hv : LinearIndependent R v) : LinearIndependent S ((1 : S) ⊗ₜ[R] v ·) := by
classical rw [LinearIndependent, ← LinearMap.coe_restrictScalars R,
Finsupp.linearCombination_one_tmul]
simpa using lTensor_preserves_injective_linearMap _ hv
end Flat
end Semiring
namespace Flat
/-! ### Flatness over a ring -/
variable {R : Type u} {M : Type v} [CommRing R] [AddCommGroup M] [Module R M]
variable {N : Type w} [AddCommGroup N] [Module R N]
/-- `M` is flat if and only if `f ⊗ 𝟙 M` is injective whenever `f` is an injective linear map.
See `Module.Flat.iff_rTensor_preserves_injective_linearMap` to specialize the universe of
`N, N', N''` to `Type (max u v)`. -/
lemma iff_rTensor_preserves_injective_linearMap' [Small.{v'} R] : Flat R M ↔
∀ ⦃N N' : Type v'⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.rTensor M) :=
⟨by introv _; apply rTensor_preserves_injective_linearMap, fun h ↦
iff_rTensor_preserves_injective_linearMapₛ.mpr fun P N _ _ _ _ ↦ by
letI := Module.addCommMonoidToAddCommGroup R (M := P)
letI := Module.addCommMonoidToAddCommGroup R (M := N)
apply h⟩
/-- `M` is flat if and only if `f ⊗ 𝟙 M` is injective whenever `f` is an injective linear map.
See `Module.Flat.iff_rTensor_preserves_injective_linearMap'` to generalize the universe of
`N, N', N''` to any universe that is higher than `R` and `M`. -/
lemma iff_rTensor_preserves_injective_linearMap : Flat R M ↔
∀ ⦃N N' : Type (max u v)⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.rTensor M) :=
iff_rTensor_preserves_injective_linearMap'
/-- `M` is flat if and only if `𝟙 M ⊗ f` is injective whenever `f` is an injective linear map.
See `Module.Flat.iff_lTensor_preserves_injective_linearMap` to specialize the universe of
`N, N', N''` to `Type (max u v)`. -/
lemma iff_lTensor_preserves_injective_linearMap' [Small.{v'} R] : Flat R M ↔
∀ ⦃N N' : Type v'⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.lTensor M) := by
simp_rw [iff_rTensor_preserves_injective_linearMap', LinearMap.lTensor_inj_iff_rTensor_inj]
/-- `M` is flat if and only if `𝟙 M ⊗ f` is injective whenever `f` is an injective linear map.
See `Module.Flat.iff_lTensor_preserves_injective_linearMap'` to generalize the universe of
`N, N', N''` to any universe that is higher than `R` and `M`. -/
lemma iff_lTensor_preserves_injective_linearMap : Flat R M ↔
∀ ⦃N N' : Type (max u v)⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.lTensor M) :=
iff_lTensor_preserves_injective_linearMap'
variable (M) in
/-- If `M` is flat then `M ⊗ -` is an exact functor. -/
lemma lTensor_exact [Flat R M] ⦃N N' N'' : Type*⦄
[AddCommGroup N] [AddCommGroup N'] [AddCommGroup N''] [Module R N] [Module R N'] [Module R N'']
⦃f : N →ₗ[R] N'⦄ ⦃g : N' →ₗ[R] N''⦄ (exact : Function.Exact f g) :
Function.Exact (f.lTensor M) (g.lTensor M) := by
let π : N' →ₗ[R] N' ⧸ LinearMap.range f := Submodule.mkQ _
let ι : N' ⧸ LinearMap.range f →ₗ[R] N'' :=
Submodule.subtype _ ∘ₗ (LinearMap.quotKerEquivRange g).toLinearMap ∘ₗ
Submodule.quotEquivOfEq (LinearMap.range f) (LinearMap.ker g)
(LinearMap.exact_iff.mp exact).symm
suffices exact1 : Function.Exact (f.lTensor M) (π.lTensor M) by
rw [show g = ι.comp π from rfl, lTensor_comp]
exact exact1.comp_injective _ (lTensor_preserves_injective_linearMap ι <| by
simpa [ι, - Subtype.val_injective] using Subtype.val_injective) (map_zero _)
exact _root_.lTensor_exact _ (fun x ↦ by simp [π]) Quotient.mk''_surjective
variable (M) in
/-- If `M` is flat then `- ⊗ M` is an exact functor. -/
lemma rTensor_exact [Flat R M] ⦃N N' N'' : Type*⦄
[AddCommGroup N] [AddCommGroup N'] [AddCommGroup N''] [Module R N] [Module R N'] [Module R N'']
⦃f : N →ₗ[R] N'⦄ ⦃g : N' →ₗ[R] N''⦄ (exact : Function.Exact f g) :
Function.Exact (f.rTensor M) (g.rTensor M) := by
let π : N' →ₗ[R] N' ⧸ LinearMap.range f := Submodule.mkQ _
let ι : N' ⧸ LinearMap.range f →ₗ[R] N'' :=
Submodule.subtype _ ∘ₗ (LinearMap.quotKerEquivRange g).toLinearMap ∘ₗ
Submodule.quotEquivOfEq (LinearMap.range f) (LinearMap.ker g)
(LinearMap.exact_iff.mp exact).symm
suffices exact1 : Function.Exact (f.rTensor M) (π.rTensor M) by
rw [show g = ι.comp π from rfl, rTensor_comp]
exact exact1.comp_injective _ (rTensor_preserves_injective_linearMap ι <| by
simpa [ι, - Subtype.val_injective] using Subtype.val_injective) (map_zero _)
exact _root_.rTensor_exact M (fun x ↦ by simp [π]) Quotient.mk''_surjective
/-- `M` is flat if and only if `M ⊗ -` is an exact functor. See
`Module.Flat.iff_lTensor_exact` to specialize the universe of `N, N', N''` to `Type (max u v)`. -/
theorem iff_lTensor_exact' [Small.{v'} R] : Flat R M ↔
∀ ⦃N N' N'' : Type v'⦄ [AddCommGroup N] [AddCommGroup N'] [AddCommGroup N'']
[Module R N] [Module R N'] [Module R N''] ⦃f : N →ₗ[R] N'⦄ ⦃g : N' →ₗ[R] N''⦄,
Function.Exact f g → Function.Exact (f.lTensor M) (g.lTensor M) := by
refine ⟨fun _ ↦ lTensor_exact _, fun H ↦ iff_lTensor_preserves_injective_linearMap'.mpr
fun N' N'' _ _ _ _ L hL ↦ LinearMap.ker_eq_bot |>.mp <| eq_bot_iff |>.mpr
fun x (hx : _ = 0) ↦ ?_⟩
simpa [Eq.comm] using @H PUnit N' N'' _ _ _ _ _ _ 0 L (fun x ↦ by
simp_rw [Set.mem_range, LinearMap.zero_apply, exists_const]
exact (L.map_eq_zero_iff hL).trans eq_comm) x |>.mp hx
/-- `M` is flat if and only if `M ⊗ -` is an exact functor.
See `Module.Flat.iff_lTensor_exact'` to generalize the universe of
`N, N', N''` to any universe that is higher than `R` and `M`. -/
theorem iff_lTensor_exact : Flat R M ↔
∀ ⦃N N' N'' : Type (max u v)⦄ [AddCommGroup N] [AddCommGroup N'] [AddCommGroup N'']
[Module R N] [Module R N'] [Module R N''] ⦃f : N →ₗ[R] N'⦄ ⦃g : N' →ₗ[R] N''⦄,
Function.Exact f g → Function.Exact (f.lTensor M) (g.lTensor M) :=
iff_lTensor_exact'
/-- `M` is flat if and only if `- ⊗ M` is an exact functor. See
`Module.Flat.iff_rTensor_exact` to specialize the universe of `N, N', N''` to `Type (max u v)`. -/
theorem iff_rTensor_exact' [Small.{v'} R] : Flat R M ↔
∀ ⦃N N' N'' : Type v'⦄ [AddCommGroup N] [AddCommGroup N'] [AddCommGroup N'']
[Module R N] [Module R N'] [Module R N''] ⦃f : N →ₗ[R] N'⦄ ⦃g : N' →ₗ[R] N''⦄,
Function.Exact f g → Function.Exact (f.rTensor M) (g.rTensor M) := by
refine ⟨fun _ ↦ rTensor_exact _, fun H ↦ iff_rTensor_preserves_injective_linearMap'.mpr
fun N' N'' _ _ _ _ f hf ↦ LinearMap.ker_eq_bot |>.mp <| eq_bot_iff |>.mpr
fun x (hx : _ = 0) ↦ ?_⟩
simpa [Eq.comm] using @H PUnit N' N'' _ _ _ _ _ _ 0 f (fun x ↦ by
simp_rw [Set.mem_range, LinearMap.zero_apply, exists_const]
exact (f.map_eq_zero_iff hf).trans eq_comm) x |>.mp hx
/-- `M` is flat if and only if `- ⊗ M` is an exact functor.
See `Module.Flat.iff_rTensor_exact'` to generalize the universe of
`N, N', N''` to any universe that is higher than `R` and `M`. -/
theorem iff_rTensor_exact : Flat R M ↔
∀ ⦃N N' N'' : Type (max u v)⦄ [AddCommGroup N] [AddCommGroup N'] [AddCommGroup N'']
[Module R N] [Module R N'] [Module R N''] ⦃f : N →ₗ[R] N'⦄ ⦃g : N' →ₗ[R] N''⦄,
Function.Exact f g → Function.Exact (f.rTensor M) (g.rTensor M) :=
iff_rTensor_exact'
end Flat
end Module
section Injective
variable {R S A B : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
[CommSemiring S] [Algebra S A] [SMulCommClass R S A]
namespace Algebra.TensorProduct
theorem includeLeft_injective [Module.Flat R A] (hb : Function.Injective (algebraMap R B)) :
Function.Injective (includeLeft : A →ₐ[S] A ⊗[R] B) := by
convert Module.Flat.lTensor_preserves_injective_linearMap (M := A) (Algebra.linearMap R B) hb
|>.comp (_root_.TensorProduct.rid R A).symm.injective
ext; simp
theorem includeRight_injective [Module.Flat R B] (ha : Function.Injective (algebraMap R A)) :
Function.Injective (includeRight : B →ₐ[R] A ⊗[R] B) := by
convert Module.Flat.rTensor_preserves_injective_linearMap (M := B) (Algebra.linearMap R A) ha
|>.comp (_root_.TensorProduct.lid R B).symm.injective
ext; simp
end Algebra.TensorProduct
end Injective
section Nontrivial
variable (R : Type*) [CommSemiring R]
namespace TensorProduct
variable (M N : Type*) [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N]
/-- If `M`, `N` are `R`-modules, there exists an injective `R`-linear map from `R` to `N`,
and `M` is a nontrivial flat `R`-module, then `M ⊗[R] N` is nontrivial. -/
theorem nontrivial_of_linearMap_injective_of_flat_left (f : R →ₗ[R] N) (h : Function.Injective f)
[Module.Flat R M] [Nontrivial M] : Nontrivial (M ⊗[R] N) :=
Module.Flat.lTensor_preserves_injective_linearMap (M := M) f h |>.comp
(TensorProduct.rid R M).symm.injective |>.nontrivial
/-- If `M`, `N` are `R`-modules, there exists an injective `R`-linear map from `R` to `M`,
and `N` is a nontrivial flat `R`-module, then `M ⊗[R] N` is nontrivial. -/
theorem nontrivial_of_linearMap_injective_of_flat_right (f : R →ₗ[R] M) (h : Function.Injective f)
[Module.Flat R N] [Nontrivial N] : Nontrivial (M ⊗[R] N) :=
Module.Flat.rTensor_preserves_injective_linearMap (M := N) f h |>.comp
(TensorProduct.lid R N).symm.injective |>.nontrivial
variable {R M N}
variable {P Q : Type*} [AddCommMonoid P] [Module R P] [AddCommMonoid Q] [Module R Q]
/-- Tensor product of injective maps are injective under some flatness conditions.
Also see `TensorProduct.map_injective_of_flat_flat'` and
`TensorProduct.map_injective_of_flat_flat_of_isDomain` for different flatness conditions. -/
lemma map_injective_of_flat_flat
(f : P →ₗ[R] M) (g : Q →ₗ[R] N) [Module.Flat R M] [Module.Flat R Q]
(hf : Function.Injective f) (hg : Function.Injective g) :
Function.Injective (TensorProduct.map f g) := by
rw [← LinearMap.lTensor_comp_rTensor]
exact (Module.Flat.lTensor_preserves_injective_linearMap g hg).comp
(Module.Flat.rTensor_preserves_injective_linearMap f hf)
/-- Tensor product of injective maps are injective under some flatness conditions.
Also see `TensorProduct.map_injective_of_flat_flat` and
`TensorProduct.map_injective_of_flat_flat_of_isDomain` for different flatness conditions. -/
lemma map_injective_of_flat_flat'
(f : P →ₗ[R] M) (g : Q →ₗ[R] N) [Module.Flat R P] [Module.Flat R N]
(hf : Function.Injective f) (hg : Function.Injective g) :
Function.Injective (TensorProduct.map f g) := by
rw [← LinearMap.rTensor_comp_lTensor]
exact (Module.Flat.rTensor_preserves_injective_linearMap f hf).comp
(Module.Flat.lTensor_preserves_injective_linearMap g hg)
variable {ι κ : Type*} {v : ι → M} {w : κ → N} {s : Set ι} {t : Set κ}
/-- Tensor product of linearly independent families is linearly
independent under some flatness conditions.
The flatness condition could be removed over domains.
See `LinearIndependent.tmul_of_isDomain`. -/
lemma _root_.LinearIndependent.tmul_of_flat_left [Module.Flat R M] (hv : LinearIndependent R v)
(hw : LinearIndependent R w) : LinearIndependent R fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2 := by
rw [LinearIndependent]
convert (TensorProduct.map_injective_of_flat_flat _ _ hv hw).comp
(finsuppTensorFinsupp' _ _ _).symm.injective
rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp]
congr!
ext i
simp [finsuppTensorFinsupp'_symm_single_eq_single_one_tmul]
/-- Tensor product of linearly independent families is linearly
independent under some flatness conditions.
The flatness condition could be removed over domains.
See `LinearIndepOn.tmul_of_isDomain`. -/
nonrec lemma LinearIndepOn.tmul_of_flat_left [Module.Flat R M] (hv : LinearIndepOn R v s)
(hw : LinearIndepOn R w t) : LinearIndepOn R (fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2) (s ×ˢ t) :=
((hv.tmul_of_flat_left hw).comp _ (Equiv.Set.prod _ _).injective:)
/-- Tensor product of linearly independent families is linearly
independent under some flatness conditions.
The flatness condition could be removed over domains.
See `LinearIndependent.tmul_of_isDomain`. -/
lemma _root_.LinearIndependent.tmul_of_flat_right [Module.Flat R N] (hv : LinearIndependent R v)
(hw : LinearIndependent R w) : LinearIndependent R fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2 :=
(((TensorProduct.comm R N M).toLinearMap.linearIndependent_iff_of_injOn
(TensorProduct.comm R N M).injective.injOn).mpr
(hw.tmul_of_flat_left hv)).comp Prod.swap Prod.swap_bijective.injective
/-- Tensor product of linearly independent families is linearly
independent under some flatness conditions.
The flatness condition could be removed over domains.
See `LinearIndepOn.tmul_of_isDomain`. -/
nonrec lemma LinearIndepOn.tmul_of_flat_right [Module.Flat R N] (hv : LinearIndepOn R v s)
(hw : LinearIndepOn R w t) : LinearIndepOn R (fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2) (s ×ˢ t) :=
((hv.tmul_of_flat_right hw).comp _ (Equiv.Set.prod _ _).injective:)
variable (p : Submodule R M) (q : Submodule R N)
/-- If p and q are submodules of M and N respectively, and M and q are flat,
then `p ⊗ q → M ⊗ N` is injective. -/
theorem _root_.Module.Flat.tensorProduct_mapIncl_injective_of_right
[Module.Flat R M] [Module.Flat R q] : Function.Injective (mapIncl p q) :=
TensorProduct.map_injective_of_flat_flat _ _ p.subtype_injective q.subtype_injective
/-- If p and q are submodules of M and N respectively, and N and p are flat,
then `p ⊗ q → M ⊗ N` is injective. -/
theorem _root_.Module.Flat.tensorProduct_mapIncl_injective_of_left
[Module.Flat R p] [Module.Flat R N] : Function.Injective (mapIncl p q) :=
TensorProduct.map_injective_of_flat_flat' _ _ p.subtype_injective q.subtype_injective
end TensorProduct
namespace Algebra.TensorProduct
variable (A B : Type*) [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
/-- If `A`, `B` are `R`-algebras, `R` injects into `B`,
and `A` is a nontrivial flat `R`-algebra, then `A ⊗[R] B` is nontrivial. -/
theorem nontrivial_of_algebraMap_injective_of_flat_left (h : Function.Injective (algebraMap R B))
[Module.Flat R A] [Nontrivial A] : Nontrivial (A ⊗[R] B) :=
TensorProduct.nontrivial_of_linearMap_injective_of_flat_left R A B (Algebra.linearMap R B) h
/-- If `A`, `B` are `R`-algebras, `R` injects into `A`,
and `B` is a nontrivial flat `R`-algebra, then `A ⊗[R] B` is nontrivial. -/
theorem nontrivial_of_algebraMap_injective_of_flat_right (h : Function.Injective (algebraMap R A))
[Module.Flat R B] [Nontrivial B] : Nontrivial (A ⊗[R] B) :=
TensorProduct.nontrivial_of_linearMap_injective_of_flat_right R A B (Algebra.linearMap R A) h
end Algebra.TensorProduct
end Nontrivial
namespace IsTensorProduct
variable {R M N P : Type*} [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]
[Module R M] [Module R N] [Module R P] {M₁ M₂ N₁ N₂ : Type*} [AddCommMonoid M₁] [AddCommMonoid M₂]
[Module R M₁] [Module R M₂] [AddCommMonoid N₁] [AddCommMonoid N₂] [Module R N₁] [Module R N₂]
{f : M₁ →ₗ[R] M₂ →ₗ[R] M} {g : N₁ →ₗ[R] N₂ →ₗ[R] N}
(hf : IsTensorProduct f) (hg : IsTensorProduct g) (i₁ : M₁ →ₗ[R] N₁) (i₂ : M₂ →ₗ[R] N₂)
theorem map_id_injective_of_flat_left {g : M₁ →ₗ[R] N₂ →ₗ[R] N} (hg : IsTensorProduct g)
(i : M₂ →ₗ[R] N₂) (hi : Function.Injective i) [Module.Flat R M₁] :
Function.Injective (hf.map hg LinearMap.id i) := by
have h : hf.map hg LinearMap.id i = hg.equiv ∘ i.lTensor M₁ ∘ hf.equiv.symm :=
funext fun x ↦ hf.inductionOn x (by simp) (by simp) (fun _ _ hx hy ↦ by simp [hx, hy])
simpa [h] using Module.Flat.lTensor_preserves_injective_linearMap i hi
theorem map_id_injective_of_flat_right {g : N₁ →ₗ[R] M₂ →ₗ[R] N} (hg : IsTensorProduct g)
(i : M₁ →ₗ[R] N₁) (hi : Function.Injective i) [Module.Flat R M₂] :
Function.Injective (hf.map hg i LinearMap.id) := by
have h : hf.map hg i LinearMap.id = hg.equiv ∘ i.rTensor M₂ ∘ hf.equiv.symm :=
funext fun x ↦ hf.inductionOn x (by simp) (by simp) (fun _ _ hx hy ↦ by simp [hx, hy])
simpa [h] using Module.Flat.rTensor_preserves_injective_linearMap i hi
/-- If `M₂` and `N₁` are flat `R`-modules, `i₁ : M₁ →ₗ[R] N₁` and `i₂ : M₂ →ₗ[R] N₂` are injective
linear maps, then the linear map `i : M ≅ M₁ ⊗[R] M₂ →ₗ[R] N₁ ⊗[R] N₂ ≅ N` induced by `i₁`
and `i₂` is injective.
See `IsTensorProduct.map_injective_of_flat'` for different flatness conditions. -/
theorem map_injective_of_flat_right_left (h₁ : Function.Injective i₁) (h₂ : Function.Injective i₂)
[Module.Flat R M₂] [Module.Flat R N₁] : Function.Injective (hf.map hg i₁ i₂) := by
have h : hf.map hg i₁ i₂ = hg.equiv ∘ TensorProduct.map i₁ i₂ ∘ hf.equiv.symm :=
funext fun x ↦ hf.inductionOn x (by simp) (by simp) (fun _ _ hx hy ↦ by simp [hx, hy])
simpa [h] using map_injective_of_flat_flat i₁ i₂ h₁ h₂
/-- If `M₁` and `N₂` are flat `R`-modules, `i₁ : M₁ →ₗ[R] N₁` and `i₂ : M₂ →ₗ[R] N₂` are injective
linear maps, then the linear map `i : M ≅ M₁ ⊗[R] M₂ →ₗ[R] N₁ ⊗[R] N₂ ≅ N` induced by `i₁`
and `i₂` is injective.
See `IsTensorProduct.map_injective_of_flat` for different flatness conditions. -/
theorem map_injective_of_flat_left_right (h₁ : Function.Injective i₁) (h₂ : Function.Injective i₂)
[Module.Flat R M₁] [Module.Flat R N₂] : Function.Injective (hf.map hg i₁ i₂) := by
have h : hf.map hg i₁ i₂ = hg.equiv ∘ TensorProduct.map i₁ i₂ ∘ hf.equiv.symm :=
funext fun x ↦ hf.inductionOn x (by simp) (by simp) (fun _ _ hx hy ↦ by simp [hx, hy])
simpa [h] using map_injective_of_flat_flat' i₁ i₂ h₁ h₂
end IsTensorProduct
section IsSMulRegular
variable {R S M N : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S] [Module.Flat R S]
[AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] [Module S N] [IsScalarTower R S N]
theorem IsSMulRegular.of_flat_of_isBaseChange {f : M →ₗ[R] N} (hf : IsBaseChange S f) {x : R}
(reg : IsSMulRegular M x) : IsSMulRegular N (algebraMap R S x) := by
have h := hf.map_id_injective_of_flat_left hf (LinearMap.lsmul R M x) reg
rwa [hf.map_id_lsmul_eq_lsmul_algebraMap] at h
theorem IsSMulRegular.of_flat {x : R} (reg : IsSMulRegular R x) :
IsSMulRegular S (algebraMap R S x) :=
reg.of_flat_of_isBaseChange (IsBaseChange.linearMap R S)
end IsSMulRegular
/-- Let `R` be a commutative semiring, let `C` be a commutative ``R`-algebra , and let `A` be an
`R`-algebra. If `C ⊗[R] B` is reduced for all finitely generated subalgebras `B` of `A`, then
`C ⊗[R] A` is also reduced. -/
theorem IsReduced.tensorProduct_of_flat_of_forall_fg {R C A : Type*}
[CommSemiring R] [CommSemiring C] [Semiring A] [Algebra R A] [Algebra R C] [Module.Flat R C]
(h : ∀ B : Subalgebra R A, B.FG → IsReduced (C ⊗[R] B)) :
IsReduced (C ⊗[R] A) := by
by_contra h_contra
obtain ⟨x, hx⟩ := exists_isNilpotent_of_not_isReduced h_contra
obtain ⟨D, hD⟩ := exists_fg_and_mem_baseChange x
have h_inj : Function.Injective
(Algebra.TensorProduct.map (AlgHom.id C C ) D.val) :=
Module.Flat.lTensor_preserves_injective_linearMap _ Subtype.val_injective
obtain ⟨z, rfl⟩ := hD.2
have h_notReduced : ¬IsReduced (C ⊗[R] D) := by
simp_rw [isReduced_iff, not_forall]
exact ⟨z, (IsNilpotent.map_iff h_inj).mp hx.right, (by simpa [·] using hx.1)⟩
tauto |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/Domain.lean | import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.RingTheory.Flat.Localization
/-!
# Flat modules in domains
We show that the tensor product of two injective linear maps is injective if the sources are flat
and the ring is an integral domain.
-/
universe u
variable {R M N : Type*} [CommRing R] [IsDomain R] [AddCommGroup M] [Module R M]
variable [AddCommGroup N] [Module R N]
variable {P Q : Type*} [AddCommGroup P] [Module R P] [AddCommGroup Q] [Module R Q]
open TensorProduct Function
attribute [local instance 1100] Module.Free.of_divisionRing Module.Flat.of_free in
/-- Tensor product of injective maps over domains are injective under some flatness conditions.
Also see `TensorProduct.map_injective_of_flat_flat`
for different flatness conditions but without the domain assumption. -/
lemma TensorProduct.map_injective_of_flat_flat_of_isDomain
(f : P →ₗ[R] M) (g : Q →ₗ[R] N) [H : Module.Flat R P] [Module.Flat R Q]
(hf : Injective f) (hg : Injective g) : Injective (TensorProduct.map f g) := by
let K := FractionRing R
refine .of_comp (f := TensorProduct.mk R K _ 1) ?_
have H₁ := TensorProduct.map_injective_of_flat_flat (f.baseChange K) (g.baseChange K)
(Module.Flat.lTensor_preserves_injective_linearMap f hf)
(Module.Flat.lTensor_preserves_injective_linearMap g hg)
have H₂ := (AlgebraTensorModule.cancelBaseChange R K K (K ⊗[R] P) Q).symm.injective
have H₃ := (AlgebraTensorModule.cancelBaseChange R K K (K ⊗[R] M) N).injective
have H₄ := (AlgebraTensorModule.assoc R R K K P Q).symm.injective
have H₅ := (AlgebraTensorModule.assoc R R K K M N).injective
have H₆ := Module.Flat.rTensor_preserves_injective_linearMap (M := P ⊗[R] Q)
(Algebra.linearMap R K) (FaithfulSMul.algebraMap_injective R K)
have H₇ := (TensorProduct.lid R (P ⊗[R] Q)).symm.injective
convert H₅.comp <| H₃.comp <| H₁.comp <| H₂.comp <| H₄.comp <| H₆.comp <| H₇
dsimp only [← LinearMap.coe_comp, ← LinearEquiv.coe_toLinearMap,
← @LinearMap.coe_restrictScalars R K]
congr! 1
ext p q
-- `simp` solves the goal but it times out
change (1 : K) ⊗ₜ[R] (f p ⊗ₜ[R] g q) = (AlgebraTensorModule.assoc R R K K M N)
(((1 : K) • (algebraMap R K) 1 ⊗ₜ[R] f p) ⊗ₜ[R] g q)
simp only [map_one, one_smul, AlgebraTensorModule.assoc_tmul]
variable {ι κ : Type*} {v : ι → M} {w : κ → N} {s : Set ι} {t : Set κ}
/-- Tensor product of linearly independent families is linearly independent over domains.
This is true over non-domains if one of the modules is flat.
See `LinearIndependent.tmul_of_flat_left`. -/
lemma LinearIndependent.tmul_of_isDomain (hv : LinearIndependent R v) (hw : LinearIndependent R w) :
LinearIndependent R fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2 := by
rw [LinearIndependent]
convert (TensorProduct.map_injective_of_flat_flat_of_isDomain _ _ hv hw).comp
(finsuppTensorFinsupp' _ _ _).symm.injective
rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp]
congr!
ext i
simp [finsuppTensorFinsupp'_symm_single_eq_single_one_tmul]
/-- Tensor product of linearly independent families is linearly independent over domains.
This is true over non-domains if one of the modules is flat.
See `LinearIndepOn.tmul_of_flat_left`. -/
nonrec lemma LinearIndepOn.tmul_of_isDomain (hv : LinearIndepOn R v s) (hw : LinearIndepOn R w t) :
LinearIndepOn R (fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2) (s ×ˢ t) :=
((hv.tmul_of_isDomain hw).comp _ (Equiv.Set.prod _ _).injective :) |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/Localization.lean | import Mathlib.RingTheory.Flat.Stability
import Mathlib.RingTheory.LocalProperties.Exactness
/-!
# Flatness and localization
In this file we show that localizations are flat, and flatness is a local property.
## Main result
* `IsLocalization.flat`: a localization of a commutative ring is flat over it.
* `Module.flat_iff_of_isLocalization` : Let `Rₚ` a localization of a commutative ring `R`
and `M` be a module over `Rₚ`. Then `M` is flat over `R` if and only if `M` is flat over `Rₚ`.
* `Module.flat_of_isLocalized_maximal` : Let `M` be a module over a commutative ring `R`.
If the localization of `M` at each maximal ideal `P` is flat over `Rₚ`, then `M` is flat over `R`.
* `Module.flat_of_isLocalized_span` : Let `M` be a module over a commutative ring `R`
and `S` be a set that spans `R`. If the localization of `M` at each `s : S` is flat
over `Localization.Away s`, then `M` is flat over `R`.
-/
open IsLocalizedModule LocalizedModule LinearMap TensorProduct
variable {R : Type*} (S : Type*) [CommSemiring R] [CommSemiring S] [Algebra R S]
variable (p : Submonoid R) [IsLocalization p S]
variable (M : Type*) [AddCommMonoid M] [Module R M] [Module S M] [IsScalarTower R S M]
include p in
theorem IsLocalization.flat : Module.Flat R S := by
refine Module.Flat.iff_lTensor_injectiveₛ.mpr fun P _ _ N ↦ ?_
have h := ((range N.subtype).isLocalizedModule S p (TensorProduct.mk R S P 1)).isBaseChange _ S
let e := (LinearEquiv.ofInjective _ Subtype.val_injective).lTensor S ≪≫ₗ h.equiv.restrictScalars R
have : N.subtype.lTensor S = Submodule.subtype _ ∘ₗ e.toLinearMap := by
ext; change _ = (h.equiv _).1; simp [h.equiv_tmul, TensorProduct.smul_tmul']
simpa [this] using e.injective
instance Localization.flat : Module.Flat R (Localization p) := IsLocalization.flat _ p
namespace Module
include p in
theorem flat_iff_of_isLocalization : Flat S M ↔ Flat R M :=
have := isLocalizedModule_id p M S
have := IsLocalization.flat S p
⟨fun _ ↦ .trans R S M, fun _ ↦ .of_isLocalizedModule S p .id⟩
variable (Mₚ : ∀ (P : Ideal S) [P.IsMaximal], Type*)
[∀ (P : Ideal S) [P.IsMaximal], AddCommMonoid (Mₚ P)]
[∀ (P : Ideal S) [P.IsMaximal], Module R (Mₚ P)]
[∀ (P : Ideal S) [P.IsMaximal], Module S (Mₚ P)]
[∀ (P : Ideal S) [P.IsMaximal], IsScalarTower R S (Mₚ P)]
(f : ∀ (P : Ideal S) [P.IsMaximal], M →ₗ[S] Mₚ P)
[∀ (P : Ideal S) [P.IsMaximal], IsLocalizedModule.AtPrime P (f P)]
include f in
theorem flat_of_isLocalized_maximal (H : ∀ (P : Ideal S) [P.IsMaximal], Flat R (Mₚ P)) :
Module.Flat R M := by
simp_rw [Flat.iff_lTensor_injectiveₛ] at H ⊢
simp_rw [← AlgebraTensorModule.coe_lTensor (A := S)]
refine fun _ _ _ N ↦ injective_of_isLocalized_maximal _
(fun P ↦ AlgebraTensorModule.rTensor R _ (f P)) _
(fun P ↦ AlgebraTensorModule.rTensor R _ (f P)) _ fun P hP ↦ ?_
simpa [IsLocalizedModule.map_lTensor] using H P N
theorem flat_of_localized_maximal
(h : ∀ (P : Ideal R) [P.IsMaximal], Flat R (LocalizedModule P.primeCompl M)) :
Flat R M :=
flat_of_isLocalized_maximal _ _ _ (fun _ _ ↦ mkLinearMap _ _) h
variable (s : Set S) (spn : Ideal.span s = ⊤)
(Mₛ : ∀ _ : s, Type*)
[∀ r : s, AddCommMonoid (Mₛ r)]
[∀ r : s, Module R (Mₛ r)]
[∀ r : s, Module S (Mₛ r)]
[∀ r : s, IsScalarTower R S (Mₛ r)]
(g : ∀ r : s, M →ₗ[S] Mₛ r)
[∀ r : s, IsLocalizedModule.Away r.1 (g r)]
include spn
include g in
theorem flat_of_isLocalized_span (H : ∀ r : s, Module.Flat R (Mₛ r)) :
Module.Flat R M := by
simp_rw [Flat.iff_lTensor_injectiveₛ] at H ⊢
simp_rw [← AlgebraTensorModule.coe_lTensor (A := S)]
refine fun _ _ _ N ↦ injective_of_isLocalized_span s spn _
(fun r ↦ AlgebraTensorModule.rTensor R _ (g r)) _
(fun r ↦ AlgebraTensorModule.rTensor R _ (g r)) _ fun r ↦ ?_
simpa [IsLocalizedModule.map_lTensor] using H r N
theorem flat_of_localized_span
(h : ∀ r : s, Flat S (LocalizedModule.Away r.1 M)) :
Flat S M :=
flat_of_isLocalized_span _ _ _ spn _ (fun _ ↦ mkLinearMap _ _) h
end Module
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
instance [Module.Flat A B] (p : Ideal A) [p.IsPrime] (P : Ideal B) [P.IsPrime] [P.LiesOver p] :
Module.Flat (Localization.AtPrime p) (Localization.AtPrime P) := by
rw [Module.flat_iff_of_isLocalization (Localization.AtPrime p) p.primeCompl]
exact Module.Flat.trans A B (Localization.AtPrime P)
section IsSMulRegular
variable {M} in
theorem IsSMulRegular.of_isLocalizedModule {K : Type*} [AddCommMonoid K] [Module R K]
(f : K →ₗ[R] M) [IsLocalizedModule p f] {x : R} (reg : IsSMulRegular K x) :
IsSMulRegular M (algebraMap R S x) :=
have : Module.Flat R S := IsLocalization.flat S p
reg.of_flat_of_isBaseChange (IsLocalizedModule.isBaseChange p S f)
include p in
theorem IsSMulRegular.of_isLocalization {x : R} (reg : IsSMulRegular R x) :
IsSMulRegular S (algebraMap R S x) :=
reg.of_isLocalizedModule S p (Algebra.linearMap R S)
end IsSMulRegular |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/Stability.lean | import Mathlib.RingTheory.Flat.Basic
import Mathlib.RingTheory.IsTensorProduct
import Mathlib.LinearAlgebra.TensorProduct.Tower
import Mathlib.RingTheory.Localization.BaseChange
import Mathlib.Algebra.Module.LocalizedModule.Basic
/-!
# Flatness is stable under composition and base change
We show that flatness is stable under composition and base change.
## Main theorems
* `Module.Flat.comp`: if `S` is a flat `R`-algebra and `M` is a flat `S`-module,
then `M` is a flat `R`-module
* `Module.Flat.baseChange`: if `M` is a flat `R`-module and `S` is any `R`-algebra,
then `S ⊗[R] M` is `S`-flat.
* `Module.Flat.of_isLocalizedModule`: if `M` is a flat `R`-module and `S` is a submonoid of `R`
then the localization of `M` at `S` is flat as a module
for the localization of `R` at `S`.
-/
universe u v w t
open Function (Injective Surjective)
open LinearMap (lsmul rTensor lTensor)
open TensorProduct
namespace Module.Flat
section Composition
/-! ### Composition
Let `R` be a ring, `S` a flat `R`-algebra and `M` a flat `S`-module. To show that `M` is flat
as an `R`-module, we show that the inclusion of an `R`-submodule `N` into an `R`-module `P`
tensored on the left with `M` is injective. For this consider the composition of natural maps
`M ⊗[R] N ≃ M ⊗[S] (S ⊗[R] N) → M ⊗[S] (S ⊗[R] P) ≃ M ⊗[R] P`;
`S ⊗[R] N → S ⊗[R] P` is injective by `R`-flatness of `S`,
so the middle map is injective by `S`-flatness of `M`.
-/
variable (R : Type u) (S : Type v) (M : Type w)
[CommSemiring R] [CommSemiring S] [Algebra R S]
[AddCommMonoid M] [Module R M] [Module S M] [IsScalarTower R S M]
open AlgebraTensorModule in
/-- If `S` is a flat `R`-algebra, then any flat `S`-Module is also `R`-flat. -/
theorem trans [Flat R S] [Flat S M] : Flat R M := by
rw [Flat.iff_lTensor_injectiveₛ]
introv
rw [← coe_lTensor (A := S), ← EquivLike.injective_comp (cancelBaseChange R S S _ _),
← LinearEquiv.coe_coe, ← LinearMap.coe_comp, lTensor_comp_cancelBaseChange,
LinearMap.coe_comp, LinearEquiv.coe_coe, EquivLike.comp_injective]
iterate 2 apply Flat.lTensor_preserves_injective_linearMap
exact Subtype.val_injective
end Composition
section BaseChange
/-! ### Base change
Let `R` be a ring, `M` a flat `R`-module and `S` an `R`-algebra, then
`S ⊗[R] M` is a flat `S`-module. This is a special case of `Module.Flat.instTensorProduct`.
-/
variable (R : Type u) (S : Type v) (M : Type w)
[CommSemiring R] [CommSemiring S] [Algebra R S]
[AddCommMonoid M] [Module R M]
/-- If `M` is a flat `R`-module and `S` is any `R`-algebra, `S ⊗[R] M` is `S`-flat. -/
instance baseChange [Flat R M] : Flat S (S ⊗[R] M) := inferInstance
/-- A base change of a flat module is flat. -/
theorem isBaseChange [Flat R M] (N : Type t) [AddCommMonoid N] [Module R N] [Module S N]
[IsScalarTower R S N] {f : M →ₗ[R] N} (h : IsBaseChange S f) :
Flat S N :=
of_linearEquiv (IsBaseChange.equiv h).symm
end BaseChange
section Localization
variable {R : Type u} {M Mp : Type*} (Rp : Type v)
[CommSemiring R] [AddCommMonoid M] [Module R M] [CommSemiring Rp] [Algebra R Rp]
[AddCommMonoid Mp] [Module R Mp] [Module Rp Mp] [IsScalarTower R Rp Mp]
instance localizedModule [Flat R M] (S : Submonoid R) :
Flat (Localization S) (LocalizedModule S M) := by
apply Flat.isBaseChange (R := R) (S := Localization S)
(f := LocalizedModule.mkLinearMap S M)
rw [← isLocalizedModule_iff_isBaseChange S]
exact localizedModuleIsLocalizedModule S
theorem of_isLocalizedModule [Flat R M] (S : Submonoid R) [IsLocalization S Rp]
(f : M →ₗ[R] Mp) [h : IsLocalizedModule S f] : Flat Rp Mp := by
fapply Flat.isBaseChange (R := R) (M := M) (S := Rp) (N := Mp)
exact (isLocalizedModule_iff_isBaseChange S Rp f).mp h
end Localization
end Module.Flat |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/CategoryTheory.lean | import Mathlib.RingTheory.Flat.Basic
import Mathlib.Algebra.Homology.ShortComplex.ModuleCat
import Mathlib.Algebra.Category.ModuleCat.Monoidal.Basic
/-!
# Tensoring with a flat module is an exact functor
In this file we prove that tensoring with a flat module is an exact functor.
## Main results
- `Module.Flat.iff_lTensor_preserves_shortComplex_exact`: an `R`-module `M` is flat if and only if
for every exact sequence `A ⟶ B ⟶ C`, `M ⊗ A ⟶ M ⊗ B ⟶ M ⊗ C` is also exact.
- `Module.Flat.iff_rTensor_preserves_shortComplex_exact`: an `R`-module `M` is flat if and only if
for every short exact sequence `A ⟶ B ⟶ C`, `A ⊗ M ⟶ B ⊗ M ⟶ C ⊗ M` is also exact.
## TODO
- Prove that tensoring with a flat module is an exact functor in the sense that it preserves both
finite limits and colimits.
- Relate flatness with `Tor`
-/
universe u
open CategoryTheory MonoidalCategory ShortComplex.ShortExact
namespace Module.Flat
variable {R : Type u} [CommRing R] (M : ModuleCat.{u} R)
lemma lTensor_shortComplex_exact [Flat R M] (C : ShortComplex <| ModuleCat R) (hC : C.Exact) :
C.map (tensorLeft M) |>.Exact := by
rw [moduleCat_exact_iff_function_exact] at hC ⊢
exact lTensor_exact M hC
lemma rTensor_shortComplex_exact [Flat R M] (C : ShortComplex <| ModuleCat R) (hC : C.Exact) :
C.map (tensorRight M) |>.Exact := by
rw [moduleCat_exact_iff_function_exact] at hC ⊢
exact rTensor_exact M hC
lemma iff_lTensor_preserves_shortComplex_exact :
Flat R M ↔
∀ (C : ShortComplex <| ModuleCat R) (_ : C.Exact), (C.map (tensorLeft M) |>.Exact) :=
⟨fun _ _ ↦ lTensor_shortComplex_exact _ _, fun H ↦ iff_lTensor_exact.2
fun _ _ _ _ _ _ _ _ _ f g h ↦
moduleCat_exact_iff_function_exact _ |>.1 <|
H (.mk (ModuleCat.ofHom f) (ModuleCat.ofHom g)
(ModuleCat.hom_ext (DFunLike.ext _ _ h.apply_apply_eq_zero)))
(moduleCat_exact_iff_function_exact _ |>.2 h)⟩
lemma iff_rTensor_preserves_shortComplex_exact :
Flat R M ↔
∀ (C : ShortComplex <| ModuleCat R) (_ : C.Exact), (C.map (tensorRight M) |>.Exact) :=
⟨fun _ _ ↦ rTensor_shortComplex_exact _ _, fun H ↦ iff_rTensor_exact.2
fun _ _ _ _ _ _ _ _ _ f g h ↦
moduleCat_exact_iff_function_exact _ |>.1 <|
H (.mk (ModuleCat.ofHom f) (ModuleCat.ofHom g)
(ModuleCat.hom_ext (DFunLike.ext _ _ h.apply_apply_eq_zero)))
(moduleCat_exact_iff_function_exact _ |>.2 h)⟩
end Module.Flat |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/Equalizer.lean | import Mathlib.RingTheory.Flat.Basic
/-!
# Base change along flat modules preserves equalizers
We show that base change along flat modules (resp. algebras)
preserves kernels and equalizers.
-/
universe t u
noncomputable section
open TensorProduct
variable {R : Type*} (S : Type*) [CommRing R] [CommRing S] [Algebra R S]
section Module
variable (M : Type*) [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M]
variable {N P : Type*} [AddCommGroup N] [AddCommGroup P] [Module R N] [Module R P]
(f g : N →ₗ[R] P)
lemma Module.Flat.ker_lTensor_eq [Module.Flat R M] :
LinearMap.ker (AlgebraTensorModule.lTensor S M f) =
LinearMap.range (AlgebraTensorModule.lTensor S M (LinearMap.ker f).subtype) := by
rw [← LinearMap.exact_iff]
exact Module.Flat.lTensor_exact M (LinearMap.exact_subtype_ker_map f)
lemma Module.Flat.eqLocus_lTensor_eq [Module.Flat R M] :
LinearMap.eqLocus (AlgebraTensorModule.lTensor S M f)
(AlgebraTensorModule.lTensor S M g) =
LinearMap.range (AlgebraTensorModule.lTensor S M (LinearMap.eqLocus f g).subtype) := by
rw [LinearMap.eqLocus_eq_ker_sub, LinearMap.eqLocus_eq_ker_sub]
rw [← map_sub, ker_lTensor_eq]
/-- The bilinear map corresponding to `LinearMap.tensorEqLocus`. -/
def LinearMap.tensorEqLocusBil :
M →ₗ[S] LinearMap.eqLocus f g →ₗ[R]
LinearMap.eqLocus (AlgebraTensorModule.lTensor S M f)
(AlgebraTensorModule.lTensor S M g) where
toFun m :=
{ toFun := fun a ↦ ⟨m ⊗ₜ a, by simp [show f a = g a from a.property]⟩
map_add' := fun x y ↦ by simp [tmul_add]
map_smul' := fun r x ↦ by simp }
map_add' x y := by
ext
simp [add_tmul]
map_smul' r x := by
ext
simp [smul_tmul']
/-- The bilinear map corresponding to `LinearMap.tensorKer`. -/
def LinearMap.tensorKerBil :
M →ₗ[S] LinearMap.ker f →ₗ[R] LinearMap.ker (AlgebraTensorModule.lTensor S M f) where
toFun m :=
{ toFun := fun a ↦ ⟨m ⊗ₜ a, by simp⟩
map_add' := fun x y ↦ by simp [tmul_add]
map_smul' := fun r x ↦ by simp }
map_add' x y := by ext; simp [add_tmul]
map_smul' r x := by ext y; simp [smul_tmul']
/-- The canonical map `M ⊗[R] eq(f, g) →ₗ[R] eq(𝟙 ⊗ f, 𝟙 ⊗ g)`. -/
def LinearMap.tensorEqLocus : M ⊗[R] (LinearMap.eqLocus f g) →ₗ[S]
LinearMap.eqLocus (AlgebraTensorModule.lTensor S M f) (AlgebraTensorModule.lTensor S M g) :=
AlgebraTensorModule.lift (tensorEqLocusBil S M f g)
/-- The canonical map `M ⊗[R] ker f →ₗ[R] ker (𝟙 ⊗ f)`. -/
def LinearMap.tensorKer : M ⊗[R] (LinearMap.ker f) →ₗ[S]
LinearMap.ker (AlgebraTensorModule.lTensor S M f) :=
AlgebraTensorModule.lift (f.tensorKerBil S M)
@[simp]
lemma LinearMap.tensorKer_tmul (m : M) (x : LinearMap.ker f) :
(tensorKer S M f (m ⊗ₜ[R] x) : M ⊗[R] N) = m ⊗ₜ[R] (x : N) :=
rfl
@[simp]
lemma LinearMap.tensorKer_coe (x : M ⊗[R] (LinearMap.ker f)) :
(tensorKer S M f x : M ⊗[R] N) = (ker f).subtype.lTensor M x := by
induction x <;> simp_all
@[simp]
lemma LinearMap.tensorEqLocus_tmul (m : M) (x : LinearMap.eqLocus f g) :
(tensorEqLocus S M f g (m ⊗ₜ[R] x) : M ⊗[R] N) = m ⊗ₜ[R] (x : N) :=
rfl
@[simp]
lemma LinearMap.tensorEqLocus_coe (x : M ⊗[R] (LinearMap.eqLocus f g)) :
(tensorEqLocus S M f g x : M ⊗[R] N) = (eqLocus f g).subtype.lTensor M x := by
induction x <;> simp_all
private def LinearMap.tensorKerInv [Module.Flat R M] :
ker (AlgebraTensorModule.lTensor S M f) →ₗ[S] M ⊗[R] (ker f) :=
LinearMap.codRestrictOfInjective (LinearMap.ker (AlgebraTensorModule.lTensor S M f)).subtype
(AlgebraTensorModule.lTensor S M (ker f).subtype)
(Module.Flat.lTensor_preserves_injective_linearMap (ker f).subtype
(ker f).injective_subtype) (by simp [Module.Flat.ker_lTensor_eq])
@[simp]
private lemma LinearMap.lTensor_ker_subtype_tensorKerInv [Module.Flat R M]
(x : ker (AlgebraTensorModule.lTensor S M f)) :
(lTensor M (ker f).subtype) ((tensorKerInv S M f) x) = x := by
rw [← AlgebraTensorModule.coe_lTensor (A := S)]
simp [LinearMap.tensorKerInv]
private def LinearMap.tensorEqLocusInv [Module.Flat R M] :
eqLocus (AlgebraTensorModule.lTensor S M f) (AlgebraTensorModule.lTensor S M g) →ₗ[S]
M ⊗[R] (eqLocus f g) :=
LinearMap.codRestrictOfInjective
(LinearMap.eqLocus (AlgebraTensorModule.lTensor S M f)
(AlgebraTensorModule.lTensor S M g)).subtype
(AlgebraTensorModule.lTensor S M (eqLocus f g).subtype)
(Module.Flat.lTensor_preserves_injective_linearMap (eqLocus f g).subtype
(eqLocus f g).injective_subtype) (by simp [Module.Flat.eqLocus_lTensor_eq])
@[simp]
private lemma LinearMap.lTensor_eqLocus_subtype_tensorEqLocusInv [Module.Flat R M]
(x : eqLocus (AlgebraTensorModule.lTensor S M f) (AlgebraTensorModule.lTensor S M g)) :
(lTensor M (eqLocus f g).subtype) (tensorEqLocusInv S M f g x) = x := by
rw [← AlgebraTensorModule.coe_lTensor (A := S)]
simp [LinearMap.tensorEqLocusInv]
/-- If `M` is `R`-flat, the canonical map `M ⊗[R] ker f →ₗ[R] ker (𝟙 ⊗ f)` is an isomorphism. -/
def LinearMap.tensorKerEquiv [Module.Flat R M] :
M ⊗[R] LinearMap.ker f ≃ₗ[S] LinearMap.ker (AlgebraTensorModule.lTensor S M f) :=
LinearEquiv.ofLinear (LinearMap.tensorKer S M f) (LinearMap.tensorKerInv S M f)
(by ext x; simp)
(by
ext m x
apply (Module.Flat.lTensor_preserves_injective_linearMap (ker f).subtype
(ker f).injective_subtype)
simp)
@[simp]
lemma LinearMap.tensorKerEquiv_apply [Module.Flat R M] (x : M ⊗[R] ker f) :
tensorKerEquiv S M f x = tensorKer S M f x :=
rfl
@[simp]
lemma LinearMap.lTensor_ker_subtype_tensorKerEquiv_symm [Module.Flat R M]
(x : ker (AlgebraTensorModule.lTensor S M f)) :
(lTensor M (ker f).subtype) ((tensorKerEquiv S M f).symm x) = x :=
lTensor_ker_subtype_tensorKerInv S M f x
/-- If `M` is `R`-flat, the canonical map `M ⊗[R] eq(f, g) →ₗ[S] eq (𝟙 ⊗ f, 𝟙 ⊗ g)` is an
isomorphism. -/
def LinearMap.tensorEqLocusEquiv [Module.Flat R M] :
M ⊗[R] eqLocus f g ≃ₗ[S]
eqLocus (AlgebraTensorModule.lTensor S M f)
(AlgebraTensorModule.lTensor S M g) :=
LinearEquiv.ofLinear (LinearMap.tensorEqLocus S M f g) (LinearMap.tensorEqLocusInv S M f g)
(by ext; simp)
(by
ext m x
apply (Module.Flat.lTensor_preserves_injective_linearMap (eqLocus f g).subtype
(eqLocus f g).injective_subtype)
simp)
@[simp]
lemma LinearMap.tensorEqLocusEquiv_apply [Module.Flat R M] (x : M ⊗[R] LinearMap.eqLocus f g) :
LinearMap.tensorEqLocusEquiv S M f g x = LinearMap.tensorEqLocus S M f g x :=
rfl
@[simp]
lemma LinearMap.lTensor_eqLocus_subtype_tensoreqLocusEquiv_symm [Module.Flat R M]
(x : eqLocus (AlgebraTensorModule.lTensor S M f) (AlgebraTensorModule.lTensor S M g)) :
(lTensor M (eqLocus f g).subtype) ((tensorEqLocusEquiv S M f g).symm x) = x :=
lTensor_eqLocus_subtype_tensorEqLocusInv S M f g x
end Module
section Algebra
variable (T : Type*) [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
(f g : A →ₐ[R] B)
private def AlgHom.tensorEqualizerAux :
T ⊗[R] AlgHom.equalizer f g →ₗ[S]
AlgHom.equalizer (Algebra.TensorProduct.map (AlgHom.id S T) f)
(Algebra.TensorProduct.map (AlgHom.id S T) g) :=
LinearMap.tensorEqLocus S T (f : A →ₗ[R] B) (g : A →ₗ[R] B)
private local instance : AddHomClass (A →ₐ[R] B) A B := inferInstance
@[simp]
private lemma AlgHom.coe_tensorEqualizerAux (x : T ⊗[R] AlgHom.equalizer f g) :
(AlgHom.tensorEqualizerAux S T f g x : T ⊗[R] A) =
Algebra.TensorProduct.map (AlgHom.id S T) (AlgHom.equalizer f g).val x := by
induction x with
| zero => rfl
| tmul => rfl
| add x y hx hy => simp [hx, hy]
private lemma AlgHom.tensorEqualizerAux_mul (x y : T ⊗[R] AlgHom.equalizer f g) :
AlgHom.tensorEqualizerAux S T f g (x * y) =
AlgHom.tensorEqualizerAux S T f g x *
AlgHom.tensorEqualizerAux S T f g y := by
apply Subtype.ext
rw [AlgHom.coe_tensorEqualizerAux]
simp
/-- The canonical map `T ⊗[R] eq(f, g) →ₐ[S] eq (𝟙 ⊗ f, 𝟙 ⊗ g)`. -/
def AlgHom.tensorEqualizer :
T ⊗[R] AlgHom.equalizer f g →ₐ[S]
AlgHom.equalizer (Algebra.TensorProduct.map (AlgHom.id S T) f)
(Algebra.TensorProduct.map (AlgHom.id S T) g) :=
AlgHom.ofLinearMap (AlgHom.tensorEqualizerAux S T f g)
rfl (AlgHom.tensorEqualizerAux_mul S T f g)
@[simp]
lemma AlgHom.coe_tensorEqualizer (x : T ⊗[R] AlgHom.equalizer f g) :
(AlgHom.tensorEqualizer S T f g x : T ⊗[R] A) =
Algebra.TensorProduct.map (AlgHom.id S T) (AlgHom.equalizer f g).val x :=
AlgHom.coe_tensorEqualizerAux S T f g x
/-- If `T` is `R`-flat, the canonical map
`T ⊗[R] eq(f, g) →ₐ[S] eq (𝟙 ⊗ f, 𝟙 ⊗ g)` is an isomorphism. -/
def AlgHom.tensorEqualizerEquiv [Module.Flat R T] :
T ⊗[R] AlgHom.equalizer f g ≃ₐ[S]
AlgHom.equalizer (Algebra.TensorProduct.map (AlgHom.id S T) f)
(Algebra.TensorProduct.map (AlgHom.id S T) g) :=
AlgEquiv.ofLinearEquiv (LinearMap.tensorEqLocusEquiv S T f.toLinearMap g.toLinearMap)
rfl (AlgHom.tensorEqualizerAux_mul S T f g)
@[simp]
lemma AlgHom.tensorEqualizerEquiv_apply [Module.Flat R T]
(x : T ⊗[R] AlgHom.equalizer f g) :
AlgHom.tensorEqualizerEquiv S T f g x = AlgHom.tensorEqualizer S T f g x :=
rfl
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/Tensor.lean | import Mathlib.Algebra.Module.CharacterModule
import Mathlib.RingTheory.Flat.Basic
/-!
# Flat modules
`M` is flat if `· ⊗ M` preserves finite limits (equivalently, pullbacks, or equalizers).
If `R` is a ring, an `R`-module `M` is flat if and only if it is mono-flat, and to show
a module is flat, it suffices to check inclusions of finitely generated ideals into `R`.
See <https://stacks.math.columbia.edu/tag/00HD>.
## Main theorems
* `Module.Flat.iff_characterModule_injective`: `CharacterModule M` is an injective module iff
`M` is flat.
* `Module.Flat.iff_lTensor_injective`, `Module.Flat.iff_rTensor_injective`,
`Module.Flat.iff_lTensor_injective'`, `Module.Flat.iff_rTensor_injective'`:
A module `M` over a ring `R` is flat iff for all (finitely generated) ideals `I` of `R`, the
tensor product of the inclusion `I → R` and the identity `M → M` is injective.
-/
universe u v
namespace Module.Flat
open Function (Surjective)
open LinearMap
variable {R : Type u} {M : Type v} [CommRing R] [AddCommGroup M] [Module R M]
/--
Define the character module of `M` to be `M →+ ℚ ⧸ ℤ`.
The character module of `M` is an injective module if and only if
`f ⊗ 𝟙 M` is injective for any linear map `f` in the same universe as `M`.
-/
lemma injective_characterModule_iff_rTensor_preserves_injective_linearMap :
Module.Injective R (CharacterModule M) ↔
∀ ⦃N N' : Type v⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
(f : N →ₗ[R] N'), Function.Injective f → Function.Injective (f.rTensor M) := by
simp_rw [injective_iff, rTensor_injective_iff_lcomp_surjective, Surjective, DFunLike.ext_iff]; rfl
/-- `CharacterModule M` is an injective module iff `M` is flat.
See [Lambek_1964] for a self-contained proof. -/
theorem iff_characterModule_injective [Small.{v} R] :
Flat R M ↔ Module.Injective R (CharacterModule M) := by
rw [injective_characterModule_iff_rTensor_preserves_injective_linearMap,
iff_rTensor_preserves_injective_linearMap']
/-- `CharacterModule M` is Baer iff `M` is flat. -/
theorem iff_characterModule_baer : Flat R M ↔ Baer R (CharacterModule M) := by
rw [equiv_iff (N := ULift.{u} M) ULift.moduleEquiv.symm, iff_characterModule_injective,
← Baer.iff_injective, Baer.congr (CharacterModule.congr ULift.moduleEquiv)]
/-- An `R`-module `M` is flat iff for all ideals `I` of `R`, the tensor product of the
inclusion `I → R` and the identity `M → M` is injective. See `iff_rTensor_injective` to
restrict to finitely generated ideals `I`. -/
theorem iff_rTensor_injective' :
Flat R M ↔ ∀ I : Ideal R, Function.Injective (rTensor M I.subtype) := by
simp_rw [iff_characterModule_baer, Baer, rTensor_injective_iff_lcomp_surjective,
Surjective, DFunLike.ext_iff, Subtype.forall, lcomp_apply, Submodule.subtype_apply]
/-- The `lTensor`-variant of `iff_rTensor_injective'`. . -/
theorem iff_lTensor_injective' :
Flat R M ↔ ∀ (I : Ideal R), Function.Injective (lTensor M I.subtype) := by
simpa [← comm_comp_rTensor_comp_comm_eq] using iff_rTensor_injective'
/-- A module `M` over a ring `R` is flat iff for all finitely generated ideals `I` of `R`, the
tensor product of the inclusion `I → R` and the identity `M → M` is injective. See
`iff_rTensor_injective'` to extend to all ideals `I`. -/
lemma iff_rTensor_injective :
Flat R M ↔ ∀ ⦃I : Ideal R⦄, I.FG → Function.Injective (I.subtype.rTensor M) := by
refine iff_rTensor_injective'.trans ⟨fun h I _ ↦ h I,
fun h I ↦ (injective_iff_map_eq_zero _).mpr fun x hx ↦ ?_⟩
obtain ⟨J, hfg, hle, y, rfl⟩ := Submodule.exists_fg_le_eq_rTensor_inclusion x
rw [← rTensor_comp_apply] at hx
rw [(injective_iff_map_eq_zero _).mp (h hfg) y hx, map_zero]
/-- The `lTensor`-variant of `iff_rTensor_injective`. -/
theorem iff_lTensor_injective :
Flat R M ↔ ∀ ⦃I : Ideal R⦄, I.FG → Function.Injective (I.subtype.lTensor M) := by
simpa [← comm_comp_rTensor_comp_comm_eq] using iff_rTensor_injective
/-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
the canonical map `I ⊗ M →ₗ M` is injective. -/
lemma iff_lift_lsmul_comp_subtype_injective : Flat R M ↔ ∀ ⦃I : Ideal R⦄, I.FG →
Function.Injective (TensorProduct.lift ((lsmul R M).comp I.subtype)) := by
simp [iff_rTensor_injective, ← lid_comp_rTensor]
end Module.Flat |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/FaithfullyFlat/Descent.lean | import Mathlib.RingTheory.RingHom.FaithfullyFlat
import Mathlib.RingTheory.RingHom.Injective
import Mathlib.RingTheory.RingHom.Surjective
/-!
# Properties satisfying faithfully flat descent for rings
We show the following properties of ring homomorphisms descend under faithfully flat ring maps:
- injective
- surjective
- bijective
-/
open TensorProduct
section
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S]
{T : Type*} [CommRing T] [Algebra R T]
lemma Module.FaithfullyFlat.injective_of_tensorProduct [Module.FaithfullyFlat R S]
(H : Function.Injective (algebraMap S (S ⊗[R] T))) :
Function.Injective (algebraMap R T) := by
have : LinearMap.lTensor S (Algebra.linearMap R T) =
Algebra.linearMap S (S ⊗[R] T) ∘ₗ (AlgebraTensorModule.rid R S S).toLinearMap := by
ext; simp
apply (Module.FaithfullyFlat.lTensor_injective_iff_injective R S (Algebra.linearMap R T)).mp
simpa [this] using H
lemma Module.FaithfullyFlat.surjective_of_tensorProduct [Module.FaithfullyFlat R S]
(H : Function.Surjective (algebraMap S (S ⊗[R] T))) :
Function.Surjective (algebraMap R T) := by
have : LinearMap.lTensor S (Algebra.linearMap R T) =
Algebra.linearMap S (S ⊗[R] T) ∘ₗ (AlgebraTensorModule.rid R S S).toLinearMap := by
ext; simp
apply (Module.FaithfullyFlat.lTensor_surjective_iff_surjective R S (Algebra.linearMap R T)).mp
simpa [this] using H
lemma Module.FaithfullyFlat.bijective_of_tensorProduct [Module.FaithfullyFlat R S]
(H : Function.Bijective (algebraMap S (S ⊗[R] T))) :
Function.Bijective (algebraMap R T) :=
⟨injective_of_tensorProduct H.1, surjective_of_tensorProduct H.2⟩
end
lemma RingHom.FaithfullyFlat.codescendsAlong_injective :
CodescendsAlong (fun f ↦ Function.Injective f) FaithfullyFlat := by
apply CodescendsAlong.mk _ injective_respectsIso
introv h H
rw [faithfullyFlat_algebraMap_iff] at h
exact h.injective_of_tensorProduct H
lemma RingHom.FaithfullyFlat.codescendsAlong_surjective :
CodescendsAlong (fun f ↦ Function.Surjective f) FaithfullyFlat := by
apply CodescendsAlong.mk _ surjective_respectsIso
introv h H
rw [faithfullyFlat_algebraMap_iff] at h
exact h.surjective_of_tensorProduct H
universe u
lemma RingHom.FaithfullyFlat.codescendsAlong_bijective :
CodescendsAlong (fun f ↦ Function.Bijective f) FaithfullyFlat :=
CodescendsAlong.and codescendsAlong_injective codescendsAlong_surjective |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/FaithfullyFlat/Basic.lean | import Mathlib.LinearAlgebra.TensorProduct.Quotient
import Mathlib.RingTheory.Flat.Stability
/-!
# Faithfully flat modules
A module `M` over a commutative ring `R` is *faithfully flat* if it is flat and `IM ≠ M` whenever
`I` is a maximal ideal of `R`.
## Main declaration
- `Module.FaithfullyFlat`: the predicate asserting that an `R`-module `M` is faithfully flat.
## Main theorems
- `Module.FaithfullyFlat.iff_flat_and_proper_ideal`: an `R`-module `M` is faithfully flat iff it is
flat and for all proper ideals `I` of `R`, `I • M ≠ M`.
- `Module.FaithfullyFlat.iff_flat_and_rTensor_faithful`: an `R`-module `M` is faithfully flat iff it
is flat and tensoring with `M` is faithful, i.e. `N ≠ 0` implies `N ⊗ M ≠ 0`.
- `Module.FaithfullyFlat.iff_flat_and_lTensor_faithful`: an `R`-module `M` is faithfully flat iff it
is flat and tensoring with `M` is faithful, i.e. `N ≠ 0` implies `M ⊗ N ≠ 0`.
- `Module.FaithfullyFlat.iff_exact_iff_rTensor_exact`: an `R`-module `M` is faithfully flat iff
tensoring with `M` preserves and reflects exact sequences, i.e. the sequence `N₁ → N₂ → N₃` is
exact *iff* the sequence `N₁ ⊗ M → N₂ ⊗ M → N₃ ⊗ M` is exact.
- `Module.FaithfullyFlat.iff_exact_iff_lTensor_exact`: an `R`-module `M` is faithfully flat iff
tensoring with `M` preserves and reflects exact sequences, i.e. the sequence `N₁ → N₂ → N₃` is
exact *iff* the sequence `M ⊗ N₁ → M ⊗ N₂ → M ⊗ N₃` is exact.
- `Module.FaithfullyFlat.iff_zero_iff_lTensor_zero`: an `R`-module `M` is faithfully flat iff for
all linear maps `f : N → N'`, `f = 0` iff `M ⊗ f = 0`.
- `Module.FaithfullyFlat.iff_zero_iff_rTensor_zero`: an `R`-module `M` is faithfully flat iff for
all linear maps `f : N → N'`, `f = 0` iff `f ⊗ M = 0`.
- `Module.FaithfullyFlat.of_linearEquiv`: modules linearly equivalent to a flat modules are flat
- `Module.FaithfullyFlat.trans`: if `S` is `R`-faithfully flat and `M` is `S`-faithfully flat, then
`M` is `R`-faithfully flat.
- `Module.FaithfullyFlat.self`: the `R`-module `R` is faithfully flat.
-/
universe u v
open TensorProduct DirectSum
namespace Module
variable (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M]
/--
A module `M` over a commutative ring `R` is *faithfully flat* if it is flat and,
for all `R`-linear maps `f : N → N'` such that `id ⊗ f = 0`, we have `f = 0`.
-/
@[mk_iff] class FaithfullyFlat : Prop extends Module.Flat R M where
submodule_ne_top : ∀ ⦃m : Ideal R⦄ (_ : Ideal.IsMaximal m), m • (⊤ : Submodule R M) ≠ ⊤
namespace FaithfullyFlat
instance self : FaithfullyFlat R R where
submodule_ne_top m h r := Ideal.eq_top_iff_one _ |>.not.1 h.ne_top <| by
simpa using show 1 ∈ (m • ⊤ : Ideal R) from r.symm ▸ ⟨⟩
section proper_ideal
lemma iff_flat_and_proper_ideal :
FaithfullyFlat R M ↔
(Flat R M ∧ ∀ (I : Ideal R), I ≠ ⊤ → I • (⊤ : Submodule R M) ≠ ⊤) := by
rw [faithfullyFlat_iff]
refine ⟨fun ⟨flat, h⟩ => ⟨flat, fun I hI r => ?_⟩, fun h => ⟨h.1, fun m hm => h.2 _ hm.ne_top⟩⟩
obtain ⟨m, hm, le⟩ := I.exists_le_maximal hI
exact h hm <| eq_top_iff.2 <| show ⊤ ≤ m • ⊤ from r ▸ Submodule.smul_mono le (by simp [r])
lemma iff_flat_and_ideal_smul_eq_top :
FaithfullyFlat R M ↔
(Flat R M ∧ ∀ (I : Ideal R), I • (⊤ : Submodule R M) = ⊤ → I = ⊤) :=
iff_flat_and_proper_ideal R M |>.trans <| and_congr_right_iff.2 fun _ => iff_of_eq <|
forall_congr fun I => eq_iff_iff.2 <| by tauto
end proper_ideal
section faithful
instance rTensor_nontrivial
[fl : FaithfullyFlat R M] (N : Type*) [AddCommGroup N] [Module R N] [Nontrivial N] :
Nontrivial (N ⊗[R] M) := by
obtain ⟨n, hn⟩ := nontrivial_iff_exists_ne (0 : N) |>.1 inferInstance
let I := (Submodule.span R {n}).annihilator
by_cases I_ne_top : I = ⊤
· rw [Ideal.eq_top_iff_one, Submodule.mem_annihilator_span_singleton, one_smul] at I_ne_top
contradiction
let inc : R ⧸ I →ₗ[R] N := Submodule.liftQ _ ((LinearMap.lsmul R N).flip n) <| fun r hr => by
simpa only [LinearMap.mem_ker, LinearMap.flip_apply, LinearMap.lsmul_apply,
Submodule.mem_annihilator_span_singleton, I] using hr
have injective_inc : Function.Injective inc := LinearMap.ker_eq_bot.1 <| eq_bot_iff.2 <| by
intro r hr
induction r using Quotient.inductionOn' with | h r =>
simpa only [Submodule.Quotient.mk''_eq_mk, Submodule.mem_bot, Submodule.Quotient.mk_eq_zero,
Submodule.mem_annihilator_span_singleton, LinearMap.mem_ker, Submodule.liftQ_apply,
LinearMap.flip_apply, LinearMap.lsmul_apply, I, inc] using hr
have ne_top := iff_flat_and_proper_ideal R M |>.1 fl |>.2 I I_ne_top
refine subsingleton_or_nontrivial _ |>.resolve_left fun rid => ?_
exact False.elim <| ne_top <| Submodule.subsingleton_quotient_iff_eq_top.1 <|
Function.Injective.comp (g := LinearMap.rTensor M inc)
(fl.toFlat.rTensor_preserves_injective_linearMap inc injective_inc)
((quotTensorEquivQuotSMul M I).symm.injective) |>.subsingleton
instance lTensor_nontrivial
[FaithfullyFlat R M] (N : Type*) [AddCommGroup N] [Module R N] [Nontrivial N] :
Nontrivial (M ⊗[R] N) :=
TensorProduct.comm R M N |>.toEquiv.nontrivial
lemma rTensor_reflects_triviality
[FaithfullyFlat R M] (N : Type*) [AddCommGroup N] [Module R N]
[h : Subsingleton (N ⊗[R] M)] : Subsingleton N := by
revert h; change _ → _; contrapose!
intro h
infer_instance
lemma lTensor_reflects_triviality
[FaithfullyFlat R M] (N : Type*) [AddCommGroup N] [Module R N]
[Subsingleton (M ⊗[R] N)] :
Subsingleton N := by
haveI : Subsingleton (N ⊗[R] M) := (TensorProduct.comm R N M).toEquiv.injective.subsingleton
apply rTensor_reflects_triviality R M
attribute [-simp] Ideal.Quotient.mk_eq_mk in
lemma iff_flat_and_rTensor_faithful :
FaithfullyFlat R M ↔
(Flat R M ∧
∀ (N : Type max u v) [AddCommGroup N] [Module R N],
Nontrivial N → Nontrivial (N ⊗[R] M)) := by
refine ⟨fun fl => ⟨inferInstance, rTensor_nontrivial R M⟩, fun ⟨flat, faithful⟩ => ⟨?_⟩⟩
intro m hm rid
specialize faithful (ULift (R ⧸ m)) inferInstance
haveI : Nontrivial ((R ⧸ m) ⊗[R] M) :=
(congr (ULift.moduleEquiv : ULift (R ⧸ m) ≃ₗ[R] R ⧸ m)
(LinearEquiv.refl R M)).symm.toEquiv.nontrivial
have := (quotTensorEquivQuotSMul M m).toEquiv.symm.nontrivial
haveI H : Subsingleton (M ⧸ m • (⊤ : Submodule R M)) := by
rwa [Submodule.subsingleton_quotient_iff_eq_top]
rw [← not_nontrivial_iff_subsingleton] at H
contradiction
lemma iff_flat_and_rTensor_reflects_triviality :
FaithfullyFlat R M ↔
(Flat R M ∧
∀ (N : Type max u v) [AddCommGroup N] [Module R N],
Subsingleton (N ⊗[R] M) → Subsingleton N) :=
iff_flat_and_rTensor_faithful R M |>.trans <| and_congr_right_iff.2 fun _ => iff_of_eq <|
forall_congr fun N => forall_congr fun _ => forall_congr fun _ => iff_iff_eq.1 <| by
simp only [← not_subsingleton_iff_nontrivial]; tauto
lemma iff_flat_and_lTensor_faithful :
FaithfullyFlat R M ↔
(Flat R M ∧
∀ (N : Type max u v) [AddCommGroup N] [Module R N],
Nontrivial N → Nontrivial (M ⊗[R] N)) :=
iff_flat_and_rTensor_faithful R M |>.trans
⟨fun ⟨flat, faithful⟩ => ⟨flat, fun N _ _ _ =>
letI := faithful N inferInstance; (TensorProduct.comm R M N).toEquiv.nontrivial⟩,
fun ⟨flat, faithful⟩ => ⟨flat, fun N _ _ _ =>
letI := faithful N inferInstance; (TensorProduct.comm R M N).symm.toEquiv.nontrivial⟩⟩
lemma iff_flat_and_lTensor_reflects_triviality :
FaithfullyFlat R M ↔
(Flat R M ∧
∀ (N : Type max u v) [AddCommGroup N] [Module R N],
Subsingleton (M ⊗[R] N) → Subsingleton N) :=
iff_flat_and_lTensor_faithful R M |>.trans <| and_congr_right_iff.2 fun _ => iff_of_eq <|
forall_congr fun N => forall_congr fun _ => forall_congr fun _ => iff_iff_eq.1 <| by
simp only [← not_subsingleton_iff_nontrivial]; tauto
end faithful
/-- If `M` is a faithfully flat `R`-module and `N` is `R`-linearly isomorphic to `M`, then
`N` is faithfully flat. -/
lemma of_linearEquiv {N : Type*} [AddCommGroup N] [Module R N] [FaithfullyFlat R M]
(e : N ≃ₗ[R] M) : FaithfullyFlat R N := by
rw [iff_flat_and_lTensor_faithful]
exact ⟨Flat.of_linearEquiv e,
fun P _ _ hP ↦ (TensorProduct.congr e (LinearEquiv.refl R P)).toEquiv.nontrivial⟩
section
/-- A direct sum of faithfully flat `R`-modules is faithfully flat. -/
instance directSum {ι : Type*} [Nonempty ι] (M : ι → Type*) [∀ i, AddCommGroup (M i)]
[∀ i, Module R (M i)] [∀ i, FaithfullyFlat R (M i)] : FaithfullyFlat R (⨁ i, M i) := by
classical
rw [iff_flat_and_lTensor_faithful]
refine ⟨inferInstance, fun N _ _ hN ↦ ?_⟩
obtain ⟨i⟩ := ‹Nonempty ι›
obtain ⟨x, y, hxy⟩ := Nontrivial.exists_pair_ne (α := M i ⊗[R] N)
haveI : Nontrivial (⨁ (i : ι), M i ⊗[R] N) :=
⟨DirectSum.of _ i x, DirectSum.of _ i y, fun h ↦ hxy (DirectSum.of_injective i h)⟩
apply (TensorProduct.directSumLeft R M N).toEquiv.nontrivial
/-- Free `R`-modules over discrete types are flat. -/
instance finsupp (ι : Type v) [Nonempty ι] : FaithfullyFlat R (ι →₀ R) := by
classical exact of_linearEquiv _ _ (finsuppLEquivDirectSum R R ι)
end
/-- Any free, nontrivial `R`-module is flat. -/
instance [Nontrivial M] [Module.Free R M] : FaithfullyFlat R M :=
of_linearEquiv _ _ (Free.chooseBasis R M).repr
section
variable {N : Type*} [AddCommGroup N] [Module R N]
@[simp]
lemma subsingleton_tensorProduct_iff_right [Module.FaithfullyFlat R M] :
Subsingleton (M ⊗[R] N) ↔ Subsingleton N :=
⟨fun _ ↦ lTensor_reflects_triviality R M N, fun _ ↦ inferInstance⟩
@[simp]
lemma subsingleton_tensorProduct_iff_left [Module.FaithfullyFlat R N] :
Subsingleton (M ⊗[R] N) ↔ Subsingleton M :=
⟨fun _ ↦ rTensor_reflects_triviality R N M, fun _ ↦ inferInstance⟩
@[simp]
lemma nontrivial_tensorProduct_iff_right [Module.FaithfullyFlat R M] :
Nontrivial (M ⊗[R] N) ↔ Nontrivial N := by
simp [← not_iff_not, not_nontrivial_iff_subsingleton]
@[simp]
lemma nontrivial_tensorProduct_iff_left [Module.FaithfullyFlat R N] :
Nontrivial (M ⊗[R] N) ↔ Nontrivial M := by
simp [← not_iff_not, not_nontrivial_iff_subsingleton]
end
section exact
/-!
### Faithfully flat modules and exact sequences
In this section we prove that an `R`-module `M` is faithfully flat iff tensoring with `M`
preserves and reflects exact sequences.
Let `N₁ -l₁₂-> N₂ -l₂₃-> N₃` be two linear maps.
- We first show that if `N₁ ⊗ M -> N₂ ⊗ M -> N₃ ⊗ M` is exact, then `N₁ -l₁₂-> N₂ -l₂₃-> N₃` is a
complex, i.e. `range l₁₂ ≤ ker l₂₃`.
This is `range_le_ker_of_exact_rTensor`.
- Then in `rTensor_reflects_exact`, we show `ker l₂₃ = range l₁₂` by considering the cohomology
`ker l₂₃ ⧸ range l₁₂`.
This shows that when `M` is faithfully flat, `- ⊗ M` reflects exact sequences. For details, see
comments in the proof. Since `M` is flat, `- ⊗ M` preserves exact sequences.
On the other hand, if `- ⊗ M` preserves and reflects exact sequences, then `M` is faithfully flat.
- `M` is flat because `- ⊗ M` preserves exact sequences.
- We need to show that if `N ⊗ M = 0` then `N = 0`. Consider the sequence `N -0-> N -0-> 0`. After
tensoring with `M`, we get `N ⊗ M -0-> N ⊗ M -0-> 0` which is exact because `N ⊗ M = 0`.
Since `- ⊗ M` reflects exact sequences, `N = 0`.
-/
section arbitrary_universe
variable {N1 : Type*} [AddCommGroup N1] [Module R N1]
variable {N2 : Type*} [AddCommGroup N2] [Module R N2]
variable {N3 : Type*} [AddCommGroup N3] [Module R N3]
variable (l12 : N1 →ₗ[R] N2) (l23 : N2 →ₗ[R] N3)
/--
If `M` is faithfully flat, then exactness of `N₁ ⊗ M -> N₂ ⊗ M -> N₃ ⊗ M` implies that the
composition `N₁ -> N₂ -> N₃` is `0`.
Implementation detail, please use `rTensor_reflects_exact` instead.
-/
lemma range_le_ker_of_exact_rTensor [fl : FaithfullyFlat R M]
(ex : Function.Exact (l12.rTensor M) (l23.rTensor M)) :
LinearMap.range l12 ≤ LinearMap.ker l23 := by
-- let `n1 ∈ N1`. We need to show `l23 (l12 n1) = 0`. Suppose this is not the case.
rintro _ ⟨n1, rfl⟩
rw [LinearMap.mem_ker]
by_contra! hn1
-- Let `E` be the submodule spanned by `l23 (l12 n1)`. Then because `l23 (l12 n1) ≠ 0`, we have
-- `E ≠ 0`.
let E : Submodule R N3 := Submodule.span R {l23 (l12 n1)}
have hE : Nontrivial E :=
⟨0, ⟨⟨l23 (l12 n1), Submodule.mem_span_singleton_self _⟩, Subtype.coe_ne_coe.1 hn1.symm⟩⟩
-- Since `N1 ⊗ M -> N2 ⊗ M -> N3 ⊗ M` is exact, we have `l23 (l12 n1) ⊗ₜ m = 0` for all `m : M`.
have eq1 : ∀ (m : M), l23 (l12 n1) ⊗ₜ[R] m = 0 := fun m ↦
ex.apply_apply_eq_zero (n1 ⊗ₜ[R] m)
-- Then `E ⊗ M = 0`. Indeed,
have eq0 : (⊤ : Submodule R (E ⊗[R] M)) = ⊥ := by
-- suppose `x ∈ E ⊗ M`. We will show `x = 0`.
ext x
simp only [Submodule.mem_top, Submodule.mem_bot, true_iff]
have mem : x ∈ (⊤ : Submodule R _) := ⟨⟩
rw [← TensorProduct.span_tmul_eq_top, Submodule.mem_span_set] at mem
obtain ⟨c, hc, rfl⟩ := mem
choose b a hy using hc
let r : ⦃a : E ⊗[R] M⦄ → a ∈ ↑c.support → R := fun a ha =>
Submodule.mem_span_singleton.1 (b ha).2 |>.choose
have hr : ∀ ⦃i : E ⊗[R] M⦄ (hi : i ∈ c.support), b hi =
r hi • ⟨l23 (l12 n1), Submodule.mem_span_singleton_self _⟩ := fun a ha =>
Subtype.ext <| Submodule.mem_span_singleton.1 (b ha).2 |>.choose_spec.symm
-- Since `M` is flat and `E -> N1` is injective, we only need to check that x = 0
-- in `N1 ⊗ M`. We write `x = ∑ μᵢ • (l23 (l12 n1)) ⊗ mᵢ = ∑ μᵢ • 0 = 0`
-- (remember `E = span {l23 (l12 n1)}` and `eq1`)
refine Finset.sum_eq_zero fun i hi => show c i • i = 0 from
(Module.Flat.rTensor_preserves_injective_linearMap (M := M) E.subtype <|
Submodule.injective_subtype E) ?_
rw [← hy hi, hr hi, smul_tmul, map_smul, LinearMap.rTensor_tmul, Submodule.subtype_apply, eq1,
smul_zero, map_zero]
have : Subsingleton (E ⊗[R] M) := subsingleton_iff_forall_eq 0 |>.2 fun x =>
show x ∈ (⊥ : Submodule R _) from eq0 ▸ ⟨⟩
-- but `E ⊗ M = 0` implies `E = 0` because `M` is faithfully flat and this is a contradiction.
exact not_subsingleton_iff_nontrivial.2 inferInstance <| fl.rTensor_reflects_triviality R M E
lemma rTensor_reflects_exact [fl : FaithfullyFlat R M]
(ex : Function.Exact (l12.rTensor M) (l23.rTensor M)) :
Function.Exact l12 l23 := LinearMap.exact_iff.2 <| by
have complex : LinearMap.range l12 ≤ LinearMap.ker l23 := range_le_ker_of_exact_rTensor R M _ _ ex
-- By the previous lemma we have that range l12 ≤ ker l23 and hence the quotient
-- H := ker l23 ⧸ range l12 makes sense.
-- Hence our goal ker l23 = range l12 follows from the claim that H = 0.
let H := LinearMap.ker l23 ⧸ LinearMap.range (Submodule.inclusion complex)
suffices triv_coh : Subsingleton H by
rw [Submodule.subsingleton_quotient_iff_eq_top, Submodule.range_inclusion,
Submodule.comap_subtype_eq_top] at triv_coh
exact le_antisymm triv_coh complex
-- Since `M` is faithfully flat, we need only to show that `H ⊗ M` is trivial.
suffices Subsingleton (H ⊗[R] M) from rTensor_reflects_triviality R M H
let e : H ⊗[R] M ≃ₗ[R] _ := TensorProduct.quotientTensorEquiv _ _
-- Note that `H ⊗ M` is isomorphic to `ker l12 ⊗ M ⧸ range ((range l12 ⊗ M) -> (ker l23 ⊗ M))`.
-- So the problem is reduced to proving surjectivity of `range l12 ⊗ M → ker l23 ⊗ M`.
rw [e.toEquiv.subsingleton_congr, Submodule.subsingleton_quotient_iff_eq_top,
LinearMap.range_eq_top]
intro x
induction x using TensorProduct.induction_on with
| zero => exact ⟨0, by simp⟩
-- let `x ⊗ m` be an element in `ker l23 ⊗ M`, then `x ⊗ m` is in the kernel of `l23 ⊗ 𝟙M`.
-- Since `N1 ⊗ M -l12 ⊗ M-> N2 ⊗ M -l23 ⊗ M-> N3 ⊗ M` is exact, we have that `x ⊗ m` is in
-- the range of `l12 ⊗ 𝟙M`, i.e. `x ⊗ m = (l12 ⊗ 𝟙M) y` for some `y ∈ N1 ⊗ M` as elements of
-- `N2 ⊗ M`. We need to prove that `x ⊗ m = (l12 ⊗ 𝟙M) y` still holds in `(ker l23) ⊗ M`.
-- This is okay because `M` is flat and `ker l23 -> N2` is injective.
| tmul x m =>
rcases x with ⟨x, (hx : l23 x = 0)⟩
have mem : x ⊗ₜ[R] m ∈ LinearMap.ker (l23.rTensor M) := by simp [hx]
rw [LinearMap.exact_iff.1 ex] at mem
obtain ⟨y, hy⟩ := mem
refine ⟨LinearMap.rTensor M (LinearMap.rangeRestrict _ ∘ₗ LinearMap.rangeRestrict l12) y,
Module.Flat.rTensor_preserves_injective_linearMap (LinearMap.ker l23).subtype
Subtype.val_injective ?_⟩
simp only [LinearMap.comp_codRestrict, LinearMap.rTensor_tmul, Submodule.coe_subtype, ← hy]
rw [← LinearMap.comp_apply, ← LinearMap.rTensor_def, ← LinearMap.rTensor_comp,
← LinearMap.comp_apply, ← LinearMap.rTensor_comp, LinearMap.comp_assoc,
LinearMap.subtype_comp_codRestrict, ← LinearMap.comp_assoc, Submodule.subtype_comp_inclusion,
LinearMap.subtype_comp_codRestrict]
| add x y hx hy =>
obtain ⟨x, rfl⟩ := hx; obtain ⟨y, rfl⟩ := hy
exact ⟨x + y, by simp⟩
lemma lTensor_reflects_exact [fl : FaithfullyFlat R M]
(ex : Function.Exact (l12.lTensor M) (l23.lTensor M)) :
Function.Exact l12 l23 :=
rTensor_reflects_exact R M _ _ <| ex.of_ladder_linearEquiv_of_exact
(e₁ := TensorProduct.comm _ _ _) (e₂ := TensorProduct.comm _ _ _)
(e₃ := TensorProduct.comm _ _ _) (by ext; rfl) (by ext; rfl)
@[simp]
lemma rTensor_exact_iff_exact [FaithfullyFlat R M] :
Function.Exact (l12.rTensor M) (l23.rTensor M) ↔ Function.Exact l12 l23 :=
⟨fun ex ↦ rTensor_reflects_exact R M l12 l23 ex, fun e ↦ Module.Flat.rTensor_exact _ e⟩
@[simp]
lemma lTensor_exact_iff_exact [FaithfullyFlat R M] :
Function.Exact (l12.lTensor M) (l23.lTensor M) ↔ Function.Exact l12 l23 :=
⟨fun ex ↦ lTensor_reflects_exact R M l12 l23 ex, fun e ↦ Module.Flat.lTensor_exact _ e⟩
section
variable {N N' : Type*} [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
(f : N →ₗ[R] N')
@[simp]
lemma lTensor_injective_iff_injective [Module.FaithfullyFlat R M] :
Function.Injective (f.lTensor M) ↔ Function.Injective f := by
rw [← LinearMap.exact_zero_iff_injective (M ⊗[R] Unit), ← LinearMap.exact_zero_iff_injective Unit]
conv_rhs => rw [← lTensor_exact_iff_exact R M]
simp
@[simp]
lemma lTensor_surjective_iff_surjective [Module.FaithfullyFlat R M] :
Function.Surjective (f.lTensor M) ↔ Function.Surjective f := by
rw [← LinearMap.exact_zero_iff_surjective (M ⊗[R] Unit),
← LinearMap.exact_zero_iff_surjective Unit]
conv_rhs => rw [← lTensor_exact_iff_exact R M]
simp
end
end arbitrary_universe
section fixed_universe
lemma iff_exact_iff_rTensor_exact :
FaithfullyFlat R M ↔
(∀ {N1 : Type max u v} [AddCommGroup N1] [Module R N1]
{N2 : Type max u v} [AddCommGroup N2] [Module R N2]
{N3 : Type max u v} [AddCommGroup N3] [Module R N3]
(l12 : N1 →ₗ[R] N2) (l23 : N2 →ₗ[R] N3),
Function.Exact l12 l23 ↔ Function.Exact (l12.rTensor M) (l23.rTensor M)) :=
⟨fun fl _ _ _ _ _ _ _ _ _ l12 l23 => (rTensor_exact_iff_exact R M l12 l23).symm, fun iff_exact =>
iff_flat_and_rTensor_reflects_triviality _ _ |>.2
⟨Flat.iff_rTensor_exact.2 <| fun _ _ _ => iff_exact .. |>.1,
fun N _ _ h => subsingleton_iff_forall_eq 0 |>.2 <| fun y => by
simpa [eq_comm] using (iff_exact (0 : PUnit →ₗ[R] N) (0 : N →ₗ[R] PUnit) |>.2 fun x => by
simpa using Subsingleton.elim _ _) y⟩⟩
lemma iff_exact_iff_lTensor_exact :
FaithfullyFlat R M ↔
(∀ {N1 : Type max u v} [AddCommGroup N1] [Module R N1]
{N2 : Type max u v} [AddCommGroup N2] [Module R N2]
{N3 : Type max u v} [AddCommGroup N3] [Module R N3]
(l12 : N1 →ₗ[R] N2) (l23 : N2 →ₗ[R] N3),
Function.Exact l12 l23 ↔ Function.Exact (l12.lTensor M) (l23.lTensor M)) := by
simp only [iff_exact_iff_rTensor_exact, LinearMap.rTensor_exact_iff_lTensor_exact]
end fixed_universe
end exact
section linearMap
/-!
### Faithfully flat modules and linear maps
In this section we prove that an `R`-module `M` is faithfully flat iff the following holds:
- `M` is flat
- for any `R`-linear map `f : N → N'`, `f` = 0 iff `f ⊗ 𝟙M = 0` iff `𝟙M ⊗ f = 0`
-/
section arbitrary_universe
/--
If `M` is a faithfully flat module, then for all linear maps `f`, the map `id ⊗ f = 0`, if and only
if `f = 0`. -/
lemma zero_iff_lTensor_zero [h : FaithfullyFlat R M]
{N : Type*} [AddCommGroup N] [Module R N]
{N' : Type*} [AddCommGroup N'] [Module R N'] (f : N →ₗ[R] N') :
f = 0 ↔ LinearMap.lTensor M f = 0 :=
⟨fun hf => hf.symm ▸ LinearMap.lTensor_zero M, fun hf => by
have := lTensor_reflects_exact R M f LinearMap.id (by
rw [LinearMap.exact_iff, hf, LinearMap.range_zero, LinearMap.ker_eq_bot]
apply Module.Flat.lTensor_preserves_injective_linearMap
exact fun _ _ h => h)
ext x; simpa using this (f x)⟩
/--
If `M` is a faithfully flat module, then for all linear maps `f`, the map `f ⊗ id = 0`, if and only
if `f = 0`. -/
lemma zero_iff_rTensor_zero [h: FaithfullyFlat R M]
{N : Type*} [AddCommGroup N] [Module R N]
{N' : Type*} [AddCommGroup N'] [Module R N']
(f : N →ₗ[R] N') :
f = 0 ↔ LinearMap.rTensor M f = 0 :=
zero_iff_lTensor_zero R M f |>.trans
⟨fun h => by ext n m; exact (TensorProduct.comm R N' M).injective <|
(by simpa using congr($h (m ⊗ₜ n))), fun h => by
ext m n; exact (TensorProduct.comm R M N').injective <| (by simpa using congr($h (n ⊗ₜ m)))⟩
/-- If `A` is a faithfully flat `R`-algebra, and `m` is a term of an `R`-module `M`,
then `1 ⊗ₜ[R] m = 0` if and only if `m = 0`. -/
@[simp]
theorem one_tmul_eq_zero_iff {A : Type*} [Ring A] [Algebra R A] [FaithfullyFlat R A] (m : M) :
(1:A) ⊗ₜ[R] m = 0 ↔ m = 0 := by
constructor; swap
· rintro rfl; rw [tmul_zero]
intro h
let f : R →ₗ[R] M := (LinearMap.lsmul R M).flip m
suffices f = 0 by simpa [f] using DFunLike.congr_fun this 1
rw [Module.FaithfullyFlat.zero_iff_lTensor_zero R A]
ext a
apply_fun (a • ·) at h
rw [smul_zero, smul_tmul', smul_eq_mul, mul_one] at h
simpa [f]
end arbitrary_universe
section fixed_universe
/--
An `R`-module `M` is faithfully flat iff it is flat and for all linear maps `f`, the map
`id ⊗ f = 0`, if and only if `f = 0`. -/
lemma iff_zero_iff_lTensor_zero :
FaithfullyFlat R M ↔
(Module.Flat R M ∧
(∀ {N : Type max u v} [AddCommGroup N] [Module R N]
{N' : Type max u v} [AddCommGroup N'] [Module R N']
(f : N →ₗ[R] N'), f.lTensor M = 0 ↔ f = 0)) :=
⟨fun fl => ⟨inferInstance, fun f => zero_iff_lTensor_zero R M f |>.symm⟩,
fun ⟨flat, Z⟩ => iff_flat_and_lTensor_reflects_triviality R M |>.2 ⟨flat, fun N _ _ _ => by
have := Z (LinearMap.id : N →ₗ[R] N) |>.1 (by ext; exact Subsingleton.elim _ _)
rw [subsingleton_iff_forall_eq 0]
exact fun y => congr($this y)⟩⟩
/--
An `R`-module `M` is faithfully flat iff it is flat and for all linear maps `f`, the map
`id ⊗ f = 0`, if and only if `f = 0`. -/
lemma iff_zero_iff_rTensor_zero :
FaithfullyFlat R M ↔
(Module.Flat R M ∧
(∀ {N : Type max u v} [AddCommGroup N] [Module R N]
{N' : Type max u v} [AddCommGroup N'] [Module R N']
(f : N →ₗ[R] N'), f.rTensor M = 0 ↔ (f = 0))) :=
⟨fun fl => ⟨inferInstance, fun f => zero_iff_rTensor_zero R M f |>.symm⟩,
fun ⟨flat, Z⟩ => iff_flat_and_rTensor_reflects_triviality R M |>.2 ⟨flat, fun N _ _ _ => by
have := Z (LinearMap.id : N →ₗ[R] N) |>.1 (by ext; exact Subsingleton.elim _ _)
rw [subsingleton_iff_forall_eq 0]
exact fun y => congr($this y)⟩⟩
end fixed_universe
end linearMap
section trans
open TensorProduct LinearMap
variable (R : Type*) [CommRing R]
variable (S : Type*) [CommRing S] [Algebra R S]
variable (M : Type*) [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M]
variable [FaithfullyFlat R S] [FaithfullyFlat S M]
include S in
/-- If `S` is a faithfully flat `R`-algebra, then any faithfully flat `S`-Module is faithfully flat
as an `R`-module. -/
theorem trans : FaithfullyFlat R M := by
rw [iff_zero_iff_lTensor_zero]
refine ⟨Module.Flat.trans R S M, @fun N _ _ N' _ _ f => ⟨fun aux => ?_, fun eq => eq ▸ by simp⟩⟩
rw [zero_iff_lTensor_zero (R:= R) (M := S) f,
show f.lTensor S = (AlgebraTensorModule.map (A:= S) LinearMap.id f).restrictScalars R by aesop,
show (0 : S ⊗[R] N →ₗ[R] S ⊗[R] N') = (0 : S ⊗[R] N →ₗ[S] S ⊗[R] N').restrictScalars R by rfl,
restrictScalars_inj, zero_iff_lTensor_zero (R:= S) (M := M)]
ext m n
apply_fun AlgebraTensorModule.cancelBaseChange R S S M N' using LinearEquiv.injective _
simpa using congr($aux (m ⊗ₜ[R] n))
end trans
/-- Faithful flatness is preserved by arbitrary base change. -/
instance (S : Type*) [CommRing S] [Algebra R S] [Module.FaithfullyFlat R M] :
Module.FaithfullyFlat S (S ⊗[R] M) := by
rw [Module.FaithfullyFlat.iff_flat_and_rTensor_reflects_triviality]
refine ⟨inferInstance, fun N _ _ hN ↦ ?_⟩
let _ : Module R N := Module.compHom N (algebraMap R S)
have : IsScalarTower R S N := IsScalarTower.of_algebraMap_smul fun r ↦ congrFun rfl
have := (AlgebraTensorModule.cancelBaseChange R S S N M).symm.subsingleton
exact FaithfullyFlat.rTensor_reflects_triviality R M N
section IsBaseChange
variable {S N : Type*} [CommRing S] [Algebra R S] [FaithfullyFlat R S]
[AddCommGroup N] [Module R N] [Module S N] [IsScalarTower R S N] {f : M →ₗ[R] N}
theorem _root_.IsBaseChange.map_smul_top_ne_top_iff_of_faithfullyFlat (hf : IsBaseChange S f)
(I : Ideal R) :
I.map (algebraMap R S) • (⊤ : Submodule S N) ≠ ⊤ ↔ I • (⊤ : Submodule R M) ≠ ⊤ := by
simpa only [← Submodule.subsingleton_quotient_iff_eq_top.not] using not_congr <|
(tensorQuotEquivQuotSMul N (I.map (algebraMap R S))).symm ≪≫ₗ TensorProduct.comm S N _ ≪≫ₗ
hf.tensorEquiv _ ≪≫ₗ AlgebraTensorModule.congr (I.qoutMapEquivTensorQout S) (.refl R M) ≪≫ₗ
AlgebraTensorModule.assoc R R S S _ M ≪≫ₗ (TensorProduct.comm R _ M).baseChange R S _ _ ≪≫ₗ
(tensorQuotEquivQuotSMul M I).baseChange R S _ _ |>.subsingleton_congr.trans <|
subsingleton_tensorProduct_iff_right R S
end IsBaseChange
end FaithfullyFlat
/-- Flat descends along faithfully flat ring maps. -/
lemma Flat.of_flat_tensorProduct (S : Type*) [CommRing S] [Algebra R S]
[Module.FaithfullyFlat R S] [Module.Flat S (S ⊗[R] M)] : Module.Flat R M := by
rw [Module.Flat.iff_lTensor_preserves_injective_linearMap]
intro N P _ _ _ _ f hf
have : Flat R (S ⊗[R] M) := Flat.trans _ S _
rw [← FaithfullyFlat.lTensor_injective_iff_injective R S]
have : LinearMap.lTensor S (LinearMap.lTensor M f) =
(TensorProduct.assoc _ _ _ _).toLinearMap ∘ₗ LinearMap.lTensor (S ⊗[R] M) f ∘ₗ
(TensorProduct.assoc _ _ _ _).symm.toLinearMap := by
ext
simp
simpa [this] using Flat.lTensor_preserves_injective_linearMap f hf
lemma Flat.iff_flat_tensorProduct (S : Type*) [CommRing S] [Algebra R S]
[Module.FaithfullyFlat R S] : Module.Flat S (S ⊗[R] M) ↔ Module.Flat R M :=
⟨fun _ ↦ .of_flat_tensorProduct R M S, fun _ ↦ inferInstance⟩
end Module |
.lake/packages/mathlib/Mathlib/RingTheory/Flat/FaithfullyFlat/Algebra.lean | import Mathlib.RingTheory.Flat.FaithfullyFlat.Basic
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.LocalRing.RingHom.Basic
import Mathlib.RingTheory.Spectrum.Prime.RingHom
import Mathlib.RingTheory.TensorProduct.Quotient
/-!
# Properties of faithfully flat algebras
An `A`-algebra `B` is faithfully flat if `B` is faithfully flat as an `A`-module. In this
file we give equivalent characterizations of faithful flatness in the algebra case.
## Main results
Let `B` be a faithfully flat `A`-algebra:
- `Ideal.comap_map_eq_self_of_faithfullyFlat`: the contraction of the extension of any ideal of
`A` to `B` is the ideal itself.
- `Module.FaithfullyFlat.tensorProduct_mk_injective`: The natural map `M →ₗ[A] B ⊗[A] M` is
injective for any `A`-module `M`.
- `PrimeSpectrum.specComap_surjective_of_faithfullyFlat`: The map on prime spectra induced by
a faithfully flat ring map is surjective. See also
`Ideal.exists_isPrime_liesOver_of_faithfullyFlat` for a version stated in terms of
`Ideal.LiesOver`.
Conversely, let `B` be a flat `A`-algebra:
- `Module.FaithfullyFlat.of_specComap_surjective`: `B` is faithfully flat over `A`,
if the induced map on prime spectra is surjective.
- `Module.FaithfullyFlat.of_flat_of_isLocalHom`: flat + local implies faithfully flat
-/
universe u v
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
open TensorProduct LinearMap
/-- If `A →+* B` is flat and surjective on prime spectra, `B` is a faithfully flat `A`-algebra. -/
lemma Module.FaithfullyFlat.of_specComap_surjective [Flat A B]
(h : Function.Surjective ((algebraMap A B).specComap)) :
Module.FaithfullyFlat A B := by
refine ⟨fun m hm ↦ ?_⟩
obtain ⟨m', hm'⟩ := h ⟨m, hm.isPrime⟩
have : m = Ideal.comap (algebraMap A B) m'.asIdeal := by
rw [← PrimeSpectrum.specComap_asIdeal (algebraMap A B) m', hm']
rw [Ideal.smul_top_eq_map, this]
exact (Submodule.restrictScalars_eq_top_iff _ _ _).ne.mpr
fun top ↦ m'.isPrime.ne_top <| top_le_iff.mp <| top ▸ Ideal.map_comap_le
/-- If `A` is local and `B` is a local and flat `A`-algebra, then `B` is faithfully flat. -/
lemma Module.FaithfullyFlat.of_flat_of_isLocalHom [IsLocalRing A] [IsLocalRing B] [Flat A B]
[IsLocalHom (algebraMap A B)] : Module.FaithfullyFlat A B := by
refine ⟨fun m hm ↦ ?_⟩
rw [Ideal.smul_top_eq_map, IsLocalRing.eq_maximalIdeal hm]
by_contra eqt
have : Submodule.restrictScalars A (Ideal.map (algebraMap A B) (IsLocalRing.maximalIdeal A)) ≤
Submodule.restrictScalars A (IsLocalRing.maximalIdeal B) :=
((IsLocalRing.local_hom_TFAE (algebraMap A B)).out 0 2).mp ‹_›
rw [eqt, top_le_iff, Submodule.restrictScalars_eq_top_iff] at this
exact Ideal.IsPrime.ne_top' this
variable [Module.FaithfullyFlat A B]
/-- If `B` is a faithfully flat `A`-module and `M` is any `A`-module, the canonical
map `M →ₗ[A] B ⊗[A] M` is injective. -/
lemma Module.FaithfullyFlat.tensorProduct_mk_injective (M : Type*) [AddCommGroup M] [Module A M] :
Function.Injective (TensorProduct.mk A B M 1) := by
rw [← Module.FaithfullyFlat.lTensor_injective_iff_injective A B]
have : (lTensor B <| TensorProduct.mk A B M 1) =
(TensorProduct.leftComm A B B M).symm.comp (TensorProduct.mk A B (B ⊗[A] M) 1) := by
apply TensorProduct.ext'
intro x y
simp
rw [this, coe_comp, LinearEquiv.coe_coe, EmbeddingLike.comp_injective]
exact Algebra.TensorProduct.mk_one_injective_of_isScalarTower _
instance Module.FaithfullyFlat.faithfulSMul : FaithfulSMul A B := by
constructor
intro a₁ a₂ ha
apply Module.FaithfullyFlat.tensorProduct_mk_injective (A := A) (B := B) A
simp only [TensorProduct.mk_apply]
rw [← mul_one a₁, ← mul_one a₂]
simp only [← smul_eq_mul, ← TensorProduct.smul_tmul, ha (1 : B)]
open Algebra.TensorProduct in
/-- If `B` is a faithfully flat `A`-algebra, the preimage of the pushforward of any
ideal `I` is again `I`. -/
lemma Ideal.comap_map_eq_self_of_faithfullyFlat (I : Ideal A) :
(I.map (algebraMap A B)).comap (algebraMap A B) = I := by
refine le_antisymm ?_ le_comap_map
have inj : Function.Injective
((quotIdealMapEquivTensorQuot B I).symm.toLinearMap.restrictScalars _ ∘ₗ
TensorProduct.mk A B (A ⧸ I) 1) := by
rw [LinearMap.coe_comp]
exact (AlgEquiv.injective _).comp <|
Module.FaithfullyFlat.tensorProduct_mk_injective (A ⧸ I)
intro x hx
rw [Ideal.mem_comap] at hx
rw [← Ideal.Quotient.eq_zero_iff_mem] at hx ⊢
apply inj
have : ((quotIdealMapEquivTensorQuot B I).symm.toLinearMap.restrictScalars _ ∘ₗ
TensorProduct.mk A B (A ⧸ I) 1) x = 0 := by
simp [← Algebra.algebraMap_eq_smul_one, hx]
simp [this]
/-- If `B` is a faithfully-flat `A`-algebra, every ideal in `A` is the preimage of some ideal
in `B`. -/
lemma Ideal.comap_surjective_of_faithfullyFlat :
Function.Surjective (Ideal.comap (algebraMap A B)) :=
fun I ↦ ⟨I.map (algebraMap A B), comap_map_eq_self_of_faithfullyFlat I⟩
/-- If `B` is faithfully flat over `A`, every prime of `A` comes from a prime of `B`. -/
lemma Ideal.exists_isPrime_liesOver_of_faithfullyFlat (p : Ideal A) [p.IsPrime] :
∃ (P : Ideal B), P.IsPrime ∧ P.LiesOver p := by
obtain ⟨P, _, hP⟩ := (Ideal.comap_map_eq_self_iff_of_isPrime p).mp <|
p.comap_map_eq_self_of_faithfullyFlat (B := B)
exact ⟨P, inferInstance, ⟨hP.symm⟩⟩
/-- If `B` is a faithfully flat `A`-algebra, the induced map on the prime spectrum is
surjective. -/
lemma PrimeSpectrum.specComap_surjective_of_faithfullyFlat :
Function.Surjective (algebraMap A B).specComap := fun I ↦
(PrimeSpectrum.mem_range_comap_iff (algebraMap A B)).mpr
I.asIdeal.comap_map_eq_self_of_faithfullyFlat |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/Regular.lean | import Mathlib.RingTheory.Flat.TorsionFree
import Mathlib.RingTheory.KrullDimension.Module
import Mathlib.RingTheory.Regular.RegularSequence
import Mathlib.RingTheory.Spectrum.Prime.LTSeries
/-!
# Krull Dimension of quotient regular sequence
## Main results
- `Module.supportDim_add_length_eq_supportDim_of_isRegular`: If `M` is a finite module over a
Noetherian local ring `R`, `r₁, …, rₙ` is an `M`-sequence, then
`dim M/(r₁, …, rₙ)M + n = dim M`.
-/
namespace Module
variable {R : Type*} [CommRing R] [IsNoetherianRing R]
{M : Type*} [AddCommGroup M] [Module R M] [Module.Finite R M]
open RingTheory Sequence IsLocalRing Ideal PrimeSpectrum Pointwise
omit [IsNoetherianRing R] [Module.Finite R M] in
lemma exists_ltSeries_support_isMaximal_last_of_ltSeries_support (q : LTSeries (support R M)) :
∃ p : LTSeries (support R M), q.length ≤ p.length ∧ p.last.1.1.IsMaximal := by
obtain ⟨m, hmm, hm⟩ := exists_le_maximal _ q.last.1.2.1
obtain hlt | rfl := lt_or_eq_of_le hm
· use q.snoc ⟨⟨m, inferInstance⟩, mem_support_mono hm q.last.2⟩ hlt
simpa
· use q
theorem supportDim_le_supportDim_quotSMulTop_succ_of_mem_jacobson {x : R}
(h : x ∈ (annihilator R M).jacobson) : supportDim R M ≤ supportDim R (QuotSMulTop x M) + 1 := by
nontriviality M
refine iSup_le_iff.mpr (fun p ↦ ?_)
wlog hxp : x ∈ p.last.1.1 generalizing p
· obtain ⟨p, hle, hm⟩ := exists_ltSeries_support_isMaximal_last_of_ltSeries_support p
have hj : (annihilator R M).jacobson ≤ p.last.1.1 :=
sInf_le ⟨mem_support_iff_of_finite.mp p.last.2, inferInstance⟩
exact (Nat.cast_le.mpr hle).trans <| this _ (hj h)
-- `q` is a chain of primes such that `x ∈ q 1`, `p.length = q.length` and `p.head = q.head`.
obtain ⟨q, hxq, hq, h0, _⟩ : ∃ q : LTSeries (PrimeSpectrum R), _ ∧ _ ∧ p.head = q.head ∧ _ :=
exist_ltSeries_mem_one_of_mem_last (p.map Subtype.val (fun ⦃_ _⦄ lt ↦ lt)) hxp
by_cases hp0 : p.length = 0
· have hb : supportDim R (QuotSMulTop x M) ≠ ⊥ :=
(supportDim_ne_bot_iff_nontrivial R (QuotSMulTop x M)).mpr <|
Submodule.Quotient.nontrivial_of_ne_top _ <|
(Submodule.top_ne_pointwise_smul_of_mem_jacobson_annihilator h).symm
rw [hp0, ← WithBot.coe_unbot (supportDim R (QuotSMulTop x M)) hb]
exact WithBot.coe_le_coe.mpr (zero_le ((supportDim R (QuotSMulTop x M)).unbot hb + 1))
-- Let `q' i := q (i + 1)`, then `q'` is a chain of prime ideals in `Supp(M/xM)`.
let q' : LTSeries (support R (QuotSMulTop x M)) := {
length := p.length - 1
toFun := by
intro ⟨i, hi⟩
have hi : i + 1 < q.length + 1 :=
Nat.succ_lt_succ (hi.trans_eq ((Nat.sub_add_cancel (Nat.pos_of_ne_zero hp0)).trans hq))
exact ⟨q ⟨i + 1, hi⟩, by simpa using
⟨mem_support_mono (by simpa [h0] using q.monotone (Fin.zero_le _)) p.head.2, q.monotone
((Fin.natCast_eq_mk (Nat.lt_of_add_left_lt hi)).trans_le (Nat.le_add_left 1 i)) hxq⟩⟩
step := by exact fun _ ↦ q.strictMono (by simp)
}
calc (p.length : WithBot ℕ∞) ≤ (p.length - 1 + 1 : ℕ) := Nat.cast_le.mpr le_tsub_add
_ ≤ _ := by simpa using add_le_add_right (by exact le_iSup_iff.mpr fun _ h ↦ h q') 1
omit [IsNoetherianRing R] in
/-- If `M` is a finite module over a commutative ring `R`, `x ∈ M` is not in any minimal prime of
`M`, then `dim M/xM + 1 ≤ dim M`. -/
theorem supportDim_quotSMulTop_succ_le_of_notMem_minimalPrimes {x : R}
(hn : ∀ p ∈ (annihilator R M).minimalPrimes, x ∉ p) :
supportDim R (QuotSMulTop x M) + 1 ≤ supportDim R M := by
nontriviality M
nontriviality (QuotSMulTop x M)
have : Nonempty (Module.support R M) := nonempty_support_of_nontrivial.to_subtype
have : Nonempty (Module.support R (QuotSMulTop x M)) := nonempty_support_of_nontrivial.to_subtype
simp only [supportDim, Order.krullDim_eq_iSup_length]
apply WithBot.coe_le_coe.mpr
simp only [ENat.iSup_add, iSup_le_iff]
intro p
have hp := p.head.2
simp only [support_quotSMulTop, Set.mem_inter_iff, mem_zeroLocus, Set.singleton_subset_iff] at hp
have le : support R (QuotSMulTop x M) ⊆ support R M := by simp
-- Since `Supp(M/xM) ⊆ Supp M`, `p` can be viewed as a chain of prime ideals in `Supp M`,
-- which we denote by `q`.
let q : LTSeries (support R M) :=
p.map (Set.MapsTo.restrict id (support R (QuotSMulTop x M)) (support R M) le) (fun _ _ h ↦ h)
obtain ⟨r, hrm, hr⟩ := exists_minimalPrimes_le (mem_support_iff_of_finite.mp q.head.2)
let r : support R M := ⟨⟨r, minimalPrimes_isPrime hrm⟩, mem_support_iff_of_finite.mpr hrm.1.2⟩
have hr : r < q.head := lt_of_le_of_ne hr (fun h ↦ hn q.head.1.1 (by rwa [← h]) hp.2)
exact le_of_eq_of_le (by simp [q]) (le_iSup _ (q.cons r hr))
theorem supportDim_quotSMulTop_succ_eq_of_notMem_minimalPrimes_of_mem_jacobson {x : R}
(hn : ∀ p ∈ (annihilator R M).minimalPrimes, x ∉ p) (hx : x ∈ (annihilator R M).jacobson) :
supportDim R (QuotSMulTop x M) + 1 = supportDim R M :=
le_antisymm (supportDim_quotSMulTop_succ_le_of_notMem_minimalPrimes hn)
(supportDim_le_supportDim_quotSMulTop_succ_of_mem_jacobson hx)
theorem supportDim_quotSMulTop_succ_eq_supportDim_mem_jacobson {x : R} (reg : IsSMulRegular M x)
(hx : x ∈ (annihilator R M).jacobson) : supportDim R (QuotSMulTop x M) + 1 = supportDim R M :=
supportDim_quotSMulTop_succ_eq_of_notMem_minimalPrimes_of_mem_jacobson
(fun _ ↦ reg.notMem_of_mem_minimalPrimes) hx
lemma _root_.ringKrullDim_quotient_span_singleton_succ_eq_ringKrullDim_of_mem_jacobson {x : R}
(reg : IsSMulRegular R x) (hx : x ∈ Ring.jacobson R) :
ringKrullDim (R ⧸ span {x}) + 1 = ringKrullDim R := by
have h := Submodule.ideal_span_singleton_smul x (⊤ : Ideal R)
simp only [smul_eq_mul, mul_top] at h
rw [ringKrullDim_eq_of_ringEquiv (quotientEquivAlgOfEq R h).toRingEquiv,
← supportDim_quotient_eq_ringKrullDim, ← supportDim_self_eq_ringKrullDim]
exact supportDim_quotSMulTop_succ_eq_supportDim_mem_jacobson reg
((annihilator R R).ringJacobson_le_jacobson hx)
variable [IsLocalRing R]
/-- If `M` is a finite module over a Noetherian local ring `R`, then `dim M ≤ dim M/xM + 1`
for every `x` in the maximal ideal of the local ring `R`. -/
@[stacks 0B52 "the second inequality"]
theorem supportDim_le_supportDim_quotSMulTop_succ {x : R} (hx : x ∈ maximalIdeal R) :
supportDim R M ≤ supportDim R (QuotSMulTop x M) + 1 :=
supportDim_le_supportDim_quotSMulTop_succ_of_mem_jacobson ((maximalIdeal_le_jacobson _) hx)
@[stacks 0B52 "the equality case"]
theorem supportDim_quotSMulTop_succ_eq_of_notMem_minimalPrimes_of_mem_maximalIdeal {x : R}
(hn : ∀ p ∈ (annihilator R M).minimalPrimes, x ∉ p) (hx : x ∈ maximalIdeal R) :
supportDim R (QuotSMulTop x M) + 1 = supportDim R M :=
supportDim_quotSMulTop_succ_eq_of_notMem_minimalPrimes_of_mem_jacobson hn <|
(maximalIdeal_le_jacobson _) hx
theorem supportDim_quotSMulTop_succ_eq_supportDim {x : R} (reg : IsSMulRegular M x)
(hx : x ∈ maximalIdeal R) : supportDim R (QuotSMulTop x M) + 1 = supportDim R M :=
supportDim_quotSMulTop_succ_eq_supportDim_mem_jacobson reg ((maximalIdeal_le_jacobson _) hx)
lemma _root_.ringKrullDim_quotient_span_singleton_succ_eq_ringKrullDim {x : R}
(reg : IsSMulRegular R x) (hx : x ∈ maximalIdeal R) :
ringKrullDim (R ⧸ span {x}) + 1 = ringKrullDim R :=
ringKrullDim_quotient_span_singleton_succ_eq_ringKrullDim_of_mem_jacobson reg <| by
rwa [ringJacobson_eq_maximalIdeal R]
open nonZeroDivisors in
@[stacks 00KW]
lemma _root_.ringKrullDim_quotient_span_singleton_succ_eq_ringKrullDim_of_mem_nonZeroDivisors
{x : R} (reg : x ∈ R⁰) (hx : x ∈ maximalIdeal R) :
ringKrullDim (R ⧸ span {x}) + 1 = ringKrullDim R :=
ringKrullDim_quotient_span_singleton_succ_eq_ringKrullDim
(Module.Flat.isSMulRegular_of_nonZeroDivisors reg) hx
/-- If `M` is a finite module over a Noetherian local ring `R`, `r₁, …, rₙ` is an
`M`-sequence, then `dim M/(r₁, …, rₙ)M + n = dim M`. -/
theorem supportDim_add_length_eq_supportDim_of_isRegular (rs : List R) (reg : IsRegular M rs) :
supportDim R (M ⧸ ofList rs • (⊤ : Submodule R M)) + rs.length = supportDim R M := by
induction rs generalizing M with
| nil =>
rw [ofList_nil, Submodule.bot_smul]
simpa using supportDim_eq_of_equiv (Submodule.quotEquivOfEqBot ⊥ rfl)
| cons x rs' ih =>
have mem : x ∈ maximalIdeal R := by
simpa using fun isu ↦ reg.2 (by simp [span_singleton_eq_top.mpr isu])
simp [supportDim_eq_of_equiv (Submodule.quotOfListConsSMulTopEquivQuotSMulTopInner M x _),
← supportDim_quotSMulTop_succ_eq_supportDim ((isRegular_cons_iff M _ _).mp reg).1 mem,
← ih ((isRegular_cons_iff M _ _).mp reg).2, ← add_assoc]
lemma _root_.ringKrullDim_add_length_eq_ringKrullDim_of_isRegular (rs : List R)
(reg : IsRegular R rs) : ringKrullDim (R ⧸ ofList rs) + rs.length = ringKrullDim R := by
have eq : ofList rs = ofList rs • (⊤ : Ideal R) := by simp
rw [ringKrullDim_eq_of_ringEquiv (quotientEquivAlgOfEq R eq).toRingEquiv,
← supportDim_quotient_eq_ringKrullDim, ← supportDim_self_eq_ringKrullDim]
exact supportDim_add_length_eq_supportDim_of_isRegular rs reg
end Module |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/Module.lean | import Mathlib.RingTheory.KrullDimension.NonZeroDivisors
import Mathlib.RingTheory.Spectrum.Prime.Module
/-!
# Krull Dimension of Module
In this file we define `Module.supportDim R M` for a `R`-module `M` as
the krull dimension of its support. It is equal to the krull dimension of `R / Ann M` when
`M` is finitely generated.
-/
variable (R : Type*) [CommRing R]
variable (M : Type*) [AddCommGroup M] [Module R M] (N : Type*) [AddCommGroup N] [Module R N]
namespace Module
open Order
/-- The krull dimension of module, defined as `krullDim` of its support. -/
noncomputable def supportDim : WithBot ℕ∞ :=
krullDim (Module.support R M)
@[nontriviality]
lemma supportDim_eq_bot_of_subsingleton [Subsingleton M] : supportDim R M = ⊥ := by
simpa [supportDim, support_eq_empty_iff]
lemma supportDim_ne_bot_of_nontrivial [Nontrivial M] : supportDim R M ≠ ⊥ := by
have : Nonempty (Module.support R M) := nonempty_support_of_nontrivial.to_subtype
simp [supportDim]
lemma supportDim_eq_bot_iff_subsingleton : supportDim R M = ⊥ ↔ Subsingleton M := by
simp [supportDim, krullDim_eq_bot_iff, support_eq_empty_iff]
lemma supportDim_ne_bot_iff_nontrivial : supportDim R M ≠ ⊥ ↔ Nontrivial M := by
simp [supportDim, krullDim_eq_bot_iff, support_eq_empty_iff, not_subsingleton_iff_nontrivial]
lemma supportDim_eq_ringKrullDim_quotient_annihilator [Module.Finite R M] :
supportDim R M = ringKrullDim (R ⧸ annihilator R M) := by
simp only [supportDim]
rw [support_eq_zeroLocus, ringKrullDim_quotient]
lemma supportDim_self_eq_ringKrullDim : supportDim R R = ringKrullDim R := by
have : annihilator R R = ⊥ :=
annihilator_eq_bot.mpr ((faithfulSMul_iff_algebraMap_injective R R).mpr fun {a₁ a₂} a ↦ a)
rw [supportDim_eq_ringKrullDim_quotient_annihilator, this]
exact (RingEquiv.ringKrullDim (RingEquiv.quotientBot R))
lemma supportDim_le_ringKrullDim : supportDim R M ≤ ringKrullDim R :=
krullDim_le_of_strictMono (fun a ↦ a) fun {_ _} lt ↦ lt
variable {R M N}
lemma supportDim_quotient_eq_ringKrullDim (I : Ideal R) :
supportDim R (R ⧸ I) = ringKrullDim (R ⧸ I) := by
rw [supportDim_eq_ringKrullDim_quotient_annihilator, Ideal.annihilator_quotient]
lemma supportDim_le_of_injective (f : M →ₗ[R] N) (h : Function.Injective f) :
supportDim R M ≤ supportDim R N :=
krullDim_le_of_strictMono (fun a ↦ ⟨a.1, Module.support_subset_of_injective f h a.2⟩)
(fun {_ _} lt ↦ lt)
lemma supportDim_le_of_surjective (f : M →ₗ[R] N) (h : Function.Surjective f) :
supportDim R N ≤ supportDim R M :=
krullDim_le_of_strictMono (fun a ↦ ⟨a.1, Module.support_subset_of_surjective f h a.2⟩)
(fun {_ _} lt ↦ lt)
lemma supportDim_eq_of_equiv (e : M ≃ₗ[R] N) :
supportDim R M = supportDim R N :=
le_antisymm (supportDim_le_of_injective e e.injective)
(supportDim_le_of_surjective e e.surjective)
end Module
open Ideal IsLocalRing
lemma support_of_supportDim_eq_zero [IsLocalRing R]
(dim : Module.supportDim R N = 0) :
Module.support R N = PrimeSpectrum.zeroLocus (maximalIdeal R) := by
let _ : Nontrivial N := by simp [← Module.supportDim_ne_bot_iff_nontrivial R, dim]
rw [PrimeSpectrum.zeroLocus_eq_singleton]
apply le_antisymm
· intro p hp
by_contra nmem
simp only [Set.mem_singleton_iff] at nmem
have : p < ⟨maximalIdeal R, IsMaximal.isPrime' (maximalIdeal R)⟩ :=
lt_of_le_of_ne (IsLocalRing.le_maximalIdeal IsPrime.ne_top') nmem
have : Module.supportDim R N > 0 := by
simp only [Module.supportDim, gt_iff_lt, Order.krullDim_pos_iff, Subtype.exists,
Subtype.mk_lt_mk, exists_prop]
use p
simpa [hp] using ⟨_, IsLocalRing.closedPoint_mem_support R N, this⟩
exact (ne_of_lt this) dim.symm
· simpa using IsLocalRing.closedPoint_mem_support R N |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/LocalRing.lean | import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.KrullDimension.Field
import Mathlib.RingTheory.KrullDimension.Zero
/-!
# The Krull dimension of a local ring
In this file, we proved some results about the Krull dimension of a local ring.
-/
lemma ringKrullDim_eq_one_iff_of_isLocalRing_isDomain {R : Type*}
[CommRing R] [IsLocalRing R] [IsDomain R] : ringKrullDim R = 1 ↔ ¬ IsField R ∧
∀ (x : R), x ≠ 0 → IsLocalRing.maximalIdeal R ≤ Ideal.radical (Ideal.span {x}) := by
refine ⟨fun h ↦ ⟨fun h' ↦ ?_, ?_⟩, fun ⟨hn, h⟩ ↦ ?_⟩
· exact zero_ne_one ((ringKrullDim_eq_zero_of_isField h') ▸ h)
· intro x hx
rw [Ideal.radical_eq_sInf]
refine le_sInf (fun J ⟨hJ1, hJ2⟩ ↦ ?_)
have : J.IsMaximal :=
Ring.krullDimLE_one_iff_of_noZeroDivisors.mp (Ring.krullDimLE_iff.mpr (by simp [h]))
J (fun hJ3 ↦ hx (by simp_all)) hJ2
exact le_of_eq (IsLocalRing.eq_maximalIdeal this).symm
· have : ¬ ringKrullDim R ≤ 0 := fun h ↦ by
have : Ring.KrullDimLE 0 R := Ring.krullDimLE_iff.mpr h
exact hn Ring.KrullDimLE.isField_of_isDomain
suffices h : Ring.KrullDimLE 1 R by
rw [Ring.krullDimLE_iff] at h
exact le_antisymm h (Order.succ_le_of_lt (lt_of_not_ge this))
refine Ring.krullDimLE_one_iff_of_noZeroDivisors.mpr fun I hI hI_prime ↦ ?_
obtain ⟨x, hI, hx⟩ : ∃ (x : R), x ∈ I ∧ x ≠ 0 := by
apply by_contradiction fun h ↦ (hI (le_antisymm (fun x ↦ ?_) bot_le))
simp only [ne_eq, not_exists, not_and, not_not] at h
exact fun hx ↦ h x hx
have : IsLocalRing.maximalIdeal R ≤ I := le_trans (h x hx)
((Ideal.IsRadical.radical_le_iff hI_prime.isRadical).mpr
((Ideal.span_singleton_le_iff_mem I).mpr hI))
have := Ideal.IsMaximal.eq_of_le (IsLocalRing.maximalIdeal.isMaximal R) hI_prime.ne_top this
exact this ▸ (IsLocalRing.maximalIdeal.isMaximal R) |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/PID.lean | import Mathlib.RingTheory.Ideal.Height
import Mathlib.RingTheory.KrullDimension.Zero
import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# The Krull dimension of a principal ideal domain
In this file, we proved some results about the dimension of a principal ideal domain.
-/
instance IsPrincipalIdealRing.krullDimLE_one (R : Type*) [CommRing R]
[IsPrincipalIdealRing R] : Ring.KrullDimLE 1 R := by
refine Ring.krullDimLE_one_iff.2 fun I hI ↦ or_iff_not_imp_left.2 fun hI' ↦ ?_
rw [minimalPrimes_eq_minimals, Set.notMem_setOf_iff, not_minimal_iff_exists_lt hI] at hI'
obtain ⟨P, hlt, hP⟩ := hI'
have := IsPrincipalIdealRing.of_surjective (Ideal.Quotient.mk P) Ideal.Quotient.mk_surjective
have : (I.map (Ideal.Quotient.mk P)).IsMaximal := by
have := Ideal.map_isPrime_of_surjective (f := Ideal.Quotient.mk P) Ideal.Quotient.mk_surjective
(I := I) (by simpa using hlt.le)
refine IsPrime.to_maximal_ideal ?_
rw [ne_eq, Ideal.map_eq_bot_iff_le_ker, Ideal.mk_ker]
exact hlt.not_ge
have := Ideal.comap_isMaximal_of_surjective (Ideal.Quotient.mk P) Ideal.Quotient.mk_surjective
(K := I.map (Ideal.Quotient.mk P))
simpa [Ideal.comap_map_of_surjective' (Ideal.Quotient.mk P) Ideal.Quotient.mk_surjective,
hlt.le] using this
theorem IsPrincipalIdealRing.ringKrullDim_eq_one (R : Type*) [CommRing R] [IsDomain R]
[IsPrincipalIdealRing R] (h : ¬ IsField R) : ringKrullDim R = 1 := by
apply eq_of_le_of_not_lt ?_ fun h' ↦ h ?_
· rw [← Nat.cast_one, ← Ring.krullDimLE_iff]
infer_instance
· have h'' : ringKrullDim R ≤ 0 := Order.le_of_lt_succ h'
rw [← Nat.cast_zero, ← Ring.krullDimLE_iff] at h''
exact Ring.KrullDimLE.isField_of_isDomain
/-- In a PID that is not a field, every maximal ideal has height one. -/
lemma IsPrincipalIdealRing.height_eq_one_of_isMaximal {R : Type*} [CommRing R] [IsDomain R]
[IsPrincipalIdealRing R] (m : Ideal R) [m.IsMaximal] (h : ¬ IsField R) :
m.height = 1 := by
refine le_antisymm ?_ ?_
· suffices h : (m.height : WithBot ℕ∞) ≤ 1 by norm_cast at h
rw [← IsPrincipalIdealRing.ringKrullDim_eq_one _ h]
exact Ideal.height_le_ringKrullDim_of_ne_top Ideal.IsPrime.ne_top'
· rw [Order.one_le_iff_pos, Ideal.height_eq_primeHeight, Ideal.primeHeight, Order.height_pos]
exact not_isMin_of_lt (b := ⊥) (Ideal.bot_lt_of_maximal m h) |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/Basic.lean | import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.Polynomial.Basic
import Mathlib.Order.KrullDimension
import Mathlib.RingTheory.Ideal.Quotient.Defs
import Mathlib.RingTheory.Ideal.MinimalPrime.Basic
import Mathlib.RingTheory.Jacobson.Radical
import Mathlib.RingTheory.Spectrum.Prime.Basic
/-!
# Krull dimensions of (commutative) rings
Given a commutative ring, its ring-theoretic Krull dimension is the order-theoretic Krull dimension
of its prime spectrum. Unfolding this definition, it is the length of the longest sequence(s) of
prime ideals ordered by strict inclusion.
-/
open Order
/--
The ring-theoretic Krull dimension is the Krull dimension of its spectrum ordered by inclusion.
-/
noncomputable def ringKrullDim (R : Type*) [CommSemiring R] : WithBot ℕ∞ :=
krullDim (PrimeSpectrum R)
/-- Type class for rings with krull dimension at most `n`. -/
abbrev Ring.KrullDimLE (n : ℕ) (R : Type*) [CommSemiring R] : Prop :=
Order.KrullDimLE n (PrimeSpectrum R)
variable {R S : Type*} [CommSemiring R] [CommSemiring S]
lemma Ring.krullDimLE_iff {n : ℕ} :
KrullDimLE n R ↔ ringKrullDim R ≤ n := Order.krullDimLE_iff n (PrimeSpectrum R)
@[nontriviality]
lemma ringKrullDim_eq_bot_of_subsingleton [Subsingleton R] :
ringKrullDim R = ⊥ :=
krullDim_eq_bot
lemma ringKrullDim_nonneg_of_nontrivial [Nontrivial R] :
0 ≤ ringKrullDim R :=
krullDim_nonneg
/-- If `f : R →+* S` is surjective, then `ringKrullDim S ≤ ringKrullDim R`. -/
theorem ringKrullDim_le_of_surjective (f : R →+* S) (hf : Function.Surjective f) :
ringKrullDim S ≤ ringKrullDim R :=
krullDim_le_of_strictMono (fun I ↦ ⟨Ideal.comap f I.asIdeal, inferInstance⟩)
(Monotone.strictMono_of_injective (fun _ _ hab ↦ Ideal.comap_mono hab)
(fun _ _ h => PrimeSpectrum.ext_iff.mpr <| Ideal.comap_injective_of_surjective f hf <| by
simpa using h))
/-- If `I` is an ideal of `R`, then `ringKrullDim (R ⧸ I) ≤ ringKrullDim R`. -/
theorem ringKrullDim_quotient_le {R : Type*} [CommRing R] (I : Ideal R) :
ringKrullDim (R ⧸ I) ≤ ringKrullDim R :=
ringKrullDim_le_of_surjective _ Ideal.Quotient.mk_surjective
/-- If `R` and `S` are isomorphic, then `ringKrullDim R = ringKrullDim S`. -/
theorem ringKrullDim_eq_of_ringEquiv (e : R ≃+* S) :
ringKrullDim R = ringKrullDim S :=
le_antisymm (ringKrullDim_le_of_surjective e.symm e.symm.surjective)
(ringKrullDim_le_of_surjective e e.surjective)
alias RingEquiv.ringKrullDim := ringKrullDim_eq_of_ringEquiv
/-- A ring has finite Krull dimension if its `PrimeSpectrum` is
finite-dimensional (and non-empty). -/
abbrev FiniteRingKrullDim (R : Type*) [CommSemiring R] :=
FiniteDimensionalOrder (PrimeSpectrum R)
lemma ringKrullDim_ne_top [FiniteRingKrullDim R] :
ringKrullDim R ≠ ⊤ := krullDim_ne_top_of_finiteDimensionalOrder
lemma ringKrullDim_lt_top [FiniteRingKrullDim R] :
ringKrullDim R < ⊤ := ringKrullDim_ne_top.lt_top
lemma ringKrullDim_ne_bot [FiniteRingKrullDim R] :
ringKrullDim R ≠ ⊥ := krullDim_ne_bot_of_finiteDimensionalOrder
lemma finiteRingKrullDim_iff_ne_bot_and_top :
FiniteRingKrullDim R ↔ (ringKrullDim R ≠ ⊥ ∧ ringKrullDim R ≠ ⊤) :=
(Order.finiteDimensionalOrder_iff_krullDim_ne_bot_and_top (α := PrimeSpectrum R))
lemma Nontrivial.of_finiteRingKrullDim [FiniteRingKrullDim R] : Nontrivial R := by
rw [← PrimeSpectrum.nonempty_iff_nontrivial]
exact LTSeries.nonempty_of_finiteDimensionalOrder _
proof_wanted MvPolynomial.fin_ringKrullDim_eq_add_of_isNoetherianRing
[IsNoetherianRing R] (n : ℕ) :
ringKrullDim (MvPolynomial (Fin n) R) = ringKrullDim R + n
section Zero
-- See `Mathlib/RingTheory/KrullDimension/Zero.lean` for further results.
lemma Ring.krullDimLE_zero_iff : Ring.KrullDimLE 0 R ↔ ∀ I : Ideal R, I.IsPrime → I.IsMaximal := by
simp_rw [Ring.KrullDimLE, Order.krullDimLE_iff, Nat.cast_zero,
Order.krullDim_nonpos_iff_forall_isMax,
(PrimeSpectrum.equivSubtype R).forall_congr_left, Subtype.forall, PrimeSpectrum.isMax_iff]
rfl
lemma Ring.KrullDimLE.mk₀ (H : ∀ I : Ideal R, I.IsPrime → I.IsMaximal) : Ring.KrullDimLE 0 R := by
rwa [Ring.krullDimLE_zero_iff]
lemma Ideal.isMaximal_of_isPrime [Ring.KrullDimLE 0 R] (I : Ideal R) [I.IsPrime] : I.IsMaximal :=
Ring.krullDimLE_zero_iff.mp ‹_› I ‹_›
/-- Also see `Ideal.IsPrime.isMaximal` for the analogous statement for Dedekind domains. -/
lemma Ideal.IsPrime.isMaximal' [Ring.KrullDimLE 0 R] {I : Ideal R} (hI : I.IsPrime) : I.IsMaximal :=
I.isMaximal_of_isPrime
instance (priority := 100) (I : Ideal R) [I.IsPrime] [Ring.KrullDimLE 0 R] : I.IsMaximal :=
I.isMaximal_of_isPrime
lemma Ideal.isMaximal_iff_isPrime [Ring.KrullDimLE 0 R] {I : Ideal R} : I.IsMaximal ↔ I.IsPrime :=
⟨IsMaximal.isPrime, fun _ ↦ inferInstance⟩
lemma Ideal.mem_minimalPrimes_of_krullDimLE_zero [Ring.KrullDimLE 0 R]
(I : Ideal R) [I.IsPrime] : I ∈ minimalPrimes R :=
minimalPrimes_eq_minimals (R := R) ▸
⟨‹_›, fun J hJ hJI ↦ (IsMaximal.eq_of_le inferInstance IsPrime.ne_top' hJI).ge⟩
lemma Ideal.mem_minimalPrimes_iff_isPrime [Ring.KrullDimLE 0 R] {I : Ideal R} :
I ∈ minimalPrimes R ↔ I.IsPrime :=
⟨(·.1.1), fun _ ↦ I.mem_minimalPrimes_of_krullDimLE_zero⟩
theorem nilradical_le_jacobson (R) [CommRing R] : nilradical R ≤ Ring.jacobson R :=
nilradical_eq_sInf R ▸ le_sInf fun _I hI ↦ sInf_le (Ideal.IsMaximal.isPrime ⟨hI⟩)
theorem Ring.jacobson_eq_nilradical_of_krullDimLE_zero (R) [CommRing R] [KrullDimLE 0 R] :
jacobson R = nilradical R :=
(nilradical_le_jacobson R).antisymm' <| nilradical_eq_sInf R ▸ le_sInf fun I (_ : I.IsPrime) ↦
sInf_le Ideal.IsMaximal.out
end Zero
section One
instance [Ring.KrullDimLE 0 R] : Ring.KrullDimLE 1 R := .mono zero_le_one _
lemma Ring.krullDimLE_one_iff : Ring.KrullDimLE 1 R ↔
∀ I : Ideal R, I.IsPrime → I ∈ minimalPrimes R ∨ I.IsMaximal := by
simp_rw [Ring.KrullDimLE, Order.krullDimLE_iff, Nat.cast_one,
Order.krullDim_le_one_iff, (PrimeSpectrum.equivSubtype R).forall_congr_left,
Subtype.forall, PrimeSpectrum.isMax_iff, PrimeSpectrum.isMin_iff]
rfl
lemma Ring.KrullDimLE.mk₁ (H : ∀ I : Ideal R, I.IsPrime → I ∈ minimalPrimes R ∨ I.IsMaximal) :
Ring.KrullDimLE 1 R := by
rwa [Ring.krullDimLE_one_iff]
lemma Ring.krullDimLE_one_iff_of_isPrime_bot [(⊥ : Ideal R).IsPrime] :
Ring.KrullDimLE 1 R ↔ ∀ I : Ideal R, I ≠ ⊥ → I.IsPrime → I.IsMaximal := by
letI : OrderBot (PrimeSpectrum R) := { bot := ⟨⊥, ‹_›⟩, bot_le I := bot_le (a := I.1) }
simp_rw [Ring.KrullDimLE, Order.krullDimLE_iff, Nat.cast_one,
Order.krullDim_le_one_iff_forall_isMax, (PrimeSpectrum.equivSubtype R).forall_congr_left,
Subtype.forall, PrimeSpectrum.isMax_iff, forall_comm (α := _ ≠ ⊥),
ne_eq, PrimeSpectrum.ext_iff]
rfl
lemma Ring.krullDimLE_one_iff_of_noZeroDivisors [NoZeroDivisors R] :
Ring.KrullDimLE 1 R ↔ ∀ I : Ideal R, I ≠ ⊥ → I.IsPrime → I.IsMaximal := by
cases subsingleton_or_nontrivial R
· exact iff_of_true inferInstance fun I h ↦ (h <| Subsingleton.elim ..).elim
have := Ideal.bot_prime (α := R)
exact Ring.krullDimLE_one_iff_of_isPrime_bot
/-- Alternative constructor for `Ring.KrullDimLE 1`, convenient for domains. -/
lemma Ring.KrullDimLE.mk₁' (H : ∀ I : Ideal R, I ≠ ⊥ → I.IsPrime → I.IsMaximal) :
Ring.KrullDimLE 1 R := by
by_cases hR : (⊥ : Ideal R).IsPrime
· rwa [Ring.krullDimLE_one_iff_of_isPrime_bot]
suffices Ring.KrullDimLE 0 R from inferInstance
exact .mk₀ fun I hI ↦ H I (fun e ↦ hR (e ▸ hI)) hI
end One |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/NonZeroDivisors.lean | import Mathlib.RingTheory.Ideal.MinimalPrime.Localization
import Mathlib.RingTheory.KrullDimension.Basic
import Mathlib.RingTheory.MvPowerSeries.NoZeroDivisors
import Mathlib.RingTheory.PowerSeries.Basic
import Mathlib.RingTheory.Spectrum.Prime.RingHom
/-!
# Krull dimension and non-zero-divisors
## Main results
- `ringKrullDim_quotient_succ_le_of_nonZeroDivisor`: If `r` is not a zero divisor, then
`dim R/r + 1 ≤ dim R`.
- `ringKrullDim_succ_le_ringKrullDim_polynomial`: `dim R + 1 ≤ dim R[X]`.
- `ringKrullDim_add_enatCard_le_ringKrullDim_mvPolynomial`: `dim R + #σ ≤ dim R[σ]`.
-/
open scoped nonZeroDivisors
variable {R S : Type*} [CommRing R] [CommRing S]
lemma ringKrullDim_quotient (I : Ideal R) :
ringKrullDim (R ⧸ I) = Order.krullDim (PrimeSpectrum.zeroLocus (R := R) I) := by
rw [ringKrullDim, Order.krullDim_eq_of_orderIso I.primeSpectrumQuotientOrderIsoZeroLocus]
lemma ringKrullDim_quotient_succ_le_of_nonZeroDivisor
{r : R} (hr : r ∈ R⁰) :
ringKrullDim (R ⧸ Ideal.span {r}) + 1 ≤ ringKrullDim R := by
by_cases hr' : Ideal.span {r} = ⊤
· rw [hr', ringKrullDim_eq_bot_of_subsingleton]
simp
have : Nonempty (PrimeSpectrum.zeroLocus (R := R) (Ideal.span {r})) := by
rwa [Set.nonempty_coe_sort, Set.nonempty_iff_ne_empty, ne_eq,
PrimeSpectrum.zeroLocus_empty_iff_eq_top]
have := Ideal.Quotient.nontrivial hr'
have := (Ideal.Quotient.mk (Ideal.span {r})).domain_nontrivial
rw [ringKrullDim_quotient, Order.krullDim_eq_iSup_length, ringKrullDim,
Order.krullDim_eq_iSup_length, ← WithBot.coe_one, ← WithBot.coe_add,
ENat.iSup_add, WithBot.coe_le_coe, iSup_le_iff]
intro l
obtain ⟨p, hp, hp'⟩ := Ideal.exists_minimalPrimes_le (J := l.head.1.asIdeal) bot_le
let p' : PrimeSpectrum R := ⟨p, hp.1.1⟩
have hp' : p' < l.head := lt_of_le_of_ne hp' fun h ↦ Set.disjoint_iff.mp
(Ideal.disjoint_nonZeroDivisors_of_mem_minimalPrimes hp)
⟨show r ∈ p by simpa [← h] using l.head.2, hr⟩
refine le_trans ?_ (le_iSup _ ((l.map Subtype.val (fun _ _ ↦ id)).cons p' hp'))
simp
/-- If `R →+* S` is surjective whose kernel contains a nonzero divisor, then `dim S + 1 ≤ dim R`. -/
lemma ringKrullDim_succ_le_of_surjective (f : R →+* S) (hf : Function.Surjective f)
{r : R} (hr : r ∈ R⁰) (hr' : f r = 0) : ringKrullDim S + 1 ≤ ringKrullDim R := by
refine le_trans ?_ (ringKrullDim_quotient_succ_le_of_nonZeroDivisor hr)
gcongr
exact ringKrullDim_le_of_surjective (Ideal.Quotient.lift _ f (RingHom.ker f
|>.span_singleton_le_iff_mem.mpr hr')) (Ideal.Quotient.lift_surjective_of_surjective _ _ hf)
open Polynomial in
lemma ringKrullDim_succ_le_ringKrullDim_polynomial :
ringKrullDim R + 1 ≤ ringKrullDim R[X] :=
ringKrullDim_succ_le_of_surjective constantCoeff (⟨C ·, coeff_C_zero⟩)
X_mem_nonzeroDivisors coeff_X_zero
open MvPolynomial in
@[simp]
lemma ringKrullDim_mvPolynomial_of_isEmpty (σ : Type*) [IsEmpty σ] :
ringKrullDim (MvPolynomial σ R) = ringKrullDim R :=
ringKrullDim_eq_of_ringEquiv (isEmptyRingEquiv _ _)
open MvPolynomial in
lemma ringKrullDim_add_natCard_le_ringKrullDim_mvPolynomial (σ : Type*) [Finite σ] :
ringKrullDim R + Nat.card σ ≤ ringKrullDim (MvPolynomial σ R) := by
induction σ using Finite.induction_empty_option with
| of_equiv e H =>
convert ← H using 1
· rw [Nat.card_congr e]
· exact ringKrullDim_eq_of_ringEquiv (renameEquiv _ e).toRingEquiv
| h_empty => simp
| h_option IH =>
simp only [Nat.card_eq_fintype_card, Fintype.card_option, Nat.cast_add, Nat.cast_one,
← add_assoc] at IH ⊢
grw [IH, ringKrullDim_succ_le_ringKrullDim_polynomial]
exact (ringKrullDim_eq_of_ringEquiv (MvPolynomial.optionEquivLeft _ _).toRingEquiv).ge
open MvPolynomial in
lemma ringKrullDim_add_enatCard_le_ringKrullDim_mvPolynomial (σ : Type*) :
ringKrullDim R + ENat.card σ ≤ ringKrullDim (MvPolynomial σ R) := by
nontriviality R
cases finite_or_infinite σ
· rw [ENat.card_eq_coe_natCard]
push_cast
exact ringKrullDim_add_natCard_le_ringKrullDim_mvPolynomial _
· simp only [ENat.card_eq_top_of_infinite, WithBot.coe_top]
suffices ringKrullDim (MvPolynomial σ R) = ⊤ by simp_all
rw [WithBot.eq_top_iff_forall_ge]
intro n
let ι := Infinite.natEmbedding σ ∘ Fin.val (n := n + 1)
have := Function.invFun_surjective (f := ι) ((Infinite.natEmbedding σ).2.comp Fin.val_injective)
refine le_trans ?_ (ringKrullDim_le_of_surjective
(rename (R := R) _).toRingHom (rename_surjective _ this))
refine le_trans ?_ (ringKrullDim_add_natCard_le_ringKrullDim_mvPolynomial _)
simp only [ENat.some_eq_coe, Nat.card_eq_fintype_card, Fintype.card_fin, Nat.cast_add,
Nat.cast_one]
trans n + 1
· norm_cast
simp
· exact WithBot.le_add_self Order.bot_lt_krullDim.ne' _
open PowerSeries in
lemma ringKrullDim_succ_le_ringKrullDim_powerseries :
ringKrullDim R + 1 ≤ ringKrullDim (PowerSeries R) :=
ringKrullDim_succ_le_of_surjective constantCoeff (⟨C ·, rfl⟩)
MvPowerSeries.X_mem_nonzeroDivisors constantCoeff_X |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/Field.lean | import Mathlib.RingTheory.KrullDimension.Basic
/-!
# The Krull dimension of a field
This file proves that the Krull dimension of a field is zero.
-/
open Order
@[simp]
theorem ringKrullDim_eq_zero_of_field (F : Type*) [Field F] : ringKrullDim F = 0 :=
krullDim_eq_zero_of_unique
theorem ringKrullDim_eq_zero_of_isField {F : Type*} [CommRing F] (hF : IsField F) :
ringKrullDim F = 0 :=
@krullDim_eq_zero_of_unique _ _ <| @PrimeSpectrum.instUnique _ hF.toField |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/Polynomial.lean | import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.RingTheory.KrullDimension.PID
import Mathlib.RingTheory.LocalRing.ResidueField.Fiber
/-!
# Krull dimension of polynomial ring
This file proves properties of the krull dimension of the polynomial ring over a commutative ring
## Main results
* `Polynomial.ringKrullDim_le`: the krull dimension of the polynomial ring over a commutative ring
`R` is less than `2 * (ringKrullDim R) + 1`.
-/
theorem Polynomial.ringKrullDim_le {R : Type*} [CommRing R] :
ringKrullDim (Polynomial R) ≤ 2 * (ringKrullDim R) + 1 := by
rw [ringKrullDim, ringKrullDim]
apply Order.krullDim_le_of_krullDim_preimage_le' C.specComap ?_ (fun p ↦ ?_)
· exact fun {a b} h ↦ Ideal.comap_mono h
· rw [show C = (algebraMap R (Polynomial R)) from rfl, Order.krullDim_eq_of_orderIso
(PrimeSpectrum.preimageOrderIsoTensorResidueField R (Polynomial R) p), ← ringKrullDim,
← ringKrullDim_eq_of_ringEquiv (polyEquivTensor R (p.asIdeal.ResidueField)).toRingEquiv,
← Ring.krullDimLE_iff]
infer_instance |
.lake/packages/mathlib/Mathlib/RingTheory/KrullDimension/Zero.lean | import Mathlib.RingTheory.Jacobson.Ring
import Mathlib.RingTheory.Spectrum.Prime.Topology
/-!
# Zero-dimensional rings
We provide further API for zero-dimensional rings.
Basic definitions and lemmas are provided in `Mathlib/RingTheory/KrullDimension/Basic.lean`.
-/
section CommSemiring
variable {R : Type*} [CommSemiring R] [Ring.KrullDimLE 0 R] (I : Ideal R)
lemma Ring.KrullDimLE.mem_minimalPrimes_iff {I J : Ideal R} :
I ∈ J.minimalPrimes ↔ I.IsPrime ∧ J ≤ I :=
⟨fun H ↦ H.1, fun H ↦ ⟨H, fun _ h e ↦ (h.1.isMaximal'.eq_of_le H.1.ne_top e).ge⟩⟩
lemma Ring.KrullDimLE.mem_minimalPrimes_iff_le_of_isPrime {I J : Ideal R} [I.IsPrime] :
I ∈ J.minimalPrimes ↔ J ≤ I := by
rwa [mem_minimalPrimes_iff, and_iff_right]
variable (R) in
lemma Ring.KrullDimLE.minimalPrimes_eq_setOf_isPrime :
minimalPrimes R = { I | I.IsPrime } := by
ext; simp [minimalPrimes, mem_minimalPrimes_iff]
variable (R) in
lemma Ring.KrullDimLE.minimalPrimes_eq_setOf_isMaximal :
minimalPrimes R = { I | I.IsMaximal } := by
ext; simp [minimalPrimes_eq_setOf_isPrime, Ideal.isMaximal_iff_isPrime]
/-- Note that the `ringKrullDim` of the trivial ring is `⊥` and not `0`. -/
example [Subsingleton R] : Ring.KrullDimLE 0 R := inferInstance
lemma Ring.KrullDimLE.isField_of_isDomain [IsDomain R] : IsField R := by
by_contra h
obtain ⟨p, hp, h⟩ := Ring.not_isField_iff_exists_prime.mp h
exact hp.symm (Ideal.bot_prime.isMaximal'.eq_of_le h.ne_top bot_le)
omit [Ring.KrullDimLE 0 R] in
lemma ringKrullDimZero_iff_ringKrullDim_eq_zero [Nontrivial R] :
Ring.KrullDimLE 0 R ↔ ringKrullDim R = 0 := by
rw [Ring.KrullDimLE, Order.krullDimLE_iff, le_antisymm_iff, ← ringKrullDim, Nat.cast_zero,
iff_self_and]
exact fun _ ↦ ringKrullDim_nonneg_of_nontrivial
section IsLocalRing
omit [Ring.KrullDimLE 0 R] in
variable (R) in
lemma Ring.krullDimLE_zero_and_isLocalRing_tfae :
List.TFAE
[ Ring.KrullDimLE 0 R ∧ IsLocalRing R,
∃! I : Ideal R, I.IsPrime,
∀ x : R, IsNilpotent x ↔ ¬ IsUnit x,
(nilradical R).IsMaximal ] := by
tfae_have 1 → 3 := by
intro ⟨h₁, h₂⟩ x
change x ∈ nilradical R ↔ x ∈ IsLocalRing.maximalIdeal R
rw [nilradical, Ideal.radical_eq_sInf]
simp [← Ideal.isMaximal_iff_isPrime, IsLocalRing.isMaximal_iff]
tfae_have 3 → 4 := by
refine fun H ↦ ⟨fun e ↦ ?_, fun I hI ↦ ?_⟩
· obtain ⟨n, hn⟩ := (Ideal.eq_top_iff_one _).mp e
exact (H 0).mp .zero ((show (1 : R) = 0 by simpa using hn) ▸ isUnit_one)
· obtain ⟨x, hx, hx'⟩ := (SetLike.lt_iff_le_and_exists.mp hI).2
exact Ideal.eq_top_of_isUnit_mem _ hx (not_not.mp ((H x).not.mp hx'))
tfae_have 4 → 2 := fun H ↦ ⟨_, H.isPrime, fun p (hp : p.IsPrime) ↦
(H.eq_of_le hp.ne_top (nilradical_le_prime p)).symm⟩
tfae_have 2 → 1 := by
rintro ⟨P, hP₁, hP₂⟩
obtain ⟨P, hP₃, -⟩ := P.exists_le_maximal hP₁.ne_top
obtain rfl := hP₂ P hP₃.isPrime
exact ⟨.mk₀ fun Q h ↦ hP₂ Q h ▸ hP₃, .of_unique_max_ideal ⟨P, hP₃, fun Q h ↦ hP₂ Q h.isPrime⟩⟩
tfae_finish
@[simp]
lemma le_isUnit_iff_zero_notMem [IsLocalRing R]
{M : Submonoid R} : M ≤ IsUnit.submonoid R ↔ 0 ∉ M := by
have := ((Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 0 2 rfl rfl).mp ⟨‹_›, ‹_›⟩
exact ⟨fun h₁ h₂ ↦ not_isUnit_zero (h₁ h₂),
fun H x hx ↦ (this x).not_left.mp fun ⟨n, hn⟩ ↦ H (hn ▸ pow_mem hx n)⟩
@[deprecated (since := "2025-05-23")] alias le_isUnit_iff_zero_not_mem := le_isUnit_iff_zero_notMem
variable (R) in
theorem Ring.KrullDimLE.existsUnique_isPrime [IsLocalRing R] :
∃! I : Ideal R, I.IsPrime :=
((Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 0 1 rfl rfl).mp ⟨‹_›, ‹_›⟩
theorem Ring.KrullDimLE.eq_maximalIdeal_of_isPrime [IsLocalRing R] (J : Ideal R) [J.IsPrime] :
J = IsLocalRing.maximalIdeal R :=
(((Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 0 1 rfl rfl).mp ⟨‹_›, ‹_›⟩).unique
‹_› inferInstance
lemma Ring.KrullDimLE.radical_eq_maximalIdeal [IsLocalRing R] (I : Ideal R) (hI : I ≠ ⊤) :
I.radical = IsLocalRing.maximalIdeal R := by
rw [Ideal.radical_eq_sInf]
refine (sInf_le ?_).antisymm (le_sInf ?_)
· exact ⟨IsLocalRing.le_maximalIdeal hI, inferInstance⟩
· rintro J ⟨h₁, h₂⟩
exact (Ring.KrullDimLE.eq_maximalIdeal_of_isPrime J).ge
variable (R) in
theorem Ring.KrullDimLE.subsingleton_primeSpectrum [IsLocalRing R] :
Subsingleton (PrimeSpectrum R) :=
⟨fun x y ↦ PrimeSpectrum.ext <|
(eq_maximalIdeal_of_isPrime x.1).trans (eq_maximalIdeal_of_isPrime y.1).symm⟩
theorem Ring.KrullDimLE.isNilpotent_iff_mem_maximalIdeal [IsLocalRing R] {x} :
IsNilpotent x ↔ x ∈ IsLocalRing.maximalIdeal R :=
((Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 0 2 rfl rfl).mp ⟨‹_›, ‹_›⟩ x
theorem Ring.KrullDimLE.isNilpotent_iff_mem_nonunits [IsLocalRing R] {x} :
IsNilpotent x ↔ x ∈ nonunits R :=
isNilpotent_iff_mem_maximalIdeal
variable (R) in
theorem Ring.KrullDimLE.nilradical_eq_maximalIdeal [IsLocalRing R] :
nilradical R = IsLocalRing.maximalIdeal R :=
Ideal.ext fun _ ↦ isNilpotent_iff_mem_maximalIdeal
omit [Ring.KrullDimLE 0 R] in
variable (R) in
theorem IsLocalRing.of_isMaximal_nilradical [(nilradical R).IsMaximal] :
IsLocalRing R :=
(((Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 3 0 rfl rfl).mp ‹_›).2
omit [Ring.KrullDimLE 0 R] in
variable (R) in
theorem Ring.KrullDimLE.of_isMaximal_nilradical [(nilradical R).IsMaximal] :
Ring.KrullDimLE 0 R :=
(((Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 3 0 rfl rfl).mp ‹_›).1
omit [Ring.KrullDimLE 0 R] in
lemma Ring.KrullDimLE.of_isLocalization (p : Ideal R) (hp : p ∈ minimalPrimes R)
(S : Type*) [CommSemiring S] [Algebra R S] [IsLocalization.AtPrime S p (hp := hp.1.1)] :
Ring.KrullDimLE 0 S :=
have := IsLocalization.subsingleton_primeSpectrum_of_mem_minimalPrimes p hp S
⟨Order.krullDim_nonpos_of_subsingleton⟩
lemma Ring.KrullDimLE.isField_of_isReduced [IsReduced R] [IsLocalRing R] : IsField R := by
rw [IsLocalRing.isField_iff_maximalIdeal_eq, ← nilradical_eq_maximalIdeal,
nilradical_eq_zero, Ideal.zero_eq_bot]
instance PrimeSpectrum.unique_of_ringKrullDimLE_zero [IsLocalRing R] : Unique (PrimeSpectrum R) :=
⟨⟨IsLocalRing.closedPoint _⟩,
fun _ ↦ PrimeSpectrum.ext (Ring.KrullDimLE.eq_maximalIdeal_of_isPrime _)⟩
end IsLocalRing
end CommSemiring
section CommRing
variable {R : Type*} [CommRing R] (I : Ideal R)
lemma Ideal.jacobson_eq_radical [Ring.KrullDimLE 0 R] : I.jacobson = I.radical := by
simp [jacobson, radical_eq_sInf, Ideal.isMaximal_iff_isPrime]
instance (priority := 100) [Ring.KrullDimLE 0 R] : IsJacobsonRing R :=
⟨fun I hI ↦ by rw [I.jacobson_eq_radical, hI.radical]⟩
end CommRing |
.lake/packages/mathlib/Mathlib/RingTheory/Kaehler/JacobiZariski.lean | import Mathlib.RingTheory.Extension.Cotangent.Basic
import Mathlib.RingTheory.Extension.Generators
import Mathlib.Algebra.Module.SnakeLemma
/-!
# The Jacobi-Zariski exact sequence
Given `R → S → T`, the Jacobi-Zariski exact sequence is
```
H¹(L_{T/R}) → H¹(L_{T/S}) → T ⊗[S] Ω[S/R] → Ω[T/R] → Ω[T/S] → 0
```
The maps are
- `Algebra.H1Cotangent.map`
- `Algebra.H1Cotangent.δ`
- `KaehlerDifferential.mapBaseChange`
- `KaehlerDifferential.map`
and the exactness lemmas are
- `Algebra.H1Cotangent.exact_map_δ`
- `Algebra.H1Cotangent.exact_δ_mapBaseChange`
- `KaehlerDifferential.exact_mapBaseChange_map`
- `KaehlerDifferential.map_surjective`
-/
open KaehlerDifferential Module MvPolynomial TensorProduct
namespace Algebra
-- `Generators.{w, u₁, u₂}` depends on three universe variables and
-- to improve performance of universe unification, it should hold that
-- `w > u₁` and `w > u₂` in the lexicographic order. For more details
-- see https://github.com/leanprover-community/mathlib4/issues/26018
-- TODO: this remains an unsolved problem, ideally the lexicographic
-- order does not affect performance
universe w₁ w₂ w₃ w₄ w₅ u₁ u₂ u₃
variable {R : Type u₁} {S : Type u₂} [CommRing R] [CommRing S] [Algebra R S]
variable {T : Type u₃} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable {ι : Type w₁} {ι' : Type w₃} {σ : Type w₂} {σ' : Type w₄} {τ : Type w₅}
variable (Q : Generators S T ι) (P : Generators R S σ)
variable (Q' : Generators S T ι') (P' : Generators R S σ') (W : Generators R T τ)
attribute [local instance] SMulCommClass.of_commMonoid
namespace Generators
lemma Cotangent.surjective_map_ofComp :
Function.Surjective (Extension.Cotangent.map (Q.ofComp P).toExtensionHom) := by
intro x
obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x
have : x ∈ Q.ker := hx
rw [← map_ofComp_ker Q P, Ideal.mem_map_iff_of_surjective
_ (toAlgHom_ofComp_surjective Q P)] at this
obtain ⟨x, hx', rfl⟩ := this
exact ⟨.mk ⟨x, hx'⟩, Extension.Cotangent.map_mk _ _⟩
/-!
Given representations `0 → I → R[X] → S → 0` and `0 → K → S[Y] → T → 0`,
we may consider the induced representation `0 → J → R[X, Y] → T → 0`, and the sequence
`T ⊗[S] (I/I²) → J/J² → K/K²` is exact.
-/
open Extension.Cotangent in
lemma Cotangent.exact :
Function.Exact
((Extension.Cotangent.map (Q.toComp P).toExtensionHom).liftBaseChange T)
(Extension.Cotangent.map (Q.ofComp P).toExtensionHom) := by
apply LinearMap.exact_of_comp_of_mem_range
· rw [LinearMap.liftBaseChange_comp, ← Extension.Cotangent.map_comp,
EmbeddingLike.map_eq_zero_iff]
ext x
obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x
simp only [map_mk, val_mk, LinearMap.zero_apply, val_zero]
convert Q.ker.toCotangent.map_zero
trans ((IsScalarTower.toAlgHom R _ _).comp (IsScalarTower.toAlgHom R P.Ring S)) x
· congr
refine MvPolynomial.algHom_ext fun i ↦ ?_
change (Q.ofComp P).toAlgHom ((Q.toComp P).toAlgHom (X i)) = _
simp
· simp [aeval_val_eq_zero hx]
· intro x hx
obtain ⟨⟨x : (Q.comp P).Ring, hx'⟩, rfl⟩ := Extension.Cotangent.mk_surjective x
replace hx : (Q.ofComp P).toAlgHom x ∈ Q.ker ^ 2 := by
simpa only [map_mk, val_mk, val_zero, Ideal.toCotangent_eq_zero] using congr(($hx).val)
rw [pow_two, ← map_ofComp_ker (P := P), ← Ideal.map_mul, Ideal.mem_map_iff_of_surjective
_ (toAlgHom_ofComp_surjective Q P)] at hx
obtain ⟨y, hy, e⟩ := hx
rw [eq_comm, ← sub_eq_zero, ← map_sub, ← RingHom.mem_ker, ← map_toComp_ker] at e
rw [LinearMap.range_liftBaseChange]
let z : (Q.comp P).ker := ⟨x - y, Ideal.sub_mem _ hx' (Ideal.mul_le_left hy)⟩
have hz : z.1 ∈ P.ker.map (Q.toComp P).toAlgHom.toRingHom := e
have : Extension.Cotangent.mk (P := (Q.comp P).toExtension) ⟨x, hx'⟩ =
Extension.Cotangent.mk z := by
ext; simpa only [val_mk, Ideal.toCotangent_eq, sub_sub_cancel, pow_two, z]
rw [this, ← Submodule.restrictScalars_mem (Q.comp P).Ring, ← Submodule.mem_comap,
← Submodule.span_singleton_le_iff_mem, ← Submodule.map_le_map_iff_of_injective
(f := Submodule.subtype _) Subtype.val_injective, Submodule.map_subtype_span_singleton,
Submodule.span_singleton_le_iff_mem]
refine (show Ideal.map (Q.toComp P).toAlgHom.toRingHom P.ker ≤ _ from ?_) hz
rw [Ideal.map_le_iff_le_comap]
rintro w hw
simp only [AlgHom.toRingHom_eq_coe, Ideal.mem_comap, RingHom.coe_coe,
Submodule.mem_map, Submodule.mem_comap, Submodule.restrictScalars_mem, Submodule.coe_subtype,
Subtype.exists, exists_and_right, exists_eq_right,
toExtension_Ring, toExtension_commRing, toExtension_algebra₂]
refine ⟨?_, Submodule.subset_span ⟨Extension.Cotangent.mk ⟨w, hw⟩, ?_⟩⟩
· simp only [ker_eq_ker_aeval_val, RingHom.mem_ker, Hom.algebraMap_toAlgHom]
rw [aeval_val_eq_zero hw, map_zero]
· rw [map_mk]
rfl
/-- Given `R[X] → S` and `S[Y] → T`, the cotangent space of `R[X][Y] → T` is isomorphic
to the direct product of the cotangent space of `S[Y] → T` and `R[X] → S` (base changed to `T`). -/
noncomputable
def CotangentSpace.compEquiv :
(Q.comp P).toExtension.CotangentSpace ≃ₗ[T]
Q.toExtension.CotangentSpace × (T ⊗[S] P.toExtension.CotangentSpace) :=
(Q.comp P).cotangentSpaceBasis.repr.trans
(Q.cotangentSpaceBasis.prod (P.cotangentSpaceBasis.baseChange T)).repr.symm
section instanceProblem
-- Note: these instances are needed to prevent instance search timeouts.
attribute [local instance 999999] Zero.toOfNat0 SemilinearMapClass.distribMulActionSemiHomClass
SemilinearEquivClass.instSemilinearMapClass TensorProduct.addZeroClass AddZero.toZero
lemma CotangentSpace.compEquiv_symm_inr :
(compEquiv Q P).symm.toLinearMap ∘ₗ
LinearMap.inr T Q.toExtension.CotangentSpace (T ⊗[S] P.toExtension.CotangentSpace) =
(Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T := by
classical
apply (P.cotangentSpaceBasis.baseChange T).ext
intro i
apply (Q.comp P).cotangentSpaceBasis.repr.injective
ext j
simp only [compEquiv, LinearEquiv.trans_symm, LinearEquiv.symm_symm,
Basis.baseChange_apply, LinearMap.coe_comp, LinearEquiv.coe_coe, LinearMap.coe_inr,
Function.comp_apply, LinearEquiv.trans_apply, Basis.repr_symm_apply, pderiv_X, toComp_val,
Basis.repr_linearCombination, LinearMap.liftBaseChange_tmul, one_smul, repr_CotangentSpaceMap]
obtain (j | j) := j <;>
simp only [Basis.prod_repr_inr, Basis.baseChange_repr_tmul,
Basis.repr_self, Basis.prod_repr_inl, map_zero, Finsupp.coe_zero,
Pi.zero_apply, ne_eq, not_false_eq_true, Pi.single_eq_of_ne, Pi.single_apply,
Finsupp.single_apply, ite_smul, one_smul, zero_smul, Sum.inr.injEq,
MonoidWithZeroHom.map_ite_one_zero, reduceCtorEq]
lemma CotangentSpace.compEquiv_symm_zero (x) :
(compEquiv Q P).symm (0, x) =
(Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T x :=
DFunLike.congr_fun (compEquiv_symm_inr Q P) x
lemma CotangentSpace.fst_compEquiv :
LinearMap.fst T Q.toExtension.CotangentSpace (T ⊗[S] P.toExtension.CotangentSpace) ∘ₗ
(compEquiv Q P).toLinearMap = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom := by
classical
apply (Q.comp P).cotangentSpaceBasis.ext
intro i
apply Q.cotangentSpaceBasis.repr.injective
ext j
simp only [compEquiv, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, ofComp_val,
LinearEquiv.trans_apply, Basis.repr_self, LinearMap.fst_apply, repr_CotangentSpaceMap]
obtain (i | i) := i <;>
simp only [Basis.repr_symm_apply, Finsupp.linearCombination_single, Basis.prod_apply,
LinearMap.coe_inl, LinearMap.coe_inr, Sum.elim_inl, Function.comp_apply, one_smul,
Basis.repr_self, Finsupp.single_apply, pderiv_X, Pi.single_apply,
Sum.elim_inr, Function.comp_apply, Basis.baseChange_apply, one_smul,
MonoidWithZeroHom.map_ite_one_zero, map_zero, Finsupp.coe_zero, Pi.zero_apply, derivation_C]
lemma CotangentSpace.fst_compEquiv_apply (x) :
(compEquiv Q P x).1 = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom x :=
DFunLike.congr_fun (fst_compEquiv Q P) x
lemma CotangentSpace.map_toComp_injective :
Function.Injective
((Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T) := by
rw [← compEquiv_symm_inr]
apply (compEquiv Q P).symm.injective.comp
exact Prod.mk_right_injective _
lemma CotangentSpace.map_ofComp_surjective :
Function.Surjective (Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom) := by
rw [← fst_compEquiv]
exact (Prod.fst_surjective).comp (compEquiv Q P).surjective
/-!
Given representations `R[X] → S` and `S[Y] → T`, the sequence
`T ⊗[S] (⨁ₓ S dx) → (⨁ₓ T dx) ⊕ (⨁ᵧ T dy) → ⨁ᵧ T dy`
is exact.
-/
lemma CotangentSpace.exact :
Function.Exact ((Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T)
(Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom) := by
rw [← fst_compEquiv, ← compEquiv_symm_inr]
conv_rhs => rw [← LinearEquiv.symm_symm (compEquiv Q P)]
rw [LinearEquiv.conj_exact_iff_exact]
exact Function.Exact.inr_fst
namespace H1Cotangent
variable (R) in
/--
Given `0 → I → S[Y] → T → 0`, this is an auxiliary map from `S[Y]` to `T ⊗[S] Ω[S⁄R]` whose
restriction to `ker(I/I² → ⊕ S dyᵢ)` is the connecting homomorphism in the Jacobi-Zariski sequence.
-/
noncomputable
def δAux :
Q.Ring →ₗ[R] T ⊗[S] Ω[S⁄R] :=
Finsupp.lsum R (R := R) fun f ↦
(TensorProduct.mk S T _ (f.prod (Q.val · ^ ·))).restrictScalars R ∘ₗ (D R S).toLinearMap
lemma δAux_monomial (n r) :
δAux R Q (monomial n r) = (n.prod (Q.val · ^ ·)) ⊗ₜ D R S r :=
Finsupp.lsum_single _ _ _ _
@[simp]
lemma δAux_X (i) :
δAux R Q (X i) = 0 := by
rw [X, δAux_monomial]
simp only [Derivation.map_one_eq_zero, tmul_zero]
lemma δAux_mul (x y) :
δAux R Q (x * y) = x • (δAux R Q y) + y • (δAux R Q x) := by
induction x using MvPolynomial.induction_on' with
| monomial n r =>
induction y using MvPolynomial.induction_on' with
| monomial m s =>
simp only [monomial_mul, δAux_monomial, Derivation.leibniz, tmul_add, tmul_smul,
smul_tmul', Algebra.smul_def, algebraMap_apply, aeval_monomial, mul_assoc]
rw [mul_comm (m.prod _) (n.prod _)]
simp only [pow_zero, implies_true, pow_add, Finsupp.prod_add_index']
| add y₁ y₂ hy₁ hy₂ => simp only [map_add, smul_add, hy₁, hy₂, mul_add, add_smul]; abel
| add x₁ x₂ hx₁ hx₂ => simp only [add_mul, map_add, hx₁, hx₂, add_smul, smul_add]; abel
lemma δAux_C (r) :
δAux R Q (C r) = 1 ⊗ₜ D R S r := by
rw [← monomial_zero', δAux_monomial, Finsupp.prod_zero_index]
variable {Q} {Q'} in
lemma δAux_toAlgHom (f : Hom Q Q') (x) :
δAux R Q' (f.toAlgHom x) = δAux R Q x + Finsupp.linearCombination _ (δAux R Q' ∘ f.val)
(Q.cotangentSpaceBasis.repr ((1 : T) ⊗ₜ[Q.Ring] D S Q.Ring x :)) := by
letI : AddCommGroup (T ⊗[S] Ω[S⁄R]) := inferInstance
have : IsScalarTower Q.Ring Q.Ring T := IsScalarTower.left _
induction x using MvPolynomial.induction_on with
| C s => simp [MvPolynomial.algebraMap_eq, δAux_C]
| add x₁ x₂ hx₁ hx₂ =>
simp only [map_add, hx₁, hx₂, tmul_add]
rw [add_add_add_comm]
| mul_X p n IH =>
simp only [map_mul, Hom.toAlgHom_X, δAux_mul, algebraMap_apply, Hom.algebraMap_toAlgHom,
← @IsScalarTower.algebraMap_smul Q'.Ring T, algebraMap_self, δAux_X,
RingHom.id_apply, coe_eval₂Hom, IH, Hom.aeval_val, smul_add, map_aeval, tmul_add, tmul_smul,
← @IsScalarTower.algebraMap_smul Q.Ring T, smul_zero, aeval_X, zero_add, Derivation.leibniz,
LinearEquiv.map_add, LinearEquiv.map_smul, Basis.repr_self, LinearMap.map_add, one_smul,
LinearMap.map_smul, Finsupp.linearCombination_single, RingHomCompTriple.comp_eq,
Function.comp_apply, ← cotangentSpaceBasis_apply]
rw [add_left_comm]
rfl
lemma δAux_ofComp (x : (Q.comp P).Ring) :
δAux R Q ((Q.ofComp P).toAlgHom x) =
P.toExtension.toKaehler.baseChange T (CotangentSpace.compEquiv Q P
(1 ⊗ₜ[(Q.comp P).Ring] (D R (Q.comp P).Ring) x : _)).2 := by
letI : AddCommGroup (T ⊗[S] Ω[S⁄R]) := inferInstance
have : IsScalarTower (Q.comp P).Ring (Q.comp P).Ring T := IsScalarTower.left _
induction x using MvPolynomial.induction_on with
| C s =>
simp only [algHom_C, δAux_C, derivation_C, Derivation.map_algebraMap,
tmul_zero, map_zero, MvPolynomial.algebraMap_apply, Prod.snd_zero]
| add x₁ x₂ hx₁ hx₂ =>
simp only [map_add, hx₁, hx₂, tmul_add, Prod.snd_add]
| mul_X p n IH =>
simp only [map_mul, Hom.toAlgHom_X, ofComp_val, δAux_mul,
← @IsScalarTower.algebraMap_smul Q.Ring T, algebraMap_apply, Hom.algebraMap_toAlgHom,
algebraMap_self, map_aeval, RingHomCompTriple.comp_eq, comp_val, RingHom.id_apply,
IH, Derivation.leibniz, tmul_add, tmul_smul, ← cotangentSpaceBasis_apply, coe_eval₂Hom,
← @IsScalarTower.algebraMap_smul (Q.comp P).Ring T, aeval_X, LinearEquiv.map_add,
LinearMapClass.map_smul, Prod.snd_add, Prod.smul_snd, LinearMap.map_add]
obtain (n | n) := n
· simp only [Sum.elim_inl, δAux_X, smul_zero, aeval_X,
CotangentSpace.compEquiv, LinearEquiv.trans_apply, Basis.repr_symm_apply, zero_add,
Basis.repr_self, Finsupp.linearCombination_single, Basis.prod_apply, LinearMap.coe_inl,
LinearMap.coe_inr, Function.comp_apply, one_smul, map_zero]
· simp only [Sum.elim_inr, Function.comp_apply, algHom_C, δAux_C,
CotangentSpace.compEquiv, LinearEquiv.trans_apply, Basis.repr_symm_apply,
algebraMap_smul, Basis.repr_self, Finsupp.linearCombination_single, Basis.prod_apply,
LinearMap.coe_inr, Basis.baseChange_apply, one_smul, LinearMap.baseChange_tmul,
toKaehler_cotangentSpaceBasis, add_left_inj, LinearMap.coe_inl]
rfl
lemma map_comp_cotangentComplex_baseChange :
(Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T ∘ₗ
P.toExtension.cotangentComplex.baseChange T =
(Q.comp P).toExtension.cotangentComplex ∘ₗ
(Extension.Cotangent.map (Q.toComp P).toExtensionHom).liftBaseChange T := by
ext x; simp [Extension.CotangentSpace.map_cotangentComplex]
open Generators in
/--
The connecting homomorphism in the Jacobi-Zariski sequence for given presentations.
Given representations `0 → I → R[X] → S → 0` and `0 → K → S[Y] → T → 0`,
we may consider the induced representation `0 → J → R[X, Y] → T → 0`,
and this map is obtained by applying snake lemma to the following diagram
```
T ⊗[S] Ω[S/R] → Ω[T/R] → Ω[T/S] → 0
↑ ↑ ↑
0 → T ⊗[S] (⨁ₓ S dx) → (⨁ₓ T dx) ⊕ (⨁ᵧ T dy) → ⨁ᵧ T dy → 0
↑ ↑ ↑
T ⊗[S] (I/I²) → J/J² → K/K² → 0
↑ ↑
H¹(L_{T/R}) → H¹(L_{T/S})
```
This is independent from the presentations chosen. See `H1Cotangent.δ_comp_equiv`.
-/
noncomputable
def δ :
Q.toExtension.H1Cotangent →ₗ[T] T ⊗[S] Ω[S⁄R] :=
SnakeLemma.δ'
(P.toExtension.cotangentComplex.baseChange T)
(Q.comp P).toExtension.cotangentComplex
Q.toExtension.cotangentComplex
((Extension.Cotangent.map (toComp Q P).toExtensionHom).liftBaseChange T)
(Extension.Cotangent.map (ofComp Q P).toExtensionHom)
(Cotangent.exact Q P)
((Extension.CotangentSpace.map (toComp Q P).toExtensionHom).liftBaseChange T)
(Extension.CotangentSpace.map (ofComp Q P).toExtensionHom)
(CotangentSpace.exact Q P)
(map_comp_cotangentComplex_baseChange Q P)
(by ext; exact Extension.CotangentSpace.map_cotangentComplex (ofComp Q P).toExtensionHom _)
Q.toExtension.h1Cotangentι
(LinearMap.exact_subtype_ker_map _)
(N₁ := T ⊗[S] P.toExtension.CotangentSpace)
(P.toExtension.toKaehler.baseChange T)
(lTensor_exact T P.toExtension.exact_cotangentComplex_toKaehler
P.toExtension.toKaehler_surjective)
(Cotangent.surjective_map_ofComp Q P)
(CotangentSpace.map_toComp_injective Q P)
lemma exact_δ_map :
Function.Exact (δ Q P) (mapBaseChange R S T) := by
simp only [δ]
apply SnakeLemma.exact_δ_left (π₂ := (Q.comp P).toExtension.toKaehler)
(hπ₂ := (Q.comp P).toExtension.exact_cotangentComplex_toKaehler)
· apply (P.cotangentSpaceBasis.baseChange T).ext
intro i
simp only [Basis.baseChange_apply, LinearMap.coe_comp, Function.comp_apply,
LinearMap.baseChange_tmul, toKaehler_cotangentSpaceBasis, mapBaseChange_tmul, map_D,
one_smul, LinearMap.liftBaseChange_tmul]
rw [cotangentSpaceBasis_apply]
conv_rhs => enter [2]; tactic => exact Extension.CotangentSpace.map_tmul ..
simp only [map_one, mapBaseChange_tmul, map_D, one_smul]
simp [Extension.Hom.toAlgHom]
· exact LinearMap.lTensor_surjective T P.toExtension.toKaehler_surjective
lemma δ_eq (x : Q.toExtension.H1Cotangent) (y)
(hy : Extension.Cotangent.map (ofComp Q P).toExtensionHom y = x.1) (z)
(hz : (Extension.CotangentSpace.map (toComp Q P).toExtensionHom).liftBaseChange T z =
(Q.comp P).toExtension.cotangentComplex y) :
δ Q P x = P.toExtension.toKaehler.baseChange T z := by
simp only [δ]
apply SnakeLemma.δ_eq
exacts [hy, hz]
lemma δ_eq_δAux (x : Q.ker) (hx) :
δ Q P ⟨.mk x, hx⟩ = δAux R Q x.1 := by
let y := Extension.Cotangent.mk (P := (Q.comp P).toExtension) (Q.kerCompPreimage P x)
have hy : (Extension.Cotangent.map (Q.ofComp P).toExtensionHom) y = Extension.Cotangent.mk x := by
simp only [y, Extension.Cotangent.map_mk]
congr
exact ofComp_kerCompPreimage Q P x
let z := (CotangentSpace.compEquiv Q P ((Q.comp P).toExtension.cotangentComplex y)).2
rw [H1Cotangent.δ_eq (y := y) (z := z)]
· rw [← ofComp_kerCompPreimage Q P x, δAux_ofComp]
rfl
· exact hy
· rw [← CotangentSpace.compEquiv_symm_inr]
apply (CotangentSpace.compEquiv Q P).injective
simp only [LinearMap.coe_comp, LinearEquiv.coe_coe, LinearMap.coe_inr, Function.comp_apply,
LinearEquiv.apply_symm_apply, z]
ext
swap; · rfl
change 0 = (LinearMap.fst T Q.toExtension.CotangentSpace
(T ⊗[S] P.toExtension.CotangentSpace) ∘ₗ (CotangentSpace.compEquiv Q P).toLinearMap)
((Q.comp P).toExtension.cotangentComplex y)
rw [CotangentSpace.fst_compEquiv, Extension.CotangentSpace.map_cotangentComplex, hy, hx]
lemma δ_eq_δ : δ Q P = δ Q P' := by
ext ⟨x, hx⟩
obtain ⟨x, rfl⟩ := Extension.Cotangent.mk_surjective x
rw [δ_eq_δAux, δ_eq_δAux]
lemma exact_map_δ :
Function.Exact (Extension.H1Cotangent.map (Q.ofComp P).toExtensionHom) (δ Q P) := by
simp only [δ]
apply SnakeLemma.exact_δ_right
(ι₂ := (Q.comp P).toExtension.h1Cotangentι)
(hι₂ := LinearMap.exact_subtype_ker_map _)
· ext x; rfl
· exact Subtype.val_injective
lemma δ_map (f : Hom Q' Q) (x) :
δ Q P (Extension.H1Cotangent.map f.toExtensionHom x) = δ Q' P' x := by
letI : AddCommGroup (T ⊗[S] Ω[S⁄R]) := inferInstance
obtain ⟨x, hx⟩ := x
obtain ⟨⟨y, hy⟩, rfl⟩ := Extension.Cotangent.mk_surjective x
change δ _ _ ⟨_, _⟩ = δ _ _ _
replace hx : (1 : T) ⊗ₜ[Q'.Ring] (D S Q'.Ring) y = 0 := by
simpa only [LinearMap.mem_ker, Extension.cotangentComplex_mk, ker, RingHom.mem_ker] using hx
simp only [LinearMap.domRestrict_apply, Extension.Cotangent.map_mk, δ_eq_δAux]
refine (δAux_toAlgHom f _).trans ?_
rw [hx, map_zero, map_zero, add_zero]
lemma δ_comp_equiv :
δ Q P ∘ₗ (H1Cotangent.equiv _ _).toLinearMap = δ Q' P' := by
ext x
exact δ_map Q P Q' P' _ _
/-- A variant of `exact_map_δ` that takes in an arbitrary map between generators. -/
lemma exact_map_δ' (f : Hom W Q) :
Function.Exact (Extension.H1Cotangent.map f.toExtensionHom) (δ Q P) := by
refine (H1Cotangent.equiv (Q.comp P) W).surjective.comp_exact_iff_exact.mp ?_
change Function.Exact ((Extension.H1Cotangent.map f.toExtensionHom).restrictScalars T ∘ₗ
(Extension.H1Cotangent.map _)) (δ Q P)
rw [← Extension.H1Cotangent.map_comp, Extension.H1Cotangent.map_eq _ (Q.ofComp P).toExtensionHom]
exact exact_map_δ Q P
end H1Cotangent
end instanceProblem
end Generators
variable {T : Type u₃} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable (R S T)
/-- The connecting homomorphism in the Jacobi-Zariski sequence. -/
noncomputable
def H1Cotangent.δ : H1Cotangent S T →ₗ[T] T ⊗[S] Ω[S⁄R] :=
Generators.H1Cotangent.δ (Generators.self S T) (Generators.self R S)
/-- Given algebras `R → S → T`, `H¹(L_{T/R}) → H¹(L_{T/S}) → T ⊗[S] Ω[S/R]` is exact. -/
lemma H1Cotangent.exact_map_δ : Function.Exact (map R S T T) (δ R S T) :=
Generators.H1Cotangent.exact_map_δ' (Generators.self S T)
(Generators.self R S) (Generators.self R T) (Generators.defaultHom _ _)
/-- Given algebras `R → S → T`, `H¹(L_{T/S}) → T ⊗[S] Ω[S/R] → Ω[T/R]` is exact. -/
lemma H1Cotangent.exact_δ_mapBaseChange : Function.Exact (δ R S T) (mapBaseChange R S T) :=
Generators.H1Cotangent.exact_δ_map (Generators.self S T) (Generators.self R S)
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Kaehler/TensorProduct.lean | import Mathlib.RingTheory.Kaehler.Basic
import Mathlib.RingTheory.Localization.BaseChange
/-!
# Kähler differential module under base change
## Main results
- `KaehlerDifferential.tensorKaehlerEquiv`: `(S ⊗[R] Ω[A⁄R]) ≃ₗ[S] Ω[B⁄S]` for `B = S ⊗[R] A`.
- `KaehlerDifferential.isLocalizedModule_of_isLocalizedModule`:
`Ω[Aₚ/Rₚ]` is the localization of `Ω[A/R]` at `p`.
-/
variable (R S A B : Type*) [CommRing R] [CommRing S] [Algebra R S] [CommRing A] [CommRing B]
variable [Algebra R A] [Algebra R B]
variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
open TensorProduct
attribute [local instance] SMulCommClass.of_commMonoid
namespace KaehlerDifferential
/-- (Implementation). `A`-action on `S ⊗[R] Ω[A⁄R]`. -/
noncomputable
abbrev mulActionBaseChange : MulAction A (S ⊗[R] Ω[A⁄R]) :=
(TensorProduct.comm R S Ω[A⁄R]).toEquiv.mulAction A
attribute [local instance] mulActionBaseChange
@[simp]
lemma mulActionBaseChange_smul_tmul (a : A) (s : S) (x : Ω[A⁄R]) :
a • (s ⊗ₜ[R] x) = s ⊗ₜ (a • x) := rfl
@[local simp]
lemma mulActionBaseChange_smul_zero (a : A) :
a • (0 : S ⊗[R] Ω[A⁄R]) = 0 := by
rw [← zero_tmul _ (0 : Ω[A⁄R]), mulActionBaseChange_smul_tmul, smul_zero]
@[local simp]
lemma mulActionBaseChange_smul_add (a : A) (x y : S ⊗[R] Ω[A⁄R]) :
a • (x + y) = a • x + a • y := by
change (TensorProduct.comm R S Ω[A⁄R]).symm (a • (TensorProduct.comm R S Ω[A⁄R]) (x + y)) = _
rw [map_add, smul_add, map_add]
rfl
/-- (Implementation). `A`-module structure on `S ⊗[R] Ω[A⁄R]`. -/
noncomputable
abbrev moduleBaseChange :
Module A (S ⊗[R] Ω[A⁄R]) where
__ := (TensorProduct.comm R S Ω[A⁄R]).toEquiv.mulAction A
add_smul r s x := by induction x <;> simp [add_smul, tmul_add, *, add_add_add_comm]
zero_smul x := by induction x <;> simp [*]
smul_zero := by simp
smul_add := by simp
attribute [local instance] moduleBaseChange
instance : IsScalarTower R A (S ⊗[R] Ω[A⁄R]) := by
apply IsScalarTower.of_algebraMap_smul
intro r x
induction x
· simp only [smul_zero]
· rw [mulActionBaseChange_smul_tmul, algebraMap_smul, tmul_smul]
· simp only [smul_add, *]
instance : SMulCommClass S A (S ⊗[R] Ω[A⁄R]) where
smul_comm s a x := by
induction x
· simp only [smul_zero]
· rw [mulActionBaseChange_smul_tmul, smul_tmul', smul_tmul', mulActionBaseChange_smul_tmul]
· simp only [smul_add, *]
instance : SMulCommClass A S (S ⊗[R] Ω[A⁄R]) where
smul_comm s a x := by rw [← smul_comm]
/-- (Implementation). `B = S ⊗[R] A`-module structure on `S ⊗[R] Ω[A⁄R]`. -/
@[reducible] noncomputable
def moduleBaseChange' [Algebra.IsPushout R S A B] :
Module B (S ⊗[R] Ω[A⁄R]) :=
Module.compHom _ (Algebra.pushoutDesc B (Algebra.lsmul R (A := S) S (S ⊗[R] Ω[A⁄R]))
(Algebra.lsmul R (A := A) _ _) (LinearMap.ext <| smul_comm · ·)).toRingHom
attribute [local instance] moduleBaseChange'
instance [Algebra.IsPushout R S A B] :
IsScalarTower A B (S ⊗[R] Ω[A⁄R]) := by
apply IsScalarTower.of_algebraMap_smul
intro r x
change (Algebra.pushoutDesc B (Algebra.lsmul R (A := S) S (S ⊗[R] Ω[A⁄R]))
(Algebra.lsmul R (A := A) _ _) (LinearMap.ext <| smul_comm · ·)
(algebraMap A B r)) • x = r • x
simp only [Algebra.pushoutDesc_right, Module.End.smul_def, Algebra.lsmul_coe]
instance [Algebra.IsPushout R S A B] :
IsScalarTower S B (S ⊗[R] Ω[A⁄R]) := by
apply IsScalarTower.of_algebraMap_smul
intro r x
change (Algebra.pushoutDesc B (Algebra.lsmul R (A := S) S (S ⊗[R] Ω[A⁄R]))
(Algebra.lsmul R (A := A) _ _) (LinearMap.ext <| smul_comm · ·)
(algebraMap S B r)) • x = r • x
simp only [Algebra.pushoutDesc_left, Module.End.smul_def, Algebra.lsmul_coe]
lemma map_liftBaseChange_smul [h : Algebra.IsPushout R S A B] (b : B) (x) :
((map R S A B).restrictScalars R).liftBaseChange S (b • x) =
b • ((map R S A B).restrictScalars R).liftBaseChange S x := by
induction b using h.1.inductionOn with
| zero => simp only [zero_smul, map_zero]
| smul s b e => rw [smul_assoc, map_smul, e, smul_assoc]
| add b₁ b₂ e₁ e₂ => simp only [map_add, e₁, e₂, add_smul]
| tmul a =>
induction x
· simp only [smul_zero, map_zero]
· simp [smul_comm]
· simp only [map_add, smul_add, *]
/-- (Implementation).
The `S`-derivation `B = S ⊗[R] A` to `S ⊗[R] Ω[A⁄R]` sending `a ⊗ b` to `a ⊗ d b`. -/
noncomputable
def derivationTensorProduct [h : Algebra.IsPushout R S A B] :
Derivation S B (S ⊗[R] Ω[A⁄R]) where
__ := h.out.lift ((TensorProduct.mk R S Ω[A⁄R] 1).comp (D R A).toLinearMap)
map_one_eq_zero' := by
rw [← (algebraMap A B).map_one]
refine (h.out.lift_eq _ _).trans ?_
dsimp
rw [Derivation.map_one_eq_zero, TensorProduct.tmul_zero]
leibniz' a b := by
induction a using h.out.inductionOn with
| zero => rw [map_zero, zero_smul, smul_zero, zero_add, zero_mul, map_zero]
| smul x y e =>
rw [smul_mul_assoc, map_smul, e, map_smul, smul_add,
smul_comm x b, smul_assoc]
| add b₁ b₂ e₁ e₂ => simp only [add_mul, add_smul, map_add, e₁, e₂, smul_add, add_add_add_comm]
| tmul z =>
dsimp
induction b using h.out.inductionOn with
| zero => rw [map_zero, zero_smul, smul_zero, zero_add, mul_zero, map_zero]
| tmul =>
simp only [AlgHom.toLinearMap_apply, IsScalarTower.coe_toAlgHom',
algebraMap_smul, ← map_mul]
rw [← IsScalarTower.toAlgHom_apply R, ← AlgHom.toLinearMap_apply, h.out.lift_eq,
← IsScalarTower.toAlgHom_apply R, ← AlgHom.toLinearMap_apply, h.out.lift_eq,
← IsScalarTower.toAlgHom_apply R, ← AlgHom.toLinearMap_apply, h.out.lift_eq]
simp only [LinearMap.coe_comp, Derivation.coeFn_coe, Function.comp_apply,
Derivation.leibniz, mk_apply, mulActionBaseChange_smul_tmul, TensorProduct.tmul_add]
| smul _ _ e =>
rw [mul_comm, smul_mul_assoc, map_smul, mul_comm, e,
map_smul, smul_add, smul_comm, smul_assoc]
| add _ _ e₁ e₂ => simp only [mul_add, add_smul, map_add, e₁, e₂, smul_add, add_add_add_comm]
lemma derivationTensorProduct_algebraMap [Algebra.IsPushout R S A B] (x) :
derivationTensorProduct R S A B (algebraMap A B x) =
1 ⊗ₜ D _ _ x :=
IsBaseChange.lift_eq _ _ _
lemma tensorKaehlerEquiv_left_inv [Algebra.IsPushout R S A B] :
((derivationTensorProduct R S A B).liftKaehlerDifferential.restrictScalars S).comp
(((map R S A B).restrictScalars R).liftBaseChange S) = LinearMap.id := by
refine LinearMap.restrictScalars_injective R ?_
apply TensorProduct.ext'
intro x y
obtain ⟨y, rfl⟩ := tensorProductTo_surjective _ _ y
induction y
· simp only [map_zero, TensorProduct.tmul_zero]
· simp only [LinearMap.restrictScalars_comp, Derivation.tensorProductTo_tmul, LinearMap.coe_comp,
LinearMap.coe_restrictScalars, Function.comp_apply, LinearMap.liftBaseChange_tmul, map_smul,
map_D, LinearMap.map_smul_of_tower, Derivation.liftKaehlerDifferential_comp_D,
LinearMap.id_coe, id_eq, derivationTensorProduct_algebraMap]
rw [smul_comm, TensorProduct.smul_tmul', smul_eq_mul, mul_one]
rfl
· simp only [map_add, TensorProduct.tmul_add, *]
/-- The canonical isomorphism `(S ⊗[R] Ω[A⁄R]) ≃ₗ[S] Ω[B⁄S]` for `B = S ⊗[R] A`. -/
@[simps! symm_apply] noncomputable
def tensorKaehlerEquiv [h : Algebra.IsPushout R S A B] :
(S ⊗[R] Ω[A⁄R]) ≃ₗ[S] Ω[B⁄S] where
__ := ((map R S A B).restrictScalars R).liftBaseChange S
invFun := (derivationTensorProduct R S A B).liftKaehlerDifferential
left_inv := LinearMap.congr_fun (tensorKaehlerEquiv_left_inv R S A B)
right_inv x := by
obtain ⟨x, rfl⟩ := tensorProductTo_surjective _ _ x
dsimp
induction x with
| zero => simp
| add x y e₁ e₂ => simp only [map_add, e₁, e₂]
| tmul x y =>
dsimp
simp only [Derivation.tensorProductTo_tmul, LinearMap.map_smul,
Derivation.liftKaehlerDifferential_comp_D, map_liftBaseChange_smul]
induction y using h.1.inductionOn
· simp only [map_zero, smul_zero]
· simp only [AlgHom.toLinearMap_apply, IsScalarTower.coe_toAlgHom',
derivationTensorProduct_algebraMap, LinearMap.liftBaseChange_tmul,
LinearMap.coe_restrictScalars, map_D, one_smul]
· simp only [Derivation.map_smul, LinearMap.map_smul, *, smul_comm x]
· simp only [map_add, smul_add, *]
@[simp]
lemma tensorKaehlerEquiv_tmul [Algebra.IsPushout R S A B] (a b) :
tensorKaehlerEquiv R S A B (a ⊗ₜ b) = a • map R S A B b :=
LinearMap.liftBaseChange_tmul _ _ _ _
/--
If `B` is the tensor product of `S` and `A` over `R`,
then `Ω[B⁄S]` is the base change of `Ω[A⁄R]` along `R → S`.
-/
lemma isBaseChange [h : Algebra.IsPushout R S A B] :
IsBaseChange S ((map R S A B).restrictScalars R) := by
convert (TensorProduct.isBaseChange R Ω[A⁄R] S).comp
(IsBaseChange.ofEquiv (tensorKaehlerEquiv R S A B))
refine LinearMap.ext fun x ↦ ?_
simp only [LinearMap.coe_restrictScalars, LinearMap.coe_comp, LinearEquiv.coe_coe,
Function.comp_apply, mk_apply, tensorKaehlerEquiv_tmul, one_smul]
instance isLocalizedModule (p : Submonoid R) [IsLocalization p S]
[IsLocalization (Algebra.algebraMapSubmonoid A p) B] :
IsLocalizedModule p ((map R S A B).restrictScalars R) :=
have := (Algebra.isPushout_of_isLocalization p S A B).symm
(isLocalizedModule_iff_isBaseChange p S _).mpr (isBaseChange R S A B)
instance isLocalizedModule_of_isLocalizedModule (p : Submonoid R) [IsLocalization p S]
[IsLocalizedModule p (IsScalarTower.toAlgHom R A B).toLinearMap] :
IsLocalizedModule p ((map R S A B).restrictScalars R) :=
have : IsLocalization (Algebra.algebraMapSubmonoid A p) B :=
isLocalizedModule_iff_isLocalization.mp inferInstance
inferInstance
end KaehlerDifferential |
.lake/packages/mathlib/Mathlib/RingTheory/Kaehler/Basic.lean | import Mathlib.RingTheory.Derivation.ToSquareZero
import Mathlib.RingTheory.Ideal.Cotangent
import Mathlib.RingTheory.IsTensorProduct
import Mathlib.RingTheory.EssentialFiniteness
import Mathlib.Algebra.Exact
import Mathlib.LinearAlgebra.TensorProduct.RightExactness
/-!
# The module of Kähler differentials
## Main results
- `KaehlerDifferential`: The module of Kähler differentials. For an `R`-algebra `S`, we provide
the notation `Ω[S⁄R]` for `KaehlerDifferential R S`.
Note that the slash is `\textfractionsolidus`.
- `KaehlerDifferential.D`: The derivation into the module of Kähler differentials.
- `KaehlerDifferential.span_range_derivation`: The image of `D` spans `Ω[S⁄R]` as an `S`-module.
- `KaehlerDifferential.linearMapEquivDerivation`:
The isomorphism `Hom_R(Ω[S⁄R], M) ≃ₗ[S] Der_R(S, M)`.
- `KaehlerDifferential.quotKerTotalEquiv`: An alternative description of `Ω[S⁄R]` as `S` copies
of `S` with kernel (`KaehlerDifferential.kerTotal`) generated by the relations:
1. `dx + dy = d(x + y)`
2. `x dy + y dx = d(x * y)`
3. `dr = 0` for `r ∈ R`
- `KaehlerDifferential.map`: Given a map between the arrows `R →+* A` and `S →+* B`, we have an
`A`-linear map `Ω[A⁄R] → Ω[B⁄S]`.
- `KaehlerDifferential.map_surjective`:
The sequence `Ω[B⁄R] → Ω[B⁄A] → 0` is exact.
- `KaehlerDifferential.exact_mapBaseChange_map`:
The sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A]` is exact.
- `KaehlerDifferential.exact_kerCotangentToTensor_mapBaseChange`:
If `A → B` is surjective with kernel `I`, then
the sequence `I/I² → B ⊗[A] Ω[A⁄R] → Ω[B⁄R]` is exact.
- `KaehlerDifferential.mapBaseChange_surjective`:
If `A → B` is surjective, then the sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → 0` is exact.
## Future project
- Define the `IsKaehlerDifferential` predicate.
-/
suppress_compilation
noncomputable section KaehlerDifferential
open scoped TensorProduct
open Algebra Finsupp
universe u v
variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S]
/-- The kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`. -/
abbrev KaehlerDifferential.ideal : Ideal (S ⊗[R] S) :=
RingHom.ker (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S)
variable {S}
theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) :
(1 : S) ⊗ₜ[R] a - a ⊗ₜ[R] (1 : S) ∈ KaehlerDifferential.ideal R S := by simp [RingHom.mem_ker]
variable {R}
variable {M : Type*} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M]
/-- For a `R`-derivation `S → M`, this is the map `S ⊗[R] S →ₗ[S] M` sending `s ⊗ₜ t ↦ s • D t`. -/
def Derivation.tensorProductTo (D : Derivation R S M) : S ⊗[R] S →ₗ[S] M :=
TensorProduct.AlgebraTensorModule.lift ((LinearMap.lsmul S (S →ₗ[R] M)).flip D.toLinearMap)
theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) :
D.tensorProductTo (s ⊗ₜ t) = s • D t := rfl
theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) :
D.tensorProductTo (x * y) =
TensorProduct.lmul' (S := S) R x • D.tensorProductTo y +
TensorProduct.lmul' (S := S) R y • D.tensorProductTo x := by
refine TensorProduct.induction_on x ?_ ?_ ?_
· rw [zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero]
swap
· intro x₁ y₁ h₁ h₂
rw [add_mul, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm]
intro x₁ x₂
refine TensorProduct.induction_on y ?_ ?_ ?_
· rw [mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero]
swap
· intro x₁ y₁ h₁ h₂
rw [mul_add, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm]
intro x y
simp only [TensorProduct.tmul_mul_tmul, Derivation.tensorProductTo,
TensorProduct.AlgebraTensorModule.lift_apply,
TensorProduct.lmul'_apply_tmul]
dsimp
rw [D.leibniz]
simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc]
variable (R S)
/-- The kernel of `S ⊗[R] S →ₐ[R] S` is generated by `1 ⊗ s - s ⊗ 1` as a `S`-module. -/
theorem KaehlerDifferential.submodule_span_range_eq_ideal :
Submodule.span S (Set.range fun s : S => (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) =
(KaehlerDifferential.ideal R S).restrictScalars S := by
apply le_antisymm
· rw [Submodule.span_le]
rintro _ ⟨s, rfl⟩
exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _
· rintro x (hx : _ = _)
have : x - TensorProduct.lmul' (S := S) R x ⊗ₜ[R] (1 : S) = x := by
rw [hx, TensorProduct.zero_tmul, sub_zero]
rw [← this]
clear this hx
refine TensorProduct.induction_on x ?_ ?_ ?_
· rw [map_zero, TensorProduct.zero_tmul, sub_zero]; exact zero_mem _
· intro x y
have : x ⊗ₜ[R] y - (x * y) ⊗ₜ[R] (1 : S) = x • ((1 : S) ⊗ₜ y - y ⊗ₜ (1 : S)) := by
simp_rw [smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one]
rw [TensorProduct.lmul'_apply_tmul, this]
refine Submodule.smul_mem _ x ?_
apply Submodule.subset_span
exact Set.mem_range_self y
· intro x y hx hy
rw [map_add, TensorProduct.add_tmul, ← sub_add_sub_comm]
exact add_mem hx hy
theorem KaehlerDifferential.span_range_eq_ideal :
Ideal.span (Set.range fun s : S => (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) =
KaehlerDifferential.ideal R S := by
apply le_antisymm
· rw [Ideal.span_le]
rintro _ ⟨s, rfl⟩
exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _
· change (KaehlerDifferential.ideal R S).restrictScalars S ≤ (Ideal.span _).restrictScalars S
rw [← KaehlerDifferential.submodule_span_range_eq_ideal, Ideal.span]
conv_rhs => rw [← Submodule.span_span_of_tower S]
exact Submodule.subset_span
/-- The module of Kähler differentials (Kahler differentials, Kaehler differentials).
This is implemented as `I / I ^ 2` with `I` the kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`.
To view elements as a linear combination of the form `s • D s'`, use
`KaehlerDifferential.tensorProductTo_surjective` and `Derivation.tensorProductTo_tmul`.
We also provide the notation `Ω[S⁄R]` for `KaehlerDifferential R S`.
Note that the slash is `\textfractionsolidus`.
-/
def KaehlerDifferential : Type v :=
(KaehlerDifferential.ideal R S).Cotangent
deriving AddCommGroup, Module (S ⊗[R] S), IsScalarTower S (S ⊗[R] S), Inhabited
@[inherit_doc KaehlerDifferential]
notation "Ω[" S "⁄" R "]" => KaehlerDifferential R S
instance KaehlerDifferential.module' {R' : Type*} [CommRing R'] [Algebra R' S]
[SMulCommClass R R' S] :
Module R' Ω[S⁄R] :=
Submodule.Quotient.module' _
instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type*} [CommRing R₁] [CommRing R₂]
[Algebra R₁ S] [Algebra R₂ S] [SMul R₁ R₂]
[SMulCommClass R R₁ S] [SMulCommClass R R₂ S] [IsScalarTower R₁ R₂ S] :
IsScalarTower R₁ R₂ Ω[S⁄R] :=
Submodule.Quotient.isScalarTower _ _
instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) Ω[S⁄R] :=
Submodule.Quotient.isScalarTower _ _
/-- The quotient map `I → Ω[S⁄R]` with `I` being the kernel of `S ⊗[R] S → S`. -/
def KaehlerDifferential.fromIdeal : KaehlerDifferential.ideal R S →ₗ[S ⊗[R] S] Ω[S⁄R] :=
(KaehlerDifferential.ideal R S).toCotangent
/-- (Implementation) The underlying linear map of the derivation into `Ω[S⁄R]`. -/
def KaehlerDifferential.DLinearMap : S →ₗ[R] Ω[S⁄R] :=
((KaehlerDifferential.fromIdeal R S).restrictScalars R).comp
((TensorProduct.includeRight.toLinearMap - TensorProduct.includeLeft.toLinearMap :
S →ₗ[R] S ⊗[R] S).codRestrict
((KaehlerDifferential.ideal R S).restrictScalars R)
(KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R) :
_ →ₗ[R] _)
theorem KaehlerDifferential.DLinearMap_apply (s : S) :
KaehlerDifferential.DLinearMap R S s =
(KaehlerDifferential.ideal R S).toCotangent
⟨1 ⊗ₜ s - s ⊗ₜ 1, KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R s⟩ := rfl
/-- The universal derivation into `Ω[S⁄R]`. -/
def KaehlerDifferential.D : Derivation R S Ω[S⁄R] :=
{ toLinearMap := KaehlerDifferential.DLinearMap R S
map_one_eq_zero' := by
dsimp [KaehlerDifferential.DLinearMap_apply, Ideal.toCotangent_apply]
congr
rw [sub_self]
leibniz' := fun a b => by
have : LinearMap.CompatibleSMul { x // x ∈ ideal R S } Ω[S⁄R] S (S ⊗[R] S) := inferInstance
dsimp [KaehlerDifferential.DLinearMap_apply]
rw [← LinearMap.map_smul_of_tower (ideal R S).toCotangent,
← LinearMap.map_smul_of_tower (ideal R S).toCotangent,
← map_add (ideal R S).toCotangent, Ideal.toCotangent_eq, pow_two]
convert Submodule.mul_mem_mul (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R a :)
(KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R b :) using 1
simp only [Submodule.coe_add,
TensorProduct.tmul_mul_tmul, mul_sub, sub_mul, mul_comm b, Submodule.coe_smul_of_tower,
smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one]
ring_nf }
theorem KaehlerDifferential.D_apply (s : S) :
KaehlerDifferential.D R S s =
(KaehlerDifferential.ideal R S).toCotangent
⟨1 ⊗ₜ s - s ⊗ₜ 1, KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R s⟩ := rfl
theorem KaehlerDifferential.span_range_derivation :
Submodule.span S (Set.range <| KaehlerDifferential.D R S) = ⊤ := by
rw [_root_.eq_top_iff]
rintro x -
obtain ⟨⟨x, hx⟩, rfl⟩ := Ideal.toCotangent_surjective _ x
have : x ∈ (KaehlerDifferential.ideal R S).restrictScalars S := hx
rw [← KaehlerDifferential.submodule_span_range_eq_ideal] at this
suffices ∃ hx, (KaehlerDifferential.ideal R S).toCotangent ⟨x, hx⟩ ∈
Submodule.span S (Set.range <| KaehlerDifferential.D R S) by
exact this.choose_spec
refine Submodule.span_induction ?_ ?_ ?_ ?_ this
· rintro _ ⟨x, rfl⟩
refine ⟨KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R x, ?_⟩
apply Submodule.subset_span
exact ⟨x, KaehlerDifferential.DLinearMap_apply R S x⟩
· exact ⟨zero_mem _, Submodule.zero_mem _⟩
· rintro x y - - ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩; exact ⟨add_mem hx₁ hy₁, Submodule.add_mem _ hx₂ hy₂⟩
· rintro r x - ⟨hx₁, hx₂⟩
exact ⟨((KaehlerDifferential.ideal R S).restrictScalars S).smul_mem r hx₁,
Submodule.smul_mem _ r hx₂⟩
/-- `Ω[S⁄R]` is trivial if `R → S` is surjective.
Also see `Algebra.FormallyUnramified.iff_subsingleton_kaehlerDifferential`. -/
lemma KaehlerDifferential.subsingleton_of_surjective (h : Function.Surjective (algebraMap R S)) :
Subsingleton Ω[S⁄R] := by
suffices (⊤ : Submodule S Ω[S⁄R]) ≤ ⊥ from
(subsingleton_iff_forall_eq 0).mpr fun y ↦ this trivial
rw [← KaehlerDifferential.span_range_derivation, Submodule.span_le]
rintro _ ⟨x, rfl⟩; obtain ⟨x, rfl⟩ := h x; simp
variable {R S}
/-- The linear map from `Ω[S⁄R]`, associated with a derivation. -/
def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ[S] M := by
refine LinearMap.comp ((((KaehlerDifferential.ideal R S) •
(⊤ : Submodule (S ⊗[R] S) (KaehlerDifferential.ideal R S))).restrictScalars S).liftQ ?_ ?_)
(Submodule.Quotient.restrictScalarsEquiv S _).symm.toLinearMap
· exact D.tensorProductTo.comp ((KaehlerDifferential.ideal R S).subtype.restrictScalars S)
· intro x hx
rw [LinearMap.mem_ker]
refine Submodule.smul_induction_on ((Submodule.restrictScalars_mem _ _ _).mp hx) ?_ ?_
· rintro x hx y -
rw [RingHom.mem_ker] at hx
dsimp
rw [Derivation.tensorProductTo_mul, hx, y.prop, zero_smul, zero_smul, zero_add]
· intro x y ex ey; rw [map_add, ex, ey, zero_add]
theorem Derivation.liftKaehlerDifferential_apply (D : Derivation R S M) (x) :
D.liftKaehlerDifferential ((KaehlerDifferential.ideal R S).toCotangent x) =
D.tensorProductTo x := rfl
theorem Derivation.liftKaehlerDifferential_comp (D : Derivation R S M) :
D.liftKaehlerDifferential.compDer (KaehlerDifferential.D R S) = D := by
ext a
dsimp [KaehlerDifferential.D_apply]
refine (D.liftKaehlerDifferential_apply _).trans ?_
rw [Subtype.coe_mk, map_sub, Derivation.tensorProductTo_tmul, Derivation.tensorProductTo_tmul,
one_smul, D.map_one_eq_zero, smul_zero, sub_zero]
@[simp]
theorem Derivation.liftKaehlerDifferential_comp_D (D' : Derivation R S M) (x : S) :
D'.liftKaehlerDifferential (KaehlerDifferential.D R S x) = D' x :=
Derivation.congr_fun D'.liftKaehlerDifferential_comp x
@[ext]
theorem Derivation.liftKaehlerDifferential_unique (f f' : Ω[S⁄R] →ₗ[S] M)
(hf : f.compDer (KaehlerDifferential.D R S) = f'.compDer (KaehlerDifferential.D R S)) :
f = f' := by
apply LinearMap.ext
intro x
have : x ∈ Submodule.span S (Set.range <| KaehlerDifferential.D R S) := by
rw [KaehlerDifferential.span_range_derivation]; trivial
refine Submodule.span_induction ?_ ?_ ?_ ?_ this
· rintro _ ⟨x, rfl⟩; exact congr_arg (fun D : Derivation R S M => D x) hf
· rw [map_zero, map_zero]
· intro x y _ _ hx hy; rw [map_add, map_add, hx, hy]
· intro a x _ e; simp [e]
variable (R S)
theorem Derivation.liftKaehlerDifferential_D :
(KaehlerDifferential.D R S).liftKaehlerDifferential = LinearMap.id :=
Derivation.liftKaehlerDifferential_unique _ _
(KaehlerDifferential.D R S).liftKaehlerDifferential_comp
variable {R S}
theorem KaehlerDifferential.D_tensorProductTo (x : KaehlerDifferential.ideal R S) :
(KaehlerDifferential.D R S).tensorProductTo x =
(KaehlerDifferential.ideal R S).toCotangent x := by
rw [← Derivation.liftKaehlerDifferential_apply, Derivation.liftKaehlerDifferential_D]
rfl
variable (R S)
theorem KaehlerDifferential.tensorProductTo_surjective :
Function.Surjective (KaehlerDifferential.D R S).tensorProductTo := by
intro x; obtain ⟨x, rfl⟩ := (KaehlerDifferential.ideal R S).toCotangent_surjective x
exact ⟨x, KaehlerDifferential.D_tensorProductTo x⟩
/-- The `S`-linear maps from `Ω[S⁄R]` to `M` are (`S`-linearly) equivalent to `R`-derivations
from `S` to `M`. -/
@[simps! symm_apply apply_apply]
def KaehlerDifferential.linearMapEquivDerivation : (Ω[S⁄R] →ₗ[S] M) ≃ₗ[S] Derivation R S M :=
{ Derivation.llcomp.flip <| KaehlerDifferential.D R S with
invFun := Derivation.liftKaehlerDifferential
left_inv := fun _ =>
Derivation.liftKaehlerDifferential_unique _ _ (Derivation.liftKaehlerDifferential_comp _)
right_inv := Derivation.liftKaehlerDifferential_comp }
/-- The quotient ring of `S ⊗ S ⧸ J ^ 2` by `Ω[S⁄R]` is isomorphic to `S`. -/
def KaehlerDifferential.quotientCotangentIdealRingEquiv :
(S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸ (KaehlerDifferential.ideal R S).cotangentIdeal ≃+*
S := by
have : Function.RightInverse (TensorProduct.includeLeft (R := R) (S := R) (A := S) (B := S))
(↑(TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) : S ⊗[R] S →+* S) := by
intro x; rw [AlgHom.coe_toRingHom, ← AlgHom.comp_apply, TensorProduct.lmul'_comp_includeLeft]
rfl
refine (Ideal.quotCotangent _).trans ?_
refine (Ideal.quotEquivOfEq ?_).trans (RingHom.quotientKerEquivOfRightInverse this)
ext; rfl
/-- The quotient ring of `S ⊗ S ⧸ J ^ 2` by `Ω[S⁄R]` is isomorphic to `S` as an `S`-algebra. -/
def KaehlerDifferential.quotientCotangentIdeal :
((S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸
(KaehlerDifferential.ideal R S).cotangentIdeal) ≃ₐ[S] S :=
{ KaehlerDifferential.quotientCotangentIdealRingEquiv R S with
commutes' := (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).apply_symm_apply }
theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) :
(Ideal.Quotient.mkₐ R (KaehlerDifferential.ideal R S).cotangentIdeal).comp f =
IsScalarTower.toAlgHom R S _ ↔
(TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S := by
rw [AlgHom.ext_iff, AlgHom.ext_iff]
apply forall_congr'
intro x
have e₁ : (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift (f x) =
KaehlerDifferential.quotientCotangentIdealRingEquiv R S
(Ideal.Quotient.mk (KaehlerDifferential.ideal R S).cotangentIdeal <| f x) := by
generalize f x = y; obtain ⟨y, rfl⟩ := Ideal.Quotient.mk_surjective y; rfl
have e₂ :
x = KaehlerDifferential.quotientCotangentIdealRingEquiv R S (IsScalarTower.toAlgHom R S _ x) :=
(mul_one x).symm
constructor
· intro e
exact (e₁.trans (@RingEquiv.congr_arg _ _ _ _ _ _
(KaehlerDifferential.quotientCotangentIdealRingEquiv R S) _ _ e)).trans e₂.symm
· intro e; apply (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).injective
exact e₁.symm.trans (e.trans e₂)
/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
local instance instR : Module R (KaehlerDifferential.ideal R S).cotangentIdeal :=
Submodule.module' _
/-- Derivations into `Ω[S⁄R]` is equivalent to derivations
into `(KaehlerDifferential.ideal R S).cotangentIdeal`. -/
noncomputable def KaehlerDifferential.endEquivDerivation' :
Derivation R S Ω[S⁄R] ≃ₗ[R] Derivation R S (ideal R S).cotangentIdeal :=
LinearEquiv.compDer ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
/-- (Implementation) An `Equiv` version of `KaehlerDifferential.End_equiv_aux`.
Used in `KaehlerDifferential.endEquiv`. -/
def KaehlerDifferential.endEquivAuxEquiv :
{ f //
(Ideal.Quotient.mkₐ R (KaehlerDifferential.ideal R S).cotangentIdeal).comp f =
IsScalarTower.toAlgHom R S _ } ≃
{ f // (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S } :=
(Equiv.refl _).subtypeEquiv (KaehlerDifferential.End_equiv_aux R S)
/--
The endomorphisms of `Ω[S⁄R]` corresponds to sections of the surjection `S ⊗[R] S ⧸ J ^ 2 →ₐ[R] S`,
with `J` being the kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`.
-/
noncomputable def KaehlerDifferential.endEquiv :
Module.End S Ω[S⁄R] ≃
{ f // (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S } :=
(KaehlerDifferential.linearMapEquivDerivation R S).toEquiv.trans <|
(KaehlerDifferential.endEquivDerivation' R S).toEquiv.trans <|
(derivationToSquareZeroEquivLift (KaehlerDifferential.ideal R S).cotangentIdeal
(KaehlerDifferential.ideal R S).cotangentIdeal_square).trans <|
KaehlerDifferential.endEquivAuxEquiv R S
section Finiteness
theorem KaehlerDifferential.ideal_fg [EssFiniteType R S] :
(KaehlerDifferential.ideal R S).FG := by
classical
use (EssFiniteType.finset R S).image (fun s ↦ (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S))
apply le_antisymm
· rw [Finset.coe_image, Ideal.span_le]
rintro _ ⟨x, _, rfl⟩
exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R x
· rw [← KaehlerDifferential.span_range_eq_ideal, Ideal.span_le]
rintro _ ⟨x, rfl⟩
let I : Ideal (S ⊗[R] S) := Ideal.span
((EssFiniteType.finset R S).image (fun s ↦ (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)))
change _ - _ ∈ I
have : (IsScalarTower.toAlgHom R (S ⊗[R] S) (S ⊗[R] S ⧸ I)).comp TensorProduct.includeRight =
(IsScalarTower.toAlgHom R (S ⊗[R] S) (S ⊗[R] S ⧸ I)).comp TensorProduct.includeLeft := by
apply EssFiniteType.algHom_ext
intro a ha
simp only [AlgHom.coe_comp, IsScalarTower.coe_toAlgHom', Ideal.Quotient.algebraMap_eq,
Function.comp_apply, TensorProduct.includeLeft_apply, TensorProduct.includeRight_apply,
Ideal.Quotient.mk_eq_mk_iff_sub_mem]
refine Ideal.subset_span ?_
simp only [Finset.coe_image, Set.mem_image, Finset.mem_coe]
exact ⟨a, ha, rfl⟩
simpa [Ideal.Quotient.mk_eq_mk_iff_sub_mem] using AlgHom.congr_fun this x
instance KaehlerDifferential.finite [EssFiniteType R S] :
Module.Finite S Ω[S⁄R] := by
classical
let s := (EssFiniteType.finset R S).image (fun s ↦ D R S s)
refine ⟨⟨s, top_le_iff.mp ?_⟩⟩
rw [← span_range_derivation, Submodule.span_le]
rintro _ ⟨x, rfl⟩
have : ∀ x ∈ adjoin R (EssFiniteType.finset R S : Set S),
.D _ _ x ∈ Submodule.span S (s : Set Ω[S⁄R]) := by
intro x hx
refine adjoin_induction ?_ ?_ ?_ ?_ hx
· exact fun x hx ↦ Submodule.subset_span (Finset.mem_image_of_mem _ hx)
· simp
· exact fun x y _ _ hx hy ↦ (D R S).map_add x y ▸ add_mem hx hy
· intro x y _ _ hx hy
simp only [Derivation.leibniz]
exact add_mem (Submodule.smul_mem _ _ hy) (Submodule.smul_mem _ _ hx)
obtain ⟨t, ht, ht', hxt⟩ := (essFiniteType_cond_iff R S (EssFiniteType.finset R S)).mp
EssFiniteType.cond.choose_spec x
rw [show D R S x =
ht'.unit⁻¹ • (D R S (x * t) - x • D R S t) by simp [smul_smul, Units.smul_def]]
exact Submodule.smul_mem _ _ (sub_mem (this _ hxt) (Submodule.smul_mem _ _ (this _ ht)))
end Finiteness
section Presentation
open KaehlerDifferential (D)
open Finsupp (single)
/-- The `S`-submodule of `S →₀ S` (the direct sum of copies of `S` indexed by `S`) generated by
the relations:
1. `dx + dy = d(x + y)`
2. `x dy + y dx = d(x * y)`
3. `dr = 0` for `r ∈ R`
where `db` is the unit in the copy of `S` with index `b`.
This is the kernel of the surjection
`Finsupp.linearCombination S Ω[S⁄R] S (KaehlerDifferential.D R S)`.
See `KaehlerDifferential.kerTotal_eq` and `KaehlerDifferential.linearCombination_surjective`.
-/
noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
Submodule.span S
(((Set.range fun x : S × S => single x.1 1 + single x.2 1 - single (x.1 + x.2) 1) ∪
Set.range fun x : S × S => single x.2 x.1 + single x.1 x.2 - single (x.1 * x.2) 1) ∪
Set.range fun x : R => single (algebraMap R S x) 1)
unsuppress_compilation in
local notation3 x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)
theorem KaehlerDifferential.kerTotal_mkQ_single_add (x y z) : (z𝖣x + y) = (z𝖣x) + z𝖣y := by
rw [← map_add, eq_comm, ← sub_eq_zero, ← map_sub (Submodule.mkQ (kerTotal R S)),
Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero]
simp_rw [← Finsupp.smul_single_one _ z, ← smul_add, ← smul_sub]
exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inl <| ⟨⟨_, _⟩, rfl⟩))
theorem KaehlerDifferential.kerTotal_mkQ_single_mul (x y z) :
(z𝖣x * y) = ((z * x)𝖣y) + (z * y)𝖣x := by
rw [← map_add, eq_comm, ← sub_eq_zero, ← map_sub (Submodule.mkQ (kerTotal R S)),
Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero]
simp_rw [← Finsupp.smul_single_one _ z, ← @smul_eq_mul _ _ z, ← Finsupp.smul_single, ← smul_add,
← smul_sub]
exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inr <| ⟨⟨_, _⟩, rfl⟩))
theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap (x y) : (y𝖣algebraMap R S x) = 0 := by
rw [Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero, ← Finsupp.smul_single_one _ y]
exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inr <| ⟨_, rfl⟩))
theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one (x) : (x𝖣1) = 0 := by
rw [← (algebraMap R S).map_one, KaehlerDifferential.kerTotal_mkQ_single_algebraMap]
theorem KaehlerDifferential.kerTotal_mkQ_single_smul (r : R) (x y) : (y𝖣r • x) = r • y𝖣x := by
letI : SMulZeroClass R S := inferInstance
rw [Algebra.smul_def, KaehlerDifferential.kerTotal_mkQ_single_mul,
KaehlerDifferential.kerTotal_mkQ_single_algebraMap, add_zero, ← LinearMap.map_smul_of_tower,
Finsupp.smul_single, mul_comm, Algebra.smul_def]
/-- The (universal) derivation into `(S →₀ S) ⧸ KaehlerDifferential.kerTotal R S`. -/
noncomputable def KaehlerDifferential.derivationQuotKerTotal :
Derivation R S ((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S) where
toFun x := 1𝖣x
map_add' _ _ := KaehlerDifferential.kerTotal_mkQ_single_add _ _ _ _ _
map_smul' _ _ := KaehlerDifferential.kerTotal_mkQ_single_smul _ _ _ _ _
map_one_eq_zero' := KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one _ _ _
leibniz' a b :=
(KaehlerDifferential.kerTotal_mkQ_single_mul _ _ _ _ _).trans
(by simp_rw [← Finsupp.smul_single_one _ (1 * _ : S)]; dsimp; simp)
theorem KaehlerDifferential.derivationQuotKerTotal_apply (x) :
KaehlerDifferential.derivationQuotKerTotal R S x = 1𝖣x :=
rfl
theorem KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination :
(KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential.comp
(Finsupp.linearCombination S (KaehlerDifferential.D R S)) =
Submodule.mkQ _ := by
apply Finsupp.lhom_ext
intro a b
conv_rhs => rw [← Finsupp.smul_single_one a b, LinearMap.map_smul]
simp [KaehlerDifferential.derivationQuotKerTotal_apply]
theorem KaehlerDifferential.kerTotal_eq :
LinearMap.ker (Finsupp.linearCombination S (KaehlerDifferential.D R S)) =
KaehlerDifferential.kerTotal R S := by
apply le_antisymm
· conv_rhs => rw [← (KaehlerDifferential.kerTotal R S).ker_mkQ]
rw [← KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination]
exact LinearMap.ker_le_ker_comp _ _
· rw [KaehlerDifferential.kerTotal, Submodule.span_le]
rintro _ ((⟨⟨x, y⟩, rfl⟩ | ⟨⟨x, y⟩, rfl⟩) | ⟨x, rfl⟩) <;> simp [LinearMap.mem_ker]
theorem KaehlerDifferential.linearCombination_surjective :
Function.Surjective (Finsupp.linearCombination S (KaehlerDifferential.D R S)) := by
rw [← LinearMap.range_eq_top, range_linearCombination, span_range_derivation]
/-- `Ω[S⁄R]` is isomorphic to `S` copies of `S` with kernel `KaehlerDifferential.kerTotal`. -/
@[simps!]
noncomputable def KaehlerDifferential.quotKerTotalEquiv :
((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S) ≃ₗ[S] Ω[S⁄R] :=
{ (KaehlerDifferential.kerTotal R S).liftQ
(Finsupp.linearCombination S (KaehlerDifferential.D R S))
(KaehlerDifferential.kerTotal_eq R S).ge with
invFun := (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential
left_inv := by
intro x
obtain ⟨x, rfl⟩ := Submodule.mkQ_surjective _ x
exact
LinearMap.congr_fun
(KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination R S :) x
right_inv := by
intro x
obtain ⟨x, rfl⟩ := KaehlerDifferential.linearCombination_surjective R S x
have := LinearMap.congr_fun
(KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination R S) x
rw [LinearMap.comp_apply] at this
rw [this]
rfl }
theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_D :
(KaehlerDifferential.quotKerTotalEquiv R S).symm.toLinearMap.compDer
(KaehlerDifferential.D R S) =
KaehlerDifferential.derivationQuotKerTotal R S := by
convert (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential_comp
end Presentation
section ExactSequence
/- We have the commutative diagram
```
A --→ B
↑ ↑
| |
R --→ S
```
-/
variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A]
variable [Algebra A B] [Algebra S B]
unsuppress_compilation in
-- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
local macro "finsupp_map" : term =>
`((Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp
(Finsupp.lmapDomain A A (algebraMap A B)))
/--
Given the commutative diagram
```
A --→ B
↑ ↑
| |
R --→ S
```
The kernel of the presentation `⊕ₓ B dx ↠ Ω_{B/S}` is spanned by the image of the
kernel of `⊕ₓ A dx ↠ Ω_{A/R}` and all `ds` with `s : S`.
See `kerTotal_map'` for the special case where `R = S`.
-/
theorem KaehlerDifferential.kerTotal_map [Algebra R B] [IsScalarTower R A B] [IsScalarTower R S B]
(h : Function.Surjective (algebraMap A B)) :
(KaehlerDifferential.kerTotal R A).map finsupp_map ⊔
Submodule.span A (Set.range fun x : S => .single (algebraMap S B x) (1 : B)) =
(KaehlerDifferential.kerTotal S B).restrictScalars _ := by
rw [KaehlerDifferential.kerTotal, Submodule.map_span, KaehlerDifferential.kerTotal,
Submodule.restrictScalars_span _ _ h]
simp_rw [Set.image_union, Submodule.span_union, ← Set.image_univ, Set.image_image, Set.image_univ,
map_sub, map_add]
simp only [LinearMap.comp_apply, Finsupp.lmapDomain_apply, Finsupp.mapDomain_single,
Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Algebra.linearMap_apply,
map_one, map_add, map_mul]
simp_rw [sup_assoc, ← (h.prodMap h).range_comp]
congr!
rw [sup_eq_right]
apply Submodule.span_mono
simp_rw [← IsScalarTower.algebraMap_apply R A B, IsScalarTower.algebraMap_apply R S B]
exact Set.range_comp_subset_range (algebraMap R S)
fun x => Finsupp.single (algebraMap S B x) (1 : B)
/--
This is a special case of `kerTotal_map` where `R = S`.
The kernel of the presentation `⊕ₓ B dx ↠ Ω_{B/R}` is spanned by the image of the
kernel of `⊕ₓ A dx ↠ Ω_{A/R}` and all `da` with `a : A`.
-/
theorem KaehlerDifferential.kerTotal_map' [Algebra R B]
[IsScalarTower R A B] (h : Function.Surjective (algebraMap A B)) :
(KaehlerDifferential.kerTotal R A ⊔
Submodule.span A (Set.range fun x ↦ .single (algebraMap R A x) 1)).map finsupp_map =
(KaehlerDifferential.kerTotal R B).restrictScalars _ := by
rw [Submodule.map_sup, ← kerTotal_map R R A B h, Submodule.map_span, ← Set.range_comp]
congr
ext; simp [IsScalarTower.algebraMap_eq R A B]
section
variable [Algebra R B] [IsScalarTower R A B] [IsScalarTower R S B] [SMulCommClass S A B]
/-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄S]` given a square
```
A --→ B
↑ ↑
| |
R --→ S
```
-/
def KaehlerDifferential.map : Ω[A⁄R] →ₗ[A] Ω[B⁄S] :=
Derivation.liftKaehlerDifferential
(((KaehlerDifferential.D S B).restrictScalars R).compAlgebraMap A)
theorem KaehlerDifferential.map_compDer :
(KaehlerDifferential.map R S A B).compDer (KaehlerDifferential.D R A) =
((KaehlerDifferential.D S B).restrictScalars R).compAlgebraMap A :=
Derivation.liftKaehlerDifferential_comp _
@[simp]
theorem KaehlerDifferential.map_D (x : A) :
KaehlerDifferential.map R S A B (KaehlerDifferential.D R A x) =
KaehlerDifferential.D S B (algebraMap A B x) :=
Derivation.congr_fun (KaehlerDifferential.map_compDer R S A B) x
theorem KaehlerDifferential.ker_map :
LinearMap.ker (KaehlerDifferential.map R S A B) =
(((kerTotal S B).restrictScalars A).comap finsupp_map).map
(Finsupp.linearCombination (M := Ω[A⁄R]) A (D R A)) := by
rw [← Submodule.map_comap_eq_of_surjective (linearCombination_surjective R A) (LinearMap.ker _)]
congr 1
ext x
simp only [Submodule.mem_comap, LinearMap.mem_ker, Finsupp.apply_linearCombination, ← kerTotal_eq,
Submodule.restrictScalars_mem]
simp only [linearCombination_apply, Function.comp_apply, LinearMap.coe_comp, lmapDomain_apply,
Finsupp.mapRange.linearMap_apply]
rw [Finsupp.sum_mapRange_index, Finsupp.sum_mapDomain_index]
· simp
· simp
· simp [add_smul]
· simp
lemma KaehlerDifferential.ker_map_of_surjective (h : Function.Surjective (algebraMap A B)) :
LinearMap.ker (map R R A B) =
(LinearMap.ker finsupp_map).map (Finsupp.linearCombination A (D R A)) := by
rw [ker_map, ← kerTotal_map' R A B h, Submodule.comap_map_eq, Submodule.map_sup,
Submodule.map_sup, ← kerTotal_eq, ← Submodule.comap_bot,
Submodule.map_comap_eq_of_surjective (linearCombination_surjective _ _),
bot_sup_eq, Submodule.map_span, ← Set.range_comp]
convert bot_sup_eq _
rw [Submodule.span_eq_bot]; simp
open IsScalarTower (toAlgHom)
theorem KaehlerDifferential.map_surjective_of_surjective
(h : Function.Surjective (algebraMap A B)) :
Function.Surjective (KaehlerDifferential.map R S A B) := by
rw [← LinearMap.range_eq_top, _root_.eq_top_iff,
← @Submodule.restrictScalars_top A B, ← span_range_derivation,
Submodule.restrictScalars_span _ _ h, Submodule.span_le]
rintro _ ⟨x, rfl⟩
obtain ⟨y, rfl⟩ := h x
rw [← KaehlerDifferential.map_D R S A B]
exact ⟨_, rfl⟩
theorem KaehlerDifferential.map_surjective :
Function.Surjective (KaehlerDifferential.map R S B B) :=
map_surjective_of_surjective R S B B Function.surjective_id
/-- The lift of the map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` to the base change along `A → B`.
This is the first map in the exact sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A] → 0`. -/
noncomputable def KaehlerDifferential.mapBaseChange : B ⊗[A] Ω[A⁄R] →ₗ[B] Ω[B⁄R] :=
(TensorProduct.isBaseChange A Ω[A⁄R] B).lift (KaehlerDifferential.map R R A B)
@[simp]
theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) :
KaehlerDifferential.mapBaseChange R A B (x ⊗ₜ y) = x • KaehlerDifferential.map R R A B y := by
conv_lhs => rw [← mul_one x, ← smul_eq_mul, ← TensorProduct.smul_tmul', LinearMap.map_smul]
congr 1
exact IsBaseChange.lift_eq _ _ _
lemma KaehlerDifferential.range_mapBaseChange :
LinearMap.range (mapBaseChange R A B) = LinearMap.ker (map R A B B) := by
apply le_antisymm
· rintro _ ⟨x, rfl⟩
induction x with
| zero => simp
| tmul r s =>
obtain ⟨x, rfl⟩ := linearCombination_surjective _ _ s
simp only [mapBaseChange_tmul, LinearMap.mem_ker, map_smul]
induction x using Finsupp.induction_linear
· simp
· simp [smul_add, *]
· simp
| add => rw [map_add]; exact add_mem ‹_› ‹_›
· convert_to (kerTotal A B).map (Finsupp.linearCombination B (D R B)) ≤ _
· rw [KaehlerDifferential.ker_map]
congr 1
convert Submodule.comap_id _
· ext; simp
rw [Submodule.map_le_iff_le_comap, kerTotal, Submodule.span_le]
rintro f ((⟨⟨x, y⟩, rfl⟩|⟨⟨x, y⟩, rfl⟩)|⟨x, rfl⟩)
· use 0; simp
· use 0; simp
· use 1 ⊗ₜ D _ _ x; simp
/-- The sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A] → 0` is exact.
Also see `KaehlerDifferential.map_surjective`. -/
lemma KaehlerDifferential.exact_mapBaseChange_map :
Function.Exact (mapBaseChange R A B) (map R A B B) :=
SetLike.ext_iff.mp (range_mapBaseChange R A B).symm
end
/-- The map `I → B ⊗[A] Ω[A⁄R]` where `I = ker(A → B)`. -/
@[simps]
noncomputable
def KaehlerDifferential.kerToTensor :
RingHom.ker (algebraMap A B) →ₗ[A] B ⊗[A] Ω[A⁄R] where
toFun x := 1 ⊗ₜ D R A x
map_add' x y := by simp only [Submodule.coe_add, map_add, TensorProduct.tmul_add]
map_smul' r x := by simp only [SetLike.val_smul, smul_eq_mul, Derivation.leibniz,
TensorProduct.tmul_add, TensorProduct.tmul_smul, TensorProduct.smul_tmul', ←
algebraMap_eq_smul_one, RingHom.mem_ker.mp x.prop, TensorProduct.zero_tmul, add_zero,
RingHom.id_apply]
/-- The map `I/I² → B ⊗[A] Ω[A⁄R]` where `I = ker(A → B)`. -/
noncomputable
def KaehlerDifferential.kerCotangentToTensor :
(RingHom.ker (algebraMap A B)).Cotangent →ₗ[A] B ⊗[A] Ω[A⁄R] :=
Submodule.liftQ _ (kerToTensor R A B) <| by
rw [Submodule.smul_eq_map₂]
apply iSup_le_iff.mpr
simp only [Submodule.map_le_iff_le_comap, Subtype.forall]
rintro x hx y -
simp only [Submodule.mem_comap, LinearMap.lsmul_apply, LinearMap.mem_ker, map_smul,
kerToTensor_apply, TensorProduct.smul_tmul', ← algebraMap_eq_smul_one,
RingHom.mem_ker.mp hx, TensorProduct.zero_tmul]
@[simp]
lemma KaehlerDifferential.kerCotangentToTensor_toCotangent (x) :
kerCotangentToTensor R A B (Ideal.toCotangent _ x) = 1 ⊗ₜ D _ _ x.1 := rfl
variable [Algebra R B] [IsScalarTower R A B]
theorem KaehlerDifferential.range_kerCotangentToTensor
(h : Function.Surjective (algebraMap A B)) :
LinearMap.range (kerCotangentToTensor R A B) =
(LinearMap.ker (KaehlerDifferential.mapBaseChange R A B)).restrictScalars A := by
classical
ext x
constructor
· rintro ⟨x, rfl⟩
obtain ⟨x, rfl⟩ := Ideal.toCotangent_surjective _ x
simp only [kerCotangentToTensor_toCotangent, Submodule.restrictScalars_mem, LinearMap.mem_ker,
mapBaseChange_tmul, map_D, RingHom.mem_ker.mp x.2, map_zero, smul_zero]
· intro hx
obtain ⟨x, rfl⟩ := LinearMap.rTensor_surjective Ω[A⁄R] (g := Algebra.linearMap A B) h x
obtain ⟨x, rfl⟩ := (TensorProduct.lid _ _).symm.surjective x
replace hx : x ∈ LinearMap.ker (KaehlerDifferential.map R R A B) := by simpa using hx
rw [KaehlerDifferential.ker_map_of_surjective R A B h] at hx
obtain ⟨x, hx, rfl⟩ := hx
simp only [TensorProduct.lid_symm_apply, LinearMap.rTensor_tmul,
Algebra.linearMap_apply, map_one]
rw [← Finsupp.sum_single x, Finsupp.sum, ← Finset.sum_fiberwise_of_maps_to
(fun _ ↦ Finset.mem_image_of_mem (algebraMap A B))]
simp only [map_sum (s := x.support.image (algebraMap A B)),
TensorProduct.tmul_sum]
apply sum_mem
intro c _
simp only [LinearMap.mem_range]
simp only [map_sum, Finsupp.linearCombination_single]
have : ∑ i ∈ x.support with algebraMap A B i = c, x i ∈ RingHom.ker (algebraMap A B) := by
simpa [Finsupp.mapDomain, Finsupp.sum, Finsupp.finset_sum_apply, RingHom.mem_ker,
Finsupp.single_apply, ← Finset.sum_filter] using DFunLike.congr_fun hx c
obtain ⟨a, ha⟩ := h c
use ∑ i ∈ {i ∈ x.support | algebraMap A B i = c}.attach, x i • Ideal.toCotangent _ ⟨i - a, ?_⟩
· simp only [map_sum, LinearMapClass.map_smul, kerCotangentToTensor_toCotangent, map_sub]
simp_rw [← TensorProduct.tmul_smul]
-- TODO: was `simp [kerCotangentToTensor_toCotangent, RingHom.mem_ker.mp x.2]` and very slow
-- (https://github.com/leanprover-community/mathlib4/issues/19751)
simp only [smul_sub, TensorProduct.tmul_sub, Finset.sum_sub_distrib, ← TensorProduct.tmul_sum,
← Finset.sum_smul, Finset.sum_attach, sub_eq_self,
Finset.sum_attach (f := fun i ↦ x i • KaehlerDifferential.D R A i)]
rw [← TensorProduct.smul_tmul, ← Algebra.algebraMap_eq_smul_one, RingHom.mem_ker.mp this,
TensorProduct.zero_tmul]
· have : x i ≠ 0 ∧ algebraMap A B i = c := by
convert i.prop
simp_rw [Finset.mem_filter, Finsupp.mem_support_iff]
simp [RingHom.mem_ker, ha, this.2]
theorem KaehlerDifferential.exact_kerCotangentToTensor_mapBaseChange
(h : Function.Surjective (algebraMap A B)) :
Function.Exact (kerCotangentToTensor R A B) (KaehlerDifferential.mapBaseChange R A B) :=
SetLike.ext_iff.mp (range_kerCotangentToTensor R A B h).symm
lemma KaehlerDifferential.mapBaseChange_surjective
(h : Function.Surjective (algebraMap A B)) :
Function.Surjective (KaehlerDifferential.mapBaseChange R A B) := by
have := subsingleton_of_surjective A B h
rw [← LinearMap.range_eq_top, range_mapBaseChange, ← top_le_iff]
exact fun x _ ↦ Subsingleton.elim _ _
end ExactSequence
end KaehlerDifferential |
.lake/packages/mathlib/Mathlib/RingTheory/Kaehler/CotangentComplex.lean | import Mathlib.RingTheory.Extension.Cotangent.Basic
deprecated_module (since := "2025-05-11") |
.lake/packages/mathlib/Mathlib/RingTheory/Kaehler/Polynomial.lean | import Mathlib.RingTheory.Kaehler.Basic
import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.Algebra.Polynomial.Derivation
/-!
# The Kähler differential module of polynomial algebras
-/
open Algebra Module
open scoped TensorProduct
universe u v
variable (R : Type u) [CommRing R]
suppress_compilation
section MvPolynomial
/-- The relative differential module of a polynomial algebra `R[σ]` is the free module generated by
`{ dx | x ∈ σ }`. Also see `KaehlerDifferential.mvPolynomialBasis`. -/
def KaehlerDifferential.mvPolynomialEquiv (σ : Type*) :
Ω[MvPolynomial σ R⁄R] ≃ₗ[MvPolynomial σ R] σ →₀ MvPolynomial σ R where
__ := (MvPolynomial.mkDerivation _ (Finsupp.single · 1)).liftKaehlerDifferential
invFun := Finsupp.linearCombination (α := σ) _ (fun x ↦ D _ _ (MvPolynomial.X x))
right_inv := by
intro x
induction x using Finsupp.induction_linear with
| zero => simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]; rw [map_zero, map_zero]
| add => simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, map_add] at *; simp only [*]
| single a b => simp [-map_smul]
left_inv := by
intro x
obtain ⟨x, rfl⟩ := linearCombination_surjective _ _ x
induction x using Finsupp.induction_linear with
| zero =>
simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]
rw [map_zero, map_zero, map_zero]
| add => simp only [map_add, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom] at *; simp only [*]
| single a b =>
simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Finsupp.linearCombination_single,
LinearMap.map_smul, Derivation.liftKaehlerDifferential_comp_D]
congr 1
induction a using MvPolynomial.induction_on
· simp only [MvPolynomial.derivation_C, map_zero]
· simp only [map_add, *]
· simp [*]
/-- `{ dx | x ∈ σ }` forms a basis of the relative differential module
of a polynomial algebra `R[σ]`. -/
def KaehlerDifferential.mvPolynomialBasis (σ) :
Basis σ (MvPolynomial σ R) Ω[MvPolynomial σ R⁄R] :=
⟨mvPolynomialEquiv R σ⟩
lemma KaehlerDifferential.mvPolynomialBasis_repr_comp_D (σ) :
(mvPolynomialBasis R σ).repr.toLinearMap.compDer (D _ _) =
MvPolynomial.mkDerivation _ (Finsupp.single · 1) :=
Derivation.liftKaehlerDifferential_comp _
lemma KaehlerDifferential.mvPolynomialBasis_repr_D (σ) (x) :
(mvPolynomialBasis R σ).repr (D _ _ x) =
MvPolynomial.mkDerivation R (Finsupp.single · (1 : MvPolynomial σ R)) x :=
Derivation.congr_fun (mvPolynomialBasis_repr_comp_D R σ) x
@[simp]
lemma KaehlerDifferential.mvPolynomialBasis_repr_D_X (σ) (i) :
(mvPolynomialBasis R σ).repr (D _ _ (.X i)) = Finsupp.single i 1 := by
simp [mvPolynomialBasis_repr_D]
@[simp]
lemma KaehlerDifferential.mvPolynomialBasis_repr_apply (σ) (x) (i) :
(mvPolynomialBasis R σ).repr (D _ _ x) i = MvPolynomial.pderiv i x := by
classical
suffices ((Finsupp.lapply i).comp
(mvPolynomialBasis R σ).repr.toLinearMap).compDer (D _ _) = MvPolynomial.pderiv i by
rw [← this]; rfl
apply MvPolynomial.derivation_ext
intro j
simp [Finsupp.single_apply, Pi.single_apply]
lemma KaehlerDifferential.mvPolynomialBasis_repr_symm_single (σ) (i) (x) :
(mvPolynomialBasis R σ).repr.symm (Finsupp.single i x) = x • D R (MvPolynomial σ R) (.X i) := by
apply (mvPolynomialBasis R σ).repr.injective; simp [LinearEquiv.map_smul, -map_smul]
@[simp]
lemma KaehlerDifferential.mvPolynomialBasis_apply (σ) (i) :
mvPolynomialBasis R σ i = D R (MvPolynomial σ R) (.X i) :=
(mvPolynomialBasis_repr_symm_single R σ i 1).trans (one_smul _ _)
instance (σ) : Module.Free (MvPolynomial σ R) Ω[MvPolynomial σ R⁄R] :=
.of_basis (KaehlerDifferential.mvPolynomialBasis R σ)
end MvPolynomial
section Polynomial
open Polynomial
lemma KaehlerDifferential.polynomial_D_apply (P : R[X]) :
D R R[X] P = derivative P • D R R[X] X := by
rw [← aeval_X_left_apply P, (D R R[X]).map_aeval, aeval_X_left_apply, aeval_X_left_apply]
/-- The relative differential module of the univariate polynomial algebra `R[X]` is isomorphic to
`R[X]` as an `R[X]`-module. -/
def KaehlerDifferential.polynomialEquiv : Ω[R[X]⁄R] ≃ₗ[R[X]] R[X] where
__ := derivative'.liftKaehlerDifferential
invFun := (Algebra.lsmul R R _).toLinearMap.flip (D R R[X] X)
left_inv := by
intro x
obtain ⟨x, rfl⟩ := linearCombination_surjective _ _ x
induction x using Finsupp.induction_linear with
| zero => simp
| add x y hx hy =>
simp only [map_add, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, LinearMap.flip_apply,
AlgHom.toLinearMap_apply, lsmul_coe] at *; simp only [*]
| single x y => simp [polynomial_D_apply _ x]
right_inv x := by simp
lemma KaehlerDifferential.polynomialEquiv_comp_D :
(polynomialEquiv R).compDer (D R R[X]) = derivative' :=
Derivation.liftKaehlerDifferential_comp _
@[simp]
lemma KaehlerDifferential.polynomialEquiv_D (P) :
polynomialEquiv R (D R R[X] P) = derivative P :=
Derivation.congr_fun (polynomialEquiv_comp_D R) P
@[simp]
lemma KaehlerDifferential.polynomialEquiv_symm (P) :
(polynomialEquiv R).symm P = P • D R R[X] X := rfl
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Perfectoid/Untilt.lean | import Mathlib.NumberTheory.Basic
import Mathlib.RingTheory.AdicCompletion.Basic
import Mathlib.RingTheory.Perfection
/-!
# Untilt Function
In this file, we define the untilt function from the pretilt of a
`p`-adically complete ring to the ring itself. Note that this
is not the untilt *functor*.
## Main definition
* `PreTilt.untilt` : Given a `p`-adically complete ring `O`, this is the
multiplicative map from `PreTilt O p` to `O` itself. Specifically, it is
defined as the limit of `p^n`-th powers of arbitrary lifts in `O` of the
`n`-th component from the perfection of `O/p`.
## Main theorem
* `PreTilt.mk_untilt_eq_coeff_zero` : The composition of the mod `p` map
with the untilt function equals taking the zeroth component of the perfection.
## Reference
* [Berkeley Lectures on \( p \)-adic Geometry][MR4446467]
## Tags
Perfectoid, Tilting equivalence, Untilt
-/
open Perfection Ideal
noncomputable section
variable {O : Type*} [CommRing O] {p : ℕ} [Fact (Nat.Prime p)] [Fact ¬IsUnit (p : O)]
namespace PreTilt
/--
The auxiliary sequence to define the untilt map. The `(n + 1)`-th term
is the `p^n`-th powers of arbitrary lifts in `O` of the `n`-th component
from the perfection of `O/p`.
-/
def untiltAux (x : PreTilt O p) (n : ℕ) : O :=
match n with
| 0 => 1
| n + 1 =>
(Quotient.out (coeff (ModP O p) _ n x)) ^ (p ^ n)
lemma pow_dvd_untiltAux_sub_untiltAux (x : PreTilt O p) {m n : ℕ} (h : m ≤ n) :
(p : O) ^ m ∣ x.untiltAux m - x.untiltAux n := by
cases m with
| zero => simp [untiltAux]
| succ m =>
let n' := n.pred
have : n = n' + 1 := by simp [n', Nat.sub_add_cancel (n := n) (m := 1) (by linarith)]
simp only [this, add_le_add_iff_right, untiltAux] at h ⊢
rw [← Nat.sub_add_cancel h, pow_add _ _ m, pow_mul]
refine (dvd_sub_pow_of_dvd_sub ?_ m)
rw [← mem_span_singleton, ← Ideal.Quotient.eq]
simp only [Ideal.Quotient.mk_out, map_pow, Nat.sub_add_cancel h]
calc
_ = (coeff (ModP O p) p (n' - (n' - m))) x := by simp [Nat.sub_sub_self h]
_ = (coeff (ModP O p) p n') (((frobenius (Ring.Perfection (ModP O p) p) p))^[n' - m] x) :=
(coeff_iterate_frobenius' x n' (n' - m) (Nat.sub_le n' m)).symm
_ = _ := by simp [iterate_frobenius]
lemma pow_dvd_one_untiltAux_sub_one (m : ℕ) :
(p : O) ^ m ∣ (1 : PreTilt O p).untiltAux m - 1 := by
cases m with
| zero => simp [untiltAux]
| succ m =>
simp only [untiltAux]
nth_rw 3 [← one_pow (p ^ m)]
refine dvd_sub_pow_of_dvd_sub (R := O) ?_ m
rw [← mem_span_singleton, ← Ideal.Quotient.eq]
simp
lemma pow_dvd_mul_untiltAux_sub_untiltAux_mul (x y : PreTilt O p) (m : ℕ) :
(p : O) ^ m ∣ (x * y).untiltAux m - (x.untiltAux m) * (y.untiltAux m) := by
cases m with
| zero => simp [untiltAux]
| succ m =>
simp only [untiltAux, map_mul, ← mul_pow]
refine dvd_sub_pow_of_dvd_sub ?_ m
rw [← mem_span_singleton, ← Ideal.Quotient.eq]
simp
section IsPrecomplete
variable [IsPrecomplete (span {(p : O)}) O]
lemma exists_smodEq_untiltAux (x : PreTilt O p) :
∃ y, ∀ (n : ℕ), x.untiltAux n ≡ y [SMOD Ideal.span {(p : O)} ^ n • (⊤ : Ideal O)] := by
refine IsPrecomplete.prec' x.untiltAux (fun {m n} h ↦ ?_)
simpa only [span_singleton_pow, smul_eq_mul, mul_top, SModEq.sub_mem,
mem_span_singleton] using x.pow_dvd_untiltAux_sub_untiltAux h
/--
Given a `p`-adically complete ring `O`, this is the underlying function of the untilt map.
It is defined as the limit of `p^n`-th powers of arbitrary lifts in `O` of the
`n`-th component from the perfection of `O/p`.
-/
def untiltFun (x : PreTilt O p) : O :=
Classical.choose <| x.exists_smodEq_untiltAux
lemma untiltAux_smodEq_untiltFun (x : PreTilt O p) (n : ℕ) :
x.untiltAux n ≡ x.untiltFun [SMOD (span {(p : O)}) ^ n] := by
simpa [untiltFun] using Classical.choose_spec x.exists_smodEq_untiltAux n
end IsPrecomplete
section IsAdicComplete
variable [IsAdicComplete (span {(p : O)}) O]
/--
Given a `p`-adically complete ring `O`, this is the
multiplicative map from `PreTilt O p` to `O` itself. Specifically, it is
defined as the limit of `p^n`-th powers of arbitrary lifts in `O` of the
`n`-th component from the perfection of `O/p`.
-/
def untilt : PreTilt O p →* O where
toFun := untiltFun
map_one' := by
rw [← sub_eq_zero, IsHausdorff.eq_iff_smodEq (I := (span {(p : O)}))]
intro n
rw [sub_smodEq_zero]
simp only [smul_eq_mul, mul_top]
apply (untiltAux_smodEq_untiltFun (1 : PreTilt O p) n).symm.trans
simp only [span_singleton_pow, SModEq.sub_mem, mem_span_singleton]
exact pow_dvd_one_untiltAux_sub_one (O := O) (p := p) n
map_mul' _ _ := by
rw [← sub_eq_zero, IsHausdorff.eq_iff_smodEq (I := (span {(p : O)}))]
intro n
rw [sub_smodEq_zero]
simp only [smul_eq_mul, mul_top]
apply (untiltAux_smodEq_untiltFun _ n).symm.trans
refine SModEq.trans ?_ (SModEq.mul (untiltAux_smodEq_untiltFun _ n)
(untiltAux_smodEq_untiltFun _ n))
simp only [span_singleton_pow, SModEq.sub_mem, mem_span_singleton]
exact pow_dvd_mul_untiltAux_sub_untiltAux_mul (O := O) (p := p) _ _ n
/--
The composition of the mod `p` map
with the untilt function equals taking the zeroth component of the perfection.
-/
@[simp]
theorem mk_untilt_eq_coeff_zero (x : PreTilt O p) :
Ideal.Quotient.mk (Ideal.span {(p : O)}) (x.untilt) = coeff (ModP O p) p 0 x := by
simp only [untilt]
rw [← Ideal.Quotient.mk_out ((coeff (ModP O p) p 0) x), Ideal.Quotient.eq, ← SModEq.sub_mem]
simpa [untiltAux] using (x.untiltAux_smodEq_untiltFun 1).symm
/--
The composition of the mod `p` map
with the untilt function equals taking the zeroth component of the perfection.
A variation of `PreTilt.mk_untilt_eq_coeff_zero`.
-/
@[simp]
theorem mk_comp_untilt_eq_coeff_zero :
Ideal.Quotient.mk (Ideal.span {(p : O)}) ∘ untilt = coeff (ModP O p) p 0 :=
funext mk_untilt_eq_coeff_zero
@[simp]
theorem untilt_iterate_frobeniusEquiv_symm_pow (x : PreTilt O p) (n : ℕ) :
untilt (((frobeniusEquiv (PreTilt O p) p).symm ^[n]) x) ^ p ^ n = x.untilt := by
simp only [← map_pow]
congr
simp
end IsAdicComplete
end PreTilt
end |
.lake/packages/mathlib/Mathlib/RingTheory/Invariant/Basic.lean | import Mathlib.RingTheory.Invariant.Defs
import Mathlib.RingTheory.IntegralClosure.IntegralRestrict
/-!
# Invariant Extensions of Rings
Given an extension of rings `B/A` and an action of `G` on `B`, we introduce a predicate
`Algebra.IsInvariant A B G` which states that every fixed point of `B` lies in the image of `A`.
The main application is in algebraic number theory, where `G := Gal(L/K)` is the Galois group
of some finite Galois extension of number fields, and `A := 𝓞K` and `B := 𝓞L` are their ring of
integers. This main result in this file implies the existence of Frobenius elements in this setting.
See `Mathlib/RingTheory/Frobenius.lean`.
## Main statements
Let `G` be a finite group acting on a commutative ring `B` satisfying `Algebra.IsInvariant A B G`.
* `Algebra.IsInvariant.isIntegral`: `B/A` is an integral extension.
* `Algebra.IsInvariant.exists_smul_of_under_eq`: `G` acts transitivity on the prime ideals of `B`
lying above a given prime ideal of `A`.
If `Q` is a prime ideal of `B` lying over a prime ideal `P` of `A`, then
* `IsFractionRing.stabilizerHom_surjective`:
The stabilizer subgroup of `Q` surjects onto `Aut(Frac(B/Q)/Frac(A/P))`.
* `Ideal.Quotient.stabilizerHom_surjective`:
The stabilizer subgroup of `Q` surjects onto `Aut((B/Q)/(A/P))`.
* `Ideal.Quotient.exists_algEquiv_fixedPoint_quotient_under`:
If `k` is a domain containing `B/Q`, then any `A/P`-algebra automorphism of `k` restricts to
an automorphism of `B/Q`.
-/
open scoped Pointwise
section Galois
variable (A K L B : Type*) [CommRing A] [CommRing B] [Field K] [Field L]
[Algebra A K] [Algebra B L] [IsFractionRing A K] [IsFractionRing B L]
[Algebra A B] [Algebra K L] [Algebra A L] [IsScalarTower A K L] [IsScalarTower A B L]
[IsIntegrallyClosed A] [IsIntegralClosure B A L]
/-- In the AKLB setup, the Galois group of `L/K` acts on `B`. -/
noncomputable def IsIntegralClosure.MulSemiringAction [Algebra.IsAlgebraic K L] :
MulSemiringAction Gal(L/K) B :=
MulSemiringAction.compHom B (galRestrict A K L B).toMonoidHom
instance [Algebra.IsAlgebraic K L] : let := IsIntegralClosure.MulSemiringAction A K L B
SMulDistribClass Gal(L/K) B L :=
let := IsIntegralClosure.MulSemiringAction A K L B
⟨fun g b l ↦ by
simp only [Algebra.smul_def, smul_mul', mul_eq_mul_right_iff]
exact Or.inl (algebraMap_galRestrictHom_apply A K L B g b).symm⟩
/-- In the AKLB setup, every fixed point of `B` lies in the image of `A`. -/
theorem Algebra.isInvariant_of_isGalois [FiniteDimensional K L] [h : IsGalois K L] :
letI := IsIntegralClosure.MulSemiringAction A K L B
Algebra.IsInvariant A B Gal(L/K) := by
replace h := ((IsGalois.tfae (F := K) (E := L)).out 0 1).mp h
letI := IsIntegralClosure.MulSemiringAction A K L B
refine ⟨fun b hb ↦ ?_⟩
replace hb : algebraMap B L b ∈ IntermediateField.fixedField (⊤ : Subgroup Gal(L/K)) := by
rintro ⟨g, -⟩
exact (algebraMap_galRestrict_apply A g b).symm.trans (congrArg (algebraMap B L) (hb g))
rw [h, IntermediateField.mem_bot] at hb
obtain ⟨k, hk⟩ := hb
have hb : IsIntegral A b := IsIntegralClosure.isIntegral A L b
rw [← isIntegral_algebraMap_iff (FaithfulSMul.algebraMap_injective B L), ← hk,
isIntegral_algebraMap_iff (FaithfulSMul.algebraMap_injective K L)] at hb
obtain ⟨a, rfl⟩ := IsIntegrallyClosed.algebraMap_eq_of_integral hb
rw [← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply A B L,
(FaithfulSMul.algebraMap_injective B L).eq_iff] at hk
exact ⟨a, hk⟩
/-- A variant of `Algebra.isInvariant_of_isGalois`, replacing `Gal(L/K)` by `Aut(B/A)`. -/
theorem Algebra.isInvariant_of_isGalois' [FiniteDimensional K L] [IsGalois K L] :
Algebra.IsInvariant A B (B ≃ₐ[A] B) :=
⟨fun b h ↦ (isInvariant_of_isGalois A K L B).1 b (fun g ↦ h (galRestrict A K L B g))⟩
end Galois
section Quotient
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
variable {G : Type*} [Group G] [MulSemiringAction G B] [SMulCommClass G A B]
instance (H : Subgroup G) [H.Normal] :
MulSemiringAction (G ⧸ H) (FixedPoints.subring B H) where
smul := Quotient.lift (fun g x ↦ ⟨g • x, fun h ↦ by
simpa [mul_smul] using congr(g • $(x.2 ⟨_, ‹H.Normal›.conj_mem' _ h.2 g⟩))⟩) (by
rintro _ a ⟨⟨⟨b⟩, hb⟩, rfl⟩
ext c
simpa [mul_smul] using congr(a • $(c.2 ⟨b, hb⟩)))
one_smul b := Subtype.ext (one_smul G b.1)
mul_smul := Quotient.ind₂ fun _ _ _ ↦ Subtype.ext (mul_smul _ _ _)
smul_zero := Quotient.ind fun _ ↦ Subtype.ext (smul_zero _)
smul_add := Quotient.ind fun _ _ _ ↦ Subtype.ext (smul_add _ _ _)
smul_one := Quotient.ind fun _ ↦ Subtype.ext (smul_one _)
smul_mul := Quotient.ind fun _ _ _ ↦ Subtype.ext (MulSemiringAction.smul_mul _ _ _)
instance (H : Subgroup G) [H.Normal] :
MulSemiringAction (G ⧸ H) (FixedPoints.subalgebra A B H) :=
inferInstanceAs (MulSemiringAction (G ⧸ H) (FixedPoints.subring B H))
instance (H : Subgroup G) [H.Normal] :
SMulCommClass (G ⧸ H) A (FixedPoints.subalgebra A B H) where
smul_comm := Quotient.ind fun g r h ↦ Subtype.ext (smul_comm g r h.1)
instance (H : Subgroup G) [H.Normal] [Algebra.IsInvariant A B G] :
Algebra.IsInvariant A (FixedPoints.subalgebra A B H) (G ⧸ H) where
isInvariant x hx := by
obtain ⟨y, hy⟩ := Algebra.IsInvariant.isInvariant (A := A) (G := G) x.1
(fun g ↦ congr_arg Subtype.val (hx g))
exact ⟨y, Subtype.ext hy⟩
end Quotient
section transitivity
variable (A B G : Type*) [CommRing A] [CommRing B] [Algebra A B] [Group G] [MulSemiringAction G B]
namespace MulSemiringAction
open Polynomial
variable {B} [Fintype G]
/-- Characteristic polynomial of a finite group action on a ring. -/
noncomputable def charpoly (b : B) : B[X] := ∏ g : G, (X - C (g • b))
theorem charpoly_eq (b : B) : charpoly G b = ∏ g : G, (X - C (g • b)) := rfl
theorem charpoly_eq_prod_smul (b : B) : charpoly G b = ∏ g : G, g • (X - C b) := by
simp only [smul_sub, smul_C, smul_X, charpoly_eq]
theorem monic_charpoly (b : B) : (charpoly G b).Monic :=
monic_prod_of_monic _ _ (fun _ _ ↦ monic_X_sub_C _)
theorem eval_charpoly (b : B) : (charpoly G b).eval b = 0 := by
rw [charpoly_eq, eval_prod]
apply Finset.prod_eq_zero (Finset.mem_univ (1 : G))
rw [one_smul, eval_sub, eval_C, eval_X, sub_self]
variable {G}
theorem smul_charpoly (b : B) (g : G) : g • (charpoly G b) = charpoly G b := by
rw [charpoly_eq_prod_smul, Finset.smul_prod_perm]
theorem smul_coeff_charpoly (b : B) (n : ℕ) (g : G) :
g • (charpoly G b).coeff n = (charpoly G b).coeff n := by
rw [← coeff_smul, smul_charpoly]
end MulSemiringAction
namespace Algebra.IsInvariant
open MulSemiringAction Polynomial
variable [IsInvariant A B G]
theorem charpoly_mem_lifts [Fintype G] (b : B) :
charpoly G b ∈ Polynomial.lifts (algebraMap A B) :=
(charpoly G b).lifts_iff_coeff_lifts.mpr fun n ↦ isInvariant _ (smul_coeff_charpoly b n)
theorem isIntegral [Finite G] : Algebra.IsIntegral A B := by
cases nonempty_fintype G
refine ⟨fun b ↦ ?_⟩
obtain ⟨p, hp1, -, hp2⟩ := Polynomial.lifts_and_natDegree_eq_and_monic
(charpoly_mem_lifts A B G b) (monic_charpoly G b)
exact ⟨p, hp2, by rw [← eval_map, hp1, eval_charpoly]⟩
/-- `G` acts transitively on the prime ideals of `B` above a given prime ideal of `A`. -/
theorem exists_smul_of_under_eq [Finite G] [SMulCommClass G A B]
(P Q : Ideal B) [hP : P.IsPrime] [hQ : Q.IsPrime]
(hPQ : P.under A = Q.under A) :
∃ g : G, Q = g • P := by
cases nonempty_fintype G
have : ∀ (P Q : Ideal B) [P.IsPrime] [Q.IsPrime], P.under A = Q.under A →
∃ g ∈ (⊤ : Finset G), Q ≤ g • P := by
intro P Q hP hQ hPQ
rw [← Ideal.subset_union_prime 1 1 (fun _ _ _ _ ↦ hP.smul _)]
intro b hb
suffices h : ∃ g ∈ Finset.univ, g • b ∈ P by
obtain ⟨g, -, hg⟩ := h
apply Set.mem_biUnion (Finset.mem_univ g⁻¹) (Ideal.mem_inv_pointwise_smul_iff.mpr hg)
obtain ⟨a, ha⟩ := isInvariant (A := A) (∏ g : G, g • b) (Finset.smul_prod_perm b)
rw [← hP.prod_mem_iff, ← ha, ← P.mem_comap, ← P.under_def A,
hPQ, Q.mem_comap, ha, hQ.prod_mem_iff]
exact ⟨1, Finset.mem_univ 1, (one_smul G b).symm ▸ hb⟩
obtain ⟨g, -, hg⟩ := this P Q hPQ
obtain ⟨g', -, hg'⟩ := this Q (g • P) ((P.under_smul A g).trans hPQ).symm
exact ⟨g, le_antisymm hg (smul_eq_of_le_smul (hg.trans hg') ▸ hg')⟩
theorem orbit_eq_primesOver [Finite G] [SMulCommClass G A B] (P : Ideal A) (Q : Ideal B)
[hP : Q.LiesOver P] [hQ : Q.IsPrime] : MulAction.orbit G Q = P.primesOver B := by
refine Set.ext fun R ↦ ⟨fun ⟨g, hg⟩ ↦ hg ▸ ⟨hQ.smul g, hP.smul g⟩, fun h ↦ ?_⟩
have : R.IsPrime := h.1
obtain ⟨g, hg⟩ := exists_smul_of_under_eq A B G Q R (hP.over.symm.trans h.2.over)
exact ⟨g, hg.symm⟩
end Algebra.IsInvariant
end transitivity
section surjectivity
open FaithfulSMul IsScalarTower Polynomial
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
(G : Type*) [Group G] [Finite G] [MulSemiringAction G B] [SMulCommClass G A B]
(P : Ideal A) (Q : Ideal B) [Q.IsPrime] [Q.LiesOver P]
variable (K L : Type*) [Field K] [Field L]
[Algebra (A ⧸ P) K] [Algebra (B ⧸ Q) L]
[Algebra (A ⧸ P) L] [IsScalarTower (A ⧸ P) (B ⧸ Q) L]
[Algebra K L] [IsScalarTower (A ⧸ P) K L]
[Algebra.IsInvariant A B G]
/-- A technical lemma for `fixed_of_fixed1`. -/
private theorem fixed_of_fixed1_aux1 [DecidableEq (Ideal B)] :
∃ a b : B, (∀ g : G, g • a = a) ∧ a ∉ Q ∧
∀ g : G, algebraMap B (B ⧸ Q) (g • b) = algebraMap B (B ⧸ Q) (if g • Q = Q then a else 0) := by
obtain ⟨_⟩ := nonempty_fintype G
let P := Finset.inf {g : G | g • Q ≠ Q} (fun g ↦ g • Q)
have h1 : ¬ P ≤ Q := by
rw [Ideal.IsPrime.inf_le' inferInstance]
rintro ⟨g, hg1, hg2⟩
exact (Finset.mem_filter.mp hg1).2 (smul_eq_of_smul_le hg2)
obtain ⟨b, hbP, hbQ⟩ := SetLike.not_le_iff_exists.mp h1
replace hbP : ∀ g : G, g • Q ≠ Q → b ∈ g • Q :=
fun g hg ↦ (Finset.inf_le (Finset.mem_filter.mpr ⟨Finset.mem_univ g, hg⟩) : P ≤ g • Q) hbP
let f := MulSemiringAction.charpoly G b
obtain ⟨q, hq, hq0⟩ :=
(f.map (algebraMap B (B ⧸ Q))).exists_eq_pow_rootMultiplicity_mul_and_not_dvd
(Polynomial.map_monic_ne_zero (MulSemiringAction.monic_charpoly G b)) 0
rw [map_zero, sub_zero] at hq hq0
let j := (f.map (algebraMap B (B ⧸ Q))).rootMultiplicity 0
let k := q.natDegree
let r := ∑ i ∈ Finset.range (k + 1), Polynomial.monomial i (f.coeff (i + j))
have hr : r.map (algebraMap B (B ⧸ Q)) = q := by
ext n
rw [Polynomial.coeff_map, Polynomial.finset_sum_coeff]
simp only [Polynomial.coeff_monomial, Finset.sum_ite_eq', Finset.mem_range_succ_iff]
split_ifs with hn
· rw [← Polynomial.coeff_map, hq, Polynomial.coeff_X_pow_mul]
· rw [map_zero, eq_comm, Polynomial.coeff_eq_zero_of_natDegree_lt (lt_of_not_ge hn)]
have hf : f.eval b = 0 := MulSemiringAction.eval_charpoly G b
have hr : r.eval b ∈ Q := by
rw [← Ideal.Quotient.eq_zero_iff_mem, ← Ideal.Quotient.algebraMap_eq] at hbQ ⊢
replace hf := congrArg (algebraMap B (B ⧸ Q)) hf
rw [← Polynomial.eval₂_at_apply, ← Polynomial.eval_map] at hf ⊢
rwa [map_zero, hq, ← hr, Polynomial.eval_mul, Polynomial.eval_pow, Polynomial.eval_X,
mul_eq_zero, or_iff_right (pow_ne_zero _ hbQ)] at hf
let a := f.coeff j
have ha : ∀ g : G, g • a = a := MulSemiringAction.smul_coeff_charpoly b j
have hr' : ∀ g : G, g • Q ≠ Q → a - r.eval b ∈ g • Q := by
intro g hg
have hr : r = ∑ i ∈ Finset.range (k + 1), Polynomial.monomial i (f.coeff (i + j)) := rfl
rw [← Ideal.neg_mem_iff, neg_sub, hr, Finset.sum_range_succ', Polynomial.eval_add,
Polynomial.eval_monomial, zero_add, pow_zero, mul_one, add_sub_cancel_right]
simp only [← Polynomial.monomial_mul_X]
rw [← Finset.sum_mul, Polynomial.eval_mul_X]
exact Ideal.mul_mem_left (g • Q) _ (hbP g hg)
refine ⟨a, a - r.eval b, ha, ?_, fun h ↦ ?_⟩
· rwa [← Ideal.Quotient.eq_zero_iff_mem, ← Ideal.Quotient.algebraMap_eq, ← Polynomial.coeff_map,
← zero_add j, hq, Polynomial.coeff_X_pow_mul, ← Polynomial.X_dvd_iff]
· rw [← sub_eq_zero, ← map_sub, Ideal.Quotient.algebraMap_eq, Ideal.Quotient.eq_zero_iff_mem,
← Ideal.smul_mem_pointwise_smul_iff (a := h⁻¹), smul_sub, inv_smul_smul]
simp only [← eq_inv_smul_iff (g := h), eq_comm (a := Q)]
split_ifs with hh
· rwa [ha, sub_sub_cancel_left, hh, Q.neg_mem_iff]
· rw [smul_zero, sub_zero]
exact hr' h⁻¹ hh
/-- A technical lemma for `fixed_of_fixed1`. -/
private theorem fixed_of_fixed1_aux2 [DecidableEq (Ideal B)] (b₀ : B)
(hx : ∀ g : G, g • Q = Q → algebraMap B (B ⧸ Q) (g • b₀) = algebraMap B (B ⧸ Q) b₀) :
∃ a b : B, (∀ g : G, g • a = a) ∧ a ∉ Q ∧
(∀ g : G, algebraMap B (B ⧸ Q) (g • b) =
algebraMap B (B ⧸ Q) (if g • Q = Q then a * b₀ else 0)) := by
obtain ⟨a, b, ha1, ha2, hb⟩ := fixed_of_fixed1_aux1 G Q
refine ⟨a, b * b₀, ha1, ha2, fun g ↦ ?_⟩
rw [smul_mul', map_mul, hb]
specialize hb g
split_ifs with hg
· rw [map_mul, hx g hg]
· rw [map_zero, zero_mul]
/-- A technical lemma for `fixed_of_fixed1`. -/
private theorem fixed_of_fixed1_aux3 [NoZeroDivisors B] {b : B} {i j : ℕ} {p : Polynomial A}
(h : p.map (algebraMap A B) = (X - C b) ^ i * X ^ j) (f : B ≃ₐ[A] B) (hi : i ≠ 0) :
f b = b := by
by_cases ha : b = 0
· rw [ha, map_zero]
have hf := congrArg (eval b) (congrArg (Polynomial.mapAlgHom f.toAlgHom) h)
rw [coe_mapAlgHom, map_map, f.toAlgHom.comp_algebraMap, h] at hf
simp_rw [Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_sub, map_X, map_C,
eval_mul, eval_pow, eval_sub, eval_X, eval_C, sub_self, zero_pow hi, zero_mul,
zero_eq_mul, or_iff_left (pow_ne_zero j ha), pow_eq_zero_iff hi, sub_eq_zero] at hf
exact hf.symm
/-- This theorem will be made redundant by `IsFractionRing.stabilizerHom_surjective`. -/
private theorem fixed_of_fixed1 [NoZeroSMulDivisors (B ⧸ Q) L] (f : Gal(L/K)) (b : B ⧸ Q)
(hx : ∀ g : MulAction.stabilizer G Q, Ideal.Quotient.stabilizerHom Q P G g b = b) :
f (algebraMap (B ⧸ Q) L b) = (algebraMap (B ⧸ Q) L b) := by
classical
cases nonempty_fintype G
obtain ⟨b₀, rfl⟩ := Ideal.Quotient.mk_surjective b
rw [← Ideal.Quotient.algebraMap_eq]
obtain ⟨a, b, ha1, ha2, hb⟩ := fixed_of_fixed1_aux2 G Q b₀ (fun g hg ↦ hx ⟨g, hg⟩)
obtain ⟨M, key⟩ := (mem_lifts _).mp (Algebra.IsInvariant.charpoly_mem_lifts A B G b)
replace key := congrArg (map (algebraMap B (B ⧸ Q))) key
rw [map_map, ← algebraMap_eq, algebraMap_eq A (A ⧸ P) (B ⧸ Q),
← map_map, MulSemiringAction.charpoly, Polynomial.map_prod] at key
have key₀ : ∀ g : G, (X - C (g • b)).map (algebraMap B (B ⧸ Q)) =
if g • Q = Q then X - C (algebraMap B (B ⧸ Q) (a * b₀)) else X := by
intro g
rw [Polynomial.map_sub, map_X, map_C, hb]
split_ifs
· rfl
· rw [map_zero, map_zero, sub_zero]
simp only [key₀, Finset.prod_ite, Finset.prod_const] at key
replace key := congrArg (map (algebraMap (B ⧸ Q) L)) key
rw [map_map, ← algebraMap_eq, algebraMap_eq (A ⧸ P) K L,
← map_map, Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_pow, Polynomial.map_sub,
map_X, map_C] at key
replace key := fixed_of_fixed1_aux3 key f (Finset.card_ne_zero_of_mem
(Finset.mem_filter.mpr ⟨Finset.mem_univ 1, one_smul G Q⟩))
simp only [map_mul] at key
obtain ⟨a, rfl⟩ := Algebra.IsInvariant.isInvariant (A := A) a ha1
rwa [← algebraMap_apply A B (B ⧸ Q), algebraMap_apply A (A ⧸ P) (B ⧸ Q),
← algebraMap_apply, algebraMap_apply (A ⧸ P) K L, f.commutes, mul_right_inj'] at key
rwa [← algebraMap_apply, algebraMap_apply (A ⧸ P) (B ⧸ Q) L,
← algebraMap_apply A (A ⧸ P) (B ⧸ Q), algebraMap_apply A B (B ⧸ Q),
Ne, algebraMap_eq_zero_iff, Ideal.Quotient.algebraMap_eq, Ideal.Quotient.eq_zero_iff_mem]
variable [IsFractionRing (A ⧸ P) K] [IsFractionRing (B ⧸ Q) L]
/-- If `Q` lies over `P`, then the stabilizer of `Q` acts on `Frac(B/Q)/Frac(A/P)`. -/
noncomputable def IsFractionRing.stabilizerHom : MulAction.stabilizer G Q →* Gal(L/K) :=
MonoidHom.comp (IsFractionRing.fieldEquivOfAlgEquivHom K L) (Ideal.Quotient.stabilizerHom Q P G)
/-- This theorem will be made redundant by `IsFractionRing.stabilizerHom_surjective`. -/
private theorem fixed_of_fixed2 (f : Gal(L/K)) (x : L)
(hx : ∀ g : MulAction.stabilizer G Q, IsFractionRing.stabilizerHom G P Q K L g x = x) :
f x = x := by
obtain ⟨_⟩ := nonempty_fintype G
have : P.IsPrime := Ideal.over_def Q P ▸ Ideal.IsPrime.under A Q
have : Algebra.IsIntegral A B := Algebra.IsInvariant.isIntegral A B G
obtain ⟨x, y, hy, rfl⟩ := IsFractionRing.div_surjective (A := B ⧸ Q) x
obtain ⟨b, a, ha, h⟩ := (Algebra.IsAlgebraic.isAlgebraic (R := A ⧸ P) y).exists_smul_eq_mul x hy
replace ha : algebraMap (A ⧸ P) L a ≠ 0 := by
rwa [Ne, algebraMap_apply (A ⧸ P) K L, algebraMap_eq_zero_iff, algebraMap_eq_zero_iff]
replace hy : algebraMap (B ⧸ Q) L y ≠ 0 :=
mt (algebraMap_eq_zero_iff (B ⧸ Q) L).mp (nonZeroDivisors.ne_zero hy)
replace h : algebraMap (B ⧸ Q) L x / algebraMap (B ⧸ Q) L y =
algebraMap (B ⧸ Q) L b / algebraMap (A ⧸ P) L a := by
rw [mul_comm, Algebra.smul_def, mul_comm] at h
rw [div_eq_div_iff hy ha, ← map_mul, ← h, map_mul, ← algebraMap_apply]
simp only [h, map_div₀, algebraMap_apply (A ⧸ P) K L, AlgEquiv.commutes] at hx ⊢
simp only [← algebraMap_apply, div_left_inj' ha] at hx ⊢
exact fixed_of_fixed1 G P Q K L f b (fun g ↦ IsFractionRing.injective (B ⧸ Q) L
((IsFractionRing.fieldEquivOfAlgEquiv_algebraMap K L L
(Ideal.Quotient.stabilizerHom Q P G g) b).symm.trans (hx g)))
/-- The stabilizer subgroup of `Q` surjects onto `Aut(Frac(B/Q)/Frac(A/P))`. -/
theorem IsFractionRing.stabilizerHom_surjective :
Function.Surjective (stabilizerHom G P Q K L) := by
let _ := MulSemiringAction.compHom L (stabilizerHom G P Q K L)
intro f
obtain ⟨g, hg⟩ := FixedPoints.toAlgAut_surjective (MulAction.stabilizer G Q) L
(AlgEquiv.ofRingEquiv (f := f) (fun x ↦ fixed_of_fixed2 G P Q K L f x x.2))
exact ⟨g, by rwa [AlgEquiv.ext_iff] at hg ⊢⟩
/-- The stabilizer subgroup of `Q` surjects onto `Aut((B/Q)/(A/P))`. -/
theorem Ideal.Quotient.stabilizerHom_surjective :
Function.Surjective (Ideal.Quotient.stabilizerHom Q P G) := by
have : P.IsPrime := Ideal.over_def Q P ▸ Ideal.IsPrime.under A Q
let _ := FractionRing.liftAlgebra (A ⧸ P) (FractionRing (B ⧸ Q))
have key := IsFractionRing.stabilizerHom_surjective G P Q
(FractionRing (A ⧸ P)) (FractionRing (B ⧸ Q))
rw [IsFractionRing.stabilizerHom, MonoidHom.coe_comp] at key
exact key.of_comp_left (IsFractionRing.fieldEquivOfAlgEquivHom_injective (A ⧸ P) (B ⧸ Q)
(FractionRing (A ⧸ P)) (FractionRing (B ⧸ Q)))
end surjectivity
section normal
variable {A B k : Type*} [CommRing A] [CommRing B] [Algebra A B]
(G : Type*) [Finite G] [Group G] [MulSemiringAction G B] [Algebra.IsInvariant A B G]
(P : Ideal A) (Q : Ideal B) [Q.LiesOver P]
[CommRing k] [Algebra (A ⧸ P) k] [Algebra (B ⧸ Q) k] [IsScalarTower (A ⧸ P) (B ⧸ Q) k]
[IsDomain k] [FaithfulSMul (B ⧸ Q) k]
include G in
/--
For any domain `k` containing `B ⧸ Q`,
any endomorphism of `k` can be restricted to an endomorphism of `B ⧸ Q`.
This is basically the fact that `L/K` normal implies `κ(Q)/κ(P)` normal in the Galois setting.
-/
lemma Ideal.Quotient.exists_algHom_fixedPoint_quotient_under
(σ : k →ₐ[A ⧸ P] k) :
∃ τ : (B ⧸ Q) →ₐ[A ⧸ P] B ⧸ Q, ∀ x : B ⧸ Q,
algebraMap _ _ (τ x) = σ (algebraMap (B ⧸ Q) k x) := by
let f : (B ⧸ Q) →ₐ[A ⧸ P] k := IsScalarTower.toAlgHom _ _ _
have hf : Function.Injective f := FaithfulSMul.algebraMap_injective _ _
suffices (σ.comp f).range ≤ f.range by
let e := (AlgEquiv.ofInjective f hf)
exact ⟨(e.symm.toAlgHom.comp (Subalgebra.inclusion this)).comp (σ.comp f).rangeRestrict,
fun x ↦ congr_arg Subtype.val (e.apply_symm_apply ⟨_, _⟩)⟩
rintro _ ⟨x, rfl⟩
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
cases nonempty_fintype G
algebraize [(algebraMap (A ⧸ P) k).comp (algebraMap A (A ⧸ P)),
(algebraMap (B ⧸ Q) k).comp (algebraMap B (B ⧸ Q))]
haveI : IsScalarTower A (B ⧸ Q) k := .of_algebraMap_eq fun x ↦
(IsScalarTower.algebraMap_apply (A ⧸ P) (B ⧸ Q) k (mk P x))
haveI : IsScalarTower A B k := .of_algebraMap_eq fun x ↦
(IsScalarTower.algebraMap_apply (A ⧸ P) (B ⧸ Q) k (mk P x))
obtain ⟨P, hp⟩ := Algebra.IsInvariant.charpoly_mem_lifts A B G x
have : Polynomial.aeval x P = 0 := by
rw [Polynomial.aeval_def, ← Polynomial.eval_map,
← Polynomial.coe_mapRingHom (R := A), hp, MulSemiringAction.eval_charpoly]
have : Polynomial.aeval (σ (algebraMap (B ⧸ Q) k (mk _ x))) P = 0 := by
refine (DFunLike.congr_fun (Polynomial.aeval_algHom ((σ.restrictScalars A).comp
(IsScalarTower.toAlgHom A (B ⧸ Q) k)) _) P).trans ?_
rw [AlgHom.comp_apply, ← algebraMap_eq, Polynomial.aeval_algebraMap_apply, this,
map_zero, map_zero]
rw [← Polynomial.aeval_map_algebraMap B, ← Polynomial.coe_mapRingHom, hp] at this
obtain ⟨τ, hτ⟩ : ∃ τ : G, σ (algebraMap _ _ x) = algebraMap _ _ (τ • x) := by
simpa [MulSemiringAction.charpoly, sub_eq_zero, Finset.prod_eq_zero_iff] using this
exact ⟨Ideal.Quotient.mk _ (τ • x), hτ.symm⟩
include G in
/--
For any domain `k` containing `B ⧸ Q`,
any endomorphism of `k` can be restricted to an endomorphism of `B ⧸ Q`.
-/
lemma Ideal.Quotient.exists_algEquiv_fixedPoint_quotient_under
(σ : k ≃ₐ[A ⧸ P] k) :
∃ τ : (B ⧸ Q) ≃ₐ[A ⧸ P] B ⧸ Q, ∀ x : B ⧸ Q,
algebraMap _ _ (τ x) = σ (algebraMap (B ⧸ Q) k x) := by
let f : (B ⧸ Q) →ₐ[A ⧸ P] k := IsScalarTower.toAlgHom _ _ _
have hf : Function.Injective f := FaithfulSMul.algebraMap_injective _ _
obtain ⟨τ₁, h₁⟩ := Ideal.Quotient.exists_algHom_fixedPoint_quotient_under G P Q σ.toAlgHom
obtain ⟨τ₂, h₂⟩ := Ideal.Quotient.exists_algHom_fixedPoint_quotient_under G P Q σ.symm.toAlgHom
refine ⟨{ __ := τ₁, invFun := τ₂, left_inv := ?_, right_inv := ?_ }, h₁⟩
· intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨y, e⟩ := Ideal.Quotient.mk_surjective (τ₁ (Ideal.Quotient.mk Q x))
apply hf
dsimp [f] at h₁ h₂ ⊢
refine .trans ?_ (σ.symm_apply_apply _)
rw [← h₁, ← e, h₂]
· intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨y, e⟩ := Ideal.Quotient.mk_surjective (τ₂ (Ideal.Quotient.mk Q x))
apply hf
dsimp [f] at h₁ h₂ ⊢
refine .trans ?_ (σ.apply_symm_apply _)
rw [← h₂, ← e, h₁]
attribute [local instance] Ideal.Quotient.field in
include G in
/--
For any domain `k` containing `B ⧸ Q`,
any endomorphism of `k` can be restricted to an endomorphism of `B ⧸ Q`. -/
lemma Ideal.Quotient.normal [P.IsMaximal] [Q.IsMaximal] :
Normal (A ⧸ P) (B ⧸ Q) := by
cases subsingleton_or_nontrivial B
· cases ‹Q.IsMaximal›.ne_top (Subsingleton.elim _ _)
have := Algebra.IsInvariant.isIntegral A B G
constructor
intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
cases nonempty_fintype G
obtain ⟨p, hp, h₁, h₂⟩ := Polynomial.lifts_and_degree_eq_and_monic
(Algebra.IsInvariant.charpoly_mem_lifts A B G x) (MulSemiringAction.monic_charpoly _ _)
have H : Polynomial.aeval x p = 0 := by
rw [Polynomial.aeval_def, ← Polynomial.eval_map, hp, MulSemiringAction.eval_charpoly]
have := minpoly.dvd _ (algebraMap _ (B ⧸ Q) x) (p := p.map (algebraMap _ (A ⧸ P)))
(by rw [Polynomial.aeval_map_algebraMap, Polynomial.aeval_algebraMap_apply, H, map_zero])
refine Polynomial.splits_of_splits_of_dvd (algebraMap (A ⧸ P) (B ⧸ Q)) ?_ ?_ this
· exact (h₂.map (algebraMap A (A ⧸ P))).ne_zero
· rw [Polynomial.splits_map_iff, ← IsScalarTower.algebraMap_eq, IsScalarTower.algebraMap_eq A B,
← Polynomial.splits_map_iff, hp, MulSemiringAction.charpoly_eq]
exact Polynomial.splits_prod _ (fun _ _ ↦ Polynomial.splits_X_sub_C _)
attribute [local instance] Ideal.Quotient.field in
include G in
/-- If the extension `B/Q` over `A/P` is separable, then it is finite dimensional. -/
lemma Ideal.Quotient.finite_of_isInvariant [P.IsMaximal] [Q.IsMaximal]
[SMulCommClass G A B] [Algebra.IsSeparable (A ⧸ P) (B ⧸ Q)] :
Module.Finite (A ⧸ P) (B ⧸ Q) := by
have : IsGalois (A ⧸ P) (B ⧸ Q) := { __ := Ideal.Quotient.normal (A := A) G P Q }
have := Finite.of_surjective _ (Ideal.Quotient.stabilizerHom_surjective G P Q)
exact IsGalois.finiteDimensional_of_finite _ _
end normal |
.lake/packages/mathlib/Mathlib/RingTheory/Invariant/Defs.lean | import Mathlib.Algebra.Algebra.Defs
/-!
# Invariant Extensions of Rings
Given an extension of rings `B/A` and an action of `G` on `B`, we introduce a predicate
`Algebra.IsInvariant A B G` which states that every fixed point of `B` lies in the image of `A`.
The main application is in algebraic number theory, where `G := Gal(L/K)` is the Galois group
of some finite Galois extension of number fields, and `A := 𝓞K` and `B := 𝓞L` are their rings of
integers.
-/
namespace Algebra
variable (A B G : Type*) [CommSemiring A] [Semiring B] [Algebra A B]
[Group G] [MulSemiringAction G B]
/-- An action of a group `G` on an extension of rings `B/A` is invariant if every fixed point of
`B` lies in the image of `A`. The converse statement that every point in the image of `A` is fixed
by `G` is `smul_algebraMap` (assuming `SMulCommClass A B G`). -/
@[mk_iff] class IsInvariant : Prop where
isInvariant : ∀ b : B, (∀ g : G, g • b = b) → ∃ a : A, algebraMap A B a = b
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Invariant/Profinite.lean | import Mathlib.RingTheory.Invariant.Basic
import Mathlib.Topology.Algebra.ClopenNhdofOne
import Mathlib.Topology.Algebra.Category.ProfiniteGrp.Limits
import Mathlib.CategoryTheory.CofilteredSystem
/-!
# Invariant Extensions of Rings
In this file we generalize the results in `Mathlib/RingTheory/Invariant/Basic.lean` to profinite
groups.
## Main statements
Let `G` be a profinite group acting continuously on a
commutative ring `B` (with the discrete topology) satisfying `Algebra.IsInvariant A B G`.
* `Algebra.IsInvariant.isIntegral_of_profinite`: `B/A` is an integral extension.
* `Algebra.IsInvariant.exists_smul_of_under_eq_of_profinite`:
`G` acts transitivity on the prime ideals of `B` lying above a given prime ideal of `A`.
* `Ideal.Quotient.stabilizerHom_surjective_of_profinite`: if `Q` is a prime ideal of `B` lying over
a prime ideal `P` of `A`, then the stabilizer subgroup of `Q` surjects onto `Aut((B/Q)/(A/P))`.
-/
open scoped Pointwise
section ProfiniteGrp
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
variable {G : Type*} [Group G] [MulSemiringAction G B] [SMulCommClass G A B]
variable {P : Ideal A}
variable [TopologicalSpace G] [CompactSpace G] [TotallyDisconnectedSpace G]
variable [IsTopologicalGroup G] [TopologicalSpace B] [DiscreteTopology B] [ContinuousSMul G B]
open Pointwise CategoryTheory
include G in
lemma Algebra.IsInvariant.isIntegral_of_profinite
[Algebra.IsInvariant A B G] : Algebra.IsIntegral A B := by
constructor
intro x
obtain ⟨N, hN⟩ := ProfiniteGrp.exist_openNormalSubgroup_sub_open_nhds_of_one
(stabilizer_isOpen G x) (one_mem _)
have := (Algebra.IsInvariant.isIntegral A (FixedPoints.subalgebra A B N.1.1) (G ⧸ N.1.1)).1
⟨x, fun g ↦ hN g.2⟩
exact this.map (FixedPoints.subalgebra A B N.1.1).val
/-- `G` acts transitively on the prime ideals of `B` above a given prime ideal of `A`. -/
lemma Algebra.IsInvariant.exists_smul_of_under_eq_of_profinite
[Algebra.IsInvariant A B G] (P Q : Ideal B) [P.IsPrime] [Q.IsPrime]
(hPQ : P.under A = Q.under A) :
∃ g : G, Q = g • P := by
let B' := FixedPoints.subalgebra A B
let F : OpenNormalSubgroup G ⥤ Type _ :=
{ obj N := { g : G ⧸ N.1.1 // Q.under (B' N.1.1) = g • P.under (B' N.1.1) }
map {N N'} f x := ⟨(QuotientGroup.map _ _ (.id _) (leOfHom f)) x.1, by
have h : B' N'.1.1 ≤ B' N.1.1 := fun x hx n ↦ hx ⟨_, f.le n.2⟩
obtain ⟨x, hx⟩ := x
obtain ⟨x, rfl⟩ := QuotientGroup.mk_surjective x
simpa only [Ideal.comap_comap, Ideal.pointwise_smul_eq_comap, ← Ideal.comap_coe
(F := RingEquiv _ _)] using congr(Ideal.comap (Subalgebra.inclusion h).toRingHom $hx)⟩
map_id N := by ext ⟨⟨x⟩, hx⟩; rfl
map_comp f g := by ext ⟨⟨x⟩, hx⟩; rfl }
have (N : _) : Nonempty (F.obj N) := by
obtain ⟨g, hg⟩ := Algebra.IsInvariant.exists_smul_of_under_eq A
(B' N.1.1) (G ⧸ N.1.1) (P.under _) (Q.under _) hPQ
exact ⟨g, hg⟩
obtain ⟨s, hs⟩ := nonempty_sections_of_finite_cofiltered_system F
let a := (ProfiniteGrp.of G).isoLimittoFiniteQuotientFunctor.inv.hom
⟨fun N ↦ (s N).1, (fun {N N'} f ↦ congr_arg Subtype.val (hs f))⟩
have (N : OpenNormalSubgroup G) : QuotientGroup.mk (s := N.1.1) a = s N := by
change ((ProfiniteGrp.of G).isoLimittoFiniteQuotientFunctor.hom.hom a).1 N = _
simp only [a]
rw [← ProfiniteGrp.comp_apply, Iso.inv_hom_id]
simp
refine ⟨a, ?_⟩
ext x
obtain ⟨N, hN⟩ := ProfiniteGrp.exist_openNormalSubgroup_sub_open_nhds_of_one
(stabilizer_isOpen G x) (one_mem _)
lift x to B' N.1.1 using fun g ↦ hN g.2
change x ∈ Q.under (B' N.1.1) ↔ x ∈ Ideal.under (B' N.1.1) ((_ : G) • P)
rw [(s N).2]
simp only [Ideal.comap_comap, Ideal.pointwise_smul_eq_comap, ← Ideal.comap_coe
(F := RingEquiv _ _)]
congr! 2
ext y
simp [← this]
rfl
attribute [local instance] Subgroup.finiteIndex_of_finite_quotient
omit
[CompactSpace G]
[TotallyDisconnectedSpace G]
[IsTopologicalGroup G]
[TopologicalSpace B]
[DiscreteTopology B]
[ContinuousSMul G B] in
lemma Ideal.Quotient.stabilizerHomSurjectiveAuxFunctor_aux
(Q : Ideal B)
{N N' : OpenNormalSubgroup G} (e : N ≤ N')
(x : G ⧸ N.1.1)
(hx : x ∈ MulAction.stabilizer (G ⧸ N.1.1) (Q.under (FixedPoints.subalgebra A B N.1.1))) :
QuotientGroup.map _ _ (.id _) e x ∈
MulAction.stabilizer (G ⧸ N'.1.1) (Q.under (FixedPoints.subalgebra A B N'.1.1)) := by
change _ = _
have h : FixedPoints.subalgebra A B N'.1.1 ≤ FixedPoints.subalgebra A B N.1.1 :=
fun x hx n ↦ hx ⟨_, e n.2⟩
obtain ⟨x, rfl⟩ := QuotientGroup.mk_surjective x
replace hx := congr(Ideal.comap (Subalgebra.inclusion h) $hx)
simpa only [Ideal.pointwise_smul_eq_comap,
← Ideal.comap_coe (F := RingEquiv _ _), Ideal.comap_comap] using hx
/-- (Implementation)
The functor taking an open normal subgroup `N ≤ G` to the set of lifts of `σ` in `G ⧸ N`.
We will show that its inverse limit is nonempty to conclude that there exists a lift in `G`. -/
def Ideal.Quotient.stabilizerHomSurjectiveAuxFunctor
(P : Ideal A) (Q : Ideal B) [Q.LiesOver P] (σ : (B ⧸ Q) ≃ₐ[A ⧸ P] B ⧸ Q) :
OpenNormalSubgroup G ⥤ Type _ where
obj N :=
letI B' := FixedPoints.subalgebra A B N.1.1
letI f : (B' ⧸ Q.under B') →ₐ[A ⧸ P] B ⧸ Q :=
{ toRingHom := Ideal.quotientMap _ B'.subtype le_rfl,
commutes' := Quotient.ind fun _ ↦ rfl }
{ σ' // f.comp (Ideal.Quotient.stabilizerHom
(Q.under B') P (G ⧸ N.1.1) σ') = σ.toAlgHom.comp f }
map {N N'} i x := ⟨⟨(QuotientGroup.map _ _ (.id _) (leOfHom i)) x.1,
Ideal.Quotient.stabilizerHomSurjectiveAuxFunctor_aux Q i.le x.1.1 x.1.2⟩, by
have h : FixedPoints.subalgebra A B N'.1.1 ≤ FixedPoints.subalgebra A B N.1.1 :=
fun x hx n ↦ hx ⟨_, i.le n.2⟩
obtain ⟨⟨x, hx⟩, hx'⟩ := x
obtain ⟨x, rfl⟩ := QuotientGroup.mk_surjective x
ext g
obtain ⟨g, rfl⟩ := Ideal.Quotient.mk_surjective g
exact DFunLike.congr_fun hx' (Ideal.Quotient.mk _ (Subalgebra.inclusion h g))⟩
map_id N := by ext ⟨⟨⟨x⟩, hx⟩, hx'⟩; rfl
map_comp f g := by ext ⟨⟨⟨x⟩, hx⟩, hx'⟩; rfl
open Ideal.Quotient in
instance (P : Ideal A) (Q : Ideal B) [Q.LiesOver P]
(σ : (B ⧸ Q) ≃ₐ[A ⧸ P] B ⧸ Q) (N : OpenNormalSubgroup G) :
Finite ((stabilizerHomSurjectiveAuxFunctor P Q σ).obj N) := by
dsimp [stabilizerHomSurjectiveAuxFunctor]
infer_instance
open Ideal.Quotient in
instance (P : Ideal A) (Q : Ideal B) [Q.IsPrime] [Q.LiesOver P]
[Algebra.IsInvariant A B G] (σ : (B ⧸ Q) ≃ₐ[A ⧸ P] B ⧸ Q) (N : OpenNormalSubgroup G) :
Nonempty ((stabilizerHomSurjectiveAuxFunctor P Q σ).obj N) := by
have : IsScalarTower (A ⧸ P) (FixedPoints.subalgebra A B N.1.1 ⧸
Q.under (FixedPoints.subalgebra A B N.1.1)) (B ⧸ Q) := IsScalarTower.of_algebraMap_eq
(Quotient.ind fun x ↦ rfl)
obtain ⟨σ', hσ'⟩ := Ideal.Quotient.exists_algEquiv_fixedPoint_quotient_under (G ⧸ N.1.1) P
(Q.under (FixedPoints.subalgebra A B N.1.1)) σ
obtain ⟨τ, rfl⟩ := Ideal.Quotient.stabilizerHom_surjective (G ⧸ N.1.1) P
(Q.under (FixedPoints.subalgebra A B N.1.1)) σ'
refine ⟨τ, ?_⟩
ext x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
exact hσ' x
/-- The stabilizer subgroup of `Q` surjects onto `Aut((B/Q)/(A/P))`. -/
theorem Ideal.Quotient.stabilizerHom_surjective_of_profinite
(P : Ideal A) (Q : Ideal B) [Q.IsPrime] [Q.LiesOver P]
[Algebra.IsInvariant A B G] :
Function.Surjective (Ideal.Quotient.stabilizerHom Q P G) := by
intro σ
let B' := FixedPoints.subalgebra A B
obtain ⟨s, hs⟩ := nonempty_sections_of_finite_cofiltered_system
(stabilizerHomSurjectiveAuxFunctor (G := G) P Q σ)
let a := (ProfiniteGrp.of G).isoLimittoFiniteQuotientFunctor.inv.hom
⟨fun N ↦ (s N).1.1, (fun {N N'} f ↦ congr($(hs f).1.1))⟩
have (N : OpenNormalSubgroup G) : QuotientGroup.mk (s := N.1.1) a = (s N).1 :=
congr_fun (congr_arg Subtype.val (ConcreteCategory.congr_hom (ProfiniteGrp.of
G).isoLimittoFiniteQuotientFunctor.inv_hom_id (Subtype.mk (fun N ↦ (s N).1.1) _))) N
refine ⟨⟨a, ?_⟩, ?_⟩
· ext x
obtain ⟨N, hN⟩ := ProfiniteGrp.exist_openNormalSubgroup_sub_open_nhds_of_one
(stabilizer_isOpen G x) (one_mem _)
lift x to B' N.1.1 using fun g ↦ hN g.2
change x ∈ (a • Q).under (B' N.1.1) ↔ x ∈ Q.under (B' N.1.1)
rw [← (s N).1.2]
simp only [Ideal.comap_comap, Ideal.pointwise_smul_eq_comap, ← Ideal.comap_coe
(F := RingEquiv _ _)]
congr! 2
ext y
rw [← this]
rfl
· ext x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨N, hN⟩ := ProfiniteGrp.exist_openNormalSubgroup_sub_open_nhds_of_one
(stabilizer_isOpen G x) (one_mem _)
lift x to B' N.1.1 using fun g ↦ hN g.2
change Ideal.Quotient.mk Q (QuotientGroup.mk (s := N) a • x).1 = _
rw [this]
exact DFunLike.congr_fun (s N).2 (Ideal.Quotient.mk _ x)
end ProfiniteGrp |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/Module.lean | import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.Algebra.Module.Torsion.Basic
import Mathlib.LinearAlgebra.Dual.Lemmas
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Flat.EquationalCriterion
import Mathlib.RingTheory.Ideal.Quotient.ChineseRemainder
import Mathlib.RingTheory.LocalProperties.Exactness
import Mathlib.RingTheory.LocalRing.ResidueField.Basic
import Mathlib.RingTheory.LocalRing.ResidueField.Ideal
import Mathlib.RingTheory.Nakayama
import Mathlib.RingTheory.Support
/-!
# Finite modules over local rings
This file gathers various results about finite modules over a local ring `(R, 𝔪, k)`.
## Main results
- `IsLocalRing.subsingleton_tensorProduct`: If `M` is finitely generated, `k ⊗ M = 0 ↔ M = 0`.
- `Module.free_of_maximalIdeal_rTensor_injective`:
If `M` is a finitely presented module such that `m ⊗ M → M` is injective
(for example when `M` is flat), then `M` is free.
- `Module.free_of_lTensor_residueField_injective`: If `N → M → P → 0` is a presentation of `P` with
`N` finite and `M` finite free, then injectivity of `k ⊗ N → k ⊗ M` implies that `P` is free.
- `IsLocalRing.split_injective_iff_lTensor_residueField_injective`:
Given an `R`-linear map `l : M → N` with `M` finite and `N` finite free,
`l` is a split injection if and only if `k ⊗ l` is a (split) injection.
-/
open Module
universe u
variable {R M N P : Type*} [CommRing R]
section
variable [AddCommGroup M] [AddCommGroup N] [Module R M] [Module R N]
open Function (Injective Surjective Exact)
open IsLocalRing TensorProduct
local notation "k" => ResidueField R
local notation "𝔪" => maximalIdeal R
variable [AddCommGroup P] [Module R P] (f : M →ₗ[R] N) (g : N →ₗ[R] P)
namespace IsLocalRing
variable [IsLocalRing R]
theorem map_mkQ_eq {N₁ N₂ : Submodule R M} (h : N₁ ≤ N₂) (h' : N₂.FG) :
N₁.map (Submodule.mkQ (𝔪 • N₂)) = N₂.map (Submodule.mkQ (𝔪 • N₂)) ↔ N₁ = N₂ := by
constructor
· intro hN
have : N₂ ≤ 𝔪 • N₂ ⊔ N₁ := by
simpa using Submodule.comap_mono (f := Submodule.mkQ (𝔪 • N₂)) hN.ge
rw [sup_comm] at this
exact h.antisymm (Submodule.le_of_le_smul_of_le_jacobson_bot h'
(by rw [jacobson_eq_maximalIdeal]; exact bot_ne_top) this)
· rintro rfl; simp
theorem map_mkQ_eq_top {N : Submodule R M} [Module.Finite R M] :
N.map (Submodule.mkQ (𝔪 • ⊤)) = ⊤ ↔ N = ⊤ := by
rw [← map_mkQ_eq (N₁ := N) le_top Module.Finite.fg_top, Submodule.map_top, Submodule.range_mkQ]
theorem map_tensorProduct_mk_eq_top {N : Submodule R M} [Module.Finite R M] :
N.map (TensorProduct.mk R k M 1) = ⊤ ↔ N = ⊤ := by
constructor
· intro hN
letI : Module k (M ⧸ (𝔪 • ⊤ : Submodule R M)) :=
inferInstanceAs (Module (R ⧸ 𝔪) (M ⧸ 𝔪 • (⊤ : Submodule R M)))
letI : IsScalarTower R k (M ⧸ (𝔪 • ⊤ : Submodule R M)) :=
inferInstanceAs (IsScalarTower R (R ⧸ 𝔪) (M ⧸ 𝔪 • (⊤ : Submodule R M)))
let f := AlgebraTensorModule.lift (((LinearMap.ringLmapEquivSelf k k _).symm
(Submodule.mkQ (𝔪 • ⊤ : Submodule R M))).restrictScalars R)
have : f.comp (TensorProduct.mk R k M 1) = Submodule.mkQ (𝔪 • ⊤) := by ext; simp [f]
have hf : Function.Surjective f := by
intro x; obtain ⟨x, rfl⟩ := Submodule.mkQ_surjective _ x
rw [← this, LinearMap.comp_apply]; exact ⟨_, rfl⟩
apply_fun Submodule.map f at hN
rwa [← Submodule.map_comp, this, Submodule.map_top, LinearMap.range_eq_top.2 hf,
map_mkQ_eq_top] at hN
· rintro rfl; rw [Submodule.map_top, LinearMap.range_eq_top]
exact TensorProduct.mk_surjective R M k Ideal.Quotient.mk_surjective
theorem subsingleton_tensorProduct [Module.Finite R M] :
Subsingleton (k ⊗[R] M) ↔ Subsingleton M := by
rw [← Submodule.subsingleton_iff R, ← subsingleton_iff_bot_eq_top,
← Submodule.subsingleton_iff R, ← subsingleton_iff_bot_eq_top,
← map_tensorProduct_mk_eq_top (M := M), Submodule.map_bot]
theorem span_eq_top_of_tmul_eq_basis [Module.Finite R M] {ι}
(f : ι → M) (b : Basis ι k (k ⊗[R] M))
(hb : ∀ i, 1 ⊗ₜ f i = b i) : Submodule.span R (Set.range f) = ⊤ := by
rw [← map_tensorProduct_mk_eq_top, Submodule.map_span, ← Submodule.restrictScalars_span R k
Ideal.Quotient.mk_surjective, Submodule.restrictScalars_eq_top_iff,
← b.span_eq, ← Set.range_comp]
simp only [Function.comp_def, mk_apply, hb, Basis.span_eq]
end IsLocalRing
lemma Module.mem_support_iff_nontrivial_residueField_tensorProduct [Module.Finite R M]
(p : PrimeSpectrum R) :
p ∈ Module.support R M ↔ Nontrivial (p.asIdeal.ResidueField ⊗[R] M) := by
let K := p.asIdeal.ResidueField
let e := (AlgebraTensorModule.cancelBaseChange R (Localization.AtPrime p.asIdeal) K K M).symm
rw [e.nontrivial_congr, Module.mem_support_iff,
(LocalizedModule.equivTensorProduct p.asIdeal.primeCompl M).nontrivial_congr,
← not_iff_not, not_nontrivial_iff_subsingleton, not_nontrivial_iff_subsingleton,
IsLocalRing.subsingleton_tensorProduct]
open Function in
/--
Given `M₁ → M₂ → M₃ → 0` and `N₁ → N₂ → N₃ → 0`,
if `M₁ ⊗ N₃ → M₂ ⊗ N₃` and `M₂ ⊗ N₁ → M₂ ⊗ N₂` are both injective,
then `M₃ ⊗ N₁ → M₃ ⊗ N₂` is also injective.
-/
theorem lTensor_injective_of_exact_of_exact_of_rTensor_injective
{M₁ M₂ M₃ N₁ N₂ N₃}
[AddCommGroup M₁] [Module R M₁] [AddCommGroup M₂] [Module R M₂] [AddCommGroup M₃] [Module R M₃]
[AddCommGroup N₁] [Module R N₁] [AddCommGroup N₂] [Module R N₂] [AddCommGroup N₃] [Module R N₃]
{f₁ : M₁ →ₗ[R] M₂} {f₂ : M₂ →ₗ[R] M₃} {g₁ : N₁ →ₗ[R] N₂} {g₂ : N₂ →ₗ[R] N₃}
(hfexact : Exact f₁ f₂) (hfsurj : Surjective f₂)
(hgexact : Exact g₁ g₂) (hgsurj : Surjective g₂)
(hfinj : Injective (f₁.rTensor N₃)) (hginj : Injective (g₁.lTensor M₂)) :
Injective (g₁.lTensor M₃) := by
rw [injective_iff_map_eq_zero]
intro x hx
obtain ⟨x, rfl⟩ := f₂.rTensor_surjective N₁ hfsurj x
have : f₂.rTensor N₂ (g₁.lTensor M₂ x) = 0 := by
rw [← hx, ← LinearMap.comp_apply, ← LinearMap.comp_apply, LinearMap.rTensor_comp_lTensor,
LinearMap.lTensor_comp_rTensor]
obtain ⟨y, hy⟩ := (rTensor_exact N₂ hfexact hfsurj _).mp this
have : g₂.lTensor M₁ y = 0 := by
apply hfinj
trans g₂.lTensor M₂ (g₁.lTensor M₂ x)
· rw [← hy, ← LinearMap.comp_apply, ← LinearMap.comp_apply, LinearMap.rTensor_comp_lTensor,
LinearMap.lTensor_comp_rTensor]
rw [← LinearMap.comp_apply, ← LinearMap.lTensor_comp, hgexact.linearMap_comp_eq_zero]
simp
obtain ⟨z, rfl⟩ := (lTensor_exact _ hgexact hgsurj _).mp this
obtain rfl : f₁.rTensor N₁ z = x := by
apply hginj
simp only [← hy, ← LinearMap.comp_apply, ← LinearMap.comp_apply, LinearMap.lTensor_comp_rTensor,
LinearMap.rTensor_comp_lTensor]
rw [← LinearMap.comp_apply, ← LinearMap.rTensor_comp, hfexact.linearMap_comp_eq_zero]
simp
namespace Module
variable [IsLocalRing R]
/-- If `M` is of finite presentation over a local ring `(R, 𝔪, k)` such that
`𝔪 ⊗ M → M` is injective, then every family of elements that is a `k`-basis of
`k ⊗ M` is an `R`-basis of `M`. -/
lemma exists_basis_of_basis_baseChange [Module.FinitePresentation R M]
{ι : Type*} (v : ι → M) (hli : LinearIndependent k (TensorProduct.mk R k M 1 ∘ v))
(hsp : Submodule.span k (Set.range (TensorProduct.mk R k M 1 ∘ v)) = ⊤)
(H : Function.Injective ((𝔪).subtype.rTensor M)) :
∃ (b : Basis ι R M), ∀ i, b i = v i := by
let bk : Basis ι k (k ⊗[R] M) := Basis.mk hli (by rw [hsp])
haveI : Finite ι := Module.Finite.finite_basis bk
letI : Fintype ι := Fintype.ofFinite ι
let i := Finsupp.linearCombination R v
have hi : Surjective i := by
rw [← LinearMap.range_eq_top, Finsupp.range_linearCombination]
refine IsLocalRing.span_eq_top_of_tmul_eq_basis (R := R) (f := v) bk
(fun _ ↦ by simp [bk])
have : Module.Finite R (LinearMap.ker i) := by
constructor
exact (Submodule.fg_top _).mpr (Module.FinitePresentation.fg_ker i hi)
-- We claim that `i` is actually a bijection,
-- hence `v` induces an isomorphism `M ≃[R] Rᴵ` showing that `v` is a basis.
let iequiv : (ι →₀ R) ≃ₗ[R] M := by
refine LinearEquiv.ofBijective i ⟨?_, hi⟩
-- By Nakayama's lemma, it suffices to show that `k ⊗ ker(i) = 0`.
rw [← LinearMap.ker_eq_bot, ← Submodule.subsingleton_iff_eq_bot,
← IsLocalRing.subsingleton_tensorProduct (R := R), subsingleton_iff_forall_eq 0]
have : Function.Surjective (i.baseChange k) := i.lTensor_surjective _ hi
-- By construction, `k ⊗ i : kᴵ → k ⊗ M` is bijective.
have hi' : Function.Bijective (i.baseChange k) := by
refine ⟨?_, this⟩
rw [← LinearMap.ker_eq_bot (M := k ⊗[R] (ι →₀ R)) (f := i.baseChange k),
← Submodule.finrank_eq_zero (R := k) (M := k ⊗[R] (ι →₀ R)),
← Nat.add_right_inj (n := Module.finrank k (LinearMap.range <| i.baseChange k)),
LinearMap.finrank_range_add_finrank_ker (V := k ⊗[R] (ι →₀ R)),
LinearMap.range_eq_top.mpr this, finrank_top]
simp only [Module.finrank_tensorProduct, Module.finrank_self,
Module.finrank_finsupp_self, one_mul, add_zero]
rw [Module.finrank_eq_card_basis bk]
-- On the other hand, `m ⊗ M → M` injective => `Tor₁(k, M) = 0` => `k ⊗ ker(i) → kᴵ` injective.
intro x
refine lTensor_injective_of_exact_of_exact_of_rTensor_injective
(N₁ := LinearMap.ker i) (N₂ := ι →₀ R) (N₃ := M)
(f₁ := (𝔪).subtype) (f₂ := Submodule.mkQ 𝔪)
(g₁ := (LinearMap.ker i).subtype) (g₂ := i) (LinearMap.exact_subtype_mkQ 𝔪)
(Submodule.mkQ_surjective _) (LinearMap.exact_subtype_ker_map i) hi H ?_ ?_
· apply Module.Flat.lTensor_preserves_injective_linearMap
exact Subtype.val_injective
· apply hi'.injective
rw [LinearMap.baseChange_eq_ltensor]
erw [← LinearMap.comp_apply (i.lTensor k), ← LinearMap.lTensor_comp]
rw [(LinearMap.exact_subtype_ker_map i).linearMap_comp_eq_zero]
simp only [LinearMap.lTensor_zero, LinearMap.zero_apply, map_zero]
use Basis.ofRepr iequiv.symm
intro j
simp [iequiv, i]
/--
If `M` is a finitely presented module over a local ring `(R, 𝔪)` such that `m ⊗ M → M` is
injective, then every generating family contains a basis.
-/
lemma exists_basis_of_span_of_maximalIdeal_rTensor_injective [Module.FinitePresentation R M]
(H : Function.Injective ((𝔪).subtype.rTensor M))
{ι : Type u} (v : ι → M) (hv : Submodule.span R (Set.range v) = ⊤) :
∃ (κ : Type u) (a : κ → ι) (b : Basis κ R M), ∀ i, b i = v (a i) := by
have := (map_tensorProduct_mk_eq_top (N := Submodule.span R (Set.range v))).mpr hv
rw [← Submodule.span_image, ← Set.range_comp, eq_top_iff, ← SetLike.coe_subset_coe,
Submodule.top_coe] at this
have : Submodule.span k (Set.range (TensorProduct.mk R k M 1 ∘ v)) = ⊤ := by
rw [eq_top_iff]
exact Set.Subset.trans this (Submodule.span_subset_span _ _ _)
obtain ⟨κ, a, ha, hsp, hli⟩ := exists_linearIndependent' k (TensorProduct.mk R k M 1 ∘ v)
rw [this] at hsp
obtain ⟨b, hb⟩ := exists_basis_of_basis_baseChange (v ∘ a) hli hsp H
use κ, a, b, hb
lemma exists_basis_of_span_of_flat [Module.FinitePresentation R M] [Module.Flat R M]
{ι : Type u} (v : ι → M) (hv : Submodule.span R (Set.range v) = ⊤) :
∃ (κ : Type u) (a : κ → ι) (b : Basis κ R M), ∀ i, b i = v (a i) :=
exists_basis_of_span_of_maximalIdeal_rTensor_injective
(Module.Flat.rTensor_preserves_injective_linearMap (𝔪).subtype Subtype.val_injective) v hv
/--
If `M` is a finitely presented module over a local ring `(R, 𝔪)` such that `m ⊗ M → M` is
injective, then `M` is free.
-/
theorem free_of_maximalIdeal_rTensor_injective [Module.FinitePresentation R M]
(H : Function.Injective ((𝔪).subtype.rTensor M)) :
Module.Free R M := by
obtain ⟨_, _, b, _⟩ := exists_basis_of_span_of_maximalIdeal_rTensor_injective H id (by simp)
exact Free.of_basis b
theorem IsLocalRing.linearIndependent_of_flat [Flat R M] {ι : Type u} (v : ι → M)
(h : LinearIndependent k (TensorProduct.mk R k M 1 ∘ v)) : LinearIndependent R v := by
rw [linearIndependent_iff']; intro s f hfv i hi
classical
induction s using Finset.induction generalizing v i with
| empty => exact (Finset.notMem_empty _ hi).elim
| insert n s hn ih => ?_
rw [← Finset.sum_coe_sort] at hfv
have ⟨l, a, y, hay, hfa⟩ := Flat.isTrivialRelation_of_sum_smul_eq_zero hfv
have : v n ∉ 𝔪 • (⊤ : Submodule R M) := by
simpa only [← LinearMap.ker_tensorProductMk] using h.ne_zero n
set n : ↥(insert n s) := ⟨n, Finset.mem_insert_self ..⟩ with n_def
obtain ⟨j, hj⟩ : ∃ j, IsUnit (a n j) := by
contrapose! this
rw [show v n = _ from hay n]
exact sum_mem fun _ _ ↦ Submodule.smul_mem_smul (this _) ⟨⟩
let a' (i : ι) : R := if hi : _ then a ⟨i, hi⟩ j else 0
have a_eq i : a i j = a' i.1 := by simp_rw [a', dif_pos i.2]
have hfn : f n = -(∑ i ∈ s, f i * a' i) * hj.unit⁻¹ := by
rw [← hj.mul_left_inj, mul_assoc, hj.val_inv_mul, mul_one, eq_neg_iff_add_eq_zero]
convert hfa j
simp_rw [a_eq, Finset.sum_coe_sort _ (fun i ↦ f i * a' i), s.sum_insert hn, n_def]
let c (i : ι) : R := -(if i = n then 0 else a' i) * hj.unit⁻¹
specialize ih (v + (c · • v n)) ?_ ?_
· convert (linearIndependent_add_smul_iff (c := Ideal.Quotient.mk _ ∘ c) (i := n.1) ?_).mpr h
· ext; simp [tmul_add]; rfl
simp_rw [Function.comp_def, c, if_pos, neg_zero, zero_mul, map_zero]
· rw [Finset.sum_coe_sort _ (fun i ↦ f i • v i), s.sum_insert hn, add_comm, hfn] at hfv
simp_rw [Pi.add_apply, smul_add, s.sum_add_distrib, c, smul_smul, ← s.sum_smul, ← mul_assoc,
← s.sum_mul, mul_neg, s.sum_neg_distrib, ← hfv]
congr 4
exact s.sum_congr rfl fun i hi ↦ by rw [if_neg (ne_of_mem_of_not_mem hi hn)]
obtain hi | hi := Finset.mem_insert.mp hi
· rw [hi, hfn, Finset.sum_eq_zero, neg_zero, zero_mul]
intro i hi; rw [ih i hi, zero_mul]
· exact ih i hi
open Finsupp in
theorem IsLocalRing.linearCombination_bijective_of_flat [Module.Finite R M] [Flat R M] {ι : Type u}
(v : ι → M) (h : Function.Bijective (linearCombination k (TensorProduct.mk R k M 1 ∘ v))) :
Function.Bijective (linearCombination R v) := by
use linearIndependent_of_flat _ h.1
rw [← LinearMap.range_eq_top, range_linearCombination]
refine span_eq_top_of_tmul_eq_basis _ (.mk h.1 ?_) fun _ ↦ ?_
· simpa only [top_le_iff, ← range_linearCombination, LinearMap.range_eq_top] using h.2
· simp
@[stacks 00NZ]
theorem free_of_flat_of_isLocalRing [Module.Finite R P] [Flat R P] : Free R P :=
let w := Free.chooseBasis k (k ⊗[R] P)
have ⟨v, eq⟩ := (TensorProduct.mk_surjective R P k Quotient.mk_surjective).comp_left w
.of_basis <| .mk (IsLocalRing.linearIndependent_of_flat _ (eq ▸ w.linearIndependent)) <| by
exact (span_eq_top_of_tmul_eq_basis _ w <| congr_fun eq).ge
/--
If `M → N → P → 0` is a presentation of `P` over a local ring `(R, 𝔪, k)` with
`M` finite and `N` finite free, then injectivity of `k ⊗ M → k ⊗ N` implies that `P` is free.
-/
theorem free_of_lTensor_residueField_injective (hg : Surjective g) (h : Exact f g)
[Module.Finite R M] [Module.Finite R N] [Module.Free R N]
(hf : Function.Injective (f.lTensor k)) :
Module.Free R P := by
have := Module.finitePresentation_of_free_of_surjective g hg
(by rw [h.linearMap_ker_eq, LinearMap.range_eq_map]; exact (Module.Finite.fg_top).map f)
apply free_of_maximalIdeal_rTensor_injective
rw [← LinearMap.lTensor_inj_iff_rTensor_inj]
apply lTensor_injective_of_exact_of_exact_of_rTensor_injective
h hg (LinearMap.exact_subtype_mkQ 𝔪) (Submodule.mkQ_surjective _)
((LinearMap.lTensor_inj_iff_rTensor_inj _ _).mp hf)
(Module.Flat.lTensor_preserves_injective_linearMap _ Subtype.val_injective)
end Module
/--
Given a linear map `l : M → N` over a local ring `(R, 𝔪, k)`
with `M` finite and `N` finite free,
`l` is a split injection if and only if `k ⊗ l` is a (split) injection.
-/
theorem IsLocalRing.split_injective_iff_lTensor_residueField_injective [IsLocalRing R]
[Module.Finite R M] [Module.Finite R N] [Module.Free R N] (l : M →ₗ[R] N) :
(∃ l', l' ∘ₗ l = LinearMap.id) ↔ Function.Injective (l.lTensor (ResidueField R)) := by
constructor
· intro ⟨l', hl⟩
have : l'.lTensor (ResidueField R) ∘ₗ l.lTensor (ResidueField R) = .id := by
rw [← LinearMap.lTensor_comp, hl, LinearMap.lTensor_id]
exact Function.HasLeftInverse.injective ⟨_, LinearMap.congr_fun this⟩
· intro h
-- By `Module.free_of_lTensor_residueField_injective`, `k ⊗ l` injective => `N ⧸ l(M)` free.
have := Module.free_of_lTensor_residueField_injective l (LinearMap.range l).mkQ
(Submodule.mkQ_surjective _) l.exact_map_mkQ_range h
-- Hence `l(M)` is projective because `0 → l(M) → N → N ⧸ l(M) → 0` splits.
have : Module.Projective R (LinearMap.range l) := by
have := (Exact.split_tfae (LinearMap.exact_subtype_mkQ (LinearMap.range l))
Subtype.val_injective (Submodule.mkQ_surjective _)).out 0 1
obtain ⟨l', hl'⟩ := this.mp
(Module.projective_lifting_property _ _ (Submodule.mkQ_surjective _))
exact Module.Projective.of_split _ _ hl'
-- Then `0 → ker l → M → l(M) → 0` splits.
obtain ⟨l', hl'⟩ : ∃ l', l' ∘ₗ (LinearMap.ker l).subtype = LinearMap.id := by
have : Function.Exact (LinearMap.ker l).subtype
(l.codRestrict (LinearMap.range l) (LinearMap.mem_range_self l)) := by
rw [LinearMap.exact_iff, LinearMap.ker_rangeRestrict, Submodule.range_subtype]
have := (Exact.split_tfae this
Subtype.val_injective (fun ⟨x, y, e⟩ ↦ ⟨y, Subtype.ext e⟩)).out 0 1
exact this.mp (Module.projective_lifting_property _ _ (fun ⟨x, y, e⟩ ↦ ⟨y, Subtype.ext e⟩))
have : Module.Finite R (LinearMap.ker l) := by
refine Module.Finite.of_surjective l' ?_
exact Function.HasRightInverse.surjective ⟨_, DFunLike.congr_fun hl'⟩
-- And tensoring with `k` preserves the injectivity of the first arrow.
-- That is, `k ⊗ ker l → k ⊗ M` is also injective.
have H : Function.Injective ((LinearMap.ker l).subtype.lTensor k) := by
apply_fun (LinearMap.lTensor k) at hl'
rw [LinearMap.lTensor_comp, LinearMap.lTensor_id] at hl'
exact Function.HasLeftInverse.injective ⟨l'.lTensor k, DFunLike.congr_fun hl'⟩
-- But by assumption `k ⊗ M → k ⊗ l(M)` is already injective, so `k ⊗ ker l = 0`.
have : Subsingleton (k ⊗[R] LinearMap.ker l) := by
refine (subsingleton_iff_forall_eq 0).mpr fun y ↦ H (h ?_)
rw [map_zero, map_zero, ← LinearMap.comp_apply, ← LinearMap.lTensor_comp,
l.exact_subtype_ker_map.linearMap_comp_eq_zero, LinearMap.lTensor_zero,
LinearMap.zero_apply]
-- By Nakayama's lemma, `l` is injective.
have : Function.Injective l := by
rwa [← LinearMap.ker_eq_bot, ← Submodule.subsingleton_iff_eq_bot,
← IsLocalRing.subsingleton_tensorProduct (R := R)]
-- Whence `M ≃ l(M)` is projective and the result follows.
have := (Exact.split_tfae l.exact_map_mkQ_range this (Submodule.mkQ_surjective _)).out 0 1
rw [← this]
exact Module.projective_lifting_property _ _ (Submodule.mkQ_surjective _)
end
namespace Module
open Ideal TensorProduct Submodule
variable (R M) [Finite (MaximalSpectrum R)] [AddCommGroup M] [Module R M]
/-- If `M` is a finite flat module over a commutative semilocal ring `R` that has the same rank `n`
at every maximal ideal, then `M` is free of rank `n`. -/
@[stacks 02M9] theorem nonempty_basis_of_flat_of_finrank_eq [Module.Finite R M] [Flat R M]
(n : ℕ) (rk : ∀ P : MaximalSpectrum R, finrank (R ⧸ P.1) ((R ⧸ P.1) ⊗[R] M) = n) :
Nonempty (Basis (Fin n) R M) := by
let := @Quotient.field
/- For every maximal ideal `P`, `R⧸P ⊗[R] M` is an `n`-dimensional vector space over the field
`R⧸P` by assumption, so we can choose a basis `b' P` indexed by `Fin n`. -/
have b' (P) := Module.finBasisOfFinrankEq _ _ (rk P)
/- By Chinese remainder theorem for modules, there exist `n` elements `b i : M` that reduces
to `b' P i` modulo each maximal ideal `P`. -/
choose b hb using fun i ↦ pi_tensorProductMk_quotient_surjective M _
(fun _ _ ne ↦ isCoprime_of_isMaximal (MaximalSpectrum.ext_iff.ne.mp ne)) (b' · i)
/- It suffices to show the linear map `Rⁿ → M` induced by `b` is bijective, for which
it suffices to show `Rₚⁿ → Rₚ ⊗[R] M` is bijective for each maximal ideal `P`. -/
refine ⟨⟨.symm <| .ofBijective (Finsupp.linearCombination R b) <| bijective_of_isLocalized_maximal
_ (fun P _ ↦ Finsupp.mapRange.linearMap (Algebra.linearMap R (Localization P.primeCompl)))
_ (fun P _ ↦ TensorProduct.mk R (Localization P.primeCompl) M 1) _ fun P _ ↦ ?_⟩⟩
rw [IsLocalizedModule.map_linearCombination, LinearMap.coe_restrictScalars]
/- Since `M` is finite flat, it suffices to show
`(Rₚ⧸PRₚ)ⁿ → Rₚ⧸PRₚ ⊗[Rₚ] Rₚ ⊗[R] M ≃ Rₚ⧸PRₚ ⊗[R⧸P] R⧸P ⊗[R] M` is bijective,
which follows from that `(R⧸P)ⁿ → R⧸P ⊗[R] M` is bijective. -/
apply IsLocalRing.linearCombination_bijective_of_flat
rw [← (AlgebraTensorModule.cancelBaseChange _ _ P.ResidueField ..).comp_bijective,
← (AlgebraTensorModule.cancelBaseChange R (R ⧸ P) P.ResidueField ..).symm.comp_bijective]
convert ((b' ⟨P, ‹_›⟩).repr.lTensor _ ≪≫ₗ finsuppScalarRight _ P.ResidueField _).symm.bijective
refine funext fun r ↦ Finsupp.induction_linear r (by simp) (by simp+contextual) fun _ _ ↦ ?_
simp [smul_tmul', ← funext_iff.mp (hb _)]
@[stacks 02M9] theorem free_of_flat_of_finrank_eq [Module.Finite R M] [Flat R M]
(n : ℕ) (rk : ∀ P : MaximalSpectrum R, finrank (R ⧸ P.1) ((R ⧸ P.1) ⊗[R] M) = n) :
Free R M :=
have ⟨b⟩ := nonempty_basis_of_flat_of_finrank_eq R M n rk
.of_basis b
end Module |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/LocalSubring.lean | import Mathlib.Tactic.FieldSimp
import Mathlib.RingTheory.LocalRing.RingHom.Basic
import Mathlib.RingTheory.Localization.AtPrime.Basic
/-!
# Local subrings of fields
## Main results
- `LocalSubring` : The class of local subrings of a commutative ring.
- `LocalSubring.ofPrime`: The localization of a subring as a `LocalSubring`.
-/
open IsLocalRing Set
variable {R S : Type*} [CommRing R] [CommRing S]
variable {K : Type*} [Field K]
instance [Nontrivial S] (f : R →+* S) (s : Subring R) [IsLocalRing s] : IsLocalRing (s.map f) :=
.of_surjective' (f.restrict s _ (fun _ ↦ Set.mem_image_of_mem f))
(fun ⟨_, a, ha, e⟩ ↦ ⟨⟨a, ha⟩, Subtype.ext e⟩)
instance isLocalRing_top [IsLocalRing R] : IsLocalRing (⊤ : Subring R) :=
Subring.topEquiv.symm.isLocalRing
variable (R) in
/-- The class of local subrings of a commutative ring. -/
@[ext]
structure LocalSubring where
/-- The underlying subring of a local subring. -/
toSubring : Subring R
[isLocalRing : IsLocalRing toSubring]
namespace LocalSubring
attribute [instance] isLocalRing
lemma toSubring_injective : Function.Injective (toSubring (R := R)) := by
rintro ⟨a, b⟩ ⟨c, d⟩ rfl; rfl
/-- Copy of a local subring with a new `carrier` equal to the old one.
Useful to fix definitional equalities. -/
protected def copy (S : LocalSubring R) (s : Set R) (hs : s = ↑S.toSubring) : LocalSubring R :=
LocalSubring.mk (S.toSubring.copy s hs) (isLocalRing := hs ▸ S.2)
/-- The image of a `LocalSubring` as a `LocalSubring`. -/
@[simps! toSubring]
def map [Nontrivial S] (f : R →+* S) (s : LocalSubring R) : LocalSubring S :=
mk (s.1.map f)
/-- The range of a ring homomorphism from a local ring as a `LocalSubring`. -/
@[simps! toSubring]
def range [IsLocalRing R] [Nontrivial S] (f : R →+* S) : LocalSubring S :=
.copy (map f (mk ⊤)) f.range (by ext x; exact congr(x ∈ $(Set.image_univ.symm)))
/--
The domination order on local subrings.
`A` dominates `B` if and only if `B ≤ A` (as subrings) and `m_A ∩ B = m_B`.
-/
@[stacks 00I9]
instance : PartialOrder (LocalSubring R) where
le A B := ∃ h : A.1 ≤ B.1, IsLocalHom (Subring.inclusion h)
le_refl a := ⟨le_rfl, ⟨fun _ ↦ id⟩⟩
le_trans A B C h₁ h₂ := ⟨h₁.1.trans h₂.1, @RingHom.isLocalHom_comp _ _ _ _ _ _ _ _ h₂.2 h₁.2⟩
le_antisymm A B h₁ h₂ := toSubring_injective (le_antisymm h₁.1 h₂.1)
/-- `A` dominates `B` if and only if `B ≤ A` (as subrings) and `m_A ∩ B = m_B`. -/
lemma le_def {A B : LocalSubring R} :
A ≤ B ↔ ∃ h : A.toSubring ≤ B.toSubring, IsLocalHom (Subring.inclusion h) := Iff.rfl
lemma toSubring_mono : Monotone (toSubring (R := R)) :=
fun _ _ e ↦ e.1
section ofPrime
variable (A : Subring K) (P : Ideal A) [P.IsPrime]
/-- The localization of a subring at a prime, as a local subring.
Also see `Localization.subalgebra.ofField` -/
noncomputable
def ofPrime (A : Subring K) (P : Ideal A) [P.IsPrime] : LocalSubring K :=
range (IsLocalization.lift (M := P.primeCompl) (S := Localization.AtPrime P)
(g := A.subtype) (by simp [Ideal.primeCompl, not_imp_not]))
lemma le_ofPrime : A ≤ (ofPrime A P).toSubring := by
intro x hx
exact ⟨algebraMap A _ ⟨x, hx⟩, by simp⟩
noncomputable
instance : Algebra A (ofPrime A P).toSubring := (Subring.inclusion (le_ofPrime A P)).toAlgebra
instance : IsScalarTower A (ofPrime A P).toSubring K := .of_algebraMap_eq (fun _ ↦ rfl)
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
/-- The localization of a subring at a prime is indeed isomorphic to its abstract localization. -/
noncomputable
def ofPrimeEquiv : Localization.AtPrime P ≃ₐ[A] (ofPrime A P).toSubring := by
refine AlgEquiv.ofInjective (IsLocalization.liftAlgHom (M := P.primeCompl)
(S := Localization.AtPrime P) (f := Algebra.ofId A K) _) ?_
intro x y e
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq P.primeCompl x
obtain ⟨y, t, rfl⟩ := IsLocalization.exists_mk'_eq P.primeCompl y
have H (x : P.primeCompl) : x.1 ≠ 0 := by aesop
have : x.1 = y.1 * t.1.1⁻¹ * s.1.1 := by
simpa [IsLocalization.lift_mk', Algebra.ofId_apply, H,
Algebra.algebraMap_ofSubring_apply, IsUnit.coe_liftRight] using congr($e * s.1.1)
rw [IsLocalization.mk'_eq_iff_eq]
congr 1
ext
simp [field, H t, this, mul_comm]
instance : IsLocalization.AtPrime (ofPrime A P).toSubring P :=
IsLocalization.isLocalization_of_algEquiv _ (ofPrimeEquiv A P)
end ofPrime
end LocalSubring |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/Subring.lean | import Mathlib.Algebra.Ring.Subsemiring.Basic
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.RingTheory.LocalRing.Defs
/-!
# Subrings of local rings
We prove basic properties of subrings of local rings.
-/
namespace IsLocalRing
variable {R S} [Semiring R] [Semiring S]
open nonZeroDivisors
/-- If a (semi)ring `R` in which every element is either invertible or a zero divisor
embeds in a local (semi)ring `S`, then `R` is local. -/
theorem of_injective [IsLocalRing S] {f : R →+* S} (hf : Function.Injective f)
(h : ∀ a, a ∈ R⁰ → IsUnit a) : IsLocalRing R := by
haveI : Nontrivial R := f.domain_nontrivial
refine .of_is_unit_or_is_unit_of_add_one fun {a b} hab ↦
(IsLocalRing.isUnit_or_isUnit_of_add_one (map_add f .. ▸ map_one f ▸ congrArg f hab)).imp ?_ ?_
<;> exact h _ ∘ mem_nonZeroDivisors_of_injective hf ∘ IsUnit.mem_nonZeroDivisors
/-- If in a sub(semi)ring `R` of a local (semi)ring `S` every element is either
invertible or a zero divisor, then `R` is local. -/
theorem of_subring [IsLocalRing S] {R : Subsemiring S} (h : ∀ a, a ∈ R⁰ → IsUnit a) :
IsLocalRing R :=
of_injective R.subtype_injective h
/-- If in a sub(semi)ring `R` of a local (semi)ring `R'` every element is either
invertible or a zero divisor, then `R` is local.
This version is for `R` and `R'` that are both sub(semi)rings of a (semi)ring `S`. -/
theorem of_subring' {R R' : Subsemiring S} [IsLocalRing R'] (inc : R ≤ R')
(h : ∀ a, a ∈ R⁰ → IsUnit a) : IsLocalRing R :=
of_injective (Subsemiring.inclusion_injective inc) h
end IsLocalRing |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/Basic.lean | import Mathlib.RingTheory.LocalRing.Defs
import Mathlib.RingTheory.Ideal.Nonunits
/-!
# Local rings
We prove basic properties of local rings.
-/
variable {R S : Type*}
namespace IsLocalRing
section Semiring
variable [Semiring R]
theorem of_isUnit_or_isUnit_of_isUnit_add [Nontrivial R]
(h : ∀ a b : R, IsUnit (a + b) → IsUnit a ∨ IsUnit b) : IsLocalRing R :=
⟨fun {a b} hab => h a b <| hab.symm ▸ isUnit_one⟩
/-- A semiring is local if it is nontrivial and the set of nonunits is closed under the addition. -/
theorem of_nonunits_add [Nontrivial R]
(h : ∀ a b : R, a ∈ nonunits R → b ∈ nonunits R → a + b ∈ nonunits R) : IsLocalRing R where
isUnit_or_isUnit_of_add_one {a b} hab :=
or_iff_not_and_not.2 fun H => h a b H.1 H.2 <| hab.symm ▸ isUnit_one
end Semiring
section CommSemiring
variable [CommSemiring R]
/-- A semiring is local if it has a unique maximal ideal. -/
theorem of_unique_max_ideal (h : ∃! I : Ideal R, I.IsMaximal) : IsLocalRing R :=
@of_nonunits_add _ _
(nontrivial_of_ne (0 : R) 1 <|
let ⟨I, Imax, _⟩ := h
fun H : 0 = 1 => Imax.1.1 <| I.eq_top_iff_one.2 <| H ▸ I.zero_mem)
fun x y hx hy H =>
let ⟨I, Imax, Iuniq⟩ := h
let ⟨Ix, Ixmax, Hx⟩ := exists_max_ideal_of_mem_nonunits hx
let ⟨Iy, Iymax, Hy⟩ := exists_max_ideal_of_mem_nonunits hy
have xmemI : x ∈ I := Iuniq Ix Ixmax ▸ Hx
have ymemI : y ∈ I := Iuniq Iy Iymax ▸ Hy
Imax.1.1 <| I.eq_top_of_isUnit_mem (I.add_mem xmemI ymemI) H
theorem of_unique_nonzero_prime (h : ∃! P : Ideal R, P ≠ ⊥ ∧ Ideal.IsPrime P) : IsLocalRing R :=
of_unique_max_ideal
(by
rcases h with ⟨P, ⟨hPnonzero, hPnot_top, _⟩, hPunique⟩
refine ⟨P, ⟨⟨hPnot_top, ?_⟩⟩, fun M hM => hPunique _ ⟨?_, Ideal.IsMaximal.isPrime hM⟩⟩
· refine Ideal.maximal_of_no_maximal fun M hPM hM => ne_of_lt hPM ?_
exact (hPunique _ ⟨ne_bot_of_gt hPM, Ideal.IsMaximal.isPrime hM⟩).symm
· rintro rfl
exact hPnot_top (hM.1.2 P (bot_lt_iff_ne_bot.2 hPnonzero)))
variable [IsLocalRing R]
theorem isUnit_or_isUnit_of_isUnit_add {a b : R} (h : IsUnit (a + b)) : IsUnit a ∨ IsUnit b := by
rcases h with ⟨u, hu⟩
rw [← Units.inv_mul_eq_one, mul_add] at hu
apply Or.imp _ _ (isUnit_or_isUnit_of_add_one hu) <;> exact isUnit_of_mul_isUnit_right
theorem nonunits_add {a b : R} (ha : a ∈ nonunits R) (hb : b ∈ nonunits R) : a + b ∈ nonunits R :=
fun H => not_or_intro ha hb (isUnit_or_isUnit_of_isUnit_add H)
end CommSemiring
section Ring
variable [Ring R]
theorem of_isUnit_or_isUnit_one_sub_self [Nontrivial R] (h : ∀ a : R, IsUnit a ∨ IsUnit (1 - a)) :
IsLocalRing R :=
⟨fun {a b} hab => add_sub_cancel_left a b ▸ hab.symm ▸ h a⟩
end Ring
section CommRing
variable [CommRing R] [IsLocalRing R]
theorem isUnit_or_isUnit_one_sub_self (a : R) : IsUnit a ∨ IsUnit (1 - a) :=
isUnit_or_isUnit_of_isUnit_add <| (add_sub_cancel a 1).symm ▸ isUnit_one
theorem isUnit_of_mem_nonunits_one_sub_self (a : R) (h : 1 - a ∈ nonunits R) : IsUnit a :=
or_iff_not_imp_right.1 (isUnit_or_isUnit_one_sub_self a) h
theorem isUnit_one_sub_self_of_mem_nonunits (a : R) (h : a ∈ nonunits R) : IsUnit (1 - a) :=
or_iff_not_imp_left.1 (isUnit_or_isUnit_one_sub_self a) h
theorem of_surjective' [Ring S] [Nontrivial S] (f : R →+* S) (hf : Function.Surjective f) :
IsLocalRing S :=
of_isUnit_or_isUnit_one_sub_self (by
intro b
obtain ⟨a, rfl⟩ := hf b
apply (isUnit_or_isUnit_one_sub_self a).imp <| RingHom.isUnit_map _
rw [← f.map_one, ← f.map_sub]
apply f.isUnit_map)
end CommRing
end IsLocalRing
namespace Field
variable (K : Type*) [Field K]
-- see Note [lower instance priority]
instance (priority := 100) : IsLocalRing K := by
classical exact IsLocalRing.of_isUnit_or_isUnit_one_sub_self fun a =>
if h : a = 0 then Or.inr (by rw [h, sub_zero]; exact isUnit_one)
else Or.inl <| IsUnit.mk0 a h
end Field |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/Quotient.lean | import Mathlib.LinearAlgebra.Dimension.DivisionRing
import Mathlib.LinearAlgebra.FreeModule.PID
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
import Mathlib.RingTheory.Artinian.Ring
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.Ideal.Quotient.Index
import Mathlib.RingTheory.LocalRing.ResidueField.Defs
import Mathlib.RingTheory.LocalRing.RingHom.Basic
import Mathlib.RingTheory.Nakayama
/-!
We gather results about the quotients of local rings.
-/
open Submodule FiniteDimensional Module
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] [IsLocalRing R] [Module.Finite R S]
namespace IsLocalRing
local notation "p" => maximalIdeal R
local notation "pS" => Ideal.map (algebraMap R S) p
theorem quotient_span_eq_top_iff_span_eq_top (s : Set S) :
span (R ⧸ p) ((Ideal.Quotient.mk (I := pS)) '' s) = ⊤ ↔ span R s = ⊤ := by
have H : (span (R ⧸ p) ((Ideal.Quotient.mk (I := pS)) '' s)).restrictScalars R =
(span R s).map (IsScalarTower.toAlgHom R S (S ⧸ pS)) := by
rw [map_span, ← restrictScalars_span R (R ⧸ p) Ideal.Quotient.mk_surjective,
IsScalarTower.coe_toAlgHom', Ideal.Quotient.algebraMap_eq]
constructor
· intro hs
rw [← top_le_iff]
apply le_of_le_smul_of_le_jacobson_bot
· exact Module.finite_def.mp ‹_›
· exact (jacobson_eq_maximalIdeal ⊥ bot_ne_top).ge
· rw [Ideal.smul_top_eq_map]
rintro x -
have : LinearMap.ker (IsScalarTower.toAlgHom R S (S ⧸ pS)) =
restrictScalars R pS := by
ext; simp [Ideal.Quotient.eq_zero_iff_mem]
rw [← this, ← comap_map_eq, mem_comap, ← H, hs, restrictScalars_top]
exact mem_top
· intro hs
rwa [hs, Submodule.map_top, LinearMap.range_eq_top.mpr,
restrictScalars_eq_top_iff] at H
rw [IsScalarTower.coe_toAlgHom', Ideal.Quotient.algebraMap_eq]
exact Ideal.Quotient.mk_surjective
attribute [local instance] Ideal.Quotient.field
variable [Module.Free R S] {ι : Type*}
theorem finrank_quotient_map :
finrank (R ⧸ p) (S ⧸ pS) = finrank R S := by
classical
have : Module.Finite R (S ⧸ pS) := Module.Finite.of_surjective
(IsScalarTower.toAlgHom R S (S ⧸ pS)).toLinearMap (Ideal.Quotient.mk_surjective (I := pS))
have : Module.Finite (R ⧸ p) (S ⧸ pS) := Module.Finite.of_restrictScalars_finite R _ _
apply le_antisymm
· let b := Module.Free.chooseBasis R S
conv_rhs => rw [finrank_eq_card_chooseBasisIndex]
apply finrank_le_of_span_eq_top
rw [Set.range_comp]
apply (quotient_span_eq_top_iff_span_eq_top _).mpr b.span_eq
· let b := Module.Free.chooseBasis (R ⧸ p) (S ⧸ pS)
choose b' hb' using fun i ↦ Ideal.Quotient.mk_surjective (b i)
conv_rhs => rw [finrank_eq_card_chooseBasisIndex]
refine finrank_le_of_span_eq_top (v := b') ?_
apply (quotient_span_eq_top_iff_span_eq_top _).mp
rw [← Set.range_comp, show Ideal.Quotient.mk pS ∘ b' = ⇑b from funext hb']
exact b.span_eq
/-- Given a basis of `S`, the induced basis of `S / Ideal.map (algebraMap R S) p`. -/
noncomputable
def basisQuotient [Fintype ι] (b : Basis ι R S) : Basis ι (R ⧸ p) (S ⧸ pS) :=
basisOfTopLeSpanOfCardEqFinrank (Ideal.Quotient.mk pS ∘ b)
(by
rw [Set.range_comp]
exact ((quotient_span_eq_top_iff_span_eq_top _).mpr b.span_eq).ge)
(by rw [finrank_quotient_map, finrank_eq_card_basis b])
lemma basisQuotient_apply [Fintype ι] (b : Basis ι R S) (i) :
(basisQuotient b) i = Ideal.Quotient.mk pS (b i) := by
delta basisQuotient
rw [coe_basisOfTopLeSpanOfCardEqFinrank, Function.comp_apply]
lemma basisQuotient_repr {ι} [Fintype ι] (b : Basis ι R S) (x) (i) :
(basisQuotient b).repr (Ideal.Quotient.mk pS x) i =
Ideal.Quotient.mk p (b.repr x i) := by
refine congr_fun (g := Ideal.Quotient.mk p ∘ b.repr x) ?_ i
apply (Finsupp.linearEquivFunOnFinite (R ⧸ p) _ _).symm.injective
apply (basisQuotient b).repr.symm.injective
simp only [Finsupp.linearEquivFunOnFinite_symm_coe, LinearEquiv.symm_apply_apply,
Basis.repr_symm_apply]
rw [Finsupp.linearCombination_eq_fintype_linearCombination_apply (R ⧸ p),
Fintype.linearCombination_apply]
simp only [Function.comp_apply, basisQuotient_apply,
Ideal.Quotient.mk_smul_mk_quotient_map_quotient, ← Algebra.smul_def]
rw [← map_sum, Basis.sum_repr b x]
lemma exists_maximalIdeal_pow_le_of_isArtinianRing_quotient
(I : Ideal R) [IsArtinianRing (R ⧸ I)] : ∃ n, maximalIdeal R ^ n ≤ I := by
by_cases hI : I = ⊤
· simp [hI]
have : Nontrivial (R ⧸ I) := Ideal.Quotient.nontrivial hI
have := IsLocalRing.of_surjective' (Ideal.Quotient.mk I) Ideal.Quotient.mk_surjective
have := IsLocalHom.of_surjective (Ideal.Quotient.mk I) Ideal.Quotient.mk_surjective
obtain ⟨n, hn⟩ := IsArtinianRing.isNilpotent_jacobson_bot (R := R ⧸ I)
have : (maximalIdeal R).map (Ideal.Quotient.mk I) = maximalIdeal (R ⧸ I) := by
ext x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
simp [sup_eq_left.mpr (le_maximalIdeal hI)]
rw [jacobson_eq_maximalIdeal _ bot_ne_top, ← this, ← Ideal.map_pow, Ideal.zero_eq_bot,
Ideal.map_eq_bot_iff_le_ker, Ideal.mk_ker] at hn
exact ⟨n, hn⟩
@[deprecated (since := "2025-09-27")]
alias exists_maximalIdeal_pow_le_of_finite_quotient :=
exists_maximalIdeal_pow_le_of_isArtinianRing_quotient
lemma finite_quotient_iff [IsNoetherianRing R] [Finite (ResidueField R)] {I : Ideal R} :
Finite (R ⧸ I) ↔ ∃ n, (maximalIdeal R) ^ n ≤ I := by
refine ⟨fun _ ↦ exists_maximalIdeal_pow_le_of_isArtinianRing_quotient I, ?_⟩
rintro ⟨n, hn⟩
have : Finite (R ⧸ maximalIdeal R) := ‹_›
have := (Ideal.finite_quotient_pow (IsNoetherian.noetherian (maximalIdeal R)) n)
exact Finite.of_surjective _ (Ideal.Quotient.factor_surjective hn)
end IsLocalRing |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/NonLocalRing.lean | import Mathlib.Algebra.Ring.Pi
import Mathlib.Algebra.Ring.Prod
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.Spectrum.Maximal.Basic
/-!
# Non-local rings
This file gathers some results about non-local rings.
## Main results
- `not_isLocalRing_of_nontrivial_pi`: for an index type `ι` with at least two elements and
an indexed family of (semi)rings `R : ι → Type*`, the indexed product (semi)ring
`Π i, R i` is not local.
- `not_isLocalRing_of_prod_of_nontrivial`: the product of two nontrivial (semi)rings is not
local.
- `not_isLocalRing_tfae`: the following conditions are equivalent for a commutative (semi)ring `R`:
* `R` is not local,
* the maximal spectrum of `R` is nontrivial,
* `R` has two distinct maximal ideals.
- `exists_surjective_of_not_isLocalRing`: there exists a surjective ring homomorphism from
a non-local commutative ring onto a product of two fields.
-/
namespace IsLocalRing
/-- If two non-units sum to 1 in a (semi)ring `R` then `R` is not local. -/
theorem not_isLocalRing_def {R : Type*} [Semiring R] {a b : R} (ha : ¬IsUnit a) (hb : ¬IsUnit b)
(hab : a + b = 1) : ¬IsLocalRing R :=
fun _ ↦ hb <| (isUnit_or_isUnit_of_add_one hab).resolve_left ha
/-- For an index type `ι` with at least two elements and an indexed family of (semi)rings
`R : ι → Type*`, the indexed product (semi)ring `Π i, R i` is not local. -/
theorem not_isLocalRing_of_nontrivial_pi {ι : Type*} [Nontrivial ι] (R : ι → Type*)
[∀ i, Semiring (R i)] [∀ i, Nontrivial (R i)] : ¬IsLocalRing (Π i, R i) := by
classical
let ⟨i₁, i₂, hi⟩ := exists_pair_ne ι
have ha : ¬IsUnit (fun i ↦ if i = i₁ then 0 else 1 : Π i, R i) :=
fun h ↦ not_isUnit_zero (M₀ := R i₁) (by simpa using h.map (Pi.evalRingHom R i₁))
have hb : ¬IsUnit (fun i ↦ if i = i₁ then 1 else 0 : Π i, R i) :=
fun h ↦ not_isUnit_zero (M₀ := R i₂) (by simpa [hi.symm] using h.map (Pi.evalRingHom R i₂))
exact not_isLocalRing_def ha hb (by ext; dsimp; split <;> simp)
/-- The product of two nontrivial (semi)rings is not local. -/
theorem not_isLocalRing_of_prod_of_nontrivial (R₁ R₂ : Type*) [Semiring R₁] [Semiring R₂]
[Nontrivial R₁] [Nontrivial R₂] : ¬IsLocalRing (R₁ × R₂) :=
have ha : ¬IsUnit ((1, 0) : R₁ × R₂) :=
fun h ↦ not_isUnit_zero (M₀ := R₁) (by simpa using h.map (RingHom.snd R₁ R₂))
have hb : ¬IsUnit ((0, 1) : R₁ × R₂) :=
fun h ↦ not_isUnit_zero (M₀ := R₂) (by simpa using h.map (RingHom.fst R₁ R₂))
not_isLocalRing_def ha hb (by simp)
/-- The following conditions are equivalent for a commutative (semi)ring `R`:
* `R` is not local,
* the maximal spectrum of `R` is nontrivial,
* `R` has two distinct maximal ideals.
-/
theorem not_isLocalRing_tfae {R : Type*} [CommSemiring R] [Nontrivial R] :
List.TFAE [
¬IsLocalRing R,
Nontrivial (MaximalSpectrum R),
∃ m₁ m₂ : Ideal R, m₁.IsMaximal ∧ m₂.IsMaximal ∧ m₁ ≠ m₂] := by
tfae_have 1 → 2
| h => not_subsingleton_iff_nontrivial.mp fun _ ↦ h of_singleton_maximalSpectrum
tfae_have 2 → 3
| ⟨⟨m₁, hm₁⟩, ⟨m₂, hm₂⟩, h⟩ => ⟨m₁, m₂, ⟨hm₁, hm₂, fun _ ↦ h (by congr)⟩⟩
tfae_have 3 → 1
| ⟨m₁, m₂, ⟨hm₁, hm₂, h⟩⟩ => fun _ ↦ h <| (eq_maximalIdeal hm₁).trans (eq_maximalIdeal hm₂).symm
tfae_finish
/-- There exists a surjective ring homomorphism from a non-local commutative ring onto a product
of two fields. -/
theorem exists_surjective_of_not_isLocalRing.{u} {R : Type u} [CommRing R] [Nontrivial R]
(h : ¬IsLocalRing R) :
∃ (K₁ K₂ : Type u) (_ : Field K₁) (_ : Field K₂) (f : R →+* K₁ × K₂),
Function.Surjective f := by
/- get two different maximal ideals and project on the product of quotients -/
obtain ⟨m₁, m₂, _, _, hm₁m₂⟩ := (not_isLocalRing_tfae.out 0 2).mp h
let e := Ideal.quotientInfEquivQuotientProd m₁ m₂ <| Ideal.isCoprime_of_isMaximal hm₁m₂
let f := e.toRingHom.comp <| Ideal.Quotient.mk (m₁ ⊓ m₂)
use R ⧸ m₁, R ⧸ m₂, Ideal.Quotient.field m₁, Ideal.Quotient.field m₂, f
apply Function.Surjective.comp e.surjective Ideal.Quotient.mk_surjective
end IsLocalRing |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/Defs.lean | import Mathlib.Algebra.Group.Units.Defs
import Mathlib.Algebra.Ring.Defs
/-!
# Local rings
Define local rings as commutative rings having a unique maximal ideal.
## Main definitions
* `IsLocalRing`: A predicate on semirings, stating that for any pair of elements that
adds up to `1`, one of them is a unit. In the commutative case this is shown to be equivalent
to the condition that there exists a unique maximal ideal, see
`IsLocalRing.of_unique_max_ideal` and `IsLocalRing.maximal_ideal_unique`.
-/
/-- A semiring is local if it is nontrivial and `a` or `b` is a unit whenever `a + b = 1`.
Note that `IsLocalRing` is a predicate. -/
class IsLocalRing (R : Type*) [Semiring R] : Prop extends Nontrivial R where
of_is_unit_or_is_unit_of_add_one ::
/-- in a local ring `R`, if `a + b = 1`, then either `a` is a unit or `b` is a unit. In another
word, for every `a : R`, either `a` is a unit or `1 - a` is a unit. -/
isUnit_or_isUnit_of_add_one {a b : R} (h : a + b = 1) : IsUnit a ∨ IsUnit b |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/ResidueField/Fiber.lean | import Mathlib.RingTheory.Spectrum.Prime.RingHom
import Mathlib.RingTheory.LocalRing.ResidueField.Ideal
import Mathlib.RingTheory.Localization.BaseChange
import Mathlib.RingTheory.TensorProduct.Quotient
/-!
# The fiber of a ring homomorphism at a prime ideal
## Main results
* `PrimeSpectrum.preimageOrderIsoTensorResidueField` : We show that there is an `OrderIso` between
fiber of a ring homomorphism `algebraMap R S : R →+* S` at a prime ideal `p : PrimeSpectrum R` and
the prime spectrum of the tensor product of `S` and the residue field of `p`.
-/
open Algebra TensorProduct in
/-- The `OrderIso` between fiber of a ring homomorphism `algebraMap R S : R →+* S` at a prime ideal
`p : PrimeSpectrum R` and the prime spectrum of the tensor product of `S` and the residue field of
`p`. -/
noncomputable def PrimeSpectrum.preimageOrderIsoTensorResidueField (R S : Type*) [CommRing R]
[CommRing S] [Algebra R S] (p : PrimeSpectrum R) :
(algebraMap R S).specComap ⁻¹' {p} ≃o
PrimeSpectrum (p.asIdeal.ResidueField ⊗[R] S) := by
let Rp := Localization.AtPrime p.asIdeal
refine .trans ?_ <| comapEquiv
((Algebra.TensorProduct.comm ..).trans <| cancelBaseChange R Rp ..).toRingEquiv
refine .trans (.symm ((Ideal.primeSpectrumQuotientOrderIsoZeroLocus _).trans ?_)) <|
comapEquiv (quotIdealMapEquivTensorQuot ..).toRingEquiv
letI := rightAlgebra (R := R) (A := Rp) (B := S)
let e := IsLocalization.primeSpectrumOrderIso
(algebraMapSubmonoid S p.asIdeal.primeCompl) (Rp ⊗[R] S) |>.trans <|
.setCongr _ {q | (algebraMap R S).specComap q ≤ p} <| Set.ext fun _ ↦
disjoint_comm.trans (Ideal.disjoint_map_primeCompl_iff_comap_le ..)
have {q : PrimeSpectrum (Rp ⊗[R] S)} :
q ∈ zeroLocus ((IsLocalRing.maximalIdeal _).map (algebraMap Rp (Rp ⊗[R] S))) ↔
p ≤ (algebraMap R S).specComap (e q) := by
rw [mem_zeroLocus, SetLike.coe_subset_coe, ← Localization.AtPrime.map_eq_maximalIdeal,
Ideal.map_map, Ideal.map_le_iff_le_comap, show algebraMap Rp _ = includeLeftRingHom from rfl,
includeLeftRingHom_comp_algebraMap]; rfl
exact
{ toFun q := ⟨e q, (e q).2.antisymm (this.mp q.2)⟩
invFun q := ⟨e.symm ⟨q, q.2.le⟩, this.mpr <| by rw [e.apply_symm_apply]; exact q.2.ge⟩
left_inv q := Subtype.ext (e.left_inv q)
right_inv q := Subtype.ext <| by apply Subtype.ext_iff.mp (e.right_inv ⟨q, q.2.le⟩)
map_rel_iff' := e.map_rel_iff } |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/ResidueField/Instances.lean | import Mathlib.RingTheory.LocalRing.ResidueField.Ideal
import Mathlib.FieldTheory.Separable
/-! # Instances on residue fields -/
variable {R A B : Type*} [CommRing R] [CommRing A] [CommRing B] [Algebra R A] [Algebra A B]
[Algebra R B] [IsScalarTower R A B]
variable (p : Ideal A) (q : Ideal B) [q.LiesOver p]
attribute [local instance] Ideal.Quotient.field
instance [p.IsMaximal] [q.IsMaximal] [Algebra.IsSeparable (A ⧸ p) (B ⧸ q)] :
Algebra.IsSeparable p.ResidueField q.ResidueField := by
refine Algebra.IsSeparable.of_equiv_equiv
(.ofBijective _ p.bijective_algebraMap_quotient_residueField)
(.ofBijective _ q.bijective_algebraMap_quotient_residueField) ?_
ext x
simp [RingHom.algebraMap_toAlgebra]
instance [p.IsMaximal] [q.IsMaximal] [Algebra.IsSeparable p.ResidueField q.ResidueField] :
Algebra.IsSeparable (A ⧸ p) (B ⧸ q) := by
refine Algebra.IsSeparable.of_equiv_equiv
(.symm <| .ofBijective _ p.bijective_algebraMap_quotient_residueField)
(.symm <| .ofBijective _ q.bijective_algebraMap_quotient_residueField) ?_
ext x
obtain ⟨x, rfl⟩ :=
(RingEquiv.ofBijective _ p.bijective_algebraMap_quotient_residueField).surjective x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
apply (RingEquiv.ofBijective _ q.bijective_algebraMap_quotient_residueField).injective
simp only [RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, RingEquiv.symm_apply_apply,
RingEquiv.apply_symm_apply]
simp [RingHom.algebraMap_toAlgebra]
variable {p q} in
lemma Algebra.isSeparable_residueField_iff [p.IsMaximal] [q.IsMaximal] :
Algebra.IsSeparable p.ResidueField q.ResidueField ↔ Algebra.IsSeparable (A ⧸ p) (B ⧸ q) :=
⟨fun _ ↦ inferInstance, fun _ ↦ inferInstance⟩
instance [p.IsPrime] : Algebra.IsAlgebraic (A ⧸ p) p.ResidueField :=
IsLocalization.isAlgebraic _ (nonZeroDivisors (A ⧸ p))
instance [p.IsPrime] [q.IsPrime] [Algebra.IsIntegral A B] :
Algebra.IsAlgebraic p.ResidueField q.ResidueField := by
have : Algebra.IsIntegral (A ⧸ p) (B ⧸ q) :=
.tower_top A
letI := ((algebraMap (B ⧸ q) q.ResidueField).comp (algebraMap (A ⧸ p) (B ⧸ q))).toAlgebra
haveI : IsScalarTower (A ⧸ p) (B ⧸ q) q.ResidueField := .of_algebraMap_eq' rfl
haveI : Algebra.IsAlgebraic (A ⧸ p) q.ResidueField := .trans _ (B ⧸ q) _
haveI : IsScalarTower (A ⧸ p) p.ResidueField q.ResidueField := by
refine .of_algebraMap_eq fun x ↦ ?_
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
simp [RingHom.algebraMap_toAlgebra]
refine .extendScalars (Ideal.injective_algebraMap_quotient_residueField p) |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/ResidueField/Basic.lean | import Mathlib.Algebra.Ring.Action.End
import Mathlib.RingTheory.Finiteness.Cardinality
import Mathlib.RingTheory.LocalRing.ResidueField.Defs
import Mathlib.RingTheory.LocalRing.RingHom.Basic
/-!
# Residue Field of local rings
We prove basic properties of the residue field of a local ring.
-/
variable {R S T : Type*}
namespace IsLocalRing
section
variable [CommRing R] [IsLocalRing R] [CommRing S] [IsLocalRing S] [CommRing T] [IsLocalRing T]
lemma residue_def (x) : residue R x = Ideal.Quotient.mk (maximalIdeal R) x := rfl
lemma ker_residue : RingHom.ker (residue R) = maximalIdeal R :=
Ideal.mk_ker
@[simp]
lemma residue_eq_zero_iff (x : R) : residue R x = 0 ↔ x ∈ maximalIdeal R := by
rw [← RingHom.mem_ker, ker_residue]
lemma residue_ne_zero_iff_isUnit (x : R) : residue R x ≠ 0 ↔ IsUnit x := by
simp
lemma residue_surjective :
Function.Surjective (IsLocalRing.residue R) :=
Ideal.Quotient.mk_surjective
variable (R)
instance ResidueField.algebra {R₀} [CommRing R₀] [Algebra R₀ R] :
Algebra R₀ (ResidueField R) :=
Ideal.Quotient.algebra _
instance {R₁ R₂} [CommRing R₁] [CommRing R₂]
[Algebra R₁ R₂] [Algebra R₁ R] [Algebra R₂ R] [IsScalarTower R₁ R₂ R] :
IsScalarTower R₁ R₂ (IsLocalRing.ResidueField R) := by
delta IsLocalRing.ResidueField; infer_instance
@[simp]
theorem ResidueField.algebraMap_eq : algebraMap R (ResidueField R) = residue R :=
rfl
instance : IsLocalHom (IsLocalRing.residue R) :=
⟨fun _ ha =>
Classical.not_not.mp (Ideal.Quotient.eq_zero_iff_mem.not.mp (isUnit_iff_ne_zero.mp ha))⟩
instance {R₀} [CommRing R₀] [Algebra R₀ R] [Module.Finite R₀ R] :
Module.Finite R₀ (ResidueField R) :=
.of_surjective (IsScalarTower.toAlgHom R₀ R _).toLinearMap Ideal.Quotient.mk_surjective
variable {R}
namespace ResidueField
/-- A local ring homomorphism into a field can be descended onto the residue field. -/
def lift {R S : Type*} [CommRing R] [IsLocalRing R] [Field S] (f : R →+* S) [IsLocalHom f] :
IsLocalRing.ResidueField R →+* S :=
Ideal.Quotient.lift _ f fun a ha =>
by_contradiction fun h => ha (isUnit_of_map_unit f a (isUnit_iff_ne_zero.mpr h))
theorem lift_comp_residue {R S : Type*} [CommRing R] [IsLocalRing R] [Field S] (f : R →+* S)
[IsLocalHom f] : (lift f).comp (residue R) = f :=
RingHom.ext fun _ => rfl
@[simp]
theorem lift_residue_apply {R S : Type*} [CommRing R] [IsLocalRing R] [Field S] (f : R →+* S)
[IsLocalHom f] (x) : lift f (residue R x) = f x :=
rfl
/-- The map on residue fields induced by a local homomorphism between local rings -/
noncomputable def map (f : R →+* S) [IsLocalHom f] : ResidueField R →+* ResidueField S :=
Ideal.Quotient.lift (maximalIdeal R) ((Ideal.Quotient.mk _).comp f) fun a ha => by
unfold ResidueField
rw [RingHom.comp_apply, Ideal.Quotient.eq_zero_iff_mem]
exact map_nonunit f a ha
/-- Applying `IsLocalRing.ResidueField.map` to the identity ring homomorphism gives the identity
ring homomorphism. -/
@[simp]
theorem map_id :
IsLocalRing.ResidueField.map (RingHom.id R) = RingHom.id (IsLocalRing.ResidueField R) :=
Ideal.Quotient.ringHom_ext <| RingHom.ext fun _ => rfl
/-- The composite of two `IsLocalRing.ResidueField.map`s is the `IsLocalRing.ResidueField.map` of
the composite. -/
theorem map_comp (f : T →+* R) (g : R →+* S) [IsLocalHom f] [IsLocalHom g] :
IsLocalRing.ResidueField.map (g.comp f) =
(IsLocalRing.ResidueField.map g).comp (IsLocalRing.ResidueField.map f) :=
Ideal.Quotient.ringHom_ext <| RingHom.ext fun _ => rfl
theorem map_comp_residue (f : R →+* S) [IsLocalHom f] :
(ResidueField.map f).comp (residue R) = (residue S).comp f :=
rfl
theorem map_residue (f : R →+* S) [IsLocalHom f] (r : R) :
ResidueField.map f (residue R r) = residue S (f r) :=
rfl
theorem map_id_apply (x : ResidueField R) : map (RingHom.id R) x = x :=
DFunLike.congr_fun map_id x
@[simp]
theorem map_map (f : R →+* S) (g : S →+* T) (x : ResidueField R) [IsLocalHom f]
[IsLocalHom g] : map g (map f x) = map (g.comp f) x :=
DFunLike.congr_fun (map_comp f g).symm x
/-- A ring isomorphism defines an isomorphism of residue fields. -/
@[simps apply]
noncomputable def mapEquiv (f : R ≃+* S) :
IsLocalRing.ResidueField R ≃+* IsLocalRing.ResidueField S where
toFun := map (f : R →+* S)
invFun := map (f.symm : S →+* R)
left_inv x := by simp only [map_map, RingEquiv.symm_comp, map_id, RingHom.id_apply]
right_inv x := by simp only [map_map, RingEquiv.comp_symm, map_id, RingHom.id_apply]
map_mul' := RingHom.map_mul _
map_add' := RingHom.map_add _
@[simp]
theorem mapEquiv.symm (f : R ≃+* S) : (mapEquiv f).symm = mapEquiv f.symm :=
rfl
@[simp]
theorem mapEquiv_trans (e₁ : R ≃+* S) (e₂ : S ≃+* T) :
mapEquiv (e₁.trans e₂) = (mapEquiv e₁).trans (mapEquiv e₂) :=
RingEquiv.toRingHom_injective <| map_comp (e₁ : R →+* S) (e₂ : S →+* T)
@[simp]
theorem mapEquiv_refl : mapEquiv (RingEquiv.refl R) = RingEquiv.refl _ :=
RingEquiv.toRingHom_injective map_id
/-- The group homomorphism from `RingAut R` to `RingAut k` where `k`
is the residue field of `R`. -/
@[simps]
noncomputable def mapAut : RingAut R →* RingAut (IsLocalRing.ResidueField R) where
toFun := mapEquiv
map_mul' e₁ e₂ := mapEquiv_trans e₂ e₁
map_one' := mapEquiv_refl
section MulSemiringAction
variable (G : Type*) [Group G] [MulSemiringAction G R]
/-- If `G` acts on `R` as a `MulSemiringAction`, then it also acts on `IsLocalRing.ResidueField R`.
-/
noncomputable instance : MulSemiringAction G (IsLocalRing.ResidueField R) :=
MulSemiringAction.compHom _ <| mapAut.comp (MulSemiringAction.toRingAut G R)
@[simp]
theorem residue_smul (g : G) (r : R) : residue R (g • r) = g • residue R r :=
rfl
end MulSemiringAction
section FiniteDimensional
variable [Algebra R S] [IsLocalHom (algebraMap R S)]
noncomputable instance : Algebra (ResidueField R) (ResidueField S) :=
(ResidueField.map (algebraMap R S)).toAlgebra
instance : IsScalarTower R (ResidueField R) (ResidueField S) :=
IsScalarTower.of_algebraMap_eq (congrFun rfl)
instance finite_of_module_finite [Module.Finite R S] :
Module.Finite (ResidueField R) (ResidueField S) :=
.of_restrictScalars_finite R _ _
lemma finite_of_finite [Module.Finite R S] (hfin : Finite (ResidueField R)) :
Finite (ResidueField S) := Module.finite_of_finite (ResidueField R)
end FiniteDimensional
end ResidueField
@[deprecated (since := "2025-10-06")]
alias isLocalHom_residue := instIsLocalHomResidueFieldRingHomResidue
end
end IsLocalRing |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/ResidueField/Ideal.lean | import Mathlib.RingTheory.LocalRing.ResidueField.Basic
import Mathlib.RingTheory.Localization.AtPrime.Basic
import Mathlib.RingTheory.Localization.FractionRing
/-!
# The residue field of a prime ideal
We define `Ideal.ResidueField I` to be the residue field of the local ring `Localization.Prime I`,
and provide an `IsFractionRing (R ⧸ I) I.ResidueField` instance.
-/
variable {R A} [CommRing R] [CommRing A] [Algebra R A]
variable (I : Ideal R) [I.IsPrime]
/--
The residue field at a prime ideal, defined to be the residue field of the local ring
`Localization.Prime I`.
We also provide an `IsFractionRing (R ⧸ I) I.ResidueField` instance.
-/
abbrev Ideal.ResidueField : Type _ :=
IsLocalRing.ResidueField (Localization.AtPrime I)
/-- If `I = f⁻¹(J)`, then there is an canonical embedding `κ(I) ↪ κ(J)`. -/
noncomputable
abbrev Ideal.ResidueField.map (I : Ideal R) [I.IsPrime] (J : Ideal A) [J.IsPrime]
(f : R →+* A) (hf : I = J.comap f) : I.ResidueField →+* J.ResidueField :=
IsLocalRing.ResidueField.map (Localization.localRingHom I J f hf)
/-- If `I = f⁻¹(J)`, then there is an canonical embedding `κ(I) ↪ κ(J)`. -/
noncomputable
def Ideal.ResidueField.mapₐ (I : Ideal R) [I.IsPrime] (J : Ideal A) [J.IsPrime]
(hf : I = J.comap (algebraMap R A)) : I.ResidueField →ₐ[R] J.ResidueField where
__ := Ideal.ResidueField.map I J (algebraMap R A) hf
commutes' r := by
rw [IsScalarTower.algebraMap_apply R (Localization.AtPrime I),
IsLocalRing.ResidueField.algebraMap_eq]
simp only [RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
MonoidHom.coe_coe, IsLocalRing.ResidueField.map_residue, Localization.localRingHom_to_map]
rfl
@[simp] lemma Ideal.ResidueField.mapₐ_apply (I : Ideal R) [I.IsPrime] (J : Ideal A) [J.IsPrime]
(hf : I = J.comap (algebraMap R A)) (x) :
Ideal.ResidueField.mapₐ I J hf x = Ideal.ResidueField.map I J _ hf x := rfl
variable {I} in
@[simp high] -- marked `high` to override the more general `FaithfulSMul.algebraMap_eq_zero_iff`
lemma Ideal.algebraMap_residueField_eq_zero {x} :
algebraMap R I.ResidueField x = 0 ↔ x ∈ I := by
rw [IsScalarTower.algebraMap_apply R (Localization.AtPrime I),
IsLocalRing.ResidueField.algebraMap_eq, IsLocalRing.residue_eq_zero_iff]
exact IsLocalization.AtPrime.to_map_mem_maximal_iff _ _ _
@[simp high] -- marked `high` to override the more general `FaithfulSMul.ker_algebraMap_eq_bot`
lemma Ideal.ker_algebraMap_residueField :
RingHom.ker (algebraMap R I.ResidueField) = I :=
Ideal.ext fun _ ↦ Ideal.algebraMap_residueField_eq_zero
attribute [-instance] IsLocalRing.ResidueField.field in
noncomputable instance : Algebra (R ⧸ I) I.ResidueField :=
(Ideal.Quotient.liftₐ I (Algebra.ofId _ _)
fun _ ↦ Ideal.algebraMap_residueField_eq_zero.mpr).toRingHom.toAlgebra
instance : IsScalarTower R (R ⧸ I) I.ResidueField :=
IsScalarTower.of_algebraMap_eq fun _ ↦ rfl
@[simp]
lemma algebraMap_mk (x) :
algebraMap (R ⧸ I) I.ResidueField (Ideal.Quotient.mk _ x) =
algebraMap R I.ResidueField x := rfl
lemma Ideal.injective_algebraMap_quotient_residueField :
Function.Injective (algebraMap (R ⧸ I) I.ResidueField) := by
rw [RingHom.injective_iff_ker_eq_bot]
refine (Ideal.ker_quotient_lift _ _).trans ?_
change map (Quotient.mk I) (RingHom.ker (algebraMap R I.ResidueField)) = ⊥
rw [Ideal.ker_algebraMap_residueField, map_quotient_self]
instance : IsFractionRing (R ⧸ I) I.ResidueField where
map_units y := isUnit_iff_ne_zero.mpr
(map_ne_zero_of_mem_nonZeroDivisors _ I.injective_algebraMap_quotient_residueField y.2)
surj x := by
obtain ⟨x, rfl⟩ := IsLocalRing.residue_surjective x
obtain ⟨x, ⟨s, hs⟩, rfl⟩ := IsLocalization.exists_mk'_eq I.primeCompl x
refine ⟨⟨Ideal.Quotient.mk _ x, ⟨Ideal.Quotient.mk _ s, ?_⟩⟩, ?_⟩
· rwa [mem_nonZeroDivisors_iff_ne_zero, ne_eq, Ideal.Quotient.eq_zero_iff_mem]
· simp [IsScalarTower.algebraMap_eq R (Localization.AtPrime I) I.ResidueField, ← map_mul]
exists_of_eq {x y} e := by
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨y, rfl⟩ := Ideal.Quotient.mk_surjective y
rw [← sub_eq_zero, ← map_sub, ← map_sub] at e
simp only [IsLocalRing.ResidueField.algebraMap_eq, IsLocalRing.residue_eq_zero_iff,
IsScalarTower.algebraMap_apply R (Localization.AtPrime I) I.ResidueField, algebraMap_mk,
IsLocalization.AtPrime.to_map_mem_maximal_iff _ I, ← Ideal.Quotient.mk_eq_mk_iff_sub_mem] at e
use 1
simp [e]
lemma Ideal.bijective_algebraMap_quotient_residueField (I : Ideal R) [I.IsMaximal] :
Function.Bijective (algebraMap (R ⧸ I) I.ResidueField) :=
⟨I.injective_algebraMap_quotient_residueField, IsFractionRing.surjective_iff_isField.mpr
((Quotient.maximal_ideal_iff_isField_quotient I).mp inferInstance)⟩
section LiesOver
variable {R A B : Type*} [CommRing R] [CommRing A] [CommRing B] [Algebra R A] [Algebra A B]
[Algebra R B] [IsScalarTower R A B]
noncomputable
instance (p : Ideal A) [p.IsPrime] (q : Ideal B) [q.IsPrime] [q.LiesOver p] :
Algebra p.ResidueField q.ResidueField :=
(Ideal.ResidueField.mapₐ p q Ideal.LiesOver.over).toAlgebra
instance (p : Ideal A) [p.IsPrime] (q : Ideal B) [q.IsPrime] [q.LiesOver p] :
IsScalarTower R p.ResidueField q.ResidueField := .of_algebraMap_eq'
((Ideal.ResidueField.mapₐ p q Ideal.LiesOver.over).restrictScalars R).comp_algebraMap.symm
instance (p : Ideal R) [p.IsPrime] (q : Ideal A) [q.IsPrime] [q.LiesOver p]
(Q : Ideal B) [Q.IsPrime] [Q.LiesOver q] [Q.LiesOver p] :
IsScalarTower p.ResidueField q.ResidueField Q.ResidueField := by
refine .of_algebraMap_eq fun x ↦ ?_
simp only [RingHom.algebraMap_toAlgebra, AlgHom.toRingHom_eq_coe, RingHom.coe_coe,
Ideal.ResidueField.mapₐ_apply, Ideal.ResidueField.map, IsLocalRing.ResidueField.map_map,
IsScalarTower.algebraMap_eq R A B,
← Localization.localRingHom_comp]
end LiesOver |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/ResidueField/Defs.lean | import Mathlib.RingTheory.Ideal.Quotient.Basic
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
/-!
# Residue Field of local rings
## Main definitions
* `IsLocalRing.ResidueField`: The quotient of a local ring by its maximal ideal.
* `IsLocalRing.residue`: The quotient map from a local ring to its residue field.
-/
namespace IsLocalRing
variable (R : Type*) [CommRing R] [IsLocalRing R]
/-- The residue field of a local ring is the quotient of the ring by its maximal ideal. -/
def ResidueField :=
R ⧸ maximalIdeal R
deriving CommRing, Inhabited
noncomputable instance ResidueField.field : Field (ResidueField R) :=
Ideal.Quotient.field (maximalIdeal R)
/-- The quotient map from a local ring to its residue field. -/
def residue : R →+* ResidueField R :=
Ideal.Quotient.mk _
end IsLocalRing |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/RingHom/Basic.lean | import Mathlib.Algebra.Group.Units.Hom
import Mathlib.Data.ZMod.Basic
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.Ideal.Maps
/-!
# Local rings homomorphisms
We prove basic properties of local rings homomorphisms.
-/
variable {R S T : Type*}
section
variable [Semiring R] [Semiring S] [Semiring T]
@[instance]
theorem isLocalHom_id (R : Type*) [Semiring R] : IsLocalHom (RingHom.id R) where
map_nonunit _ := id
-- see note [lower instance priority]
@[instance 100]
theorem isLocalHom_toRingHom {F : Type*} [FunLike F R S]
[RingHomClass F R S] (f : F) [IsLocalHom f] : IsLocalHom (f : R →+* S) :=
⟨IsLocalHom.map_nonunit (f := f)⟩
@[instance]
theorem RingHom.isLocalHom_comp (g : S →+* T) (f : R →+* S) [IsLocalHom g]
[IsLocalHom f] : IsLocalHom (g.comp f) where
map_nonunit a := IsLocalHom.map_nonunit a ∘ IsLocalHom.map_nonunit (f := g) (f a)
theorem isLocalHom_of_comp (f : R →+* S) (g : S →+* T) [IsLocalHom (g.comp f)] :
IsLocalHom f :=
⟨fun _ ha => (isUnit_map_iff (g.comp f) _).mp (g.isUnit_map ha)⟩
/-- If `f : R →+* S` is a local ring hom, then `R` is a local ring if `S` is. -/
theorem RingHom.domain_isLocalRing {R S : Type*} [Semiring R] [CommSemiring S] [IsLocalRing S]
(f : R →+* S) [IsLocalHom f] : IsLocalRing R := by
haveI : Nontrivial R := f.domain_nontrivial
apply IsLocalRing.of_nonunits_add
intro a b
simp_rw [← map_mem_nonunits_iff f, f.map_add]
exact IsLocalRing.nonunits_add
end
section
open IsLocalRing
variable [CommSemiring R] [IsLocalRing R] [CommSemiring S] [IsLocalRing S]
/--
The image of the maximal ideal of the source is contained within the maximal ideal of the target.
-/
theorem map_nonunit (f : R →+* S) [IsLocalHom f] (a : R) (h : a ∈ maximalIdeal R) :
f a ∈ maximalIdeal S := fun H => h <| isUnit_of_map_unit f a H
end
namespace IsLocalRing
section
variable [CommSemiring R] [IsLocalRing R] [CommSemiring S] [IsLocalRing S]
/-- A ring homomorphism between local rings is a local ring hom iff it reflects units,
i.e. any preimage of a unit is still a unit. -/
@[stacks 07BJ]
theorem local_hom_TFAE (f : R →+* S) :
List.TFAE
[IsLocalHom f, f '' (maximalIdeal R).1 ⊆ maximalIdeal S,
(maximalIdeal R).map f ≤ maximalIdeal S, maximalIdeal R ≤ (maximalIdeal S).comap f,
(maximalIdeal S).comap f = maximalIdeal R] := by
tfae_have 1 → 2
| _, _, ⟨a, ha, rfl⟩ => map_nonunit f a ha
tfae_have 2 → 4 := Set.image_subset_iff.1
tfae_have 3 ↔ 4 := Ideal.map_le_iff_le_comap
tfae_have 4 → 1 := fun h ↦ ⟨fun x => not_imp_not.1 (@h x)⟩
tfae_have 1 → 5
| _ => by ext; exact not_iff_not.2 (isUnit_map_iff f _)
tfae_have 5 → 4 := fun h ↦ le_of_eq h.symm
tfae_finish
end
theorem of_surjective [CommSemiring R] [IsLocalRing R] [Semiring S] [Nontrivial S] (f : R →+* S)
[IsLocalHom f] (hf : Function.Surjective f) : IsLocalRing S :=
of_isUnit_or_isUnit_of_isUnit_add (by
intro a b hab
obtain ⟨a, rfl⟩ := hf a
obtain ⟨b, rfl⟩ := hf b
rw [← map_add] at hab
exact
(isUnit_or_isUnit_of_isUnit_add <| IsLocalHom.map_nonunit _ hab).imp f.isUnit_map
f.isUnit_map)
lemma _root_.IsLocalHom.of_surjective [CommRing R] [CommRing S] [Nontrivial S] [IsLocalRing R]
(f : R →+* S) (hf : Function.Surjective f) :
IsLocalHom f := by
have := IsLocalRing.of_surjective' f ‹_›
refine ((local_hom_TFAE f).out 3 0).mp ?_
have := Ideal.comap_isMaximal_of_surjective f hf (K := maximalIdeal S)
exact ((maximal_ideal_unique R).unique (inferInstanceAs (maximalIdeal R).IsMaximal) this).le
alias _root_.Function.Surjective.isLocalHom := _root_.IsLocalHom.of_surjective
/-- If `f : R →+* S` is a surjective local ring hom, then the induced units map is surjective. -/
theorem surjective_units_map_of_local_ringHom [Semiring R] [Semiring S] (f : R →+* S)
(hf : Function.Surjective f) (h : IsLocalHom f) :
Function.Surjective (Units.map <| f.toMonoidHom) := by
intro a
obtain ⟨b, hb⟩ := hf (a : S)
use (isUnit_of_map_unit f b (by rw [hb]; exact Units.isUnit _)).unit
ext
exact hb
-- see Note [lower instance priority]
/-- Every ring hom `f : K →+* R` from a division ring `K` to a nontrivial ring `R` is a
local ring hom. -/
instance (priority := 100) {K R} [DivisionRing K] [CommRing R] [Nontrivial R]
(f : K →+* R) : IsLocalHom f where
map_nonunit r hr := by simpa only [isUnit_iff_ne_zero, ne_eq, map_eq_zero] using hr.ne_zero
end IsLocalRing
namespace RingEquiv
protected theorem isLocalRing {A B : Type*} [CommSemiring A] [IsLocalRing A] [Semiring B]
(e : A ≃+* B) : IsLocalRing B :=
haveI := e.symm.toEquiv.nontrivial
IsLocalRing.of_surjective (e : A →+* B) e.surjective
end RingEquiv
instance {R : Type*} [CommRing R] [IsLocalRing R] {n : ℕ} [Nontrivial (ZMod n)] (f : R →+* ZMod n) :
IsLocalHom f :=
(ZMod.ringHom_surjective f).isLocalHom |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/MaximalIdeal/Basic.lean | import Mathlib.RingTheory.Jacobson.Ideal
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Defs
import Mathlib.RingTheory.Spectrum.Maximal.Defs
/-!
# Maximal ideal of local rings
We prove basic properties of the maximal ideal of a local ring.
-/
namespace IsLocalRing
variable {R S K : Type*}
section CommSemiring
variable [CommSemiring R]
variable [IsLocalRing R]
@[simp]
theorem mem_maximalIdeal (x) : x ∈ maximalIdeal R ↔ x ∈ nonunits R :=
Iff.rfl
variable (R)
instance maximalIdeal.isMaximal : (maximalIdeal R).IsMaximal := by
rw [Ideal.isMaximal_iff]
constructor
· intro h
apply h
exact isUnit_one
· intro I x _ hx H
rw [mem_maximalIdeal, mem_nonunits_iff, Classical.not_not] at hx
rcases hx with ⟨u, rfl⟩
simpa using I.mul_mem_left (↑u⁻¹) H
theorem isMaximal_iff {I : Ideal R} : I.IsMaximal ↔ I = maximalIdeal R where
mp hI := hI.eq_of_le (maximalIdeal.isMaximal R).1.1 fun _ h ↦ hI.1.1 ∘ I.eq_top_of_isUnit_mem h
mpr e := e ▸ maximalIdeal.isMaximal R
theorem maximal_ideal_unique : ∃! I : Ideal R, I.IsMaximal := by
simp [isMaximal_iff]
variable {R}
theorem eq_maximalIdeal {I : Ideal R} (hI : I.IsMaximal) : I = maximalIdeal R :=
ExistsUnique.unique (maximal_ideal_unique R) hI <| maximalIdeal.isMaximal R
/-- The maximal spectrum of a local ring is a singleton. -/
instance : Unique (MaximalSpectrum R) where
default := ⟨maximalIdeal R, maximalIdeal.isMaximal R⟩
uniq := fun I ↦ MaximalSpectrum.ext_iff.mpr <| eq_maximalIdeal I.isMaximal
omit [IsLocalRing R] in
/-- If the maximal spectrum of a ring is a singleton, then the ring is local. -/
theorem of_singleton_maximalSpectrum [Subsingleton (MaximalSpectrum R)]
[Nonempty (MaximalSpectrum R)] : IsLocalRing R :=
let m := Classical.arbitrary (MaximalSpectrum R)
.of_unique_max_ideal ⟨m.asIdeal, m.isMaximal,
fun I hI ↦ MaximalSpectrum.mk.inj <| Subsingleton.elim ⟨I, hI⟩ m⟩
theorem le_maximalIdeal {J : Ideal R} (hJ : J ≠ ⊤) : J ≤ maximalIdeal R := by
rcases Ideal.exists_le_maximal J hJ with ⟨M, hM1, hM2⟩
rwa [← eq_maximalIdeal hM1]
theorem le_maximalIdeal_of_isPrime (p : Ideal R) [hp : p.IsPrime] : p ≤ maximalIdeal R :=
le_maximalIdeal hp.ne_top
/--
An element `x` of a commutative local semiring is not contained in the maximal ideal
iff it is a unit.
-/
theorem notMem_maximalIdeal {x : R} : x ∉ maximalIdeal R ↔ IsUnit x := by
simp only [mem_maximalIdeal, mem_nonunits_iff, not_not]
@[deprecated (since := "2025-05-23")] alias not_mem_maximalIdeal := notMem_maximalIdeal
theorem isField_iff_maximalIdeal_eq : IsField R ↔ maximalIdeal R = ⊥ :=
not_iff_not.mp
⟨Ring.ne_bot_of_isMaximal_of_not_isField inferInstance, fun h =>
Ring.not_isField_iff_exists_prime.mpr ⟨_, h, Ideal.IsMaximal.isPrime' _⟩⟩
end CommSemiring
section CommRing
variable [CommRing R]
variable [IsLocalRing R]
theorem maximalIdeal_le_jacobson (I : Ideal R) :
IsLocalRing.maximalIdeal R ≤ I.jacobson :=
le_sInf fun _ ⟨_, h⟩ => le_of_eq (IsLocalRing.eq_maximalIdeal h).symm
theorem jacobson_eq_maximalIdeal (I : Ideal R) (h : I ≠ ⊤) :
I.jacobson = IsLocalRing.maximalIdeal R :=
le_antisymm (sInf_le ⟨le_maximalIdeal h, maximalIdeal.isMaximal R⟩)
(maximalIdeal_le_jacobson I)
variable (R) in
theorem ringJacobson_eq_maximalIdeal : Ring.jacobson R = maximalIdeal R :=
Ideal.jacobson_bot.symm.trans (jacobson_eq_maximalIdeal _ top_ne_bot.symm)
end CommRing
section
variable [CommRing R] [IsLocalRing R] [CommRing S] [IsLocalRing S]
theorem ker_eq_maximalIdeal [DivisionRing K] (φ : R →+* K) (hφ : Function.Surjective φ) :
RingHom.ker φ = maximalIdeal R :=
IsLocalRing.eq_maximalIdeal <| (RingHom.ker_isMaximal_of_surjective φ) hφ
end
theorem maximalIdeal_eq_bot {R : Type*} [Field R] : IsLocalRing.maximalIdeal R = ⊥ :=
IsLocalRing.isField_iff_maximalIdeal_eq.mp (Field.toIsField R)
end IsLocalRing
lemma Subsemiring.isLocalRing_of_unit {R : Type*} [Semiring R] [IsLocalRing R] (S : Subsemiring R)
(h_unit : ∀ (x : R) (hx : x ∈ S), IsUnit x → IsUnit (⟨x, hx⟩ : S)) :
IsLocalRing S where
isUnit_or_isUnit_of_add_one {x y} hxy :=
(‹IsLocalRing R›.isUnit_or_isUnit_of_add_one congr(Subtype.val $hxy)).elim
(fun hx ↦ Or.inl (h_unit x.val x.prop hx)) (fun hy ↦ Or.inr (h_unit y.val y.prop hy))
lemma Subring.isLocalRing_of_unit {R : Type*} [Ring R] [IsLocalRing R] (S : Subring R)
(h_unit : ∀ (x : R) (hx : x ∈ S), IsUnit x → IsUnit (⟨x, hx⟩ : S)) :
IsLocalRing S :=
S.toSubsemiring.isLocalRing_of_unit h_unit |
.lake/packages/mathlib/Mathlib/RingTheory/LocalRing/MaximalIdeal/Defs.lean | import Mathlib.RingTheory.LocalRing.Basic
/-!
# Maximal ideal of local rings
We define the maximal ideal of a local ring as the ideal of all nonunits.
## Main definitions
* `IsLocalRing.maximalIdeal`: The unique maximal ideal for a local rings. Its carrier set is the
set of nonunits.
-/
namespace IsLocalRing
variable (R : Type*) [CommSemiring R] [IsLocalRing R]
/-- The ideal of elements that are not units. -/
def maximalIdeal : Ideal R where
carrier := nonunits R
zero_mem' := zero_mem_nonunits.2 <| zero_ne_one
add_mem' {_ _} hx hy := nonunits_add hx hy
smul_mem' _ _ := mul_mem_nonunits_right
end IsLocalRing |
.lake/packages/mathlib/Mathlib/RingTheory/Trace/Basic.lean | import Mathlib.FieldTheory.Galois.Basic
import Mathlib.FieldTheory.Minpoly.MinpolyDiv
import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure
import Mathlib.FieldTheory.PurelyInseparable.Basic
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Charpoly.Minpoly
import Mathlib.LinearAlgebra.Vandermonde
import Mathlib.RingTheory.Trace.Defs
/-!
# Trace for (finite) ring extensions.
Suppose we have an `R`-algebra `S` with a finite basis. For each `s : S`,
the trace of the linear map given by multiplying by `s` gives information about
the roots of the minimal polynomial of `s` over `R`.
## Main definitions
* `Algebra.embeddingsMatrix A C b : Matrix κ (B →ₐ[A] C) C` is the matrix whose
`(i, σ)` coefficient is `σ (b i)`.
* `Algebra.embeddingsMatrixReindex A C b e : Matrix κ κ C` is the matrix whose `(i, j)`
coefficient is `σⱼ (b i)`, where `σⱼ : B →ₐ[A] C` is the embedding corresponding to `j : κ`
given by a bijection `e : κ ≃ (B →ₐ[A] C)`.
* `Module.Basis.traceDual`: The dual basis of a basis under the trace form in a finite separable
extension.
## Main results
* `trace_eq_sum_embeddings`: the trace of `x : K(x)` is the sum of all embeddings of `x` into an
algebraically closed field
* `traceForm_nondegenerate`: the trace form over a separable extension is a nondegenerate
bilinear form
* `Module.Basis.traceDual_powerBasis_eq`: The dual basis of a power basis `{1, x, x²...}` under the
trace form is `aᵢ / f'(x)`, with `f` being the minpoly of `x` and `f / (X - x) = ∑ aᵢxⁱ`.
## References
* https://en.wikipedia.org/wiki/Field_trace
-/
universe u v w z
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
variable [Algebra R S] [Algebra R T]
variable {K L : Type*} [Field K] [Field L] [Algebra K L]
variable {ι κ : Type w}
open Module
open LinearMap (BilinForm)
open LinearMap
open Matrix
open scoped Matrix
theorem Algebra.traceForm_toMatrix_powerBasis (h : PowerBasis R S) :
BilinForm.toMatrix h.basis (traceForm R S) = of fun i j => trace R S (h.gen ^ (i.1 + j.1)) := by
ext; rw [traceForm_toMatrix, of_apply, pow_add, h.basis_eq_pow, h.basis_eq_pow]
section EqSumRoots
open Algebra Polynomial
variable {F : Type*} [Field F]
variable [Algebra K S] [Algebra K F]
/-- Given `pb : PowerBasis K S`, the trace of `pb.gen` is `-(minpoly K pb.gen).nextCoeff`. -/
theorem PowerBasis.trace_gen_eq_nextCoeff_minpoly [Nontrivial S] (pb : PowerBasis K S) :
Algebra.trace K S pb.gen = -(minpoly K pb.gen).nextCoeff := by
have d_pos : 0 < pb.dim := PowerBasis.dim_pos pb
have d_pos' : 0 < (minpoly K pb.gen).natDegree := by simpa
haveI : Nonempty (Fin pb.dim) := ⟨⟨0, d_pos⟩⟩
rw [trace_eq_matrix_trace pb.basis, trace_eq_neg_charpoly_coeff, charpoly_leftMulMatrix, ←
pb.natDegree_minpoly, Fintype.card_fin, ← nextCoeff_of_natDegree_pos d_pos']
/-- Given `pb : PowerBasis K S`, then the trace of `pb.gen` is
`((minpoly K pb.gen).aroots F).sum`. -/
theorem PowerBasis.trace_gen_eq_sum_roots [Nontrivial S] (pb : PowerBasis K S)
(hf : (minpoly K pb.gen).Splits (algebraMap K F)) :
algebraMap K F (trace K S pb.gen) = ((minpoly K pb.gen).aroots F).sum := by
rw [PowerBasis.trace_gen_eq_nextCoeff_minpoly, RingHom.map_neg,
← nextCoeff_map_eq, nextCoeff_eq_neg_sum_roots_of_monic_of_splits
((minpoly.monic (PowerBasis.isIntegral_gen _)).map _) ((splits_id_iff_splits _).2 hf),
neg_neg]
namespace IntermediateField.AdjoinSimple
open IntermediateField
theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
Algebra.trace K K⟮x⟯ (AdjoinSimple.gen K x) = 0 := by
rw [trace_eq_zero_of_not_exists_basis, LinearMap.zero_apply]
contrapose! hx
obtain ⟨s, ⟨b⟩⟩ := hx
refine .of_mem_of_fg K⟮x⟯.toSubalgebra ?_ x ?_
· exact (Submodule.fg_iff_finiteDimensional _).mpr (b.finiteDimensional_of_finite)
· exact subset_adjoin K _ (Set.mem_singleton x)
theorem trace_gen_eq_sum_roots (x : L) (hf : (minpoly K x).Splits (algebraMap K F)) :
algebraMap K F (trace K K⟮x⟯ (AdjoinSimple.gen K x)) =
((minpoly K x).aroots F).sum := by
have injKxL := (algebraMap K⟮x⟯ L).injective
by_cases hx : IsIntegral K x; swap
· simp [minpoly.eq_zero hx, trace_gen_eq_zero hx, aroots_def]
rw [← adjoin.powerBasis_gen hx, (adjoin.powerBasis hx).trace_gen_eq_sum_roots] <;>
rw [adjoin.powerBasis_gen hx, ← minpoly.algebraMap_eq injKxL] <;>
try simp only [AdjoinSimple.algebraMap_gen _ _]
exact hf
end IntermediateField.AdjoinSimple
open IntermediateField
variable (K)
theorem trace_eq_trace_adjoin [FiniteDimensional K L] (x : L) :
trace K L x = finrank K⟮x⟯ L • trace K K⟮x⟯ (AdjoinSimple.gen K x) := by
rw [← trace_trace (S := K⟮x⟯)]
conv in x => rw [← AdjoinSimple.algebraMap_gen K x]
rw [trace_algebraMap, LinearMap.map_smul_of_tower]
variable {K} in
/-- Trace of the generator of a simple adjoin equals negative of the next coefficient of
its minimal polynomial coefficient. -/
theorem trace_adjoinSimpleGen {x : L} (hx : IsIntegral K x) :
trace K K⟮x⟯ (AdjoinSimple.gen K x) = -(minpoly K x).nextCoeff := by
simpa [minpoly_gen K x] using PowerBasis.trace_gen_eq_nextCoeff_minpoly <| adjoin.powerBasis hx
theorem trace_eq_finrank_mul_minpoly_nextCoeff [FiniteDimensional K L] (x : L) :
trace K L x = finrank K⟮x⟯ L * -(minpoly K x).nextCoeff := by
rw [trace_eq_trace_adjoin, trace_adjoinSimpleGen (.of_finite K x), Algebra.smul_def]; rfl
variable {K}
theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
(hF : (minpoly K x).Splits (algebraMap K F)) :
algebraMap K F (Algebra.trace K L x) =
finrank K⟮x⟯ L • ((minpoly K x).aroots F).sum := by
rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← Algebra.smul_def,
IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots _ hF, IsScalarTower.algebraMap_smul]
end EqSumRoots
variable {F : Type*} [Field F]
variable [Algebra R L] [Algebra L F] [Algebra R F] [IsScalarTower R L F]
open Polynomial
attribute [-instance] Field.toEuclideanDomain
theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegral R x) :
IsIntegral R (Algebra.trace L F x) := by
have hx' : IsIntegral L x := hx.tower_top
rw [← isIntegral_algebraMap_iff (algebraMap L (AlgebraicClosure F)).injective, trace_eq_sum_roots]
· refine (IsIntegral.multiset_sum ?_).nsmul _
intro y hy
rw [mem_roots_map (minpoly.ne_zero hx')] at hy
use minpoly R x, minpoly.monic hx
rw [← aeval_def] at hy ⊢
exact minpoly.aeval_of_isScalarTower R x y hy
· apply IsAlgClosed.splits_codomain
lemma Algebra.trace_eq_of_algEquiv {A B C : Type*} [CommRing A] [CommRing B] [CommRing C]
[Algebra A B] [Algebra A C] (e : B ≃ₐ[A] C) (x) :
Algebra.trace A C (e x) = Algebra.trace A B x := by
simp_rw [Algebra.trace_apply, ← LinearMap.trace_conj' _ e.toLinearEquiv]
congr; ext; simp [LinearEquiv.conj_apply]
lemma Algebra.trace_eq_of_ringEquiv {A B C : Type*} [CommRing A] [CommRing B] [CommRing C]
[Algebra A C] [Algebra B C] (e : A ≃+* B) (he : (algebraMap B C).comp e = algebraMap A C) (x) :
e (Algebra.trace A C x) = Algebra.trace B C x := by
classical
by_cases h : ∃ s : Finset C, Nonempty (Basis s B C)
· obtain ⟨s, ⟨b⟩⟩ := h
letI : Algebra A B := RingHom.toAlgebra e
letI : IsScalarTower A B C := IsScalarTower.of_algebraMap_eq' he.symm
rw [Algebra.trace_eq_matrix_trace b,
Algebra.trace_eq_matrix_trace (b.mapCoeffs e.symm (by simp [Algebra.smul_def, ← he]))]
rw [AddMonoidHom.map_trace]
congr
ext i j
simp [leftMulMatrix_apply, LinearMap.toMatrix_apply]
rw [trace_eq_zero_of_not_exists_basis _ h, trace_eq_zero_of_not_exists_basis,
LinearMap.zero_apply, LinearMap.zero_apply, map_zero]
intro ⟨s, ⟨b⟩⟩
exact h ⟨s, ⟨b.mapCoeffs e (by simp [Algebra.smul_def, ← he])⟩⟩
lemma Algebra.trace_eq_of_equiv_equiv {A₁ B₁ A₂ B₂ : Type*} [CommRing A₁] [CommRing B₁]
[CommRing A₂] [CommRing B₂] [Algebra A₁ B₁] [Algebra A₂ B₂] (e₁ : A₁ ≃+* A₂) (e₂ : B₁ ≃+* B₂)
(he : RingHom.comp (algebraMap A₂ B₂) ↑e₁ = RingHom.comp ↑e₂ (algebraMap A₁ B₁)) (x) :
Algebra.trace A₁ B₁ x = e₁.symm (Algebra.trace A₂ B₂ (e₂ x)) := by
letI := (RingHom.comp (e₂ : B₁ →+* B₂) (algebraMap A₁ B₁)).toAlgebra
let e' : B₁ ≃ₐ[A₁] B₂ := { e₂ with commutes' := fun _ ↦ rfl }
rw [← Algebra.trace_eq_of_ringEquiv e₁ he, ← Algebra.trace_eq_of_algEquiv e',
RingEquiv.symm_apply_apply]
rfl
section EqSumEmbeddings
variable [Algebra K F] [IsScalarTower K L F]
open Algebra IntermediateField
variable (F) (E : Type*) [Field E] [Algebra K E]
theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
(hE : (minpoly K pb.gen).Splits (algebraMap K E)) (hfx : IsSeparable K pb.gen) :
algebraMap K E (Algebra.trace K L pb.gen) =
(@Finset.univ _ (PowerBasis.AlgHom.fintype pb)).sum fun σ => σ pb.gen := by
letI := Classical.decEq E
letI : Fintype (L →ₐ[K] E) := PowerBasis.AlgHom.fintype pb
rw [pb.trace_gen_eq_sum_roots hE, Fintype.sum_equiv pb.liftEquiv', Finset.sum_mem_multiset,
Finset.sum_eq_multiset_sum, Multiset.toFinset_val, Multiset.dedup_eq_self.mpr _,
Multiset.map_id]
· exact nodup_roots ((separable_map _).mpr hfx)
swap
· intro x; rfl
· intro σ
rw [PowerBasis.liftEquiv'_apply_coe, id_def]
variable [IsAlgClosed E]
theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [Algebra.IsSeparable K F]
(pb : PowerBasis K L) :
∑ σ : F →ₐ[K] E, σ (algebraMap L F pb.gen) =
finrank L F •
(@Finset.univ _ (PowerBasis.AlgHom.fintype pb)).sum fun σ : L →ₐ[K] E => σ pb.gen := by
haveI : FiniteDimensional L F := FiniteDimensional.right K L F
haveI : Algebra.IsSeparable L F := Algebra.isSeparable_tower_top_of_isSeparable K L F
letI : Fintype (L →ₐ[K] E) := PowerBasis.AlgHom.fintype pb
rw [Fintype.sum_equiv algHomEquivSigma (fun σ : F →ₐ[K] E => _) fun σ => σ.1 pb.gen,
← Finset.univ_sigma_univ, Finset.sum_sigma, ← Finset.sum_nsmul]
· refine Finset.sum_congr rfl fun σ _ => ?_
letI : Algebra L E := σ.toRingHom.toAlgebra
simp_rw [Finset.sum_const, Finset.card_univ, ← AlgHom.card L F E]
· intro σ
simp only [algHomEquivSigma, Equiv.coe_fn_mk, AlgHom.restrictDomain, AlgHom.comp_apply,
IsScalarTower.coe_toAlgHom']
theorem trace_eq_sum_embeddings [FiniteDimensional K L] [Algebra.IsSeparable K L] {x : L} :
algebraMap K E (Algebra.trace K L x) = ∑ σ : L →ₐ[K] E, σ x := by
have hx := Algebra.IsSeparable.isIntegral K x
let pb := adjoin.powerBasis hx
rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← adjoin.powerBasis_gen hx,
trace_eq_sum_embeddings_gen E pb (IsAlgClosed.splits_codomain _), ← Algebra.smul_def,
algebraMap_smul]
· exact (sum_embeddings_eq_finrank_mul L E pb).symm
· haveI := Algebra.isSeparable_tower_bot_of_isSeparable K K⟮x⟯ L
exact Algebra.IsSeparable.isSeparable K _
theorem trace_eq_sum_automorphisms (x : L) [FiniteDimensional K L] [IsGalois K L] :
algebraMap K L (Algebra.trace K L x) = ∑ σ : Gal(L/K), σ x := by
apply FaithfulSMul.algebraMap_injective L (AlgebraicClosure L)
rw [_root_.map_sum (algebraMap L (AlgebraicClosure L))]
rw [← Fintype.sum_equiv (Normal.algHomEquivAut K (AlgebraicClosure L) L)]
· rw [← trace_eq_sum_embeddings (AlgebraicClosure L) (x := x)]
simp only [algebraMap_eq_smul_one, smul_one_smul]
· intro σ
simp only [Normal.algHomEquivAut, AlgHom.restrictNormal', Equiv.coe_fn_mk,
AlgEquiv.coe_ofBijective, AlgHom.restrictNormal_commutes, algebraMap_self, RingHom.id_apply]
end EqSumEmbeddings
section NotIsSeparable
lemma Algebra.trace_eq_zero_of_not_isSeparable (H : ¬ Algebra.IsSeparable K L) :
trace K L = 0 := by
obtain ⟨p, hp⟩ := ExpChar.exists K
have := expChar_ne_zero K p
ext x
by_cases h₀ : FiniteDimensional K L; swap
· rw [trace_eq_zero_of_not_exists_basis]
rintro ⟨s, ⟨b⟩⟩
exact h₀ (Module.Finite.of_basis b)
by_cases hx : IsSeparable K x
· lift x to separableClosure K L using hx
rw [← IntermediateField.algebraMap_apply, ← trace_trace (S := separableClosure K L),
trace_algebraMap]
obtain ⟨n, hn⟩ := IsPurelyInseparable.finrank_eq_pow (separableClosure K L) L p
cases n with
| zero =>
rw [pow_zero, IntermediateField.finrank_eq_one_iff_eq_top, separableClosure.eq_top_iff] at hn
cases H hn
| succ n =>
cases hp with
| zero =>
rw [one_pow, IntermediateField.finrank_eq_one_iff_eq_top, separableClosure.eq_top_iff] at hn
cases H hn
| prime hprime =>
rw [hn, pow_succ', MulAction.mul_smul, LinearMap.map_smul_of_tower, nsmul_eq_mul,
CharP.cast_eq_zero, zero_mul, LinearMap.zero_apply]
· rw [trace_eq_finrank_mul_minpoly_nextCoeff]
obtain ⟨g, hg₁, m, hg₂⟩ :=
(minpoly.irreducible (IsIntegral.isIntegral (R := K) x)).hasSeparableContraction p
cases m with
| zero =>
obtain rfl : g = minpoly K x := by simpa using hg₂
cases hx hg₁
| succ n =>
rw [nextCoeff, if_neg, ← hg₂, coeff_expand (by positivity),
if_neg, neg_zero, mul_zero, LinearMap.zero_apply]
· rw [natDegree_expand]
intro h
have := Nat.dvd_sub (dvd_mul_left (p ^ (n + 1)) g.natDegree) h
rw [tsub_tsub_cancel_of_le, Nat.dvd_one] at this
· obtain rfl : g = minpoly K x := by simpa [this] using hg₂
cases hx hg₁
· rw [Nat.one_le_iff_ne_zero]
have : g.natDegree ≠ 0 := fun e ↦ by
have := congr(natDegree $hg₂)
rw [natDegree_expand, e, zero_mul] at this
exact (minpoly.natDegree_pos (IsIntegral.isIntegral x)).ne this
positivity
· exact (minpoly.natDegree_pos (IsIntegral.isIntegral x)).ne'
end NotIsSeparable
section DetNeZero
namespace Algebra
variable (A : Type u) {B : Type v} (C : Type z)
variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C]
open Finset
/-- Given an `A`-algebra `B` and `b`, a `κ`-indexed family of elements of `B`, we define
`traceMatrix A b` as the matrix whose `(i j)`-th element is the trace of `b i * b j`. -/
noncomputable def traceMatrix (b : κ → B) : Matrix κ κ A :=
of fun i j => traceForm A B (b i) (b j)
-- TODO: set as an equation lemma for `traceMatrix`, see https://github.com/leanprover-community/mathlib4/pull/3024
@[simp]
theorem traceMatrix_apply (b : κ → B) (i j) : traceMatrix A b i j = traceForm A B (b i) (b j) :=
rfl
theorem traceMatrix_reindex {κ' : Type*} (b : Basis κ A B) (f : κ ≃ κ') :
traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) := by ext (x y); simp
variable {A}
theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
traceMatrix A (b ᵥ* P.map (algebraMap A B)) = Pᵀ * traceMatrix A b * P := by
ext (α β)
rw [traceMatrix_apply, vecMul, dotProduct, vecMul, dotProduct, Matrix.mul_apply,
BilinForm.sum_left,
Fintype.sum_congr _ _ fun i : κ =>
BilinForm.sum_right _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
b y * P.map (algebraMap A B) y β,
sum_comm]
congr; ext x
rw [Matrix.mul_apply, sum_mul]
congr; ext y
rw [map_apply, traceForm_apply, mul_comm (b y), ← smul_def]
simp only [id.smul_eq_mul, RingHom.id_apply, map_apply, transpose_apply, LinearMap.map_smulₛₗ,
Algebra.smul_mul_assoc]
rw [mul_comm (b x), ← smul_def]
ring_nf
rw [mul_assoc]
simp [mul_comm]
theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
traceMatrix A (P.map (algebraMap A B) *ᵥ b) = P * traceMatrix A b * Pᵀ := by
refine AddEquiv.injective (transposeAddEquiv κ κ A) ?_
rw [transposeAddEquiv_apply, transposeAddEquiv_apply, ← vecMul_transpose, ← transpose_map,
traceMatrix_of_matrix_vecMul, transpose_transpose]
theorem traceMatrix_of_basis [Fintype κ] [DecidableEq κ] (b : Basis κ A B) :
traceMatrix A b = BilinForm.toMatrix b (traceForm A B) := by
ext (i j)
rw [traceMatrix_apply, traceForm_apply, traceForm_toMatrix]
theorem traceMatrix_of_basis_mulVec [Fintype ι] (b : Basis ι A B) (z : B) :
traceMatrix A b *ᵥ b.equivFun z = fun i => trace A B (z * b i) := by
ext i
rw [← replicateCol_apply (ι := Fin 1) (traceMatrix A b *ᵥ b.equivFun z) i 0, replicateCol_mulVec,
Matrix.mul_apply, traceMatrix]
simp only [replicateCol_apply, traceForm_apply]
conv_lhs =>
congr
rfl
ext
rw [mul_comm _ (b.equivFun z _), ← smul_eq_mul, of_apply, ← LinearMap.map_smul]
rw [← _root_.map_sum]
congr
conv_lhs =>
congr
rfl
ext
rw [← mul_smul_comm]
rw [← Finset.mul_sum, mul_comm z]
congr
rw [b.sum_equivFun]
variable (A)
/-- `embeddingsMatrix A C b : Matrix κ (B →ₐ[A] C) C` is the matrix whose `(i, σ)` coefficient is
`σ (b i)`. It is mostly useful for fields when `Fintype.card κ = finrank A B` and `C` is
algebraically closed. -/
def embeddingsMatrix (b : κ → B) : Matrix κ (B →ₐ[A] C) C :=
of fun i (σ : B →ₐ[A] C) => σ (b i)
-- TODO: set as an equation lemma for `embeddingsMatrix`, see https://github.com/leanprover-community/mathlib4/pull/3024
@[simp]
theorem embeddingsMatrix_apply (b : κ → B) (i) (σ : B →ₐ[A] C) :
embeddingsMatrix A C b i σ = σ (b i) :=
rfl
/-- `embeddingsMatrixReindex A C b e : Matrix κ κ C` is the matrix whose `(i, j)` coefficient
is `σⱼ (b i)`, where `σⱼ : B →ₐ[A] C` is the embedding corresponding to `j : κ` given by a
bijection `e : κ ≃ (B →ₐ[A] C)`. It is mostly useful for fields and `C` is algebraically closed.
In this case, in presence of `h : Fintype.card κ = finrank A B`, one can take
`e := equivOfCardEq ((AlgHom.card A B C).trans h.symm)`. -/
def embeddingsMatrixReindex (b : κ → B) (e : κ ≃ (B →ₐ[A] C)) :=
reindex (Equiv.refl κ) e.symm (embeddingsMatrix A C b)
variable {A}
theorem embeddingsMatrixReindex_eq_vandermonde (pb : PowerBasis A B)
(e : Fin pb.dim ≃ (B →ₐ[A] C)) :
embeddingsMatrixReindex A C pb.basis e = (vandermonde fun i => e i pb.gen)ᵀ := by
ext i j
simp [embeddingsMatrixReindex, embeddingsMatrix]
section Field
variable (K) (E : Type z) [Field E]
variable [Algebra K E]
variable [Module.Finite K L] [Algebra.IsSeparable K L] [IsAlgClosed E]
variable (b : κ → L) (pb : PowerBasis K L)
theorem traceMatrix_eq_embeddingsMatrix_mul_trans : (traceMatrix K b).map (algebraMap K E) =
embeddingsMatrix K E b * (embeddingsMatrix K E b)ᵀ := by
ext (i j); simp [trace_eq_sum_embeddings, embeddingsMatrix, Matrix.mul_apply]
theorem traceMatrix_eq_embeddingsMatrixReindex_mul_trans [Fintype κ] (e : κ ≃ (L →ₐ[K] E)) :
(traceMatrix K b).map (algebraMap K E) =
embeddingsMatrixReindex K E b e * (embeddingsMatrixReindex K E b e)ᵀ := by
rw [traceMatrix_eq_embeddingsMatrix_mul_trans, embeddingsMatrixReindex, reindex_apply,
transpose_submatrix, ← submatrix_mul_transpose_submatrix, ← Equiv.coe_refl, Equiv.refl_symm]
end Field
end Algebra
open Algebra
variable (pb : PowerBasis K L)
theorem det_traceMatrix_ne_zero' [Algebra.IsSeparable K L] : det (traceMatrix K pb.basis) ≠ 0 := by
suffices algebraMap K (AlgebraicClosure L) (det (traceMatrix K pb.basis)) ≠ 0 by
refine mt (fun ht => ?_) this
rw [ht, RingHom.map_zero]
haveI : FiniteDimensional K L := pb.finite
let e : Fin pb.dim ≃ (L →ₐ[K] AlgebraicClosure L) := (Fintype.equivFinOfCardEq ?_).symm
· rw [RingHom.map_det, RingHom.mapMatrix_apply,
traceMatrix_eq_embeddingsMatrixReindex_mul_trans K _ _ e,
embeddingsMatrixReindex_eq_vandermonde, det_mul, det_transpose]
refine mt mul_self_eq_zero.mp ?_
simp only [det_vandermonde, Finset.prod_eq_zero_iff, not_exists, sub_eq_zero]
rintro i ⟨_, j, hij, h⟩
exact (Finset.mem_Ioi.mp hij).ne' (e.injective <| pb.algHom_ext h)
· rw [AlgHom.card, pb.finrank]
theorem det_traceForm_ne_zero [Algebra.IsSeparable K L] [Fintype ι] [DecidableEq ι]
(b : Basis ι K L) :
det (BilinForm.toMatrix b (traceForm K L)) ≠ 0 := by
haveI : FiniteDimensional K L := b.finiteDimensional_of_finite
let pb : PowerBasis K L := Field.powerBasisOfFiniteOfSeparable _ _
rw [← BilinForm.toMatrix_mul_basis_toMatrix pb.basis b, ←
det_comm' (pb.basis.toMatrix_mul_toMatrix_flip b) _, ← Matrix.mul_assoc, det_mul]
swap; · apply Basis.toMatrix_mul_toMatrix_flip
refine
mul_ne_zero
(IsUnit.of_mul_eq_one ((b.toMatrix pb.basis)ᵀ * b.toMatrix pb.basis).det ?_).ne_zero ?_
· calc
(pb.basis.toMatrix b * (pb.basis.toMatrix b)ᵀ).det *
((b.toMatrix pb.basis)ᵀ * b.toMatrix pb.basis).det =
(pb.basis.toMatrix b * (b.toMatrix pb.basis * pb.basis.toMatrix b)ᵀ *
b.toMatrix pb.basis).det := by
simp only [← det_mul, Matrix.mul_assoc, Matrix.transpose_mul]
_ = 1 := by
simp only [Basis.toMatrix_mul_toMatrix_flip, Matrix.transpose_one, Matrix.mul_one,
Matrix.det_one]
simpa only [traceMatrix_of_basis] using det_traceMatrix_ne_zero' pb
variable (K L)
/-- Let $L/K$ be a finite extension of fields. If $L/K$ is separable,
then `traceForm` is nondegenerate. -/
@[stacks 0BIL "(1) => (3)"]
theorem traceForm_nondegenerate [FiniteDimensional K L] [Algebra.IsSeparable K L] :
(traceForm K L).Nondegenerate :=
BilinForm.nondegenerate_of_det_ne_zero (traceForm K L) _
(det_traceForm_ne_zero (Module.finBasis K L))
@[stacks 0BIL]
theorem traceForm_nondegenerate_tfae [FiniteDimensional K L] :
[Algebra.IsSeparable K L, Algebra.trace K L ≠ 0, (traceForm K L).Nondegenerate].TFAE := by
tfae_have 1 → 3 := fun _ ↦ traceForm_nondegenerate K L
tfae_have 3 → 2 := fun H₁ H₂ ↦ H₁.ne_zero (by ext; simp [H₂])
tfae_have 2 → 1 := not_imp_comm.mp Algebra.trace_eq_zero_of_not_isSeparable
tfae_finish
theorem Algebra.trace_ne_zero [FiniteDimensional K L] [Algebra.IsSeparable K L] :
Algebra.trace K L ≠ 0 :=
((traceForm_nondegenerate_tfae K L).out 0 1).mp ‹_›
theorem Algebra.trace_surjective [FiniteDimensional K L] [Algebra.IsSeparable K L] :
Function.Surjective (Algebra.trace K L) := by
rw [← LinearMap.range_eq_top]
apply (IsSimpleOrder.eq_bot_or_eq_top (α := Ideal K) _).resolve_left
rw [LinearMap.range_eq_bot]
exact Algebra.trace_ne_zero K L
end DetNeZero
section isNilpotent
namespace Algebra
/-- The trace of a nilpotent element is nilpotent. -/
lemma isNilpotent_trace_of_isNilpotent {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] {x : S}
(hx : IsNilpotent x) : IsNilpotent (trace R S x) :=
LinearMap.isNilpotent_trace_of_isNilpotent (hx.map (lmul R S))
@[deprecated (since := "2025-10-21")] alias trace_isNilpotent_of_isNilpotent :=
isNilpotent_trace_of_isNilpotent
end Algebra
end isNilpotent
section Basis
open Algebra
variable [FiniteDimensional K L] [Algebra.IsSeparable K L] [Finite ι] [DecidableEq ι]
(b : Basis ι K L)
/--
The dual basis of a basis under the trace form in a finite separable extension.
-/
noncomputable def Module.Basis.traceDual :
Basis ι K L :=
(traceForm K L).dualBasis (traceForm_nondegenerate K L) b
theorem Module.Basis.traceDual_def :
b.traceDual = (traceForm K L).dualBasis (traceForm_nondegenerate K L) b := rfl
@[simp]
theorem Module.Basis.traceDual_repr_apply (x : L) (i : ι) :
(b.traceDual).repr x i = (traceForm K L x) (b i) :=
(traceForm K L).dualBasis_repr_apply _ b _ i
@[simp]
theorem Module.Basis.trace_traceDual_mul (i j : ι) :
trace K L ((b.traceDual i) * (b j)) = if j = i then 1 else 0 :=
(traceForm K L).apply_dualBasis_left _ _ i j
@[simp]
theorem Module.Basis.trace_mul_traceDual (i j : ι) :
trace K L ((b i) * (b.traceDual j)) = if i = j then 1 else 0 :=
(traceForm K L).apply_dualBasis_right _ (traceForm_isSymm K) _ i j
@[simp]
theorem Module.Basis.traceDual_traceDual :
b.traceDual.traceDual = b :=
(traceForm K L).dualBasis_dualBasis _ (traceForm_isSymm K) _
variable (K L)
theorem Module.Basis.traceDual_involutive :
Function.Involutive (Basis.traceDual : Basis ι K L → Basis ι K L) :=
(traceForm K L).dualBasis_involutive _ (traceForm_isSymm K)
theorem Module.Basis.traceDual_injective :
Function.Injective (Basis.traceDual : Basis ι K L → Basis ι K L) :=
(traceForm K L).dualBasis_injective _ (traceForm_isSymm K)
variable {K L b}
@[simp]
theorem Module.Basis.traceDual_inj {b' : Basis ι K L} :
b.traceDual = b'.traceDual ↔ b = b' :=
(traceDual_injective K L).eq_iff
/--
A family of vectors `v` is the dual for the trace of the basis `b` if and only if
`∀ i j, Tr(v i * b j) = δ_ij`.
-/
@[simp]
theorem Module.Basis.traceDual_eq_iff {v : ι → L} :
b.traceDual = v ↔ ∀ i j, traceForm K L (v i) (b j) = if j = i then 1 else 0 :=
(traceForm K L).dualBasis_eq_iff (traceForm_nondegenerate K L) b v
/--
The dual basis of a powerbasis `{1, x, x²...}` under the trace form is `aᵢ / f'(x)`,
with `f` being the minimal polynomial of `x` and `f / (X - x) = ∑ aᵢxⁱ`.
-/
lemma Module.Basis.traceDual_powerBasis_eq (pb : PowerBasis K L) (i) :
pb.basis.traceDual i =
(minpolyDiv K pb.gen).coeff i / aeval pb.gen (derivative <| minpoly K pb.gen) := by
revert i
rw [← funext_iff, Basis.traceDual_eq_iff]
intro i j
apply (algebraMap K (AlgebraicClosure K)).injective
have := congr_arg (coeff · i) (sum_smul_minpolyDiv_eq_X_pow (AlgebraicClosure K)
pb.adjoin_gen_eq_top (r := j) (pb.finrank.symm ▸ j.prop))
simp only [Polynomial.map_smul, map_div₀, map_pow, RingHom.coe_coe, finset_sum_coeff, coeff_smul,
coeff_map, smul_eq_mul, coeff_X_pow, ← Fin.ext_iff, @eq_comm _ i] at this
rw [PowerBasis.coe_basis]
simp only [traceForm_apply, MonoidWithZeroHom.map_ite_one_zero]
rw [← this, trace_eq_sum_embeddings (E := AlgebraicClosure K)]
apply Finset.sum_congr rfl
intro σ _
simp only [map_mul, map_div₀, map_pow]
ring
@[deprecated (since := "2025-06-25")] alias traceForm_dualBasis_powerBasis_eq :=
Module.Basis.traceDual_powerBasis_eq
end Basis |
.lake/packages/mathlib/Mathlib/RingTheory/Trace/Quotient.lean | import Mathlib.RingTheory.DedekindDomain.Dvr
import Mathlib.RingTheory.IntegralClosure.IntegralRestrict
import Mathlib.RingTheory.LocalRing.Quotient
/-!
We gather results about the relations between the trace map on `B → A` and the trace map on
quotients and localizations.
## Main Results
* `Algebra.trace_quotient_eq_of_isDedekindDomain` : The trace map on `B → A` coincides with the
trace map on `B⧸pB → A⧸p`.
-/
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S]
open IsLocalRing FiniteDimensional Submodule
section IsLocalRing
local notation "p" => maximalIdeal R
local notation "pS" => Ideal.map (algebraMap R S) p
variable [Module.Free R S] [Module.Finite R S]
attribute [local instance] Ideal.Quotient.field
lemma Algebra.trace_quotient_mk [IsLocalRing R] (x : S) :
Algebra.trace (R ⧸ p) (S ⧸ pS) (Ideal.Quotient.mk pS x) =
Ideal.Quotient.mk p (Algebra.trace R S x) := by
classical
let ι := Module.Free.ChooseBasisIndex R S
let b : Module.Basis ι R S := Module.Free.chooseBasis R S
rw [trace_eq_matrix_trace b, trace_eq_matrix_trace (basisQuotient b), AddMonoidHom.map_trace]
congr 1
ext i j
simp only [leftMulMatrix_apply, coe_lmul_eq_mul, LinearMap.toMatrix_apply,
basisQuotient_apply, LinearMap.mul_apply', Matrix.map_apply, ← map_mul,
basisQuotient_repr]
end IsLocalRing
section IsDedekindDomain
variable (p : Ideal R) [p.IsMaximal]
variable {Rₚ Sₚ : Type*} [CommRing Rₚ] [CommRing Sₚ] [Algebra R Rₚ] [IsLocalization.AtPrime Rₚ p]
variable [IsLocalRing Rₚ] [Algebra S Sₚ] [Algebra R Sₚ] [Algebra Rₚ Sₚ]
variable [IsLocalization (Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ]
variable [IsScalarTower R S Sₚ] [IsScalarTower R Rₚ Sₚ]
variable (Rₚ)
attribute [local instance] Ideal.Quotient.field
/-- The isomorphism `R ⧸ p ≃+* Rₚ ⧸ maximalIdeal Rₚ`, where `Rₚ` satisfies
`IsLocalization.AtPrime Rₚ p`. In particular, localization preserves the residue field. -/
noncomputable
def equivQuotMaximalIdealOfIsLocalization : R ⧸ p ≃+* Rₚ ⧸ maximalIdeal Rₚ := by
refine (Ideal.quotEquivOfEq ?_).trans
(RingHom.quotientKerEquivOfSurjective (f := algebraMap R (Rₚ ⧸ maximalIdeal Rₚ)) ?_)
· rw [IsScalarTower.algebraMap_eq R Rₚ, ← RingHom.comap_ker,
Ideal.Quotient.algebraMap_eq, Ideal.mk_ker, IsLocalization.AtPrime.comap_maximalIdeal Rₚ p]
· intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq p.primeCompl x
obtain ⟨s', hs⟩ := Ideal.Quotient.mk_surjective (I := p) (Ideal.Quotient.mk p s)⁻¹
simp only [IsScalarTower.algebraMap_eq R Rₚ (Rₚ ⧸ _),
Ideal.Quotient.algebraMap_eq, RingHom.comp_apply]
use x * s'
rw [← sub_eq_zero, ← map_sub, Ideal.Quotient.eq_zero_iff_mem]
have : algebraMap R Rₚ s ∉ maximalIdeal Rₚ := by
rw [← Ideal.mem_comap, IsLocalization.AtPrime.comap_maximalIdeal Rₚ p]
exact s.prop
refine ((inferInstanceAs <| (maximalIdeal Rₚ).IsPrime).mem_or_mem ?_).resolve_left this
rw [mul_sub, IsLocalization.mul_mk'_eq_mk'_of_mul, IsLocalization.mk'_mul_cancel_left,
← map_mul, ← map_sub, ← Ideal.mem_comap, IsLocalization.AtPrime.comap_maximalIdeal Rₚ p,
mul_left_comm, ← Ideal.Quotient.eq_zero_iff_mem, map_sub, map_mul, map_mul, hs,
mul_inv_cancel₀, mul_one, sub_self]
rw [Ne, Ideal.Quotient.eq_zero_iff_mem]
exact s.prop
local notation "pS" => Ideal.map (algebraMap R S) p
local notation "pSₚ" => Ideal.map (algebraMap Rₚ Sₚ) (maximalIdeal Rₚ)
lemma comap_map_eq_map_of_isLocalization_algebraMapSubmonoid :
(Ideal.map (algebraMap R Sₚ) p).comap (algebraMap S Sₚ) = pS := by
rw [IsScalarTower.algebraMap_eq R S Sₚ, ← Ideal.map_map, eq_comm]
apply Ideal.le_comap_map.antisymm
intro x hx
obtain ⟨α, hα, hαx⟩ : ∃ α ∉ p, α • x ∈ pS := by
have ⟨⟨y, s⟩, hy⟩ := (IsLocalization.mem_map_algebraMap_iff
(Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ).mp hx
rw [← map_mul,
IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S p.primeCompl)] at hy
obtain ⟨c, hc⟩ := hy
obtain ⟨α, hα, e⟩ := (c * s).prop
refine ⟨α, hα, ?_⟩
rw [Algebra.smul_def, e, Submonoid.coe_mul, mul_assoc, mul_comm _ x, hc]
exact Ideal.mul_mem_left _ _ y.prop
obtain ⟨β, γ, hγ, hβ⟩ : ∃ β γ, γ ∈ p ∧ β * α = 1 + γ := by
obtain ⟨β, hβ⟩ := Ideal.Quotient.mk_surjective (I := p) (Ideal.Quotient.mk p α)⁻¹
refine ⟨β, β * α - 1, ?_, ?_⟩
· rw [← Ideal.Quotient.eq_zero_iff_mem, map_sub, map_one,
map_mul, hβ, inv_mul_cancel₀, sub_self]
rwa [Ne, Ideal.Quotient.eq_zero_iff_mem]
· rw [add_sub_cancel]
have := Ideal.mul_mem_left _ (algebraMap _ _ β) hαx
rw [← Algebra.smul_def, smul_smul, hβ, add_smul, one_smul] at this
refine (Submodule.add_mem_iff_left _ ?_).mp this
rw [Algebra.smul_def]
apply Ideal.mul_mem_right
exact Ideal.mem_map_of_mem _ hγ
variable (S Sₚ)
/-- The isomorphism `S ⧸ pS ≃+* Sₚ ⧸ pSₚ`. -/
noncomputable
def quotMapEquivQuotMapMaximalIdealOfIsLocalization : S ⧸ pS ≃+* Sₚ ⧸ pSₚ := by
haveI h : pSₚ = Ideal.map (algebraMap S Sₚ) pS := by
rw [← IsLocalization.AtPrime.map_eq_maximalIdeal p Rₚ, Ideal.map_map,
← IsScalarTower.algebraMap_eq, Ideal.map_map, ← IsScalarTower.algebraMap_eq]
refine (Ideal.quotEquivOfEq ?_).trans
(RingHom.quotientKerEquivOfSurjective (f := algebraMap S (Sₚ ⧸ pSₚ)) ?_)
· rw [IsScalarTower.algebraMap_eq S Sₚ, Ideal.Quotient.algebraMap_eq, ← RingHom.comap_ker,
Ideal.mk_ker, h, Ideal.map_map, ← IsScalarTower.algebraMap_eq,
comap_map_eq_map_of_isLocalization_algebraMapSubmonoid]
· intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq
(Algebra.algebraMapSubmonoid S p.primeCompl) x
obtain ⟨α, hα : α ∉ p, e⟩ := s.prop
obtain ⟨β, γ, hγ, hβ⟩ : ∃ β γ, γ ∈ p ∧ α * β = 1 + γ := by
obtain ⟨β, hβ⟩ := Ideal.Quotient.mk_surjective (I := p) (Ideal.Quotient.mk p α)⁻¹
refine ⟨β, α * β - 1, ?_, ?_⟩
· rw [← Ideal.Quotient.eq_zero_iff_mem, map_sub, map_one,
map_mul, hβ, mul_inv_cancel₀, sub_self]
rwa [Ne, Ideal.Quotient.eq_zero_iff_mem]
· rw [add_sub_cancel]
use β • x
rw [IsScalarTower.algebraMap_eq S Sₚ (Sₚ ⧸ pSₚ), Ideal.Quotient.algebraMap_eq,
RingHom.comp_apply, ← sub_eq_zero, ← map_sub, Ideal.Quotient.eq_zero_iff_mem]
rw [h, IsLocalization.mem_map_algebraMap_iff
(Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ]
refine ⟨⟨⟨γ • x, ?_⟩, s⟩, ?_⟩
· rw [Algebra.smul_def]
apply Ideal.mul_mem_right
exact Ideal.mem_map_of_mem _ hγ
simp only
rw [mul_comm, mul_sub, IsLocalization.mul_mk'_eq_mk'_of_mul,
IsLocalization.mk'_mul_cancel_left, ← map_mul, ← e, ← Algebra.smul_def, smul_smul,
hβ, ← map_sub, add_smul, one_smul, add_comm x, add_sub_cancel_right]
lemma trace_quotient_eq_trace_localization_quotient (x) :
Algebra.trace (R ⧸ p) (S ⧸ pS) (Ideal.Quotient.mk pS x) =
(equivQuotMaximalIdealOfIsLocalization p Rₚ).symm
(Algebra.trace (Rₚ ⧸ maximalIdeal Rₚ) (Sₚ ⧸ pSₚ) (algebraMap S _ x)) := by
have : IsScalarTower R (Rₚ ⧸ maximalIdeal Rₚ) (Sₚ ⧸ pSₚ) := by
apply IsScalarTower.of_algebraMap_eq'
rw [IsScalarTower.algebraMap_eq R Rₚ (Rₚ ⧸ _), IsScalarTower.algebraMap_eq R Rₚ (Sₚ ⧸ _),
← RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq Rₚ]
rw [Algebra.trace_eq_of_equiv_equiv (equivQuotMaximalIdealOfIsLocalization p Rₚ)
(quotMapEquivQuotMapMaximalIdealOfIsLocalization S p Rₚ Sₚ)]
· congr
· ext x
simp only [equivQuotMaximalIdealOfIsLocalization, RingHom.quotientKerEquivOfSurjective,
RingEquiv.coe_ringHom_trans, RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply,
Ideal.quotEquivOfEq_mk, RingHom.quotientKerEquivOfRightInverse.apply, RingHom.kerLift_mk,
quotMapEquivQuotMapMaximalIdealOfIsLocalization,
Ideal.Quotient.algebraMap_quotient_map_quotient]
rw [← IsScalarTower.algebraMap_apply, ← IsScalarTower.algebraMap_apply]
open nonZeroDivisors in
/-- The trace map on `B → A` coincides with the trace map on `B⧸pB → A⧸p`. -/
lemma Algebra.trace_quotient_eq_of_isDedekindDomain (x) [IsDedekindDomain R] [IsDomain S]
[NoZeroSMulDivisors R S] [Module.Finite R S] [IsIntegrallyClosed S] :
Algebra.trace (R ⧸ p) (S ⧸ pS) (Ideal.Quotient.mk pS x) =
Ideal.Quotient.mk p (Algebra.intTrace R S x) := by
let Rₚ := Localization.AtPrime p
let Sₚ := Localization (Algebra.algebraMapSubmonoid S p.primeCompl)
letI : Algebra Rₚ Sₚ := localizationAlgebra p.primeCompl S
haveI : IsScalarTower R Rₚ Sₚ := IsScalarTower.of_algebraMap_eq'
(by rw [RingHom.algebraMap_toAlgebra, IsLocalization.map_comp, ← IsScalarTower.algebraMap_eq])
haveI : IsLocalization (Submonoid.map (algebraMap R S) (Ideal.primeCompl p)) Sₚ :=
inferInstanceAs (IsLocalization (Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ)
have e : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
Submonoid.map_le_of_le_comap _ <| p.primeCompl_le_nonZeroDivisors.trans
(nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _
(FaithfulSMul.algebraMap_injective _ _))
haveI : IsDomain Sₚ := IsLocalization.isDomain_of_le_nonZeroDivisors _ e
haveI : NoZeroSMulDivisors Rₚ Sₚ := by
rw [NoZeroSMulDivisors.iff_algebraMap_injective, RingHom.injective_iff_ker_eq_bot,
RingHom.ker_eq_bot_iff_eq_zero]
simp
haveI : Module.Finite Rₚ Sₚ := .of_isLocalization R S p.primeCompl
haveI : IsIntegrallyClosed Sₚ := isIntegrallyClosed_of_isLocalization _ _ e
have : IsPrincipalIdealRing Rₚ := by
by_cases hp : p = ⊥
· infer_instance
· have := (IsDedekindDomain.isDedekindDomainDvr R).2 p hp inferInstance
infer_instance
haveI : Module.Free Rₚ Sₚ := Module.free_of_finite_type_torsion_free'
apply (equivQuotMaximalIdealOfIsLocalization p Rₚ).injective
rw [trace_quotient_eq_trace_localization_quotient S p Rₚ Sₚ, IsScalarTower.algebraMap_eq S Sₚ,
RingHom.comp_apply, Ideal.Quotient.algebraMap_eq, Algebra.trace_quotient_mk,
RingEquiv.apply_symm_apply, ← Algebra.intTrace_eq_trace,
← Algebra.intTrace_eq_of_isLocalization R S p.primeCompl (Aₘ := Rₚ) (Bₘ := Sₚ) x,
← Ideal.Quotient.algebraMap_eq, ← IsScalarTower.algebraMap_apply]
simp only [equivQuotMaximalIdealOfIsLocalization, RingHom.quotientKerEquivOfSurjective,
RingEquiv.coe_trans, Function.comp_apply, Ideal.quotEquivOfEq_mk,
RingHom.quotientKerEquivOfRightInverse.apply, RingHom.kerLift_mk]
end IsDedekindDomain |
.lake/packages/mathlib/Mathlib/RingTheory/Trace/Defs.lean | import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas
import Mathlib.LinearAlgebra.Matrix.BilinearForm
import Mathlib.LinearAlgebra.Trace
/-!
# Trace for (finite) ring extensions.
Suppose we have an `R`-algebra `S` with a finite basis. For each `s : S`,
the trace of the linear map given by multiplying by `s` gives information about
the roots of the minimal polynomial of `s` over `R`.
## Main definitions
* `Algebra.trace R S x`: the trace of an element `s` of an `R`-algebra `S`
* `Algebra.traceForm R S`: bilinear form sending `x`, `y` to the trace of `x * y`
* `Algebra.traceMatrix R b`: the matrix whose `(i j)`-th element is the trace of `b i * b j`.
## Main results
* `trace_algebraMap_of_basis`, `trace_algebraMap`: if `x : K`, then `Tr_{L/K} x = [L : K] x`
* `trace_trace_of_basis`, `trace_trace`: `Tr_{L/K} (Tr_{F/L} x) = Tr_{F/K} x`
## Implementation notes
Typically, the trace is defined specifically for finite field extensions.
The definition is as general as possible and the assumption that the extension is finite
is added to the lemmas as needed.
We only define the trace for left multiplication (`Algebra.leftMulMatrix`,
i.e. `LinearMap.mulLeft`).
For now, the definitions assume `S` is commutative, so the choice doesn't matter anyway.
## References
* https://en.wikipedia.org/wiki/Field_trace
-/
universe w
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
variable [Algebra R S] [Algebra R T]
variable {ι : Type w} [Fintype ι]
open Module
open LinearMap (BilinForm)
open LinearMap
open Matrix
open scoped Matrix
namespace Algebra
variable (R S)
/-- The trace of an element `s` of an `R`-algebra is the trace of `(s * ·)`,
as an `R`-linear map. -/
@[stacks 0BIF "Trace"]
noncomputable def trace : S →ₗ[R] R :=
(LinearMap.trace R S).comp (lmul R S).toLinearMap
variable {S}
-- Not a `simp` lemma since there are more interesting ways to rewrite `trace R S x`,
-- for example `trace_trace`
theorem trace_apply (x) : trace R S x = LinearMap.trace R S (lmul R S x) :=
rfl
theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) :
trace R S = 0 := by ext s; simp [trace_apply, LinearMap.trace, h]
variable {R}
-- Can't be a `simp` lemma because it depends on a choice of basis
theorem trace_eq_matrix_trace [DecidableEq ι] (b : Basis ι R S) (s : S) :
trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) := by
rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← toMatrix_lmul_eq]; rfl
/-- If `x` is in the base field `K`, then the trace is `[L : K] * x`. -/
theorem trace_algebraMap_of_basis (b : Basis ι R S) (x : R) :
trace R S (algebraMap R S x) = Fintype.card ι • x := by
haveI := Classical.decEq ι
rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace]
convert Finset.sum_const x
simp [-coe_lmul_eq_mul]
/-- The trace map from `R` to itself is the identity map. -/
@[simp] theorem trace_self : trace R R = LinearMap.id := by
ext; simpa using trace_algebraMap_of_basis (.singleton (Fin 1) R) 1
theorem trace_self_apply (a) : trace R R a = a := by simp
/-- If `x` is in the base field `K`, then the trace is `[L : K] * x`.
(If `L` is not finite-dimensional over `K`, then `trace` and `finrank` return `0`.)
-/
@[simp]
theorem trace_algebraMap [StrongRankCondition R] [Module.Free R S] (x : R) :
trace R S (algebraMap R S x) = finrank R S • x := by
by_cases H : ∃ s : Finset S, Nonempty (Basis s R S)
· rw [trace_algebraMap_of_basis H.choose_spec.some, finrank_eq_card_basis H.choose_spec.some]
· simp [trace_eq_zero_of_not_exists_basis R H, finrank_eq_zero_of_not_exists_basis_finset H]
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
[Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
trace R S (trace S T x) = trace R T x := by
haveI := Classical.decEq ι
haveI := Classical.decEq κ
cases nonempty_fintype ι
cases nonempty_fintype κ
rw [trace_eq_matrix_trace (b.smulTower c), trace_eq_matrix_trace b, trace_eq_matrix_trace c,
Matrix.trace, Matrix.trace, Matrix.trace, ← Finset.univ_product_univ, Finset.sum_product]
refine Finset.sum_congr rfl fun i _ ↦ ?_
simp only [map_sum, smulTower_leftMulMatrix, Finset.sum_apply, Matrix.diag,
Finset.sum_apply i (Finset.univ : Finset κ) fun y => leftMulMatrix b (leftMulMatrix c x y y)]
theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
[Finite κ] (b : Basis ι R S) (c : Basis κ S T) :
(trace R S).comp ((trace S T).restrictScalars R) = trace R T := by
ext
rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace_of_basis b c]
@[simp]
theorem trace_trace [Algebra S T] [IsScalarTower R S T]
[Module.Free R S] [Module.Finite R S] [Module.Free S T] [Module.Finite S T] (x : T) :
trace R S (trace S T x) = trace R T x :=
trace_trace_of_basis (Module.Free.chooseBasis R S) (Module.Free.chooseBasis S T) x
/-- Let `T / S / R` be a tower of finite extensions of fields. Then
$\text{Trace}_{T/R} = \text{Trace}_{S/R} \circ \text{Trace}_{T/S}$. -/
@[simp, stacks 0BIJ "Trace"]
theorem trace_comp_trace [Algebra S T] [IsScalarTower R S T]
[Module.Free R S] [Module.Finite R S] [Module.Free S T] [Module.Finite S T] :
(trace R S).comp ((trace S T).restrictScalars R) = trace R T :=
LinearMap.ext trace_trace
@[simp]
theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T]
(x : S × T) : trace R (S × T) x = trace R S x.fst + trace R T x.snd := by
nontriviality R
let f := (lmul R S).toLinearMap.prodMap (lmul R T).toLinearMap
have : (lmul R (S × T)).toLinearMap = (prodMapLinear R S T S T R).comp f :=
LinearMap.ext₂ Prod.mul_def
simp_rw [trace, this]
exact trace_prodMap' _ _
theorem trace_prod [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T] :
trace R (S × T) = (trace R S).coprod (trace R T) :=
LinearMap.ext fun p => by rw [coprod_apply, trace_prod_apply]
section TraceForm
variable (R S)
/-- The `traceForm` maps `x y : S` to the trace of `x * y`.
It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
@[stacks 0BIK "Trace pairing"]
noncomputable def traceForm : BilinForm R S :=
LinearMap.compr₂ (lmul R S).toLinearMap (trace R S)
variable {S}
-- This is a nicer lemma than the one produced by `@[simps] def traceForm`.
@[simp]
theorem traceForm_apply (x y : S) : traceForm R S x y = trace R S (x * y) :=
rfl
theorem traceForm_isSymm : (traceForm R S).IsSymm :=
⟨fun _ _ => congr_arg (trace R S) (mul_comm _ _)⟩
theorem traceForm_toMatrix [DecidableEq ι] (b : Basis ι R S) (i j) :
BilinForm.toMatrix b (traceForm R S) i j = trace R S (b i * b j) := by
rw [BilinForm.toMatrix_apply, traceForm_apply]
end TraceForm
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Basic.lean | import Mathlib.LinearAlgebra.TensorProduct.RightExactness
import Mathlib.RingTheory.Ideal.Cotangent
import Mathlib.RingTheory.Localization.Defs
/-!
# Extension of algebras
## Main definition
- `Algebra.Extension`: An extension of an `R`-algebra `S` is an `R` algebra `P` together with a
surjection `P →ₐ[R] R`.
- `Algebra.Extension.Hom`: Given a commuting square
```
R --→ P -→ S
| |
↓ ↓
R' -→ P' → S
```
A hom between `P` and `P'` is a ring homomorphism that makes the two squares commute.
- `Algebra.Extension.Cotangent`:
The cotangent space w.r.t. an extension `P → S` by `I`, i.e. the space `I/I²`.
-/
universe w u v
open TensorProduct MvPolynomial
variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S]
/--
An extension of an `R`-algebra `S` is an `R` algebra `P` together with a surjection `P →ₐ[R] S`.
Also see `Algebra.Extension.ofSurjective`.
-/
structure Algebra.Extension where
/-- The underlying algebra of an extension. -/
Ring : Type w
[commRing : CommRing Ring]
[algebra₁ : Algebra R Ring]
[algebra₂ : Algebra Ring S]
[isScalarTower : IsScalarTower R Ring S]
/-- A chosen (set-theoretic) section of an extension. -/
σ : S → Ring
algebraMap_σ : ∀ x, algebraMap Ring S (σ x) = x
namespace Algebra.Extension
variable {R S}
variable (P : Extension.{w} R S)
attribute [instance] commRing algebra₁ algebra₂ isScalarTower
attribute [simp] algebraMap_σ
-- We want to make sure `R₀` acts compatibly on `R` and `S` to avoid nonsensical instances
@[nolint unusedArguments]
noncomputable instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S] :
Algebra R₀ P.Ring := Algebra.compHom P.Ring (algebraMap R₀ R)
instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S] :
IsScalarTower R₀ R P.Ring := IsScalarTower.of_algebraMap_eq' rfl
instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S]
{R₁} [CommRing R₁] [Algebra R₁ R] [Algebra R₁ S] [IsScalarTower R₁ R S]
[Algebra R₀ R₁] [IsScalarTower R₀ R₁ R] :
IsScalarTower R₀ R₁ P.Ring := IsScalarTower.of_algebraMap_eq' <| by
rw [IsScalarTower.algebraMap_eq R₀ R, IsScalarTower.algebraMap_eq R₁ R,
RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq R₀ R₁ R]
instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S] :
IsScalarTower R₀ P.Ring S := IsScalarTower.of_algebraMap_eq' <| by
rw [IsScalarTower.algebraMap_eq R₀ R P.Ring, ← RingHom.comp_assoc,
← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq]
@[simp]
lemma σ_smul (x y) : P.σ x • y = x * y := by
rw [Algebra.smul_def, algebraMap_σ]
lemma σ_injective : P.σ.Injective := by
intro x y e
rw [← P.algebraMap_σ x, ← P.algebraMap_σ y, e]
lemma algebraMap_surjective : Function.Surjective (algebraMap P.Ring S) := (⟨_, P.algebraMap_σ ·⟩)
section Construction
/-- Construct `Extension` from a surjective algebra homomorphism. -/
@[simps -isSimp Ring σ]
noncomputable
def ofSurjective {P : Type w} [CommRing P] [Algebra R P] (f : P →ₐ[R] S)
(h : Function.Surjective f) : Extension.{w} R S where
Ring := P
algebra₂ := f.toAlgebra
isScalarTower := letI := f.toAlgebra; IsScalarTower.of_algebraMap_eq' f.comp_algebraMap.symm
σ x := (h x).choose
algebraMap_σ x := (h x).choose_spec
variable (R S) in
/-- The trivial extension of `S`. -/
@[simps -isSimp Ring σ]
noncomputable
def self : Extension R S where
Ring := S
σ := _root_.id
algebraMap_σ _ := rfl
/-- The kernel of an extension. -/
abbrev ker : Ideal P.Ring := RingHom.ker (algebraMap P.Ring S)
section Localization
variable (M : Submonoid S) {S' : Type*} [CommRing S'] [Algebra S S'] [IsLocalization M S']
variable [Algebra R S'] [IsScalarTower R S S']
/--
An `R`-extension `P → S` gives an `R`-extension `Pₘ → Sₘ`.
Note that this is different from `baseChange` as the base does not change.
-/
noncomputable
def localization (P : Extension.{w} R S) : Extension R S' where
Ring := Localization (M.comap (algebraMap P.Ring S))
algebra₂ := (IsLocalization.lift (M := (M.comap (algebraMap P.Ring S)))
(g := (algebraMap S S').comp (algebraMap P.Ring S))
(by simpa using fun x hx ↦ IsLocalization.map_units S' ⟨_, hx⟩)).toAlgebra
isScalarTower := by
letI : Algebra (Localization (M.comap (algebraMap P.Ring S))) S' :=
(IsLocalization.lift (M := (M.comap (algebraMap P.Ring S)))
(g := (algebraMap S S').comp (algebraMap P.Ring S))
(by simpa using fun x hx ↦ IsLocalization.map_units S' ⟨_, hx⟩)).toAlgebra
apply IsScalarTower.of_algebraMap_eq'
rw [RingHom.algebraMap_toAlgebra, IsScalarTower.algebraMap_eq R P.Ring (Localization _),
← RingHom.comp_assoc, IsLocalization.lift_comp, RingHom.comp_assoc,
← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq]
σ s := Localization.mk (P.σ (IsLocalization.sec M s).1) ⟨P.σ (IsLocalization.sec M s).2, by simp⟩
algebraMap_σ s := by
simp [RingHom.algebraMap_toAlgebra, Localization.mk_eq_mk', IsLocalization.lift_mk',
Units.mul_inv_eq_iff_eq_mul, IsUnit.coe_liftRight, IsLocalization.sec_spec]
end Localization
variable {T} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
/-- The base change of an `R`-extension of `S` to `T` gives a `T`-extension of `T ⊗[R] S`. -/
noncomputable
def baseChange {T} [CommRing T] [Algebra R T] (P : Extension R S) : Extension T (T ⊗[R] S) where
Ring := T ⊗[R] P.Ring
__ := ofSurjective (P := T ⊗[R] P.Ring) (Algebra.TensorProduct.map (AlgHom.id T T)
(IsScalarTower.toAlgHom _ _ _)) (LinearMap.lTensor_surjective T
(g := (IsScalarTower.toAlgHom R P.Ring S).toLinearMap) P.algebraMap_surjective)
end Construction
variable {R' S'} [CommRing R'] [CommRing S'] [Algebra R' S'] (P' : Extension R' S')
variable {R'' S''} [CommRing R''] [CommRing S''] [Algebra R'' S''] (P'' : Extension R'' S'')
section Hom
section
variable [Algebra R R'] [Algebra R' R''] [Algebra R R'']
variable [Algebra S S'] [Algebra S' S''] [Algebra S S'']
/-- Given a commuting square
```
R --→ P -→ S
| |
↓ ↓
R' -→ P' → S
```
A hom between `P` and `P'` is a ring homomorphism that makes the two squares commute.
-/
@[ext]
structure Hom where
/-- The underlying ring homomorphism of a hom between extensions. -/
toRingHom : P.Ring →+* P'.Ring
toRingHom_algebraMap :
∀ x, toRingHom (algebraMap R P.Ring x) = algebraMap R' P'.Ring (algebraMap R R' x)
algebraMap_toRingHom :
∀ x, (algebraMap P'.Ring S' (toRingHom x)) = algebraMap S S' (algebraMap P.Ring S x)
attribute [simp] Hom.toRingHom_algebraMap Hom.algebraMap_toRingHom
variable {P P'}
/-- A hom between extensions as an algebra homomorphism. -/
noncomputable
def Hom.toAlgHom [Algebra R S'] [IsScalarTower R R' S'] (f : Hom P P') :
P.Ring →ₐ[R] P'.Ring where
__ := f.toRingHom
commutes' := by simp [← IsScalarTower.algebraMap_apply]
@[simp]
lemma Hom.toAlgHom_apply [Algebra R S'] [IsScalarTower R R' S'] (f : Hom P P') (x) :
f.toAlgHom x = f.toRingHom x := rfl
variable (P P')
/-- The identity hom. -/
@[simps]
protected noncomputable def Hom.id : Hom P P := ⟨RingHom.id _, by simp, by simp⟩
@[simp]
lemma Hom.toAlgHom_id : Hom.toAlgHom (.id P) = AlgHom.id _ _ := by ext1; simp
variable {P P' P''}
variable [IsScalarTower R R' R''] [IsScalarTower S S' S''] in
/-- The composition of two homs. -/
@[simps]
noncomputable def Hom.comp (f : Hom P' P'') (g : Hom P P') : Hom P P'' where
toRingHom := f.toRingHom.comp g.toRingHom
toRingHom_algebraMap := by simp [← IsScalarTower.algebraMap_apply]
algebraMap_toRingHom := by simp [← IsScalarTower.algebraMap_apply]
@[simp]
lemma Hom.comp_id (f : Hom P P') : f.comp (Hom.id P) = f := by ext; simp
@[simp]
lemma Hom.id_comp (f : Hom P P') : (Hom.id P').comp f = f := by
ext; simp [Hom.id]
/-- A map between extensions induce a map between kernels. -/
@[simps]
def Hom.mapKer (f : P.Hom P')
[alg : Algebra P.Ring P'.Ring] (halg : algebraMap P.Ring P'.Ring = f.toRingHom) :
P.ker →ₗ[P.Ring] P'.ker where
toFun x := ⟨f.toRingHom x, by simp [show algebraMap P.Ring S x = 0 from x.2]⟩
map_add' _ _ := Subtype.ext (map_add _ _ _)
map_smul' := by simp [Algebra.smul_def, ← halg]
end
end Hom
section Infinitesimal
/-- Given an `R`-algebra extension `0 → I → P → S → 0` of `S`,
the infinitesimal extension associated to it is `0 → I/I² → P/I² → S → 0`. -/
noncomputable
def infinitesimal (P : Extension R S) : Extension R S where
Ring := P.Ring ⧸ P.ker ^ 2
σ := Ideal.Quotient.mk _ ∘ P.σ
algebraMap_σ x := by dsimp; exact P.algebraMap_σ x
/-- The canonical map `P → P/I²` as maps between extensions. -/
noncomputable
def toInfinitesimal (P : Extension R S) : P.Hom P.infinitesimal where
toRingHom := Ideal.Quotient.mk _
toRingHom_algebraMap _ := rfl
algebraMap_toRingHom _ := rfl
lemma ker_infinitesimal (P : Extension R S) :
P.infinitesimal.ker = P.ker.cotangentIdeal :=
AlgHom.ker_kerSquareLift _
end Infinitesimal
section Cotangent
/-- The cotangent space of an extension.
This is a type synonym so that `P.Ring` can act on it through the action of `S` without creating
a diamond. -/
def Cotangent : Type _ := P.ker.Cotangent
noncomputable
instance : AddCommGroup P.Cotangent := inferInstanceAs (AddCommGroup P.ker.Cotangent)
variable {P}
/-- The identity map `P.ker.Cotangent → P.Cotangent` into the type synonym. -/
def Cotangent.of (x : P.ker.Cotangent) : P.Cotangent := x
/-- The identity map `P.Cotangent → P.ker.Cotangent` from the type synonym. -/
def Cotangent.val (x : P.Cotangent) : P.ker.Cotangent := x
@[ext]
lemma Cotangent.ext {x y : P.Cotangent} (e : x.val = y.val) : x = y := e
namespace Cotangent
variable (x y : P.Cotangent) (w z : P.ker.Cotangent)
@[simp] lemma val_add : (x + y).val = x.val + y.val := rfl
@[simp] lemma val_zero : (0 : P.Cotangent).val = 0 := rfl
@[simp] lemma of_add : of (w + z) = of w + of z := rfl
@[simp] lemma of_zero : (of 0 : P.Cotangent) = 0 := rfl
@[simp] lemma of_val : of x.val = x := rfl
@[simp] lemma val_of : (of w).val = w := rfl
@[simp] lemma val_sub : (x - y).val = x.val - y.val := rfl
end Cotangent
lemma Cotangent.smul_eq_zero_of_mem (p : P.Ring) (hp : p ∈ P.ker) (m : P.ker.Cotangent) :
p • m = 0 :=
Ideal.Cotangent.smul_eq_zero_of_mem hp m
attribute [local simp] RingHom.mem_ker
noncomputable
instance Cotangent.module : Module S P.Cotangent where
smul := fun r s ↦ .of (P.σ r • s.val)
smul_zero := fun r ↦ ext (smul_zero (P.σ r))
smul_add := fun r x y ↦ ext (smul_add (P.σ r) x.val y.val)
add_smul := fun r s x ↦ by
have := smul_eq_zero_of_mem (P.σ (r + s) - (P.σ r + P.σ s) : P.Ring) (by simp ) x
simpa only [sub_smul, add_smul, sub_eq_zero]
zero_smul := fun x ↦ smul_eq_zero_of_mem (P.σ 0 : P.Ring) (by simp) x
one_smul := fun x ↦ by
have := smul_eq_zero_of_mem (P.σ 1 - 1 : P.Ring) (by simp) x
simpa [sub_eq_zero, sub_smul]
mul_smul := fun r s x ↦ by
have := smul_eq_zero_of_mem (P.σ (r * s) - (P.σ r * P.σ s) : P.Ring) (by simp) x
simpa only [sub_smul, mul_smul, sub_eq_zero] using this
noncomputable
instance {R₀} [CommRing R₀] [Algebra R₀ S] : Module R₀ P.Cotangent :=
Module.compHom P.Cotangent (algebraMap R₀ S)
instance {R₁ R₂} [CommRing R₁] [CommRing R₂] [Algebra R₁ S] [Algebra R₂ S] [Algebra R₁ R₂]
[IsScalarTower R₁ R₂ S] :
IsScalarTower R₁ R₂ P.Cotangent := by
constructor
intro r s m
change algebraMap R₂ S (r • s) • m = (algebraMap _ S r) • (algebraMap _ S s) • m
rw [Algebra.smul_def, map_mul, mul_smul, ← IsScalarTower.algebraMap_apply]
/-- The action of `R₀` on `P.Cotangent` for an extension `P → S`, if `S` is an `R₀` algebra. -/
lemma Cotangent.val_smul''' {R₀} [CommRing R₀] [Algebra R₀ S] (r : R₀) (x : P.Cotangent) :
(r • x).val = P.σ (algebraMap R₀ S r) • x.val := rfl
/-- The action of `S` on `P.Cotangent` for an extension `P → S`. -/
@[simp]
lemma Cotangent.val_smul (r : S) (x : P.Cotangent) : (r • x).val = P.σ r • x.val := rfl
/-- The action of `P` on `P.Cotangent` for an extension `P → S`. -/
@[simp]
lemma Cotangent.val_smul' (r : P.Ring) (x : P.Cotangent) : (r • x).val = r • x.val := by
rw [val_smul''', ← sub_eq_zero, ← sub_smul]
exact Cotangent.smul_eq_zero_of_mem _ (by simp) _
/-- The action of `R` on `P.Cotangent` for an `R`-extension `P → S`. -/
@[simp]
lemma Cotangent.val_smul'' (r : R) (x : P.Cotangent) : (r • x).val = r • x.val := by
rw [← algebraMap_smul P.Ring, val_smul', algebraMap_smul]
/-- The quotient map from the kernel of `P → S` onto the cotangent space. -/
noncomputable def Cotangent.mk : P.ker →ₗ[P.Ring] P.Cotangent where
toFun x := .of (Ideal.toCotangent _ x)
map_add' x y := by simp
map_smul' x y := ext <| by simp
@[simp]
lemma Cotangent.val_mk (x : P.ker) : (mk x).val = Ideal.toCotangent _ x := rfl
lemma Cotangent.mk_surjective : Function.Surjective (mk (P := P)) :=
fun x ↦ Ideal.toCotangent_surjective P.ker x.val
lemma Cotangent.mk_eq_zero_iff {P : Extension R S} (x : P.ker) :
Cotangent.mk x = 0 ↔ x.val ∈ P.ker ^ 2 := by
simp [Cotangent.ext_iff, Ideal.toCotangent_eq_zero]
variable {P'}
variable [Algebra R R'] [Algebra R' R''] [Algebra R' S'']
variable [Algebra S S'] [Algebra S' S''] [Algebra S S'']
variable [Algebra R S'] [IsScalarTower R R' S']
/-- A hom between two extensions induces a map between cotangent spaces. -/
noncomputable
def Cotangent.map (f : Hom P P') : P.Cotangent →ₗ[S] P'.Cotangent where
toFun x := .of (Ideal.mapCotangent (R := R) _ _ f.toAlgHom
(fun x hx ↦ by simpa using RingHom.congr_arg (algebraMap S S') hx) x.val)
map_add' x y := ext (map_add _ x.val y.val)
map_smul' r x := by
ext
obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x
obtain ⟨r, rfl⟩ := P.algebraMap_surjective r
simp only [algebraMap_smul, val_smul', val_mk, val_of, Ideal.mapCotangent_toCotangent,
RingHomCompTriple.comp_apply, ← (Ideal.toCotangent _).map_smul]
conv_rhs => rw [← algebraMap_smul S', ← f.algebraMap_toRingHom, algebraMap_smul, val_smul',
val_of, ← (Ideal.toCotangent _).map_smul]
congr 1
ext1
simp only [SetLike.val_smul, smul_eq_mul, map_mul, Hom.toAlgHom_apply]
@[simp]
lemma Cotangent.map_mk (f : Hom P P') (x) :
Cotangent.map f (.mk x) =
.mk ⟨f.toAlgHom x, by simpa [-map_aeval] using RingHom.congr_arg (algebraMap S S') x.2⟩ :=
rfl
@[simp]
lemma Cotangent.map_id :
Cotangent.map (.id P) = LinearMap.id := by
ext x
obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x
simp only [map_mk, Hom.toAlgHom_id, AlgHom.coe_id, id_eq, Subtype.coe_eta, val_mk,
LinearMap.id_coe]
variable [Algebra R R''] [IsScalarTower R R' R''] [IsScalarTower R' R'' S'']
[Algebra R S''] [IsScalarTower R R'' S''] [IsScalarTower S S' S'']
lemma Cotangent.map_comp (f : Hom P P') (g : Hom P' P'') :
Cotangent.map (g.comp f) = (map g).restrictScalars S ∘ₗ map f := by
ext x
obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x
simp only [map_mk, Hom.toAlgHom_apply, Hom.comp_toRingHom, RingHom.coe_comp, Function.comp_apply,
val_mk, LinearMap.coe_comp, LinearMap.coe_restrictScalars]
lemma Cotangent.finite (hP : P.ker.FG) :
Module.Finite S P.Cotangent := by
refine ⟨.of_restrictScalars (R := P.Ring) _ ?_⟩
rw [Submodule.restrictScalars_top, ← LinearMap.range_eq_top.mpr Extension.Cotangent.mk_surjective,
← Submodule.map_top]
exact ((Submodule.fg_top P.ker).mpr hP).map _
end Cotangent
end Algebra.Extension |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Generators.lean | import Mathlib.RingTheory.Ideal.Cotangent
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.MvPolynomial.Tower
import Mathlib.RingTheory.TensorProduct.Basic
import Mathlib.RingTheory.Extension.Basic
/-!
# Generators of algebras
## Main definition
- `Algebra.Generators`: A family of generators of a `R`-algebra `S` consists of
1. `vars`: The type of variables.
2. `val : vars → S`: The assignment of each variable to a value.
3. `σ`: A set-theoretic section of the induced `R`-algebra homomorphism `R[X] → S`, where we
write `R[X]` for `R[vars]`.
- `Algebra.Generators.Hom`: Given a commuting square
```
R --→ P = R[X] ---→ S
| |
↓ ↓
R' -→ P' = R'[X'] → S
```
A hom between `P` and `P'` is an assignment `X → P'` such that the arrows commute.
- `Algebra.Generators.Cotangent`: The cotangent space w.r.t. `P = R[X] → S`, i.e. the
space `I/I²` with `I` being the kernel of the presentation.
## TODOs
Currently, Lean does not see through the `vars` field of terms of `Generators R S` obtained
from constructions, e.g. composition. This causes fragile and cumbersome proofs, because
`simp` and `rw` often don't work properly. `Generators R S` (and `Presentation R S`, etc.) should
be refactored in a way that makes these equalities reducibly def-eq, for example
by unbundling the `vars` field or making the field globally reducible in constructions using
unification hints.
-/
universe w u v
open TensorProduct MvPolynomial
variable (R : Type u) (S : Type v) (ι : Type w) [CommRing R] [CommRing S] [Algebra R S]
/-- A family of generators of a `R`-algebra `S` consists of
1. `vars`: The type of variables.
2. `val : vars → S`: The assignment of each variable to a value in `S`.
3. `σ`: A section of `R[X] → S`. -/
structure Algebra.Generators where
/-- The assignment of each variable to a value in `S`. -/
val : ι → S
/-- A section of `R[X] → S`. -/
σ' : S → MvPolynomial ι R
aeval_val_σ' : ∀ s, aeval val (σ' s) = s
/-- An `R[X]`-algebra instance on `S`. The default is the one induced by the map `R[X] → S`,
but this causes a diamond if there is an existing instance. -/
algebra : Algebra (MvPolynomial ι R) S := (aeval val).toAlgebra
algebraMap_eq :
algebraMap (MvPolynomial ι R) S = aeval (R := R) val := by rfl
namespace Algebra.Generators
variable {R S ι}
variable (P : Generators R S ι)
set_option linter.unusedVariables false in
/-- The polynomial ring w.r.t. a family of generators. -/
@[nolint unusedArguments]
protected
abbrev Ring (P : Generators R S ι) : Type (max w u) := MvPolynomial ι R
instance : Algebra P.Ring S := P.algebra
/-- The designated section of w.r.t. a family of generators. -/
def σ : S → P.Ring := P.σ'
/-- See Note [custom simps projection] -/
def Simps.σ : S → P.Ring := P.σ
initialize_simps_projections Algebra.Generators (σ' → σ)
@[simp]
lemma aeval_val_σ (s) : aeval P.val (P.σ s) = s := P.aeval_val_σ' s
noncomputable instance {R₀} [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S] :
IsScalarTower R₀ P.Ring S := IsScalarTower.of_algebraMap_eq' <|
P.algebraMap_eq ▸ ((aeval (R := R) P.val).comp_algebraMap_of_tower R₀).symm
@[simp]
lemma algebraMap_apply (x) : algebraMap P.Ring S x = aeval (R := R) P.val x := by
simp [algebraMap_eq]
@[simp]
lemma σ_smul (x y) : P.σ x • y = x * y := by
rw [Algebra.smul_def, algebraMap_apply, aeval_val_σ]
lemma σ_injective : P.σ.Injective := by
intro x y e
rw [← P.aeval_val_σ x, ← P.aeval_val_σ y, e]
lemma algebraMap_surjective : Function.Surjective (algebraMap P.Ring S) :=
(⟨_, P.algebraMap_apply _ ▸ P.aeval_val_σ ·⟩)
section Construction
/-- Construct `Generators` from an assignment `I → S` such that `R[X] → S` is surjective. -/
@[simps val]
noncomputable
def ofSurjective (val : ι → S) (h : Function.Surjective (aeval (R := R) val)) :
Generators R S ι where
val := val
σ' x := (h x).choose
aeval_val_σ' x := (h x).choose_spec
/-- If `algebraMap R S` is surjective, the empty type generates `S`. -/
noncomputable def ofSurjectiveAlgebraMap (h : Function.Surjective (algebraMap R S)) :
Generators R S PEmpty.{w + 1} :=
ofSurjective PEmpty.elim <| fun s ↦ by
use C (h s).choose
simp [(h s).choose_spec]
/-- The canonical generators for `R` as an `R`-algebra. -/
noncomputable def id : Generators R R PEmpty.{w + 1} := ofSurjectiveAlgebraMap <| by
rw [algebraMap_self]
exact RingHomSurjective.is_surjective
/-- Construct `Generators` from an assignment `I → S` such that `R[X] → S` is surjective. -/
noncomputable
def ofAlgHom {I : Type*} (f : MvPolynomial I R →ₐ[R] S) (h : Function.Surjective f) :
Generators R S I :=
ofSurjective (f ∘ X) (by rwa [show aeval (f ∘ X) = f by ext; simp])
/-- Construct `Generators` from a family of generators of `S`. -/
noncomputable
def ofSet {s : Set S} (hs : Algebra.adjoin R s = ⊤) : Generators R S s := by
refine ofSurjective (Subtype.val : s → S) ?_
rwa [← AlgHom.range_eq_top, ← Algebra.adjoin_range_eq_range_aeval,
Subtype.range_coe_subtype, Set.setOf_mem_eq]
variable (R S) in
/-- The `Generators` containing the whole algebra, which induces the canonical map `R[S] → S`. -/
@[simps]
noncomputable
def self : Generators R S S where
val := _root_.id
σ' := X
aeval_val_σ' := aeval_X _
/-- The extension `R[X₁,...,Xₙ] → S` given a family of generators. -/
@[simps]
noncomputable
def toExtension : Extension R S where
Ring := P.Ring
σ := P.σ
algebraMap_σ := by simp
section Localization
variable (r : R) [IsLocalization.Away r S]
variable (S) in
/-- If `S` is the localization of `R` away from `r`, we obtain a canonical generator mapping
to the inverse of `r`. -/
@[simps val, simps -isSimp σ]
noncomputable
def localizationAway : Generators R S Unit where
val _ := IsLocalization.Away.invSelf r
σ' s :=
letI a : R := (IsLocalization.Away.sec r s).1
letI n : ℕ := (IsLocalization.Away.sec r s).2
C a * X () ^ n
aeval_val_σ' s := by
rw [map_mul, algHom_C, map_pow, aeval_X]
simp only [← IsLocalization.Away.sec_spec, map_pow, IsLocalization.Away.invSelf]
rw [← IsLocalization.mk'_pow, one_pow, ← IsLocalization.mk'_one (M := Submonoid.powers r) S r]
rw [← IsLocalization.mk'_pow, one_pow, mul_assoc, ← IsLocalization.mk'_mul]
rw [mul_one, one_mul, IsLocalization.mk'_pow]
simp
end Localization
variable {ι' : Type*} {T} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
/-- Given two families of generators `S[X] → T` and `R[Y] → S`,
we may construct the family of generators `R[X, Y] → T`. -/
@[simps val, simps -isSimp σ]
noncomputable
def comp (Q : Generators S T ι') (P : Generators R S ι) : Generators R T (ι' ⊕ ι) where
val := Sum.elim Q.val (algebraMap S T ∘ P.val)
σ' x := (Q.σ x).sum (fun n r ↦ rename Sum.inr (P.σ r) * monomial (n.mapDomain Sum.inl) 1)
aeval_val_σ' s := by
have (x : P.Ring) : aeval (algebraMap S T ∘ P.val) x = algebraMap S T (aeval P.val x) := by
rw [map_aeval, aeval_def, coe_eval₂Hom, ← IsScalarTower.algebraMap_eq, Function.comp_def]
conv_rhs => rw [← Q.aeval_val_σ s, ← (Q.σ s).sum_single]
simp only [map_finsuppSum, map_mul, aeval_rename, Sum.elim_comp_inr, this, aeval_val_σ,
aeval_monomial, map_one, Finsupp.prod_mapDomain_index_inj Sum.inl_injective, Sum.elim_inl,
one_mul, single_eq_monomial]
variable (S) in
/-- If `R → S → T` is a tower of algebras, a family of generators `R[X] → T`
gives a family of generators `S[X] → T`. -/
@[simps val]
noncomputable
def extendScalars (P : Generators R T ι) : Generators S T ι where
val := P.val
σ' x := map (algebraMap R S) (P.σ x)
aeval_val_σ' s := by simp [@aeval_def S, ← IsScalarTower.algebraMap_eq, ← @aeval_def R]
/-- If `P` is a family of generators of `S` over `R` and `T` is an `R`-algebra, we
obtain a natural family of generators of `T ⊗[R] S` over `T`. -/
@[simps! val]
noncomputable
def baseChange (T) [CommRing T] [Algebra R T] (P : Generators R S ι) :
Generators T (T ⊗[R] S) ι := by
apply Generators.ofSurjective (fun x ↦ 1 ⊗ₜ[R] P.val x)
intro x
induction x using TensorProduct.induction_on with
| zero => exact ⟨0, map_zero _⟩
| tmul a b =>
let X := P.σ b
use a • MvPolynomial.map (algebraMap R T) X
simp only [LinearMapClass.map_smul, X, aeval_map_algebraMap]
have : ∀ y : P.Ring,
aeval (fun x ↦ (1 ⊗ₜ[R] P.val x : T ⊗[R] S)) y = 1 ⊗ₜ aeval (fun x ↦ P.val x) y := by
intro y
induction y using MvPolynomial.induction_on with
| C a =>
rw [aeval_C, aeval_C, TensorProduct.algebraMap_apply, algebraMap_eq_smul_one, smul_tmul,
algebraMap_eq_smul_one]
| add p q hp hq => simp [map_add, tmul_add, hp, hq]
| mul_X p i hp => simp [hp]
rw [this, P.aeval_val_σ, smul_tmul', smul_eq_mul, mul_one]
| add x y ex ey =>
obtain ⟨a, ha⟩ := ex
obtain ⟨b, hb⟩ := ey
use (a + b)
rw [map_add, ha, hb]
/-- Given generators `P` and an equivalence `ι ≃ P.vars`, these
are the induced generators indexed by `ι`. -/
noncomputable def reindex (P : Generators R S ι') (e : ι ≃ ι') :
Generators R S ι where
val := P.val ∘ e
σ' := rename e.symm ∘ P.σ
aeval_val_σ' s := by
conv_rhs => rw [← P.aeval_val_σ s]
rw [← MvPolynomial.aeval_rename]
simp
lemma reindex_val (P : Generators R S ι') (e : ι ≃ ι') :
(P.reindex e).val = P.val ∘ e :=
rfl
section
variable {σ : Type*} {I : Ideal (MvPolynomial σ R)}
(s : MvPolynomial σ R ⧸ I → MvPolynomial σ R)
(hs : ∀ x, Ideal.Quotient.mk _ (s x) = x)
/--
The naive generators for a quotient `R[Xᵢ] ⧸ I`.
If the definitional equality of the section matters, it can be explicitly provided.
-/
@[simps val]
noncomputable
def naive (s : MvPolynomial σ R ⧸ I → MvPolynomial σ R :=
Function.surjInv Ideal.Quotient.mk_surjective)
(hs : ∀ x, Ideal.Quotient.mk _ (s x) = x := by apply Function.surjInv_eq) :
Generators R (MvPolynomial σ R ⧸ I) σ where
val i := Ideal.Quotient.mk _ (X i)
σ' := s
aeval_val_σ' x := by
conv_rhs => rw [← hs x, ← Ideal.Quotient.mkₐ_eq_mk R, aeval_unique (Ideal.Quotient.mkₐ _ I)]
simp [Function.comp_def]
algebra := inferInstance
algebraMap_eq := by ext x <;> simp [IsScalarTower.algebraMap_apply R (MvPolynomial σ R)]
@[simp] lemma naive_σ : (Generators.naive s hs).σ = s := rfl
end
lemma finiteType {α : Type*} [Finite α] (P : Generators R S α) : FiniteType R S :=
.of_surjective (IsScalarTower.toAlgHom R P.Ring S) P.algebraMap_surjective
lemma _root_.Algebra.FiniteType.iff_exists_generators :
FiniteType R S ↔ ∃ (n : ℕ), Nonempty (Generators R S (Fin n)) := by
refine ⟨fun h ↦ ?_, fun ⟨n, ⟨P⟩⟩ ↦ P.finiteType⟩
obtain ⟨n, f, hf⟩ := Algebra.FiniteType.iff_quotient_mvPolynomial''.mp h
exact ⟨n, ⟨.ofSurjective (fun i ↦ f (X i)) <| by rwa [aeval_unique f] at hf⟩⟩
end Construction
variable {R' S' ι' : Type*} [CommRing R'] [CommRing S'] [Algebra R' S'] (P' : Generators R' S' ι')
variable {R'' S'' ι'' : Type*} [CommRing R''] [CommRing S''] [Algebra R'' S'']
(P'' : Generators R'' S'' ι'')
section Hom
section
variable [Algebra R R'] [Algebra R' R''] [Algebra R' S'']
variable [Algebra S S'] [Algebra S' S''] [Algebra S S'']
/-- Given a commuting square
R --→ P = R[X] ---→ S
| |
↓ ↓
R' -→ P' = R'[X'] → S
A hom between `P` and `P'` is an assignment `I → P'` such that the arrows commute.
Also see `Algebra.Generators.Hom.equivAlgHom`.
-/
@[ext]
structure Hom where
/-- The assignment of each variable in `I` to a value in `P' = R'[X']`. -/
val : ι → P'.Ring
aeval_val : ∀ i, aeval P'.val (val i) = algebraMap S S' (P.val i)
attribute [simp] Hom.aeval_val
variable {P P'}
/-- A hom between two families of generators gives
an algebra homomorphism between the polynomial rings. -/
noncomputable
def Hom.toAlgHom (f : Hom P P') : P.Ring →ₐ[R] P'.Ring := MvPolynomial.aeval f.val
variable [Algebra R S'] [IsScalarTower R R' S'] [IsScalarTower R S S'] in
@[simp]
lemma Hom.algebraMap_toAlgHom (f : Hom P P') (x) : MvPolynomial.aeval P'.val (f.toAlgHom x) =
algebraMap S S' (MvPolynomial.aeval P.val x) := by
suffices ((MvPolynomial.aeval P'.val).restrictScalars R).comp f.toAlgHom =
(IsScalarTower.toAlgHom R S S').comp (MvPolynomial.aeval P.val) from
DFunLike.congr_fun this x
apply MvPolynomial.algHom_ext
intro i
simp [Hom.toAlgHom]
/-- Version of `Hom.algebraMap_toAlgHom` where `S = S'`, sometimes useful for rewriting. -/
lemma Hom.algebraMap_toAlgHom' [Algebra R' S] [IsScalarTower R R' S]
{P' : Generators R' S ι'} (f : Hom P P') (x : P.Ring) :
MvPolynomial.aeval P'.val (f.toAlgHom x) = MvPolynomial.aeval P.val x :=
f.algebraMap_toAlgHom _
@[simp]
lemma Hom.toAlgHom_X (f : Hom P P') (i) : f.toAlgHom (.X i) = f.val i :=
MvPolynomial.aeval_X f.val i
lemma Hom.toAlgHom_C (f : Hom P P') (r) : f.toAlgHom (.C r) = .C (algebraMap _ _ r) :=
MvPolynomial.aeval_C f.val r
lemma Hom.toAlgHom_monomial (f : Generators.Hom P P') (v r) :
f.toAlgHom (monomial v r) = r • v.prod (f.val · ^ ·) := by
rw [toAlgHom, aeval_monomial, Algebra.smul_def]
variable [Algebra R S'] [IsScalarTower R R' S'] [IsScalarTower R S S'] in
/-- Giving a hom between two families of generators is equivalent to
giving an algebra homomorphism between the polynomial rings. -/
@[simps]
noncomputable
def Hom.equivAlgHom :
Hom P P' ≃ { f : P.Ring →ₐ[R] P'.Ring //
∀ x, aeval P'.val (f x) = algebraMap S S' (aeval P.val x) } where
toFun f := ⟨f.toAlgHom, f.algebraMap_toAlgHom⟩
invFun f := ⟨fun i ↦ f.1 (.X i), fun i ↦ by simp [f.2]⟩
left_inv f := by ext; simp
right_inv f := by ext; simp
variable (P P')
/-- The hom from `P` to `P'` given by the designated section of `P'`. -/
@[simps]
def defaultHom : Hom P P' := ⟨P'.σ ∘ algebraMap S S' ∘ P.val, fun x ↦ by simp⟩
instance : Inhabited (Hom P P') := ⟨defaultHom P P'⟩
/-- The identity hom. -/
@[simps]
protected noncomputable def Hom.id : Hom P P := ⟨X, by simp⟩
@[simp]
lemma Hom.toAlgHom_id : Hom.toAlgHom (.id P) = AlgHom.id _ _ := by ext1; simp
variable {P P' P''}
/-- The composition of two homs. -/
@[simps]
noncomputable def Hom.comp [IsScalarTower R' R'' S''] [IsScalarTower R' S' S'']
[IsScalarTower S S' S''] (f : Hom P' P'') (g : Hom P P') : Hom P P'' where
val x := aeval f.val (g.val x)
aeval_val x := by
rw [IsScalarTower.algebraMap_apply S S' S'', ← g.aeval_val]
induction g.val x using MvPolynomial.induction_on with
| C r => simp [← IsScalarTower.algebraMap_apply]
| add x y hx hy => simp only [map_add, hx, hy]
| mul_X p i hp => simp only [map_mul, hp, aeval_X, aeval_val]
@[simp]
lemma Hom.comp_id [Algebra R S'] [IsScalarTower R R' S'] [IsScalarTower R S S'] (f : Hom P P') :
f.comp (Hom.id P) = f := by ext; simp
end
@[simp]
lemma Hom.id_comp [Algebra S S'] (f : Hom P P') : (Hom.id P').comp f = f := by
ext; simp [Hom.id, aeval_X_left]
variable [Algebra R R'] [Algebra R' R''] [Algebra R' S'']
variable [Algebra S S'] [Algebra S' S''] [Algebra S S'']
@[simp]
lemma Hom.toAlgHom_comp_apply
[Algebra R R''] [IsScalarTower R R' R''] [IsScalarTower R' R'' S'']
[IsScalarTower R' S' S''] [IsScalarTower S S' S'']
(f : Hom P P') (g : Hom P' P'') (x) :
(g.comp f).toAlgHom x = g.toAlgHom (f.toAlgHom x) := by
induction x using MvPolynomial.induction_on with
| C r => simp only [← MvPolynomial.algebraMap_eq, AlgHom.map_algebraMap]
| add x y hx hy => simp only [map_add, hx, hy]
| mul_X p i hp => simp only [map_mul, hp, toAlgHom_X, comp_val]; rfl
variable {T : Type*} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
/-- Given families of generators `X ⊆ T` over `S` and `Y ⊆ S` over `R`,
there is a map of generators `R[Y] → R[X, Y]`. -/
@[simps]
noncomputable
def toComp (Q : Generators S T ι') (P : Generators R S ι) : Hom P (Q.comp P) where
val i := X (.inr i)
aeval_val i := by simp
lemma toComp_toAlgHom (Q : Generators S T ι') (P : Generators R S ι) :
(Q.toComp P).toAlgHom = rename Sum.inr := rfl
/-- Given families of generators `X ⊆ T` over `S` and `Y ⊆ S` over `R`,
there is a map of generators `R[X, Y] → S[X]`. -/
@[simps]
noncomputable
def ofComp (Q : Generators S T ι') (P : Generators R S ι) : Hom (Q.comp P) Q where
val i := i.elim X (C ∘ P.val)
aeval_val i := by cases i <;> simp
lemma ofComp_toAlgHom_monomial_sumElim (Q : Generators S T ι') (P : Generators R S ι) (v₁ v₂ a) :
(Q.ofComp P).toAlgHom (monomial (Finsupp.sumElim v₁ v₂) a) =
monomial v₁ (aeval P.val (monomial v₂ a)) := by
rw [Hom.toAlgHom_monomial, monomial_eq]
simp only [ofComp_val, aeval_monomial]
rw [Finsupp.prod_sumElim]
simp only [Function.comp_def, Sum.elim_inl, Sum.elim_inr, ← map_pow, ← map_finsuppProd,
C_mul, Algebra.smul_def, MvPolynomial.algebraMap_apply, mul_assoc]
nth_rw 2 [mul_comm]
lemma toComp_toAlgHom_monomial (Q : Generators S T ι') (P : Generators R S ι) (j a) :
(Q.toComp P).toAlgHom (monomial j a) =
monomial (Finsupp.sumElim 0 j) a := by
convert rename_monomial _ _ _
ext f (i₁ | i₂) <;>
simp [Finsupp.mapDomain_notin_range, Finsupp.mapDomain_apply Sum.inr_injective]
@[simp]
lemma toAlgHom_ofComp_rename (Q : Generators S T ι') (P : Generators R S ι) (p : P.Ring) :
(Q.ofComp P).toAlgHom ((rename Sum.inr) p) = C (algebraMap _ _ p) :=
have : (Q.ofComp P).toAlgHom.comp (rename Sum.inr) =
(IsScalarTower.toAlgHom R S Q.Ring).comp (IsScalarTower.toAlgHom R P.Ring S) := by ext; simp
DFunLike.congr_fun this p
lemma toAlgHom_ofComp_surjective (Q : Generators S T ι') (P : Generators R S ι) :
Function.Surjective (Q.ofComp P).toAlgHom := by
intro p
induction p using MvPolynomial.induction_on with
| C a =>
use MvPolynomial.rename Sum.inr (P.σ a)
simp only [Hom.toAlgHom, ofComp, Generators.comp, MvPolynomial.aeval_rename,
Sum.elim_comp_inr]
simp_rw [Function.comp_def, ← MvPolynomial.algebraMap_eq, ← IsScalarTower.toAlgHom_apply R,
← MvPolynomial.comp_aeval]
simp
| add p q hp hq =>
obtain ⟨p, rfl⟩ := hp
obtain ⟨q, rfl⟩ := hq
use p + q
simp
| mul_X p i hp =>
obtain ⟨(p : MvPolynomial (ι' ⊕ ι) R), rfl⟩ := hp
use p * MvPolynomial.X (R := R) (Sum.inl i)
simp [Algebra.Generators.ofComp, Algebra.Generators.Hom.toAlgHom]
/-- Given families of generators `X ⊆ T`, there is a map `R[X] → S[X]`. -/
@[simps]
noncomputable
def toExtendScalars (P : Generators R T ι) : Hom P (P.extendScalars S) where
val := X
aeval_val i := by simp
variable {P P'} in
/-- Reinterpret a hom between generators as a hom between extensions. -/
@[simps]
noncomputable
def Hom.toExtensionHom [Algebra R S'] [IsScalarTower R R' S'] [IsScalarTower R S S']
(f : P.Hom P') : P.toExtension.Hom P'.toExtension where
toRingHom := f.toAlgHom.toRingHom
toRingHom_algebraMap x := by simp
algebraMap_toRingHom x := by simp
@[simp]
lemma Hom.toExtensionHom_id : Hom.toExtensionHom (.id P) = .id _ := by ext; simp
@[simp]
lemma Hom.toExtensionHom_comp [Algebra R S'] [IsScalarTower R S S']
[Algebra R R''] [Algebra R S''] [IsScalarTower R R'' S'']
[IsScalarTower R S S''] [IsScalarTower R' R'' S''] [IsScalarTower R' S' S'']
[IsScalarTower S S' S''] [IsScalarTower R R' R''] [IsScalarTower R R' S']
(f : P'.Hom P'') (g : P.Hom P') :
toExtensionHom (f.comp g) = f.toExtensionHom.comp g.toExtensionHom := by ext; simp
lemma Hom.toExtensionHom_toAlgHom_apply [Algebra R S'] [IsScalarTower R R' S']
[IsScalarTower R S S'] (f : P.Hom P') (x) :
f.toExtensionHom.toAlgHom x = f.toAlgHom x := rfl
/-- The kernel of a presentation. -/
noncomputable abbrev ker : Ideal P.Ring := P.toExtension.ker
lemma ker_eq_ker_aeval_val : P.ker = RingHom.ker (aeval P.val) := by
simp only [ker, Extension.ker, toExtension_Ring, algebraMap_eq]
rfl
variable {P} in
lemma aeval_val_eq_zero {x} (hx : x ∈ P.ker) : aeval P.val x = 0 := by rwa [← algebraMap_apply]
lemma ker_naive {σ : Type*} {I : Ideal (MvPolynomial σ R)}
(s : MvPolynomial σ R ⧸ I → MvPolynomial σ R) (hs : ∀ x, Ideal.Quotient.mk _ (s x) = x) :
(Generators.naive s hs).ker = I :=
I.mk_ker
lemma map_toComp_ker (Q : Generators S T ι') (P : Generators R S ι) :
P.ker.map (Q.toComp P).toAlgHom = RingHom.ker (Q.ofComp P).toAlgHom := by
letI : DecidableEq (ι' →₀ ℕ) := Classical.decEq _
apply le_antisymm
· rw [Ideal.map_le_iff_le_comap]
rintro x (hx : algebraMap P.Ring S x = 0)
have : (Q.ofComp P).toAlgHom.comp (Q.toComp P).toAlgHom = IsScalarTower.toAlgHom R _ _ := by
ext1; simp
simp only [Ideal.mem_comap,
RingHom.mem_ker, ← AlgHom.comp_apply, this, IsScalarTower.toAlgHom_apply]
rw [IsScalarTower.algebraMap_apply P.Ring S, hx, map_zero]
· rintro x (h₂ : (Q.ofComp P).toAlgHom x = 0)
let e : (ι' ⊕ ι →₀ ℕ) ≃+ (ι' →₀ ℕ) × (ι →₀ ℕ) :=
Finsupp.sumFinsuppAddEquivProdFinsupp
suffices ∑ v ∈ (support x).map e, (monomial (e.symm v)) (coeff (e.symm v) x) ∈
Ideal.map (Q.toComp P).toAlgHom.toRingHom P.ker by
simpa only [AlgHom.toRingHom_eq_coe, Finset.sum_map, Equiv.coe_toEmbedding,
EquivLike.coe_coe, AddEquiv.symm_apply_apply, support_sum_monomial_coeff] using this
rw [← Finset.sum_fiberwise_of_maps_to (fun i ↦ Finset.mem_image_of_mem Prod.fst)]
refine sum_mem fun i hi ↦ ?_
convert_to monomial (e.symm (i, 0)) 1 * (Q.toComp P).toAlgHom.toRingHom
(∑ j ∈ (support x).map e.toEmbedding with j.1 = i, monomial j.2 (coeff (e.symm j) x)) ∈ _
· rw [map_sum, Finset.mul_sum]
refine Finset.sum_congr rfl fun j hj ↦ ?_
obtain rfl := (Finset.mem_filter.mp hj).2
obtain ⟨i, j⟩ := j
clear hj hi
have : (Q.toComp P).toAlgHom (monomial j (coeff (e.symm (i, j)) x)) =
monomial (e.symm (0, j)) (coeff (e.symm (i, j)) x) :=
toComp_toAlgHom_monomial ..
simp only [AlgHom.toRingHom_eq_coe, RingHom.coe_coe,
this]
rw [monomial_mul, ← map_add, Prod.mk_add_mk, add_zero, zero_add, one_mul]
· apply Ideal.mul_mem_left
refine Ideal.mem_map_of_mem _ ?_
simp only [ker_eq_ker_aeval_val, AddEquiv.toEquiv_eq_coe, RingHom.mem_ker, map_sum]
rw [← coeff_zero i, ← h₂]
clear h₂ hi
have (x : (Q.comp P).Ring) : (Function.support fun a ↦ if a.1 = i then aeval P.val
(monomial a.2 (coeff (e.symm a) x)) else 0) ⊆ SetLike.coe ((support x).map e) := by
rw [← Set.compl_subset_compl]
intro j
obtain ⟨j, rfl⟩ := e.surjective j
simp_all
rw [Finset.sum_filter, ← finsum_eq_sum_of_support_subset _ (this x)]
induction x using MvPolynomial.induction_on' with
| monomial v a =>
rw [finsum_eq_sum_of_support_subset _ (this _), ← Finset.sum_filter]
obtain ⟨v, rfl⟩ := e.symm.surjective v
-- Rewrite `e` in the right-hand side only.
conv_rhs => simp only [e, Finsupp.sumFinsuppAddEquivProdFinsupp,
Finsupp.sumFinsuppEquivProdFinsupp, AddEquiv.symm_mk, AddEquiv.coe_mk,
Equiv.coe_fn_symm_mk, ofComp_toAlgHom_monomial_sumElim]
classical
simp only [coeff_monomial, ← e.injective.eq_iff,
map_zero, AddEquiv.apply_symm_apply, apply_ite]
rw [← apply_ite, Finset.sum_ite_eq]
simp only [Finset.mem_filter, Finset.mem_map_equiv, AddEquiv.coe_toEquiv_symm,
mem_support_iff, coeff_monomial, ↓reduceIte, ne_eq, ite_and, ite_not]
split
· simp only [*, map_zero, ite_self]
· congr
| add p q hp hq =>
simp only [coeff_add, map_add, ite_add_zero]
rw [finsum_add_distrib, hp, hq]
· refine (((support p).map e).finite_toSet.subset ?_)
convert this p
· refine (((support q).map e).finite_toSet.subset ?_)
convert this q
/--
Given `R[X] → S` and `S[Y] → T`, this is the lift of an element in `ker(S[Y] → T)`
to `ker(R[X][Y] → S[Y] → T)` constructed from `P.σ`.
-/
noncomputable
def kerCompPreimage (Q : Generators S T ι') (P : Generators R S ι) (x : Q.ker) :
(Q.comp P).ker := by
refine ⟨x.1.sum fun n r ↦ ?_, ?_⟩
· -- The use of `refine` is intentional to control the elaboration order
-- so that the term has type `(Q.comp P).Ring` and not `MvPolynomial (Q.vars ⊕ P.vars) R`
refine rename ?_ (P.σ r) * monomial ?_ 1
exacts [Sum.inr, n.mapDomain Sum.inl]
· simp only [ker_eq_ker_aeval_val, RingHom.mem_ker]
conv_rhs => rw [← aeval_val_eq_zero x.2, ← x.1.support_sum_monomial_coeff]
simp only [Finsupp.sum, map_sum, map_mul, aeval_rename, Function.comp_def, comp_val,
Sum.elim_inr, aeval_monomial, map_one, Finsupp.prod_mapDomain_index_inj Sum.inl_injective,
Sum.elim_inl, one_mul]
congr! with v i
simp_rw [← IsScalarTower.toAlgHom_apply R, ← comp_aeval, AlgHom.comp_apply, P.aeval_val_σ,
coeff]
lemma ofComp_kerCompPreimage (Q : Generators S T ι') (P : Generators R S ι) (x : Q.ker) :
(Q.ofComp P).toAlgHom (kerCompPreimage Q P x) = x := by
conv_rhs => rw [← x.1.support_sum_monomial_coeff]
rw [kerCompPreimage, map_finsuppSum, Finsupp.sum]
refine Finset.sum_congr rfl fun j _ ↦ ?_
simp only [map_mul, Hom.toAlgHom_monomial]
rw [one_smul, Finsupp.prod_mapDomain_index_inj Sum.inl_injective]
rw [rename, ← AlgHom.comp_apply, comp_aeval]
simp only [ofComp_val, Sum.elim_inr, Function.comp_apply,
Sum.elim_inl, monomial_eq, Hom.toAlgHom_X]
congr 1
rw [aeval_def, IsScalarTower.algebraMap_eq R S, ← MvPolynomial.algebraMap_eq,
← coe_eval₂Hom, ← map_aeval, P.aeval_val_σ]
simp [coeff]
lemma map_ofComp_ker (Q : Generators S T ι') (P : Generators R S ι) :
Ideal.map (Q.ofComp P).toAlgHom (Q.comp P).ker = Q.ker := by
ext x
rw [Ideal.mem_map_iff_of_surjective _ (toAlgHom_ofComp_surjective Q P)]
constructor
· rintro ⟨x, hx, rfl⟩
simp only [ker_eq_ker_aeval_val,
RingHom.mem_ker] at hx ⊢
rw [← hx, Hom.algebraMap_toAlgHom, algebraMap_self_apply]
· intro hx
exact ⟨_, (kerCompPreimage Q P ⟨x, hx⟩).2, ofComp_kerCompPreimage Q P ⟨x, hx⟩⟩
lemma ker_comp_eq_sup (Q : Generators S T ι') (P : Generators R S ι) :
(Q.comp P).ker =
Ideal.map (Q.toComp P).toAlgHom P.ker ⊔ Ideal.comap (Q.ofComp P).toAlgHom Q.ker := by
rw [← map_ofComp_ker Q P,
Ideal.comap_map_of_surjective _ (toAlgHom_ofComp_surjective Q P)]
rw [← sup_assoc, Algebra.Generators.map_toComp_ker, ← RingHom.ker_eq_comap_bot]
apply le_antisymm (le_trans le_sup_right le_sup_left)
simp only [le_sup_left, sup_of_le_left, sup_le_iff, le_refl, and_true]
intro x hx
simp only [RingHom.mem_ker] at hx
rw [Generators.ker_eq_ker_aeval_val, RingHom.mem_ker,
← algebraMap_self_apply (MvPolynomial.aeval _ x)]
rw [← Generators.Hom.algebraMap_toAlgHom (Q.ofComp P), hx, map_zero]
lemma toAlgHom_ofComp_localizationAway (g : S) [IsLocalization.Away g T] :
((localizationAway T g).ofComp P).toAlgHom
(rename Sum.inr (P.σ g) * X (Sum.inl ()) - 1) = C g * X () - 1 := by
simp [Generators.Hom.toAlgHom, Generators.ofComp, aeval_rename]
end Hom
end Algebra.Generators |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Cotangent/Basic.lean | import Mathlib.RingTheory.Kaehler.Polynomial
import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.RingTheory.Extension.Presentation.Basic
/-!
# Naive cotangent complex associated to a presentation.
Given a presentation `0 → I → R[x₁,...,xₙ] → S → 0` (or equivalently a closed embedding `S ↪ Aⁿ`
defined by `I`), we may define the (naive) cotangent complex `I/I² → ⨁ᵢ S dxᵢ → Ω[S/R] → 0`.
## Main results
- `Algebra.Extension.Cotangent`: The conormal space `I/I²`. (Defined in `Generators/Basic`)
- `Algebra.Extension.CotangentSpace`: The cotangent space `⨁ᵢ S dxᵢ`.
- `Algebra.Generators.cotangentSpaceBasis`: The canonical basis on `⨁ᵢ S dxᵢ`.
- `Algebra.Extension.CotangentComplex`: The map `I/I² → ⨁ᵢ S dxᵢ`.
- `Algebra.Extension.toKaehler`: The projection `⨁ᵢ S dxᵢ → Ω[S/R]`.
- `Algebra.Extension.toKaehler_surjective`: The map `⨁ᵢ S dxᵢ → Ω[S/R]` is surjective.
- `Algebra.Extension.exact_cotangentComplex_toKaehler`: `I/I² → ⨁ᵢ S dxᵢ → Ω[S/R]` is exact.
- `Algebra.Extension.Hom.Sub`: If `f` and `g` are two maps between presentations, `f - g` induces
a map `⨁ᵢ S dxᵢ → I/I²` that makes `f` and `g` homotopic.
- `Algebra.Extension.H1Cotangent`: The first homology of the (naive) cotangent complex
of `S` over `R`, induced by a given presentation.
- `Algebra.H1Cotangent`: `H¹(L_{S/R})`,
the first homology of the (naive) cotangent complex of `S` over `R`.
## Implementation detail
We actually develop these material for general extensions (i.e. surjection `P → S`) so that we can
apply them to infinitesimal smooth (or versal) extensions later.
-/
open KaehlerDifferential Module MvPolynomial TensorProduct
namespace Algebra
universe w u v
variable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]
namespace Extension
variable (P : Extension.{w} R S)
/--
The cotangent space on `P = R[X]`.
This is isomorphic to `Sⁿ` with `n` being the number of variables of `P`.
-/
abbrev CotangentSpace : Type _ := S ⊗[P.Ring] Ω[P.Ring⁄R]
/-- The cotangent complex given by a presentation `R[X] → S` (i.e. a closed embedding `S ↪ Aⁿ`). -/
noncomputable
def cotangentComplex : P.Cotangent →ₗ[S] P.CotangentSpace :=
letI f : P.Cotangent ≃ₗ[P.Ring] P.ker.Cotangent :=
{ __ := AddEquiv.refl _, map_smul' := Cotangent.val_smul' }
(kerCotangentToTensor R P.Ring S ∘ₗ f).extendScalarsOfSurjective P.algebraMap_surjective
@[simp]
lemma cotangentComplex_mk (x) : P.cotangentComplex (.mk x) = 1 ⊗ₜ .D _ _ x :=
rfl
universe w' u' v'
variable {R' : Type u'} {S' : Type v'} [CommRing R'] [CommRing S'] [Algebra R' S']
variable (P' : Extension.{w'} R' S')
variable [Algebra R R'] [Algebra S S'] [Algebra R S'] [IsScalarTower R R' S']
attribute [local instance] SMulCommClass.of_commMonoid
variable {P P'}
universe w'' u'' v''
variable {R'' : Type u''} {S'' : Type v''} [CommRing R''] [CommRing S''] [Algebra R'' S'']
variable {P'' : Extension.{w''} R'' S''}
variable [Algebra R R''] [Algebra S S''] [Algebra R S'']
[IsScalarTower R R'' S'']
variable [Algebra R' R''] [Algebra S' S''] [Algebra R' S'']
[IsScalarTower R' R'' S'']
variable [IsScalarTower R R' R''] [IsScalarTower S S' S'']
namespace CotangentSpace
/--
This is the map on the cotangent space associated to a map of presentation.
The matrix associated to this map is the Jacobian matrix. See `CotangentSpace.repr_map`.
-/
protected noncomputable
def map (f : Hom P P') : P.CotangentSpace →ₗ[S] P'.CotangentSpace := by
letI := ((algebraMap S S').comp (algebraMap P.Ring S)).toAlgebra
haveI : IsScalarTower P.Ring S S' := IsScalarTower.of_algebraMap_eq' rfl
letI := f.toAlgHom.toAlgebra
haveI : IsScalarTower P.Ring P'.Ring S' :=
IsScalarTower.of_algebraMap_eq (fun x ↦ (f.algebraMap_toRingHom x).symm)
apply LinearMap.liftBaseChange
refine (TensorProduct.mk _ _ _ 1).restrictScalars _ ∘ₗ KaehlerDifferential.map R R' P.Ring P'.Ring
@[simp]
lemma map_tmul (f : Hom P P') (x y) :
CotangentSpace.map f (x ⊗ₜ .D _ _ y) = (algebraMap _ _ x) ⊗ₜ .D _ _ (f.toAlgHom y) := by
simp only [CotangentSpace.map, AlgHom.toRingHom_eq_coe, LinearMap.liftBaseChange_tmul,
LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, map_D, mk_apply]
rw [smul_tmul', ← Algebra.algebraMap_eq_smul_one]
rfl
@[simp]
lemma map_id :
CotangentSpace.map (.id P) = LinearMap.id := by ext; simp
lemma map_comp (f : Hom P P') (g : Hom P' P'') :
CotangentSpace.map (g.comp f) =
(CotangentSpace.map g).restrictScalars S ∘ₗ CotangentSpace.map f := by
ext x
induction x using TensorProduct.induction_on with
| zero =>
simp only [map_zero]
| add =>
simp only [map_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, *]
| tmul x y =>
obtain ⟨y, rfl⟩ := KaehlerDifferential.tensorProductTo_surjective _ _ y
induction y with
| zero => simp only [map_zero, tmul_zero]
| add => simp only [map_add, tmul_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars,
Function.comp_apply, *]
| tmul => simp only [Derivation.tensorProductTo_tmul, tmul_smul, smul_tmul', map_tmul,
Hom.toAlgHom_apply, Hom.comp_toRingHom, RingHom.coe_comp, Function.comp_apply,
LinearMap.coe_comp, LinearMap.coe_restrictScalars,
← IsScalarTower.algebraMap_apply S S' S'']
lemma map_comp_apply (f : Hom P P') (g : Hom P' P'') (x) :
CotangentSpace.map (g.comp f) x = .map g (.map f x) :=
DFunLike.congr_fun (map_comp f g) x
lemma map_cotangentComplex (f : Hom P P') (x) :
CotangentSpace.map f (P.cotangentComplex x) = P'.cotangentComplex (.map f x) := by
obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x
rw [cotangentComplex_mk, map_tmul, map_one, Cotangent.map_mk, cotangentComplex_mk]
lemma map_comp_cotangentComplex (f : Hom P P') :
CotangentSpace.map f ∘ₗ P.cotangentComplex =
P'.cotangentComplex.restrictScalars S ∘ₗ Cotangent.map f := by
ext x; exact map_cotangentComplex f x
end CotangentSpace
lemma Hom.sub_aux (f g : Hom P P') (x y) :
letI := ((algebraMap S S').comp (algebraMap P.Ring S)).toAlgebra
f.toAlgHom (x * y) - g.toAlgHom (x * y) -
(P'.σ ((algebraMap P.Ring S') x) * (f.toAlgHom y - g.toAlgHom y) +
P'.σ ((algebraMap P.Ring S') y) * (f.toAlgHom x - g.toAlgHom x)) ∈
P'.ker ^ 2 := by
letI := ((algebraMap S S').comp (algebraMap P.Ring S)).toAlgebra
have :
(f.toAlgHom x - P'.σ (algebraMap P.Ring S' x)) * (f.toAlgHom y - g.toAlgHom y) +
(g.toAlgHom y - P'.σ (algebraMap P.Ring S' y)) * (f.toAlgHom x - g.toAlgHom x)
∈ P'.ker ^ 2 := by
rw [pow_two]
refine Ideal.add_mem _ (Ideal.mul_mem_mul ?_ ?_) (Ideal.mul_mem_mul ?_ ?_) <;>
simp only [RingHom.algebraMap_toAlgebra, RingHom.coe_comp,
Function.comp_apply,
ker, RingHom.mem_ker, map_sub, algebraMap_toRingHom,
algebraMap_σ, sub_self, toAlgHom_apply]
convert this using 1
simp only [map_mul]
ring
/--
If `f` and `g` are two maps `P → P'` between presentations,
then the image of `f - g` is in the kernel of `P' → S`.
-/
@[simps! apply_coe]
noncomputable
def Hom.subToKer (f g : Hom P P') : P.Ring →ₗ[R] P'.ker := by
refine ((f.toAlgHom.toLinearMap - g.toAlgHom.toLinearMap).codRestrict
(P'.ker.restrictScalars R) ?_)
intro x
simp only [LinearMap.sub_apply, AlgHom.toLinearMap_apply, ker,
Submodule.restrictScalars_mem, RingHom.mem_ker, map_sub, algebraMap_toRingHom,
sub_self, toAlgHom_apply]
variable [IsScalarTower R S S'] in
/--
If `f` and `g` are two maps `P → P'` between presentations,
their difference induces a map `P.CotangentSpace →ₗ[S] P'.Cotangent` that makes two maps
between the cotangent complexes homotopic.
-/
noncomputable
def Hom.sub (f g : Hom P P') : P.CotangentSpace →ₗ[S] P'.Cotangent := by
letI := ((algebraMap S S').comp (algebraMap P.Ring S)).toAlgebra
haveI : IsScalarTower P.Ring S S' := IsScalarTower.of_algebraMap_eq' rfl
letI := f.toAlgHom.toAlgebra
haveI : IsScalarTower P.Ring P'.Ring S' :=
IsScalarTower.of_algebraMap_eq fun x ↦ (f.algebraMap_toRingHom x).symm
haveI : IsScalarTower R P.Ring S' :=
IsScalarTower.of_algebraMap_eq fun x ↦
show algebraMap R S' x = algebraMap S S' (algebraMap P.Ring S (algebraMap R P.Ring x)) by
rw [← IsScalarTower.algebraMap_apply R P.Ring S, ← IsScalarTower.algebraMap_apply]
refine (Derivation.liftKaehlerDifferential ?_).liftBaseChange S
refine
{ __ := Cotangent.mk.restrictScalars R ∘ₗ f.subToKer g
map_one_eq_zero' := ?_
leibniz' := ?_ }
· ext
simp [Ideal.toCotangent_eq_zero]
· intro x y
ext
simp only [LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply,
Cotangent.val_mk, Cotangent.val_add, Cotangent.val_smul''', ← map_smul, ← map_add,
Ideal.toCotangent_eq]
exact Hom.sub_aux f g x y
variable [IsScalarTower R S S']
lemma Hom.sub_one_tmul (f g : Hom P P') (x) :
f.sub g (1 ⊗ₜ .D _ _ x) = Cotangent.mk (f.subToKer g x) := by
simp only [sub, LinearMap.liftBaseChange_tmul, Derivation.liftKaehlerDifferential_comp_D,
Derivation.mk_coe, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply,
one_smul]
@[simp]
lemma Hom.sub_tmul (f g : Hom P P') (r x) :
f.sub g (r ⊗ₜ .D _ _ x) = r • Cotangent.mk (f.subToKer g x) := by
simp only [sub, LinearMap.liftBaseChange_tmul, Derivation.liftKaehlerDifferential_comp_D,
Derivation.mk_coe, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply]
lemma CotangentSpace.map_sub_map (f g : Hom P P') :
CotangentSpace.map f - CotangentSpace.map g =
P'.cotangentComplex.restrictScalars S ∘ₗ (f.sub g) := by
ext x
induction x using TensorProduct.induction_on with
| zero =>
simp only [map_zero]
| add =>
simp only [map_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, *]
| tmul x y =>
obtain ⟨y, rfl⟩ := KaehlerDifferential.tensorProductTo_surjective _ _ y
induction y with
| zero => simp only [map_zero, tmul_zero]
| add => simp only [map_add, tmul_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars,
Function.comp_apply, *]
| tmul =>
simp only [Derivation.tensorProductTo_tmul, tmul_smul, smul_tmul', LinearMap.sub_apply,
map_tmul, Hom.toAlgHom_apply, LinearMap.coe_comp, LinearMap.coe_restrictScalars,
Function.comp_apply, Hom.sub_tmul, LinearMap.map_smul_of_tower, cotangentComplex_mk,
Hom.subToKer_apply_coe, map_sub, ← algebraMap_eq_smul_one, tmul_sub, smul_sub]
lemma Cotangent.map_sub_map (f g : Hom P P') :
map f - map g = (f.sub g) ∘ₗ P.cotangentComplex := by
ext x
obtain ⟨x, rfl⟩ := mk_surjective x
simp only [LinearMap.sub_apply, map_mk, LinearMap.coe_comp, Function.comp_apply,
cotangentComplex_mk, Hom.sub_tmul, one_smul, val_mk]
apply (Ideal.cotangentEquivIdeal _).injective
ext
simp only [val_sub, val_mk, map_sub, AddSubgroupClass.coe_sub, Ideal.cotangentEquivIdeal_apply,
Ideal.toCotangent_to_quotient_square, Submodule.mkQ_apply, Ideal.Quotient.mk_eq_mk,
Hom.subToKer_apply_coe, Hom.toAlgHom_apply]
variable (P) in
/-- The projection map from the relative cotangent space to the module of differentials. -/
noncomputable
abbrev toKaehler : P.CotangentSpace →ₗ[S] Ω[S⁄R] := mapBaseChange _ _ _
lemma toKaehler_surjective : Function.Surjective P.toKaehler :=
mapBaseChange_surjective _ _ _ P.algebraMap_surjective
lemma exact_cotangentComplex_toKaehler : Function.Exact P.cotangentComplex P.toKaehler :=
exact_kerCotangentToTensor_mapBaseChange _ _ _ P.algebraMap_surjective
variable (P) in
/--
The first homology of the (naive) cotangent complex of `S` over `R`,
induced by a given presentation `0 → I → P → R → 0`,
defined as the kernel of `I/I² → S ⊗[P] Ω[P⁄R]`.
-/
protected noncomputable
def H1Cotangent : Type _ := LinearMap.ker P.cotangentComplex
variable {P : Extension R S}
noncomputable
instance : AddCommGroup P.H1Cotangent := by delta Extension.H1Cotangent; infer_instance
noncomputable
instance {R₀} [CommRing R₀] [Algebra R₀ S] [Module R₀ P.Cotangent]
[IsScalarTower R₀ S P.Cotangent] : Module R₀ P.H1Cotangent := by
delta Extension.H1Cotangent; infer_instance
@[simp] lemma H1Cotangent.val_add (x y : P.H1Cotangent) : (x + y).1 = x.1 + y.1 := rfl
@[simp] lemma H1Cotangent.val_zero : (0 : P.H1Cotangent).1 = 0 := rfl
@[simp] lemma H1Cotangent.val_smul {R₀} [CommRing R₀] [Algebra R₀ S] [Module R₀ P.Cotangent]
[IsScalarTower R₀ S P.Cotangent] (r : R₀) (x : P.H1Cotangent) : (r • x).1 = r • x.1 := rfl
noncomputable
instance {R₁ R₂} [CommRing R₁] [CommRing R₂] [Algebra R₁ R₂]
[Algebra R₁ S] [Algebra R₂ S]
[Module R₁ P.Cotangent] [IsScalarTower R₁ S P.Cotangent]
[Module R₂ P.Cotangent] [IsScalarTower R₂ S P.Cotangent]
[IsScalarTower R₁ R₂ P.Cotangent] :
IsScalarTower R₁ R₂ P.H1Cotangent := by
delta Extension.H1Cotangent; infer_instance
lemma subsingleton_h1Cotangent (P : Extension R S) :
Subsingleton P.H1Cotangent ↔ Function.Injective P.cotangentComplex := by
delta Extension.H1Cotangent
rw [← LinearMap.ker_eq_bot, Submodule.eq_bot_iff, subsingleton_iff_forall_eq 0, Subtype.forall']
simp only [Subtype.ext_iff, Submodule.coe_zero]
/-- The inclusion of `H¹(L_{S/R})` into the conormal space of a presentation. -/
@[simps!] noncomputable def h1Cotangentι : P.H1Cotangent →ₗ[S] P.Cotangent := Submodule.subtype _
lemma h1Cotangentι_injective : Function.Injective P.h1Cotangentι := Subtype.val_injective
@[ext] lemma h1Cotangentι_ext (x y : P.H1Cotangent) (e : x.1 = y.1) : x = y := Subtype.ext e
/--
The induced map on the first homology of the (naive) cotangent complex.
-/
@[simps!]
noncomputable
def H1Cotangent.map (f : Hom P P') : P.H1Cotangent →ₗ[S] P'.H1Cotangent := by
refine (Cotangent.map f).restrict (p := LinearMap.ker P.cotangentComplex)
(q := (LinearMap.ker P'.cotangentComplex).restrictScalars S) fun x hx ↦ ?_
simp only [LinearMap.mem_ker, Submodule.restrictScalars_mem] at hx ⊢
apply_fun (CotangentSpace.map f) at hx
rw [CotangentSpace.map_cotangentComplex] at hx
rw [hx]
exact LinearMap.map_zero _
lemma H1Cotangent.map_eq (f g : Hom P P') : map f = map g := by
ext x
simp only [map_apply_coe]
rw [← sub_eq_zero, ← Cotangent.val_sub, ← LinearMap.sub_apply, Cotangent.map_sub_map]
simp only [LinearMap.coe_comp, Function.comp_apply, LinearMap.map_coe_ker, map_zero,
Cotangent.val_zero]
@[simp] lemma H1Cotangent.map_id : map (.id P) = LinearMap.id := by ext; simp
omit [IsScalarTower R S S'] in
lemma H1Cotangent.map_comp
(f : Hom P P') (g : Hom P' P'') :
map (g.comp f) = (map g).restrictScalars S ∘ₗ map f := by
ext; simp [Cotangent.map_comp]
/-- Maps `P₁ → P₂` and `P₂ → P₁` between extensions
induce an isomorphism between `H¹(L_P₁)` and `H¹(L_P₂)`. -/
@[simps! apply]
noncomputable
def H1Cotangent.equiv {P₁ P₂ : Extension R S} (f₁ : P₁.Hom P₂) (f₂ : P₂.Hom P₁) :
P₁.H1Cotangent ≃ₗ[S] P₂.H1Cotangent where
__ := map f₁
invFun := map f₂
left_inv x :=
show (map f₂ ∘ₗ map f₁) x = LinearMap.id x by
rw [← Extension.H1Cotangent.map_id, eq_comm, map_eq _ (f₂.comp f₁),
Extension.H1Cotangent.map_comp]; rfl
right_inv x :=
show (map f₁ ∘ₗ map f₂) x = LinearMap.id x by
rw [← Extension.H1Cotangent.map_id, eq_comm, map_eq _ (f₁.comp f₂),
Extension.H1Cotangent.map_comp]; rfl
end Extension
namespace Generators
variable {ι : Type w} (P : Generators R S ι)
/-- The canonical basis on the `CotangentSpace`. -/
noncomputable
def cotangentSpaceBasis : Basis ι S P.toExtension.CotangentSpace :=
(mvPolynomialBasis _ _).baseChange (R := P.Ring) _
@[simp]
lemma cotangentSpaceBasis_repr_tmul (r x i) :
P.cotangentSpaceBasis.repr (r ⊗ₜ[P.Ring] KaehlerDifferential.D R P.Ring x : _) i =
r * aeval P.val (pderiv i x) := by
classical
simp only [cotangentSpaceBasis, Basis.baseChange_repr_tmul, mvPolynomialBasis_repr_apply,
Algebra.smul_def, mul_comm r, algebraMap_apply, toExtension]
lemma cotangentSpaceBasis_repr_one_tmul (x i) :
P.cotangentSpaceBasis.repr (1 ⊗ₜ .D _ _ x) i = aeval P.val (pderiv i x) := by
simp
lemma cotangentSpaceBasis_apply (i) :
P.cotangentSpaceBasis i = ((1 : S) ⊗ₜ[P.Ring] D R P.Ring (.X i) :) := by
simp [cotangentSpaceBasis, toExtension]
instance (P : Generators R S ι) : Module.Free S P.toExtension.CotangentSpace :=
.of_basis P.cotangentSpaceBasis
/-- Given generators `R[xᵢ] → S` and an injective map `σ → ι`, this is the
composition `I/I² → ⊕ S dxᵢ → ⊕ S dxᵢ` where the second `i` only runs over `σ`. -/
noncomputable
def cotangentRestrict {σ : Type*} {u : σ → ι} (hu : Function.Injective u) :
P.toExtension.Cotangent →ₗ[S] (σ →₀ S) :=
Finsupp.lcomapDomain u hu ∘ₗ P.cotangentSpaceBasis.repr.toLinearMap ∘ₗ
P.toExtension.cotangentComplex
lemma cotangentRestrict_mk {σ : Type*} {u : σ → ι} (hu : Function.Injective u) (x : P.ker) :
cotangentRestrict P hu (Extension.Cotangent.mk x) =
fun j ↦ (aeval P.val) <| pderiv (u j) x.val := by
ext j
simp only [cotangentRestrict, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply,
Finsupp.lcomapDomain_apply, Finsupp.comapDomain_apply, Extension.cotangentComplex_mk]
simp only [toExtension_Ring, P.cotangentSpaceBasis_repr_tmul, one_mul]
universe w' u' v'
variable {R' : Type u'} {S' : Type v'} {ι' : Type w'} [CommRing R'] [CommRing S'] [Algebra R' S']
variable (P' : Generators R' S' ι')
variable [Algebra R R'] [Algebra S S'] [Algebra R S'] [IsScalarTower R R' S'] [IsScalarTower R S S']
attribute [local instance] SMulCommClass.of_commMonoid
variable {P P'}
universe w'' u'' v''
variable {R'' : Type u''} {S'' : Type v''} {ι'' : Type w''}
[CommRing R''] [CommRing S''] [Algebra R'' S''] {P'' : Generators R'' S'' ι''}
variable [Algebra R R''] [Algebra S S''] [Algebra R S'']
[IsScalarTower R R'' S''] [IsScalarTower R S S'']
variable [Algebra R' R''] [Algebra S' S''] [Algebra R' S'']
[IsScalarTower R' R'' S''] [IsScalarTower R' S' S'']
variable [IsScalarTower S S' S'']
open Extension
@[simp]
lemma repr_CotangentSpaceMap (f : Hom P P') (i j) :
P'.cotangentSpaceBasis.repr (CotangentSpace.map f.toExtensionHom (P.cotangentSpaceBasis i)) j =
aeval P'.val (pderiv j (f.val i)) := by
rw [cotangentSpaceBasis_apply]
simp only [toExtension]
rw [CotangentSpace.map_tmul, map_one]
erw [cotangentSpaceBasis_repr_one_tmul, Hom.toAlgHom_X]
lemma toKaehler_tmul_D (i) :
P.toExtension.toKaehler (1 ⊗ₜ D R P.Ring (X i)) = D _ _ (P.val i) :=
(KaehlerDifferential.mapBaseChange_tmul ..).trans (by simp)
@[simp]
lemma toKaehler_cotangentSpaceBasis (i) :
P.toExtension.toKaehler (P.cotangentSpaceBasis i) = D R S (P.val i) := by
rw [cotangentSpaceBasis_apply]
exact toKaehler_tmul_D i
end Generators
-- TODO: generalize to essentially of finite presentation algebras
open KaehlerDifferential in
attribute [local instance] Module.finitePresentation_of_projective in
instance [Algebra.FinitePresentation R S] : Module.FinitePresentation S Ω[S⁄R] := by
let P := Algebra.Presentation.ofFinitePresentation R S
have : Algebra.FiniteType R P.toExtension.Ring := by simp [P]; infer_instance
refine Module.finitePresentation_of_surjective _ P.toExtension.toKaehler_surjective ?_
rw [LinearMap.exact_iff.mp P.toExtension.exact_cotangentComplex_toKaehler, ← Submodule.map_top]
exact (Extension.Cotangent.finite P.fg_ker).1.map P.toExtension.cotangentComplex
variable {ι : Type w} {ι' : Type*} {P : Generators R S ι}
open Extension.H1Cotangent in
/-- `H¹(L_{S/R})` is independent of the presentation chosen. -/
@[simps! apply]
noncomputable
def Generators.H1Cotangent.equiv (P : Generators R S ι) (P' : Generators R S ι') :
P.toExtension.H1Cotangent ≃ₗ[S] P'.toExtension.H1Cotangent :=
Extension.H1Cotangent.equiv
(Generators.defaultHom P P').toExtensionHom (Generators.defaultHom P' P).toExtensionHom
variable {S' : Type*} [CommRing S'] [Algebra R S']
variable {T : Type w} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable [Algebra S' T] [IsScalarTower R S' T]
variable (R S S' T)
/-- `H¹(L_{S/R})`, the first homology of the (naive) cotangent complex of `S` over `R`. -/
abbrev H1Cotangent : Type _ := (Generators.self R S).toExtension.H1Cotangent
/-- The induced map on the first homology of the (naive) cotangent complex of `S` over `R`. -/
noncomputable
def H1Cotangent.map : H1Cotangent R S' →ₗ[S'] H1Cotangent S T :=
Extension.H1Cotangent.map (Generators.defaultHom _ _).toExtensionHom
/-- Isomorphic algebras induce isomorphic `H¹(L_{S/R})`. -/
noncomputable
def H1Cotangent.mapEquiv (e : S ≃ₐ[R] S') :
H1Cotangent R S ≃ₗ[R] H1Cotangent R S' :=
-- we are constructing data, so we do not use `algebraize`
letI := e.toRingHom.toAlgebra
letI := e.symm.toRingHom.toAlgebra
have : IsScalarTower R S S' := .of_algebraMap_eq' e.toAlgHom.comp_algebraMap.symm
have : IsScalarTower R S' S := .of_algebraMap_eq' e.symm.toAlgHom.comp_algebraMap.symm
have : IsScalarTower S S' S := .of_algebraMap_eq fun _ ↦ (e.symm_apply_apply _).symm
have : IsScalarTower S' S S' := .of_algebraMap_eq fun _ ↦ (e.apply_symm_apply _).symm
{ toFun := map R R S S'
invFun := map R R S' S
left_inv x := by
change ((map R R S' S).restrictScalars S ∘ₗ map R R S S') x = x
rw [map, map, ← Extension.H1Cotangent.map_comp, Extension.H1Cotangent.map_eq,
Extension.H1Cotangent.map_id, LinearMap.id_apply]
right_inv x := by
change ((map R R S S').restrictScalars S' ∘ₗ map R R S' S) x = x
rw [map, map, ← Extension.H1Cotangent.map_comp, Extension.H1Cotangent.map_eq,
Extension.H1Cotangent.map_id, LinearMap.id_apply]
map_add' := LinearMap.map_add (map R R S S')
map_smul' := LinearMap.CompatibleSMul.map_smul (map R R S S') }
variable {R S S' T}
/-- `H¹(L_{S/R})` is independent of the presentation chosen. -/
noncomputable
abbrev Generators.equivH1Cotangent (P : Generators R S ι) :
P.toExtension.H1Cotangent ≃ₗ[S] H1Cotangent R S :=
Generators.H1Cotangent.equiv _ _
attribute [local instance] Module.finitePresentation_of_projective in
instance [FinitePresentation R S] [Module.Projective S Ω[S⁄R]] :
Module.Finite S (H1Cotangent R S) := by
let P := Algebra.Presentation.ofFinitePresentation R S
have : Algebra.FiniteType R P.toExtension.Ring := by simp [P]; infer_instance
suffices Module.Finite S P.toExtension.H1Cotangent from
.of_surjective P.equivH1Cotangent.toLinearMap P.equivH1Cotangent.surjective
rw [Module.finite_def, Submodule.fg_top, ← LinearMap.ker_rangeRestrict]
have := Extension.Cotangent.finite P.fg_ker
have : Module.FinitePresentation S (LinearMap.range P.toExtension.cotangentComplex) := by
rw [← LinearMap.exact_iff.mp P.toExtension.exact_cotangentComplex_toKaehler]
exact Module.finitePresentation_of_projective_of_exact
_ _ (Subtype.val_injective) P.toExtension.toKaehler_surjective
(LinearMap.exact_subtype_ker_map _)
exact Module.FinitePresentation.fg_ker (N := LinearMap.range P.toExtension.cotangentComplex)
_ P.toExtension.cotangentComplex.surjective_rangeRestrict
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Cotangent/LocalizationAway.lean | import Mathlib.RingTheory.Extension.Presentation.Basic
import Mathlib.RingTheory.Smooth.StandardSmoothCotangent
import Mathlib.RingTheory.Kaehler.JacobiZariski
/-!
# Cotangent and localization away
Let `R → S → T` be algebras such that `T` is the localization of `S` away from one
element, where `S` is generated over `R` by `P : R[X] → S` with kernel `I` and
`Q : S[Y] → T` is the canonical `S`-presentation of `T` with kernel `K`.
Denote by `J` the kernel of the composition `R[X,Y] → T`.
This file proves `J/J² ≃ₗ[T] T ⊗[S] (I/I²) × K/K²`. For this we establish the exact sequence:
```
0 → T ⊗[S] (I/I²) → J/J² → K/K² → 0
```
and use that `K/K²` is free, so the sequence splits. The first part of the file
shows the exactness on the left and the rest of the file deduces the exact sequence
and the splitting from the Jacobi Zariski sequence.
## Main results
- `Algebra.Generators.liftBaseChange_injective`:
`T ⊗[S] (I/I²) → J/J²` is injective if `T` is the localization of `S` away from an element.
- `Algebra.Generators.cotangentCompLocalizationAwayEquiv`: `J/J² ≃ₗ[T] T ⊗[S] (I/I²) × K/K²`.
-/
open TensorProduct MvPolynomial
namespace Algebra.Generators
variable {R S T ι : Type*} [CommRing R] [CommRing S] [Algebra R S]
[CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable (g : S) [IsLocalization.Away g T] (P : Generators R S ι)
lemma comp_localizationAway_ker (P : Generators R S ι) (f : P.Ring)
(h : algebraMap P.Ring S f = g) :
((Generators.localizationAway T g).comp P).ker =
Ideal.map ((Generators.localizationAway T g).toComp P).toAlgHom P.ker ⊔
Ideal.span {rename Sum.inr f * X (Sum.inl ()) - 1} := by
have : (localizationAway T g).ker = Ideal.map ((localizationAway T g).ofComp P).toAlgHom
(Ideal.span {MvPolynomial.rename Sum.inr f * MvPolynomial.X (Sum.inl ()) - 1}) := by
rw [Ideal.map_span, Set.image_singleton, map_sub, map_mul, map_one, ker_localizationAway,
Hom.toAlgHom_X, toAlgHom_ofComp_rename, h, ofComp_val, Sum.elim_inl]
rw [ker_comp_eq_sup, Algebra.Generators.map_toComp_ker, this,
Ideal.comap_map_of_surjective _ (toAlgHom_ofComp_surjective _ P), ← RingHom.ker_eq_comap_bot,
← sup_assoc]
simp
variable (T) in
/-- If `R[X] → S` generates `S`, `T` is the localization of `S` away from `g` and
`f` is a pre-image of `g` in `R[X]`, this is the `R`-algebra map `R[X,Y] →ₐ[R] (R[X]/I²)[1/f]`
defined via mapping `Y` to `1/f`. -/
noncomputable
def compLocalizationAwayAlgHom : ((Generators.localizationAway T g).comp P).Ring →ₐ[R]
Localization.Away (Ideal.Quotient.mk (P.ker ^ 2) (P.σ g)) :=
aeval (R := R) (S₁ := Localization.Away _)
(Sum.elim
(fun _ ↦ IsLocalization.Away.invSelf <| (Ideal.Quotient.mk (P.ker ^ 2) (P.σ g)))
(fun i : ι ↦ algebraMap P.Ring _ (X i)))
@[simp]
lemma compLocalizationAwayAlgHom_toAlgHom_toComp (x : P.Ring) :
compLocalizationAwayAlgHom T g P (((localizationAway T g).toComp P).toAlgHom x) =
algebraMap P.Ring _ x := by
simp only [toComp_toAlgHom, compLocalizationAwayAlgHom, comp,
localizationAway, AlgHom.toRingHom_eq_coe, aeval_rename,
Sum.elim_comp_inr, ← IsScalarTower.toAlgHom_apply (R := R), ← comp_aeval_apply,
aeval_X_left_apply]
@[simp]
lemma compLocalizationAwayAlgHom_X_inl : compLocalizationAwayAlgHom T g P (X (Sum.inl ())) =
IsLocalization.Away.invSelf ((Ideal.Quotient.mk (P.ker ^ 2)) (P.σ g)) := by
simp [compLocalizationAwayAlgHom]
lemma compLocalizationAwayAlgHom_relation_eq_zero :
compLocalizationAwayAlgHom T g P (rename Sum.inr (P.σ g) * X (Sum.inl ()) - 1) = 0 := by
rw [map_sub, map_one, map_mul, ← toComp_toAlgHom (Generators.localizationAway T g) P]
change (compLocalizationAwayAlgHom T g P)
(((localizationAway T g).toComp P).toAlgHom _) * _ - _ = _
rw [compLocalizationAwayAlgHom_toAlgHom_toComp, compLocalizationAwayAlgHom_X_inl,
IsScalarTower.algebraMap_apply P.Ring (P.Ring ⧸ P.ker ^ 2) (Localization.Away _)]
simp
lemma sq_ker_comp_le_ker_compLocalizationAwayAlgHom :
((localizationAway T g).comp P).ker ^ 2 ≤
RingHom.ker (compLocalizationAwayAlgHom T g P) := by
have hsple {x} (hx : x ∈ Ideal.span {(rename Sum.inr) (P.σ g) * X (Sum.inl ()) - 1}) :
(compLocalizationAwayAlgHom T g P) x = 0 := by
obtain ⟨a, rfl⟩ := Ideal.mem_span_singleton.mp hx
rw [map_mul, compLocalizationAwayAlgHom_relation_eq_zero, zero_mul]
rw [comp_localizationAway_ker _ _ (P.σ g) (by simp), sq, Ideal.sup_mul, Ideal.mul_sup,
Ideal.mul_sup]
apply sup_le
· apply sup_le
· rw [← Ideal.map_mul, Ideal.map_le_iff_le_comap, ← sq]
intro x hx
simp only [Ideal.mem_comap, RingHom.mem_ker,
compLocalizationAwayAlgHom_toAlgHom_toComp (T := T) g P x]
rw [IsScalarTower.algebraMap_apply P.Ring (P.Ring ⧸ P.ker ^ 2) (Localization.Away _),
Ideal.Quotient.algebraMap_eq, Ideal.Quotient.eq_zero_iff_mem.mpr hx, map_zero]
· rw [Ideal.mul_le]
intro x hx y hy
simp [hsple hy]
· apply sup_le <;>
· rw [Ideal.mul_le]
intro x hx y hy
simp [hsple hx]
/--
Let `R → S → T` be algebras such that `T` is the localization of `S` away from one
element, where `S` is generated over `R` by `P` with kernel `I` and `Q` is the
canonical `S`-presentation of `T`. Denote by `J` the kernel of the composition
`R[X,Y] → T`. Then `T ⊗[S] (I/I²) → J/J²` is injective.
-/
@[stacks 08JZ "part of (1)"]
lemma liftBaseChange_injective_of_isLocalizationAway :
Function.Injective (LinearMap.liftBaseChange T
(Extension.Cotangent.map
((Generators.localizationAway T g).toComp P).toExtensionHom)) := by
set Q := Generators.localizationAway T g
algebraize [((Generators.localizationAway T g).toComp P).toAlgHom.toRingHom]
let f : P.Ring ⧸ P.ker ^ 2 := P.σ g
let π := compLocalizationAwayAlgHom T g P
refine IsLocalizedModule.injective_of_map_zero (Submonoid.powers g)
(TensorProduct.mk S T P.toExtension.Cotangent 1) (fun x hx ↦ ?_)
obtain ⟨x, rfl⟩ := Algebra.Extension.Cotangent.mk_surjective x
suffices h : algebraMap P.Ring (Localization.Away f) x.val = 0 by
rw [IsScalarTower.algebraMap_apply _ (P.Ring ⧸ P.ker ^ 2) _,
IsLocalization.map_eq_zero_iff (Submonoid.powers f) (Localization.Away f)] at h
obtain ⟨⟨m, ⟨n, rfl⟩⟩, hm⟩ := h
rw [IsLocalizedModule.eq_zero_iff (Submonoid.powers g)]
use ⟨g ^ n, n, rfl⟩
dsimp [f] at hm
rw [← map_pow, ← map_mul, Ideal.Quotient.eq_zero_iff_mem] at hm
simp only [Submonoid.smul_def]
rw [show g = algebraMap P.Ring S (P.σ g) by simp, ← map_pow, algebraMap_smul, ← map_smul,
Extension.Cotangent.mk_eq_zero_iff]
simpa using hm
rw [← compLocalizationAwayAlgHom_toAlgHom_toComp (T := T)]
apply sq_ker_comp_le_ker_compLocalizationAwayAlgHom
simpa only [LinearEquiv.coe_coe, LinearMap.ringLmapEquivSelf_symm_apply,
mk_apply, lift.tmul, LinearMap.coe_restrictScalars, LinearMap.coe_smulRight,
Module.End.one_apply, LinearMap.smul_apply, one_smul, Algebra.Extension.Cotangent.map_mk,
Extension.Cotangent.mk_eq_zero_iff] using hx
/--
In the notation of the module docstring: Since `T` is standard smooth
of relative dimension one over `S`, `K/K²` is free of rank one generated
by the image of `g * X - 1`.
This is the section `K/K² → J/J²` defined by sending the image of `g * X - 1` to `x : J/J²`.
-/
noncomputable def cotangentCompAwaySec (x : ((localizationAway T g).comp P).toExtension.Cotangent) :
(localizationAway T g).toExtension.Cotangent →ₗ[T]
((localizationAway T g).comp P).toExtension.Cotangent :=
(basisCotangentAway T g).constr T fun _ ↦ x
variable (x : ((localizationAway T g).comp P).toExtension.Cotangent)
/-- By construction, the section `cotangentCompAwaySec` sends `g * X - 1` to `x`. -/
lemma cotangentCompAwaySec_apply :
cotangentCompAwaySec g P x (cMulXSubOneCotangent T g) = x := by
rw [← basisCotangentAway_apply _ (), cotangentCompAwaySec, Module.Basis.constr_basis]
variable {x}
(hx : Extension.Cotangent.map ((localizationAway T g).ofComp P).toExtensionHom x =
cMulXSubOneCotangent T g)
include hx in
/-- The section `cotangentCompAwaySec` is indeed a section of the canonical map `J/J² → K/K²`. -/
lemma map_comp_cotangentCompAwaySec :
(Extension.Cotangent.map ((localizationAway T g).ofComp P).toExtensionHom) ∘ₗ
cotangentCompAwaySec g P x = .id := by
refine (basisCotangentAway T g).ext fun r ↦ ?_
simpa only [LinearMap.coe_comp, Function.comp_apply, basisCotangentAway_apply,
cotangentCompAwaySec_apply]
/--
Let `S` be generated over `R` by `P : R[X] → S` with kernel `I` and let `T`
be the localization of `S` away from `g` generated over `S` by `S[Y] → T` with
kernel `K`.
Denote by `J` the kernel of the induced `R[X, Y] → T`. Then
`J/J² ≃ₗ[T] T ⊗[S] (I/I²) × (K/K²)`.
This is the splitting characterised by `x ↦ (0, g * X - 1)`.
-/
@[stacks 08JZ "(1)"]
noncomputable
def cotangentCompLocalizationAwayEquiv :
((localizationAway T g).comp P).toExtension.Cotangent ≃ₗ[T]
T ⊗[S] P.toExtension.Cotangent × (Generators.localizationAway T g).toExtension.Cotangent :=
((Cotangent.exact (localizationAway g (S := T)) P).splitSurjectiveEquiv
(liftBaseChange_injective_of_isLocalizationAway _ P)
⟨cotangentCompAwaySec g P x, map_comp_cotangentCompAwaySec g P hx⟩).1
lemma cotangentCompLocalizationAwayEquiv_symm_inr :
(cotangentCompLocalizationAwayEquiv g P hx).symm
(0, cMulXSubOneCotangent T g) = x := by
simpa [cotangentCompLocalizationAwayEquiv, Function.Exact.splitSurjectiveEquiv] using
cotangentCompAwaySec_apply g P x
lemma cotangentCompLocalizationAwayEquiv_symm_comp_inl :
(cotangentCompLocalizationAwayEquiv g P hx).symm.toLinearMap ∘ₗ
.inl T (T ⊗[S] P.toExtension.Cotangent) (localizationAway T g).toExtension.Cotangent =
.liftBaseChange T
(Extension.Cotangent.map ((localizationAway T g).toComp P).toExtensionHom) :=
((Cotangent.exact (localizationAway g (S := T)) P).splitSurjectiveEquiv
(liftBaseChange_injective_of_isLocalizationAway _ P)
⟨cotangentCompAwaySec g P x,
map_comp_cotangentCompAwaySec g P hx⟩).2.left.symm
@[simp]
lemma cotangentCompLocalizationAwayEquiv_symm_inl (a : T ⊗[S] P.toExtension.Cotangent) :
(cotangentCompLocalizationAwayEquiv g P hx).symm (a, 0) = LinearMap.liftBaseChange T
(Extension.Cotangent.map ((localizationAway T g).toComp P).toExtensionHom) a := by
simp [← cotangentCompLocalizationAwayEquiv_symm_comp_inl g P hx]
lemma snd_comp_cotangentCompLocalizationAwayEquiv :
LinearMap.snd T (T ⊗[S] P.toExtension.Cotangent) (localizationAway T g).toExtension.Cotangent ∘ₗ
(cotangentCompLocalizationAwayEquiv g P hx).toLinearMap =
Extension.Cotangent.map ((localizationAway T g).ofComp P).toExtensionHom :=
((Cotangent.exact (localizationAway T g) P).splitSurjectiveEquiv
(liftBaseChange_injective_of_isLocalizationAway _ P)
⟨cotangentCompAwaySec g P x, map_comp_cotangentCompAwaySec g P hx⟩).2.right.symm
@[simp]
lemma snd_cotangentCompLocalizationAwayEquiv
(a : ((localizationAway T g).comp P).toExtension.Cotangent) :
(cotangentCompLocalizationAwayEquiv g P hx a).2 =
Extension.Cotangent.map ((localizationAway T g).ofComp P).toExtensionHom a := by
simp [← snd_comp_cotangentCompLocalizationAwayEquiv g P hx]
end Algebra.Generators |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Cotangent/Free.lean | import Mathlib.LinearAlgebra.Basis.Exact
import Mathlib.RingTheory.Extension.Cotangent.Basic
import Mathlib.RingTheory.Extension.Presentation.Submersive
/-!
# Computation of Jacobian of presentations from basis of Cotangent
Let `P` be a presentation of an `R`-algebra `S` with kernel `I = (fᵢ)`.
In this file we provide lemmas to show that `P` is submersive when given suitable bases of
`I/I²` and `Ω[S⁄R]`.
We will later deduce from this a presentation-independent characterisation of standard
smooth algebras (TODO @chrisflav).
## Main results
- `PreSubmersivePresentation.isUnit_jacobian_of_cotangentRestrict_bijective`:
If the `fᵢ` form a basis of `I/I²` and the restricted cotangent complex
`I/I² → S ⊗[R] (Ω[R[Xᵢ]⁄R]) = ⊕ᵢ S → ⊕ⱼ S` is bijective, `P` is submersive.
-/
universe t₂ t₁ u v
open KaehlerDifferential MvPolynomial
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] {ι σ κ : Type*}
namespace Algebra
namespace Generators
variable (P : Generators R S ι) {u : σ → ι} (hu : Function.Injective u)
{v : κ → ι} (hv : Function.Injective v)
/--
If `H¹(L_{S/R}) = 0` and `R[xᵢ] → S` are generators indexed by `σ ⊕ κ` such that the images
of `dxₖ` for `k : κ` span `Ω[S⁄R]` and the span of the `dXₖ` for `k : κ` in
`S ⊗[R] Ω[R[Xᵢ⁄R]]` intersects the kernel of the projection trivially, then the restriction of
`I/I² → ⊕ S dxᵢ` to the direct sum indexed by `i : ι` is an isomorphism.
The assumptions are in particular satisfied if the `dsₖ` form an `S`-basis of `Ω[S⁄R]`,
see `Generators.disjoint_ker_toKaehler_of_linearIndependent` for one half.
Via `PreSubmersivePresentation.isUnit_jacobian_of_cotangentRestrict_bijective`, this can be useful
to show a presentation is submersive.
-/
lemma cotangentRestrict_bijective_of_isCompl
(huv : IsCompl (Set.range v) (Set.range u))
(hm : Submodule.span S (.range fun i ↦ D R S (P.val (v i))) = ⊤)
(hk : Disjoint (LinearMap.ker P.toExtension.toKaehler)
(.span S (.range fun x ↦ P.cotangentSpaceBasis (v x))))
[Subsingleton (H1Cotangent R S)] :
Function.Bijective (cotangentRestrict P hu) := by
rw [cotangentRestrict, Finsupp.lcomapDomain_eq_linearProjOfIsCompl _ huv.symm]
set f : _ →ₗ[S] (ι →₀ S) := P.cotangentSpaceBasis.repr ∘ₗ P.toExtension.cotangentComplex
let g : (ι →₀ S) →ₗ[S] (Ω[S⁄R]) := P.toExtension.toKaehler ∘ₗ P.cotangentSpaceBasis.repr.symm
have hfg : Function.Exact f g := by
simp only [f, g, LinearEquiv.conj_exact_iff_exact]
exact Extension.exact_cotangentComplex_toKaehler
apply LinearMap.linearProjOfIsCompl_comp_bijective_of_exact hfg
· exact P.cotangentSpaceBasis.repr.injective.comp <|
(Extension.subsingleton_h1Cotangent P.toExtension).mp P.equivH1Cotangent.subsingleton
· simp only [disjoint_iff, g]
apply Submodule.map_injective_of_injective (f := P.cotangentSpaceBasis.repr.symm.toLinearMap)
P.cotangentSpaceBasis.repr.symm.injective
rw [Submodule.map_inf P.cotangentSpaceBasis.repr.symm.toLinearMap
P.cotangentSpaceBasis.repr.symm.injective, Submodule.map_span, ← Set.range_comp,
Function.comp_def, LinearMap.ker_comp, Submodule.map_comap_eq_of_surjective]
· simpa [← disjoint_iff]
· exact P.cotangentSpaceBasis.repr.symm.surjective
· simpa [g, Submodule.map_comp, Submodule.map_span, ← Set.range_comp, Function.comp_def]
lemma disjoint_ker_toKaehler_of_linearIndependent
(h : LinearIndependent S (fun k ↦ D R S (P.val (v k)))) :
Disjoint (LinearMap.ker P.toExtension.toKaehler)
(.span S <| .range fun x ↦ P.cotangentSpaceBasis (v x)) := by
rw [disjoint_iff, Submodule.eq_bot_iff]
intro x ⟨hx, hxs⟩
rw [SetLike.mem_coe, Finsupp.mem_span_range_iff_exists_finsupp] at hxs
obtain ⟨c, rfl⟩ := hxs
simp only [SetLike.mem_coe, LinearMap.mem_ker, map_finsuppSum, map_smul,
toKaehler_cotangentSpaceBasis] at hx
obtain rfl := (linearIndependent_iff.mp h) c hx
simp
end Generators
namespace PreSubmersivePresentation
open Generators
variable (P : PreSubmersivePresentation R S ι σ) [Finite σ]
/-- To show a pre-submersive presentation with kernel `I = (fᵢ)` is submersive, it suffices to show
that the images of the `fᵢ` form a basis of `I/I²` and that the restricted
cotangent complex `I/I² → S ⊗[R] (Ω[R[Xᵢ]⁄R]) = ⊕ᵢ S → ⊕ⱼ S` is bijective. -/
lemma isUnit_jacobian_of_cotangentRestrict_bijective
(b : Module.Basis σ S P.toExtension.Cotangent)
(hb : ∀ r, b r = Extension.Cotangent.mk ⟨P.relation r, P.relation_mem_ker r⟩)
(h : Function.Bijective (P.cotangentRestrict P.map_inj)) :
IsUnit P.jacobian := by
have heq : (fun j i ↦ (aeval P.val) (pderiv (P.map i) (P.relation j))) =
Finsupp.linearEquivFunOnFinite S S _ ∘ P.cotangentRestrict P.map_inj ∘ ⇑b := by
ext i j
simp only [Function.comp_apply, hb, Finsupp.linearEquivFunOnFinite_apply, cotangentRestrict_mk]
apply P.isUnit_jacobian_of_linearIndependent_of_span_eq_top
· rw [heq]
exact (b.linearIndependent.map' _ (LinearMap.ker_eq_bot_of_injective h.injective)).map' _
(Finsupp.linearEquivFunOnFinite S S σ).ker
· rw [heq, Set.range_comp, Set.range_comp, ← Submodule.map_span, ← Submodule.map_span,
b.span_eq, Submodule.map_top, LinearMap.range_eq_top_of_surjective _ h.surjective,
Submodule.map_top, LinearEquivClass.range]
end PreSubmersivePresentation
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Presentation/Submersive.lean | import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.LinearAlgebra.Determinant
import Mathlib.RingTheory.Extension.Presentation.Basic
/-!
# Submersive presentations
In this file we define `PreSubmersivePresentation`. This is a presentation `P` that has
fewer relations than generators. More precisely there exists an injective map from `σ`
to `ι`. To such a presentation we may associate a Jacobian. `P` is then a submersive
presentation, if its Jacobian is invertible.
Algebras that admit such a presentation are called standard smooth. See
`Mathlib.RingTheory.Smooth.StandardSmooth` for applications.
## Main definitions
All of these are in the `Algebra` namespace. Let `S` be an `R`-algebra.
- `PreSubmersivePresentation`: A `Presentation` of `S` as `R`-algebra, equipped with an injective
map `P.map` from `σ` to `ι`. This map is used to define the differential of a
presubmersive presentation.
For a presubmersive presentation `P` of `S` over `R` we make the following definitions:
- `PreSubmersivePresentation.differential`: A linear endomorphism of `σ → P.Ring` sending
the `j`-th standard basis vector, corresponding to the `j`-th relation, to the vector
of partial derivatives of `P.relation j` with respect to the coordinates `P.map i` for
`i : σ`.
- `PreSubmersivePresentation.jacobian`: The determinant of `P.differential`.
- `PreSubmersivePresentation.jacobiMatrix`: If `σ` has a `Fintype` instance, we may form
the matrix corresponding to `P.differential`. Its determinant is `P.jacobian`.
- `SubmersivePresentation`: A submersive presentation is a finite, presubmersive presentation `P`
with in `S` invertible Jacobian.
## Notes
This contribution was created as part of the AIM workshop "Formalizing algebraic geometry"
in June 2024.
-/
universe t t' w w' u v
open TensorProduct Module MvPolynomial
namespace Algebra
variable (R : Type u) (S : Type v) (ι : Type w) (σ : Type t) [CommRing R] [CommRing S] [Algebra R S]
/--
A `PreSubmersivePresentation` of an `R`-algebra `S` is a `Presentation`
with relations equipped with an injective `map : relations → vars`.
This map determines how the differential of `P` is constructed. See
`PreSubmersivePresentation.differential` for details.
-/
@[nolint checkUnivs]
structure PreSubmersivePresentation extends Algebra.Presentation R S ι σ where
/-- A map from the relations type to the variables type. Used to compute the differential. -/
map : σ → ι
map_inj : Function.Injective map
namespace PreSubmersivePresentation
variable {R S ι σ}
variable (P : PreSubmersivePresentation R S ι σ)
include P in
lemma card_relations_le_card_vars_of_isFinite [Finite ι] :
Nat.card σ ≤ Nat.card ι :=
Nat.card_le_card_of_injective P.map P.map_inj
section
variable [Finite σ]
/-- The standard basis of `σ → P.ring`. -/
noncomputable abbrev basis : Basis σ P.Ring (σ → P.Ring) :=
Pi.basisFun P.Ring σ
/--
The differential of a `P : PreSubmersivePresentation` is a `P.Ring`-linear map on
`σ → P.Ring`:
The `j`-th standard basis vector, corresponding to the `j`-th relation of `P`, is mapped
to the vector of partial derivatives of `P.relation j` with respect
to the coordinates `P.map i` for all `i : σ`.
The determinant of this map is the Jacobian of `P` used to define when a `PreSubmersivePresentation`
is submersive. See `PreSubmersivePresentation.jacobian`.
-/
noncomputable def differential : (σ → P.Ring) →ₗ[P.Ring] (σ → P.Ring) :=
Basis.constr P.basis P.Ring
(fun j i : σ ↦ MvPolynomial.pderiv (P.map i) (P.relation j))
/-- `PreSubmersivePresentation.differential` pushed forward to `S` via `aeval P.val`. -/
noncomputable def aevalDifferential : (σ → S) →ₗ[S] (σ → S) :=
(Pi.basisFun S σ).constr S
(fun j i : σ ↦ aeval P.val <| pderiv (P.map i) (P.relation j))
@[simp]
lemma aevalDifferential_single [DecidableEq σ] (i j : σ) :
P.aevalDifferential (Pi.single i 1) j = aeval P.val (pderiv (P.map j) (P.relation i)) := by
dsimp only [aevalDifferential]
rw [← Pi.basisFun_apply, Basis.constr_basis]
/-- The Jacobian of a `P : PreSubmersivePresentation` is the determinant
of `P.differential` viewed as element of `S`. -/
noncomputable def jacobian : S :=
algebraMap P.Ring S <| LinearMap.det P.differential
end
section Matrix
variable [Fintype σ] [DecidableEq σ]
/--
If `σ` has a `Fintype` and `DecidableEq` instance, the differential of `P`
can be expressed in matrix form.
-/
noncomputable def jacobiMatrix : Matrix σ σ P.Ring :=
LinearMap.toMatrix P.basis P.basis P.differential
lemma jacobian_eq_jacobiMatrix_det : P.jacobian = algebraMap P.Ring S P.jacobiMatrix.det := by
simp [jacobiMatrix, jacobian]
lemma jacobiMatrix_apply (i j : σ) :
P.jacobiMatrix i j = MvPolynomial.pderiv (P.map i) (P.relation j) := by
simp [jacobiMatrix, LinearMap.toMatrix, differential, basis]
lemma aevalDifferential_toMatrix'_eq_mapMatrix_jacobiMatrix :
P.aevalDifferential.toMatrix' = (aeval P.val).mapMatrix P.jacobiMatrix := by
ext i j : 1
rw [← LinearMap.toMatrix_eq_toMatrix']
rw [LinearMap.toMatrix_apply]
simp [jacobiMatrix_apply]
end Matrix
section
variable [Finite σ]
lemma jacobian_eq_det_aevalDifferential : P.jacobian = P.aevalDifferential.det := by
classical
cases nonempty_fintype σ
simp [← LinearMap.det_toMatrix', P.aevalDifferential_toMatrix'_eq_mapMatrix_jacobiMatrix,
jacobian_eq_jacobiMatrix_det, RingHom.map_det, P.algebraMap_eq]
lemma isUnit_jacobian_iff_aevalDifferential_bijective :
IsUnit P.jacobian ↔ Function.Bijective P.aevalDifferential := by
rw [P.jacobian_eq_det_aevalDifferential, ← LinearMap.isUnit_iff_isUnit_det]
exact Module.End.isUnit_iff P.aevalDifferential
lemma isUnit_jacobian_of_linearIndependent_of_span_eq_top
(hli : LinearIndependent S (fun j i : σ ↦ aeval P.val <| pderiv (P.map i) (P.relation j)))
(hsp : Submodule.span S
(Set.range <| (fun j i : σ ↦ aeval P.val <| pderiv (P.map i) (P.relation j))) = ⊤) :
IsUnit P.jacobian := by
classical
rw [isUnit_jacobian_iff_aevalDifferential_bijective]
exact LinearMap.bijective_of_linearIndependent_of_span_eq_top (Pi.basisFun _ _).span_eq
(by convert hli; simp) (by convert hsp; simp)
end
section Constructions
/-- If `algebraMap R S` is bijective, the empty generators are a pre-submersive
presentation with no relations. -/
noncomputable def ofBijectiveAlgebraMap (h : Function.Bijective (algebraMap R S)) :
PreSubmersivePresentation R S PEmpty.{w + 1} PEmpty.{t + 1} where
toPresentation := Presentation.ofBijectiveAlgebraMap.{t, w} h
map := PEmpty.elim
map_inj (a b : PEmpty) h := by contradiction
@[simp]
lemma ofBijectiveAlgebraMap_jacobian (h : Function.Bijective (algebraMap R S)) :
(ofBijectiveAlgebraMap h).jacobian = 1 := by
classical
have : (algebraMap (ofBijectiveAlgebraMap h).Ring S).mapMatrix
(ofBijectiveAlgebraMap h).jacobiMatrix = 1 := by
ext (i j : PEmpty)
contradiction
rw [jacobian_eq_jacobiMatrix_det, RingHom.map_det, this, Matrix.det_one]
section Localization
variable (r : R) [IsLocalization.Away r S]
variable (S) in
/-- If `S` is the localization of `R` at `r`, this is the canonical submersive presentation
of `S` as `R`-algebra. -/
@[simps map]
noncomputable def localizationAway : PreSubmersivePresentation R S Unit Unit where
__ := Presentation.localizationAway S r
map _ := ()
map_inj _ _ h := h
@[simp]
lemma localizationAway_jacobiMatrix :
(localizationAway S r).jacobiMatrix = Matrix.diagonal (fun () ↦ MvPolynomial.C r) := by
have h : (pderiv ()) (C r * X () - 1) = C r := by simp
ext (i : Unit) (j : Unit) : 1
rwa [jacobiMatrix_apply]
@[simp]
lemma localizationAway_jacobian : (localizationAway S r).jacobian = algebraMap R S r := by
rw [jacobian_eq_jacobiMatrix_det, localizationAway_jacobiMatrix]
simp [show Fintype.card (localizationAway r (S := S)).rels = 1 from rfl]
end Localization
section Composition
variable {ι' σ' T : Type*} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable (Q : PreSubmersivePresentation S T ι' σ') (P : PreSubmersivePresentation R S ι σ)
/-- Given an `R`-algebra `S` and an `S`-algebra `T` with pre-submersive presentations,
this is the canonical pre-submersive presentation of `T` as an `R`-algebra. -/
@[simps map]
noncomputable def comp : PreSubmersivePresentation R T (ι' ⊕ ι) (σ' ⊕ σ) where
__ := Q.toPresentation.comp P.toPresentation
map := Sum.elim (fun rq ↦ Sum.inl <| Q.map rq) (fun rp ↦ Sum.inr <| P.map rp)
map_inj := Function.Injective.sumElim ((Sum.inl_injective).comp (Q.map_inj))
((Sum.inr_injective).comp (P.map_inj)) <| by simp
lemma toPresentation_comp : (Q.comp P).toPresentation = Q.toPresentation.comp P.toPresentation :=
rfl
lemma toGenerators_comp : (Q.comp P).toGenerators = Q.toGenerators.comp P.toGenerators := rfl
/-- The dimension of the composition of two finite submersive presentations is
the sum of the dimensions. -/
lemma dimension_comp_eq_dimension_add_dimension [Finite ι] [Finite ι'] [Finite σ] [Finite σ'] :
(Q.comp P).dimension = Q.dimension + P.dimension := by
simp only [Presentation.dimension]
have : Nat.card σ ≤ Nat.card ι :=
card_relations_le_card_vars_of_isFinite P
have : Nat.card σ' ≤ Nat.card ι' :=
card_relations_le_card_vars_of_isFinite Q
simp only [Nat.card_sum]
cutsat
section
/-!
### Jacobian of composition
Let `S` be an `R`-algebra and `T` be an `S`-algebra with presentations `P` and `Q` respectively.
In this section we compute the Jacobian of the composition of `Q` and `P` to be
the product of the Jacobians. For this we use a block decomposition of the Jacobi matrix and show
that the upper-right block vanishes, the upper-left block has determinant Jacobian of `Q` and
the lower-right block has determinant Jacobian of `P`.
-/
variable [Fintype σ] [Fintype σ']
open scoped Classical in
private lemma jacobiMatrix_comp_inl_inr (i : σ') (j : σ) :
(Q.comp P).jacobiMatrix (Sum.inl i) (Sum.inr j) = 0 := by
classical
rw [jacobiMatrix_apply]
refine MvPolynomial.pderiv_eq_zero_of_notMem_vars (fun hmem ↦ ?_)
apply MvPolynomial.vars_rename at hmem
simp at hmem
open scoped Classical in
private lemma jacobiMatrix_comp_₁₂ : (Q.comp P).jacobiMatrix.toBlocks₁₂ = 0 := by
ext i j : 1
simp [Matrix.toBlocks₁₂, jacobiMatrix_comp_inl_inr]
section Q
open scoped Classical in
private lemma jacobiMatrix_comp_inl_inl (i j : σ') :
aeval (Sum.elim X (MvPolynomial.C ∘ P.val))
((Q.comp P).jacobiMatrix (Sum.inl j) (Sum.inl i)) = Q.jacobiMatrix j i := by
rw [jacobiMatrix_apply, jacobiMatrix_apply, comp_map, Sum.elim_inl,
← Q.comp_aeval_relation_inl P.toPresentation]
apply aeval_sumElim_pderiv_inl
open scoped Classical in
private lemma jacobiMatrix_comp_₁₁_det :
(aeval (Q.comp P).val) (Q.comp P).jacobiMatrix.toBlocks₁₁.det = Q.jacobian := by
rw [jacobian_eq_jacobiMatrix_det, AlgHom.map_det (aeval (Q.comp P).val), RingHom.map_det]
congr
ext i j : 1
simp only [Matrix.map_apply, RingHom.mapMatrix_apply, ← Q.jacobiMatrix_comp_inl_inl P,
Q.algebraMap_apply]
apply aeval_sumElim
end Q
section P
open scoped Classical in
private lemma jacobiMatrix_comp_inr_inr (i j : σ) :
(Q.comp P).jacobiMatrix (Sum.inr i) (Sum.inr j) =
MvPolynomial.rename Sum.inr (P.jacobiMatrix i j) := by
rw [jacobiMatrix_apply, jacobiMatrix_apply]
simp only [comp_map, Sum.elim_inr]
apply pderiv_rename Sum.inr_injective
open scoped Classical in
private lemma jacobiMatrix_comp_₂₂_det :
(aeval (Q.comp P).val) (Q.comp P).jacobiMatrix.toBlocks₂₂.det = algebraMap S T P.jacobian := by
rw [jacobian_eq_jacobiMatrix_det]
rw [AlgHom.map_det (aeval (Q.comp P).val), RingHom.map_det, RingHom.map_det]
congr
ext i j : 1
simp only [Matrix.toBlocks₂₂, AlgHom.mapMatrix_apply, Matrix.map_apply, Matrix.of_apply,
RingHom.mapMatrix_apply, Generators.algebraMap_apply, map_aeval, coe_eval₂Hom]
rw [jacobiMatrix_comp_inr_inr, ← IsScalarTower.algebraMap_eq]
simp only [aeval, AlgHom.coe_mk, coe_eval₂Hom]
generalize P.jacobiMatrix i j = p
induction p using MvPolynomial.induction_on with
| C a =>
simp only [algHom_C, algebraMap_eq, eval₂_C]
| add p q hp hq => simp [hp, hq]
| mul_X p i hp =>
simp only [map_mul, eval₂_mul, hp]
simp [Presentation.toGenerators_comp, toPresentation_comp]
end P
end
/-- The Jacobian of the composition of presentations is the product of the Jacobians. -/
@[simp]
lemma comp_jacobian_eq_jacobian_smul_jacobian [Finite σ] [Finite σ'] :
(Q.comp P).jacobian = P.jacobian • Q.jacobian := by
classical
cases nonempty_fintype σ'
cases nonempty_fintype σ
rw [jacobian_eq_jacobiMatrix_det, ← Matrix.fromBlocks_toBlocks ((Q.comp P).jacobiMatrix),
jacobiMatrix_comp_₁₂]
convert_to
(aeval (Q.comp P).val) (Q.comp P).jacobiMatrix.toBlocks₁₁.det *
(aeval (Q.comp P).val) (Q.comp P).jacobiMatrix.toBlocks₂₂.det = P.jacobian • Q.jacobian
· simp only [Generators.algebraMap_apply, ← map_mul]
congr
convert Matrix.det_fromBlocks_zero₁₂ (Q.comp P).jacobiMatrix.toBlocks₁₁
(Q.comp P).jacobiMatrix.toBlocks₂₁ (Q.comp P).jacobiMatrix.toBlocks₂₂
· rw [jacobiMatrix_comp_₁₁_det, jacobiMatrix_comp_₂₂_det, mul_comm, Algebra.smul_def]
end Composition
section BaseChange
variable (T : Type*) [CommRing T] [Algebra R T] (P : PreSubmersivePresentation R S ι σ)
/-- If `P` is a pre-submersive presentation of `S` over `R` and `T` is an `R`-algebra, we
obtain a natural pre-submersive presentation of `T ⊗[R] S` over `T`. -/
noncomputable def baseChange : PreSubmersivePresentation T (T ⊗[R] S) ι σ where
__ := P.toPresentation.baseChange T
map := P.map
map_inj := P.map_inj
lemma baseChange_toPresentation :
(P.baseChange R).toPresentation = P.toPresentation.baseChange R :=
rfl
lemma baseChange_ring : (P.baseChange R).Ring = P.Ring := rfl
@[simp]
lemma baseChange_jacobian [Finite σ] : (P.baseChange T).jacobian = 1 ⊗ₜ P.jacobian := by
classical
cases nonempty_fintype σ
simp_rw [jacobian_eq_jacobiMatrix_det]
have h : (baseChange T P).jacobiMatrix =
(MvPolynomial.map (algebraMap R T)).mapMatrix P.jacobiMatrix := by
ext i j : 1
simp only [baseChange, jacobiMatrix_apply, Presentation.baseChange_relation,
RingHom.mapMatrix_apply, Matrix.map_apply,
Presentation.baseChange_toGenerators, MvPolynomial.pderiv_map]
rw [h, ← RingHom.map_det, Generators.algebraMap_apply, aeval_map_algebraMap, P.algebraMap_apply]
apply aeval_one_tmul
end BaseChange
/-- Given a pre-submersive presentation `P` and equivalences `ι' ≃ ι` and
`σ' ≃ σ`, this is the induced pre-submersive presentation with variables indexed
by `ι` and relations indexed by `κ -/
@[simps toPresentation, simps -isSimp map]
noncomputable def reindex (P : PreSubmersivePresentation R S ι σ)
{ι' σ' : Type*} (e : ι' ≃ ι) (f : σ' ≃ σ) :
PreSubmersivePresentation R S ι' σ' where
__ := P.toPresentation.reindex e f
map := e.symm ∘ P.map ∘ f
map_inj := by
rw [Function.Injective.of_comp_iff e.symm.injective, Function.Injective.of_comp_iff P.map_inj]
exact f.injective
lemma jacobiMatrix_reindex {ι' σ' : Type*} (e : ι' ≃ ι) (f : σ' ≃ σ)
[Fintype σ'] [DecidableEq σ'] [Fintype σ] [DecidableEq σ] :
(P.reindex e f).jacobiMatrix =
(P.jacobiMatrix.reindex f.symm f.symm).map (MvPolynomial.rename e.symm) := by
ext i j : 1
simp [jacobiMatrix_apply,
MvPolynomial.pderiv_rename e.symm.injective, reindex, Presentation.reindex]
@[simp]
lemma jacobian_reindex (P : PreSubmersivePresentation R S ι σ)
{ι' σ' : Type*} (e : ι' ≃ ι) (f : σ' ≃ σ) [Finite σ] [Finite σ'] :
(P.reindex e f).jacobian = P.jacobian := by
classical
cases nonempty_fintype σ
cases nonempty_fintype σ'
simp_rw [PreSubmersivePresentation.jacobian_eq_jacobiMatrix_det]
simp only [reindex_toPresentation, Presentation.reindex_toGenerators, jacobiMatrix_reindex,
Matrix.reindex_apply, Equiv.symm_symm, Generators.algebraMap_apply, Generators.reindex_val]
simp_rw [← MvPolynomial.aeval_rename,
← AlgHom.mapMatrix_apply, ← Matrix.det_submatrix_equiv_self f, AlgHom.map_det,
AlgHom.mapMatrix_apply, Matrix.map_map]
simp [← AlgHom.coe_comp, rename_comp_rename, rename_id]
section
variable {v : ι → MvPolynomial σ R} (a : ι → σ) (ha : Function.Injective a)
(s : MvPolynomial σ R ⧸ (Ideal.span <| Set.range v) → MvPolynomial σ R :=
Function.surjInv Ideal.Quotient.mk_surjective)
(hs : ∀ x, Ideal.Quotient.mk _ (s x) = x := by apply Function.surjInv_eq)
/--
The naive pre-submersive presentation of a quotient `R[Xᵢ] ⧸ (vⱼ)`.
If the definitional equality of the section matters, it can be explicitly provided.
To construct the associated submersive presentation, use
`PreSubmersivePresentation.jacobiMatrix_naive`.
-/
@[simps! toPresentation]
noncomputable
def naive {v : ι → MvPolynomial σ R} (a : ι → σ) (ha : Function.Injective a)
(s : MvPolynomial σ R ⧸ (Ideal.span <| Set.range v) → MvPolynomial σ R :=
Function.surjInv Ideal.Quotient.mk_surjective)
(hs : ∀ x, Ideal.Quotient.mk _ (s x) = x := by apply Function.surjInv_eq) :
PreSubmersivePresentation R (MvPolynomial σ R ⧸ (Ideal.span <| Set.range v)) σ ι where
__ := Presentation.naive s hs
map := a
map_inj := ha
@[simp] lemma jacobiMatrix_naive [Fintype ι] [DecidableEq ι] (i j : ι) :
(naive a ha s hs).jacobiMatrix i j = (v j).pderiv (a i) :=
jacobiMatrix_apply _ _ _
end
end Constructions
end PreSubmersivePresentation
variable [Finite σ]
/--
A `PreSubmersivePresentation` is submersive if its Jacobian is a unit in `S`
and the presentation is finite.
-/
@[nolint checkUnivs]
structure SubmersivePresentation extends PreSubmersivePresentation.{t, w} R S ι σ where
jacobian_isUnit : IsUnit toPreSubmersivePresentation.jacobian
namespace SubmersivePresentation
open PreSubmersivePresentation
section Constructions
variable {R S} in
/-- If `algebraMap R S` is bijective, the empty generators are a submersive
presentation with no relations. -/
noncomputable def ofBijectiveAlgebraMap (h : Function.Bijective (algebraMap R S)) :
SubmersivePresentation R S PEmpty.{w + 1} PEmpty.{t + 1} where
__ := PreSubmersivePresentation.ofBijectiveAlgebraMap.{t, w} h
jacobian_isUnit := by
rw [ofBijectiveAlgebraMap_jacobian]
exact isUnit_one
/-- The canonical submersive `R`-presentation of `R` with no generators and no relations. -/
noncomputable def id : SubmersivePresentation R R PEmpty.{w + 1} PEmpty.{t + 1} :=
ofBijectiveAlgebraMap Function.bijective_id
section Composition
variable {R S ι σ}
variable {T ι' σ' : Type*} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable [Finite σ'] (Q : SubmersivePresentation S T ι' σ') (P : SubmersivePresentation R S ι σ)
/-- Given an `R`-algebra `S` and an `S`-algebra `T` with submersive presentations,
this is the canonical submersive presentation of `T` as an `R`-algebra. -/
noncomputable def comp : SubmersivePresentation R T (ι' ⊕ ι) (σ' ⊕ σ) where
__ := Q.toPreSubmersivePresentation.comp P.toPreSubmersivePresentation
jacobian_isUnit := by
rw [comp_jacobian_eq_jacobian_smul_jacobian, Algebra.smul_def, IsUnit.mul_iff]
exact ⟨RingHom.isUnit_map _ <| P.jacobian_isUnit, Q.jacobian_isUnit⟩
end Composition
section Localization
variable {R} (r : R) [IsLocalization.Away r S]
/-- If `S` is the localization of `R` at `r`, this is the canonical submersive presentation
of `S` as `R`-algebra. -/
noncomputable def localizationAway : SubmersivePresentation R S Unit Unit where
__ := PreSubmersivePresentation.localizationAway S r
jacobian_isUnit := by
rw [localizationAway_jacobian]
apply IsLocalization.map_units _ (⟨r, 1, by simp⟩ : Submonoid.powers r)
end Localization
section BaseChange
variable (T) [CommRing T] [Algebra R T] (P : SubmersivePresentation R S ι σ)
variable {R S ι σ} in
/-- If `P` is a submersive presentation of `S` over `R` and `T` is an `R`-algebra, we
obtain a natural submersive presentation of `T ⊗[R] S` over `T`. -/
noncomputable def baseChange : SubmersivePresentation T (T ⊗[R] S) ι σ where
toPreSubmersivePresentation := P.toPreSubmersivePresentation.baseChange T
jacobian_isUnit :=
P.baseChange_jacobian T ▸ P.jacobian_isUnit.map TensorProduct.includeRight
end BaseChange
variable {R S ι σ} in
/-- Given a submersive presentation `P` and equivalences `ι' ≃ ι` and
`σ' ≃ σ`, this is the induced submersive presentation with variables indexed
by `ι'` and relations indexed by `σ'` -/
@[simps toPreSubmersivePresentation]
noncomputable def reindex (P : SubmersivePresentation R S ι σ)
{ι' σ' : Type*} [Finite σ'] (e : ι' ≃ ι) (f : σ' ≃ σ) : SubmersivePresentation R S ι' σ' where
__ := P.toPreSubmersivePresentation.reindex e f
jacobian_isUnit := by simp [P.jacobian_isUnit]
/-- If `S = 0`, this is the submersive presentation on one generator and one relation. -/
@[simps]
noncomputable def ofSubsingleton [Subsingleton S] : SubmersivePresentation R S PUnit PUnit where
val _ := 1
σ' _ := 1
aeval_val_σ' _ := Subsingleton.elim _ _
relation _ := 1
span_range_relation_eq_ker := by
simp [Generators.ker, Extension.ker, RingHom.ker_eq_top_of_subsingleton]
map _ := ⟨⟩
map_inj _ _ _ := rfl
jacobian_isUnit := isUnit_of_subsingleton _
end Constructions
variable {R S ι σ}
open Classical in
/-- If `P` is submersive, `PreSubmersivePresentation.aevalDifferential` is an isomorphism. -/
noncomputable def aevalDifferentialEquiv (P : SubmersivePresentation R S ι σ) :
(σ → S) ≃ₗ[S] (σ → S) :=
haveI : Fintype σ := Fintype.ofFinite σ
have :
IsUnit (LinearMap.toMatrix (Pi.basisFun S σ) (Pi.basisFun S σ) P.aevalDifferential).det := by
convert P.jacobian_isUnit
rw [LinearMap.toMatrix_eq_toMatrix', jacobian_eq_jacobiMatrix_det,
aevalDifferential_toMatrix'_eq_mapMatrix_jacobiMatrix, P.algebraMap_eq]
simp [RingHom.map_det]
LinearEquiv.ofIsUnitDet this
variable (P : SubmersivePresentation R S ι σ)
@[simp]
lemma aevalDifferentialEquiv_apply [Finite σ] (x : σ → S) :
P.aevalDifferentialEquiv x = P.aevalDifferential x :=
rfl
/-- If `P` is a submersive presentation, the partial derivatives of `P.relation i` by
`P.map j` form a basis of `σ → S`. -/
noncomputable def basisDeriv (P : SubmersivePresentation R S ι σ) : Basis σ S (σ → S) :=
Basis.map (Pi.basisFun S σ) P.aevalDifferentialEquiv
@[simp]
lemma basisDeriv_apply (i j : σ) :
P.basisDeriv i j = (aeval P.val) (pderiv (P.map j) (P.relation i)) := by
classical
simp [basisDeriv]
lemma linearIndependent_aeval_val_pderiv_relation :
LinearIndependent S (fun i j ↦ (aeval P.val) (pderiv (P.map j) (P.relation i))) := by
simp_rw [← SubmersivePresentation.basisDeriv_apply]
exact P.basisDeriv.linearIndependent
end SubmersivePresentation
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Presentation/Core.lean | import Mathlib.RingTheory.Extension.Presentation.Basic
/-!
# Presentations on subrings
In this file we establish the API for realising a presentation over a
subring of `R`. We define a property `HasCoeffs R₀` for a presentation `P` to mean
the (sub)ring `R₀` contains the coefficients of the relations of `P`.
subring `R₀` of `R` that contains the coefficients of the relations
In this case there exists a model of `S` over `R₀`, i.e., there exists an `R₀`-algebra `S₀`
such that `S` is isomorphic to `R ⊗[R₀] S₀`.
If the presentation is finite, `R₀` may be chosen as a Noetherian ring. In this case,
this API can be used to remove Noetherian hypothesis in certain cases.
-/
open TensorProduct
variable {R S ι σ : Type*} [CommRing R] [CommRing S] [Algebra R S]
variable {P : Algebra.Presentation R S ι σ}
namespace Algebra.Presentation
variable (P) in
/-- The coefficients of a presentation are the coefficients of the relations. -/
def coeffs : Set R := ⋃ (i : σ), (P.relation i).coeffs
lemma coeffs_relation_subset_coeffs (x : σ) :
((P.relation x).coeffs : Set R) ⊆ P.coeffs :=
Set.subset_iUnion_of_subset x (by simp)
lemma finite_coeffs [Finite σ] : P.coeffs.Finite :=
Set.finite_iUnion fun _ ↦ Finset.finite_toSet _
variable (P) in
/-- The core of a presentation is the subalgebra generated by the coefficients of the relations. -/
def core : Subalgebra ℤ R := Algebra.adjoin _ P.coeffs
variable (P) in
lemma coeffs_subset_core : P.coeffs ⊆ P.core := Algebra.subset_adjoin
lemma coeffs_relation_subset_core (x : σ) :
((P.relation x).coeffs : Set R) ⊆ P.core :=
subset_trans (P.coeffs_relation_subset_coeffs x) P.coeffs_subset_core
variable (P) in
/-- The core coerced to a type for performance reasons. -/
def Core : Type _ := P.core
instance : CommRing P.Core := fast_instance% (inferInstanceAs <| CommRing P.core)
instance : Algebra P.Core R := fast_instance% (inferInstanceAs <| Algebra P.core R)
instance : FaithfulSMul P.Core R := inferInstanceAs <| FaithfulSMul P.core R
instance : Algebra P.Core S := fast_instance% (inferInstanceAs <| Algebra P.core S)
instance : IsScalarTower P.Core R S := inferInstanceAs <| IsScalarTower P.core R S
instance [Finite σ] : FiniteType ℤ P.Core := .adjoin_of_finite P.finite_coeffs
variable (P) in
/--
A ring `R₀` has the coefficients of the presentation `P` if the coefficients of the relations of `P`
lie in the image of `R₀` in `R`.
The smallest subring of `R` satisfying this is given by `Algebra.Presentation.Core P`.
-/
class HasCoeffs (R₀ : Type*) [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S]
[IsScalarTower R₀ R S] where
coeffs_subset_range : P.coeffs ⊆ Set.range (algebraMap R₀ R)
instance : P.HasCoeffs P.Core where
coeffs_subset_range := by
refine subset_trans P.coeffs_subset_core ?_
simp [Core, Subalgebra.algebraMap_eq]
variable (R₀ : Type*) [CommRing R₀] [Algebra R₀ R] [Algebra R₀ S] [IsScalarTower R₀ R S]
[P.HasCoeffs R₀]
lemma coeffs_subset_range : (P.coeffs : Set R) ⊆ Set.range (algebraMap R₀ R) :=
HasCoeffs.coeffs_subset_range
lemma HasCoeffs.of_isScalarTower {R₁ : Type*} [CommRing R₁] [Algebra R₀ R₁] [Algebra R₁ R]
[IsScalarTower R₀ R₁ R] [Algebra R₁ S] [IsScalarTower R₁ R S] :
P.HasCoeffs R₁ := by
refine ⟨subset_trans (P.coeffs_subset_range R₀) ?_⟩
simp [IsScalarTower.algebraMap_eq R₀ R₁ R, RingHom.coe_comp, Set.range_comp]
instance (s : Set R) : P.HasCoeffs (Algebra.adjoin R₀ s) := HasCoeffs.of_isScalarTower R₀
lemma HasCoeffs.coeffs_relation_mem_range (x : σ) :
↑(P.relation x).coeffs ⊆ Set.range (algebraMap R₀ R) :=
subset_trans (P.coeffs_relation_subset_coeffs x) HasCoeffs.coeffs_subset_range
lemma HasCoeffs.relation_mem_range_map (x : σ) :
P.relation x ∈ Set.range (MvPolynomial.map (algebraMap R₀ R)) := by
rw [MvPolynomial.mem_range_map_iff_coeffs_subset]
exact HasCoeffs.coeffs_relation_mem_range R₀ x
/-- The `r`-th relation of `P` as a polynomial in `R₀`. This is the (arbitrary) choice of a
pre-image under the map `R₀[X] → R[X]`. -/
noncomputable def relationOfHasCoeffs (r : σ) : MvPolynomial ι R₀ :=
(HasCoeffs.relation_mem_range_map (P := P) R₀ r).choose
lemma map_relationOfHasCoeffs (r : σ) :
MvPolynomial.map (algebraMap R₀ R) (P.relationOfHasCoeffs R₀ r) = P.relation r :=
(HasCoeffs.relation_mem_range_map R₀ r).choose_spec
@[simp]
lemma aeval_val_relationOfHasCoeffs (r : σ) :
MvPolynomial.aeval P.val (P.relationOfHasCoeffs R₀ r) = 0 := by
rw [← MvPolynomial.aeval_map_algebraMap R, map_relationOfHasCoeffs, aeval_val_relation]
@[simp]
lemma algebraTensorAlgEquiv_symm_relation (r : σ) :
(MvPolynomial.algebraTensorAlgEquiv R₀ R).symm (P.relation r) =
1 ⊗ₜ P.relationOfHasCoeffs R₀ r := by
rw [← map_relationOfHasCoeffs R₀, MvPolynomial.algebraTensorAlgEquiv_symm_map]
/-- The model of `S` over a `R₀` that contains the coefficients of `P` is `R₀[X]` quotiented by the
same relations. -/
abbrev ModelOfHasCoeffs : Type _ :=
MvPolynomial ι R₀ ⧸ (Ideal.span <| Set.range (P.relationOfHasCoeffs R₀))
instance [Finite ι] [Finite σ] : Algebra.FinitePresentation R₀ (P.ModelOfHasCoeffs R₀) := by
classical
cases nonempty_fintype σ
exact .quotient ⟨Finset.image (P.relationOfHasCoeffs R₀) .univ, by simp⟩
variable (P) in
/-- (Implementation detail): The underlying `AlgHom` of `tensorModelOfHasCoeffsEquiv`. -/
noncomputable def tensorModelOfHasCoeffsHom : R ⊗[R₀] P.ModelOfHasCoeffs R₀ →ₐ[R] S :=
Algebra.TensorProduct.lift (Algebra.ofId R S)
(Ideal.Quotient.liftₐ _ (MvPolynomial.aeval P.val) <| by
simp_rw [← RingHom.mem_ker, ← SetLike.le_def, Ideal.span_le]
rintro a ⟨i, rfl⟩
simp)
fun _ _ ↦ Commute.all _ _
@[simp]
lemma tensorModelOfHasCoeffsHom_tmul (x : R) (y : MvPolynomial ι R₀) :
P.tensorModelOfHasCoeffsHom R₀ (x ⊗ₜ y) = algebraMap R S x * MvPolynomial.aeval P.val y :=
rfl
variable (P) in
/-- (Implementation detail): The inverse of `tensorModelOfHasCoeffsHom`. -/
noncomputable def tensorModelOfHasCoeffsInv : S →ₐ[R] R ⊗[R₀] P.ModelOfHasCoeffs R₀ :=
(Ideal.Quotient.liftₐ _
((Algebra.TensorProduct.map (.id R R) (Ideal.Quotient.mkₐ _ _)).comp
(MvPolynomial.algebraTensorAlgEquiv R₀ R).symm.toAlgHom) <| by
simp_rw [← RingHom.mem_ker, ← SetLike.le_def]
rw [← P.span_range_relation_eq_ker, Ideal.span_le]
rintro a ⟨i, rfl⟩
simp only [AlgEquiv.toAlgHom_eq_coe, SetLike.mem_coe, RingHom.mem_ker, AlgHom.coe_comp,
AlgHom.coe_coe, Function.comp_apply, algebraTensorAlgEquiv_symm_relation]
simp only [TensorProduct.map_tmul, AlgHom.coe_id, id_eq, Ideal.Quotient.mkₐ_eq_mk,
Ideal.Quotient.mk_span_range, tmul_zero]).comp
(P.quotientEquiv.restrictScalars R).symm.toAlgHom
@[simp]
lemma tensorModelOfHasCoeffsInv_aeval_val (x : MvPolynomial ι R₀) :
P.tensorModelOfHasCoeffsInv R₀ (MvPolynomial.aeval P.val x) =
1 ⊗ₜ[R₀] (Ideal.Quotient.mk _ x) := by
rw [← MvPolynomial.aeval_map_algebraMap R, ← Generators.algebraMap_apply, ← quotientEquiv_mk]
simp [tensorModelOfHasCoeffsInv, -quotientEquiv_symm, -quotientEquiv_mk]
private lemma hom_comp_inv :
(P.tensorModelOfHasCoeffsHom R₀).comp (P.tensorModelOfHasCoeffsInv R₀) = AlgHom.id R S := by
have h : Function.Surjective
((P.quotientEquiv.restrictScalars R).toAlgHom.comp (Ideal.Quotient.mkₐ _ _)) :=
(P.quotientEquiv.restrictScalars R).surjective.comp Ideal.Quotient.mk_surjective
simp only [← AlgHom.cancel_right h, tensorModelOfHasCoeffsInv, AlgEquiv.toAlgHom_eq_coe,
AlgHom.id_comp]
rw [AlgHom.comp_assoc, AlgHom.comp_assoc, ← AlgHom.comp_assoc _ _ (Ideal.Quotient.mkₐ R P.ker),
AlgEquiv.symm_comp, AlgHom.id_comp]
ext x
simp
private lemma inv_comp_hom :
(P.tensorModelOfHasCoeffsInv R₀).comp (P.tensorModelOfHasCoeffsHom R₀) = AlgHom.id R _ := by
ext x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
simp
/-- The natural isomorphism `R ⊗[R₀] S₀ ≃ₐ[R] S`. -/
noncomputable def tensorModelOfHasCoeffsEquiv : R ⊗[R₀] P.ModelOfHasCoeffs R₀ ≃ₐ[R] S :=
AlgEquiv.ofAlgHom (P.tensorModelOfHasCoeffsHom R₀) (P.tensorModelOfHasCoeffsInv R₀)
(P.hom_comp_inv R₀) (P.inv_comp_hom R₀)
@[simp]
lemma tensorModelOfHasCoeffsEquiv_tmul (x : R) (y : MvPolynomial ι R₀) :
P.tensorModelOfHasCoeffsEquiv R₀ (x ⊗ₜ y) = algebraMap R S x * MvPolynomial.aeval P.val y :=
rfl
@[simp]
lemma tensorModelOfHasCoeffsEquiv_symm_tmul (x : MvPolynomial ι R₀) :
(P.tensorModelOfHasCoeffsEquiv R₀).symm (MvPolynomial.aeval P.val x) =
1 ⊗ₜ[R₀] (Ideal.Quotient.mk _ x) :=
tensorModelOfHasCoeffsInv_aeval_val _ x
end Algebra.Presentation |
.lake/packages/mathlib/Mathlib/RingTheory/Extension/Presentation/Basic.lean | import Mathlib.LinearAlgebra.TensorProduct.RightExactness
import Mathlib.RingTheory.FinitePresentation
import Mathlib.RingTheory.Extension.Generators
import Mathlib.RingTheory.MvPolynomial.Localization
import Mathlib.RingTheory.TensorProduct.MvPolynomial
/-!
# Presentations of algebras
A presentation of an `R`-algebra `S` is a distinguished family of generators and relations.
## Main definition
- `Algebra.Presentation`: A presentation of an `R`-algebra `S` is a family of
generators with
1. `rels`: The type of relations.
2. `relation : relations → MvPolynomial vars R`: The assignment of
each relation to a polynomial in the generators.
- `Algebra.Presentation.IsFinite`: A presentation is called finite, if both variables and relations
are finite.
- `Algebra.Presentation.dimension`: The dimension of a presentation is the number of generators
minus the number of relations.
We also give constructors for localization, base change and composition.
## TODO
- Define `Hom`s of presentations.
## Notes
This contribution was created as part of the AIM workshop "Formalizing algebraic geometry"
in June 2024.
-/
universe t w u v
open TensorProduct MvPolynomial
variable (R : Type u) (S : Type v) (ι : Type w) (σ : Type t) [CommRing R] [CommRing S] [Algebra R S]
/--
A presentation of an `R`-algebra `S` is a family of
generators with `σ → MvPolynomial ι R`: The assignment of
each relation to a polynomial in the generators.
-/
@[nolint checkUnivs]
structure Algebra.Presentation extends Algebra.Generators R S ι where
/-- The assignment of each relation to a polynomial in the generators. -/
relation : σ → toGenerators.Ring
/-- The relations span the kernel of the canonical map. -/
span_range_relation_eq_ker :
Ideal.span (Set.range relation) = toGenerators.ker
namespace Algebra.Presentation
variable {R S ι σ}
variable (P : Presentation R S ι σ)
@[simp]
lemma aeval_val_relation (i) : aeval P.val (P.relation i) = 0 := by
rw [← RingHom.mem_ker, ← P.ker_eq_ker_aeval_val, ← P.span_range_relation_eq_ker]
exact Ideal.subset_span ⟨i, rfl⟩
lemma relation_mem_ker (i) : P.relation i ∈ P.ker := by
rw [← P.span_range_relation_eq_ker]
apply Ideal.subset_span
use i
/-- The polynomial algebra w.r.t. a family of generators modulo a family of relations. -/
protected abbrev Quotient : Type (max w u) := P.Ring ⧸ P.ker
/-- `P.Quotient` is `P.Ring`-isomorphic to `S` and in particular `R`-isomorphic to `S`. -/
def quotientEquiv : P.Quotient ≃ₐ[P.Ring] S :=
Ideal.quotientKerAlgEquivOfRightInverse (f := Algebra.ofId P.Ring S) (g := P.σ) <| fun x ↦ by
rw [Algebra.ofId_apply, P.algebraMap_apply, P.aeval_val_σ]
@[simp]
lemma quotientEquiv_mk (p : P.Ring) : P.quotientEquiv p = algebraMap P.Ring S p :=
rfl
@[simp]
lemma quotientEquiv_symm (x : S) : P.quotientEquiv.symm x = P.σ x :=
rfl
set_option linter.unusedVariables false in
/--
Dimension of a presentation defined as the cardinality of the generators
minus the cardinality of the relations.
Note: this definition is completely non-sensical for non-finite presentations and
even then for this to make sense, you should assume that the presentation
is a complete intersection.
-/
@[nolint unusedArguments]
noncomputable def dimension (P : Presentation R S ι σ) : ℕ :=
Nat.card ι - Nat.card σ
lemma fg_ker [Finite σ] : P.ker.FG := by
use (Set.finite_range P.relation).toFinset
simp [span_range_relation_eq_ker]
@[deprecated (since := "2025-05-27")] alias ideal_fg_of_isFinite := fg_ker
/-- If a presentation is finite, the corresponding quotient is
of finite presentation. -/
instance [Finite σ] [Finite ι] : FinitePresentation R P.Quotient :=
FinitePresentation.quotient P.fg_ker
lemma finitePresentation_of_isFinite [Finite σ] [Finite ι] (P : Presentation R S ι σ) :
FinitePresentation R S :=
FinitePresentation.equiv (P.quotientEquiv.restrictScalars R)
variable (R S) in
lemma exists_presentation_fin [FinitePresentation R S] :
∃ n m, Nonempty (Presentation R S (Fin n) (Fin m)) :=
letI H := FinitePresentation.out (R := R) (A := S)
letI n : ℕ := H.choose
letI f : MvPolynomial (Fin n) R →ₐ[R] S := H.choose_spec.choose
haveI hf : Function.Surjective f := H.choose_spec.choose_spec.1
haveI hf' : (RingHom.ker f).FG := H.choose_spec.choose_spec.2
letI H' := Submodule.fg_iff_exists_fin_generating_family.mp hf'
let m : ℕ := H'.choose
let v : Fin m → MvPolynomial (Fin n) R := H'.choose_spec.choose
have hv : Ideal.span (Set.range v) = RingHom.ker f := H'.choose_spec.choose_spec
⟨n, m,
⟨{__ := Generators.ofSurjective (fun x ↦ f (.X x)) (by convert hf; ext; simp)
relation := v
span_range_relation_eq_ker := hv.trans (by congr; ext; simp) }⟩⟩
variable (R S) in
/-- The index of generators to `ofFinitePresentation`. -/
noncomputable
def ofFinitePresentationVars [FinitePresentation R S] : ℕ :=
(exists_presentation_fin R S).choose
variable (R S) in
/-- The index of relations to `ofFinitePresentation`. -/
noncomputable
def ofFinitePresentationRels [FinitePresentation R S] : ℕ :=
(exists_presentation_fin R S).choose_spec.choose
variable (R S) in
/-- An arbitrary choice of a finite presentation of a finitely presented algebra. -/
noncomputable
def ofFinitePresentation [FinitePresentation R S] :
Presentation R S (Fin (ofFinitePresentationVars R S)) (Fin (ofFinitePresentationRels R S)) :=
(exists_presentation_fin R S).choose_spec.choose_spec.some
section Construction
/-- If `algebraMap R S` is bijective, the empty generators are a presentation with no relations. -/
noncomputable def ofBijectiveAlgebraMap (h : Function.Bijective (algebraMap R S)) :
Presentation R S PEmpty.{w + 1} PEmpty.{t + 1} where
__ := Generators.ofSurjectiveAlgebraMap h.surjective
relation := PEmpty.elim
span_range_relation_eq_ker := by
simp only [Set.range_eq_empty, Ideal.span_empty]
symm
rw [← RingHom.injective_iff_ker_eq_bot]
change Function.Injective (aeval PEmpty.elim)
rw [aeval_injective_iff_of_isEmpty]
exact h.injective
lemma ofBijectiveAlgebraMap_dimension (h : Function.Bijective (algebraMap R S)) :
(ofBijectiveAlgebraMap h).dimension = 0 := by
simp [dimension]
variable (R) in
/-- The canonical `R`-presentation of `R` with no generators and no relations. -/
noncomputable def id : Presentation R R PEmpty.{w + 1} PEmpty.{t + 1} :=
ofBijectiveAlgebraMap Function.bijective_id
lemma id_dimension : (Presentation.id R).dimension = 0 :=
ofBijectiveAlgebraMap_dimension (R := R) Function.bijective_id
section Localization
variable (r : R) [IsLocalization.Away r S]
open IsLocalization.Away
lemma _root_.Algebra.Generators.ker_localizationAway :
(Generators.localizationAway S r).ker = Ideal.span { C r * X () - 1 } := by
have : aeval (S₁ := S) (Generators.localizationAway S r).val =
(mvPolynomialQuotientEquiv S r).toAlgHom.comp
(Ideal.Quotient.mkₐ R (Ideal.span {C r * X () - 1})) := by
ext x
simp only [aeval_X, Generators.localizationAway_val,
AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, AlgHom.coe_coe, Ideal.Quotient.mkₐ_eq_mk,
Function.comp_apply]
rw [IsLocalization.Away.mvPolynomialQuotientEquiv_apply, aeval_X]
rw [Generators.ker_eq_ker_aeval_val, this, AlgEquiv.toAlgHom_eq_coe, ← RingHom.ker_coe_toRingHom,
AlgHom.comp_toRingHom, ← RingHom.comap_ker]
simp only [AlgEquiv.toAlgHom_toRingHom]
change Ideal.comap _ (RingHom.ker (mvPolynomialQuotientEquiv S r)) = Ideal.span {C r * X () - 1}
simp [RingHom.ker_equiv, ← RingHom.ker_eq_comap_bot]
variable (S) in
/-- If `S` is the localization of `R` away from `r`, we can construct a natural
presentation of `S` as `R`-algebra with a single generator `X` and the relation `r * X - 1 = 0`. -/
@[simps relation]
noncomputable def localizationAway : Presentation R S Unit Unit where
toGenerators := Generators.localizationAway S r
relation _ := C r * X () - 1
span_range_relation_eq_ker := by
simp only [Set.range_const]
exact (Generators.ker_localizationAway r).symm
@[simp]
lemma localizationAway_dimension_zero : (localizationAway S r).dimension = 0 := by
simp [Presentation.dimension]
lemma _root_.Algebra.Generators.C_mul_X_sub_one_mem_ker :
C r * X () - 1 ∈ (Generators.localizationAway S r).ker :=
(Presentation.localizationAway S r).relation_mem_ker ()
end Localization
section BaseChange
variable (T) [CommRing T] [Algebra R T] (P : Presentation R S ι σ)
private lemma span_range_relation_eq_ker_baseChange :
Ideal.span (Set.range fun i ↦ (MvPolynomial.map (algebraMap R T)) (P.relation i)) =
RingHom.ker (aeval (S₁ := T ⊗[R] S) (P.baseChange T).val) := by
apply le_antisymm
· rw [Ideal.span_le]
intro x ⟨y, hy⟩
have Z := aeval_val_relation P y
apply_fun TensorProduct.includeRight (R := R) (A := T) at Z
rw [map_zero] at Z
simp only [SetLike.mem_coe, RingHom.mem_ker, ← Z, ← hy,
TensorProduct.includeRight_apply]
erw [aeval_map_algebraMap T (P.baseChange T).val (P.relation y)]
change _ = TensorProduct.includeRight.toRingHom _
rw [map_aeval, AlgHom.toRingHom_eq_coe, RingHom.coe_coe,
TensorProduct.includeRight.comp_algebraMap]
rfl
· intro x hx
rw [RingHom.mem_ker] at hx
have H := Algebra.TensorProduct.lTensor_ker (A := T) (IsScalarTower.toAlgHom R P.Ring S)
P.algebraMap_surjective
let e := MvPolynomial.algebraTensorAlgEquiv (R := R) (σ := ι) (A := T)
have H' : e.symm x ∈ RingHom.ker (TensorProduct.map (AlgHom.id R T)
(IsScalarTower.toAlgHom R P.Ring S)) := by
rw [RingHom.mem_ker, ← hx]
clear hx
induction x using MvPolynomial.induction_on with
| C a =>
simp only [algHom_C, TensorProduct.algebraMap_apply,
algebraMap_self, RingHom.id_apply, e]
rw [← MvPolynomial.algebraMap_eq, AlgEquiv.commutes]
simp only [TensorProduct.algebraMap_apply, algebraMap_self, RingHom.id_apply,
TensorProduct.map_tmul, AlgHom.coe_id, id_eq, map_one]
| add p q hp hq => simp only [map_add, hp, hq]
| mul_X p i hp => simp [hp, e]
rw [H] at H'
replace H' : e.symm x ∈ Ideal.map TensorProduct.includeRight P.ker := H'
rw [← P.span_range_relation_eq_ker, ← Ideal.mem_comap, ← Ideal.comap_coe,
← AlgEquiv.toRingEquiv_toRingHom, Ideal.comap_coe, AlgEquiv.symm_toRingEquiv,
Ideal.comap_symm, ← Ideal.map_coe, ← Ideal.map_coe _ (Ideal.span _), Ideal.map_map,
Ideal.map_span, ← Set.range_comp, AlgEquiv.toRingEquiv_toRingHom, RingHom.coe_comp,
RingHom.coe_coe] at H'
convert H'
simp [e]
/-- If `P` is a presentation of `S` over `R` and `T` is an `R`-algebra, we
obtain a natural presentation of `T ⊗[R] S` over `T`. -/
@[simps relation]
noncomputable
def baseChange : Presentation T (T ⊗[R] S) ι σ where
__ := P.toGenerators.baseChange T
relation i := MvPolynomial.map (algebraMap R T) (P.relation i)
span_range_relation_eq_ker := P.span_range_relation_eq_ker_baseChange T
lemma baseChange_toGenerators : (P.baseChange T).toGenerators = P.toGenerators.baseChange T := rfl
end BaseChange
section Composition
/-!
### Composition of presentations
Let `S` be an `R`-algebra with presentation `P` and `T` be an `S`-algebra with
presentation `Q`. In this section we construct a presentation of `T` as an `R`-algebra.
For the underlying generators see `Algebra.Generators.comp`. The family of relations is
indexed by `σ' ⊕ σ`.
We have two canonical maps:
`MvPolynomial ι R →ₐ[R] MvPolynomial (ι' ⊕ ι) R` induced by `Sum.inr`
and `aux : MvPolynomial (ι' ⊕ ι) R →ₐ[R] MvPolynomial ι' S` induced by
the evaluation `MvPolynomial ι R →ₐ[R] S` (see below).
Now `i : σ` is mapped to the image of `P.relation i` under the first map and
`j : σ'` is mapped to a pre-image under `aux` of `Q.relation j` (see `comp_relation_aux`
for the construction of the pre-image and `comp_relation_aux_map` for a proof that it is indeed
a pre-image).
The evaluation map factors as:
`MvPolynomial (ι' ⊕ ι) R →ₐ[R] MvPolynomial ι' S →ₐ[R] T`, where
the first map is `aux`. The goal is to compute that the kernel of this composition
is spanned by the relations indexed by `σ' ⊕ σ` (`span_range_relation_eq_ker_comp`).
One easily sees that this kernel is the pre-image under `aux` of the kernel of the evaluation
of `Q`, where the latter is by assumption spanned by the relations `Q.relation j`.
Since `aux` is surjective (`aux_surjective`), the pre-image is the sum of the ideal spanned
by the constructed pre-images of the `Q.relation j` and the kernel of `aux`. It hence
remains to show that the kernel of `aux` is spanned by the image of the `P.relation i`
under the canonical map `MvPolynomial ι R →ₐ[R] MvPolynomial (ι' ⊕ ι) R`. By
assumption this span is the kernel of the evaluation map of `P`. For this, we use the isomorphism
`MvPolynomial (ι' ⊕ ι) R ≃ₐ[R] MvPolynomial ι' (MvPolynomial ι R)` and
`MvPolynomial.ker_map`.
-/
variable {ι' σ' T : Type*} [CommRing T] [Algebra S T]
variable (Q : Presentation S T ι' σ') (P : Presentation R S ι σ)
set_option linter.unusedVariables false in
/-- The evaluation map `MvPolynomial (ι' ⊕ ι) →ₐ[R] T` factors via this map. For more
details, see the module docstring at the beginning of the section. -/
private noncomputable def aux (Q : Presentation S T ι' σ') (P : Presentation R S ι σ) :
MvPolynomial (ι' ⊕ ι) R →ₐ[R] MvPolynomial ι' S :=
aeval (Sum.elim X (MvPolynomial.C ∘ P.val))
/-- A choice of pre-image of `Q.relation r` under the canonical
map `MvPolynomial (ι' ⊕ ι) R →ₐ[R] MvPolynomial ι' S` given by the evalation of `P`. -/
noncomputable def compRelationAux (r : σ') : MvPolynomial (ι' ⊕ ι) R :=
Finsupp.sum (Q.relation r)
(fun x j ↦ (MvPolynomial.rename Sum.inr <| P.σ j) * monomial (x.mapDomain Sum.inl) 1)
@[simp]
private lemma aux_X (i : ι' ⊕ ι) : (Q.aux P) (X i) = Sum.elim X (C ∘ P.val) i :=
aeval_X (Sum.elim X (C ∘ P.val)) i
/-- The pre-images constructed in `compRelationAux` are indeed pre-images under `aux`. -/
private lemma compRelationAux_map (r : σ') :
(Q.aux P) (Q.compRelationAux P r) = Q.relation r := by
simp only [aux, compRelationAux, map_finsuppSum]
simp only [map_mul, aeval_rename, aeval_monomial, Sum.elim_comp_inr]
conv_rhs => rw [← Finsupp.sum_single (Q.relation r)]
congr
ext u s m
simp only [MvPolynomial.single_eq_monomial, aeval, AlgHom.coe_mk, coe_eval₂Hom]
rw [monomial_eq, IsScalarTower.algebraMap_eq R S, algebraMap_eq, ← eval₂_comp_left, ← aeval_def]
simp [Finsupp.prod_mapDomain_index_inj (Sum.inl_injective)]
private lemma aux_surjective : Function.Surjective (Q.aux P) := fun p ↦ by
induction p using MvPolynomial.induction_on with
| C a =>
use rename Sum.inr <| P.σ a
simp [aux, aeval_rename]
| add p q hp hq =>
obtain ⟨a, rfl⟩ := hp
obtain ⟨b, rfl⟩ := hq
exact ⟨a + b, map_add _ _ _⟩
| mul_X p i h =>
obtain ⟨a, rfl⟩ := h
exact ⟨(a * X (Sum.inl i)), by simp⟩
private lemma aux_image_relation :
Q.aux P '' (Set.range (Algebra.Presentation.compRelationAux Q P)) = Set.range Q.relation := by
ext x
constructor
· rintro ⟨y, ⟨a, rfl⟩, rfl⟩
exact ⟨a, (Q.compRelationAux_map P a).symm⟩
· rintro ⟨y, rfl⟩
use Q.compRelationAux P y
simp only [Set.mem_range, exists_apply_eq_apply, true_and, compRelationAux_map]
private lemma aux_eq_comp : Q.aux P =
(MvPolynomial.mapAlgHom (aeval P.val)).comp (sumAlgEquiv R ι' ι).toAlgHom := by
ext i : 1
cases i <;> simp
private lemma aux_ker :
RingHom.ker (Q.aux P) = Ideal.map (rename Sum.inr) (RingHom.ker (aeval P.val)) := by
rw [aux_eq_comp, ← AlgHom.comap_ker, MvPolynomial.ker_mapAlgHom]
change Ideal.comap _ (Ideal.map (IsScalarTower.toAlgHom R (MvPolynomial ι R) _) _) = _
rw [← sumAlgEquiv_comp_rename_inr, ← Ideal.map_mapₐ, Ideal.comap_map_of_bijective]
simpa using AlgEquiv.bijective (sumAlgEquiv R ι' ι)
variable [Algebra R T] [IsScalarTower R S T]
private lemma aeval_comp_val_eq :
(aeval (Q.comp P.toGenerators).val) =
(aevalTower (IsScalarTower.toAlgHom R S T) Q.val).comp (Q.aux P) := by
ext i
simp only [AlgHom.coe_comp, Function.comp_apply]
cases i <;> simp
private lemma span_range_relation_eq_ker_comp : Ideal.span
(Set.range (Sum.elim (Algebra.Presentation.compRelationAux Q P)
fun rp ↦ (rename Sum.inr) (P.relation rp))) = (Q.comp P.toGenerators).ker := by
rw [Generators.ker_eq_ker_aeval_val, Q.aeval_comp_val_eq, ← AlgHom.comap_ker]
change _ = Ideal.comap _ (RingHom.ker (aeval Q.val))
rw [← Q.ker_eq_ker_aeval_val, ← Q.span_range_relation_eq_ker, ← Q.aux_image_relation P,
← Ideal.map_span, Ideal.comap_map_of_surjective' _ (Q.aux_surjective P)]
rw [Set.Sum.elim_range, Ideal.span_union, Q.aux_ker, ← P.ker_eq_ker_aeval_val,
← P.span_range_relation_eq_ker, Ideal.map_span]
congr
ext
simp
/-- Given presentations of `T` over `S` and of `S` over `R`,
we may construct a presentation of `T` over `R`. -/
@[simps -isSimp relation]
noncomputable def comp : Presentation R T (ι' ⊕ ι) (σ' ⊕ σ) where
toGenerators := Q.toGenerators.comp P.toGenerators
relation := Sum.elim (Q.compRelationAux P)
(fun rp ↦ MvPolynomial.rename Sum.inr <| P.relation rp)
span_range_relation_eq_ker := Q.span_range_relation_eq_ker_comp P
lemma toGenerators_comp : (Q.comp P).toGenerators = Q.toGenerators.comp P.toGenerators := rfl
@[simp]
lemma comp_relation_inr (r : σ) :
(Q.comp P).relation (Sum.inr r) = rename Sum.inr (P.relation r) :=
rfl
lemma comp_aeval_relation_inl (r : σ') :
aeval (Sum.elim X (MvPolynomial.C ∘ P.val)) ((Q.comp P).relation (Sum.inl r)) =
Q.relation r := by
change (Q.aux P) _ = _
simp [comp_relation, compRelationAux_map]
variable (g : S) [IsLocalization.Away g T] (P : Generators R S ι)
/-- The composition of a presentation `P` with a
localization away from an element has the form `R[Xᵢ, Y]/(fⱼ, (P.σ g) Y - 1)`,
if the chosen section of `P` preserves `-1` and `0`.
Note: If `S` is non-trivial, we can ensure this by only modifying `P.σ`. -/
lemma relation_comp_localizationAway_inl (P : Presentation R S ι σ)
(h1 : P.σ (-1) = -1) (h0 : P.σ 0 = 0) (r : Unit) :
((Presentation.localizationAway T g).comp P).relation (Sum.inl r) =
rename Sum.inr (P.σ g) * X (Sum.inl ()) - 1 := by
classical
simp only [Presentation.comp, Sum.elim_inl, Presentation.compRelationAux,
Presentation.localizationAway_relation, sub_eq_add_neg, C_mul_X_eq_monomial,
← map_one C, ← map_neg C]
refine (Finsupp.sum_single_add_single (Finsupp.single () 1) 0 g (-1 : S) _ ?_ ?_).trans ?_
· simp
· simp [h0]
· simp only [Finsupp.mapDomain_single, h1, map_neg, map_one, Finsupp.mapDomain_zero,
monomial_zero', mul_one, add_left_inj]
rfl
end Composition
/-- Given a presentation `P` and equivalences `ι' ≃ ι` and
`σ' ≃ σ`, this is the induced presentation with variables indexed
by `ι'` and relations indexed by `σ'` -/
@[simps toGenerators]
noncomputable def reindex (P : Presentation R S ι σ)
{ι' σ' : Type*} (e : ι' ≃ ι) (f : σ' ≃ σ) :
Presentation R S ι' σ' where
__ := P.toGenerators.reindex e
relation := rename e.symm ∘ P.relation ∘ f
span_range_relation_eq_ker := by
rw [Generators.ker_eq_ker_aeval_val, Generators.reindex_val, ← aeval_comp_rename,
← AlgHom.comap_ker, ← P.ker_eq_ker_aeval_val, ← P.span_range_relation_eq_ker,
Set.range_comp, Set.range_comp, Equiv.range_eq_univ, Set.image_univ,
← Ideal.map_span (rename ⇑e.symm)]
have hf : Function.Bijective (MvPolynomial.rename e.symm) := (renameEquiv R e.symm).bijective
apply Ideal.comap_injective_of_surjective _ hf.2
simp_rw [Ideal.comap_comapₐ, rename_comp_rename, Equiv.self_comp_symm]
simp [Ideal.comap_map_of_bijective _ hf, rename_id]
@[simp]
lemma dimension_reindex (P : Presentation R S ι σ) {ι' σ' : Type*} (e : ι' ≃ ι) (f : σ' ≃ σ) :
(P.reindex e f).dimension = P.dimension := by
simp [dimension, Nat.card_congr e, Nat.card_congr f]
section
variable {v : ι → MvPolynomial σ R}
(s : MvPolynomial σ R ⧸ (Ideal.span <| Set.range v) → MvPolynomial σ R :=
Function.surjInv Ideal.Quotient.mk_surjective)
(hs : ∀ x, Ideal.Quotient.mk _ (s x) = x := by apply Function.surjInv_eq)
/--
The naive presentation of a quotient `R[Xᵢ] ⧸ (vⱼ)`.
If the definitional equality of the section matters, it can be explicitly provided.
-/
@[simps! toGenerators]
noncomputable
def naive {v : ι → MvPolynomial σ R}
(s : MvPolynomial σ R ⧸ (Ideal.span <| Set.range v) → MvPolynomial σ R :=
Function.surjInv Ideal.Quotient.mk_surjective)
(hs : ∀ x, Ideal.Quotient.mk _ (s x) = x := by apply Function.surjInv_eq) :
Presentation R (MvPolynomial σ R ⧸ (Ideal.span <| Set.range v)) σ ι where
__ := Generators.naive s hs
relation := v
span_range_relation_eq_ker := (Generators.ker_naive s hs).symm
lemma naive_relation : (naive s hs).relation = v := rfl
@[simp] lemma naive_relation_apply (i : ι) : (naive s hs).relation i = v i := rfl
end
end Construction
end Presentation
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/DividedPowers/SubDPIdeal.lean | import Mathlib.RingTheory.DividedPowers.DPMorphism
import Mathlib.RingTheory.Ideal.Quotient.Operations
/-! # Sub-divided power-ideals
Let `A` be a commutative (semi)ring and let `I` be an ideal of `A` with a divided power
structure `hI`. A subideal `J` of `I` is a *sub-dp-ideal* of `(I, hI)` if, for all `n ∈ ℕ > 0` and
all `x ∈ J`, `hI.dpow n x ∈ J`.
## Main definitions
* `DividedPowers.IsSubDPIdeal` : A sub-ideal `J` of a divided power ideal `(I, hI)` is a
*sub-dp-ideal* if for all `n > 0` and all `x ∈ J`, `hI.dpow n j ∈ J`.
* `DividedPowers.SubDPIdeal` : A bundled version of `IsSubDPIdeal`.
* `DividedPowers.IsSubDPIdeal.dividedPowers`: the divided power structure on a sub-dp-ideal.
* `DividedPowers.IsSubDPIdeal.prod` : if `J` is an `A`-ideal, then `I ⬝ J` is a sub-dp-ideal of `I`.
* `DividedPowers.IsSubDPIdeal.span` : the sub-dp-ideal of `I` generated by a set of elements of `A`.
* `DividedPowers.subDPIdeal_inf_of_quot` : if there is a dp-structure on `I⬝(A/J)` such that the
quotient map is a dp-morphism, then `J ⊓ I` is a sub-dp-ideal of `I`.
* `DividedPowers.Quotient.OfSurjective.dividedPowers`: when `f : A → B` is a surjective map and
`f.ker ⊓ I` is a sub-dp-ideal of `I`, this is the induced divided power structure on the ideal
`I.map f` of the target.
* `DividedPowers.Quotient.dividedPowers` : when `I ⊓ J` is a sub-dp-ideal of `I`, this is the
divided power structure on the ideal `I(A⧸J)` of the quotient.
## Main results
* `DividedPowers.isSubDPIdeal_inf_iff` : the ideal `J ⊓ I` is a sub-dp-ideal of `I` if and only if
(on `I`) the divided powers are compatible mod `J`.
* `DividedPowers.span_isSubDPIdeal_iff` : the span of a set `S : Set A` is a sub-dp-ideal of `I`
if and only if for all `n ∈ ℕ > 0` and all `s ∈ S`, hI.dpow n s ∈ span S.
* `DividedPowers.isSubDPIdeal_ker` : the kernel of a divided power morphism from `I` to `J` is
a sub-dp-ideal of `I`.
* `DividedPowers.isSubDPIdeal_map` : the image of a divided power morphism from `I` to `J` is
a sub-dp-ideal of `J`.
* `DividedPowers.SubDPIdeal.instCompleteLattice` : sub-dp-ideals of `I` form a complete lattice
under inclusion.
* `DividedPowers.SubDPIdeal.span_carrier_eq_dpow_span` : the underlying ideal of
`SubDPIdeal.span hI S` is generated by the elements of the form `hI.dpow n x` with `n > 0`
and `x ∈ S`.
* `DividedPowers.Quotient.OfSurjective.dividedPowers_unique` : the only divided power structure on
`I.map f` such that the surjective map `f : A → B` is a divided power morphism is given by
`DividedPowers.Quotient.OfSurjective.dividedPowers`.
* `DividedPowers.Quotient.dividedPowers_unique` : the only divided power structure on `I(A⧸J)` such
that the quotient map `A → A/J` is a divided power morphism is given by
`DividedPowers.Quotient.dividedPowers`.
## Implementation remarks
We provide both a bundled and an unbundled definition of sub-dp-ideals. The unbundled version is
often more convenient when a larger proof requires to show that a certain ideal is a sub-dp-ideal.
On the other hand, a bundled version is required to prove that sub-dp-ideals form a complete
lattice.
## References
* [P. Berthelot, *Cohomologie cristalline des schémas de caractéristique $p$ > 0*][Berthelot-1974]
* [P. Berthelot and A. Ogus, *Notes on crystalline cohomology*][BerthelotOgus-1978]
* [N. Roby, *Lois polynomes et lois formelles en théorie des modules*][Roby-1963]
* [N. Roby, *Les algèbres à puissances dividées*][Roby-1965]
-/
open Subtype
namespace DividedPowers
/-- A sub-ideal `J` of a divided power ideal `(I, hI)` is a sub-dp-ideal if for all `n > 0` and
all `x ∈ J`, `hI.dpow n j ∈ J`. -/
structure IsSubDPIdeal {A : Type*} [CommSemiring A] {I : Ideal A} (hI : DividedPowers I)
(J : Ideal A) : Prop where
isSubideal : J ≤ I
dpow_mem : ∀ (n : ℕ) (_ : n ≠ 0) {j : A} (_ : j ∈ J), hI.dpow n j ∈ J
section IsSubDPIdeal
namespace IsSubDPIdeal
variable {A : Type*} [CommSemiring A] {I : Ideal A} (hI : DividedPowers I)
open Ideal
theorem self : IsSubDPIdeal hI I where
isSubideal := le_rfl
dpow_mem _ hn _ ha := hI.dpow_mem hn ha
/-- The divided power structure on a sub-dp-ideal. -/
def dividedPowers {J : Ideal A} (hJ : IsSubDPIdeal hI J) [∀ x, Decidable (x ∈ J)] :
DividedPowers J where
dpow n x := if x ∈ J then hI.dpow n x else 0
dpow_null hx := by simp [if_neg hx]
dpow_zero hx := by simp [if_pos hx, hI.dpow_zero (hJ.isSubideal hx)]
dpow_one hx := by simp [if_pos hx, hI.dpow_one (hJ.isSubideal hx)]
dpow_mem hn hx := by simp [if_pos hx, hJ.dpow_mem _ hn hx]
dpow_add hx hy := by simp_rw [if_pos hx, if_pos hy, if_pos (Ideal.add_mem J hx hy),
hI.dpow_add (hJ.isSubideal hx) (hJ.isSubideal hy)]
dpow_mul hx := by
simp [if_pos hx, if_pos (mul_mem_left J _ hx), hI.dpow_mul (hJ.isSubideal hx)]
mul_dpow hx := by simp [if_pos hx, hI.mul_dpow (hJ.isSubideal hx)]
dpow_comp hn hx := by
simp [if_pos hx, if_pos (hJ.dpow_mem _ hn hx), hI.dpow_comp hn (hJ.isSubideal hx)]
variable {J : Ideal A} (hJ : IsSubDPIdeal hI J) [∀ x, Decidable (x ∈ J)]
lemma dpow_eq (n : ℕ) (a : A) :
(IsSubDPIdeal.dividedPowers hI hJ).dpow n a = if a ∈ J then hI.dpow n a else 0 := rfl
lemma dpow_eq_of_mem {n : ℕ} {a : A} (ha : a ∈ J) :
(IsSubDPIdeal.dividedPowers hI hJ).dpow n a = hI.dpow n a := by rw [dpow_eq, if_pos ha]
theorem isDPMorphism (hJ : IsSubDPIdeal hI J) :
(IsSubDPIdeal.dividedPowers hI hJ).IsDPMorphism hI (RingHom.id A) := by
simpa only [isDPMorphism_iff, Ideal.map_id, RingHom.id_apply]
using ⟨hJ.1, fun _ _ _ ha ↦ by rw [dpow_eq_of_mem _ _ ha]⟩
end IsSubDPIdeal
open Finset Ideal
/-- The ideal `J ⊓ I` is a sub-dp-ideal of `I` if and only if the divided powers have
some compatibility mod `J`. (The necessity was proved as a sanity check.) -/
theorem isSubDPIdeal_inf_iff {A : Type*} [CommRing A] {I : Ideal A} (hI : DividedPowers I)
{J : Ideal A} : IsSubDPIdeal hI (J ⊓ I) ↔
∀ {n : ℕ} {a b : A} (_ : a ∈ I) (_ : b ∈ I) (_ : a - b ∈ J), hI.dpow n a - hI.dpow n b ∈ J := by
refine ⟨fun hIJ n a b ha hb hab ↦ ?_, fun hIJ ↦ ?_⟩
· have hab' : a - b ∈ I := I.sub_mem ha hb
rw [← add_sub_cancel b a, hI.dpow_add' hb hab', range_add_one, sum_insert notMem_range_self,
tsub_self, hI.dpow_zero hab', mul_one, add_sub_cancel_left]
exact J.sum_mem (fun i hi ↦ SemilatticeInf.inf_le_left J I ((J ⊓ I).smul_mem _
(hIJ.dpow_mem _ (ne_of_gt (Nat.sub_pos_of_lt (mem_range.mp hi))) ⟨hab, hab'⟩)))
· refine ⟨SemilatticeInf.inf_le_right J I, fun {n} hn {a} ha ↦ ⟨?_, hI.dpow_mem hn ha.right⟩⟩
rw [← sub_zero (hI.dpow n a), ← hI.dpow_eval_zero hn]
exact hIJ ha.right I.zero_mem (J.sub_mem ha.left J.zero_mem)
variable {A B : Type*} [CommSemiring A] {I : Ideal A} {hI : DividedPowers I} [CommSemiring B]
{J : Ideal B} {hJ : DividedPowers J}
/-- [P. Berthelot and A. Ogus, *Notes on crystalline cohomology* (Lemma 3.6)][BerthelotOgus-1978] -/
theorem span_isSubDPIdeal_iff {S : Set A} (hS : S ⊆ I) :
IsSubDPIdeal hI (span S) ↔ ∀ {n : ℕ} (_ : n ≠ 0), ∀ s ∈ S, hI.dpow n s ∈ span S := by
refine ⟨fun hhI n hn s hs ↦ hhI.dpow_mem n hn (subset_span hs), fun hhI ↦ ?_⟩
· -- interesting direction
have hSI := span_le.mpr hS
apply IsSubDPIdeal.mk hSI
intro m hm z hz
induction hz using Submodule.span_induction generalizing m hm with
| mem x h => exact hhI hm x h
| zero =>
rw [hI.dpow_eval_zero hm]
exact (span S).zero_mem
| add x y hxI hyI hx hy =>
rw [hI.dpow_add' (hSI hxI) (hSI hyI)]
apply Submodule.sum_mem (span S)
intro m _
by_cases hm0 : m = 0
· exact hm0 ▸ mul_mem_left (span S) _ (hy _ hm)
· exact mul_mem_right _ (span S) (hx _ hm0)
| smul a x hxI hx =>
rw [Algebra.id.smul_eq_mul, hI.dpow_mul (hSI hxI)]
exact mul_mem_left (span S) (a ^ m) (hx m hm)
theorem isSubDPIdeal_sup {J K : Ideal A} (hJ : IsSubDPIdeal hI J) (hK : IsSubDPIdeal hI K) :
IsSubDPIdeal hI (J ⊔ K) := by
rw [← J.span_eq, ← K.span_eq, ← span_union,
span_isSubDPIdeal_iff (Set.union_subset_iff.mpr ⟨hJ.1, hK.1⟩)]
intro n hn a ha
rcases ha with ha | ha
· exact span_mono Set.subset_union_left (subset_span (hJ.2 n hn ha))
· exact span_mono Set.subset_union_right (subset_span (hK.2 n hn ha))
theorem isSubDPIdeal_iSup {ι : Type*} {J : ι → Ideal A} (hJ : ∀ i, IsSubDPIdeal hI (J i)) :
IsSubDPIdeal hI (iSup J) := by
rw [iSup_eq_span, span_isSubDPIdeal_iff (Set.iUnion_subset_iff.mpr <| fun i ↦ (hJ i).1)]
simp_rw [Set.mem_iUnion]
rintro n hn a ⟨i, ha⟩
exact span_mono (Set.subset_iUnion _ i) (subset_span ((hJ i).2 n hn ha))
theorem isSubDPIdeal_iInf {ι : Type*} {J : ι → Ideal A} (hJ : ∀ i, IsSubDPIdeal hI (J i)) :
IsSubDPIdeal hI (I ⊓ iInf (fun i ↦ J i)) := by
cases isEmpty_or_nonempty ι with
| inr _ =>
refine ⟨fun _ hx ↦ hx.1, ?_⟩
intro n hn x hx
simp only [Ideal.mem_inf, mem_iInf] at hx ⊢
exact ⟨hI.dpow_mem hn hx.1, fun i ↦ IsSubDPIdeal.dpow_mem (hJ i) n hn (hx.2 i)⟩
| inl _ =>
simp only [iInf_of_empty, le_top, inf_of_le_left]
exact IsSubDPIdeal.self hI
theorem isSubDPIdeal_map_of_isSubDPIdeal {f : A →+* B} (hf : IsDPMorphism hI hJ f) {K : Ideal A}
(hK : IsSubDPIdeal hI K) : IsSubDPIdeal hJ (map f K) := by
rw [Ideal.map, span_isSubDPIdeal_iff]
· rintro n hn y ⟨x, hx, rfl⟩
exact hf.2 x (hK.1 hx) ▸ mem_map_of_mem _ (hK.2 _ hn hx)
· rintro y ⟨x, hx, rfl⟩
exact hf.1 (mem_map_of_mem f (hK.1 hx))
/-- The image of a divided power morphism from `I` to `J` is a sub-dp-ideal of `J`. -/
theorem isSubDPIdeal_map {f : A →+* B} (hf : IsDPMorphism hI hJ f) :
IsSubDPIdeal hJ (Ideal.map f I) :=
isSubDPIdeal_map_of_isSubDPIdeal hf (IsSubDPIdeal.self hI)
end IsSubDPIdeal
/-- A `SubDPIdeal` of `I` is a sub-ideal `J` of `I` such that for all `n > 0` `x ∈ J`,
`hI.dpow n j ∈ J`. The unbundled version of this definition is called `IsSubDPIdeal`. -/
@[ext]
structure SubDPIdeal {A : Type*} [CommSemiring A] {I : Ideal A} (hI : DividedPowers I) where
/-- The underlying ideal. -/
carrier : Ideal A
isSubideal : carrier ≤ I
dpow_mem : ∀ (n : ℕ) (_ : n ≠ 0), ∀ j ∈ carrier, hI.dpow n j ∈ carrier
namespace SubDPIdeal
variable {A : Type*} [CommSemiring A] {I : Ideal A} {hI : DividedPowers I}
/-- Constructs a `SubPDIdeal` given an ideal `J` satisfying `hI.IsSubDPIdeal J`. -/
def mk' {J : Ideal A} (hJ : hI.IsSubDPIdeal J) : hI.SubDPIdeal := ⟨J, hJ.1, hJ.2⟩
instance : SetLike (SubDPIdeal hI) A where
coe s := s.carrier
coe_injective' p q h := by
rw [SetLike.coe_set_eq] at h
cases p; cases q; congr
/-- The coercion from `SubDPIdeal` to `Ideal`. -/
@[coe]
def toIdeal (J : hI.SubDPIdeal) : Ideal A := J.carrier
instance : CoeOut (hI.SubDPIdeal) (Ideal A) := ⟨fun J ↦ J.toIdeal⟩
theorem coe_def (J : SubDPIdeal hI) : J.toIdeal = J.carrier := rfl
@[simp]
theorem memCarrier {s : SubDPIdeal hI} {x : A} : x ∈ s.carrier ↔ x ∈ s := Iff.rfl
lemma toIsSubDPIdeal (J : SubDPIdeal hI) : IsSubDPIdeal hI J.carrier where
isSubideal := J.isSubideal
dpow_mem := J.dpow_mem
open Ideal
/-- If `J` is an ideal of `A`, then `I⬝J` is a sub-dp-ideal of `I`.
See [P. Berthelot, *Cohomologie cristalline des schémas de caractéristique $p$ > 0*,
(Proposition 1.6.1 (i))][Berthelot-1974] -/
def prod (J : Ideal A) : SubDPIdeal hI where
carrier := I • J
isSubideal := mul_le_right
dpow_mem m hm x hx := by
induction hx using Submodule.smul_induction_on' generalizing m with
| smul a ha b hb =>
rw [Algebra.id.smul_eq_mul, smul_eq_mul, mul_comm a b, hI.dpow_mul ha, mul_comm]
exact Submodule.mul_mem_mul (J.pow_mem_of_mem hb m (zero_lt_iff.mpr hm))
(hI.dpow_mem hm ha)
| add x hx y hy hx' hy' =>
rw [hI.dpow_add' (mul_le_right hx) (mul_le_right hy)]
apply Submodule.sum_mem (I • J)
intro k _
by_cases hk0 : k = 0
· exact hk0 ▸ mul_mem_left (I • J) _ (hy' _ hm)
· exact mul_mem_right _ (I • J) (hx' k hk0)
section CompleteLattice
instance : CoeOut (SubDPIdeal hI) (Set.Iic I) := ⟨fun J ↦ ⟨J.carrier, J.isSubideal⟩⟩
instance : LE (SubDPIdeal hI) := ⟨fun J J' ↦ J.carrier ≤ J'.carrier⟩
theorem le_iff {J J' : SubDPIdeal hI} : J ≤ J' ↔ J.carrier ≤ J'.carrier := Iff.rfl
instance : LT (SubDPIdeal hI) := ⟨fun J J' ↦ J.carrier < J'.carrier⟩
theorem lt_iff {J J' : SubDPIdeal hI} : J < J' ↔ J.carrier < J'.carrier := Iff.rfl
/-- `I` is a sub-dp-ideal of itself. -/
instance : Top (SubDPIdeal hI) :=
⟨{carrier := I
isSubideal := le_refl _
dpow_mem := fun _ hn _ hx ↦ hI.dpow_mem hn hx }⟩
instance inhabited : Inhabited hI.SubDPIdeal := ⟨⊤⟩
/-- `(0)` is a sub-dp-ideal of the dp-ideal `I`. -/
instance : Bot (SubDPIdeal hI) :=
⟨{carrier := ⊥
isSubideal := bot_le
dpow_mem := fun _ hn x hx ↦ by rw [mem_bot.mp hx, hI.dpow_eval_zero hn, mem_bot]}⟩
/-- The intersection of two sub-dp-ideals is a sub-dp-ideal. -/
instance : Min (SubDPIdeal hI) :=
⟨fun J J' ↦
{ carrier := J.carrier ⊓ J'.carrier
isSubideal := fun _ hx ↦ J.isSubideal hx.1
dpow_mem := fun _ hn x hx ↦ ⟨J.dpow_mem _ hn x hx.1, J'.dpow_mem _ hn x hx.2⟩ }⟩
theorem inf_carrier_def (J J' : SubDPIdeal hI) : (J ⊓ J').carrier = J.carrier ⊓ J'.carrier := rfl
instance : InfSet (SubDPIdeal hI) :=
⟨fun S ↦
{ carrier := ⨅ s ∈ Insert.insert ⊤ S, (s : hI.SubDPIdeal).carrier
isSubideal := fun x hx ↦ by
simp only [mem_iInf] at hx
exact hx ⊤ (Set.mem_insert ⊤ S)
dpow_mem := fun _ hn x hx ↦ by
simp only [mem_iInf] at hx ⊢
exact fun s hs ↦ s.dpow_mem _ hn x (hx s hs) }⟩
theorem sInf_carrier_def (S : Set (SubDPIdeal hI)) :
(sInf S).carrier = ⨅ s ∈ Insert.insert ⊤ S, (s : hI.SubDPIdeal).carrier := rfl
instance : Max (SubDPIdeal hI) :=
⟨fun J J' ↦ SubDPIdeal.mk' (isSubDPIdeal_sup J.toIsSubDPIdeal J'.toIsSubDPIdeal)⟩
theorem sup_carrier_def (J J' : SubDPIdeal hI) : (J ⊔ J').carrier = J ⊔ J' := rfl
instance : SupSet (SubDPIdeal hI) :=
⟨fun S ↦ SubDPIdeal.mk' (J := sSup ((fun J ↦ J.carrier) '' S)) <| by
have h : (⋃ (i : Ideal A) (_ : i ∈ (fun J ↦ J.carrier) '' S), ↑i) ⊆ (I : Set A) := by
rintro a ⟨-, ⟨J, rfl⟩, haJ⟩
rw [Set.mem_iUnion, SetLike.mem_coe, exists_prop] at haJ
obtain ⟨J', hJ'⟩ := (Set.mem_image _ _ _).mp haJ.1
exact J'.isSubideal (hJ'.2 ▸ haJ.2)
rw [sSup_eq_iSup, Submodule.iSup_eq_span', submodule_span_eq, span_isSubDPIdeal_iff h]
rintro n hn x ⟨T, ⟨J, rfl⟩, ⟨J', ⟨⟨hJ', rfl⟩, h'⟩⟩⟩
apply subset_span
apply Set.mem_biUnion hJ'
obtain ⟨K, hKS, rfl⟩ := hJ'
exact K.dpow_mem _ hn x h'⟩
theorem sSup_carrier_def (S : Set (SubDPIdeal hI)) : (sSup S).carrier = sSup ((toIdeal) '' S) := rfl
instance : CompleteLattice (SubDPIdeal hI) := by
refine Function.Injective.completeLattice (fun J : SubDPIdeal hI ↦ (J : Set.Iic I))
(fun J J' h ↦ by simpa only [SubDPIdeal.ext_iff, Subtype.mk.injEq] using h) (fun J J' ↦ by rfl)
(fun J J' ↦ by rfl)
(fun S ↦ ?_) (fun S ↦ ?_) rfl rfl
· conv_rhs => rw [iSup]
rw [Subtype.ext_iff, Set.Iic.coe_sSup]
dsimp only
rw [sSup_carrier_def, sSup_image, sSup_image, iSup_range]
have (J : hI.SubDPIdeal) :
((⨆ (_ : J ∈ S), (J : Set.Iic I) : Set.Iic I) : Ideal A) = ⨆ (_ : J ∈ S), (J : Ideal A) := by
by_cases hJ : J ∈ S
· simp [ciSup_pos hJ]
· simp [hJ, not_false_eq_true, iSup_neg, Set.Iic.coe_bot]
simp_rw [this]
rfl
· conv_rhs => rw [iInf]
rw [Subtype.ext_iff, Set.Iic.coe_sInf]
dsimp only
rw [sInf_carrier_def, sInf_image, iInf_range, inf_iInf, iInf_insert, inf_iInf]
apply iInf_congr (fun J ↦ ?_)
by_cases hJ : J ∈ S
· rw [ciInf_pos hJ, ciInf_pos hJ]; rfl
· simp [hJ, iInf_neg, le_top, inf_of_le_left, Set.Iic.coe_top, le_refl]; rfl
end CompleteLattice
section Generated
variable (hI)
/-- The sub-dp-ideal of I generated by a family of elements of A. -/
protected def span (S : Set A) : SubDPIdeal hI := sInf {J : SubDPIdeal hI | S ⊆ J.carrier}
theorem _root_.DividedPowers.dpow_span_isSubideal {S : Set A} (hS : S ⊆ I) :
span {y : A | ∃ (n : ℕ) (_ : n ≠ 0) (x : A) (_ : x ∈ S), y = hI.dpow n x} ≤ I := by
rw [span_le]
rintro y ⟨n, hn, x, hx, hxy⟩
exact hxy ▸ hI.dpow_mem hn (hS hx)
theorem dpow_mem_span_of_mem_span {S : Set A} (hS : S ⊆ I) {k : ℕ} (hk : k ≠ 0)
{z : A} (hz : z ∈ span {y : A | ∃ (n : ℕ) (_ : n ≠ 0) (x : A) (_ : x ∈ S), y = hI.dpow n x}) :
hI.dpow k z ∈ span {y : A | ∃ (n : ℕ) (_ : n ≠ 0) (x : A) (_ : x ∈ S), y = hI.dpow n x} := by
let J := span {y : A | ∃ (n : ℕ) (_ : n ≠ 0) (x : A) (_ : x ∈ S), y = hI.dpow n x}
have hSI := hI.dpow_span_isSubideal hS
have haux : ∀ (n : ℕ) (_ : n ≠ 0),
hI.dpow n z ∈ span {y | ∃ n, ∃ (_ : n ≠ 0), ∃ x, ∃ (_ : x ∈ S), y = hI.dpow n x} := by
refine Submodule.span_induction ?_ ?_ ?_ ?_ hz
· -- Elements of S
rintro y ⟨m, hm, x, hxS, hxy⟩ n hn
rw [hxy, hI.dpow_comp hm (hS hxS)]
exact mul_mem_left _ _ (subset_span ⟨n * m, mul_ne_zero hn hm, x, hxS, rfl⟩)
· -- Zero
exact fun _ hn ↦ by simp only [hI.dpow_eval_zero hn, zero_mem]
· intro x y hx hy hx_pow hy_pow n hn
rw [hI.dpow_add' (hSI hx) (hSI hy)]
apply Submodule.sum_mem (span _)
intro m _
by_cases hm0 : m = 0
· rw [hm0]; exact (span _).mul_mem_left _ (hy_pow n hn)
· exact (span _).mul_mem_right _ (hx_pow m hm0)
· intro a x hx hx_pow n hn
rw [smul_eq_mul, hI.dpow_mul (hSI hx)]
exact mul_mem_left (span _) (a ^ n) (hx_pow n hn)
exact haux _ hk
/-- The underlying ideal of `SubDPIdeal.span hI S` is generated by the elements
of the form `hI.dpow n x` with `n > 0` and `x ∈ S`. -/
theorem span_carrier_eq_dpow_span {S : Set A} (hS : S ⊆ I) :
(SubDPIdeal.span hI S).carrier =
span {y : A | ∃ (n : ℕ) (_ : n ≠ 0) (x : A) (_ : x ∈ S), y = hI.dpow n x} := by
set J : SubDPIdeal hI := {
carrier := span {y : A | ∃ (n : ℕ) (_ : n ≠ 0) (x : A) (_ : x ∈ S), y = hI.dpow n x }
isSubideal := hI.dpow_span_isSubideal hS
dpow_mem _ hk _ hz := dpow_mem_span_of_mem_span hI hS hk hz }
simp only [SubDPIdeal.span, sInf_carrier_def]
apply le_antisymm
· have h : J ∈ insert ⊤ {J : hI.SubDPIdeal | S ⊆ ↑J.carrier} :=
Set.mem_insert_of_mem _
(fun x hx ↦ subset_span ⟨1, one_ne_zero, x, hx, by rw [hI.dpow_one (hS hx)]⟩)
refine sInf_le_of_le ⟨J, ?_⟩ (le_refl _)
simp only [h, ciInf_pos, J]
· rw [le_iInf₂_iff]
intro K hK
have : S ≤ K := by
simp only [Set.mem_insert_iff, Set.mem_setOf_eq] at hK
rcases hK with rfl | hKS
exacts [hS, hKS]
rw [span_le]
rintro y ⟨n, hn, x, hx, rfl⟩
exact K.dpow_mem n hn x (this hx)
end Generated
end SubDPIdeal
section Ker
variable {A : Type*} [CommRing A] {I : Ideal A} (hI : DividedPowers I)
{B : Type*} [CommRing B] {J : Ideal B} (hJ : DividedPowers J)
/-- The kernel of a divided power morphism from `I` to `J` is a sub-dp-ideal of `I`. -/
theorem isSubDPIdeal_ker {f : A →+* B} (hf : IsDPMorphism hI hJ f) :
IsSubDPIdeal hI (RingHom.ker f ⊓ I) := by
rw [isSubDPIdeal_inf_iff]
simp only [isDPMorphism_def] at hf
intro n a b ha hb
simp only [RingHom.sub_mem_ker_iff, ← hf.2 a ha, ← hf.2 b hb]
exact congr_arg _
open Ideal
/-- The kernel of a divided power morphism, as a `SubDPIdeal`. -/
def DPMorphism.ker (f : DPMorphism hI hJ) : SubDPIdeal hI where
carrier := RingHom.ker f.toRingHom ⊓ I
isSubideal := inf_le_right
dpow_mem _ hn a := by
simp only [mem_inf, and_imp, RingHom.mem_ker]
intro ha ha'
rw [← f.isDPMorphism.2 a ha', ha]
exact ⟨dpow_eval_zero hJ hn, hI.dpow_mem hn ha'⟩
end Ker
section Equalizer
variable {A : Type*} [CommSemiring A] {I : Ideal A} (hI hI' : DividedPowers I)
/-- The ideal of `A` in which the two divided power structures `hI` and `hI'` coincide. -/
-- TODO : prove that this is the largest ideal which is a sub-dp-ideal in both `hI` and `hI'`.
def dpEqualizer : Ideal A where
carrier := { a ∈ I | ∀ n : ℕ, hI.dpow n a = hI'.dpow n a }
add_mem' {a b} ha hb := by
apply And.intro (I.add_mem ha.1 hb.1) (fun n ↦ ?_)
rw [hI.dpow_add ha.1 hb.1, hI'.dpow_add ha.1 hb.1]
exact Finset.sum_congr rfl (fun k _ ↦ by rw [ha.2, hb.2])
zero_mem' := by
apply And.intro I.zero_mem (fun n ↦ ?_)
by_cases hn : n = 0
· rw [hn, hI.dpow_zero (zero_mem I), hI'.dpow_zero (zero_mem I)]
· rw [hI.dpow_eval_zero hn, hI'.dpow_eval_zero hn]
smul_mem' a x hx := by
rw [Algebra.id.smul_eq_mul]
exact ⟨I.mul_mem_left a hx.1, (fun n ↦ by rw [hI.dpow_mul hx.1, hI'.dpow_mul hx.1, hx.2])⟩
theorem mem_dpEqualizer_iff {x : A} :
x ∈ dpEqualizer hI hI' ↔ x ∈ I ∧ ∀ n : ℕ, hI.dpow n x = hI'.dpow n x := by
simp [dpEqualizer, Submodule.mem_mk, AddSubmonoid.mem_mk, AddSubsemigroup.mem_mk,
Set.mem_setOf_eq]
theorem dpEqualizer_is_dp_ideal_left :
DividedPowers.IsSubDPIdeal hI (dpEqualizer hI hI') :=
IsSubDPIdeal.mk (fun _ hx ↦ hx.1) (fun _ hn x hx ↦ ⟨hI.dpow_mem hn hx.1,
fun m ↦ by rw [hI.dpow_comp hn hx.1, hx.2, hx.2, hI'.dpow_comp hn hx.1]⟩)
theorem dpEqualizer_is_dp_ideal_right :
DividedPowers.IsSubDPIdeal hI' (dpEqualizer hI hI') :=
IsSubDPIdeal.mk (fun _ hx ↦ hx.1) (fun _ hn x hx ↦ ⟨hI'.dpow_mem hn hx.1, fun m ↦ by
rw [← hx.2, hI.dpow_comp hn hx.1, hx.2, hx.2, hI'.dpow_comp hn hx.1]⟩)
open Ideal
theorem le_equalizer_of_isDPMorphism {B : Type*} [CommSemiring B] (f : A →+* B)
{K : Ideal B} (hI_le_K : Ideal.map f I ≤ K)
(hK hK' : DividedPowers K) (hIK : IsDPMorphism hI hK f) (hIK' : IsDPMorphism hI hK' f) :
Ideal.map f I ≤ dpEqualizer hK hK' := by
rw [Ideal.map, span_le]
rintro b ⟨a, ha, rfl⟩
exact ⟨hI_le_K (mem_map_of_mem f ha), fun n ↦ by rw [hIK.2 a ha, hIK'.2 a ha]⟩
/-- If there is a divided power structure on `I⬝(A/J)` such that the quotient map is
a dp-morphism, then `J ⊓ I` is a sub-dp-ideal of `I`. -/
def subDPIdeal_inf_of_quot {A : Type*} [CommRing A] {I : Ideal A} {hI : DividedPowers I}
{J : Ideal A} {hJ : DividedPowers (I.map (Ideal.Quotient.mk J))} {φ : DPMorphism hI hJ}
(hφ : φ.toRingHom = Ideal.Quotient.mk J) :
SubDPIdeal hI where
carrier := J ⊓ I
isSubideal := by simp only [inf_le_right]
dpow_mem := fun _ hn a ⟨haJ, haI⟩ ↦ by
refine ⟨?_, hI.dpow_mem hn haI⟩
rw [SetLike.mem_coe, ← Quotient.eq_zero_iff_mem, ← hφ, ← φ.dpow_comp a haI]
suffices ha0 : φ.toRingHom a = 0 by
rw [ha0, hJ.dpow_eval_zero hn]
rw [hφ, Quotient.eq_zero_iff_mem]
exact haJ
end Equalizer
section Quotient
/- Divided power structure on a quotient ring in two settings:
* The case of a surjective `RingHom`.
* The specific case for `Ideal.Quotient.mk`. -/
namespace Quotient
variable {A : Type*} [CommRing A] {I : Ideal A} (hI : DividedPowers I)
namespace OfSurjective
variable {B : Type*} [CommRing B] (f : A →+* B) (J : Ideal B)
/-- The definition of divided powers on the codomain `B` of a surjective ring homomorphism
from a ring `A` with divided powers `hI`. This definition is tagged as noncomputable
because it makes use of `Function.extend`, but under the hypothesis
`IsSubDPIdeal hI (RingHom.ker f ⊓ I)`, `dividedPowers_unique` proves that no choices are
involved. -/
noncomputable def dpow : ℕ → B → B := fun n ↦
Function.extend (fun a ↦ f a : I → B) (fun a ↦ f (hI.dpow n a) : I → B) 0
variable {f} (hf : Function.Surjective f) {J} (hIJ : J = I.map f)
(hIf : hI.IsSubDPIdeal (RingHom.ker f ⊓ I))
/-- Divided powers on the codomain `B` of a surjective ring homomorphism `f` are compatible
with `f`. -/
theorem dpow_apply' (hIf : IsSubDPIdeal hI (RingHom.ker f ⊓ I)) {n : ℕ} {a : A} (ha : a ∈ I) :
dpow hI f n (f a) = f (hI.dpow n a) := by
classical
simp only [dpow, Function.extend_def]
have h : ∃ (a_1 : I), f ↑a_1 = f a := by use ⟨a, ha⟩
rw [dif_pos h, ← sub_eq_zero, ← map_sub, ← RingHom.mem_ker]
apply (hI.isSubDPIdeal_inf_iff.mp hIf) (Submodule.coe_mem _) ha
rw [RingHom.mem_ker, map_sub, sub_eq_zero, h.choose_spec]
open Ideal
/-- When `f.ker ⊓ I` is a sub-dp-ideal of `I`, this is the induced divided power structure on
the ideal `I.map f` of the target. -/
noncomputable def dividedPowers : DividedPowers J where
dpow := dpow hI f
dpow_null n {x} hx' := by
classical
rw [dpow, Function.extend_def, dif_neg, Pi.zero_apply]
rintro ⟨⟨a, ha⟩, rfl⟩
exact (hIJ ▸ hx') (apply_coe_mem_map f I ⟨a, ha⟩)
dpow_zero {x} hx := by
obtain ⟨a, ha, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hx)
rw [dpow_apply' hI hIf ha, hI.dpow_zero ha, map_one]
dpow_one {x} hx := by
obtain ⟨a, ha, hax⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hx)
rw [← hax, dpow_apply' hI hIf ha, hI.dpow_one ha]
dpow_mem {n x} hn hx := by
rw [hIJ] at hx ⊢
obtain ⟨a, ha, rfl⟩ := (mem_map_iff_of_surjective f hf).mp hx
rw [dpow_apply' hI hIf ha]
exact mem_map_of_mem _ (hI.dpow_mem hn ha)
dpow_add hx hy := by
obtain ⟨a, ha, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hx)
obtain ⟨b, hb, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hy)
rw [← map_add, dpow_apply' hI hIf (I.add_mem ha hb), hI.dpow_add ha hb, map_sum,
Finset.sum_congr rfl]
exact fun k _ ↦ by rw [dpow_apply' hI hIf ha, dpow_apply' hI hIf hb, ← _root_.map_mul]
dpow_mul {n x y} hy := by
obtain ⟨a, rfl⟩ := hf x
obtain ⟨b, hb, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hy)
rw [dpow_apply' hI hIf hb, ← _root_.map_mul, ← map_pow,
dpow_apply' hI hIf (mul_mem_left I a hb), hI.dpow_mul hb, _root_.map_mul]
mul_dpow hx := by
obtain ⟨a, ha, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hx)
simp only [dpow_apply' hI hIf ha]
rw [← _root_.map_mul, hI.mul_dpow ha, _root_.map_mul, map_natCast]
dpow_comp hn hx := by
obtain ⟨a, ha, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hx)
simp only [dpow_apply' hI hIf, ha, hI.dpow_mem hn ha]
rw [hI.dpow_comp hn ha, _root_.map_mul, map_natCast]
theorem dpow_def {n : ℕ} {x : B} : (dividedPowers hI hf hIJ hIf).dpow n x = dpow hI f n x := rfl
theorem dpow_apply {n : ℕ} {a : A} (ha : a ∈ I) :
(dividedPowers hI hf hIJ hIf).dpow n (f a) = f (hI.dpow n a) := by
rw [dpow_def, dpow_apply' hI hIf ha]
theorem isDPMorphism : IsDPMorphism hI (dividedPowers hI hf hIJ hIf) f :=
⟨le_of_eq hIJ.symm, fun a ha ↦ by rw [dpow_apply hI hf hIJ hIf ha]⟩
theorem dividedPowers_unique (hquot : DividedPowers J)
(hm : DividedPowers.IsDPMorphism hI hquot f) : hquot = dividedPowers hI hf hIJ hIf :=
ext _ _ fun n x hx ↦ by
obtain ⟨a, ha, rfl⟩ := (mem_map_iff_of_surjective f hf).mp (hIJ ▸ hx)
rw [hm.2 a ha, dpow_apply hI hf hIJ hIf ha]
end OfSurjective
variable {J : Ideal A} (hIJ : IsSubDPIdeal hI (J ⊓ I))
/-- The definition of divided powers on `A ⧸ J`. Tagged as noncomputable because it makes use of
`Function.extend`, but under `IsSubDPIdeal hI (J ⊓ I)`, `dividedPowers_unique` proves that no
choices are involved. -/
noncomputable def dpow (J : Ideal A) : ℕ → A ⧸ J → A ⧸ J :=
DividedPowers.Quotient.OfSurjective.dpow hI (Ideal.Quotient.mk J)
private theorem isSubDPIdeal_aux (hIJ : IsSubDPIdeal hI (J ⊓ I)) :
IsSubDPIdeal hI (RingHom.ker (Ideal.Quotient.mk J) ⊓ I) := by
simpa [Ideal.mk_ker] using hIJ
/-- When `I ⊓ J` is a sub-dp-ideal of `I`, this is the divided power structure on the ideal
`I(A⧸J)` of the quotient. -/
noncomputable def dividedPowers : DividedPowers (I.map (Ideal.Quotient.mk J)) :=
DividedPowers.Quotient.OfSurjective.dividedPowers
hI Ideal.Quotient.mk_surjective (refl _) (isSubDPIdeal_aux hI hIJ)
/-- Divided powers on the quotient are compatible with quotient map -/
theorem dpow_apply {n : ℕ} {a : A} (ha : a ∈ I) :
(dividedPowers hI hIJ).dpow n (Ideal.Quotient.mk J a) = (Ideal.Quotient.mk J) (hI.dpow n a) :=
DividedPowers.Quotient.OfSurjective.dpow_apply
hI Ideal.Quotient.mk_surjective (refl _) (isSubDPIdeal_aux hI hIJ) ha
theorem isDPMorphism : hI.IsDPMorphism (dividedPowers hI hIJ) (Ideal.Quotient.mk J) :=
DividedPowers.Quotient.OfSurjective.isDPMorphism
hI Ideal.Quotient.mk_surjective (refl _) (isSubDPIdeal_aux hI hIJ)
theorem dividedPowers_unique (hquot : DividedPowers (I.map (Ideal.Quotient.mk J)))
(hm : DividedPowers.IsDPMorphism hI hquot (Ideal.Quotient.mk J)) :
hquot = dividedPowers hI hIJ :=
DividedPowers.Quotient.OfSurjective.dividedPowers_unique
hI Ideal.Quotient.mk_surjective (refl _) (isSubDPIdeal_aux hI hIJ) hquot hm
end Quotient
end Quotient
end DividedPowers |
.lake/packages/mathlib/Mathlib/RingTheory/DividedPowers/DPMorphism.lean | import Mathlib.RingTheory.DividedPowers.Basic
/-! # Divided power morphisms
Let `A` and `B` be commutative (semi)rings, let `I` be an ideal of `A` and let `J` be an ideal of
`B`. Given divided power structures on `I` and `J`, a ring morphism `A →+* B` is a *divided
power morphism* if it is compatible with these divided power structures.
## Main definitions
* `DividedPowers.IsDPMorphism` : given divided power structures on the `A`-ideal `I` and the
`B`-ideal `J`, a ring morphism `A →+* B` is a divided power morphism if it is compatible with
these divided power structures.
* `DividedPowers.DPMorphism` : a bundled version of `IsDPMorphism`.
* `DividedPowers.ideal_from_ringHom` : given a ring homomorphism `A →+* B` and ideals `I ⊆ A` and
`J ⊆ B` such that `I.map f ≤ J`, this is the `A`-ideal on which
`f (hI.dpow n x) = hJ.dpow n (f x)`.
* `DividedPowers.DPMorphism.fromGens` : the `DPMorphism` induced by a ring morphism, given that
divided powers are compatible on a generating set.
## Main results
* `DividedPowers.dpow_eq_from_gens` : if two divided power structures on an ideal `I` agree on a
generating set, then they are equal.
## Implementation remarks
We provided both a bundled and an unbundled definition of divided power morphisms. For developing
the basic theory, the unbundled version `IsDPMorphism` is more convenient. However, we anticipate
that the bundled version `DPMorphism` will be better for the development of crystalline
cohomology.
## References
* [P. Berthelot, *Cohomologie cristalline des schémas de
caractéristique $p$ > 0*][Berthelot-1974]
* [P. Berthelot and A. Ogus, *Notes on crystalline
cohomology*][BerthelotOgus-1978]
* [N. Roby, *Lois polynomes et lois formelles en théorie des
modules*][Roby-1963]
* [N. Roby, *Les algèbres à puissances dividées*][Roby-1965]
-/
open Ideal Set SetLike
namespace DividedPowers
/-- Given divided power structures on the `A`-ideal `I` and the `B`-ideal `J`, a ring morphism
`A → B` is a divided power morphism if it is compatible with these divided power structures. -/
structure IsDPMorphism {A B : Type*} [CommSemiring A] [CommSemiring B] {I : Ideal A} {J : Ideal B}
(hI : DividedPowers I) (hJ : DividedPowers J) (f : A →+* B) : Prop where
ideal_comp : I.map f ≤ J
dpow_comp : ∀ {n : ℕ}, ∀ a ∈ I, hJ.dpow n (f a) = f (hI.dpow n a)
variable {A B : Type*} [CommSemiring A] [CommSemiring B] {I : Ideal A} {J : Ideal B}
(hI : DividedPowers I) (hJ : DividedPowers J)
lemma isDPMorphism_def (f : A →+* B) :
IsDPMorphism hI hJ f ↔ I.map f ≤ J ∧ ∀ {n}, ∀ a ∈ I, hJ.dpow n (f a) = f (hI.dpow n a) :=
⟨fun h ↦ ⟨h.ideal_comp, h.dpow_comp⟩, fun ⟨h1, h2⟩ ↦ IsDPMorphism.mk h1 h2⟩
lemma isDPMorphism_iff (f : A →+* B) :
IsDPMorphism hI hJ f ↔ I.map f ≤ J ∧ ∀ n ≠ 0, ∀ a ∈ I, hJ.dpow n (f a) = f (hI.dpow n a) := by
rw [isDPMorphism_def, and_congr_right_iff]
refine fun hIJ ↦ ⟨fun H n _ ↦ H, fun H n ↦ ?_⟩
by_cases hn : n = 0
· intro _ ha
rw [hn, hI.dpow_zero ha, hJ.dpow_zero (hIJ (mem_map_of_mem f ha)), map_one]
· exact H n hn
namespace IsDPMorphism
variable {hI hJ} {C : Type*} [CommSemiring C] {K : Ideal C} (hK : DividedPowers K)
theorem map_dpow {f : A →+* B} (hf : IsDPMorphism hI hJ f) {n : ℕ} {a : A} (ha : a ∈ I) :
f (hI.dpow n a) = hJ.dpow n (f a) := (hf.2 a ha).symm
theorem comp {f : A →+* B} {g : B →+* C} (hg : IsDPMorphism hJ hK g) (hf : IsDPMorphism hI hJ f) :
IsDPMorphism hI hK (g.comp f) := by
refine ⟨le_trans (map_map f g ▸ map_mono hf.1) hg.1, fun a ha ↦ ?_⟩
simp only [RingHom.coe_comp, Function.comp_apply]
rw [← hf.2 a ha, hg.2]
exact hf.1 (mem_map_of_mem f ha)
end IsDPMorphism
/-- A bundled divided power morphism between rings endowed with divided power structures. -/
@[ext]
structure DPMorphism {A B : Type*} [CommSemiring A] [CommSemiring B] {I : Ideal A} {J : Ideal B}
(hI : DividedPowers I) (hJ : DividedPowers J) extends RingHom A B where
ideal_comp : I.map toRingHom ≤ J
dpow_comp : ∀ {n : ℕ}, ∀ a ∈ I, hJ.dpow n (toRingHom a) = toRingHom (hI.dpow n a)
namespace DPMorphism
variable {A B : Type*} [CommSemiring A] [CommSemiring B] {I : Ideal A} {J : Ideal B}
(hI : DividedPowers I) (hJ : DividedPowers J)
instance instFunLike : FunLike (DPMorphism hI hJ) A B where
coe h := h.toRingHom
coe_injective' h h' hh' := by
cases h; cases h'; congr
dsimp at hh'; ext; rw [hh']
instance coe_ringHom : CoeOut (DPMorphism hI hJ) (A →+* B) := ⟨DPMorphism.toRingHom⟩
@[simp] theorem coe_toRingHom {f : DPMorphism hI hJ} : ⇑(f : A →+* B) = f := rfl
@[simp] lemma toRingHom_apply {f : DPMorphism hI hJ} {a : A} : f.toRingHom a = f a := rfl
variable {hI hJ}
lemma isDPMorphism (f : DPMorphism hI hJ) : IsDPMorphism hI hJ f.toRingHom :=
⟨f.ideal_comp, f.dpow_comp⟩
/-- A constructor for `DPMorphism` from a ring homomorphism `f : A →+* B` satisfying
`IsDPMorphism hI hJ f`. -/
def mk' {f : A →+* B} (hf : IsDPMorphism hI hJ f) : DPMorphism hI hJ :=
⟨f, hf.1, hf.2⟩
variable (hI hJ)
/-- Given a ring homomorphism `A → B` and ideals `I ⊆ A` and `J ⊆ B` such that `I.map f ≤ J`,
this is the `A`-ideal on which `f (hI.dpow n x) = hJ.dpow n (f x)`.
See [N. Roby, *Les algèbres à puissances dividées* (Proposition 2)][Roby-1965]. -/
def _root_.DividedPowers.ideal_from_ringHom {f : A →+* B} (hf : I.map f ≤ J) : Ideal A where
carrier := {x ∈ I | ∀ n : ℕ, f (hI.dpow n (x : A)) = hJ.dpow n (f (x : A))}
add_mem' := fun hx hy ↦ by
simp only [mem_setOf_eq, map_add] at hx hy ⊢
refine ⟨I.add_mem hx.1 hy.1, fun n ↦ ?_⟩
rw [hI.dpow_add hx.1 hy.1, map_sum,
hJ.dpow_add (hf (mem_map_of_mem f hx.1)) (hf (mem_map_of_mem f hy.1))]
apply congr_arg
ext k
rw [map_mul, hx.2, hy.2]
zero_mem' := by
simp only [mem_setOf_eq, Submodule.zero_mem, map_zero, true_and]
intro n
induction n with
| zero => rw [hI.dpow_zero I.zero_mem, hJ.dpow_zero J.zero_mem, map_one]
| succ n => rw [hI.dpow_eval_zero n.succ_ne_zero, hJ.dpow_eval_zero n.succ_ne_zero, map_zero]
smul_mem' := fun r x hx ↦ by
refine ⟨I.smul_mem r hx.1, (fun n ↦ ?_)⟩
rw [smul_eq_mul, hI.dpow_mul hx.1, map_mul, map_mul, map_pow,
hJ.dpow_mul (hf (mem_map_of_mem f hx.1)), hx.2 n]
/-- The `DPMorphism` induced by a ring morphism, given that divided powers are compatible on a
generating set.
See [N. Roby, *Les algèbres à puissances dividées* (Proposition 3)][Roby-1965]. -/
def fromGens {f : A →+* B} {S : Set A} (hS : I = span S) (hf : I.map f ≤ J)
(h : ∀ {n : ℕ}, ∀ x ∈ S, f (hI.dpow n x) = hJ.dpow n (f x)) : DPMorphism hI hJ where
toRingHom := f
ideal_comp := hf
dpow_comp {n} x hx := by
have hS' : S ⊆ ideal_from_ringHom hI hJ hf := fun y hy ↦ by
simp only [mem_coe, ideal_from_ringHom, Submodule.mem_mk]
exact ⟨hS ▸ subset_span hy, fun n => h y hy⟩
rw [← span_le, ← hS] at hS'
exact ((hS' hx).2 n).symm
/-- The identity map as a `DPMorphism`. -/
def id : DPMorphism hI hI where
toRingHom := RingHom.id A
ideal_comp := by simp only [map_id, le_refl]
dpow_comp _ _ := by simp only [RingHom.id_apply]
instance : Inhabited (DPMorphism hI hI) := ⟨DPMorphism.id hI⟩
theorem fromGens_coe {f : A →+* B} {S : Set A} (hS : I = span S) (hf : I.map f ≤ J)
(h : ∀ {n : ℕ}, ∀ x ∈ S, f (hI.dpow n x) = hJ.dpow n (f x)) :
(fromGens hI hJ hS hf h).toRingHom = f := rfl
end DPMorphism
namespace IsDPMorphism
variable {A B C : Type*} [CommSemiring A] [CommSemiring B] [CommSemiring C] {I : Ideal A}
{J : Ideal B} {K : Ideal C} (hI : DividedPowers I) (hJ : DividedPowers J) (hK : DividedPowers K)
open DPMorphism
theorem on_span {f : A →+* B} {S : Set A} (hS : I = span S) (hS' : ∀ s ∈ S, f s ∈ J)
(hdp : ∀ {n : ℕ}, ∀ a ∈ S, f (hI.dpow n a) = hJ.dpow n (f a)) : IsDPMorphism hI hJ f := by
suffices h : I.map f ≤ J by
exact ⟨h, fun a ha ↦ by
rw [← fromGens_coe hI hJ hS h hdp, (fromGens hI hJ hS h hdp).dpow_comp a ha]⟩
rw [hS, map_span, span_le]
rintro b ⟨a, has, rfl⟩
exact hS' a has
theorem of_comp (f : A →+* B) (g : B →+* C) (heq : J = I.map f) (hf : IsDPMorphism hI hJ f)
(hh : IsDPMorphism hI hK (g.comp f)) : IsDPMorphism hJ hK g := by
apply on_span _ _ heq
· rintro b ⟨a, ha, rfl⟩
rw [← RingHom.comp_apply]
exact hh.1 (mem_map_of_mem _ ha)
· rintro n b ⟨a, ha, rfl⟩
rw [← RingHom.comp_apply, hh.2 a ha, RingHom.comp_apply, hf.2 a ha]
end IsDPMorphism
namespace DPMorphism
variable {A B C : Type*} [CommSemiring A] [CommSemiring B] [CommSemiring C] {I : Ideal A}
{J : Ideal B} {K : Ideal C} {hI : DividedPowers I} {hJ : DividedPowers J} {hK : DividedPowers K}
/-- The composition of two divided power morphisms as a `DPMorphism`. -/
protected def comp (g : DPMorphism hJ hK) (f : DPMorphism hI hJ) :
DPMorphism hI hK :=
mk' (IsDPMorphism.comp hK g.isDPMorphism f.isDPMorphism)
@[simp] lemma comp_toRingHom (g : DPMorphism hJ hK) (f : DPMorphism hI hJ) :
(g.comp f).toRingHom = g.toRingHom.comp f.toRingHom := rfl
end DPMorphism
section Uniqueness
variable {A B : Type*} [CommSemiring A] [CommSemiring B] {I : Ideal A} {J : Ideal B}
(hI hI' : DividedPowers I) (hJ : DividedPowers J) {f : A →+* B}
theorem dpow_comp_from_gens {S : Set A} (hS : I = span S) (hS' : ∀ s ∈ S, f s ∈ J)
(hdp : ∀ {n : ℕ}, ∀ a ∈ S, f (hI.dpow n a) = hJ.dpow n (f a)) :
∀ {n}, ∀ a ∈ I, hJ.dpow n (f a) = f (hI.dpow n a) :=
(IsDPMorphism.on_span hI hJ hS hS' hdp).2
/-- If two divided power structures on the ideal `I` agree on a generating set, then they are
equal.
See [N. Roby, *Les algèbres à puissances dividées* (Corollary to Proposition 3)][Roby-1965]. -/
theorem dpow_eq_from_gens {S : Set A} (hS : I = span S)
(hdp : ∀ {n : ℕ}, ∀ a ∈ S, hI.dpow n a = hI'.dpow n a) : hI' = hI := by
ext n a
by_cases ha : a ∈ I
· refine hI.dpow_comp_from_gens hI' (f := RingHom.id A) hS ?_ ?_ a ha
· intro s hs
simp only [RingHom.id_apply, hS]
exact subset_span hs
· intro m b hb
simpa only [RingHom.id_apply] using (hdp b hb)
· rw [hI.dpow_null ha, hI'.dpow_null ha]
end Uniqueness
end DividedPowers |
.lake/packages/mathlib/Mathlib/RingTheory/DividedPowers/Basic.lean | import Mathlib.RingTheory.PowerSeries.Basic
import Mathlib.Combinatorics.Enumerative.Bell
import Mathlib.Data.Nat.Choose.Multinomial
import Mathlib.RingTheory.Ideal.Maps
/-! # Divided powers
Let `A` be a commutative (semi)ring and `I` be an ideal of `A`.
A *divided power* structure on `I` is the datum of operations `a n ↦ dpow a n`
satisfying relations that model the intuitive formula `dpow n a = a ^ n / n !` and
collected by the structure `DividedPowers`. The list of axioms is embedded in the structure:
To avoid coercions, we rather consider `DividedPowers.dpow : ℕ → A → A`, extended by 0.
* `DividedPowers.dpow_null` asserts that `dpow n x = 0` for `x ∉ I`
* `DividedPowers.dpow_mem` : `dpow n x ∈ I` for `n ≠ 0`
For `x y : A` and `m n : ℕ` such that `x ∈ I` and `y ∈ I`, one has
* `DividedPowers.dpow_zero` : `dpow 0 x = 1`
* `DividedPowers.dpow_one` : `dpow 1 x = 1`
* `DividedPowers.dpow_add` :
`dpow n (x + y) = (antidiagonal n).sum fun k ↦ dpow k.1 x * dpow k.2 y`,
this is the binomial theorem without binomial coefficients.
* `DividedPowers.dpow_mul`: `dpow n (a * x) = a ^ n * dpow n x`
* `DividedPowers.mul_dpow` : `dpow m x * dpow n x = choose (m + n) m * dpow (m + n) x`
* `DividedPowers.dpow_comp` : `dpow m (dpow n x) = uniformBell m n * dpow (m * n) x`
* `DividedPowers.dividedPowersBot` : the trivial divided powers structure on the zero ideal
* `DividedPowers.prod_dpow`: a product of divided powers is a multinomial coefficient
times a divided power
* `DividedPowers.dpow_sum`: the multinomial theorem for divided powers,
without multinomial coefficients.
* `DividedPowers.ofRingEquiv`: transfer divided powers along `RingEquiv`
* `DividedPowers.equiv`: the equivalence `DividedPowers I ≃ DividedPowers J`,
for `e : R ≃+* S`, and `I : Ideal R`, `J : Ideal S` such that `I.map e = J`
* `DividedPowers.exp`: the power series `Σ (dpow n a) X ^n`
* `DividedPowers.exp_add`: its multiplicativity
## References
* [P. Berthelot (1974), *Cohomologie cristalline des schémas de
caractéristique $p$ > 0*][Berthelot-1974]
* [P. Berthelot and A. Ogus (1978), *Notes on crystalline
cohomology*][BerthelotOgus-1978]
* [N. Roby (1963), *Lois polynomes et lois formelles en théorie des
modules*][Roby-1963]
* [N. Roby (1965), *Les algèbres à puissances dividées*][Roby-1965]
## Discussion
* In practice, one often has a single such structure to handle on a given ideal,
but several ideals of the same ring might be considered.
Without any explicit mention of the ideal, it is not clear whether such structures
should be provided as instances.
* We do not provide any notation such as `a ^[n]` for `dpow a n`.
-/
open Finset Nat Ideal
section DividedPowersDefinition
/- ## Definition of divided powers -/
variable {A : Type*} [CommSemiring A] (I : Ideal A)
/-- The divided power structure on an ideal I of a commutative ring A -/
structure DividedPowers where
/-- The divided power function underlying a divided power structure -/
dpow : ℕ → A → A
dpow_null : ∀ {n x} (_ : x ∉ I), dpow n x = 0
dpow_zero : ∀ {x} (_ : x ∈ I), dpow 0 x = 1
dpow_one : ∀ {x} (_ : x ∈ I), dpow 1 x = x
dpow_mem : ∀ {n x} (_ : n ≠ 0) (_ : x ∈ I), dpow n x ∈ I
dpow_add : ∀ {n} {x y} (_ : x ∈ I) (_ : y ∈ I),
dpow n (x + y) = (antidiagonal n).sum fun k ↦ dpow k.1 x * dpow k.2 y
dpow_mul : ∀ {n} {a : A} {x} (_ : x ∈ I),
dpow n (a * x) = a ^ n * dpow n x
mul_dpow : ∀ {m n} {x} (_ : x ∈ I),
dpow m x * dpow n x = choose (m + n) m * dpow (m + n) x
dpow_comp : ∀ {m n x} (_ : n ≠ 0) (_ : x ∈ I),
dpow m (dpow n x) = uniformBell m n * dpow (m * n) x
variable (A) in
/-- The canonical `DividedPowers` structure on the zero ideal -/
noncomputable def dividedPowersBot : DividedPowers (⊥ : Ideal A) where
dpow n a := open Classical in ite (a = 0 ∧ n = 0) 1 0
dpow_null {n a} ha := by
simp only [mem_bot] at ha
rw [if_neg]
exact not_and_of_not_left (n = 0) ha
dpow_zero ha := by
rw [mem_bot.mp ha]
simp only [and_self, ite_true]
dpow_one ha := by
simp [mem_bot.mp ha]
dpow_mem {n a} hn _ := by
simp only [mem_bot, ite_eq_right_iff, and_imp]
exact fun _ a ↦ False.elim (hn a)
dpow_add ha hb := by
rw [mem_bot.mp ha, mem_bot.mp hb, add_zero]
simp only [true_and, mul_ite, mul_one, mul_zero]
split_ifs with h
· simp [h]
· symm
apply sum_eq_zero
grind [mem_antidiagonal]
dpow_mul {n} _ _ hx := by
rw [mem_bot.mp hx]
simp only [mul_zero, true_and, mul_ite, mul_one]
by_cases hn : n = 0
· rw [if_pos hn, hn, if_pos rfl, _root_.pow_zero]
· simp only [if_neg hn]
mul_dpow {m n x} hx := by
rw [mem_bot.mp hx]
simp only [true_and, mul_ite, mul_one, mul_zero, add_eq_zero]
by_cases hn : n = 0
· simp only [hn, ite_true, and_true, add_zero, choose_self, cast_one]
· rw [if_neg hn, if_neg]
exact not_and_of_not_right (m = 0) hn
dpow_comp m {n a} hn ha := by
rw [mem_bot.mp ha]
simp only [true_and, ite_eq_right_iff, _root_.mul_eq_zero, mul_ite, mul_one, mul_zero]
by_cases hm : m = 0
· simp [hm, uniformBell_zero_left, hn]
· simp only [hm, and_false, ite_false, false_or, if_neg hn]
lemma dividedPowersBot_dpow_eq [DecidableEq A] (n : ℕ) (a : A) :
(dividedPowersBot A).dpow n a =
if a = 0 ∧ n = 0 then 1 else 0 := by
simp [dividedPowersBot]
noncomputable instance : Inhabited (DividedPowers (⊥ : Ideal A)) :=
⟨dividedPowersBot A⟩
/-- The coercion from the divided powers structures to functions -/
instance : CoeFun (DividedPowers I) fun _ ↦ ℕ → A → A := ⟨fun hI ↦ hI.dpow⟩
variable {I} in
@[ext]
theorem DividedPowers.ext (hI : DividedPowers I) (hI' : DividedPowers I)
(h_eq : ∀ (n : ℕ) {x : A} (_ : x ∈ I), hI.dpow n x = hI'.dpow n x) :
hI = hI' := by
obtain ⟨hI, h₀, _⟩ := hI
obtain ⟨hI', h₀', _⟩ := hI'
simp only [mk.injEq]
grind
theorem DividedPowers.coe_injective :
Function.Injective (fun (h : DividedPowers I) ↦ (h : ℕ → A → A)) := fun hI hI' h ↦ by
ext n x
exact congr_fun (congr_fun h n) x
end DividedPowersDefinition
namespace DividedPowers
section BasicLemmas
/- ## Basic lemmas for divided powers -/
variable {A : Type*} [CommSemiring A] {I : Ideal A} {a b : A}
/-- Variant of `DividedPowers.dpow_add` with a sum on `range (n + 1)` -/
theorem dpow_add' (hI : DividedPowers I) {n : ℕ} (ha : a ∈ I) (hb : b ∈ I) :
hI.dpow n (a + b) = (range (n + 1)).sum fun k ↦ hI.dpow k a * hI.dpow (n - k) b := by
rw [hI.dpow_add ha hb, sum_antidiagonal_eq_sum_range_succ_mk]
/-- The exponential series of an element in the context of divided powers,
`Σ (dpow n a) X ^ n` -/
def exp (hI : DividedPowers I) (a : A) : PowerSeries A :=
PowerSeries.mk fun n ↦ hI.dpow n a
/-- A more general of `DividedPowers.exp_add` -/
theorem exp_add' (dp : ℕ → A → A)
(dp_add : ∀ n, dp n (a + b) = (antidiagonal n).sum fun k ↦ dp k.1 a * dp k.2 b) :
PowerSeries.mk (fun n ↦ dp n (a + b)) =
(PowerSeries.mk fun n ↦ dp n a) * (PowerSeries.mk fun n ↦ dp n b) := by
ext n
simp only [PowerSeries.coeff_mk, PowerSeries.coeff_mul, dp_add n,
sum_antidiagonal_eq_sum_range_succ_mk]
theorem exp_add (hI : DividedPowers I) (ha : a ∈ I) (hb : b ∈ I) :
hI.exp (a + b) = hI.exp a * hI.exp b :=
exp_add' _ (fun _ ↦ hI.dpow_add ha hb)
variable (hI : DividedPowers I)
/- ## Rewriting lemmas -/
theorem dpow_smul {n : ℕ} (ha : a ∈ I) :
hI.dpow n (b • a) = b ^ n • hI.dpow n a := by
simp only [smul_eq_mul, hI.dpow_mul, ha]
theorem dpow_mul_right {n : ℕ} (ha : a ∈ I) :
hI.dpow n (a * b) = hI.dpow n a * b ^ n := by
rw [mul_comm, hI.dpow_mul ha, mul_comm]
theorem dpow_smul_right {n : ℕ} (ha : a ∈ I) :
hI.dpow n (a • b) = hI.dpow n a • b ^ n := by
rw [smul_eq_mul, hI.dpow_mul_right ha, smul_eq_mul]
theorem factorial_mul_dpow_eq_pow {n : ℕ} (ha : a ∈ I) :
(n ! : A) * hI.dpow n a = a ^ n := by
induction n with
| zero => rw [factorial_zero, cast_one, one_mul, pow_zero, hI.dpow_zero ha]
| succ n ih =>
rw [factorial_succ, mul_comm (n + 1)]
nth_rewrite 1 [← (n + 1).choose_one_right]
rw [← choose_symm_add, cast_mul, mul_assoc,
← hI.mul_dpow ha, ← mul_assoc, ih, hI.dpow_one ha, pow_succ, mul_comm]
theorem dpow_eval_zero {n : ℕ} (hn : n ≠ 0) : hI.dpow n 0 = 0 := by
rw [← MulZeroClass.mul_zero (0 : A), hI.dpow_mul I.zero_mem,
zero_pow hn, zero_mul, zero_mul]
/-- If an element of a divided power ideal is killed by multiplication
by some nonzero integer `n`, then its `n`th power is zero.
Proposition 1.2.7 of [Berthelot-1974], part (i). -/
theorem nilpotent_of_mem_dpIdeal {n : ℕ} (hn : n ≠ 0) (hnI : ∀ {y}, y ∈ I → n • y = 0)
(hI : DividedPowers I) (ha : a ∈ I) : a ^ n = 0 := by
have h_fac : (n ! : A) * hI.dpow n a = n • ((n - 1)! : A) * hI.dpow n a := by
rw [nsmul_eq_mul, ← cast_mul, mul_factorial_pred hn]
rw [← hI.factorial_mul_dpow_eq_pow ha, h_fac, smul_mul_assoc]
exact hnI (I.mul_mem_left ((n - 1)! : A) (hI.dpow_mem hn ha))
/-- If J is another ideal of A with divided powers,
then the divided powers of I and J coincide on I • J
[Berthelot-1974], 1.6.1 (ii) -/
theorem coincide_on_smul {J : Ideal A} (hJ : DividedPowers J) {n : ℕ} (ha : a ∈ I • J) :
hI.dpow n a = hJ.dpow n a := by
induction ha using Submodule.smul_induction_on' generalizing n with
| smul a ha b hb =>
rw [Algebra.id.smul_eq_mul, hJ.dpow_mul hb, mul_comm a b, hI.dpow_mul ha,
← hJ.factorial_mul_dpow_eq_pow hb, ← hI.factorial_mul_dpow_eq_pow ha]
ring
| add x hx y hy hx' hy' =>
rw [hI.dpow_add (mul_le_right hx) (mul_le_right hy),
hJ.dpow_add (mul_le_left hx) (mul_le_left hy)]
apply sum_congr rfl
intro k _
rw [hx', hy']
/-- A product of divided powers is a multinomial coefficient times the divided power
[Roby-1965], formula (III') -/
theorem prod_dpow {ι : Type*} {s : Finset ι} {n : ι → ℕ} (ha : a ∈ I) :
(s.prod fun i ↦ hI.dpow (n i) a) = multinomial s n * hI.dpow (s.sum n) a := by
classical
induction s using Finset.induction with
| empty =>
simp only [prod_empty, multinomial_empty, cast_one, sum_empty, one_mul]
rw [hI.dpow_zero ha]
| insert _ _ hi hrec =>
rw [prod_insert hi, hrec, ← mul_assoc, mul_comm (hI.dpow (n _) a),
mul_assoc, hI.mul_dpow ha, ← sum_insert hi, ← mul_assoc]
apply congr_arg₂ _ _ rfl
rw [multinomial_insert hi, mul_comm, cast_mul, sum_insert hi]
-- TODO : can probably be simplified using `DividedPowers.exp`
/-- Lemma towards `dpow_sum` when we only have partial information on a divided power ideal -/
theorem dpow_sum' {M : Type*} [AddCommMonoid M] {I : AddSubmonoid M} (dpow : ℕ → M → A)
(dpow_zero : ∀ {x}, x ∈ I → dpow 0 x = 1)
(dpow_add : ∀ {n x y}, x ∈ I → y ∈ I →
dpow n (x + y) = (antidiagonal n).sum fun k ↦ dpow k.1 x * dpow k.2 y)
(dpow_eval_zero : ∀ {n : ℕ}, n ≠ 0 → dpow n 0 = 0)
{ι : Type*} [DecidableEq ι] {s : Finset ι} {x : ι → M} (hx : ∀ i ∈ s, x i ∈ I) {n : ℕ} :
dpow n (s.sum x) = (s.sym n).sum fun k ↦ s.prod fun i ↦ dpow (Multiset.count i k) (x i) := by
simp only [sum_antidiagonal_eq_sum_range_succ_mk] at dpow_add
induction s using Finset.induction generalizing n with
| empty =>
simp only [sum_empty, prod_empty, sum_const, nsmul_eq_mul, mul_one]
by_cases hn : n = 0
· rw [hn]
rw [dpow_zero I.zero_mem]
simp only [sym_zero, card_singleton, cast_one]
· rw [dpow_eval_zero hn, eq_comm, ← cast_zero]
apply congr_arg
rw [card_eq_zero, sym_eq_empty]
exact ⟨hn, rfl⟩
| insert a s ha ih =>
-- This should be golfable using `Finset.symInsertEquiv`
have hx' : ∀ i, i ∈ s → x i ∈ I := fun i hi ↦ hx i (mem_insert_of_mem hi)
simp_rw [sum_insert ha,
dpow_add (hx a (mem_insert_self a s)) (I.sum_mem fun i ↦ hx' i),
sum_range, ih hx', mul_sum, sum_sigma', eq_comm]
apply sum_bij'
(fun m _ ↦ m.filterNe a)
(fun m _ ↦ m.2.fill a m.1)
(fun m hm ↦ mem_sigma.2 ⟨mem_univ _, _⟩)
(fun m hm ↦ by
simp only [succ_eq_add_one, mem_sym_iff, mem_insert, Sym.mem_fill_iff]
simp only [mem_sigma, mem_univ, mem_sym_iff, true_and] at hm
intro b
apply Or.imp (fun h ↦ h.2) (fun h ↦ hm b h))
(fun m _ ↦ m.fill_filterNe a)
· intro m hm
simp only [mem_sigma, mem_univ, mem_sym_iff, true_and] at hm
exact Sym.filter_ne_fill a m fun a_1 ↦ ha (hm a a_1)
· intro m hm
simp only [mem_sym_iff, mem_insert] at hm
rw [prod_insert ha]
apply congr_arg₂ _ rfl
apply prod_congr rfl
intro i hi
apply congr_arg₂ _ _ rfl
conv_lhs => rw [← m.fill_filterNe a]
exact Sym.count_coe_fill_of_ne (ne_of_mem_of_not_mem hi ha)
· intro m hm
convert sym_filterNe_mem a hm
rw [erase_insert ha]
/-- A “multinomial” theorem for divided powers — without multinomial coefficients -/
theorem dpow_sum {ι : Type*} [DecidableEq ι] {s : Finset ι} {x : ι → A}
(hx : ∀ i ∈ s, x i ∈ I) {n : ℕ} :
hI.dpow n (s.sum x) =
(s.sym n).sum fun k ↦ s.prod fun i ↦ hI.dpow (Multiset.count i k) (x i) :=
dpow_sum' hI.dpow hI.dpow_zero hI.dpow_add hI.dpow_eval_zero hx
end BasicLemmas
section Equiv
/- ## Relation of divided powers with ring equivalences -/
variable {A B : Type*} [CommSemiring A] {I : Ideal A} [CommSemiring B] {J : Ideal B}
{e : A ≃+* B} (h : I.map e = J)
/-- Transfer divided powers under an equivalence -/
def ofRingEquiv (hI : DividedPowers I) : DividedPowers J where
dpow n b := e (hI.dpow n (e.symm b))
dpow_null hx := by
rw [EmbeddingLike.map_eq_zero_iff, hI.dpow_null]
rwa [symm_apply_mem_of_equiv_iff, h]
dpow_zero hx := by
rw [EmbeddingLike.map_eq_one_iff, hI.dpow_zero]
rwa [symm_apply_mem_of_equiv_iff, h]
dpow_one hx := by
rw [dpow_one, RingEquiv.apply_symm_apply]
rwa [I.symm_apply_mem_of_equiv_iff, h]
dpow_mem hn hx := by
rw [← h, I.apply_mem_of_equiv_iff]
apply hI.dpow_mem hn
rwa [I.symm_apply_mem_of_equiv_iff, h]
dpow_add hx hy := by
simp only [map_add]
rw [hI.dpow_add (symm_apply_mem_of_equiv_iff.mpr (h ▸ hx))
(symm_apply_mem_of_equiv_iff.mpr (h ▸ hy))]
simp only [map_sum, map_mul]
dpow_mul hx := by
simp only [map_mul]
rw [hI.dpow_mul (symm_apply_mem_of_equiv_iff.mpr (h ▸ hx))]
rw [map_mul, map_pow]
simp only [RingEquiv.apply_symm_apply]
mul_dpow hx := by
rw [← map_mul, hI.mul_dpow, map_mul]
· simp only [map_natCast]
· rwa [symm_apply_mem_of_equiv_iff, h]
dpow_comp hn hx := by
simp only [RingEquiv.symm_apply_apply]
rw [hI.dpow_comp hn]
· simp only [map_mul, map_natCast]
· rwa [symm_apply_mem_of_equiv_iff, h]
@[simp]
theorem ofRingEquiv_dpow (hI : DividedPowers I) {n : ℕ} {b : B} :
(ofRingEquiv h hI).dpow n b = e (hI.dpow n (e.symm b)) := rfl
theorem ofRingEquiv_dpow_apply (hI : DividedPowers I) {n : ℕ} {a : A} :
(ofRingEquiv h hI).dpow n (e a) = e (hI.dpow n a) := by
simp
/-- Transfer divided powers under an equivalence (Equiv version) -/
def equiv : DividedPowers I ≃ DividedPowers J where
toFun := ofRingEquiv h
invFun := ofRingEquiv (show map e.symm J = I by rw [← h]; exact I.map_of_equiv e)
left_inv := fun hI ↦ by ext n a; simp [ofRingEquiv]
right_inv := fun hJ ↦ by ext n b; simp [ofRingEquiv]
theorem equiv_apply (hI : DividedPowers I) (n : ℕ) (b : B) :
(equiv h hI).dpow n b = e (hI.dpow n (e.symm b)) := rfl
/-- Variant of `DividedPowers.equiv_apply` -/
theorem equiv_apply' (hI : DividedPowers I) {n : ℕ} {a : A} :
(equiv h hI).dpow n (e a) = e (hI.dpow n a) :=
ofRingEquiv_dpow_apply h hI
end Equiv
end DividedPowers |
.lake/packages/mathlib/Mathlib/RingTheory/DividedPowers/Padic.lean | import Mathlib.NumberTheory.Padics.PadicIntegers
import Mathlib.RingTheory.DividedPowers.RatAlgebra
/-! # Divided powers on ℤ_[p]
Given a divided power algebra `(B, J, δ)` and an injective ring morphism `f : A →+* B`, if `I` is
an `A`-ideal such that `I.map f = J` and such that for all `n : ℕ`, `x ∈ I`, the preimage of
`hJ.dpow n (f x)` under `f` belongs to `I`, we get an induced divided power structure on `I`.
We specialize this construction to the coercion map `ℤ_[p] →+* ℚ_[p]` to get a divided power
structure on the ideal `(p) ⊆ ℤ_[p]`. This divided power structure is given by the family of maps
`fun n x ↦ x^n / n!`.
TODO: If `K` is a `p`-adic local field with ring of integers `R` and uniformizer `π` such that
`p = u * π^e` for some unit `u`, then the ideal `(π) ⊆ R` has divided powers if and only if
`e ≤ p - 1`.
-/
namespace PadicInt
open DividedPowers DividedPowers.OfInvertibleFactorial Nat Ring
variable (p : ℕ) [hp : Fact p.Prime]
section Injective
open Function
variable {A B : Type*} [CommSemiring A] [CommSemiring B] (I : Ideal A) (J : Ideal B)
/-- Given a divided power algebra `(B, J, δ)` and an injective ring morphism `f : A →+* B`, if `I`
is an `A`-ideal such that `I.map f = J` and such that for all `n : ℕ`, `x ∈ I`, the preimage of
`hJ.dpow n (f x)` under `f` belongs to `I`, this is the induced divided power structure on `I`. -/
noncomputable def dividedPowers_of_injective (f : A →+* B) (hf : Injective f)
(hJ : DividedPowers J) (hIJ : I.map f = J)
(hmem : ∀ (n : ℕ) {x : A} (_ : x ∈ I), ∃ (y : A) (_ : n ≠ 0 → y ∈ I), f y = hJ.dpow n (f x)) :
DividedPowers I where
dpow n x := open Classical in if hx : x ∈ I then Exists.choose (hmem n hx) else 0
dpow_null hx := by simp [dif_neg hx]
dpow_zero {x} hx := by
simp only [dif_pos hx, ← hf.eq_iff, (Exists.choose_spec (hmem 0 hx)).2, map_one]
rw [hJ.dpow_zero (hIJ ▸ Ideal.mem_map_of_mem f hx)]
dpow_one hx := by
simpa only [dif_pos hx, ← hf.eq_iff, (Exists.choose_spec (_ : ∃ a, ∃ _, f a = _)).2]
using hJ.dpow_one (hIJ ▸ Ideal.mem_map_of_mem f hx)
dpow_mem {n x} hn hx := by simpa only [dif_pos hx] using (Exists.choose_spec (hmem n hx)).1 hn
dpow_add {n x y} hx hy := by
have hxy : x + y ∈ I := Ideal.add_mem _ hx hy
simpa only [dif_pos hxy, dif_pos hx, dif_pos hy, ← hf.eq_iff, map_sum, map_mul,
(Exists.choose_spec (_ : ∃ a, ∃ _, f a = _)).2, map_add]
using hJ.dpow_add (hIJ ▸ I.mem_map_of_mem f hx) (hIJ ▸ I.mem_map_of_mem f hy)
dpow_mul {n a x} hx := by
have hax : a * x ∈ I := Ideal.mul_mem_left _ _ hx
simpa only [(Exists.choose_spec (_ : ∃ a, ∃ _, f a = _)).2, dif_pos hax, dif_pos hx,
← hf.eq_iff, map_mul, map_pow] using hJ.dpow_mul (hIJ ▸ I.mem_map_of_mem f hx)
mul_dpow hx := by simpa only [dif_pos hx, ← hf.eq_iff, (Exists.choose_spec (hmem _ hx)).2,
map_mul, map_natCast] using hJ.mul_dpow (hIJ ▸ I.mem_map_of_mem f hx)
dpow_comp {n m x} hm hx := by
simp only [dif_pos hx, ← hf.eq_iff, map_mul, map_natCast]
-- the condition for the other `dif_pos` is a bit messy so we use `rw` to
-- spin it off into a separate branch
rw [dif_pos]
· simp only [(Exists.choose_spec (_ : ∃ a, ∃ _, f a = _)).2]
exact hJ.dpow_comp hm (hIJ ▸ I.mem_map_of_mem f hx)
· rw [dif_pos hx]
exact (Exists.choose_spec (hmem m hx)).1 hm
end Injective
section Padic
/-- The family `ℕ → ℚ_[p] → ℚ_[p]` given by `dpow n x = x ^ n / n!`. -/
private noncomputable def dpow' : ℕ → ℚ_[p] → ℚ_[p] := fun m x => inverse (m ! : ℚ_[p]) * x ^ m
private lemma dpow'_norm_le_of_ne_zero {n : ℕ} (hn : n ≠ 0) {x : ℤ_[p]}
(hx : x ∈ Ideal.span {(p : ℤ_[p])}) : ‖dpow' p n x‖ ≤ (p : ℝ)⁻¹ := by
unfold dpow'
by_cases hx0 : x = 0
· rw [hx0]
simp [inverse_eq_inv', coe_zero, ne_eq, hn, not_false_eq_true, zero_pow, mul_zero,
norm_zero, inv_nonneg, cast_nonneg]
· have hlt : (padicValNat p n.factorial : ℤ) < n := by
exact_mod_cast padicValNat_factorial_lt_of_ne_zero p hn
have hnorm : 0 < ‖(n ! : ℚ_[p])‖ := by
simp only [norm_pos_iff, ne_eq, cast_eq_zero]
exact factorial_ne_zero n
rw [← zpow_neg_one, ← Nat.cast_one (R := ℤ), Padic.norm_le_pow_iff_norm_lt_pow_add_one]
simp only [inverse_eq_inv', Padic.padicNormE.mul, norm_inv, _root_.norm_pow,
padic_norm_e_of_padicInt, cast_one, Int.reduceNeg, neg_add_cancel, zpow_zero]
rw [norm_eq_zpow_neg_valuation hx0, inv_mul_lt_one₀ hnorm, Padic.norm_eq_zpow_neg_valuation
(cast_ne_zero.mpr n.factorial_ne_zero), ← zpow_natCast, ← zpow_mul]
gcongr
· exact_mod_cast Nat.Prime.one_lt hp.elim
· simp only [neg_mul, Padic.valuation_natCast, neg_lt_neg_iff]
apply lt_of_lt_of_le hlt
conv_lhs => rw [← one_mul (n : ℤ)]
gcongr
norm_cast
rwa [← PadicInt.mem_span_pow_iff_le_valuation x hx0, pow_one]
private lemma dpow'_int (n : ℕ) {x : ℤ_[p]} (hx : x ∈ Ideal.span {(p : ℤ_[p])}) :
‖dpow' p n x‖ ≤ 1 := by
unfold dpow'
by_cases hn : n = 0
· simp [hn]
· apply le_trans (dpow'_norm_le_of_ne_zero p hn hx)
rw [← zpow_neg_one, ← zpow_zero ↑p]
gcongr
· exact_mod_cast Nat.Prime.one_le hp.elim
· norm_num
private theorem dpow'_mem {n : ℕ} {x : ℤ_[p]} (hm : n ≠ 0) (hx : x ∈ Ideal.span {↑p}) :
⟨dpow' p n x, dpow'_int p n hx⟩ ∈ Ideal.span {(p : ℤ_[p])} := by
have hiff := PadicInt.norm_le_pow_iff_mem_span_pow ⟨dpow' p n x, dpow'_int p n hx⟩ 1
rw [pow_one] at hiff
rw [← hiff]
simp only [cast_one, zpow_neg_one]
exact dpow'_norm_le_of_ne_zero p hm hx
/-- The family `ℕ → Ideal.span {(p : ℤ_[p])} → ℤ_[p]` given by `dpow n x = x ^ n / n!` is a
divided power structure on the `ℤ_[p]`-ideal `(p)`. -/
noncomputable def dividedPowers : DividedPowers (Ideal.span {(p : ℤ_[p])}) := by
classical
refine dividedPowers_of_injective (Ideal.span {(p : ℤ_[p])}) (⊤)
PadicInt.Coe.ringHom ((Set.injective_codRestrict Subtype.property).mp fun ⦃a₁ a₂⦄ a ↦ a)
(RatAlgebra.dividedPowers (⊤ : Ideal ℚ_[p])) ?_ ?_
· rw [Ideal.map_span, Set.image_singleton, map_natCast]
simp only [Ideal.span_singleton_eq_top, isUnit_iff_ne_zero, ne_eq, cast_eq_zero]
exact Nat.Prime.ne_zero hp.elim
· intro n x hx
exact ⟨⟨dpow' p n x, dpow'_int p n hx⟩, fun hn ↦ dpow'_mem p hn hx, by
simp [dpow', inverse_eq_inv', Coe.ringHom_apply, RatAlgebra.dpow_apply,
Submodule.mem_top, ↓reduceIte]⟩
open Function
private lemma dividedPowers_eq (n : ℕ) (x : ℤ_[p]) :
(dividedPowers p).dpow n x = open Classical in
if hx : x ∈ Ideal.span {(p : ℤ_[p])} then ⟨dpow' p n x, dpow'_int p n hx⟩ else 0 := by
simp only [dividedPowers, dividedPowers_of_injective]
split_ifs with hx
· have hinj : Injective (PadicInt.Coe.ringHom (p := p)) :=
(Set.injective_codRestrict Subtype.property).mp fun ⦃a₁ a₂⦄ a ↦ a
have heq : Coe.ringHom ⟨dpow' p n x, dpow'_int p n hx⟩ =
inverse (n ! : ℚ_[p]) * Coe.ringHom x ^ n := by
simp [dpow', inverse_eq_inv', Coe.ringHom_apply]
simpa only [← hinj.eq_iff, (Exists.choose_spec (_ : ∃ a, ∃ _, Coe.ringHom a = _)).2,
RatAlgebra.dpow_apply, Submodule.mem_top] using heq.symm
· rfl
lemma coe_dpow_eq (n : ℕ) (x : ℤ_[p]) :
((dividedPowers p).dpow n x : ℚ_[p]) = open Classical in
if _ : x ∈ Ideal.span {(p : ℤ_[p])} then inverse (n ! : ℚ_[p]) * x ^ n else 0 := by
simp only [dividedPowers_eq, dpow', inverse_eq_inv', dite_eq_ite]
split_ifs <;> simp
end Padic
end PadicInt |
.lake/packages/mathlib/Mathlib/RingTheory/DividedPowers/RatAlgebra.lean | import Mathlib.Data.Nat.Factorial.NatCast
import Mathlib.RingTheory.DividedPowers.Basic
/-! # Examples of divided power structures
In this file we show that, for certain choices of a commutative (semi)ring `A` and an ideal `I` of
`A`, the family of maps `ℕ → A → A` given by `fun n x ↦ x^n/n!` is a divided power structure on `I`.
## Main Definitions
* `DividedPowers.OfInvertibleFactorial.dpow` : the family of functions `ℕ → A → A` given by
`x^n/n!`.
* `DividedPowers.OfInvertibleFactorial.dividedPowers` : the divided power structure on `I` given by
`fun x n ↦ x^n/n!`, assuming that there exists a natural number `n` such that `f (n-1)!` is
invertible in `A` and `I^n = 0`.
* `DividedPowers.OfSquareZero.dividedPowers` : given an ideal `I` such that `I^2 =0`, this is
the divided power structure on `I` given by `fun x n ↦ x^n/n!`.
* `DividedPowers.CharP.dividedPowers` : if `A` is a commutative ring of prime characteristic `p`
and `I` is an ideal such that `I^p = 0`, , this is the divided power structure on `I` given by
`fun x n ↦ x^n/n!`.
* `DividedPowers.RatAlgebra.dividedPowers` : if `I` is any ideal in a `ℚ`-algebra, this is the
divided power structure on `I` given by `fun x n ↦ x^n/n!`.
## Main Results
* `DividedPowers.RatAlgebra.dividedPowers_unique`: there are no other divided power structures on an
ideal of a `ℚ`-algebra.
## References
* [P. Berthelot (1974), *Cohomologie cristalline des schémas de
caractéristique $p$ > 0*][Berthelot-1974]
* [P. Berthelot and A. Ogus (1978), *Notes on crystalline
cohomology*][BerthelotOgus-1978]
* [N. Roby (1963), *Lois polynomes et lois formelles en théorie des
modules*][Roby-1963]
* [N. Roby (1965), *Les algèbres à puissances dividées*][Roby-1965]
-/
open Nat Ring
namespace DividedPowers
namespace OfInvertibleFactorial
variable {A : Type*} [CommSemiring A] (I : Ideal A) [DecidablePred (fun x ↦ x ∈ I)]
/-- The family of functions `ℕ → A → A` given by `x^n/n!`. -/
noncomputable def dpow : ℕ → A → A := fun m x => if x ∈ I then inverse (m ! : A) * x ^ m else 0
variable {I}
theorem dpow_eq_of_mem {m : ℕ} {x : A} (hx : x ∈ I) : dpow I m x = inverse (m ! : A) * x ^ m := by
simp [dpow, hx]
theorem dpow_eq_of_not_mem {m : ℕ} {x : A} (hx : x ∉ I) : dpow I m x = 0 := by simp [dpow, hx]
theorem dpow_null {m : ℕ} {x : A} (hx : x ∉ I) : dpow I m x = 0 := by simp [dpow, hx]
theorem dpow_zero {x : A} (hx : x ∈ I) : dpow I 0 x = 1 := by simp [dpow, hx]
theorem dpow_one {x : A} (hx : x ∈ I) : dpow I 1 x = x := by simp [dpow_eq_of_mem hx]
theorem dpow_mem {m : ℕ} (hm : m ≠ 0) {x : A} (hx : x ∈ I) : dpow I m x ∈ I := by
rw [dpow_eq_of_mem hx]
exact Ideal.mul_mem_left I _ (Ideal.pow_mem_of_mem I hx _ (Nat.pos_of_ne_zero hm))
theorem dpow_add_of_lt {n : ℕ} (hn_fac : IsUnit ((n - 1)! : A)) {m : ℕ} (hmn : m < n)
{x y : A} (hx : x ∈ I) (hy : y ∈ I) :
dpow I m (x + y) = (Finset.antidiagonal m).sum (fun k ↦ dpow I k.1 x * dpow I k.2 y) := by
rw [dpow_eq_of_mem (Ideal.add_mem I hx hy)]
simp only [dpow]
rw [inverse_mul_eq_iff_eq_mul _ _ _ (hn_fac.natCast_factorial_of_lt hmn),
Finset.mul_sum, Commute.add_pow' (Commute.all _ _)]
apply Finset.sum_congr rfl
intro k hk
rw [if_pos hx, if_pos hy]
ring_nf
simp only [mul_assoc]; congr; rw [← mul_assoc]
exact castChoose_eq (hn_fac.natCast_factorial_of_lt hmn) hk
theorem dpow_add {n : ℕ} (hn_fac : IsUnit ((n - 1)! : A)) (hnI : I ^ n = 0) {m : ℕ} {x : A}
(hx : x ∈ I) {y : A} (hy : y ∈ I) :
dpow I m (x + y) = (Finset.antidiagonal m).sum fun k ↦ dpow I k.1 x * dpow I k.2 y := by
by_cases! hmn : m < n
· exact dpow_add_of_lt hn_fac hmn hx hy
· have h_sub : I ^ m ≤ I ^ n := Ideal.pow_le_pow_right hmn
rw [dpow_eq_of_mem (Ideal.add_mem I hx hy)]
simp only [dpow]
have hxy : (x + y) ^ m = 0 := by
rw [← Ideal.mem_bot, ← Ideal.zero_eq_bot, ← hnI]
exact Set.mem_of_subset_of_mem h_sub (Ideal.pow_mem_pow (Ideal.add_mem I hx hy) m)
rw [hxy, mul_zero, eq_comm]
apply Finset.sum_eq_zero
intro k hk
rw [if_pos hx, if_pos hy, mul_assoc, mul_comm (x ^ k.1), mul_assoc, ← mul_assoc]
apply mul_eq_zero_of_right
rw [← Ideal.mem_bot, ← Ideal.zero_eq_bot, ← hnI]
apply Set.mem_of_subset_of_mem h_sub
rw [← Finset.mem_antidiagonal.mp hk, add_comm, pow_add]
exact Ideal.mul_mem_mul (Ideal.pow_mem_pow hy _) (Ideal.pow_mem_pow hx _)
theorem dpow_mul {m : ℕ} {a x : A} (hx : x ∈ I) : dpow I m (a * x) = a ^ m * dpow I m x := by
rw [dpow_eq_of_mem (Ideal.mul_mem_left I _ hx), dpow_eq_of_mem hx,
mul_pow, ← mul_assoc, mul_comm _ (a ^ m), mul_assoc]
theorem dpow_mul_of_add_lt {n : ℕ} (hn_fac : IsUnit ((n - 1)! : A)) {m k : ℕ}
(hkm : m + k < n) {x : A} (hx : x ∈ I) :
dpow I m x * dpow I k x = ↑((m + k).choose m) * dpow I (m + k) x := by
have hm : m < n := lt_of_le_of_lt le_self_add hkm
have hk : k < n := lt_of_le_of_lt le_add_self hkm
rw [dpow_eq_of_mem hx, dpow_eq_of_mem hx, dpow_eq_of_mem hx,
mul_assoc, ← mul_assoc (x ^ m), mul_comm (x ^ m), mul_assoc _ (x ^ m),
← pow_add, ← mul_assoc, ← mul_assoc]
apply congr_arg₂ _ _ rfl
rw [eq_mul_inverse_iff_mul_eq _ _ _ (hn_fac.natCast_factorial_of_lt hkm),
mul_assoc,
inverse_mul_eq_iff_eq_mul _ _ _ (hn_fac.natCast_factorial_of_lt hm),
inverse_mul_eq_iff_eq_mul _ _ _ (hn_fac.natCast_factorial_of_lt hk)]
norm_cast; apply congr_arg
rw [← Nat.add_choose_mul_factorial_mul_factorial, mul_comm, mul_comm _ (m !), Nat.choose_symm_add]
theorem mul_dpow {n : ℕ} (hn_fac : IsUnit ((n - 1).factorial : A)) (hnI : I ^ n = 0)
{m k : ℕ} {x : A} (hx : x ∈ I) :
dpow I m x * dpow I k x = ↑((m + k).choose m) * dpow I (m + k) x := by
by_cases! hkm : m + k < n
· exact dpow_mul_of_add_lt hn_fac hkm hx
· have hxmk : x ^ (m + k) = 0 := Ideal.pow_eq_zero_of_mem hnI hkm hx
rw [dpow_eq_of_mem hx, dpow_eq_of_mem hx, dpow_eq_of_mem hx,
mul_assoc, ← mul_assoc (x ^ m), mul_comm (x ^ m), mul_assoc _ (x ^ m), ← pow_add, hxmk,
mul_zero, mul_zero, mul_zero, mul_zero]
theorem dpow_comp_of_mul_lt {n : ℕ} (hn_fac : IsUnit ((n - 1)! : A)) {m k : ℕ} (hk : k ≠ 0)
(hkm : m * k < n) {x : A} (hx : x ∈ I) :
dpow I m (dpow I k x) = ↑(uniformBell m k) * dpow I (m * k) x := by
have hmn : m < n := lt_of_le_of_lt (Nat.le_mul_of_pos_right _ (Nat.pos_of_ne_zero hk)) hkm
rw [dpow_eq_of_mem (m := m * k) hx, dpow_eq_of_mem (dpow_mem hk hx)]
by_cases hm0 : m = 0
· simp only [hm0, zero_mul, _root_.pow_zero, mul_one, uniformBell_zero_left, cast_one, one_mul]
· have hkn : k < n := lt_of_le_of_lt (Nat.le_mul_of_pos_left _ (Nat.pos_of_ne_zero hm0)) hkm
rw [dpow_eq_of_mem hx, mul_pow, ← pow_mul, mul_comm k, ← mul_assoc, ← mul_assoc]
apply congr_arg₂ _ _ rfl
rw [eq_mul_inverse_iff_mul_eq _ _ _ (hn_fac.natCast_factorial_of_lt hkm),
mul_assoc, inverse_mul_eq_iff_eq_mul _ _ _ (hn_fac.natCast_factorial_of_lt hmn),
inverse_pow_mul_eq_iff_eq_mul _ _ (hn_fac.natCast_factorial_of_lt hkn),
← uniformBell_mul_eq _ hk]
simp only [Nat.cast_mul, Nat.cast_pow]
ring_nf
theorem dpow_comp {n : ℕ} (hn_fac : IsUnit ((n - 1).factorial : A)) (hnI : I ^ n = 0)
{m k : ℕ} (hk : k ≠ 0) {x : A} (hx : x ∈ I) :
dpow I m (dpow I k x) = ↑(uniformBell m k) * dpow I (m * k) x := by
by_cases! hmk : m * k < n
· exact dpow_comp_of_mul_lt hn_fac hk hmk hx
· have hxmk : x ^ (m * k) = 0 := Ideal.pow_eq_zero_of_mem hnI hmk hx
rw [dpow_eq_of_mem (dpow_mem hk hx), dpow_eq_of_mem hx, dpow_eq_of_mem hx,
mul_pow, ← pow_mul, ← mul_assoc, mul_comm k, hxmk, mul_zero, mul_zero, mul_zero]
/-- If `(n-1)!` is invertible in `A` and `I^n = 0`, then `I` admits a divided power structure.
Proposition 1.2.7 of [B74], part (ii). -/
noncomputable def dividedPowers {n : ℕ} (hn_fac : IsUnit ((n - 1).factorial : A))
(hnI : I ^ n = 0) : DividedPowers I where
dpow := dpow I
dpow_null hx := dpow_null hx
dpow_zero hx := dpow_zero hx
dpow_one hx := dpow_one hx
dpow_mem hn hx := dpow_mem hn hx
dpow_add hx hy := dpow_add hn_fac hnI hx hy
dpow_mul := dpow_mul
mul_dpow hx := mul_dpow hn_fac hnI hx
dpow_comp hk hx := dpow_comp hn_fac hnI hk hx
lemma dpow_apply {n : ℕ} (hn_fac : IsUnit ((n - 1).factorial : A)) (hnI : I ^ n = 0)
{m : ℕ} {x : A} :
(dividedPowers hn_fac hnI).dpow m x =
if x ∈ I then inverse (m.factorial : A) * x ^ m else 0 := rfl
end OfInvertibleFactorial
namespace OfSquareZero
variable {A : Type*} [CommSemiring A] {I : Ideal A} [DecidablePred (fun x ↦ x ∈ I)]
(hI2 : I ^ 2 = 0)
/-- If `I^2 = 0`, then `I` admits a divided power structure. -/
noncomputable def dividedPowers : DividedPowers I :=
OfInvertibleFactorial.dividedPowers (by norm_num) hI2
theorem dpow_of_two_le {n : ℕ} (hn : 2 ≤ n) (a : A) :
(dividedPowers hI2) n a = 0 := by
simp only [dividedPowers, OfInvertibleFactorial.dpow_apply, ite_eq_right_iff]
intro ha
rw [Ideal.pow_eq_zero_of_mem hI2 hn ha, mul_zero]
end OfSquareZero
namespace IsNilpotent
variable {A : Type*} [CommRing A] {p : ℕ} [Fact (Nat.Prime p)] (hp : IsNilpotent (p : A))
{I : Ideal A} [DecidablePred (fun x ↦ x ∈ I)] (hIp : I ^ p = 0)
/-- If `A` is a commutative ring of prime characteristic `p` and `I` is an ideal such that
`I^p = 0`, then `I` admits a divided power structure. -/
noncomputable def dividedPowers : DividedPowers I :=
OfInvertibleFactorial.dividedPowers (n := p)
(IsUnit.natCast_factorial_of_isNilpotent hp (Nat.sub_one_lt (NeZero.ne' p).symm)) hIp
theorem dpow_of_prime_le {n : ℕ} (hn : p ≤ n) (a : A) : (dividedPowers hp hIp) n a = 0 := by
simp only [dividedPowers, OfInvertibleFactorial.dpow_apply, ite_eq_right_iff]
intro ha
rw [Ideal.pow_eq_zero_of_mem hIp hn ha, mul_zero]
end IsNilpotent
namespace CharP
variable (A : Type*) [CommRing A] (p : ℕ) [CharP A p] [Fact (Nat.Prime p)]
{I : Ideal A} [DecidablePred (fun x ↦ x ∈ I)] (hIp : I ^ p = 0)
/-- If `A` is a commutative ring of prime characteristic `p` and `I` is an ideal such that
`I^p = 0`, then `I` admits a divided power structure. -/
noncomputable def dividedPowers : DividedPowers I :=
IsNilpotent.dividedPowers ((CharP.cast_eq_zero A p) ▸ IsNilpotent.zero) hIp
theorem dpow_of_prime_le {n : ℕ} (hn : p ≤ n) (a : A) : (dividedPowers A p hIp) n a = 0 := by
simp only [dividedPowers, IsNilpotent.dividedPowers, OfInvertibleFactorial.dpow_apply,
ite_eq_right_iff]
intro ha
rw [Ideal.pow_eq_zero_of_mem hIp hn ha, mul_zero]
end CharP
-- We formalize example 2 from [BO], Section 3.
namespace RatAlgebra
variable {R : Type*} [CommSemiring R] (I : Ideal R) [DecidablePred (fun x ↦ x ∈ I)]
/-- The family `ℕ → R → R` given by `dpow n x = x ^ n / n!`. -/
noncomputable def dpow : ℕ → R → R := OfInvertibleFactorial.dpow I
variable {I}
theorem dpow_eq_of_mem (n : ℕ) {x : R} (hx : x ∈ I) :
dpow I n x = (inverse n.factorial : R) * x ^ n := by
rw [dpow, OfInvertibleFactorial.dpow_eq_of_mem hx]
variable [Algebra ℚ R]
variable (I)
/-- If `I` is an ideal in a `ℚ`-algebra `A`, then `I` admits a unique divided power structure,
given by `dpow n x = x ^ n / n!`. -/
noncomputable def dividedPowers : DividedPowers I where
dpow := dpow I
dpow_null hx := OfInvertibleFactorial.dpow_null hx
dpow_zero hx := OfInvertibleFactorial.dpow_zero hx
dpow_one hx := OfInvertibleFactorial.dpow_one hx
dpow_mem hn hx := OfInvertibleFactorial.dpow_mem hn hx
dpow_add {n} _ _ hx hy := OfInvertibleFactorial.dpow_add_of_lt
(IsUnit.natCast_factorial_of_algebra ℚ _) (n.lt_succ_self) hx hy
dpow_mul hx := OfInvertibleFactorial.dpow_mul hx
mul_dpow {m} k _ hx := OfInvertibleFactorial.dpow_mul_of_add_lt
(IsUnit.natCast_factorial_of_algebra ℚ _) (m + k).lt_succ_self hx
dpow_comp hk hx := OfInvertibleFactorial.dpow_comp_of_mul_lt
(IsUnit.natCast_factorial_of_algebra ℚ _) hk (lt_add_one _) hx
@[simp]
lemma dpow_apply {n : ℕ} {x : R} :
(dividedPowers I).dpow n x = if x ∈ I then inverse (n.factorial : R) * x ^ n else 0 := rfl
omit [DecidablePred fun x ↦ x ∈ I] in
/-- If `I` is an ideal in a `ℚ`-algebra `A`, then the divided power structure on `I` given by
`dpow n x = x ^ n / n!` is the only possible one. -/
theorem dpow_eq_inv_fact_smul (hI : DividedPowers I) {n : ℕ} {x : R} (hx : x ∈ I) :
hI.dpow n x = (inverse (n.factorial : ℚ)) • x ^ n := by
rw [inverse_eq_inv', ← factorial_mul_dpow_eq_pow hI hx, ← smul_eq_mul, ← smul_assoc]
nth_rewrite 1 [← one_smul R (hI.dpow n x)]
congr
have aux : ((n !) : R) = (n ! : ℚ) • (1 : R) := by
rw [cast_smul_eq_nsmul, nsmul_eq_mul, mul_one]
rw [aux, ← mul_smul]
suffices (n ! : ℚ)⁻¹ * (n !) = 1 by
rw [this, one_smul]
apply Rat.inv_mul_cancel
rw [← cast_zero, ne_eq]
simp [factorial_ne_zero]
variable {I}
/-- There are no other divided power structures on an ideal of a `ℚ`-algebra. -/
theorem dividedPowers_unique (hI : DividedPowers I) : hI = dividedPowers I :=
hI.ext _ (fun n x hx ↦ by rw [dpow_apply, if_pos hx, eq_comm, inverse_mul_eq_iff_eq_mul _ _ _
(IsUnit.natCast_factorial_of_algebra ℚ n), factorial_mul_dpow_eq_pow _ hx])
end RatAlgebra
end DividedPowers |
.lake/packages/mathlib/Mathlib/RingTheory/FilteredAlgebra/Basic.lean | import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.GradedMonoid
import Mathlib.Algebra.Group.Submonoid.Defs
import Mathlib.Algebra.GradedMulAction
import Mathlib.Algebra.Order.Ring.Unbundled.Basic
import Mathlib.Algebra.Ring.Int.Defs
/-!
# The filtration on abelian groups and rings
In this file, we define the concept of filtration for abelian groups, rings, and modules.
## Main definitions
* `IsFiltration` : For a family of subsets `σ` of `A`, an increasing series of `F` in `σ` is a
filtration if there is another series `F_lt` in `σ` equal to the
supremum of `F` with smaller index.
* `IsRingFiltration` : For a family of subsets `σ` of semiring `R`, an increasing series `F` in `σ`
is a ring filtration if `IsFiltration F F_lt` and the pointwise multiplication of `F i` and `F j`
is in `F (i + j)`.
* `IsModuleFiltration` : For `F` satisfying `IsRingFiltration F F_lt` in a semiring `R` and `σM` a
family of subsets of a `R` module `M`, an increasing series `FM` in `σM` is a module filtration
if `IsFiltration F F_lt` and the pointwise scalar multiplication of `F i` and `FM j`
is in `F (i +ᵥ j)`.
-/
section GeneralFiltration
variable {ι A σ : Type*} [Preorder ι] [SetLike σ A]
/-- For a family of subsets `σ` of `A`, an increasing series of `F` in `σ` is a filtration if
there is another series `F_lt` in `σ` equal to the supremum of `F` with smaller index.
In the intended applications, `σ` is a complete lattice, and `F_lt` is uniquely-determined as
`F_lt j = ⨆ i < j, F i`. Thus `F_lt` is an implementation detail which allows us defer depending
on a complete lattice structure on `σ`. It also provides the ancillary benefit of giving us better
definition control. This is convenient e.g., when the index is `ℤ`. -/
class IsFiltration (F : ι → σ) (F_lt : outParam <| ι → σ) : Prop where
mono : Monotone F
is_le {i j} : i < j → F i ≤ F_lt j
is_sup (B : σ) (j : ι) : (∀ i < j, F i ≤ B) → F_lt j ≤ B
lemma IsFiltration.F_lt_le_F (F : ι → σ) (F_lt : outParam <| ι → σ) (i : ι) [IsFiltration F F_lt] :
F_lt i ≤ F i :=
is_sup (F i) i (fun _ hi ↦ IsFiltration.mono (le_of_lt hi))
/-- A convenience constructor for `IsFiltration` when the index is the integers. -/
lemma IsFiltration.mk_int (F : ℤ → σ) (mono : Monotone F) :
IsFiltration F (fun n ↦ F (n - 1)) where
mono := mono
is_le lt := mono (Int.le_sub_one_of_lt lt)
is_sup _ j hi := hi (j - 1) (sub_one_lt j)
end GeneralFiltration
section FilteredRing
variable {ι R σ : Type*} [AddMonoid ι] [PartialOrder ι]
[Semiring R] [SetLike σ R]
/-- For a family of subsets `σ` of semiring `R`, an increasing series `F` in `σ` is
a ring filtration if `IsFiltration F F_lt` and the pointwise multiplication of `F i` and `F j`
is in `F (i + j)`. -/
class IsRingFiltration (F : ι → σ) (F_lt : outParam <| ι → σ) : Prop
extends IsFiltration F F_lt, SetLike.GradedMonoid F
/-- A convenience constructor for `IsRingFiltration` when the index is the integers. -/
lemma IsRingFiltration.mk_int (F : ℤ → σ) (mono : Monotone F) [SetLike.GradedMonoid F] :
IsRingFiltration F (fun n ↦ F (n - 1)) where
__ := IsFiltration.mk_int F mono
end FilteredRing
section FilteredModule
variable {ι ιM R M σ σM : Type*} [AddMonoid ι] [PartialOrder ι] [PartialOrder ιM] [VAdd ι ιM]
variable [Semiring R] [SetLike σ R] [AddCommMonoid M] [Module R M] [SetLike σM M]
/-- For `F` satisfying `IsRingFiltration F F_lt` in a semiring `R` and `σM` a family of subsets of
a `R` module `M`, an increasing series `FM` in `σM` is a module filtration if `IsFiltration F F_lt`
and the pointwise scalar multiplication of `F i` and `FM j` is in `F (i +ᵥ j)`.
The index set `ιM` for the module can be more general, however usually we take `ιM = ι`. -/
class IsModuleFiltration (F : ι → σ) (F_lt : outParam <| ι → σ) [IsRingFiltration F F_lt]
(F' : ιM → σM) (F'_lt : outParam <| ιM → σM) : Prop
extends IsFiltration F' F'_lt, SetLike.GradedSMul F F'
/-- A convenience constructor for `IsModuleFiltration` when the index is the integers. -/
lemma IsModuleFiltration.mk_int (F : ℤ → σ) (mono : Monotone F) [SetLike.GradedMonoid F]
(F' : ℤ → σM) (mono' : Monotone F') [SetLike.GradedSMul F F'] :
letI := IsRingFiltration.mk_int F mono
IsModuleFiltration F (fun n ↦ F (n - 1)) F' (fun n ↦ F' (n - 1)) :=
letI := IsRingFiltration.mk_int F mono
{ IsFiltration.mk_int F' mono' with }
end FilteredModule |
.lake/packages/mathlib/Mathlib/RingTheory/WittVector/Complete.lean | import Mathlib.RingTheory.WittVector.Domain
import Mathlib.RingTheory.WittVector.Truncated
import Mathlib.RingTheory.AdicCompletion.Basic
/-!
# The ring of Witt vectors is p-torsion free and p-adically complete
In this file, we prove that the ring of Witt vectors `𝕎 k` is p-torsion free and p-adically complete
when `k` is a perfect ring of characteristic `p`.
## Main declarations
* `WittVector.eq_zero_of_p_mul_eq_zero` : If `k` is a perfect ring of characteristic `p`,
then the Witt vector `𝕎 k` is `p`-torsion free.
* `isAdicCompleteIdealSpanP` : If `k` is a perfect ring of characteristic `p`,
then the Witt vector `𝕎 k` is `p`-adically complete.
## TODO
Define the map `𝕎 k / p ≃+* k`.
-/
namespace WittVector
variable {p : ℕ} [hp : Fact (Nat.Prime p)] {k : Type*} [CommRing k]
local notation "𝕎" => WittVector p
theorem le_coeff_eq_iff_le_sub_coeff_eq_zero {x y : 𝕎 k} {n : ℕ} :
(∀ i < n, x.coeff i = y.coeff i) ↔ ∀ i < n, (x - y).coeff i = 0 := by
calc
_ ↔ x.truncate n = y.truncate n := by
refine ⟨fun h => ?_, fun h i hi => ?_⟩
· ext i
simp [h i]
· rw [← coeff_truncate x ⟨i, hi⟩, ← coeff_truncate y ⟨i, hi⟩, h]
_ ↔ (x - y).truncate n = 0 := by
simp only [map_sub, sub_eq_zero]
_ ↔ _ := by simp only [← mem_ker_truncate, RingHom.mem_ker]
section PerfectRing
variable [CharP k p] [PerfectRing k p]
/--
If `k` is a perfect ring of characteristic `p`, then the ring of Witt vectors `𝕎 k` is
`p`-torsion free.
-/
theorem eq_zero_of_p_mul_eq_zero (x : 𝕎 k) (h : x * p = 0) : x = 0 := by
rwa [← frobenius_verschiebung, _root_.map_eq_zero_iff _ (frobenius_bijective p k).injective,
_root_.map_eq_zero_iff _ (verschiebung_injective p k)] at h
/--
If `k` is a perfect ring of characteristic `p`, a Witt vector `x : 𝕎 k` falls in ideal generated by
`p` if and only if its zeroth coefficient is `0`.
-/
theorem mem_span_p_iff_coeff_zero_eq_zero (x : 𝕎 k) :
x ∈ (Ideal.span {(p : 𝕎 k)}) ↔ x.coeff 0 = 0 := by
simp_rw [Ideal.mem_span_singleton, dvd_def, mul_comm]
refine ⟨fun ⟨u, hu⟩ ↦ ?_, fun h ↦ ?_⟩
· rw [hu, mul_charP_coeff_zero]
· use (frobeniusEquiv p k).symm (x.shift 1)
calc
_ = verschiebung (x.shift 1) := by
simpa using eq_iterate_verschiebung (n := 1) (by simp [h])
_ = _ := by
rw [← verschiebung_frobenius, ← frobeniusEquiv_apply,
RingEquiv.apply_symm_apply (frobeniusEquiv p k) _]
/--
If `k` is a perfect ring of characteristic `p`, a Witt vector `x : 𝕎 k` falls in ideal generated by
`p ^ n` if and only if its initial `n` coefficients are `0`.
-/
theorem mem_span_p_pow_iff_le_coeff_eq_zero (x : 𝕎 k) (n : ℕ) :
x ∈ (Ideal.span {(p ^ n : 𝕎 k)}) ↔ ∀ m, m < n → x.coeff m = 0 := by
simp_rw [Ideal.mem_span_singleton, dvd_def, mul_comm]
refine ⟨fun ⟨u, hu⟩ m hm ↦ ?_, fun h ↦ ?_⟩
· rw [hu, mul_pow_charP_coeff_zero _ hm]
· use (frobeniusEquiv p k).symm^[n] (x.shift n)
rw [← iterate_verschiebung_iterate_frobenius]
calc
_ = verschiebung^[n] (x.shift n) := by
simpa using eq_iterate_verschiebung (x := x) (n := n) h
_ = _ := by
congr
rw [← Function.comp_apply (f := frobenius^[n]), ← Function.Commute.comp_iterate]
· rw [← WittVector.frobeniusEquiv_apply, ← RingEquiv.coe_trans]
simp
· rw [Function.Commute, Function.Semiconj, ← WittVector.frobeniusEquiv_apply]
simp only [RingEquiv.apply_symm_apply, RingEquiv.symm_apply_apply, implies_true]
/--
If `k` is a perfect ring of characteristic `p`, then the ring of Witt vectors `𝕎 k`
is `p`-adically complete.
-/
instance isAdicCompleteIdealSpanP : IsAdicComplete (Ideal.span {(p : 𝕎 k)}) (𝕎 k) where
haus' := by
intro _ h
ext n
simp only [smul_eq_mul, Ideal.mul_top] at h
have := h (n + 1)
simp only [Ideal.span_singleton_pow, SModEq.zero,
mem_span_p_pow_iff_le_coeff_eq_zero] at this
simpa using this n
prec' := by
intro x h
-- construct the limit Witt vector w diagonally
use .mk p (fun n ↦ (x (n + 1)).coeff n)
intro n
simp only [Ideal.span_singleton_pow, smul_eq_mul, Ideal.mul_top, SModEq.sub_mem,
mem_span_p_pow_iff_le_coeff_eq_zero, ← le_coeff_eq_iff_le_sub_coeff_eq_zero] at h ⊢
intro i hi
exact (h hi i (Nat.lt_succ_self i)).symm
end PerfectRing
end WittVector |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.