l3lab/ntp-mathlib huggingface dataset:
/-- When `C` has pushouts, a morphism `f : X ⟶ Y` induces a functor `Under X ⥤ Under Y`,
by pushing a morphism forward along `f`. -/
@[simps]
def pushout {X Y : C} (f : X ⟶ Y) : Under X ⥤ Under Y where
  obj g := Under.mk (pushout.inr : Y ⟶ CategoryTheory.Limits.pushout g.hom f)
  map := fun g {h} {k} =>
    Under.homMk (pushout.desc (k.right ≫ pushout.inl) pushout.inr (by 

Proof state:
J : Type w
inst✝² : Category.{w', w} J
C : Type u
inst✝¹ : Category.{v, u} C
X✝ : C
inst✝ : HasPushouts C
X Y : C
f : X ⟶ Y
g h : Under X
k : g ⟶ h
⊢ g.hom ≫ k.right ≫ pushout.inl = f ≫ pushout.inr

Next tactic:
simp [← pushout.condition]
theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) :
    trace R S = 0 := by 

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
h : ¬∃ s, Nonempty (Basis { x // x ∈ s } R S)
⊢ trace R S = 0

Next tactic:
ext s
theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) :
    trace R S = 0 := by ext s; 

Proof state:
case h
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
h : ¬∃ s, Nonempty (Basis { x // x ∈ s } R S)
s : S
⊢ (trace R S) s = 0 s

Next tactic:
simp [trace_apply, LinearMap.trace, h]
theorem trace_eq_matrix_trace [DecidableEq ι] (b : Basis ι R S) (s : S) :
    trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) := by
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
inst✝⁷ : CommRing T
inst✝⁶ : Algebra R S
inst✝⁵ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Algebra K L
ι κ : Type w
inst✝¹ : Fintype ι
b✝ : Basis ι R S
inst✝ : DecidableEq ι
b : Basis ι R S
s : S
⊢ (trace R S) s = Matrix.trace ((leftMulMatrix b) s)

Next tactic:
rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← toMatrix_lmul_eq]
theorem trace_eq_matrix_trace [DecidableEq ι] (b : Basis ι R S) (s : S) :
    trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) := by
  rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← toMatrix_lmul_eq]; 

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁹ : CommRing R
inst✝⁸ : CommRing S
inst✝⁷ : CommRing T
inst✝⁶ : Algebra R S
inst✝⁵ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Algebra K L
ι κ : Type w
inst✝¹ : Fintype ι
b✝ : Basis ι R S
inst✝ : DecidableEq ι
b : Basis ι R S
s : S
⊢ Matrix.trace ((toMatrix b b) ((lmul R S) s)) = Matrix.trace ((toMatrix b b) (mulLeft R s))

Next tactic:
rfl
/-- 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
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : R
⊢ (trace R S) ((algebraMap R S) x) = Fintype.card ι • x

Next tactic:
haveI := Classical.decEq ι
/-- 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
  haveI := Classical.decEq ι
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : R
this : DecidableEq ι
⊢ (trace R S) ((algebraMap R S) x) = Fintype.card ι • x

Next tactic:
rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace]
/-- 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
  haveI := Classical.decEq ι
  rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace]
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : R
this : DecidableEq ι
⊢ ∑ i : ι, Matrix.diag ((toMatrix b b) ((lmul R S) ((algebraMap R S) x))) i = Fintype.card ι • x

Next tactic:
convert Finset.sum_const x
/-- 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
  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]`.
  

Proof state:
case h.e'_2.a
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : R
this : DecidableEq ι
x✝ : ι
a✝ : x✝ ∈ Finset.univ
⊢ Matrix.diag ((toMatrix b b) ((lmul R S) ((algebraMap R S) x))) x✝ = x

Next tactic:
simp only [AlgHom.commutes, toMatrix_algebraMap, diag_apply, scalar_apply, diagonal_apply_eq]
/-- If `x` is in the base field `K`, then the trace is `[L : K] * x`.

(If `L` is not finite-dimensional over `K`, then `trace` and `finrank` return `0`.)
-/
@[simp]
theorem trace_algebraMap (x : K) : trace K L (algebraMap K L x) = finrank K L • x := by
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : K
⊢ (trace K L) ((algebraMap K L) x) = finrank K L • x

Next tactic:
by_cases H : ∃ s : Finset L, Nonempty (Basis s K L)
/-- If `x` is in the base field `K`, then the trace is `[L : K] * x`.

(If `L` is not finite-dimensional over `K`, then `trace` and `finrank` return `0`.)
-/
@[simp]
theorem trace_algebraMap (x : K) : trace K L (algebraMap K L x) = finrank K L • x := by
  by_cases H : ∃ s : Finset L, Nonempty (Basis s K L)
  · 

Proof state:
case pos
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : K
H : ∃ s, Nonempty (Basis { x // x ∈ s } K L)
⊢ (trace K L) ((algebraMap K L) x) = finrank K L • x

Next tactic:
rw [trace_algebraMap_of_basis H.choose_spec.some, finrank_eq_card_basis H.choose_spec.some]
/-- If `x` is in the base field `K`, then the trace is `[L : K] * x`.

(If `L` is not finite-dimensional over `K`, then `trace` and `finrank` return `0`.)
-/
@[simp]
theorem trace_algebraMap (x : K) : trace K L (algebraMap K L x) = finrank K L • x := by
  by_cases H : ∃ s : Finset L, Nonempty (Basis s K L)
  · rw [trace_algebraMap_of_basis H.choose_spec.some, finrank_eq_card_basis H.choose_spec.some]
  · 

Proof state:
case neg
R : Type u_1
S : Type u_2
T : Type u_3
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : CommRing T
inst✝⁵ : Algebra R S
inst✝⁴ : Algebra R T
K : Type u_4
L : Type u_5
inst✝³ : Field K
inst✝² : Field L
inst✝¹ : Algebra K L
ι κ : Type w
inst✝ : Fintype ι
b : Basis ι R S
x : K
H : ¬∃ s, Nonempty (Basis { x // x ∈ s } K L)
⊢ (trace K L) ((algebraMap K L) x) = finrank K L • x

Next tactic:
simp [trace_eq_zero_of_not_exists_basis K H, finrank_eq_zero_of_not_exists_basis_finset H]
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
⊢ (trace R S) ((trace S T) x) = (trace R T) x

Next tactic:
haveI := Classical.decEq ι
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 ι
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this : DecidableEq ι
⊢ (trace R S) ((trace S T) x) = (trace R T) x

Next tactic:
haveI := Classical.decEq κ
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
⊢ (trace R S) ((trace S T) x) = (trace R T) x

Next tactic:
cases nonempty_fintype ι
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  cases nonempty_fintype ι
  

Proof state:
case intro
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
val✝ : Fintype ι
⊢ (trace R S) ((trace S T) x) = (trace R T) x

Next tactic:
cases nonempty_fintype κ
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  cases nonempty_fintype ι
  cases nonempty_fintype κ
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
val✝¹ : Fintype ι
val✝ : Fintype κ
⊢ (trace R S) ((trace S T) x) = (trace R T) x

Next tactic:
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]
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  cases nonempty_fintype ι
  cases nonempty_fintype κ
  rw [trace_eq_matrix_trace (b.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]
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
val✝¹ : Fintype ι
val✝ : Fintype κ
⊢ ∑ i : ι, Matrix.diag ((leftMulMatrix b) (∑ i : κ, Matrix.diag ((leftMulMatrix c) x) i)) i =
    ∑ x_1 : ι, ∑ y : κ, Matrix.diag ((leftMulMatrix (Basis.smul b c)) x) (x_1, y)

Next tactic:
refine' Finset.sum_congr rfl fun i _ => _
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  cases nonempty_fintype ι
  cases nonempty_fintype κ
  rw [trace_eq_matrix_trace (b.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 _ => _
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
val✝¹ : Fintype ι
val✝ : Fintype κ
i : ι
x✝ : i ∈ Finset.univ
⊢ Matrix.diag ((leftMulMatrix b) (∑ i : κ, Matrix.diag ((leftMulMatrix c) x) i)) i =
    ∑ y : κ, Matrix.diag ((leftMulMatrix (Basis.smul b c)) x) (i, y)

Next tactic:
simp only [AlgHom.map_sum, smul_leftMulMatrix, Finset.sum_apply,
    Matrix.diag]
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  cases nonempty_fintype ι
  cases nonempty_fintype κ
  rw [trace_eq_matrix_trace (b.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 _ => _
  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.
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
val✝¹ : Fintype ι
val✝ : Fintype κ
i : ι
x✝ : i ∈ Finset.univ
⊢ Finset.sum Finset.univ (fun x_1 => (leftMulMatrix b) ((leftMulMatrix c) x x_1 x_1)) i i =
    ∑ x_1 : κ, (leftMulMatrix b) ((leftMulMatrix c) x x_1 x_1) i i

Next tactic:
rw [Finset.sum_apply
      i (Finset.univ : Finset κ) fun y => leftMulMatrix b (leftMulMatrix c x y y)]
theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι]
    [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) :
    trace R S (trace S T x) = trace R T x := by
  haveI := Classical.decEq ι
  haveI := Classical.decEq κ
  cases nonempty_fintype ι
  cases nonempty_fintype κ
  rw [trace_eq_matrix_trace (b.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 _ => _
  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
      i (Finset.univ : Finset κ) fun y => leftMulMatrix b (leftMulMatrix c x y y)]
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Finite κ
b : Basis ι R S
c : Basis κ S T
x : T
this✝ : DecidableEq ι
this : DecidableEq κ
val✝¹ : Fintype ι
val✝ : Fintype κ
i : ι
x✝ : i ∈ Finset.univ
⊢ Finset.sum Finset.univ (fun c_1 => (leftMulMatrix b) ((leftMulMatrix c) x c_1 c_1) i) i =
    ∑ x_1 : κ, (leftMulMatrix b) ((leftMulMatrix c) x x_1 x_1) i i

Next tactic:
apply Finset.sum_apply
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
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Fintype κ
b : Basis ι R S
c : Basis κ S T
⊢ trace R S ∘ₗ ↑R (trace S T) = trace R T

Next tactic:
ext
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
  

Proof state:
case h
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι✝ κ✝ : Type w
inst✝⁴ : Fintype ι✝
b✝ : Basis ι✝ R S
inst✝³ : Algebra S T
inst✝² : IsScalarTower R S T
ι : Type u_6
κ : Type u_7
inst✝¹ : Finite ι
inst✝ : Fintype κ
b : Basis ι R S
c : Basis κ S T
x✝ : T
⊢ (trace R S ∘ₗ ↑R (trace S T)) x✝ = (trace R T) x✝

Next tactic:
rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace_of_basis b c]
@[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
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing T
inst✝¹⁰ : Algebra R S
inst✝⁹ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Algebra K L
ι κ : Type w
inst✝⁵ : Fintype ι
b : Basis ι R S
inst✝⁴ : Algebra K T
inst✝³ : Algebra L T
inst✝² : IsScalarTower K L T
inst✝¹ : FiniteDimensional K L
inst✝ : FiniteDimensional L T
⊢ trace K L ∘ₗ ↑K (trace L T) = trace K T

Next tactic:
ext
@[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; 

Proof state:
case h
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing T
inst✝¹⁰ : Algebra R S
inst✝⁹ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Algebra K L
ι κ : Type w
inst✝⁵ : Fintype ι
b : Basis ι R S
inst✝⁴ : Algebra K T
inst✝³ : Algebra L T
inst✝² : IsScalarTower K L T
inst✝¹ : FiniteDimensional K L
inst✝ : FiniteDimensional L T
x✝ : T
⊢ (trace K L ∘ₗ ↑K (trace L T)) x✝ = (trace K T) x✝

Next tactic:
rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace]
@[simp]
theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T]
    (x : S × T) : trace R (S × T) x = trace R S x.fst + trace R T x.snd := by
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι κ : Type w
inst✝⁴ : Fintype ι
b : Basis ι R S
inst✝³ : Module.Free R S
inst✝² : Module.Free R T
inst✝¹ : Module.Finite R S
inst✝ : Module.Finite R T
x : S × T
⊢ (trace R (S × T)) x = (trace R S) x.1 + (trace R T) x.2

Next tactic:
nontriviality R
@[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
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι κ : Type w
inst✝⁴ : Fintype ι
b : Basis ι R S
inst✝³ : Module.Free R S
inst✝² : Module.Free R T
inst✝¹ : Module.Finite R S
inst✝ : Module.Finite R T
x : S × T
✝ : Nontrivial R
⊢ (trace R (S × T)) x = (trace R S) x.1 + (trace R T) x.2

Next tactic:
let f := (lmul R S).toLinearMap.prodMap (lmul R T).toLinearMap
@[simp]
theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T]
    (x : S × T) : trace R (S × T) x = trace R S x.fst + trace R T x.snd := by
  nontriviality R
  let f := (lmul R S).toLinearMap.prodMap (lmul R T).toLinearMap
  

Proof state:
R : Type u_1
S : Type u_2
T : Type u_3
inst✝¹² : CommRing R
inst✝¹¹ : CommRing S
inst✝¹⁰ : CommRing T
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R T
K : Type u_4
L : Type u_5
inst✝⁷ : Field K
inst✝⁶ : Field L
inst✝⁵ : Algebra K L
ι κ : Type w
inst✝⁴ : Fintype ι
b : Basis ι R S
inst✝³ : Module.Free R S
inst✝² : Module.Free R T
inst✝¹ : Module.Finite R S
inst✝ : Module.Finite R T
x : S × T
✝ : Nontrivial R
f : S × T →ₗ[R] Module.End R S × Module.End R T :=
  prodMap (AlgHom.toLinearMap (lmul R S)) (AlgHom.toLinearMap (lmul R T))
⊢ (trace R (S × T)) x = (trace R S) x.1 + (trace R T) x.2

Next tactic:
have : (lmul R (S × T)).toLinearMap = (prodMapLinear R S T S T R).comp f :=
    LinearMap.ext₂ Prod.mul_def