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

Commit cdaa6d2

Browse files
committed
refactor(analysis/normed_space/pi_Lp): golf some instances (#14339)
* drop `pi_Lp.emetric_aux`; * use `T₀` to get `(e)metric_space` from `pseudo_(e)metric_space`; * restate `pi_Lp.(anti)lipschitz_with_equiv` with correct `pseudo_emetric_space` instances; while they're defeq, it's better not to leak auxiliary instances unless necessary.
1 parent 23f30a3 commit cdaa6d2

File tree

1 file changed

+38
-65
lines changed

1 file changed

+38
-65
lines changed

src/analysis/normed_space/pi_Lp.lean

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -101,56 +101,40 @@ from the edistance (which is equal to it, but not defeq). See Note [forgetful in
101101
explaining why having definitionally the right uniformity is often important.
102102
-/
103103

104-
variables [Π i, emetric_space (α i)] [Π i, pseudo_emetric_space (β i)] [fintype ι]
104+
variables [Π i, pseudo_metric_space (α i)] [Π i, pseudo_emetric_space (β i)] [fintype ι]
105+
105106
include fact_one_le_p
106107

108+
private lemma pos : 0 < p := zero_lt_one.trans_le fact_one_le_p.out
109+
107110
/-- Endowing the space `pi_Lp p β` with the `L^p` pseudoedistance. This definition is not
108111
satisfactory, as it does not register the fact that the topology and the uniform structure coincide
109112
with the product one. Therefore, we do not register it as an instance. Using this as a temporary
110113
pseudoemetric space instance, we will show that the uniform structure is equal (but not defeq) to
111114
the product one, and then register an instance in which we replace the uniform structure by the
112115
product one using this pseudoemetric space and `pseudo_emetric_space.replace_uniformity`. -/
113116
def pseudo_emetric_aux : pseudo_emetric_space (pi_Lp p β) :=
114-
have pos : 0 < p := lt_of_lt_of_le zero_lt_one fact_one_le_p.out,
115117
{ edist := λ f g, (∑ i, edist (f i) (g i) ^ p) ^ (1/p),
116-
edist_self := λ f, by simp [edist, ennreal.zero_rpow_of_pos pos,
117-
ennreal.zero_rpow_of_pos (inv_pos.2 pos)],
118+
edist_self := λ f, by simp [edist, ennreal.zero_rpow_of_pos (pos p),
119+
ennreal.zero_rpow_of_pos (inv_pos.2 $ pos p)],
118120
edist_comm := λ f g, by simp [edist, edist_comm],
119121
edist_triangle := λ f g h, calc
120122
(∑ i, edist (f i) (h i) ^ p) ^ (1 / p) ≤
121123
(∑ i, (edist (f i) (g i) + edist (g i) (h i)) ^ p) ^ (1 / p) :
122124
begin
123-
apply ennreal.rpow_le_rpow _ (one_div_nonneg.2 $ le_of_lt pos),
125+
apply ennreal.rpow_le_rpow _ (one_div_nonneg.2 (pos p).le),
124126
refine finset.sum_le_sum (λ i hi, _),
125-
exact ennreal.rpow_le_rpow (edist_triangle _ _ _) (le_trans zero_le_one fact_one_le_p.out)
127+
exact ennreal.rpow_le_rpow (edist_triangle _ _ _) (pos p).le
126128
end
127129
... ≤
128130
(∑ i, edist (f i) (g i) ^ p) ^ (1 / p) + (∑ i, edist (g i) (h i) ^ p) ^ (1 / p) :
129131
ennreal.Lp_add_le _ _ _ fact_one_le_p.out }
130132

131-
/-- Endowing the space `pi_Lp p α` with the `L^p` edistance. This definition is not satisfactory,
132-
as it does not register the fact that the topology and the uniform structure coincide with the
133-
product one. Therefore, we do not register it as an instance. Using this as a temporary emetric
134-
space instance, we will show that the uniform structure is equal (but not defeq) to the product
135-
one, and then register an instance in which we replace the uniform structure by the product one
136-
using this emetric space and `emetric_space.replace_uniformity`. -/
137-
def emetric_aux : emetric_space (pi_Lp p α) :=
138-
{ eq_of_edist_eq_zero := λ f g hfg,
139-
begin
140-
have pos : 0 < p := lt_of_lt_of_le zero_lt_one fact_one_le_p.out,
141-
letI h := pseudo_emetric_aux p α,
142-
have h : edist f g = (∑ i, (edist (f i) (g i)) ^ p) ^ (1/p) := rfl,
143-
simp [h, ennreal.rpow_eq_zero_iff, pos, asymm pos, finset.sum_eq_zero_iff_of_nonneg] at hfg,
144-
exact funext hfg
145-
end,
146-
..pseudo_emetric_aux p α }
147-
148-
local attribute [instance] pi_Lp.emetric_aux pi_Lp.pseudo_emetric_aux
133+
local attribute [instance] pi_Lp.pseudo_emetric_aux
149134

150-
lemma lipschitz_with_equiv : lipschitz_with 1 (pi_Lp.equiv p β) :=
135+
lemma lipschitz_with_equiv_aux : lipschitz_with 1 (pi_Lp.equiv p β) :=
151136
begin
152-
have pos : 0 < p := lt_of_lt_of_le zero_lt_one fact_one_le_p.out,
153-
have cancel : p * (1/p) = 1 := mul_div_cancel' 1 (ne_of_gt pos),
137+
have cancel : p * (1/p) = 1 := mul_div_cancel' 1 (pos p).ne',
154138
assume x y,
155139
simp only [edist, forall_prop_of_true, one_mul, finset.mem_univ, finset.sup_le_iff,
156140
ennreal.coe_one],
@@ -160,12 +144,12 @@ begin
160144
by simp [← ennreal.rpow_mul, cancel, -one_div]
161145
... ≤ (∑ i, edist (x i) (y i) ^ p) ^ (1 / p) :
162146
begin
163-
apply ennreal.rpow_le_rpow _ (one_div_nonneg.2 $ le_of_lt pos),
147+
apply ennreal.rpow_le_rpow _ (one_div_nonneg.2 $ (pos p).le),
164148
exact finset.single_le_sum (λ i hi, (bot_le : (0 : ℝ≥0∞) ≤ _)) (finset.mem_univ i)
165149
end
166150
end
167151

168-
lemma antilipschitz_with_equiv :
152+
lemma antilipschitz_with_equiv_aux :
169153
antilipschitz_with ((fintype.card ι : ℝ≥0) ^ (1/p)) (pi_Lp.equiv p β) :=
170154
begin
171155
have pos : 0 < p := lt_of_lt_of_le zero_lt_one fact_one_le_p.out,
@@ -196,8 +180,8 @@ lemma aux_uniformity_eq :
196180
𝓤 (pi_Lp p β) = @uniformity _ (Pi.uniform_space _) :=
197181
begin
198182
have A : uniform_inducing (pi_Lp.equiv p β) :=
199-
(antilipschitz_with_equiv p β).uniform_inducing
200-
(lipschitz_with_equiv p β).uniform_continuous,
183+
(antilipschitz_with_equiv_aux p β).uniform_inducing
184+
(lipschitz_with_equiv_aux p β).uniform_continuous,
201185
have : (λ (x : pi_Lp p β × pi_Lp p β),
202186
((pi_Lp.equiv p β) x.fst, (pi_Lp.equiv p β) x.snd)) = id,
203187
by ext i; refl,
@@ -222,49 +206,30 @@ instance [Π i, pseudo_emetric_space (β i)] : pseudo_emetric_space (pi_Lp p β)
222206
/-- emetric space instance on the product of finitely many emetric spaces, using the `L^p`
223207
edistance, and having as uniformity the product uniformity. -/
224208
instance [Π i, emetric_space (α i)] : emetric_space (pi_Lp p α) :=
225-
(emetric_aux p α).replace_uniformity (aux_uniformity_eq p α).symm
209+
@emetric.of_t0_pseudo_emetric_space _ _ $
210+
-- TODO: add `Pi.t0_space`
211+
by { haveI : t2_space (pi_Lp p α) := Pi.t2_space, apply_instance }
226212

227-
omit fact_one_le_p
228-
lemma edist_eq {p : ℝ} [fact (1 ≤ p)] {β : ι → Type*}
229-
[Π i, pseudo_emetric_space (β i)] (x y : pi_Lp p β) :
213+
variables {p β}
214+
lemma edist_eq [Π i, pseudo_emetric_space (β i)] (x y : pi_Lp p β) :
230215
edist x y = (∑ i, edist (x i) (y i) ^ p) ^ (1/p) := rfl
231-
include fact_one_le_p
216+
variables (p β)
232217

233218
/-- pseudometric space instance on the product of finitely many psuedometric spaces, using the
234219
`L^p` distance, and having as uniformity the product uniformity. -/
235220
instance [Π i, pseudo_metric_space (β i)] : pseudo_metric_space (pi_Lp p β) :=
236-
begin
237-
/- we construct the instance from the pseudo emetric space instance to avoid checking again that
238-
the uniformity is the same as the product uniformity, but we register nevertheless a nice formula
239-
for the distance -/
240-
have pos : 0 < p := lt_of_lt_of_le zero_lt_one fact_one_le_p.out,
241-
refine pseudo_emetric_space.to_pseudo_metric_space_of_dist
242-
(λf g, (∑ i, dist (f i) (g i) ^ p) ^ (1/p)) (λ f g, _) (λ f g, _),
243-
{ simp [pi_Lp.edist_eq, ennreal.rpow_eq_top_iff, asymm pos, pos,
244-
ennreal.sum_eq_top_iff, edist_ne_top] },
245-
{ have A : ∀ (i : ι), i ∈ (finset.univ : finset ι) → edist (f i) (g i) ^ p ≠ ⊤ :=
246-
λ i hi, by simp [lt_top_iff_ne_top, edist_ne_top, le_of_lt pos],
247-
simp [dist, -one_div, pi_Lp.edist_eq, ← ennreal.to_real_rpow,
248-
ennreal.to_real_sum A, dist_edist] }
249-
end
221+
pseudo_emetric_space.to_pseudo_metric_space_of_dist
222+
(λ f g, (∑ i, dist (f i) (g i) ^ p) ^ (1/p))
223+
(λ f g, ennreal.rpow_ne_top_of_nonneg (one_div_nonneg.2 (pos p).le) $ ne_of_lt $
224+
(ennreal.sum_lt_top $ λ i hi, ennreal.rpow_ne_top_of_nonneg (pos p).le (edist_ne_top _ _)))
225+
(λ f g,
226+
have A : ∀ i, edist (f i) (g i) ^ p ≠ ⊤,
227+
from λ i, ennreal.rpow_ne_top_of_nonneg (pos p).le (edist_ne_top _ _),
228+
by simp only [edist_eq, dist_edist, ennreal.to_real_rpow, ← ennreal.to_real_sum (λ i _, A i)])
250229

251230
/-- metric space instance on the product of finitely many metric spaces, using the `L^p` distance,
252231
and having as uniformity the product uniformity. -/
253-
instance [Π i, metric_space (α i)] : metric_space (pi_Lp p α) :=
254-
begin
255-
/- we construct the instance from the emetric space instance to avoid checking again that the
256-
uniformity is the same as the product uniformity, but we register nevertheless a nice formula
257-
for the distance -/
258-
have pos : 0 < p := lt_of_lt_of_le zero_lt_one fact_one_le_p.out,
259-
refine emetric_space.to_metric_space_of_dist
260-
(λf g, (∑ i, dist (f i) (g i) ^ p) ^ (1/p)) (λ f g, _) (λ f g, _),
261-
{ simp [pi_Lp.edist_eq, ennreal.rpow_eq_top_iff, asymm pos, pos,
262-
ennreal.sum_eq_top_iff, edist_ne_top] },
263-
{ have A : ∀ (i : ι), i ∈ (finset.univ : finset ι) → edist (f i) (g i) ^ p ≠ ⊤ :=
264-
λ i hi, by simp [edist_ne_top, pos.le],
265-
simp [dist, -one_div, pi_Lp.edist_eq, ← ennreal.to_real_rpow,
266-
ennreal.to_real_sum A, dist_edist] }
267-
end
232+
instance [Π i, metric_space (α i)] : metric_space (pi_Lp p α) := metric.of_t0_pseudo_metric_space _
268233

269234
omit fact_one_le_p
270235
lemma dist_eq {p : ℝ} [fact (1 ≤ p)] {β : ι → Type*}
@@ -278,6 +243,14 @@ subtype.ext $ by { push_cast, exact dist_eq _ _ }
278243

279244
include fact_one_le_p
280245

246+
lemma lipschitz_with_equiv [Π i, pseudo_emetric_space (β i)] :
247+
lipschitz_with 1 (pi_Lp.equiv p β) :=
248+
lipschitz_with_equiv_aux p β
249+
250+
lemma antilipschitz_with_equiv [Π i, pseudo_emetric_space (β i)] :
251+
antilipschitz_with ((fintype.card ι : ℝ≥0) ^ (1/p)) (pi_Lp.equiv p β) :=
252+
antilipschitz_with_equiv_aux p β
253+
281254
/-- seminormed group instance on the product of finitely many normed groups, using the `L^p`
282255
norm. -/
283256
instance semi_normed_group [Π i, semi_normed_group (β i)] : semi_normed_group (pi_Lp p β) :=

0 commit comments

Comments
 (0)