λ-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.
- Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.openRec i sub (Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_1) = Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_1
- Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.openRec i sub M.abs = (Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.openRec (i + 1) sub M).abs
Instances For
Variable opening of the ith bound variable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Variable opening of the closest binding.
Equations
Instances For
Variable opening of the closest binding.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Variable closing, replacing a free fvar x with bvar k
Equations
- One or more equations did not get rendered due to their size.
- Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.closeRec k x (Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.bvar i) = Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.bvar i
- Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.closeRec k x t.abs = (Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.closeRec (k + 1) x t).abs
Instances For
Variable closing of the closest binding.
Equations
Instances For
Variable closing of the closest binding.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Substitution of a free variable to a term.
Equations
- (Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.bvar i').subst x sub = Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.bvar i'
- (Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.fvar x_2).subst x sub = if x = x_2 then sub else Cslib.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
Term.subst is a substitution for λ-terms. Gives access to the notation m[x := n].
Free variables of a term.