Skip to content

[Merged by Bors] - refactor(Order/CompleteLatticeIntervals): redefine sSup and sInf - #37082

Closed
astrainfinita wants to merge 8 commits into
leanprover-community:masterfrom
astrainfinita:interval_bot
Closed

astrainfinita wants to merge 8 commits into
leanprover-community:masterfrom
astrainfinita:interval_bot

Conversation

@astrainfinita

@astrainfinita astrainfinita commented Mar 24, 2026 •

Copy link
Copy Markdown
Collaborator

This PR introduces OrderSupSet.chooseBot and OrderInfSet.chooseTop. Unlike OrderSupSet.choose d, which returns d whenever a least upper bound does not exist, OrderSupSet.chooseBot d returns the bottom element in this case, and d only if there is no bottom element either. Thus it satisfies the requirements of ConditionallyCompleteLinearOrder on junk values.

The ConditionallyCompleteLinearOrder instance on OrdConnected sets is redefined using them, and the new instance satisfies OrderSupSet and OrderInfSet. This is needed for #35674.


Open in Gitpod

…or `sSup` and `sInf`

In a subsequent PR, some assumptions will be added to `ordConnectedSubsetConditionallyCompleteLinearOrderOfBotTop`.
@github-actions

github-actions Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

PR summary 83ba96b6b6

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ OrderSupSet.chooseBot
+ OrderSupSet.chooseBot_sSup_empty_of_noBotOrder
+ OrderSupSet.chooseBot_sSup_of_not_exists
+ Set.OrdConnected.coe_sInf
+ Set.OrdConnected.coe_sSup
+ Set.OrdConnected.conditionallyCompleteLinearOrder
+ Set.OrdConnected.csInf_image_mem
+ Set.OrdConnected.csSup_image_mem
+ Set.OrdConnected.sInf_empty_of_noTopOrder
+ Set.OrdConnected.sSup_empty_of_noBotOrder
+ Subtype.isLUB_of_csSup_image_mem
- ordConnectedSubsetConditionallyCompleteLinearOrder

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

  • +17 new declarations
  • −1 removed declarations
+OrderInfSet.chooseTop
+OrderInfSet.chooseTop_sInf_empty_of_noTopOrder
+OrderInfSet.chooseTop_sInf_of_not_exists
+OrderInfSet.choose_sInf
+OrderSupSet.chooseBot
+OrderSupSet.chooseBot_sSup_empty_of_noBotOrder
+OrderSupSet.chooseBot_sSup_of_not_exists
+OrderSupSet.choose_sSup
+Set.OrdConnected.coe_sInf
+Set.OrdConnected.coe_sSup
+Set.OrdConnected.conditionallyCompleteLinearOrder
+Set.OrdConnected.csInf_image_mem
+Set.OrdConnected.csSup_image_mem
+Set.OrdConnected.sInf_empty_of_noTopOrder
+Set.OrdConnected.sSup_empty_of_noBotOrder
+Subtype.isGLB_of_csInf_image_mem
+Subtype.isLUB_of_csSup_image_mem
-ordConnectedSubsetConditionallyCompleteLinearOrder

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

Current commit 83ba96b6b6
Reference commit 40d045ae49

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

@bryangingechen

Copy link
Copy Markdown
Contributor

Can you explain the motivation for this more in the PR comment?

@YaelDillies

YaelDillies commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

As discussed on Zulip, could we instead make SupSet be Prop-valued?

@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Mar 27, 2026
@astrainfinita

Copy link
Copy Markdown
Collaborator Author

Currently, the lemmas for Set, Filter, Setoid, SimpleGraph, etc., all rely on defeq. Also, we need to prove the existence of LUBs in any case, so I lean towards a step-by-step approach. Given that some of the code has already been refactored using IsLUB and IsGLB, I can give it another try.

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

Copy link
Copy Markdown
Collaborator Author

Removed awaiting-author, see Zulip.

@astrainfinita astrainfinita added awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. and removed awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there labels Apr 20, 2026
@YaelDillies

Copy link
Copy Markdown
Contributor

Is this supposed to be awaiting-author? Will a refactor make sSup not data anymore?

@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@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 Jul 8, 2026
@YaelDillies
YaelDillies removed their request for review July 8, 2026 23:23
@astrainfinita astrainfinita changed the title chore(Order/CompleteLatticeIntervals): use different default values for sSup and sInf chore(Order/CompleteLatticeIntervals): redefine sSup and sInf Oct 26, 2026
@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 Oct 26, 2026
@astrainfinita astrainfinita removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 26, 2026
@astrainfinita astrainfinita changed the title chore(Order/CompleteLatticeIntervals): redefine sSup and sInf refactor(Order/CompleteLatticeIntervals): redefine sSup and sInf Oct 26, 2026

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

Are subsetSupSet/subsetInfSet even useful now?

Comment thread Mathlib/Order/Bounds/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 27, 2026
@astrainfinita astrainfinita removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 27, 2026
rintro - ⟨y, -, rfl⟩
exact y.2
exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm
· exact @Set.OrdConnected.coe_sSup ℝ (Set.Ici 0) _ (_) _ s hs H

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.

Can you explain this use of @? Same below

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.

The instance for NNReal is defined using the one for Nonneg, which in turn uses Set.OrdConnected.conditionallyCompleteLinearOrder. @ was already used in these proofs.

I haven't thought through how best to handle this. Perhaps we should take an injective function as an argument instead of working directly with sets. That seems orthogonal to this PR.

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.

Oh, is the issue that NNReal is semireducible?

@astrainfinita astrainfinita Oct 28, 2026 •

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.

It might also be because the lemma takes an Inhabited instance parameter, while Nonneg.conditionallyCompleteLinearOrder introduces one locally.

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 tried making Inhabited s an implicit parameter, and that removed the need for @, but it might not be the right fix.

@YaelDillies YaelDillies Oct 28, 2026 •

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.

Oh nice! But yeah let's punt this to a later PR

Comment thread Mathlib/Order/Bounds/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 27, 2026
@astrainfinita astrainfinita removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 27, 2026
Comment thread Mathlib/Order/Bounds/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 28, 2026
@astrainfinita astrainfinita removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 28, 2026

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

@YaelDillies YaelDillies removed their assignment Oct 28, 2026
@github-actions

Copy link
Copy Markdown

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

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Oct 28, 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.

I agree that putting the deprecations at the bottom is a bit confusing, but otherwise LGTM.

@bryangingechen

Copy link
Copy Markdown
Contributor

Thanks!
bors r+

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Nov 3, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Nov 3, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Nov 3, 2026
…37082)

This PR introduces `OrderSupSet.chooseBot` and `OrderInfSet.chooseTop`. Unlike `OrderSupSet.choose d`, which returns `d` whenever a least upper bound does not exist, `OrderSupSet.chooseBot d` returns the bottom element in this case, and `d` only if there is no bottom element either. Thus it satisfies the requirements of  `ConditionallyCompleteLinearOrder` on junk values.

The `ConditionallyCompleteLinearOrder` instance on `OrdConnected` sets is redefined using them, and the new instance satisfies `OrderSupSet` and `OrderInfSet`. This is needed for #35674.
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Nov 3, 2026
@mathlib-bors

mathlib-bors Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title refactor(Order/CompleteLatticeIntervals): redefine sSup and sInf [Merged by Bors] - refactor(Order/CompleteLatticeIntervals): redefine sSup and sInf Nov 3, 2026
@mathlib-bors mathlib-bors Bot closed this Nov 3, 2026
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. ready-to-merge This PR has been sent to bors. t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants