Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit decd67c

Browse files
feat(analysis/convex): slope_mono_adjacent (#4307)
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
1 parent a06c87e commit decd67c

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/analysis/convex/basic.lean

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,43 @@ begin
599599
convert this; symmetry; simp only [div_eq_iff (ne_of_gt B), y]; ring
600600
end
601601

602+
/-- For a function `f` defined on a subset `D` of `ℝ`, if `f` is convex on `D`, then for any three
603+
points `x<y<z`, the slope of the secant line of `f` on `[x, y]` is less than or equal to the slope
604+
of the secant line of `f` on `[x, z]`. -/
605+
lemma convex_on.slope_mono_adjacent {s : set ℝ} {f : ℝ → ℝ} (hf : convex_on s f)
606+
{x y z : ℝ} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) :
607+
(f y - f x) / (y - x) ≤ (f z - f y) / (z - y) :=
608+
begin
609+
have h₁ : 0 < y - x := by linarith,
610+
have h₂ : 0 < z - y := by linarith,
611+
have h₃ : 0 < z - x := by linarith,
612+
suffices : f y / (y - x) + f y / (z - y) ≤ f x / (y - x) + f z / (z - y),
613+
by { ring at this ⊢, linarith },
614+
set a := (z - y) / (z - x),
615+
set b := (y - x) / (z - x),
616+
have heqz : a • x + b • z = y, by { field_simp, rw div_eq_iff; [ring, linarith], },
617+
have key, from
618+
hf.2 hx hz
619+
(show 0 ≤ a, by apply div_nonneg; linarith)
620+
(show 0 ≤ b, by apply div_nonneg; linarith)
621+
(show a + b = 1, by { field_simp, rw div_eq_iff; [ring, linarith], }),
622+
rw heqz at key,
623+
replace key := mul_le_mul_of_nonneg_left key (le_of_lt h₃),
624+
field_simp [ne_of_gt h₁, ne_of_gt h₂, ne_of_gt h₃, mul_comm (z - x) _] at key ⊢,
625+
rw div_le_div_right,
626+
{ linarith, },
627+
{ nlinarith, },
628+
end
629+
630+
/-- For a function `f` defined on a convex subset `D` of `ℝ`, `f` is convex on `D` iff for any three
631+
points `x<y<z` the slope of the secant line of `f` on `[x, y]` is less than or equal to the slope
632+
of the secant line of `f` on `[x, z]`. -/
633+
lemma convex_on_real_iff_slope_mono_adjacent {s : set ℝ} (hs : convex s) {f : ℝ → ℝ} :
634+
convex_on s f ↔
635+
(∀ {x y z : ℝ}, x ∈ s → z ∈ s → x < y → y < z →
636+
(f y - f x) / (y - x) ≤ (f z - f y) / (z - y)) :=
637+
⟨convex_on.slope_mono_adjacent, convex_on_real_of_slope_mono_adjacent hs⟩
638+
602639
/-- For a function `f` defined on a convex subset `D` of `ℝ`, if for any three points `x<y<z`
603640
the slope of the secant line of `f` on `[x, y]` is greater than or equal to the slope
604641
of the secant line of `f` on `[x, z]`, then `f` is concave on `D`. -/
@@ -613,6 +650,29 @@ begin
613650
simp only [hf xs zs xy yz, neg_sub_neg, pi.neg_apply],
614651
end
615652

653+
/-- For a function `f` defined on a subset `D` of `ℝ`, if `f` is concave on `D`, then for any three
654+
points `x<y<z`, the slope of the secant line of `f` on `[x, y]` is greater than or equal to the
655+
slope of the secant line of `f` on `[x, z]`. -/
656+
lemma concave_on.slope_mono_adjacent {s : set ℝ} {f : ℝ → ℝ} (hf : concave_on s f)
657+
{x y z : ℝ} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) :
658+
(f z - f y) / (z - y) ≤ (f y - f x) / (y - x) :=
659+
begin
660+
rw [←neg_le_neg_iff, ←neg_div, ←neg_div, neg_sub, neg_sub],
661+
rw [←neg_sub_neg (f y), ←neg_sub_neg (f z)],
662+
simp_rw [←pi.neg_apply],
663+
rw [←neg_convex_on_iff] at hf,
664+
apply convex_on.slope_mono_adjacent hf; assumption,
665+
end
666+
667+
/-- For a function `f` defined on a convex subset `D` of `ℝ`, `f` is concave on `D` iff for any
668+
three points `x<y<z` the slope of the secant line of `f` on `[x, y]` is greater than or equal to
669+
the slope of the secant line of `f` on `[x, z]`. -/
670+
lemma concave_on_real_iff_slope_mono_adjacent {s : set ℝ} (hs : convex s) {f : ℝ → ℝ} :
671+
concave_on s f ↔
672+
(∀ {x y z : ℝ}, x ∈ s → z ∈ s → x < y → y < z →
673+
(f z - f y) / (z - y) ≤ (f y - f x) / (y - x)) :=
674+
⟨concave_on.slope_mono_adjacent, concave_on_real_of_slope_mono_adjacent hs⟩
675+
616676
lemma convex_on.subset {f : E → β} (h_convex_on : convex_on t f)
617677
(h_subset : s ⊆ t) (h_convex : convex s) : convex_on s f :=
618678
begin

0 commit comments

Comments
 (0)