-- Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean
theorem vanishesTrivially_of_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤)
    (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
⊢ VanishesTrivially R m n

Tactic:
have G_surjective : Surjective G := by
  apply LinearMap.range_eq_top.mp
  apply top_le_iff.mp
  rw [← hm]
  apply Submodule.span_le.mpr
  rintro _ ⟨i, rfl⟩
  use Finsupp.single i 1, G_basis_eq i

Result:
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
⊢ VanishesTrivially R m n

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
en_mem_ker : en ∈ ker (rTensor N G)
⊢ VanishesTrivially R m n

Tactic:
have exact_ker_subtype : Exact (ker G).subtype G := G.exact_subtype_ker_map

Result:
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
en_mem_ker : en ∈ ker (rTensor N G)
exact_ker_subtype : Exact ⇑(ker G).subtype ⇑G
⊢ VanishesTrivially R m n

Proof state:
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
⊢ VanishesTrivially R m n

Tactic:
have en_mem_ker : en ∈ ker (rTensor N G) := by simp [hen, G_basis_eq, hmn]

Result:
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
en_mem_ker : en ∈ ker (rTensor N G)
⊢ VanishesTrivially R m n

Proof state:
case intro.intro.refine_2.mk.mk.mk
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
en_mem_ker : en ∈ ker (rTensor N G)
exact_ker_subtype : Exact ⇑(ker G).subtype ⇑G
exact_rTensor_ker_subtype : Exact ⇑(rTensor N (ker G).subtype) ⇑(rTensor N G)
ma : Finset (↥(ker G) × N)
hkn : (rTensor N (ker G).subtype) (∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2) = en
snd✝ : N
k : ι →₀ R
hk : k ∈ ker G
property✝ : (⟨k, hk⟩, snd✝) ∈ ma
⊢ ∑ i : ι,
      (fun i x =>
            match x with
            | ⟨(kj, snd), property⟩ => ↑kj i)
          i ⟨(⟨k, hk⟩, snd✝), property✝⟩ •
        m i =
    0

Tactic:
simpa only [hG, linearCombination_apply, zero_smul, implies_true, Finsupp.sum_fintype] using
  mem_ker.mp hk

Result:
no goals

Proof state:
case intro.intro.refine_1
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
en_mem_ker : en ∈ ker (rTensor N G)
exact_ker_subtype : Exact ⇑(ker G).subtype ⇑G
exact_rTensor_ker_subtype : Exact ⇑(rTensor N (ker G).subtype) ⇑(rTensor N G)
ma : Finset (↥(ker G) × N)
i : ι
hkn :
  ((finsuppScalarLeft R N ι) ((rTensor N (ker G).subtype) (∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2))) i =
    ((finsuppScalarLeft R N ι) en) i
⊢ n i =
    ∑ j : { x // x ∈ ma },
      (fun i x =>
            match x with
            | ⟨(kj, snd), property⟩ => ↑kj i)
          i j •
        (fun x =>
            match x with
            | ⟨(fst, yj), property⟩ => yj)
          j

Tactic:
symm at hkn

Result:
case intro.intro.refine_1
R : Type u_1
inst✝⁵ : CommRing R
M : Type u_2
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
N : Type u_3
inst✝² : AddCommGroup N
inst✝¹ : Module R N
ι : Type u_4
inst✝ : Fintype ι
m : ι → M
n : ι → N
hm : span R (Set.range m) = ⊤
hmn : ∑ i : ι, m i ⊗ₜ[R] n i = 0
G : (ι →₀ R) →ₗ[R] M := linearCombination R m
hG : G = linearCombination R m
G_basis_eq : ∀ (i : ι), G (Finsupp.single i 1) = m i
G_surjective : Surjective ⇑G
en : (ι →₀ R) ⊗[R] N := ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
hen : en = ∑ i : ι, Finsupp.single i 1 ⊗ₜ[R] n i
en_mem_ker : en ∈ ker (rTensor N G)
exact_ker_subtype : Exact ⇑(ker G).subtype ⇑G
exact_rTensor_ker_subtype : Exact ⇑(rTensor N (ker G).subtype) ⇑(rTensor N G)
ma : Finset (↥(ker G) × N)
i : ι
hkn :
  ((finsuppScalarLeft R N ι) en) i =
    ((finsuppScalarLeft R N ι) ((rTensor N (ker G).subtype) (∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2))) i
⊢ n i =
    ∑ j : { x // x ∈ ma },
      (fun i x =>
            match x with
            | ⟨(kj, snd), property⟩ => ↑kj i)
          i j •
        (fun x =>
            match x with
            | ⟨(fst, yj), property⟩ => yj)
          j