theorempopular_square_mass {α : Type*} (S : Finset α) (w : α →ℝ)
{θ MPI : ℝ} (hθ : 0≤ θ) (_hM : 0≤M)
(hw : ∀ x ∈S, 0≤ w x ∧ w x ≤M)
(htotal : ∑ x ∈S, w x ≤P) (henergy : I≤∑ x ∈S, (w x)^2) :
letG:=S.filter fun x => θ ≤ w x
proof · 33
lines
θ*(G.card : ℝ) ≤P∧I-θ*P≤M*(∑ x ∈G, w x) :=byletG:=S.filter fun x => θ ≤ w x
letD:=S.filter fun x =>¬θ ≤ w x
havehgood : (∑ x ∈G, w x) ≤P:=
(Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _)
(fun x hx _ => (hw x hx).1)).trans htotal
havehgcard : θ*(G.card : ℝ) ≤∑ x ∈G, w x :=bycalc
_ = ∑ _x ∈G, θ :=by simp [mul_comm]
_ ≤ _ :=Finset.sum_le_sum fun x hx => (Finset.mem_filter.mp hx).2havehbad : (∑ x ∈D, (w x)^2) ≤ θ*P:=bycalc
_ ≤∑ x ∈D, θ*w x :=by
apply Finset.sum_le_sum
intro x hx
have hxS := (Finset.mem_filter.mp hx).1have hsmall := (lt_of_not_ge (Finset.mem_filter.mp hx).2).le
nlinarith [(hw x hxS).1]
_ = θ*∑ x ∈D, w x := (Finset.mul_sum ..).symm
_ ≤ θ*P:= mul_le_mul_of_nonneg_left
((Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _)
(fun x hx _ => (hw x hx).1)).trans htotal) hθ
havehhigh : (∑ x ∈G, (w x)^2) ≤M*∑ x ∈G, w x :=by
rw [Finset.mul_sum]
apply Finset.sum_le_sum
intro x hx
have h := hw x (Finset.mem_filter.mp hx).1
nlinarith
have hsplit :=Finset.sum_filter_add_sum_filter_not S (fun x => θ ≤ w x) (fun x => (w x)^2)
havehremaining : I-θ*P≤M*∑ x ∈G, w x :=by
change (∑ x ∈G, (w x)^2)+(∑ x ∈D, (w x)^2) = _ at hsplit
linarith
exact ⟨hgcard.trans hgood,hremaining⟩