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
|
import Mathlib
import Nominal.Support
import Nominal.Equivariance
import Nominal.Category
import Nominal.Permutations
import Nominal.Instances.Basic
variable (𝔸 : Type) [Infinite 𝔸] [Countable 𝔸] [DecidableEq 𝔸]
namespace PermSet
/-- Restrict a type to its finitely supported elements -/
abbrev Finsupp (X : Type) [PermSet 𝔸 X] : Type :=
{ x : X // ∃ S, PermSet.HasSupport 𝔸 x S ∧ S.Finite }
namespace Finsupp
variable {X : Type} [PermSet 𝔸 X]
instance : PermSet 𝔸 (Finsupp 𝔸 X) where
smul π x := ⟨π • x.val, by
obtain ⟨S, ⟨hS₁, hS₂⟩⟩ := x.prop
use π • S; constructor
· rw [← Rel.equivariant 𝔸 (HasSupport 𝔸)]
exact hS₁
· exact Set.Finite.smul_set hS₂⟩
one_smul x := by
apply Subtype.eq
exact MulAction.one_smul x.val
mul_smul π τ x := by
apply Subtype.eq
exact MulAction.mul_smul π τ x.val
@[simp] lemma smul_val (π : FPerm 𝔸) (x : Finsupp 𝔸 X) : (π • x).val = π • x.val := rfl
instance instValEquivariant : Function.Equivariant 𝔸 (Subtype.val : Finsupp 𝔸 X → X) := by
constructor; simp
instance : NominalSet 𝔸 (Finsupp 𝔸 X) where
fin_supp x := by
obtain ⟨S, ⟨hS₁, hS₂⟩⟩ := x.prop
use S; constructor
· intro π hπ
apply Subtype.eq
exact hS₁ hπ
· exact hS₂
end Finsupp
abbrev FinsuppSet (X : Type) [PermSet 𝔸 X] : Type :=
Finsupp 𝔸 (Set X)
instance {X Y : Type} [SMul (FPerm 𝔸) X] [SMul (FPerm 𝔸) Y] : SMul (FPerm 𝔸) (X → Y) where
smul π f := fun x ↦ π • f (π⁻¹ • x)
@[simp] lemma smul_function {X Y : Type} [PermSet 𝔸 X] [PermSet 𝔸 Y] (π : FPerm 𝔸)
(f : X → Y) (x : X) : (π • f) x = π • f (π⁻¹ • x) :=
rfl
instance {X Y : Type} [PermSet 𝔸 X] [PermSet 𝔸 Y] : PermSet 𝔸 (X → Y) where
one_smul f := by ext x; simp
mul_smul π τ f := by ext x; simp [MulAction.mul_smul]
abbrev FinsuppFunction (X Y : Type) [PermSet 𝔸 X] [PermSet 𝔸 Y] : Type :=
Finsupp 𝔸 (X → Y)
variable (X Y : Type) [NominalSet 𝔸 X] [NominalSet 𝔸 Y]
namespace Finsupp
private def flatten' (f : X → PermSet.FinsuppSet 𝔸 Y) : Set (X × Y) :=
{p : X × Y | p.snd ∈ (f p.fst).val}
instance : Function.Equivariant 𝔸 (flatten' 𝔸 X Y) := by
constructor
intro f π; ext ⟨x, y⟩; constructor
· simp only [flatten', PermSet.smul_function, PermSet.Finsupp.smul_val, Set.mem_setOf_eq]
intro hy
have hy' : π⁻¹ • y ∈ π⁻¹ • π • (f (π⁻¹ • x)).val := by
rw [Set.smul_mem_smul_set_iff]; exact hy
rw [inv_smul_smul] at hy'
rw [show (x, y) = π • (π⁻¹ • x, π⁻¹ • y) by simp]
rw [Set.smul_mem_smul_set_iff]
exact hy'
· intro hxy
have hxy' : π⁻¹ • (x, y) ∈ π⁻¹ • π • flatten' 𝔸 X Y f := by
rw [Set.smul_mem_smul_set_iff]; exact hxy
simp only [inv_smul_smul, Prod.smul_mk, flatten', Set.mem_setOf_eq] at hxy'
simp only [flatten', PermSet.smul_function, PermSet.Finsupp.smul_val, Set.mem_setOf_eq]
have hy : π • π⁻¹ • y ∈ π • (f (π⁻¹ • x)).val := by
rw [Set.smul_mem_smul_set_iff]; exact hxy'
simp only [smul_inv_smul] at hy
exact hy
def flatten (f : PermSet.FinsuppFunction 𝔸 X (PermSet.FinsuppSet 𝔸 Y)) :
PermSet.FinsuppSet 𝔸 (X × Y) :=
⟨flatten' 𝔸 X Y f.val, by
obtain ⟨S, ⟨hS₁, hS₂⟩⟩ := f.prop
use S; constructor
· apply Function.Equivariant.preserve_support
exact hS₁
· exact hS₂⟩
instance : Function.Equivariant 𝔸 (flatten 𝔸 X Y) := by
constructor; intro p π
apply Subtype.eq
simp only [flatten, Finsupp.smul_val]
apply Function.equivariant
private def unflatten' (S : PermSet.FinsuppSet 𝔸 (X × Y)) : X → (PermSet.FinsuppSet 𝔸 Y) :=
fun x ↦ ⟨{y : Y | (x, y) ∈ S.val}, by
-- Pitts
sorry⟩
instance : Function.Equivariant 𝔸 (unflatten' 𝔸 X Y) := by
constructor
intro S π
-- Pitts
sorry
def unflatten (S : PermSet.FinsuppSet 𝔸 (X × Y)) : PermSet.FinsuppFunction 𝔸 X (PermSet.FinsuppSet 𝔸 Y) :=
⟨unflatten' 𝔸 X Y S, by
obtain ⟨A, ⟨hS₁, hS₂⟩⟩ := S.prop
use A; constructor
· apply Function.Equivariant.preserve_support
rw [← Function.Equivariant.preserve_support_inj 𝔸 Subtype.val_injective] at hS₁
exact hS₁
· exact hS₂⟩
instance : Function.Equivariant 𝔸 (unflatten 𝔸 X Y) := by
constructor; intro p π
apply Subtype.eq
simp only [unflatten, Finsupp.smul_val]
apply Function.equivariant
def flattenEquiv :
EquivariantEquiv 𝔸
(PermSet.FinsuppFunction 𝔸 X (PermSet.FinsuppSet 𝔸 Y))
(PermSet.FinsuppSet 𝔸 (X × Y)) where
toFun := flatten 𝔸 X Y
invFun := unflatten 𝔸 X Y
toFun_equivariant := inferInstance
end Finsupp
namespace FinsuppSet
private def union' : (FinsuppSet 𝔸 X × FinsuppSet 𝔸 X) → Set X :=
fun (S₁, S₂) ↦ S₁.val ∪ S₂.val
instance : Function.Equivariant 𝔸 (union' 𝔸 X) := by
constructor; intro (S₁, S₂) π
simp only [union', PermSet.Finsupp.smul_val]
exact Eq.symm Set.smul_set_union
def union : (FinsuppSet 𝔸 X × FinsuppSet 𝔸 X) → FinsuppSet 𝔸 X :=
fun p ↦ ⟨union' 𝔸 X p, by
use NominalSet.supp 𝔸 p; constructor
· apply Function.Equivariant.preserve_support
apply NominalSet.supp_is_support
· apply NominalSet.supp_finite⟩
instance : Function.Equivariant 𝔸 (union 𝔸 X) := by
constructor; intro p π
apply Subtype.eq
simp only [union, Finsupp.smul_val]
apply Function.equivariant
instance : Union (FinsuppSet 𝔸 X) := ⟨Function.curry (union 𝔸 X)⟩
@[simp] lemma union_val {S₁ S₂ : FinsuppSet 𝔸 X} :
(S₁ ∪ S₂).val = S₁.val ∪ S₂.val := rfl
@[simp] lemma union_equivariant {S₁ S₂ : FinsuppSet 𝔸 X} {π : FPerm 𝔸} :
π • (S₁ ∪ S₂) = π • S₁ ∪ π • S₂ := by
show π • (union _ _ (S₁, S₂)) = union _ _ (π • (S₁, S₂))
rw [← Function.equivariant]
private def inter' : (FinsuppSet 𝔸 X × FinsuppSet 𝔸 X) → Set X :=
fun (S₁, S₂) ↦ S₁.val ∩ S₂.val
instance : Function.Equivariant 𝔸 (inter' 𝔸 X) := by
constructor; intro (S₁, S₂) π
simp only [inter', PermSet.Finsupp.smul_val]
exact Eq.symm Set.smul_set_inter
def inter : (FinsuppSet 𝔸 X × FinsuppSet 𝔸 X) → FinsuppSet 𝔸 X :=
fun p ↦ ⟨inter' 𝔸 X p, by
use NominalSet.supp 𝔸 p; constructor
· apply Function.Equivariant.preserve_support
apply NominalSet.supp_is_support
· apply NominalSet.supp_finite⟩
instance : Function.Equivariant 𝔸 (inter 𝔸 X) := by
constructor; intro p π
apply Subtype.eq
simp only [inter, Finsupp.smul_val]
apply Function.equivariant
instance : Inter (FinsuppSet 𝔸 X) := ⟨Function.curry (inter 𝔸 X)⟩
@[simp] lemma inter_val {S₁ S₂ : FinsuppSet 𝔸 X} :
(S₁ ∩ S₂).val = S₁.val ∩ S₂.val := rfl
@[simp] lemma inter_equivariant {S₁ S₂ : FinsuppSet 𝔸 X} {π : FPerm 𝔸} :
π • (S₁ ∩ S₂) = π • S₁ ∩ π • S₂ := by
show π • (inter _ _ (S₁, S₂)) = inter _ _ (π • (S₁, S₂))
rw [← Function.equivariant]
private def sdiff' : (FinsuppSet 𝔸 X × FinsuppSet 𝔸 X) → Set X :=
fun (S₁, S₂) ↦ S₁.val \ S₂.val
instance : Function.Equivariant 𝔸 (sdiff' 𝔸 X) := by
constructor; intro (S₁, S₂) π
simp only [sdiff', PermSet.Finsupp.smul_val]
exact Eq.symm Set.smul_set_sdiff
def sdiff : (FinsuppSet 𝔸 X × FinsuppSet 𝔸 X) → FinsuppSet 𝔸 X :=
fun p ↦ ⟨sdiff' 𝔸 X p, by
use NominalSet.supp 𝔸 p; constructor
· apply Function.Equivariant.preserve_support
apply NominalSet.supp_is_support
· apply NominalSet.supp_finite⟩
instance : Function.Equivariant 𝔸 (sdiff 𝔸 X) := by
constructor; intro p π
apply Subtype.eq
simp only [sdiff, Finsupp.smul_val]
apply Function.equivariant
instance : SDiff (FinsuppSet 𝔸 X) := ⟨Function.curry (sdiff 𝔸 X)⟩
@[simp] lemma sdiff_val {S₁ S₂ : FinsuppSet 𝔸 X} :
(S₁ \ S₂).val = S₁.val \ S₂.val := rfl
@[simp] lemma sdiff_equivariant {S₁ S₂ : FinsuppSet 𝔸 X} {π : FPerm 𝔸} :
π • (S₁ \ S₂) = π • S₁ \ π • S₂ := by
show π • (sdiff _ _ (S₁, S₂)) = sdiff _ _ (π • (S₁, S₂))
rw [← Function.equivariant]
end FinsuppSet
abbrev FinSet (X : Type) [PermSet 𝔸 X] :=
{ S : Set X // S.Finite }
namespace FinSet
variable {X : Type} [PermSet 𝔸 X]
instance : PermSet 𝔸 (FinSet 𝔸 X) where
smul π S := ⟨π • S.val, by
rw [Set.finite_smul_set]
exact S.prop⟩
one_smul x := by
apply Subtype.eq
exact MulAction.one_smul x.val
mul_smul π τ x := by
apply Subtype.eq
exact MulAction.mul_smul π τ x.val
@[simp] lemma smul_val (π : FPerm 𝔸) (S : FinSet 𝔸 X) : (π • S).val = π • S.val := rfl
instance instValEquivariant : Function.Equivariant 𝔸 (Subtype.val : FinSet 𝔸 X → Set X) := by
constructor; simp
variable {X : Type} [NominalSet 𝔸 X]
instance : NominalSet 𝔸 (FinSet 𝔸 X) where
fin_supp := by sorry
@[simp] lemma supp {S : FinSet 𝔸 X} : NominalSet.supp 𝔸 S = ⋃₀ {NominalSet.supp 𝔸 x | x ∈ S.val} := by sorry
@[simp] lemma fresh {a : 𝔸} {S : FinSet 𝔸 X} : a # S ↔ ∀ x ∈ S.val, a # x := by
simp [NominalSet.IsFresh]
def toFinsuppSet (S : FinSet 𝔸 X) : FinsuppSet 𝔸 X :=
⟨S.val, by
use NominalSet.supp 𝔸 S; constructor
· apply Function.Equivariant.preserve_support
apply NominalSet.supp_is_support
· apply NominalSet.supp_finite⟩
@[simp] lemma toFinsuppSet_val (S : FinSet 𝔸 X) : S.toFinsuppSet.val = S.val := rfl
noncomputable def toFinset (S : FinSet 𝔸 X) : Finset X :=
S.prop.toFinset
def union : (FinSet 𝔸 X × FinSet 𝔸 X) → FinSet 𝔸 X :=
fun (S₁, S₂) ↦ ⟨S₁.val ∪ S₂.val, Set.Finite.union S₁.prop S₂.prop⟩
instance : Union (FinSet 𝔸 X) := ⟨Function.curry (union 𝔸)⟩
instance : Function.Equivariant 𝔸 (union 𝔸 : (FinSet 𝔸 X × FinSet 𝔸 X → FinSet 𝔸 X)) := by
constructor; intro (S₁, S₂) π
apply Subtype.eq
simp only [union, smul_val]
exact Eq.symm Set.smul_set_union
@[simp] lemma union_val {S₁ S₂ : FinSet 𝔸 X} :
(S₁ ∪ S₂).val = S₁.val ∪ S₂.val := rfl
@[simp] lemma union_equivariant {S₁ S₂ : FinSet 𝔸 X} {π : FPerm 𝔸} :
π • (S₁ ∪ S₂) = π • S₁ ∪ π • S₂ := by
show π • (union _ (S₁, S₂)) = union _ (π • (S₁, S₂))
rw [← Function.equivariant]
def inter : (FinSet 𝔸 X × FinSet 𝔸 X) → FinSet 𝔸 X :=
fun (S₁, S₂) ↦ ⟨S₁.val ∩ S₂.val, Set.Finite.inter_of_left S₁.prop S₂.val⟩
instance : Function.Equivariant 𝔸 (inter 𝔸 : (FinSet 𝔸 X × FinSet 𝔸 X → FinSet 𝔸 X)) := by
constructor; intro (S₁, S₂) π
apply Subtype.eq
simp only [inter, smul_val]
exact Eq.symm Set.smul_set_inter
instance : Inter (FinSet 𝔸 X) := ⟨Function.curry (inter 𝔸)⟩
@[simp] lemma inter_val {S₁ S₂ : FinSet 𝔸 X} :
(S₁ ∩ S₂).val = S₁.val ∩ S₂.val := rfl
@[simp] lemma inter_equivariant {S₁ S₂ : FinSet 𝔸 X} {π : FPerm 𝔸} :
π • (S₁ ∩ S₂) = π • S₁ ∩ π • S₂ := by
show π • (inter _ (S₁, S₂)) = inter _ (π • (S₁, S₂))
rw [← Function.equivariant]
def sdiff : (FinSet 𝔸 X × FinSet 𝔸 X) → FinSet 𝔸 X :=
fun (S₁, S₂) ↦ ⟨S₁.val \ S₂.val, Set.Finite.diff S₁.prop⟩
instance : Function.Equivariant 𝔸 (sdiff 𝔸 : (FinSet 𝔸 X × FinSet 𝔸 X → FinSet 𝔸 X)) := by
constructor; intro (S₁, S₂) π
apply Subtype.eq
simp only [sdiff, smul_val]
exact Eq.symm Set.smul_set_sdiff
def empty : FinSet 𝔸 X :=
⟨∅, Set.finite_empty⟩
instance : EmptyCollection (FinSet 𝔸 X) := ⟨empty 𝔸⟩
@[simp] lemma empty_val : (∅ : FinSet 𝔸 X).val = ∅ := rfl
instance : SDiff (FinSet 𝔸 X) := ⟨Function.curry (sdiff 𝔸)⟩
@[simp] lemma sdiff_val {S₁ S₂ : FinSet 𝔸 X} :
(S₁ \ S₂).val = S₁.val \ S₂.val := rfl
@[simp] lemma sdiff_equivariant {S₁ S₂ : FinSet 𝔸 X} {π : FPerm 𝔸} :
π • (S₁ \ S₂) = π • S₁ \ π • S₂ := by
show π • (sdiff _ (S₁, S₂)) = sdiff _ (π • (S₁, S₂))
rw [← Function.equivariant]
end FinSet
def Finset.toPermFinSet {S : Finset X} : PermSet.FinSet 𝔸 X :=
⟨S, Finset.finite_toSet S⟩
end PermSet
|