diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-12-05 23:19:57 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-12-05 23:19:57 +0100 |
| commit | aa280ca672aff145e811b79f4315ba200a09bad5 (patch) | |
| tree | ab6e3f4944c52a8ba928a2f1358084364762baf4 | |
| parent | cc3483496781b10b6acd2450117b443d03957dc4 (diff) | |
define algebras
| -rw-r--r-- | Algebra/Derivations.lean | 4 | ||||
| -rw-r--r-- | Algebra/Semantics.lean | 34 | ||||
| -rw-r--r-- | Algebra/Terms.lean | 24 | ||||
| -rw-r--r-- | Nominal/Instances/Basic.lean | 60 |
4 files changed, 103 insertions, 19 deletions
diff --git a/Algebra/Derivations.lean b/Algebra/Derivations.lean index 142c49c..e2cd052 100644 --- a/Algebra/Derivations.lean +++ b/Algebra/Derivations.lean @@ -1,7 +1,7 @@ import Mathlib import Algebra.Terms -namespace Algebra +namespace NominalAlgebra section Theories @@ -237,4 +237,4 @@ instance TermAtDepth.setoid : Setoid (TermAtDepth πΈ T.sig X n) where end DerivableEquations -end Algebra +end NominalAlgebra diff --git a/Algebra/Semantics.lean b/Algebra/Semantics.lean new file mode 100644 index 0000000..f5160dd --- /dev/null +++ b/Algebra/Semantics.lean @@ -0,0 +1,34 @@ +import Mathlib +import Algebra.Terms +import Algebra.Derivations + +namespace NominalAlgebra + +variable (πΈ : Type) [Infinite πΈ] [Countable πΈ] [DecidableEq πΈ] +variable (sig : Signature) + +structure Algebra where + carrier : β β Nom πΈ + pure (f : sig.pure) {m : β} : + (sig.pureArgs f β carrier m) ββ[πΈ] carrier (m + sig.pureDepth f) + free (f : sig.free) {m : β} : + (πΈ Γ (sig.freeArgs f β carrier m)) ββ[πΈ] carrier (m + sig.freeDepth f) + bound (f : sig.bound) {m : β} : + NameAbstraction πΈ (sig.boundArgs f β carrier m) ββ[πΈ] carrier (m + sig.boundDepth f) + +instance : CoeFun (Algebra πΈ sig) (fun _ => β β Nom πΈ) where + coe A := A.carrier + +structure Algebra.Hom (A B : Algebra πΈ sig) where + toFun : (n : β) β (A n ββ[πΈ] B n) + preserve_pure : β (f : sig.pure) {m : β} (args : sig.pureArgs f β A m), + toFun (m + sig.pureDepth f) (A.pure f args) = B.pure f (toFun m β args) + preserve_free : β (a : πΈ) (f : sig.free) {m : β} (args : sig.freeArgs f β A m), + toFun (m + sig.freeDepth f) (A.free f β¨a, argsβ©) = B.free f β¨a, toFun m β argsβ© + preserve_bound : β (a : πΈ) (f : sig.bound) {m : β} (args : sig.boundArgs f β A m), + toFun (m + sig.boundDepth f) (A.bound f (βͺaβ« args)) = B.bound f (βͺaβ« toFun m β args) + +instance {A B : Algebra πΈ sig} : CoeFun (Algebra.Hom πΈ sig A B) (fun _ => (n : β) β (A n ββ[πΈ] B n)) where + coe h := h.toFun + +end NominalAlgebra diff --git a/Algebra/Terms.lean b/Algebra/Terms.lean index 997dca4..568f5cb 100644 --- a/Algebra/Terms.lean +++ b/Algebra/Terms.lean @@ -1,7 +1,7 @@ import Mathlib import Nominal -namespace Algebra +namespace NominalAlgebra section Definitions @@ -20,9 +20,9 @@ def Signature.pureArgs (sig : Signature) (f : sig.pure) : Type := sig.args (.inl def Signature.freeArgs (sig : Signature) (f : sig.free) : Type := sig.args (.inr (.inl f)) def Signature.boundArgs (sig : Signature) (f : sig.bound) : Type := sig.args (.inr (.inr f)) -def Signature.pureArgs_fintype (sig : Signature) (f : sig.pure) : Fintype (sig.pureArgs f) := sig.args_fintype (.inl f) -def Signature.freeArgs_fintype (sig : Signature) (f : sig.free) : Fintype (sig.freeArgs f) := sig.args_fintype (.inr (.inl f)) -def Signature.boundArgs_fintype (sig : Signature) (f : sig.bound) : Fintype (sig.boundArgs f) := sig.args_fintype (.inr (.inr f)) +instance Signature.instPureArgsFintype (sig : Signature) (f : sig.pure) : Fintype (sig.pureArgs f) := sig.args_fintype (.inl f) +instance Signature.instFreeArgsFintype (sig : Signature) (f : sig.free) : Fintype (sig.freeArgs f) := sig.args_fintype (.inr (.inl f)) +instance Signature.instBoundArgsFintype (sig : Signature) (f : sig.bound) : Fintype (sig.boundArgs f) := sig.args_fintype (.inr (.inr f)) def Signature.arity (sig : Signature) (f : sig.pure β sig.free β sig.bound) : β := (sig.args_fintype f).card def Signature.pureArity (sig : Signature) (f : sig.pure) : β := sig.arity (.inl f) @@ -217,23 +217,13 @@ private def atoms : Term πΈ sig X β Set πΈ private lemma atoms_finite (t : Term πΈ sig X) : t.atoms.Finite := by fun_induction atoms <;> all_goals expose_names Β· exact NominalSet.supp_finite πΈ - Β· have hfin := (sig.pureArgs_fintype f).finite - apply Set.Finite.sUnion + Β· apply Set.Finite.sUnion Β· simp only [Set.setOf_exists, Set.setOf_eq_eq_singleton', Set.iUnion_singleton_eq_range] apply Set.finite_range Β· intro S β¨x, hSβ© rw [β hS] exact ih1 x - Β· have hfin := (sig.freeArgs_fintype f).finite - apply Set.Finite.union - Β· exact Set.finite_singleton a - Β· apply Set.Finite.sUnion - Β· simp only [Set.setOf_exists, Set.setOf_eq_eq_singleton', Set.iUnion_singleton_eq_range] - apply Set.finite_range - Β· intro S β¨x, hSβ© - rw [β hS] - exact ih1 x - Β· have hfin := (sig.boundArgs_fintype f).finite + all_goals apply Set.Finite.union Β· exact Set.finite_singleton a Β· apply Set.Finite.sUnion @@ -319,4 +309,4 @@ end TermAtDepth end NominalSet -end Algebra +end NominalAlgebra diff --git a/Nominal/Instances/Basic.lean b/Nominal/Instances/Basic.lean index 64b6425..b627c1b 100644 --- a/Nominal/Instances/Basic.lean +++ b/Nominal/Instances/Basic.lean @@ -238,6 +238,66 @@ end Sum end Coproducts /-! +## Finitary Functions + +We can view functions with a finite domain as a finite product. As such, if the codomain is a +nominal set, the set of such functions is itself a nominal set, where supp f = ββ {supp (f x) | x}. +-/ +section FinitaryFunctions + +namespace Function + +instance {X Y : Type} [Fintype X] [PermSet πΈ Y] : PermSet πΈ (X β Y) where + +variable {X Y : Type} [Fintype X] [NominalSet πΈ Y] + +private lemma supp' {f : X β Y} : PermSet.HasSupport πΈ f (ββ {NominalSet.supp πΈ (f x) | x : X}) := by + intro Ο hΟ + ext x; rw [Pi.smul_apply] + show Ο β PermSet.fix' πΈ (f x) + apply NominalSet.supp_is_support + apply PermSet.fix_antitone_mem πΈ hΟ + apply Set.subset_sUnion_of_mem + use x + +private lemma fin {f : X β Y} : (ββ {NominalSet.supp πΈ (f x) | x : X}).Finite := by + apply Set.Finite.sUnion + Β· simp only [Set.setOf_exists, Set.setOf_eq_eq_singleton', Set.iUnion_singleton_eq_range] + apply Set.finite_range + Β· intro S β¨x, hSβ© + rw [β hS] + apply NominalSet.supp_finite + +instance : NominalSet πΈ (X β Y) where + fin_supp := by + intro f; use ββ {NominalSet.supp πΈ (f x) | x : X} + exact β¨supp' πΈ, fin πΈβ© + +@[simp] lemma supp {f : X β Y} : NominalSet.supp πΈ f = ββ {NominalSet.supp πΈ (f x) | x : X} := by + ext a; constructor + Β· apply NominalSet.support_subset_supp + Β· exact supp' πΈ + Β· exact fin πΈ + Β· intro hb + obtain β¨S, β¨x, hxβ©, haβ© := hb + subst hx + intro S hS + suffices PermSet.HasSupport πΈ (f x) S by + apply ha; exact β¨this, hS.out.rightβ© + intro Ο hΟ + suffices Ο β PermSet.fix' πΈ f by + rw [PermSet.fix', Set.mem_setOf_eq] at this + rw [PermSet.fix', Set.mem_setOf_eq, β Pi.smul_apply, this] + exact (hS.out.left hΟ).out + +@[simp] lemma fresh {a : πΈ} {f : X β Y} : a # f β β x, a # (f x) := by + simp [NominalSet.IsFresh] + +end Function + +end FinitaryFunctions + +/-! ## Quotient Types If β is an equivariant relation on X Γ X, then X/β is a nominal set with `supp [x] = ββ {supp y | y β [x]}`. |
