Skip to content

[Merged by Bors] - feat(SetTheory/ZFC): add ZFSet.card - #29365

Closed
staroperator wants to merge 18 commits into
leanprover-community:masterfrom
staroperator:zfset_card
Closed

staroperator wants to merge 18 commits into
leanprover-community:masterfrom
staroperator:zfset_card

Conversation

@staroperator

@staroperator staroperator commented Sep 5, 2025 •

Copy link
Copy Markdown
Collaborator

The same as ZFSet.rank, we define ZFSet.card as ZFSet.{u} → Cardinal.{u} and prove some basic properties.


Open in Gitpod

@github-actions github-actions Bot added the t-set-theory Set theory label Sep 5, 2025
@github-actions

github-actions Bot commented Sep 5, 2025 •

Copy link
Copy Markdown

PR summary 16e4c581cf

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ card
+ card_empty
+ card_image_le
+ card_insert
+ card_insert_le
+ card_mono
+ card_pair_of_ne
+ card_powerset
+ card_singleton
+ card_union_le
+ cardinalMk_coe_sort
+ iSup_card_le_card_iUnion
+ iSup_mk_le_mk_iUnion
+ inter_eq_left_of_subset
+ inter_eq_right_of_subset
+ lift_card_iUnion_le_sum_card
+ lift_card_range_le
+ powersetEquiv

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh 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).

@vihdzp vihdzp 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.

Thank you for this! This was a long-standing TODO on my personal list.

Speaking of that, one of the results I wanted to prove was that (V_ o).card = preBeth o. I think you should have all the tools to prove that - if it's not too hard, could you add it to the PR?

@staroperator

Copy link
Copy Markdown
Collaborator Author

Thank you for this! This was a long-standing TODO on my personal list.

Speaking of that, one of the results I wanted to prove was that (V_ o).card = preBeth o. I think you should have all the tools to prove that - if it's not too hard, could you add it to the PR?

I have! But that proof is not trivial and will depend on #26544. I will make a draft PR for that later

@YaelDillies YaelDillies 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.

Thanks for the PR! Here's a first batch of comments

Comment on lines +700 to +702
theorem iSup_mk_le_mk_iUnion {α : Type u} {ι : Type v} {f : ι → Set α} :
⨆ i, #(f i) ≤ #(⋃ i, f i) :=
ciSup_le' fun _ => mk_le_mk_of_subset (subset_iUnion _ _)

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.

Are you sure we really need this lemma? I think we should instead make sure that simp can prove it

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 don't think simp can prove an inequality. It is definitely used in #29393, and since we already have Cardinal.mk_iUnion_le_sum_mk that gives an upper bound for #(⋃ i, f i), it should be natural to have a lower bound for it.

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.

I don't think simp can prove an inequality

Have you seen iSup_le_iff ?

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.

Have you seen iSup_le_iff ?

Now I know, thanks to point it out 😃 But still, I don't think simp can help in this lemma.

Comment thread Mathlib/SetTheory/ZFC/Basic.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Basic.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Basic.lean Resolved
@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 4, 2025
@staroperator staroperator removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 4, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 24, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Nov 4, 2025
@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 4, 2025
@mathlib4-merge-conflict-bot

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 4, 2025
Comment thread Mathlib/SetTheory/ZFC/Basic.lean Resolved
Comment thread Mathlib/SetTheory/Cardinal/Basic.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Outdated
def card (x : ZFSet.{u}) : Cardinal.{u} := #(Shrink x.toSet)

/-- `ZFSet.card x` is equal to the cardinality of `x` as a set of `ZFSet`s. -/
theorem card_eq {x : ZFSet.{u}} : lift.{u + 1, u} (card x) = #x.toSet := by

@YaelDillies YaelDillies Nov 4, 2025 •

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.

I would turn this around and call it mk_toSet

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.

Looks good. Should that also be @[simp]?

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.

Probably yes

@staroperator staroperator Nov 5, 2025 •

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.

Probably not, because it will make simp non-confluent on card (x ∪ y).toSet and others

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.

Do you mind expanding?

@staroperator staroperator Nov 5, 2025 •

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 mean this makes simp on #(x ∪ y).toSet produce different normal forms based on choice of order of rewriting lemmas. card_toSet will rewrite it to lift (card (x ∪ y)) while toSet_union (which is already simp) will rewrite it to #(x.toSet ∪ y.toSet), both can not be rewritten further.

(Sorry, the card above should be Cardinal.mk.)

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.

Do you mean #(x ∪ y).toSet?

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.

Also, since # is Cardinal.mk should we call it mk_toSet? Or cardinalMk_toSet?

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.

But yes, good point

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.

Or cardinal_toSet? That has a few precedents like LinearIndependent.cardinal_le_rank.

Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 4, 2025
Comment thread Mathlib/SetTheory/ZFC/Basic.lean Resolved
@staroperator staroperator added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. labels Nov 5, 2025
@github-actions github-actions Bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Nov 5, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Nov 5, 2025
@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 19, 2025
@mathlib4-merge-conflict-bot

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Nov 21, 2025
@mathlib4-dependent-issues-bot

Copy link
Copy Markdown

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 22, 2025

@YaelDillies YaelDillies 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.

Thanks!

maintainer delegate

Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved
@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by YaelDillies.

@ghost ghost added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Nov 22, 2025
Co-authored-by: Yaël Yanis Dillies <[email protected]>
Comment thread Mathlib/SetTheory/ZFC/Cardinal.lean Resolved

@b-mehta b-mehta 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.

Thanks!

bors merge

@ghost ghost added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Nov 23, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Nov 23, 2025
The same as `ZFSet.rank`, we define `ZFSet.card` as `ZFSet.{u} → Cardinal.{u}` and prove some basic properties.

Co-authored-by: Yaël Dillies <[email protected]>
@mathlib-bors

mathlib-bors Bot commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(SetTheory/ZFC): add ZFSet.card [Merged by Bors] - feat(SetTheory/ZFC): add ZFSet.card Nov 23, 2025
@mathlib-bors mathlib-bors Bot closed this Nov 23, 2025
alok added a commit to alok/mathlib4 that referenced this pull request Mar 17, 2026
…lib4

* 'master' of https://github.com/leanprover-community/mathlib4: (3130 commits)
  feat(SetTheory/ZFC): add `ZFSet.card` (leanprover-community#29365)
  feat: grind annotations for `choose_spec` (leanprover-community#31927)
  chore(scripts): update nolints.json (leanprover-community#31975)
  feat(Analysis): cos (n * π) = (-1) ^ n (leanprover-community#31971)
  chore: rename `mul_le_mul_right'` to `mul_le_mul_left` (leanprover-community#30242)
  chore: update Mathlib dependencies 2025-11-22 (leanprover-community#31955)
  feat(MeasureTheory): ae-measurability notation wrt non-standard sigma-algebra (leanprover-community#31910)
  doc: add missing spaces around doc code blocks (leanprover-community#31917)
  chore: update Mathlib dependencies 2025-11-22 (leanprover-community#31945)
  chore: shortcut instance for `Nat` to be mul-torsion-free (leanprover-community#31027)
  doc(Topology/Algebra/Algebra): outdated TODO (leanprover-community#31944)
  feat(EqHaar): add `addHaar_nnreal_smul` (leanprover-community#31922)
  chore(Algebra): make invertibleInv an instance (leanprover-community#31916)
  chore(Algebra): change two statements in CubicDiscriminant (leanprover-community#31912)
  chore(MeasureTheory): mark `map_dirac`  as simp (leanprover-community#31909)
  feat: `LinearOrder` instance for `Empty` (leanprover-community#31889)
  chore: deprecate all remaining modules in `Analysis/NormedSpace` (leanprover-community#31913)
  feat(SimpleGraph): weaker condition for paths in acyclic graphs (leanprover-community#25814)
  chore: do not set `group` when declaring option (leanprover-community#31888)
  chore: clean up more unused `Decidable*` instances in types (leanprover-community#31934)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-set-theory Set theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants