Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b77e9d7
feat: Church–Rosser theorem (Q1308502) for ULC (de Bruijn)
zayn7lie Apr 7, 2026
3f5ddca
upd: change dir
zayn7lie Apr 10, 2026
96f33e8
upd: localize from to
zayn7lie Apr 10, 2026
071c9dc
upd: eliminate for de bruijn syntax and explicit all and
zayn7lie Apr 10, 2026
20ef1d5
upd: eliminate for diamond and Confluent definition
zayn7lie Apr 10, 2026
014cda1
upd: generalize decrement for consistency
zayn7lie Apr 10, 2026
9654d06
upd: instantiate with
zayn7lie Apr 10, 2026
4a1599c
upd: newline between theorems
zayn7lie Apr 10, 2026
ad6931b
upd: clean up `ConfluentReduction.lean` to `Cslib.Foundations.Data.Re…
zayn7lie Apr 10, 2026
f787d3b
upd: clean up `ConfluentReduction.lean` to `Cslib.Foundations.Data.Re…
zayn7lie Apr 10, 2026
24a337c
upd: clarification for consistency of decre
zayn7lie Apr 10, 2026
f77e852
upd: `reduction_sys` for generating notations for reductions and the …
zayn7lie Apr 10, 2026
62b7ee4
fix: notation typeclass for substitution
zayn7lie Apr 11, 2026
0969761
fix: sandwich
zayn7lie May 5, 2026
fdc3f91
fix: par_subst - lt_trichotomy
zayn7lie May 5, 2026
bc75fe0
fix: syntax - disambiuity
zayn7lie May 5, 2026
0369903
upd: syntax - sub - specify type
zayn7lie May 5, 2026
35a22dc
upd: syntax - Term - docstring
zayn7lie May 5, 2026
e07ba96
upd: xyntax - incre_rfl - proof
zayn7lie May 5, 2026
1b0d933
fix: namespace
zayn7lie May 5, 2026
2d967ed
upd: open term redundent
zayn7lie May 5, 2026
c99b0ed
upd: \@\[expose\] public section
zayn7lie May 5, 2026
7e98def
upd: betareduction - proof simp
zayn7lie May 5, 2026
069b415
upd: typo
zayn7lie May 5, 2026
8840251
upd: betareduction
zayn7lie May 5, 2026
a717634
fix: debruijn - where
zayn7lie May 5, 2026
c94b1de
upd: debruijn def - dosctring
zayn7lie May 18, 2026
1c6607a
upd: Nat.assoc update
zayn7lie Jun 14, 2026
8715e8a
upd: Relation after split, sandwich_to_eq
zayn7lie Jun 14, 2026
54cd173
upd: final
zayn7lie Jun 14, 2026
fd90475
fix: ParStar definition
zayn7lie Jun 14, 2026
9f7a2d4
fix: remove whitespace
zayn7lie Jun 14, 2026
a1232e7
upd: subst sandwich with reflTransGen_mono_closed
zayn7lie Jun 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cslib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.MultiSubst
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.Properties
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.StrongNorm
public import Cslib.Languages.LambdaCalculus.Named.Untyped.Basic
public import Cslib.Languages.LambdaCalculus.Unscoped.Untyped.BetaReduction
public import Cslib.Languages.LambdaCalculus.Unscoped.Untyped.ChurchRosser
public import Cslib.Languages.LambdaCalculus.Unscoped.Untyped.DeBruijnSyntax
public import Cslib.Languages.LambdaCalculus.Unscoped.Untyped.ParallelReduction
public import Cslib.Logics.HML.Basic
public import Cslib.Logics.HML.LogicalEquivalence
public import Cslib.Logics.LinearLogic.CLL.Basic
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/-
Copyright (c) 2026 zayn7lie. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zayn Wang
-/
module

public import Cslib.Languages.LambdaCalculus.Unscoped.Untyped.DeBruijnSyntax
public import Cslib.Foundations.Relation.Attr

/-!
# One-step β-reduction and its reflexive-transitive closure (Star)

This file defines the usual compatible one-step β-reduction on de Bruijn lambda terms.
It also introduces its reflexive-transitive closure and proves basic closure lemmas for
application and abstraction.

## Main definitions

* `Lambda.Beta`: one-step β-reduction.

## Main lemmas

Inside `namespace BetaStar` we provide the standard constructors and congruence lemmas:

* `BetaStar.appL`, `BetaStar.appR`, `BetaStar.app`, `BetaStar.abs`

These lemmas are used later to compare β-reduction with parallel reduction.
-/

@[expose] public section

namespace Cslib.LambdaCalculus.Unscoped.Untyped

open Term

open Relation.ReflTransGen

/-- One-step β-reduction (compatible closure). -/
@[reduction_sys "β"]
inductive Beta : Term → Term → Prop
| abs {t t'} : Beta t t' → Beta (abs t) (abs t')
| appL {t t' u} : Beta t t' → Beta (app t u) (app t' u)
| appR {t u u'} : Beta u u' → Beta (app t u) (app t u')
| red (t' s : Term) : Beta (app (abs t') s) (t'.sub 0 s)

namespace BetaStar

theorem appL {t t' u : Term} (h : t ↠β t') :
(app t u) ↠β (app t' u) := h.lift (app · u) (fun _ _ => .appL)

theorem appR {t u u' : Term} (h : u ↠β u') :
(app t u) ↠β (app t u') := h.lift (app t ·) (fun _ _ => .appR)

theorem app {t t' u u'}
(ht : t ↠β t') (hu : u ↠β u') :
(app t u) ↠β (app t' u') := (appL ht).trans (appR hu)

theorem abs {t t' : Term} (h : t ↠β t') :
(abs t) ↠β (abs t') := h.lift Term.abs (fun _ _ => Beta.abs)

end BetaStar

end Cslib.LambdaCalculus.Unscoped.Untyped
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/-
Copyright (c) 2026 zayn7lie. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zayn Wang
-/
module

public import Cslib.Foundations.Relation.Confluence
public import Cslib.Languages.LambdaCalculus.Unscoped.Untyped.ParallelReduction

/-!
# The Church–Rosser theorem for β-reduction

This file proves confluence of β-reduction on de Bruijn lambda terms. The proof follows
the classical route:

1. define parallel β-reduction,
2. show that parallel reduction has the diamond property using complete developments,
3. compare parallel reduction with ordinary β-reduction via reflexive-transitive closure,
4. transport confluence back to β-reduction.

## Main results

* `diamond_par`: parallel reduction is diamond.
* `churchRosser_beta`: β-reduction is confluent.

## Implementation note

The proof relies on the generic rewriting lemmas from `ConfluentReduction` together with
the complete-development machinery from `ParallelReduction`.
-/

@[expose] public section

namespace Cslib.LambdaCalculus.Unscoped.Untyped

open Relation

/-- Parallel Reduction is Diamond. -/
private lemma diamond_par : Diamond Par := by
intro a b c hab hac
exact ⟨a.dev, par_to_dev hab, par_to_dev hac⟩

/-- Church–Rosser: β is confluent (on RTC). -/
theorem churchRosser_beta : Confluent Beta := by
-- Confluence of Par from diamond
have hPar : Confluent Par :=
Diamond.toConfluent (r := Par) diamond_par
-- Identify BetaStar and ParStar via sandwich
have hEq {a b : Term} : a ↠β b ↔ a ↠∥ b := by
have hRel : ReflTransGen Beta = ReflTransGen Par :=
reflTransGen_mono_closed (r₁ := Beta) (r₂ := Par)
(by intro a b h; exact beta_subset_par h)
(by intro a b h; exact par_subset_betaStar h)
simp only [hRel]
-- Transport confluence
intro a b c hab hac
have hab' : a ↠∥ b := (hEq).1 hab
have hac' : a ↠∥ c := (hEq).1 hac
rcases hPar hab' hac' with ⟨d, hbd, hcd⟩
exact ⟨d, (hEq).2 hbd, (hEq).2 hcd⟩

end Cslib.LambdaCalculus.Unscoped.Untyped
Loading
Loading