λ-calculus #
The untyped λ-calculus, with a locally nameless representation of syntax.
References #
- A. Chargueraud, The Locally Nameless Representation
- See also https://www.cis.upenn.edu/~plclub/popl08-tutorial/code/, from which this is partially adapted
Syntax of locally nameless lambda terms, with free variables over Var
.
- bvar
{Var : Type u}
: ℕ → Term Var
Bound variables that appear under a lambda abstraction, using a de-Bruijn index.
- fvar
{Var : Type u}
: Var → Term Var
Free variables.
- abs
{Var : Type u}
: Term Var → Term Var
Lambda abstraction, introducing a new bound variable.
- app
{Var : Type u}
: Term Var → Term Var → Term Var
Function application.
Instances For
Variable opening of the ith bound variable.
Equations
- One or more equations did not get rendered due to their size.
- LambdaCalculus.LocallyNameless.Untyped.Term.openRec i sub (LambdaCalculus.LocallyNameless.Untyped.Term.bvar i') = if i = i' then sub else LambdaCalculus.LocallyNameless.Untyped.Term.bvar i'
- LambdaCalculus.LocallyNameless.Untyped.Term.openRec i sub (LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_1) = LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_1
- LambdaCalculus.LocallyNameless.Untyped.Term.openRec i sub M.abs = (LambdaCalculus.LocallyNameless.Untyped.Term.openRec (i + 1) sub M).abs
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Variable opening of the closest binding.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
LambdaCalculus.LocallyNameless.Untyped.Term.closeRec
{Var : Type u}
[DecidableEq Var]
(k : ℕ)
(x : Var)
:
Variable closing, replacing a free fvar x
with bvar k
Equations
- One or more equations did not get rendered due to their size.
- LambdaCalculus.LocallyNameless.Untyped.Term.closeRec k x (LambdaCalculus.LocallyNameless.Untyped.Term.bvar i) = LambdaCalculus.LocallyNameless.Untyped.Term.bvar i
- LambdaCalculus.LocallyNameless.Untyped.Term.closeRec k x t.abs = (LambdaCalculus.LocallyNameless.Untyped.Term.closeRec (k + 1) x t).abs
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
LambdaCalculus.LocallyNameless.Untyped.Term.close
{Var : Type u_1}
[DecidableEq Var]
(e : Term Var)
(u : Var)
:
Term Var
Variable closing of the closest binding.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
LambdaCalculus.LocallyNameless.Untyped.Term.subst
{Var : Type u}
[DecidableEq Var]
(m : Term Var)
(x : Var)
(sub : Term Var)
:
Term Var
Equations
- (LambdaCalculus.LocallyNameless.Untyped.Term.bvar i').subst x sub = LambdaCalculus.LocallyNameless.Untyped.Term.bvar i'
- (LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_2).subst x sub = if x = x_2 then sub else LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_2
- (l.app r).subst x sub = (l.subst x sub).app (r.subst x sub)
- M.abs.subst x sub = (M.subst x sub).abs
Instances For
instance
LambdaCalculus.LocallyNameless.Untyped.Term.instHasSubstitutionTerm
{Var : Type u}
[DecidableEq Var]
:
HasSubstitution (Term Var) Var
Term.subst
is a substitution for λ-terms. Gives access to the notation m[x := n]
.
Free variables of a term.
Equations
Instances For
theorem
LambdaCalculus.LocallyNameless.Untyped.Term.closeRec_bvar
{Var : Type u}
[DecidableEq Var]
{x : Var}
{k i : ℕ}
: