Theorem: Real.pow_sum_div_card_le_sum_pow
File: Mathlib/Analysis/MeanInequalitiesPow.lean

tactic: rcases s.eq_empty_or_nonempty with (rfl | hs)
state_before: ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ (∑ x ∈ s, f x) ^ (n + 1) / ↑s.card ^ n ≤ ∑ x ∈ s, f x ^ (n + 1)
state_after: case inl
ι : Type u
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ ∅, 0 ≤ f a
⊢ (∑ x ∈ ∅, f x) ^ (n + 1) / ↑∅.card ^ n ≤ ∑ x ∈ ∅, f x ^ (n + 1)

case inr
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
⊢ (∑ x ∈ s, f x) ^ (n + 1) / ↑s.card ^ n ≤ ∑ x ∈ s, f x ^ (n + 1)

tactic: simp_rw [Finset.sum_empty, zero_pow n.succ_ne_zero, zero_div]
state_before: case inl
ι : Type u
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ ∅, 0 ≤ f a
⊢ (∑ x ∈ ∅, f x) ^ (n + 1) / ↑∅.card ^ n ≤ ∑ x ∈ ∅, f x ^ (n + 1)
state_after: case inl
ι : Type u
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ ∅, 0 ≤ f a
⊢ 0 ≤ 0

tactic: rfl
state_before: case inl
ι : Type u
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ ∅, 0 ≤ f a
⊢ 0 ≤ 0
state_after: no goals

tactic: have hs0 : 0 < (s.card : ℝ) := Nat.cast_pos.2 hs.card_pos
state_before: case inr
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
⊢ (∑ x ∈ s, f x) ^ (n + 1) / ↑s.card ^ n ≤ ∑ x ∈ s, f x ^ (n + 1)
state_after: case inr
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ (∑ x ∈ s, f x) ^ (n + 1) / ↑s.card ^ n ≤ ∑ x ∈ s, f x ^ (n + 1)

tactic: suffices (∑ x ∈ s, f x / s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / s.card by
  rwa [← Finset.sum_div, ← Finset.sum_div, div_pow, pow_succ (s.card : ℝ), ← div_div,
    div_le_iff hs0, div_mul, div_self hs0.ne', div_one] at this
state_before: case inr
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ (∑ x ∈ s, f x) ^ (n + 1) / ↑s.card ^ n ≤ ∑ x ∈ s, f x ^ (n + 1)
state_after: case inr
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ (∑ x ∈ s, f x / ↑s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / ↑s.card

tactic: have :=
  @ConvexOn.map_sum_le ℝ ℝ ℝ ι _ _ _ _ _ _ (Set.Ici 0) (fun x => x ^ (n + 1)) s
    (fun _ => 1 / s.card) ((↑) ∘ f) (convexOn_pow (n + 1)) ?_ ?_ fun i hi =>
    Set.mem_Ici.2 (hf i hi)
state_before: case inr
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ (∑ x ∈ s, f x / ↑s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / ↑s.card
state_after: case inr.refine_3
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
this :
  (fun x => x ^ (n + 1)) (∑ i ∈ s, (fun x => 1 / ↑s.card) i • ((fun x => x) ∘ f) i) ≤
    ∑ i ∈ s, (fun x => 1 / ↑s.card) i • (fun x => x ^ (n + 1)) (((fun x => x) ∘ f) i)
⊢ (∑ x ∈ s, f x / ↑s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / ↑s.card

case inr.refine_1
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ ∀ i ∈ s, 0 ≤ (fun x => 1 / ↑s.card) i

case inr.refine_2
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ ∑ i ∈ s, (fun x => 1 / ↑s.card) i = 1

tactic: rwa [← Finset.sum_div, ← Finset.sum_div, div_pow, pow_succ (s.card : ℝ), ← div_div,
  div_le_iff hs0, div_mul, div_self hs0.ne', div_one] at this
state_before: ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
this : (∑ x ∈ s, f x / ↑s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / ↑s.card
⊢ (∑ x ∈ s, f x) ^ (n + 1) / ↑s.card ^ n ≤ ∑ x ∈ s, f x ^ (n + 1)
state_after: no goals

tactic: simpa only [inv_mul_eq_div, one_div, Algebra.id.smul_eq_mul] using this
state_before: case inr.refine_3
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
this :
  (fun x => x ^ (n + 1)) (∑ i ∈ s, (fun x => 1 / ↑s.card) i • ((fun x => x) ∘ f) i) ≤
    ∑ i ∈ s, (fun x => 1 / ↑s.card) i • (fun x => x ^ (n + 1)) (((fun x => x) ∘ f) i)
⊢ (∑ x ∈ s, f x / ↑s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / ↑s.card
state_after: no goals

tactic: simp only [one_div, inv_nonneg, Nat.cast_nonneg, imp_true_iff]
state_before: case inr.refine_1
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ ∀ i ∈ s, 0 ≤ (fun x => 1 / ↑s.card) i
state_after: no goals

tactic: simpa only [one_div, Finset.sum_const, nsmul_eq_mul] using mul_inv_cancel hs0.ne'
state_before: case inr.refine_2
ι : Type u
s : Finset ι
f : ι → ℝ
n : ℕ
hf : ∀ a ∈ s, 0 ≤ f a
hs : s.Nonempty
hs0 : 0 < ↑s.card
⊢ ∑ i ∈ s, (fun x => 1 / ↑s.card) i = 1
state_after: no goals