@@ -25,11 +25,6 @@ lemma open_lc_aux (e : Term Var) (j v i u) (neq : i ≠ j) (eq : e⟦j ↝ v⟧
2525 e = e ⟦i ↝ u⟧ := by
2626 induction e generalizing j i <;> grind
2727
28- /-- Opening is associative for nonclashing free variables. -/
29- lemma swap_open_fvars (k n : ℕ) (x y : Var) (m : Term Var) (neq : k ≠ n) :
30- m⟦n ↝ fvar y⟧⟦k ↝ fvar x⟧ = m⟦k ↝ fvar x⟧⟦n ↝ fvar y⟧ := by
31- induction m generalizing k n <;> grind
32-
3328variable [DecidableEq Var]
3429
3530/-- Substitution of a free variable not present in a term leaves it unchanged. -/
@@ -91,6 +86,12 @@ lemma open_lc (k t) (e : Term Var) (e_lc : e.LC) : e = e⟦k ↝ t⟧ := by
9186 | abs xs e _ _ => grind [open_lc_aux e 0 (fvar (fresh xs)) (k+1 ) t]
9287 | _ => grind
9388
89+ omit [DecidableEq Var] in
90+ /-- Opening is associative for nonclashing locally closed terms. -/
91+ lemma swap_open (k n : ℕ) (t₁ t₂ m : Term Var) (neq : k ≠ n) (h1 : t₁.LC) (h2 : t₂.LC) :
92+ m⟦n ↝ t₂⟧⟦k ↝ t₁⟧ = m⟦k ↝ t₁⟧⟦n ↝ t₂⟧ := by
93+ induction m generalizing k n with grind
94+
9495/- If opening yields `app m x`, the original term was `app m (bvar 0)`. -/
9596lemma open_eq_app {x : Var} {m n : Term Var} (hw_n : x ∉ n.fv) (hw_m : x ∉ m.fv) (lc_m : LC m)
9697 (h : n ^ fvar x = app m (fvar x)) : n = app m (bvar 0 ) := by
@@ -139,7 +140,7 @@ lemma open_close_to_subst (m : Term Var) (x y : Var) (k : ℕ) (m_lc : LC m) :
139140 | abs xs t =>
140141 have ⟨x', _⟩ := fresh_exists <| free_union [fv] Var
141142 grind [
142- swap_open_fvars , =_ swap_open_fvar_close,
143+ swap_open , =_ swap_open_fvar_close,
143144 open_close x' (t⟦k+1 ↜ x⟧⟦k+1 ↝ fvar y⟧) 0 , open_close x' (t[x := fvar y]) 0 ,
144145 open_fresh_preserve_not_fvar, close_preserve_not_fvar, subst_preserve_not_fvar]
145146 | _ => grind
@@ -150,7 +151,7 @@ lemma close_open (x : Var) (t : Term Var) (k : ℕ) (t_lc : LC t) : t⟦k ↜ x
150151 | abs _ t _ ih =>
151152 let z := t⟦k + 1 ↜ x⟧⟦k + 1 ↝ fvar x⟧
152153 have ⟨y, _⟩ := fresh_exists <| free_union [fv] Var
153- grind [ih y ?_ (k+1 ), open_injective, swap_open_fvar_close, swap_open_fvars ]
154+ grind [ih y ?_ (k+1 ), open_injective, swap_open_fvar_close, swap_open ]
154155 | _ => grind
155156
156157end LambdaCalculus.LocallyNameless.Untyped.Term
0 commit comments