Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ namespace Cslib

universe u

variable {Var : Type u} [HasFresh Var] [DecidableEq Var]

namespace LambdaCalculus.LocallyNameless.Untyped

/-- Syntax of locally nameless lambda terms, with free variables over `Var`. -/
Expand All @@ -45,6 +43,8 @@ deriving DecidableEq

namespace Term

variable {Var : Type u}

/-- Variable opening of the ith bound variable. -/
@[scoped grind =]
def openRec (i : ℕ) (sub : Term Var) : Term Var → Term Var
Expand All @@ -66,11 +66,13 @@ lemma openRec_abs : M.abs⟦i ↝ s⟧ = M⟦i + 1 ↝ s⟧.abs := by rfl

/-- Variable opening of the closest binding. -/
@[scoped grind =]
def open' {X} (e u):= @Term.openRec X 0 u e
def open' (e u : Term Var):= Term.openRec 0 u e

@[inherit_doc]
scoped infixr:80 " ^ " => Term.open'

variable [DecidableEq Var]

/-- Variable closing, replacing a free `fvar x` with `bvar k` -/
@[scoped grind =]
def closeRec (k : ℕ) (x : Var) : Term Var → Term Var
Expand All @@ -82,11 +84,9 @@ def closeRec (k : ℕ) (x : Var) : Term Var → Term Var
@[inherit_doc]
scoped notation:68 e "⟦" k " ↜ " x "⟧"=> Term.closeRec k x e

variable {x : Var}

/-- Variable closing of the closest binding. -/
@[scoped grind =]
def close {Var} [DecidableEq Var] (e u):= @Term.closeRec Var _ 0 u e
def close (e) (u : Var):= Term.closeRec 0 u e

@[inherit_doc]
scoped infixr:80 " ^* " => Term.close
Expand Down Expand Up @@ -114,7 +114,7 @@ def fv : Term Var → Finset Var

section

omit [HasFresh Var]
variable {x : Var} {n : Term Var}

lemma closeRec_bvar : (bvar i)⟦k ↜ x⟧ = bvar i := by rfl

Expand All @@ -124,8 +124,6 @@ lemma closeRec_app : (app l r)⟦k ↜ x⟧ = app (l⟦k ↜ x⟧) (r⟦k ↜ x

lemma closeRec_abs : t.abs⟦k ↜ x⟧ = t⟦k + 1 ↜ x⟧.abs := by rfl

variable {x : Var} {n : Term Var}

lemma subst_bvar : (bvar i : Term Var)[x := n] = bvar i := by rfl

lemma subst_fvar : (fvar x')[x := n] = if x = x' then n else fvar x' := by rfl
Expand Down
Loading