|
| 1 | +/- |
| 2 | +Copyright (c) 2018 Patrick Massot. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Normed spaces. |
| 5 | +
|
| 6 | +Authors: Patrick Massot, Johannes Hölzl |
| 7 | +-/ |
| 8 | + |
| 9 | +import algebra.pi_instances |
| 10 | +import linear_algebra.prod_module |
| 11 | +import analysis.nnreal |
| 12 | +variables {α : Type*} {β : Type*} {γ : Type*} {ι : Type*} |
| 13 | + |
| 14 | +noncomputable theory |
| 15 | +open filter |
| 16 | +local notation f `→_{`:50 a `}`:0 b := tendsto f (nhds a) (nhds b) |
| 17 | + |
| 18 | +lemma squeeze_zero {α} {f g : α → ℝ} {t₀ : filter α} (hf : ∀t, 0 ≤ f t) (hft : ∀t, f t ≤ g t) |
| 19 | + (g0 : tendsto g t₀ (nhds 0)) : tendsto f t₀ (nhds 0) := |
| 20 | +begin |
| 21 | + apply tendsto_of_tendsto_of_tendsto_of_le_of_le (tendsto_const_nhds) g0; |
| 22 | + simp [*]; exact filter.univ_mem_sets |
| 23 | +end |
| 24 | + |
| 25 | +class has_norm (α : Type*) := (norm : α → ℝ) |
| 26 | + |
| 27 | +export has_norm (norm) |
| 28 | + |
| 29 | +notation `∥`:1024 e:1 `∥`:1 := norm e |
| 30 | + |
| 31 | +class normed_group (α : Type*) extends has_norm α, add_comm_group α, metric_space α := |
| 32 | +(dist_eq : ∀ x y, dist x y = norm (x - y)) |
| 33 | + |
| 34 | +section normed_group |
| 35 | +variables [normed_group α] [normed_group β] |
| 36 | + |
| 37 | +lemma dist_eq_norm (g h : α) : dist g h = ∥g - h∥ := |
| 38 | +normed_group.dist_eq _ _ |
| 39 | + |
| 40 | +@[simp] lemma dist_zero_right (g : α) : dist g 0 = ∥g∥ := |
| 41 | +by { rw[dist_eq_norm], simp } |
| 42 | + |
| 43 | +lemma norm_triangle (g h : α) : ∥g + h∥ ≤ ∥g∥ + ∥h∥ := |
| 44 | +calc ∥g + h∥ = ∥g - (-h)∥ : by simp |
| 45 | + ... = dist g (-h) : by simp[dist_eq_norm] |
| 46 | + ... ≤ dist g 0 + dist 0 (-h) : by apply dist_triangle |
| 47 | + ... = ∥g∥ + ∥h∥ : by simp[dist_eq_norm] |
| 48 | + |
| 49 | +@[simp] lemma norm_nonneg (g : α) : 0 ≤ ∥g∥ := |
| 50 | +by { rw[←dist_zero_right], exact dist_nonneg } |
| 51 | + |
| 52 | +lemma norm_eq_zero (g : α) : ∥g∥ = 0 ↔ g = 0 := |
| 53 | +by { rw[←dist_zero_right], exact dist_eq_zero } |
| 54 | + |
| 55 | +@[simp] lemma norm_zero : ∥(0:α)∥ = 0 := (norm_eq_zero _).2 (by simp) |
| 56 | + |
| 57 | +lemma norm_pos_iff (g : α) : ∥ g ∥ > 0 ↔ g ≠ 0 := |
| 58 | +begin |
| 59 | + split ; intro h ; rw[←dist_zero_right] at *, |
| 60 | + { exact dist_pos.1 h }, |
| 61 | + { exact dist_pos.2 h } |
| 62 | +end |
| 63 | + |
| 64 | +lemma norm_le_zero_iff (g : α) : ∥g∥ ≤ 0 ↔ g = 0 := |
| 65 | +by { rw[←dist_zero_right], exact dist_le_zero } |
| 66 | + |
| 67 | +@[simp] lemma norm_neg (g : α) : ∥-g∥ = ∥g∥ := |
| 68 | +calc ∥-g∥ = ∥0 - g∥ : by simp |
| 69 | + ... = dist 0 g : (dist_eq_norm 0 g).symm |
| 70 | + ... = dist g 0 : dist_comm _ _ |
| 71 | + ... = ∥g - 0∥ : (dist_eq_norm g 0) |
| 72 | + ... = ∥g∥ : by simp |
| 73 | + |
| 74 | +lemma abs_norm_sub_norm_le (g h : α) : abs(∥g∥ - ∥h∥) ≤ ∥g - h∥ := |
| 75 | +abs_le.2 $ and.intro |
| 76 | + (suffices -∥g - h∥ ≤ -(∥h∥ - ∥g∥), by simpa, |
| 77 | + neg_le_neg $ sub_right_le_of_le_add $ |
| 78 | + calc ∥h∥ = ∥h - g + g∥ : by simp |
| 79 | + ... ≤ ∥h - g∥ + ∥g∥ : norm_triangle _ _ |
| 80 | + ... = ∥-(g - h)∥ + ∥g∥ : by simp |
| 81 | + ... = ∥g - h∥ + ∥g∥ : by { rw [norm_neg (g-h)] }) |
| 82 | + (sub_right_le_of_le_add $ calc ∥g∥ = ∥g - h + h∥ : by simp ... ≤ ∥g-h∥ + ∥h∥ : norm_triangle _ _) |
| 83 | + |
| 84 | +lemma dist_norm_norm_le (g h : α) : dist ∥g∥ ∥h∥ ≤ ∥g - h∥ := |
| 85 | +abs_norm_sub_norm_le g h |
| 86 | + |
| 87 | +section nnnorm |
| 88 | + |
| 89 | +def nnnorm (a : α) : nnreal := ⟨norm a, norm_nonneg a⟩ |
| 90 | + |
| 91 | +@[simp] lemma coe_nnnorm (a : α) : (nnnorm a : ℝ) = norm a := rfl |
| 92 | + |
| 93 | +lemma nndist_eq_nnnorm (a b : α) : nndist a b = nnnorm (a - b) := nnreal.eq $ dist_eq_norm _ _ |
| 94 | + |
| 95 | +lemma nnnorm_eq_zero (a : α) : nnnorm a = 0 ↔ a = 0 := |
| 96 | +by simp only [nnreal.eq_iff.symm, nnreal.coe_zero, coe_nnnorm, norm_eq_zero] |
| 97 | + |
| 98 | +@[simp] lemma nnnorm_zero : nnnorm (0 : α) = 0 := |
| 99 | +nnreal.eq norm_zero |
| 100 | + |
| 101 | +lemma nnnorm_triangle (g h : α) : nnnorm (g + h) ≤ nnnorm g + nnnorm h := |
| 102 | +by simpa [nnreal.coe_le] using norm_triangle g h |
| 103 | + |
| 104 | +@[simp] lemma nnnorm_neg (g : α) : nnnorm (-g) = nnnorm g := |
| 105 | +nnreal.eq $ norm_neg g |
| 106 | + |
| 107 | +lemma nndist_nnnorm_nnnorm_le (g h : α) : nndist (nnnorm g) (nnnorm h) ≤ nnnorm (g - h) := |
| 108 | +(nnreal.coe_le _ _).2 $ dist_norm_norm_le g h |
| 109 | + |
| 110 | +end nnnorm |
| 111 | + |
| 112 | +instance prod.normed_group [normed_group β] : normed_group (α × β) := |
| 113 | +{ norm := λx, max ∥x.1∥ ∥x.2∥, |
| 114 | + dist_eq := assume (x y : α × β), |
| 115 | + show max (dist x.1 y.1) (dist x.2 y.2) = (max ∥(x - y).1∥ ∥(x - y).2∥), by simp [dist_eq_norm] } |
| 116 | + |
| 117 | +lemma norm_fst_le (x : α × β) : ∥x.1∥ ≤ ∥x∥ := |
| 118 | +begin have : ∥x∥ = max (∥x.fst∥) (∥x.snd∥) := rfl, rw this, simp[le_max_left] end |
| 119 | + |
| 120 | +lemma norm_snd_le (x : α × β) : ∥x.2∥ ≤ ∥x∥ := |
| 121 | +begin have : ∥x∥ = max (∥x.fst∥) (∥x.snd∥) := rfl, rw this, simp[le_max_right] end |
| 122 | + |
| 123 | +instance fintype.normed_group {π : α → Type*} [fintype α] [∀i, normed_group (π i)] : |
| 124 | + normed_group (Πb, π b) := |
| 125 | +{ norm := λf, ((finset.sup finset.univ (λ b, nnnorm (f b)) : nnreal) : ℝ), |
| 126 | + dist_eq := assume x y, |
| 127 | + congr_arg (coe : nnreal → ℝ) $ congr_arg (finset.sup finset.univ) $ funext $ assume a, |
| 128 | + show nndist (x a) (y a) = nnnorm (x a - y a), from nndist_eq_nnnorm _ _ } |
| 129 | + |
| 130 | +lemma tendsto_iff_norm_tendsto_zero {f : ι → β} {a : filter ι} {b : β} : |
| 131 | + tendsto f a (nhds b) ↔ tendsto (λ e, ∥ f e - b ∥) a (nhds 0) := |
| 132 | +by rw tendsto_iff_dist_tendsto_zero ; simp only [(dist_eq_norm _ _).symm] |
| 133 | + |
| 134 | +lemma lim_norm (x : α) : ((λ g, ∥g - x∥) : α → ℝ) →_{x} 0 := |
| 135 | +tendsto_iff_norm_tendsto_zero.1 (continuous_iff_tendsto.1 continuous_id x) |
| 136 | + |
| 137 | +lemma lim_norm_zero : ((λ g, ∥g∥) : α → ℝ) →_{0} 0 := |
| 138 | +by simpa using lim_norm (0:α) |
| 139 | + |
| 140 | +lemma continuous_norm : continuous ((λ g, ∥g∥) : α → ℝ) := |
| 141 | +begin |
| 142 | + rw continuous_iff_tendsto, |
| 143 | + intro x, |
| 144 | + rw tendsto_iff_dist_tendsto_zero, |
| 145 | + exact squeeze_zero (λ t, abs_nonneg _) (λ t, abs_norm_sub_norm_le _ _) (lim_norm x) |
| 146 | +end |
| 147 | + |
| 148 | +instance normed_top_monoid : topological_add_monoid α := |
| 149 | +⟨continuous_iff_tendsto.2 $ λ ⟨x₁, x₂⟩, |
| 150 | + tendsto_iff_norm_tendsto_zero.2 |
| 151 | + begin |
| 152 | + refine squeeze_zero (by simp) _ |
| 153 | + (by simpa using tendsto_add (lim_norm (x₁, x₂)) (lim_norm (x₁, x₂))), |
| 154 | + exact λ ⟨e₁, e₂⟩, calc |
| 155 | + ∥(e₁ + e₂) - (x₁ + x₂)∥ = ∥(e₁ - x₁) + (e₂ - x₂)∥ : by simp |
| 156 | + ... ≤ ∥e₁ - x₁∥ + ∥e₂ - x₂∥ : norm_triangle _ _ |
| 157 | + ... ≤ max (∥e₁ - x₁∥) (∥e₂ - x₂∥) + max (∥e₁ - x₁∥) (∥e₂ - x₂∥) : |
| 158 | + add_le_add (le_max_left _ _) (le_max_right _ _) |
| 159 | + end⟩ |
| 160 | + |
| 161 | +instance normed_top_group : topological_add_group α := |
| 162 | +⟨continuous_iff_tendsto.2 $ λ x, |
| 163 | +tendsto_iff_norm_tendsto_zero.2 begin |
| 164 | + have : ∀ (e : α), ∥-e - -x∥ = ∥e - x∥, |
| 165 | + { intro, simpa using norm_neg (e - x) }, |
| 166 | + rw funext this, exact lim_norm x, |
| 167 | +end⟩ |
| 168 | + |
| 169 | +end normed_group |
| 170 | + |
| 171 | +section normed_ring |
| 172 | + |
| 173 | +class normed_ring (α : Type*) extends has_norm α, ring α, metric_space α := |
| 174 | +(dist_eq : ∀ x y, dist x y = norm (x - y)) |
| 175 | +(norm_mul : ∀ a b, norm (a * b) ≤ norm a * norm b) |
| 176 | + |
| 177 | +instance normed_ring.to_normed_group [β : normed_ring α] : normed_group α := { ..β } |
| 178 | + |
| 179 | +lemma norm_mul {α : Type*} [normed_ring α] (a b : α) : (∥a*b∥) ≤ (∥a∥) * (∥b∥) := |
| 180 | +normed_ring.norm_mul _ _ |
| 181 | + |
| 182 | +instance prod.ring [ring α] [ring β] : ring (α × β) := |
| 183 | +{ left_distrib := assume x y z, calc |
| 184 | + x*(y+z) = (x.1, x.2) * (y.1 + z.1, y.2 + z.2) : rfl |
| 185 | + ... = (x.1*(y.1 + z.1), x.2*(y.2 + z.2)) : rfl |
| 186 | + ... = (x.1*y.1 + x.1*z.1, x.2*y.2 + x.2*z.2) : by simp[left_distrib], |
| 187 | + right_distrib := assume x y z, calc |
| 188 | + (x+y)*z = (x.1 + y.1, x.2 + y.2)*(z.1, z.2) : rfl |
| 189 | + ... = ((x.1 + y.1)*z.1, (x.2 + y.2)*z.2) : rfl |
| 190 | + ... = (x.1*z.1 + y.1*z.1, x.2*z.2 + y.2*z.2) : by simp[right_distrib], |
| 191 | + ..prod.monoid, |
| 192 | + ..prod.add_comm_group} |
| 193 | + |
| 194 | +instance prod.normed_ring [normed_ring α] [normed_ring β] : normed_ring (α × β) := |
| 195 | +{ norm_mul := assume x y, |
| 196 | + calc |
| 197 | + ∥x * y∥ = ∥(x.1*y.1, x.2*y.2)∥ : rfl |
| 198 | + ... = (max ∥x.1*y.1∥ ∥x.2*y.2∥) : rfl |
| 199 | + ... ≤ (max (∥x.1∥*∥y.1∥) (∥x.2∥*∥y.2∥)) : max_le_max (norm_mul (x.1) (y.1)) (norm_mul (x.2) (y.2)) |
| 200 | + ... = (max (∥x.1∥*∥y.1∥) (∥y.2∥*∥x.2∥)) : by simp[mul_comm] |
| 201 | + ... ≤ (max (∥x.1∥) (∥x.2∥)) * (max (∥y.2∥) (∥y.1∥)) : by { apply max_mul_mul_le_max_mul_max; simp [norm_nonneg] } |
| 202 | + ... = (max (∥x.1∥) (∥x.2∥)) * (max (∥y.1∥) (∥y.2∥)) : by simp[max_comm] |
| 203 | + ... = (∥x∥*∥y∥) : rfl, |
| 204 | + ..prod.normed_group } |
| 205 | +end normed_ring |
| 206 | + |
| 207 | +section normed_field |
| 208 | + |
| 209 | +class normed_field (α : Type*) extends has_norm α, discrete_field α, metric_space α := |
| 210 | +(dist_eq : ∀ x y, dist x y = norm (x - y)) |
| 211 | +(norm_mul : ∀ a b, norm (a * b) = norm a * norm b) |
| 212 | + |
| 213 | +instance normed_field.to_normed_ring [i : normed_field α] : normed_ring α := |
| 214 | +{ norm_mul := by finish [i.norm_mul], ..i } |
| 215 | + |
| 216 | +instance : normed_field ℝ := |
| 217 | +{ norm := λ x, abs x, |
| 218 | + dist_eq := assume x y, rfl, |
| 219 | + norm_mul := abs_mul } |
| 220 | + |
| 221 | +end normed_field |
| 222 | + |
| 223 | +section normed_space |
| 224 | + |
| 225 | +class normed_space (α : out_param $ Type*) (β : Type*) [out_param $ normed_field α] |
| 226 | + extends has_norm β , vector_space α β, metric_space β := |
| 227 | +(dist_eq : ∀ x y, dist x y = norm (x - y)) |
| 228 | +(norm_smul : ∀ a b, norm (a • b) = has_norm.norm a * norm b) |
| 229 | + |
| 230 | +variables [normed_field α] |
| 231 | + |
| 232 | +instance normed_space.to_normed_group [i : normed_space α β] : normed_group β := |
| 233 | +by refine { add := (+), |
| 234 | + dist_eq := normed_space.dist_eq, |
| 235 | + zero := 0, |
| 236 | + neg := λ x, -x, |
| 237 | + ..i, .. }; simp |
| 238 | + |
| 239 | +lemma norm_smul [normed_space α β] (s : α) (x : β) : ∥s • x∥ = ∥s∥ * ∥x∥ := |
| 240 | +normed_space.norm_smul _ _ |
| 241 | + |
| 242 | +lemma nnnorm_smul [normed_space α β] (s : α) (x : β) : nnnorm (s • x) = nnnorm s * nnnorm x := |
| 243 | +nnreal.eq $ norm_smul s x |
| 244 | + |
| 245 | +variables {E : Type*} {F : Type*} [normed_space α E] [normed_space α F] |
| 246 | + |
| 247 | +lemma tendsto_smul {f : γ → α} { g : γ → F} {e : filter γ} {s : α} {b : F} : |
| 248 | + (tendsto f e (nhds s)) → (tendsto g e (nhds b)) → tendsto (λ x, (f x) • (g x)) e (nhds (s • b)) := |
| 249 | +begin |
| 250 | + intros limf limg, |
| 251 | + rw tendsto_iff_norm_tendsto_zero, |
| 252 | + have ineq := λ x : γ, calc |
| 253 | + ∥f x • g x - s • b∥ = ∥(f x • g x - s • g x) + (s • g x - s • b)∥ : by simp[add_assoc] |
| 254 | + ... ≤ ∥f x • g x - s • g x∥ + ∥s • g x - s • b∥ : norm_triangle (f x • g x - s • g x) (s • g x - s • b) |
| 255 | + ... ≤ ∥f x - s∥*∥g x∥ + ∥s∥*∥g x - b∥ : by { rw [←smul_sub, ←sub_smul, norm_smul, norm_smul] }, |
| 256 | + apply squeeze_zero, |
| 257 | + { intro t, exact norm_nonneg _ }, |
| 258 | + { exact ineq }, |
| 259 | + { clear ineq, |
| 260 | + |
| 261 | + have limf': tendsto (λ x, ∥f x - s∥) e (nhds 0) := tendsto_iff_norm_tendsto_zero.1 limf, |
| 262 | + have limg' : tendsto (λ x, ∥g x∥) e (nhds ∥b∥) := filter.tendsto.comp limg (continuous_iff_tendsto.1 continuous_norm _), |
| 263 | + |
| 264 | + have lim1 : tendsto (λ x, ∥f x - s∥ * ∥g x∥) e (nhds 0), |
| 265 | + by simpa using tendsto_mul limf' limg', |
| 266 | + have limg3 := tendsto_iff_norm_tendsto_zero.1 limg, |
| 267 | + have lim2 : tendsto (λ x, ∥s∥ * ∥g x - b∥) e (nhds 0), |
| 268 | + by simpa using tendsto_mul tendsto_const_nhds limg3, |
| 269 | + |
| 270 | + rw [show (0:ℝ) = 0 + 0, by simp], |
| 271 | + exact tendsto_add lim1 lim2 } |
| 272 | +end |
| 273 | + |
| 274 | +instance : normed_space α (E × F) := |
| 275 | +{ norm_smul := |
| 276 | + begin |
| 277 | + intros s x, |
| 278 | + cases x with x₁ x₂, |
| 279 | + exact calc |
| 280 | + ∥s • (x₁, x₂)∥ = ∥ (s • x₁, s• x₂)∥ : rfl |
| 281 | + ... = max (∥s • x₁∥) (∥ s• x₂∥) : rfl |
| 282 | + ... = max (∥s∥ * ∥x₁∥) (∥s∥ * ∥x₂∥) : by simp[norm_smul s x₁, norm_smul s x₂] |
| 283 | + ... = ∥s∥ * max (∥x₁∥) (∥x₂∥) : by simp[mul_max_of_nonneg] |
| 284 | + end, |
| 285 | + |
| 286 | + add_smul := by simp[add_smul], |
| 287 | + -- I have no idea why by simp[smul_add] is not enough for the next goal |
| 288 | + smul_add := assume r x y, show (r•(x+y).fst, r•(x+y).snd) = (r•x.fst+r•y.fst, r•x.snd+r•y.snd), |
| 289 | + by simp[smul_add], |
| 290 | + ..prod.normed_group, |
| 291 | + ..prod.vector_space } |
| 292 | + |
| 293 | +instance fintype.normed_space |
| 294 | + {ι : Type*} {E : ι → Type*} [fintype ι] [∀i, normed_space α (E i)] : |
| 295 | + normed_space α (Πi, E i) := |
| 296 | +{ norm := λf, ((finset.univ.sup (λb, nnnorm (f b)) : nnreal) : ℝ), |
| 297 | + dist_eq := |
| 298 | + assume f g, congr_arg coe $ congr_arg (finset.sup finset.univ) $ |
| 299 | + by funext i; exact nndist_eq_nnnorm _ _, |
| 300 | + norm_smul := λ a f, |
| 301 | + show (↑(finset.sup finset.univ (λ (b : ι), nnnorm (a • f b))) : ℝ) = |
| 302 | + nnnorm a * ↑(finset.sup finset.univ (λ (b : ι), nnnorm (f b))), |
| 303 | + by simp only [(nnreal.coe_mul _ _).symm, nnreal.mul_finset_sup, nnnorm_smul], |
| 304 | + ..metric_space_pi } |
| 305 | + |
| 306 | +end normed_space |
0 commit comments