Theorem: weightedVSub_mem_vectorSpan_pair
File: Mathlib/LinearAlgebra/AffineSpace/Independent.lean

tactic: rw [mem_vectorSpan_pair]
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
⊢ ↑(Finset.weightedVSub s p) w ∈
      vectorSpan k {↑(Finset.affineCombination k s p) w₁, ↑(Finset.affineCombination k s p) w₂} ↔
    ∃ r, ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)

tactic: refine' ⟨fun h => _, fun h => _⟩
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
⊢ (∃ r,
      r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) =
        ↑(Finset.weightedVSub s p) w) ↔
    ∃ r, ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)

tactic: rcases h with ⟨r, hr⟩
state_before: case refine'_1
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h✝ : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
h :
  ∃ r, r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w
⊢ ∃ r, ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)

tactic: refine' ⟨r, fun i hi => _⟩
state_before: case refine'_1.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr : r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w
⊢ ∃ r, ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)

tactic: rw [s.affineCombination_vsub, ← s.weightedVSub_const_smul, ← sub_eq_zero, ← map_sub] at hr
state_before: case refine'_1.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr : r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w
i : ι
hi : i ∈ s
⊢ w i = r * (w₁ i - w₂ i)

tactic: have hw' : (∑ j in s, (r • (w₁ - w₂) - w) j) = 0 := by
  simp_rw [Pi.sub_apply, Pi.smul_apply, Pi.sub_apply, smul_sub, Finset.sum_sub_distrib, ←
    Finset.smul_sum, hw, hw₁, hw₂, sub_self]
state_before: case refine'_1.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr✝ : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂)) = ↑(Finset.weightedVSub s p) w
hr : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂) - w) = 0
i : ι
hi : i ∈ s
⊢ w i = r * (w₁ i - w₂ i)

tactic: have hr' := h s _ hw' hr i hi
state_before: case refine'_1.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr✝ : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂)) = ↑(Finset.weightedVSub s p) w
hr : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂) - w) = 0
i : ι
hi : i ∈ s
hw' : ∑ j in s, (r • (w₁ - w₂) - w) j = 0
⊢ w i = r * (w₁ i - w₂ i)

tactic: rw [eq_comm, ← sub_eq_zero, ← smul_eq_mul]
state_before: case refine'_1.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr✝ : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂)) = ↑(Finset.weightedVSub s p) w
hr : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂) - w) = 0
i : ι
hi : i ∈ s
hw' : ∑ j in s, (r • (w₁ - w₂) - w) j = 0
hr' : (r • (w₁ - w₂) - w) i = 0
⊢ w i = r * (w₁ i - w₂ i)

tactic: exact hr'
state_before: case refine'_1.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr✝ : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂)) = ↑(Finset.weightedVSub s p) w
hr : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂) - w) = 0
i : ι
hi : i ∈ s
hw' : ∑ j in s, (r • (w₁ - w₂) - w) j = 0
hr' : (r • (w₁ - w₂) - w) i = 0
⊢ r • (w₁ i - w₂ i) - w i = 0

tactic: simp_rw [Pi.sub_apply, Pi.smul_apply, Pi.sub_apply, smul_sub, Finset.sum_sub_distrib, ←
  Finset.smul_sum, hw, hw₁, hw₂, sub_self]
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr✝ : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂)) = ↑(Finset.weightedVSub s p) w
hr : ↑(Finset.weightedVSub s p) (r • (w₁ - w₂) - w) = 0
i : ι
hi : i ∈ s
⊢ ∑ j in s, (r • (w₁ - w₂) - w) j = 0

tactic: rcases h with ⟨r, hr⟩
state_before: case refine'_2
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h✝ : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
h : ∃ r, ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)
⊢ ∃ r, r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w

tactic: refine' ⟨r, _⟩
state_before: case refine'_2.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr : ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)
⊢ ∃ r, r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w

tactic: let w' i := r * (w₁ i - w₂ i)
state_before: case refine'_2.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr : ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)
⊢ r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w

tactic: change ∀ i ∈ s, w i = w' i at hr
state_before: case refine'_2.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
hr : ∀ (i : ι), i ∈ s → w i = r * (w₁ i - w₂ i)
w' : ι → k := fun i => r * (w₁ i - w₂ i)
⊢ r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w

tactic: rw [s.weightedVSub_congr hr fun _ _ => rfl, s.affineCombination_vsub, ←
  s.weightedVSub_const_smul]
state_before: case refine'_2.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
w' : ι → k := fun i => r * (w₁ i - w₂ i)
hr : ∀ (i : ι), i ∈ s → w i = w' i
⊢ r • (↑(Finset.affineCombination k s p) w₁ -ᵥ ↑(Finset.affineCombination k s p) w₂) = ↑(Finset.weightedVSub s p) w

tactic: congr
state_before: case refine'_2.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
h : AffineIndependent k p
w w₁ w₂ : ι → k
s : Finset ι
hw : ∑ i in s, w i = 0
hw₁ : ∑ i in s, w₁ i = 1
hw₂ : ∑ i in s, w₂ i = 1
r : k
w' : ι → k := fun i => r * (w₁ i - w₂ i)
hr : ∀ (i : ι), i ∈ s → w i = w' i
⊢ ↑(Finset.weightedVSub s p) (r • (w₁ - w₂)) = ↑(Finset.weightedVSub s fun x => p x) fun i => w' i