feat: generalize LE, LT and the Std order-predicate classes to Sort u - #14737
feat: generalize LE, LT and the Std order-predicate classes to Sort u#14737sgraf812 wants to merge 6 commits into
LE, LT and the Std order-predicate classes to Sort u#14737Conversation
|
!bench |
|
Benchmark results for 2b77fd4 against 8d96b70 are in. No significant results found. @sgraf812 Warning These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.
Small changes (5🟥)
|
|
!bench |
|
Benchmark results for 2b77fd4 against 8d96b70 are in. (These commits have already been benchmarked in a previous command.) No significant results found. @sgraf812 Warning These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.
Small changes (5🟥)
|
2b77fd4 to
dde890c
Compare
|
!bench |
|
Benchmark results for dde890c against 3fc29d3 are in. No significant results found. @sgraf812
Small changes (5🟥)
|
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
…t u` This PR makes every metaprogram that constructs an application of `LE`, `LT`, `Std.IsPreorder`, `Std.IsPartialOrder`, `Std.IsLinearOrder`, `Std.IsLinearPreorder` or `Std.LawfulOrderLT` derive the universe argument from the declared form of `LE`, so that generalizing these classes from `Type u` to `Sort u` needs no further compiler changes once this change is the stage0 compiler. `Lean.leCarrierIsSort` classifies the declared form of `LE` once per process. Every affected site branches on it, with the else branch carrying the present code unchanged; the branch and its else are removed once the generalization lands. Pure helpers such as `Lean.Expr.mkNatLE` take the universe argument as a parameter, with the branch at their callers; the `Grind.CommRing.*_norm0` helpers likewise take the ring structure's universe argument, which coincides with the order structure's until the generalization. Grind's per-carrier order structure caches the universe argument `LE` takes at the carrier, so its downstream instantiation sites are unchanged; the `_k` helper lemmas whose `[Ring α]` constraint binds their carrier as a `Type` are constructed directly in the two ord-ring prefix builders.
…`Sort u` This PR generalizes the carriers of `LE`, `LT`, `GE.ge`, `GT.gt`, `DecidableLE`, `DecidableLT`, `Std.IsPreorder`, `Std.IsPartialOrder`, `Std.IsLinearOrder`, `Std.IsLinearPreorder` and `Std.LawfulOrderLT` from `Type u` to `Sort u`, so that propositions and proof-indexed function types can carry order structure. This is the prerequisite for stating the order on `Lean.Order` fixpoint carriers in terms of `Std.IsPartialOrder`. The compiler needs no changes: since the previous stage0 update its `LE`/`LT` construction sites branch on the declared form of `LE`.
35e2374 to
f8b5216
Compare
This PR removes the `leCarrierIsSort` classification and the branches it selected, keeping the code for the `Sort u` form of `LE` throughout, and returns the universe argument of the `Expr` comparison builders and the `Nat` simproc helpers to a fixed level. `Lean.OrderLevel` is deleted.
f8b5216 to
88d74fd
Compare
This PR generalizes the carriers of
LE,LT,GE.ge,GT.gt,DecidableLE,DecidableLT,Std.IsPreorder,Std.IsPartialOrder,Std.IsLinearOrder,Std.IsLinearPreorderandStd.LawfulOrderLTfromType utoSort u, so that propositions can carry order structure. It is the prerequisite for stating the order onLean.Orderfixpoint carriers in terms ofStd.IsPartialOrder.The library fallout is binder-level only. Metaprograms that build
LEandLTapplications pass the carrier's own universe where they used to pass its predecessor. Grind's order module works onSort-carried goals, taking the argumentLEtakes as its per-carrier universe and recovering aTypelevel bydecLevelwhere theGrind.Ring-constrained lemmas, which stayType-fixed, need one.Mathlib needs an adaptation of seven files, mostly Qq pattern universes and one notation elaborator.