Skip to content

refactor(Order): generalise the CompleteLattice instance on WithTop - #45250

Open
YaelDillies wants to merge 3 commits into
leanprover-community:masterfrom
YaelDillies:complete_lattice_with_top
Open

YaelDillies wants to merge 3 commits into
leanprover-community:masterfrom
YaelDillies:complete_lattice_with_top

Conversation

@YaelDillies

@YaelDillies YaelDillies commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Replace the CompleteLattice/CompleteLinearOrder instances on WithTop (WithBot α)/WithBot (WithTop α) by (the composition of) CompleteLattice/CompleteLinearOrder instances on WithTop α/WithBot α assuming OrderBot α/OrderTop α.

Also create some sections to organise the file and generalise and dualise some lemmas.


@YaelDillies YaelDillies added the t-order Order theory label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

PR summary 0f6278743b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ coe_biInf
+ coe_biSup
+ instCompleteLattice
+ instCompleteLinearOrder
+ instance : ConditionallyCompleteLattice (WithTop α)
+ instance : ConditionallyCompleteLinearOrder (WithTop α)
+ sSup_def
- WithBot.WithTop.completeLinearOrder
- WithBot.coe_biInf
- WithBot.coe_biSup
- WithTop.WithBot.completeLattice
- WithTop.conditionallyCompleteLattice
- completeLatticeOfCompleteSemilatticeSup
- completeLatticeOfSup
- instance : CompleteLinearOrder (WithTop α)
- instance [CompleteLattice α] : CompleteLattice (WithTop α)
- instance [CompleteLinearOrder α] : CompleteLinearOrder (WithBot α)
- instance [ConditionallyCompleteLinearOrder α] :

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 -- stale, waiting for the new build)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 7d68576).

  • +6 new declarations
  • −6 removed declarations
-WithBot.WithTop.completeLattice
-WithBot.WithTop.completeLinearOrder
+WithBot.completeLattice
+WithBot.sInf_def
-WithTop.WithBot.completeLattice
+WithTop.completeLattice
+WithTop.sSup_def
-instCompleteLatticeWithBot
-instCompleteLatticeWithTop
-instCompleteLinearOrderWithBot
+instCompleteLinearOrderWithBotOfOrderTop
+instCompleteLinearOrderWithTopOfOrderBot

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

Current commit 0f6278743b
Reference commit 3e03553901

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

@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 Nov 3, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@YaelDillies
YaelDillies force-pushed the complete_lattice_with_top branch from c622eeb to 5d6e224 Compare November 5, 2026 09:53
@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 5, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Nov 14, 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 Nov 18, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@YaelDillies
YaelDillies force-pushed the complete_lattice_with_top branch from 5d6e224 to c29ff9f Compare November 18, 2026 13:54
@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 18, 2026
@YaelDillies
YaelDillies force-pushed the complete_lattice_with_top branch from c29ff9f to 0c4a05d Compare November 22, 2026 12:49
@Komyyy

Komyyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thank you! I'm reviewing...

@Komyyy Komyyy 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'm thinking about how to remove s.Nonempty assumptions elegantly, but I've run into Mathlib's structural issues about conditionally complete lattices, and sorting them out is taking time.

In the meantime, I've left minor style reviews.

@YaelDillies

Copy link
Copy Markdown
Contributor Author

Re structural issues, are you aware of #35674?

@Komyyy

Komyyy commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Oh, thank you to tell me about it!

After #35674 is merged, s.Nonempty assumptions can be dropped!

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

Could you make #35674 dependend PR of this PR?

After it was marged, s.Nonempty assumptions can be dropped like this:

@[to_dual]
theorem sSup_eq_coe_iff {α} [PartialOrder α] [OrderSupSet α] {s : Set (WithTop α)} {a : α} :
    sSup s = a ↔ ⊤ ∉ s ∧ BddAbove ((↑) ⁻¹' s : Set α) ∧ sSup ((↑) ⁻¹' s) = a := by
  obtain rfl | hs := eq_empty_or_nonempty s
  · obtain _ | _ := botOrderOrNoBotOrder α
    · simp
    · simp [sSup_def]
  · exact sSup_eq_coe_iff_of_nonempty hs

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

Copy link
Copy Markdown
Contributor Author

I don't think it is a good idea to unnecessarily linearise PRs. Here, #35674 and #45250 can land in any order, and whichever of the two PRs isn't merged first can drop the s.Nonempty assumptions. No need to block where it's non-blocking 😁

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

Copy link
Copy Markdown
Collaborator

Do we still need to change the definition of SupSet (WithTop α) after #35674?

@YaelDillies

Copy link
Copy Markdown
Contributor Author

The current definition is simply wrong when α has a minimal element and sSup (\empty : Set α) is not that minimal element. Are you saying that the point is the SupSet (WithTop α) instance shouldn't bother fixing wrong suprema of sets lying in α since it is the job of the SupSet α instance instead? Sounds reasonable. I've marked this PR as depending on #35674.

@mathlib-dependent-issues mathlib-dependent-issues Bot added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Nov 28, 2026
@mathlib-dependent-issues

mathlib-dependent-issues Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Dec 2, 2026

attribute [to_dual existing] LinearOrder.toMax

to_dual_for LinearOrder.le_total := self.le_total b a

@JovanGerb JovanGerb Dec 2, 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.

The idea behind not dualizing LinearOrder.le_total was that you're supposed to always use _root_.le_total. What do you think?

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 think anything. I've added this to_dual_for solely because it is necessary to dualise the CompleteLinearOrder instances in #45250.

This branch has not been deployed

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

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants