l3lab/ntp-mathlib huggingface dataset:
/-- The **rank-nullity theorem** -/
theorem rank_range_add_rank_ker (f : V →ₗ[K] V₁) :
    Module.rank K (LinearMap.range f) + Module.rank K (LinearMap.ker f) = Module.rank K 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
f : V →ₗ[K] V₁
⊢ Module.rank K ↥(LinearMap.range f) + Module.rank K ↥(LinearMap.ker f) = Module.rank K V

Next tactic:
haveI := fun p : Submodule K V => Classical.decEq (V ⧸ p)
/-- The **rank-nullity theorem** -/
theorem rank_range_add_rank_ker (f : V →ₗ[K] V₁) :
    Module.rank K (LinearMap.range f) + Module.rank K (LinearMap.ker f) = Module.rank K V := by
  haveI := fun p : Submodule K V => Classical.decEq (V ⧸ 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
f : V →ₗ[K] V₁
this : (p : Submodule K V) → DecidableEq (V ⧸ p)
⊢ Module.rank K ↥(LinearMap.range f) + Module.rank K ↥(LinearMap.ker f) = Module.rank K V

Next tactic:
rw [← f.quotKerEquivRange.rank_eq, rank_quotient_add_rank]
theorem rank_eq_of_surjective (f : V →ₗ[K] V₁) (h : Surjective f) :
    Module.rank K V = Module.rank K V₁ + Module.rank K (LinearMap.ker f) := 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
f : V →ₗ[K] V₁
h : Surjective ⇑f
⊢ Module.rank K V = Module.rank K V₁ + Module.rank K ↥(LinearMap.ker f)

Next tactic:
rw [← rank_range_add_rank_ker f, ← rank_range_of_surjective f h]
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
⊢ ∃ x, LinearIndependent K (Fin.cons x v)

Next tactic:
have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
    exact lt_irrefl _ (h.trans_le this)
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
⊢ span K (range v) ≠ ⊤

Next tactic:
intro H
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
H : span K (range v) = ⊤
⊢ False

Next tactic:
rw [← rank_top, ← H] at h
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K ↥(span K (range v))
H : span K (range v) = ⊤
⊢ False

Next tactic:
have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K ↥(span K (range v))
H : span K (range v) = ⊤
⊢ Module.rank K ↥(span K (range v)) ≤ ↑n

Next tactic:
have := Cardinal.mk_range_le_lift (f := v)
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K ↥(span K (range v))
H : span K (range v) = ⊤
this : lift.{0, v} #↑(range v) ≤ lift.{v, 0} #(Fin n)
⊢ Module.rank K ↥(span K (range v)) ≤ ↑n

Next tactic:
simp only [Cardinal.lift_id'] at this
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K ↥(span K (range v))
H : span K (range v) = ⊤
this : #↑(range v) ≤ lift.{v, 0} #(Fin n)
⊢ Module.rank K ↥(span K (range v)) ≤ ↑n

Next tactic:
exact (rank_span_le _).trans (this.trans (by simp))
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K ↥(span K (range v))
H : span K (range v) = ⊤
this : #↑(range v) ≤ lift.{v, 0} #(Fin n)
⊢ lift.{v, 0} #(Fin n) ≤ ↑n

Next tactic:
simp
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
    

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K ↥(span K (range v))
H : span K (range v) = ⊤
this : Module.rank K ↥(span K (range v)) ≤ ↑n
⊢ False

Next tactic:
exact lt_irrefl _ (h.trans_le this)
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
    exact lt_irrefl _ (h.trans_le this)
  

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
A : span K (range v) ≠ ⊤
⊢ ∃ x, LinearIndependent K (Fin.cons x v)

Next tactic:
obtain ⟨x, hx⟩ : ∃ x, x ∉ Submodule.span K (range v) := by
    contrapose! A
    exact Iff.mpr Submodule.eq_top_iff' A
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
    exact lt_irrefl _ (h.trans_le this)
  obtain ⟨x, hx⟩ : ∃ x, x ∉ Submodule.span K (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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
A : span K (range v) ≠ ⊤
⊢ ∃ x, x ∉ span K (range v)

Next tactic:
contrapose! A
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
    exact lt_irrefl _ (h.trans_le this)
  obtain ⟨x, hx⟩ : ∃ x, x ∉ Submodule.span K (range v) := by
    contrapose! A
    

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
A : ∀ (x : V), x ∈ span K (range v)
⊢ span K (range v) = ⊤

Next tactic:
exact Iff.mpr Submodule.eq_top_iff' A
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_cons_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.cons x v) := by
  have A : Submodule.span K (range v) ≠ ⊤ := by
    intro H
    rw [← rank_top, ← H] at h
    have : Module.rank K (Submodule.span K (range v)) ≤ n := by
      have := Cardinal.mk_range_le_lift (f := v)
      simp only [Cardinal.lift_id'] at this
      exact (rank_span_le _).trans (this.trans (by simp))
    exact lt_irrefl _ (h.trans_le this)
  obtain ⟨x, hx⟩ : ∃ x, x ∉ Submodule.span K (range v) := by
    contrapose! A
    exact Iff.mpr Submodule.eq_top_iff' A
  

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
A : span K (range v) ≠ ⊤
x : V
hx : x ∉ span K (range v)
⊢ ∃ x, LinearIndependent K (Fin.cons x v)

Next tactic:
exact ⟨x, linearIndependent_fin_cons.2 ⟨hv, hx⟩⟩
/-- Given a family of `n` linearly independent vectors in a space of dimension `> n`, one may extend
the family by another vector while retaining linear independence. -/
theorem exists_linearIndependent_snoc_of_lt_rank {n : ℕ} {v : Fin n → V}
    (hv : LinearIndependent K v) (h : n < Module.rank K V) :
    ∃ (x : V), LinearIndependent K (Fin.snoc v x) := 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
n : ℕ
v : Fin n → V
hv : LinearIndependent K v
h : ↑n < Module.rank K V
⊢ ∃ x, LinearIndependent K (Fin.snoc v x)

Next tactic:
simpa [linearIndependent_fin_cons, ← linearIndependent_fin_snoc]
    using exists_linearIndependent_cons_of_lt_rank hv h
/-- Given a nonzero vector in a space of dimension `> 1`, one may find another vector linearly
independent of the first one. -/
theorem exists_linearIndependent_pair_of_one_lt_rank
    (h : 1 < Module.rank K V) {x : V} (hx : x ≠ 0) :
    ∃ y, LinearIndependent K ![x, y] := 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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
h : 1 < Module.rank K V
x : V
hx : x ≠ 0
⊢ ∃ y, LinearIndependent K ![x, y]

Next tactic:
obtain ⟨y, hy⟩ := exists_linearIndependent_snoc_of_lt_rank (linearIndependent_unique ![x] hx) h
/-- Given a nonzero vector in a space of dimension `> 1`, one may find another vector linearly
independent of the first one. -/
theorem exists_linearIndependent_pair_of_one_lt_rank
    (h : 1 < Module.rank K V) {x : V} (hx : x ≠ 0) :
    ∃ y, LinearIndependent K ![x, y] := by
  obtain ⟨y, hy⟩ := exists_linearIndependent_snoc_of_lt_rank (linearIndependent_unique ![x] hx) h
  

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
h : 1 < Module.rank K V
x : V
hx : x ≠ 0
y : V
hy : LinearIndependent K (Fin.snoc ![x] y)
⊢ ∃ y, LinearIndependent K ![x, y]

Next tactic:
have : Fin.snoc ![x] y = ![x, y] := Iff.mp List.ofFn_inj rfl
/-- Given a nonzero vector in a space of dimension `> 1`, one may find another vector linearly
independent of the first one. -/
theorem exists_linearIndependent_pair_of_one_lt_rank
    (h : 1 < Module.rank K V) {x : V} (hx : x ≠ 0) :
    ∃ y, LinearIndependent K ![x, y] := by
  obtain ⟨y, hy⟩ := exists_linearIndependent_snoc_of_lt_rank (linearIndependent_unique ![x] hx) h
  have : Fin.snoc ![x] y = ![x, y] := Iff.mp List.ofFn_inj rfl
  

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
h : 1 < Module.rank K V
x : V
hx : x ≠ 0
y : V
hy : LinearIndependent K (Fin.snoc ![x] y)
this : Fin.snoc ![x] y = ![x, y]
⊢ ∃ y, LinearIndependent K ![x, y]

Next tactic:
rw [this] at hy
/-- Given a nonzero vector in a space of dimension `> 1`, one may find another vector linearly
independent of the first one. -/
theorem exists_linearIndependent_pair_of_one_lt_rank
    (h : 1 < Module.rank K V) {x : V} (hx : x ≠ 0) :
    ∃ y, LinearIndependent K ![x, y] := by
  obtain ⟨y, hy⟩ := exists_linearIndependent_snoc_of_lt_rank (linearIndependent_unique ![x] hx) h
  have : Fin.snoc ![x] y = ![x, y] := Iff.mp List.ofFn_inj rfl
  rw [this] at hy
  

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✝⁹ : DivisionRing K
inst✝⁸ : Ring R
inst✝⁷ : StrongRankCondition R
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module K V
inst✝⁴ : Module R V
inst✝³ : AddCommGroup V'
inst✝² : Module K V'
inst✝¹ : AddCommGroup V₁
inst✝ : Module K V₁
h : 1 < Module.rank K V
x : V
hx : x ≠ 0
y : V
hy : LinearIndependent K ![x, y]
this : Fin.snoc ![x] y = ![x, y]
⊢ ∃ y, LinearIndependent K ![x, y]

Next tactic:
exact ⟨y, hy⟩
/-- This is mostly an auxiliary lemma for `Submodule.rank_sup_add_rank_inf_eq`. -/
theorem rank_add_rank_split (db : V₂ →ₗ[K] V) (eb : V₃ →ₗ[K] V) (cd : V₁ →ₗ[K] V₂)
    (ce : V₁ →ₗ[K] V₃) (hde : ⊤ ≤ LinearMap.range db ⊔ LinearMap.range eb) (hgd : ker cd = ⊥)
    (eq : db.comp cd = eb.comp ce) (eq₂ : ∀ d e, db d = eb e → ∃ c, cd c = d ∧ ce c = e) :
    Module.rank K V + Module.rank K V₁ = Module.rank K V₂ + Module.rank K 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✝¹³ : DivisionRing K
inst✝¹² : Ring R
inst✝¹¹ : StrongRankCondition R
inst✝¹⁰ : AddCommGroup V
inst✝⁹ : Module K V
inst✝⁸ : Module R V
inst✝⁷ : AddCommGroup V'
inst✝⁶ : Module K V'
inst✝⁵ : AddCommGroup V₁
inst✝⁴ : Module K V₁
inst✝³ : AddCommGroup V₂
inst✝² : Module K V₂
inst✝¹ : AddCommGroup V₃
inst✝ : Module K V₃
db : V₂ →ₗ[K] V
eb : V₃ →ₗ[K] V
cd : V₁ →ₗ[K] V₂
ce : V₁ →ₗ[K] V₃
hde : ⊤ ≤ LinearMap.range db ⊔ LinearMap.range eb
hgd : ker cd = ⊥
eq : db ∘ₗ cd = eb ∘ₗ ce
eq₂ : ∀ (d : V₂) (e : V₃), db d = eb e → ∃ c, cd c = d ∧ ce c = e
⊢ Module.rank K V + Module.rank K V₁ = Module.rank K V₂ + Module.rank K V₃

Next tactic:
have hf : Surjective (coprod db eb) := by rwa [← range_eq_top, range_coprod, eq_top_iff]