Skip to content

chore(Algebra/Order): make Nonneg a structure - #45709

Open
YaelDillies wants to merge 2 commits into
leanprover-community:masterfrom
YaelDillies:nonneg_struct
Open

YaelDillies wants to merge 2 commits into
leanprover-community:masterfrom
YaelDillies:nonneg_struct

Conversation

@YaelDillies

Copy link
Copy Markdown
Contributor

The goal is to eventually make NNRat and NNReal abbrevs for Nonneg Rat and Nonneg Real, and deduplicate their API. This is currently not possible due to prohibitive slowdowns when making their definition in terms of Subtype visible to automation.

Generated by Claude Sonnet in many rounds of review by myself.

Assisted-by: Claude Sonnet 5.5


@github-actions github-actions 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 5, 2026
@github-actions github-actions Bot added large-import Automatically added label for PRs with a significant increase in transitive imports tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

PR summary f225118705

Import changes exceeding 2%

% File
+5.88% Mathlib.Data.Rat.Init

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Data.Rat.Init 102 108 +6 (+5.88%)
Mathlib.Analysis.Normed.Group.Constructions 1290 1295 +5 (+0.39%)
Mathlib.Topology.Instances.NNReal.Lemmas 1474 1479 +5 (+0.34%)
Mathlib.Analysis.Complex.Norm 1486 1491 +5 (+0.34%)
Mathlib.Analysis.Normed.Field.Basic 1489 1494 +5 (+0.34%)
Mathlib.Analysis.Normed.Group.Continuity 1500 1505 +5 (+0.33%)
Mathlib.Analysis.ConstantSpeed 1517 1522 +5 (+0.33%)
Mathlib.Analysis.Normed.Group.Uniform 1599 1604 +5 (+0.31%)
Mathlib.Analysis.Normed.Group.Hom 1603 1608 +5 (+0.31%)
Mathlib.Topology.ContinuousMap.Bounded.Basic 1642 1647 +5 (+0.30%)
Mathlib.Analysis.Normed.Module.Basic 1645 1650 +5 (+0.30%)
Mathlib.Topology.MetricSpace.Thickening 1647 1652 +5 (+0.30%)
Mathlib.MeasureTheory.Constructions.BorelSpace.Basic 1688 1693 +5 (+0.30%)
Mathlib.Analysis.CStarAlgebra.Basic 1733 1738 +5 (+0.29%)
Mathlib.Analysis.LocallyConvex.Asymptotics 1778 1783 +5 (+0.28%)
Mathlib.Analysis.Normed.Operator.Basic 1834 1839 +5 (+0.27%)
Mathlib.Analysis.Normed.Operator.NNNorm 1835 1840 +5 (+0.27%)
Mathlib.Analysis.Normed.Operator.NormedSpace 1838 1843 +5 (+0.27%)
Mathlib.Analysis.Normed.Operator.Prod 1838 1843 +5 (+0.27%)
Mathlib.Analysis.Normed.Operator.Mul 1839 1844 +5 (+0.27%)
Mathlib.Topology.ContinuousMap.Bounded.Normed 1846 1851 +5 (+0.27%)
Mathlib.Analysis.Complex.Basic 1849 1854 +5 (+0.27%)
Mathlib.Analysis.Analytic.Composition 1912 1917 +5 (+0.26%)
Mathlib.Analysis.InnerProductSpace.Basic 1938 1943 +5 (+0.26%)
Mathlib.Analysis.CStarAlgebra.Unitization 1972 1977 +5 (+0.25%)
Mathlib.Analysis.SpecialFunctions.Pow.NNReal 2001 2006 +5 (+0.25%)
Mathlib.Analysis.Convex.SpecificFunctions.Pow 2022 2027 +5 (+0.25%)
Mathlib.Analysis.MeanInequalities 2038 2043 +5 (+0.25%)
Mathlib.Analysis.Normed.Algebra.UnitizationL1 2043 2048 +5 (+0.24%)
Mathlib.MeasureTheory.Function.SpecialFunctions.Basic 2064 2069 +5 (+0.24%)
Mathlib.RingTheory.RootsOfUnity.Complex 2084 2089 +5 (+0.24%)
Mathlib.Analysis.CStarAlgebra.Multiplier 2089 2094 +5 (+0.24%)
Mathlib.Analysis.Normed.Lp.lpHolder 2094 2099 +5 (+0.24%)
Mathlib.Analysis.Complex.OperatorNorm 2285 2290 +5 (+0.22%)
Mathlib.Analysis.Matrix.Normed 2434 2439 +5 (+0.21%)
Mathlib.Analysis.Quaternion 2436 2441 +5 (+0.21%)
Mathlib.NumberTheory.Modular 2451 2456 +5 (+0.20%)
Mathlib.Analysis.CStarAlgebra.Matrix 2455 2460 +5 (+0.20%)
Mathlib.Analysis.Normed.Algebra.Spectrum 2510 2515 +5 (+0.20%)
Mathlib.MeasureTheory.Function.UniformIntegrable 2530 2535 +5 (+0.20%)
Mathlib.Probability.Moments.IntegrableExpMul 2530 2535 +5 (+0.20%)
Mathlib.MeasureTheory.Function.SimpleFuncDenseLp 2534 2539 +5 (+0.20%)
Mathlib.MeasureTheory.Integral.SetToL1.L1 2544 2549 +5 (+0.20%)
Mathlib.MeasureTheory.Integral.Bochner.Basic 2550 2555 +5 (+0.20%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric 2605 2610 +5 (+0.19%)
Mathlib.Topology.MetricSpace.HausdorffDimension 2630 2635 +5 (+0.19%)
Mathlib.Analysis.BoxIntegral.Integrability 2641 2646 +5 (+0.19%)
Mathlib.MeasureTheory.Function.Jacobian 2667 2672 +5 (+0.19%)
Mathlib.MeasureTheory.Measure.Prokhorov 2685 2690 +5 (+0.19%)
Mathlib.Analysis.ODE.PicardLindelof 2791 2796 +5 (+0.18%)
Mathlib.Analysis.Complex.CauchyIntegral 2825 2830 +5 (+0.18%)
Mathlib.MeasureTheory.Function.ConditionalExpectation.Real 2968 2973 +5 (+0.17%)
Mathlib.Analysis.Complex.UpperHalfPlane.Measure 3035 3040 +5 (+0.16%)
Mathlib.Analysis.CStarAlgebra.GelfandDuality 3040 3045 +5 (+0.16%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order 3066 3071 +5 (+0.16%)
Mathlib.Analysis.CStarAlgebra.Hom 3067 3072 +5 (+0.16%)
Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic 3085 3090 +5 (+0.16%)
Mathlib.Probability.Moments.Tilted 3144 3149 +5 (+0.16%)
Import changes for all files
Files Import difference
../mathlib-ci/scripts/pr_summary/import_trans_difference.sh all
There are 5137 files with changed transitive imports taking up over 236291 characters: this is too many to display!
You can run this locally from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci


Declarations diff (regex)

+ Continuous.nonnegMk
+ IsClosedMap.nonnegMk
+ IsOpenMap.nonnegMk
+ Measurable.nonnegMk
+ Nonneg.borelSpace
+ Nonneg.instMeasurableSpace
+ Nonneg.measurable_val
+ UniformContinuous.nonnegMk
+ bddBelow_image
+ canLift
+ coe_bot
+ coe_image
+ coe_inf
+ coe_inj
+ coe_le_coe
+ coe_lt_coe
+ coe_mk
+ coe_ne_coe
+ coe_sInf
+ coe_sSup
+ coe_sup
+ continuous_val
+ decidableLE
+ decidableLT
+ dist_def
+ image_val_Icc
+ image_val_Ici
+ image_val_Ico
+ image_val_Iic
+ image_val_Iio
+ image_val_Ioc
+ image_val_Ioi
+ image_val_Ioo
+ image_val_uIcc
+ image_val_uIoc
+ image_val_uIoo
+ instInfSet
+ instLinearOrder
+ instMax
+ instMetricSpace
+ instMin
+ instPartialOrder
+ instPreorder
+ instPseudoMetricSpace
+ instSupSet
+ instTopologicalSpace
+ instance : CoeOut (Nonneg α) α := ⟨val⟩
+ instance : ContinuousSub ℚ≥0 := ⟨Continuous.nonnegMk (by fun_prop) _⟩
+ instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Nonneg ℝ)
+ instance : OrderTopology ℚ≥0
+ instance : SecondCountableTopology ℝ≥0 := NNReal.isEmbedding_coe.secondCountableTopology
+ isEmbedding_val
+ isGLB_sInf
+ isInducing_val
+ isLUB_sSup
+ isUniformEmbedding_val
+ isUniformInducing_val
+ lattice
+ mk_le_mk
+ mk_lt_mk
+ mk_val
+ monotone_val
+ nnDist_def
+ orderIsoIci
+ property
+ range_val
+ sInf_empty
+ sSup_empty
+ strictMono_val
+ uniformContinuous_val
+ valOrderHom
+ val_injective
+ zero_le_sInf_image
+ zero_le_sSup_image
++- sSup_of_not_bddAbove
++- «exists»
++- «forall»
++-- extendScalars.orderIso
- conditionallyCompleteLinearOrder
- instance : ContinuousSub ℚ≥0 := ⟨Continuous.subtype_mk (by fun_prop) _⟩
- instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Subtype _)
- instance : OrderTopology ℚ≥0 := orderTopology_of_ordConnected (t := Set.Ici 0)
- instance : SecondCountableTopology ℝ≥0
- orderIsoIccZeroCoe_symm_apply_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 f225118).

  • +93 new declarations
  • −6 removed declarations
+Continuous.nonnegMk
+IsClosedMap.nonnegMk
+IsOpenMap.nonnegMk
+Measurable.nonnegMk
+Nonneg.borelSpace
+Nonneg.canLift
+Nonneg.casesOn
+Nonneg.coe_bot
+Nonneg.coe_image
+Nonneg.coe_inf
+Nonneg.coe_inj
+Nonneg.coe_le_coe
+Nonneg.coe_lt_coe
+Nonneg.coe_mk
+Nonneg.coe_ne_coe
+Nonneg.coe_sInf
+Nonneg.coe_sSup
+Nonneg.coe_sup
-Nonneg.conditionallyCompleteLinearOrder
+Nonneg.continuous_val
+Nonneg.ctorIdx
+Nonneg.decidableLE
+Nonneg.decidableLT
+Nonneg.dist_def
+Nonneg.exists
+Nonneg.ext
+Nonneg.ext_iff
+Nonneg.forall
+Nonneg.image_val_Icc
+Nonneg.image_val_Ici
+Nonneg.image_val_Ico
+Nonneg.image_val_Iic
+Nonneg.image_val_Iio
+Nonneg.image_val_Ioc
+Nonneg.image_val_Ioi
+Nonneg.image_val_Ioo
+Nonneg.image_val_uIcc
+Nonneg.image_val_uIoc
+Nonneg.image_val_uIoo
+Nonneg.instCoeOut
+Nonneg.instInfSet
+Nonneg.instLinearOrder
+Nonneg.instMax
+Nonneg.instMeasurableSpace
+Nonneg.instMetricSpace
+Nonneg.instMin
+Nonneg.instPartialOrder
+Nonneg.instPreorder
+Nonneg.instPseudoMetricSpace
+Nonneg.instSupSet
+Nonneg.instTopologicalSpace
+Nonneg.isEmbedding_val
+Nonneg.isGLB_sInf
+Nonneg.isInducing_val
+Nonneg.isLUB_sSup
+Nonneg.isUniformEmbedding_val
+Nonneg.isUniformInducing_val
+Nonneg.lattice
+Nonneg.measurable_val
+Nonneg.mk
+Nonneg.mk.congr_simp
+Nonneg.mk.inj
+Nonneg.mk.injEq
+Nonneg.mk.noConfusion
+Nonneg.mk.sizeOf_spec
+Nonneg.mk_le_mk
+Nonneg.mk_lt_mk
+Nonneg.mk_val
+Nonneg.monotone_val
+Nonneg.nnDist_def
+Nonneg.noConfusion
+Nonneg.noConfusionType
+Nonneg.orderIsoIci
+Nonneg.orderIsoIci_apply_coe
+Nonneg.orderIsoIci_symm_apply_val
+Nonneg.property
+Nonneg.range_val
+Nonneg.rec
+Nonneg.recOn
+Nonneg.sInf_empty
+Nonneg.sSup_empty
+Nonneg.sSup_of_not_bddAbove
+Nonneg.strictMono_val
+Nonneg.uniformContinuous_val
-Nonneg.unitsEquivPos.congr_simp
+Nonneg.val
+Nonneg.valOrderHom
+Nonneg.valOrderHom_coe
+Nonneg.val_injective
-Nonneg.val_inv_unitsEquivPos_symm_apply_coe
+Nonneg.val_inv_unitsEquivPos_symm_apply_val
-Nonneg.val_inv_unitsHomeomorphPos_symm_apply_coe
+Nonneg.val_inv_unitsHomeomorphPos_symm_apply_val
+Nonneg.val_nonneg
-Nonneg.val_unitsEquivPos_symm_apply_coe
+Nonneg.val_unitsEquivPos_symm_apply_val
-Nonneg.val_unitsHomeomorphPos_symm_apply_coe
+Nonneg.val_unitsHomeomorphPos_symm_apply_val
+UniformContinuous.nonnegMk

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (2.00, 0.00)
Current number Change Type (weak)
5166 2 exposed public sections

Current commit f225118705
Reference commit d153afcf87

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

@YaelDillies YaelDillies added t-algebra Algebra (groups, rings, fields, etc) t-order Order theory LLM-generated PRs with substantial input from LLMs - review accordingly labels Nov 5, 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 6, 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 6, 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 9, 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 9, 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 9, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@YaelDillies YaelDillies changed the title chore(Algebra/Order): make Nonneg a one-field structure chore(Algebra/Order): make Nonneg a structure Nov 10, 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 Nov 10, 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 10, 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 11, 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.

@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
@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 19, 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 20, 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 24, 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 24, 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 26, 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 Dec 1, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

The goal is to eventually make  `NNRat` and `NNReal` `abbrev`s for `Nonneg Rat` and `Nonneg Real`, and deduplicate their API. This is currently not possible due to prohibitive slowdowns when making their definition in terms of `Subtype` visible to automation.

Generated by Claude Sonnet in many rounds of review by myself.

Assisted-by: Claude Sonnet 5.5
@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 LLM-generated PRs with substantial input from LLMs - review accordingly t-algebra Algebra (groups, rings, fields, etc) 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.

1 participant