Skip to content

feat: Church–Rosser theorem (Q1308502) for ULC (de Bruijn)#475

Open
zayn7lie wants to merge 12 commits intoleanprover:mainfrom
zayn7lie:main
Open

feat: Church–Rosser theorem (Q1308502) for ULC (de Bruijn)#475
zayn7lie wants to merge 12 commits intoleanprover:mainfrom
zayn7lie:main

Conversation

@zayn7lie
Copy link
Copy Markdown

@zayn7lie zayn7lie commented Apr 7, 2026

Main contributions

Q1308502: Church-Rosser theorem in 1000 theorems

  • A de Bruijn syntax for λ-terms together with substitution and shifting operations.
  • Definition of one-step β-reduction.
  • Definition of parallel β-reduction (Par) and its basic properties.
  • Abstract confluence infrastructure (Diamond, Confluent) for binary relations.
  • Proof that parallel β-reduction satisfies the diamond property.
  • Deduction of confluence of β-reduction (Church–Rosser theorem) via standard closure arguments.

The development follows the classical proof strategy:
parallel reduction -> diamond -> confluence -> Church–Rosser.

Design choices

  • De Bruijn indices are used to avoid α-equivalence bookkeeping.
  • Parallel reduction is defined inductively to enable a direct diamond proof.
  • Confluence lemmas are factored through generic relation-theoretic definitions
    (Diamond, Confluent) to keep the proof modular.

Use of AI

  • Rough structure for beginning
  • Small/trivial structure proof
  • Docs/Comment generating
  • Final refinement

@chenson2018 chenson2018 self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@chenson2018 chenson2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your interest in contributing to CSLib! We do have Church-Rosser for locally nameless binding, but I think we are interested in having the more common de Bruijn indices representation as well.

I see there is a disclosure of AI usage, but this looks like its been mostly cleaned up pretty well, so thank you.

Below are some initial reviews about making this fit into CSLib conventions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go with the other lambda calculus modules under Cslib/Languages/LambdaCalculus and follow their structure of a directory for each type system. I would call this binding Unscoped to distinguish from well-scoped de Bruijn indices. So all togther, everything here would go under Cslib.Languages.LambdaCalculus.Unscoped.Untyped.*

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of this is subsumed by Cslib.Foundations.Data.Relation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I was unclear here. I don't think this file should exist at all. All of this, with maybe the exception of rtc_eq_of_sandwich, is already in Cslib.Foundations.Data.Relation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infixl:77 "·" => Term.app

/-- `incre i l t` increments `i` for all free vars `≥ l`. -/
@[simp, expose] public def incre (i : Nat) (l : Nat) : Term → Term
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you should just use @[expose] public section for these modules.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| app t u => app (subst j s t) (subst j s u)

/-- `decre c t` decrements free vars `> c` by 1. -/
@[simp, expose] public def decre (l : Nat) : Term → Term
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency, I would also generalize this to an arbitrary decrement.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| app t₁ t₂ ih₁ ih₂ => simp_all

/-- Communitivity of incre. -/
public theorem incre_comm {i j k l t} :
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can clean up some of the arithmetic in theorems like this, but I'll wait until we have more high-level changes done first to give specific suggestions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks.

| app t u => app (decre l t) (decre l u)

/-- Substitute into the body of a lambda: `(λ.t) s` -/
@[simp, expose] public def sub (t : Term) (n : Nat) (s : Term) := decre n (subst n (incre 1 n s) t)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Cslib.Foundations.Syntax.HasSubstitution for the notation typeclass we use for substitution.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| appL {t t' u} : Beta t t' → Beta (t·u) (t'·u)
| appR {t u u'} : Beta u u' → Beta (t·u) (t·u')
| red (t' s : Term) : Beta ((λ.t')·s) (t'.sub 0 s)
public abbrev BetaStar := Relation.ReflTransGen Beta
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the attribute reduction_sys for generating notations for reductions and the multi-step closure.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


namespace BetaStar

public theorem refl (t : Term) : BetaStar t t :=
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general style rule, please out a single space between theorems.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants