Skip to content

refactor: make WithTop and WithBot inductive types - #46043

Open
EtienneC30 wants to merge 47 commits into
leanprover-community:masterfrom
EtienneC30:withtop
Open

EtienneC30 wants to merge 47 commits into
leanprover-community:masterfrom
EtienneC30:withtop

Conversation

@EtienneC30

@EtienneC30 EtienneC30 commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Some points to notice:

  • The order on WithZero given by WithZero.le is defined through defeq with WithBot, which no longer holds. Thus this PR also makes WithZero an inductive type and transfers the order through an equivalence passing through Option.
  • In Mathlib.Order.Hom.WithTopBot file, I can't make the lemmas generated by simps! for withTop' and withBot' dual to each other, while they are currently. I don't really understand what is going on.

Declarations deleted without deprecation:

Zulip thread: https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Identity.20equivalence.20between.20WithTop.2FWithBot.20and.20Option/with/639616431


@github-actions github-actions Bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

PR summary 18b2ca4412

Import changes exceeding 2%

% File
+3.48% Mathlib.Algebra.Group.WithOne.Defs
+3.47% Mathlib.Algebra.Group.WithOne.Map
+11.36% Mathlib.Algebra.Order.Monoid.Unbundled.WithTop
+5.74% Mathlib.Data.List.MinMax
+6.13% Mathlib.Order.Hom.WithTopBot
+7.24% Mathlib.Order.Sum.Order
+13.17% Mathlib.Order.WithBot

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Order.WithBot 281 318 +37 (+13.17%)
Mathlib.Algebra.Order.Monoid.Unbundled.WithTop 317 353 +36 (+11.36%)
Mathlib.Order.Sum.Order 304 326 +22 (+7.24%)
Mathlib.Order.Hom.WithTopBot 310 329 +19 (+6.13%)
Mathlib.Data.List.MinMax 453 479 +26 (+5.74%)
Mathlib.Algebra.Group.WithOne.Defs 402 416 +14 (+3.48%)
Mathlib.Algebra.Group.WithOne.Map 404 418 +14 (+3.47%)
Mathlib.Order.Set 316 319 +3 (+0.95%)
Mathlib.Data.Fintype.WithTopBot 628 631 +3 (+0.48%)
Mathlib.Algebra.Group.WithOne.Basic 427 429 +2 (+0.47%)
Mathlib.Algebra.GroupWithZero.WithZero 497 498 +1 (+0.20%)
Mathlib.Algebra.GroupWithZero.Range 840 841 +1 (+0.12%)
Import changes for all files
Files Import difference
134 files Mathlib.Algebra.Algebra.Basic Mathlib.Algebra.Algebra.Bilinear Mathlib.Algebra.Algebra.Equiv Mathlib.Algebra.Algebra.FunLike Mathlib.Algebra.Algebra.Hom.Rat Mathlib.Algebra.Algebra.Hom Mathlib.Algebra.Algebra.IsSimpleRing Mathlib.Algebra.Algebra.NonUnitalHom Mathlib.Algebra.Algebra.NonUnitalSubalgebra Mathlib.Algebra.Algebra.Opposite Mathlib.Algebra.Algebra.Pi Mathlib.Algebra.Algebra.Prod Mathlib.Algebra.Algebra.RestrictScalars Mathlib.Algebra.Algebra.Shrink Mathlib.Algebra.Algebra.Subalgebra.Basic Mathlib.Algebra.Algebra.Subalgebra.Order Mathlib.Algebra.Algebra.Tower Mathlib.Algebra.Algebra.TransferInstance Mathlib.Algebra.Algebra.Unitization Mathlib.Algebra.Category.Grp.ZModuleEquivalence Mathlib.Algebra.Category.GrpWithZero Mathlib.Algebra.Category.ModuleCat.Algebra Mathlib.Algebra.Category.ModuleCat.Basic Mathlib.Algebra.Category.ModuleCat.Monoidal.Basic Mathlib.Algebra.Category.ModuleCat.Monoidal.Closed Mathlib.Algebra.Category.ModuleCat.Monoidal.Symmetric Mathlib.Algebra.Category.ModuleCat.Semi Mathlib.Algebra.Category.ModuleCat.Tannaka Mathlib.Algebra.Category.MonCat.Adjunctions Mathlib.Algebra.Colimit.DirectLimit Mathlib.Algebra.Field.Subfield.Basic Mathlib.Algebra.GroupWithZero.Action.Basic Mathlib.Algebra.GroupWithZero.Action.Pointwise.Finset Mathlib.Algebra.GroupWithZero.Action.Pointwise.Set Mathlib.Algebra.GroupWithZero.ProdHom Mathlib.Algebra.GroupWithZero.Prod Mathlib.Algebra.GroupWithZero.Range Mathlib.Algebra.GroupWithZero.Subgroup Mathlib.Algebra.GroupWithZero.Submonoid.Pointwise Mathlib.Algebra.GroupWithZero.WithZero Mathlib.Algebra.Lie.Basic Mathlib.Algebra.Lie.NonUnitalNonAssocAlgebra Mathlib.Algebra.Lie.TransferInstance Mathlib.Algebra.Module.Equiv.Basic Mathlib.Algebra.Module.Submodule.Bilinear Mathlib.Algebra.Module.Submodule.Invariant Mathlib.Algebra.Module.Submodule.Pointwise Mathlib.Algebra.NonAssoc.LieAdmissible.Defs Mathlib.Algebra.Order.Kleene Mathlib.Algebra.Order.Module.Equiv Mathlib.Algebra.Order.Ring.Ordering.Defs Mathlib.Algebra.Order.Ring.Prod Mathlib.Algebra.Order.Star.Prod Mathlib.Algebra.Order.Star.Unitization Mathlib.Algebra.Ring.Action.End Mathlib.Algebra.Ring.Action.Group Mathlib.Algebra.Ring.Action.Pointwise.Finset Mathlib.Algebra.Ring.Action.Pointwise.Set Mathlib.Algebra.Ring.AddAut Mathlib.Algebra.Ring.CentroidHom Mathlib.Algebra.Ring.Prod Mathlib.Algebra.Ring.Semireal.Defs Mathlib.Algebra.Ring.Subgroup Mathlib.Algebra.Ring.Subring.Basic Mathlib.Algebra.Ring.Subring.MulOpposite Mathlib.Algebra.Ring.Subring.Pointwise Mathlib.Algebra.Ring.Subring.Units Mathlib.Algebra.Ring.Subsemiring.Basic Mathlib.Algebra.Ring.Subsemiring.MulOpposite Mathlib.Algebra.Ring.Subsemiring.Pointwise Mathlib.Algebra.Ring.Subsemiring.Support Mathlib.Algebra.Ring.SumsOfSquares Mathlib.Algebra.Ring.WithZero Mathlib.Algebra.Star.CentroidHom Mathlib.Algebra.Star.Module Mathlib.Algebra.Star.NonUnitalSubalgebra Mathlib.Algebra.Star.NonUnitalSubsemiring Mathlib.Algebra.Star.Prod Mathlib.Algebra.Star.StarAlgHom Mathlib.Algebra.Star.Subsemiring Mathlib.Algebra.Star.TensorProduct Mathlib.CategoryTheory.Action.Continuous Mathlib.CategoryTheory.Adjunction.Additive Mathlib.CategoryTheory.Generator.Abelian Mathlib.CategoryTheory.Generator.Preadditive Mathlib.CategoryTheory.Limits.ConcreteCategory.WithAlgebraicStructures Mathlib.CategoryTheory.Linear.Yoneda Mathlib.CategoryTheory.Preadditive.Yoneda.Basic Mathlib.Computability.ContextFreeGrammar Mathlib.Computability.Language Mathlib.Computability.RegularExpressions Mathlib.Data.Set.Pointwise.Support Mathlib.Data.Set.Semiring Mathlib.Dynamics.Minimal Mathlib.Dynamics.Transitive Mathlib.FieldTheory.Galois.Notation Mathlib.GroupTheory.Divisible Mathlib.LinearAlgebra.BilinearForm.Basic Mathlib.LinearAlgebra.GeneralLinearGroup.Basic Mathlib.LinearAlgebra.LinearPMap Mathlib.LinearAlgebra.Prod Mathlib.LinearAlgebra.Span.Basic Mathlib.LinearAlgebra.TensorProduct.Associator Mathlib.LinearAlgebra.TensorProduct.Basic Mathlib.LinearAlgebra.TensorProduct.Defs Mathlib.LinearAlgebra.TensorProduct.Lift Mathlib.LinearAlgebra.TensorProduct.Map Mathlib.LinearAlgebra.TensorProduct.Prod Mathlib.LinearAlgebra.TensorProduct.Tower Mathlib.RingTheory.Congruence.Basic Mathlib.RingTheory.Congruence.Opposite Mathlib.RingTheory.LocalRing.Subring Mathlib.RingTheory.NonUnitalSubring.Basic Mathlib.RingTheory.NonUnitalSubsemiring.Basic Mathlib.RingTheory.SimpleRing.Basic Mathlib.RingTheory.SimpleRing.Congr Mathlib.RingTheory.SimpleRing.Defs Mathlib.RingTheory.SimpleRing.Field Mathlib.RingTheory.TwoSidedIdeal.Basic Mathlib.RingTheory.TwoSidedIdeal.Instances Mathlib.RingTheory.TwoSidedIdeal.Kernel Mathlib.RingTheory.TwoSidedIdeal.Lattice Mathlib.RingTheory.TwoSidedIdeal.Operations Mathlib.Tactic.Algebra.AlgebraNF Mathlib.Tactic.Algebra.Basic Mathlib.Tactic.Algebraize Mathlib.Topology.Algebra.Algebra.Rat Mathlib.Topology.Algebra.ConstMulAction Mathlib.Topology.Algebra.MulAction Mathlib.Topology.Algebra.Order.Module Mathlib.Topology.Algebra.ProperConstSMul Mathlib.Topology.Baire.Absorbent Mathlib.Topology.Bornology.Absorbs Mathlib.Topology.Covering.Deck
1
Mathlib.Algebra.FreeMonoid.FreeSemigroup Mathlib.Algebra.Group.WithOne.Basic 2
Mathlib.Data.Fintype.WithTopBot Mathlib.Order.Set 3
Mathlib.Algebra.Group.WithOne.Defs Mathlib.Algebra.Group.WithOne.Map 14
Mathlib.Order.Hom.WithTopBot 19
4 files Mathlib.Data.Sum.Lattice Mathlib.Data.Sum.Order Mathlib.Order.Sum.Lattice Mathlib.Order.Sum.Order
22
Mathlib.Data.List.MinMax 26
8 files Mathlib.Algebra.Order.AddGroupWithTop Mathlib.Algebra.Order.Monoid.Unbundled.WithTop Mathlib.Algebra.Order.Monoid.WithTop Mathlib.Algebra.Order.PUnit Mathlib.Algebra.Order.Sub.WithTop Mathlib.Data.ENat.Basic Mathlib.Data.Nat.Cast.WithTop Mathlib.Data.Nat.WithBot
36
Mathlib.Order.WithBotTop Mathlib.Order.WithBot 37

Declarations diff (regex)

+ Topology.IsInducing.weakEMetricSpace
+ WithBot.isOpenEmbedding_some
+ WithTop
+ WithZero
+ _root_.Equiv.withOneCongr
+ _root_.WithBot.addLECancellable_coe
+ _root_.WithBot.addLECancellable_iff_ne_bot
+ _root_.WithBot.addLECancellable_of_lt_bot
+ _root_.WithBot.addLECancellable_of_ne_bot
+ _root_.WithBot.bot_lt_one
+ _root_.WithBot.bot_lt_zero
+ _root_.WithBot.coe_le_one
+ _root_.WithBot.coe_lt_one
+ _root_.WithBot.one_le_coe
+ _root_.WithBot.one_lt_coe
+ bot_eq_bot
+ compl_range_coe
+ eq_some_iff
+ instance (priority := 10) instLT : LT (WithZero α)
+ instance (priority := 10) le : LE (WithZero α)
+ instance : Bot (WithBot α)
+ instance : Fintype Two := .ofEquiv _ (WithZero.toOption Unit).symm
+ instance : NatCast (WithTop α)
+ instance [Fintype α] : Fintype (WithTop α) := .ofEquiv _ (WithTop.toOption α).symm
+ instance [IsEmpty α] : Subsingleton (WithOne α) := (toOption α).subsingleton
+ instance [IsEmpty α] : Unique (WithBot α) := (toOption α).unique
+ instance _root_.WithBot.addLeftMono [LE α] [AddLeftMono α] : AddLeftMono (WithBot α)
+ instance _root_.WithBot.addLeftReflectLT [LT α] [AddLeftReflectLT α] :
+ instance _root_.WithBot.addRightMono [LE α] [AddRightMono α] : AddRightMono (WithBot α)
+ instance _root_.WithBot.addRightReflectLT [LT α] [AddRightReflectLT α] :
+ instance _root_.WithBot.zeroLEOneClass [Zero α] [LE α] [ZeroLEOneClass α] :
+ isCompl_range_coe_bot
+ le_def'
+ lt_def'
+ map_eq_comp_comp
+ map_id
+ map₂_eq_one_iff
+ map₂_eq_some_iff
+ map₂_one_left
+ map₂_one_right
+ ne_bot_iff_exists'
+ nonsingularPointEquivSubtype_symm_zero
+ nonsingularPointEquiv_symm_zero
+ pointEquivSubtype_symm_zero
+ pointEquiv_symm_zero
+ range_eq
+ some_eq_ofNNReal
+ symm_toOption_eq_bot_iff
+ symm_toOption_eq_one_iff
+ toDual_truncatedInf
+ toDual_truncatedSup
+ toOption_apply_one
+ toWithBotOrderIso
+ top_eq_top
+ untopD_natCast
+ untopD_ofNat
+ unzero_le_iff
+ withBotWithTop'
++ map₂_assoc
++ map₂_comm
++ map₂_eq_comp_comp
++ map₂_left_identity
++ map₂_right_identity
++ symm_toOption_apply_none
++ symm_toOption_apply_some
++ symm_toOption_comp_some
++ symm_toOption_eq_coe_iff
++ toOption
++ toOption_apply_bot
++ toOption_apply_coe
++ toOption_comp_coe
++ toOption_eq_none_iff
++ toOption_eq_some_iff
++-- coe_inj
++-- map₂
+-+ map_map
+-+- coe_injective
- WithBot.range_eq
- WithTop.range_eq
- _root_.AddHom.withBotMap
- _root_.AddMonoidHom.withBotMap
- _root_.IsAddLeftRegular.withBot
- _root_.IsAddRightRegular.withBot
- _root_.OneHom.withBotMap
- add
- addCommMonoid
- addCommMonoidWithOne
- addCommSemigroup
- addHom
- addLECancellable_coe
- addLECancellable_iff_ne_bot
- addLECancellable_of_lt_bot
- addLECancellable_of_ne_bot
- addLeftMono
- addLeftReflectLT
- addMonoid
- addMonoidWithOne
- addRightMono
- addRightReflectLT
- addSemigroup
- addZeroClass
- add_bot
- add_coe_eq_bot_iff
- add_eq_bot
- add_eq_coe
- add_le_add_iff_left
- add_le_add_iff_right
- add_left_cancel
- add_left_inj
- add_lt_add_iff_left
- add_lt_add_iff_right
- add_lt_add_left
- add_lt_add_of_le_of_lt
- add_lt_add_of_lt_of_le
- add_lt_add_right
- add_ne_bot
- add_right_cancel
- add_right_inj
- bot
- bot_add
- bot_lt_add
- bot_lt_natCast
- bot_lt_one
- bot_ne_natCast
- bot_ne_ofNat
- bot_ne_one
- charZero
- coe_add
- coe_addHom
- coe_add_eq_bot_iff
- coe_eq_one
- coe_le_one
- coe_lt_one
- coe_mul_eq_bind
- coe_natCast
- coe_nsmul
- coe_one
- inf'_biUnion
- inf'_image₂_left
- inf'_image₂_right
- instMonad
- instance (priority := 10) instLT : LT (WithZero α) := inferInstanceAs <| LT (WithBot α)
- instance (priority := 10) le : LE (WithZero α) := inferInstanceAs <| LE (WithBot α)
- instance : Fintype Two
- instance : NatCast (WithBot α) where natCast n := (n : α)
- instance [Fintype α] : Fintype (WithTop α)
- instance [IsEmpty α] : Subsingleton (WithOne α)
- instance [IsEmpty α] : Unique (WithBot α)
- le_of_add_le_add_left
- le_of_add_le_add_right
- map_add
- map_eq_natCast_iff
- map_eq_ofNat_iff
- map_eq_one_iff
- mul_coe_eq_bind
- natCast
- natCast_eq_map_iff
- natCast_ne_bot
- ofNat_eq_map_iff
- ofNat_ne_bot
- one
- one_eq_coe
- one_eq_map_iff
- one_le_coe
- one_lt_coe
- one_ne_bot
- optionSome_eq_some
- some
- unbotD_natCast
- unbotD_ofNat
- unbotD_one
- unbot_le_iff
- unbot_one
- zeroLEOneClass
-+- coe_eq_ofNat
-+- coe_ofNat
-+- map_natCast
-+- map_ofNat
-+- ofNat_eq_coe
-+-+ map
--+ some_eq_coe

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

  • +237 new declarations
  • −14 removed declarations

(showing first 200 of 251 lines)

+BoxIntegral.Box.eq_some_iff
+ENNReal.some_eq_ofNNReal
+ENNReal.top_eq_top
+Equiv.withOneCongr
+Equiv.withZeroCongr
+Finset.toDual_truncatedInf
+Finset.toDual_truncatedSup
-Inclusion.IntervalInt.binarySplitMap.match_4.congr_eq_1
-Inclusion.IntervalInt.binarySplitMap.match_4.congr_eq_2
+Inclusion.IntervalInt.binarySplitMap.match_5.congr_eq_1
+Inclusion.IntervalInt.binarySplitMap.match_5.congr_eq_2
+InfHom.withBot'.match_1.congr_eq_1
+InfHom.withBot'.match_1.congr_eq_2
+InfHom.withTop'.match_1.congr_eq_1
+InfHom.withTop'.match_1.congr_eq_2
+SupHom.withBot'.match_1.congr_eq_1
+SupHom.withBot'.match_1.congr_eq_2
+SupHom.withTop'.match_1.congr_eq_1
+SupHom.withTop'.match_1.congr_eq_2
+Topology.IsInducing.weakEMetricSpace
+WeierstrassCurve.Affine.nonsingularPointEquivSubtype_symm_zero
+WeierstrassCurve.Affine.nonsingularPointEquiv_symm_zero
+WeierstrassCurve.Affine.pointEquivSubtype_symm_zero
+WeierstrassCurve.Affine.pointEquiv_symm_zero
+WithBot.addMonoid.match_1.congr_eq_1
+WithBot.addMonoid.match_1.congr_eq_2
+WithBot.addMonoid.match_1.congr_eq_3
+WithBot.add_lt_add
+WithBot.bot.elim
+WithBot.bot.sizeOf_spec
+WithBot.bot_eq_bot
+WithBot.bot_lt_zero
+WithBot.casesOn
-WithBot.coe_mul_eq_bind
+WithBot.coe_ne_one
+WithBot.coe_ne_zero
+WithBot.compl_range_coe
+WithBot.ctorElim
+WithBot.ctorElimType
+WithBot.ctorIdx
+WithBot.instBot
+WithBot.isCompl_range_coe_bot
+WithBot.map_eq_comp_comp
+WithBot.map₂_assoc
+WithBot.map₂_comm
+WithBot.map₂_eq_comp_comp
+WithBot.map₂_eq_some_iff
+WithBot.map₂_left_identity
+WithBot.map₂_right_identity
-WithBot.mul_coe_eq_bind
+WithBot.ne_bot_iff_exists'
+WithBot.noConfusion
+WithBot.noConfusionType
+WithBot.ofDual.match_1.congr_eq_1
+WithBot.ofDual.match_1.congr_eq_2
+WithBot.ofDual.match_3.congr_eq_1
+WithBot.ofDual.match_3.congr_eq_2
-WithBot.optionSome_eq_some
+WithBot.rec
+WithBot.recOn
+WithBot.some.elim
+WithBot.some.inj
+WithBot.some.injEq
+WithBot.some.noConfusion
+WithBot.some.sizeOf_spec
-WithBot.some_eq_coe
+WithBot.symm_toOption_apply_none
+WithBot.symm_toOption_apply_some
+WithBot.symm_toOption_comp_some
+WithBot.symm_toOption_eq_bot_iff
+WithBot.symm_toOption_eq_coe_iff
+WithBot.toDual.match_1.congr_eq_1
+WithBot.toDual.match_1.congr_eq_2
+WithBot.toOption
+WithBot.toOption.match_1.congr_eq_1
+WithBot.toOption.match_1.congr_eq_2
+WithBot.toOption.match_3.congr_eq_1
+WithBot.toOption.match_3.congr_eq_2
+WithBot.toOption_apply_bot
+WithBot.toOption_apply_coe
+WithBot.toOption_comp_coe
+WithBot.toOption_eq_none_iff
+WithBot.toOption_eq_some_iff
+WithOne.casesOn
+WithOne.ctorElim
+WithOne.ctorElimType
+WithOne.ctorIdx
-WithOne.instMonad
+WithOne.instMul.match_1.congr_eq_1
+WithOne.instMul.match_1.congr_eq_2
+WithOne.instMul.match_1.congr_eq_3
+WithOne.instMul.match_1.congr_eq_4
+WithOne.map.match_1.congr_eq_1
+WithOne.map.match_1.congr_eq_2
+WithOne.map_id
+WithOne.map_map
+WithOne.map_one
+WithOne.map₂.eq_def
+WithOne.map₂.match_1.congr_eq_1
+WithOne.map₂.match_1.congr_eq_2
+WithOne.map₂.match_1.congr_eq_3
+WithOne.map₂_assoc
+WithOne.map₂_comm
+WithOne.map₂_eq_comp_comp
+WithOne.map₂_eq_one_iff
+WithOne.map₂_left_identity
+WithOne.map₂_one_left
+WithOne.map₂_one_right
+WithOne.map₂_right_identity
+WithOne.noConfusion
+WithOne.noConfusionType
+WithOne.one
+WithOne.one.elim
+WithOne.one.sizeOf_spec
+WithOne.rec
+WithOne.recOn
+WithOne.some
+WithOne.some.elim
+WithOne.some.inj
+WithOne.some.injEq
+WithOne.some.noConfusion
+WithOne.some.sizeOf_spec
+WithOne.symm_toOption_apply_none
+WithOne.symm_toOption_apply_some
+WithOne.symm_toOption_comp_some
+WithOne.symm_toOption_eq_coe_iff
+WithOne.symm_toOption_eq_one_iff
+WithOne.toOption
+WithOne.toOption.match_1.congr_eq_1
+WithOne.toOption.match_1.congr_eq_2
+WithOne.toOption_apply_bot
+WithOne.toOption_apply_coe
+WithOne.toOption_apply_one
+WithOne.toOption_comp_coe
+WithOne.toOption_eq_none_iff
+WithOne.toOption_eq_some_iff
+WithTop.addMonoid.match_1.congr_eq_1
+WithTop.addMonoid.match_1.congr_eq_2
+WithTop.addMonoid.match_1.congr_eq_3
+WithTop.casesOn
-WithTop.coe_mul_eq_bind
+WithTop.compl_range_coe
+WithTop.ctorElim
+WithTop.ctorElimType
+WithTop.ctorIdx
+WithTop.instNatCast
+WithTop.instTop
+WithTop.isCompl_range_coe_top
+WithTop.map_eq_comp_comp
+WithTop.map₂_assoc
+WithTop.map₂_comm
+WithTop.map₂_eq_comp_comp
+WithTop.map₂_eq_some_iff
+WithTop.map₂_left_identity
+WithTop.map₂_right_identity
-WithTop.mul_coe_eq_bind
-WithTop.natCast
+WithTop.ne_top_iff_exists'
+WithTop.noConfusion
+WithTop.noConfusionType
+WithTop.ofDual.match_1.congr_eq_1
+WithTop.ofDual.match_1.congr_eq_2
+WithTop.ofDual.match_3.congr_eq_1
+WithTop.ofDual.match_3.congr_eq_2
-WithTop.optionSome_eq_some
+WithTop.rec
+WithTop.recOn
+WithTop.some.elim
+WithTop.some.inj
+WithTop.some.injEq
+WithTop.some.noConfusion
+WithTop.some.sizeOf_spec
-WithTop.some_eq_coe
+WithTop.symm_toOption_apply_none
+WithTop.symm_toOption_apply_some
+WithTop.symm_toOption_comp_some
+WithTop.symm_toOption_eq_coe_iff
+WithTop.symm_toOption_eq_top_iff
+WithTop.toDual.match_1.congr_eq_1
+WithTop.toDual.match_1.congr_eq_2
+WithTop.toOption
+WithTop.toOption.match_1.congr_eq_1
+WithTop.toOption.match_1.congr_eq_2
+WithTop.toOption.match_3.congr_eq_1
+WithTop.toOption.match_3.congr_eq_2
+WithTop.toOption_apply_coe
+WithTop.toOption_apply_top
+WithTop.toOption_comp_coe
+WithTop.toOption_eq_none_iff
+WithTop.toOption_eq_some_iff
+WithTop.top.elim
+WithTop.top.sizeOf_spec
+WithTop.top_eq_top
+WithZero.casesOn
+WithZero.ctorElim
+WithZero.ctorElimType
+WithZero.ctorIdx
+WithZero.instAdd.match_1.congr_eq_1
+WithZero.instAdd.match_1.congr_eq_2
+WithZero.instAdd.match_1.congr_eq_3

Decrease in strong tech debt: (relative, absolute) = (5.00, 0.00)
Current number Change Type (strong)
3413 -5 backward.isDefEq.respectTransparency
No changes to weak technical debt.

Current commit 18b2ca4412
Reference commit bf61fbb2b0

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

variable {α : Type u}

/-- Add an extra element `0` to a type -/
inductive WithZero (α : Type u) where

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.

It might be easier to start here instead of trying to do this simultaneously with WithBot.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the difficult part tbh

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.

True, but a 900 line PR is still better than a 1000 line PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true but it would not make things easier as you said above. However the reason I made the change in this PR is that the order on WithZero is the one on WithBot. Therefore if I do the change only on WithZero first I must abuse defeq between Option and WithBot and then fix that in the WithBot PR. I would say it is simpler to do everything in one PR.

@github-actions github-actions Bot added the tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip label Nov 16, 2026
@eric-wieser

Copy link
Copy Markdown
Member

This probably warrants a Zulip thread; I'm assuming one doesn't already exist, since the PR description does not mention it.

@EtienneC30

Copy link
Copy Markdown
Member Author

Actually it does my bad, I updated the description.

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

Copy link
Copy Markdown

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

@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 27, 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 28, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@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 29, 2026
@@ -503,7 +503,7 @@ lemma nonsingularPointEquivSubtype_some {x y : R} {h : W'.Nonsingular x y} {p :

@[simp]
lemma nonsingularPointEquivSubtype_symm_none {p : W'.Point → Prop} (p0 : p .zero) :

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.

Ditto with three others:

Suggested change
lemma nonsingularPointEquivSubtype_symm_none {p : W'.Point → Prop} (p0 : p .zero) :
lemma nonsingularPointEquivSubtype_symm_zero {p : W'.Point → Prop} (p0 : p .zero) :

lemma le_unzero_iff (hy : y ≠ 0) : a ≤ unzero hy ↔ a ≤ y := WithBot.le_unbot_iff _
lemma unbot_le_iff (hx : x ≠ 0) : unzero hx ≤ b ↔ x ≤ b := WithBot.unbot_le_iff _
@[simp] lemma le_unzero_iff (hy : y ≠ 0) : a ≤ unzero hy ↔ a ≤ y := by lift y to α using hy; simp
@[simp] lemma unzero_le_iff (hx : x ≠ 0) : unzero hx ≤ b ↔ x ≤ b := by lift x to α using hx; simp

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.

Seems like there are a few deprecations missing, including this one that the bot missed.

Comment thread Mathlib/Algebra/Group/WithOne/Defs.lean Outdated

@[to_additive (attr := simp)] lemma toOption_apply_coe (x : α) : toOption α x = x := rfl

@[to_additive (attr := simp)] lemma toOption_apply_bot : toOption α 1 = none := rfl

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.

Suggested change
@[to_additive (attr := simp)] lemma toOption_apply_bot : toOption α 1 = none := rfl
@[to_additive (attr := simp)] lemma toOption_apply_one : toOption α 1 = none := rfl

@Multramate

Copy link
Copy Markdown
Collaborator

!radar

@leanprover-radar

leanprover-radar commented Nov 30, 2026 •

Copy link
Copy Markdown

Benchmark results for ab6f104 against 3ff2462 are in. There are significant results. @Multramate

  • 🟥 build//instructions: +39.1G (+0.05%)

Large changes (1🟥)

  • 🟥 build/module/Mathlib.NumberTheory.Bernoulli//instructions: +13.8G (+39.88%)

Small changes (39✅, 113🟥)

  • 152 hidden

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

Copy link
Copy Markdown

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

@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 30, 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 Dec 2, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

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

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

large-import Automatically added label for PRs with a significant increase in transitive imports t-order Order theory tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants