Skip to content

feat(Foundations/Data/Relation): strongly normalising elements of a type equipped with a relation#549

Merged
chenson2018 merged 4 commits into
leanprover:mainfrom
thomaskwaring:sn
May 6, 2026
Merged

feat(Foundations/Data/Relation): strongly normalising elements of a type equipped with a relation#549
chenson2018 merged 4 commits into
leanprover:mainfrom
thomaskwaring:sn

Conversation

@thomaskwaring
Copy link
Copy Markdown
Collaborator

This PR defines a predicate SN r x (better naming suggestions welcome) expressing that there is no infinite chain of r-related elements starting with x. This extends the definition of Terminating using WellFounded to individual elements, using Acc.


I'm very open to being told this is not a useful generalisation / abstraction, but the existing API for Acc does seem to make certain proofs easier. For instance, sn_app_left in LambdaCalculus/LocallyNameless/Untyped/StrongNorm falls out as reduction on M is a subrelation of reduction on M.app N.

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.

I think this makes sense and is consistent with how we defined Terminating. I had in mind something pretty similar and hadn't found the time, so thanks!

Just a few mostly style reviews:

Comment thread Cslib/Foundations/Data/Relation.lean Outdated
Comment thread Cslib/Foundations/Data/Relation.lean Outdated
Comment thread Cslib/Foundations/Data/Relation.lean Outdated

/-- An element `x` is `SN` (for strongly-normalising) for a relation `r` if it is accesible under
the inverse of `r`. -/
abbrev SN (r : α → α → Prop) (x : α) := Acc (fun a b => r b a) x
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 consistency with Terminating I'd write

Suggested change
abbrev SN (r : α → α → Prop) (x : α) := Acc (fun a b => r b a) x
abbrev SN (r : α → α → Prop) := Acc (fun a b => r b a)

Do you have an opinion about us writing fun a b => r b a versus using Function.swap? It seems a bit painful either way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i agree, no particular opinion i went with what you had for terminating (flip is also an option)

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.

Yeah, let's leave this for now. It is somewhat dissatisfying that we do all this work just to change the direction that the relation goes...

Comment thread Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/StrongNorm.lean Outdated
Comment thread Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/StrongNorm.lean Outdated
thomaskwaring and others added 2 commits May 6, 2026 11:23
Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com>
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.

Looks good, thanks for doing this!

@chenson2018 chenson2018 added this pull request to the merge queue May 6, 2026
Merged via the queue into leanprover:main with commit cdfe655 May 6, 2026
2 checks passed
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