@@ -30,10 +30,17 @@ distribute over pointwise operations. For example,
30
30
`t ∈ g`.
31
31
* `f -ᵥ g` (`filter.has_vsub`): Scalar subtraction, filter generated by all `x -ᵥ y` where `s ∈ f`
32
32
and `t ∈ g`.
33
- * `f • g` (`filter.has_smul `): Scalar multiplication, filter generated by all `x • y` where `s ∈ f`
34
- and `t ∈ g`.
33
+ * `f • g` (`filter.has_scalar `): Scalar multiplication, filter generated by all `x • y` where
34
+ `s ∈ f` and `t ∈ g`.
35
35
* `a +ᵥ f` (`filter.has_vadd_filter`): Translation, filter of all `a +ᵥ x` where `s ∈ f`.
36
- * `a • f` (`filter.has_smul_filter`): Scaling, filter of all `a • s` where `s ∈ f`.
36
+ * `a • f` (`filter.has_scalar_filter`): Scaling, filter of all `a • s` where `s ∈ f`.
37
+
38
+ ## Implementation notes
39
+
40
+ We put all instances in the locale `pointwise`, so that these instances are not available by
41
+ default. Note that we do not mark them as reducible (as argued by note [reducible non-instances])
42
+ since we expect the locale to be open whenever the instances are actually used (and making the
43
+ instances reducible changes the behavior of `simp`.
37
44
38
45
## Tags
39
46
@@ -52,9 +59,12 @@ namespace filter
52
59
section one
53
60
variables [has_one α] {f : filter α} {s : set α}
54
61
55
- /-- `1 : filter α` is the set of sets containing `1 : α`. -/
56
- @[to_additive " `0 : filter α` is the set of sets containing `0 : α`." ]
57
- instance : has_one (filter α) := ⟨principal 1 ⟩
62
+ /-- `1 : filter α` is defined as the filter of sets containing `1 : α` in locale `pointwise`. -/
63
+ @[to_additive " `0 : filter α` is defined as the filter of sets containing `0 : α` in locale
64
+ `pointwise`." ]
65
+ protected def has_one : has_one (filter α) := ⟨principal 1 ⟩
66
+
67
+ localized " attribute [instance] filter.has_one filter.has_zero" in pointwise
58
68
59
69
@[simp, to_additive] lemma mem_one : s ∈ (1 : filter α) ↔ (1 : α) ∈ s := one_subset
60
70
@@ -84,7 +94,11 @@ end one
84
94
section mul
85
95
variables [has_mul α] [has_mul β] {f f₁ f₂ g g₁ g₂ h : filter α} {s t : set α}
86
96
87
- @[to_additive] instance : has_mul (filter α) := ⟨map₂ (*)⟩
97
+ /-- The filter `f * g` is generated by `{s * t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
98
+ @[to_additive " The filter `f + g` is generated by `{s + t | s ∈ f, t ∈ g}` in locale `pointwise`." ]
99
+ protected def has_mul : has_mul (filter α) := ⟨map₂ (*)⟩
100
+
101
+ localized " attribute [instance] filter.has_mul filter.has_add" in pointwise
88
102
89
103
@[simp, to_additive] lemma map₂_mul : map₂ (*) f g = f * g := rfl
90
104
@[to_additive] lemma mem_mul_iff : s ∈ f * g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ * t₂ ⊆ s := iff.rfl
@@ -109,30 +123,42 @@ map_map₂_distrib $ map_mul m
109
123
110
124
end mul
111
125
112
- @[to_additive]
113
- instance [semigroup α] : semigroup (filter α) :=
126
+ open_locale pointwise
127
+
128
+ /-- `filter α` is a `semigroup` under pointwise operations if `α` is.-/
129
+ @[to_additive " `filter α` is an `add_semigroup` under pointwise operations if `α` is." ]
130
+ protected def semigroup [semigroup α] : semigroup (filter α) :=
114
131
{ mul := (*),
115
132
mul_assoc := λ f g h, map₂_assoc mul_assoc }
116
133
117
- @[to_additive]
118
- instance [comm_semigroup α] : comm_semigroup (filter α) :=
134
+ /-- `filter α` is a `comm_semigroup` under pointwise operations if `α` is. -/
135
+ @[to_additive " `filter α` is an `add_comm_semigroup` under pointwise operations if `α` is." ]
136
+ protected def comm_semigroup [comm_semigroup α] : comm_semigroup (filter α) :=
119
137
{ mul_comm := λ f g, map₂_comm mul_comm,
120
138
..filter.semigroup }
121
139
122
- @[to_additive]
123
- instance [mul_one_class α] : mul_one_class (filter α) :=
140
+ /-- `filter α` is a `mul_one_class` under pointwise operations if `α` is. -/
141
+ @[to_additive " `filter α` is an `add_zero_class` under pointwise operations if `α` is." ]
142
+ protected def mul_one_class [mul_one_class α] : mul_one_class (filter α) :=
124
143
{ one := 1 ,
125
144
mul := (*),
126
145
one_mul := λ f, by simp only [←pure_one, ←map₂_mul, map₂_pure_left, one_mul, map_id'],
127
146
mul_one := λ f, by simp only [←pure_one, ←map₂_mul, map₂_pure_right, mul_one, map_id'] }
128
147
129
- @[to_additive]
130
- instance [monoid α] : monoid (filter α) := { ..filter.mul_one_class, ..filter.semigroup }
148
+ /-- `filter α` is a `monoid` under pointwise operations if `α` is. -/
149
+ @[to_additive " `filter α` is an `add_monoid` under pointwise operations if `α` is." ]
150
+ protected def monoid [monoid α] : monoid (filter α) :=
151
+ { ..filter.mul_one_class, ..filter.semigroup }
131
152
132
- @[to_additive]
133
- instance [comm_monoid α] : comm_monoid (filter α) :=
153
+ /-- `filter α` is a `comm_monoid` under pointwise operations if `α` is. -/
154
+ @[to_additive " `filter α` is an `add_comm_monoid` under pointwise operations if `α` is." ]
155
+ protected def comm_monoid [comm_monoid α] : comm_monoid (filter α) :=
134
156
{ ..filter.mul_one_class, ..filter.comm_semigroup }
135
157
158
+ localized " attribute [instance] filter.mul_one_class filter.add_zero_class filter.semigroup
159
+ filter.add_semigroup filter.comm_semigroup filter.add_comm_semigroup filter.monoid
160
+ filter.add_monoid filter.comm_monoid filter.add_comm_monoid" in pointwise
161
+
136
162
section map
137
163
138
164
variables [mul_one_class α] [mul_one_class β]
@@ -183,7 +209,9 @@ variables [has_involutive_inv α] {f : filter α} {s : set α}
183
209
184
210
@[to_additive] lemma inv_mem_inv (hs : s ∈ f) : s⁻¹ ∈ f⁻¹ := by rwa [mem_inv, inv_preimage, inv_inv]
185
211
186
- instance : has_involutive_inv (filter α) :=
212
+ /-- Inversion is involutive on `filter α` if it is on `α`. -/
213
+ @[to_additive " Negation is involutive on `filter α` if it is on `α`." ]
214
+ def has_involutive_inv : has_involutive_inv (filter α) :=
187
215
{ inv_inv := λ f, map_map.trans $ by rw [inv_involutive.comp_self, map_id],
188
216
..filter.has_inv }
189
217
@@ -208,7 +236,11 @@ end group
208
236
section div
209
237
variables [has_div α] {f f₁ f₂ g g₁ g₂ h : filter α} {s t : set α}
210
238
211
- @[to_additive] instance : has_div (filter α) := ⟨map₂ (/)⟩
239
+ /-- The filter `f / g` is generated by `{s / t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
240
+ @[to_additive " The filter `f - g` is generated by `{s - t | s ∈ f, t ∈ g}` in locale `pointwise`." ]
241
+ protected def has_div : has_div (filter α) := ⟨map₂ (/)⟩
242
+
243
+ localized " attribute [instance] filter.has_div filter.has_sub" in pointwise
212
244
213
245
@[simp, to_additive] lemma map₂_div : map₂ (/) f g = f / g := rfl
214
246
@[to_additive] lemma mem_div : s ∈ f / g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ / t₂ ⊆ s := iff.rfl
@@ -233,6 +265,8 @@ le_map₂_iff
233
265
234
266
end div
235
267
268
+ open_locale pointwise
269
+
236
270
section group
237
271
variables [group α] [group β] {f g : filter α} {f₂ : filter β}
238
272
@@ -251,16 +285,20 @@ end group
251
285
`div_inv_monoid` and `has_involutive_inv` but smaller than `group` and `group_with_zero`. -/
252
286
253
287
/-- `f / g = f * g⁻¹` for all `f g : filter α` if `a / b = a * b⁻¹` for all `a b : α`. -/
254
- @[to_additive " `f - g = f + -g` for all `f g : filter α` if `a - b = a + -b` for all `a b : α`." ]
255
- instance div_inv_monoid [group α] : div_inv_monoid (filter α) :=
288
+ @[to_additive filter.sub_neg_monoid " `f - g = f + -g` for all `f g : filter α` if `a - b = a + -b`
289
+ for all `a b : α`." ]
290
+ protected def div_inv_monoid [group α] : div_inv_monoid (filter α) :=
256
291
{ div_eq_mul_inv := λ f g, map_map₂_distrib_right div_eq_mul_inv,
257
292
..filter.monoid, ..filter.has_inv, ..filter.has_div }
258
293
259
294
/-- `f / g = f * g⁻¹` for all `f g : filter α` if `a / b = a * b⁻¹` for all `a b : α`. -/
260
- instance div_inv_monoid' [group_with_zero α] : div_inv_monoid (filter α) :=
295
+ protected def div_inv_monoid' [group_with_zero α] : div_inv_monoid (filter α) :=
261
296
{ div_eq_mul_inv := λ f g, map_map₂_distrib_right div_eq_mul_inv,
262
297
..filter.monoid, ..filter.has_inv, ..filter.has_div }
263
298
299
+ localized " attribute [instance] filter.div_inv_monoid filter.sub_neg_monoid filter.div_inv_monoid'"
300
+ in pointwise
301
+
264
302
/-! ### Scalar addition/multiplication of filters -/
265
303
266
304
section smul
@@ -298,7 +336,10 @@ section vsub
298
336
variables [has_vsub α β] {f f₁ f₂ g g₁ g₂ : filter β} {h : filter α} {s t : set β}
299
337
include α
300
338
301
- instance : has_vsub (filter α) (filter β) := ⟨map₂ (-ᵥ)⟩
339
+ /-- The filter `f -ᵥ g` is generated by `{s -ᵥ t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
340
+ protected def has_vsub : has_vsub (filter α) (filter β) := ⟨map₂ (-ᵥ)⟩
341
+
342
+ localized " attribute [instance] filter.has_vsub" in pointwise
302
343
303
344
@[simp] lemma map₂_vsub : map₂ (-ᵥ) f g = f -ᵥ g := rfl
304
345
lemma mem_vsub {s : set α} : s ∈ f -ᵥ g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ -ᵥ t₂ ⊆ s := iff.rfl
@@ -320,8 +361,12 @@ end vsub
320
361
section smul
321
362
variables [has_scalar α β] {f f₁ f₂ : filter β} {s : set β} {a : α}
322
363
323
- @[to_additive filter.has_vadd_filter]
324
- instance has_scalar_filter : has_scalar α (filter β) := ⟨λ a, map ((•) a)⟩
364
+ /-- `a • f` is the map of `f` under `a •` in locale `pointwise`. -/
365
+ @[to_additive filter.has_vadd_filter
366
+ " `a +ᵥ f` is the map of `f` under `a +ᵥ` in locale `pointwise`." ]
367
+ protected def has_scalar_filter : has_scalar α (filter β) := ⟨λ a, map ((•) a)⟩
368
+
369
+ localized " attribute [instance] filter.has_scalar_filter filter.has_vadd_filter" in pointwise
325
370
326
371
@[simp, to_additive] lemma map_smul : map (λ b, a • b) f = a • f := rfl
327
372
@[to_additive] lemma mem_smul_filter : s ∈ a • f ↔ (•) a ⁻¹' s ∈ f := iff.rfl
@@ -339,6 +384,8 @@ map_mono hf
339
384
340
385
end smul
341
386
387
+ open_locale pointwise
388
+
342
389
@[to_additive]
343
390
instance smul_comm_class_filter [has_scalar α γ] [has_scalar β γ] [smul_comm_class α β γ] :
344
391
smul_comm_class α (filter β) (filter γ) :=
0 commit comments