Theorem: Even.convexOn_pow
File: Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean

tactic: refine' ⟨convex_univ, _⟩
state_before: n : ℕ
hn : Even n
⊢ ConvexOn ℝ univ fun x => x ^ n

tactic: rintro a - b - μ ν hμ hν h
state_before: n : ℕ
hn : Even n
⊢ ∀ ⦃x : ℝ⦄,
    x ∈ univ →
      ∀ ⦃y : ℝ⦄,
        y ∈ univ →
          ∀ ⦃a b : ℝ⦄,
            0 ≤ a →
              0 ≤ b → a + b = 1 → (fun x => x ^ n) (a • x + b • y) ≤ a • (fun x => x ^ n) x + b • (fun x => x ^ n) y

tactic: obtain ⟨k, rfl⟩ := hn.exists_two_nsmul _
state_before: n : ℕ
hn : Even n
a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
⊢ (fun x => x ^ n) (μ • a + ν • b) ≤ μ • (fun x => x ^ n) a + ν • (fun x => x ^ n) b

tactic: have : (0 : ℝ) ≤ (a - b) ^ 2 * μ * ν := by positivity
state_before: case intro
a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
⊢ (fun x => x ^ (2 • k)) (μ • a + ν • b) ≤ μ • (fun x => x ^ (2 • k)) a + ν • (fun x => x ^ (2 • k)) b

tactic: calc
  (μ * a + ν * b) ^ (2 * k) = ((μ * a + ν * b) ^ 2) ^ k := by rw [pow_mul]
  _ ≤ ((μ + ν) * (μ * a ^ 2 + ν * b ^ 2)) ^ k := by gcongr; linarith
  _ = (μ * a ^ 2 + ν * b ^ 2) ^ k := by rw [h]; ring
  _ ≤ μ * (a ^ 2) ^ k + ν * (b ^ 2) ^ k := ?_
  _ ≤ μ * a ^ (2 * k) + ν * b ^ (2 * k) := by ring_nf; rfl
state_before: case intro
a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ (fun x => x ^ (2 • k)) (μ • a + ν • b) ≤ μ • (fun x => x ^ (2 • k)) a + ν • (fun x => x ^ (2 • k)) b

tactic: refine' (convexOn_pow k).2 _ _ hμ hν h <;> rw [mem_Ici] <;> positivity
state_before: case intro
a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ (μ * a ^ 2 + ν * b ^ 2) ^ k ≤ μ * (a ^ 2) ^ k + ν * (b ^ 2) ^ k

tactic: positivity
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
⊢ 0 ≤ (a - b) ^ 2 * μ * ν

tactic: rw [pow_mul]
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ (μ * a + ν * b) ^ (2 * k) = ((μ * a + ν * b) ^ 2) ^ k

tactic: gcongr
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ ((μ * a + ν * b) ^ 2) ^ k ≤ ((μ + ν) * (μ * a ^ 2 + ν * b ^ 2)) ^ k

tactic: linarith
state_before: case hab
a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ (μ * a + ν * b) ^ 2 ≤ (μ + ν) * (μ * a ^ 2 + ν * b ^ 2)

tactic: rw [h]
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ ((μ + ν) * (μ * a ^ 2 + ν * b ^ 2)) ^ k = (μ * a ^ 2 + ν * b ^ 2) ^ k

tactic: ring
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ (1 * (μ * a ^ 2 + ν * b ^ 2)) ^ k = (μ * a ^ 2 + ν * b ^ 2) ^ k

tactic: ring_nf
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ μ * (a ^ 2) ^ k + ν * (b ^ 2) ^ k ≤ μ * a ^ (2 * k) + ν * b ^ (2 * k)

tactic: rfl
state_before: a b μ ν : ℝ
hμ : 0 ≤ μ
hν : 0 ≤ ν
h : μ + ν = 1
k : ℕ
hn : Even (2 • k)
this : 0 ≤ (a - b) ^ 2 * μ * ν
⊢ μ * a ^ (k * 2) + ν * b ^ (k * 2) ≤ μ * a ^ (k * 2) + ν * b ^ (k * 2)