1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
import Mathlib
import Nominal.Permutations
import Nominal.Support
/-!
# Definitions and Properties for Equivariance
We define equivariance for functions, sets, and binary relations.
-/
variable (๐ธ : Type) [Infinite ๐ธ] [Countable ๐ธ] [DecidableEq ๐ธ]
/-!
## Definitions
Basic definitions for equivariance.
-/
section Definition
variable {X Y : Type} [PermSet ๐ธ X] [PermSet ๐ธ Y]
/-- A function is equivariant if it is invariant to applying a permutation before or after the function. -/
class inductive Function.Equivariant (f : X โ Y) : Prop
| intro : (โ (x : X) (ฯ : FPerm ๐ธ), f (ฯ โข x) = ฯ โข f x) โ Equivariant f
lemma Function.equivariant (f : X โ Y) [Equivariant ๐ธ f] :
โ (x : X) (ฯ : FPerm ๐ธ), f (ฯ โข x) = ฯ โข f x := by
cases (inferInstanceAs (Equivariant ๐ธ f)); assumption
/-- A set is equivariant if it is closed under permutations. -/
class inductive Set.Equivariant (S : Set X) : Prop
| intro : (โ (x : X) (ฯ : FPerm ๐ธ), x โ S โ ฯ โข x โ S) โ Equivariant S
/-- For equivariant sets, we even have "if and only if". -/
lemma Set.equivariant (S : Set X) [Equivariant ๐ธ S] :
โ (x : X) (ฯ : FPerm ๐ธ), x โ S โ ฯ โข x โ S := by
cases (inferInstanceAs (Equivariant ๐ธ S)); rename_i h
intro x ฯ; constructor
ยท intro hx; exact h x ฯ hx
ยท intro hx
apply (h (ฯ โข x) ฯโปยน) at hx
simp only [inv_smul_smul] at hx
exact hx
/-- A binary relation is equivariant if it is closed under permutations. -/
class inductive Rel.Equivariant (R : Rel X Y) : Prop
| intro : (โ (x : X) (y : Y) (ฯ : FPerm ๐ธ), R x y โ R (ฯ โข x) (ฯ โข y)) โ Equivariant R
/-- For equivariant relations, we even have "if and only if". -/
lemma Rel.equivariant (R : Rel X Y) [Rel.Equivariant ๐ธ R] :
โ (x : X) (y : Y) (ฯ : FPerm ๐ธ), R x y โ R (ฯ โข x) (ฯ โข y) := by
cases (inferInstanceAs (Equivariant ๐ธ R)); rename_i h
intro x y ฯ; constructor
ยท intro hxy; exact h x y ฯ hxy
ยท intro hxy
apply (h (ฯ โข x) (ฯ โข y) ฯโปยน) at hxy
simp only [inv_smul_smul] at hxy
exact hxy
end Definition
/-!
## Trivial Instances
Some trivial instances of equivariant functions, sets, and relations.
-/
section Trivial
variable {X Y Z : Type} [PermSet ๐ธ X] [PermSet ๐ธ Y] [PermSet ๐ธ Z]
/-- The identity function is equivariant. -/
instance Function.Equivariant.id : Function.Equivariant ๐ธ (id : X โ X) := by
constructor
simp
/-- The composition of two equivariant functions is equivariant. -/
instance Function.Equivariant.comp
{f : Y โ Z} [Function.Equivariant ๐ธ f] {g : X โ Y} [Function.Equivariant ๐ธ g] :
Function.Equivariant ๐ธ (f โ g) := by
constructor; intro x ฯ
calc
f (g (ฯ โข x)) = f (ฯ โข g x) := by rw [โ Function.equivariant ๐ธ g]
_ = ฯ โข (f (g x)) := by rw [โ Function.equivariant ๐ธ f]
/-- If a function is equivariant, its inverse is also equivariant. -/
def Function.Equivariant.inv
{f : X โ Y} [Function.Equivariant ๐ธ f] {inv : Y โ X}
(hleft : Function.LeftInverse inv f)
(hright : Function.RightInverse inv f) :
Function.Equivariant ๐ธ inv := by
constructor; intro y ฯ
apply hleft.injective
rw [Function.equivariant ๐ธ f, hright, hright]
/-- The subset relation is equivariant. -/
instance Set.Equivariant.subset : Rel.Equivariant ๐ธ (Set.Subset : Set X โ Set X โ Prop) := by
constructor; intro S T ฯ hST x hx
rw [Set.mem_smul_set_iff_inv_smul_mem] at hx
rw [Set.mem_smul_set_iff_inv_smul_mem]
exact hST hx
end Trivial
/-!
## Support
Propositions relating equivariance to support in (FPerm ๐ธ)-sets.
-/
section Support
variable {X Y : Type} [PermSet ๐ธ X] [PermSet ๐ธ Y]
namespace Function.Equivariant
/-- Equivariant functions preserve supports. -/
lemma preserve_support {x : X} {f : X โ Y} [Equivariant ๐ธ f] {S : Set ๐ธ} :
PermSet.HasSupport ๐ธ x S โ PermSet.HasSupport ๐ธ (f x) S := by
intro hsupp ฯ hฯ
calc
ฯ โข f x = f (ฯ โข x) := by rw [โ equivariant ๐ธ f]
_ = f x := by rw [hsupp hฯ]
/-- Equivariant injective functions exactly preserve supports. -/
lemma preserve_support_inj {x : X} {f : X โ Y} [Equivariant ๐ธ f] {S : Set ๐ธ} :
f.Injective โ (PermSet.HasSupport ๐ธ x S โ PermSet.HasSupport ๐ธ (f x) S) := by
intro hinj; constructor
ยท exact preserve_support ๐ธ
ยท intro hsupp ฯ hฯ
by_contra h
have : ฯ โข f x โ f x := by rw [โ equivariant ๐ธ f]; intro hcontra; exact h (hinj hcontra)
have : ฯ โข f x = f x := hsupp hฯ
contradiction
end Function.Equivariant
/-- HasSupport is an equivariant relation. -/
instance PermSet.instHasSupportEquivariant : Rel.Equivariant ๐ธ (HasSupport ๐ธ : X โ Set ๐ธ โ Prop) := by
constructor; intro x S ฯ hS ฯ hฯ
have hfix : (ฯโปยน * ฯ * ฯ) โ fix ๐ธ S := by
intro a ha
calc
(ฯโปยน * ฯ * ฯ) โข a = ฯโปยน โข (ฯ โข (ฯ โข a)) := rfl
_ = ฯโปยน โข (ฯ โข a) := by rw [hฯ (ฯ โข a) (Set.smul_mem_smul_set ha)]
_ = (ฯโปยน * ฯ) โข a := rfl
_ = (1 : FPerm ๐ธ) โข a := by rw [@Group.inv_mul_cancel]
_ = a := rfl
calc
ฯ โข (ฯ โข x) = (ฯ * ฯ) โข x := by apply smul_smul
_ = (1 * ฯ * ฯ) โข x := rfl
_ = (ฯ * ฯโปยน * ฯ * ฯ) โข x := by rw [@mul_inv_cancel]
_ = ฯ โข ((ฯโปยน * ฯ * ฯ) โข x) := by symm; apply smul_smul
_ = ฯ โข x := by rw [hS hfix]
end Support
/-!
## Nominal Sets
Properties about equivariance relating to nominal sets.
-/
section Nominal
variable {X Y : Type} [NominalSet ๐ธ X] [NominalSet ๐ธ Y]
namespace Function.Equivariant
/-- If f is equivariant, then supp (f x) โ supp x. -/
lemma supp_subset {x : X} {f : X โ Y} [Equivariant ๐ธ f] :
NominalSet.supp ๐ธ (f x) โ NominalSet.supp ๐ธ x := by
apply NominalSet.support_subset_supp
ยท exact preserve_support ๐ธ (NominalSet.supp_is_support ๐ธ)
ยท exact NominalSet.supp_finite ๐ธ
/-- If f is equivariant and injective, then supp (f x) = supp x. -/
lemma supp_eq_if_inj {x : X} {f : X โ Y} [Equivariant ๐ธ f] :
Function.Injective f โ NominalSet.supp ๐ธ (f x) = NominalSet.supp ๐ธ x := by
intro hinj
simp [NominalSet.supp, preserve_support_inj ๐ธ hinj]
/-- If f is equivariant and a # x, then a # f x. -/
lemma preserve_fresh {a : ๐ธ} {x : X} {f : X โ Y} [Equivariant ๐ธ f] : a # x โ a # f x := by
intro hx ha
exact hx (supp_subset ๐ธ ha)
/-- If f is equivariant and injective, then a # x iff a # f x. -/
lemma preserve_fresh_inj {a : ๐ธ} {x : X} {f : X โ Y} [Equivariant ๐ธ f] :
Function.Injective f โ (a # x โ a # f x) := by
intro hinj
rw [NominalSet.IsFresh, NominalSet.IsFresh, supp_eq_if_inj ๐ธ hinj]
end Function.Equivariant
/-- If there is an equivariant surjection from a nominal set into an (FPerm ๐ธ)-Set, then that set is nominal. -/
def NominalSet.ofEquivariantSurjective
{X Y : Type} [NominalSet ๐ธ X] [PermSet ๐ธ Y]
(f : X โ Y) [Function.Equivariant ๐ธ f] (hsurj : Function.Surjective f) :
NominalSet ๐ธ Y where
fin_supp := by
intro y
obtain โจx, hxโฉ := hsurj y
use (NominalSet.supp ๐ธ x)
constructor
ยท rw [โ hx]
exact Function.Equivariant.preserve_support ๐ธ (supp_is_support ๐ธ)
ยท exact supp_finite ๐ธ
/-- supp is an equivariant function. -/
instance NominalSet.instSuppEquivariant : Function.Equivariant ๐ธ (supp ๐ธ : X โ Set ๐ธ) := by
constructor; intro x ฯ
ext a; constructor
ยท apply support_subset_supp ๐ธ
ยท rw [โ Rel.equivariant ๐ธ (PermSet.HasSupport ๐ธ)]
exact supp_is_support ๐ธ
ยท apply Set.Finite.smul_set
exact supp_finite ๐ธ
ยท intro ha S hS
have hsupp : PermSet.HasSupport ๐ธ x (ฯโปยน โข S) := by
rw [show x = ฯโปยน โข ฯ โข x by exact eq_inv_smul_iff.mpr rfl]
rw [โ Rel.equivariant ๐ธ (PermSet.HasSupport ๐ธ)]
exact hS.out.left
rw [Set.mem_smul_set_iff_inv_smul_mem] at ha
suffices ฯโปยน โข a โ ฯโปยน โข S by rw [Set.smul_mem_smul_set_iff] at this; assumption
suffices supp ๐ธ x โ ฯโปยน โข S by exact this ha
apply support_subset_supp ๐ธ
ยท exact hsupp
ยท apply Set.Finite.smul_set
exact hS.out.right
/-- Freshness is an equivariant relation. -/
instance NominalSet.instFreshEquivariant : Rel.Equivariant ๐ธ (NominalSet.IsFresh : ๐ธ โ X โ Prop) := by
constructor; intro x y ฯ h
rwa [IsFresh, Function.equivariant ๐ธ (supp ๐ธ), Set.smul_mem_smul_set_iff]
end Nominal
/-!
## Freshness
For propositions of the form `ะ a, a R x`, where `R` is an equivariant relation, we do not have to differentiate between "for any fresh a" and "for all fresh a".
-/
section Freshness
namespace Rel.Equivariant
variable {X : Type} [NominalSet ๐ธ X] {R: Rel ๐ธ X} {x : X}
-- We continue with a circular implication chain argument to show these equivalences.
private lemma for_fresh_iffโ : (ะ a, R a x) โ (โ a, a # x โง R a x) := by
intro h
apply Set.Finite.infinite_compl at h
simp at h
have hinf : ({a | R a x} \ NominalSet.supp ๐ธ x).Infinite := Set.Infinite.diff h (NominalSet.supp_finite ๐ธ)
obtain โจa, haโฉ := hinf.nonempty
simp only [Set.mem_diff, Set.mem_setOf_eq] at ha
use a; exact ha.symm
private lemma for_fresh_iffโ [Rel.Equivariant ๐ธ R] : (โ a, a # x โง R a x) โ (โ a, a # x โ R a x) := by
intro h
obtain โจa, โจhfresha, haโฉโฉ := h
intro b hfreshb
rw [Rel.equivariant ๐ธ R b x โธจa, bโธฉ]
rw [PermSet.atom_swap, Equiv.swap_apply_right, NominalSet.fresh_swap_fix ๐ธ hfresha hfreshb]
exact ha
private lemma for_fresh_iffโ : (โ a, a # x โ R a x) โ (ะ a, R a x) := by
intro h
have hsub : {a : ๐ธ | R a x}แถ โ NominalSet.supp ๐ธ x := by
rw [Set.compl_subset_comm]
intro a ha
rw [Set.mem_compl_iff] at ha
exact h a ha
simp only [NominalSet.ForFresh]
apply Set.Finite.subset (NominalSet.supp_finite ๐ธ) hsub
/-- The quantifier in `ะ a, a R x` is equivalent to "for any fresh `a`". -/
lemma for_fresh_iff_exists [Rel.Equivariant ๐ธ R] : ((ะ a, R a x) โ (โ a, a # x โง R a x)) := by
constructor
ยท intro h
apply for_fresh_iffโ
exact h
ยท intro h
apply for_fresh_iffโ
apply for_fresh_iffโ
exact h
/-- The quantifier in `ะ a, a R x` is equivalent to "for all fresh `a`". -/
lemma for_fresh_iff_all [Rel.Equivariant ๐ธ R] : ((ะ a, R a x) โ (โ a, a # x โ R a x)) := by
constructor
ยท intro h
apply for_fresh_iffโ
apply for_fresh_iffโ
exact h
ยท intro h
apply for_fresh_iffโ
exact h
end Rel.Equivariant
end Freshness
/-!
## Bundled Functions
In the following, we also define a bundled function type for equivariant functions.
-/
section BundledFunction
/-- A function carrying a proof of its equivariance. -/
structure EquivariantMap (X Y : Type) [PermSet ๐ธ X] [PermSet ๐ธ Y] where
/-- The underlying function. -/
toFun : X โ Y
/-- Proof of equivariance. -/
equivariant : Function.Equivariant ๐ธ toFun
/-- We write `X โโ Y` or `X โโ[๐ธ] Y` for an equivariant map X โ Y. -/
infixr:25 " โโ " => EquivariantMap _
/-- We write `X โโ Y` or `X โโ[๐ธ] Y` for an equivariant map X โ Y. -/
notation:25 X " โโ[" A "] " Y => EquivariantMap A X Y
variable {X Y Z : Type} [PermSet ๐ธ X] [PermSet ๐ธ Y] [PermSet ๐ธ Z]
instance EquivariantMap.toFunEquivariant (f : X โโ[๐ธ] Y) : Function.Equivariant ๐ธ f.toFun :=
f.equivariant
instance : FunLike (X โโ[๐ธ] Y) X Y where
coe := EquivariantMap.toFun
coe_injective' f g h := by cases f; cases g; congr
namespace EquivariantMap
/-- The identity function. -/
def id : X โโ[๐ธ] X := โจ_root_.id, inferInstanceโฉ
/-- Function composition. -/
def comp (f : Y โโ[๐ธ] Z) (g : X โโ[๐ธ] Y) : X โโ[๐ธ] Z := โจf.toFun โ g.toFun, inferInstanceโฉ
@[simp]
lemma id_app (x : X) : id ๐ธ x = x := rfl
@[simp]
lemma comp_app (f : Y โโ[๐ธ] Z) (g : X โโ[๐ธ] Y) (x : X) : comp ๐ธ f g x = f (g x) := rfl
@[simp]
lemma toFun_eq_coe {f : X โโ[๐ธ] Y} : f.toFun = (f : X โ Y) :=
rfl
@[ext]
lemma ext {f g : X โโ[๐ธ] Y} (h : โ a, f a = g a) : f = g :=
DFunLike.ext _ _ h
end EquivariantMap
end BundledFunction
/-!
## Equivalences
If two types are equivalent and the conversion function is also equivariant, we know some additional information about nominal set structures.
-/
section Equivalence
/-- An equivalence where the function is equivariant. -/
structure EquivariantEquiv (X Y : Type) [PermSet ๐ธ X] [PermSet ๐ธ Y] extends Equiv X Y where
toFun_equivariant : Function.Equivariant ๐ธ toFun
invFun_equivariant : Function.Equivariant ๐ธ invFun := Function.Equivariant.inv ๐ธ left_inv right_inv
def Equivariant.Equiv.symm {๐ธ X Y : Type} [Infinite ๐ธ] [Countable ๐ธ] [DecidableEq ๐ธ] [PermSet ๐ธ X] [PermSet ๐ธ Y] (equiv : EquivariantEquiv ๐ธ X Y) : EquivariantEquiv ๐ธ Y X :=
{ toFun := equiv.invFun
invFun := equiv.toFun
toFun_equivariant := equiv.invFun_equivariant
left_inv := equiv.right_inv
right_inv := equiv.left_inv
}
instance EquivariantEquiv.toFunEquivariant
{X Y : Type} [PermSet ๐ธ X] [PermSet ๐ธ Y]
(equiv : EquivariantEquiv ๐ธ X Y) : Function.Equivariant ๐ธ equiv.toFun :=
equiv.toFun_equivariant
instance EquivariantEquiv.invFunEquivariant
{X Y : Type} [PermSet ๐ธ X] [PermSet ๐ธ Y]
(equiv : EquivariantEquiv ๐ธ X Y) : Function.Equivariant ๐ธ equiv.invFun :=
equiv.invFun_equivariant
/-- If an (FPerm ๐ธ)-Set is equivalent to a nominal set, it is also a nominal set. -/
def NominalSet.ofEquivariantEquiv {X Y : Type} [PermSet ๐ธ X] [NominalSet ๐ธ Y] (equiv : EquivariantEquiv ๐ธ X Y) : NominalSet ๐ธ X :=
NominalSet.ofEquivariantSurjective ๐ธ equiv.invFun equiv.symm.surjective
/-- If two nominal sets are equivalent, the corresponding least supports are equal. -/
lemma EquivariantEquiv.supp_eq {X Y : Type} [NominalSet ๐ธ X] [NominalSet ๐ธ Y] (equiv : EquivariantEquiv ๐ธ X Y) (x : X) : NominalSet.supp ๐ธ x = NominalSet.supp ๐ธ (equiv.toFun x) := by
symm
apply Function.Equivariant.supp_eq_if_inj
exact equiv.injective
end Equivalence
|