Skip to content

feat(untyped): define CBN and Standard evaluation strategies - #671

Merged
chenson2018 merged 8 commits into
leanprover:mainfrom
m-ow:feat/standard-reduction
Jun 22, 2026
Merged

feat(untyped): define CBN and Standard evaluation strategies#671
chenson2018 merged 8 commits into
leanprover:mainfrom
m-ow:feat/standard-reduction

Conversation

@m-ow

@m-ow m-ow commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

This is the first step towards the Standardization Theorem.

Instead of the classic (and painful) Barendregt approach, I defined Standard reduction
relying on CBN to find the head redex, which makes the proofs much nicer.

@lengyijun

lengyijun commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Hi, I am doing something similar.
I have verified eta-postpone theorem yet.

I also have verified leftmost theorem in debruijn index.

We are working on https://github.com/awesome-lambda-calculus/Fokker_challenge , normalization theorem is of most importance to us.

@m-ow

m-ow commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi! Really cool project!
You mentioned using De Bruijn indices, but I'm writing the Standardization theorem in Locally Nameless.
Are you planning to open a PR to add the De Bruijn representation? Let's coordinate our efforts to avoid duplicating work.

@m-ow

m-ow commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Just read through your docs and I'm glad to see the project officially uses Locally Nameless.
I also noticed that you are currently blocked by the Standardization theorem. I can focus my efforts there so your team can use it soon. Let me know what you think and how you'd like to proceed!

@lengyijun

Copy link
Copy Markdown
Contributor

https://github.com/awesome-lambda-calculus/Fokker_challenge/issues/3

@chenson2018 chenson2018 left a comment

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.

Looks straightforward, just a couple of small golfs:

Comment thread Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/CallByName.lean Outdated
variable {M N : Term Var}

/-- The left side of a standard reduction is locally closed. -/
lemma stand_lc_l (step : M ⭢ₛ N) : LC M := by

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 for the other reduction strategies we namespace all these lemmas. Especially since you do so for Standard.lc_refl below this feels odd.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review!

m-ow and others added 3 commits June 22, 2026 13:29
…ame.lean

Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
…ame.lean

Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
Comment thread Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/CallByName.lean Outdated

@chenson2018 chenson2018 left a comment

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.

Looks good, thanks!

@chenson2018
chenson2018 enabled auto-merge June 22, 2026 20:26
@chenson2018
chenson2018 added this pull request to the merge queue Jun 22, 2026
Merged via the queue into leanprover:main with commit f10c049 Jun 22, 2026
2 checks passed
@lengyijun

Copy link
Copy Markdown
Contributor

@chenson2018 Why merge such unfinished code?

@chenson2018

Copy link
Copy Markdown
Collaborator

@chenson2018 Why merge such unfinished code?

We in general encourage making small PRs. This seemed fine to me for an initial pass at adding these definitions.

@lengyijun

lengyijun commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@m-ow May I ask what project you are working on that requires this definition?
For fokker_challenge, this definition of standard theorem looks useless.

In my development of fokker_challenge, changes to cslib are saved in enhancedcslib/ directory for several weeks, until I can make sure this is useful and general enough to contribute to upstream.

@chenson2018

Copy link
Copy Markdown
Collaborator

this definition of standard theorem looks useless.

Instead of phrasing things so negatively, could you please explain the specific issue that you have with the definitions in this PR?

@lengyijun

lengyijun commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Personally I prefer https://www.is.c.titech.ac.jp/~kashima/pub/C-145.pdf

Actually I have verified most part of the paper, but I am still testing them in fokker_challenge, so I will not pr soon.

I don't understand merge such a pr in one day.

@lengyijun

lengyijun commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

this definition of standard theorem looks useless.

Instead of phrasing things so negatively, could you please explain the specific issue that you have with the definitions in this PR?

I doubt this is helpful to verify "two vars are not enough".
I am currently still experimenting with various definitions.
I don't understand why the decision is being made so quickly.

https://github.com/awesome-lambda-calculus/Fokker_challenge/wiki/Two-vars-are-not-enough

@lengyijun

Copy link
Copy Markdown
Contributor

BTW: "Formalization in Coq of the Standardization Theorem for λ-calculus" is not based on locallynameless

@chenson2018

Copy link
Copy Markdown
Collaborator

BTW: "Formalization in Coq of the Standardization Theorem for λ-calculus" is not based on locallynameless

It seems unlikely to be relevant that this reference is not specifically using locally nameless binding, as most theorems we care about are independent of this?

So I don't understand merge such a pr in one day.

I've still not understood your specific objection to these definitions. They seemed very straightforward to me, so I merged the PR. There is no rush, but if you follow up with a specific alternative proposal and a fleshed out explanation of why it works better, I will certainly consider it.

@lengyijun

lengyijun commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

In this pr, standardization is parallel style.
In https://www.is.c.titech.ac.jp/~kashima/pub/C-145.pdf, standardization is small step style.

Proof in parallel style might be easier to write.

@m-ow @chenson2018

@lengyijun

Copy link
Copy Markdown
Contributor

Actually I have the whole proof this pr, but it is not tested in fokker_challenge, so I didn't push a pr:

3176a427-5996-4dfd-85d5-33b8f32eff1a-aristotle.tar.gz

@m-ow

m-ow commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@lengyijun Thanks for the feedback.
I'd like to clarify a couple of points regarding the definitions in this PR:

In this pr, standardization is parallel style.

The proof strategy in this PR is not parallel, it's CBN based (following Calisto, adapted to locally nameless).

I doubt this is helpful to verify "two vars are not enough".

Agreed that the current PR is not sufficient for fokker_challenge on its own. The next step is M ⭢ₛ N ↔ M ↠βᶠ N, followed by the leftmost reduction theorem. These are the next PRs I have in mind.

@lengyijun

Copy link
Copy Markdown
Contributor

@m-ow Are you going to define properties of Normal FullBeta ?

@m-ow

m-ow commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

If you already have Normal and related properties in locally nameless, I'd encourage you to open a PR for them. Let's avoid overlap

@lengyijun

Copy link
Copy Markdown
Contributor

@m-ow I will not pr those. Thanks for your work. I will focus on following theorems, although I don't have any idea now:

theorem betaeta_factor_betaNF {M N : Term} (h : StepsBetaEta M N) (hN : NormalFormBetaEta N) :
    ∃ P, StepsBeta M P ∧ NormalFormBeta P ∧ StepsEta P N := by

lemma sn_eta_step [DecidableEq Var] [HasFresh Var]
  (t_st_t' : t ⭢ηᶠ t') (sn_t : SN FullBeta t) : SN FullBeta t'

@m-ow
m-ow deleted the feat/standard-reduction branch June 24, 2026 12:44
lengyijun pushed a commit to awesome-lambda-calculus/cslib that referenced this pull request Jul 9, 2026
…rover#679)

This PR proves the standardization theorem: if `M` beta-reduces to `N`
in any number of steps, then `N` is reachable from `M` by a standard
reduction.

Builds on leanprover#671.

---------

Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
Co-authored-by: Chris Henson <chrishenson.net@gmail.com>
intgrah pushed a commit to intgrah/cslib that referenced this pull request Jul 14, 2026
…rover#679)

This PR proves the standardization theorem: if `M` beta-reduces to `N`
in any number of steps, then `N` is reachable from `M` by a standard
reduction.

Builds on leanprover#671.

---------

Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
Co-authored-by: Chris Henson <chrishenson.net@gmail.com>
fmontesi pushed a commit that referenced this pull request Jul 22, 2026
This PR proves the standardization theorem: if `M` beta-reduces to `N`
in any number of steps, then `N` is reachable from `M` by a standard
reduction.

Builds on #671.

---------

Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
Co-authored-by: Chris Henson <chrishenson.net@gmail.com>
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.

3 participants