Theorem: NNReal.isGreatest_Lp
File: Mathlib/Analysis/MeanInequalities.lean

tactic: constructor
state_before: ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
⊢ IsGreatest ((fun g => ∑ i in s, f i * g i) '' {g | ∑ i in s, g i ^ q ≤ 1}) ((∑ i in s, f i ^ p) ^ (1 / p))

tactic: use fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)
state_before: case left
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
⊢ (∑ i in s, f i ^ p) ^ (1 / p) ∈ (fun g => ∑ i in s, f i * g i) '' {g | ∑ i in s, g i ^ q ≤ 1}

tactic: by_cases hf : (∑ i in s, f i ^ p) = 0
state_before: case left
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
⊢ (fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) ∈ {g | ∑ i in s, g i ^ q ≤ 1} ∧
    ((fun g => ∑ i in s, f i * g i) fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) =
      (∑ i in s, f i ^ p) ^ (1 / p)

tactic: simp [hf, hpq.ne_zero, hpq.symm.ne_zero]
state_before: case pos
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ∑ i in s, f i ^ p = 0
⊢ (fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) ∈ {g | ∑ i in s, g i ^ q ≤ 1} ∧
    ((fun g => ∑ i in s, f i * g i) fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) =
      (∑ i in s, f i ^ p) ^ (1 / p)

tactic: have A : p + q - q ≠ 0 := by simp [hpq.ne_zero]
state_before: case neg
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
⊢ (fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) ∈ {g | ∑ i in s, g i ^ q ≤ 1} ∧
    ((fun g => ∑ i in s, f i * g i) fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) =
      (∑ i in s, f i ^ p) ^ (1 / p)

tactic: have B : ∀ y : ℝ≥0, y * y ^ p / y = y ^ p := by
  refine' fun y => mul_div_cancel_left_of_imp fun h => _
  simp [h, hpq.ne_zero]
state_before: case neg
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
A : p + q - q ≠ 0
⊢ (fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) ∈ {g | ∑ i in s, g i ^ q ≤ 1} ∧
    ((fun g => ∑ i in s, f i * g i) fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) =
      (∑ i in s, f i ^ p) ^ (1 / p)

tactic: simp only [Set.mem_setOf_eq, div_rpow, ← sum_div, ← rpow_mul,
  div_mul_cancel _ hpq.symm.ne_zero, rpow_one, div_le_iff hf, one_mul, hpq.mul_eq_add, ←
  rpow_sub' _ A, _root_.add_sub_cancel, le_refl, true_and_iff, ← mul_div_assoc, B]
state_before: case neg
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
A : p + q - q ≠ 0
B : ∀ (y : ℝ≥0), y * y ^ p / y = y ^ p
⊢ (fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) ∈ {g | ∑ i in s, g i ^ q ≤ 1} ∧
    ((fun g => ∑ i in s, f i * g i) fun i => f i ^ p / f i / (∑ i in s, f i ^ p) ^ (1 / q)) =
      (∑ i in s, f i ^ p) ^ (1 / p)

tactic: rw [div_eq_iff, ← rpow_add hf, hpq.inv_add_inv_conj, rpow_one]
state_before: case neg
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
A : p + q - q ≠ 0
B : ∀ (y : ℝ≥0), y * y ^ p / y = y ^ p
⊢ (∑ i in s, f i ^ p) / (∑ i in s, f i ^ p) ^ (1 / q) = (∑ i in s, f i ^ p) ^ (1 / p)

tactic: simpa [hpq.symm.ne_zero] using hf
state_before: case neg
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
A : p + q - q ≠ 0
B : ∀ (y : ℝ≥0), y * y ^ p / y = y ^ p
⊢ (∑ i in s, f i ^ p) ^ (1 / q) ≠ 0

tactic: simp [hpq.ne_zero]
state_before: ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
⊢ p + q - q ≠ 0

tactic: refine' fun y => mul_div_cancel_left_of_imp fun h => _
state_before: ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
A : p + q - q ≠ 0
⊢ ∀ (y : ℝ≥0), y * y ^ p / y = y ^ p

tactic: simp [h, hpq.ne_zero]
state_before: ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
hf : ¬∑ i in s, f i ^ p = 0
A : p + q - q ≠ 0
y : ℝ≥0
h : y = 0
⊢ y ^ p = 0

tactic: rintro _ ⟨g, hg, rfl⟩
state_before: case right
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
⊢ (∑ i in s, f i ^ p) ^ (1 / p) ∈ upperBounds ((fun g => ∑ i in s, f i * g i) '' {g | ∑ i in s, g i ^ q ≤ 1})

tactic: apply le_trans (inner_le_Lp_mul_Lq s f g hpq)
state_before: case right.intro.intro
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
g : ι → ℝ≥0
hg : g ∈ {g | ∑ i in s, g i ^ q ≤ 1}
⊢ (fun g => ∑ i in s, f i * g i) g ≤ (∑ i in s, f i ^ p) ^ (1 / p)

tactic: simpa only [mul_one] using
  mul_le_mul_left' (NNReal.rpow_le_one hg (le_of_lt hpq.symm.one_div_pos)) _
state_before: case right.intro.intro
ι : Type u
s : Finset ι
f : ι → ℝ≥0
p q : ℝ
hpq : Real.IsConjugateExponent p q
g : ι → ℝ≥0
hg : g ∈ {g | ∑ i in s, g i ^ q ≤ 1}
⊢ (∑ i in s, f i ^ p) ^ (1 / p) * (∑ i in s, g i ^ q) ^ (1 / q) ≤ (∑ i in s, f i ^ p) ^ (1 / p)