l3lab/ntp-mathlib huggingface dataset:
/-- 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 <;> 

Proof state:
case refine_2
𝕜 : 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
⊢ 0 ≤ w k / c

Next tactic:
positivity
/-- 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
      

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 • f ((w j / c) • p j + (w k / c) • p k) + ∑ x in u, w x • f (p x) <
    c • ((w j / c) • f (p j) + (w k / c) • f (p k)) + ∑ x in u, w x • f (p x)

Next tactic:
gcongr
/-- 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; 

Proof state:
case bc.a
𝕜 : 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
⊢ f ((w j / c) • p j + (w k / c) • p k) < (w j / c) • f (p j) + (w k / c) • f (p k)

Next tactic:
refine hf.2 (hmem _ $ by simp) (hmem _ $ by simp) hjk ?_ ?_ hc
/-- 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 

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
⊢ j ∈ cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝)

Next tactic:
simp
/-- 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 

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
⊢ k ∈ cons j (cons k u hk✝) (_ : j ∉ cons k u hk✝)

Next tactic:
simp
/-- 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 <;> 

Proof state:
case bc.a.refine_1
𝕜 : 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
⊢ 0 < w j / c

Next tactic:
positivity
/-- 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 <;> 

Proof state:
case bc.a.refine_2
𝕜 : 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
⊢ 0 < w k / c

Next tactic:
positivity
/-- A form of the **equality case of Jensen's equality**.

For a strictly convex function `f` and positive weights `w`, if
`f (∑ i in t, w i • p i) = ∑ i in t, w i • f (p i)`, then the points `p` are all equal.

See also `StrictConvexOn.map_sum_eq_iff`. -/
lemma StrictConvexOn.eq_of_le_map_sum (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i)
    (h₁ : ∑ i in t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s)
    (h_eq : ∑ i in t, w i • f (p i) ≤ f (∑ i in t, w i • p i)) :
    ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := 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 → β
t : Finset ι
w : ι → 𝕜
p : ι → E
v : 𝕜
q : E
hf : StrictConvexOn 𝕜 s f
h₀ : ∀ i ∈ t, 0 < w i
h₁ : ∑ i in t, w i = 1
hmem : ∀ i ∈ t, p i ∈ s
h_eq : ∑ i in t, w i • f (p i) ≤ f (∑ i in t, w i • p i)
⊢ ∀ ⦃j : ι⦄, j ∈ t → ∀ ⦃k : ι⦄, k ∈ t → p j = p k

Next tactic:
by_contra!
/-- A form of the **equality case of Jensen's equality**.

For a strictly convex function `f` and positive weights `w`, if
`f (∑ i in t, w i • p i) = ∑ i in t, w i • f (p i)`, then the points `p` are all equal.

See also `StrictConvexOn.map_sum_eq_iff`. -/
lemma StrictConvexOn.eq_of_le_map_sum (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i)
    (h₁ : ∑ i in t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s)
    (h_eq : ∑ i in t, w i • f (p i) ≤ f (∑ i in t, w i • p i)) :
    ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := by
  by_contra!; 

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 → β
t : Finset ι
w : ι → 𝕜
p : ι → E
v : 𝕜
q : E
hf : StrictConvexOn 𝕜 s f
h₀ : ∀ i ∈ t, 0 < w i
h₁ : ∑ i in t, w i = 1
hmem : ∀ i ∈ t, p i ∈ s
h_eq : ∑ i in t, w i • f (p i) ≤ f (∑ i in t, w i • p i)
this : ∃ j ∈ t, ∃ k ∈ t, p j ≠ p k
⊢ False

Next tactic:
exact h_eq.not_lt $ hf.map_sum_lt h₀ h₁ hmem this
/-- A form of the **equality case of Jensen's equality**.

For a strictly concave function `f` and positive weights `w`, if
`f (∑ i in t, w i • p i) = ∑ i in t, w i • f (p i)`, then the points `p` are all equal.

See also `StrictConcaveOn.map_sum_eq_iff`. -/
lemma StrictConcaveOn.eq_of_map_sum_eq (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i)
    (h₁ : ∑ i in t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s)
    (h_eq : f (∑ i in t, w i • p i) ≤ ∑ i in t, w i • f (p i)) :
    ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := 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 → β
t : Finset ι
w : ι → 𝕜
p : ι → E
v : 𝕜
q : E
hf : StrictConcaveOn 𝕜 s f
h₀ : ∀ i ∈ t, 0 < w i
h₁ : ∑ i in t, w i = 1
hmem : ∀ i ∈ t, p i ∈ s
h_eq : f (∑ i in t, w i • p i) ≤ ∑ i in t, w i • f (p i)
⊢ ∀ ⦃j : ι⦄, j ∈ t → ∀ ⦃k : ι⦄, k ∈ t → p j = p k

Next tactic:
by_contra!