/-- Convex **strict Jensen inequality**.

If the function is strictly convex, the weights are strictly positive and the indexed family of
points is non-constant, then Jensen's inequality is strict.

See also `StrictConvexOn.map_sum_eq_iff`. -/
lemma StrictConvexOn.map_sum_lt (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i)
    (h₁ : ∑ i in t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) (hp : ∃ j ∈ t, ∃ k ∈ t, p j ≠ p k) :
    f (∑ i in t, w i • p i) < ∑ i in t, w i • f (p i) := by
  classical
  obtain ⟨j, hj, k, hk, hjk⟩ := hp
  -- We replace `t` by `t \ {j, k}`
  have : k ∈ t.erase j := mem_erase.2 ⟨ne_of_apply_ne _ hjk.symm, hk⟩
  let u := (t.erase j).erase k
  have hj : j ∉ u := by simp
  have hk : k ∉ u := by simp
  have ht : t = (u.cons k hk).cons j (mem_cons.not.2 $ not_or_intro (ne_of_apply_ne _ hjk) hj)
  · simp [insert_erase this, insert_erase ‹j ∈ t›, *]
  clear_value u
  subst ht
  simp only [sum_cons]
  have := h₀ j $ by simp
  have := h₀ k $ by simp
  let c := w j + w k
  have hc : w j / c + w k / c = 1 := by field_simp
  have hcj : c * (w j / c) = w j := by field_simp; ring
  have hck : c * (w k / c) = w k := by field_simp; ring
  calc f (w j • p j + (w k • p k + ∑ x in u, w x • p x))
    _ = f (c • ((w j / c) • p j + (w k / c) • p k) + ∑ x in u, w x • p x) := by
      rw [smul_add, ← mul_smul, ← mul_smul, hcj, hck, add_assoc]
    _ ≤ c • f ((w j / c) • p j + (w k / c) • p k) + ∑ x in u, w x • f (p x) :=
      -- apply the usual Jensen's inequality wrt the weighted average of the two distinguished
      -- points and all the other points
        hf.convexOn.map_add_sum_le (fun i hi ↦ (h₀ _ $ by simp [hi]).le)
          (by simpa [-cons_eq_insert, ← add_assoc] using h₁)
          (forall_of_forall_cons $ forall_of_forall_cons hmem) (by positivity) $ by
           refine hf.1 (hmem _ $ by simp) (hmem _ $ by simp) ?_ ?_ hc <;> positivity
    _ < c • ((w j / c) • f (p j) + (w k / c) • f (p k)) + ∑ x in u, w x • f (p x) := by
      -- then apply the definition of strict convexity for the two distinguished points
      gcongr; refine hf.2 (hmem _ $ by simp) (hmem _ $ by simp) hjk ?_ ?_ hc <;> positivity
    _ = (w j • f (p j) + w k • f (p k)) + ∑ x in u, w x • f (p x) := by
      

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
β : Type u_4
ι : Type u_5
inst✝⁵ : LinearOrderedField 𝕜
inst✝⁴ : AddCommGroup E
inst✝³ : OrderedAddCommGroup β
inst✝² : Module 𝕜 E
inst✝¹ : Module 𝕜 β
inst✝ : OrderedSMul 𝕜 β
s : Set E
f : E → β
w : ι → 𝕜
p : ι → E
v : 𝕜
q : E
hf : StrictConvexOn 𝕜 s f
j k : ι
hjk : p j ≠ p k
u : Finset ι
hj✝ : j ∉ u
hk✝ : k ∉ u
h₀ : ∀ i ∈ cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝), 0 < w i
h₁ : ∑ i in cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝), w i = 1
hmem : ∀ i ∈ cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝), p i ∈ s
hj : j ∈ cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝)
hk : k ∈ cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝)
this✝¹ : k ∈ erase (cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝)) j
this✝ : 0 < w j
this : 0 < w k
c : 𝕜 := w j + w k
hc : w j / c + w k / c = 1
hcj : c * (w j / c) = w j
hck : c * (w k / c) = w k
⊢ c • ((w j / c) • f (p j) + (w k / c) • f (p k)) + ∑ x in u, w x • f (p x) =
    w j • f (p j) + w k • f (p k) + ∑ x in u, w x • f (p x)

Next tactic:
rw [smul_add, ← mul_smul, ← mul_smul, hcj, hck]