Skip to content

Commit dc23a39

Browse files
feat(LocallyNameless/Untyped): subst_intro weaker precondition (#666)
- New theorem `subst_intro_openRec` - `subst_intro` no longer needs `LC t` - `subst_intro` no longer needs `subst_fresh` - `subst_intro` new proof based on `subst_intro_openRec` - Updated `preservation_open` in STLC to take advantage of the weaker precondition Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
1 parent e0573fb commit dc23a39

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

Cslib/Languages/LambdaCalculus/LocallyNameless/Stlc/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ theorem preservation_open {xs : Finset Var}
125125
(cofin : ∀ x ∉ xs, ⟨x, σ⟩ :: Γ ⊢ m ^ fvar x ∶ τ) (der : Γ ⊢ n ∶ σ) :
126126
Γ ⊢ m ^ n ∶ τ := by
127127
have ⟨fresh, _⟩ := fresh_exists <| free_union [Term.fv] Var
128-
grind [subst_intro fresh _ _ ?_ der.lc, typing_subst_head]
128+
grind [subst_intro fresh _ _ ?_, typing_subst_head]
129129

130130
end LambdaCalculus.LocallyNameless.Stlc.Typing
131131

Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/Properties.lean

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ lemma subst_preserve_not_fvar {y : Var} (m n : Term Var) :
7474
lemma subst_refl (m : Term Var) (x : Var) : m[x := fvar x] = m := by
7575
induction m <;> grind
7676

77+
lemma subst_intro_openRec {x} {t e : Term Var} (mem : x ∉ e.fv) {k : ℕ} :
78+
e ⟦k ↝ t⟧ = (e ⟦ k ↝ fvar x⟧)[ x := t ] := by
79+
induction e generalizing k with grind
80+
81+
/-- Opening to a term `t` is equivalent to opening to a free variable and substituting for `t`. -/
82+
lemma subst_intro (x : Var) (t e : Term Var) (mem : x ∉ e.fv) :
83+
e ^ t = (e ^ fvar x) [ x := t ] := subst_intro_openRec mem
84+
85+
scoped grind_pattern subst_intro => open' e t, open' e (fvar x)
86+
7787
variable [HasFresh Var]
7888

7989
omit [DecidableEq Var] in
@@ -115,12 +125,6 @@ theorem subst_lc {x : Var} {e u : Term Var} (e_lc : LC e) (u_lc : LC u) : LC (e
115125
case' abs => apply LC.abs (free_union Var)
116126
all_goals grind
117127

118-
/-- Opening to a term `t` is equivalent to opening to a free variable and substituting for `t`. -/
119-
lemma subst_intro (x : Var) (t e : Term Var) (mem : x ∉ e.fv) (t_lc : LC t) :
120-
e ^ t = (e ^ fvar x) [ x := t ] := by grind [subst_fresh]
121-
122-
scoped grind_pattern subst_intro => open' e t, open' e (fvar x)
123-
124128
set_option linter.unusedDecidableInType false in
125129
/-- Opening of locally closed terms is locally closed. -/
126130
@[scoped grind ←]

0 commit comments

Comments
 (0)