l3lab/ntp-mathlib huggingface dataset:
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          

Proof state:
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
p : ∀ (κ : Type v) (w : κ → M), LinearIndependent R w → ∀ (j : ι → κ), w ∘ j = v → Surjective j
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
⊢ (Subtype.val ∘ fun i => { val := v i, property := (_ : v i ∈ w) }) = v

Next tactic:
ext
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          ext
          

Proof state:
case h
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
p : ∀ (κ : Type v) (w : κ → M), LinearIndependent R w → ∀ (j : ι → κ), w ∘ j = v → Surjective j
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
x✝ : ι
⊢ (Subtype.val ∘ fun i => { val := v i, property := (_ : v i ∈ w) }) x✝ = v x✝

Next tactic:
simp
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          ext
          simp)
    

Proof state:
case mpr
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
p : Surjective fun i => { val := v i, property := (_ : v i ∈ w) }
⊢ range v = w

Next tactic:
have q := congr_arg (fun s => ((↑) : w → M) '' s) p.range_eq
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          ext
          simp)
    have q := congr_arg (fun s => ((↑) : w → M) '' s) p.range_eq
    

Proof state:
case mpr
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
p : Surjective fun i => { val := v i, property := (_ : v i ∈ w) }
q :
  (fun s => Subtype.val '' s) (range fun i => { val := v i, property := (_ : v i ∈ w) }) =
    (fun s => Subtype.val '' s) univ
⊢ range v = w

Next tactic:
dsimp at q
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          ext
          simp)
    have q := congr_arg (fun s => ((↑) : w → M) '' s) p.range_eq
    dsimp at q
    

Proof state:
case mpr
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
p : Surjective fun i => { val := v i, property := (_ : v i ∈ w) }
q : (Subtype.val '' range fun i => { val := v i, property := (_ : v i ∈ w) }) = Subtype.val '' univ
⊢ range v = w

Next tactic:
rw [← image_univ, image_image] at q
/-- An alternative characterization of a maximal linearly independent family,
quantifying over types (in the same universe as `M`) into which the indexing family injects.
-/
theorem LinearIndependent.maximal_iff {ι : Type w} {R : Type u} [Ring R] [Nontrivial R] {M : Type v}
    [AddCommGroup M] [Module R M] {v : ι → M} (i : LinearIndependent R v) :
    i.Maximal ↔
      ∀ (κ : Type v) (w : κ → M) (_i' : LinearIndependent R w) (j : ι → κ) (_h : w ∘ j = v),
        Surjective j := by
  constructor
  · rintro p κ w i' j rfl
    specialize p (range w) i'.coe_range (range_comp_subset_range _ _)
    rw [range_comp, ← image_univ (f := w)] at p
    exact range_iff_surjective.mp (image_injective.mpr i'.injective p)
  · intro p w i' h
    specialize
      p w ((↑) : w → M) i' (fun i => ⟨v i, range_subset_iff.mp h i⟩)
        (by
          ext
          simp)
    have q := congr_arg (fun s => ((↑) : w → M) '' s) p.range_eq
    dsimp at q
    rw [← image_univ, image_image] at q
    

Proof state:
case mpr
ι✝ : Type u'
ι' : Type u_1
R✝ : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι✝ → M✝
inst✝¹⁰ : Ring R✝
inst✝⁹ : AddCommGroup M✝
inst✝⁸ : AddCommGroup M'
inst✝⁷ : AddCommGroup M''
inst✝⁶ : Module R✝ M✝
inst✝⁵ : Module R✝ M'
inst✝⁴ : Module R✝ M''
a b : R✝
x y : M✝
ι : Type w
R : Type u
inst✝³ : Ring R
inst✝² : Nontrivial R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
i : LinearIndependent R v
w : Set M
i' : LinearIndependent (ι := { x // x ∈ w }) R Subtype.val
h : range v ≤ w
p : Surjective fun i => { val := v i, property := (_ : v i ∈ w) }
q : (fun x => ↑{ val := v x, property := (_ : v x ∈ w) }) '' univ = Subtype.val '' univ
⊢ range v = w

Next tactic:
simpa using q
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
⊢ i = j

Next tactic:
let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
⊢ i = j

Next tactic:
have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
⊢ (Finsupp.total ι M R v) l = 0

Next tactic:
simp_rw [LinearMap.map_sub, Finsupp.total_apply]
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
⊢ ((Finsupp.sum (fun₀ | i => c) fun i a => a • v i) - Finsupp.sum (fun₀ | j => d) fun i a => a • v i) = 0

Next tactic:
simp [h]
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
  

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
h_total : (Finsupp.total ι M R v) l = 0
⊢ i = j

Next tactic:
have h_single_eq : Finsupp.single i c = Finsupp.single j d := by
    rw [linearIndependent_iff] at li
    simp [eq_add_of_sub_eq' (li l h_total)]
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
  have h_single_eq : Finsupp.single i c = Finsupp.single j d := by
    

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
h_total : (Finsupp.total ι M R v) l = 0
⊢ (fun₀ | i => c) = fun₀ | j => d

Next tactic:
rw [linearIndependent_iff] at li
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
  have h_single_eq : Finsupp.single i c = Finsupp.single j d := by
    rw [linearIndependent_iff] at li
    

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : ∀ (l : ι →₀ R), (Finsupp.total ι M R v) l = 0 → l = 0
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
h_total : (Finsupp.total ι M R v) l = 0
⊢ (fun₀ | i => c) = fun₀ | j => d

Next tactic:
simp [eq_add_of_sub_eq' (li l h_total)]
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
  have h_single_eq : Finsupp.single i c = Finsupp.single j d := by
    rw [linearIndependent_iff] at li
    simp [eq_add_of_sub_eq' (li l h_total)]
  

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
h_total : (Finsupp.total ι M R v) l = 0
h_single_eq : (fun₀ | i => c) = fun₀ | j => d
⊢ i = j

Next tactic:
rcases (Finsupp.single_eq_single_iff ..).mp h_single_eq with (⟨H, _⟩ | ⟨hc, _⟩)
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
  have h_single_eq : Finsupp.single i c = Finsupp.single j d := by
    rw [linearIndependent_iff] at li
    simp [eq_add_of_sub_eq' (li l h_total)]
  rcases (Finsupp.single_eq_single_iff ..).mp h_single_eq with (⟨H, _⟩ | ⟨hc, _⟩)
  · 

Proof state:
case inl.intro
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
h_total : (Finsupp.total ι M R v) l = 0
h_single_eq : (fun₀ | i => c) = fun₀ | j => d
H : i = j
right✝ : c = d
⊢ i = j

Next tactic:
exact H
/-- Linear independent families are injective, even if you multiply either side. -/
theorem LinearIndependent.eq_of_smul_apply_eq_smul_apply {M : Type*} [AddCommGroup M] [Module R M]
    {v : ι → M} (li : LinearIndependent R v) (c d : R) (i j : ι) (hc : c ≠ 0)
    (h : c • v i = d • v j) : i = j := by
  let l : ι →₀ R := Finsupp.single i c - Finsupp.single j d
  have h_total : Finsupp.total ι M R v l = 0 := by
    simp_rw [LinearMap.map_sub, Finsupp.total_apply]
    simp [h]
  have h_single_eq : Finsupp.single i c = Finsupp.single j d := by
    rw [linearIndependent_iff] at li
    simp [eq_add_of_sub_eq' (li l h_total)]
  rcases (Finsupp.single_eq_single_iff ..).mp h_single_eq with (⟨H, _⟩ | ⟨hc, _⟩)
  · exact H
  · 

Proof state:
case inr.intro
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M✝ : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v✝ : ι → M✝
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : AddCommGroup M'
inst✝⁵ : AddCommGroup M''
inst✝⁴ : Module R M✝
inst✝³ : Module R M'
inst✝² : Module R M''
a b : R
x y : M✝
M : Type u_8
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : ι → M
li : LinearIndependent R v
c d : R
i j : ι
hc✝ : c ≠ 0
h : c • v i = d • v j
l : ι →₀ R := (fun₀ | i => c) - fun₀ | j => d
h_total : (Finsupp.total ι M R v) l = 0
h_single_eq : (fun₀ | i => c) = fun₀ | j => d
hc : c = 0
right✝ : d = 0
⊢ i = j

Next tactic:
contradiction
theorem LinearIndependent.disjoint_span_image (hv : LinearIndependent R v) {s t : Set ι}
    (hs : Disjoint s t) : Disjoint (Submodule.span R <| v '' s) (Submodule.span R <| v '' t) := by
  

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M
inst✝⁶ : Ring R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup M'
inst✝³ : AddCommGroup M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
a b : R
x y : M
hv : LinearIndependent R v
s t : Set ι
hs : Disjoint s t
⊢ Disjoint (span R (v '' s)) (span R (v '' t))

Next tactic:
simp only [disjoint_def, Finsupp.mem_span_image_iff_total]
theorem LinearIndependent.disjoint_span_image (hv : LinearIndependent R v) {s t : Set ι}
    (hs : Disjoint s t) : Disjoint (Submodule.span R <| v '' s) (Submodule.span R <| v '' t) := by
  simp only [disjoint_def, Finsupp.mem_span_image_iff_total]
  

Proof state:
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M
inst✝⁶ : Ring R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup M'
inst✝³ : AddCommGroup M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
a b : R
x y : M
hv : LinearIndependent R v
s t : Set ι
hs : Disjoint s t
⊢ ∀ (x : M),
    (∃ l ∈ Finsupp.supported R R s, (Finsupp.total ι M R v) l = x) →
      (∃ l ∈ Finsupp.supported R R t, (Finsupp.total ι M R v) l = x) → x = 0

Next tactic:
rintro _ ⟨l₁, hl₁, rfl⟩ ⟨l₂, hl₂, H⟩
theorem LinearIndependent.disjoint_span_image (hv : LinearIndependent R v) {s t : Set ι}
    (hs : Disjoint s t) : Disjoint (Submodule.span R <| v '' s) (Submodule.span R <| v '' t) := by
  simp only [disjoint_def, Finsupp.mem_span_image_iff_total]
  rintro _ ⟨l₁, hl₁, rfl⟩ ⟨l₂, hl₂, H⟩
  

Proof state:
case intro.intro.intro.intro
ι : Type u'
ι' : Type u_1
R : Type u_2
K : Type u_3
M : Type u_4
M' : Type u_5
M'' : Type u_6
V : Type u
V' : Type u_7
v : ι → M
inst✝⁶ : Ring R
inst✝⁵ : AddCommGroup M
inst✝⁴ : AddCommGroup M'
inst✝³ : AddCommGroup M''
inst✝² : Module R M
inst✝¹ : Module R M'
inst✝ : Module R M''
a b : R
x y : M
hv : LinearIndependent R v
s t : Set ι
hs : Disjoint s t
l₁ : ι →₀ R
hl₁ : l₁ ∈ Finsupp.supported R R s
l₂ : ι →₀ R
hl₂ : l₂ ∈ Finsupp.supported R R t
H : (Finsupp.total ι M R v) l₂ = (Finsupp.total ι M R v) l₁
⊢ (Finsupp.total ι M R v) l₁ = 0

Next tactic:
rw [hv.injective_total.eq_iff] at H