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
|
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)
/-- 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 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 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
/-- 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
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}
/-- 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 sorry
/-- 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 sorry
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
|