l3lab/ntp-mathlib huggingface dataset:
/-- The value of `weightedVSub`, where the given points are equal and the sum of the weights
is 0. -/
@[simp]
theorem weightedVSub_apply_const (w : ι → k) (p : P) (h : ∑ i in s, w i = 0) :
    s.weightedVSub (fun _ => p) w = 0 := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : P
h : ∑ i in s, w i = 0
⊢ (weightedVSub s fun x => p) w = 0

Next tactic:
rw [weightedVSub, weightedVSubOfPoint_apply_const, h, zero_smul]
/-- The `weightedVSub` for an empty set is 0. -/
@[simp]
theorem weightedVSub_empty (w : ι → k) (p : ι → P) : (∅ : Finset ι).weightedVSub p w = (0 : V) := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
⊢ (weightedVSub ∅ p) w = 0

Next tactic:
simp [weightedVSub_apply]
/-- A weighted sum of pairwise subtractions, where the point on the right is constant and the
sum of the weights is 0. -/
theorem sum_smul_vsub_const_eq_weightedVSub (w : ι → k) (p₁ : ι → P) (p₂ : P)
    (h : ∑ i in s, w i = 0) : (∑ i in s, w i • (p₁ i -ᵥ p₂)) = s.weightedVSub p₁ w := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p₁ : ι → P
p₂ : P
h : ∑ i in s, w i = 0
⊢ ∑ i in s, w i • (p₁ i -ᵥ p₂) = (weightedVSub s p₁) w

Next tactic:
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, sub_zero]
/-- A weighted sum of pairwise subtractions, where the point on the left is constant and the
sum of the weights is 0. -/
theorem sum_smul_const_vsub_eq_neg_weightedVSub (w : ι → k) (p₂ : ι → P) (p₁ : P)
    (h : ∑ i in s, w i = 0) : (∑ i in s, w i • (p₁ -ᵥ p₂ i)) = -s.weightedVSub p₂ w := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p₂ : ι → P
p₁ : P
h : ∑ i in s, w i = 0
⊢ ∑ i in s, w i • (p₁ -ᵥ p₂ i) = -(weightedVSub s p₂) w

Next tactic:
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, zero_sub]
/-- A weighted sum of the results of subtracting a default base point
from the given points, added to that base point, as an affine map on
the weights.  This is intended to be used when the sum of the weights
is 1, in which case it is an affine combination (barycenter) of the
points with the given weights; that condition is specified as a
hypothesis on those lemmas that require it. -/
def affineCombination (p : ι → P) : (ι → k) →ᵃ[k] P
    where
  toFun w := s.weightedVSubOfPoint p (Classical.choice S.nonempty) w +ᵥ Classical.choice S.nonempty
  linear := s.weightedVSub p
  map_vadd' w₁ w₂ := by 

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
p : ι → P
w₁ w₂ : ι → k
⊢ (fun w => (weightedVSubOfPoint s p (Classical.choice (_ : Nonempty P))) w +ᵥ Classical.choice (_ : Nonempty P))
      (w₂ +ᵥ w₁) =
    (weightedVSub s p) w₂ +ᵥ
      (fun w => (weightedVSubOfPoint s p (Classical.choice (_ : Nonempty P))) w +ᵥ Classical.choice (_ : Nonempty P)) w₁

Next tactic:
simp_rw [vadd_vadd, weightedVSub, vadd_eq_add, LinearMap.map_add]
/-- The value of `affineCombination`, where the given points are equal. -/
@[simp]
theorem affineCombination_apply_const (w : ι → k) (p : P) (h : ∑ i in s, w i = 1) :
    s.affineCombination k (fun _ => p) w = p := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : P
h : ∑ i in s, w i = 1
⊢ (affineCombination k s fun x => p) w = p

Next tactic:
rw [affineCombination_apply, s.weightedVSubOfPoint_apply_const, h, one_smul, vsub_vadd]
/-- `affineCombination` gives equal results for two families of weights and two families of
points that are equal on `s`. -/
theorem affineCombination_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
    (hp : ∀ i ∈ s, p₁ i = p₂ i) : s.affineCombination k p₁ w₁ = s.affineCombination k p₂ w₂ := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w₁ w₂ : ι → k
hw : ∀ i ∈ s, w₁ i = w₂ i
p₁ p₂ : ι → P
hp : ∀ i ∈ s, p₁ i = p₂ i
⊢ (affineCombination k s p₁) w₁ = (affineCombination k s p₂) w₂

Next tactic:
simp_rw [affineCombination_apply, s.weightedVSubOfPoint_congr hw hp]
/-- Adding a `weightedVSub` to an `affineCombination`. -/
theorem weightedVSub_vadd_affineCombination (w₁ w₂ : ι → k) (p : ι → P) :
    s.weightedVSub p w₁ +ᵥ s.affineCombination k p w₂ = s.affineCombination k p (w₁ + w₂) := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w₁ w₂ : ι → k
p : ι → P
⊢ (weightedVSub s p) w₁ +ᵥ (affineCombination k s p) w₂ = (affineCombination k s p) (w₁ + w₂)

Next tactic:
rw [← vadd_eq_add, AffineMap.map_vadd, affineCombination_linear]
/-- Subtracting two `affineCombination`s. -/
theorem affineCombination_vsub (w₁ w₂ : ι → k) (p : ι → P) :
    s.affineCombination k p w₁ -ᵥ s.affineCombination k p w₂ = s.weightedVSub p (w₁ - w₂) := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w₁ w₂ : ι → k
p : ι → P
⊢ (affineCombination k s p) w₁ -ᵥ (affineCombination k s p) w₂ = (weightedVSub s p) (w₁ - w₂)

Next tactic:
rw [← AffineMap.linearMap_vsub, affineCombination_linear, vsub_eq_sub]
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
⊢ (affineCombination k (attach s) f) (w ∘ f) = (affineCombination k (image f univ) id) w

Next tactic:
simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
⊢ ∑ x in attach s, w (f x) • (f x -ᵥ Classical.choice (_ : Nonempty P)) =
    ∑ x in image f univ, w x • (x -ᵥ Classical.choice (_ : Nonempty P))

Next tactic:
let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
⊢ ∑ x in attach s, w (f x) • (f x -ᵥ Classical.choice (_ : Nonempty P)) =
    ∑ x in image f univ, w x • (x -ᵥ Classical.choice (_ : Nonempty P))

Next tactic:
let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
⊢ ∑ x in attach s, w (f x) • (f x -ᵥ Classical.choice (_ : Nonempty P)) =
    ∑ x in image f univ, w x • (x -ᵥ Classical.choice (_ : Nonempty P))

Next tactic:
change univ.sum g₁ = (image f univ).sum g₂
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  change univ.sum g₁ = (image f univ).sum g₂
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
⊢ Finset.sum univ g₁ = Finset.sum (image f univ) g₂

Next tactic:
have hgf : g₁ = g₂ ∘ f := by
    ext
    simp
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  change univ.sum g₁ = (image f univ).sum g₂
  have hgf : g₁ = g₂ ∘ f := by
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
⊢ g₁ = g₂ ∘ f

Next tactic:
ext
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  change univ.sum g₁ = (image f univ).sum g₂
  have hgf : g₁ = g₂ ∘ f := by
    ext
    

Proof state:
case h
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
x✝ : { x // x ∈ s }
⊢ g₁ x✝ = (g₂ ∘ f) x✝

Next tactic:
simp
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  change univ.sum g₁ = (image f univ).sum g₂
  have hgf : g₁ = g₂ ∘ f := by
    ext
    simp
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
hgf : g₁ = g₂ ∘ f
⊢ Finset.sum univ g₁ = Finset.sum (image f univ) g₂

Next tactic:
rw [hgf, sum_image]
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  change univ.sum g₁ = (image f univ).sum g₂
  have hgf : g₁ = g₂ ∘ f := by
    ext
    simp
  rw [hgf, sum_image]
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
hgf : g₁ = g₂ ∘ f
⊢ Finset.sum univ (g₂ ∘ f) = ∑ x : { x // x ∈ s }, w (f x) • (f x -ᵥ Classical.choice (_ : Nonempty P))
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
hgf : g₁ = g₂ ∘ f
⊢ ∀ x ∈ univ, ∀ y ∈ univ, f x = f y → x = y

Next tactic:
simp only [Function.comp_apply]
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P)
    (hf : Function.Injective f) :
    s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by
  simp only [affineCombination, weightedVSubOfPoint_apply, id.def, vadd_right_cancel_iff,
    Function.comp_apply, AffineMap.coe_mk]
  let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty)
  let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty)
  change univ.sum g₁ = (image f univ).sum g₂
  have hgf : g₁ = g₂ ∘ f := by
    ext
    simp
  rw [hgf, sum_image]
  simp only [Function.comp_apply]
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
inst✝ : DecidableEq P
s : Finset P
w : P → k
f : { x // x ∈ s } → P
hf : Function.Injective f
g₁ : { x // x ∈ s } → V := fun i => w (f i) • (f i -ᵥ Classical.choice (_ : Nonempty P))
g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice (_ : Nonempty P))
hgf : g₁ = g₂ ∘ f
⊢ ∀ x ∈ univ, ∀ y ∈ univ, f x = f y → x = y

Next tactic:
exact fun _ _ _ _ hxy => hf hxy
theorem attach_affineCombination_coe (s : Finset P) (w : P → k) :
    s.attach.affineCombination k ((↑) : s → P) (w ∘ (↑)) = s.affineCombination k id w := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
s : Finset P
w : P → k
⊢ (affineCombination k (attach s) Subtype.val) (w ∘ Subtype.val) = (affineCombination k s id) w

Next tactic:
classical rw [attach_affineCombination_of_injective s w ((↑) : s → P) Subtype.coe_injective,
      univ_eq_attach, attach_image_val]
theorem attach_affineCombination_coe (s : Finset P) (w : P → k) :
    s.attach.affineCombination k ((↑) : s → P) (w ∘ (↑)) = s.affineCombination k id w := by
  classical 

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
s : Finset P
w : P → k
⊢ (affineCombination k (attach s) Subtype.val) (w ∘ Subtype.val) = (affineCombination k s id) w

Next tactic:
rw [attach_affineCombination_of_injective s w ((↑) : s → P) Subtype.coe_injective,
      univ_eq_attach, attach_image_val]
/-- Viewing a module as an affine space modelled on itself, a `weightedVSub` is just a linear
combination. -/
@[simp]
theorem weightedVSub_eq_linear_combination {ι} (s : Finset ι) {w : ι → k} {p : ι → V}
    (hw : s.sum w = 0) : s.weightedVSub p w = ∑ i in s, w i • p i := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι✝ : Type u_4
s✝ : Finset ι✝
ι₂ : Type u_5
s₂ : Finset ι₂
ι : Type u_6
s : Finset ι
w : ι → k
p : ι → V
hw : Finset.sum s w = 0
⊢ (weightedVSub s p) w = ∑ i in s, w i • p i

Next tactic:
simp [s.weightedVSub_apply, vsub_eq_sub, smul_sub, ← Finset.sum_smul, hw]
/-- Viewing a module as an affine space modelled on itself, affine combinations are just linear
combinations. -/
@[simp]
theorem affineCombination_eq_linear_combination (s : Finset ι) (p : ι → V) (w : ι → k)
    (hw : ∑ i in s, w i = 1) : s.affineCombination k p w = ∑ i in s, w i • p i := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s✝ : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
s : Finset ι
p : ι → V
w : ι → k
hw : ∑ i in s, w i = 1
⊢ (affineCombination k s p) w = ∑ i in s, w i • p i

Next tactic:
simp [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p hw 0]
/-- An `affineCombination` equals a point if that point is in the set
and has weight 1 and the other points in the set have weight 0. -/
@[simp]
theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s)
    (hwi : w i = 1) (hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0) : s.affineCombination k p w = p i := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
i : ι
his : i ∈ s
hwi : w i = 1
hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0
⊢ (affineCombination k s p) w = p i

Next tactic:
have h1 : ∑ i in s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his)
/-- An `affineCombination` equals a point if that point is in the set
and has weight 1 and the other points in the set have weight 0. -/
@[simp]
theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s)
    (hwi : w i = 1) (hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0) : s.affineCombination k p w = p i := by
  have h1 : ∑ i in s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his)
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
i : ι
his : i ∈ s
hwi : w i = 1
hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0
h1 : ∑ i in s, w i = 1
⊢ (affineCombination k s p) w = p i

Next tactic:
rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i),
    weightedVSubOfPoint_apply]
/-- An `affineCombination` equals a point if that point is in the set
and has weight 1 and the other points in the set have weight 0. -/
@[simp]
theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s)
    (hwi : w i = 1) (hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0) : s.affineCombination k p w = p i := by
  have h1 : ∑ i in s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his)
  rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i),
    weightedVSubOfPoint_apply]
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
i : ι
his : i ∈ s
hwi : w i = 1
hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0
h1 : ∑ i in s, w i = 1
⊢ ∑ i_1 in s, w i_1 • (p i_1 -ᵥ p i) +ᵥ p i = p i

Next tactic:
convert zero_vadd V (p i)
/-- An `affineCombination` equals a point if that point is in the set
and has weight 1 and the other points in the set have weight 0. -/
@[simp]
theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s)
    (hwi : w i = 1) (hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0) : s.affineCombination k p w = p i := by
  have h1 : ∑ i in s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his)
  rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i),
    weightedVSubOfPoint_apply]
  convert zero_vadd V (p i)
  

Proof state:
case h.e'_2.h.e'_5
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
i : ι
his : i ∈ s
hwi : w i = 1
hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0
h1 : ∑ i in s, w i = 1
⊢ ∑ i_1 in s, w i_1 • (p i_1 -ᵥ p i) = 0

Next tactic:
refine sum_eq_zero ?_
/-- An `affineCombination` equals a point if that point is in the set
and has weight 1 and the other points in the set have weight 0. -/
@[simp]
theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s)
    (hwi : w i = 1) (hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0) : s.affineCombination k p w = p i := by
  have h1 : ∑ i in s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his)
  rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i),
    weightedVSubOfPoint_apply]
  convert zero_vadd V (p i)
  refine sum_eq_zero ?_
  

Proof state:
case h.e'_2.h.e'_5
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
i : ι
his : i ∈ s
hwi : w i = 1
hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0
h1 : ∑ i in s, w i = 1
⊢ ∀ x ∈ s, w x • (p x -ᵥ p i) = 0

Next tactic:
intro i2 hi2