l3lab/ntp-mathlib huggingface dataset:
/-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/
lemma rank_eq_zero_iff {R M} [Ring R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by
  nontriviality R
  constructor
  · contrapose!
    rintro ⟨x, hx⟩
    rw [← Cardinal.one_le_iff_ne_zero]
    have : LinearIndependent R (fun _ : Unit ↦ x)
    · exact linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦
        hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl))
    simpa using cardinal_lift_le_rank_of_linearIndependent this
  · intro h
    rw [← le_zero_iff, Module.rank_def]
    apply ciSup_le'
    intro ⟨s, hs⟩
    

Proof state:
case mpr.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✝⁴ : NoZeroSMulDivisors R✝ M✝
inst✝³ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
✝ : Nontrivial R
h : ∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
⊢ #↑↑{ val := s, property := hs } ≤ 0

Next tactic:
rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff]
/-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/
lemma rank_eq_zero_iff {R M} [Ring R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by
  nontriviality R
  constructor
  · contrapose!
    rintro ⟨x, hx⟩
    rw [← Cardinal.one_le_iff_ne_zero]
    have : LinearIndependent R (fun _ : Unit ↦ x)
    · exact linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦
        hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl))
    simpa using cardinal_lift_le_rank_of_linearIndependent this
  · intro h
    rw [← le_zero_iff, Module.rank_def]
    apply ciSup_le'
    intro ⟨s, hs⟩
    rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff]
    

Proof state:
case mpr.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✝⁴ : NoZeroSMulDivisors R✝ M✝
inst✝³ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
✝ : Nontrivial R
h : ∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
⊢ ¬Nonempty ↑↑{ val := s, property := hs }

Next tactic:
rintro ⟨i : s⟩
/-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/
lemma rank_eq_zero_iff {R M} [Ring R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by
  nontriviality R
  constructor
  · contrapose!
    rintro ⟨x, hx⟩
    rw [← Cardinal.one_le_iff_ne_zero]
    have : LinearIndependent R (fun _ : Unit ↦ x)
    · exact linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦
        hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl))
    simpa using cardinal_lift_le_rank_of_linearIndependent this
  · intro h
    rw [← le_zero_iff, Module.rank_def]
    apply ciSup_le'
    intro ⟨s, hs⟩
    rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff]
    rintro ⟨i : s⟩
    

Proof state:
case mpr.h.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
R✝ : Type u
M✝ : Type v
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M✝
inst✝⁵ : Module R✝ M✝
inst✝⁴ : NoZeroSMulDivisors R✝ M✝
inst✝³ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
✝ : Nontrivial R
h : ∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
i : ↑s
⊢ False

Next tactic:
obtain ⟨a, ha, ha'⟩ := h i
/-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/
lemma rank_eq_zero_iff {R M} [Ring R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by
  nontriviality R
  constructor
  · contrapose!
    rintro ⟨x, hx⟩
    rw [← Cardinal.one_le_iff_ne_zero]
    have : LinearIndependent R (fun _ : Unit ↦ x)
    · exact linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦
        hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl))
    simpa using cardinal_lift_le_rank_of_linearIndependent this
  · intro h
    rw [← le_zero_iff, Module.rank_def]
    apply ciSup_le'
    intro ⟨s, hs⟩
    rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff]
    rintro ⟨i : s⟩
    obtain ⟨a, ha, ha'⟩ := h i
    

Proof state:
case mpr.h.intro.intro.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
R✝ : Type u
M✝ : Type v
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M✝
inst✝⁵ : Module R✝ M✝
inst✝⁴ : NoZeroSMulDivisors R✝ M✝
inst✝³ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
✝ : Nontrivial R
h : ∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
i : ↑s
a : R
ha : a ≠ 0
ha' : a • ↑i = 0
⊢ False

Next tactic:
apply ha
/-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/
lemma rank_eq_zero_iff {R M} [Ring R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by
  nontriviality R
  constructor
  · contrapose!
    rintro ⟨x, hx⟩
    rw [← Cardinal.one_le_iff_ne_zero]
    have : LinearIndependent R (fun _ : Unit ↦ x)
    · exact linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦
        hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl))
    simpa using cardinal_lift_le_rank_of_linearIndependent this
  · intro h
    rw [← le_zero_iff, Module.rank_def]
    apply ciSup_le'
    intro ⟨s, hs⟩
    rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff]
    rintro ⟨i : s⟩
    obtain ⟨a, ha, ha'⟩ := h i
    apply ha
    

Proof state:
case mpr.h.intro.intro.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
R✝ : Type u
M✝ : Type v
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M✝
inst✝⁵ : Module R✝ M✝
inst✝⁴ : NoZeroSMulDivisors R✝ M✝
inst✝³ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
✝ : Nontrivial R
h : ∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
i : ↑s
a : R
ha : a ≠ 0
ha' : a • ↑i = 0
⊢ a = 0

Next tactic:
simpa using FunLike.congr_fun (linearIndependent_iff.mp hs (Finsupp.single i a) (by simpa)) i
/-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/
lemma rank_eq_zero_iff {R M} [Ring R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by
  nontriviality R
  constructor
  · contrapose!
    rintro ⟨x, hx⟩
    rw [← Cardinal.one_le_iff_ne_zero]
    have : LinearIndependent R (fun _ : Unit ↦ x)
    · exact linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦
        hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl))
    simpa using cardinal_lift_le_rank_of_linearIndependent this
  · intro h
    rw [← le_zero_iff, Module.rank_def]
    apply ciSup_le'
    intro ⟨s, hs⟩
    rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff]
    rintro ⟨i : s⟩
    obtain ⟨a, ha, ha'⟩ := h i
    apply ha
    simpa using FunLike.congr_fun (linearIndependent_iff.mp hs (Finsupp.single i a) (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✝⁴ : NoZeroSMulDivisors R✝ M✝
inst✝³ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
✝ : Nontrivial R
h : ∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
i : ↑s
a : R
ha : a ≠ 0
ha' : a • ↑i = 0
⊢ ((Finsupp.total { x // x ∈ s } M R Subtype.val) fun₀ | i => a) = 0

Next tactic:
simpa
lemma rank_eq_zero_iff_isTorsion {R M} [CommRing R] [IsDomain R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ Module.IsTorsion 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
R✝ : Type u
M✝ : Type v
inst✝⁸ : Ring R✝
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R✝ M✝
inst✝⁵ : NoZeroSMulDivisors R✝ M✝
inst✝⁴ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
⊢ Module.rank R M = 0 ↔ Module.IsTorsion R M

Next tactic:
rw [Module.IsTorsion, rank_eq_zero_iff]
lemma rank_eq_zero_iff_isTorsion {R M} [CommRing R] [IsDomain R] [AddCommGroup M] [Module R M] :
    Module.rank R M = 0 ↔ Module.IsTorsion R M := by
  rw [Module.IsTorsion, rank_eq_zero_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
R✝ : Type u
M✝ : Type v
inst✝⁸ : Ring R✝
inst✝⁷ : AddCommGroup M✝
inst✝⁶ : Module R✝ M✝
inst✝⁵ : NoZeroSMulDivisors R✝ M✝
inst✝⁴ : Nontrivial R✝
R : Type u_2
M : Type u_3
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
⊢ (∀ (x : M), ∃ a, a ≠ 0 ∧ a • x = 0) ↔ ∀ ⦃x : M⦄, ∃ a, a • x = 0

Next tactic:
simp [mem_nonZeroDivisors_iff_ne_zero]
theorem rank_pos_iff_exists_ne_zero : 0 < Module.rank R M ↔ ∃ x : M, x ≠ 0 := 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✝¹ : NoZeroSMulDivisors R M
inst✝ : Nontrivial R
⊢ 0 < Module.rank R M ↔ ∃ x, x ≠ 0

Next tactic:
rw [← not_iff_not]
theorem rank_pos_iff_exists_ne_zero : 0 < Module.rank R M ↔ ∃ x : M, x ≠ 0 := by
  rw [← not_iff_not]
  

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✝¹ : NoZeroSMulDivisors R M
inst✝ : Nontrivial R
⊢ ¬0 < Module.rank R M ↔ ¬∃ x, x ≠ 0

Next tactic:
simpa using rank_zero_iff_forall_zero
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    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
R : Type u
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
    simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
    -- Now we can use invariant basis number to show they have the same cardinality.
    apply card_eq_of_linearEquiv R
    exact
      (Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm ≪≫ₗ v'.repr ≪≫ₗ
        Finsupp.linearEquivFunOnFinite R R ι'
  · -- `v` is an infinite basis,
    -- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big,
    -- and then applying `infinite_basis_le_maximal_linearIndependent` again
    -- we see they have the same cardinality.
    have w₁ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal
    rcases Cardinal.lift_mk_le'.mp w₁ with ⟨f⟩
    haveI : Infinite ι' := Infinite.of_injective f f.2
    have w₂ := infinite_basis_le_maximal_linearIndependent' v' _ v.linearIndependent v.maximal
    exact le_antisymm w₁ w₂
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  

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
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
haveI := nontrivial_of_invariantBasisNumber R
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  

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
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this : Nontrivial R
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
cases fintypeOrInfinite ι
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    

Proof state:
case inl
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
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this : Nontrivial R
val✝ : Fintype ι
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    

Proof state:
case inl
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
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this✝ : Nontrivial R
val✝ : Fintype ι
this : Finite ι'
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
cases nonempty_fintype ι'
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    

Proof state:
case inl.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
R : Type u
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this✝ : Nontrivial R
val✝¹ : Fintype ι
this : Finite ι'
val✝ : Fintype ι'
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
    

Proof state:
case inl.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
R : Type u
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this✝ : Nontrivial R
val✝¹ : Fintype ι
this : Finite ι'
val✝ : Fintype ι'
⊢ lift.{w', w} ↑(Fintype.card ι) = lift.{w, w'} ↑(Fintype.card ι')

Next tactic:
simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
    simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
    -- Now we can use invariant basis number to show they have the same cardinality.
    

Proof state:
case inl.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
R : Type u
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this✝ : Nontrivial R
val✝¹ : Fintype ι
this : Finite ι'
val✝ : Fintype ι'
⊢ Fintype.card ι = Fintype.card ι'

Next tactic:
apply card_eq_of_linearEquiv R
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
    simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
    -- Now we can use invariant basis number to show they have the same cardinality.
    apply card_eq_of_linearEquiv R
    

Proof state:
case inl.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
R : Type u
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this✝ : Nontrivial R
val✝¹ : Fintype ι
this : Finite ι'
val✝ : Fintype ι'
⊢ (ι → R) ≃ₗ[R] ι' → R

Next tactic:
exact
      (Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm ≪≫ₗ v'.repr ≪≫ₗ
        Finsupp.linearEquivFunOnFinite R R ι'
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
    simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
    -- Now we can use invariant basis number to show they have the same cardinality.
    apply card_eq_of_linearEquiv R
    exact
      (Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm ≪≫ₗ v'.repr ≪≫ₗ
        Finsupp.linearEquivFunOnFinite R R ι'
  · -- `v` is an infinite basis,
    -- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big,
    -- and then applying `infinite_basis_le_maximal_linearIndependent` again
    -- we see they have the same cardinality.
    

Proof state:
case inr
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
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this : Nontrivial R
val✝ : Infinite ι
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
have w₁ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
    Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
  classical
  haveI := nontrivial_of_invariantBasisNumber R
  cases fintypeOrInfinite ι
  · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
    -- haveI : Finite (range v) := Set.finite_range v
    haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
    cases nonempty_fintype ι'
    -- We clean up a little:
    rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
    simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
    -- Now we can use invariant basis number to show they have the same cardinality.
    apply card_eq_of_linearEquiv R
    exact
      (Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm ≪≫ₗ v'.repr ≪≫ₗ
        Finsupp.linearEquivFunOnFinite R R ι'
  · -- `v` is an infinite basis,
    -- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big,
    -- and then applying `infinite_basis_le_maximal_linearIndependent` again
    -- we see they have the same cardinality.
    have w₁ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal
    

Proof state:
case inr
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
inst✝³ : Ring R
inst✝² : InvariantBasisNumber R
M : Type v
inst✝¹ : AddCommGroup M
inst✝ : Module R M
v : Basis ι R M
v' : Basis ι' R M
this : Nontrivial R
val✝ : Infinite ι
w₁ : lift.{w', w} #ι ≤ lift.{w, w'} #ι'
⊢ lift.{w', w} #ι = lift.{w, w'} #ι'

Next tactic:
rcases Cardinal.lift_mk_le'.mp w₁ with ⟨f⟩