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

Commit ed84298

Browse files
committed
feat(analysis/topology): add continuity rules for list and vector insert/remove_nth
1 parent f6812d5 commit ed84298

File tree

3 files changed

+172
-19
lines changed

3 files changed

+172
-19
lines changed

analysis/topology/continuity.lean

Lines changed: 163 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -761,24 +761,6 @@ lemma continuous_sum_rec {f : α → γ} {g : β → γ}
761761
(hf : continuous f) (hg : continuous g) : @continuous (α ⊕ β) γ _ _ (@sum.rec α β (λ_, γ) f g) :=
762762
continuous_inf_dom hf hg
763763

764-
end sum
765-
766-
section subtype
767-
variables [topological_space α] [topological_space β] [topological_space γ] {p : α → Prop}
768-
769-
lemma embedding_graph {f : α → β} (hf : continuous f) : embedding (λx, (x, f x)) :=
770-
embedding_of_embedding_compose (continuous_id.prod_mk hf) continuous_fst embedding_id
771-
772-
lemma embedding_subtype_val : embedding (@subtype.val α p) :=
773-
⟨assume a₁ a₂, subtype.eq, rfl⟩
774-
775-
lemma continuous_subtype_val : continuous (@subtype.val α p) :=
776-
continuous_induced_dom
777-
778-
lemma continuous_subtype_mk {f : β → α}
779-
(hp : ∀x, p (f x)) (h : continuous f) : continuous (λx, (⟨f x, hp x⟩ : subtype p)) :=
780-
continuous_induced_rng h
781-
782764
lemma embedding_inl : embedding (@sum.inl α β) :=
783765
⟨λ _ _, sum.inl.inj_iff.mp,
784766
begin
@@ -815,6 +797,28 @@ lemma embedding_inr : embedding (@sum.inr α β) :=
815797
{ rw induced_le_iff_le_coinduced, exact lattice.inf_le_right }
816798
end
817799

800+
end sum
801+
802+
section subtype
803+
variables [topological_space α] [topological_space β] [topological_space γ] {p : α → Prop}
804+
805+
lemma embedding_graph {f : α → β} (hf : continuous f) : embedding (λx, (x, f x)) :=
806+
embedding_of_embedding_compose (continuous_id.prod_mk hf) continuous_fst embedding_id
807+
808+
lemma embedding_subtype_val : embedding (@subtype.val α p) :=
809+
⟨assume a₁ a₂, subtype.eq, rfl⟩
810+
811+
lemma continuous_subtype_val : continuous (@subtype.val α p) :=
812+
continuous_induced_dom
813+
814+
lemma continuous_subtype_mk {f : β → α}
815+
(hp : ∀x, p (f x)) (h : continuous f) : continuous (λx, (⟨f x, hp x⟩ : subtype p)) :=
816+
continuous_induced_rng h
817+
818+
lemma tendsto_subtype_val [topological_space α] {p : α → Prop} {a : subtype p} :
819+
tendsto subtype.val (nhds a) (nhds a.val) :=
820+
continuous_iff_tendsto.1 continuous_subtype_val _
821+
818822
lemma map_nhds_subtype_val_eq {a : α} (ha : p a) (h : {a | p a} ∈ (nhds a).sets) :
819823
map (@subtype.val α p) (nhds ⟨a, ha⟩) = nhds a :=
820824
map_nhds_induced_eq (by simp [subtype_val_image, h])
@@ -823,6 +827,10 @@ lemma nhds_subtype_eq_comap {a : α} {h : p a} :
823827
nhds (⟨a, h⟩ : subtype p) = comap subtype.val (nhds a) :=
824828
nhds_induced_eq_comap
825829

830+
lemma tendsto_subtype_rng [topological_space α] {p : α → Prop} {b : filter β} {f : β → subtype p} :
831+
∀{a:subtype p}, tendsto f b (nhds a) ↔ tendsto (λx, subtype.val (f x)) b (nhds a.val)
832+
| ⟨a, ha⟩ := by rw [nhds_subtype_eq_comap, tendsto_comap_iff]
833+
826834
lemma continuous_subtype_nhds_cover {ι : Sort*} {f : α → β} {c : ι → α → Prop}
827835
(c_cover : ∀x:α, ∃i, {x | c i x} ∈ (nhds x).sets)
828836
(f_cont : ∀i, continuous (λ(x : subtype (c i)), f x.val)) :
@@ -1001,6 +1009,143 @@ end
10011009

10021010
end pi
10031011

1012+
namespace list
1013+
variables [topological_space α] [topological_space β]
1014+
1015+
lemma tendsto_cons' {a : α} {l : list α} :
1016+
tendsto (λp:α×list α, list.cons p.1 p.2) ((nhds a).prod (nhds l)) (nhds (a :: l)) :=
1017+
by rw [nhds_cons, tendsto, map_prod]; exact le_refl _
1018+
1019+
lemma tendsto_cons {f : α → β} {g : α → list β}
1020+
{a : _root_.filter α} {b : β} {l : list β} (hf : tendsto f a (nhds b)) (hg : tendsto g a (nhds l)):
1021+
tendsto (λa, list.cons (f a) (g a)) a (nhds (b :: l)) :=
1022+
(tendsto.prod_mk hf hg).comp tendsto_cons'
1023+
1024+
lemma tendsto_cons_iff [topological_space β]
1025+
{f : list α → β} {b : _root_.filter β} {a : α} {l : list α} :
1026+
tendsto f (nhds (a :: l)) b ↔ tendsto (λp:α×list α, f (p.1 :: p.2)) ((nhds a).prod (nhds l)) b :=
1027+
have nhds (a :: l) = ((nhds a).prod (nhds l)).map (λp:α×list α, (p.1 :: p.2)),
1028+
begin
1029+
simp only [nhds_cons, prod_eq, (filter.map_def _ _).symm, (filter.seq_eq_filter_seq _ _).symm],
1030+
simp [-filter.seq_eq_filter_seq, -filter.map_def, (∘)] with functor_norm,
1031+
end,
1032+
by rw [this, filter.tendsto_map'_iff]
1033+
1034+
lemma tendsto_nhds [topological_space β]
1035+
{f : list α → β} {r : list α → _root_.filter β}
1036+
(h_nil : tendsto f (pure []) (r []))
1037+
(h_cons : ∀l a, tendsto f (nhds l) (r l) → tendsto (λp:α×list α, f (p.1 :: p.2)) ((nhds a).prod (nhds l)) (r (a::l))) :
1038+
∀l, tendsto f (nhds l) (r l)
1039+
| [] := by rwa [nhds_nil]
1040+
| (a::l) := by rw [tendsto_cons_iff]; exact h_cons l a (tendsto_nhds l)
1041+
1042+
lemma tendsto_length [topological_space α] :
1043+
∀(l : list α), tendsto list.length (nhds l) (nhds l.length) :=
1044+
begin
1045+
simp only [nhds_discrete],
1046+
refine tendsto_nhds _ _,
1047+
{ exact tendsto_pure_pure _ _ },
1048+
{ assume l a ih,
1049+
dsimp only [list.length],
1050+
refine tendsto.comp _ (tendsto_pure_pure (λx, x + 1) _),
1051+
refine tendsto.comp tendsto_snd ih }
1052+
end
1053+
1054+
lemma tendsto_insert_nth' {a : α} : ∀{n : ℕ} {l : list α},
1055+
tendsto (λp:α×list α, insert_nth n p.1 p.2) ((nhds a).prod (nhds l)) (nhds (insert_nth n a l))
1056+
| 0 l := tendsto_cons'
1057+
| (n+1) [] :=
1058+
suffices tendsto (λa, []) (nhds a) (nhds ([] : list α)),
1059+
by simpa [nhds_nil, tendsto, map_prod, -filter.pure_def, (∘), insert_nth],
1060+
tendsto_const_nhds
1061+
| (n+1) (a'::l) :=
1062+
have (nhds a).prod (nhds (a' :: l)) =
1063+
((nhds a).prod ((nhds a').prod (nhds l))).map (λp:α×α×list α, (p.1, p.2.1 :: p.2.2)),
1064+
begin
1065+
simp only [nhds_cons, prod_eq, (filter.map_def _ _).symm, (filter.seq_eq_filter_seq _ _).symm],
1066+
simp [-filter.seq_eq_filter_seq, -filter.map_def, (∘)] with functor_norm
1067+
end,
1068+
begin
1069+
rw [this, tendsto_map'_iff],
1070+
exact tendsto_cons
1071+
(tendsto_snd.comp tendsto_fst)
1072+
((tendsto.prod_mk tendsto_fst (tendsto_snd.comp tendsto_snd)).comp (@tendsto_insert_nth' n l))
1073+
end
1074+
1075+
lemma tendsto_insert_nth {n : ℕ} {a : α} {l : list α} {f : β → α} {g : β → list α}
1076+
{b : _root_.filter β} (hf : tendsto f b (nhds a)) (hg : tendsto g b (nhds l)) :
1077+
tendsto (λb:β, insert_nth n (f b) (g b)) b (nhds (insert_nth n a l)) :=
1078+
(tendsto.prod_mk hf hg).comp tendsto_insert_nth'
1079+
1080+
lemma continuous_insert_nth {n : ℕ} : continuous (λp:α×list α, insert_nth n p.1 p.2) :=
1081+
continuous_iff_tendsto.2 $ assume ⟨a, l⟩, by rw [nhds_prod_eq]; exact tendsto_insert_nth'
1082+
1083+
lemma tendsto_remove_nth : ∀{n : ℕ} {l : list α},
1084+
tendsto (λl, remove_nth l n) (nhds l) (nhds (remove_nth l n))
1085+
| _ [] := by rw [nhds_nil]; exact tendsto_pure_nhds _ _
1086+
| 0 (a::l) := by rw [tendsto_cons_iff]; exact tendsto_snd
1087+
| (n+1) (a::l) :=
1088+
begin
1089+
rw [tendsto_cons_iff],
1090+
dsimp [remove_nth],
1091+
exact tendsto_cons tendsto_fst (tendsto_snd.comp (@tendsto_remove_nth n l))
1092+
end
1093+
1094+
lemma continuous_remove_nth {n : ℕ} : continuous (λl : list α, remove_nth l n) :=
1095+
continuous_iff_tendsto.2 $ assume a, tendsto_remove_nth
1096+
1097+
end list
1098+
1099+
namespace vector
1100+
open list filter
1101+
1102+
instance (n : ℕ) [topological_space α] : topological_space (vector α n) :=
1103+
by unfold vector; apply_instance
1104+
1105+
lemma cons_val {n : ℕ} {a : α} : ∀{v : vector α n}, (a :: v).val = a :: v.val
1106+
| ⟨l, hl⟩ := rfl
1107+
1108+
lemma tendsto_cons [topological_space α] {n : ℕ} {a : α} {l : vector α n}:
1109+
tendsto (λp:α×vector α n, vector.cons p.1 p.2) ((nhds a).prod (nhds l)) (nhds (a :: l)) :=
1110+
by
1111+
simp [tendsto_subtype_rng, cons_val];
1112+
exact tendsto_cons tendsto_fst (tendsto.comp tendsto_snd tendsto_subtype_val)
1113+
1114+
lemma tendsto_insert_nth
1115+
[topological_space α] {n : ℕ} {i : fin (n+1)} {a:α} :
1116+
∀{l:vector α n}, tendsto (λp:α×vector α n, insert_nth p.1 i p.2)
1117+
((nhds a).prod (nhds l)) (nhds (insert_nth a i l))
1118+
| ⟨l, hl⟩ :=
1119+
begin
1120+
rw [insert_nth, tendsto_subtype_rng],
1121+
simp [insert_nth_val],
1122+
exact list.tendsto_insert_nth tendsto_fst (tendsto.comp tendsto_snd tendsto_subtype_val)
1123+
end
1124+
1125+
lemma continuous_insert_nth' [topological_space α] {n : ℕ} {i : fin (n+1)} :
1126+
continuous (λp:α×vector α n, insert_nth p.1 i p.2) :=
1127+
continuous_iff_tendsto.2 $ assume ⟨a, l⟩, by rw [nhds_prod_eq]; exact tendsto_insert_nth
1128+
1129+
lemma continuous_insert_nth [topological_space α] [topological_space β] {n : ℕ} {i : fin (n+1)}
1130+
{f : β → α} {g : β → vector α n} (hf : continuous f) (hg : continuous g) :
1131+
continuous (λb, insert_nth (f b) i (g b)) :=
1132+
continuous.comp (continuous.prod_mk hf hg) continuous_insert_nth'
1133+
1134+
lemma tendsto_remove_nth [topological_space α] {n : ℕ} {i : fin (n+1)} :
1135+
∀{l:vector α (n+1)}, tendsto (remove_nth i) (nhds l) (nhds (remove_nth i l))
1136+
| ⟨l, hl⟩ :=
1137+
begin
1138+
rw [remove_nth, tendsto_subtype_rng],
1139+
simp [remove_nth_val],
1140+
exact tendsto_subtype_val.comp list.tendsto_remove_nth
1141+
end
1142+
1143+
lemma continuous_remove_nth [topological_space α] {n : ℕ} {i : fin (n+1)} :
1144+
continuous (remove_nth i : vector α (n+1) → vector α n) :=
1145+
continuous_iff_tendsto.2 $ assume ⟨a, l⟩, tendsto_remove_nth
1146+
1147+
end vector
1148+
10041149
-- TODO: use embeddings from above!
10051150
structure dense_embedding [topological_space α] [topological_space β] (e : α → β) : Prop :=
10061151
(dense : ∀x, x ∈ closure (range e))

analysis/topology/topological_space.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,13 @@ begin
10601060
exact mem_traverse_sets _ _ (this.imp $ assume a s ⟨hs, ha⟩, mem_nhds_sets hs ha) } }
10611061
end
10621062

1063+
lemma nhds_nil [topological_space α] : nhds ([] : list α) = pure [] :=
1064+
by rw [nhds_list, list.traverse_nil _]; apply_instance
1065+
1066+
lemma nhds_cons [topological_space α] (a : α) (l : list α) :
1067+
nhds (a :: l) = list.cons <$> nhds a <*> nhds l :=
1068+
by rw [nhds_list, list.traverse_cons _, ← nhds_list]; apply_instance
1069+
10631070
lemma quotient_dense_of_dense [setoid α] [topological_space α] {s : set α} (H : ∀ x, x ∈ closure s) :
10641071
closure (quotient.mk '' s) = univ :=
10651072
eq_univ_of_forall $ λ x, begin

analysis/topology/uniform_space.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@ instance : has_top (uniform_space α) :=
10551055
rw [lift'_principal], {simp},
10561056
exact monotone_comp_rel monotone_id monotone_id
10571057
end,
1058-
is_open_uniformity := by simp [is_open_fold, subset_def, id_rel] {contextual := tt } } ⟩
1058+
is_open_uniformity :=
1059+
assume s, by simp [is_open_fold, subset_def, id_rel] {contextual := tt } } ⟩
10591060

10601061
instance : complete_lattice (uniform_space α) :=
10611062
{ sup := λa b, Sup {a, b},

0 commit comments

Comments
 (0)