ring_theory.kaehlerMathlib.RingTheory.Kaehler

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

chore(ring_theory/kaehler): cleanup instances (#19234)

The previous module instance has the wrong defeqs, and was more work to construct. The new one remains propositionally equal to the old one.

Diff
@@ -145,31 +145,23 @@ notation `Ω[`:100 S `⁄`:0 R `]`:0 := kaehler_differential R S
 
 instance : nonempty Ω[S⁄R] := ⟨0⟩
 
-instance kaehler_differential.module' {R' : Type*} [comm_ring R'] [algebra R' S] :
+instance kaehler_differential.module' {R' : Type*} [comm_ring R'] [algebra R' S]
+  [smul_comm_class R R' S] :
   module R' Ω[S⁄R] :=
-(module.comp_hom (kaehler_differential.ideal R S).cotangent (algebra_map R' S) : _)
+submodule.quotient.module' _
 
 instance : is_scalar_tower S (S ⊗[R] S) Ω[S⁄R] :=
 ideal.cotangent.is_scalar_tower _
 
 instance kaehler_differential.is_scalar_tower_of_tower {R₁ R₂ : Type*} [comm_ring R₁] [comm_ring R₂]
-  [algebra R₁ S] [algebra R₂ S] [algebra R₁ R₂] [is_scalar_tower R₁ R₂ S] :
+  [algebra R₁ S] [algebra R₂ S] [has_smul R₁ R₂]
+  [smul_comm_class R R₁ S] [smul_comm_class R R₂ S] [is_scalar_tower R₁ R₂ S] :
   is_scalar_tower R₁ R₂ Ω[S⁄R] :=
-begin
-  convert restrict_scalars.is_scalar_tower R₁ R₂ Ω[S⁄R] using 1,
-  ext x m,
-  show algebra_map R₁ S x • m = algebra_map R₂ S (algebra_map R₁ R₂ x) • m,
-  rw ← is_scalar_tower.algebra_map_apply,
-end
+submodule.quotient.is_scalar_tower _ _
 
 instance kaehler_differential.is_scalar_tower' :
   is_scalar_tower R (S ⊗[R] S) Ω[S⁄R] :=
-begin
-  convert restrict_scalars.is_scalar_tower R (S ⊗[R] S) Ω[S⁄R] using 1,
-  ext x m,
-  show algebra_map R S x • m = algebra_map R (S ⊗[R] S) x • m,
-  simp_rw [is_scalar_tower.algebra_map_apply R S (S ⊗[R] S), is_scalar_tower.algebra_map_smul]
-end
+submodule.quotient.is_scalar_tower _ _
 
 /-- The quotient map `I → Ω[S⁄R]` with `I` being the kernel of `S ⊗[R] S → S`. -/
 def kaehler_differential.from_ideal : kaehler_differential.ideal R S →ₗ[S ⊗[R] S] Ω[S⁄R] :=
@@ -190,13 +182,14 @@ rfl
 /-- The universal derivation into `Ω[S⁄R]`. -/
 def kaehler_differential.D : derivation R S Ω[S⁄R] :=
 { map_one_eq_zero' := begin
-    dsimp [kaehler_differential.D_linear_map_apply],
+    dsimp only [kaehler_differential.D_linear_map_apply],
     rw [ideal.to_cotangent_eq_zero, subtype.coe_mk, sub_self],
     exact zero_mem _
   end,
   leibniz' := λ a b, begin
-    dsimp [kaehler_differential.D_linear_map_apply],
-    rw [← linear_map.map_smul_of_tower, ← linear_map.map_smul_of_tower, ← map_add,
+    dsimp only [kaehler_differential.D_linear_map_apply],
+    rw [← linear_map.map_smul_of_tower ((kaehler_differential.ideal R S).to_cotangent) a,
+      ← linear_map.map_smul_of_tower ((kaehler_differential.ideal R S).to_cotangent) b, ← map_add,
       ideal.to_cotangent_eq, pow_two],
     convert submodule.mul_mem_mul (kaehler_differential.one_smul_sub_smul_one_mem_ideal R a : _)
       (kaehler_differential.one_smul_sub_smul_one_mem_ideal R b : _) using 1,
@@ -205,7 +198,7 @@ def kaehler_differential.D : derivation R S Ω[S⁄R] :=
       submodule.coe_smul_of_tower, smul_sub, tensor_product.smul_tmul', smul_eq_mul, mul_one],
     ring_nf,
   end,
-  ..(kaehler_differential.D_linear_map R S) }
+  to_linear_map := kaehler_differential.D_linear_map R S }
 
 lemma kaehler_differential.D_apply (s : S) :
   kaehler_differential.D R S s = (kaehler_differential.ideal R S).to_cotangent
@@ -373,9 +366,9 @@ into `(kaehler_differential.ideal R S).cotangent_ideal` -/
 -- `derivation R S Ω[S⁄R] ≃ₗ[R] derivation R S (kaehler_differential.ideal R S).cotangent_ideal`
 -- But lean times-out if this is given explicitly.
 noncomputable
-def kaehler_differential.End_equiv_derivation' :=
-@linear_equiv.comp_der R _ _ _ _ Ω[S⁄R] _ _ _ _ _ _ _ _ _
-  ((kaehler_differential.ideal R S).cotangent_equiv_ideal.restrict_scalars S)
+def kaehler_differential.End_equiv_derivation' :
+  derivation R S Ω[S⁄R] ≃ₗ[R] derivation R S _ :=
+linear_equiv.comp_der ((kaehler_differential.ideal R S).cotangent_equiv_ideal.restrict_scalars S)
 
 /-- (Implementation) An `equiv` version of `kaehler_differential.End_equiv_aux`.
 Used in `kaehler_differential.End_equiv`. -/
@@ -538,7 +531,7 @@ variables (A B : Type*) [comm_ring A] [comm_ring B] [algebra R A] [algebra S B]
 variables [algebra A B] [is_scalar_tower R S B] [is_scalar_tower R A B]
 
 -- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
-local notation `finsupp_map` := ((finsupp.map_range.linear_map (algebra.of_id A B).to_linear_map)
+local notation `finsupp_map` := ((finsupp.map_range.linear_map (algebra.linear_map A B))
   .comp (finsupp.lmap_domain A A (algebra_map A B)))
 
 lemma kaehler_differential.ker_total_map (h : function.surjective (algebra_map A B)) :
@@ -552,7 +545,7 @@ begin
     set.image_univ, map_sub, map_add],
   simp only [linear_map.comp_apply, finsupp.map_range.linear_map_apply, finsupp.map_range_single,
     finsupp.lmap_domain_apply, finsupp.map_domain_single, alg_hom.to_linear_map_apply,
-    algebra.of_id_apply, ← is_scalar_tower.algebra_map_apply, map_one, map_add, map_mul],
+    algebra.linear_map_apply, ← is_scalar_tower.algebra_map_apply, map_one, map_add, map_mul],
   simp_rw [sup_assoc, ← (h.prod_map h).range_comp],
   congr' 3,
   rw [sup_eq_right],
@@ -565,8 +558,6 @@ end presentation
 
 section exact_sequence
 
-local attribute [irreducible] kaehler_differential
-
 /- We have the commutative diagram
 A --→ B
 ↑     ↑
@@ -585,7 +576,7 @@ def derivation.comp_algebra_map [module A M] [module B M] [is_scalar_tower A B M
   leibniz' := λ a b, by simp,
   to_linear_map := d.to_linear_map.comp (is_scalar_tower.to_alg_hom R A B).to_linear_map }
 
-variables (R B)
+variables (R B) [smul_comm_class S A B]
 
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` given a square
 A --→ B

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -267,7 +267,7 @@ theorem KaehlerDifferential.span_range_derivation :
   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 
+  rw [← KaehlerDifferential.submodule_span_range_eq_ideal] at this
   suffices
     ∃ hx,
       (KaehlerDifferential.ideal R S).toCotangent ⟨x, hx⟩ ∈
Diff
@@ -3,9 +3,9 @@ Copyright © 2020 Nicolò Cavalleri. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Nicolò Cavalleri, Andrew Yang
 -/
-import Mathbin.RingTheory.Derivation.ToSquareZero
-import Mathbin.RingTheory.Ideal.Cotangent
-import Mathbin.RingTheory.IsTensorProduct
+import RingTheory.Derivation.ToSquareZero
+import RingTheory.Ideal.Cotangent
+import RingTheory.IsTensorProduct
 
 #align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364"
 
Diff
@@ -7,7 +7,7 @@ import Mathbin.RingTheory.Derivation.ToSquareZero
 import Mathbin.RingTheory.Ideal.Cotangent
 import Mathbin.RingTheory.IsTensorProduct
 
-#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"2fe465deb81bcd7ccafa065bb686888a82f15372"
+#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364"
 
 /-!
 # The module of kaehler differentials
@@ -174,9 +174,9 @@ instance : Nonempty (Ω[S⁄R]) :=
   ⟨0⟩
 
 #print KaehlerDifferential.module' /-
-instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S] :
-    Module R' (Ω[S⁄R]) :=
-  (Module.compHom (KaehlerDifferential.ideal R S).Cotangent (algebraMap R' S) : _)
+instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S]
+    [SMulCommClass R R' S] : Module R' (Ω[S⁄R]) :=
+  Submodule.Quotient.module' _
 #align kaehler_differential.module' KaehlerDifferential.module'
 -/
 
@@ -185,23 +185,15 @@ instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
 
 #print KaehlerDifferential.isScalarTower_of_tower /-
 instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRing R₁] [CommRing R₂]
-    [Algebra R₁ S] [Algebra R₂ S] [Algebra R₁ R₂] [IsScalarTower R₁ R₂ S] :
-    IsScalarTower R₁ R₂ (Ω[S⁄R]) :=
-  by
-  convert RestrictScalars.isScalarTower R₁ R₂ (Ω[S⁄R]) using 1
-  ext x m
-  show algebraMap R₁ S x • m = algebraMap R₂ S (algebraMap R₁ R₂ x) • m
-  rw [← IsScalarTower.algebraMap_apply]
+    [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 _ _
 #align kaehler_differential.is_scalar_tower_of_tower KaehlerDifferential.isScalarTower_of_tower
 -/
 
 #print KaehlerDifferential.isScalarTower' /-
 instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) :=
-  by
-  convert RestrictScalars.isScalarTower R (S ⊗[R] S) (Ω[S⁄R]) using 1
-  ext x m
-  show algebraMap R S x • m = algebraMap R (S ⊗[R] S) x • m
-  simp_rw [IsScalarTower.algebraMap_apply R S (S ⊗[R] S), IsScalarTower.algebraMap_smul]
+  Submodule.Quotient.isScalarTower _ _
 #align kaehler_differential.is_scalar_tower' KaehlerDifferential.isScalarTower'
 -/
 
@@ -235,26 +227,26 @@ theorem KaehlerDifferential.DLinearMap_apply (s : S) :
 
 #print KaehlerDifferential.D /-
 /-- The universal derivation into `Ω[S⁄R]`. -/
-def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
-  {
-    KaehlerDifferential.DLinearMap R
-      S with
-    map_one_eq_zero' := by
-      dsimp [KaehlerDifferential.DLinearMap_apply]
-      rw [Ideal.toCotangent_eq_zero, Subtype.coe_mk, sub_self]
-      exact zero_mem _
-    leibniz' := fun a b => by
-      dsimp [KaehlerDifferential.DLinearMap_apply]
-      rw [← LinearMap.map_smul_of_tower, ← LinearMap.map_smul_of_tower, ← map_add,
-        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 [AddSubgroupClass.coe_sub, Submodule.coe_add, Submodule.coe_mk,
-        tensor_product.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 }
+def KaehlerDifferential.D : Derivation R S (Ω[S⁄R])
+    where
+  map_one_eq_zero' := by
+    dsimp only [KaehlerDifferential.DLinearMap_apply]
+    rw [Ideal.toCotangent_eq_zero, Subtype.coe_mk, sub_self]
+    exact zero_mem _
+  leibniz' a b := by
+    dsimp only [KaehlerDifferential.DLinearMap_apply]
+    rw [← LinearMap.map_smul_of_tower (KaehlerDifferential.ideal R S).toCotangent a, ←
+      LinearMap.map_smul_of_tower (KaehlerDifferential.ideal R S).toCotangent b, ← map_add,
+      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 [AddSubgroupClass.coe_sub, Submodule.coe_add, Submodule.coe_mk,
+      tensor_product.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
+  toLinearMap := KaehlerDifferential.DLinearMap R S
 #align kaehler_differential.D KaehlerDifferential.D
 -/
 
@@ -473,9 +465,9 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
 -- But lean times-out if this is given explicitly.
 /-- Derivations into `Ω[S⁄R]` is equivalent to derivations
 into `(kaehler_differential.ideal R S).cotangent_ideal` -/
-noncomputable def KaehlerDifferential.endEquivDerivation' :=
-  @LinearEquiv.compDer R _ _ _ _ (Ω[S⁄R]) _ _ _ _ _ _ _ _ _
-    ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
+noncomputable def KaehlerDifferential.endEquivDerivation' :
+    Derivation R S (Ω[S⁄R]) ≃ₗ[R] Derivation R S _ :=
+  LinearEquiv.compDer ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
 #align kaehler_differential.End_equiv_derivation' KaehlerDifferential.endEquivDerivation'
 -/
 
@@ -673,7 +665,7 @@ variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
 
 -- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
 local notation "finsupp_map" =>
-  (Finsupp.mapRange.linearMap (Algebra.ofId A B).toLinearMap).comp
+  (Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp
     (Finsupp.lmapDomain A A (algebraMap A B))
 
 #print KaehlerDifferential.kerTotal_map /-
@@ -688,7 +680,7 @@ theorem KaehlerDifferential.kerTotal_map (h : Function.Surjective (algebraMap A
     map_sub, map_add]
   simp only [LinearMap.comp_apply, Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single,
     Finsupp.lmapDomain_apply, Finsupp.mapDomain_single, AlgHom.toLinearMap_apply,
-    Algebra.ofId_apply, ← IsScalarTower.algebraMap_apply, map_one, map_add, map_mul]
+    Algebra.linearMap_apply, ← IsScalarTower.algebraMap_apply, map_one, map_add, map_mul]
   simp_rw [sup_assoc, ← (h.prod_map h).range_comp]
   congr 3
   rw [sup_eq_right]
@@ -725,7 +717,7 @@ def Derivation.compAlgebraMap [Module A M] [Module B M] [IsScalarTower A B M]
 #align derivation.comp_algebra_map Derivation.compAlgebraMap
 -/
 
-variable (R B)
+variable (R B) [SMulCommClass S A B]
 
 #print KaehlerDifferential.map /-
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` given a square
Diff
@@ -2,16 +2,13 @@
 Copyright © 2020 Nicolò Cavalleri. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Nicolò Cavalleri, Andrew Yang
-
-! This file was ported from Lean 3 source module ring_theory.kaehler
-! leanprover-community/mathlib commit 2fe465deb81bcd7ccafa065bb686888a82f15372
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.RingTheory.Derivation.ToSquareZero
 import Mathbin.RingTheory.Ideal.Cotangent
 import Mathbin.RingTheory.IsTensorProduct
 
+#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"2fe465deb81bcd7ccafa065bb686888a82f15372"
+
 /-!
 # The module of kaehler differentials
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Nicolò Cavalleri, Andrew Yang
 
 ! This file was ported from Lean 3 source module ring_theory.kaehler
-! leanprover-community/mathlib commit b608348ffaeb7f557f2fd46876037abafd326ff3
+! leanprover-community/mathlib commit 2fe465deb81bcd7ccafa065bb686888a82f15372
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.RingTheory.IsTensorProduct
 /-!
 # The module of kaehler differentials
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 ## Main results
 
 - `kaehler_differential`: The module of kaehler differentials. For an `R`-algebra `S`, we provide
Diff
@@ -46,31 +46,40 @@ open Algebra
 
 variable (R S : Type _) [CommRing R] [CommRing S] [Algebra R S]
 
+#print KaehlerDifferential.ideal /-
 /-- 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)
 #align kaehler_differential.ideal KaehlerDifferential.ideal
+-/
 
 variable {S}
 
+#print KaehlerDifferential.one_smul_sub_smul_one_mem_ideal /-
 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]
 #align kaehler_differential.one_smul_sub_smul_one_mem_ideal KaehlerDifferential.one_smul_sub_smul_one_mem_ideal
+-/
 
 variable {R}
 
 variable {M : Type _} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M]
 
+#print Derivation.tensorProductTo /-
 /-- 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)
 #align derivation.tensor_product_to Derivation.tensorProductTo
+-/
 
+#print Derivation.tensorProductTo_tmul /-
 theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) :
     D.tensorProductTo (s ⊗ₜ t) = s • D t :=
   rfl
 #align derivation.tensor_product_to_tmul Derivation.tensorProductTo_tmul
+-/
 
+#print Derivation.tensorProductTo_mul /-
 theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) :
     D.tensorProductTo (x * y) =
       TensorProduct.lmul' R x • D.tensorProductTo y +
@@ -91,9 +100,11 @@ theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S)
   rw [D.leibniz]
   simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc]
 #align derivation.tensor_product_to_mul Derivation.tensorProductTo_mul
+-/
 
 variable (R S)
 
+#print KaehlerDifferential.submodule_span_range_eq_ideal /-
 /-- 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)) =
@@ -122,7 +133,9 @@ theorem KaehlerDifferential.submodule_span_range_eq_ideal :
       rw [map_add, TensorProduct.add_tmul, ← sub_add_sub_comm]
       exact add_mem hx hy
 #align kaehler_differential.submodule_span_range_eq_ideal KaehlerDifferential.submodule_span_range_eq_ideal
+-/
 
+#print KaehlerDifferential.span_range_eq_ideal /-
 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 :=
@@ -136,8 +149,10 @@ theorem KaehlerDifferential.span_range_eq_ideal :
     conv_rhs => rw [← Submodule.span_span_of_tower S]
     exact Submodule.subset_span
 #align kaehler_differential.span_range_eq_ideal KaehlerDifferential.span_range_eq_ideal
+-/
 
 /- ./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler module[module] tensor_product(S, R, S) -/
+#print KaehlerDifferential /-
 /-- 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
@@ -151,20 +166,24 @@ def KaehlerDifferential : Type _ :=
 deriving AddCommGroup,
   «./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler module[module] tensor_product(S, R, S)»
 #align kaehler_differential KaehlerDifferential
+-/
 
 notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
 
 instance : Nonempty (Ω[S⁄R]) :=
   ⟨0⟩
 
+#print KaehlerDifferential.module' /-
 instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S] :
     Module R' (Ω[S⁄R]) :=
   (Module.compHom (KaehlerDifferential.ideal R S).Cotangent (algebraMap R' S) : _)
 #align kaehler_differential.module' KaehlerDifferential.module'
+-/
 
 instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
   Ideal.Cotangent.isScalarTower _
 
+#print KaehlerDifferential.isScalarTower_of_tower /-
 instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRing R₁] [CommRing R₂]
     [Algebra R₁ S] [Algebra R₂ S] [Algebra R₁ R₂] [IsScalarTower R₁ R₂ S] :
     IsScalarTower R₁ R₂ (Ω[S⁄R]) :=
@@ -174,48 +193,58 @@ instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRi
   show algebraMap R₁ S x • m = algebraMap R₂ S (algebraMap R₁ R₂ x) • m
   rw [← IsScalarTower.algebraMap_apply]
 #align kaehler_differential.is_scalar_tower_of_tower KaehlerDifferential.isScalarTower_of_tower
+-/
 
-instance KaehlerDifferential.is_scalar_tower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) :=
+#print KaehlerDifferential.isScalarTower' /-
+instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) :=
   by
   convert RestrictScalars.isScalarTower R (S ⊗[R] S) (Ω[S⁄R]) using 1
   ext x m
   show algebraMap R S x • m = algebraMap R (S ⊗[R] S) x • m
   simp_rw [IsScalarTower.algebraMap_apply R S (S ⊗[R] S), IsScalarTower.algebraMap_smul]
-#align kaehler_differential.is_scalar_tower' KaehlerDifferential.is_scalar_tower'
+#align kaehler_differential.is_scalar_tower' KaehlerDifferential.isScalarTower'
+-/
 
+#print KaehlerDifferential.fromIdeal /-
 /-- 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
 #align kaehler_differential.from_ideal KaehlerDifferential.fromIdeal
+-/
 
+#print KaehlerDifferential.DLinearMap /-
 /-- (Implementation) The underlying linear map of the derivation into `Ω[S⁄R]`. -/
-def KaehlerDifferential.dLinearMap : S →ₗ[R] Ω[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] _)
-#align kaehler_differential.D_linear_map KaehlerDifferential.dLinearMap
+#align kaehler_differential.D_linear_map KaehlerDifferential.DLinearMap
+-/
 
-theorem KaehlerDifferential.dLinearMap_apply (s : S) :
-    KaehlerDifferential.dLinearMap R S s =
+#print KaehlerDifferential.DLinearMap_apply /-
+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
-#align kaehler_differential.D_linear_map_apply KaehlerDifferential.dLinearMap_apply
+#align kaehler_differential.D_linear_map_apply KaehlerDifferential.DLinearMap_apply
+-/
 
+#print KaehlerDifferential.D /-
 /-- The universal derivation into `Ω[S⁄R]`. -/
-def KaehlerDifferential.d : Derivation R S (Ω[S⁄R]) :=
+def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
   {
-    KaehlerDifferential.dLinearMap R
+    KaehlerDifferential.DLinearMap R
       S with
     map_one_eq_zero' := by
-      dsimp [KaehlerDifferential.dLinearMap_apply]
+      dsimp [KaehlerDifferential.DLinearMap_apply]
       rw [Ideal.toCotangent_eq_zero, Subtype.coe_mk, sub_self]
       exact zero_mem _
     leibniz' := fun a b => by
-      dsimp [KaehlerDifferential.dLinearMap_apply]
+      dsimp [KaehlerDifferential.DLinearMap_apply]
       rw [← LinearMap.map_smul_of_tower, ← LinearMap.map_smul_of_tower, ← map_add,
         Ideal.toCotangent_eq, pow_two]
       convert
@@ -226,17 +255,21 @@ def KaehlerDifferential.d : Derivation R S (Ω[S⁄R]) :=
         tensor_product.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 }
-#align kaehler_differential.D KaehlerDifferential.d
+#align kaehler_differential.D KaehlerDifferential.D
+-/
 
-theorem KaehlerDifferential.d_apply (s : S) :
-    KaehlerDifferential.d R S s =
+#print KaehlerDifferential.D_apply /-
+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
-#align kaehler_differential.D_apply KaehlerDifferential.d_apply
+#align kaehler_differential.D_apply KaehlerDifferential.D_apply
+-/
 
+#print KaehlerDifferential.span_range_derivation /-
 theorem KaehlerDifferential.span_range_derivation :
-    Submodule.span S (Set.range <| KaehlerDifferential.d R S) = ⊤ :=
+    Submodule.span S (Set.range <| KaehlerDifferential.D R S) = ⊤ :=
   by
   rw [_root_.eq_top_iff]
   rintro x -
@@ -246,13 +279,13 @@ theorem KaehlerDifferential.span_range_derivation :
   suffices
     ∃ hx,
       (KaehlerDifferential.ideal R S).toCotangent ⟨x, hx⟩ ∈
-        Submodule.span S (Set.range <| KaehlerDifferential.d R S)
+        Submodule.span S (Set.range <| KaehlerDifferential.D R S)
     by exact this.some_spec
   apply 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 ⟨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₂⟩;
@@ -260,9 +293,11 @@ theorem KaehlerDifferential.span_range_derivation :
       ⟨((KaehlerDifferential.ideal R S).restrictScalars S).smul_mem r hx₁,
         Submodule.smul_mem _ r hx₂⟩
 #align kaehler_differential.span_range_derivation KaehlerDifferential.span_range_derivation
+-/
 
 variable {R S}
 
+#print Derivation.liftKaehlerDifferential /-
 /-- The linear map from `Ω[S⁄R]`, associated with a derivation. -/
 def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ[S] M :=
   by
@@ -280,83 +315,101 @@ def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ
       rw [Derivation.tensorProductTo_mul, hx, hy, zero_smul, zero_smul, zero_add]
     · intro x y ex ey; rw [map_add, ex, ey, zero_add]
 #align derivation.lift_kaehler_differential Derivation.liftKaehlerDifferential
+-/
 
+#print Derivation.liftKaehlerDifferential_apply /-
 theorem Derivation.liftKaehlerDifferential_apply (D : Derivation R S M) (x) :
     D.liftKaehlerDifferential ((KaehlerDifferential.ideal R S).toCotangent x) =
       D.tensorProductTo x :=
   rfl
 #align derivation.lift_kaehler_differential_apply Derivation.liftKaehlerDifferential_apply
+-/
 
+#print Derivation.liftKaehlerDifferential_comp /-
 theorem Derivation.liftKaehlerDifferential_comp (D : Derivation R S M) :
-    D.liftKaehlerDifferential.compDer (KaehlerDifferential.d R S) = D :=
+    D.liftKaehlerDifferential.compDer (KaehlerDifferential.D R S) = D :=
   by
   ext a
-  dsimp [KaehlerDifferential.d_apply]
+  dsimp [KaehlerDifferential.D_apply]
   refine' (D.lift_kaehler_differential_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]
 #align derivation.lift_kaehler_differential_comp Derivation.liftKaehlerDifferential_comp
+-/
 
+#print Derivation.liftKaehlerDifferential_comp_D /-
 @[simp]
-theorem Derivation.liftKaehlerDifferential_comp_d (D' : Derivation R S M) (x : S) :
-    D'.liftKaehlerDifferential (KaehlerDifferential.d R S x) = D' x :=
+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
-#align derivation.lift_kaehler_differential_comp_D Derivation.liftKaehlerDifferential_comp_d
+#align derivation.lift_kaehler_differential_comp_D Derivation.liftKaehlerDifferential_comp_D
+-/
 
+#print Derivation.liftKaehlerDifferential_unique /-
 @[ext]
-theorem Derivation.lift_kaehlerDifferential_unique (f f' : Ω[S⁄R] →ₗ[S] M)
-    (hf : f.compDer (KaehlerDifferential.d R S) = f'.compDer (KaehlerDifferential.d R S)) :
+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
+  have : x ∈ Submodule.span S (Set.range <| KaehlerDifferential.D R S) := by
     rw [KaehlerDifferential.span_range_derivation]; trivial
   apply 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; rw [map_smul, map_smul, e]
-#align derivation.lift_kaehler_differential_unique Derivation.lift_kaehlerDifferential_unique
+#align derivation.lift_kaehler_differential_unique Derivation.liftKaehlerDifferential_unique
+-/
 
 variable (R S)
 
-theorem Derivation.liftKaehlerDifferential_d :
-    (KaehlerDifferential.d R S).liftKaehlerDifferential = LinearMap.id :=
-  Derivation.lift_kaehlerDifferential_unique _ _
-    (KaehlerDifferential.d R S).liftKaehlerDifferential_comp
-#align derivation.lift_kaehler_differential_D Derivation.liftKaehlerDifferential_d
+#print Derivation.liftKaehlerDifferential_D /-
+theorem Derivation.liftKaehlerDifferential_D :
+    (KaehlerDifferential.D R S).liftKaehlerDifferential = LinearMap.id :=
+  Derivation.liftKaehlerDifferential_unique _ _
+    (KaehlerDifferential.D R S).liftKaehlerDifferential_comp
+#align derivation.lift_kaehler_differential_D Derivation.liftKaehlerDifferential_D
+-/
 
 variable {R S}
 
-theorem KaehlerDifferential.d_tensorProductTo (x : KaehlerDifferential.ideal R S) :
-    (KaehlerDifferential.d R S).tensorProductTo x = (KaehlerDifferential.ideal R S).toCotangent x :=
+#print KaehlerDifferential.D_tensorProductTo /-
+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]
+  rw [← Derivation.liftKaehlerDifferential_apply, Derivation.liftKaehlerDifferential_D]
   rfl
-#align kaehler_differential.D_tensor_product_to KaehlerDifferential.d_tensorProductTo
+#align kaehler_differential.D_tensor_product_to KaehlerDifferential.D_tensorProductTo
+-/
 
 variable (R S)
 
+#print KaehlerDifferential.tensorProductTo_surjective /-
 theorem KaehlerDifferential.tensorProductTo_surjective :
-    Function.Surjective (KaehlerDifferential.d R S).tensorProductTo :=
+    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⟩
+  exact ⟨x, KaehlerDifferential.D_tensorProductTo x⟩
 #align kaehler_differential.tensor_product_to_surjective KaehlerDifferential.tensorProductTo_surjective
+-/
 
+#print KaehlerDifferential.linearMapEquivDerivation /-
 /-- The `S`-linear maps from `Ω[S⁄R]` to `M` are (`S`-linearly) equivalent to `R`-derivations
 from `S` to `M`.  -/
 def KaehlerDifferential.linearMapEquivDerivation : (Ω[S⁄R] →ₗ[S] M) ≃ₗ[S] Derivation R S M :=
   {
     Derivation.llcomp.flip <|
-      KaehlerDifferential.d R
+      KaehlerDifferential.D R
         S with
     invFun := Derivation.liftKaehlerDifferential
     left_inv := fun f =>
-      Derivation.lift_kaehlerDifferential_unique _ _ (Derivation.liftKaehlerDifferential_comp _)
+      Derivation.liftKaehlerDifferential_unique _ _ (Derivation.liftKaehlerDifferential_comp _)
     right_inv := Derivation.liftKaehlerDifferential_comp }
 #align kaehler_differential.linear_map_equiv_derivation KaehlerDifferential.linearMapEquivDerivation
+-/
 
+#print KaehlerDifferential.quotientCotangentIdealRingEquiv /-
 /-- 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 ≃+*
@@ -372,7 +425,9 @@ def KaehlerDifferential.quotientCotangentIdealRingEquiv :
   refine' (Ideal.quotEquivOfEq _).trans (RingHom.quotientKerEquivOfRightInverse this)
   ext; rfl
 #align kaehler_differential.quotient_cotangent_ideal_ring_equiv KaehlerDifferential.quotientCotangentIdealRingEquiv
+-/
 
+#print KaehlerDifferential.quotientCotangentIdeal /-
 /-- 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) ⧸
@@ -381,7 +436,9 @@ def KaehlerDifferential.quotientCotangentIdeal :
   { KaehlerDifferential.quotientCotangentIdealRingEquiv R S with
     commutes' := (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).apply_symm_apply }
 #align kaehler_differential.quotient_cotangent_ideal KaehlerDifferential.quotientCotangentIdeal
+-/
 
+#print KaehlerDifferential.End_equiv_aux /-
 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 _ ↔
@@ -408,7 +465,9 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
   · intro e; apply (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).Injective
     exact e₁.symm.trans (e.trans e₂)
 #align kaehler_differential.End_equiv_aux KaehlerDifferential.End_equiv_aux
+-/
 
+#print KaehlerDifferential.endEquivDerivation' /-
 -- This has type
 -- `derivation R S Ω[S⁄R] ≃ₗ[R] derivation R S (kaehler_differential.ideal R S).cotangent_ideal`
 -- But lean times-out if this is given explicitly.
@@ -418,7 +477,9 @@ noncomputable def KaehlerDifferential.endEquivDerivation' :=
   @LinearEquiv.compDer R _ _ _ _ (Ω[S⁄R]) _ _ _ _ _ _ _ _ _
     ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
 #align kaehler_differential.End_equiv_derivation' KaehlerDifferential.endEquivDerivation'
+-/
 
+#print KaehlerDifferential.endEquivAuxEquiv /-
 /-- (Implementation) An `equiv` version of `kaehler_differential.End_equiv_aux`.
 Used in `kaehler_differential.End_equiv`. -/
 def KaehlerDifferential.endEquivAuxEquiv :
@@ -428,7 +489,9 @@ def KaehlerDifferential.endEquivAuxEquiv :
       { 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)
 #align kaehler_differential.End_equiv_aux_equiv KaehlerDifferential.endEquivAuxEquiv
+-/
 
+#print KaehlerDifferential.endEquiv /-
 /--
 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`.
@@ -442,13 +505,15 @@ noncomputable def KaehlerDifferential.endEquiv :
             (KaehlerDifferential.ideal R S).cotangentIdeal_square).trans <|
         KaehlerDifferential.endEquivAuxEquiv R S
 #align kaehler_differential.End_equiv KaehlerDifferential.endEquiv
+-/
 
 section Presentation
 
-open KaehlerDifferential (d)
+open KaehlerDifferential (D)
 
 open Finsupp (single)
 
+#print KaehlerDifferential.kerTotal /-
 /-- 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)`
@@ -465,9 +530,11 @@ noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
         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)
 #align kaehler_differential.ker_total KaehlerDifferential.kerTotal
+-/
 
 local notation x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)
 
+#print KaehlerDifferential.kerTotal_mkQ_single_add /-
 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_apply,
@@ -475,7 +542,9 @@ theorem KaehlerDifferential.kerTotal_mkQ_single_add (x y z) : (z𝖣x + y) = (z
   simp_rw [← Finsupp.smul_single_one _ z, ← smul_add, ← smul_sub]
   exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inl <| ⟨⟨_, _⟩, rfl⟩))
 #align kaehler_differential.ker_total_mkq_single_add KaehlerDifferential.kerTotal_mkQ_single_add
+-/
 
+#print KaehlerDifferential.kerTotal_mkQ_single_mul /-
 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_apply,
@@ -484,23 +553,31 @@ theorem KaehlerDifferential.kerTotal_mkQ_single_mul (x y z) : (z𝖣x * y) = ((z
     smul_sub]
   exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inr <| ⟨⟨_, _⟩, rfl⟩))
 #align kaehler_differential.ker_total_mkq_single_mul KaehlerDifferential.kerTotal_mkQ_single_mul
+-/
 
+#print KaehlerDifferential.kerTotal_mkQ_single_algebraMap /-
 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⟩))
 #align kaehler_differential.ker_total_mkq_single_algebra_map KaehlerDifferential.kerTotal_mkQ_single_algebraMap
+-/
 
-theorem KaehlerDifferential.kerTotal_mkQ_single_algebra_map_one (x) : (x𝖣1) = 0 := by
+#print KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one /-
+theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one (x) : (x𝖣1) = 0 := by
   rw [← (algebraMap R S).map_one, KaehlerDifferential.kerTotal_mkQ_single_algebraMap]
-#align kaehler_differential.ker_total_mkq_single_algebra_map_one KaehlerDifferential.kerTotal_mkQ_single_algebra_map_one
+#align kaehler_differential.ker_total_mkq_single_algebra_map_one KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one
+-/
 
+#print KaehlerDifferential.kerTotal_mkQ_single_smul /-
 theorem KaehlerDifferential.kerTotal_mkQ_single_smul (r : R) (x y) : (y𝖣r • x) = r • y𝖣x := by
   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]
 #align kaehler_differential.ker_total_mkq_single_smul KaehlerDifferential.kerTotal_mkQ_single_smul
+-/
 
+#print KaehlerDifferential.derivationQuotKerTotal /-
 /-- The (universal) derivation into `(S →₀ S) ⧸ kaehler_differential.ker_total R S`. -/
 noncomputable def KaehlerDifferential.derivationQuotKerTotal :
     Derivation R S ((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S)
@@ -508,20 +585,24 @@ noncomputable def KaehlerDifferential.derivationQuotKerTotal :
   toFun x := 1𝖣x
   map_add' x y := KaehlerDifferential.kerTotal_mkQ_single_add _ _ _ _ _
   map_smul' r s := KaehlerDifferential.kerTotal_mkQ_single_smul _ _ _ _ _
-  map_one_eq_zero' := KaehlerDifferential.kerTotal_mkQ_single_algebra_map_one _ _ _
+  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)
 #align kaehler_differential.derivation_quot_ker_total KaehlerDifferential.derivationQuotKerTotal
+-/
 
+#print KaehlerDifferential.derivationQuotKerTotal_apply /-
 theorem KaehlerDifferential.derivationQuotKerTotal_apply (x) :
     KaehlerDifferential.derivationQuotKerTotal R S x = 1𝖣x :=
   rfl
 #align kaehler_differential.derivation_quot_ker_total_apply KaehlerDifferential.derivationQuotKerTotal_apply
+-/
 
+#print KaehlerDifferential.derivationQuotKerTotal_lift_comp_total /-
 theorem KaehlerDifferential.derivationQuotKerTotal_lift_comp_total :
     (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential.comp
-        (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.d R S)) =
+        (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S)) =
       Submodule.mkQ _ :=
   by
   apply Finsupp.lhom_ext
@@ -529,9 +610,11 @@ theorem KaehlerDifferential.derivationQuotKerTotal_lift_comp_total :
   conv_rhs => rw [← Finsupp.smul_single_one a b, LinearMap.map_smul]
   simp [KaehlerDifferential.derivationQuotKerTotal_apply]
 #align kaehler_differential.derivation_quot_ker_total_lift_comp_total KaehlerDifferential.derivationQuotKerTotal_lift_comp_total
+-/
 
+#print KaehlerDifferential.kerTotal_eq /-
 theorem KaehlerDifferential.kerTotal_eq :
-    (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.d R S)).ker =
+    (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S)).ker =
       KaehlerDifferential.kerTotal R S :=
   by
   apply le_antisymm
@@ -541,19 +624,23 @@ theorem KaehlerDifferential.kerTotal_eq :
   · rw [KaehlerDifferential.kerTotal, Submodule.span_le]
     rintro _ ((⟨⟨x, y⟩, rfl⟩ | ⟨⟨x, y⟩, rfl⟩) | ⟨x, rfl⟩) <;> dsimp <;> simp [LinearMap.mem_ker]
 #align kaehler_differential.ker_total_eq KaehlerDifferential.kerTotal_eq
+-/
 
+#print KaehlerDifferential.total_surjective /-
 theorem KaehlerDifferential.total_surjective :
-    Function.Surjective (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.d R S)) := by
+    Function.Surjective (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S)) := by
   rw [← LinearMap.range_eq_top, Finsupp.range_total, KaehlerDifferential.span_range_derivation]
 #align kaehler_differential.total_surjective KaehlerDifferential.total_surjective
+-/
 
+#print KaehlerDifferential.quotKerTotalEquiv /-
 /-- `Ω[S⁄R]` is isomorphic to `S` copies of `S` with kernel `kaehler_differential.ker_total`. -/
 @[simps]
 noncomputable def KaehlerDifferential.quotKerTotalEquiv :
     ((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S) ≃ₗ[S] Ω[S⁄R] :=
   {
     (KaehlerDifferential.kerTotal R S).liftQ
-      (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.d R S))
+      (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S))
       (KaehlerDifferential.kerTotal_eq R
           S).ge with
     invFun := (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential
@@ -569,13 +656,16 @@ noncomputable def KaehlerDifferential.quotKerTotalEquiv :
           x]
       rfl }
 #align kaehler_differential.quot_ker_total_equiv KaehlerDifferential.quotKerTotalEquiv
+-/
 
-theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_d :
+#print KaehlerDifferential.quotKerTotalEquiv_symm_comp_D /-
+theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_D :
     (KaehlerDifferential.quotKerTotalEquiv R S).symm.toLinearMap.compDer
-        (KaehlerDifferential.d R S) =
+        (KaehlerDifferential.D R S) =
       KaehlerDifferential.derivationQuotKerTotal R S :=
   by convert (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential_comp using 0
-#align kaehler_differential.quot_ker_total_equiv_symm_comp_D KaehlerDifferential.quotKerTotalEquiv_symm_comp_d
+#align kaehler_differential.quot_ker_total_equiv_symm_comp_D KaehlerDifferential.quotKerTotalEquiv_symm_comp_D
+-/
 
 variable (A B : Type _) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Algebra R B]
 
@@ -586,6 +676,7 @@ local notation "finsupp_map" =>
   (Finsupp.mapRange.linearMap (Algebra.ofId A B).toLinearMap).comp
     (Finsupp.lmapDomain A A (algebraMap A B))
 
+#print KaehlerDifferential.kerTotal_map /-
 theorem KaehlerDifferential.kerTotal_map (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)) =
@@ -605,6 +696,7 @@ theorem KaehlerDifferential.kerTotal_map (h : Function.Surjective (algebraMap A
   simp_rw [IsScalarTower.algebraMap_apply R S B]
   exact Set.range_comp_subset_range (algebraMap R S) fun x => single (algebraMap S B x) (1 : B)
 #align kaehler_differential.ker_total_map KaehlerDifferential.kerTotal_map
+-/
 
 end Presentation
 
@@ -621,6 +713,7 @@ variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
 
 variable {R B}
 
+#print Derivation.compAlgebraMap /-
 /-- For a tower `R → A → B` and an `R`-derivation `B → M`, we may compose with `A → B` to obtain an
 `R`-derivation `A → M`. -/
 def Derivation.compAlgebraMap [Module A M] [Module B M] [IsScalarTower A B M]
@@ -630,9 +723,11 @@ def Derivation.compAlgebraMap [Module A M] [Module B M] [IsScalarTower A B M]
   leibniz' a b := by simp
   toLinearMap := d.toLinearMap.comp (IsScalarTower.toAlgHom R A B).toLinearMap
 #align derivation.comp_algebra_map Derivation.compAlgebraMap
+-/
 
 variable (R B)
 
+#print KaehlerDifferential.map /-
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` given a square
 A --→ B
 ↑     ↑
@@ -640,23 +735,29 @@ A --→ B
 R --→ S -/
 def KaehlerDifferential.map : Ω[A⁄R] →ₗ[A] Ω[B⁄S] :=
   Derivation.liftKaehlerDifferential
-    (((KaehlerDifferential.d S B).restrictScalars R).comp_algebraMap A)
+    (((KaehlerDifferential.D S B).restrictScalars R).comp_algebraMap A)
 #align kaehler_differential.map KaehlerDifferential.map
+-/
 
+#print KaehlerDifferential.map_compDer /-
 theorem KaehlerDifferential.map_compDer :
-    (KaehlerDifferential.map R S A B).compDer (KaehlerDifferential.d R A) =
-      ((KaehlerDifferential.d S B).restrictScalars R).comp_algebraMap A :=
+    (KaehlerDifferential.map R S A B).compDer (KaehlerDifferential.D R A) =
+      ((KaehlerDifferential.D S B).restrictScalars R).comp_algebraMap A :=
   Derivation.liftKaehlerDifferential_comp _
 #align kaehler_differential.map_comp_der KaehlerDifferential.map_compDer
+-/
 
-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) :=
+#print KaehlerDifferential.map_D /-
+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
-#align kaehler_differential.map_D KaehlerDifferential.map_d
+#align kaehler_differential.map_D KaehlerDifferential.map_D
+-/
 
 open IsScalarTower (toAlgHom)
 
+#print KaehlerDifferential.map_surjective_of_surjective /-
 theorem KaehlerDifferential.map_surjective_of_surjective
     (h : Function.Surjective (algebraMap A B)) :
     Function.Surjective (KaehlerDifferential.map R S A B) :=
@@ -666,16 +767,20 @@ theorem KaehlerDifferential.map_surjective_of_surjective
     Submodule.span_le]
   rintro _ ⟨x, rfl⟩
   obtain ⟨y, rfl⟩ := h x
-  rw [← KaehlerDifferential.map_d R S A B]
+  rw [← KaehlerDifferential.map_D R S A B]
   exact ⟨_, rfl⟩
 #align kaehler_differential.map_surjective_of_surjective KaehlerDifferential.map_surjective_of_surjective
+-/
 
+#print KaehlerDifferential.mapBaseChange /-
 /-- 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)
 #align kaehler_differential.map_base_change KaehlerDifferential.mapBaseChange
+-/
 
+#print KaehlerDifferential.mapBaseChange_tmul /-
 @[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 :=
@@ -684,6 +789,7 @@ theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) :
   congr 1
   exact IsBaseChange.lift_eq _ _ _
 #align kaehler_differential.map_base_change_tmul KaehlerDifferential.mapBaseChange_tmul
+-/
 
 end ExactSequence
 
Diff
@@ -170,7 +170,7 @@ instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRi
     IsScalarTower R₁ R₂ (Ω[S⁄R]) :=
   by
   convert RestrictScalars.isScalarTower R₁ R₂ (Ω[S⁄R]) using 1
-  ext (x m)
+  ext x m
   show algebraMap R₁ S x • m = algebraMap R₂ S (algebraMap R₁ R₂ x) • m
   rw [← IsScalarTower.algebraMap_apply]
 #align kaehler_differential.is_scalar_tower_of_tower KaehlerDifferential.isScalarTower_of_tower
@@ -178,7 +178,7 @@ instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRi
 instance KaehlerDifferential.is_scalar_tower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) :=
   by
   convert RestrictScalars.isScalarTower R (S ⊗[R] S) (Ω[S⁄R]) using 1
-  ext (x m)
+  ext x m
   show algebraMap R S x • m = algebraMap R (S ⊗[R] S) x • m
   simp_rw [IsScalarTower.algebraMap_apply R S (S ⊗[R] S), IsScalarTower.algebraMap_smul]
 #align kaehler_differential.is_scalar_tower' KaehlerDifferential.is_scalar_tower'
Diff
@@ -152,7 +152,6 @@ deriving AddCommGroup,
   «./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler module[module] tensor_product(S, R, S)»
 #align kaehler_differential KaehlerDifferential
 
--- mathport name: «exprΩ[ ⁄ ]»
 notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
 
 instance : Nonempty (Ω[S⁄R]) :=
@@ -467,7 +466,6 @@ noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
       Set.range fun x : R => single (algebraMap R S x) 1)
 #align kaehler_differential.ker_total KaehlerDifferential.kerTotal
 
--- mathport name: «expr 𝖣 »
 local notation 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 :=
@@ -583,7 +581,6 @@ variable (A B : Type _) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [A
 
 variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
 
--- mathport name: exprfinsupp_map
 -- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
 local notation "finsupp_map" =>
   (Finsupp.mapRange.linearMap (Algebra.ofId A B).toLinearMap).comp
Diff
@@ -137,7 +137,7 @@ theorem KaehlerDifferential.span_range_eq_ideal :
     exact Submodule.subset_span
 #align kaehler_differential.span_range_eq_ideal KaehlerDifferential.span_range_eq_ideal
 
-/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler module[module] tensor_product(S, R, S) -/
+/- ./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler module[module] tensor_product(S, R, S) -/
 /-- 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
@@ -149,7 +149,7 @@ Note that the slash is `\textfractionsolidus`.
 def KaehlerDifferential : Type _ :=
   (KaehlerDifferential.ideal R S).Cotangent
 deriving AddCommGroup,
-  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler module[module] tensor_product(S, R, S)»
+  «./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler module[module] tensor_product(S, R, S)»
 #align kaehler_differential KaehlerDifferential
 
 -- mathport name: «exprΩ[ ⁄ ]»
@@ -219,7 +219,8 @@ def KaehlerDifferential.d : Derivation R S (Ω[S⁄R]) :=
       dsimp [KaehlerDifferential.dLinearMap_apply]
       rw [← LinearMap.map_smul_of_tower, ← LinearMap.map_smul_of_tower, ← map_add,
         Ideal.toCotangent_eq, pow_two]
-      convert Submodule.mul_mem_mul (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R a : _)
+      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 [AddSubgroupClass.coe_sub, Submodule.coe_add, Submodule.coe_mk,
@@ -575,7 +576,7 @@ 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 using 0
+  by convert (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential_comp using 0
 #align kaehler_differential.quot_ker_total_equiv_symm_comp_D KaehlerDifferential.quotKerTotalEquiv_symm_comp_d
 
 variable (A B : Type _) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Algebra R B]
Diff
@@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Nicolò Cavalleri, Andrew Yang
 
 ! This file was ported from Lean 3 source module ring_theory.kaehler
-! leanprover-community/mathlib commit 73f96237417835f148a1f7bc1ff55f67119b7166
+! leanprover-community/mathlib commit b608348ffaeb7f557f2fd46876037abafd326ff3
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.RingTheory.Derivation
+import Mathbin.RingTheory.Derivation.ToSquareZero
 import Mathbin.RingTheory.Ideal.Cotangent
 import Mathbin.RingTheory.IsTensorProduct
 
Diff
@@ -147,7 +147,8 @@ We also provide the notation `Ω[S⁄R]` for `kaehler_differential R S`.
 Note that the slash is `\textfractionsolidus`.
 -/
 def KaehlerDifferential : Type _ :=
-  (KaehlerDifferential.ideal R S).Cotangent deriving AddCommGroup,
+  (KaehlerDifferential.ideal R S).Cotangent
+deriving AddCommGroup,
   «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler module[module] tensor_product(S, R, S)»
 #align kaehler_differential KaehlerDifferential
 
@@ -241,7 +242,7 @@ theorem KaehlerDifferential.span_range_derivation :
   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
+  rw [← KaehlerDifferential.submodule_span_range_eq_ideal] at this 
   suffices
     ∃ hx,
       (KaehlerDifferential.ideal R S).toCotangent ⟨x, hx⟩ ∈
Diff
@@ -40,7 +40,7 @@ import Mathbin.RingTheory.IsTensorProduct
 
 section KaehlerDifferential
 
-open TensorProduct
+open scoped TensorProduct
 
 open Algebra
 
Diff
@@ -78,17 +78,11 @@ theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S)
   by
   apply TensorProduct.induction_on x
   · rw [MulZeroClass.zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero]
-  swap;
-  · rintro
-    simp only [add_mul, map_add, add_smul, *, smul_add]
-    rw [add_add_add_comm]
+  swap; · rintro; simp only [add_mul, map_add, add_smul, *, smul_add]; rw [add_add_add_comm]
   intro x₁ x₂
   apply TensorProduct.induction_on y
   · rw [MulZeroClass.mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero]
-  swap;
-  · rintro
-    simp only [mul_add, map_add, add_smul, *, smul_add]
-    rw [add_add_add_comm]
+  swap; · rintro; simp only [mul_add, map_add, add_smul, *, smul_add]; rw [add_add_add_comm]
   intro x y
   simp only [tensor_product.tmul_mul_tmul, Derivation.tensorProductTo,
     TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lift.tmul',
@@ -115,8 +109,7 @@ theorem KaehlerDifferential.submodule_span_range_eq_ideal :
     rw [← this]
     clear this hx
     apply TensorProduct.induction_on x <;> clear x
-    · rw [map_zero, TensorProduct.zero_tmul, sub_zero]
-      exact zero_mem _
+    · rw [map_zero, TensorProduct.zero_tmul, sub_zero]; exact zero_mem _
     · intro x y
       convert_to x • (1 ⊗ₜ y - y ⊗ₜ 1) ∈ _
       ·
@@ -260,9 +253,8 @@ theorem KaehlerDifferential.span_range_derivation :
     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₂⟩
+  · 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₂⟩
@@ -285,8 +277,7 @@ def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ
     · rintro x (hx : _ = _) ⟨y, hy : _ = _⟩ -
       dsimp
       rw [Derivation.tensorProductTo_mul, hx, hy, zero_smul, zero_smul, zero_add]
-    · intro x y ex ey
-      rw [map_add, ex, ey, zero_add]
+    · intro x y ex ey; rw [map_add, ex, ey, zero_add]
 #align derivation.lift_kaehler_differential Derivation.liftKaehlerDifferential
 
 theorem Derivation.liftKaehlerDifferential_apply (D : Derivation R S M) (x) :
@@ -317,18 +308,13 @@ theorem Derivation.lift_kaehlerDifferential_unique (f f' : Ω[S⁄R] →ₗ[S] M
     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
+  have : x ∈ Submodule.span S (Set.range <| KaehlerDifferential.d R S) := by
+    rw [KaehlerDifferential.span_range_derivation]; trivial
   apply Submodule.span_induction this
-  · rintro _ ⟨x, rfl⟩
-    exact congr_arg (fun D : Derivation R S M => D x) hf
+  · 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
-    rw [map_smul, map_smul, e]
+  · intro x y hx hy; rw [map_add, map_add, hx, hy]
+  · intro a x e; rw [map_smul, map_smul, e]
 #align derivation.lift_kaehler_differential_unique Derivation.lift_kaehlerDifferential_unique
 
 variable (R S)
@@ -379,13 +365,11 @@ def KaehlerDifferential.quotientCotangentIdealRingEquiv :
     Function.RightInverse tensor_product.include_left
       (↑(tensor_product.lmul' R : S ⊗[R] S →ₐ[R] S) : S ⊗[R] S →+* S) :=
     by
-    intro x
-    rw [AlgHom.coe_toRingHom, ← AlgHom.comp_apply, tensor_product.lmul'_comp_include_left]
+    intro x; rw [AlgHom.coe_toRingHom, ← AlgHom.comp_apply, tensor_product.lmul'_comp_include_left]
     rfl
   refine' (Ideal.quotCotangent _).trans _
   refine' (Ideal.quotEquivOfEq _).trans (RingHom.quotientKerEquivOfRightInverse this)
-  ext
-  rfl
+  ext; rfl
 #align kaehler_differential.quotient_cotangent_ideal_ring_equiv KaehlerDifferential.quotientCotangentIdealRingEquiv
 
 /-- The quotient ring of `S ⊗ S ⧸ J ^ 2` by `Ω[S⁄R]` is isomorphic to `S` as an `S`-algebra. -/
@@ -409,10 +393,7 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
     (tensor_product.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
+    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
@@ -423,8 +404,7 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
             (@RingEquiv.congr_arg _ _ _ _ _ _
               (KaehlerDifferential.quotientCotangentIdealRingEquiv R S) _ _ e)).trans
         e₂.symm
-  · intro e
-    apply (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).Injective
+  · intro e; apply (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).Injective
     exact e₁.symm.trans (e.trans e₂)
 #align kaehler_differential.End_equiv_aux KaehlerDifferential.End_equiv_aux
 
@@ -531,10 +511,7 @@ noncomputable def KaehlerDifferential.derivationQuotKerTotal :
   map_one_eq_zero' := KaehlerDifferential.kerTotal_mkQ_single_algebra_map_one _ _ _
   leibniz' a b :=
     (KaehlerDifferential.kerTotal_mkQ_single_mul _ _ _ _ _).trans
-      (by
-        simp_rw [← Finsupp.smul_single_one _ (1 * _ : S)]
-        dsimp
-        simp)
+      (by simp_rw [← Finsupp.smul_single_one _ (1 * _ : S)]; dsimp; simp)
 #align kaehler_differential.derivation_quot_ker_total KaehlerDifferential.derivationQuotKerTotal
 
 theorem KaehlerDifferential.derivationQuotKerTotal_apply (x) :

Changes in mathlib4

mathlib3
mathlib4
feat(RingTheory/Kaehler): The exact sequence B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A] → 0. (#11925)

Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com>

Diff
@@ -6,6 +6,7 @@ Authors: Nicolò Cavalleri, Andrew Yang
 import Mathlib.RingTheory.Derivation.ToSquareZero
 import Mathlib.RingTheory.Ideal.Cotangent
 import Mathlib.RingTheory.IsTensorProduct
+import Mathlib.Algebra.Exact
 import Mathlib.Algebra.MvPolynomial.PDeriv
 import Mathlib.Algebra.Polynomial.Derivation
 
@@ -28,8 +29,12 @@ import Mathlib.Algebra.Polynomial.Derivation
   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
+- `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.
 
 ## Future project
 
@@ -339,6 +344,7 @@ theorem KaehlerDifferential.tensorProductTo_surjective :
 
 /-- 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
@@ -591,8 +597,18 @@ theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_D :
 set_option linter.uppercaseLean3 false in
 #align kaehler_differential.quot_ker_total_equiv_symm_comp_D KaehlerDifferential.quotKerTotalEquiv_symm_comp_D
 
-variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Algebra R B]
-variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
+end Presentation
+
+section ExactSequence
+
+/- We have the commutative diagram
+A --→ B
+↑     ↑
+|     |
+R --→ S -/
+variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
+variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
+variable [SMulCommClass S A B]
 
 unsuppress_compilation in
 -- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
@@ -600,9 +616,19 @@ 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 (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)) =
+        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]
@@ -620,21 +646,23 @@ theorem KaehlerDifferential.kerTotal_map (h : Function.Surjective (algebraMap A
   rw [sup_eq_right]
   apply Submodule.span_mono
   simp_rw [IsScalarTower.algebraMap_apply R S B]
-  exact Set.range_comp_subset_range (algebraMap R S) fun x => single (algebraMap S B x) (1 : B)
+  exact Set.range_comp_subset_range (algebraMap R S)
+    fun x => Finsupp.single (algebraMap S B x) (1 : B)
 #align kaehler_differential.ker_total_map KaehlerDifferential.kerTotal_map
 
-end Presentation
-
-section ExactSequence
-
-/- We have the commutative diagram
-A --→ B
-↑     ↑
-|     |
-R --→ S -/
-variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
-variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
-variable [SMulCommClass S A 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' (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
+  refine congr_arg Set.range ?_
+  ext; simp [IsScalarTower.algebraMap_eq R A B]
 
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄S]` given a square
 A --→ B
@@ -652,6 +680,7 @@ theorem KaehlerDifferential.map_compDer :
   Derivation.liftKaehlerDifferential_comp _
 #align kaehler_differential.map_comp_der KaehlerDifferential.map_compDer
 
+@[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) :=
@@ -659,6 +688,23 @@ theorem KaehlerDifferential.map_D (x : A) :
 set_option linter.uppercaseLean3 false in
 #align kaehler_differential.map_D KaehlerDifferential.map_D
 
+theorem KaehlerDifferential.ker_map :
+    LinearMap.ker (KaehlerDifferential.map R S A B) =
+      (((kerTotal S B).restrictScalars A).comap finsupp_map).map
+        (Finsupp.total A (Ω[A⁄R]) A (D R A)) := by
+  rw [← Submodule.map_comap_eq_of_surjective (total_surjective R A) (LinearMap.ker _)]
+  congr 1
+  ext x
+  simp only [Submodule.mem_comap, LinearMap.mem_ker, Finsupp.apply_total, ← kerTotal_eq,
+    Submodule.restrictScalars_mem]
+  simp only [Finsupp.total_apply, Function.comp_apply, LinearMap.coe_comp, Finsupp.lmapDomain_apply,
+    Finsupp.mapRange.linearMap_apply]
+  rw [Finsupp.sum_mapRange_index, Finsupp.sum_mapDomain_index]
+  · simp [ofId]
+  · simp
+  · simp [add_smul]
+  · simp
+
 open IsScalarTower (toAlgHom)
 
 theorem KaehlerDifferential.map_surjective_of_surjective
@@ -673,6 +719,10 @@ theorem KaehlerDifferential.map_surjective_of_surjective
   exact ⟨_, rfl⟩
 #align kaehler_differential.map_surjective_of_surjective KaehlerDifferential.map_surjective_of_surjective
 
+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] :=
@@ -687,6 +737,36 @@ theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) :
   exact IsBaseChange.lift_eq _ _ _
 #align kaehler_differential.map_base_change_tmul KaehlerDifferential.mapBaseChange_tmul
 
+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 using TensorProduct.induction_on with r s
+    · simp
+    · obtain ⟨x, rfl⟩ := total_surjective _ _ s
+      simp only [mapBaseChange_tmul, LinearMap.mem_ker, map_smul]
+      induction x using Finsupp.induction_linear
+      · simp
+      · simp [smul_add, *]
+      · simp
+    · rw [map_add]; exact add_mem ‹_› ‹_›
+  · convert_to (kerTotal A B).map (Finsupp.total B (Ω[B⁄R]) 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 ExactSequence
 
 section MvPolynomial
feat(RingTheory/Kaehler): The Kaehler differential module of polynomial algebras. (#11895)

Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com>

Diff
@@ -6,6 +6,8 @@ Authors: Nicolò Cavalleri, Andrew Yang
 import Mathlib.RingTheory.Derivation.ToSquareZero
 import Mathlib.RingTheory.Ideal.Cotangent
 import Mathlib.RingTheory.IsTensorProduct
+import Mathlib.Algebra.MvPolynomial.PDeriv
+import Mathlib.Algebra.Polynomial.Derivation
 
 #align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364"
 
@@ -687,4 +689,117 @@ theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) :
 
 end ExactSequence
 
+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.total σ _ _ (fun x ↦ D _ _ (MvPolynomial.X x))
+  right_inv := by
+    intro x
+    induction' x using Finsupp.induction_linear with _ _ _ _ a b
+    · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]; rw [map_zero, map_zero]
+    · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, map_add] at *; simp only [*]
+    · simp [LinearMap.map_smul, -map_smul]
+  left_inv := by
+    intro x
+    obtain ⟨x, rfl⟩ := total_surjective _ _ x
+    induction' x using Finsupp.induction_linear with _ _ _ _ a b
+    · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]; rw [map_zero, map_zero, map_zero]
+    · simp only [map_add, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom] at *; simp only [*]
+    · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Finsupp.total_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 _ _ (.X i) := by
+  apply (mvPolynomialBasis R σ).repr.injective; simp [LinearEquiv.map_smul, -map_smul]
+
+
+@[simp]
+lemma KaehlerDifferential.mvPolynomialBasis_apply (σ) (i) :
+    mvPolynomialBasis R σ i = D _ _ (.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⟩ := total_surjective _ _ x
+    induction' x using Finsupp.induction_linear with x y hx hy x y
+    · simp
+    · simp only [map_add, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, LinearMap.flip_apply,
+        AlgHom.toLinearMap_apply, lsmul_coe] at *; simp only [*]
+    · 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
+
 end KaehlerDifferential
chore(RingTheory/Ideal/Cotangent): Restore lemmasOnly config on Ideal.toCotangent. (#12088)
Diff
@@ -207,12 +207,12 @@ set_option linter.uppercaseLean3 false in
 def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
   { toLinearMap := KaehlerDifferential.DLinearMap R S
     map_one_eq_zero' := by
-      dsimp [KaehlerDifferential.DLinearMap_apply]
+      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, - Ideal.toCotangent_apply]
+      dsimp [KaehlerDifferential.DLinearMap_apply]
       -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
       erw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
         ← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]), ← map_add, Ideal.toCotangent_eq, pow_two]
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -57,7 +57,6 @@ theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) :
 #align kaehler_differential.one_smul_sub_smul_one_mem_ideal KaehlerDifferential.one_smul_sub_smul_one_mem_ideal
 
 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`. -/
@@ -591,7 +590,6 @@ set_option linter.uppercaseLean3 false in
 #align kaehler_differential.quot_ker_total_equiv_symm_comp_D KaehlerDifferential.quotKerTotalEquiv_symm_comp_D
 
 variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Algebra R B]
-
 variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
 
 unsuppress_compilation in
@@ -633,9 +631,7 @@ A --→ B
 |     |
 R --→ S -/
 variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
-
 variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
-
 variable [SMulCommClass S A B]
 
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄S]` given a square
fix(RingTheory.Kaehler): fix map docstring (#11459)
Diff
@@ -638,7 +638,7 @@ variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
 
 variable [SMulCommClass S A B]
 
-/-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` given a square
+/-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄S]` given a square
 A --→ B
 ↑     ↑
 |     |
chore: tidy various files (#11135)
Diff
@@ -264,9 +264,10 @@ def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ
     (Submodule.Quotient.restrictScalarsEquiv S _).symm.toLinearMap
   · exact D.tensorProductTo.comp ((KaehlerDifferential.ideal R S).subtype.restrictScalars S)
   · intro x hx
-    change _ = _
+    rw [LinearMap.mem_ker]
     refine Submodule.smul_induction_on hx ?_ ?_
-    · rintro x (hx : _ = _) y -
+    · 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]
chore(Algebra.Basic): override toFun and smul in Algebra.id (#9949)

The current definition of Algebra.id is (RingHom.id _).toAlgebra. The problem with this is that RingHom.id is a def and is not reducible. Thus Lean will often refuse to unfold it causing unification to fail unecessarily in typeclass searches. This overrides the data fields from RingHom.id.

Diff
@@ -268,8 +268,7 @@ def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ
     refine Submodule.smul_induction_on hx ?_ ?_
     · rintro x (hx : _ = _) y -
       dsimp
-      rw [show ↑(x • y) = x * ↑y by rfl, Derivation.tensorProductTo_mul, hx, y.prop, zero_smul,
-        zero_smul, zero_add]
+      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]
 #align derivation.lift_kaehler_differential Derivation.liftKaehlerDifferential
 
chore(*): rename FunLike to DFunLike (#9785)

This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.

This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:

sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean     
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -482,8 +482,8 @@ noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
 
 unsuppress_compilation in
 -- Porting note: was `local notation x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)`
--- but not having `FunLike.coe` leads to `kerTotal_mkQ_single_smul` failing.
-local notation3 x "𝖣" y => FunLike.coe (KaehlerDifferential.kerTotal R S).mkQ (single y x)
+-- but not having `DFunLike.coe` leads to `kerTotal_mkQ_single_smul` failing.
+local notation3 x "𝖣" y => DFunLike.coe (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)),
chore: gather results about Submodule.restrictScalars into new file (#9765)

This is a straight copy-paste: there are no new lemmas and nothing has been removed or renamed. The only changes are a few lemmas where argument explicitness or ordering has changed (and where it did not seem to make sense to replicate the old argument explicitness or ordering).

Diff
@@ -666,7 +666,7 @@ 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 B A,
+  rw [← LinearMap.range_eq_top, _root_.eq_top_iff, ← @Submodule.restrictScalars_top A B,
     ← KaehlerDifferential.span_range_derivation, Submodule.restrictScalars_span _ _ h,
     Submodule.span_le]
   rintro _ ⟨x, rfl⟩
feat(Algebra): generalize Basis.smul (#9382)

Add various LinearMap.CompatibleSMul instances that ultimately lead to generalization of Basis.smul to allow a noncommutative base ring. The key observations that allows the generalization are IsScalarTower.smulHomClass and isScalarTower_of_injective.

Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>

Diff
@@ -511,6 +511,7 @@ theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one (x) : (x𝖣1) =
 #align kaehler_differential.ker_total_mkq_single_algebra_map_one KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one
 
 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]
feat(RingTheory/TensorProduct): Tensor product for CommSemiring (#9125)

Added the instance of TensorProduct.instCommRing.

Previously we only had the CommRing and Semiring instance; this moves an existing proof to populate the intermediate instance.

Co-authored-by: Xavier Xarles <56635243+XavierXarles@users.noreply.github.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -400,19 +400,19 @@ local instance smul_SSmod_SSmod : SMul (S ⊗[R] S ⧸ KaehlerDifferential.ideal
 @[nolint defLemma]
 local instance isScalarTower_S_right :
     IsScalarTower S (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
-      (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := IsScalarTower.right
+      (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right
 
 /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
 @[nolint defLemma]
 local instance isScalarTower_R_right :
     IsScalarTower R (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
-      (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := IsScalarTower.right
+      (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right
 
 /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
 @[nolint defLemma]
 local instance isScalarTower_SS_right : IsScalarTower (S ⊗[R] S)
     (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) :=
-  IsScalarTower.right
+  Ideal.Quotient.isScalarTower_right
 
 /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
 local instance instS : Module S (KaehlerDifferential.ideal R S).cotangentIdeal :=
chore(RingTheory/Derivation/Basic): generalize Derivation.compAlgebraMap to semirings (#8151)

Also adds a simps configuration so we get nice lemmas names with @[simps] and shuffles the variable order to put all the types first

Diff
@@ -635,18 +635,6 @@ variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
 
 variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
 
-variable {R B}
-
-/-- For a tower `R → A → B` and an `R`-derivation `B → M`, we may compose with `A → B` to obtain an
-`R`-derivation `A → M`. -/
-def Derivation.compAlgebraMap [Module A M] [Module B M] [IsScalarTower A B M]
-    (d : Derivation R B M) : Derivation R A M where
-  map_one_eq_zero' := by simp
-  leibniz' a b := by simp
-  toLinearMap := d.toLinearMap.comp (IsScalarTower.toAlgHom R A B).toLinearMap
-#align derivation.comp_algebra_map Derivation.compAlgebraMap
-
-variable (R B)
 variable [SMulCommClass S A B]
 
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` given a square
feat: have notation3 use elaborator when generating matchers, add support for pi/lambda (#6833)

notation3 was generating matchers directly from syntax, which included a half-baked implementation of a term elaborator. This switches to elaborating the term and then generating matchers from the elaborated term. This

  1. is more robust and consistent, since it uses the main elaborator and one can make use of other notations
  2. has the nice side effect of adding term info to expansions in the notation3 command
  3. can unfortunately generate matchers that are more restrictive than before since they also match against elaborated features such as implicit arguments.

We now also generate matchers for expansions that have pi types and lambda expressions.

Diff
@@ -482,9 +482,8 @@ noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
 
 unsuppress_compilation in
 -- Porting note: was `local notation x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)`
--- but `notation3` wants an explicit expansion to be able to generate a pretty printer.
-local notation3 x "𝖣" y =>
-  FunLike.coe (Submodule.mkQ (KaehlerDifferential.kerTotal R S)) (single y x)
+-- but not having `FunLike.coe` leads to `kerTotal_mkQ_single_smul` failing.
+local notation3 x "𝖣" y => FunLike.coe (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)),
Revert "chore: revert #7703 (#7710)"

This reverts commit f3695eb2.

Diff
@@ -214,7 +214,8 @@ def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
     leibniz' := fun a b => by
       have : LinearMap.CompatibleSMul { x // x ∈ ideal R S } (Ω[S⁄R]) S (S ⊗[R] S) := inferInstance
       dsimp [KaehlerDifferential.DLinearMap_apply, - Ideal.toCotangent_apply]
-      rw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
+      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+      erw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
         ← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]), ← map_add, 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
chore: revert #7703 (#7710)

This reverts commit 26eb2b0a.

Diff
@@ -214,8 +214,7 @@ def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
     leibniz' := fun a b => by
       have : LinearMap.CompatibleSMul { x // x ∈ ideal R S } (Ω[S⁄R]) S (S ⊗[R] S) := inferInstance
       dsimp [KaehlerDifferential.DLinearMap_apply, - Ideal.toCotangent_apply]
-      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-      erw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
+      rw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
         ← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]), ← map_add, 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
chore: bump toolchain to v4.2.0-rc2 (#7703)

This includes all the changes from #7606.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -214,7 +214,8 @@ def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
     leibniz' := fun a b => by
       have : LinearMap.CompatibleSMul { x // x ∈ ideal R S } (Ω[S⁄R]) S (S ⊗[R] S) := inferInstance
       dsimp [KaehlerDifferential.DLinearMap_apply, - Ideal.toCotangent_apply]
-      rw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
+      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+      erw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
         ← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]), ← map_add, 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
feat: use suppress_compilation in tensor products (#7504)

More principled version of #7281.

Diff
@@ -34,6 +34,8 @@ import Mathlib.RingTheory.IsTensorProduct
 - Define the `IsKaehlerDifferential` predicate.
 -/
 
+suppress_compilation
+
 section KaehlerDifferential
 
 open scoped TensorProduct
@@ -477,6 +479,7 @@ noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
       Set.range fun x : R => single (algebraMap R S x) 1)
 #align kaehler_differential.ker_total KaehlerDifferential.kerTotal
 
+unsuppress_compilation in
 -- Porting note: was `local notation x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)`
 -- but `notation3` wants an explicit expansion to be able to generate a pretty printer.
 local notation3 x "𝖣" y =>
@@ -590,6 +593,7 @@ variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Al
 
 variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
 
+unsuppress_compilation in
 -- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
 local macro "finsupp_map" : term =>
   `((Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp
feat(RingTheory/TensorProduct): non-unital algebras (#7106)

Mathlib already knows that the tensor product of two rings is a ring. This splits the instance into multiple intermediate pieces so as to conclude analogous results for non-unital and non-associative rings.

Diff
@@ -699,4 +699,3 @@ theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) :
 end ExactSequence
 
 end KaehlerDifferential
-
fix (RingTheory.Kaehler): short cut instances to remove timeouts (#6149)

This obviates the need for bumping timeout limits in RingTheory.Kaehler at the expense of explicit instances that Lean should easily be finding.

Co-authored-by: Kevin Buzzard <k.buzzard@imperial.ac.uk> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -141,7 +141,7 @@ To view elements as a linear combination of the form `s • D s'`, use
 We also provide the notation `Ω[S⁄R]` for `KaehlerDifferential R S`.
 Note that the slash is `\textfractionsolidus`.
 -/
-def KaehlerDifferential : Type _ :=
+def KaehlerDifferential : Type v :=
   (KaehlerDifferential.ideal R S).Cotangent
 #align kaehler_differential KaehlerDifferential
 
@@ -153,6 +153,7 @@ instance KaehlerDifferential.module : Module (S ⊗[R] S) (KaehlerDifferential R
   Ideal.Cotangent.moduleOfTower _
 #align kaehler_differential.module KaehlerDifferential.module
 
+@[inherit_doc KaehlerDifferential]
 notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
 
 instance : Nonempty (Ω[S⁄R]) := ⟨0⟩
@@ -285,11 +286,8 @@ theorem Derivation.liftKaehlerDifferential_comp (D : Derivation R S M) :
 
 @[simp]
 theorem Derivation.liftKaehlerDifferential_comp_D (D' : Derivation R S M) (x : S) :
-    D'.liftKaehlerDifferential (KaehlerDifferential.D R S x) = D' x := by
--- Porting note: original proof (timeout)
---  Derivation.congr_fun D'.liftKaehlerDifferential_comp x
-  rw [← Derivation.congr_fun D'.liftKaehlerDifferential_comp x]
-  simp
+    D'.liftKaehlerDifferential (KaehlerDifferential.D R S x) = D' x :=
+  Derivation.congr_fun D'.liftKaehlerDifferential_comp x
 set_option linter.uppercaseLean3 false in
 #align derivation.lift_kaehler_differential_comp_D Derivation.liftKaehlerDifferential_comp_D
 
@@ -388,18 +386,48 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
     exact e₁.symm.trans (e.trans e₂)
 #align kaehler_differential.End_equiv_aux KaehlerDifferential.End_equiv_aux
 
-set_option maxHeartbeats 700000 in
--- Porting note: extra heartbeats are needed to infer the instance
--- Module S { x // x ∈ Ideal.cotangentIdeal (ideal R S) }
-set_option synthInstance.maxHeartbeats 200000 in
--- This has type
--- `Derivation R S (Ω[S⁄R]) ≃ₗ[R] Derivation R S (KaehlerDifferential.ideal R S).cotangentIdeal`
--- But lean times-out if this is given explicitly.
+/- Note: Lean is slow to synthesize theses instances (times out).
+  Without them the endEquivDerivation' and endEquivAuxEquiv both have significant timeouts.
+  In Mathlib 3, it was slow but not this slow. -/
+/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
+local instance smul_SSmod_SSmod : SMul (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
+    (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Mul.toSMul _
+
+/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
+@[nolint defLemma]
+local instance isScalarTower_S_right :
+    IsScalarTower S (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
+      (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := IsScalarTower.right
+
+/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
+@[nolint defLemma]
+local instance isScalarTower_R_right :
+    IsScalarTower R (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
+      (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := IsScalarTower.right
+
+/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
+@[nolint defLemma]
+local instance isScalarTower_SS_right : IsScalarTower (S ⊗[R] S)
+    (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) :=
+  IsScalarTower.right
+
+/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
+local instance instS : Module S (KaehlerDifferential.ideal R S).cotangentIdeal :=
+  Submodule.module' _
+
+/-- 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' _
+
+/-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/
+local instance instSS : Module (S ⊗[R] S) (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' :=
-  @LinearEquiv.compDer R _ S _ _ (Ω[S⁄R]) _ _ _ (KaehlerDifferential.ideal R S).cotangentIdeal
-    _ _ _ _ _ ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
+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)
 #align kaehler_differential.End_equiv_derivation' KaehlerDifferential.endEquivDerivation'
 
 /-- (Implementation) An `Equiv` version of `KaehlerDifferential.End_equiv_aux`.
@@ -412,9 +440,6 @@ def KaehlerDifferential.endEquivAuxEquiv :
   (Equiv.refl _).subtypeEquiv (KaehlerDifferential.End_equiv_aux R S)
 #align kaehler_differential.End_equiv_aux_equiv KaehlerDifferential.endEquivAuxEquiv
 
-
-set_option maxHeartbeats 1200000 in
-set_option synthInstance.maxHeartbeats 900000 in
 /--
 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`.
@@ -547,8 +572,9 @@ noncomputable def KaehlerDifferential.quotKerTotalEquiv :
     right_inv := by
       intro x
       obtain ⟨x, rfl⟩ := KaehlerDifferential.total_surjective R S x
-      erw [LinearMap.congr_fun (KaehlerDifferential.derivationQuotKerTotal_lift_comp_total R S : _)
-          x]
+      have := LinearMap.congr_fun (KaehlerDifferential.derivationQuotKerTotal_lift_comp_total R S) x
+      rw [LinearMap.comp_apply] at this
+      rw [this]
       rfl }
 #align kaehler_differential.quot_ker_total_equiv KaehlerDifferential.quotKerTotalEquiv
 
@@ -569,7 +595,6 @@ local macro "finsupp_map" : term =>
   `((Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp
     (Finsupp.lmapDomain A A (algebraMap A B)))
 
-set_option maxHeartbeats 300000 in
 theorem KaehlerDifferential.kerTotal_map (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)) =
@@ -584,7 +609,7 @@ theorem KaehlerDifferential.kerTotal_map (h : Function.Surjective (algebraMap A
     Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Algebra.linearMap_apply,
     map_one, map_add, map_mul]
   simp_rw [sup_assoc, ← (h.Prod_map h).range_comp]
-  congr 3
+  congr!
   -- Porting note: new
   simp_rw [← IsScalarTower.algebraMap_apply R A B]
   rw [sup_eq_right]
@@ -674,3 +699,4 @@ theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) :
 end ExactSequence
 
 end KaehlerDifferential
+
chore: update/remove heart beat bumps (#6860)

We clean up heart beat bumps after #6474.

Diff
@@ -414,7 +414,7 @@ def KaehlerDifferential.endEquivAuxEquiv :
 
 
 set_option maxHeartbeats 1200000 in
-set_option synthInstance.maxHeartbeats 1000000 in
+set_option synthInstance.maxHeartbeats 900000 in
 /--
 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`.
@@ -531,7 +531,6 @@ theorem KaehlerDifferential.total_surjective :
   rw [← LinearMap.range_eq_top, Finsupp.range_total, KaehlerDifferential.span_range_derivation]
 #align kaehler_differential.total_surjective KaehlerDifferential.total_surjective
 
-set_option maxHeartbeats 400000 in
 /-- `Ω[S⁄R]` is isomorphic to `S` copies of `S` with kernel `KaehlerDifferential.kerTotal`. -/
 @[simps!]
 noncomputable def KaehlerDifferential.quotKerTotalEquiv :
@@ -570,7 +569,7 @@ local macro "finsupp_map" : term =>
   `((Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp
     (Finsupp.lmapDomain A A (algebraMap A B)))
 
-set_option maxHeartbeats 400000 in
+set_option maxHeartbeats 300000 in
 theorem KaehlerDifferential.kerTotal_map (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)) =
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -72,13 +72,13 @@ theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S)
       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 [MulZeroClass.zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero]
+  · 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 [MulZeroClass.mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero]
+  · 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]
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -56,7 +56,7 @@ theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) :
 
 variable {R}
 
-variable {M : Type _} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M]
+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 :=
@@ -157,7 +157,7 @@ notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
 
 instance : Nonempty (Ω[S⁄R]) := ⟨0⟩
 
-instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S]
+instance KaehlerDifferential.module' {R' : Type*} [CommRing R'] [Algebra R' S]
   [SMulCommClass R R' S] :
     Module R' (Ω[S⁄R]) :=
   Submodule.Quotient.module' _
@@ -166,7 +166,7 @@ instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S]
 instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
   Ideal.Cotangent.isScalarTower _
 
-instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRing R₁] [CommRing R₂]
+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]) :=
@@ -561,7 +561,7 @@ theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_D :
 set_option linter.uppercaseLean3 false in
 #align kaehler_differential.quot_ker_total_equiv_symm_comp_D KaehlerDifferential.quotKerTotalEquiv_symm_comp_D
 
-variable (A B : Type _) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Algebra R B]
+variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra S B] [Algebra R B]
 
 variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
 
@@ -603,7 +603,7 @@ A --→ B
 ↑     ↑
 |     |
 R --→ S -/
-variable (A B : Type _) [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
+variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
 
 variable [Algebra A B] [Algebra S B] [IsScalarTower R A B] [IsScalarTower R S B]
 
chore (RingTheory.Kaehler): reasonable heartbeat limits (#6178)

In light of #6141, we can change the heart beats to more representantive numbers.

Co-authored-by: Matthew Robert Ballard <100034030+mattrobball@users.noreply.github.com>

Diff
@@ -391,7 +391,7 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
 set_option maxHeartbeats 700000 in
 -- Porting note: extra heartbeats are needed to infer the instance
 -- Module S { x // x ∈ Ideal.cotangentIdeal (ideal R S) }
-set_option synthInstance.maxHeartbeats 2000000 in
+set_option synthInstance.maxHeartbeats 200000 in
 -- This has type
 -- `Derivation R S (Ω[S⁄R]) ≃ₗ[R] Derivation R S (KaehlerDifferential.ideal R S).cotangentIdeal`
 -- But lean times-out if this is given explicitly.
@@ -412,8 +412,9 @@ def KaehlerDifferential.endEquivAuxEquiv :
   (Equiv.refl _).subtypeEquiv (KaehlerDifferential.End_equiv_aux R S)
 #align kaehler_differential.End_equiv_aux_equiv KaehlerDifferential.endEquivAuxEquiv
 
-set_option maxHeartbeats 4100000 in
-set_option synthInstance.maxHeartbeats 4000000 in
+
+set_option maxHeartbeats 1200000 in
+set_option synthInstance.maxHeartbeats 1000000 in
 /--
 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`.
chore(linear_algebra/tensor_product): forward-port leanprover-community/mathlib#19143 (#6094)
Diff
@@ -388,10 +388,10 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
     exact e₁.symm.trans (e.trans e₂)
 #align kaehler_differential.End_equiv_aux KaehlerDifferential.End_equiv_aux
 
-set_option maxHeartbeats 600000 in
+set_option maxHeartbeats 700000 in
 -- Porting note: extra heartbeats are needed to infer the instance
 -- Module S { x // x ∈ Ideal.cotangentIdeal (ideal R S) }
-set_option synthInstance.maxHeartbeats 1500000 in
+set_option synthInstance.maxHeartbeats 2000000 in
 -- This has type
 -- `Derivation R S (Ω[S⁄R]) ≃ₗ[R] Derivation R S (KaehlerDifferential.ideal R S).cotangentIdeal`
 -- But lean times-out if this is given explicitly.
@@ -412,7 +412,7 @@ def KaehlerDifferential.endEquivAuxEquiv :
   (Equiv.refl _).subtypeEquiv (KaehlerDifferential.End_equiv_aux R S)
 #align kaehler_differential.End_equiv_aux_equiv KaehlerDifferential.endEquivAuxEquiv
 
-set_option maxHeartbeats 4000000 in
+set_option maxHeartbeats 4100000 in
 set_option synthInstance.maxHeartbeats 4000000 in
 /--
 The endomorphisms of `Ω[S⁄R]` corresponds to sections of the surjection `S ⊗[R] S ⧸ J ^ 2 →ₐ[R] S`,
fix(RingTheory/TensorProduct): fix instance diamonds (#6162)

The optional fields to the algebra typeclasses are a trap; if you forget to provide them then you get diamonds.

This change includes examples to verify that the issues are gone.

It looks like this was contributing to the very poor performance of RingTheory.Kahler; while the intAlgebra and natAlgebra diamonds were probably irrelevant, the Ring.toAddCommGroup diamond likely caused havoc during unification.

Diff
@@ -388,12 +388,12 @@ theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDi
     exact e₁.symm.trans (e.trans e₂)
 #align kaehler_differential.End_equiv_aux KaehlerDifferential.End_equiv_aux
 
-set_option maxHeartbeats 4400000 in
+set_option maxHeartbeats 600000 in
 -- Porting note: extra heartbeats are needed to infer the instance
 -- Module S { x // x ∈ Ideal.cotangentIdeal (ideal R S) }
 set_option synthInstance.maxHeartbeats 1500000 in
 -- This has type
--- `Derivation R S Ω[S⁄R] ≃ₗ[R] Derivation R S (KaehlerDifferential.ideal R S).cotangentIdeal`
+-- `Derivation R S (Ω[S⁄R]) ≃ₗ[R] Derivation R S (KaehlerDifferential.ideal R S).cotangentIdeal`
 -- But lean times-out if this is given explicitly.
 /-- Derivations into `Ω[S⁄R]` is equivalent to derivations
 into `(KaehlerDifferential.ideal R S).cotangentIdeal`. -/
fix: redefine semiring instance on tensor product (#6141)

By providing the Mul instance up front, this seems to make future typeclass search much easier.

This comes at the expense of causing minor elaboration problem in various tensor definitions, which now require the implicit type arguments to be provided explicitly.

This also simplifies some proofs, removing a porting note.

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -69,8 +69,8 @@ theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) :
 
 theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) :
     D.tensorProductTo (x * y) =
-      TensorProduct.lmul' R x • D.tensorProductTo y +
-        TensorProduct.lmul' R y • D.tensorProductTo x := by
+      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 [MulZeroClass.zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero]
   swap
@@ -102,7 +102,7 @@ theorem KaehlerDifferential.submodule_span_range_eq_ideal :
     rintro _ ⟨s, rfl⟩
     exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _
   · rintro x (hx : _ = _)
-    have : x - TensorProduct.lmul' R x ⊗ₜ[R] (1 : S) = x := by
+    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
@@ -157,7 +157,6 @@ notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
 
 instance : Nonempty (Ω[S⁄R]) := ⟨0⟩
 
-set_option synthInstance.maxHeartbeats 40000 in
 instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S]
   [SMulCommClass R R' S] :
     Module R' (Ω[S⁄R]) :=
@@ -167,7 +166,6 @@ instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S]
 instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
   Ideal.Cotangent.isScalarTower _
 
-set_option synthInstance.maxHeartbeats 40000 in
 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] :
@@ -203,7 +201,6 @@ theorem KaehlerDifferential.DLinearMap_apply (s : S) :
 set_option linter.uppercaseLean3 false in
 #align kaehler_differential.D_linear_map_apply KaehlerDifferential.DLinearMap_apply
 
-set_option maxHeartbeats 300000 in -- Porting note: Added to prevent timeout
 /-- The universal derivation into `Ω[S⁄R]`. -/
 def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
   { toLinearMap := KaehlerDifferential.DLinearMap R S
@@ -256,10 +253,6 @@ theorem KaehlerDifferential.span_range_derivation :
 
 variable {R S}
 
--- Porting note: this def is really slow
--- See https://github.com/leanprover-community/mathlib4/issues/5028
-set_option maxHeartbeats 800000 in
-set_option synthInstance.maxHeartbeats 30000 in
 /-- 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) •
@@ -356,7 +349,7 @@ def KaehlerDifferential.linearMapEquivDerivation : (Ω[S⁄R] →ₗ[S] M) ≃
 def KaehlerDifferential.quotientCotangentIdealRingEquiv :
     (S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸ (KaehlerDifferential.ideal R S).cotangentIdeal ≃+*
       S := by
-  have : Function.RightInverse TensorProduct.includeLeft
+  have : Function.RightInverse (TensorProduct.includeLeft (R := 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
@@ -373,12 +366,6 @@ def KaehlerDifferential.quotientCotangentIdeal :
     commutes' := (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).apply_symm_apply }
 #align kaehler_differential.quotient_cotangent_ideal KaehlerDifferential.quotientCotangentIdeal
 
--- Porting note: this proof is really slow
--- See https://github.com/leanprover-community/mathlib4/issues/5028
-set_option maxHeartbeats 600000 in
--- Porting note: extra heartbeats are needed to infer the instance
--- IsScalarTower R S ((S ⊗[R] S ⧸ ideal R S ^ 2) ⧸ Ideal.cotangentIdeal (ideal R S))
-set_option synthInstance.maxHeartbeats 23000 in
 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 _ ↔
@@ -415,8 +402,6 @@ noncomputable def KaehlerDifferential.endEquivDerivation' :=
     _ _ _ _ _ ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
 #align kaehler_differential.End_equiv_derivation' KaehlerDifferential.endEquivDerivation'
 
-set_option maxHeartbeats 400000 in
-set_option synthInstance.maxHeartbeats 40000 in
 /-- (Implementation) An `Equiv` version of `KaehlerDifferential.End_equiv_aux`.
 Used in `KaehlerDifferential.endEquiv`. -/
 def KaehlerDifferential.endEquivAuxEquiv :
@@ -545,7 +530,7 @@ theorem KaehlerDifferential.total_surjective :
   rw [← LinearMap.range_eq_top, Finsupp.range_total, KaehlerDifferential.span_range_derivation]
 #align kaehler_differential.total_surjective KaehlerDifferential.total_surjective
 
-set_option maxHeartbeats 3200000 in -- 2569452
+set_option maxHeartbeats 400000 in
 /-- `Ω[S⁄R]` is isomorphic to `S` copies of `S` with kernel `KaehlerDifferential.kerTotal`. -/
 @[simps!]
 noncomputable def KaehlerDifferential.quotKerTotalEquiv :
@@ -651,7 +636,6 @@ theorem KaehlerDifferential.map_compDer :
   Derivation.liftKaehlerDifferential_comp _
 #align kaehler_differential.map_comp_der KaehlerDifferential.map_compDer
 
-set_option maxHeartbeats 2400000 in -- 1692832
 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) :=
chore: forward-port leanprover-community/mathlib#19234 (#5879)

Unfortunately I was not able to forward port the addition of a partially-explicit type to kaehler_differential.End_equiv_derivation', as Lean 4 no longer allows metavariables in instance arguments.

Diff
@@ -7,7 +7,7 @@ import Mathlib.RingTheory.Derivation.ToSquareZero
 import Mathlib.RingTheory.Ideal.Cotangent
 import Mathlib.RingTheory.IsTensorProduct
 
-#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"b608348ffaeb7f557f2fd46876037abafd326ff3"
+#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364"
 
 /-!
 # The module of kaehler differentials
@@ -157,28 +157,27 @@ notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
 
 instance : Nonempty (Ω[S⁄R]) := ⟨0⟩
 
-instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S] :
+set_option synthInstance.maxHeartbeats 40000 in
+instance KaehlerDifferential.module' {R' : Type _} [CommRing R'] [Algebra R' S]
+  [SMulCommClass R R' S] :
     Module R' (Ω[S⁄R]) :=
-  (Module.compHom (KaehlerDifferential.ideal R S).Cotangent (algebraMap R' S) : _)
+  Submodule.Quotient.module' _
 #align kaehler_differential.module' KaehlerDifferential.module'
 
 instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
   Ideal.Cotangent.isScalarTower _
 
+set_option synthInstance.maxHeartbeats 40000 in
 instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRing R₁] [CommRing R₂]
-    [Algebra R₁ S] [Algebra R₂ S] [Algebra R₁ R₂] [IsScalarTower R₁ R₂ S] :
-    IsScalarTower R₁ R₂ (Ω[S⁄R]) := by
-  convert RestrictScalars.isScalarTower R₁ R₂ (Ω[S⁄R]) using 1
-  ext (x m)
-  show algebraMap R₁ S x • m = algebraMap R₂ S (algebraMap R₁ R₂ x) • m
-  rw [← IsScalarTower.algebraMap_apply]
+    [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 _ _
+
 #align kaehler_differential.is_scalar_tower_of_tower KaehlerDifferential.isScalarTower_of_tower
 
-instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) := by
-  convert RestrictScalars.isScalarTower R (S ⊗[R] S) (Ω[S⁄R]) using 1
-  ext (x m)
-  show algebraMap R S x • m = algebraMap R (S ⊗[R] S) x • m
-  simp_rw [IsScalarTower.algebraMap_apply R S (S ⊗[R] S), IsScalarTower.algebraMap_smul]
+instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) :=
+  Submodule.Quotient.isScalarTower _ _
 #align kaehler_differential.is_scalar_tower' KaehlerDifferential.isScalarTower'
 
 /-- The quotient map `I → Ω[S⁄R]` with `I` being the kernel of `S ⊗[R] S → S`. -/
@@ -207,7 +206,7 @@ set_option linter.uppercaseLean3 false in
 set_option maxHeartbeats 300000 in -- Porting note: Added to prevent timeout
 /-- The universal derivation into `Ω[S⁄R]`. -/
 def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
-  { KaehlerDifferential.DLinearMap R S with
+  { toLinearMap := KaehlerDifferential.DLinearMap R S
     map_one_eq_zero' := by
       dsimp [KaehlerDifferential.DLinearMap_apply]
       congr
@@ -582,7 +581,7 @@ variable [Algebra A B] [IsScalarTower R S B] [IsScalarTower R A B]
 
 -- The map `(A →₀ A) →ₗ[A] (B →₀ B)`
 local macro "finsupp_map" : term =>
-  `((Finsupp.mapRange.linearMap (Algebra.ofId A B).toLinearMap).comp
+  `((Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp
     (Finsupp.lmapDomain A A (algebraMap A B)))
 
 set_option maxHeartbeats 400000 in
@@ -597,7 +596,7 @@ theorem KaehlerDifferential.kerTotal_map (h : Function.Surjective (algebraMap A
   simp_rw [Set.image_union, Submodule.span_union, ← Set.image_univ, Set.image_image, Set.image_univ,
     LinearMap.map_sub, LinearMap.map_add]
   simp only [LinearMap.comp_apply, Finsupp.lmapDomain_apply, Finsupp.mapDomain_single,
-    Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, AlgHom.toLinearMap_apply,
+    Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Algebra.linearMap_apply,
     map_one, map_add, map_mul]
   simp_rw [sup_assoc, ← (h.Prod_map h).range_comp]
   congr 3
@@ -634,6 +633,7 @@ def Derivation.compAlgebraMap [Module A M] [Module B M] [IsScalarTower A B M]
 #align derivation.comp_algebra_map Derivation.compAlgebraMap
 
 variable (R B)
+variable [SMulCommClass S A B]
 
 /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` given a square
 A --→ B
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,16 +2,13 @@
 Copyright © 2020 Nicolò Cavalleri. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Nicolò Cavalleri, Andrew Yang
-
-! This file was ported from Lean 3 source module ring_theory.kaehler
-! leanprover-community/mathlib commit b608348ffaeb7f557f2fd46876037abafd326ff3
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.RingTheory.Derivation.ToSquareZero
 import Mathlib.RingTheory.Ideal.Cotangent
 import Mathlib.RingTheory.IsTensorProduct
 
+#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"b608348ffaeb7f557f2fd46876037abafd326ff3"
+
 /-!
 # The module of kaehler differentials
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -171,7 +171,7 @@ instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
 instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type _} [CommRing R₁] [CommRing R₂]
     [Algebra R₁ S] [Algebra R₂ S] [Algebra R₁ R₂] [IsScalarTower R₁ R₂ S] :
     IsScalarTower R₁ R₂ (Ω[S⁄R]) := by
-  convert  RestrictScalars.isScalarTower R₁ R₂ (Ω[S⁄R]) using 1
+  convert RestrictScalars.isScalarTower R₁ R₂ (Ω[S⁄R]) using 1
   ext (x m)
   show algebraMap R₁ S x • m = algebraMap R₂ S (algebraMap R₁ R₂ x) • m
   rw [← IsScalarTower.algebraMap_apply]
@@ -275,7 +275,7 @@ def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ
     refine Submodule.smul_induction_on hx ?_ ?_
     · rintro x (hx : _ = _) y -
       dsimp
-      rw [show ↑(x • y) = x * ↑y  by rfl, Derivation.tensorProductTo_mul, hx, y.prop, zero_smul,
+      rw [show ↑(x • y) = x * ↑y by rfl, Derivation.tensorProductTo_mul, hx, y.prop, zero_smul,
         zero_smul, zero_add]
     · intro x y ex ey; rw [map_add, ex, ey, zero_add]
 #align derivation.lift_kaehler_differential Derivation.liftKaehlerDifferential
feat: port RingTheory.Kaehler (#4668)

Co-authored-by: ART <anand.rao.art@gmail.com> Co-authored-by: Xavier-François Roblot <46200072+xroblot@users.noreply.github.com> Co-authored-by: Bulhwi Cha <chabulhwi@semmalgil.com> Co-authored-by: Kevin Buzzard <k.buzzard@imperial.ac.uk> Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Parcly Taxel <reddeloostw@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Dependencies 10 + 625

626 files ported (98.4%)
263669 lines ported (98.7%)
Show graph

The unported dependencies are