l3lab/ntp-mathlib huggingface dataset:
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
⊢ ∀ i ∈ s, w i = 0

Next tactic:
let p' : { y // y ≠ i } → P := fun x => p x
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
⊢ ∀ i ∈ s, w i = 0

Next tactic:
by_cases his : i ∈ s ∧ w i ≠ 0
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · 

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
⊢ ∀ i ∈ s, w i = 0

Next tactic:
refine' False.elim (hi _)
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
⊢ p i ∈ affineSpan k (p '' {x | x ≠ i})

Next tactic:
let wm : ι → k := -(w i)⁻¹ • w
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
⊢ p i ∈ affineSpan k (p '' {x | x ≠ i})

Next tactic:
have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by 

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
⊢ (weightedVSub s p) wm = 0

Next tactic:
simp [hs]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
⊢ p i ∈ affineSpan k (p '' {x | x ≠ i})

Next tactic:
have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by 

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
⊢ ∑ i in s, wm i = 0

Next tactic:
simp [← Finset.mul_sum, hw]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ i in s, wm i = 0
⊢ p i ∈ affineSpan k (p '' {x | x ≠ i})

Next tactic:
have hwmi : wm i = -1 := by simp [his.2]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by 

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ i in s, wm i = 0
⊢ wm i = -1

Next tactic:
simp [his.2]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by simp [his.2]
      

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ i in s, wm i = 0
hwmi : wm i = -1
⊢ p i ∈ affineSpan k (p '' {x | x ≠ i})

Next tactic:
let w' : { y // y ≠ i } → k := fun x => wm x
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by simp [his.2]
      let w' : { y // y ≠ i } → k := fun x => wm x
      

Proof state:
case pos
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ i in s, wm i = 0
hwmi : wm i = -1
w' : { y // y ≠ i } → k := fun x => wm ↑x
⊢ p i ∈ affineSpan k (p '' {x | x ≠ i})

Next tactic:
have hw' : ∑ x in s', w' x = 1 := by
        simp_rw [Finset.sum_subtype_eq_sum_filter]
        rw [← s.sum_filter_add_sum_filter_not (· ≠ i)] at hwm
        simp_rw [Classical.not_not] at hwm
        -- Porting note: this `erw` used to be part of the `simp_rw`
        erw [Finset.filter_eq'] at hwm
        simp_rw [if_pos his.1, Finset.sum_singleton, hwmi, ← sub_eq_add_neg, sub_eq_zero] at hwm
        exact hwm
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by simp [his.2]
      let w' : { y // y ≠ i } → k := fun x => wm x
      have hw' : ∑ x in s', w' x = 1 := by
        

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ i in s, wm i = 0
hwmi : wm i = -1
w' : { y // y ≠ i } → k := fun x => wm ↑x
⊢ ∑ x in s', w' x = 1

Next tactic:
simp_rw [Finset.sum_subtype_eq_sum_filter]
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by simp [his.2]
      let w' : { y // y ≠ i } → k := fun x => wm x
      have hw' : ∑ x in s', w' x = 1 := by
        simp_rw [Finset.sum_subtype_eq_sum_filter]
        

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ i in s, wm i = 0
hwmi : wm i = -1
w' : { y // y ≠ i } → k := fun x => wm ↑x
⊢ ∑ x in filter (fun x => x ≠ i) s, (-(w i)⁻¹ • w) x = 1

Next tactic:
rw [← s.sum_filter_add_sum_filter_not (· ≠ i)] at hwm
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by simp [his.2]
      let w' : { y // y ≠ i } → k := fun x => wm x
      have hw' : ∑ x in s', w' x = 1 := by
        simp_rw [Finset.sum_subtype_eq_sum_filter]
        rw [← s.sum_filter_add_sum_filter_not (· ≠ i)] at hwm
        

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwm : ∑ x in filter (fun x => x ≠ i) s, wm x + ∑ x in filter (fun x => ¬x ≠ i) s, wm x = 0
hwmi : wm i = -1
w' : { y // y ≠ i } → k := fun x => wm ↑x
⊢ ∑ x in filter (fun x => x ≠ i) s, (-(w i)⁻¹ • w) x = 1

Next tactic:
simp_rw [Classical.not_not] at hwm
/-- If all but one point of a family are affinely independent, and that point does not lie in
the affine span of that family, the family is affinely independent. -/
theorem AffineIndependent.affineIndependent_of_not_mem_span {p : ι → P} {i : ι}
    (ha : AffineIndependent k fun x : { y // y ≠ i } => p x)
    (hi : p i ∉ affineSpan k (p '' { x | x ≠ i })) : AffineIndependent k p := by
  classical
    intro s w hw hs
    let s' : Finset { y // y ≠ i } := s.subtype (· ≠ i)
    let p' : { y // y ≠ i } → P := fun x => p x
    by_cases his : i ∈ s ∧ w i ≠ 0
    · refine' False.elim (hi _)
      let wm : ι → k := -(w i)⁻¹ • w
      have hms : s.weightedVSub p wm = (0 : V) := by simp [hs]
      have hwm : ∑ i in s, wm i = 0 := by simp [← Finset.mul_sum, hw]
      have hwmi : wm i = -1 := by simp [his.2]
      let w' : { y // y ≠ i } → k := fun x => wm x
      have hw' : ∑ x in s', w' x = 1 := by
        simp_rw [Finset.sum_subtype_eq_sum_filter]
        rw [← s.sum_filter_add_sum_filter_not (· ≠ i)] at hwm
        simp_rw [Classical.not_not] at hwm
        -- Porting note: this `erw` used to be part of the `simp_rw`
        

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : DivisionRing k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
ι : Type u_4
p : ι → P
i : ι
ha : AffineIndependent k fun x => p ↑x
hi : p i ∉ affineSpan k (p '' {x | x ≠ i})
s : Finset ι
w : ι → k
hw : ∑ i in s, w i = 0
hs : (weightedVSub s p) w = 0
s' : Finset { y // y ≠ i } := Finset.subtype (fun x => x ≠ i) s
p' : { y // y ≠ i } → P := fun x => p ↑x
his : i ∈ s ∧ w i ≠ 0
wm : ι → k := -(w i)⁻¹ • w
hms : (weightedVSub s p) wm = 0
hwmi : wm i = -1
w' : { y // y ≠ i } → k := fun x => wm ↑x
hwm : ∑ x in filter (fun x => x ≠ i) s, (-(w i)⁻¹ • w) x + ∑ x in filter (fun x => x = i) s, (-(w i)⁻¹ • w) x = 0
⊢ ∑ x in filter (fun x => x ≠ i) s, (-(w i)⁻¹ • w) x = 1

Next tactic:
erw [Finset.filter_eq'] at hwm