forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApproximation.lean
More file actions
279 lines (243 loc) · 14.9 KB
/
Approximation.lean
File metadata and controls
279 lines (243 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/-
Copyright (c) 2026 Yongxi Lin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yongxi Lin
-/
module
public import Mathlib.Analysis.LocallyConvex.Separation
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.Normed.Order.Lattice
import Mathlib.Topology.Semicontinuity.Lindelof
/-!
# Approximation to convex functions
In this file we show that a convex lower-semicontinuous function is the upper envelope of a family
of continuous affine linear functions. We follow the proof in
[N. Bourbaki, *Topological vector spaces*, Chapter II, §5][bourbaki1987].
## Main Statement
* `sSup_affine_eq` : A function `φ : E → ℝ` that is convex and lower-semicontinuous on a closed
convex subset `s` is the supremum of a family of functions that are the restrictions to `s` of
continuous affine linear functions.
* `sSup_of_countable_affine_eq` : Suppose `E` is a `HereditarilyLindelofSpace`. A function
`φ : E → ℝ` that is convex and lower-semicontinuous on a closed convex subset `s` is the supremum
of a family of countably many functions that are the restrictions to `s` of continuous affine
linear functions.
-/
@[expose] public section
open Function Set RCLike ContinuousLinearMap
namespace ConvexOn
variable {𝕜 E F : Type*} {s : Set E} {φ : E → ℝ} [RCLike 𝕜]
theorem convex_re_epigraph [AddCommMonoid E] [Module ℝ E] (hφcv : ConvexOn ℝ s φ) :
Convex ℝ { p : E × 𝕜 | p.1 ∈ s ∧ φ p.1 ≤ re p.2 } := by
have lem : { p : E × 𝕜 | p.1 ∈ s ∧ φ p.1 ≤ re p.2 } =
((LinearMap.id : E →ₗ[ℝ] E).prodMap reLm) ⁻¹' { p : E × ℝ | p.1 ∈ s ∧ φ p.1 ≤ p.2 } := by simp
exact lem ▸ hφcv.convex_epigraph.linear_preimage _
variable [TopologicalSpace E]
theorem _root_.LowerSemicontinuousOn.isClosed_re_epigraph (hsc : IsClosed s)
(hφ_cont : LowerSemicontinuousOn φ s) :
IsClosed { p : E × 𝕜 | p.1 ∈ s ∧ φ p.1 ≤ re p.2 } := by
let A := { p : E × EReal | p.1 ∈ s ∧ φ p.1 ≤ p.2 }
have hC : { p : E × 𝕜 | p.1 ∈ s ∧ φ p.1 ≤ re p.2 }
= (Prod.map id ((Real.toEReal ∘ re) : 𝕜 → EReal)) ⁻¹' A := by simp [A]
refine hC.symm ▸ IsClosed.preimage ?_ ?_
· exact continuous_id.prodMap <| continuous_coe_real_ereal.comp reCLM.cont
· exact (lowerSemicontinuousOn_iff_isClosed_epigraph hsc).1
(continuous_coe_real_ereal.comp_lowerSemicontinuousOn hφ_cont (EReal.coe_strictMono.monotone))
section RCLike
variable [AddCommGroup E] [Module ℝ E] [Module 𝕜 E] [IsScalarTower ℝ 𝕜 E] [IsTopologicalAddGroup E]
[ContinuousSMul 𝕜 E] [LocallyConvexSpace ℝ E]
/-- Let `φ : E → ℝ` be a convex and lower-semicontinuous function on a closed convex subset `s`. For
any point `x ∈ s` and `a < φ x`, there exists a continuous affine linear function `f` in `E` such
that `f ≤ φ` on `s` and `f x = a`. This is an auxiliary lemma used in the proof of
`ConvexOn.sSup_affine_eq.` -/
lemma exists_affine_le_of_lt {x : E} {a : ℝ} (hx : x ∈ s) (hax : a < φ x) (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
∃ (l : E →L[𝕜] 𝕜) (c : ℝ),
s.restrict (re ∘ l) + const s c ≤ s.restrict φ ∧ re (l x) + c = a := by
let A := { p : E × 𝕜 | p.1 ∈ s ∧ φ p.1 ≤ re p.2 }
obtain ⟨L, ⟨b, hLb⟩⟩ := geometric_hahn_banach_point_closed (𝕜 := 𝕜) hφcv.convex_re_epigraph
(hφc.isClosed_re_epigraph hsc) (by simp [A, hax] : (x, ofReal a) ∉ A)
let u := L.comp (.inl 𝕜 E 𝕜)
let c := (re (L (0, 1)))⁻¹
refine ⟨- c • u, c * re (u x) + a, fun z => ?_, ?_⟩
· have hv (v : 𝕜) : v * L (0, 1) = L (0, v) := by rw [← smul_eq_mul, ← map_smul]; simp
have hine {w : E} (h : w ∈ s) : re (L (x, 0)) + re (L (0, 1)) * a
< re (L (w, 0)) + re (L (0, 1)) * φ w := by
have hw := hLb.1.trans (hLb.2 _ (by simp [A, h] : (w, ofReal (φ w)) ∈ A))
rw [← coprod_comp_inl_inr L] at hw
simpa [-coprod_comp_inl_inr, ← hv (ofReal a), ← hv (ofReal (φ w)), mul_comm a,
mul_comm (φ w)] using hw
have hc : 0 < c := inv_pos.2 (pos_of_right_mul_lt_le (lt_of_add_lt_add_left (hine hx)) hax.le)
simpa [smul_re, u, c, mul_add, ← mul_assoc, inv_mul_cancel₀ (ne_of_gt (inv_pos.1 hc))]
using mul_le_mul_of_nonneg_left (hine z.2).le hc.le
· simp [u, c, smul_re]
lemma exists_affine_le_of_lt_real {s : Set ℝ} {f : ℝ → ℝ} {x : ℝ} {a : ℝ} (hx : x ∈ s)
(hax : a < f x) (hsc : IsClosed s) (hfc : LowerSemicontinuousOn f s) (hf : ConvexOn ℝ s f) :
∃ (c c' : ℝ), (∀ y ∈ s, c * y + c' ≤ f y) ∧ c * x + c' = a := by
obtain ⟨l, c', hlc'_le, hlc'_eq⟩ := exists_affine_le_of_lt (𝕜 := ℝ) hx hax hsc hfc hf
have h1 y : l 1 * y = l y := by rw [mul_comm, ← smul_eq_mul, ← map_smul, smul_eq_mul, mul_one]
exact ⟨l 1, c', fun y hy ↦ by simpa [h1] using hlc'_le ⟨y, hy⟩, by simpa [h1] using hlc'_eq⟩
lemma exists_affine_le_real {s : Set ℝ} {f : ℝ → ℝ}
(hsc : IsClosed s) (hfc : LowerSemicontinuousOn f s) (hf : ConvexOn ℝ s f) :
∃ c c', ∀ x ∈ s, c * x + c' ≤ f x := by
rcases s.eq_empty_or_nonempty with rfl | ⟨x, hxs⟩
· simp
obtain ⟨c, c', hlc'_le, -⟩ :=
hf.exists_affine_le_of_lt_real (a := f x - 1) hxs (by simp) hsc hfc
exact ⟨c, c', hlc'_le⟩
/-- A function `φ : E → ℝ` that is convex and lower-semicontinuous on a closed convex subset `s` is
the supremum of a family of functions that are the restrictions to `s` of continuous affine linear
functions in `E`. -/
theorem sSup_affine_eq (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
sSup {f | f ≤ s.restrict φ ∧ ∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = s.restrict (re ∘ l) + const s c} =
s.restrict φ := by
let A := { p : E × 𝕜 | p.1 ∈ s ∧ φ p.1 ≤ re p.2 }
ext x
rw [sSup_apply]
refine csSup_eq_of_forall_le_of_forall_lt_exists_gt ?_ (fun r ⟨f, hf⟩ => ?_) (fun r hr => ?_)
· obtain ⟨l, c, hlc⟩ := exists_affine_le_of_lt (𝕜 := 𝕜) x.2 (show φ x - 1 < φ x from by grind)
hsc hφc hφcv
exact ⟨φ x - 1, hlc.2 ▸ ⟨⟨s.restrict (re ∘ l) + const s c, hlc.1, l, c, rfl⟩, rfl⟩⟩
· exact hf ▸ f.2.1 x
· obtain ⟨z, hz⟩ := exists_between hr
obtain ⟨l, c, hlc⟩ := exists_affine_le_of_lt (𝕜 := 𝕜) x.2 hz.2 hsc hφc hφcv
exact ⟨z, hlc.2 ▸ ⟨⟨s.restrict (re ∘ l) + const s c, hlc.1, l, c, rfl⟩, rfl⟩, hz.1⟩
/-- The countable version of `sSup_affine_eq`. -/
theorem sSup_of_countable_affine_eq [HereditarilyLindelofSpace E] (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
∃ 𝓕' : Set (s → ℝ), 𝓕'.Countable ∧ sSup 𝓕' = s.restrict φ ∧
∀ f ∈ 𝓕', f ≤ s.restrict φ ∧
∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = s.restrict (re ∘ l) + const s c := by
by_cases! hs : s.Nonempty
· let 𝓕 := {f | f ≤ s.restrict φ ∧
∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = s.restrict (re ∘ l) + const s c}
have hl : IsLUB 𝓕 (s.restrict φ) := by
refine (hφcv.sSup_affine_eq (𝕜 := 𝕜) hsc hφc) ▸ isLUB_csSup ?_ ?_
· obtain ⟨l, c, hlc⟩ := exists_affine_le_of_lt (𝕜 := 𝕜) hs.some_mem
(by grind : φ hs.some - 1 < φ (⟨hs.some, hs.some_mem⟩ : s)) hsc hφc hφcv
exact ⟨s.restrict (re ∘ l) + const s c, hlc.1, l, c, rfl⟩
· exact (bddAbove_def.2 ⟨φ ∘ Subtype.val, fun y hy => hy.1⟩)
have hr (f) (hf : f ∈ 𝓕) : LowerSemicontinuous f := by
obtain ⟨l, c, hlc⟩ := hf.2
exact Continuous.lowerSemicontinuous (hlc ▸ by fun_prop)
obtain ⟨𝓕', h𝓕'⟩ := exists_countable_lowerSemicontinuous_isLUB hr hl
refine ⟨𝓕', h𝓕'.2.1, h𝓕'.2.2.csSup_eq ?_, fun f hf => h𝓕'.1 hf⟩
by_contra!
grind [(isLUB_empty_iff.1 (this ▸ h𝓕'.2.2)) (fun x : s => φ x - 1) ⟨hs.some, hs.some_mem⟩]
· use ∅; simp [restrict_def]; grind
/-- The sequential version of `sSup_of_countable_affine_eq`. -/
theorem sSup_of_nat_affine_eq [HereditarilyLindelofSpace E] (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
∃ (l : ℕ → E →L[𝕜] 𝕜) (c : ℕ → ℝ),
(∀ i, s.restrict (re ∘ (l i)) + const s (c i) ≤ s.restrict φ) ∧
⨆ i, s.restrict (re ∘ (l i)) + const s (c i) = s.restrict φ := by
obtain ⟨𝓕', h𝓕'⟩ := hφcv.sSup_of_countable_affine_eq (𝕜 := 𝕜) hsc hφc
by_cases! he : 𝓕'.Nonempty
· obtain ⟨f, hf⟩ := h𝓕'.1.exists_eq_range he
have (i : ℕ) : ∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f i = s.restrict (re ∘ l) + const s c := by simp_all
choose l c hlc using this
refine ⟨l, c, fun i => (hlc i) ▸ (h𝓕'.2.2 (f i) (hf ▸ mem_range_self i)).1, ?_⟩
calc
_ = ⨆ i, f i := by congr with i x; exact congrFun (hlc i).symm x
_ = _ := by rw [← sSup_range, ← hf, h𝓕'.2.1]
· by_cases! hsφ : s.restrict φ = 0
· have := congrFun hsφ
refine ⟨fun _ => 0, fun _ => 0, ?_, ?_⟩
· simp_all [restrict_def]
· ext; simp_all
· obtain ⟨x, hx⟩ := Function.ne_iff.1 hsφ
have : s = ∅ := by have := congrFun h𝓕'.2.1 x; simp_all
grind
/-- A function `φ : E → ℝ` that is convex and lower-semicontinuous is the supremum of a family of
of continuous affine linear functions. -/
theorem univ_sSup_affine_eq (hφc : LowerSemicontinuous φ) (hφcv : ConvexOn ℝ univ φ) :
sSup {f | f ≤ φ ∧ ∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = (re ∘ l) + const E c} = φ := by
let 𝓕 := {f | f ≤ φ ∘ Subtype.val ∧ ∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = (re ∘ l) ∘ Subtype.val +
const univ c}
have := hφcv.sSup_affine_eq (𝕜 := 𝕜) isClosed_univ (lowerSemicontinuousOn_univ_iff.2 hφc)
simp only [restrict_eq] at this
calc
_ = sSup ((fun g => g ∘ (Equiv.Set.univ E).symm) '' 𝓕) := by
congr
ext f
refine ⟨fun ⟨hp, l, c, hlc⟩ => ⟨f ∘ Subtype.val, ⟨fun x => hp (Subtype.val x), ⟨l, c, ?_⟩⟩, ?_⟩,
fun ⟨a, ⟨⟨h, ⟨l, c, hlc⟩⟩, hb⟩⟩ => ⟨fun x => ?_, ⟨l, c, ?_⟩⟩⟩
· ext x; simpa using congrFun hlc x
· ext; simp
· simpa using hb ▸ h ⟨x, trivial⟩
· subst hlc; simpa using hb.symm
_ = sSup 𝓕 ∘ (Equiv.Set.univ E).symm := by ext x; rw [sSup_image', sSup_eq_iSup']; simp
_ = φ ∘ Subtype.val ∘ (Equiv.Set.univ E).symm :=
congrArg (fun g => g ∘ (Equiv.Set.univ E).symm) this
_ = φ := by ext; simp
/-- The countable version of `univ_sSup_affine_eq`. -/
theorem univ_sSup_of_countable_affine_eq [HereditarilyLindelofSpace E]
(hφc : LowerSemicontinuous φ) (hφcv : ConvexOn ℝ univ φ) :
∃ 𝓕' : Set (E → ℝ), 𝓕'.Countable ∧ sSup 𝓕' = φ ∧
∀ f ∈ 𝓕', f ≤ φ ∧ ∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = (re ∘ l) + const E c := by
let 𝓕 := {f | f ≤ φ ∧ ∃ (l : E →L[𝕜] 𝕜) (c : ℝ), f = (re ∘ l) + const E c}
have hl : IsLUB 𝓕 φ := by
refine (hφcv.univ_sSup_affine_eq (𝕜 := 𝕜) hφc) ▸ isLUB_csSup ?_ ?_
· obtain ⟨l, c, hlc⟩ := exists_affine_le_of_lt (𝕜 := 𝕜) (@mem_univ E 0)
(by grind : φ 0 - 1 < φ (⟨0, @mem_univ E 0⟩ : univ)) isClosed_univ
(lowerSemicontinuousOn_univ_iff.2 hφc) hφcv
exact ⟨(re ∘ l) + const E c, fun x => hlc.1 ⟨x, mem_univ x⟩, ⟨l, c, rfl⟩⟩
· exact (bddAbove_def.2 ⟨φ, fun y hy => hy.1⟩)
have hr (f) (hf : f ∈ 𝓕) : LowerSemicontinuous f := by
obtain ⟨l, c, hlc⟩ := hf.2
exact Continuous.lowerSemicontinuous (by rw [hlc]; fun_prop)
obtain ⟨𝓕', h𝓕'⟩ := exists_countable_lowerSemicontinuous_isLUB hr hl
refine ⟨𝓕', h𝓕'.2.1, h𝓕'.2.2.csSup_eq ?_, fun f hf => h𝓕'.1 hf⟩
by_contra!
grind [(isLUB_empty_iff.1 (this ▸ h𝓕'.2.2)) (fun x => φ x - 1) 0]
/-- The sequential version of `univ_sSup_of_countable_affine_eq`. -/
theorem univ_sSup_of_nat_affine_eq [HereditarilyLindelofSpace E]
(hφc : LowerSemicontinuous φ) (hφcv : ConvexOn ℝ univ φ) :
∃ (l : ℕ → E →L[𝕜] 𝕜) (c : ℕ → ℝ), (∀ i, re ∘ (l i) + const E (c i) ≤ φ)
∧ ⨆ i, re ∘ (l i) + const E (c i) = φ := by
obtain ⟨l, c, hle, hsup⟩ := hφcv.sSup_of_nat_affine_eq (𝕜 := 𝕜) (s := univ) isClosed_univ
(lowerSemicontinuousOn_univ_iff.2 hφc)
refine ⟨l, c, fun i x ↦ hle i ⟨x, trivial⟩, ?_⟩
ext x
simpa using congrFun hsup ⟨x, trivial⟩
end RCLike
section Real
variable [AddCommGroup E] [Module ℝ E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]
[LocallyConvexSpace ℝ E]
/-- The real version of `sSup_affine_eq`. -/
theorem real_sSup_affine_eq (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
sSup {f | f ≤ s.restrict φ ∧ ∃ (l : E →L[ℝ] ℝ) (c : ℝ), f = s.restrict l + const s c} =
s.restrict φ :=
sSup_affine_eq (𝕜 := ℝ) hsc hφc hφcv
/-- The real version of `sSup_of_countable_affine_eq`. -/
theorem real_sSup_of_countable_affine_eq [HereditarilyLindelofSpace E] (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
∃ 𝓕' : Set (s → ℝ), 𝓕'.Countable ∧ sSup 𝓕' = s.restrict φ ∧
∀ f ∈ 𝓕', f ≤ s.restrict φ ∧ ∃ (l : E →L[ℝ] ℝ) (c : ℝ), f = s.restrict l + const s c :=
sSup_of_countable_affine_eq (𝕜 := ℝ) hsc hφc hφcv
/-- The real version of `sSup_of_nat_affine_eq`. -/
theorem real_sSup_of_nat_affine_eq [HereditarilyLindelofSpace E] (hsc : IsClosed s)
(hφc : LowerSemicontinuousOn φ s) (hφcv : ConvexOn ℝ s φ) :
∃ (l : ℕ → E →L[ℝ] ℝ) (c : ℕ → ℝ),
(∀ i, s.restrict (l i) + const s (c i) ≤ s.restrict φ) ∧
⨆ i, s.restrict (l i) + const s (c i) = s.restrict φ :=
sSup_of_nat_affine_eq (𝕜 := ℝ) hsc hφc hφcv
/-- The real version of `univ_sSup_affine_eq`. -/
theorem real_univ_sSup_affine_eq (hφc : LowerSemicontinuous φ) (hφcv : ConvexOn ℝ univ φ) :
sSup {f | f ≤ φ ∧ ∃ (l : E →L[ℝ] ℝ) (c : ℝ), f = l + const E c} = φ :=
univ_sSup_affine_eq (𝕜 := ℝ) hφc hφcv
/-- The real version of `univ_sSup_of_countable_affine_eq`. -/
theorem real_univ_sSup_of_countable_affine_eq [HereditarilyLindelofSpace E]
(hφc : LowerSemicontinuous φ) (hφcv : ConvexOn ℝ univ φ) :
∃ 𝓕' : Set (E → ℝ), 𝓕'.Countable ∧ sSup 𝓕' = φ ∧
∀ f ∈ 𝓕', f ≤ φ ∧ ∃ (l : E →L[ℝ] ℝ) (c : ℝ), f = l + const E c :=
univ_sSup_of_countable_affine_eq (𝕜 := ℝ) hφc hφcv
/-- The real version of `univ_sSup_of_nat_affine_eq`. -/
theorem real_univ_sSup_of_nat_affine_eq [HereditarilyLindelofSpace E]
(hφc : LowerSemicontinuous φ) (hφcv : ConvexOn ℝ univ φ) :
∃ (l : ℕ → E →L[ℝ] ℝ) (c : ℕ → ℝ), (∀ i, (l i) + const E (c i) ≤ φ) ∧
⨆ i, (l i) + const E (c i) = φ :=
univ_sSup_of_nat_affine_eq (𝕜 := ℝ) hφc hφcv
end Real
end ConvexOn