-- Mathlib/RingTheory/Unramified/Finite.lean
lemma finite_of_free_aux (I) [DecidableEq I] (b : Basis I R S)
    (f : I →₀ S) (x : S) (a : I → I →₀ R) (ha : a = fun i ↦ b.repr (b i * x)) :
    (1 ⊗ₜ[R] x * Finsupp.sum f fun i y ↦ y ⊗ₜ[R] b i) =
      Finset.sum (f.support.biUnion fun i ↦ (a i).support) fun k ↦
    Finsupp.sum (b.repr (f.sum fun i y ↦ a i k • y)) fun j c ↦ c • b j ⊗ₜ[R] b k

Proof state:
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
h₁ :
  ∀ (k : I),
    ((f.sum fun i y => (a i) k • b.repr y).sum fun j z => z • b j ⊗ₜ[R] b k) =
      f.sum fun i y => (b.repr y).sum fun j z => (a i) k • z • b j ⊗ₜ[R] b k
⊢ ∑ x ∈ f.support, ∑ x_1 ∈ (a x).support, ((a x) x_1 • f x) ⊗ₜ[R] b x_1 =
    ∑ k ∈ f.support.biUnion fun i => ((fun i => b.repr (b i * x)) i).support,
      (b.repr (f.sum fun i y => ((fun i => b.repr (b i * x)) i) k • y)).sum fun j c => c • b j ⊗ₜ[R] b k

Tactic:
have h₂ : ∀ (x : S), ((b.repr x).support.sum fun a ↦ b.repr x a • b a) = x := by
  simpa only [Finsupp.linearCombination_apply, Finsupp.sum] using b.linearCombination_repr

Result:
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
h₁ :
  ∀ (k : I),
    ((f.sum fun i y => (a i) k • b.repr y).sum fun j z => z • b j ⊗ₜ[R] b k) =
      f.sum fun i y => (b.repr y).sum fun j z => (a i) k • z • b j ⊗ₜ[R] b k
h₂ : ∀ (x : S), ∑ a ∈ (b.repr x).support, (b.repr x) a • b a = x
⊢ ∑ x ∈ f.support, ∑ x_1 ∈ (a x).support, ((a x) x_1 • f x) ⊗ₜ[R] b x_1 =
    ∑ k ∈ f.support.biUnion fun i => ((fun i => b.repr (b i * x)) i).support,
      (b.repr (f.sum fun i y => ((fun i => b.repr (b i * x)) i) k • y)).sum fun j c => c • b j ⊗ₜ[R] b k

Proof state:
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
⊢ ∑ i ∈ f.support, f i ⊗ₜ[R] (Finsupp.linearCombination R ⇑b) (a i) =
    ∑ k ∈ f.support.biUnion fun i => ((fun i => b.repr (b i * x)) i).support,
      (b.repr (f.sum fun i y => ((fun i => b.repr (b i * x)) i) k • y)).sum fun j c => c • b j ⊗ₜ[R] b k

Tactic:
conv_lhs => simp only [Finsupp.linearCombination, Finsupp.coe_lsum,
  LinearMap.coe_smulRight, LinearMap.id_coe, id_eq, Finsupp.sum, TensorProduct.tmul_sum,
  ← TensorProduct.smul_tmul]

Result:
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
⊢ ∑ x ∈ f.support, ∑ x_1 ∈ (a x).support, ((a x) x_1 • f x) ⊗ₜ[R] b x_1 =
    ∑ k ∈ f.support.biUnion fun i => ((fun i => b.repr (b i * x)) i).support,
      (b.repr (f.sum fun i y => ((fun i => b.repr (b i * x)) i) k • y)).sum fun j c => c • b j ⊗ₜ[R] b k

Proof state:
case h_zero
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i a✝ : I
⊢ 0 • b a✝ ⊗ₜ[R] b i = 0

Tactic:
simp only [zero_smul]

Result:
no goals

Proof state:
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ (f.sum fun a_1 b_1 => ((a a_1) i • b.repr b_1).sum fun j z => z • b j ⊗ₜ[R] b i) =
    f.sum fun i_1 y => (b.repr y).sum fun j z => (a i_1) i • z • b j ⊗ₜ[R] b i

case h_zero
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I), 0 • b a ⊗ₜ[R] b i = 0

case h_add
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I) (b₁ b₂ : R), (b₁ + b₂) • b a ⊗ₜ[R] b i = b₁ • b a ⊗ₜ[R] b i + b₂ • b a ⊗ₜ[R] b i

Tactic:
congr

Result:
case e_g
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ (fun a_1 b_1 => ((a a_1) i • b.repr b_1).sum fun j z => z • b j ⊗ₜ[R] b i) = fun i_1 y =>
    (b.repr y).sum fun j z => (a i_1) i • z • b j ⊗ₜ[R] b i

case h_zero
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I), 0 • b a ⊗ₜ[R] b i = 0

case h_add
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I) (b₁ b₂ : R), (b₁ + b₂) • b a ⊗ₜ[R] b i = b₁ • b a ⊗ₜ[R] b i + b₂ • b a ⊗ₜ[R] b i

Proof state:
case e_g.h.h
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i j : I
s : S
⊢ ((b.repr s).sum fun i_1 a_1 => ((a j) i * a_1) • b i_1 ⊗ₜ[R] b i) =
    (b.repr s).sum fun j_1 z => (a j) i • z • b j_1 ⊗ₜ[R] b i

case e_g.h.h
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i j : I
s : S
⊢ ∀ (i_1 : I), 0 • b i_1 ⊗ₜ[R] b i = 0

case h_zero
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I), 0 • b a ⊗ₜ[R] b i = 0

case h_add
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I) (b₁ b₂ : R), (b₁ + b₂) • b a ⊗ₜ[R] b i = b₁ • b a ⊗ₜ[R] b i + b₂ • b a ⊗ₜ[R] b i

Tactic:
simp only [mul_smul, Finsupp.sum, ← Finset.smul_sum]

Result:
case e_g.h.h
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i j : I
s : S
⊢ ∀ (i_1 : I), 0 • b i_1 ⊗ₜ[R] b i = 0

case h_zero
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I), 0 • b a ⊗ₜ[R] b i = 0

case h_add
R : Type u_3
S : Type u_4
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : Algebra R S
I : Type u_2
inst✝ : DecidableEq I
b : Basis I R S
f : I →₀ S
x : S
a : I → I →₀ R := fun i => b.repr (b i * x)
i : I
⊢ ∀ (a : I) (b₁ b₂ : R), (b₁ + b₂) • b a ⊗ₜ[R] b i = b₁ • b a ⊗ₜ[R] b i + b₂ • b a ⊗ₜ[R] b i