Skip to content

feat(Mathlib/Data/Finite/Option): option type is finite iff type is finite - #39567

Open
AlexBrodbelt wants to merge 11 commits into
leanprover-community:masterfrom
AlexBrodbelt:AlexBrodbelt/Finite/Option
Open

AlexBrodbelt wants to merge 11 commits into
leanprover-community:masterfrom
AlexBrodbelt:AlexBrodbelt/Finite/Option

Conversation

@AlexBrodbelt

@AlexBrodbelt AlexBrodbelt commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Option type is finite if and only if the type is finite.

This is an intermediate result to proving that if the GroupWithZero is (in)finite then the Units are (in)finite.


Open in Gitpod

@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label May 19, 2026
@github-actions

Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR.

Thank you again for joining our community.

@github-actions github-actions Bot added the t-data Data (lists, quotients, numbers, etc) label May 19, 2026
@github-actions

github-actions Bot commented May 19, 2026 •

Copy link
Copy Markdown

PR summary e6a4467394

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Data.Finite.Option (new file) 627

Declarations diff (regex)

+ Option.finite_iff
+ Option.infinite_iff

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit e6a4467).

  • +2 new declarations
  • −0 removed declarations
+Option.finite_iff
+Option.infinite_iff

No changes to strong technical debt.
No changes to weak technical debt.

Current commit e6a4467394
Reference commit 8e30cac82f

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

Comment thread Mathlib/Data/Finite/Option.lean Outdated
Comment thread Mathlib/Data/Finite/Option.lean Outdated
Comment thread Mathlib/Data/Finite/Option.lean Outdated
Comment thread Mathlib/Data/Finite/Option.lean Outdated
Comment thread Mathlib/Data/Finite/Option.lean Outdated
Comment thread Mathlib/Data/Finite/Option.lean Outdated
Comment thread Mathlib/Data/Finite/Option.lean
@mathlib-triage mathlib-triage Bot assigned TwoFX and unassigned joneugster Jun 21, 2026
@mathlib-triage mathlib-triage Bot assigned eric-wieser and unassigned TwoFX Jul 16, 2026
@ADedecker ADedecker added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Aug 13, 2026
@ADedecker

Copy link
Copy Markdown
Member

Hi @AlexBrodbelt, are you still working on this? No pressure of course!

@felixpernegger felixpernegger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe also include the same thing for Infinite?

Also, would proving the result for Countable and Uncountable here cause issues?

Comment thread Mathlib/Data/Finite/Option.lean Outdated
-/
module

public import Mathlib.Data.Finite.Defs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
public import Mathlib.Data.Finite.Defs
public import Mathlib.Data.Finite.Defs

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.

The change you are proposing leaves it unchanged?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no; it adds an empty line between public and private imports; which is the convention

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.

ah okay, will keep that in mind. thanks!

@AlexBrodbelt AlexBrodbelt Oct 1, 2026 •

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.

Regarding the analogous Countable and Uncountable results. Maybe a new file or even folder should be made? For now I will push including the Infinite case and work on the remaining cases on another branch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah maybe, but at the same time 30 lines files are a bit unfortunate imo

@themathqueen

themathqueen commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Please "resolve conversation" when you've addressed the comments, and then when you're ready for another review please comment -awaiting-review :)

Also, you'll probably need to merge master in order to fix the CI error.

Comment thread Mathlib/Data/Finite/Option.lean Outdated

public section

/-- `Option α` is finite if and only if the underlying type `α`is finite. -/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/-- `Option α` is finite if and only if the underlying type `α`is finite. -/
/-- `Option α` is finite if and only if the underlying type `α` is finite. -/

Comment thread Mathlib/Data/Finite/Option.lean Outdated
@AlexBrodbelt

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 2, 2026

@themathqueen themathqueen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should probably move this file to Basic/Finite?

/-- `Option α` is infinite if and only if the underlying type `α` is infinite. -/
@[simp]
theorem Option.infinite_iff {α : Type*} : Infinite (Option α) ↔ Infinite α := by
rw [← not_finite_iff_infinite, ← not_finite_iff_infinite, Option.finite_iff]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
rw [← not_finite_iff_infinite, ← not_finite_iff_infinite, Option.finite_iff]
simp [← not_finite_iff_infinite]

Comment on lines +25 to +27
mp
| @Finite.intro _ 0 e => (e none).elim0
| @Finite.intro _ (n + 1) e => ⟨(e.trans (finSuccEquiv n)).removeNone⟩

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
mp
| @Finite.intro _ 0 e => (e none).elim0
| @Finite.intro _ (n + 1) e => ⟨(e.trans (finSuccEquiv n)).removeNone⟩
mp _ := .of_injective _ (Option.some_injective α)

@themathqueen

Copy link
Copy Markdown
Member

Or actually, why not just add these results to Mathlib/Data/Fintype/Option?

@themathqueen themathqueen added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 2, 2026

This branch has not been deployed

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

Labels

awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants