Skip to content

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

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

[Merged by Bors] - feat(SetTheory/ZFC): add ZFSet.card#29365
staroperator wants to merge 18 commits intoleanprover-community:masterfrom
staroperator:zfset_card

Conversation

@staroperator
Copy link
Copy Markdown
Collaborator

@staroperator staroperator commented Sep 5, 2025

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
Copy link
Copy Markdown

github-actions bot commented Sep 5, 2025

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).

Copy link
Copy Markdown
Collaborator

@vihdzp vihdzp left a comment

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

Copy link
Copy Markdown
Contributor

@YaelDillies YaelDillies left a comment

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.

@YaelDillies YaelDillies added the awaiting-author A reviewer has asked the author a question or requested changes. label Oct 4, 2025
@staroperator staroperator removed the awaiting-author A reviewer has asked the author a question or requested changes. 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
Collaborator

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
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
Copy link
Copy Markdown
Contributor

@YaelDillies YaelDillies Nov 4, 2025

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

Copy link
Copy Markdown
Collaborator Author

@staroperator staroperator Nov 5, 2025

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?

Copy link
Copy Markdown
Collaborator Author

@staroperator staroperator Nov 5, 2025

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.

@YaelDillies YaelDillies added the awaiting-author A reviewer has asked the author a question or requested changes. label Nov 4, 2025
@staroperator staroperator added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed awaiting-author A reviewer has asked the author a question or requested changes. 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
Collaborator

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
Collaborator

@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
Copy link
Copy Markdown
Contributor

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

Thanks!

maintainer delegate

@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 <yael.dillies@gmail.com>
Copy link
Copy Markdown
Contributor

@b-mehta b-mehta left a comment

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 <yael.dillies@gmail.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Nov 23, 2025

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