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
|
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. -/
def Equivariant (f : X โ Y) : Prop :=
โ (x : X) (ฯ : FPerm ๐ธ), f (ฯ โข x) = ฯ โข f x
/-- A set is equivariant if it is closed under permutations. -/
def EquivariantSet (S : Set X) : Prop :=
โ (x : X) (ฯ : FPerm ๐ธ), x โ S โ ฯ โข x โ S
/-- A binary relation is equivariant if it is closed under permutations. -/
def EquivariantRelation (R : Rel X Y) : Prop :=
โ (x : X) (y : Y) (ฯ : FPerm ๐ธ), R x y โ R (ฯ โข x) (ฯ โข y)
/-- Extended setoid definition that also requires the relation to be equivariant. -/
class EquivariantSetoid (X : Type) [PermSet ๐ธ X] extends Setoid X where
equivariant : EquivariantRelation ๐ธ r
/-- For equivariant sets, we even have "if and only if". -/
lemma equivariant_set_iff {S : Set X} : EquivariantSet ๐ธ S โ โ (x : X) (ฯ : FPerm ๐ธ), x โ S โ ฯ โข x โ S := by
constructor
ยท intro h x ฯ; constructor
ยท intro hx; exact h x ฯ hx
ยท intro hx
apply (h (ฯ โข x) ฯโปยน) at hx
simp only [inv_smul_smul] at hx
exact hx
ยท intro h x ฯ hx
exact (h x ฯ).mp hx
/-- For equivariant relations, we even have "if and only if". -/
lemma equivariant_relation_iff {R : Rel X Y} : EquivariantRelation ๐ธ R โ โ (x : X) (y : Y) (ฯ : FPerm ๐ธ), R x y โ R (ฯ โข x) (ฯ โข y) := by
constructor
ยท intro h 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
ยท intro h x y ฯ hxy
exact (h x y ฯ).mp 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. -/
lemma id_equivariant : Equivariant ๐ธ (id : X โ X) := by
simp [Equivariant]
/-- The composition of two equivariant functions is equivariant. -/
lemma comp_equivariant {f : Y โ Z} {g : X โ Y} : Equivariant ๐ธ f โ Equivariant ๐ธ g โ Equivariant ๐ธ (f โ g) := by
intro hf hg x ฯ
calc
f (g (ฯ โข x)) = f (ฯ โข g x) := by rw [hg]
_ = ฯ โข (f (g x)) := by rw [hf]
/-- The subset relation is equivariant. -/
lemma subset_equivariant : EquivariantRelation ๐ธ (Set.Subset : Set X โ Set X โ Prop) := by
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 Equivariant
/-- Equivariant functions preserve supports. -/
lemma preserve_support {x : X} {f : X โ Y} {S : Set ๐ธ} : Equivariant ๐ธ f โ PermSet.HasSupport ๐ธ x S โ PermSet.HasSupport ๐ธ (f x) S := by
intro hequi hsupp ฯ hฯ
calc
ฯ โข f x = f (ฯ โข x) := by rw [โ hequi]
_ = f x := by rw [hsupp hฯ]
/-- Equivariant injective functions exactly preserve supports. -/
lemma preserve_support_inj {x : X} {f : X โ Y} {S : Set ๐ธ} : Equivariant ๐ธ f โ f.Injective โ (PermSet.HasSupport ๐ธ x S โ PermSet.HasSupport ๐ธ (f x) S) := by
intro hequi hinj; constructor
ยท exact preserve_support ๐ธ hequi
ยท intro hsupp ฯ hฯ
by_contra h
have : ฯ โข f x โ f x := by rw [โ hequi]; exact fun a => h (hinj a)
have : ฯ โข f x = f x := hsupp hฯ
contradiction
end Equivariant
/-- HasSupport is an equivariant relation. -/
lemma PermSet.support_equivariant : EquivariantRelation ๐ธ (HasSupport ๐ธ : X โ Set ๐ธ โ Prop) := by
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 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
intro hequi
apply NominalSet.support_subset_supp
ยท exact preserve_support ๐ธ hequi (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 hequi hinj
simp [NominalSet.supp, preserve_support_inj ๐ธ hequi hinj]
end Equivariant
/-- If there is an equivariant surjection from a nominal set into an (FPerm ๐ธ)-Set, then that set is nominal. -/
def NominalSet.fromEquivariantSurjective {X Y : Type} [NominalSet ๐ธ X] [PermSet ๐ธ Y] (f : X โ Y) (hequi : 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 Equivariant.preserve_support ๐ธ hequi (supp_is_support ๐ธ)
ยท exact supp_finite ๐ธ
/-- supp is an equivariant function. -/
lemma NominalSet.supp_equivariant : Equivariant ๐ธ (supp ๐ธ : X โ Set ๐ธ) := by
intro x ฯ; ext a; constructor
ยท apply support_subset_supp ๐ธ
ยท apply PermSet.support_equivariant
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]
apply PermSet.support_equivariant
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. -/
lemma NominalSet.fresh_equivariant : EquivariantRelation ๐ธ (NominalSet.IsFresh : ๐ธ โ X โ Prop) := by
intro x y ฯ h
rwa [IsFresh, supp_equivariant, 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 Equivariance
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โ : EquivariantRelation ๐ธ R โ (ะ a, R a x) โ (โ a, a # x โง R a x) := by
intro hequi 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โ : EquivariantRelation ๐ธ R โ (โ a, a # x โง R a x) โ (โ a, a # x โ R a x) := by
intro hequi h
obtain โจa, โจhfresha, haโฉโฉ := h
intro b hfreshb
have hmem := hequi a x โธจa, bโธฉ ha
rw [PermSet.atom_swap, Equiv.swap_apply_left] at hmem
rw [NominalSet.fresh_swap_fix ๐ธ hfresha hfreshb] at hmem
exact hmem
private lemma for_fresh_iffโ : EquivariantRelation ๐ธ R โ (โ a, a # x โ R a x) โ (ะ a, R a x) := by
intro hequi 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 : EquivariantRelation ๐ธ R โ ((ะ a, R a x) โ (โ a, a # x โง R a x)) := by
intro hequi; constructor
ยท intro h
apply for_fresh_iffโ ๐ธ hequi
exact h
ยท intro h
apply for_fresh_iffโ ๐ธ hequi
apply for_fresh_iffโ ๐ธ hequi
exact h
/-- The quantifier in `ะ a, a R x` is equivalent to "for all fresh `a`". -/
lemma for_fresh_iff_all : EquivariantRelation ๐ธ R โ ((ะ a, R a x) โ (โ a, a # x โ R a x)) := by
intro hequi; constructor
ยท intro h
apply for_fresh_iffโ ๐ธ hequi
apply for_fresh_iffโ ๐ธ hequi
exact h
ยท intro h
apply for_fresh_iffโ ๐ธ hequi
exact h
end Equivariance
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 : 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 : 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, id_equivariant ๐ธโฉ
/-- Function composition. -/
def comp (f : Y โโ[๐ธ] Z) (g : X โโ[๐ธ] Y) : X โโ[๐ธ] Z := โจf โ g, comp_equivariant ๐ธ f.equivariant g.equivariantโฉ
@[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
|