Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
55aac0c
feat: Church–Rosser theorem (Q1308502) for ULC (de Bruijn)
zayn7lie Apr 7, 2026
bcfca97
upd: change dir
zayn7lie Apr 10, 2026
f2c0926
upd: localize from to
zayn7lie Apr 10, 2026
7611b04
upd: eliminate for de bruijn syntax and explicit all and
zayn7lie Apr 10, 2026
e600c64
upd: eliminate for diamond and Confluent definition
zayn7lie Apr 10, 2026
e07b8c3
upd: generalize decrement for consistency
zayn7lie Apr 10, 2026
70967bb
upd: instantiate with
zayn7lie Apr 10, 2026
dd4dd39
upd: newline between theorems
zayn7lie Apr 10, 2026
89bb8e5
upd: clean up `ConfluentReduction.lean` to `Cslib.Foundations.Data.Re…
zayn7lie Apr 10, 2026
6c5d50e
upd: clean up `ConfluentReduction.lean` to `Cslib.Foundations.Data.Re…
zayn7lie Apr 10, 2026
fbc1567
upd: clarification for consistency of decre
zayn7lie Apr 10, 2026
367fece
upd: `reduction_sys` for generating notations for reductions and the …
zayn7lie Apr 10, 2026
e0d47e8
fix: notation typeclass for substitution
zayn7lie Apr 11, 2026
2bb6b42
fix: sandwich
zayn7lie May 5, 2026
1296ebc
fix: par_subst - lt_trichotomy
zayn7lie May 5, 2026
93efa90
fix: syntax - disambiuity
zayn7lie May 5, 2026
007a476
upd: syntax - sub - specify type
zayn7lie May 5, 2026
4b9e5dc
upd: syntax - Term - docstring
zayn7lie May 5, 2026
a65a9b9
upd: xyntax - incre_rfl - proof
zayn7lie May 5, 2026
75817ce
fix: namespace
zayn7lie May 5, 2026
51e099e
upd: open term redundent
zayn7lie May 5, 2026
89e157a
upd: \@\[expose\] public section
zayn7lie May 5, 2026
afac21b
upd: betareduction - proof simp
zayn7lie May 5, 2026
3ea56a2
upd: typo
zayn7lie May 5, 2026
88f98b2
upd: betareduction
zayn7lie May 5, 2026
f94c25e
fix: debruijn - where
zayn7lie May 5, 2026
d9720d1
upd: debruijn def - dosctring
zayn7lie May 18, 2026
89c9887
upd: Nat.assoc update
zayn7lie Jun 14, 2026
89ca52c
upd: Relation after split, sandwich_to_eq
zayn7lie Jun 14, 2026
e8dec0d
upd: final resolve Conflicts
zayn7lie Jun 14, 2026
492b21b
fix: ParStar definition
zayn7lie Jun 14, 2026
194d9c3
fix: remove whitespace
zayn7lie Jun 14, 2026
a6d4f67
upd: subst sandwich with reflTransGen_mono_closed
zayn7lie Jun 14, 2026
c16b3af
upd: DeBruijnSyntax - `if_neg` has been deprecated: Use `ite_eq_right…
zayn7lie Aug 18, 2026
cd9bd6b
fix: has been deprecated: Use `Relation.Diamond.to_confluent` instead
zayn7lie Sep 21, 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 @@ -244,6 +244,10 @@ public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.StandardRed
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.StrongNorm
public import Cslib.Languages.LambdaCalculus.Named.Untyped.Basic
public import Cslib.Languages.LambdaCalculus.Named.Untyped.Properties
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.Languages.Mech.Choreography.Basic
public import Cslib.Languages.Mech.LocalComputation
public import Cslib.Languages.StatefulProcesses.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.to_confluent (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