Theorem: EuclideanGeometry.dist_affineCombination
File: Mathlib/Geometry/Euclidean/Basic.lean

tactic: have a₁ := s.affineCombination ℝ p w₁
state_before: V : Type ?u.16219
P : Type ?u.16222
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type ?u.16493
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
⊢ Sort ?u.16606

tactic: have a₂ := s.affineCombination ℝ p w₂
state_before: V : Type ?u.16219
P : Type ?u.16222
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type ?u.16493
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
a₁ : (fun a => P) w₁
⊢ Sort ?u.16606

tactic: exact dist a₁ a₂ * dist a₁ a₂ = (-∑ i₁ in s, ∑ i₂ in s,
  (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2
state_before: V : Type ?u.16219
P : Type ?u.16222
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type ?u.16493
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
a₁ : (fun a => P) w₁
a₂ : (fun a => P) w₂
⊢ Sort ?u.16606

tactic: dsimp only
state_before: V : Type u_3
P : Type u_2
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type u_1
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
⊢ let_fun a₁ := ↑(Finset.affineCombination ℝ s p) w₁;
  let_fun a₂ := ↑(Finset.affineCombination ℝ s p) w₂;
  dist a₁ a₂ * dist a₁ a₂ =
    (-∑ i₁ in s, ∑ i₂ in s, (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2

tactic: rw [dist_eq_norm_vsub V (s.affineCombination ℝ p w₁) (s.affineCombination ℝ p w₂), ←
  @inner_self_eq_norm_mul_norm ℝ, Finset.affineCombination_vsub]
state_before: V : Type u_3
P : Type u_2
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type u_1
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
⊢ dist (↑(Finset.affineCombination ℝ s p) w₁) (↑(Finset.affineCombination ℝ s p) w₂) *
      dist (↑(Finset.affineCombination ℝ s p) w₁) (↑(Finset.affineCombination ℝ s p) w₂) =
    (-∑ i₁ in s, ∑ i₂ in s, (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2

tactic: have h : (∑ i in s, (w₁ - w₂) i) = 0 := by
  simp_rw [Pi.sub_apply, Finset.sum_sub_distrib, h₁, h₂, sub_self]
state_before: V : Type u_3
P : Type u_2
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type u_1
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
⊢ ↑IsROrC.re (inner (↑(Finset.weightedVSub s p) (w₁ - w₂)) (↑(Finset.weightedVSub s p) (w₁ - w₂))) =
    (-∑ i₁ in s, ∑ i₂ in s, (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2

tactic: exact inner_weightedVSub p h p h
state_before: V : Type u_3
P : Type u_2
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type u_1
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
h : ∑ i in s, (w₁ - w₂) i = 0
⊢ ↑IsROrC.re (inner (↑(Finset.weightedVSub s p) (w₁ - w₂)) (↑(Finset.weightedVSub s p) (w₁ - w₂))) =
    (-∑ i₁ in s, ∑ i₂ in s, (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2

tactic: simp_rw [Pi.sub_apply, Finset.sum_sub_distrib, h₁, h₂, sub_self]
state_before: V : Type u_3
P : Type u_2
inst✝³ : NormedAddCommGroup V
inst✝² : InnerProductSpace ℝ V
inst✝¹ : MetricSpace P
inst✝ : NormedAddTorsor V P
ι : Type u_1
s : Finset ι
w₁ w₂ : ι → ℝ
p : ι → P
h₁ : ∑ i in s, w₁ i = 1
h₂ : ∑ i in s, w₂ i = 1
⊢ ∑ i in s, (w₁ - w₂) i = 0