|
| 1 | +/- |
| 2 | +Copyright (c) 2025 Mitchell Horner. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Mitchell Horner |
| 5 | +-/ |
| 6 | +import Mathlib.Analysis.Convex.Function |
| 7 | + |
| 8 | +/-! |
| 9 | +# Convex and concave piecewise functions |
| 10 | +
|
| 11 | +This file proves convex and concave theorems for piecewise functions. |
| 12 | +
|
| 13 | +## Main statements |
| 14 | +
|
| 15 | +* `convexOn_univ_piecewise_Iic_of_antitoneOn_Iic_monotoneOn_Ici` is the proof that the piecewise |
| 16 | + function `(Set.Iic e).piecewise f g` of a function `f` decreasing and convex on `Set.Iic e` and a |
| 17 | + function `g` increasing and convex on `Set.Ici e`, such that `f e = g e`, is convex on the |
| 18 | + universal set. |
| 19 | +
|
| 20 | + This version has the boundary point included in the left-hand function. |
| 21 | +
|
| 22 | + See `convexOn_univ_piecewise_Ici_of_monotoneOn_Ici_antitoneOn_Iic` for the version with the |
| 23 | + boundary point included in the right-hand function. |
| 24 | +
|
| 25 | + See concave version(s) `concaveOn_univ_piecewise_Iic_of_monotoneOn_Iic_antitoneOn_Ici` |
| 26 | + and `concaveOn_univ_piecewise_Ici_of_antitoneOn_Ici_monotoneOn_Iic`. |
| 27 | +-/ |
| 28 | + |
| 29 | + |
| 30 | +variable {𝕜 E β : Type*} [OrderedSemiring 𝕜] [LinearOrderedAddCommMonoid E] [Module 𝕜 E] |
| 31 | + [OrderedSMul 𝕜 E] [OrderedAddCommGroup β] [Module 𝕜 β] [PosSMulMono 𝕜 β] {e : E} {f g : E → β} |
| 32 | + |
| 33 | +/-- The piecewise function `(Set.Iic e).piecewise f g` of a function `f` decreasing and convex on |
| 34 | +`Set.Iic e` and a function `g` increasing and convex on `Set.Ici e`, such that `f e = g e`, is |
| 35 | +convex on the universal set. -/ |
| 36 | +theorem convexOn_univ_piecewise_Iic_of_antitoneOn_Iic_monotoneOn_Ici |
| 37 | + (hf : ConvexOn 𝕜 (Set.Iic e) f) (hg : ConvexOn 𝕜 (Set.Ici e) g) |
| 38 | + (h_anti : AntitoneOn f (Set.Iic e)) (h_mono : MonotoneOn g (Set.Ici e)) (h_eq : f e = g e) : |
| 39 | + ConvexOn 𝕜 Set.univ ((Set.Iic e).piecewise f g) := by |
| 40 | + refine ⟨convex_univ, fun x _ y _ a b ha hb hab ↦ ?_⟩ |
| 41 | + by_cases hx : x ≤ e <;> by_cases hy : y ≤ e <;> push_neg at hx hy |
| 42 | + · have hc : a • x + b • y ≤ e := (Convex.combo_le_max x y ha hb hab).trans (max_le hx hy) |
| 43 | + rw [Set.piecewise_eq_of_mem (Set.Iic e) f g hx, Set.piecewise_eq_of_mem (Set.Iic e) f g hy, |
| 44 | + Set.piecewise_eq_of_mem (Set.Iic e) f g hc] |
| 45 | + exact hf.2 hx hy ha hb hab |
| 46 | + · rw [Set.piecewise_eq_of_mem (Set.Iic e) f g hx, |
| 47 | + Set.piecewise_eq_of_not_mem (Set.Iic e) f g (Set.not_mem_Iic.mpr hy)] |
| 48 | + by_cases hc : a • x + b • y ≤ e <;> push_neg at hc |
| 49 | + · rw [Set.piecewise_eq_of_mem (Set.Iic e) f g hc] |
| 50 | + have hc' : a • x + b • e ≤ a • x + b • y := |
| 51 | + add_le_add_left (smul_le_smul_of_nonneg_left hy.le hb) (a • x) |
| 52 | + trans a • f x + b • f e |
| 53 | + · exact (h_anti (hc'.trans hc) hc hc').trans (hf.2 hx Set.right_mem_Iic ha hb hab) |
| 54 | + · rw [add_le_add_iff_left, h_eq] |
| 55 | + exact smul_le_smul_of_nonneg_left (h_mono Set.left_mem_Ici hy.le hy.le) hb |
| 56 | + · rw [Set.piecewise_eq_of_not_mem (Set.Iic e) f g (Set.not_mem_Iic.mpr hc)] |
| 57 | + have hc' : a • x + b • y ≤ a • e + b • y := |
| 58 | + add_le_add_right (smul_le_smul_of_nonneg_left hx ha) (b • y) |
| 59 | + trans a • g e + b • g y |
| 60 | + · exact (h_mono hc.le (hc.le.trans hc') hc').trans (hg.2 Set.left_mem_Ici hy.le ha hb hab) |
| 61 | + · rw [add_le_add_iff_right, ← h_eq] |
| 62 | + exact smul_le_smul_of_nonneg_left (h_anti hx Set.right_mem_Iic hx) ha |
| 63 | + · rw [Set.piecewise_eq_of_not_mem (Set.Iic e) f g (Set.not_mem_Iic.mpr hx), |
| 64 | + Set.piecewise_eq_of_mem (Set.Iic e) f g hy] |
| 65 | + by_cases hc : a • x + b • y ≤ e <;> push_neg at hc |
| 66 | + · rw [Set.piecewise_eq_of_mem (Set.Iic e) f g hc] |
| 67 | + have hc' : a • e + b • y ≤ a • x + b • y := |
| 68 | + add_le_add_right (smul_le_smul_of_nonneg_left hx.le ha) (b • y) |
| 69 | + trans a • f e + b • f y |
| 70 | + · exact (h_anti (hc'.trans hc) hc hc').trans (hf.2 Set.right_mem_Iic hy ha hb hab) |
| 71 | + · rw [add_le_add_iff_right, h_eq] |
| 72 | + exact smul_le_smul_of_nonneg_left (h_mono Set.left_mem_Ici hx.le hx.le) ha |
| 73 | + · rw [Set.piecewise_eq_of_not_mem (Set.Iic e) f g (Set.not_mem_Iic.mpr hc)] |
| 74 | + have hc' : a • x + b • y ≤ a • x + b • e := |
| 75 | + add_le_add_left (smul_le_smul_of_nonneg_left hy hb) (a • x) |
| 76 | + trans a • g x + b • g e |
| 77 | + · exact (h_mono hc.le (hc.le.trans hc') hc').trans (hg.2 hx.le Set.left_mem_Ici ha hb hab) |
| 78 | + · rw [add_le_add_iff_left, ← h_eq] |
| 79 | + exact smul_le_smul_of_nonneg_left (h_anti hy Set.right_mem_Iic hy) hb |
| 80 | + · have hc : e < a • x + b • y := |
| 81 | + (lt_min hx hy).trans_le (Convex.min_le_combo x y ha hb hab) |
| 82 | + rw [(Set.Iic e).piecewise_eq_of_not_mem f g (Set.not_mem_Iic.mpr hx), |
| 83 | + (Set.Iic e).piecewise_eq_of_not_mem f g (Set.not_mem_Iic.mpr hy), |
| 84 | + (Set.Iic e).piecewise_eq_of_not_mem f g (Set.not_mem_Iic.mpr hc)] |
| 85 | + exact hg.2 hx.le hy.le ha hb hab |
| 86 | + |
| 87 | +/-- The piecewise function `(Set.Ici e).piecewise f g` of a function `f` increasing and convex on |
| 88 | +`Set.Ici e` and a function `g` decreasing and convex on `Set.Iic e`, such that `f e = g e`, is |
| 89 | +convex on the universal set. -/ |
| 90 | +theorem convexOn_univ_piecewise_Ici_of_monotoneOn_Ici_antitoneOn_Iic |
| 91 | + (hf : ConvexOn 𝕜 (Set.Ici e) f) (hg : ConvexOn 𝕜 (Set.Iic e) g) |
| 92 | + (h_mono : MonotoneOn f (Set.Ici e)) (h_anti : AntitoneOn g (Set.Iic e)) (h_eq : f e = g e) : |
| 93 | + ConvexOn 𝕜 Set.univ ((Set.Ici e).piecewise f g) := by |
| 94 | + have h_piecewise_Ici_eq_piecewise_Iic : |
| 95 | + (Set.Ici e).piecewise f g = (Set.Iic e).piecewise g f := by |
| 96 | + ext x; by_cases hx : x = e |
| 97 | + <;> simp [Set.piecewise, @le_iff_lt_or_eq _ _ x e, ← @ite_not _ (e ≤ _), hx, h_eq] |
| 98 | + rw [h_piecewise_Ici_eq_piecewise_Iic] |
| 99 | + exact convexOn_univ_piecewise_Iic_of_antitoneOn_Iic_monotoneOn_Ici hg hf h_anti h_mono h_eq.symm |
| 100 | + |
| 101 | +/-- The piecewise function `(Set.Iic e).piecewise f g` of a function `f` increasing and concave on |
| 102 | +`Set.Iic e` and a function `g` decreasing and concave on `Set.Ici e`, such that `f e = g e`, is |
| 103 | +concave on the universal set. -/ |
| 104 | +theorem concaveOn_univ_piecewise_Iic_of_monotoneOn_Iic_antitoneOn_Ici |
| 105 | + (hf : ConcaveOn 𝕜 (Set.Iic e) f) (hg : ConcaveOn 𝕜 (Set.Ici e) g) |
| 106 | + (h_mono : MonotoneOn f (Set.Iic e)) (h_anti : AntitoneOn g (Set.Ici e)) (h_eq : f e = g e) : |
| 107 | + ConcaveOn 𝕜 Set.univ ((Set.Iic e).piecewise f g) := by |
| 108 | + rw [← neg_convexOn_iff, ← Set.piecewise_neg] |
| 109 | + exact convexOn_univ_piecewise_Iic_of_antitoneOn_Iic_monotoneOn_Ici |
| 110 | + hf.neg hg.neg h_mono.neg h_anti.neg (neg_inj.mpr h_eq) |
| 111 | + |
| 112 | +/-- The piecewise function `(Set.Ici e).piecewise f g` of a function `f` decreasing and concave on |
| 113 | +`Set.Ici e` and a function `g` increasing and concave on `Set.Iic e`, such that `f e = g e`, is |
| 114 | +concave on the universal set. -/ |
| 115 | +theorem concaveOn_univ_piecewise_Ici_of_antitoneOn_Ici_monotoneOn_Iic |
| 116 | + (hf : ConcaveOn 𝕜 (Set.Ici e) f) (hg : ConcaveOn 𝕜 (Set.Iic e) g) |
| 117 | + (h_anti : AntitoneOn f (Set.Ici e)) (h_mono : MonotoneOn g (Set.Iic e)) (h_eq : f e = g e) : |
| 118 | + ConcaveOn 𝕜 Set.univ ((Set.Ici e).piecewise f g) := by |
| 119 | + rw [← neg_convexOn_iff, ← Set.piecewise_neg] |
| 120 | + exact convexOn_univ_piecewise_Ici_of_monotoneOn_Ici_antitoneOn_Iic |
| 121 | + hf.neg hg.neg h_anti.neg h_mono.neg (neg_inj.mpr h_eq) |
0 commit comments