analysis.calculus.darbouxMathlib.Analysis.Calculus.Darboux

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

(last sync)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

refactor(analysis/calculus/darboux): review API (#19125)

Add more versions of the main theorem, slightly generalize existing versions.

Diff
@@ -19,16 +19,14 @@ open_locale topology classical
 variables {a b : ℝ} {f f' : ℝ → ℝ}
 
 /-- **Darboux's theorem**: if `a ≤ b` and `f' a < m < f' b`, then `f' c = m` for some
-`c ∈ [a, b]`. -/
+`c ∈ (a, b)`. -/
 theorem exists_has_deriv_within_at_eq_of_gt_of_lt
   (hab : a ≤ b) (hf : ∀ x ∈ (Icc a b), has_deriv_within_at f (f' x) (Icc a b) x)
   {m : ℝ} (hma : f' a < m) (hmb : m < f' b) :
-  m ∈ f' '' (Icc a b) :=
+  m ∈ f' '' Ioo a b :=
 begin
-  have hab' : a < b,
-  { refine lt_of_le_of_ne hab (λ hab', _),
-    subst b,
-    exact lt_asymm hma hmb },
+  rcases hab.eq_or_lt with rfl | hab',
+  { exact (lt_asymm hma hmb).elim },
   set g : ℝ → ℝ := λ x, f x - m * x,
   have hg : ∀ x ∈ Icc a b, has_deriv_within_at g (f' x - m) (Icc a b) x,
   { intros x hx,
@@ -37,73 +35,121 @@ begin
     from is_compact_Icc.exists_forall_le (nonempty_Icc.2 $ hab)
       (λ x hx, (hg x hx).continuous_within_at),
   have cmem' : c ∈ Ioo a b,
-  { cases eq_or_lt_of_le cmem.1 with hac hac,
+  { rcases cmem.1.eq_or_lt with rfl | hac,
     -- Show that `c` can't be equal to `a`
-    { subst c,
-      refine absurd (sub_nonneg.1 $ nonneg_of_mul_nonneg_right _ (sub_pos.2 hab'))
+    { refine absurd (sub_nonneg.1 $ nonneg_of_mul_nonneg_right _ (sub_pos.2 hab'))
         (not_le_of_lt hma),
       have : b - a ∈ pos_tangent_cone_at (Icc a b) a,
         from mem_pos_tangent_cone_at_of_segment_subset (segment_eq_Icc hab ▸ subset.refl _),
       simpa [-sub_nonneg, -continuous_linear_map.map_sub]
         using hc.localize.has_fderiv_within_at_nonneg (hg a (left_mem_Icc.2 hab)) this },
-    cases eq_or_lt_of_le cmem.2 with hbc hbc,
+    rcases cmem.2.eq_or_gt with rfl | hcb,
     -- Show that `c` can't be equal to `b`
-    { subst c,
-      refine absurd (sub_nonpos.1 $ nonpos_of_mul_nonneg_right _ (sub_lt_zero.2 hab'))
+    { refine absurd (sub_nonpos.1 $ nonpos_of_mul_nonneg_right _ (sub_lt_zero.2 hab'))
         (not_le_of_lt hmb),
       have : a - b ∈ pos_tangent_cone_at (Icc a b) b,
         from mem_pos_tangent_cone_at_of_segment_subset (by rw [segment_symm, segment_eq_Icc hab]),
       simpa [-sub_nonneg, -continuous_linear_map.map_sub]
         using hc.localize.has_fderiv_within_at_nonneg (hg b (right_mem_Icc.2 hab)) this },
-    exact ⟨hac, hbc⟩ },
-  use [c, cmem],
+    exact ⟨hac, hcb⟩ },
+  use [c, cmem'],
   rw [← sub_eq_zero],
   have : Icc a b ∈ 𝓝 c, by rwa [← mem_interior_iff_mem_nhds, interior_Icc],
   exact (hc.is_local_min this).has_deriv_at_eq_zero ((hg c cmem).has_deriv_at this)
 end
 
-/-- **Darboux's theorem**: if `a ≤ b` and `f' a > m > f' b`, then `f' c = m` for some `c ∈ [a, b]`.
+/-- **Darboux's theorem**: if `a ≤ b` and `f' b < m < f' a`, then `f' c = m` for some `c ∈ (a, b)`.
 -/
 theorem exists_has_deriv_within_at_eq_of_lt_of_gt
   (hab : a ≤ b) (hf : ∀ x ∈ (Icc a b), has_deriv_within_at f (f' x) (Icc a b) x)
   {m : ℝ} (hma : m < f' a) (hmb : f' b < m) :
-  m ∈ f' '' (Icc a b) :=
+  m ∈ f' '' Ioo a b :=
 let ⟨c, cmem, hc⟩ := exists_has_deriv_within_at_eq_of_gt_of_lt hab (λ x hx, (hf x hx).neg)
   (neg_lt_neg hma) (neg_lt_neg hmb)
 in ⟨c, cmem, neg_injective hc⟩
 
-/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set. -/
-theorem convex_image_has_deriv_at {s : set ℝ} (hs : convex ℝ s)
-  (hf : ∀ x ∈ s, has_deriv_at f (f' x) x) :
-  convex ℝ (f' '' s) :=
+/-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
+set, `has_deriv_within_at` version. -/
+theorem set.ord_connected.image_has_deriv_within_at {s : set ℝ} (hs : ord_connected s)
+  (hf : ∀ x ∈ s, has_deriv_within_at f (f' x) s x) :
+  ord_connected (f' '' s) :=
 begin
-  refine ord_connected.convex ⟨_⟩,
-  rintros _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ m ⟨hma, hmb⟩,
-  cases eq_or_lt_of_le hma with hma hma,
-    by exact hma ▸ mem_image_of_mem f' ha,
-  cases eq_or_lt_of_le hmb with hmb hmb,
-    by exact hmb.symm ▸ mem_image_of_mem f' hb,
+  apply ord_connected_of_Ioo,
+  rintros _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - m ⟨hma, hmb⟩,
   cases le_total a b with hab hab,
-  { have : Icc a b ⊆ s, from hs.ord_connected.out ha hb,
+  { have : Icc a b ⊆ s, from hs.out ha hb,
     rcases exists_has_deriv_within_at_eq_of_gt_of_lt hab
-      (λ x hx, (hf x $ this hx).has_deriv_within_at) hma hmb
+      (λ x hx, (hf x $ this hx).mono this) hma hmb
       with ⟨c, cmem, hc⟩,
-    exact ⟨c, this cmem, hc⟩ },
-  { have : Icc b a ⊆ s, from hs.ord_connected.out hb ha,
+    exact ⟨c, this $ Ioo_subset_Icc_self cmem, hc⟩ },
+  { have : Icc b a ⊆ s, from hs.out hb ha,
     rcases exists_has_deriv_within_at_eq_of_lt_of_gt hab
-      (λ x hx, (hf x $ this hx).has_deriv_within_at) hmb hma
+      (λ x hx, (hf x $ this hx).mono this) hmb hma
       with ⟨c, cmem, hc⟩,
-    exact ⟨c, this cmem, hc⟩ }
+    exact ⟨c, this $ Ioo_subset_Icc_self cmem, hc⟩ }
 end
 
+/-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
+set, `deriv_within` version. -/
+theorem set.ord_connected.image_deriv_within {s : set ℝ} (hs : ord_connected s)
+  (hf : differentiable_on ℝ f s) :
+  ord_connected (deriv_within f s '' s) :=
+hs.image_has_deriv_within_at $ λ x hx, (hf x hx).has_deriv_within_at
+
+/-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
+set, `deriv` version. -/
+theorem set.ord_connected.image_deriv {s : set ℝ} (hs : ord_connected s)
+  (hf : ∀ x ∈ s, differentiable_at ℝ f x) :
+  ord_connected (deriv f '' s) :=
+hs.image_has_deriv_within_at $ λ x hx, (hf x hx).has_deriv_at.has_deriv_within_at
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`has_deriv_within_at` version. -/
+theorem convex.image_has_deriv_within_at {s : set ℝ} (hs : convex ℝ s)
+  (hf : ∀ x ∈ s, has_deriv_within_at f (f' x) s x) :
+  convex ℝ (f' '' s) :=
+(hs.ord_connected.image_has_deriv_within_at hf).convex
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`deriv_within` version. -/
+theorem convex.image_deriv_within {s : set ℝ} (hs : convex ℝ s)
+  (hf : differentiable_on ℝ f s) :
+  convex ℝ (deriv_within f s '' s) :=
+(hs.ord_connected.image_deriv_within hf).convex
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`deriv` version. -/
+theorem convex.image_deriv {s : set ℝ} (hs : convex ℝ s)
+  (hf : ∀ x ∈ s, differentiable_at ℝ f x) :
+  convex ℝ (deriv f '' s) :=
+(hs.ord_connected.image_deriv hf).convex
+
+/-- **Darboux's theorem**: if `a ≤ b` and `f' a ≤ m ≤ f' b`, then `f' c = m` for some
+`c ∈ [a, b]`. -/
+theorem exists_has_deriv_within_at_eq_of_ge_of_le
+  (hab : a ≤ b) (hf : ∀ x ∈ (Icc a b), has_deriv_within_at f (f' x) (Icc a b) x)
+  {m : ℝ} (hma : f' a ≤ m) (hmb : m ≤ f' b) :
+  m ∈ f' '' Icc a b :=
+(ord_connected_Icc.image_has_deriv_within_at hf).out
+  (mem_image_of_mem _ (left_mem_Icc.2 hab)) (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
+
+/-- **Darboux's theorem**: if `a ≤ b` and `f' b ≤ m ≤ f' a`, then `f' c = m` for some
+`c ∈ [a, b]`. -/
+theorem exists_has_deriv_within_at_eq_of_le_of_ge
+  (hab : a ≤ b) (hf : ∀ x ∈ (Icc a b), has_deriv_within_at f (f' x) (Icc a b) x)
+  {m : ℝ} (hma : f' a ≤ m) (hmb : m ≤ f' b) :
+  m ∈ f' '' Icc a b :=
+(ord_connected_Icc.image_has_deriv_within_at hf).out
+  (mem_image_of_mem _ (left_mem_Icc.2 hab)) (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
+
 /-- If the derivative of a function is never equal to `m`, then either
 it is always greater than `m`, or it is always less than `m`. -/
-theorem deriv_forall_lt_or_forall_gt_of_forall_ne {s : set ℝ} (hs : convex ℝ s)
-  (hf : ∀ x ∈ s, has_deriv_at f (f' x) x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
+theorem has_deriv_within_at_forall_lt_or_forall_gt_of_forall_ne {s : set ℝ} (hs : convex ℝ s)
+  (hf : ∀ x ∈ s, has_deriv_within_at f (f' x) s x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
   (∀ x ∈ s, f' x < m) ∨ (∀ x ∈ s, m < f' x) :=
 begin
   contrapose! hf',
   rcases hf' with ⟨⟨b, hb, hmb⟩, ⟨a, ha, hma⟩⟩,
-  exact (convex_image_has_deriv_at hs hf).ord_connected.out (mem_image_of_mem f' ha)
+  exact (hs.ord_connected.image_has_deriv_within_at hf).out (mem_image_of_mem f' ha)
     (mem_image_of_mem f' hb) ⟨hma, hmb⟩
 end

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2020 Yury Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
 -/
-import Analysis.Calculus.LocalExtr
+import Analysis.Calculus.LocalExtr.Basic
 
 #align_import analysis.calculus.darboux from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
 
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2020 Yury Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
 -/
-import Mathbin.Analysis.Calculus.LocalExtr
+import Analysis.Calculus.LocalExtr
 
 #align_import analysis.calculus.darboux from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2020 Yury Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
-
-! This file was ported from Lean 3 source module analysis.calculus.darboux
-! leanprover-community/mathlib commit 61b5e2755ccb464b68d05a9acf891ae04992d09d
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Analysis.Calculus.LocalExtr
 
+#align_import analysis.calculus.darboux from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
+
 /-!
 # Darboux's theorem
 
Diff
@@ -28,6 +28,7 @@ open scoped Topology Classical
 
 variable {a b : ℝ} {f f' : ℝ → ℝ}
 
+#print exists_hasDerivWithinAt_eq_of_gt_of_lt /-
 /-- **Darboux's theorem**: if `a ≤ b` and `f' a < m < f' b`, then `f' c = m` for some
 `c ∈ (a, b)`. -/
 theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
@@ -68,7 +69,9 @@ theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
   have : Icc a b ∈ 𝓝 c := by rwa [← mem_interior_iff_mem_nhds, interior_Icc]
   exact (hc.is_local_min this).hasDerivAt_eq_zero ((hg c cmem).HasDerivAt this)
 #align exists_has_deriv_within_at_eq_of_gt_of_lt exists_hasDerivWithinAt_eq_of_gt_of_lt
+-/
 
+#print exists_hasDerivWithinAt_eq_of_lt_of_gt /-
 /-- **Darboux's theorem**: if `a ≤ b` and `f' b < m < f' a`, then `f' c = m` for some `c ∈ (a, b)`.
 -/
 theorem exists_hasDerivWithinAt_eq_of_lt_of_gt (hab : a ≤ b)
@@ -79,6 +82,7 @@ theorem exists_hasDerivWithinAt_eq_of_lt_of_gt (hab : a ≤ b)
       (neg_lt_neg hmb)
   ⟨c, cmem, neg_injective hc⟩
 #align exists_has_deriv_within_at_eq_of_lt_of_gt exists_hasDerivWithinAt_eq_of_lt_of_gt
+-/
 
 #print Set.OrdConnected.image_hasDerivWithinAt /-
 /-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
@@ -120,27 +124,34 @@ theorem Set.OrdConnected.image_deriv {s : Set ℝ} (hs : OrdConnected s)
 #align set.ord_connected.image_deriv Set.OrdConnected.image_deriv
 -/
 
+#print Convex.image_hasDerivWithinAt /-
 /-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
 `has_deriv_within_at` version. -/
 theorem Convex.image_hasDerivWithinAt {s : Set ℝ} (hs : Convex ℝ s)
     (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : Convex ℝ (f' '' s) :=
   (hs.OrdConnected.image_hasDerivWithinAt hf).Convex
 #align convex.image_has_deriv_within_at Convex.image_hasDerivWithinAt
+-/
 
+#print Convex.image_derivWithin /-
 /-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
 `deriv_within` version. -/
 theorem Convex.image_derivWithin {s : Set ℝ} (hs : Convex ℝ s) (hf : DifferentiableOn ℝ f s) :
     Convex ℝ (derivWithin f s '' s) :=
   (hs.OrdConnected.image_derivWithin hf).Convex
 #align convex.image_deriv_within Convex.image_derivWithin
+-/
 
+#print Convex.image_deriv /-
 /-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
 `deriv` version. -/
 theorem Convex.image_deriv {s : Set ℝ} (hs : Convex ℝ s) (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) :
     Convex ℝ (deriv f '' s) :=
   (hs.OrdConnected.image_deriv hf).Convex
 #align convex.image_deriv Convex.image_deriv
+-/
 
+#print exists_hasDerivWithinAt_eq_of_ge_of_le /-
 /-- **Darboux's theorem**: if `a ≤ b` and `f' a ≤ m ≤ f' b`, then `f' c = m` for some
 `c ∈ [a, b]`. -/
 theorem exists_hasDerivWithinAt_eq_of_ge_of_le (hab : a ≤ b)
@@ -149,7 +160,9 @@ theorem exists_hasDerivWithinAt_eq_of_ge_of_le (hab : a ≤ b)
   (ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
     (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
 #align exists_has_deriv_within_at_eq_of_ge_of_le exists_hasDerivWithinAt_eq_of_ge_of_le
+-/
 
+#print exists_hasDerivWithinAt_eq_of_le_of_ge /-
 /-- **Darboux's theorem**: if `a ≤ b` and `f' b ≤ m ≤ f' a`, then `f' c = m` for some
 `c ∈ [a, b]`. -/
 theorem exists_hasDerivWithinAt_eq_of_le_of_ge (hab : a ≤ b)
@@ -158,7 +171,9 @@ theorem exists_hasDerivWithinAt_eq_of_le_of_ge (hab : a ≤ b)
   (ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
     (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
 #align exists_has_deriv_within_at_eq_of_le_of_ge exists_hasDerivWithinAt_eq_of_le_of_ge
+-/
 
+#print hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne /-
 /-- If the derivative of a function is never equal to `m`, then either
 it is always greater than `m`, or it is always less than `m`. -/
 theorem hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs : Convex ℝ s)
@@ -171,4 +186,5 @@ theorem hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs :
     (hs.ord_connected.image_has_deriv_within_at hf).out (mem_image_of_mem f' ha)
       (mem_image_of_mem f' hb) ⟨hma, hmb⟩
 #align has_deriv_within_at_forall_lt_or_forall_gt_of_forall_ne hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne
+-/
 
Diff
@@ -80,6 +80,7 @@ theorem exists_hasDerivWithinAt_eq_of_lt_of_gt (hab : a ≤ b)
   ⟨c, cmem, neg_injective hc⟩
 #align exists_has_deriv_within_at_eq_of_lt_of_gt exists_hasDerivWithinAt_eq_of_lt_of_gt
 
+#print Set.OrdConnected.image_hasDerivWithinAt /-
 /-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
 set, `has_deriv_within_at` version. -/
 theorem Set.OrdConnected.image_hasDerivWithinAt {s : Set ℝ} (hs : OrdConnected s)
@@ -99,20 +100,25 @@ theorem Set.OrdConnected.image_hasDerivWithinAt {s : Set ℝ} (hs : OrdConnected
       ⟨c, cmem, hc⟩
     exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
 #align set.ord_connected.image_has_deriv_within_at Set.OrdConnected.image_hasDerivWithinAt
+-/
 
+#print Set.OrdConnected.image_derivWithin /-
 /-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
 set, `deriv_within` version. -/
 theorem Set.OrdConnected.image_derivWithin {s : Set ℝ} (hs : OrdConnected s)
     (hf : DifferentiableOn ℝ f s) : OrdConnected (derivWithin f s '' s) :=
   hs.image_hasDerivWithinAt fun x hx => (hf x hx).HasDerivWithinAt
 #align set.ord_connected.image_deriv_within Set.OrdConnected.image_derivWithin
+-/
 
+#print Set.OrdConnected.image_deriv /-
 /-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
 set, `deriv` version. -/
 theorem Set.OrdConnected.image_deriv {s : Set ℝ} (hs : OrdConnected s)
     (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) : OrdConnected (deriv f '' s) :=
   hs.image_hasDerivWithinAt fun x hx => (hf x hx).HasDerivAt.HasDerivWithinAt
 #align set.ord_connected.image_deriv Set.OrdConnected.image_deriv
+-/
 
 /-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
 `has_deriv_within_at` version. -/
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
 
 ! This file was ported from Lean 3 source module analysis.calculus.darboux
-! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
+! leanprover-community/mathlib commit 61b5e2755ccb464b68d05a9acf891ae04992d09d
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.Analysis.Calculus.LocalExtr
 /-!
 # Darboux's theorem
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 In this file we prove that the derivative of a differentiable function on an interval takes all
 intermediate values. The proof is based on the
 [Wikipedia](https://en.wikipedia.org/wiki/Darboux%27s_theorem_(analysis)) page about this theorem.
@@ -26,15 +29,13 @@ open scoped Topology Classical
 variable {a b : ℝ} {f f' : ℝ → ℝ}
 
 /-- **Darboux's theorem**: if `a ≤ b` and `f' a < m < f' b`, then `f' c = m` for some
-`c ∈ [a, b]`. -/
+`c ∈ (a, b)`. -/
 theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
     (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a < m)
-    (hmb : m < f' b) : m ∈ f' '' Icc a b :=
+    (hmb : m < f' b) : m ∈ f' '' Ioo a b :=
   by
-  have hab' : a < b := by
-    refine' lt_of_le_of_ne hab fun hab' => _
-    subst b
-    exact lt_asymm hma hmb
+  rcases hab.eq_or_lt with (rfl | hab')
+  · exact (lt_asymm hma hmb).elim
   set g : ℝ → ℝ := fun x => f x - m * x
   have hg : ∀ x ∈ Icc a b, HasDerivWithinAt g (f' x - m) (Icc a b) x :=
     by
@@ -44,76 +45,124 @@ theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
   exact
     is_compact_Icc.exists_forall_le (nonempty_Icc.2 <| hab) fun x hx => (hg x hx).ContinuousWithinAt
   have cmem' : c ∈ Ioo a b := by
-    cases' eq_or_lt_of_le cmem.1 with hac hac
+    rcases cmem.1.eq_or_lt with (rfl | hac)
     -- Show that `c` can't be equal to `a`
-    · subst c
-      refine'
+    · refine'
         absurd (sub_nonneg.1 <| nonneg_of_mul_nonneg_right _ (sub_pos.2 hab')) (not_le_of_lt hma)
       have : b - a ∈ posTangentConeAt (Icc a b) a :=
         mem_posTangentConeAt_of_segment_subset (segment_eq_Icc hab ▸ subset.refl _)
       simpa [-sub_nonneg, -ContinuousLinearMap.map_sub] using
         hc.localize.has_fderiv_within_at_nonneg (hg a (left_mem_Icc.2 hab)) this
-    cases' eq_or_lt_of_le cmem.2 with hbc hbc
+    rcases cmem.2.eq_or_gt with (rfl | hcb)
     -- Show that `c` can't be equal to `b`
-    · subst c
-      refine'
+    · refine'
         absurd (sub_nonpos.1 <| nonpos_of_mul_nonneg_right _ (sub_lt_zero.2 hab'))
           (not_le_of_lt hmb)
       have : a - b ∈ posTangentConeAt (Icc a b) b :=
         mem_posTangentConeAt_of_segment_subset (by rw [segment_symm, segment_eq_Icc hab])
       simpa [-sub_nonneg, -ContinuousLinearMap.map_sub] using
         hc.localize.has_fderiv_within_at_nonneg (hg b (right_mem_Icc.2 hab)) this
-    exact ⟨hac, hbc⟩
-  use c, cmem
+    exact ⟨hac, hcb⟩
+  use c, cmem'
   rw [← sub_eq_zero]
   have : Icc a b ∈ 𝓝 c := by rwa [← mem_interior_iff_mem_nhds, interior_Icc]
   exact (hc.is_local_min this).hasDerivAt_eq_zero ((hg c cmem).HasDerivAt this)
 #align exists_has_deriv_within_at_eq_of_gt_of_lt exists_hasDerivWithinAt_eq_of_gt_of_lt
 
-/-- **Darboux's theorem**: if `a ≤ b` and `f' a > m > f' b`, then `f' c = m` for some `c ∈ [a, b]`.
+/-- **Darboux's theorem**: if `a ≤ b` and `f' b < m < f' a`, then `f' c = m` for some `c ∈ (a, b)`.
 -/
 theorem exists_hasDerivWithinAt_eq_of_lt_of_gt (hab : a ≤ b)
     (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : m < f' a)
-    (hmb : f' b < m) : m ∈ f' '' Icc a b :=
+    (hmb : f' b < m) : m ∈ f' '' Ioo a b :=
   let ⟨c, cmem, hc⟩ :=
     exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x hx).neg) (neg_lt_neg hma)
       (neg_lt_neg hmb)
   ⟨c, cmem, neg_injective hc⟩
 #align exists_has_deriv_within_at_eq_of_lt_of_gt exists_hasDerivWithinAt_eq_of_lt_of_gt
 
-/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set. -/
-theorem convex_image_hasDerivAt {s : Set ℝ} (hs : Convex ℝ s)
-    (hf : ∀ x ∈ s, HasDerivAt f (f' x) x) : Convex ℝ (f' '' s) :=
+/-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
+set, `has_deriv_within_at` version. -/
+theorem Set.OrdConnected.image_hasDerivWithinAt {s : Set ℝ} (hs : OrdConnected s)
+    (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : OrdConnected (f' '' s) :=
   by
-  refine' ord_connected.convex ⟨_⟩
-  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ m ⟨hma, hmb⟩
-  cases' eq_or_lt_of_le hma with hma hma
-  · exact hma ▸ mem_image_of_mem f' ha
-  cases' eq_or_lt_of_le hmb with hmb hmb
-  · exact hmb.symm ▸ mem_image_of_mem f' hb
+  apply ord_connected_of_Ioo
+  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - m ⟨hma, hmb⟩
   cases' le_total a b with hab hab
-  · have : Icc a b ⊆ s := hs.ord_connected.out ha hb
-    rcases exists_hasDerivWithinAt_eq_of_gt_of_lt hab
-        (fun x hx => (hf x <| this hx).HasDerivWithinAt) hma hmb with
+  · have : Icc a b ⊆ s := hs.out ha hb
+    rcases exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x <| this hx).mono this) hma
+        hmb with
       ⟨c, cmem, hc⟩
-    exact ⟨c, this cmem, hc⟩
-  · have : Icc b a ⊆ s := hs.ord_connected.out hb ha
-    rcases exists_hasDerivWithinAt_eq_of_lt_of_gt hab
-        (fun x hx => (hf x <| this hx).HasDerivWithinAt) hmb hma with
+    exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
+  · have : Icc b a ⊆ s := hs.out hb ha
+    rcases exists_hasDerivWithinAt_eq_of_lt_of_gt hab (fun x hx => (hf x <| this hx).mono this) hmb
+        hma with
       ⟨c, cmem, hc⟩
-    exact ⟨c, this cmem, hc⟩
-#align convex_image_has_deriv_at convex_image_hasDerivAt
+    exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
+#align set.ord_connected.image_has_deriv_within_at Set.OrdConnected.image_hasDerivWithinAt
+
+/-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
+set, `deriv_within` version. -/
+theorem Set.OrdConnected.image_derivWithin {s : Set ℝ} (hs : OrdConnected s)
+    (hf : DifferentiableOn ℝ f s) : OrdConnected (derivWithin f s '' s) :=
+  hs.image_hasDerivWithinAt fun x hx => (hf x hx).HasDerivWithinAt
+#align set.ord_connected.image_deriv_within Set.OrdConnected.image_derivWithin
+
+/-- **Darboux's theorem**: the image of an `ord_connected` set under `f'` is an `ord_connected`
+set, `deriv` version. -/
+theorem Set.OrdConnected.image_deriv {s : Set ℝ} (hs : OrdConnected s)
+    (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) : OrdConnected (deriv f '' s) :=
+  hs.image_hasDerivWithinAt fun x hx => (hf x hx).HasDerivAt.HasDerivWithinAt
+#align set.ord_connected.image_deriv Set.OrdConnected.image_deriv
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`has_deriv_within_at` version. -/
+theorem Convex.image_hasDerivWithinAt {s : Set ℝ} (hs : Convex ℝ s)
+    (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : Convex ℝ (f' '' s) :=
+  (hs.OrdConnected.image_hasDerivWithinAt hf).Convex
+#align convex.image_has_deriv_within_at Convex.image_hasDerivWithinAt
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`deriv_within` version. -/
+theorem Convex.image_derivWithin {s : Set ℝ} (hs : Convex ℝ s) (hf : DifferentiableOn ℝ f s) :
+    Convex ℝ (derivWithin f s '' s) :=
+  (hs.OrdConnected.image_derivWithin hf).Convex
+#align convex.image_deriv_within Convex.image_derivWithin
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`deriv` version. -/
+theorem Convex.image_deriv {s : Set ℝ} (hs : Convex ℝ s) (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) :
+    Convex ℝ (deriv f '' s) :=
+  (hs.OrdConnected.image_deriv hf).Convex
+#align convex.image_deriv Convex.image_deriv
+
+/-- **Darboux's theorem**: if `a ≤ b` and `f' a ≤ m ≤ f' b`, then `f' c = m` for some
+`c ∈ [a, b]`. -/
+theorem exists_hasDerivWithinAt_eq_of_ge_of_le (hab : a ≤ b)
+    (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a ≤ m)
+    (hmb : m ≤ f' b) : m ∈ f' '' Icc a b :=
+  (ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
+    (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
+#align exists_has_deriv_within_at_eq_of_ge_of_le exists_hasDerivWithinAt_eq_of_ge_of_le
+
+/-- **Darboux's theorem**: if `a ≤ b` and `f' b ≤ m ≤ f' a`, then `f' c = m` for some
+`c ∈ [a, b]`. -/
+theorem exists_hasDerivWithinAt_eq_of_le_of_ge (hab : a ≤ b)
+    (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a ≤ m)
+    (hmb : m ≤ f' b) : m ∈ f' '' Icc a b :=
+  (ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
+    (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
+#align exists_has_deriv_within_at_eq_of_le_of_ge exists_hasDerivWithinAt_eq_of_le_of_ge
 
 /-- If the derivative of a function is never equal to `m`, then either
 it is always greater than `m`, or it is always less than `m`. -/
-theorem deriv_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs : Convex ℝ s)
-    (hf : ∀ x ∈ s, HasDerivAt f (f' x) x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
+theorem hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs : Convex ℝ s)
+    (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
     (∀ x ∈ s, f' x < m) ∨ ∀ x ∈ s, m < f' x :=
   by
   contrapose! hf'
   rcases hf' with ⟨⟨b, hb, hmb⟩, ⟨a, ha, hma⟩⟩
   exact
-    (convex_image_hasDerivAt hs hf).OrdConnected.out (mem_image_of_mem f' ha)
+    (hs.ord_connected.image_has_deriv_within_at hf).out (mem_image_of_mem f' ha)
       (mem_image_of_mem f' hb) ⟨hma, hmb⟩
-#align deriv_forall_lt_or_forall_gt_of_forall_ne deriv_forall_lt_or_forall_gt_of_forall_ne
+#align has_deriv_within_at_forall_lt_or_forall_gt_of_forall_ne hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne
 
Diff
@@ -21,7 +21,7 @@ intermediate values. The proof is based on the
 
 open Filter Set
 
-open Topology Classical
+open scoped Topology Classical
 
 variable {a b : ℝ} {f f' : ℝ → ℝ}
 

Changes in mathlib4

mathlib3
mathlib4
chore: remove stream-of-conciousness syntax for obtain (#11045)

This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.

Diff
@@ -34,8 +34,7 @@ theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
   have hg : ∀ x ∈ Icc a b, HasDerivWithinAt g (f' x - m) (Icc a b) x := by
     intro x hx
     simpa using (hf x hx).sub ((hasDerivWithinAt_id x _).const_mul m)
-  obtain ⟨c, cmem, hc⟩ : ∃ c ∈ Icc a b, IsMinOn g (Icc a b) c
-  exact
+  obtain ⟨c, cmem, hc⟩ : ∃ c ∈ Icc a b, IsMinOn g (Icc a b) c :=
     isCompact_Icc.exists_forall_le (nonempty_Icc.2 <| hab) fun x hx => (hg x hx).continuousWithinAt
   have cmem' : c ∈ Ioo a b := by
     rcases cmem.1.eq_or_lt with (rfl | hac)
chore: remove uses of cases' (#9171)

I literally went through and regex'd some uses of cases', replacing them with rcases; this is meant to be a low effort PR as I hope that tools can do this in the future.

rcases is an easier replacement than cases, though with better tools we could in future do a second pass converting simple rcases added here (and existing ones) to cases.

Diff
@@ -78,7 +78,7 @@ theorem Set.OrdConnected.image_hasDerivWithinAt {s : Set ℝ} (hs : OrdConnected
     (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : OrdConnected (f' '' s) := by
   apply ordConnected_of_Ioo
   rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - m ⟨hma, hmb⟩
-  cases' le_total a b with hab hab
+  rcases le_total a b with hab | hab
   · have : Icc a b ⊆ s := hs.out ha hb
     rcases exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x <| this hx).mono this) hma
         hmb with
@@ -154,4 +154,3 @@ theorem hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs :
   exact (hs.ordConnected.image_hasDerivWithinAt hf).out (mem_image_of_mem f' ha)
     (mem_image_of_mem f' hb) ⟨hma, hmb⟩
 #align has_deriv_within_at_forall_lt_or_forall_gt_of_forall_ne hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne
-
refactor: split Analysis.Calculus.LocalExtr (#5944)

Also make f/f' arguments implicit in all versions of Rolle's Theorem.

Fixes #4830

API changes

  • exists_Ioo_extr_on_Icc:
    • generalize from functions f : ℝ → ℝ to functions from a conditionally complete linear order to a linear order.
    • make f implicit;
  • exists_local_extr_Ioo:
    • rename to exists_isLocalExtr_Ioo;
    • generalize as above;
    • make f implicit;
  • exists_isExtrOn_Ioo_of_tendsto, exists_isLocalExtr_Ioo_of_tendsto: new lemmas extracted from the proof of exists_hasDerivAt_eq_zero';
  • exists_hasDerivAt_eq_zero, exists_hasDerivAt_eq_zero': make f and f' implicit;
  • exists_deriv_eq_zero, exists_deriv_eq_zero': make f implicit.
Diff
@@ -3,7 +3,9 @@ Copyright (c) 2020 Yury Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
 -/
-import Mathlib.Analysis.Calculus.LocalExtr
+import Mathlib.Analysis.Calculus.Deriv.Add
+import Mathlib.Analysis.Calculus.Deriv.Mul
+import Mathlib.Analysis.Calculus.LocalExtr.Basic
 
 #align_import analysis.calculus.darboux from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2020 Yury Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
-
-! This file was ported from Lean 3 source module analysis.calculus.darboux
-! leanprover-community/mathlib commit 61b5e2755ccb464b68d05a9acf891ae04992d09d
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.Calculus.LocalExtr
 
+#align_import analysis.calculus.darboux from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
+
 /-!
 # Darboux's theorem
 
feat: re-port Analysis.Calculus.Darboux (#4993)

Forward-port leanprover-community/mathlib#19125 by re-porting the file.

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury Kudryashov
 
 ! This file was ported from Lean 3 source module analysis.calculus.darboux
-! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
+! leanprover-community/mathlib commit 61b5e2755ccb464b68d05a9acf891ae04992d09d
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -18,7 +18,6 @@ intermediate values. The proof is based on the
 [Wikipedia](https://en.wikipedia.org/wiki/Darboux%27s_theorem_(analysis)) page about this theorem.
 -/
 
-
 open Filter Set
 
 open scoped Topology Classical
@@ -26,14 +25,12 @@ open scoped Topology Classical
 variable {a b : ℝ} {f f' : ℝ → ℝ}
 
 /-- **Darboux's theorem**: if `a ≤ b` and `f' a < m < f' b`, then `f' c = m` for some
-`c ∈ [a, b]`. -/
+`c ∈ (a, b)`. -/
 theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
     (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a < m)
-    (hmb : m < f' b) : m ∈ f' '' Icc a b := by
-  have hab' : a < b := by
-    refine' lt_of_le_of_ne hab fun hab' => _
-    subst b
-    exact lt_asymm hma hmb
+    (hmb : m < f' b) : m ∈ f' '' Ioo a b := by
+  rcases hab.eq_or_lt with (rfl | hab')
+  · exact (lt_asymm hma hmb).elim
   set g : ℝ → ℝ := fun x => f x - m * x
   have hg : ∀ x ∈ Icc a b, HasDerivWithinAt g (f' x - m) (Icc a b) x := by
     intro x hx
@@ -42,70 +39,120 @@ theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
   exact
     isCompact_Icc.exists_forall_le (nonempty_Icc.2 <| hab) fun x hx => (hg x hx).continuousWithinAt
   have cmem' : c ∈ Ioo a b := by
-    cases' eq_or_lt_of_le cmem.1 with hac hac
+    rcases cmem.1.eq_or_lt with (rfl | hac)
     -- Show that `c` can't be equal to `a`
-    · subst c
-      refine'
-        absurd (sub_nonneg.1 <| nonneg_of_mul_nonneg_right _ (sub_pos.2 hab')) (not_le_of_lt hma)
+    · refine' absurd (sub_nonneg.1 <| nonneg_of_mul_nonneg_right _ (sub_pos.2 hab'))
+        (not_le_of_lt hma)
       have : b - a ∈ posTangentConeAt (Icc a b) a :=
         mem_posTangentConeAt_of_segment_subset (segment_eq_Icc hab ▸ Subset.refl _)
-      simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply] using
-        hc.localize.hasFDerivWithinAt_nonneg (hg a (left_mem_Icc.2 hab)) this
-    cases' eq_or_lt_of_le cmem.2 with hbc hbc
+      simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply]
+        using hc.localize.hasFDerivWithinAt_nonneg (hg a (left_mem_Icc.2 hab)) this
+    rcases cmem.2.eq_or_gt with (rfl | hcb)
     -- Show that `c` can't be equal to `b`
-    · subst c
-      refine' absurd
-        (sub_nonpos.1 <| nonpos_of_mul_nonneg_right _ (sub_lt_zero.2 hab')) (not_le_of_lt hmb)
+    · refine' absurd (sub_nonpos.1 <| nonpos_of_mul_nonneg_right _ (sub_lt_zero.2 hab'))
+        (not_le_of_lt hmb)
       have : a - b ∈ posTangentConeAt (Icc a b) b :=
         mem_posTangentConeAt_of_segment_subset (by rw [segment_symm, segment_eq_Icc hab])
-      simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply] using
-        hc.localize.hasFDerivWithinAt_nonneg (hg b (right_mem_Icc.2 hab)) this
-    exact ⟨hac, hbc⟩
-  use c, cmem
+      simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply]
+        using hc.localize.hasFDerivWithinAt_nonneg (hg b (right_mem_Icc.2 hab)) this
+    exact ⟨hac, hcb⟩
+  use c, cmem'
   rw [← sub_eq_zero]
   have : Icc a b ∈ 𝓝 c := by rwa [← mem_interior_iff_mem_nhds, interior_Icc]
   exact (hc.isLocalMin this).hasDerivAt_eq_zero ((hg c cmem).hasDerivAt this)
 #align exists_has_deriv_within_at_eq_of_gt_of_lt exists_hasDerivWithinAt_eq_of_gt_of_lt
 
-/-- **Darboux's theorem**: if `a ≤ b` and `f' a > m > f' b`, then `f' c = m` for some `c ∈ [a, b]`.
+/-- **Darboux's theorem**: if `a ≤ b` and `f' b < m < f' a`, then `f' c = m` for some `c ∈ (a, b)`.
 -/
 theorem exists_hasDerivWithinAt_eq_of_lt_of_gt (hab : a ≤ b)
     (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : m < f' a)
-    (hmb : f' b < m) : m ∈ f' '' Icc a b :=
-  let ⟨c, cmem, hc⟩ := exists_hasDerivWithinAt_eq_of_gt_of_lt
-    hab (fun x hx => (hf x hx).neg) (neg_lt_neg hma) (neg_lt_neg hmb)
+    (hmb : f' b < m) : m ∈ f' '' Ioo a b :=
+  let ⟨c, cmem, hc⟩ :=
+    exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x hx).neg) (neg_lt_neg hma)
+      (neg_lt_neg hmb)
   ⟨c, cmem, neg_injective hc⟩
 #align exists_has_deriv_within_at_eq_of_lt_of_gt exists_hasDerivWithinAt_eq_of_lt_of_gt
 
-/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set. -/
-theorem convex_image_hasDerivAt {s : Set ℝ} (hs : Convex ℝ s)
-    (hf : ∀ x ∈ s, HasDerivAt f (f' x) x) : Convex ℝ (f' '' s) := by
-  refine' OrdConnected.convex ⟨_⟩
-  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ m ⟨hma, hmb⟩
-  cases' eq_or_lt_of_le hma with hma hma
-  · exact hma ▸ mem_image_of_mem f' ha
-  cases' eq_or_lt_of_le hmb with hmb hmb
-  · exact hmb.symm ▸ mem_image_of_mem f' hb
+/-- **Darboux's theorem**: the image of a `Set.OrdConnected` set under `f'` is a `Set.OrdConnected`
+set, `HasDerivWithinAt` version. -/
+theorem Set.OrdConnected.image_hasDerivWithinAt {s : Set ℝ} (hs : OrdConnected s)
+    (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : OrdConnected (f' '' s) := by
+  apply ordConnected_of_Ioo
+  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - m ⟨hma, hmb⟩
   cases' le_total a b with hab hab
-  · have : Icc a b ⊆ s := hs.ordConnected.out ha hb
-    rcases exists_hasDerivWithinAt_eq_of_gt_of_lt hab
-        (fun x hx => (hf x <| this hx).hasDerivWithinAt) hma hmb with
+  · have : Icc a b ⊆ s := hs.out ha hb
+    rcases exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x <| this hx).mono this) hma
+        hmb with
       ⟨c, cmem, hc⟩
-    exact ⟨c, this cmem, hc⟩
-  · have : Icc b a ⊆ s := hs.ordConnected.out hb ha
-    rcases exists_hasDerivWithinAt_eq_of_lt_of_gt hab
-        (fun x hx => (hf x <| this hx).hasDerivWithinAt) hmb hma with
+    exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
+  · have : Icc b a ⊆ s := hs.out hb ha
+    rcases exists_hasDerivWithinAt_eq_of_lt_of_gt hab (fun x hx => (hf x <| this hx).mono this) hmb
+        hma with
       ⟨c, cmem, hc⟩
-    exact ⟨c, this cmem, hc⟩
-#align convex_image_has_deriv_at convex_image_hasDerivAt
+    exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
+#align set.ord_connected.image_has_deriv_within_at Set.OrdConnected.image_hasDerivWithinAt
+
+/-- **Darboux's theorem**: the image of a `Set.OrdConnected` set under `f'` is a `Set.OrdConnected`
+set, `derivWithin` version. -/
+theorem Set.OrdConnected.image_derivWithin {s : Set ℝ} (hs : OrdConnected s)
+    (hf : DifferentiableOn ℝ f s) : OrdConnected (derivWithin f s '' s) :=
+  hs.image_hasDerivWithinAt fun x hx => (hf x hx).hasDerivWithinAt
+#align set.ord_connected.image_deriv_within Set.OrdConnected.image_derivWithin
+
+/-- **Darboux's theorem**: the image of a `Set.OrdConnected` set under `f'` is a `Set.OrdConnected`
+set, `deriv` version. -/
+theorem Set.OrdConnected.image_deriv {s : Set ℝ} (hs : OrdConnected s)
+    (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) : OrdConnected (deriv f '' s) :=
+  hs.image_hasDerivWithinAt fun x hx => (hf x hx).hasDerivAt.hasDerivWithinAt
+#align set.ord_connected.image_deriv Set.OrdConnected.image_deriv
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`HasDerivWithinAt` version. -/
+theorem Convex.image_hasDerivWithinAt {s : Set ℝ} (hs : Convex ℝ s)
+    (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : Convex ℝ (f' '' s) :=
+  (hs.ordConnected.image_hasDerivWithinAt hf).convex
+#align convex.image_has_deriv_within_at Convex.image_hasDerivWithinAt
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`derivWithin` version. -/
+theorem Convex.image_derivWithin {s : Set ℝ} (hs : Convex ℝ s) (hf : DifferentiableOn ℝ f s) :
+    Convex ℝ (derivWithin f s '' s) :=
+  (hs.ordConnected.image_derivWithin hf).convex
+#align convex.image_deriv_within Convex.image_derivWithin
+
+/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
+`deriv` version. -/
+theorem Convex.image_deriv {s : Set ℝ} (hs : Convex ℝ s) (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) :
+    Convex ℝ (deriv f '' s) :=
+  (hs.ordConnected.image_deriv hf).convex
+#align convex.image_deriv Convex.image_deriv
+
+/-- **Darboux's theorem**: if `a ≤ b` and `f' a ≤ m ≤ f' b`, then `f' c = m` for some
+`c ∈ [a, b]`. -/
+theorem exists_hasDerivWithinAt_eq_of_ge_of_le (hab : a ≤ b)
+    (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a ≤ m)
+    (hmb : m ≤ f' b) : m ∈ f' '' Icc a b :=
+  (ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
+    (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
+#align exists_has_deriv_within_at_eq_of_ge_of_le exists_hasDerivWithinAt_eq_of_ge_of_le
+
+/-- **Darboux's theorem**: if `a ≤ b` and `f' b ≤ m ≤ f' a`, then `f' c = m` for some
+`c ∈ [a, b]`. -/
+theorem exists_hasDerivWithinAt_eq_of_le_of_ge (hab : a ≤ b)
+    (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a ≤ m)
+    (hmb : m ≤ f' b) : m ∈ f' '' Icc a b :=
+  (ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
+    (mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
+#align exists_has_deriv_within_at_eq_of_le_of_ge exists_hasDerivWithinAt_eq_of_le_of_ge
 
 /-- If the derivative of a function is never equal to `m`, then either
 it is always greater than `m`, or it is always less than `m`. -/
-theorem deriv_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs : Convex ℝ s)
-    (hf : ∀ x ∈ s, HasDerivAt f (f' x) x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
+theorem hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs : Convex ℝ s)
+    (hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
     (∀ x ∈ s, f' x < m) ∨ ∀ x ∈ s, m < f' x := by
   contrapose! hf'
   rcases hf' with ⟨⟨b, hb, hmb⟩, ⟨a, ha, hma⟩⟩
-  exact (convex_image_hasDerivAt hs hf).ordConnected.out
-    (mem_image_of_mem f' ha) (mem_image_of_mem f' hb) ⟨hma, hmb⟩
-#align deriv_forall_lt_or_forall_gt_of_forall_ne deriv_forall_lt_or_forall_gt_of_forall_ne
+  exact (hs.ordConnected.image_hasDerivWithinAt hf).out (mem_image_of_mem f' ha)
+    (mem_image_of_mem f' hb) ⟨hma, hmb⟩
+#align has_deriv_within_at_forall_lt_or_forall_gt_of_forall_ne hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne
+
feat: port Analysis.Calculus.Darboux (#4483)

Dependencies 10 + 743

744 files ported (98.7%)
330407 lines ported (98.4%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file