@@ -128,6 +128,115 @@ namespace LeanSubst
128128 simp [Subst.compose]
129129 cases σ x <;> simp
130130
131+ @[simp]
132+ theorem hrewrite1
133+ [RenMap T] [SubstMap S T] [SubstMapId S T]
134+ {σ : Subst S}
135+ : σ ◾ (+0 @T) = σ
136+ := by
137+ funext; case _ x =>
138+ simp [Subst.hcompose]
139+ generalize zdef : σ x = z
140+ cases z <;> simp
141+
142+ theorem hcomp_ren_left
143+ [RenMap S] [RenMap T] [SubstMap S T]
144+ (r : Ren) (σ : Subst T)
145+ : (@Ren.to S r) ◾ σ = r.to
146+ := by
147+ funext; case _ x =>
148+ induction x <;> simp [Subst.hcompose, Ren.to]
149+
150+ @[simp]
151+ theorem hrewrite2
152+ [RenMap S] [RenMap T] [SubstMap S T]
153+ {σ : Subst T}
154+ : (+0 @S) ◾ σ = +0
155+ := by
156+ have lem := hcomp_ren_left (S := S) (T := T) (λ x => x) σ
157+ simp at lem; exact lem
158+
159+ @[simp]
160+ theorem hrewrite3
161+ [RenMap S] [RenMap T] [SubstMap S T]
162+ {σ : Subst T}
163+ : (+1 @S) ◾ σ = +1
164+ := by
165+ have lem := hcomp_ren_left (S := S) (T := T) (· + 1 ) σ
166+ simp at lem; exact lem
167+
168+ @[simp]
169+ theorem hrewrite4
170+ [RenMap T] [SubstMap S T]
171+ {x} {σ : Subst S} {τ : Subst T}
172+ : (re x :: σ) ◾ τ = re x :: (σ ◾ τ)
173+ := by
174+ funext; case _ i =>
175+ cases i <;> simp [Subst.hcompose]
176+
177+ theorem hcomp_dist_ren_left
178+ [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T]
179+ (r : Ren) {σ : Subst S} {τ : Subst T}
180+ : (r.to ∘ σ) ◾ τ = r.to ∘ σ ◾ τ
181+ := by
182+ funext; case _ x =>
183+ simp [Subst.hcompose, Subst.compose, Ren.to]
184+
185+ class SubstMapRenCommute (S T : Type ) [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T] where
186+ apply_ren_commute {s : S} (r : Ren) (τ : Subst T) : s[r.to][τ:T] = s[τ:T][r.to]
187+
188+ @[simp]
189+ theorem hrewrite5
190+ [RenMap S] [RenMap T] [SubstMap T T] [SubstMap S T] [SubstMapCompose S T]
191+ {σ : Subst S} {τ μ : Subst T}
192+ : (σ ◾ τ) ◾ μ = σ ◾ (τ ∘ μ)
193+ := by
194+ funext; case _ x =>
195+ simp [Subst.hcompose]
196+ generalize zdef : σ x = z
197+ cases z <;> simp
198+
199+ theorem hcomp_distr_ren_right
200+ [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T] [SubstMapRenCommute S T]
201+ (r : Ren) (σ : Subst S) (μ : Subst T)
202+ : (σ ∘ r.to) ◾ μ = (σ ◾ μ) ∘ r.to
203+ := by
204+ funext; case _ x =>
205+ simp [Subst.hcompose, Subst.compose, Ren.to]
206+ generalize zdef : σ x = z
207+ cases z <;> simp
208+ rw [SubstMapRenCommute.apply_ren_commute r μ]
209+
210+ @[simp]
211+ theorem hrewrite6
212+ [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T] [SubstMapRenCommute S T]
213+ (r : Ren) (σ : Subst S)
214+ : (σ ∘ r.to) ◾ (+1 @T) = (σ ◾ +1 @T) ∘ r.to
215+ := by
216+ have lem := hcomp_distr_ren_right (T := T) r σ +1
217+ simp at lem; exact lem
218+
219+ class SubstMapHetCompose (S T : Type ) [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T] where
220+ apply_hcompose {s : S} {σ : Subst S} {τ : Subst T} : s[σ][τ:T] = s[τ:T][σ ◾ τ]
221+
222+ @[simp]
223+ theorem apply_hcompose
224+ [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T] [SubstMapHetCompose S T]
225+ {s : S} {σ : Subst S} {τ : Subst T}
226+ : s[σ][τ:T] = s[τ:T][σ ◾ τ]
227+ := by exact SubstMapHetCompose.apply_hcompose
228+
229+ @[simp]
230+ theorem hrewrite7
231+ [RenMap S] [RenMap T] [SubstMap S S] [SubstMap S T] [SubstMapHetCompose S T]
232+ {σ τ : Subst S} (μ : Subst T)
233+ : (σ ∘ τ) ◾ μ = (σ ◾ μ) ∘ τ ◾ μ
234+ := by
235+ funext; case _ x =>
236+ simp [Subst.hcompose, Subst.compose]
237+ generalize zdef : σ x = z
238+ cases z <;> simp
239+
131240 end Subst
132241
133242 macro "solve_stable" S:term "," r:term "," σ:term : tactic => `(tactic| {
@@ -136,7 +245,7 @@ namespace LeanSubst
136245 induction t generalizing $r $σ
137246 all_goals simp [RenMap.rmap, SubstMap.smap, *] at *; try simp [*]
138247 any_goals solve | (
139- rw [<-Ren.lift_eq_from_eq (S := $S) h])
248+ rw [<-Ren.lift_eq_from_eq (S := $S) (r := $r) h])
140249 any_goals solve | (rw [<-h]; simp [Ren.to])
141250 })
142251
@@ -152,13 +261,14 @@ namespace LeanSubst
152261 cases x <;> simp
153262 case _ x => simp [Ren.to, Subst.succ, Subst.compose]
154263 have lem2s {σ : Subst $Ty} : (+1 ∘ σ).lift = +1 .lift ∘ σ.lift := by rw [<-Ren.to_succ, lem2]
155- have lem3 {σ : Subst $Ty} {r : Ren} {t} : t[r][σ] = t[r ∘ σ] := by
264+ have lem3 {σ : Subst $Ty} {r : Ren} {t : $Ty } : t[r:$Ty ][σ:_ ] = t[( r ∘ σ):_ ] := by
156265 induction t generalizing σ r
157266 any_goals solve | simp [*]
158267 any_goals solve | (
159268 simp [-Subst.rewrite_lift, *]
160269 rw [<-Ren.to_lift (S := $Ty)]; simp [*])
161- have lem3s {σ : Subst $Ty} {t} : t[+1 ][σ] = t[+1 ∘ σ] := by rw [<-Ren.to_succ, lem3]
270+ have lem3s {σ : Subst $Ty} {t : $Ty} : t[+1 :$Ty][σ:_] = t[+1 ∘ σ:_] := by
271+ rw [<-Ren.to_succ, lem3]
162272 have lem4 {σ τ : Subst $Ty} : +1 ∘ τ ∘ σ = (+1 ∘ τ) ∘ σ := by
163273 funext; case _ x =>
164274 cases x <;> simp [Subst.compose, Subst.succ]
@@ -174,13 +284,14 @@ namespace LeanSubst
174284 simp [Subst.compose]
175285 cases τ x <;> simp [*]
176286 have lem6s {τ : Subst $Ty} : (τ ∘ +1 ).lift = τ.lift ∘ +1 .lift := by rw [<-Ren.to_succ, lem6]
177- have lem7 {τ : Subst $Ty} {t} {r : Ren} : t[τ][r] = t[τ ∘ r.to] := by
287+ have lem7 {τ : Subst $Ty} {t:$Ty } {r : Ren} : t[τ:_ ][r:$Ty ] = t[τ ∘ r.to:_ ] := by
178288 induction t generalizing τ r
179289 any_goals solve | simp [*]
180290 any_goals solve | (
181291 simp [-Subst.rewrite_lift, *]
182292 rw [<-Ren.to_lift (S := $Ty)]; simp [*])
183- have lem7s {τ : Subst $Ty} {t} : t[τ][+1 ] = t[τ ∘ +1 ] := by rw [<-Ren.to_succ, lem7]
293+ have lem7s {τ : Subst $Ty} {t : $Ty} : t[τ:_][+1 :$Ty] = t[τ ∘ +1 :_] := by
294+ rw [<-Ren.to_succ, lem7]
184295 have lem8 {σ τ : Subst $Ty} : (σ ∘ +1 ) ∘ τ = σ ∘ +1 ∘ τ := by
185296 funext; case _ x =>
186297 unfold Subst.compose; simp
0 commit comments