← Back to Pull requests

feat(Algebra/Order): linear order and strict ordered ring structures on opposites #46504

Open
unknown opened this pull request with 285 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 25, 2026 21:36 UTC
Author

Add LinearOrder, IsOrderedCancelMonoid / IsOrderedCancelAddMonoid and IsStrictOrderedRing instances on αᵐᵒᵖ and αᵃᵒᵖ, the Max, Min and Ord instances they are built from, and the simp lemmas op_lt_op, unop_lt_unop, op_sup, unop_sup, op_inf, unop_inf, op_compare, unop_compare and the strict versions of unop_le_one, unop_nonneg etc. (unop_lt_one, op_pos, ...). Also generalize the existing IsOrderedMonoid / IsOrderedAddMonoid instances from PartialOrder to Preorder.

With the existing Field αᵐᵒᵖ instance, αᵐᵒᵖ is now a linearly ordered field whenever α is.

---

Design: the LinearOrder is built with Function.Injective.linearOrder from pointwise Max/Min/Ord instances (as for ULift), not with LinearOrder.lift', so that max/min/compare commute with op/unop by rfl and the PartialOrder and DecidableEq fields agree with the existing instances at instance-reducible transparency (checked with with_reducible_and_instances rfl for both opposites).

The cancellative instances are included because IsStrictOrderedRing extends IsOrderedCancelAddMonoid. In Rᵐᵒᵖ the left and right strict monotonicity of multiplication swap, since op a op b = op (b a).

TwoUniqueProds.of_covariant_left in Mathlib/Algebra/Group/UniqueProds/Basic.lean still builds this order locally with LinearOrder.lift'; using the new instance there would need an import of Mathlib.Algebra.Order.Group.Opposite, which the directory import check does not allow for that file, so it is left unchanged.

The additive names of the new < 1 lemmas are given explicitly (unop_lt_zero, unop_pos, op_lt_zero, op_pos) because the default to_additive names would clash with AddOpposite.unop_neg.

AI use: I used Claude Code (Anthropic) to draft these instances and lemmas and to check them against mathlib's conventions; an initial version used LinearOrder.lift' and was changed to the construction above after checking the instance diamonds. I reviewed the code myself afterwards. Checked locally: the changed modules and Mathlib.Algebra.Group.UniqueProds.Basic and Mathlib.Algebra.Order.Star.Basic build, lake exe lint-style passes, and the diamond and instance-synthesis tests described above.

Diff: 285 lines (+213 / -72) across 3 files Reviewer: eric-wieser Review duration: 7423m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 285 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.338
Real PR Conversation Timeline
1 comments
"Review active on #46504"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.8% (MEDIUM) · Higher = larger blast radius
39.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 46.7% · Lower = rushed or shallow review
46.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 21.2% · Safe to merge
21.2%