Skip to content

Commit 9a159ac

Browse files
m-owchenson2018
andauthored
feat: Add η-reduction definition (#414)
This PR introduces the definition of $\eta$-reduction for the untyped lambda calculus using the locally nameless representation. This is the first PR aimed at formalizing the confluence of $\beta \cup \eta$. --------- Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
1 parent dedc0d7 commit 9a159ac

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Cslib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public import Cslib.Languages.LambdaCalculus.LocallyNameless.Stlc.Safety
9292
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.Basic
9393
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullBeta
9494
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullBetaConfluence
95+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullEta
9596
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.LcAt
9697
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.MultiApp
9798
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.MultiSubst
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/-
2+
Copyright (c) 2026 Maximiliano Onofre Martínez. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Maximiliano Onofre Martínez
5+
-/
6+
7+
module
8+
9+
public import Cslib.Foundations.Data.Relation
10+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.Properties
11+
12+
public section
13+
14+
/-! # η-reduction for the λ-calculus -/
15+
16+
namespace Cslib
17+
18+
universe u
19+
20+
variable {Var : Type u}
21+
22+
namespace LambdaCalculus.LocallyNameless.Untyped.Term
23+
24+
/-- A single η-reduction step. -/
25+
@[reduction_sys "ηᶠ"]
26+
inductive FullEta : Term Var → Term Var → Prop
27+
/-- The eta rule: λx. M x ⟶ M, provided x is not free in M. -/
28+
| eta : LC M → FullEta (abs (app M (bvar 0))) M
29+
/-- Left congruence rule for application. -/
30+
| appL: LC Z → FullEta M N → FullEta (app Z M) (app Z N)
31+
/-- Right congruence rule for application. -/
32+
| appR : LC Z → FullEta M N → FullEta (app M Z) (app N Z)
33+
/-- Congruence rule for lambda terms. -/
34+
| abs (xs : Finset Var) : (∀ x ∉ xs, FullEta (M ^ fvar x) (N ^ fvar x)) → FullEta (abs M) (abs N)
35+
36+
namespace FullEta
37+
38+
attribute [scoped grind .] appL appR
39+
40+
variable {M M' : Term Var}
41+
42+
/-- The right side of an η-reduction is locally closed. -/
43+
lemma step_lc_r (step : M ⭢ηᶠ M') : LC M' := by
44+
induction step
45+
case abs => constructor; assumption
46+
all_goals grind
47+
48+
variable [HasFresh Var] [DecidableEq Var]
49+
50+
/-- An η-reduction step does not introduce new free variables. -/
51+
lemma step_not_fv (step : M ⭢ηᶠ M') (hw : w ∉ M.fv) : w ∉ M'.fv := by
52+
induction step with
53+
| abs =>
54+
have ⟨x, _⟩ := fresh_exists <| free_union [fv] Var
55+
have := open_close x
56+
grind [close_preserve_not_fvar, open_fresh_preserve_not_fvar]
57+
| _ => grind
58+
59+
end LambdaCalculus.LocallyNameless.Untyped.Term.FullEta
60+
61+
end Cslib

0 commit comments

Comments
 (0)