Theorem: mem_vectorSpan_iff_eq_weightedVSub
File: Mathlib/LinearAlgebra/AffineSpace/Combination.lean

tactic: constructor
state_before: k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
⊢ v ∈ vectorSpan k (Set.range p) ↔ ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: rcases isEmpty_or_nonempty ι with (hι | ⟨⟨i0⟩⟩)
state_before: case mp
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
⊢ v ∈ vectorSpan k (Set.range p) → ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: swap
state_before: case mp.inl
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
hι : IsEmpty ι
⊢ v ∈ vectorSpan k (Set.range p) → ∃ s w x, v = ↑(Finset.weightedVSub s p) w

case mp.inr.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
⊢ v ∈ vectorSpan k (Set.range p) → ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: rw [vectorSpan_range_eq_span_range_vsub_right k p i0, ← Set.image_univ,
  Finsupp.mem_span_image_iff_total]
state_before: case mp.inr.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
⊢ v ∈ vectorSpan k (Set.range p) → ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: rintro ⟨l, _, hv⟩
state_before: case mp.inr.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
⊢ (∃ l, l ∈ Finsupp.supported k k Set.univ ∧ ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v) →
    ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: use insert i0 l.support
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
⊢ ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: set w :=
  (l : ι → k) - Function.update (Function.const ι 0 : ι → k) i0 (∑ i in l.support, l i) with
  hwdef
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
⊢ ∃ w x, v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: use w
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
⊢ ∃ w x, v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: have hw : (∑ i in insert i0 l.support, w i) = 0 := by
  rw [hwdef]
  simp_rw [Pi.sub_apply, Finset.sum_sub_distrib,
    Finset.sum_update_of_mem (Finset.mem_insert_self _ _),
    Finset.sum_insert_of_eq_zero_if_not_mem Finsupp.not_mem_support_iff.1]
  simp only [Finsupp.mem_support_iff, ne_eq, Finset.mem_insert, true_or, not_true,
    Function.const_apply, Finset.sum_const_zero, add_zero, sub_self]
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
⊢ ∃ x, v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: use hw
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
⊢ ∃ x, v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: have hz : w i0 • (p i0 -ᵥ p i0 : V) = 0 := (vsub_self (p i0)).symm ▸ smul_zero _
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
⊢ v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: change (fun i => w i • (p i -ᵥ p i0 : V)) i0 = 0 at hz
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : w i0 • (p i0 -ᵥ p i0) = 0
⊢ v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: rw [Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero _ w p hw (p i0),
  Finset.weightedVSubOfPoint_apply, ← hv, Finsupp.total_apply,
  @Finset.sum_insert_zero _ _ l.support i0 _ _ _ hz]
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : (fun i => w i • (p i -ᵥ p i0)) i0 = 0
⊢ v = ↑(Finset.weightedVSub (insert i0 l.support) p) w

tactic: change (∑ i in l.support, l i • _) = _
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : (fun i => w i • (p i -ᵥ p i0)) i0 = 0
⊢ (Finsupp.sum l fun i a => a • (p i -ᵥ p i0)) = ∑ x in l.support, w x • (p x -ᵥ p i0)

tactic: congr with i
state_before: case mp.inr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : (fun i => w i • (p i -ᵥ p i0)) i0 = 0
⊢ ∑ i in l.support, ↑l i • (p i -ᵥ p i0) = ∑ x in l.support, w x • (p x -ᵥ p i0)

tactic: by_cases h : i = i0
state_before: case mp.inr.intro.intro.intro.e_f.h
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : (fun i => w i • (p i -ᵥ p i0)) i0 = 0
i : ι
⊢ ↑l i • (p i -ᵥ p i0) = w i • (p i -ᵥ p i0)

tactic: rw [hwdef]
state_before: k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
⊢ ∑ i in insert i0 l.support, w i = 0

tactic: simp_rw [Pi.sub_apply, Finset.sum_sub_distrib,
  Finset.sum_update_of_mem (Finset.mem_insert_self _ _),
  Finset.sum_insert_of_eq_zero_if_not_mem Finsupp.not_mem_support_iff.1]
state_before: k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
⊢ ∑ i in insert i0 l.support, (↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)) i = 0

tactic: simp only [Finsupp.mem_support_iff, ne_eq, Finset.mem_insert, true_or, not_true,
  Function.const_apply, Finset.sum_const_zero, add_zero, sub_self]
state_before: k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
⊢ ∑ x in l.support, ↑l x - (∑ x in l.support, ↑l x + ∑ x in insert i0 l.support \ {i0}, Function.const ι 0 x) = 0

tactic: simp [h]
state_before: case pos
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : (fun i => w i • (p i -ᵥ p i0)) i0 = 0
i : ι
h : i = i0
⊢ ↑l i • (p i -ᵥ p i0) = w i • (p i -ᵥ p i0)

tactic: simp [hwdef, h]
state_before: case neg
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
i0 : ι
l : ι →₀ k
left✝ : l ∈ Finsupp.supported k k Set.univ
hv : ↑(Finsupp.total ι V k fun i => p i -ᵥ p i0) l = v
w : (a : ι) → (fun x => k) a := ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hwdef : w = ↑l - Function.update (Function.const ι 0) i0 (∑ i in l.support, ↑l i)
hw : ∑ i in insert i0 l.support, w i = 0
hz : (fun i => w i • (p i -ᵥ p i0)) i0 = 0
i : ι
h : ¬i = i0
⊢ ↑l i • (p i -ᵥ p i0) = w i • (p i -ᵥ p i0)

tactic: rw [Set.range_eq_empty, vectorSpan_empty, Submodule.mem_bot]
state_before: case mp.inl
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
hι : IsEmpty ι
⊢ v ∈ vectorSpan k (Set.range p) → ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: rintro rfl
state_before: case mp.inl
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
hι : IsEmpty ι
⊢ v = 0 → ∃ s w x, v = ↑(Finset.weightedVSub s p) w

tactic: use ∅
state_before: case mp.inl
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
p : ι → P
hι : IsEmpty ι
⊢ ∃ s w x, 0 = ↑(Finset.weightedVSub s p) w

tactic: simp
state_before: case mp.inl
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
p : ι → P
hι : IsEmpty ι
⊢ ∃ w x, 0 = ↑(Finset.weightedVSub ∅ p) w

tactic: rintro ⟨s, w, hw, rfl⟩
state_before: case mpr
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
v : V
p : ι → P
⊢ (∃ s w x, v = ↑(Finset.weightedVSub s p) w) → v ∈ vectorSpan k (Set.range p)

tactic: exact weightedVSub_mem_vectorSpan hw p
state_before: case mpr.intro.intro.intro
k : Type u_3
V : Type u_2
P : Type u_4
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_1
p : ι → P
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
⊢ ↑(Finset.weightedVSub s p) w ∈ vectorSpan k (Set.range p)