ring_theory.traceMathlib.RingTheory.Trace

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)

(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)

(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)

(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)

(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)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -516,9 +516,9 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
   by
   ext α β
   rw [trace_matrix_apply, vec_mul, dot_product, vec_mul, dot_product, Matrix.mul_apply,
-    BilinForm.sum_left,
+    LinearMap.BilinForm.sum_left,
     Fintype.sum_congr _ _ fun i : κ =>
-      @BilinForm.sum_right _ _ _ _ _ _ _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
+      @LinearMap.BilinForm.sum_right _ _ _ _ _ _ _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
         b y * P.map (algebraMap A B) y β,
     sum_comm]
   congr; ext x
@@ -706,7 +706,7 @@ variable (K L)
 #print traceForm_nondegenerate /-
 theorem traceForm_nondegenerate [FiniteDimensional K L] [IsSeparable K L] :
     (traceForm K L).Nondegenerate :=
-  BilinForm.nondegenerate_of_det_ne_zero (traceForm K L) _
+  LinearMap.BilinForm.nondegenerate_of_det_ne_zero (traceForm K L) _
     (det_traceForm_ne_zero (FiniteDimensional.finBasis K L))
 #align trace_form_nondegenerate traceForm_nondegenerate
 -/
Diff
@@ -384,7 +384,7 @@ theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegra
     trace_eq_sum_roots]
   · refine' (IsIntegral.multiset_sum _).nsmul _
     intro y hy
-    rw [mem_roots_map (minpoly.ne_zero hx')] at hy 
+    rw [mem_roots_map (minpoly.ne_zero hx')] at hy
     use minpoly R x, minpoly.monic hx
     rw [← aeval_def] at hy ⊢
     exact minpoly.aeval_of_isScalarTower R x y hy
Diff
@@ -307,7 +307,7 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
   rw [trace_eq_zero_of_not_exists_basis, LinearMap.zero_apply]
   contrapose! hx
   obtain ⟨s, ⟨b⟩⟩ := hx
-  refine' isIntegral_of_mem_of_FG K⟮⟯.toSubalgebra _ x _
+  refine' IsIntegral.of_mem_of_fg K⟮⟯.toSubalgebra _ x _
   · exact (Submodule.fg_iff_finiteDimensional _).mpr (FiniteDimensional.of_fintype_basis b)
   · exact subset_adjoin K _ (Set.mem_singleton x)
 #align intermediate_field.adjoin_simple.trace_gen_eq_zero IntermediateField.AdjoinSimple.trace_gen_eq_zero
@@ -379,7 +379,7 @@ open Polynomial
 theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegral R x) :
     IsIntegral R (Algebra.trace L F x) :=
   by
-  have hx' : IsIntegral L x := isIntegral_of_isScalarTower hx
+  have hx' : IsIntegral L x := IsIntegral.tower_top hx
   rw [← isIntegral_algebraMap_iff (algebraMap L (AlgebraicClosureAux F)).Injective,
     trace_eq_sum_roots]
   · refine' (IsIntegral.multiset_sum _).nsmul _
Diff
@@ -566,7 +566,7 @@ theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
     skip
     ext
     rw [mul_comm _ (b.equiv_fun z _), ← smul_eq_mul, of_apply, ← LinearMap.map_smul]
-  rw [← LinearMap.map_sum]
+  rw [← map_sum]
   congr
   conv_lhs =>
     congr
Diff
@@ -3,16 +3,16 @@ Copyright (c) 2020 Anne Baanen. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Anne Baanen
 -/
-import Mathbin.LinearAlgebra.Matrix.BilinearForm
-import Mathbin.LinearAlgebra.Matrix.Charpoly.Minpoly
-import Mathbin.LinearAlgebra.Determinant
-import Mathbin.LinearAlgebra.FiniteDimensional
-import Mathbin.LinearAlgebra.Vandermonde
-import Mathbin.LinearAlgebra.Trace
-import Mathbin.FieldTheory.IsAlgClosed.AlgebraicClosure
-import Mathbin.FieldTheory.PrimitiveElement
-import Mathbin.FieldTheory.Galois
-import Mathbin.RingTheory.PowerBasis
+import LinearAlgebra.Matrix.BilinearForm
+import LinearAlgebra.Matrix.Charpoly.Minpoly
+import LinearAlgebra.Determinant
+import LinearAlgebra.FiniteDimensional
+import LinearAlgebra.Vandermonde
+import LinearAlgebra.Trace
+import FieldTheory.IsAlgClosed.AlgebraicClosure
+import FieldTheory.PrimitiveElement
+import FieldTheory.Galois
+import RingTheory.PowerBasis
 
 #align_import ring_theory.trace from "leanprover-community/mathlib"@"e8e130de9dba4ed6897183c3193c752ffadbcc77"
 
Diff
@@ -380,7 +380,8 @@ theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegra
     IsIntegral R (Algebra.trace L F x) :=
   by
   have hx' : IsIntegral L x := isIntegral_of_isScalarTower hx
-  rw [← isIntegral_algebraMap_iff (algebraMap L (AlgebraicClosure F)).Injective, trace_eq_sum_roots]
+  rw [← isIntegral_algebraMap_iff (algebraMap L (AlgebraicClosureAux F)).Injective,
+    trace_eq_sum_roots]
   · refine' (IsIntegral.multiset_sum _).nsmul _
     intro y hy
     rw [mem_roots_map (minpoly.ne_zero hx')] at hy 
@@ -461,10 +462,10 @@ theorem trace_eq_sum_embeddings [FiniteDimensional K L] [IsSeparable K L] {x : L
 theorem trace_eq_sum_automorphisms (x : L) [FiniteDimensional K L] [IsGalois K L] :
     algebraMap K L (Algebra.trace K L x) = ∑ σ : L ≃ₐ[K] L, σ x :=
   by
-  apply NoZeroSMulDivisors.algebraMap_injective L (AlgebraicClosure L)
-  rw [map_sum (algebraMap L (AlgebraicClosure L))]
-  rw [← Fintype.sum_equiv (Normal.algHomEquivAut K (AlgebraicClosure L) L)]
-  · rw [← trace_eq_sum_embeddings (AlgebraicClosure L)]
+  apply NoZeroSMulDivisors.algebraMap_injective L (AlgebraicClosureAux L)
+  rw [map_sum (algebraMap L (AlgebraicClosureAux L))]
+  rw [← Fintype.sum_equiv (Normal.algHomEquivAut K (AlgebraicClosureAux L) L)]
+  · rw [← trace_eq_sum_embeddings (AlgebraicClosureAux L)]
     · simp only [algebra_map_eq_smul_one, smul_one_smul]
     · exact IsGalois.to_isSeparable
   · intro σ
@@ -657,12 +658,12 @@ variable (pb : PowerBasis K L)
 #print det_traceMatrix_ne_zero' /-
 theorem det_traceMatrix_ne_zero' [IsSeparable K L] : det (traceMatrix K pb.Basis) ≠ 0 :=
   by
-  suffices algebraMap K (AlgebraicClosure L) (det (trace_matrix K pb.basis)) ≠ 0
+  suffices algebraMap K (AlgebraicClosureAux L) (det (trace_matrix K pb.basis)) ≠ 0
     by
     refine' mt (fun ht => _) this
     rw [ht, RingHom.map_zero]
   haveI : FiniteDimensional K L := pb.finite_dimensional
-  let e : Fin pb.dim ≃ (L →ₐ[K] AlgebraicClosure L) := (Fintype.equivFinOfCardEq _).symm
+  let e : Fin pb.dim ≃ (L →ₐ[K] AlgebraicClosureAux L) := (Fintype.equivFinOfCardEq _).symm
   rw [RingHom.map_det, RingHom.mapMatrix_apply,
     trace_matrix_eq_embeddings_matrix_reindex_mul_trans K _ _ e,
     embeddings_matrix_reindex_eq_vandermonde, det_mul, det_transpose]
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2020 Anne Baanen. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Anne Baanen
-
-! This file was ported from Lean 3 source module ring_theory.trace
-! leanprover-community/mathlib commit e8e130de9dba4ed6897183c3193c752ffadbcc77
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.LinearAlgebra.Matrix.BilinearForm
 import Mathbin.LinearAlgebra.Matrix.Charpoly.Minpoly
@@ -19,6 +14,8 @@ import Mathbin.FieldTheory.PrimitiveElement
 import Mathbin.FieldTheory.Galois
 import Mathbin.RingTheory.PowerBasis
 
+#align_import ring_theory.trace from "leanprover-community/mathlib"@"e8e130de9dba4ed6897183c3193c752ffadbcc77"
+
 /-!
 # Trace for (finite) ring extensions.
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Anne Baanen
 
 ! This file was ported from Lean 3 source module ring_theory.trace
-! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
+! leanprover-community/mathlib commit e8e130de9dba4ed6897183c3193c752ffadbcc77
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -22,6 +22,9 @@ import Mathbin.RingTheory.PowerBasis
 /-!
 # Trace for (finite) ring extensions.
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Suppose we have an `R`-algebra `S` with a finite basis. For each `s : S`,
 the trace of the linear map given by multiplying by `s` gives information about
 the roots of the minimal polynomial of `s` over `R`.
Diff
@@ -90,32 +90,41 @@ variable (b : Basis ι R S)
 
 variable (R S)
 
+#print Algebra.trace /-
 /-- The trace of an element `s` of an `R`-algebra is the trace of `(*) s`,
 as an `R`-linear map. -/
 noncomputable def trace : S →ₗ[R] R :=
   (LinearMap.trace R S).comp (lmul R S).toLinearMap
 #align algebra.trace Algebra.trace
+-/
 
 variable {S}
 
+#print Algebra.trace_apply /-
 -- Not a `simp` lemma since there are more interesting ways to rewrite `trace R S x`,
 -- for example `trace_trace`
 theorem trace_apply (x) : trace R S x = LinearMap.trace R S (lmul R S x) :=
   rfl
 #align algebra.trace_apply Algebra.trace_apply
+-/
 
+#print Algebra.trace_eq_zero_of_not_exists_basis /-
 theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) :
     trace R S = 0 := by ext s; simp [trace_apply, LinearMap.trace, h]
 #align algebra.trace_eq_zero_of_not_exists_basis Algebra.trace_eq_zero_of_not_exists_basis
+-/
 
 variable {R}
 
+#print Algebra.trace_eq_matrix_trace /-
 -- Can't be a `simp` lemma because it depends on a choice of basis
 theorem trace_eq_matrix_trace [DecidableEq ι] (b : Basis ι R S) (s : S) :
     trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) := by
   rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← to_matrix_lmul_eq]; rfl
 #align algebra.trace_eq_matrix_trace Algebra.trace_eq_matrix_trace
+-/
 
+#print Algebra.trace_algebraMap_of_basis /-
 /-- If `x` is in the base field `K`, then the trace is `[L : K] * x`. -/
 theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Fintype.card ι • x :=
   by
@@ -125,7 +134,9 @@ theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Finty
   ext i
   simp [-coe_lmul_eq_mul]
 #align algebra.trace_algebra_map_of_basis Algebra.trace_algebraMap_of_basis
+-/
 
+#print Algebra.trace_algebraMap /-
 /-- If `x` is in the base field `K`, then the trace is `[L : K] * x`.
 
 (If `L` is not finite-dimensional over `K`, then `trace` and `finrank` return `0`.)
@@ -137,7 +148,9 @@ theorem trace_algebraMap (x : K) : trace K L (algebraMap K L x) = finrank K L 
   · rw [trace_algebra_map_of_basis H.some_spec.some, finrank_eq_card_basis H.some_spec.some]
   · simp [trace_eq_zero_of_not_exists_basis K H, finrank_eq_zero_of_not_exists_basis_finset H]
 #align algebra.trace_algebra_map Algebra.trace_algebraMap
+-/
 
+#print Algebra.trace_trace_of_basis /-
 theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _} [Finite ι]
     [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
     trace R S (trace S T x) = trace R T x :=
@@ -154,25 +167,33 @@ theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _
       Finset.sum_apply
       i _ fun y => left_mul_matrix b (left_mul_matrix c x y y)]
 #align algebra.trace_trace_of_basis Algebra.trace_trace_of_basis
+-/
 
+#print Algebra.trace_comp_trace_of_basis /-
 theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _} [Finite ι]
     [Fintype κ] (b : Basis ι R S) (c : Basis κ S T) :
     (trace R S).comp ((trace S T).restrictScalars R) = trace R T := by ext;
   rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace_of_basis b c]
 #align algebra.trace_comp_trace_of_basis Algebra.trace_comp_trace_of_basis
+-/
 
+#print Algebra.trace_trace /-
 @[simp]
 theorem trace_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [FiniteDimensional K L]
     [FiniteDimensional L T] (x : T) : trace K L (trace L T x) = trace K T x :=
   trace_trace_of_basis (Basis.ofVectorSpace K L) (Basis.ofVectorSpace L T) x
 #align algebra.trace_trace Algebra.trace_trace
+-/
 
+#print Algebra.trace_comp_trace /-
 @[simp]
 theorem trace_comp_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [FiniteDimensional K L]
     [FiniteDimensional L T] : (trace K L).comp ((trace L T).restrictScalars K) = trace K T := by
   ext; rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace]
 #align algebra.trace_comp_trace Algebra.trace_comp_trace
+-/
 
+#print Algebra.trace_prod_apply /-
 @[simp]
 theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T]
     (x : S × T) : trace R (S × T) x = trace R S x.fst + trace R T x.snd :=
@@ -184,42 +205,55 @@ theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S]
   simp_rw [trace, this]
   exact trace_prod_map' _ _
 #align algebra.trace_prod_apply Algebra.trace_prod_apply
+-/
 
+#print Algebra.trace_prod /-
 theorem trace_prod [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T] :
     trace R (S × T) = (trace R S).coprod (trace R T) :=
   LinearMap.ext fun p => by rw [coprod_apply, trace_prod_apply]
 #align algebra.trace_prod Algebra.trace_prod
+-/
 
 section TraceForm
 
 variable (R S)
 
+#print Algebra.traceForm /-
 /-- The `trace_form` maps `x y : S` to the trace of `x * y`.
 It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
 noncomputable def traceForm : BilinForm R S :=
   (LinearMap.compr₂ (lmul R S).toLinearMap (trace R S)).toBilin
 #align algebra.trace_form Algebra.traceForm
+-/
 
 variable {S}
 
+#print Algebra.traceForm_apply /-
 -- This is a nicer lemma than the one produced by `@[simps] def trace_form`.
 @[simp]
 theorem traceForm_apply (x y : S) : traceForm R S x y = trace R S (x * y) :=
   rfl
 #align algebra.trace_form_apply Algebra.traceForm_apply
+-/
 
+#print Algebra.traceForm_isSymm /-
 theorem traceForm_isSymm : (traceForm R S).IsSymm := fun x y => congr_arg (trace R S) (mul_comm _ _)
 #align algebra.trace_form_is_symm Algebra.traceForm_isSymm
+-/
 
+#print Algebra.traceForm_toMatrix /-
 theorem traceForm_toMatrix [DecidableEq ι] (i j) :
     BilinForm.toMatrix b (traceForm R S) i j = trace R S (b i * b j) := by
   rw [BilinForm.toMatrix_apply, trace_form_apply]
 #align algebra.trace_form_to_matrix Algebra.traceForm_toMatrix
+-/
 
+#print Algebra.traceForm_toMatrix_powerBasis /-
 theorem traceForm_toMatrix_powerBasis (h : PowerBasis R S) :
     BilinForm.toMatrix h.Basis (traceForm R S) = of fun i j => trace R S (h.gen ^ (↑i + ↑j : ℕ)) :=
   by ext; rw [trace_form_to_matrix, of_apply, pow_add, h.basis_eq_pow, h.basis_eq_pow]
 #align algebra.trace_form_to_matrix_power_basis Algebra.traceForm_toMatrix_powerBasis
+-/
 
 end TraceForm
 
@@ -233,6 +267,7 @@ variable {F : Type _} [Field F]
 
 variable [Algebra K S] [Algebra K F]
 
+#print PowerBasis.trace_gen_eq_nextCoeff_minpoly /-
 /-- Given `pb : power_basis K S`, the trace of `pb.gen` is `-(minpoly K pb.gen).next_coeff`. -/
 theorem PowerBasis.trace_gen_eq_nextCoeff_minpoly [Nontrivial S] (pb : PowerBasis K S) :
     Algebra.trace K S pb.gen = -(minpoly K pb.gen).nextCoeff :=
@@ -243,7 +278,9 @@ theorem PowerBasis.trace_gen_eq_nextCoeff_minpoly [Nontrivial S] (pb : PowerBasi
   rw [trace_eq_matrix_trace pb.basis, trace_eq_neg_charpoly_coeff, charpoly_leftMulMatrix, ←
     pb.nat_degree_minpoly, Fintype.card_fin, ← next_coeff_of_pos_nat_degree _ d_pos']
 #align power_basis.trace_gen_eq_next_coeff_minpoly PowerBasis.trace_gen_eq_nextCoeff_minpoly
+-/
 
+#print PowerBasis.trace_gen_eq_sum_roots /-
 /-- Given `pb : power_basis K S`, then the trace of `pb.gen` is
 `((minpoly K pb.gen).map (algebra_map K F)).roots.sum`. -/
 theorem PowerBasis.trace_gen_eq_sum_roots [Nontrivial S] (pb : PowerBasis K S)
@@ -255,6 +292,7 @@ theorem PowerBasis.trace_gen_eq_sum_roots [Nontrivial S] (pb : PowerBasis K S)
       ((splits_id_iff_splits _).2 hf),
     neg_neg]
 #align power_basis.trace_gen_eq_sum_roots PowerBasis.trace_gen_eq_sum_roots
+-/
 
 namespace IntermediateField.AdjoinSimple
 
@@ -262,6 +300,7 @@ open IntermediateField
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
+#print IntermediateField.AdjoinSimple.trace_gen_eq_zero /-
 theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
     Algebra.trace K K⟮⟯ (AdjoinSimple.gen K x) = 0 :=
   by
@@ -272,9 +311,11 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
   · exact (Submodule.fg_iff_finiteDimensional _).mpr (FiniteDimensional.of_fintype_basis b)
   · exact subset_adjoin K _ (Set.mem_singleton x)
 #align intermediate_field.adjoin_simple.trace_gen_eq_zero IntermediateField.AdjoinSimple.trace_gen_eq_zero
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
+#print IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots /-
 theorem trace_gen_eq_sum_roots (x : L) (hf : (minpoly K x).Splits (algebraMap K F)) :
     algebraMap K F (trace K K⟮⟯ (AdjoinSimple.gen K x)) =
       ((minpoly K x).map (algebraMap K F)).roots.Sum :=
@@ -291,6 +332,7 @@ theorem trace_gen_eq_sum_roots (x : L) (hf : (minpoly K x).Splits (algebraMap K
     try simp only [adjoin_simple.algebra_map_gen _ _]
   exact hf
 #align intermediate_field.adjoin_simple.trace_gen_eq_sum_roots IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots
+-/
 
 end IntermediateField.AdjoinSimple
 
@@ -301,6 +343,7 @@ variable (K)
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
+#print trace_eq_trace_adjoin /-
 theorem trace_eq_trace_adjoin [FiniteDimensional K L] (x : L) :
     Algebra.trace K L x = finrank K⟮⟯ L • trace K K⟮⟯ (AdjoinSimple.gen K x) :=
   by
@@ -308,10 +351,12 @@ theorem trace_eq_trace_adjoin [FiniteDimensional K L] (x : L) :
   conv in x => rw [← IntermediateField.AdjoinSimple.algebraMap_gen K x]
   rw [trace_algebra_map, LinearMap.map_smul_of_tower]
 #align trace_eq_trace_adjoin trace_eq_trace_adjoin
+-/
 
 variable {K}
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
+#print trace_eq_sum_roots /-
 theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
     (hF : (minpoly K x).Splits (algebraMap K F)) :
     algebraMap K F (Algebra.trace K L x) =
@@ -320,6 +365,7 @@ theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
   rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← Algebra.smul_def,
     IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots _ hF, IsScalarTower.algebraMap_smul]
 #align trace_eq_sum_roots trace_eq_sum_roots
+-/
 
 end EqSumRoots
 
@@ -329,6 +375,7 @@ variable [Algebra R L] [Algebra L F] [Algebra R F] [IsScalarTower R L F]
 
 open Polynomial
 
+#print Algebra.isIntegral_trace /-
 theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegral R x) :
     IsIntegral R (Algebra.trace L F x) :=
   by
@@ -343,6 +390,7 @@ theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegra
   · apply IsAlgClosed.splits_codomain
   · infer_instance
 #align algebra.is_integral_trace Algebra.isIntegral_trace
+-/
 
 section EqSumEmbeddings
 
@@ -352,6 +400,7 @@ open Algebra IntermediateField
 
 variable (F) (E : Type _) [Field E] [Algebra K E]
 
+#print trace_eq_sum_embeddings_gen /-
 theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
     (hE : (minpoly K pb.gen).Splits (algebraMap K E)) (hfx : (minpoly K pb.gen).Separable) :
     algebraMap K E (Algebra.trace K L pb.gen) =
@@ -365,9 +414,11 @@ theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
   · intro x; rfl
   · intro σ; rw [PowerBasis.liftEquiv'_apply_coe, id.def]
 #align trace_eq_sum_embeddings_gen trace_eq_sum_embeddings_gen
+-/
 
 variable [IsAlgClosed E]
 
+#print sum_embeddings_eq_finrank_mul /-
 theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
     (pb : PowerBasis K L) :
     ∑ σ : F →ₐ[K] E, σ (algebraMap L F pb.gen) =
@@ -389,8 +440,10 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
     simp only [algHomEquivSigma, Equiv.coe_fn_mk, AlgHom.restrictDomain, AlgHom.comp_apply,
       IsScalarTower.coe_toAlgHom']
 #align sum_embeddings_eq_finrank_mul sum_embeddings_eq_finrank_mul
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
+#print trace_eq_sum_embeddings /-
 theorem trace_eq_sum_embeddings [FiniteDimensional K L] [IsSeparable K L] {x : L} :
     algebraMap K E (Algebra.trace K L x) = ∑ σ : L →ₐ[K] E, σ x :=
   by
@@ -402,7 +455,9 @@ theorem trace_eq_sum_embeddings [FiniteDimensional K L] [IsSeparable K L] {x : L
   · haveI := isSeparable_tower_bot_of_isSeparable K K⟮⟯ L
     exact IsSeparable.separable K _
 #align trace_eq_sum_embeddings trace_eq_sum_embeddings
+-/
 
+#print trace_eq_sum_automorphisms /-
 theorem trace_eq_sum_automorphisms (x : L) [FiniteDimensional K L] [IsGalois K L] :
     algebraMap K L (Algebra.trace K L x) = ∑ σ : L ≃ₐ[K] L, σ x :=
   by
@@ -416,6 +471,7 @@ theorem trace_eq_sum_automorphisms (x : L) [FiniteDimensional K L] [IsGalois K L
     simp only [Normal.algHomEquivAut, AlgHom.restrictNormal', Equiv.coe_fn_mk,
       AlgEquiv.coe_ofBijective, AlgHom.restrictNormal_commutes, id.map_eq_id, RingHom.id_apply]
 #align trace_eq_sum_automorphisms trace_eq_sum_automorphisms
+-/
 
 end EqSumEmbeddings
 
@@ -429,24 +485,31 @@ variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C]
 
 open Finset
 
+#print Algebra.traceMatrix /-
 /-- Given an `A`-algebra `B` and `b`, an `κ`-indexed family of elements of `B`, we define
 `trace_matrix A b` as the matrix whose `(i j)`-th element is the trace of `b i * b j`. -/
 noncomputable def traceMatrix (b : κ → B) : Matrix κ κ A :=
   of fun i j => traceForm A B (b i) (b j)
 #align algebra.trace_matrix Algebra.traceMatrix
+-/
 
+#print Algebra.traceMatrix_apply /-
 -- TODO: set as an equation lemma for `trace_matrix`, see mathlib4#3024
 @[simp]
 theorem traceMatrix_apply (b : κ → B) (i j) : traceMatrix A b i j = traceForm A B (b i) (b j) :=
   rfl
 #align algebra.trace_matrix_apply Algebra.traceMatrix_apply
+-/
 
+#print Algebra.traceMatrix_reindex /-
 theorem traceMatrix_reindex {κ' : Type _} (b : Basis κ A B) (f : κ ≃ κ') :
     traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) := by ext x y; simp
 #align algebra.trace_matrix_reindex Algebra.traceMatrix_reindex
+-/
 
 variable {A}
 
+#print Algebra.traceMatrix_of_matrix_vecMul /-
 theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
     traceMatrix A ((P.map (algebraMap A B)).vecMul b) = Pᵀ ⬝ traceMatrix A b ⬝ P :=
   by
@@ -467,7 +530,9 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
   ring_nf
   simp [mul_comm]
 #align algebra.trace_matrix_of_matrix_vec_mul Algebra.traceMatrix_of_matrix_vecMul
+-/
 
+#print Algebra.traceMatrix_of_matrix_mulVec /-
 theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
     traceMatrix A ((P.map (algebraMap A B)).mulVec b) = P ⬝ traceMatrix A b ⬝ Pᵀ :=
   by
@@ -476,14 +541,18 @@ theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ
     trace_matrix_of_matrix_vec_mul, transpose_transpose, transpose_mul, transpose_transpose,
     transpose_mul]
 #align algebra.trace_matrix_of_matrix_mul_vec Algebra.traceMatrix_of_matrix_mulVec
+-/
 
+#print Algebra.traceMatrix_of_basis /-
 theorem traceMatrix_of_basis [Fintype κ] [DecidableEq κ] (b : Basis κ A B) :
     traceMatrix A b = BilinForm.toMatrix b (traceForm A B) :=
   by
   ext i j
   rw [trace_matrix_apply, trace_form_apply, trace_form_to_matrix]
 #align algebra.trace_matrix_of_basis Algebra.traceMatrix_of_basis
+-/
 
+#print Algebra.traceMatrix_of_basis_mulVec /-
 theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
     (traceMatrix A b).mulVec (b.equivFun z) = fun i => trace A B (z * b i) :=
   by
@@ -507,23 +576,29 @@ theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
   congr
   rw [b.sum_equiv_fun]
 #align algebra.trace_matrix_of_basis_mul_vec Algebra.traceMatrix_of_basis_mulVec
+-/
 
 variable (A)
 
+#print Algebra.embeddingsMatrix /-
 /-- `embeddings_matrix A C b : matrix κ (B →ₐ[A] C) C` is the matrix whose `(i, σ)` coefficient is
   `σ (b i)`. It is mostly useful for fields when `fintype.card κ = finrank A B` and `C` is
   algebraically closed. -/
 def embeddingsMatrix (b : κ → B) : Matrix κ (B →ₐ[A] C) C :=
   of fun i (σ : B →ₐ[A] C) => σ (b i)
 #align algebra.embeddings_matrix Algebra.embeddingsMatrix
+-/
 
+#print Algebra.embeddingsMatrix_apply /-
 -- TODO: set as an equation lemma for `embeddings_matrix`, see mathlib4#3024
 @[simp]
 theorem embeddingsMatrix_apply (b : κ → B) (i) (σ : B →ₐ[A] C) :
     embeddingsMatrix A C b i σ = σ (b i) :=
   rfl
 #align algebra.embeddings_matrix_apply Algebra.embeddingsMatrix_apply
+-/
 
+#print Algebra.embeddingsMatrixReindex /-
 /-- `embeddings_matrix_reindex A C b e : matrix κ κ C` is the matrix whose `(i, j)` coefficient
   is `σⱼ (b i)`, where `σⱼ : B →ₐ[A] C` is the embedding corresponding to `j : κ` given by a
   bijection `e : κ ≃ (B →ₐ[A] C)`. It is mostly useful for fields and `C` is algebraically closed.
@@ -532,14 +607,17 @@ theorem embeddingsMatrix_apply (b : κ → B) (i) (σ : B →ₐ[A] C) :
 def embeddingsMatrixReindex (b : κ → B) (e : κ ≃ (B →ₐ[A] C)) :=
   reindex (Equiv.refl κ) e.symm (embeddingsMatrix A C b)
 #align algebra.embeddings_matrix_reindex Algebra.embeddingsMatrixReindex
+-/
 
 variable {A}
 
+#print Algebra.embeddingsMatrixReindex_eq_vandermonde /-
 theorem embeddingsMatrixReindex_eq_vandermonde (pb : PowerBasis A B)
     (e : Fin pb.dim ≃ (B →ₐ[A] C)) :
     embeddingsMatrixReindex A C pb.Basis e = (vandermonde fun i => e i pb.gen)ᵀ := by ext i j;
   simp [embeddings_matrix_reindex, embeddings_matrix]
 #align algebra.embeddings_matrix_reindex_eq_vandermonde Algebra.embeddingsMatrixReindex_eq_vandermonde
+-/
 
 section Field
 
@@ -551,11 +629,14 @@ variable [Module.Finite K L] [IsSeparable K L] [IsAlgClosed E]
 
 variable (b : κ → L) (pb : PowerBasis K L)
 
+#print Algebra.traceMatrix_eq_embeddingsMatrix_mul_trans /-
 theorem traceMatrix_eq_embeddingsMatrix_mul_trans :
     (traceMatrix K b).map (algebraMap K E) = embeddingsMatrix K E b ⬝ (embeddingsMatrix K E b)ᵀ :=
   by ext i j; simp [trace_eq_sum_embeddings, embeddings_matrix, Matrix.mul_apply]
 #align algebra.trace_matrix_eq_embeddings_matrix_mul_trans Algebra.traceMatrix_eq_embeddingsMatrix_mul_trans
+-/
 
+#print Algebra.traceMatrix_eq_embeddingsMatrixReindex_mul_trans /-
 theorem traceMatrix_eq_embeddingsMatrixReindex_mul_trans [Fintype κ] (e : κ ≃ (L →ₐ[K] E)) :
     (traceMatrix K b).map (algebraMap K E) =
       embeddingsMatrixReindex K E b e ⬝ (embeddingsMatrixReindex K E b e)ᵀ :=
@@ -563,6 +644,7 @@ theorem traceMatrix_eq_embeddingsMatrixReindex_mul_trans [Fintype κ] (e : κ 
   rw [trace_matrix_eq_embeddings_matrix_mul_trans, embeddings_matrix_reindex, reindex_apply,
     transpose_submatrix, ← submatrix_mul_transpose_submatrix, ← Equiv.coe_refl, Equiv.refl_symm]
 #align algebra.trace_matrix_eq_embeddings_matrix_reindex_mul_trans Algebra.traceMatrix_eq_embeddingsMatrixReindex_mul_trans
+-/
 
 end Field
 
@@ -572,6 +654,7 @@ open Algebra
 
 variable (pb : PowerBasis K L)
 
+#print det_traceMatrix_ne_zero' /-
 theorem det_traceMatrix_ne_zero' [IsSeparable K L] : det (traceMatrix K pb.Basis) ≠ 0 :=
   by
   suffices algebraMap K (AlgebraicClosure L) (det (trace_matrix K pb.basis)) ≠ 0
@@ -589,7 +672,9 @@ theorem det_traceMatrix_ne_zero' [IsSeparable K L] : det (traceMatrix K pb.Basis
     exact (finset.mem_Ioi.mp hij).ne' (e.injective <| pb.alg_hom_ext h)
   · rw [AlgHom.card, pb.finrank]
 #align det_trace_matrix_ne_zero' det_traceMatrix_ne_zero'
+-/
 
+#print det_traceForm_ne_zero /-
 theorem det_traceForm_ne_zero [IsSeparable K L] [DecidableEq ι] (b : Basis ι K L) :
     det (BilinForm.toMatrix b (traceForm K L)) ≠ 0 :=
   by
@@ -613,14 +698,17 @@ theorem det_traceForm_ne_zero [IsSeparable K L] [DecidableEq ι] (b : Basis ι K
           Matrix.det_one]
   simpa only [trace_matrix_of_basis] using det_traceMatrix_ne_zero' pb
 #align det_trace_form_ne_zero det_traceForm_ne_zero
+-/
 
 variable (K L)
 
+#print traceForm_nondegenerate /-
 theorem traceForm_nondegenerate [FiniteDimensional K L] [IsSeparable K L] :
     (traceForm K L).Nondegenerate :=
   BilinForm.nondegenerate_of_det_ne_zero (traceForm K L) _
     (det_traceForm_ne_zero (FiniteDimensional.finBasis K L))
 #align trace_form_nondegenerate traceForm_nondegenerate
+-/
 
 end DetNeZero
 
Diff
@@ -442,7 +442,7 @@ theorem traceMatrix_apply (b : κ → B) (i j) : traceMatrix A b i j = traceForm
 #align algebra.trace_matrix_apply Algebra.traceMatrix_apply
 
 theorem traceMatrix_reindex {κ' : Type _} (b : Basis κ A B) (f : κ ≃ κ') :
-    traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) := by ext (x y); simp
+    traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) := by ext x y; simp
 #align algebra.trace_matrix_reindex Algebra.traceMatrix_reindex
 
 variable {A}
@@ -450,7 +450,7 @@ variable {A}
 theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
     traceMatrix A ((P.map (algebraMap A B)).vecMul b) = Pᵀ ⬝ traceMatrix A b ⬝ P :=
   by
-  ext (α β)
+  ext α β
   rw [trace_matrix_apply, vec_mul, dot_product, vec_mul, dot_product, Matrix.mul_apply,
     BilinForm.sum_left,
     Fintype.sum_congr _ _ fun i : κ =>
@@ -480,7 +480,7 @@ theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ
 theorem traceMatrix_of_basis [Fintype κ] [DecidableEq κ] (b : Basis κ A B) :
     traceMatrix A b = BilinForm.toMatrix b (traceForm A B) :=
   by
-  ext (i j)
+  ext i j
   rw [trace_matrix_apply, trace_form_apply, trace_form_to_matrix]
 #align algebra.trace_matrix_of_basis Algebra.traceMatrix_of_basis
 
@@ -537,7 +537,7 @@ variable {A}
 
 theorem embeddingsMatrixReindex_eq_vandermonde (pb : PowerBasis A B)
     (e : Fin pb.dim ≃ (B →ₐ[A] C)) :
-    embeddingsMatrixReindex A C pb.Basis e = (vandermonde fun i => e i pb.gen)ᵀ := by ext (i j);
+    embeddingsMatrixReindex A C pb.Basis e = (vandermonde fun i => e i pb.gen)ᵀ := by ext i j;
   simp [embeddings_matrix_reindex, embeddings_matrix]
 #align algebra.embeddings_matrix_reindex_eq_vandermonde Algebra.embeddingsMatrixReindex_eq_vandermonde
 
@@ -553,7 +553,7 @@ variable (b : κ → L) (pb : PowerBasis K L)
 
 theorem traceMatrix_eq_embeddingsMatrix_mul_trans :
     (traceMatrix K b).map (algebraMap K E) = embeddingsMatrix K E b ⬝ (embeddingsMatrix K E b)ᵀ :=
-  by ext (i j); simp [trace_eq_sum_embeddings, embeddings_matrix, Matrix.mul_apply]
+  by ext i j; simp [trace_eq_sum_embeddings, embeddings_matrix, Matrix.mul_apply]
 #align algebra.trace_matrix_eq_embeddings_matrix_mul_trans Algebra.traceMatrix_eq_embeddingsMatrix_mul_trans
 
 theorem traceMatrix_eq_embeddingsMatrixReindex_mul_trans [Fintype κ] (e : κ ≃ (L →ₐ[K] E)) :
Diff
@@ -108,8 +108,6 @@ theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Bas
     trace R S = 0 := by ext s; simp [trace_apply, LinearMap.trace, h]
 #align algebra.trace_eq_zero_of_not_exists_basis Algebra.trace_eq_zero_of_not_exists_basis
 
-include b
-
 variable {R}
 
 -- Can't be a `simp` lemma because it depends on a choice of basis
@@ -128,8 +126,6 @@ theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Finty
   simp [-coe_lmul_eq_mul]
 #align algebra.trace_algebra_map_of_basis Algebra.trace_algebraMap_of_basis
 
-omit b
-
 /-- If `x` is in the base field `K`, then the trace is `[L : K] * x`.
 
 (If `L` is not finite-dimensional over `K`, then `trace` and `finrank` return `0`.)
Diff
@@ -374,7 +374,7 @@ variable [IsAlgClosed E]
 
 theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
     (pb : PowerBasis K L) :
-    (∑ σ : F →ₐ[K] E, σ (algebraMap L F pb.gen)) =
+    ∑ σ : F →ₐ[K] E, σ (algebraMap L F pb.gen) =
       finrank L F •
         (@Finset.univ (PowerBasis.AlgHom.fintype pb)).Sum fun σ : L →ₐ[K] E => σ pb.gen :=
   by
Diff
@@ -615,7 +615,6 @@ theorem det_traceForm_ne_zero [IsSeparable K L] [DecidableEq ι] (b : Basis ι K
       _ = 1 := by
         simp only [Basis.toMatrix_mul_toMatrix_flip, Matrix.transpose_one, Matrix.mul_one,
           Matrix.det_one]
-      
   simpa only [trace_matrix_of_basis] using det_traceMatrix_ne_zero' pb
 #align det_trace_form_ne_zero det_traceForm_ne_zero
 
Diff
@@ -340,9 +340,9 @@ theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegra
   rw [← isIntegral_algebraMap_iff (algebraMap L (AlgebraicClosure F)).Injective, trace_eq_sum_roots]
   · refine' (IsIntegral.multiset_sum _).nsmul _
     intro y hy
-    rw [mem_roots_map (minpoly.ne_zero hx')] at hy
+    rw [mem_roots_map (minpoly.ne_zero hx')] at hy 
     use minpoly R x, minpoly.monic hx
-    rw [← aeval_def] at hy⊢
+    rw [← aeval_def] at hy ⊢
     exact minpoly.aeval_of_isScalarTower R x y hy
   · apply IsAlgClosed.splits_codomain
   · infer_instance
@@ -461,9 +461,9 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
       @BilinForm.sum_right _ _ _ _ _ _ _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
         b y * P.map (algebraMap A B) y β,
     sum_comm]
-  congr ; ext x
+  congr; ext x
   rw [Matrix.mul_apply, sum_mul]
-  congr ; ext y
+  congr; ext y
   rw [map_apply, trace_form_apply, mul_comm (b y), ← smul_def]
   simp only [id.smul_eq_mul, RingHom.id_apply, map_apply, transpose_apply, LinearMap.map_smulₛₗ,
     trace_form_apply, Algebra.smul_mul_assoc]
Diff
@@ -80,9 +80,9 @@ open LinearMap
 
 open Matrix
 
-open BigOperators
+open scoped BigOperators
 
-open Matrix
+open scoped Matrix
 
 namespace Algebra
 
Diff
@@ -105,9 +105,7 @@ theorem trace_apply (x) : trace R S x = LinearMap.trace R S (lmul R S x) :=
 #align algebra.trace_apply Algebra.trace_apply
 
 theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) :
-    trace R S = 0 := by
-  ext s
-  simp [trace_apply, LinearMap.trace, h]
+    trace R S = 0 := by ext s; simp [trace_apply, LinearMap.trace, h]
 #align algebra.trace_eq_zero_of_not_exists_basis Algebra.trace_eq_zero_of_not_exists_basis
 
 include b
@@ -116,10 +114,8 @@ variable {R}
 
 -- Can't be a `simp` lemma because it depends on a choice of basis
 theorem trace_eq_matrix_trace [DecidableEq ι] (b : Basis ι R S) (s : S) :
-    trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) :=
-  by
-  rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← to_matrix_lmul_eq]
-  rfl
+    trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) := by
+  rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← to_matrix_lmul_eq]; rfl
 #align algebra.trace_eq_matrix_trace Algebra.trace_eq_matrix_trace
 
 /-- If `x` is in the base field `K`, then the trace is `[L : K] * x`. -/
@@ -165,9 +161,7 @@ theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _
 
 theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _} [Finite ι]
     [Fintype κ] (b : Basis ι R S) (c : Basis κ S T) :
-    (trace R S).comp ((trace S T).restrictScalars R) = trace R T :=
-  by
-  ext
+    (trace R S).comp ((trace S T).restrictScalars R) = trace R T := by ext;
   rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace_of_basis b c]
 #align algebra.trace_comp_trace_of_basis Algebra.trace_comp_trace_of_basis
 
@@ -179,10 +173,8 @@ theorem trace_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [FiniteDim
 
 @[simp]
 theorem trace_comp_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [FiniteDimensional K L]
-    [FiniteDimensional L T] : (trace K L).comp ((trace L T).restrictScalars K) = trace K T :=
-  by
-  ext
-  rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace]
+    [FiniteDimensional L T] : (trace K L).comp ((trace L T).restrictScalars K) = trace K T := by
+  ext; rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace]
 #align algebra.trace_comp_trace Algebra.trace_comp_trace
 
 @[simp]
@@ -230,9 +222,7 @@ theorem traceForm_toMatrix [DecidableEq ι] (i j) :
 
 theorem traceForm_toMatrix_powerBasis (h : PowerBasis R S) :
     BilinForm.toMatrix h.Basis (traceForm R S) = of fun i j => trace R S (h.gen ^ (↑i + ↑j : ℕ)) :=
-  by
-  ext
-  rw [trace_form_to_matrix, of_apply, pow_add, h.basis_eq_pow, h.basis_eq_pow]
+  by ext; rw [trace_form_to_matrix, of_apply, pow_add, h.basis_eq_pow, h.basis_eq_pow]
 #align algebra.trace_form_to_matrix_power_basis Algebra.traceForm_toMatrix_powerBasis
 
 end TraceForm
@@ -294,8 +284,7 @@ theorem trace_gen_eq_sum_roots (x : L) (hf : (minpoly K x).Splits (algebraMap K
       ((minpoly K x).map (algebraMap K F)).roots.Sum :=
   by
   have injKxL := (algebraMap K⟮⟯ L).Injective
-  by_cases hx : IsIntegral K x
-  swap
+  by_cases hx : IsIntegral K x; swap
   · simp [minpoly.eq_zero hx, trace_gen_eq_zero hx]
   have hx' : IsIntegral K (adjoin_simple.gen K x) :=
     by
@@ -377,10 +366,8 @@ theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
     Finset.sum_eq_multiset_sum, Multiset.toFinset_val, multiset.dedup_eq_self.mpr _,
     Multiset.map_id]
   · exact nodup_roots ((separable_map _).mpr hfx)
-  · intro x
-    rfl
-  · intro σ
-    rw [PowerBasis.liftEquiv'_apply_coe, id.def]
+  · intro x; rfl
+  · intro σ; rw [PowerBasis.liftEquiv'_apply_coe, id.def]
 #align trace_eq_sum_embeddings_gen trace_eq_sum_embeddings_gen
 
 variable [IsAlgClosed E]
@@ -459,10 +446,7 @@ theorem traceMatrix_apply (b : κ → B) (i j) : traceMatrix A b i j = traceForm
 #align algebra.trace_matrix_apply Algebra.traceMatrix_apply
 
 theorem traceMatrix_reindex {κ' : Type _} (b : Basis κ A B) (f : κ ≃ κ') :
-    traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) :=
-  by
-  ext (x y)
-  simp
+    traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) := by ext (x y); simp
 #align algebra.trace_matrix_reindex Algebra.traceMatrix_reindex
 
 variable {A}
@@ -557,9 +541,7 @@ variable {A}
 
 theorem embeddingsMatrixReindex_eq_vandermonde (pb : PowerBasis A B)
     (e : Fin pb.dim ≃ (B →ₐ[A] C)) :
-    embeddingsMatrixReindex A C pb.Basis e = (vandermonde fun i => e i pb.gen)ᵀ :=
-  by
-  ext (i j)
+    embeddingsMatrixReindex A C pb.Basis e = (vandermonde fun i => e i pb.gen)ᵀ := by ext (i j);
   simp [embeddings_matrix_reindex, embeddings_matrix]
 #align algebra.embeddings_matrix_reindex_eq_vandermonde Algebra.embeddingsMatrixReindex_eq_vandermonde
 
@@ -575,9 +557,7 @@ variable (b : κ → L) (pb : PowerBasis K L)
 
 theorem traceMatrix_eq_embeddingsMatrix_mul_trans :
     (traceMatrix K b).map (algebraMap K E) = embeddingsMatrix K E b ⬝ (embeddingsMatrix K E b)ᵀ :=
-  by
-  ext (i j)
-  simp [trace_eq_sum_embeddings, embeddings_matrix, Matrix.mul_apply]
+  by ext (i j); simp [trace_eq_sum_embeddings, embeddings_matrix, Matrix.mul_apply]
 #align algebra.trace_matrix_eq_embeddings_matrix_mul_trans Algebra.traceMatrix_eq_embeddingsMatrix_mul_trans
 
 theorem traceMatrix_eq_embeddingsMatrixReindex_mul_trans [Fintype κ] (e : κ ≃ (L →ₐ[K] E)) :
Diff
@@ -220,8 +220,8 @@ theorem traceForm_apply (x y : S) : traceForm R S x y = trace R S (x * y) :=
   rfl
 #align algebra.trace_form_apply Algebra.traceForm_apply
 
-theorem traceFormIsSymm : (traceForm R S).IsSymm := fun x y => congr_arg (trace R S) (mul_comm _ _)
-#align algebra.trace_form_is_symm Algebra.traceFormIsSymm
+theorem traceForm_isSymm : (traceForm R S).IsSymm := fun x y => congr_arg (trace R S) (mul_comm _ _)
+#align algebra.trace_form_is_symm Algebra.traceForm_isSymm
 
 theorem traceForm_toMatrix [DecidableEq ι] (i j) :
     BilinForm.toMatrix b (traceForm R S) i j = trace R S (b i * b j) := by
@@ -282,7 +282,7 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
   rw [trace_eq_zero_of_not_exists_basis, LinearMap.zero_apply]
   contrapose! hx
   obtain ⟨s, ⟨b⟩⟩ := hx
-  refine' isIntegral_of_mem_of_fG K⟮⟯.toSubalgebra _ x _
+  refine' isIntegral_of_mem_of_FG K⟮⟯.toSubalgebra _ x _
   · exact (Submodule.fg_iff_finiteDimensional _).mpr (FiniteDimensional.of_fintype_basis b)
   · exact subset_adjoin K _ (Set.mem_singleton x)
 #align intermediate_field.adjoin_simple.trace_gen_eq_zero IntermediateField.AdjoinSimple.trace_gen_eq_zero
@@ -641,11 +641,11 @@ theorem det_traceForm_ne_zero [IsSeparable K L] [DecidableEq ι] (b : Basis ι K
 
 variable (K L)
 
-theorem traceFormNondegenerate [FiniteDimensional K L] [IsSeparable K L] :
+theorem traceForm_nondegenerate [FiniteDimensional K L] [IsSeparable K L] :
     (traceForm K L).Nondegenerate :=
-  BilinForm.nondegenerateOfDetNeZero (traceForm K L) _
+  BilinForm.nondegenerate_of_det_ne_zero (traceForm K L) _
     (det_traceForm_ne_zero (FiniteDimensional.finBasis K L))
-#align trace_form_nondegenerate traceFormNondegenerate
+#align trace_form_nondegenerate traceForm_nondegenerate
 
 end DetNeZero
 
Diff
@@ -282,7 +282,7 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
   rw [trace_eq_zero_of_not_exists_basis, LinearMap.zero_apply]
   contrapose! hx
   obtain ⟨s, ⟨b⟩⟩ := hx
-  refine' isIntegral_of_mem_of_fg K⟮⟯.toSubalgebra _ x _
+  refine' isIntegral_of_mem_of_fG K⟮⟯.toSubalgebra _ x _
   · exact (Submodule.fg_iff_finiteDimensional _).mpr (FiniteDimensional.of_fintype_basis b)
   · exact subset_adjoin K _ (Set.mem_singleton x)
 #align intermediate_field.adjoin_simple.trace_gen_eq_zero IntermediateField.AdjoinSimple.trace_gen_eq_zero
Diff
@@ -93,14 +93,14 @@ variable (R S)
 /-- The trace of an element `s` of an `R`-algebra is the trace of `(*) s`,
 as an `R`-linear map. -/
 noncomputable def trace : S →ₗ[R] R :=
-  (LinearMap.trace R S).comp (LinearMap.Algebra.lmul R S).toLinearMap
+  (LinearMap.trace R S).comp (lmul R S).toLinearMap
 #align algebra.trace Algebra.trace
 
 variable {S}
 
 -- Not a `simp` lemma since there are more interesting ways to rewrite `trace R S x`,
 -- for example `trace_trace`
-theorem trace_apply (x) : trace R S x = LinearMap.trace R S (LinearMap.Algebra.lmul R S x) :=
+theorem trace_apply (x) : trace R S x = LinearMap.trace R S (lmul R S x) :=
   rfl
 #align algebra.trace_apply Algebra.trace_apply
 
@@ -209,7 +209,7 @@ variable (R S)
 /-- The `trace_form` maps `x y : S` to the trace of `x * y`.
 It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
 noncomputable def traceForm : BilinForm R S :=
-  (LinearMap.compr₂ (LinearMap.Algebra.lmul R S).toLinearMap (trace R S)).toBilin
+  (LinearMap.compr₂ (lmul R S).toLinearMap (trace R S)).toBilin
 #align algebra.trace_form Algebra.traceForm
 
 variable {S}
Diff
@@ -404,7 +404,7 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
     rw [AlgHom.card L F E]
   · intro σ
     simp only [algHomEquivSigma, Equiv.coe_fn_mk, AlgHom.restrictDomain, AlgHom.comp_apply,
-      IsScalarTower.coe_to_alg_hom']
+      IsScalarTower.coe_toAlgHom']
 #align sum_embeddings_eq_finrank_mul sum_embeddings_eq_finrank_mul
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:192:11: unsupported (impossible) -/
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Anne Baanen
 
 ! This file was ported from Lean 3 source module ring_theory.trace
-! leanprover-community/mathlib commit b68f3403d74afcfd65ab3fe65220572b410a3ed4
+! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -448,14 +448,15 @@ open Finset
 
 /-- Given an `A`-algebra `B` and `b`, an `κ`-indexed family of elements of `B`, we define
 `trace_matrix A b` as the matrix whose `(i j)`-th element is the trace of `b i * b j`. -/
-@[simp]
-noncomputable def traceMatrix (b : κ → B) : Matrix κ κ A
-  | i, j => traceForm A B (b i) (b j)
+noncomputable def traceMatrix (b : κ → B) : Matrix κ κ A :=
+  of fun i j => traceForm A B (b i) (b j)
 #align algebra.trace_matrix Algebra.traceMatrix
 
-theorem traceMatrix_def (b : κ → B) : traceMatrix A b = of fun i j => traceForm A B (b i) (b j) :=
+-- TODO: set as an equation lemma for `trace_matrix`, see mathlib4#3024
+@[simp]
+theorem traceMatrix_apply (b : κ → B) (i j) : traceMatrix A b i j = traceForm A B (b i) (b j) :=
   rfl
-#align algebra.trace_matrix_def Algebra.traceMatrix_def
+#align algebra.trace_matrix_apply Algebra.traceMatrix_apply
 
 theorem traceMatrix_reindex {κ' : Type _} (b : Basis κ A B) (f : κ ≃ κ') :
     traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) :=
@@ -470,7 +471,7 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
     traceMatrix A ((P.map (algebraMap A B)).vecMul b) = Pᵀ ⬝ traceMatrix A b ⬝ P :=
   by
   ext (α β)
-  rw [trace_matrix, vec_mul, dot_product, vec_mul, dot_product, Matrix.mul_apply,
+  rw [trace_matrix_apply, vec_mul, dot_product, vec_mul, dot_product, Matrix.mul_apply,
     BilinForm.sum_left,
     Fintype.sum_congr _ _ fun i : κ =>
       @BilinForm.sum_right _ _ _ _ _ _ _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
@@ -500,7 +501,7 @@ theorem traceMatrix_of_basis [Fintype κ] [DecidableEq κ] (b : Basis κ A B) :
     traceMatrix A b = BilinForm.toMatrix b (traceForm A B) :=
   by
   ext (i j)
-  rw [trace_matrix, trace_form_apply, trace_form_to_matrix]
+  rw [trace_matrix_apply, trace_form_apply, trace_form_to_matrix]
 #align algebra.trace_matrix_of_basis Algebra.traceMatrix_of_basis
 
 theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
@@ -508,7 +509,7 @@ theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
   by
   ext i
   rw [← col_apply ((trace_matrix A b).mulVec (b.equiv_fun z)) i Unit.unit, col_mul_vec,
-    Matrix.mul_apply, trace_matrix_def]
+    Matrix.mul_apply, trace_matrix]
   simp only [col_apply, trace_form_apply]
   conv_lhs =>
     congr
@@ -532,11 +533,17 @@ variable (A)
 /-- `embeddings_matrix A C b : matrix κ (B →ₐ[A] C) C` is the matrix whose `(i, σ)` coefficient is
   `σ (b i)`. It is mostly useful for fields when `fintype.card κ = finrank A B` and `C` is
   algebraically closed. -/
-@[simp]
-def embeddingsMatrix (b : κ → B) : Matrix κ (B →ₐ[A] C) C
-  | i, σ => σ (b i)
+def embeddingsMatrix (b : κ → B) : Matrix κ (B →ₐ[A] C) C :=
+  of fun i (σ : B →ₐ[A] C) => σ (b i)
 #align algebra.embeddings_matrix Algebra.embeddingsMatrix
 
+-- TODO: set as an equation lemma for `embeddings_matrix`, see mathlib4#3024
+@[simp]
+theorem embeddingsMatrix_apply (b : κ → B) (i) (σ : B →ₐ[A] C) :
+    embeddingsMatrix A C b i σ = σ (b i) :=
+  rfl
+#align algebra.embeddings_matrix_apply Algebra.embeddingsMatrix_apply
+
 /-- `embeddings_matrix_reindex A C b e : matrix κ κ C` is the matrix whose `(i, j)` coefficient
   is `σⱼ (b i)`, where `σⱼ : B →ₐ[A] C` is the embedding corresponding to `j : κ` given by a
   bijection `e : κ ≃ (B →ₐ[A] C)`. It is mostly useful for fields and `C` is algebraically closed.
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Anne Baanen
 
 ! This file was ported from Lean 3 source module ring_theory.trace
-! leanprover-community/mathlib commit 825edd3cd735e87495b0c2a2114fc3929eefce41
+! leanprover-community/mathlib commit b68f3403d74afcfd65ab3fe65220572b410a3ed4
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -185,6 +185,23 @@ theorem trace_comp_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [Fini
   rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace]
 #align algebra.trace_comp_trace Algebra.trace_comp_trace
 
+@[simp]
+theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T]
+    (x : S × T) : trace R (S × T) x = trace R S x.fst + trace R T x.snd :=
+  by
+  nontriviality R
+  let f := (lmul R S).toLinearMap.Prod_map (lmul R T).toLinearMap
+  have : (lmul R (S × T)).toLinearMap = (prod_map_linear R S T S T R).comp f :=
+    LinearMap.ext₂ Prod.mul_def
+  simp_rw [trace, this]
+  exact trace_prod_map' _ _
+#align algebra.trace_prod_apply Algebra.trace_prod_apply
+
+theorem trace_prod [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T] :
+    trace R (S × T) = (trace R S).coprod (trace R T) :=
+  LinearMap.ext fun p => by rw [coprod_apply, trace_prod_apply]
+#align algebra.trace_prod Algebra.trace_prod
+
 section TraceForm
 
 variable (R S)
Diff
@@ -93,14 +93,14 @@ variable (R S)
 /-- The trace of an element `s` of an `R`-algebra is the trace of `(*) s`,
 as an `R`-linear map. -/
 noncomputable def trace : S →ₗ[R] R :=
-  (LinearMap.trace R S).comp (lmul R S).toLinearMap
+  (LinearMap.trace R S).comp (LinearMap.Algebra.lmul R S).toLinearMap
 #align algebra.trace Algebra.trace
 
 variable {S}
 
 -- Not a `simp` lemma since there are more interesting ways to rewrite `trace R S x`,
 -- for example `trace_trace`
-theorem trace_apply (x) : trace R S x = LinearMap.trace R S (lmul R S x) :=
+theorem trace_apply (x) : trace R S x = LinearMap.trace R S (LinearMap.Algebra.lmul R S x) :=
   rfl
 #align algebra.trace_apply Algebra.trace_apply
 
@@ -192,7 +192,7 @@ variable (R S)
 /-- The `trace_form` maps `x y : S` to the trace of `x * y`.
 It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
 noncomputable def traceForm : BilinForm R S :=
-  (LinearMap.compr₂ (lmul R S).toLinearMap (trace R S)).toBilin
+  (LinearMap.compr₂ (LinearMap.Algebra.lmul R S).toLinearMap (trace R S)).toBilin
 #align algebra.trace_form Algebra.traceForm
 
 variable {S}

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 2 (#12361)

A PR analogous to #12338: reformatting proofs following the multiple goals linter of #12339.

Diff
@@ -395,18 +395,18 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
   haveI : IsSeparable L F := isSeparable_tower_top_of_isSeparable K L F
   letI : Fintype (L →ₐ[K] E) := PowerBasis.AlgHom.fintype pb
   letI : ∀ f : L →ₐ[K] E, Fintype (haveI := f.toRingHom.toAlgebra; AlgHom L F E) := ?_
-  rw [Fintype.sum_equiv algHomEquivSigma (fun σ : F →ₐ[K] E => _) fun σ => σ.1 pb.gen, ←
-    Finset.univ_sigma_univ, Finset.sum_sigma, ← Finset.sum_nsmul]
-  refine' Finset.sum_congr rfl fun σ _ => _
-  · letI : Algebra L E := σ.toRingHom.toAlgebra
-    -- Porting note: `Finset.card_univ` was inside `simp only`.
-    simp only [Finset.sum_const]
-    congr
-    rw [← AlgHom.card L F E]
-    exact Finset.card_univ (α := F →ₐ[L] E)
-  · intro σ
-    simp only [algHomEquivSigma, Equiv.coe_fn_mk, AlgHom.restrictDomain, AlgHom.comp_apply,
-      IsScalarTower.coe_toAlgHom']
+  · rw [Fintype.sum_equiv algHomEquivSigma (fun σ : F →ₐ[K] E => _) fun σ => σ.1 pb.gen, ←
+      Finset.univ_sigma_univ, Finset.sum_sigma, ← Finset.sum_nsmul]
+    · refine' Finset.sum_congr rfl fun σ _ => _
+      letI : Algebra L E := σ.toRingHom.toAlgebra
+      -- Porting note: `Finset.card_univ` was inside `simp only`.
+      simp only [Finset.sum_const]
+      congr
+      rw [← AlgHom.card L F E]
+      exact Finset.card_univ (α := F →ₐ[L] E)
+    · intro σ
+      simp only [algHomEquivSigma, Equiv.coe_fn_mk, AlgHom.restrictDomain, AlgHom.comp_apply,
+        IsScalarTower.coe_toAlgHom']
 #align sum_embeddings_eq_finrank_mul sum_embeddings_eq_finrank_mul
 
 theorem trace_eq_sum_embeddings [FiniteDimensional K L] [IsSeparable K L] {x : L} :
@@ -591,13 +591,13 @@ theorem det_traceMatrix_ne_zero' [IsSeparable K L] : det (traceMatrix K pb.basis
     rw [ht, RingHom.map_zero]
   haveI : FiniteDimensional K L := pb.finiteDimensional
   let e : Fin pb.dim ≃ (L →ₐ[K] AlgebraicClosure L) := (Fintype.equivFinOfCardEq ?_).symm
-  rw [RingHom.map_det, RingHom.mapMatrix_apply,
-    traceMatrix_eq_embeddingsMatrixReindex_mul_trans K _ _ e,
-    embeddingsMatrixReindex_eq_vandermonde, det_mul, det_transpose]
-  refine mt mul_self_eq_zero.mp ?_
-  · simp only [det_vandermonde, Finset.prod_eq_zero_iff, not_exists, sub_eq_zero]
-    rintro i ⟨_, j, hij, h⟩
-    exact (Finset.mem_Ioi.mp hij).ne' (e.injective <| pb.algHom_ext h)
+  · rw [RingHom.map_det, RingHom.mapMatrix_apply,
+      traceMatrix_eq_embeddingsMatrixReindex_mul_trans K _ _ e,
+      embeddingsMatrixReindex_eq_vandermonde, det_mul, det_transpose]
+    refine mt mul_self_eq_zero.mp ?_
+    · simp only [det_vandermonde, Finset.prod_eq_zero_iff, not_exists, sub_eq_zero]
+      rintro i ⟨_, j, hij, h⟩
+      exact (Finset.mem_Ioi.mp hij).ne' (e.injective <| pb.algHom_ext h)
   · rw [AlgHom.card, pb.finrank]
 #align det_trace_matrix_ne_zero' det_traceMatrix_ne_zero'
 
doc(RingTheory/Trace): Remove porting note (#12489)

toBilin was depreciated in #12078. This porting note no longer makes sense.

Diff
@@ -190,7 +190,6 @@ variable (R S)
 /-- The `traceForm` maps `x y : S` to the trace of `x * y`.
 It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
 noncomputable def traceForm : BilinForm R S :=
--- Porting note: dot notation `().toBilin` does not work anymore.
   LinearMap.compr₂ (lmul R S).toLinearMap (trace R S)
 #align algebra.trace_form Algebra.traceForm
 
refactor(LinearAlgebra/BilinearForm/Hom): Deprecate results (#12078)

Following the removal of structure BilinForm from Mathlib (#11278) a number of definitions and results in LinearAlgebra/BilinearForm/Hom are essentially just the identity. This PR deprecates these results.

Co-authored-by: Christopher Hoskin <christopher.hoskin@gmail.com>

Diff
@@ -190,8 +190,8 @@ variable (R S)
 /-- The `traceForm` maps `x y : S` to the trace of `x * y`.
 It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
 noncomputable def traceForm : BilinForm R S :=
-  -- Porting note: dot notation `().toBilin` does not work anymore.
-  LinearMap.toBilin (LinearMap.compr₂ (lmul R S).toLinearMap (trace R S))
+-- Porting note: dot notation `().toBilin` does not work anymore.
+  LinearMap.compr₂ (lmul R S).toLinearMap (trace R S)
 #align algebra.trace_form Algebra.traceForm
 
 variable {S}
chore: remove a few miscellaneous now-resolved porting notes (#12127)
Diff
@@ -190,7 +190,7 @@ variable (R S)
 /-- The `traceForm` maps `x y : S` to the trace of `x * y`.
 It is a symmetric bilinear form and is nondegenerate if the extension is separable. -/
 noncomputable def traceForm : BilinForm R S :=
--- Porting note: dot notation `().toBilin` does not work anymore.
+  -- Porting note: dot notation `().toBilin` does not work anymore.
   LinearMap.toBilin (LinearMap.compr₂ (lmul R S).toLinearMap (trace R S))
 #align algebra.trace_form Algebra.traceForm
 
@@ -282,8 +282,9 @@ variable (K)
 
 theorem trace_eq_trace_adjoin [FiniteDimensional K L] (x : L) :
     Algebra.trace K L x = finrank K⟮x⟯ L • trace K K⟮x⟯ (AdjoinSimple.gen K x) := by
--- Porting note: `conv` was `conv in x => rw [← IntermediateField.AdjoinSimple.algebraMap_gen K x]`
--- and it was after the first `rw`.
+  -- Porting note: `conv` was
+  -- `conv in x => rw [← IntermediateField.AdjoinSimple.algebraMap_gen K x]`
+  -- and it was after the first `rw`.
   conv =>
     lhs
     rw [← IntermediateField.AdjoinSimple.algebraMap_gen K x]
@@ -371,13 +372,13 @@ theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
     algebraMap K E (Algebra.trace K L pb.gen) =
       (@Finset.univ _ (PowerBasis.AlgHom.fintype pb)).sum fun σ => σ pb.gen := by
   letI := Classical.decEq E
--- Porting note: the following `letI` was not needed.
-  letI : Fintype (L →ₐ[K] E) := PowerBasis.AlgHom.fintype pb
+  -- Porting note: the following `letI` was not needed.
+  letI : Fintype (L →ₐ[K] E) := (PowerBasis.AlgHom.fintype pb)
   rw [pb.trace_gen_eq_sum_roots hE, Fintype.sum_equiv pb.liftEquiv', Finset.sum_mem_multiset,
     Finset.sum_eq_multiset_sum, Multiset.toFinset_val, Multiset.dedup_eq_self.mpr _,
     Multiset.map_id]
   · exact nodup_roots ((separable_map _).mpr hfx)
--- Porting note: the following goal does not exist in mathlib3.
+  -- Porting note: the following goal does not exist in mathlib3.
   · exact (fun x => x.1)
   · intro x; rfl
   · intro σ
@@ -399,7 +400,7 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
     Finset.univ_sigma_univ, Finset.sum_sigma, ← Finset.sum_nsmul]
   refine' Finset.sum_congr rfl fun σ _ => _
   · letI : Algebra L E := σ.toRingHom.toAlgebra
--- Porting note: `Finset.card_univ` was inside `simp only`.
+    -- Porting note: `Finset.card_univ` was inside `simp only`.
     simp only [Finset.sum_const]
     congr
     rw [← AlgHom.card L F E]
@@ -415,8 +416,8 @@ theorem trace_eq_sum_embeddings [FiniteDimensional K L] [IsSeparable K L] {x : L
   let pb := adjoin.powerBasis hx
   rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← adjoin.powerBasis_gen hx,
     trace_eq_sum_embeddings_gen E pb (IsAlgClosed.splits_codomain _)]
--- Porting note: the following `convert` was `exact`, with `← algebra.smul_def, algebra_map_smul`
--- in the previous `rw`.
+  -- Porting note: the following `convert` was `exact`, with `← algebra.smul_def, algebra_map_smul`
+  -- in the previous `rw`.
   · convert (sum_embeddings_eq_finrank_mul L E pb).symm
     ext
     simp
@@ -594,9 +595,7 @@ theorem det_traceMatrix_ne_zero' [IsSeparable K L] : det (traceMatrix K pb.basis
   rw [RingHom.map_det, RingHom.mapMatrix_apply,
     traceMatrix_eq_embeddingsMatrixReindex_mul_trans K _ _ e,
     embeddingsMatrixReindex_eq_vandermonde, det_mul, det_transpose]
--- Porting note: the following is necessary.
-  haveI := IsDomain.to_noZeroDivisors (AlgebraicClosure L)
-  refine' mt mul_self_eq_zero.mp _
+  refine mt mul_self_eq_zero.mp ?_
   · simp only [det_vandermonde, Finset.prod_eq_zero_iff, not_exists, sub_eq_zero]
     rintro i ⟨_, j, hij, h⟩
     exact (Finset.mem_Ioi.mp hij).ne' (e.injective <| pb.algHom_ext h)
chore: remove more simp-related porting notes which are fixed now (#12128)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -142,13 +142,10 @@ theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*}
   cases nonempty_fintype κ
   rw [trace_eq_matrix_trace (b.smul c), trace_eq_matrix_trace b, trace_eq_matrix_trace c,
     Matrix.trace, Matrix.trace, Matrix.trace, ← Finset.univ_product_univ, Finset.sum_product]
-  refine' Finset.sum_congr rfl fun i _ => _
+  refine Finset.sum_congr rfl fun i _ ↦ ?_
   simp only [AlgHom.map_sum, smul_leftMulMatrix, Finset.sum_apply,
-    Matrix.diag]
--- Porting note: the `rw` was inside `simp only`, but it doesn't work anymore.
-  rw [Finset.sum_apply
+    Matrix.diag, Finset.sum_apply
       i (Finset.univ : Finset κ) fun y => leftMulMatrix b (leftMulMatrix c x y y)]
-  apply Finset.sum_apply
 #align algebra.trace_trace_of_basis Algebra.trace_trace_of_basis
 
 theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
@@ -434,7 +431,7 @@ theorem trace_eq_sum_automorphisms (x : L) [FiniteDimensional K L] [IsGalois K L
   rw [← Fintype.sum_equiv (Normal.algHomEquivAut K (AlgebraicClosure L) L)]
   · rw [← trace_eq_sum_embeddings (AlgebraicClosure L)]
     · simp only [algebraMap_eq_smul_one]
--- Porting note: `smul_one_smul` was in the `simp only`.
+      -- Porting note: `smul_one_smul` was in the `simp only`.
       apply smul_one_smul
   · intro σ
     simp only [Normal.algHomEquivAut, AlgHom.restrictNormal', Equiv.coe_fn_mk,
chore: restore simps that used to work (#12126)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -118,8 +118,7 @@ theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Finty
   haveI := Classical.decEq ι
   rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace]
   convert Finset.sum_const x
-  -- porting note (#10745): was `simp [-coe_lmul_eq_mul]`.
-  simp only [AlgHom.commutes, toMatrix_algebraMap, diag_apply, scalar_apply, diagonal_apply_eq]
+  simp [-coe_lmul_eq_mul]
 
 #align algebra.trace_algebra_map_of_basis Algebra.trace_algebraMap_of_basis
 
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -376,7 +376,7 @@ theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
       (@Finset.univ _ (PowerBasis.AlgHom.fintype pb)).sum fun σ => σ pb.gen := by
   letI := Classical.decEq E
 -- Porting note: the following `letI` was not needed.
-  letI : Fintype (L →ₐ[K] E) := (PowerBasis.AlgHom.fintype pb)
+  letI : Fintype (L →ₐ[K] E) := PowerBasis.AlgHom.fintype pb
   rw [pb.trace_gen_eq_sum_roots hE, Fintype.sum_equiv pb.liftEquiv', Finset.sum_mem_multiset,
     Finset.sum_eq_multiset_sum, Multiset.toFinset_val, Multiset.dedup_eq_self.mpr _,
     Multiset.map_id]
@@ -416,7 +416,7 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
 theorem trace_eq_sum_embeddings [FiniteDimensional K L] [IsSeparable K L] {x : L} :
     algebraMap K E (Algebra.trace K L x) = ∑ σ : L →ₐ[K] E, σ x := by
   have hx := IsSeparable.isIntegral K x
-  let pb := (adjoin.powerBasis hx)
+  let pb := adjoin.powerBasis hx
   rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← adjoin.powerBasis_gen hx,
     trace_eq_sum_embeddings_gen E pb (IsAlgClosed.splits_codomain _)]
 -- Porting note: the following `convert` was `exact`, with `← algebra.smul_def, algebra_map_smul`
refactor(LinearAlgebra/BilinForm): Remove structure BilinForm from Mathlib, migrate all of _root_.BilinForm to LinearMap.BilinForm (#11278)

Remove structure BilinForm from LinearAlgebra/BilinearForm/Basic and migrate all of _root_.BilinForm to LinearMap.BilinForm

Closes: #10553

This isn't the end of the story, as there's still a lot of overlap between LinearAlgebra/BilinearForm and LinearAlgebra/SesquilinearForm but that can be sorted out in subsequent PRs.

Supersedes:

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Christopher Hoskin <christopher.hoskin@overleaf.com> Co-authored-by: Christopher Hoskin <mans0954@users.noreply.github.com> Co-authored-by: Vierkantor <vierkantor@vierkantor.com>

Diff
@@ -73,6 +73,7 @@ variable {ι κ : Type w} [Fintype ι]
 
 open FiniteDimensional
 
+open LinearMap (BilinForm)
 open LinearMap
 
 open Matrix
@@ -673,8 +674,9 @@ lemma traceForm_dualBasis_powerBasis_eq [FiniteDimensional K L] [IsSeparable K L
   simp only [AlgEquiv.toAlgHom_eq_coe, Polynomial.map_smul, map_div₀,
     map_pow, RingHom.coe_coe, AlgHom.coe_coe, finset_sum_coeff, coeff_smul, coeff_map, smul_eq_mul,
     coeff_X_pow, ← Fin.ext_iff, @eq_comm _ i] at this
-  rw [PowerBasis.coe_basis, Algebra.traceForm_apply, RingHom.map_ite_one_zero,
-  ← this, trace_eq_sum_embeddings (E := AlgebraicClosure K)]
+  rw [PowerBasis.coe_basis]
+  simp only [RingHom.map_ite_one_zero, traceForm_apply]
+  rw [← this, trace_eq_sum_embeddings (E := AlgebraicClosure K)]
   apply Finset.sum_congr rfl
   intro σ _
   simp only [_root_.map_mul, map_div₀, map_pow]
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
@@ -67,11 +67,8 @@ For now, the definitions assume `S` is commutative, so the choice doesn't matter
 universe u v w z
 
 variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
-
 variable [Algebra R S] [Algebra R T]
-
 variable {K L : Type*} [Field K] [Field L] [Algebra K L]
-
 variable {ι κ : Type w} [Fintype ι]
 
 open FiniteDimensional
@@ -87,7 +84,6 @@ open scoped Matrix
 namespace Algebra
 
 variable (b : Basis ι R S)
-
 variable (R S)
 
 /-- The trace of an element `s` of an `R`-algebra is the trace of `(s * ·)`,
@@ -231,7 +227,6 @@ section EqSumRoots
 open Algebra Polynomial
 
 variable {F : Type*} [Field F]
-
 variable [Algebra K S] [Algebra K F]
 
 /-- Given `pb : PowerBasis K S`, the trace of `pb.gen` is `-(minpoly K pb.gen).nextCoeff`. -/
@@ -311,7 +306,6 @@ theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
 end EqSumRoots
 
 variable {F : Type*} [Field F]
-
 variable [Algebra R L] [Algebra L F] [Algebra R F] [IsScalarTower R L F]
 
 open Polynomial
@@ -454,7 +448,6 @@ section DetNeZero
 namespace Algebra
 
 variable (A : Type u) {B : Type v} (C : Type z)
-
 variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C]
 
 open Finset
@@ -571,11 +564,8 @@ theorem embeddingsMatrixReindex_eq_vandermonde (pb : PowerBasis A B)
 section Field
 
 variable (K) (E : Type z) [Field E]
-
 variable [Algebra K E]
-
 variable [Module.Finite K L] [IsSeparable K L] [IsAlgClosed E]
-
 variable (b : κ → L) (pb : PowerBasis K L)
 
 theorem traceMatrix_eq_embeddingsMatrix_mul_trans :
chore(RingTheory/Trace): Fintype -> Finite (#11309)
Diff
@@ -90,7 +90,7 @@ variable (b : Basis ι R S)
 
 variable (R S)
 
-/-- The trace of an element `s` of an `R`-algebra is the trace of `(*) s`,
+/-- The trace of an element `s` of an `R`-algebra is the trace of `(s * ·)`,
 as an `R`-linear map. -/
 noncomputable def trace : S →ₗ[R] R :=
   (LinearMap.trace R S).comp (lmul R S).toLinearMap
@@ -156,7 +156,7 @@ theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*}
 #align algebra.trace_trace_of_basis Algebra.trace_trace_of_basis
 
 theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
-    [Fintype κ] (b : Basis ι R S) (c : Basis κ S T) :
+    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) :
     (trace R S).comp ((trace S T).restrictScalars R) = trace R T := by
   ext
   rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace_of_basis b c]
chore: classify was simp porting notes (#10746)

Classifies by adding issue number (#10745) to porting notes claiming was simp.

Diff
@@ -121,7 +121,7 @@ theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Finty
   haveI := Classical.decEq ι
   rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace]
   convert Finset.sum_const x
-  -- Porting note: was `simp [-coe_lmul_eq_mul]`.
+  -- porting note (#10745): was `simp [-coe_lmul_eq_mul]`.
   simp only [AlgHom.commutes, toMatrix_algebraMap, diag_apply, scalar_apply, diagonal_apply_eq]
 
 #align algebra.trace_algebra_map_of_basis Algebra.trace_algebraMap_of_basis
chore: Remove unnecessary "rw"s (#10704)

Remove unnecessary "rw"s.

Diff
@@ -502,8 +502,7 @@ theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ
     traceMatrix A (P.map (algebraMap A B) *ᵥ b) = P * traceMatrix A b * Pᵀ := by
   refine' AddEquiv.injective (transposeAddEquiv κ κ A) _
   rw [transposeAddEquiv_apply, transposeAddEquiv_apply, ← vecMul_transpose, ← transpose_map,
-    traceMatrix_of_matrix_vecMul, transpose_transpose, transpose_mul, transpose_transpose,
-    transpose_mul]
+    traceMatrix_of_matrix_vecMul, transpose_transpose]
 #align algebra.trace_matrix_of_matrix_mul_vec Algebra.traceMatrix_of_matrix_mulVec
 
 theorem traceMatrix_of_basis [Fintype κ] [DecidableEq κ] (b : Basis κ A B) :
chore: Matrix.mulVec and Matrix.vecMul get infix notation (#10297)

Zulip discussion: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20mul_vec.20and.20vec_mul

Co-authored-by: Martin Dvorak <mdvorak@ista.ac.at>

Diff
@@ -478,7 +478,7 @@ theorem traceMatrix_reindex {κ' : Type*} (b : Basis κ A B) (f : κ ≃ κ') :
 variable {A}
 
 theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
-    traceMatrix A ((P.map (algebraMap A B)).vecMul b) = Pᵀ * traceMatrix A b * P := by
+    traceMatrix A (b ᵥ* P.map (algebraMap A B)) = Pᵀ * traceMatrix A b * P := by
   ext (α β)
   rw [traceMatrix_apply, vecMul, dotProduct, vecMul, dotProduct, Matrix.mul_apply,
     BilinForm.sum_left,
@@ -499,7 +499,7 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
 #align algebra.trace_matrix_of_matrix_vec_mul Algebra.traceMatrix_of_matrix_vecMul
 
 theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
-    traceMatrix A ((P.map (algebraMap A B)).mulVec b) = P * traceMatrix A b * Pᵀ := by
+    traceMatrix A (P.map (algebraMap A B) *ᵥ b) = P * traceMatrix A b * Pᵀ := by
   refine' AddEquiv.injective (transposeAddEquiv κ κ A) _
   rw [transposeAddEquiv_apply, transposeAddEquiv_apply, ← vecMul_transpose, ← transpose_map,
     traceMatrix_of_matrix_vecMul, transpose_transpose, transpose_mul, transpose_transpose,
@@ -513,9 +513,9 @@ theorem traceMatrix_of_basis [Fintype κ] [DecidableEq κ] (b : Basis κ A B) :
 #align algebra.trace_matrix_of_basis Algebra.traceMatrix_of_basis
 
 theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
-    (traceMatrix A b).mulVec (b.equivFun z) = fun i => trace A B (z * b i) := by
+    traceMatrix A b *ᵥ b.equivFun z = fun i => trace A B (z * b i) := by
   ext i
-  rw [← col_apply ((traceMatrix A b).mulVec (b.equivFun z)) i Unit.unit, col_mulVec,
+  rw [← col_apply (traceMatrix A b *ᵥ b.equivFun z) i Unit.unit, col_mulVec,
     Matrix.mul_apply, traceMatrix]
   simp only [col_apply, traceForm_apply]
   conv_lhs =>
feat: Lemmas relating Polynomial.eraseLead and nextCoeff. (#9083)

Some little theorems relating eraseLead and nextCoeff to each other. Also includes monomial_sub and card_support_mul which could be of independent interest.

Co-authored-by: Alex Meiburg <timeroot.alex@gmail.com> Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>

Diff
@@ -241,7 +241,7 @@ theorem PowerBasis.trace_gen_eq_nextCoeff_minpoly [Nontrivial S] (pb : PowerBasi
   have d_pos' : 0 < (minpoly K pb.gen).natDegree := by simpa
   haveI : Nonempty (Fin pb.dim) := ⟨⟨0, d_pos⟩⟩
   rw [trace_eq_matrix_trace pb.basis, trace_eq_neg_charpoly_coeff, charpoly_leftMulMatrix, ←
-    pb.natDegree_minpoly, Fintype.card_fin, ← nextCoeff_of_pos_natDegree _ d_pos']
+    pb.natDegree_minpoly, Fintype.card_fin, ← nextCoeff_of_natDegree_pos d_pos']
 #align power_basis.trace_gen_eq_next_coeff_minpoly PowerBasis.trace_gen_eq_nextCoeff_minpoly
 
 /-- Given `pb : PowerBasis K S`, then the trace of `pb.gen` is
feat: Dual basis of power basis wrt trace form (#8835)

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

Diff
@@ -13,6 +13,7 @@ import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure
 import Mathlib.FieldTheory.PrimitiveElement
 import Mathlib.FieldTheory.Galois
 import Mathlib.RingTheory.PowerBasis
+import Mathlib.FieldTheory.Minpoly.MinpolyDiv
 
 #align_import ring_theory.trace from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
 
@@ -43,6 +44,8 @@ the roots of the minimal polynomial of `s` over `R`.
    algebraically closed field
  * `traceForm_nondegenerate`: the trace form over a separable extension is a nondegenerate
    bilinear form
+* `traceForm_dualBasis_powerBasis_eq`: The dual basis of a powerbasis `{1, x, x²...}` under the
+   trace form is `aᵢ / f'(x)`, with `f` being the minpoly of `x` and `f / (X - x) = ∑ aᵢxⁱ`.
 
 ## Implementation notes
 
@@ -660,4 +663,32 @@ theorem Algebra.trace_surjective [FiniteDimensional K L] [IsSeparable K L] :
   rw [LinearMap.range_eq_bot]
   exact Algebra.trace_ne_zero K L
 
+variable {K L}
+
+/--
+The dual basis of a powerbasis `{1, x, x²...}` under the trace form is `aᵢ / f'(x)`,
+with `f` being the minimal polynomial of `x` and `f / (X - x) = ∑ aᵢxⁱ`.
+-/
+lemma traceForm_dualBasis_powerBasis_eq [FiniteDimensional K L] [IsSeparable K L]
+    (pb : PowerBasis K L) (i) :
+    (Algebra.traceForm K L).dualBasis (traceForm_nondegenerate K L) pb.basis i =
+      (minpolyDiv K pb.gen).coeff i / aeval pb.gen (derivative <| minpoly K pb.gen) := by
+  classical
+  apply ((Algebra.traceForm K L).toDual (traceForm_nondegenerate K L)).injective
+  apply pb.basis.ext
+  intro j
+  simp only [BilinForm.toDual_def, BilinForm.apply_dualBasis_left]
+  apply (algebraMap K (AlgebraicClosure K)).injective
+  have := congr_arg (coeff · i) (sum_smul_minpolyDiv_eq_X_pow (AlgebraicClosure K)
+    pb.adjoin_gen_eq_top (r := j) (pb.finrank.symm ▸ j.prop))
+  simp only [AlgEquiv.toAlgHom_eq_coe, Polynomial.map_smul, map_div₀,
+    map_pow, RingHom.coe_coe, AlgHom.coe_coe, finset_sum_coeff, coeff_smul, coeff_map, smul_eq_mul,
+    coeff_X_pow, ← Fin.ext_iff, @eq_comm _ i] at this
+  rw [PowerBasis.coe_basis, Algebra.traceForm_apply, RingHom.map_ite_one_zero,
+  ← this, trace_eq_sum_embeddings (E := AlgebraicClosure K)]
+  apply Finset.sum_congr rfl
+  intro σ _
+  simp only [_root_.map_mul, map_div₀, map_pow]
+  ring
+
 end DetNeZero
feat: Define the dual of a fractional ideal. (#8833)

Also moved Algebra.discr_eq_discr_of_toMatrix_coeff_isIntegral to Mathlib/NumberTheory/NumberField/Discriminant.lean.

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

Diff
@@ -644,4 +644,20 @@ theorem traceForm_nondegenerate [FiniteDimensional K L] [IsSeparable K L] :
     (det_traceForm_ne_zero (FiniteDimensional.finBasis K L))
 #align trace_form_nondegenerate traceForm_nondegenerate
 
+theorem Algebra.trace_ne_zero [FiniteDimensional K L] [IsSeparable K L] :
+    Algebra.trace K L ≠ 0 := by
+  intro e
+  let pb : PowerBasis K L := Field.powerBasisOfFiniteOfSeparable _ _
+  apply det_traceMatrix_ne_zero' pb
+  rw [show traceMatrix K pb.basis = 0 by ext; simp [e], Matrix.det_zero]
+  rw [← pb.finrank, ← Fin.pos_iff_nonempty]
+  exact finrank_pos
+
+theorem Algebra.trace_surjective [FiniteDimensional K L] [IsSeparable K L] :
+    Function.Surjective (Algebra.trace K L) := by
+  rw [← LinearMap.range_eq_top]
+  apply (IsSimpleOrder.eq_bot_or_eq_top (α := Ideal K) _).resolve_left
+  rw [LinearMap.range_eq_bot]
+  exact Algebra.trace_ne_zero K L
+
 end DetNeZero
feat: Norm and trace under isomorphisms. (#8682)

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

Diff
@@ -328,6 +328,42 @@ theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegra
   · apply IsAlgClosed.splits_codomain
 #align algebra.is_integral_trace Algebra.isIntegral_trace
 
+lemma Algebra.trace_eq_of_algEquiv {A B C : Type*} [CommRing A] [CommRing B] [CommRing C]
+    [Algebra A B] [Algebra A C] (e : B ≃ₐ[A] C) (x) :
+    Algebra.trace A C (e x) = Algebra.trace A B x := by
+  simp_rw [Algebra.trace_apply, ← LinearMap.trace_conj' _ e.toLinearEquiv]
+  congr; ext; simp [LinearEquiv.conj_apply]
+
+lemma Algebra.trace_eq_of_ringEquiv {A B C : Type*} [CommRing A] [CommRing B] [CommRing C]
+    [Algebra A C] [Algebra B C] (e : A ≃+* B) (he : (algebraMap B C).comp e = algebraMap A C) (x) :
+    e (Algebra.trace A C x) = Algebra.trace B C x := by
+  classical
+  by_cases h : ∃ s : Finset C, Nonempty (Basis s B C)
+  · obtain ⟨s, ⟨b⟩⟩ := h
+    letI : Algebra A B := RingHom.toAlgebra e
+    letI : IsScalarTower A B C := IsScalarTower.of_algebraMap_eq' he.symm
+    rw [Algebra.trace_eq_matrix_trace b,
+      Algebra.trace_eq_matrix_trace (b.mapCoeffs e.symm (by simp [Algebra.smul_def, ← he]))]
+    show e.toAddMonoidHom _ = _
+    rw [AddMonoidHom.map_trace]
+    congr
+    ext i j
+    simp [leftMulMatrix_apply, LinearMap.toMatrix_apply]
+  rw [trace_eq_zero_of_not_exists_basis _ h, trace_eq_zero_of_not_exists_basis,
+    LinearMap.zero_apply, LinearMap.zero_apply, map_zero]
+  intro ⟨s, ⟨b⟩⟩
+  exact h ⟨s, ⟨b.mapCoeffs e (by simp [Algebra.smul_def, ← he])⟩⟩
+
+lemma Algebra.trace_eq_of_equiv_equiv {A₁ B₁ A₂ B₂ : Type*} [CommRing A₁] [CommRing B₁]
+    [CommRing A₂] [CommRing B₂] [Algebra A₁ B₁] [Algebra A₂ B₂] (e₁ : A₁ ≃+* A₂) (e₂ : B₁ ≃+* B₂)
+    (he : RingHom.comp (algebraMap A₂ B₂) ↑e₁ = RingHom.comp ↑e₂ (algebraMap A₁ B₁)) (x) :
+    Algebra.trace A₁ B₁ x = e₁.symm (Algebra.trace A₂ B₂ (e₂ x)) := by
+  letI := (RingHom.comp (e₂ : B₁ →+* B₂) (algebraMap A₁ B₁)).toAlgebra
+  let e' : B₁ ≃ₐ[A₁] B₂ := { e₂ with commutes' := fun _ ↦ rfl }
+  rw [← Algebra.trace_eq_of_ringEquiv e₁ he, ← Algebra.trace_eq_of_algEquiv e',
+    RingEquiv.symm_apply_apply]
+  rfl
+
 section EqSumEmbeddings
 
 variable [Algebra K F] [IsScalarTower K L F]
refactor: replace some [@foo](https://github.com/foo) _ _ _ _ _ ... by named arguments (#8702)

Using Lean4's named arguments, we manage to remove a few hard-to-read explicit function calls [@foo](https://github.com/foo) _ _ _ _ _ ... which used to be necessary in Lean3.

Occasionally, this results in slightly longer code. The benefit of named arguments is readability, as well as to reduce the brittleness of the code when the argument order is changed.

Co-authored-by: Michael Rothgang <rothgami@math.hu-berlin.de>

Diff
@@ -292,7 +292,7 @@ theorem trace_eq_trace_adjoin [FiniteDimensional K L] (x : L) :
   conv =>
     lhs
     rw [← IntermediateField.AdjoinSimple.algebraMap_gen K x]
-  rw [← @trace_trace _ _ K K⟮x⟯ _ _ _ _ _ _ _ _ _, trace_algebraMap, LinearMap.map_smul_of_tower]
+  rw [← trace_trace (L := K⟮x⟯), trace_algebraMap, LinearMap.map_smul_of_tower]
 #align trace_eq_trace_adjoin trace_eq_trace_adjoin
 
 variable {K}
@@ -364,7 +364,7 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
   haveI : FiniteDimensional L F := FiniteDimensional.right K L F
   haveI : IsSeparable L F := isSeparable_tower_top_of_isSeparable K L F
   letI : Fintype (L →ₐ[K] E) := PowerBasis.AlgHom.fintype pb
-  letI : ∀ f : L →ₐ[K] E, Fintype (@AlgHom L F E _ _ _ _ f.toRingHom.toAlgebra) := ?_
+  letI : ∀ f : L →ₐ[K] E, Fintype (haveI := f.toRingHom.toAlgebra; AlgHom L F E) := ?_
   rw [Fintype.sum_equiv algHomEquivSigma (fun σ : F →ₐ[K] E => _) fun σ => σ.1 pb.gen, ←
     Finset.univ_sigma_univ, Finset.sum_sigma, ← Finset.sum_nsmul]
   refine' Finset.sum_congr rfl fun σ _ => _
@@ -444,7 +444,7 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
   rw [traceMatrix_apply, vecMul, dotProduct, vecMul, dotProduct, Matrix.mul_apply,
     BilinForm.sum_left,
     Fintype.sum_congr _ _ fun i : κ =>
-      @BilinForm.sum_right _ _ _ _ _ _ _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
+      BilinForm.sum_right _ _ (b i * P.map (algebraMap A B) i α) fun y : κ =>
         b y * P.map (algebraMap A B) y β,
     sum_comm]
   congr; ext x
refactor(Data/Matrix/Basic): use a defeq for scalar that matches its docstring (#8115)

This changes the defeq from scalar a = a • 1 to scalar a = diagonal fun _ => a, which has the nice bonus of making algebraMap_eq_diagonal true by rfl.

As a result, we need a new smul_one_eq_diagonal lemma to rewrite diagonal fun _ => a back into a • 1, along with some variants for convenience.

In the long term we could generalize this to non-unital rings, now that it needs no 1.

Diff
@@ -118,8 +118,8 @@ theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Finty
   haveI := Classical.decEq ι
   rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace]
   convert Finset.sum_const x
--- Porting note: was `simp [-coe_lmul_eq_mul]`.
-  simp only [AlgHom.commutes, toMatrix_algebraMap, diag_apply, Matrix.scalar_apply_eq]
+  -- Porting note: was `simp [-coe_lmul_eq_mul]`.
+  simp only [AlgHom.commutes, toMatrix_algebraMap, diag_apply, scalar_apply, diagonal_apply_eq]
 
 #align algebra.trace_algebra_map_of_basis Algebra.trace_algebraMap_of_basis
 
chore(IntegralClosure): noncommutative generalizations and golfs (#8406)

Zulip

Initially I just wanted to add more dot notations for IsIntegral and IsAlgebraic (done in #8437); then I noticed near-duplicates Algebra.isIntegral_of_finite [Field R] [Ring A] and RingHom.IsIntegral.of_finite [CommRing R] [CommRing A] so I went on to generalize the latter to cover the former, and generalized everything in the IntegralClosure file to the noncommutative case whenever possible.

In the process I noticed more golfs, which result in this PR. Most notably, isIntegral_of_mem_of_FG is now proven using Cayley-Hamilton and doesn't depend on the Noetherian case isIntegral_of_noetherian; the latter is now proven using the former. In total the golfs makes mathlib 227 lines leaner (+487 -714).

The main changes are in the single file RingTheory/IntegralClosure:

  • Change the definition of Algebra.IsIntegral which makes it unfold to IsIntegral rather than RingHom.IsIntegralElem because the former has much more APIs.

  • Fix lemma names involving is_integral which are actually about IsIntegralElem: RingHom.is_integral_mapRingHom.isIntegralElem_map RingHom.is_integral_of_mem_closureRingHom.IsIntegralElem.of_mem_closure RingHom.is_integral_zero/oneRingHom.isIntegralElem_zero/one RingHom.is_integral_add/neg/sub/mul/of_mul_unitRingHom.IsIntegralElem.add/neg/sub/mul/of_mul_unit

  • Add a lemma Algebra.IsIntegral.of_injective.

  • Move isIntegral_of_(submodule_)noetherian down and golf them.

  • Remove (Algebra.)isIntegral_of_finite that work only over fields, in favor of the more general (Algebra.)isIntegral.of_finite.

  • Merge duplicate lemmas isIntegral_of_isScalarTower and isIntegral_tower_top_of_isIntegral into IsIntegral.tower_top.

  • Golf IsIntegral.of_mem_of_fg by first proving IsIntegral.of_finite using Cayley-Hamilton.

  • Add a docstring mentioning the Kurosh problem at Algebra.IsIntegral.finite. The negative solution to the problem means the theorem doesn't generalize to noncommutative algebras.

  • Golf IsIntegral.tmul and isField_of_isIntegral_of_isField(').

  • Combine isIntegral_trans_aux into isIntegral_trans and golf.

  • Add Algebra namespace to isIntegral_sup.

  • rename lemmas for dot notation: RingHom.isIntegral_transRingHom.IsIntegral.trans RingHom.isIntegral_quotient/tower_bot/top_of_isIntegralRingHom.IsIntegral.quotient/tower_bot/top isIntegral_of_mem_closure'IsIntegral.of_mem_closure' (and the '' version) isIntegral_of_surjectiveAlgebra.isIntegral_of_surjective

The next changed file is RingTheory/Algebraic:

  • Rename: of_larger_basetower_top (for consistency with IsIntegral) Algebra.isAlgebraic_of_finiteAlgebra.IsAlgebraic.of_finite Algebra.isAlgebraic_transAlgebra.IsAlgebraic.trans

  • Add new lemmasAlgebra.IsIntegral.isAlgebraic, isAlgebraic_algHom_iff, and Algebra.IsAlgebraic.of_injective to streamline some proofs.

The generalization from CommRing to Ring requires an additional lemma scaleRoots_eval₂_mul_of_commute in Polynomial/ScaleRoots.

A lemma Algebra.lmul_injective is added to Algebra/Bilinear (in order to golf the proof of IsIntegral.of_mem_of_fg).

In all other files, I merely fix the changed names, or use newly available dot notations.

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

Diff
@@ -262,7 +262,7 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
   rw [trace_eq_zero_of_not_exists_basis, LinearMap.zero_apply]
   contrapose! hx
   obtain ⟨s, ⟨b⟩⟩ := hx
-  refine' IsIntegral.of_mem_of_fg K⟮x⟯.toSubalgebra _ x _
+  refine' .of_mem_of_fg K⟮x⟯.toSubalgebra _ x _
   · exact (Submodule.fg_iff_finiteDimensional _).mpr (FiniteDimensional.of_fintype_basis b)
   · exact subset_adjoin K _ (Set.mem_singleton x)
 #align intermediate_field.adjoin_simple.trace_gen_eq_zero IntermediateField.AdjoinSimple.trace_gen_eq_zero
@@ -317,7 +317,7 @@ attribute [-instance] Field.toEuclideanDomain
 
 theorem Algebra.isIntegral_trace [FiniteDimensional L F] {x : F} (hx : IsIntegral R x) :
     IsIntegral R (Algebra.trace L F x) := by
-  have hx' : IsIntegral L x := isIntegral_of_isScalarTower hx
+  have hx' : IsIntegral L x := hx.tower_top
   rw [← isIntegral_algebraMap_iff (algebraMap L (AlgebraicClosure F)).injective, trace_eq_sum_roots]
   · refine' (IsIntegral.multiset_sum _).nsmul _
     intro y hy
chore(RingTheory/{Algebraic, Localization/Integral}): rename decls to use dot notation (#8437)

This PR tests a string-based tool for renaming declarations.

Inspired by this Zulip thread, I am trying to reduce the diff of #8406.

This PR makes the following renames:

| From | To |

Diff
@@ -262,7 +262,7 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
   rw [trace_eq_zero_of_not_exists_basis, LinearMap.zero_apply]
   contrapose! hx
   obtain ⟨s, ⟨b⟩⟩ := hx
-  refine' isIntegral_of_mem_of_FG K⟮x⟯.toSubalgebra _ x _
+  refine' IsIntegral.of_mem_of_fg K⟮x⟯.toSubalgebra _ x _
   · exact (Submodule.fg_iff_finiteDimensional _).mpr (FiniteDimensional.of_fintype_basis b)
   · exact subset_adjoin K _ (Set.mem_singleton x)
 #align intermediate_field.adjoin_simple.trace_gen_eq_zero IntermediateField.AdjoinSimple.trace_gen_eq_zero
perf(FunLike.Basic): beta reduce CoeFun.coe (#7905)

This eliminates (fun a ↦ β) α in the type when applying a FunLike.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -302,9 +302,7 @@ theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
     algebraMap K F (Algebra.trace K L x) =
       finrank K⟮x⟯ L • ((minpoly K x).aroots F).sum := by
   rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← Algebra.smul_def,
-    IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots _ hF]
--- Porting note: last `simp` was `IsScalarTower.algebraMap_smul` inside the `rw`.
-  simp only [eq_natCast, map_natCast, nsmul_eq_mul]
+    IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots _ hF, IsScalarTower.algebraMap_smul]
 #align trace_eq_sum_roots trace_eq_sum_roots
 
 end EqSumRoots
chore: replace minpoly.eq_of_algebraMap_eq by algebraMap_eq (#7228)

Also changes the repetitive names minpoly.minpoly_algHom/Equiv to minpoly.algHom/Equiv_eq

Diff
@@ -273,13 +273,10 @@ theorem trace_gen_eq_sum_roots (x : L) (hf : (minpoly K x).Splits (algebraMap K
   have injKxL := (algebraMap K⟮x⟯ L).injective
   by_cases hx : IsIntegral K x; swap
   · simp [minpoly.eq_zero hx, trace_gen_eq_zero hx, aroots_def]
-  have hx' : IsIntegral K (AdjoinSimple.gen K x) := by
-    rwa [← isIntegral_algebraMap_iff injKxL, AdjoinSimple.algebraMap_gen]
   rw [← adjoin.powerBasis_gen hx, (adjoin.powerBasis hx).trace_gen_eq_sum_roots] <;>
-      rw [adjoin.powerBasis_gen hx, minpoly.eq_of_algebraMap_eq injKxL hx'] <;>
+    rw [adjoin.powerBasis_gen hx, ← minpoly.algebraMap_eq injKxL] <;>
     try simp only [AdjoinSimple.algebraMap_gen _ _]
-  · exact hf
-  · rfl
+  exact hf
 #align intermediate_field.adjoin_simple.trace_gen_eq_sum_roots IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots
 
 end IntermediateField.AdjoinSimple
chore: use _root_.map_sum more consistently (#7189)

Also _root_.map_smul when in the neighbourhood.

Diff
@@ -489,7 +489,7 @@ theorem traceMatrix_of_basis_mulVec (b : Basis ι A B) (z : B) :
     rfl
     ext
     rw [mul_comm _ (b.equivFun z _), ← smul_eq_mul, of_apply, ← LinearMap.map_smul]
-  rw [← LinearMap.map_sum]
+  rw [← _root_.map_sum]
   congr
   conv_lhs =>
     congr
feat: roots in an algebra (#6740)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Diff
@@ -242,10 +242,10 @@ theorem PowerBasis.trace_gen_eq_nextCoeff_minpoly [Nontrivial S] (pb : PowerBasi
 #align power_basis.trace_gen_eq_next_coeff_minpoly PowerBasis.trace_gen_eq_nextCoeff_minpoly
 
 /-- Given `pb : PowerBasis K S`, then the trace of `pb.gen` is
-`((minpoly K pb.gen).map (algebraMap K F)).roots.sum`. -/
+`((minpoly K pb.gen).aroots F).sum`. -/
 theorem PowerBasis.trace_gen_eq_sum_roots [Nontrivial S] (pb : PowerBasis K S)
     (hf : (minpoly K pb.gen).Splits (algebraMap K F)) :
-    algebraMap K F (trace K S pb.gen) = ((minpoly K pb.gen).map (algebraMap K F)).roots.sum := by
+    algebraMap K F (trace K S pb.gen) = ((minpoly K pb.gen).aroots F).sum := by
   rw [PowerBasis.trace_gen_eq_nextCoeff_minpoly, RingHom.map_neg, ←
     nextCoeff_map (algebraMap K F).injective,
     sum_roots_eq_nextCoeff_of_monic_of_split ((minpoly.monic (PowerBasis.isIntegral_gen _)).map _)
@@ -269,10 +269,10 @@ theorem trace_gen_eq_zero {x : L} (hx : ¬IsIntegral K x) :
 
 theorem trace_gen_eq_sum_roots (x : L) (hf : (minpoly K x).Splits (algebraMap K F)) :
     algebraMap K F (trace K K⟮x⟯ (AdjoinSimple.gen K x)) =
-      ((minpoly K x).map (algebraMap K F)).roots.sum := by
+      ((minpoly K x).aroots F).sum := by
   have injKxL := (algebraMap K⟮x⟯ L).injective
   by_cases hx : IsIntegral K x; swap
-  · simp [minpoly.eq_zero hx, trace_gen_eq_zero hx]
+  · simp [minpoly.eq_zero hx, trace_gen_eq_zero hx, aroots_def]
   have hx' : IsIntegral K (AdjoinSimple.gen K x) := by
     rwa [← isIntegral_algebraMap_iff injKxL, AdjoinSimple.algebraMap_gen]
   rw [← adjoin.powerBasis_gen hx, (adjoin.powerBasis hx).trace_gen_eq_sum_roots] <;>
@@ -303,7 +303,7 @@ variable {K}
 theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
     (hF : (minpoly K x).Splits (algebraMap K F)) :
     algebraMap K F (Algebra.trace K L x) =
-      finrank K⟮x⟯ L • ((minpoly K x).map (algebraMap K _)).roots.sum := by
+      finrank K⟮x⟯ L • ((minpoly K x).aroots F).sum := by
   rw [trace_eq_trace_adjoin K x, Algebra.smul_def, RingHom.map_mul, ← Algebra.smul_def,
     IntermediateField.AdjoinSimple.trace_gen_eq_sum_roots _ hF]
 -- Porting note: last `simp` was `IsScalarTower.algebraMap_smul` inside the `rw`.
refactor(Data/Matrix): Eliminate notation in favor of HMul (#6487)

The main difficulty here is that * has a slightly difference precedence to . notably around smul and neg.

The other annoyance is that ↑U ⬝ A ⬝ ↑U⁻¹ : Matrix m m 𝔸 now has to be written U.val * A * (U⁻¹).val in order to typecheck.

A downside of this change to consider: if you have a goal of A * (B * C) = (A * B) * C, mul_assoc now gives the illusion of matching, when in fact Matrix.mul_assoc is needed. Previously the distinct symbol made it easy to avoid this mistake.

On the flipside, there is now no need to rewrite by Matrix.mul_eq_mul all the time (indeed, the lemma is now removed).

Diff
@@ -444,7 +444,7 @@ theorem traceMatrix_reindex {κ' : Type*} (b : Basis κ A B) (f : κ ≃ κ') :
 variable {A}
 
 theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
-    traceMatrix A ((P.map (algebraMap A B)).vecMul b) = Pᵀ ⬝ traceMatrix A b ⬝ P := by
+    traceMatrix A ((P.map (algebraMap A B)).vecMul b) = Pᵀ * traceMatrix A b * P := by
   ext (α β)
   rw [traceMatrix_apply, vecMul, dotProduct, vecMul, dotProduct, Matrix.mul_apply,
     BilinForm.sum_left,
@@ -465,7 +465,7 @@ theorem traceMatrix_of_matrix_vecMul [Fintype κ] (b : κ → B) (P : Matrix κ
 #align algebra.trace_matrix_of_matrix_vec_mul Algebra.traceMatrix_of_matrix_vecMul
 
 theorem traceMatrix_of_matrix_mulVec [Fintype κ] (b : κ → B) (P : Matrix κ κ A) :
-    traceMatrix A ((P.map (algebraMap A B)).mulVec b) = P ⬝ traceMatrix A b ⬝ Pᵀ := by
+    traceMatrix A ((P.map (algebraMap A B)).mulVec b) = P * traceMatrix A b * Pᵀ := by
   refine' AddEquiv.injective (transposeAddEquiv κ κ A) _
   rw [transposeAddEquiv_apply, transposeAddEquiv_apply, ← vecMul_transpose, ← transpose_map,
     traceMatrix_of_matrix_vecMul, transpose_transpose, transpose_mul, transpose_transpose,
@@ -546,13 +546,13 @@ variable [Module.Finite K L] [IsSeparable K L] [IsAlgClosed E]
 variable (b : κ → L) (pb : PowerBasis K L)
 
 theorem traceMatrix_eq_embeddingsMatrix_mul_trans :
-    (traceMatrix K b).map (algebraMap K E) = embeddingsMatrix K E b ⬝ (embeddingsMatrix K E b)ᵀ :=
+    (traceMatrix K b).map (algebraMap K E) = embeddingsMatrix K E b * (embeddingsMatrix K E b)ᵀ :=
   by ext (i j); simp [trace_eq_sum_embeddings, embeddingsMatrix, Matrix.mul_apply]
 #align algebra.trace_matrix_eq_embeddings_matrix_mul_trans Algebra.traceMatrix_eq_embeddingsMatrix_mul_trans
 
 theorem traceMatrix_eq_embeddingsMatrixReindex_mul_trans [Fintype κ] (e : κ ≃ (L →ₐ[K] E)) :
     (traceMatrix K b).map (algebraMap K E) =
-      embeddingsMatrixReindex K E b e ⬝ (embeddingsMatrixReindex K E b e)ᵀ := by
+      embeddingsMatrixReindex K E b e * (embeddingsMatrixReindex K E b e)ᵀ := by
   rw [traceMatrix_eq_embeddingsMatrix_mul_trans, embeddingsMatrixReindex, reindex_apply,
     transpose_submatrix, ← submatrix_mul_transpose_submatrix, ← Equiv.coe_refl, Equiv.refl_symm]
 #align algebra.trace_matrix_eq_embeddings_matrix_reindex_mul_trans Algebra.traceMatrix_eq_embeddingsMatrixReindex_mul_trans
@@ -592,11 +592,11 @@ theorem det_traceForm_ne_zero [IsSeparable K L] [DecidableEq ι] (b : Basis ι K
   swap; · apply Basis.toMatrix_mul_toMatrix_flip
   refine'
     mul_ne_zero
-      (isUnit_of_mul_eq_one _ ((b.toMatrix pb.basis)ᵀ ⬝ b.toMatrix pb.basis).det _).ne_zero _
+      (isUnit_of_mul_eq_one _ ((b.toMatrix pb.basis)ᵀ * b.toMatrix pb.basis).det _).ne_zero _
   · calc
-      (pb.basis.toMatrix b ⬝ (pb.basis.toMatrix b)ᵀ).det *
-            ((b.toMatrix pb.basis)ᵀ ⬝ b.toMatrix pb.basis).det =
-          (pb.basis.toMatrix b ⬝ (b.toMatrix pb.basis ⬝ pb.basis.toMatrix b)ᵀ ⬝
+      (pb.basis.toMatrix b * (pb.basis.toMatrix b)ᵀ).det *
+            ((b.toMatrix pb.basis)ᵀ * b.toMatrix pb.basis).det =
+          (pb.basis.toMatrix b * (b.toMatrix pb.basis * pb.basis.toMatrix b)ᵀ *
               b.toMatrix pb.basis).det :=
         by simp only [← det_mul, Matrix.mul_assoc, Matrix.transpose_mul]
       _ = 1 := by
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
@@ -63,11 +63,11 @@ For now, the definitions assume `S` is commutative, so the choice doesn't matter
 
 universe u v w z
 
-variable {R S T : Type _} [CommRing R] [CommRing S] [CommRing T]
+variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
 
 variable [Algebra R S] [Algebra R T]
 
-variable {K L : Type _} [Field K] [Field L] [Algebra K L]
+variable {K L : Type*} [Field K] [Field L] [Algebra K L]
 
 variable {ι κ : Type w} [Fintype ι]
 
@@ -134,7 +134,7 @@ theorem trace_algebraMap (x : K) : trace K L (algebraMap K L x) = finrank K L 
   · simp [trace_eq_zero_of_not_exists_basis K H, finrank_eq_zero_of_not_exists_basis_finset H]
 #align algebra.trace_algebra_map Algebra.trace_algebraMap
 
-theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _} [Finite ι]
+theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
     [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
     trace R S (trace S T x) = trace R T x := by
   haveI := Classical.decEq ι
@@ -152,7 +152,7 @@ theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _
   apply Finset.sum_apply
 #align algebra.trace_trace_of_basis Algebra.trace_trace_of_basis
 
-theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type _} [Finite ι]
+theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
     [Fintype κ] (b : Basis ι R S) (c : Basis κ S T) :
     (trace R S).comp ((trace S T).restrictScalars R) = trace R T := by
   ext
@@ -227,7 +227,7 @@ section EqSumRoots
 
 open Algebra Polynomial
 
-variable {F : Type _} [Field F]
+variable {F : Type*} [Field F]
 
 variable [Algebra K S] [Algebra K F]
 
@@ -312,7 +312,7 @@ theorem trace_eq_sum_roots [FiniteDimensional K L] {x : L}
 
 end EqSumRoots
 
-variable {F : Type _} [Field F]
+variable {F : Type*} [Field F]
 
 variable [Algebra R L] [Algebra L F] [Algebra R F] [IsScalarTower R L F]
 
@@ -339,7 +339,7 @@ variable [Algebra K F] [IsScalarTower K L F]
 
 open Algebra IntermediateField
 
-variable (F) (E : Type _) [Field E] [Algebra K E]
+variable (F) (E : Type*) [Field E] [Algebra K E]
 
 theorem trace_eq_sum_embeddings_gen (pb : PowerBasis K L)
     (hE : (minpoly K pb.gen).Splits (algebraMap K E)) (hfx : (minpoly K pb.gen).Separable) :
@@ -437,7 +437,7 @@ theorem traceMatrix_apply (b : κ → B) (i j) : traceMatrix A b i j = traceForm
   rfl
 #align algebra.trace_matrix_apply Algebra.traceMatrix_apply
 
-theorem traceMatrix_reindex {κ' : Type _} (b : Basis κ A B) (f : κ ≃ κ') :
+theorem traceMatrix_reindex {κ' : Type*} (b : Basis κ A B) (f : κ ≃ κ') :
     traceMatrix A (b.reindex f) = reindex f f (traceMatrix A b) := by ext (x y); simp
 #align algebra.trace_matrix_reindex Algebra.traceMatrix_reindex
 
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,11 +2,6 @@
 Copyright (c) 2020 Anne Baanen. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Anne Baanen
-
-! This file was ported from Lean 3 source module ring_theory.trace
-! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.LinearAlgebra.Matrix.BilinearForm
 import Mathlib.LinearAlgebra.Matrix.Charpoly.Minpoly
@@ -19,6 +14,8 @@ import Mathlib.FieldTheory.PrimitiveElement
 import Mathlib.FieldTheory.Galois
 import Mathlib.RingTheory.PowerBasis
 
+#align_import ring_theory.trace from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
+
 /-!
 # Trace for (finite) ring extensions.
 
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
@@ -381,7 +381,7 @@ theorem sum_embeddings_eq_finrank_mul [FiniteDimensional K F] [IsSeparable K F]
     simp only [Finset.sum_const]
     congr
     rw [← AlgHom.card L F E]
-    exact Finset.card_univ (α :=  F →ₐ[L] E)
+    exact Finset.card_univ (α := F →ₐ[L] E)
   · intro σ
     simp only [algHomEquivSigma, Equiv.coe_fn_mk, AlgHom.restrictDomain, AlgHom.comp_apply,
       IsScalarTower.coe_toAlgHom']
chore: fix grammar in docs (#5668)
Diff
@@ -428,7 +428,7 @@ variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C]
 
 open Finset
 
-/-- Given an `A`-algebra `B` and `b`, an `κ`-indexed family of elements of `B`, we define
+/-- Given an `A`-algebra `B` and `b`, a `κ`-indexed family of elements of `B`, we define
 `traceMatrix A b` as the matrix whose `(i j)`-th element is the trace of `b i * b j`. -/
 noncomputable def traceMatrix (b : κ → B) : Matrix κ κ A :=
   of fun i j => traceForm A B (b i) (b j)
feat: port RingTheory.Trace (#5256)

Dependencies 10 + 720

721 files ported (98.6%)
296367 lines ported (98.9%)
Show graph

The unported dependencies are