Theorem: linearIndependent_of_top_le_span_of_card_eq_finrank
File: Mathlib/LinearAlgebra/Finrank.lean

tactic: by_contra gx_ne_zero
state_before: K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
⊢ g i = 0

tactic: refine' not_le_of_gt (span_lt_top_of_card_lt_finrank
  (show (b '' (Set.univ \ {i})).toFinset.card < finrank K V from _)) _
state_before: K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
⊢ False

tactic: refine' spans.trans (span_le.mpr _)
state_before: case refine'_2
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
⊢ ⊤ ≤ span K (b '' (Set.univ \ {i}))

tactic: rintro _ ⟨j, rfl, rfl⟩
state_before: case refine'_2
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
⊢ Set.range b ⊆ ↑(span K (b '' (Set.univ \ {i})))

tactic: by_cases j_eq : j = i
state_before: case refine'_2.intro.refl
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
⊢ b j ∈ ↑(span K (b '' (Set.univ \ {i})))

tactic: swap
state_before: case pos
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ b j ∈ ↑(span K (b '' (Set.univ \ {i})))

case neg
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : ¬j = i
⊢ b j ∈ ↑(span K (b '' (Set.univ \ {i})))

tactic: rw [j_eq, SetLike.mem_coe, show b i = -((g i)⁻¹ • (s.erase i).sum fun j => g j • b j) from _]
state_before: case pos
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ b j ∈ ↑(span K (b '' (Set.univ \ {i})))

tactic: apply eq_neg_of_add_eq_zero_left
state_before: K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ b i = -((g i)⁻¹ • Finset.sum (Finset.erase s i) fun j => g j • b j)

tactic: calc
  (b i + (g i)⁻¹ • (s.erase i).sum fun j => g j • b j) =
      (g i)⁻¹ • (g i • b i + (s.erase i).sum fun j => g j • b j) :=
    by rw [smul_add, ← mul_smul, inv_mul_cancel gx_ne_zero, one_smul]
  _ = (g i)⁻¹ • (0 : V) := (congr_arg _ ?_)
  _ = 0 := smul_zero _
state_before: case h
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ (b i + (g i)⁻¹ • Finset.sum (Finset.erase s i) fun j => g j • b j) = 0

tactic: rwa [← Finset.insert_erase i_mem_s, Finset.sum_insert (Finset.not_mem_erase _ _)] at dependent
state_before: case h
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ (g i • b i + Finset.sum (Finset.erase s i) fun j => g j • b j) = 0

tactic: calc
  (b '' (Set.univ \ {i})).toFinset.card = ((Set.univ \ {i}).toFinset.image b).card := by
    rw [Set.toFinset_card, Fintype.card_ofFinset]
  _ ≤ (Set.univ \ {i}).toFinset.card := Finset.card_image_le
  _ = (Finset.univ.erase i).card := (congr_arg Finset.card (Finset.ext (by simp [and_comm])))
  _ < Finset.univ.card := (Finset.card_erase_lt_of_mem (Finset.mem_univ i))
  _ = finrank K V := card_eq
state_before: case refine'_1
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
⊢ Finset.card (Set.toFinset (b '' (Set.univ \ {i}))) < finrank K V

tactic: rw [Set.toFinset_card, Fintype.card_ofFinset]
state_before: K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
⊢ Finset.card (Set.toFinset (b '' (Set.univ \ {i}))) = Finset.card (Finset.image b (Set.toFinset (Set.univ \ {i})))

tactic: simp [and_comm]
state_before: K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
⊢ ∀ (a : ι), a ∈ Set.toFinset (Set.univ \ {i}) ↔ a ∈ Finset.erase Finset.univ i

tactic: refine' subset_span ⟨j, (Set.mem_diff _).mpr ⟨Set.mem_univ _, _⟩, rfl⟩
state_before: case neg
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : ¬j = i
⊢ b j ∈ ↑(span K (b '' (Set.univ \ {i})))

tactic: exact mt Set.mem_singleton_iff.mp j_eq
state_before: case neg
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : ¬j = i
⊢ ¬j ∈ {i}

tactic: refine' neg_mem (smul_mem _ _ (sum_mem fun k hk => _))
state_before: case pos
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ -((g i)⁻¹ • Finset.sum (Finset.erase s i) fun j => g j • b j) ∈ span K (b '' (Set.univ \ {i}))

tactic: obtain ⟨k_ne_i, _⟩ := Finset.mem_erase.mp hk
state_before: case pos
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
k : ι
hk : k ∈ Finset.erase s i
⊢ g k • b k ∈ span K (b '' (Set.univ \ {i}))

tactic: refine' smul_mem _ _ (subset_span ⟨k, _, rfl⟩)
state_before: case pos.intro
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
k : ι
hk : k ∈ Finset.erase s i
k_ne_i : k ≠ i
right✝ : k ∈ s
⊢ g k • b k ∈ span K (b '' (Set.univ \ {i}))

tactic: simp_all only [Set.mem_univ, Set.mem_diff, Set.mem_singleton_iff]
state_before: case pos.intro
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
k : ι
hk : k ∈ Finset.erase s i
k_ne_i : k ≠ i
right✝ : k ∈ s
⊢ k ∈ Set.univ \ {i}

tactic: rw [smul_add, ← mul_smul, inv_mul_cancel gx_ne_zero, one_smul]
state_before: K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
ι : Type u_1
inst✝ : Fintype ι
b : ι → V
spans : ⊤ ≤ span K (Set.range b)
card_eq : Fintype.card ι = finrank K V
s : Finset ι
g : ι → K
dependent : (Finset.sum s fun i => g i • b i) = 0
i : ι
i_mem_s : i ∈ s
gx_ne_zero : ¬g i = 0
j : ι
j_eq : j = i
⊢ (b i + (g i)⁻¹ • Finset.sum (Finset.erase s i) fun j => g j • b j) =
    (g i)⁻¹ • (g i • b i + Finset.sum (Finset.erase s i) fun j => g j • b j)