Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
707638c
feat: Church–Rosser theorem (Q1308502) for ULC (de Bruijn)
zayn7lie Apr 7, 2026
bdf1e98
upd: change dir
zayn7lie Apr 10, 2026
8fa2604
upd: localize from to
zayn7lie Apr 10, 2026
1d711e1
upd: eliminate for de bruijn syntax and explicit all and
zayn7lie Apr 10, 2026
e9b1afc
upd: eliminate for diamond and Confluent definition
zayn7lie Apr 10, 2026
bd8f72d
upd: generalize decrement for consistency
zayn7lie Apr 10, 2026
2721e03
upd: instantiate with
zayn7lie Apr 10, 2026
8d4d4e2
upd: newline between theorems
zayn7lie Apr 10, 2026
7d59f58
upd: clean up `ConfluentReduction.lean` to `Cslib.Foundations.Data.Re…
zayn7lie Apr 10, 2026
409487f
upd: clean up `ConfluentReduction.lean` to `Cslib.Foundations.Data.Re…
zayn7lie Apr 10, 2026
997612e
upd: clarification for consistency of decre
zayn7lie Apr 10, 2026
5888bb7
upd: `reduction_sys` for generating notations for reductions and the …
zayn7lie Apr 10, 2026
b3b3cbf
fix: notation typeclass for substitution
zayn7lie Apr 11, 2026
f38f365
fix: sandwich
zayn7lie May 5, 2026
2e9f98a
fix: par_subst - lt_trichotomy
zayn7lie May 5, 2026
cfaafd5
fix: syntax - disambiuity
zayn7lie May 5, 2026
71fea86
upd: syntax - sub - specify type
zayn7lie May 5, 2026
f028d59
upd: syntax - Term - docstring
zayn7lie May 5, 2026
d0df686
upd: xyntax - incre_rfl - proof
zayn7lie May 5, 2026
cb74c0f
fix: namespace
zayn7lie May 5, 2026
8ce89f0
upd: open term redundent
zayn7lie May 5, 2026
22d4f9a
upd: \@\[expose\] public section
zayn7lie May 5, 2026
29a0aad
upd: betareduction - proof simp
zayn7lie May 5, 2026
224bdc4
upd: typo
zayn7lie May 5, 2026
6201d90
upd: betareduction
zayn7lie May 5, 2026
fedf24f
fix: debruijn - where
zayn7lie May 5, 2026
f1ef763
upd: debruijn def - dosctring
zayn7lie May 18, 2026
741140a
upd: Nat.assoc update
zayn7lie Jun 14, 2026
515e234
upd: Relation after split, sandwich_to_eq
zayn7lie Jun 14, 2026
d1e4c01
upd: final resolve Conflicts
zayn7lie Jun 14, 2026
a798ec2
fix: ParStar definition
zayn7lie Jun 14, 2026
20558fc
fix: remove whitespace
zayn7lie Jun 14, 2026
66346c7
upd: subst sandwich with reflTransGen_mono_closed
zayn7lie Jun 14, 2026
fcdd44a
upd: DeBruijnSyntax - `if_neg` has been deprecated: Use `ite_eq_right…
zayn7lie Aug 18, 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 @@ -163,6 +163,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.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