Skip to content

chore(ConditionallyCompleteLattice/Indexed): dualize#38938

Open
lua-vr wants to merge 3 commits into
leanprover-community:masterfrom
lua-vr:dualize-indexed
Open

chore(ConditionallyCompleteLattice/Indexed): dualize#38938
lua-vr wants to merge 3 commits into
leanprover-community:masterfrom
lua-vr:dualize-indexed

Conversation

@lua-vr

@lua-vr lua-vr commented May 4, 2026

Copy link
Copy Markdown
Contributor

Open in Gitpod

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

PR summary e19202a082

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ WithTop.coe_biInf
+ WithTop.coe_biSup
- BddBelow.range_iInf_of_iUnion_range
- IsGLB.ciInf_eq
- IsGLB.ciInf_set_eq
- Set.Ici_ciSup
- WithBot.coe_iInf
- WithBot.coe_iSup
- WithBot.coe_sInf'
- WithBot.coe_sSup'
- WithBot.instInfSet
- WithBot.instSupSet
- WithBot.sSup_empty
- cbiInf_eq_ciInf_subtype
- cbiInf_eq_of_not_forall
- cbiInf_id
- cbiInf_of_not_bddBelow
- ciInf_and
- ciInf_eq_bot_of_bot_mem
- ciInf_eq_of_forall_ge_of_forall_gt_exists_lt
- ciInf_eq_univ_of_not_bddBelow
- ciInf_image
- ciInf_inf_eq
- ciInf_inf_le
- ciInf_le
- ciInf_le_of_le
- ciInf_lt_iff
- ciInf_mono
- ciInf_mono_of_forall_exists
- ciInf_of_not_bddBelow
- ciInf_prod
- ciInf_set_le
- ciInf_subtype
- ciInf_subtype_fun
- ciInf₂_le
- csInf_eq_csInf_of_forall_exists_le
- csInf_eq_of_forall_ge_of_forall_gt_exists_lt
- csInf_eq_univ_of_not_bddBelow
- csInf_image
- csInf_lt_iff
- csInf_lt_of_lt
- csInf_of_not_bddBelow
- csSup_eq_top_of_top_mem
- exists_lt_of_ciInf_lt
- exists_lt_of_csInf_lt
- isGLB_ciInf
- isGLB_ciInf_set
- le_ciInf
- le_ciInf_exists
- le_ciInf_iff
- le_ciInf_set_iff
- map_ciInf
- map_ciInf_set
- map_csInf
- map_csInf'
- u_ciInf
- u_ciInf_set
- u_csInf
- u_csInf'

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.


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

Current commit e19202a082
Reference commit 72a044471f

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

@github-actions github-actions Bot added the t-order Order theory label May 4, 2026
theorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=
if_pos <| by simp

@[to_dual (attr := norm_cast)]

@lua-vr lua-vr May 4, 2026

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.

Was there a particular reason for the WithTop ones to not have norm_cast? With this PR, both versions get tagged for norm_cast

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.

Yes, this is probably an oversight. I'm not sure that this is actually a good norm_cast lemma. can you try removing the tag? If something breaks as a result, then we'll know why we need the norm_cast tag.

@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 May 4, 2026
@lua-vr lua-vr force-pushed the dualize-indexed branch 3 times, most recently from 4ff10ea to 7590793 Compare May 6, 2026 14:25

@[deprecated (since := "2026-04-05")] alias ciInf_eq_top_of_top_mem := ciSup_eq_top_of_top_mem

variable [WellFoundedLT α]

@lua-vr lua-vr May 6, 2026

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.

Dual theorems for WellFoundedLT did not get added because the chain of @[to_dual]s to add eventually leads to the WellFounded structure, which does not have a dual. And similarly for ConditionallyCompleteOrderBot

@lua-vr lua-vr marked this pull request as ready for review May 6, 2026 17:11
@lua-vr lua-vr force-pushed the dualize-indexed branch from d9165c9 to 0aa2584 Compare May 6, 2026 17:19
@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 May 11, 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 May 13, 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 May 15, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@lua-vr lua-vr force-pushed the dualize-indexed branch from b317858 to 9a752ae Compare May 18, 2026 11:55
@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 May 18, 2026
@lua-vr lua-vr force-pushed the dualize-indexed branch from 9a752ae to 5518032 Compare May 18, 2026 14:37
@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 May 23, 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 May 30, 2026
@JovanGerb

Copy link
Copy Markdown
Contributor

Why does this PR depend on the other PR? Can't this be a standalone PR?

@lua-vr lua-vr force-pushed the dualize-indexed branch 2 times, most recently from c23b520 to b86c675 Compare May 31, 2026 11:26
@lua-vr lua-vr marked this pull request as draft May 31, 2026 11:30
@mathlib-bors

mathlib-bors Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in draft mode. No active bors state needed cleanup.

While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like bors r+ or bors try.

@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label May 31, 2026
@lua-vr lua-vr force-pushed the dualize-indexed branch from b86c675 to 271a91c Compare May 31, 2026 11:36
@lua-vr lua-vr marked this pull request as ready for review May 31, 2026 11:52

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

Thanks for making this PR! With to_dual PRs, it is best to try to dualize all of the declarations in the files that you are dualizing, because otherwise, we will run into missing to_dual tags in the future. Doing so will make this PR even bigger, so you could maybe split it into a PR doing Basic.lean, and a subsequent one doing Indexed.lean.


open Classical in
@[to_dual]
noncomputable instance WithTop.instSupSet [SupSet α] :

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.

Suggested change
noncomputable instance WithTop.instSupSet [SupSet α] :
noncomputable instance [SupSet α] :

Can you put the first part of the file inside a namespace WithTop? Then you can also omit the name of the instance altogether.

That does require dualizing all of the declarations in the section.

InfSet (WithBot α) :=
⟨(WithTop.instSupSet (α := αᵒᵈ)).sSup⟩

theorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)

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.

Is there a reason not to tag this with to_dual?

theorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=
if_pos <| by simp

@[to_dual (attr := norm_cast)]

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.

Yes, this is probably an oversight. I'm not sure that this is actually a good norm_cast lemma. can you try removing the tag? If something breaks as a result, then we'll know why we need the norm_cast tag.

by_cases BddAbove (s ∪ t) <;>
grind [csSup_union, bddAbove_union, csSup_of_not_bddAbove]

lemma sSup_iUnion_Iic (f : ι → α) : sSup (⋃ (i : ι), Iic (f i)) = ⨆ i, f i := by

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 dualize this too?

Comment on lines +239 to +242
@[to_dual csInf_eq_of_forall_ge_of_forall_gt_exists_lt /-- Introduction rule to prove that `b` is
the infimum of `s`: it suffices to check that `b` is smaller than all elements of `s`, and that this
is not the case of any `w>b`. See `sInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in
complete lattices. -/]

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.

Suggested change
@[to_dual csInf_eq_of_forall_ge_of_forall_gt_exists_lt /-- Introduction rule to prove that `b` is
the infimum of `s`: it suffices to check that `b` is smaller than all elements of `s`, and that this
is not the case of any `w>b`. See `sInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in
complete lattices. -/]
@[to_dual csInf_eq_of_forall_ge_of_forall_gt_exists_lt
/-- Introduction rule to prove that `b` is the infimum of `s`: it suffices to check that `b`
is smaller than all elements of `s`, and that this is not the case of any `w>b`.
See `sInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in complete lattices. -/]

I prefer starting the dual comment on a new line if it takes multiple lines, so that it aligns nicely with original comment. This makes it easier to edit both, and to ensure that they actually align. Similarly below

@lua-vr

lua-vr commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@JovanGerb Thank you for your comments! This makes sense, I will try to split it for Basic first.

@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 Jun 5, 2026
@JovanGerb

Copy link
Copy Markdown
Contributor

@lua-vr, have you made the new PR already?

@lua-vr

lua-vr commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@JovanGerb no, not yet. Feel free to add awaiting-author.

@JovanGerb

Copy link
Copy Markdown
Contributor

I have now created #41558 for using to_dual in Basic

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

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants