Skip to content

Commit 342815a

Browse files
committed
feat: port Topology.Instances.Real (#2633)
I generalized some lemmas from additive subgroups of the real numbers to additive subgroups of an archimedean additive group.
1 parent 6aa35a6 commit 342815a

File tree

7 files changed

+403
-36
lines changed

7 files changed

+403
-36
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ import Mathlib.Topology.Homeomorph
12951295
import Mathlib.Topology.Inseparable
12961296
import Mathlib.Topology.Instances.Int
12971297
import Mathlib.Topology.Instances.Nat
1298+
import Mathlib.Topology.Instances.Real
12981299
import Mathlib.Topology.Instances.Sign
12991300
import Mathlib.Topology.IsLocallyHomeomorph
13001301
import Mathlib.Topology.List

Mathlib/Algebra/Periodic.lean

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ period, periodic, periodicity, antiperiodic
4040

4141
variable {α β γ : Type _} {f g : α → β} {c c₁ c₂ x : α}
4242

43-
open BigOperators
43+
open Set BigOperators
4444

4545
namespace Function
4646

@@ -285,35 +285,46 @@ theorem Periodic.int_mul_eq [Ring α] (h : Periodic f c) (n : ℤ) : f (n * c) =
285285
/-- If a function `f` is `periodic` with positive period `c`, then for all `x` there exists some
286286
`y ∈ Ico 0 c` such that `f x = f y`. -/
287287
theorem Periodic.exists_mem_Ico₀ [LinearOrderedAddCommGroup α] [Archimedean α] (h : Periodic f c)
288-
(hc : 0 < c) (x) : ∃ y ∈ Set.Ico 0 c, f x = f y :=
288+
(hc : 0 < c) (x) : ∃ y ∈ Ico 0 c, f x = f y :=
289289
let ⟨n, H, _⟩ := existsUnique_zsmul_near_of_pos' hc x
290290
⟨x - n • c, H, (h.sub_zsmul_eq n).symm⟩
291291
#align function.periodic.exists_mem_Ico₀ Function.Periodic.exists_mem_Ico₀
292292

293293
/-- If a function `f` is `periodic` with positive period `c`, then for all `x` there exists some
294294
`y ∈ Ico a (a + c)` such that `f x = f y`. -/
295295
theorem Periodic.exists_mem_Ico [LinearOrderedAddCommGroup α] [Archimedean α] (h : Periodic f c)
296-
(hc : 0 < c) (x a) : ∃ y ∈ Set.Ico a (a + c), f x = f y :=
296+
(hc : 0 < c) (x a) : ∃ y ∈ Ico a (a + c), f x = f y :=
297297
let ⟨n, H, _⟩ := existsUnique_add_zsmul_mem_Ico hc x a
298298
⟨x + n • c, H, (h.zsmul n x).symm⟩
299299
#align function.periodic.exists_mem_Ico Function.Periodic.exists_mem_Ico
300300

301301
/-- If a function `f` is `periodic` with positive period `c`, then for all `x` there exists some
302302
`y ∈ Ioc a (a + c)` such that `f x = f y`. -/
303303
theorem Periodic.exists_mem_Ioc [LinearOrderedAddCommGroup α] [Archimedean α] (h : Periodic f c)
304-
(hc : 0 < c) (x a) : ∃ y ∈ Set.Ioc a (a + c), f x = f y :=
304+
(hc : 0 < c) (x a) : ∃ y ∈ Ioc a (a + c), f x = f y :=
305305
let ⟨n, H, _⟩ := existsUnique_add_zsmul_mem_Ioc hc x a
306306
⟨x + n • c, H, (h.zsmul n x).symm⟩
307307
#align function.periodic.exists_mem_Ioc Function.Periodic.exists_mem_Ioc
308308

309309
theorem Periodic.image_Ioc [LinearOrderedAddCommGroup α] [Archimedean α] (h : Periodic f c)
310-
(hc : 0 < c) (a : α) : f '' Set.Ioc a (a + c) = Set.range f :=
311-
(Set.image_subset_range _ _).antisymm <|
312-
Set.range_subset_iff.2 fun x =>
313-
let ⟨y, hy, hyx⟩ := h.exists_mem_Ioc hc x a
314-
⟨y, hy, hyx.symm⟩
310+
(hc : 0 < c) (a : α) : f '' Ioc a (a + c) = range f :=
311+
(image_subset_range _ _).antisymm <|range_subset_iff.2 fun x =>
312+
let ⟨y, hy, hyx⟩ := h.exists_mem_Ioc hc x a
313+
⟨y, hy, hyx.symm⟩
315314
#align function.periodic.image_Ioc Function.Periodic.image_Ioc
316315

316+
theorem Periodic.image_Icc [LinearOrderedAddCommGroup α] [Archimedean α] (h : Periodic f c)
317+
(hc : 0 < c) (a : α) : f '' Icc a (a + c) = range f :=
318+
(image_subset_range _ _).antisymm <| h.image_Ioc hc a ▸ image_subset _ Ioc_subset_Icc_self
319+
320+
theorem Periodic.image_uIcc [LinearOrderedAddCommGroup α] [Archimedean α] (h : Periodic f c)
321+
(hc : c ≠ 0) (a : α) : f '' uIcc a (a + c) = range f := by
322+
cases hc.lt_or_lt with
323+
| inl hc =>
324+
rw [uIcc_of_ge (add_le_of_nonpos_right hc.le), ← h.neg.image_Icc (neg_pos.2 hc) (a + c),
325+
add_neg_cancel_right]
326+
| inr hc => rw [uIcc_of_le (le_add_of_nonneg_right hc.le), h.image_Icc hc]
327+
317328
theorem periodic_with_period_zero [AddZeroClass α] (f : α → β) : Periodic f 0 := fun x => by
318329
rw [add_zero]
319330
#align function.periodic_with_period_zero Function.periodic_with_period_zero

Mathlib/GroupTheory/Archimedean.lean

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ The result is also used in `Topology.Instances.Real` as an ingredient in the cla
3434
subgroups of `ℝ`.
3535
-/
3636

37-
37+
open Set
3838
variable {G : Type _} [LinearOrderedAddCommGroup G] [Archimedean G]
3939

40-
open LinearOrderedAddCommGroup
41-
4240
/-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there
4341
exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
4442
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
@@ -58,21 +56,49 @@ theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
5856
simp [sub_eq_zero.mp h_zero, AddSubgroup.mem_closure_singleton]
5957
#align add_subgroup.cyclic_of_min AddSubgroup.cyclic_of_min
6058

59+
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
60+
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
61+
group admits the least element. -/
62+
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
63+
(hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
64+
-- todo: move to a lemma?
65+
have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
66+
rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
67+
simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
68+
lift m to ℕ
69+
· rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
70+
exact hg.trans_le hm
71+
· simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
72+
exact ⟨m, hm', hm⟩
73+
have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a))
74+
· rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
75+
rcases hex (|g|) (abs_pos.2 hg₀) with ⟨n, hn⟩
76+
exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
77+
classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
78+
by_contra hxmin
79+
simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
80+
not_le] at hxmin
81+
rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
82+
rcases hex y hy₀ with ⟨m, hm⟩
83+
cases' lt_or_le m n with hmn hnm
84+
· exact hmin m hmn ⟨y, hyH, hm⟩
85+
· refine disjoint_left.1 hd (sub_mem hxH hyH) ⟨sub_pos.2 hxy, sub_lt_iff_lt_add'.2 ?_⟩
86+
calc x ≤ (n + 1) • a := hxn
87+
_ ≤ (m + 1) • a := nsmul_le_nsmul h₀.le (add_le_add_right hnm _)
88+
_ = m • a + a := succ_nsmul' _ _
89+
_ < y + a := add_lt_add_right hm.1 _
90+
91+
/-- If an additive subgroup of a linear ordered additive commutative group is disjoint with the
92+
interval `Set.Ioo 0 a` for some positive `a`, then this is a cyclic subgroup. -/
93+
theorem AddSubgroup.cyclic_of_isolated_zero {H : AddSubgroup G} {a : G} (h₀ : 0 < a)
94+
(hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, H = closure {b} := by
95+
rcases eq_or_ne H ⊥ with rfl | hbot
96+
· exact ⟨0, closure_singleton_zero.symm⟩
97+
· exact (exists_isLeast_pos hbot h₀ hd).imp fun _ => cyclic_of_min
98+
6199
/-- Every subgroup of `ℤ` is cyclic. -/
62-
theorem Int.subgroup_cyclic (H : AddSubgroup ℤ) : ∃ a, H = AddSubgroup.closure {a} := by
63-
cases' AddSubgroup.bot_or_exists_ne_zero H with h h
64-
· use 0
65-
rw [h]
66-
exact AddSubgroup.closure_singleton_zero.symm
67-
let s := { g : ℤ | g ∈ H ∧ 0 < g }
68-
have h_bdd : ∀ g ∈ s, (0 : ℤ) ≤ g := fun _ h => le_of_lt h.2
69-
obtain ⟨g₀, g₀_in, g₀_ne⟩ := h
70-
obtain ⟨g₁, g₁_in, g₁_pos⟩ : ∃ g₁ : ℤ, g₁ ∈ H ∧ 0 < g₁ :=
71-
by
72-
cases' lt_or_gt_of_ne g₀_ne with Hg₀ Hg₀
73-
· exact ⟨-g₀, H.neg_mem g₀_in, neg_pos.mpr Hg₀⟩
74-
· exact ⟨g₀, g₀_in, Hg₀⟩
75-
classical
76-
obtain ⟨a, ha, ha'⟩ := Int.exists_least_of_bdd ⟨(0 : ℤ), h_bdd⟩ ⟨g₁, g₁_in, g₁_pos⟩
77-
exact ⟨a, AddSubgroup.cyclic_of_min ⟨ha, ha'⟩⟩
100+
theorem Int.subgroup_cyclic (H : AddSubgroup ℤ) : ∃ a, H = AddSubgroup.closure {a} :=
101+
have : Ioo (0 : ℤ) 1 = ∅ := eq_empty_of_forall_not_mem fun m hm =>
102+
hm.1.not_le (lt_add_one_iff.1 hm.2)
103+
AddSubgroup.cyclic_of_isolated_zero one_pos <| by simp [this]
78104
#align int.subgroup_cyclic Int.subgroup_cyclic

Mathlib/GroupTheory/Subgroup/Basic.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ theorem inv_mem_iff {S G} [InvolutiveInv G] {_ : SetLike S G} [InvMemClass S G]
134134
#align inv_mem_iff inv_mem_iff
135135
#align neg_mem_iff neg_mem_iff
136136

137+
@[simp] theorem abs_mem_iff {S G} [InvolutiveNeg G] [LinearOrder G] {_ : SetLike S G}
138+
[NegMemClass S G] {H : S} {x : G} : |x| ∈ H ↔ x ∈ H := by
139+
cases abs_choice x <;> simp [*]
140+
137141
variable {M S : Type _} [DivInvMonoid M] [SetLike S M] [hSM : SubgroupClass S M] {H K : S}
138142

139143
/-- A subgroup is closed under division. -/

Mathlib/Order/Filter/Cofinite.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ instance cofinite_neBot [Infinite α] : NeBot (@cofinite α) :=
5959
hasBasis_cofinite.neBot_iff.2 fun hs => hs.infinite_compl.nonempty
6060
#align filter.cofinite_ne_bot Filter.cofinite_neBot
6161

62+
@[simp]
63+
theorem cofinite_eq_bot_iff : @cofinite α = ⊥ ↔ Finite α := by
64+
simp [← empty_mem_iff_bot, finite_univ_iff]
65+
66+
@[simp]
67+
theorem cofinite_eq_bot [Finite α] : @cofinite α = ⊥ := cofinite_eq_bot_iff.2 ‹_›
68+
6269
theorem frequently_cofinite_iff_infinite {p : α → Prop} :
6370
(∃ᶠ x in cofinite, p x) ↔ Set.Infinite { x | p x } := by
6471
simp only [Filter.Frequently, Filter.Eventually, mem_cofinite, compl_setOf, not_not,
@@ -182,6 +189,9 @@ theorem Filter.Tendsto.exists_forall_ge [Nonempty α] [LinearOrder β] {f : α
182189
@Filter.Tendsto.exists_forall_le _ βᵒᵈ _ _ _ hf
183190
#align filter.tendsto.exists_forall_ge Filter.Tendsto.exists_forall_ge
184191

192+
theorem Function.Surjective.le_map_cofinite {f : α → β} (hf : Surjective f) :
193+
cofinite ≤ map f cofinite := fun _ h => .of_preimage h hf
194+
185195
/-- For an injective function `f`, inverse images of finite sets are finite. See also
186196
`Filter.comap_cofinite_le` and `Function.Injective.comap_cofinite_eq`. -/
187197
theorem Function.Injective.tendsto_cofinite {f : α → β} (hf : Injective f) :

Mathlib/Topology/Algebra/Order/Archimedean.lean

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,67 @@ Authors: Yury G. Kudryashov
99
! if you have ported upstream changes.
1010
-/
1111
import Mathlib.Topology.Order.Basic
12-
import Mathlib.Algebra.Order.Archimedean
12+
import Mathlib.GroupTheory.Archimedean
1313

1414
/-!
15-
# Rational numbers are dense in a linear ordered archimedean field
15+
# Topology on archimedean groups and fields
1616
17-
In this file we prove that coercion from `ℚ` to a linear ordered archimedean field has dense range.
18-
This lemma is in a separate file because `Mathlib.Topology.Order.Basic` does not import
19-
`Mathlib.Algebra.Order.Archimedean`.
20-
-/
17+
In this file we prove the following theorems:
18+
19+
- `Rat.denseRange_cast`: the coercion from `ℚ` to a linear ordered archimedean field has dense
20+
range;
2121
22+
- `AddSubgroup.dense_of_not_isolated_zero`, `AddSubgroup.dense_of_no_min`: two sufficient conditions
23+
for a subgroup of an archimedean linear ordered additive commutative group to be dense;
24+
25+
- `AddSubgroup.dense_or_cyclic`: an additive subgroup of an archimedean linear ordered additive
26+
commutative group `G` with order topology either is dense in `G` or is a cyclic subgroup.
27+
-/
2228

23-
variable {𝕜 : Type _} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] [Archimedean 𝕜]
29+
open Set
2430

2531
/-- Rational numbers are dense in a linear ordered archimedean field. -/
26-
theorem Rat.denseRange_cast : DenseRange ((↑) : ℚ → 𝕜) :=
32+
theorem Rat.denseRange_cast {𝕜} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜]
33+
[Archimedean 𝕜] : DenseRange ((↑) : ℚ → 𝕜) :=
2734
dense_of_exists_between fun _ _ h => Set.exists_range_iff.2 <| exists_rat_btwn h
2835
#align rat.dense_range_cast Rat.denseRange_cast
2936

37+
namespace AddSubgroup
38+
39+
variable {G : Type _} [LinearOrderedAddCommGroup G] [TopologicalSpace G] [OrderTopology G]
40+
[Archimedean G]
41+
42+
/-- An additive subgroup of an archimedean linear ordered additive commutative group with order
43+
topology is dense provided that for all positive `ε` there exists a positive element of the
44+
subgroup that is less than `ε`. -/
45+
theorem dense_of_not_isolated_zero (S : AddSubgroup G) (hS : ∀ ε > 0, ∃ g ∈ S, g ∈ Ioo 0 ε) :
46+
Dense (S : Set G) := by
47+
cases subsingleton_or_nontrivial G
48+
· refine fun x => _root_.subset_closure ?_
49+
rw [Subsingleton.elim x 0]
50+
exact zero_mem S
51+
refine dense_of_exists_between fun a b hlt => ?_
52+
rcases hS (b - a) (sub_pos.2 hlt) with ⟨g, hgS, hg0, hg⟩
53+
rcases (existsUnique_add_zsmul_mem_Ioc hg0 0 a).exists with ⟨m, hm⟩
54+
rw [zero_add] at hm
55+
refine ⟨m • g, zsmul_mem hgS _, hm.1, hm.2.trans_lt ?_⟩
56+
rwa [lt_sub_iff_add_lt'] at hg
57+
58+
/-- Let `S` be a nontrivial additive subgroup in an archimedean linear ordered additive commutative
59+
group `G` with order topology. If the set of positive elements of `S` does not have a minimal
60+
element, then `S` is dense `G`. -/
61+
theorem dense_of_no_min (S : AddSubgroup G) (hbot : S ≠ ⊥)
62+
(H : ¬∃ a : G, IsLeast { g : G | g ∈ S ∧ 0 < g } a) : Dense (S : Set G) := by
63+
refine S.dense_of_not_isolated_zero fun ε ε0 => ?_
64+
contrapose! H
65+
exact exists_isLeast_pos hbot ε0 (disjoint_left.2 H)
66+
#align real.subgroup_dense_of_no_min AddSubgroup.dense_of_no_minₓ
67+
68+
/-- An additive subgroup of an archimedean linear ordered additive commutative group `G` with order
69+
topology either is dense in `G` or is a cyclic subgroup. -/
70+
theorem dense_or_cyclic (S : AddSubgroup G) : Dense (S : Set G) ∨ ∃ a : G, S = closure {a} := by
71+
refine (em _).imp (dense_of_not_isolated_zero S) fun h => ?_
72+
push_neg at h
73+
rcases h with ⟨ε, ε0, hε⟩
74+
exact cyclic_of_isolated_zero ε0 (disjoint_left.2 hε)
75+
#align real.subgroup_dense_or_cyclic AddSubgroup.dense_or_cyclicₓ

0 commit comments

Comments
 (0)