diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-10-23 22:32:44 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-10-23 22:32:44 +0200 |
| commit | 4cb79d58996f2601f886a7185e89fa6dd71579e1 (patch) | |
| tree | c47f846649a2b9e7fddab12ecd3f30f1e79e64b8 | |
| parent | f95c4f2bd8a88c4b4b35e77fc45f0f1036d10c9e (diff) | |
add forgetful functors
| -rw-r--r-- | Nominal/Category.lean | 41 | ||||
| -rw-r--r-- | Nominal/Equivariance.lean | 52 |
2 files changed, 82 insertions, 11 deletions
diff --git a/Nominal/Category.lean b/Nominal/Category.lean index fc7e161..9ee4fe3 100644 --- a/Nominal/Category.lean +++ b/Nominal/Category.lean @@ -11,6 +11,8 @@ This file contains formalizations for this category-theoretical view. variable (๐ธ : Type) [Infinite ๐ธ] [Countable ๐ธ] [DecidableEq ๐ธ] +open CategoryTheory + /-! ## Category Definition @@ -27,17 +29,40 @@ structure Nom where attribute [instance] Nom.nom +/-- Objects in Nom can be coerced to the underlying nominal set type. -/ +instance : CoeSort (Nom ๐ธ) Type := โจNom.carrierโฉ + /-- A morphism in the category of nominal sets; i.e., an equivariant function. -/ -structure Nom.Hom (X Y : Nom ๐ธ) where - /-- The underlying function. -/ - toFun : X.carrier โ Y.carrier - /-- Equivariance of the function. -/ - equivariant : Equivariant ๐ธ toFun +def Nom.Hom (X Y : Nom ๐ธ) := X โโ[๐ธ] Y + +/-- Coerce morphisms to functions between the underlying sets. -/ +instance (X Y : Nom ๐ธ) : CoeFun (Nom.Hom ๐ธ X Y) (fun _ => X.carrier โ Y.carrier) where + coe f := f.toFun /-- Nominal sets form a category with equivariant functions as morphisms. -/ -instance : CategoryTheory.Category (Nom ๐ธ) where +instance : Category (Nom ๐ธ) where Hom := Nom.Hom ๐ธ - id X := โจid, id_equivariant ๐ธโฉ - comp f g := โจg.toFun โ f.toFun, comp_equivariant ๐ธ f.equivariant g.equivariantโฉ + id X := EquivariantMap.id ๐ธ + comp f g := EquivariantMap.comp ๐ธ g f end Definition + +/-! +## Forgetful Functors + +Definitions of forgetful functors from the Nom category. +-/ +section Forget + +/-- The Nom category is a ConcreteCategory where objects correspond to types. -/ +instance : ConcreteCategory (Nom ๐ธ) (ยท โโ[๐ธ] ยท) where + hom := id + ofHom := id + +/-- There is a forgetful functor from Nom to the category of monoidal actions. -/ +instance : HasForgetโ (Nom ๐ธ) (Action Type (FPerm ๐ธ)) where + forgetโ := + { obj X := Action.ofMulAction (FPerm ๐ธ) X.carrier + map {X Y} f := โจf.toFun, by intro ฯ; ext x; simp; apply f.equivariantโฉ } + +end Forget diff --git a/Nominal/Equivariance.lean b/Nominal/Equivariance.lean index c9a5261..ac50519 100644 --- a/Nominal/Equivariance.lean +++ b/Nominal/Equivariance.lean @@ -71,11 +71,11 @@ lemma id_equivariant : Equivariant ๐ธ (id : X โ X) := by simp [Equivariant] /-- The composition of two equivariant functions is equivariant. -/ -lemma comp_equivariant {f : X โ Y} {g : Y โ Z} : Equivariant ๐ธ f โ Equivariant ๐ธ g โ Equivariant ๐ธ (g โ f) := by +lemma comp_equivariant {f : Y โ Z} {g : X โ Y} : Equivariant ๐ธ f โ Equivariant ๐ธ g โ Equivariant ๐ธ (f โ g) := by intro hf hg x ฯ calc - g (f (ฯ โข x)) = g (ฯ โข f x) := by rw [hf] - _ = ฯ โข (g (f x)) := by rw [hg] + 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 @@ -183,3 +183,49 @@ lemma NominalSet.supp_equivariant : Equivariant ๐ธ (supp ๐ธ : X โ Set ๐ธ exact hS.out.right end Nominal + +/-! +## 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 |
