Skip to content

Commit

Permalink
feat(analysis/convex/specific_functions): log is concave (#5508)
Browse files Browse the repository at this point in the history
This PR proves that the real log is concave on `Ioi 0` and `Iio 0`, and adds lemmas about concavity of functions along the way.




Co-authored-by: Frédéric Dupuis <31101893+dupuisf@users.noreply.github.com>
  • Loading branch information
dupuisf and dupuisf committed Dec 29, 2020
1 parent 8e413eb commit abffbaa
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
60 changes: 58 additions & 2 deletions src/analysis/calculus/mean_value.lean
Expand Up @@ -896,12 +896,32 @@ begin
end

/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is differentiable on its interior,
and `f'` is monotone on the interior, then `f` is convex on `ℝ`. -/
and `f'` is antimonotone on the interior, then `f` is concave on `D`. -/
theorem concave_on_of_deriv_antimono {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'_mono : ∀ x y ∈ interior D, x ≤ y → deriv f y ≤ deriv f x) :
concave_on D f :=
begin
have : ∀ x y ∈ interior D, x ≤ y → deriv (-f) x ≤ deriv (-f) y,
{ intros x y hx hy hxy,
convert neg_le_neg (hf'_mono x y hx hy hxy);
convert deriv.neg },
exact (neg_convex_on_iff D f).mp (convex_on_of_deriv_mono hD
hf.neg hf'.neg this),
end

/-- If a function `f` is differentiable and `f'` is monotone on `ℝ` then `f` is convex. -/
theorem convex_on_univ_of_deriv_mono {f : ℝ → ℝ} (hf : differentiable ℝ f)
(hf'_mono : monotone (deriv f)) : convex_on univ f :=
convex_on_of_deriv_mono convex_univ hf.continuous.continuous_on hf.differentiable_on
(λ x y _ _ h, hf'_mono h)

/-- If a function `f` is differentiable and `f'` is antimonotone on `ℝ` then `f` is concave. -/
theorem concave_on_univ_of_deriv_antimono {f : ℝ → ℝ} (hf : differentiable ℝ f)
(hf'_antimono : ∀⦃a b⦄, a ≤ b → (deriv f) b ≤ (deriv f) a) : concave_on univ f :=
concave_on_of_deriv_antimono convex_univ hf.continuous.continuous_on hf.differentiable_on
(λ x y _ _ h, hf'_antimono h)

/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is twice differentiable on its interior,
and `f''` is nonnegative on the interior, then `f` is convex on `D`. -/
theorem convex_on_of_deriv2_nonneg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
Expand All @@ -914,14 +934,50 @@ assume x y hx hy hxy,
hD.interior.mono_of_deriv_nonneg hf''.continuous_on (by rwa [interior_interior])
(by rwa [interior_interior]) _ _ hx hy hxy

/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is twice differentiable on its interior,
and `f''` is nonpositive on the interior, then `f` is concave on `D`. -/
theorem concave_on_of_deriv2_nonpos {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'' : differentiable_on ℝ (deriv f) (interior D))
(hf''_nonpos : ∀ x ∈ interior D, (deriv^[2] f x) ≤ 0) :
concave_on D f :=
concave_on_of_deriv_antimono hD hf hf' $
assume x y hx hy hxy,
hD.interior.antimono_of_deriv_nonpos hf''.continuous_on (by rwa [interior_interior])
(by rwa [interior_interior]) _ _ hx hy hxy

/-- If a function `f` is twice differentiable on a open convex set `D ⊆ ℝ` and
`f''` is nonnegative on `D`, then `f` is convex on `D`. -/
theorem convex_on_open_of_deriv2_nonneg {D : set ℝ} (hD : convex D) (hD₂ : is_open D) {f : ℝ → ℝ}
(hf' : differentiable_on ℝ f D) (hf'' : differentiable_on ℝ (deriv f) D)
(hf''_nonneg : ∀ x ∈ D, 0 ≤ (deriv^[2] f x)) : convex_on D f :=
convex_on_of_deriv2_nonneg hD hf'.continuous_on (by simpa [hD₂.interior_eq] using hf')
(by simpa [hD₂.interior_eq] using hf'') (by simpa [hD₂.interior_eq] using hf''_nonneg)

/-- If a function `f` is twice differentiable on a open convex set `D ⊆ ℝ` and
`f''` is nonpositive on `D`, then `f` is concave on `D`. -/
theorem concave_on_open_of_deriv2_nonpos {D : set ℝ} (hD : convex D) (hD₂ : is_open D) {f : ℝ → ℝ}
(hf' : differentiable_on ℝ f D) (hf'' : differentiable_on ℝ (deriv f) D)
(hf''_nonpos : ∀ x ∈ D, (deriv^[2] f x) ≤ 0) : concave_on D f :=
concave_on_of_deriv2_nonpos hD hf'.continuous_on (by simpa [hD₂.interior_eq] using hf')
(by simpa [hD₂.interior_eq] using hf'') (by simpa [hD₂.interior_eq] using hf''_nonpos)

/-- If a function `f` is twice differentiable on `ℝ`, and `f''` is nonnegative on `ℝ`,
then `f` is convex on `ℝ`. -/
theorem convex_on_univ_of_deriv2_nonneg {f : ℝ → ℝ} (hf' : differentiable ℝ f)
(hf'' : differentiable ℝ (deriv f)) (hf''_nonneg : ∀ x, 0 ≤ (deriv^[2] f x)) :
convex_on univ f :=
convex_on_of_deriv2_nonneg convex_univ hf'.continuous.continuous_on hf'.differentiable_on
convex_on_open_of_deriv2_nonneg convex_univ is_open_univ hf'.differentiable_on
hf''.differentiable_on (λ x _, hf''_nonneg x)

/-- If a function `f` is twice differentiable on `ℝ`, and `f''` is nonpositive on `ℝ`,
then `f` is concave on `ℝ`. -/
theorem concave_on_univ_of_deriv2_nonpos {f : ℝ → ℝ} (hf' : differentiable ℝ f)
(hf'' : differentiable ℝ (deriv f)) (hf''_nonpos : ∀ x, (deriv^[2] f x) ≤ 0) :
concave_on univ f :=
concave_on_open_of_deriv2_nonpos convex_univ is_open_univ hf'.differentiable_on
hf''.differentiable_on (λ x _, hf''_nonpos x)

/-! ### Functions `f : E → ℝ` -/

/-- Lagrange's Mean Value Theorem, applied to convex domains. -/
Expand Down
37 changes: 37 additions & 0 deletions src/analysis/convex/specific_functions.lean
Expand Up @@ -18,6 +18,7 @@ In this file we prove that the following functions are convex:
* `convex_on_pow` : for a natural $n$, the function $f(x)=x^n$ is convex on $[0, +∞)$;
* `convex_on_fpow` : for an integer $m$, the function $f(x)=x^m$ is convex on $(0, +∞)$.
* `convex_on_rpow : ∀ p : ℝ, 1 ≤ p → convex_on (Ici 0) (λ x, x ^ p)`
* `concave_on_log_Ioi` and `concave_on_log_Iio`: log is concave on `Ioi 0` and `Iio 0` respectively.
-/

open real set
Expand Down Expand Up @@ -114,3 +115,39 @@ begin
apply mul_nonneg (le_trans zero_le_one hp),
exact mul_nonneg (sub_nonneg_of_le hp) (rpow_nonneg_of_nonneg (le_of_lt hx) _) }
end

lemma concave_on_log_Ioi : concave_on (Ioi 0) log :=
begin
have h₁ : Ioi 0 ⊆ ({0} : set ℝ)ᶜ,
{ intros x hx hx',
rw [mem_singleton_iff] at hx',
rw [hx'] at hx,
exact lt_irrefl 0 hx },
refine concave_on_open_of_deriv2_nonpos (convex_Ioi 0) is_open_Ioi _ _ _,
{ exact differentiable_on_log.mono h₁ },
{ refine ((times_cont_diff_on_log.deriv_of_open _ le_top).differentiable_on le_top).mono h₁,
exact is_open_compl_singleton },
{ intros x hx,
rw [function.iterate_succ, function.iterate_one],
change (deriv (deriv log)) x ≤ 0,
rw [deriv_log', deriv_inv (show x ≠ 0, by {rintro rfl, exact lt_irrefl 0 hx})],
exact neg_nonpos.mpr (inv_nonneg.mpr (pow_two_nonneg x)) }
end

lemma concave_on_log_Iio : concave_on (Iio 0) log :=
begin
have h₁ : Iio 0 ⊆ ({0} : set ℝ)ᶜ,
{ intros x hx hx',
rw [mem_singleton_iff] at hx',
rw [hx'] at hx,
exact lt_irrefl 0 hx },
refine concave_on_open_of_deriv2_nonpos (convex_Iio 0) is_open_Iio _ _ _,
{ exact differentiable_on_log.mono h₁ },
{ refine ((times_cont_diff_on_log.deriv_of_open _ le_top).differentiable_on le_top).mono h₁,
exact is_open_compl_singleton },
{ intros x hx,
rw [function.iterate_succ, function.iterate_one],
change (deriv (deriv log)) x ≤ 0,
rw [deriv_log', deriv_inv (show x ≠ 0, by {rintro rfl, exact lt_irrefl 0 hx})],
exact neg_nonpos.mpr (inv_nonneg.mpr (pow_two_nonneg x)) }
end

0 comments on commit abffbaa

Please sign in to comment.