summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Algebra/Term.lean107
1 files changed, 61 insertions, 46 deletions
diff --git a/Algebra/Term.lean b/Algebra/Term.lean
index 665999f..b4d18f9 100644
--- a/Algebra/Term.lean
+++ b/Algebra/Term.lean
@@ -55,21 +55,35 @@ inductive Term.HasDepth : Term ๐”ธ sig X โ†’ โ„• โ†’ Prop
def TermAtDepth (sig : Signature) (X : Type) [NominalSet ๐”ธ X] (n : โ„•) :=
{ t : Term ๐”ธ sig X // t.HasDepth ๐”ธ n }
+def TermAtDepth.var (x : X) : TermAtDepth ๐”ธ sig X 0 := โŸจ.var x, by constructorโŸฉ
+
+def TermAtDepth.pure {n : โ„•} (f : sig.pure) (args : sig.pureArgs f โ†’ TermAtDepth ๐”ธ sig X n) :
+ TermAtDepth ๐”ธ sig X (n + sig.pureDepth f) :=
+ โŸจ.pure f (Subtype.val โˆ˜ args), by constructor; intro arg; exact (args arg).propโŸฉ
+
+def TermAtDepth.free {n : โ„•} (a : ๐”ธ) (f : sig.free) (args : sig.freeArgs f โ†’ TermAtDepth ๐”ธ sig X n) :
+ TermAtDepth ๐”ธ sig X (n + sig.freeDepth f) :=
+ โŸจ.free a f (Subtype.val โˆ˜ args), by constructor; intro arg; exact (args arg).propโŸฉ
+
+def TermAtDepth.bound {n : โ„•} (a : ๐”ธ) (f : sig.bound) (args : sig.boundArgs f โ†’ TermAtDepth ๐”ธ sig X n) :
+ TermAtDepth ๐”ธ sig X (n + sig.boundDepth f) :=
+ โŸจ.bound a f (Subtype.val โˆ˜ args), by constructor; intro arg; exact (args arg).propโŸฉ
+
def Substitution (sig : Signature) (X : Type) [NominalSet ๐”ธ X] (Y : Type) [NominalSet ๐”ธ Y] (l : โ„•) :=
X โ†’ TermAtDepth ๐”ธ sig Y l
-private def Substitution.apply' {l : โ„•} (ฯƒ : Substitution ๐”ธ sig X Y l) : Term ๐”ธ sig X โ†’ Term ๐”ธ sig Y
+def Substitution.apply {l : โ„•} (ฯƒ : Substitution ๐”ธ sig X Y l) : Term ๐”ธ sig X โ†’ Term ๐”ธ sig Y
| .var x => (ฯƒ x).val
- | .pure f args => .pure f (fun x => ฯƒ.apply' (args x))
- | .free a f args => .free a f (fun x => ฯƒ.apply' (args x))
- | .bound a f args => .bound a f (fun x => ฯƒ.apply' (args x))
+ | .pure f args => .pure f (fun x => ฯƒ.apply (args x))
+ | .free a f args => .free a f (fun x => ฯƒ.apply (args x))
+ | .bound a f args => .bound a f (fun x => ฯƒ.apply (args x))
-def Substitution.apply {n l : โ„•} (ฯƒ : Substitution ๐”ธ sig X Y l) (t : TermAtDepth ๐”ธ sig X n) :
+def Substitution.applyUniform {n l : โ„•} (ฯƒ : Substitution ๐”ธ sig X Y l) (t : TermAtDepth ๐”ธ sig X n) :
TermAtDepth ๐”ธ sig Y (n + l) :=
- โŸจฯƒ.apply' ๐”ธ t.val, by
- suffices โˆ€ t n, t.HasDepth ๐”ธ n โ†’ (ฯƒ.apply' ๐”ธ t).HasDepth ๐”ธ (n + l) by
+ โŸจฯƒ.apply ๐”ธ t.val, by
+ suffices โˆ€ t n, t.HasDepth ๐”ธ n โ†’ (ฯƒ.apply ๐”ธ t).HasDepth ๐”ธ (n + l) by
exact this t.val n t.prop
- intro t; fun_induction apply'
+ intro t; fun_induction apply
ยท intro n h; cases h
rw [Nat.zero_add]
exact (ฯƒ _).prop
@@ -79,21 +93,36 @@ def Substitution.apply {n l : โ„•} (ฯƒ : Substitution ๐”ธ sig X Y l) (t : TermA
constructor; intro arg
apply ih1; exact h argโŸฉ
-private def rename' (ฯ€ : FPerm ๐”ธ) : Term ๐”ธ sig X โ†’ Term ๐”ธ sig X
+@[simp] lemma Substitution.apply_var {l : โ„•} {x : X} {ฯƒ : Substitution ๐”ธ sig X Y l} :
+ ฯƒ.apply ๐”ธ (.var x) = (ฯƒ x).val := rfl
+
+@[simp] lemma Substitution.apply_pure
+ {f : sig.pure} {args : sig.pureArgs f โ†’ Term ๐”ธ sig X} {l : โ„•} {ฯƒ : Substitution ๐”ธ sig X Y l} :
+ ฯƒ.apply ๐”ธ (.pure f args) = .pure f (apply ๐”ธ ฯƒ โˆ˜ args) := rfl
+
+@[simp] lemma Substitution.apply_free
+ {a : ๐”ธ} {f : sig.free} {args : sig.freeArgs f โ†’ Term ๐”ธ sig X} {l : โ„•} {ฯƒ : Substitution ๐”ธ sig X Y l} :
+ ฯƒ.apply ๐”ธ (.free a f args) = .free a f (apply ๐”ธ ฯƒ โˆ˜ args) := rfl
+
+@[simp] lemma Substitution.apply_bound
+ {a : ๐”ธ} {f : sig.bound} {l : โ„•} {args : sig.boundArgs f โ†’ Term ๐”ธ sig X} {ฯƒ : Substitution ๐”ธ sig X Y l} :
+ ฯƒ.apply ๐”ธ (.bound a f args) = .bound a f (apply ๐”ธ ฯƒ โˆ˜ args) := rfl
+
+private def rename (ฯ€ : FPerm ๐”ธ) : Term ๐”ธ sig X โ†’ Term ๐”ธ sig X
| .var x => .var (ฯ€ โ€ข x)
- | .pure f args => .pure f (fun x => rename' ฯ€ (args x))
- | .free a f args => .free (ฯ€ โ€ข a) f (fun x => rename' ฯ€ (args x))
- | .bound a f args => .bound (ฯ€ โ€ข a) f (fun x => rename' ฯ€ (args x))
+ | .pure f args => .pure f (fun x => rename ฯ€ (args x))
+ | .free a f args => .free (ฯ€ โ€ข a) f (fun x => rename ฯ€ (args x))
+ | .bound a f args => .bound (ฯ€ โ€ข a) f (fun x => rename ฯ€ (args x))
-private lemma one_rename (t : Term ๐”ธ sig X) : rename' ๐”ธ 1 t = t := by
- induction' t <;> all_goals simp [rename', *]
+private lemma one_rename (t : Term ๐”ธ sig X) : rename ๐”ธ 1 t = t := by
+ induction' t <;> all_goals simp [rename, *]
private lemma mul_rename (ฯ€ ฯ„ : FPerm ๐”ธ) (t : Term ๐”ธ sig X) :
- rename' ๐”ธ (ฯ€ * ฯ„) t = rename' ๐”ธ ฯ€ (rename' ๐”ธ ฯ„ t) := by
- induction' t <;> all_goals simp [rename', mul_smul, *]
+ rename ๐”ธ (ฯ€ * ฯ„) t = rename ๐”ธ ฯ€ (rename ๐”ธ ฯ„ t) := by
+ induction' t <;> all_goals simp [rename, mul_smul, *]
instance : PermSet ๐”ธ (Term ๐”ธ sig X) where
- smul := rename' ๐”ธ
+ smul := rename ๐”ธ
one_smul := one_rename ๐”ธ
mul_smul := mul_rename ๐”ธ
@@ -159,21 +188,10 @@ private lemma atoms_support (t : Term ๐”ธ sig X) : PermSet.HasSupport ๐”ธ t (a
apply PermSet.fix_antitone_mem ๐”ธ hฯ€
apply Set.subset_sUnion_of_mem
use x
- ยท intro hฯ€
- simp only [PermSet.fix', smul_free, Term.free.injEq, heq_eq_eq, true_and, Set.mem_setOf_eq]
- constructor
- ยท apply PermSet.fix_antitone_mem ๐”ธ hฯ€
- apply Set.subset_union_left
- rfl
- ยท ext x
- rw [Function.comp_apply]
- apply ih1
- apply PermSet.fix_antitone_mem ๐”ธ hฯ€
- apply Set.subset_union_of_subset_right
- apply Set.subset_sUnion_of_mem
- use x
- ยท intro hฯ€
- simp only [PermSet.fix', smul_bound, Term.bound.injEq, heq_eq_eq, true_and, Set.mem_setOf_eq]
+ all_goals
+ intro hฯ€
+ simp only [PermSet.fix', smul_free, smul_bound, Term.free.injEq, Term.bound.injEq, heq_eq_eq,
+ true_and, Set.mem_setOf_eq]
constructor
ยท apply PermSet.fix_antitone_mem ๐”ธ hฯ€
apply Set.subset_union_left
@@ -191,21 +209,18 @@ instance : NominalSet ๐”ธ (Term ๐”ธ sig X) where
use atoms ๐”ธ t
exact โŸจatoms_support ๐”ธ t, atoms_finite ๐”ธ tโŸฉ
-private def rename {n : โ„•} (ฯ€ : FPerm ๐”ธ) (t : TermAtDepth ๐”ธ sig X n) : TermAtDepth ๐”ธ sig X n :=
- โŸจฯ€ โ€ข t.val, by
- suffices โˆ€ t n, t.HasDepth ๐”ธ n โ†’ (rename' ๐”ธ ฯ€ t).HasDepth ๐”ธ n by
- exact this t.val n t.prop
- intro t; fun_induction rename'
- ยท intro n h; cases h; constructor
- all_goals
- intro n h; cases h
- expose_names
- constructor; intro arg
- apply ih1; exact h argโŸฉ
-
-instance Term.instHasDepthEquivariant {n : โ„•} : Set.Equivariant ๐”ธ {t : Term ๐”ธ sig X | HasDepth ๐”ธ t n} := by
+instance Term.instHasDepthEquivariant {n : โ„•} :
+ Set.Equivariant ๐”ธ {t : Term ๐”ธ sig X | HasDepth ๐”ธ t n} := by
constructor; intro t ฯ€ ht
- exact (rename ๐”ธ ฯ€ โŸจt, htโŸฉ).prop
+ suffices โˆ€ t n, t.HasDepth ๐”ธ n โ†’ (rename ๐”ธ ฯ€ t).HasDepth ๐”ธ n by
+ exact this t n ht
+ intro t; fun_induction rename
+ ยท intro n h; cases h; constructor
+ all_goals
+ intro n h; cases h
+ expose_names
+ constructor; intro arg
+ apply ih1; exact h arg
instance {n : โ„•} : NominalSet ๐”ธ (TermAtDepth ๐”ธ sig X n) :=
(Subtype.instNominalSetElem ๐”ธ : NominalSet ๐”ธ {t : Term ๐”ธ sig X | Term.HasDepth ๐”ธ t n})