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
    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]
    intro l z
    rw [Finsupp.total_option] at z
    simp only [Option.elim'] at z
    change _ + Finsupp.total κ M R v l.some = 0 at z
    -- We have some linear combination of `b b'` and the `v i`, which we want to show is trivial.
    -- We'll first show the coefficient of `b b'` is zero,
    -- by expressing the `v i` in the basis `b`, and using that the `v i` have no `b b'` term.
    have l₀ : l none = 0 := by
      rw [← eq_neg_iff_add_eq_zero] at z
      replace z := neg_eq_iff_eq_neg.mpr z
      apply_fun fun x => b.repr x b' at z
      simp only [repr_self, LinearEquiv.map_smul, mul_one, Finsupp.single_eq_same, Pi.neg_apply,
        Finsupp.smul_single', LinearEquiv.map_neg, Finsupp.coe_neg] at z
      erw [FunLike.congr_fun (Finsupp.apply_total R (b.repr : M →ₗ[R] ι →₀ R) v l.some) b'] at z
      

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'
l : Option κ →₀ R
z :
  -(l none • b.repr (Option.elim none (b b') v)) b' = ((Finsupp.total κ (ι →₀ R) R (⇑↑b.repr ∘ v)) (Finsupp.some l)) b'
⊢ l none = 0

Next tactic:
simpa [Finsupp.total_apply, w] using z
/-- Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
theorem infinite_basis_le_maximal_linearIndependent' {ι : Type w} (b : Basis ι R M) [Infinite ι]
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    Cardinal.lift.{w'} #ι ≤ Cardinal.lift.{w} #κ := 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
inst✝ : Infinite ι
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
⊢ lift.{w', w} #ι ≤ lift.{w, w'} #κ

Next tactic:
let Φ := fun k : κ => (b.repr (v k)).support
/-- Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
theorem infinite_basis_le_maximal_linearIndependent' {ι : Type w} (b : Basis ι R M) [Infinite ι]
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    Cardinal.lift.{w'} #ι ≤ Cardinal.lift.{w} #κ := by
  let Φ := fun k : κ => (b.repr (v k)).support
  

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
inst✝ : Infinite ι
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
Φ : κ → Finset ι := fun k => (b.repr (v k)).support
⊢ lift.{w', w} #ι ≤ lift.{w, w'} #κ

Next tactic:
have w₁ : #ι ≤ #(Set.range Φ) := by
    apply Cardinal.le_range_of_union_finset_eq_top
    exact union_support_maximal_linearIndependent_eq_range_basis b v i m
/-- Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
theorem infinite_basis_le_maximal_linearIndependent' {ι : Type w} (b : Basis ι R M) [Infinite ι]
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    Cardinal.lift.{w'} #ι ≤ Cardinal.lift.{w} #κ := by
  let Φ := fun k : κ => (b.repr (v k)).support
  have w₁ : #ι ≤ #(Set.range Φ) := 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
inst✝ : Infinite ι
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
Φ : κ → Finset ι := fun k => (b.repr (v k)).support
⊢ #ι ≤ #↑(range Φ)

Next tactic:
apply Cardinal.le_range_of_union_finset_eq_top
/-- Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
theorem infinite_basis_le_maximal_linearIndependent' {ι : Type w} (b : Basis ι R M) [Infinite ι]
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    Cardinal.lift.{w'} #ι ≤ Cardinal.lift.{w} #κ := by
  let Φ := fun k : κ => (b.repr (v k)).support
  have w₁ : #ι ≤ #(Set.range Φ) := by
    apply Cardinal.le_range_of_union_finset_eq_top
    

Proof state:
case w
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
inst✝ : Infinite ι
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
Φ : κ → Finset ι := fun k => (b.repr (v k)).support
⊢ ⋃ a, ↑(Φ a) = ⊤

Next tactic:
exact union_support_maximal_linearIndependent_eq_range_basis b v i m
/-- Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
theorem infinite_basis_le_maximal_linearIndependent' {ι : Type w} (b : Basis ι R M) [Infinite ι]
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    Cardinal.lift.{w'} #ι ≤ Cardinal.lift.{w} #κ := by
  let Φ := fun k : κ => (b.repr (v k)).support
  have w₁ : #ι ≤ #(Set.range Φ) := by
    apply Cardinal.le_range_of_union_finset_eq_top
    exact union_support_maximal_linearIndependent_eq_range_basis b v i m
  

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
inst✝ : Infinite ι
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
Φ : κ → Finset ι := fun k => (b.repr (v k)).support
w₁ : #ι ≤ #↑(range Φ)
⊢ lift.{w', w} #ι ≤ lift.{w, w'} #κ

Next tactic:
have w₂ : Cardinal.lift.{w'} #(Set.range Φ) ≤ Cardinal.lift.{w} #κ := Cardinal.mk_range_le_lift
/-- Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
theorem infinite_basis_le_maximal_linearIndependent' {ι : Type w} (b : Basis ι R M) [Infinite ι]
    {κ : Type w'} (v : κ → M) (i : LinearIndependent R v) (m : i.Maximal) :
    Cardinal.lift.{w'} #ι ≤ Cardinal.lift.{w} #κ := by
  let Φ := fun k : κ => (b.repr (v k)).support
  have w₁ : #ι ≤ #(Set.range Φ) := by
    apply Cardinal.le_range_of_union_finset_eq_top
    exact union_support_maximal_linearIndependent_eq_range_basis b v i m
  have w₂ : Cardinal.lift.{w'} #(Set.range Φ) ≤ Cardinal.lift.{w} #κ := Cardinal.mk_range_le_lift
  

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
inst✝ : Infinite ι
κ : Type w'
v : κ → M
i : LinearIndependent R v
m : LinearIndependent.Maximal i
Φ : κ → Finset ι := fun k => (b.repr (v k)).support
w₁ : #ι ≤ #↑(range Φ)
w₂ : lift.{w', w} #↑(range Φ) ≤ lift.{w, w'} #κ
⊢ lift.{w', w} #ι ≤ lift.{w, w'} #κ

Next tactic:
exact (Cardinal.lift_le.mpr w₁).trans w₂
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R 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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
⊢ lift.{v, w} #{ i // V i ≠ ⊥ } ≤ lift.{w, v} (Module.rank R M)

Next tactic:
set I := { i : ι // V i ≠ ⊥ }
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  

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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
⊢ lift.{v, w} #I ≤ lift.{w, v} (Module.rank R M)

Next tactic:
have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : M) := by
    intro i
    rw [← Submodule.ne_bot_iff]
    exact i.prop
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : 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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
⊢ ∀ (i : I), ∃ v ∈ V ↑i, v ≠ 0

Next tactic:
intro i
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : M) := by
    intro i
    

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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
i : I
⊢ ∃ v ∈ V ↑i, v ≠ 0

Next tactic:
rw [← Submodule.ne_bot_iff]
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : M) := by
    intro i
    rw [← Submodule.ne_bot_iff]
    

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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
i : I
⊢ V ↑i ≠ ⊥

Next tactic:
exact i.prop
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : M) := by
    intro i
    rw [← Submodule.ne_bot_iff]
    exact i.prop
  

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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
hI : ∀ (i : I), ∃ v ∈ V ↑i, v ≠ 0
⊢ lift.{v, w} #I ≤ lift.{w, v} (Module.rank R M)

Next tactic:
choose v hvV hv using hI
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : M) := by
    intro i
    rw [← Submodule.ne_bot_iff]
    exact i.prop
  choose v hvV hv using hI
  

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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
v : I → M
hvV : ∀ (i : I), v i ∈ V ↑i
hv : ∀ (i : I), v i ≠ 0
⊢ lift.{v, w} #I ≤ lift.{w, v} (Module.rank R M)

Next tactic:
have : LinearIndependent R v := (hV.comp Subtype.coe_injective).linearIndependent _ hvV hv
theorem CompleteLattice.Independent.subtype_ne_bot_le_rank [NoZeroSMulDivisors R M]
    {V : ι → Submodule R M} (hV : CompleteLattice.Independent V) :
    Cardinal.lift.{v} #{ i : ι // V i ≠ ⊥ } ≤ Cardinal.lift.{w} (Module.rank R M) := by
  set I := { i : ι // V i ≠ ⊥ }
  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0 : M) := by
    intro i
    rw [← Submodule.ne_bot_iff]
    exact i.prop
  choose v hvV hv using hI
  have : LinearIndependent R v := (hV.comp Subtype.coe_injective).linearIndependent _ hvV hv
  

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
inst✝ : NoZeroSMulDivisors R M
V : ι → Submodule R M
hV : Independent V
I : Type w := { i // V i ≠ ⊥ }
v : I → M
hvV : ∀ (i : I), v i ∈ V ↑i
hv : ∀ (i : I), v i ≠ 0
this : LinearIndependent R v
⊢ lift.{v, w} #I ≤ lift.{w, v} (Module.rank R M)

Next tactic:
exact cardinal_lift_le_rank_of_linearIndependent' this
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := 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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
⊢ Module.rank R M = 1

Next tactic:
haveI := Module.subsingleton R M
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  

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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this : Subsingleton M
⊢ Module.rank R M = 1

Next tactic:
have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  

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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
⊢ Module.rank R M = 1

Next tactic:
rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
  · 

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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
⊢ ∀ (i : { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }), #↑↑i ≤ 1

Next tactic:
rintro ⟨s, hs⟩
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
  · rintro ⟨s, hs⟩
    

Proof state:
case h₁.mk
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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
⊢ #↑↑{ val := s, property := hs } ≤ 1

Next tactic:
rw [Cardinal.mk_le_one_iff_set_subsingleton]
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
  · rintro ⟨s, hs⟩
    rw [Cardinal.mk_le_one_iff_set_subsingleton]
    

Proof state:
case h₁.mk
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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
⊢ Set.Subsingleton ↑{ val := s, property := hs }

Next tactic:
apply subsingleton_of_subsingleton
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
  · rintro ⟨s, hs⟩
    rw [Cardinal.mk_le_one_iff_set_subsingleton]
    apply subsingleton_of_subsingleton
  

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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
⊢ ∀ w < 1, ∃ i, w < #↑↑i

Next tactic:
intro w hw
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
  · rintro ⟨s, hs⟩
    rw [Cardinal.mk_le_one_iff_set_subsingleton]
    apply subsingleton_of_subsingleton
  intro w hw
  

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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
w : Cardinal.{v}
hw : w < 1
⊢ ∃ i, w < #↑↑i

Next tactic:
refine' ⟨⟨{0}, _⟩, _⟩
@[nontriviality, simp]
theorem rank_subsingleton [Subsingleton R] : Module.rank R M = 1 := by
  haveI := Module.subsingleton R M
  have : Nonempty { s : Set M // LinearIndependent R ((↑) : s → M) } :=
    ⟨⟨∅, linearIndependent_empty _ _⟩⟩
  rw [Module.rank_def, ciSup_eq_of_forall_le_of_forall_lt_exists_gt]
  · rintro ⟨s, hs⟩
    rw [Cardinal.mk_le_one_iff_set_subsingleton]
    apply subsingleton_of_subsingleton
  intro w hw
  refine' ⟨⟨{0}, _⟩, _⟩
  · 

Proof state:
case h₂.refine'_1
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
R : Type u
M : Type v
inst✝³ : Ring R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Subsingleton R
this✝ : Subsingleton M
this : Nonempty { s // LinearIndependent (ι := { x // x ∈ s }) R Subtype.val }
w : Cardinal.{v}
hw : w < 1
⊢ LinearIndependent (ι := { x // x ∈ {0} }) R Subtype.val

Next tactic:
rw [linearIndependent_iff']