β-reduction for the λ-calculus #
References #
- [A. Chargueraud, The Locally Nameless Representation] [Cha12]
- See also https://www.cis.upenn.edu/~plclub/popl08-tutorial/code/, from which this is partially adapted
A single β-reduction step.
- beta
{Var : Type u}
{M N : Term Var}
: M.abs.LC → N.LC → (M.abs.app N).FullBeta (M.open' N)
Reduce an application to a lambda term.
- appL
{Var : Type u}
{Z M N : Term Var}
: Z.LC → M.FullBeta N → (Z.app M).FullBeta (Z.app N)
Left congruence rule for application.
- appR
{Var : Type u}
{Z M N : Term Var}
: Z.LC → M.FullBeta N → (M.app Z).FullBeta (N.app Z)
Right congruence rule for application.
- abs
{Var : Type u}
{M N : Term Var}
(xs : Finset Var)
: (∀ x ∉ xs, (M.open' (fvar x)).FullBeta (N.open' (fvar x))) → M.abs.FullBeta N.abs
Congruence rule for lambda terms.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.redex_app_l_cong
{Var : Type u}
{M M' N : Term Var}
(redex : Relation.ReflTransGen FullBeta M M')
(lc_N : N.LC)
:
Relation.ReflTransGen FullBeta (M.app N) (M'.app N)
Left congruence rule for application in multiple reduction.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.redex_app_r_cong
{Var : Type u}
{M M' N : Term Var}
(redex : Relation.ReflTransGen FullBeta M M')
(lc_N : N.LC)
:
Relation.ReflTransGen FullBeta (N.app M) (N.app M')
Right congruence rule for application in multiple reduction.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.step_lc_r
{Var : Type u}
{M M' : Term Var}
[HasFresh Var]
[DecidableEq Var]
(step : M.FullBeta M')
:
M'.LC
The right side of a reduction is locally closed.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.steps_lc_or_rfl
{Var : Type u}
[HasFresh Var]
[DecidableEq Var]
{M M' : Term Var}
(redex : Relation.ReflTransGen FullBeta M M')
:
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.redex_subst_cong_lc
{Var : Type u}
[HasFresh Var]
[DecidableEq Var]
(s s' t : Term Var)
(x : Var)
(step : s.FullBeta s')
(h_lc : t.LC)
:
Substitution of a locally closed term respects a single reduction step.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.redex_abs_close
{Var : Type u}
{M M' : Term Var}
[HasFresh Var]
[DecidableEq Var]
{x : Var}
(step : Relation.ReflTransGen FullBeta M M')
:
Abstracting then closing preserves multiple reductions.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.step_abs_cong
{Var : Type u}
{M M' : Term Var}
[HasFresh Var]
[DecidableEq Var]
(xs : Finset Var)
(cofin : ∀ x ∉ xs, (M.open' (fvar x)).FullBeta (M'.open' (fvar x)))
:
Multiple reduction of opening implies multiple reduction of abstraction.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.redex_abs_cong
{Var : Type u}
{M M' : Term Var}
[HasFresh Var]
[DecidableEq Var]
(xs : Finset Var)
(cofin : ∀ x ∉ xs, Relation.ReflTransGen FullBeta (M.open' (fvar x)) (M'.open' (fvar x)))
:
Multiple reduction of opening implies multiple reduction of abstraction.
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.invert_steps_abs
{Var : Type u}
[HasFresh Var]
[DecidableEq Var]
{s t : Term Var}
(step : Relation.ReflTransGen FullBeta s.abs t)
:
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.steps_open_cong_l_abs
{Var : Type u}
[HasFresh Var]
[DecidableEq Var]
(s s' t : Term Var)
(steps : Relation.ReflTransGen FullBeta s.abs s'.abs)
(lc_s : s.abs.LC)
(lc_t : t.LC)
:
Relation.ReflTransGen FullBeta (s.open' t) (s'.open' t)
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.steps_subst_cong_r
{Var : Type u}
[HasFresh Var]
[DecidableEq Var]
{x : Var}
(s t t' : Term Var)
(step : Relation.ReflTransGen FullBeta t t')
(h_lc : s.LC)
:
theorem
Cslib.LambdaCalculus.LocallyNameless.Untyped.Term.FullBeta.steps_open_cong_abs
{Var : Type u}
[HasFresh Var]
[DecidableEq Var]
(s s' t t' : Term Var)
(step1 : Relation.ReflTransGen FullBeta t t')
(step2 : Relation.ReflTransGen FullBeta s.abs s'.abs)
(lc_t : t.LC)
(lc_s : s.abs.LC)
:
Relation.ReflTransGen FullBeta (s.open' t) (s'.open' t')