summaryrefslogtreecommitdiff
path: root/Algebra
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-12-05 23:19:57 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-12-05 23:19:57 +0100
commitaa280ca672aff145e811b79f4315ba200a09bad5 (patch)
treeab6e3f4944c52a8ba928a2f1358084364762baf4 /Algebra
parentcc3483496781b10b6acd2450117b443d03957dc4 (diff)
define algebras
Diffstat (limited to 'Algebra')
-rw-r--r--Algebra/Derivations.lean4
-rw-r--r--Algebra/Semantics.lean34
-rw-r--r--Algebra/Terms.lean24
3 files changed, 43 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