Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 338331e

Browse files
committed
feat(topology/urysohns_lemma): Urysohn's lemma (#6967)
1 parent ee58d66 commit 338331e

File tree

7 files changed

+419
-8
lines changed

7 files changed

+419
-8
lines changed

src/algebra/ordered_ring.lean

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro
55
-/
66
import algebra.ordered_group
7+
import algebra.invertible
78
import data.set.intervals.basic
89

910
set_option old_structure_cmd true
@@ -322,12 +323,33 @@ lemma pos_of_mul_pos_left (h : 0 < a * b) (ha : 0 ≤ a) : 0 < b :=
322323
lemma pos_of_mul_pos_right (h : 0 < a * b) (hb : 0 ≤ b) : 0 < a :=
323324
((pos_and_pos_or_neg_and_neg_of_mul_pos h).resolve_right $ λ h, h.2.not_le hb).1
324325

326+
@[simp] lemma inv_of_pos [invertible a] : 0 < ⅟a ↔ 0 < a :=
327+
begin
328+
have : 0 < a * ⅟a, by simp only [mul_inv_of_self, zero_lt_one],
329+
exact ⟨λ h, pos_of_mul_pos_right this h.le, λ h, pos_of_mul_pos_left this h.le⟩
330+
end
331+
332+
@[simp] lemma inv_of_nonpos [invertible a] : ⅟a ≤ 0 ↔ a ≤ 0 :=
333+
by simp only [← not_lt, inv_of_pos]
334+
325335
lemma nonneg_of_mul_nonneg_left (h : 0 ≤ a * b) (h1 : 0 < a) : 0 ≤ b :=
326336
le_of_not_gt (assume h2 : b < 0, (mul_neg_of_pos_of_neg h1 h2).not_le h)
327337

328338
lemma nonneg_of_mul_nonneg_right (h : 0 ≤ a * b) (h1 : 0 < b) : 0 ≤ a :=
329339
le_of_not_gt (assume h2 : a < 0, (mul_neg_of_neg_of_pos h2 h1).not_le h)
330340

341+
@[simp] lemma inv_of_nonneg [invertible a] : 0 ≤ ⅟a ↔ 0 ≤ a :=
342+
begin
343+
have : 0 < a * ⅟a, by simp only [mul_inv_of_self, zero_lt_one],
344+
exact ⟨λ h, (pos_of_mul_pos_right this h).le, λ h, (pos_of_mul_pos_left this h).le⟩
345+
end
346+
347+
@[simp] lemma inv_of_lt_zero [invertible a] : ⅟a < 0 ↔ a < 0 :=
348+
by simp only [← not_le, inv_of_nonneg]
349+
350+
@[simp] lemma inv_of_le_one [invertible a] (h : 1 ≤ a) : ⅟a ≤ 1 :=
351+
mul_inv_of_self a ▸ le_mul_of_one_le_left (inv_of_nonneg.2 $ zero_le_one.trans h) h
352+
331353
lemma neg_of_mul_neg_left (h : a * b < 0) (h1 : 0 ≤ a) : b < 0 :=
332354
lt_of_not_ge (assume h2 : b ≥ 0, (mul_nonneg h1 h2).not_lt h)
333355

src/analysis/normed_space/add_torsor.lean

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,22 @@ hf.vsub hg
280280

281281
end
282282

283+
section
284+
285+
variables {R : Type*} [ring R] [topological_space R] [semimodule R V] [has_continuous_smul R V]
286+
287+
lemma filter.tendsto.line_map {l : filter α} {f₁ f₂ : α → P} {g : α → R} {p₁ p₂ : P} {c : R}
288+
(h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) (hg : tendsto g l (𝓝 c)) :
289+
tendsto (λ x, affine_map.line_map (f₁ x) (f₂ x) (g x)) l (𝓝 $ affine_map.line_map p₁ p₂ c) :=
290+
(hg.smul (h₂.vsub h₁)).vadd h₁
291+
292+
lemma filter.tendsto.midpoint [invertible (2:R)] {l : filter α} {f₁ f₂ : α → P} {p₁ p₂ : P}
293+
(h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) :
294+
tendsto (λ x, midpoint R (f₁ x) (f₂ x)) l (𝓝 $ midpoint R p₁ p₂) :=
295+
h₁.line_map h₂ tendsto_const_nhds
296+
297+
end
298+
283299
variables {V' : Type*} {P' : Type*} [normed_group V'] [metric_space P'] [normed_add_torsor V' P']
284300

285301
/-- The map `g` from `V1` to `V2` corresponding to a map `f` from `P1`
@@ -347,9 +363,23 @@ by rw [midpoint_comm, dist_midpoint_left, dist_comm]
347363
dist p₂ (midpoint 𝕜 p₁ p₂) = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=
348364
by rw [dist_comm, dist_midpoint_right]
349365

366+
lemma dist_midpoint_midpoint_le' (p₁ p₂ p₃ p₄ : P) :
367+
dist (midpoint 𝕜 p₁ p₂) (midpoint 𝕜 p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / ∥(2 : 𝕜)∥ :=
368+
begin
369+
rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, midpoint_vsub_midpoint];
370+
try { apply_instance },
371+
rw [midpoint_eq_smul_add, norm_smul, inv_of_eq_inv, normed_field.norm_inv, ← div_eq_inv_mul],
372+
exact div_le_div_of_le_of_nonneg (norm_add_le _ _) (norm_nonneg _),
373+
end
374+
350375
end normed_space
351376

352377
variables [normed_space ℝ V] [normed_space ℝ V']
378+
379+
lemma dist_midpoint_midpoint_le (p₁ p₂ p₃ p₄ : V) :
380+
dist (midpoint ℝ p₁ p₂) (midpoint ℝ p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / 2 :=
381+
by simpa using dist_midpoint_midpoint_le' p₁ p₂ p₃ p₄
382+
353383
include V'
354384

355385
/-- A continuous map between two normed affine spaces is an affine map provided that

src/data/indicator_function.lean

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,22 @@ lemma indicator_sub {G} [add_group G] (s : set α) (f g : α → G) :
265265
indicator s (λa, f a - g a) = λa, indicator s f a - indicator s g a :=
266266
(indicator_hom G s).map_sub f g
267267

268-
@[to_additive indicator_compl''] lemma mul_indicator_compl (s : set α) (f : α → G) :
268+
@[to_additive indicator_compl'] lemma mul_indicator_compl (s : set α) (f : α → G) :
269269
mul_indicator sᶜ f = f * (mul_indicator s f)⁻¹ :=
270270
eq_mul_inv_of_mul_eq $ s.mul_indicator_compl_mul_self f
271271

272272
lemma indicator_compl {G} [add_group G] (s : set α) (f : α → G) :
273273
indicator sᶜ f = f - indicator s f :=
274-
by rw [sub_eq_add_neg, indicator_compl'']
274+
by rw [sub_eq_add_neg, indicator_compl']
275+
276+
@[to_additive indicator_diff'] lemma mul_indicator_diff (h : s ⊆ t) (f : α → G) :
277+
mul_indicator (t \ s) f = mul_indicator t f * (mul_indicator s f)⁻¹ :=
278+
eq_mul_inv_of_mul_eq $ by rw [pi.mul_def, ← mul_indicator_union_of_disjoint disjoint_diff.symm f,
279+
diff_union_self, union_eq_self_of_subset_right h]
280+
281+
lemma indicator_diff {G : Type*} [add_group G] {s t : set α} (h : s ⊆ t) (f : α → G) :
282+
indicator (t \ s) f = indicator t f - indicator s f :=
283+
by rw [indicator_diff' h, sub_eq_add_neg]
275284

276285
end group
277286

@@ -373,19 +382,19 @@ by simp [indicator, ← ite_and]
373382
end monoid_with_zero
374383

375384
section order
376-
variables [has_one M] [preorder M] {s t : set α} {f g : α → M} {a : α}
385+
variables [has_one M] [preorder M] {s t : set α} {f g : α → M} {a : α} {y : M}
377386

378-
@[to_additive] lemma mul_indicator_apply_le' (hfg : a ∈ s → f a ≤ g a) (hg : a ∉ s → 1g a) :
379-
mul_indicator s f a ≤ g a :=
387+
@[to_additive] lemma mul_indicator_apply_le' (hfg : a ∈ s → f a ≤ y) (hg : a ∉ s → 1y) :
388+
mul_indicator s f a ≤ y :=
380389
if ha : a ∈ s then by simpa [ha] using hfg ha else by simpa [ha] using hg ha
381390

382391
@[to_additive] lemma mul_indicator_le' (hfg : ∀ a ∈ s, f a ≤ g a) (hg : ∀ a ∉ s, 1 ≤ g a) :
383392
mul_indicator s f ≤ g :=
384393
λ a, mul_indicator_apply_le' (hfg _) (hg _)
385394

386-
@[to_additive] lemma le_mul_indicator_apply (hfg : a ∈ s → f a ≤ g a) (hf : a ∉ s → f a1) :
387-
f a ≤ mul_indicator s g a :=
388-
if ha : a ∈ s then by simpa [ha] using hfg ha else by simpa [ha] using hf ha
395+
@[to_additive] lemma le_mul_indicator_apply {y} (hfg : a ∈ s → y ≤ g a) (hf : a ∉ s → y1) :
396+
y ≤ mul_indicator s g a :=
397+
@mul_indicator_apply_le' α (order_dual M) ‹_› _ _ _ _ _ hfg hf
389398

390399
@[to_additive] lemma le_mul_indicator (hfg : ∀ a ∈ s, f a ≤ g a) (hf : ∀ a ∉ s, f a ≤ 1) :
391400
f ≤ mul_indicator s g :=

src/linear_algebra/affine_space/midpoint.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ calc midpoint R x y +ᵥ midpoint R x y = midpoint R x y +ᵥ midpoint R y x : b
130130
lemma midpoint_zero_add (x y : V) : midpoint R 0 (x + y) = midpoint R x y :=
131131
(midpoint_eq_midpoint_iff_vsub_eq_vsub R).2 $ by simp [sub_add_eq_sub_sub_swap]
132132

133+
lemma midpoint_eq_smul_add (x y : V) : midpoint R x y = (⅟2 : R) • (x + y) :=
134+
by rw [midpoint_eq_iff, point_reflection_apply, vsub_eq_sub, vadd_eq_add, sub_add_eq_add_sub,
135+
← two_smul R, smul_smul, mul_inv_of_self, one_smul, add_sub_cancel']
136+
133137
end
134138

135139
lemma line_map_inv_two {R : Type*} {V P : Type*} [division_ring R] [char_zero R]

src/linear_algebra/affine_space/ordered.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ lemma right_lt_line_map_iff_lt (h : r < 1) : b < line_map a b r ↔ b < a :=
182182

183183
end ordered_ring
184184

185+
section linear_ordered_ring
186+
187+
variables [linear_ordered_ring k] [ordered_add_comm_group E] [semimodule k E]
188+
[ordered_semimodule k E] [invertible (2:k)] {a a' b b' : E} {r r' : k}
189+
190+
lemma midpoint_le_midpoint (ha : a ≤ a') (hb : b ≤ b') :
191+
midpoint k a b ≤ midpoint k a' b' :=
192+
line_map_mono_endpoints ha hb (inv_of_nonneg.2 zero_le_two) $
193+
inv_of_le_one one_le_two
194+
195+
end linear_ordered_ring
196+
185197
section linear_ordered_field
186198

187199
variables [linear_ordered_field k] [ordered_add_comm_group E]

src/topology/metric_space/basic.lean

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ theorem uniformity_basis_dist_inv_nat_pos :
381381
metric.mk_uniformity_basis (λ n hn, div_pos zero_lt_one $ nat.cast_pos.2 hn)
382382
(λ ε ε0, let ⟨n, hn⟩ := exists_nat_one_div_lt ε0 in ⟨n+1, nat.succ_pos n, hn.le⟩)
383383

384+
theorem uniformity_basis_dist_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
385+
(𝓤 α).has_basis (λ n:ℕ, true) (λ n:ℕ, {p:α×α | dist p.1 p.2 < r ^ n }) :=
386+
metric.mk_uniformity_basis (λ n hn, pow_pos h0 _)
387+
(λ ε ε0, let ⟨n, hn⟩ := exists_pow_lt_of_lt_one ε0 h1 in ⟨n, trivial, hn.le⟩)
388+
384389
theorem uniformity_basis_dist_lt {R : ℝ} (hR : 0 < R) :
385390
(𝓤 α).has_basis (λ r : ℝ, 0 < r ∧ r < R) (λ r, {p : α × α | dist p.1 p.2 < r}) :=
386391
metric.mk_uniformity_basis (λ r, and.left) $ λ r hr,
@@ -412,6 +417,11 @@ theorem uniformity_basis_dist_le :
412417
(𝓤 α).has_basis (λ ε : ℝ, 0 < ε) (λ ε, {p:α×α | dist p.1 p.2 ≤ ε}) :=
413418
metric.mk_uniformity_basis_le (λ _, id) (λ ε ε₀, ⟨ε, ε₀, le_refl ε⟩)
414419

420+
theorem uniformity_basis_dist_le_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
421+
(𝓤 α).has_basis (λ n:ℕ, true) (λ n:ℕ, {p:α×α | dist p.1 p.2 ≤ r ^ n }) :=
422+
metric.mk_uniformity_basis_le (λ n hn, pow_pos h0 _)
423+
(λ ε ε0, let ⟨n, hn⟩ := exists_pow_lt_of_lt_one ε0 h1 in ⟨n, trivial, hn.le⟩)
424+
415425
theorem mem_uniformity_dist {s : set (α×α)} :
416426
s ∈ 𝓤 α ↔ (∃ε>0, ∀{a b:α}, dist a b < ε → (a, b) ∈ s) :=
417427
uniformity_basis_dist.mem_uniformity_iff
@@ -559,6 +569,14 @@ theorem nhds_basis_ball_inv_nat_pos :
559569
(𝓝 x).has_basis (λ n, 0<n) (λ n:ℕ, ball x (1 / ↑n)) :=
560570
nhds_basis_uniformity uniformity_basis_dist_inv_nat_pos
561571

572+
theorem nhds_basis_ball_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
573+
(𝓝 x).has_basis (λ n, true) (λ n:ℕ, ball x (r ^ n)) :=
574+
nhds_basis_uniformity (uniformity_basis_dist_pow h0 h1)
575+
576+
theorem nhds_basis_closed_ball_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
577+
(𝓝 x).has_basis (λ n, true) (λ n:ℕ, closed_ball x (r ^ n)) :=
578+
nhds_basis_uniformity (uniformity_basis_dist_le_pow h0 h1)
579+
562580
theorem is_open_iff : is_open s ↔ ∀x∈s, ∃ε>0, ball x ε ⊆ s :=
563581
by simp only [is_open_iff_mem_nhds, mem_nhds_iff]
564582

@@ -820,6 +838,26 @@ theorem real.dist_eq (x y : ℝ) : dist x y = abs (x - y) := rfl
820838
theorem real.dist_0_eq_abs (x : ℝ) : dist x 0 = abs x :=
821839
by simp [real.dist_eq]
822840

841+
theorem real.dist_left_le_of_mem_interval {x y z : ℝ} (h : y ∈ interval x z) :
842+
dist x y ≤ dist x z :=
843+
by simpa only [dist_comm x] using abs_sub_left_of_mem_interval h
844+
845+
theorem real.dist_right_le_of_mem_interval {x y z : ℝ} (h : y ∈ interval x z) :
846+
dist y z ≤ dist x z :=
847+
by simpa only [dist_comm _ z] using abs_sub_right_of_mem_interval h
848+
849+
theorem real.dist_le_of_mem_interval {x y x' y' : ℝ} (hx : x ∈ interval x' y')
850+
(hy : y ∈ interval x' y') : dist x y ≤ dist x' y' :=
851+
abs_sub_le_of_subinterval $ interval_subset_interval (by rwa interval_swap) (by rwa interval_swap)
852+
853+
theorem real.dist_le_of_mem_Icc {x y x' y' : ℝ} (hx : x ∈ Icc x' y') (hy : y ∈ Icc x' y') :
854+
dist x y ≤ dist x' y' :=
855+
real.dist_le_of_mem_interval (Icc_subset_interval hx) (Icc_subset_interval hy)
856+
857+
theorem real.dist_le_of_mem_Icc_01 {x y : ℝ} (hx : x ∈ Icc (0:ℝ) 1) (hy : y ∈ Icc (0:ℝ) 1) :
858+
dist x y ≤ 1 :=
859+
by simpa [real.dist_eq] using real.dist_le_of_mem_Icc hx hy
860+
823861
instance : order_topology ℝ :=
824862
order_topology_of_nhds_abs $ λ x,
825863
by simp only [nhds_basis_ball.eq_binfi, ball, real.dist_eq, abs_sub]

0 commit comments

Comments
 (0)