Skip to content

Conversation

@chenson2018
Copy link
Collaborator

This PR adds an instance directly showing that HasFresh implies Infinite. This replaces HasFresh.not_of_finite which triggered a linter and is now equivalent to just not_finite. HasFresh.of_infinite is also changed to an instance with a slightly more direct definition.

@chenson2018 chenson2018 requested a review from fmontesi as a code owner January 29, 2026 23:07
Copy link
Contributor

@ctchou ctchou left a comment

Choose a reason for hiding this comment

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

LGTM.

fresh_notMem s := s.finite_toSet.infinite_compl.nonempty.choose_spec
This, in conjunction with `HasFresh.to_infinite`, characterizes `HasFresh`. -/
noncomputable instance HasFresh.of_infinite (α : Type u) [Infinite α] : HasFresh α where
fresh s := Infinite.exists_notMem_finset s |>.choose
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't know what the preferred style is: should there be a space between |> and .?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are semantically different:

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know that. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, I wonder if (Infinite.exists_notMem_finset s).choose is actually clearer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am fairly ambivalent, but I think this is a common enough core syntax to not be considered obfuscatory. I wrote it without thinking, not as a golfing attempt.

@fmontesi fmontesi added this pull request to the merge queue Jan 30, 2026
Merged via the queue into leanprover:main with commit b91aeb4 Jan 30, 2026
2 checks passed
chenson2018 added a commit that referenced this pull request Jan 30, 2026
This PR adds an instance directly showing that `HasFresh` implies
`Infinite`. This replaces `HasFresh.not_of_finite` which triggered a
linter and is now equivalent to just `not_finite`.
`HasFresh.of_infinite` is also changed to an instance with a slightly
more direct definition.
arademaker pushed a commit to arademaker/cslib that referenced this pull request Feb 2, 2026
…nprover#303)

This PR adds an instance directly showing that `HasFresh` implies
`Infinite`. This replaces `HasFresh.not_of_finite` which triggered a
linter and is now equivalent to just `not_finite`.
`HasFresh.of_infinite` is also changed to an instance with a slightly
more direct definition.
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