l3lab/ntp-mathlib huggingface dataset:
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
⊢ b b' ∉ range v

Next tactic:
rintro ⟨k, p⟩
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    

Proof state:
case intro
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
k : κ
p : v k = b b'
⊢ False

Next tactic:
simpa [w] using congr_arg (fun m => (b.repr m) b') p
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  

Proof state:
case intro
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
⊢ False

Next tactic:
have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      rfl
    rw [← e] at p
    exact r' p
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
⊢ range v ≠ range v'

Next tactic:
intro e
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
e : range v = range v'
⊢ False

Next tactic:
have p : b b' ∈ range v' := by
      use none
      rfl
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
e : range v = range v'
⊢ b b' ∈ range v'

Next tactic:
use none
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      

Proof state:
case h
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
e : range v = range v'
⊢ v' none = b b'

Next tactic:
rfl
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      rfl
    

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
e : range v = range v'
p : b b' ∈ range v'
⊢ False

Next tactic:
rw [← e] at p
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      rfl
    rw [← e] at p
    

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
e : range v = range v'
p : b b' ∈ range v
⊢ False

Next tactic:
exact r' p
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      rfl
    rw [← e] at p
    exact r' p
  -- The key step in the proof is checking that this strictly larger family is linearly independent.
  have i' : LinearIndependent R ((↑) : range v' → M) := by
    

Proof state:
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
r'' : range v ≠ range v'
⊢ LinearIndependent (ι := { x // x ∈ range v' }) R Subtype.val

Next tactic:
apply LinearIndependent.to_subtype_range
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      rfl
    rw [← e] at p
    exact r' p
  -- The key step in the proof is checking that this strictly larger family is linearly independent.
  have i' : LinearIndependent R ((↑) : range v' → M) := by
    apply LinearIndependent.to_subtype_range
    

Proof state:
case hf
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
r'' : range v ≠ range v'
⊢ LinearIndependent R v'

Next tactic:
rw [linearIndependent_iff]
/-- Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
theorem union_support_maximal_linearIndependent_eq_range_basis {ι : Type w} (b : Basis ι R M)
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    ⋃ k, ((b.repr (v k)).support : Set ι) = Set.univ := by
  -- If that's not the case,
  by_contra h
  simp only [← Ne.def, ne_univ_iff_exists_not_mem, mem_iUnion, not_exists_not,
    Finsupp.mem_support_iff, Finset.mem_coe] at h
  -- We have some basis element `b b'` which is not in the support of any of the `v i`.
  obtain ⟨b', w⟩ := h
  -- Using this, we'll construct a linearly independent family strictly larger than `v`,
  -- by also using this `b b'`.
  let v' : Option κ → M := fun o => o.elim (b b') v
  have r : range v ⊆ range v' := by
    rintro - ⟨k, rfl⟩
    use some k
    rfl
  have r' : b b' ∉ range v := by
    rintro ⟨k, p⟩
    simpa [w] using congr_arg (fun m => (b.repr m) b') p
  have r'' : range v ≠ range v' := by
    intro e
    have p : b b' ∈ range v' := by
      use none
      rfl
    rw [← e] at p
    exact r' p
  -- The key step in the proof is checking that this strictly larger family is linearly independent.
  have i' : LinearIndependent R ((↑) : range v' → M) := by
    apply LinearIndependent.to_subtype_range
    rw [linearIndependent_iff]
    

Proof state:
case hf
K R : Type u
V V₁ V₂ V₃ : Type v
V' V'₁ : Type v'
V'' : Type v''
ι✝ : Type w
ι' : Type w'
η : Type u₁'
φ : η → Type u_1
inst✝⁷ : Ring R
M : Type v
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
M' : Type v'
inst✝⁴ : AddCommGroup M'
inst✝³ : Module R M'
M₁ : Type v
inst✝² : AddCommGroup M₁
inst✝¹ : Module R M₁
inst✝ : Nontrivial R
ι : Type w
b : Basis ι R M
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
b' : ι
w : ∀ (x : κ), (b.repr (v x)) b' = 0
v' : Option κ → M := fun o => Option.elim o (b b') v
r : range v ⊆ range v'
r' : b b' ∉ range v
r'' : range v ≠ range v'
⊢ ∀ (l : Option κ →₀ R), (Finsupp.total (Option κ) M R v') l = 0 → l = 0

Next tactic:
intro l z