Skip to content

chore: use @[to_dual] in ConditionallyCompleteLattice - #35212

Closed
kim-em wants to merge 21 commits into
leanprover-community:masterfrom
kim-em:kim/to-dual-ccl-basic
Closed

kim-em wants to merge 21 commits into
leanprover-community:masterfrom
kim-em:kim/to-dual-ccl-basic

Conversation

@kim-em

@kim-em kim-em commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds @[to_dual existing] annotations in ConditionallyCompleteLattice/Defs and @[to_dual] annotations to primal theorems in ConditionallyCompleteLattice/Basic, auto-generating their dual counterparts and deleting the hand-written versions.

Diff relative to previous PR

🤖 Prepared with Claude Code

kim-em and others added 2 commits February 12, 2026 21:53
This enables @[to_dual] to automatically translate between
atom/coatom and lfp/gfp theorem names, preparing for expanded
@[to_dual] coverage in subsequent commits.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add @[to_dual] to IsLUB.insert, isLUB_pair, IsLeast.unique,
IsLeast.isLeast_iff_eq, and IsLUB.unique, auto-generating
their duals instead of maintaining hand-written copies.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions

github-actions Bot commented Feb 12, 2026 •

Copy link
Copy Markdown

PR summary 3efa02168f

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+-+- mem_upperBounds_image
- Antitone.map_iSup_le
- Antitone.map_iSup₂_le
- BddAbove.bddBelow_image2_of_bddAbove
- BddAbove.image2_bddBelow
- BddBelow.bddBelow_image2_of_bddAbove
- BddBelow.image2
- BddBelow.insert
- BddBelow.range_comp
- Equiv.biInf_comp
- Equiv.iInf_comp
- Equiv.iInf_congr
- Function.Surjective.iInf_comp
- Function.Surjective.iInf_congr
- IsCoinitialFor.image_of_antitone
- IsCoinitialFor.image_of_monotone
- IsGLB.csInf_eq
- IsGLB.iInf_eq
- IsGLB.insert
- IsGLB.nonempty
- IsGLB.prod
- IsGLB.unique
- IsGreatest.isGreatest_iff_eq
- IsGreatest.isLeast_image2
- IsGreatest.isLeast_image2_of_isLeast
- IsGreatest.unique
- IsLUB.of_image
- IsLeast.csInf_eq
- IsLeast.csInf_mem
- IsLeast.image2
- IsLeast.insert
- IsLeast.isLeast_image2_of_isGreatest
- Monotone.map_iInf_le
- Monotone.map_iInf₂_le
- MonotoneOn.csSup_eq_of_subset_of_forall_exists_le
- NoBotOrder.lowerBounds_univ
- OrderBot.bddBelow
- OrderBot.lowerBounds_univ
- OrderIso.map_iInf
- OrderIso.map_iInf₂
- OrderIso.map_sInf
- OrderIso.map_sInf_eq_sInf_symm_preimage
- Set.BijOn.iInf_comp
- Set.BijOn.iInf_congr
- bddAbove_iff_subset_Iic
- bddBelow_empty
- bddBelow_insert
- bddBelow_pi
- bddBelow_prod
- bddBelow_range_pi
- bddBelow_range_prod
- biInf_congr
- biInf_congr'
- biInf_const
- biInf_inf
- biInf_le
- biInf_lt_iff
- biInf_mono
- biInf_prod
- biInf_prod'
- biSup_inf_le_biSup_inf
- biSup_inf_le_inf_biSup
- ciInf_eq_univ_of_not_bddBelow
- ciInf_of_not_bddBelow
- 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_le
- csInf_insert
- csInf_le
- csInf_le_csInf
- csInf_le_iff
- csInf_le_of_le
- csInf_lt_of_lt
- csInf_of_not_bddBelow
- csInf_pair
- csInf_singleton
- csInf_union
- csInf_upperBounds_eq_csSup
- csInf_upperBounds_range
- eq_singleton_top_of_sInf_eq_top_of_nonempty
- exists_lt_of_csInf_lt
- iInf_and
- iInf_and'
- iInf_biUnion
- iInf_bool_eq
- iInf_comm
- iInf_congr
- iInf_congr_Prop
- iInf_const
- iInf_dite
- iInf_emptyset
- iInf_eq_dif
- iInf_eq_iInf_finset
- iInf_eq_iInf_finset'
- iInf_eq_if
- iInf_eq_of_forall_ge_of_forall_gt_exists_lt
- iInf_eq_top
- iInf_exists
- iInf_extend_top
- iInf_false
- iInf_ge_eq_iInf_nat_add
- iInf_iInf_eq_left
- iInf_iInf_eq_right
- iInf_iUnion
- iInf_image
- iInf_image2
- iInf_inf
- iInf_inf_eq
- iInf_insert_update
- iInf_ite
- iInf_le
- iInf_le_iInf_of_subset
- iInf_le_iInf₂
- iInf_le_of_le
- iInf_lt_iff
- iInf_lt_top
- iInf_mono
- iInf_mono'
- iInf_nat_gt_zero_eq
- iInf_ne_top_subtype
- iInf_neg
- iInf_of_empty
- iInf_option
- iInf_option_elim
- iInf_option_toFinset
- iInf_or
- iInf_pair
- iInf_plift_down
- iInf_plift_up
- iInf_pos
- iInf_prod
- iInf_prod'
- iInf_psigma
- iInf_psigma'
- iInf_range
- iInf_range'
- iInf_sUnion
- iInf_sigma
- iInf_sigma'
- iInf_split
- iInf_split_single
- iInf_subtype
- iInf_subtype'
- iInf_subtype''
- iInf_sum
- iInf_sup_iInf_le
- iInf_top
- iInf_true
- iInf_ulift
- iInf_unique
- iInf_univ
- iInf₂_comm
- iInf₂_eq_top
- iInf₂_le
- iInf₂_le_of_le
- iInf₂_mono
- iInf₂_mono'
- iSup_inf_le_iSup_inf
- iSup_inf_le_inf_iSup
- iSup_inf_le_inf_sSup
- iSup_inf_le_sSup_inf
- image2_lowerBounds_lowerBounds_subset
- image2_lowerBounds_lowerBounds_subset_lowerBounds_image2
- image2_lowerBounds_upperBounds_subset_lowerBounds_image2
- image2_upperBounds_lowerBounds_subset_lowerBounds_image2
- inf_biInf
- inf_eq_iInf
- inf_iInf
- inf_iInf_nat_succ
- isGLB_biInf
- isGLB_csInf
- isGLB_iInf
- isGLB_lt_iff
- isGLB_pair
- isGLB_pi
- isGLB_prod
- isGLB_univ
- isGLB_upperBounds
- isLUB_empty
- isLUB_empty_iff
- isLeast_pair
- isLeast_univ
- isLeast_univ_iff
- le_csInf
- le_csInf_iff
- le_csInf_image
- le_csInf_inter
- le_iInf
- le_iInf_comp
- le_iInf_const
- le_iInf_iff
- le_iInf₂
- le_iInf₂_iff
- le_sInf_inter
- lowerBounds_empty
- lowerBounds_insert
- lowerBounds_prod
- lt_iInf_iff
- lt_isGLB_iff
- mem_lowerBounds_image2
- mem_lowerBounds_image2_of_mem_lowerBounds_of_mem_lowerBounds
- mem_lowerBounds_image2_of_mem_lowerBounds_of_mem_upperBounds
- mem_lowerBounds_image2_of_mem_upperBounds
- nonempty_iInter_Ici_iff
- nonempty_of_not_bddBelow
- notMem_of_csSup_lt
- not_bddBelow_univ
- sInf_diff_singleton_top
- sInf_eq_iInf
- sInf_eq_iInf'
- sInf_eq_of_forall_ge_of_forall_gt_exists_lt
- sInf_iUnion_Ici
- sInf_image
- sInf_image'
- sInf_image2
- sInf_insert
- sInf_le_sInf_of_isCoinitialFor
- sInf_le_sInf_of_subset_insert_top
- sInf_pair
- sInf_range
- sInf_sUnion
- sInf_union
- sInf_upperBounds_eq_sSup
-++--- map_isGreatest
-- iInf_insert
-- iInf_singleton
-- iInf_union
-- image_lowerBounds_subset_lowerBounds_image
-- image_upperBounds_subset_lowerBounds_image
-- map_isLeast
-- mem_lowerBounds_image_self
---- map_bddBelow
---- mem_lowerBounds_image

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


Decrease in tech debt: (relative, absolute) = (2.00, 0.00)
Current number Change Type
492 -2 porting notes

Current commit a9fae26090
Reference commit 3efa02168f

You can run this locally as

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

Add @[to_dual] to 15 more theorems in Order.Bounds.Basic,
auto-generating their duals instead of maintaining hand-written copies.

Covers univ, empty set, bounds, and lt_iff sections.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@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 Feb 12, 2026
@mathlib-dependent-issues

mathlib-dependent-issues Bot commented Feb 12, 2026 •

Copy link
Copy Markdown

This PR/issue depends on:

@kim-em
kim-em marked this pull request as draft February 12, 2026 22:58
kim-em and others added 4 commits February 12, 2026 23:00
Add @[to_dual] to 7 more theorems: bddBelow_iff_subset_Ici,
IsGreatest.insert, upperBounds_insert, OrderTop.bddAbove,
isGreatest_pair, upperBounds_prod, and IsLUB.prod.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
These don't enable any new @[to_dual] annotations in Bounds.Basic
(the Heyting pairs have type class issues), but prepare the dictionary
for use elsewhere.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@kim-em
kim-em force-pushed the kim/to-dual-ccl-basic branch 4 times, most recently from 289247c to 046d6a5 Compare February 13, 2026 00:02
@kim-em
kim-em marked this pull request as ready for review February 13, 2026 00:08
@kim-em
kim-em force-pushed the kim/to-dual-ccl-basic branch 2 times, most recently from 483f2b5 to 8760618 Compare February 13, 2026 03:50
kim-em and others added 11 commits February 13, 2026 03:51
Add @[to_dual existing] to sInf_lt_iff and @[to_dual] to
lt_iSup_iff and lt_biSup_iff, auto-generating iInf_lt_iff and
biInf_lt_iff.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add ~100 @[to_dual] annotations to primal theorems in
Order.CompleteLattice.Basic and delete corresponding hand-written
dual theorems. The `@[to_dual]` attribute auto-generates the dual
versions by term-level translation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add @[to_dual] to 10 primal theorems (iSup_bool_eq, sup_eq_iSup,
iSup_nat_gt_zero_eq, and distributivity lemmas) and delete
hand-written duals.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add @[to_dual] to 8 primal theorems (iSup_eq_iSup_finset,
iSup_singleton, iSup_union, iSup_insert, etc.) and delete
hand-written duals.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add @[to_dual] to iSup_iUnion, sSup_iUnion, sSup_sUnion,
iSup_sUnion and delete hand-written duals.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add `@[to_dual]` to:
- `iSup_ge_eq_iSup_nat_add` (generates `iInf_ge_eq_iInf_nat_add`)
- `sup_iSup_nat_succ` (generates `inf_iInf_nat_succ`, explicit name needed
  due to `succ`→`Pred` name dictionary collision)
- `nonempty_iInter_Iic_iff` (generates `nonempty_iInter_Ici_iff`)

Add TODO comments for pairs that can't use `@[to_dual]`:
- `Monotone.iSup_nat_add`/`Antitone.iInf_nat_add` (Monotone/Antitone not
  in name dictionary)
- `iSup_iInf_ge_nat_add`/`iInf_iSup_ge_nat_add` (same reason)
- `iSup_finset_image`/`iInf_finset_image` (iSup_coe/iInf_coe not
  registered duals)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Register dual mappings for ConditionallyCompleteLattice and
ConditionallyCompleteLinearOrder fields.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add @[to_dual] to ~40 primal theorems across MonotoneOn, AntitoneOn,
Monotone, Antitone, and image2 sections. Delete hand-written duals.
Antitone proofs rewritten to be self-contained (not via dual_right).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
kim-em and others added 3 commits February 13, 2026 03:52
Add `@[to_dual]` to `IsGLB.of_image` (generates `IsLUB.of_image`).

Add TODO comment for `BddAbove.range_mono`/`BddBelow.range_mono`
(different explicit/implicit parameter structure prevents conversion).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add @[to_dual] to ~25 primal theorems (le_csSup, csSup_le,
csSup_singleton, csSup_union, csSup_insert, etc.) and delete
hand-written duals. Register existing dual pairs with
attribute [to_dual existing].

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add `@[to_dual]` to:
- `Monotone.le_csSup_image` (generates `Monotone.csInf_image_le`)
- `Monotone.csSup_image_le` (generates `Monotone.le_csInf_image`)
- `MonotoneOn.csInf_eq_of_subset_of_forall_exists_le`
  (generates `MonotoneOn.csSup_eq_of_subset_of_forall_exists_le`)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@kim-em
kim-em force-pushed the kim/to-dual-ccl-basic branch from 8760618 to a9fae26 Compare February 13, 2026 03:53
@kim-em

kim-em commented Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

Merged into #35213 to reduce the PR chain depth.

@kim-em kim-em closed this Feb 13, 2026
@kim-em
kim-em deleted the kim/to-dual-ccl-basic branch February 13, 2026 04:20
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant