Skip to content

[Merged by Bors] - refactor(Logic/Relation): move inclusion lemmas out of EqvGen - #43643

Closed
Sanghyeok0 wants to merge 14 commits into
leanprover-community:masterfrom
Sanghyeok0:relation-eqvgen-namespace
Closed

Sanghyeok0 wants to merge 14 commits into
leanprover-community:masterfrom
Sanghyeok0:relation-eqvgen-namespace

Conversation

@Sanghyeok0

@Sanghyeok0 Sanghyeok0 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

This refactor was split out from #40368 following the review discussion there.

Following further review, I moved all lemmas from the Relation.EqvGen namespace to Relation, except for is_equivalence, setoid, and mono, which retain their original names.

The old names are preserved as deprecated aliases for backward compatibility. I also updated the reference in Mathlib/Order/JordanHolder.lean to use Relation.eqvGen_le instead of the deprecated name.

Changes:

  • Relation.EqvGen.eqvGen_le → Relation.eqvGen_le
  • Relation.EqvGen.eqvGen_mono → Relation.eqvGen_mono
  • Relation.EqvGen.reflGen_le_eqvGen → Relation.reflGen_le_eqvGen
  • Relation.EqvGen.symmGen_le_eqvGen → Relation.symmGen_le_eqvGen
  • Relation.EqvGen.transGen_le_eqvGen → Relation.transGen_le_eqvGen
  • Relation.EqvGen.reflTransGen_le_eqvGen → Relation.reflTransGen_le_eqvGen
  • Relation.EqvGen.eqvGen_reflGen → Relation.eqvGen_reflGen
  • Relation.EqvGen.eqvGen_transGen → Relation.eqvGen_transGen
  • Relation.EqvGen.eqvGen_symmGen → Relation.eqvGen_symmGen
  • Relation.EqvGen.eqvGen_reflTransGen → Relation.eqvGen_reflTransGen
  • Relation.EqvGen.eqvGen_eq_reflTransGen → Relation.eqvGen_eq_reflTransGen
  • Relation.EqvGen.reflTransGen_symmGen → Relation.reflTransGen_symmGen

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 Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

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 Zulip and join the Lean community.
Thank you again for joining our community.

@github-actions github-actions Bot added the t-logic Logic (model theory, etc) label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

PR summary 8b1ca9c5f0

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ EqvGen.equivalence
+ EqvGen.eqvGen_eq_reflTransGen
+ EqvGen.eqvGen_le
+ EqvGen.eqvGen_mono
+ EqvGen.eqvGen_reflGen
+ EqvGen.eqvGen_reflTransGen
+ EqvGen.eqvGen_symmGen
+ EqvGen.eqvGen_transGen
+ EqvGen.is_equivalence
+ EqvGen.mono
+ EqvGen.reflGen_le_eqvGen
+ EqvGen.reflTransGen_le_eqvGen
+ EqvGen.reflTransGen_symmGen
+ EqvGen.setoid
+ EqvGen.symmGen_le_eqvGen
+ EqvGen.transGen_le_eqvGen
+ instance : IsEquiv α (EqvGen r) := EqvGen.equivalence _ |>.isEquiv
- eqvGen_mono
- instance : IsEquiv α (EqvGen r) := is_equivalence _ |>.isEquiv
- is_equivalence
- mono
- setoid

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

  • +13 new declarations
  • −1 removed declarations
+Relation.EqvGen.equivalence
-Relation.EqvGen.instIsEquiv
+Relation.eqvGen_eq_reflTransGen
+Relation.eqvGen_le
+Relation.eqvGen_reflGen
+Relation.eqvGen_reflTransGen
+Relation.eqvGen_symmGen
+Relation.eqvGen_transGen
+Relation.instIsEquivEqvGen
+Relation.reflGen_le_eqvGen
+Relation.reflTransGen_le_eqvGen
+Relation.reflTransGen_symmGen
+Relation.symmGen_le_eqvGen
+Relation.transGen_le_eqvGen

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

Current commit 8b1ca9c5f0
Reference commit b5d0cc06b3

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/Logic/Relation.lean Outdated
lemma reflGen_le_eqvGen : ReflGen r ≤ EqvGen r
end EqvGen

lemma reflGen_le_eqvGen (r : α → α → Prop) : ReflGen r ≤ EqvGen r

@themathqueen themathqueen Sep 15, 2026 •

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.

Another option rather than closing and reopening the namespace is to name these _root_.Relation.reflGen_le_eqvGen

(but what you have is okay for now, I think)

Comment thread Mathlib/Logic/Relation.lean Resolved
@themathqueen themathqueen added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 15, 2026
@Sanghyeok0

Copy link
Copy Markdown
Contributor Author

-awaiting-author

Thanks for the review. I’ve applied the protected change.

I kept the current namespace structure because the _root_.Relation... notation is a little less readable for me.

@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 Sep 17, 2026
Comment thread Mathlib/Logic/Relation.lean Resolved
Comment thread Mathlib/Logic/Relation.lean Resolved
Comment thread Mathlib/Logic/Relation.lean Resolved

@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 just want to note that in a lot of cases _root_. is preferable, especially when there are variables involved. You don't want to be introducing the same variables 3 times just to avoid doing _root_.. I guess here is fine because you're just making the variable explicit and not introducing anything.

Anyway,

maintainer merge

@github-actions

Copy link
Copy Markdown

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

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 22, 2026
@Sanghyeok0

Copy link
Copy Markdown
Contributor Author

I just want to note that in a lot of cases _root_. is preferable, especially when there are variables involved. You don't want to be introducing the same variables 3 times just to avoid doing _root_.. I guess here is fine because you're just making the variable explicit and not introducing anything.

Anyway,

maintainer merge

I see. I'll try using _root_. in cases like this in the future.

Thanks for all the reviews. I've learned a lot from them.

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

I appreciate what you're trying to do here, but I think it doesn't make much sense. To be clear, I agree with removing the EqvGen namespace from these, but there are a bunch of lemmas surrounding this which could also have that namespace removed. So it doesn't make sense that we're only doing these few.

In fact, in this namespace EqvGen section, I think the only things that should actually be in that namespace are is_equivalence, setoid and mono. It should just be a section EqvGen and those three shoul dbe prefixed with EqvGen.

@j-loreaux j-loreaux added awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Oct 6, 2026
@Sanghyeok0

Copy link
Copy Markdown
Contributor Author

I appreciate what you're trying to do here, but I think it doesn't make much sense. To be clear, I agree with removing the EqvGen namespace from these, but there are a bunch of lemmas surrounding this which could also have that namespace removed. So it doesn't make sense that we're only doing these few.

In fact, in this namespace EqvGen section, I think the only things that should actually be in that namespace are is_equivalence, setoid and mono. It should just be a section EqvGen and those three shoul dbe prefixed with EqvGen.

Sorry for the very late response. I've incorporated your feedback and updated the code so that only is_equivalence, setoid, and mono remain in the EqvGen namespace, while all the other lemmas are now in the Relation namespace. I've also updated the reference in JordanHolder.lean to use the new name. Thank you for your suggestions!

By the way, it seems that we no longer need both EqvGen.mono and eqvGen_mono, since they now state the same result. What do you think?

-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 15, 2026
Comment thread Mathlib/Logic/Relation.lean Outdated
Comment on lines 838 to 842
lemma eqvGen_mono {r r' : α → α → Prop} (h : r ≤ r') : EqvGen r ≤ EqvGen r'
| _, _, .refl _ => .refl _
| _, _, .symm _ _ hxy => .symm _ _ (eqvGen_mono h _ _ hxy)
| _, _, .trans _ _ _ hxy hyz => .trans _ _ _ (eqvGen_mono h _ _ hxy) (eqvGen_mono h _ _ hyz)
| _, _, .rel _ _ hab => .rel _ _ (h _ _ hab)

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.

right, one of these should go and be deprecated
I don't know which is nicer eqvGen_mono or EqvGen.mono

Comment thread Mathlib/Logic/Relation.lean Outdated
variable (r)

theorem is_equivalence : Equivalence (@EqvGen α r) :=
theorem EqvGen.is_equivalence : Equivalence (@EqvGen α r) :=

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.

this name should also maybe change to EqvGen.equivalence instead of is_equivalence?

Comment thread Mathlib/Logic/Relation.lean Resolved
@themathqueen themathqueen added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 15, 2026
@Sanghyeok0

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestions! I kept EqvGen.mono for consistency with ReflGen.mono, TransGen.mono, and ReflTransGen.mono, and removed the duplicate eqvGen_mono proof. The old name EqvGen.eqvGen_mono is preserved as a deprecated alias.

I also renamed EqvGen.is_equivalence to EqvGen.equivalence, keeping the old name as a deprecated alias.

-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 24, 2026

@j-loreaux j-loreaux 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

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Nov 17, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Nov 17, 2026
This refactor was split out from #40368 following the review discussion there.

Following further review, I moved all lemmas from the `Relation.EqvGen` namespace to `Relation`, except for `is_equivalence`, `setoid`, and `mono`, which retain their original names.

The old names are preserved as deprecated aliases for backward compatibility. I also updated the reference in `Mathlib/Order/JordanHolder.lean` to use `Relation.eqvGen_le` instead of the deprecated name.

**Changes:**

* `Relation.EqvGen.eqvGen_le` → `Relation.eqvGen_le`
* `Relation.EqvGen.eqvGen_mono` → `Relation.eqvGen_mono`
* `Relation.EqvGen.reflGen_le_eqvGen` → `Relation.reflGen_le_eqvGen`
* `Relation.EqvGen.symmGen_le_eqvGen` → `Relation.symmGen_le_eqvGen`
* `Relation.EqvGen.transGen_le_eqvGen` → `Relation.transGen_le_eqvGen`
* `Relation.EqvGen.reflTransGen_le_eqvGen` → `Relation.reflTransGen_le_eqvGen`
* `Relation.EqvGen.eqvGen_reflGen` → `Relation.eqvGen_reflGen`
* `Relation.EqvGen.eqvGen_transGen` → `Relation.eqvGen_transGen`
* `Relation.EqvGen.eqvGen_symmGen` → `Relation.eqvGen_symmGen`
* `Relation.EqvGen.eqvGen_reflTransGen` → `Relation.eqvGen_reflTransGen`
* `Relation.EqvGen.eqvGen_eq_reflTransGen` → `Relation.eqvGen_eq_reflTransGen`
* `Relation.EqvGen.reflTransGen_symmGen` → `Relation.reflTransGen_symmGen`

Co-authored-by: unknown <[email protected]>
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Nov 17, 2026
@mathlib-bors

mathlib-bors Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title refactor(Logic/Relation): move inclusion lemmas out of EqvGen [Merged by Bors] - refactor(Logic/Relation): move inclusion lemmas out of EqvGen Nov 17, 2026
@mathlib-bors mathlib-bors Bot closed this Nov 17, 2026
jkatz2 pushed a commit to jkatz2/my_cslib that referenced this pull request Nov 19, 2026
Bumps Mathlib to
[83e85ad](leanprover-community/mathlib4@83e85ad)
and adapts to [breaking
changes](https://leanprover.zulipchat.com/#narrow/channel/536994-ecosystem-infrastructure/topic/downstream-lean4.20breakages/near/641600658).

[Mathlib
#43643](leanprover-community/mathlib4#43643)
moved the `EqvGen` inclusion lemmas into the `Relation` namespace, so
Mathlib now has its own `Relation.reflTransGen_symmGen`. Here, we remove
that theorem but keep its `simp` and `scoped grind =` attributes.

Also, fix some deprecated and updated names from Mathlib.

Supersedes leanprover#1226.
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. new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! ready-to-merge This PR has been sent to bors. t-logic Logic (model theory, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants