Skip to content

[Merged by Bors] - refactor(SetTheory/ZFC): make Class an abbrev for Set ZFSet - #43467

Closed
YaelDillies wants to merge 6 commits into
leanprover-community:masterfrom
YaelDillies:class_abbrev
Closed

YaelDillies wants to merge 6 commits into
leanprover-community:masterfrom
YaelDillies:class_abbrev

Conversation

@YaelDillies

@YaelDillies YaelDillies commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Also take the opportunity to perform a few more changes:

  • Rename Class to ZFClass
  • Rename the coercion from ZFSet to ZFClass to ofSet in lemma names, following the naming convention.

Some simp/norm_cast lemmas are becoming duplicates of lemmas about Set ZFSet in ZFC.Basic. We might want to drop the abbrev or move it earlier so as to deduplicate these lemmas, but this is out of scope for this PR.

Generated by Claude Sonnet/reviewed by myself in several prompts, then subsequently heavily rewritten by hand.

Assisted-by: Claude Sonnet 5


Open in Gitpod

@github-actions github-actions Bot added the tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

PR summary 0f1aa04e25

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ CMem
+ ZFClass
+ choice_cmem
+ classToCong
+ classToCong_empty
+ cmem_asymm
+ cmem_irrefl
+ cmem_of_cmem_sInter
+ cmem_sInter
+ cmem_sUnion
+ cmem_univ
+ coe
+ coe.inj
+ coe_cmem
+ coe_empty
+ coe_insert
+ coe_inter
+ coe_powerset
+ coe_sInter
+ coe_sUnion
+ coe_sdiff
+ coe_sep
+ coe_subset
+ coe_union
+ congToClass
+ congToClass_empty
+ eq_univ_of_powerset_subset
+ fval
+ instance : WellFoundedRelation ZFClass := ⟨(· ᶜ∈ ·), inferInstance⟩
+ iota
+ iota_ex
+ iota_val
+ isOrdinal_notCMem_univ
+ mem_powerset
+ mem_sInter
+ mem_sUnion
+ notCMem_empty
+ powerset
+ sInter
+ sInter_empty
+ sUnion
+ sUnion_empty
+ univ_notCMem_univ
+ wellFounded_cmem
+-+ fval_ex
- choice_mem
- isOrdinal_notMem_univ
- ofSet
- ofSet.inj

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

  • +50 new declarations
  • −5 removed declarations
+Class.coe
+Class.coe.inj
-Class.ofSet
-Class.ofSet.inj
-Class.«term_′_»
+ZFClass
+ZFClass.CMem
+ZFClass.classToCong
+ZFClass.classToCong_empty
+ZFClass.cmem_asymm
+ZFClass.cmem_irrefl
+ZFClass.cmem_of_cmem_sInter
+ZFClass.cmem_sInter
+ZFClass.cmem_sUnion
+ZFClass.cmem_univ
+ZFClass.coe_cmem
+ZFClass.coe_empty
+ZFClass.coe_insert
+ZFClass.coe_inter
+ZFClass.coe_powerset
+ZFClass.coe_sInter
+ZFClass.coe_sUnion
+ZFClass.coe_sdiff
+ZFClass.coe_sep
+ZFClass.coe_subset
+ZFClass.coe_union
+ZFClass.congToClass
+ZFClass.congToClass_empty
+ZFClass.eq_univ_of_powerset_subset
+ZFClass.fval
+ZFClass.fval_ex
+ZFClass.instWellFoundedRelation
+ZFClass.iota
+ZFClass.iota_ex
+ZFClass.iota_val
+ZFClass.mem_powerset
+ZFClass.mem_sInter
+ZFClass.mem_sUnion
+ZFClass.notCMem_empty
+ZFClass.powerset
+ZFClass.sInter
+ZFClass.sInter_empty
+ZFClass.sUnion
+ZFClass.sUnion_empty
+ZFClass.univ_notCMem_univ
+ZFClass.wellFounded_cmem
+ZFClass.«term_ᶜ∈_»
+ZFClass.«term_ᶜ∉_»
+ZFClass.«term_′_»
+ZFClass.«term⋂₀_»
+ZFClass.«term⋃₀_»
+ZFSet.choice_cmem
-ZFSet.choice_mem
+ZFSet.isOrdinal_notCMem_univ
-ZFSet.isOrdinal_notMem_univ

Decrease in strong tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type (strong)
2316 -1 backward.isDefEq.respectTransparency.types
419 -1 porting notes
No changes to weak technical debt.

Current commit 0f1aa04e25
Reference commit 5e0c4e5239

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

@github-actions github-actions Bot added the t-set-theory Set theory label Sep 5, 2026
@YaelDillies YaelDillies changed the title refactor(SetTheory/ZFC): make Class an abbrev for Set ZFC refactor(SetTheory/ZFC): make Class an abbrev for Set ZFSet Sep 5, 2026
@YaelDillies YaelDillies added the LLM-generated PRs with substantial input from LLMs - review accordingly label Sep 5, 2026
@vihdzp vihdzp self-assigned this Sep 7, 2026

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

It seems a bit silly that we sometimes spell Set ZFSet as ZFClass, and other times as Set ZFSet. Do we really need the separate ZFClass abbrev? Can we just deprecate this material and restate the few lemmas with content (i.e. Burali-Forti) as lemmas about Set ZFSet?

Comment thread Mathlib/SetTheory/ZFC/Class.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Class.lean Resolved
Comment thread Mathlib/SetTheory/ZFC/Class.lean Outdated
Comment on lines +273 to +284
@[simp, deprecated ZFClass.not_cmem_empty (since := "2026-09-05")]
theorem notMem_empty (x : Class.{u}) : x ∉ (∅ : Class.{u}) := fun ⟨_, _, h⟩ => h

@[simp]
@[simp, deprecated Set.notMem_empty (since := "2026-09-05")]
theorem not_empty_hom (x : ZFSet.{u}) : ¬(∅ : Class.{u}) x :=
id

@[simp]
@[simp, deprecated ZFClass.cmem_univ (since := "2026-09-05")]
theorem mem_univ {A : Class.{u}} : A ∈ univ.{u} ↔ ∃ x : ZFSet.{u}, ↑x = A :=
exists_congr fun _ => iff_of_eq (and_true _)

@[simp]
@[simp, deprecated Set.mem_univ (since := "2026-09-05")]

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.

These, and the other deprecated lemmas should not be simp. They trip up the SimpNF linter.

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.

I don't know where you got this from

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.

Well, if we make these lemmas simp, doesn't it make it so simp? starts suggesting them? That seems bad.

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.

Yes, but

  1. That has nothing to do with the simp nf linter. Are you sure you didn't misread the CI output?
  2. They are about deprecated declarations, so what's the issue? I am keeping them simp so that I don't need to change the deprecated proofs in this file.

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.

Then why not make them local simp?

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.

Although this would work here, it has the wrong semantics: What if the lemmas I was deprecating were spread across two files?

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.

Well, marking any deprecated lemma as simp definitely has wrong semantics.

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.

No, I don't see how: if the LHS of the simp lemma contains a deprecated declaration, it is guaranteed not to fire in code relying only on non-deprecated declarations and not using set_option linter.deprecated false.

Comment thread Mathlib/SetTheory/ZFC/Class.lean Resolved
@jcommelin jcommelin added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 7, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts 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 Sep 11, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@YaelDillies

Copy link
Copy Markdown
Contributor Author

It seems a bit silly that we sometimes spell Set ZFSet as ZFClass, and other times as Set ZFSet. Do we really need the separate ZFClass abbrev? Can we just deprecate this material and restate the few lemmas with content (i.e. Burali-Forti) as lemmas about Set ZFSet?

I have thought about this and I find myself in an uncomfortable position:

  1. On one hand, I am trying to land the huge refactor of making Set a one-field structure ([Merged by Bors] - refactor(Data): make Set a one-field structure #41506) in a timely fashion.
  2. On the other hand, I want to land prerequisites in properly, and you are opposing the simplest version of the refactor of ZFClass, which is one of them, and instead require me to perform a much bigger preliminary refactor.

Could the solution be that you refactor ZFClass yourself very rapidly?

@vihdzp

vihdzp commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

I can't really do things very rapidly at this moment, sorry. If we do decide to go in the direction I'm suggesting, I think this refactor would still be good intermediate work.

@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 Sep 19, 2026
@YaelDillies

Copy link
Copy Markdown
Contributor Author

Okay, let's worry about removing the abbrev later.

@YaelDillies YaelDillies removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 19, 2026

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

Should there be a recommended_spelling entry for the new ∈ᶜ notation? You use cmem, but wouldn't that fit with ᶜ∈, while ∈ᶜ reads as memc? Additionally, since we spell ∉ as notmem, I think ∉ᶜ should be one word, so notmemc or notcmem or cnotmem.

The docstring of ZFClass and CMem both explain the need for the ∉ᶜ notation (in different words). One of these can be dropped I think.

All of the theorem commands were changed to lemma. Is this intentional?

Comment thread Mathlib/SetTheory/ZFC/Class.lean Resolved
@[inherit_doc]
scoped prefix:110 "⋂₀ " => ZFClass.sInter

lemma coe_subset : (x : ZFClass.{u}) ⊆ y ↔ x ⊆ y := .rfl

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.

A bunch of these lemmas have lost their simp/norm_cast attribute. Is this intentional?

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.

Yes. As pointed out by Violeta in #43467 (comment), these lemmas are duplicates of lemmas about Set ZFSet in .Basic. As was decided above, I am not touching this further for the purpose of moving forward with the Set refactor.

@YaelDillies

Copy link
Copy Markdown
Contributor Author

Should there be a recommended_spelling entry for the new ∈ᶜ notation?

I don't see the point of a recommended_spelling for CMem: it is the name of the underlying declaration. I will add one for its negation, since indeed we call it notCMem, instead of not_cmem.

You use cmem, but wouldn't that fit with ᶜ∈, while ∈ᶜ reads as memc?

I chose CMem, not MemC, because between (x : ZFSet) ∈ (A : ZFClass) and (A : ZFClass) ∈ (B : ZFClass) it is the left argument that changes type, not the right. I will change the notation to ᶜ∈.

Additionally, since we spell ∉ as notmem, I think ∉ᶜ should be one word, so notmemc or notcmem or cnotmem.

No, we spell it notMem, which is why I have been using notCMem instead of notcmem.

The docstring of ZFClass and CMem both explain the need for the ∉ᶜ notation (in different words). One of these can be dropped I think.

Here sure it looks out of place in the docstring of ZFClass. But I disagree with the suggested principle that things should be documented in exactly one place.

All of the theorem commands were changed to lemma. Is this intentional?

Whoops, fixed.

@github-actions github-actions Bot added the increases-technical-debt Automatically added label for PRs which increase "strong" technical debts label Sep 23, 2026
@JovanGerb

Copy link
Copy Markdown
Contributor

There is still the lemma called not_cmem_empty instead of notCMem_empty

Also, it looks like there are still quite some lemmas that used to be theorems. (I don't necessarily mind, but it's good to be aware at least)

Also take the opportunity to perform a few more changes:
* Rename `Class` to `ZFClass`
* Rename the coercion from `ZFSet` to `ZFClass` to `ofSet` in lemma names, following the naming convention.

Generated by Claude Sonnet/reviewed by myself in several prompts.

Assisted-by: Claude Sonnet 5
@github-actions github-actions Bot removed the increases-technical-debt Automatically added label for PRs which increase "strong" technical debts label Sep 25, 2026
@JovanGerb

Copy link
Copy Markdown
Contributor

It's quite annoying with these force pushes that it's impossible to see what is actually being changed.

There are still a bunch of theorem that turned into lemma, and also one lemma that turned into theorem. And I can't tell whether you're aware of this (you don't write it in the PR description) or if it is just an LLM making random changes.

Comment thread Mathlib/SetTheory/ZFC/Class.lean Resolved
@YaelDillies

Copy link
Copy Markdown
Contributor Author

The force pushes have nothing to do with it. Nothing changes when I rebase except for eventual merge conflicts (which are usually trivial to resolve). I have now looked at the diff for a third time for this issue only and I can see no trace of theorems turning into lemmas (except if you're talking about the theorems that are being deprecated in favor of lemmas? That is not what I call a theorem turning into a lemma). The one lemma that turned into a theorem was me overreverting (by hand!) the actual theorems that were turning into lemmas a while ago. I do not use an LLM to do random changes, only to generate hard to automate lists of changes, and in particular I almost never use it to address reviewer feedback.

@JovanGerb

Copy link
Copy Markdown
Contributor

I was looking at the diff that appears when removing all the @[deprecated] declarations. Then the diff shows more clearly how the new declarations correspond to the old ones.

@YaelDillies

Copy link
Copy Markdown
Contributor Author

Cool. You are free to diff as you want, but the diff that ultimately matters is the one we see here on github (/the one git diff creates, which is only subtly different), and my opinion is and has always been that theorem should be reserved for named results in the literature (and I hope that one day we will have a linter that checks that every theorem has a docstring). Are you now happy with this PR?

@JovanGerb

Copy link
Copy Markdown
Contributor

maintainer merge

@github-actions

Copy link
Copy Markdown

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

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 29, 2026
Comment thread Mathlib/SetTheory/ZFC/Class.lean Resolved
@faenuccio

Copy link
Copy Markdown
Contributor

bors d+

@mathlib-bors

mathlib-bors Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

✌️ YaelDillies can now approve this pull request until 2026-10-14 17:51 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

⚠️ This delegation only covers changes within Archive/**, Counterexamples/**, docs/**, DownstreamTest/**, Mathlib/**, MathlibTest/**, Wanted/**, widget/**, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean, Wanted.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

@mathlib-bors mathlib-bors Bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Sep 30, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 30, 2026
@YaelDillies

Copy link
Copy Markdown
Contributor Author

bors merge

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Sep 30, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 30, 2026
…3467)

Also take the opportunity to perform a few more changes:
* Rename `Class` to `ZFClass`
* Rename the coercion from `ZFSet` to `ZFClass` to `ofSet` in lemma names, following the naming convention.

Some `simp`/`norm_cast` lemmas are becoming duplicates of lemmas about `Set ZFSet` in `ZFC.Basic`. We might want to drop the `abbrev` or move it earlier so as to deduplicate these lemmas, but this is out of scope for this PR.

Generated by Claude Sonnet/reviewed by myself in several prompts, then subsequently heavily rewritten by hand.

Assisted-by: Claude Sonnet 5
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Sep 30, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title refactor(SetTheory/ZFC): make Class an abbrev for Set ZFSet [Merged by Bors] - refactor(SetTheory/ZFC): make Class an abbrev for Set ZFSet Sep 30, 2026
@mathlib-bors mathlib-bors Bot closed this Sep 30, 2026
@mathlib-bors mathlib-bors Bot removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Sep 30, 2026
@YaelDillies
YaelDillies deleted the class_abbrev branch September 30, 2026 20:04
@JovanGerb

Copy link
Copy Markdown
Contributor

Just noting here that the duplicate declaration linter found some duplicates introduced by this PR:

ZFClass.coe_inter : ∀ (x y : ZFSet.{u}), ↑(x ∩ y) = ↑x ∩ ↑y
ZFSet.coe_inter : ∀ (x y : ZFSet.{u}), ↑(x ∩ y) = ↑x ∩ ↑y

ZFClass.coe_sep : ∀ (p : ZFSet.{u} → Prop) (x : ZFSet.{u}), ↑(ZFSet.sep p x) = {y | y ∈ x ∧ p y}
ZFSet.coe_sep : ∀ (a : ZFSet.{u_1}) (p : ZFSet.{u_1} → Prop), ↑(ZFSet.sep p a) = {x | x ∈ a ∧ p x}

ZFClass.coe_union : ∀ (x y : ZFSet.{u}), ↑(x ∪ y) = ↑x ∪ ↑y
ZFSet.coe_union : ∀ (x y : ZFSet.{u}), ↑(x ∪ y) = ↑x ∪ ↑y

ZFClass.coe_insert : ∀ (x y : ZFSet.{u}), ↑(insert x y) = insert x ↑y
ZFSet.coe_insert : ∀ (x y : ZFSet.{u_1}), ↑(insert x y) = insert x ↑y

ZFClass.coe_subset : ∀ {x y : ZFSet.{u}}, ↑x ⊆ ↑y ↔ x ⊆ y
ZFSet.coe_subset_coe : ∀ {x y : ZFSet.{u}}, ↑x ⊆ ↑y ↔ x ⊆ y

ZFClass.coe_sdiff : ∀ (x y : ZFSet.{u}), ↑(x \ y) = ↑x \ ↑y
ZFSet.coe_sdiff : ∀ (x y : ZFSet.{u}), ↑(x \ y) = ↑x \ ↑y

I'm not sure which is the "correct" version here.

@vihdzp

vihdzp commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

I think the correct versions are the ZFSet versions.
I've gone ahead and made the PR for you: #46089

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

Labels

bors-staging This PR is currently being built by bors on the staging branch. LLM-generated PRs with substantial input from LLMs - review accordingly ready-to-merge This PR has been sent to bors. t-set-theory Set theory tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants