diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-12-04 17:14:46 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-12-04 17:14:46 +0100 |
| commit | 8fdf459876b999dbe184196f9abd330a3c24d560 (patch) | |
| tree | 3a834246faba68d9dcb59448e21c166816e0c8e0 | |
| parent | b00c95bd3580a8a8bd779f57a034900140ce41fa (diff) | |
implement derivable equality
| -rw-r--r-- | Algebra/Derivations.lean | 136 | ||||
| -rw-r--r-- | Algebra/Terms.lean | 23 | ||||
| -rw-r--r-- | Nominal/Instances/Basic.lean | 15 | ||||
| -rw-r--r-- | Nominal/Permutations.lean | 17 |
4 files changed, 191 insertions, 0 deletions
diff --git a/Algebra/Derivations.lean b/Algebra/Derivations.lean index e69de29..6f81e9a 100644 --- a/Algebra/Derivations.lean +++ b/Algebra/Derivations.lean @@ -0,0 +1,136 @@ +import Mathlib +import Algebra.Terms + +namespace Algebra + +section Theories + +variable (πΈ : Type) [Infinite πΈ] [Countable πΈ] [DecidableEq πΈ] +variable (sig : Signature) + +structure Equation where + vars : Type + [vars_nominal : NominalSet πΈ vars] + [vars_orbitFinite : OrbitFinite πΈ vars] + left : Term πΈ sig vars + right : Term πΈ sig vars + +namespace Equation + +instance (eq : Equation πΈ sig) : NominalSet πΈ eq.vars := + eq.vars_nominal + +instance (eq : Equation πΈ sig) : OrbitFinite πΈ eq.vars := + eq.vars_orbitFinite + +def HasDepth + {πΈ : Type} [Infinite πΈ] [Countable πΈ] [DecidableEq πΈ] {sig : Signature} + (eq : Equation πΈ sig) (n : β) : Prop := + eq.left.HasDepth n β§ eq.right.HasDepth n + +end Equation + +def EquationAtDepth (n : β) := + { eq : Equation πΈ sig // eq.HasDepth n } + +def UniformEquation := + { eq : Equation πΈ sig // β n, eq.HasDepth n } + +structure Theory where + sig : Signature + axioms : Set (UniformEquation πΈ sig) + +end Theories + +variable {πΈ : Type} [Infinite πΈ] [Countable πΈ] [DecidableEq πΈ] +variable {sig : Signature} + +section Helpers + +def EquationAtDepth.left {n : β} (eq : EquationAtDepth πΈ sig n) : TermAtDepth πΈ sig eq.val.vars n := + β¨eq.val.left, eq.prop.leftβ© + +def EquationAtDepth.right {n : β} (eq : EquationAtDepth πΈ sig n) : TermAtDepth πΈ sig eq.val.vars n := + β¨eq.val.right, eq.prop.rightβ© + +def EquationAtDepth.mk + (X : Type) [NominalSet πΈ X] [OrbitFinite πΈ X] {n : β} (t u : TermAtDepth πΈ sig X n) : + EquationAtDepth πΈ sig n := + β¨β¨X, t.val, u.valβ©, β¨t.prop, u.propβ©β© + +def EquationAtDepth.toUniform {n : β} (eq : EquationAtDepth πΈ sig n) : UniformEquation πΈ sig := + β¨eq.val, β¨n, eq.propβ©β© + +notation:50 X " β’ " lhs " β£ " rhs => EquationAtDepth.mk X lhs rhs + +end Helpers + +section DerivableEquations + +inductive Derivable (T : Theory πΈ) : {m : β} β (eq : EquationAtDepth πΈ T.sig m) β Prop + | refl {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] {x : X} : + Derivable T (X β’ .var x β£ .var x) + | symm {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] + {m : β} {t u : TermAtDepth πΈ T.sig X m} : + Derivable T (X β’ u β£ t) β + Derivable T (X β’ t β£ u) + | trans {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] + {m : β} {t u v : TermAtDepth πΈ T.sig X m} : + Derivable T (X β’ t β£ v) β + Derivable T (X β’ v β£ u) β + Derivable T (X β’ t β£ u) + | cong_pure {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] + {f : T.sig.pure} {m : β} {ts us : T.sig.pureArgs f β TermAtDepth πΈ T.sig X m} : + (β x, Derivable T (X β’ ts x β£ us x)) β + Derivable T (X β’ .pure f ts β£ .pure f us) + | cong_free {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] + {a : πΈ} {f : T.sig.free} {m : β} {ts us : T.sig.freeArgs f β TermAtDepth πΈ T.sig X m} : + (β x, Derivable T (X β’ ts x β£ us x)) β + Derivable T (X β’ .free a f ts β£ .free a f us) + | cong_bound {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] + {a : πΈ} {f : T.sig.bound} {m : β} {ts us : T.sig.boundArgs f β TermAtDepth πΈ T.sig X m} : + (β x, Derivable T (X β’ ts x β£ us x)) β + Derivable T (X β’ .bound a f ts β£ .bound a f us) + | ax' {X Y : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] [NominalSet πΈ Y] [OrbitFinite πΈ Y] + {m : β} {r s : TermAtDepth πΈ T.sig Y m} + {l : β} {Ο : UniformSubstitution πΈ T.sig Y X l} {Ο : FPerm πΈ} : + ((Y β’ r β£ s).toUniform β T.axioms) β + (β (y : Y) (Ο : FPerm πΈ), Derivable T (X β’ Ο (Ο β’ y) β£ Ο β’ (Ο y))) β + Derivable T (X β’ Ο.apply (Ο β’ r) β£ Ο.apply (Ο β’ s)) + | perm {X : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] + {a b : πΈ} {f : T.sig.bound} {m : β} {ts us : T.sig.boundArgs f β TermAtDepth πΈ T.sig X m} : + a β b β + (β x, a # us x) β + (β x, Derivable T (X β’ ts x β£ βΈ¨a, bβΈ© β’ us x)) β + Derivable T (X β’ .bound a f ts β£ .bound b f us) + +variable {X Y : Type} [NominalSet πΈ X] [OrbitFinite πΈ X] [NominalSet πΈ Y] [OrbitFinite πΈ Y] + +def UniformSubstitution.DerivablyEquivariant + (T : Theory πΈ) {l : β} (Ο : UniformSubstitution πΈ T.sig X Y l) : Prop := + (β (x : X) (Ο : FPerm πΈ), Derivable T (Y β’ Ο (Ο β’ x) β£ Ο β’ Ο x)) + +/-- Restated ax' rule using DerivablyEquivariant in the premiss. -/ +lemma Derivable.ax + {T : Theory πΈ} + {m : β} {r s : TermAtDepth πΈ T.sig Y m} + {l : β} {Ο : UniformSubstitution πΈ T.sig Y X l} {Ο : FPerm πΈ} : + ((Y β’ r β£ s).toUniform β T.axioms) β + Ο.DerivablyEquivariant T β + Derivable T (X β’ Ο.apply (Ο β’ r) β£ Ο.apply (Ο β’ s)) := + .ax' + +lemma Derivable.equivariant_substitution + (T : Theory πΈ) + {l : β} (Ο : UniformSubstitution πΈ T.sig Y X l) (hequi : Ο.DerivablyEquivariant T) + {m : β} (t : TermAtDepth πΈ T.sig Y m) {Ο : FPerm πΈ} : + Derivable T (X β’ Ο.apply (Ο β’ t) β£ Ο β’ (Ο.apply t)) := by + induction' t using TermAtDepth.induction <;> expose_names + Β· sorry + Β· sorry + Β· sorry + Β· sorry + +end DerivableEquations + +end Algebra diff --git a/Algebra/Terms.lean b/Algebra/Terms.lean index aa853a8..997dca4 100644 --- a/Algebra/Terms.lean +++ b/Algebra/Terms.lean @@ -87,6 +87,29 @@ def TermAtDepth.bound {n : β} (a : πΈ) (f : sig.bound) (args : sig.boundArgs TermAtDepth πΈ sig X (n + sig.boundDepth f) := β¨.bound a f (Subtype.val β args), by constructor; intro arg; exact (args arg).propβ© +theorem TermAtDepth.induction + {motive : {n : β} β TermAtDepth πΈ sig X n β Prop} + (var : β (x : X), motive (.var x)) + (pure : β {n : β} (f : sig.pure) (args : sig.pureArgs f β TermAtDepth πΈ sig X n), + (β x, motive (args x)) β motive (.pure f args)) + (free : β {n : β} (a : πΈ) (f : sig.free) (args : sig.freeArgs f β TermAtDepth πΈ sig X n), + (β x, motive (args x)) β motive (.free a f args)) + (bound : β {n : β} (a : πΈ) (f : sig.bound) (args : sig.boundArgs f β TermAtDepth πΈ sig X n), + (β x, motive (args x)) β motive (.bound a f args)) + : β {n : β} (t : TermAtDepth πΈ sig X n), motive t := by + intro n β¨t, htβ© + induction' t generalizing n <;> cases ht <;> expose_names + Β· exact var x + Β· let args' : sig.pureArgs f β TermAtDepth πΈ sig X k := fun x => β¨args x, h xβ© + have args_ih' : β x, motive (args' x) := fun x => args_ih x (h x) + exact pure f args' args_ih' + Β· let args' : sig.freeArgs f β TermAtDepth πΈ sig X k := fun x => β¨args x, h xβ© + have args_ih' : β x, motive (args' x) := fun x => args_ih x (h x) + exact free a f args' args_ih' + Β· let args' : sig.boundArgs f β TermAtDepth πΈ sig X k := fun x => β¨args x, h xβ© + have args_ih' : β x, motive (args' x) := fun x => args_ih x (h x) + exact bound a f args' args_ih' + end ConvenienceConstructors section Substitution diff --git a/Nominal/Instances/Basic.lean b/Nominal/Instances/Basic.lean index dcca75b..64b6425 100644 --- a/Nominal/Instances/Basic.lean +++ b/Nominal/Instances/Basic.lean @@ -70,6 +70,21 @@ def NominalSet.mkDiscrete (X : Type) : NominalSet.Discrete πΈ X where Β· intro Ο hΟ; simp only [PermSet.fix', Set.mem_setOf_eq]; rfl Β· exact Set.finite_empty +instance {X : Type} [NominalSet.Discrete πΈ X] [Finite X] : OrbitFinite πΈ X where + fin_orbits := Finite.of_equiv X + { toFun x := Quotient.mk _ x + invFun x := x.out + left_inv x := by + suffices β (x y : X), MulAction.orbitRel (FPerm πΈ) X x y β x = y by + apply this + rw [β Quotient.eq] + apply Quotient.out_eq + intro x y β¨Ο, hΟβ© + simp only [NominalSet.Discrete.is_discrete] at hΟ + exact hΟ.symm + right_inv x := by simp + } + @[simp] lemma NominalSet.Discrete.supp {X : Type} [NominalSet.Discrete πΈ X] {x : X} : supp πΈ x = β
:= by rw [β Set.subset_empty_iff] apply Set.sInter_subset_of_mem diff --git a/Nominal/Permutations.lean b/Nominal/Permutations.lean index 79a5042..0a4974a 100644 --- a/Nominal/Permutations.lean +++ b/Nominal/Permutations.lean @@ -187,12 +187,29 @@ class PermSet (πΈ : Type) [Infinite πΈ] [Countable πΈ] [DecidableEq πΈ] variable (πΈ : Type) [Infinite πΈ] [Countable πΈ] [DecidableEq πΈ] +/-- An (FPerm πΈ)-set is orbit-finite if there are only finitely many different orbits. -/ +class OrbitFinite (X : Type) [PermSet πΈ X] where + fin_orbits : Finite (Quotient (MulAction.orbitRel (FPerm πΈ) X)) + /-- The set of atoms itself forms an (FPerm πΈ)-Set. -/ instance : PermSet πΈ πΈ where smul Ο a := Ο a one_smul := by intro; rfl mul_smul := by intro _ _ _; rfl +instance : OrbitFinite πΈ πΈ where + fin_orbits := Finite.of_equiv Unit + { toFun _ := Quotient.mk _ (inferInstanceAs (Nonempty πΈ)).some + invFun _ := () + right_inv := by + let chosen := (inferInstanceAs (Nonempty πΈ)).some + apply Quotient.ind; intro a + rw [Quotient.eq] + show chosen β MulAction.orbit (FPerm πΈ) a + use βΈ¨chosen, aβΈ© + exact FPerm.swap_apply_right chosen a + } + /-- The set of finite permutations forms an (FPerm πΈ)-Set. -/ instance : PermSet πΈ (FPerm πΈ) where smul Ο Ο := Ο * Ο |
