λ-calculus #
The λ-calculus with polymorphism and subtyping, 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 adapted
Types of the polymorphic lambda calculus.
- top
{Var : Type u_2}
: Ty Var
The type ⊤, with a single inhabitant.
- bvar
{Var : Type u_2}
: ℕ → Ty Var
Bound variables that appear in a type, using a de-Bruijn index.
- fvar
{Var : Type u_2}
: Var → Ty Var
Free type variables.
- arrow
{Var : Type u_2}
: Ty Var → Ty Var → Ty Var
A function type.
- all
{Var : Type u_2}
: Ty Var → Ty Var → Ty Var
A universal quantification.
- sum
{Var : Type u_2}
: Ty Var → Ty Var → Ty Var
A sum type.
Instances For
Syntax of locally nameless lambda terms, with free variables over Var.
- bvar
{Var : Type u_2}
: ℕ → Term Var
Bound term variables that appear under a lambda abstraction, using a de-Bruijn index.
- fvar
{Var : Type u_2}
: Var → Term Var
Free term variables.
- abs
{Var : Type u_2}
: Ty Var → Term Var → Term Var
Lambda abstraction, introducing a new bound term variable.
- app
{Var : Type u_2}
: Term Var → Term Var → Term Var
Function application.
- tabs
{Var : Type u_2}
: Ty Var → Term Var → Term Var
Type abstraction, introducing a new bound type variable.
- tapp
{Var : Type u_2}
: Term Var → Ty Var → Term Var
Type application.
- let'
{Var : Type u_2}
: Term Var → Term Var → Term Var
Binding of a term.
- inl
{Var : Type u_2}
: Term Var → Term Var
Left constructor of a sum.
- inr
{Var : Type u_2}
: Term Var → Term Var
Right constructor of a sum.
- case
{Var : Type u_2}
: Term Var → Term Var → Term Var → Term Var
Case matching on a sum.
Instances For
Free variables of a type.
Equations
Instances For
Free variables of a binding.
Equations
Instances For
Free type variables of a term.
Equations
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.bvar a).fv_ty = ∅
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.fvar a).fv_ty = ∅
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.abs σ t₁).fv_ty = σ.fv ∪ t₁.fv_ty
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.tabs σ t₁).fv_ty = σ.fv ∪ t₁.fv_ty
- (t₁.tapp σ).fv_ty = σ.fv ∪ t₁.fv_ty
- t₁.inl.fv_ty = t₁.fv_ty
- t₁.inr.fv_ty = t₁.fv_ty
- (t₁.app t₂).fv_ty = t₁.fv_ty ∪ t₂.fv_ty
- (t₁.let' t₂).fv_ty = t₁.fv_ty ∪ t₂.fv_ty
- (t₁.case t₂ t₃).fv_ty = t₁.fv_ty ∪ t₂.fv_ty ∪ t₃.fv_ty
Instances For
Free term variables of a term.
Equations
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.bvar a).fv_tm = ∅
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.fvar a).fv_tm = {a}
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.abs σ t₁).fv_tm = t₁.fv_tm
- (Cslib.LambdaCalculus.LocallyNameless.Fsub.Term.tabs σ t₁).fv_tm = t₁.fv_tm
- (t₁.tapp σ).fv_tm = t₁.fv_tm
- t₁.inl.fv_tm = t₁.fv_tm
- t₁.inr.fv_tm = t₁.fv_tm
- (t₁.app t₂).fv_tm = t₁.fv_tm ∪ t₂.fv_tm
- (t₁.let' t₂).fv_tm = t₁.fv_tm ∪ t₂.fv_tm
- (t₁.case t₂ t₃).fv_tm = t₁.fv_tm ∪ t₂.fv_tm ∪ t₃.fv_tm
Instances For
A context of bindings.