Analysis I, Section 10.2: Local maxima, local minima, and derivatives

I have attempted to make the translation as faithful a paraphrasing as possible of the original text. When there is a choice between a more idiomatic Lean solution and a more faithful translation, I have generally chosen the latter. In particular, there will be places where the Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided doing so.

Main constructions and results of this section:

open Chapter9namespace Chapter10

Definition 10.2.1 (Local maxima and minima). Here we use Mathlib's IsLocalMaxOn.{u, v} {α : Type u} {β : Type v} [TopologicalSpace α] [Preorder β] (f : α β) (s : Set α) (a : α) : PropIsLocalMaxOn type.

theorem IsLocalMaxOn.iff (X:Set ) (f: ) (x₀:) : IsLocalMaxOn f X x₀ δ > 0, IsMaxOn f (X .Ioo (x₀ - δ) (x₀ + δ)) x₀ := X:Set f: x₀:IsLocalMaxOn f X x₀ δ > 0, IsMaxOn f (X Set.Ioo (x₀ - δ) (x₀ + δ)) x₀ X:Set f: x₀:(∃ ε, 0 < ε y : ⦄, y - x₀ < ε x₀ - y < ε y X f y f x₀) δ, 0 < δ x X, x₀ - δ < x x < x₀ + δ f x f x₀ X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f a✝ f x₀ a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f a✝ f x₀; X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f a✝ f x₀) a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f a✝ f x₀X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f a✝ f x₀) a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f a✝ f x₀ X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f a✝ f x₀) a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f a✝ f x₀X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f a✝ f x₀) a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f a✝ f x₀ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xf a✝³ f x₀ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f a✝³ f x₀a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵f a✝³ f x₀X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xf a✝³ f x₀ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ XX:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xx₀ - a✝⁵ < a✝³X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ < x₀ + a✝⁵ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f a✝³ f x₀a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵a✝³ - x₀ < a✝⁵X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f a✝³ f x₀a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵x₀ - a✝³ < a✝⁵X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f a✝³ f x₀a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵a✝³ XX:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ XX:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xx₀ - a✝⁵ < a✝³X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f a✝³ f x₀a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ < x₀ + a✝⁵ All goals completed! 🐙
theorem IsLocalMinOn.iff (X:Set ) (f: ) (x₀:) : IsLocalMinOn f X x₀ δ > 0, IsMinOn f (X .Ioo (x₀ - δ) (x₀ + δ)) x₀ := X:Set f: x₀:IsLocalMinOn f X x₀ δ > 0, IsMinOn f (X Set.Ioo (x₀ - δ) (x₀ + δ)) x₀ X:Set f: x₀:(∃ ε, 0 < ε y : ⦄, y - x₀ < ε x₀ - y < ε y X f x₀ f y) δ, 0 < δ x X, x₀ - δ < x x < x₀ + δ f x₀ f x X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f x₀ f a✝ a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f x₀ f a✝; X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f x₀ f a✝) a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f x₀ f a✝X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f x₀ f a✝) a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f x₀ f a✝ X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f x₀ f a✝) a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f x₀ f a✝X:Set f: x₀:a✝²:a✝¹:0 < a✝²a✝:(a✝ X x₀ - a✝² < a✝ a✝ < x₀ + a✝² f x₀ f a✝) a✝ - x₀ < a✝² x₀ - a✝ < a✝² a✝ X f x₀ f a✝ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xf x₀ f a✝³ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f x₀ f a✝³a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵f x₀ f a✝³X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xf x₀ f a✝³ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ XX:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xx₀ - a✝⁵ < a✝³X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ < x₀ + a✝⁵ X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f x₀ f a✝³a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵a✝³ - x₀ < a✝⁵X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f x₀ f a✝³a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵x₀ - a✝³ < a✝⁵X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ - x₀ < a✝⁵ x₀ - a✝³ < a✝⁵ a✝³ X f x₀ f a✝³a✝²:a✝³ Xa✝¹:x₀ - a✝⁵ < a✝³a✝:a✝³ < x₀ + a✝⁵a✝³ XX:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ XX:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xx₀ - a✝⁵ < a✝³X:Set f: x₀:a✝⁵:a✝⁴:0 < a✝⁵a✝³:h:a✝³ X x₀ - a✝⁵ < a✝³ a✝³ < x₀ + a✝⁵ f x₀ f a✝³a✝²:a✝³ - x₀ < a✝⁵a✝¹:x₀ - a✝³ < a✝⁵a✝:a✝³ Xa✝³ < x₀ + a✝⁵ All goals completed! 🐙

Example 10.2.3

abbrev f_10_2_3 : := fun x x^2 - x^4
declaration uses 'sorry'example : ¬ IsMinOn f_10_2_3 .univ 0 := ¬IsMinOn f_10_2_3 Set.univ 0 All goals completed! 🐙declaration uses 'sorry'example : IsMinOn f_10_2_3 (.Ioo (-1) 1) 0 := IsMinOn f_10_2_3 (Set.Ioo (-1) 1) 0 All goals completed! 🐙declaration uses 'sorry'example : IsLocalMaxOn f_10_2_3 .univ 0 := IsLocalMaxOn f_10_2_3 Set.univ 0 All goals completed! 🐙

Example 10.2.4

declaration uses 'sorry'example : ¬ x, IsMaxOn (·: ) ((·: ) '' .univ) x := ¬ x, IsMaxOn (fun x => x) ((fun x => x) '' Set.univ) x All goals completed! 🐙
declaration uses 'sorry'example : ¬ x, IsMinOn (·: ) ((·: ) '' .univ) x := ¬ x, IsMinOn (fun x => x) ((fun x => x) '' Set.univ) x All goals completed! 🐙declaration uses 'sorry'example (n:) : IsMaxOn (·: ) ((·: ) '' .univ) n := n:IsMaxOn (fun x => x) ((fun x => x) '' Set.univ) n All goals completed! 🐙declaration uses 'sorry'example (n:) : IsMinOn (·: ) ((·: ) '' .univ) n := n:IsMinOn (fun x => x) ((fun x => x) '' Set.univ) n All goals completed! 🐙

Remark 10.2.5

theorem declaration uses 'sorry'IsLocalMaxOn.of_restrict {X Y:Set } (hXY: Y X) (f: ) (x₀:) (h: IsLocalMaxOn f X x₀) : IsLocalMaxOn f Y x₀ := X:Set Y:Set hXY:Y Xf: x₀:h:IsLocalMaxOn f X x₀IsLocalMaxOn f Y x₀ All goals completed! 🐙
theorem declaration uses 'sorry'IsLocalMinOn.of_restrict {X Y:Set } (hXY: Y X) (f: ) (x₀:) (h: IsLocalMinOn f X x₀) : IsLocalMinOn f Y x₀ := X:Set Y:Set hXY:Y Xf: x₀:h:IsLocalMinOn f X x₀IsLocalMinOn f Y x₀ All goals completed! 🐙

Proposition 10.2.6 (Local extrema are stationary) / Exercise 10.2.1

theorem declaration uses 'sorry'IsLocalMaxOn.deriv_eq_zero {a b:} (hab: a < b) {f: } {x₀:} (hx₀: x₀ Set.Ioo a b) (h: IsLocalMaxOn f (.Ioo a b) x₀) {L:} (hderiv: HasDerivWithinAt f L (.Ioo a b) x₀) : L = 0 := a:b:hab:a < bf: x₀:hx₀:x₀ Set.Ioo a bh:IsLocalMaxOn f (Set.Ioo a b) x₀L:hderiv:HasDerivWithinAt f L (Set.Ioo a b) x₀L = 0 All goals completed! 🐙

Proposition 10.2.6 (Local extrema are stationary) / Exercise 10.2.1

theorem declaration uses 'sorry'IsLocalMinOn.deriv_eq_zero {a b:} (hab: a < b) {f: } {x₀:} (hx₀: x₀ Set.Ioo a b) (h: IsLocalMinOn f (.Ioo a b) x₀) {L:} (hderiv: HasDerivWithinAt f L (.Ioo a b) x₀) : L = 0 := a:b:hab:a < bf: x₀:hx₀:x₀ Set.Ioo a bh:IsLocalMinOn f (Set.Ioo a b) x₀L:hderiv:HasDerivWithinAt f L (Set.Ioo a b) x₀L = 0 All goals completed! 🐙
theorem declaration uses 'sorry'IsMaxOn.deriv_eq_zero_counter : (a b:) (hab: a < b) (f: ) (x₀:) (hx₀: x₀ Set.Icc a b) (h: IsMaxOn f (.Icc a b) x₀) (L:) (hderiv: HasDerivWithinAt f L (.Icc a b) x₀), L 0 := a b, (_ : a < b), f x₀, (_ : x₀ Set.Icc a b) (_ : IsMaxOn f (Set.Icc a b) x₀), L, (_ : HasDerivWithinAt f L (Set.Icc a b) x₀), L 0 All goals completed! 🐙

Theorem 10.2.7 (Rolle's theorem) / Exercise 10.2.4

theorem declaration uses 'sorry'_root_.HasDerivWithinAt.exist_zero {a b:} (hab: a < b) {g: } (hcont: ContinuousOn g (.Icc a b)) (hderiv: DifferentiableOn g (.Ioo a b)) (hgab: g a = g b) : x Set.Ioo a b, HasDerivWithinAt g 0 (.Ioo a b) x := a:b:hab:a < bg: hcont:ContinuousOn g (Set.Icc a b)hderiv:DifferentiableOn g (Set.Ioo a b)hgab:g a = g b x Set.Ioo a b, HasDerivWithinAt g 0 (Set.Ioo a b) x All goals completed! 🐙

Corollary 10.2.9 (Mean value theorem ) / Exercise 10.2.5

theorem declaration uses 'sorry'_root_.HasDerivWithinAt.mean_value {a b:} (hab: a < b) {f: } (hcont: ContinuousOn f (.Icc a b)) (hderiv: DifferentiableOn f (.Ioo a b)) : x Set.Ioo a b, HasDerivWithinAt f ((f b - f a) / (b - a)) (.Ioo a b) x := a:b:hab:a < bf: hcont:ContinuousOn f (Set.Icc a b)hderiv:DifferentiableOn f (Set.Ioo a b) x Set.Ioo a b, HasDerivWithinAt f ((f b - f a) / (b - a)) (Set.Ioo a b) x All goals completed! 🐙

Exercise 10.2.2

declaration uses 'sorry'example : f: , ContinuousOn f (.Icc (-1) 1) IsMaxOn f (.Icc (-1) 1) 0 ¬ DifferentiableWithinAt f (.Icc (-1) 1) 0 := f, ContinuousOn f (Set.Icc (-1) 1) IsMaxOn f (Set.Icc (-1) 1) 0 ¬DifferentiableWithinAt f (Set.Icc (-1) 1) 0 All goals completed! 🐙

Exercise 10.2.3

declaration uses 'sorry'example : f: , DifferentiableOn f (.Icc (-1) 1) HasDerivWithinAt f 0 (.Ioo (-1) 1) 0 ¬ IsLocalMaxOn f (.Icc (-1) 1) 0 ¬ IsLocalMinOn f (.Icc (-1) 1) 0 := f, DifferentiableOn f (Set.Icc (-1) 1) HasDerivWithinAt f 0 (Set.Ioo (-1) 1) 0 ¬IsLocalMaxOn f (Set.Icc (-1) 1) 0 ¬IsLocalMinOn f (Set.Icc (-1) 1) 0 All goals completed! 🐙

Exercise 10.2.6

theorem declaration uses 'sorry'lipschitz_bound {M a b:} (hM: M > 0) (hab: a < b) {f: } (hcont: ContinuousOn f (.Icc a b)) (hderiv: DifferentiableOn f (.Ioo a b)) (hlip: x Set.Ioo a b, |derivWithin f (.Ioo a b) x| M) {x y:} (hx: x Set.Ioo a b) (hy: y Set.Ioo a b) : |f x - f y| M * |x - y| := M:a:b:hM:M > 0hab:a < bf: hcont:ContinuousOn f (Set.Icc a b)hderiv:DifferentiableOn f (Set.Ioo a b)hlip: x Set.Ioo a b, |derivWithin f (Set.Ioo a b) x| Mx:y:hx:x Set.Ioo a bhy:y Set.Ioo a b|f x - f y| M * |x - y| All goals completed! 🐙

Exercise 10.2.7

theorem declaration uses 'sorry'_root_.UniformContinuousOn.of_lipschitz {f: } (hcont: ContinuousOn f .univ) (hderiv: DifferentiableOn f .univ) (hlip: BddOn (deriv f) .univ) : UniformContinuousOn f (.univ) := f: hcont:ContinuousOn f Set.univhderiv:DifferentiableOn f Set.univhlip:BddOn (deriv f) Set.univUniformContinuousOn f Set.univ All goals completed! 🐙
end Chapter10