Repository navigation
[Merged by Bors] - feat: OrderSupSet - #38328
astrainfinita wants to merge 17 commits into
Conversation
PR summary 063c5accb9
|
| File | Base Count | Head Count | Change |
|---|---|---|---|
| Mathlib.Order.SetNotation | 170 | 171 | +1 (+0.59%) |
| Mathlib.Order.Bounds.Basic | 328 | 329 | +1 (+0.30%) |
Import changes for all files
| Files | Import difference |
|---|---|
86 filesMathlib.Algebra.BigOperators.Group.Finset.Basic Mathlib.Algebra.BigOperators.Group.Finset.Lemmas Mathlib.Algebra.BigOperators.Group.Finset.Pi Mathlib.Algebra.BigOperators.Group.Finset.Piecewise Mathlib.Algebra.BigOperators.Option Mathlib.Algebra.GradedMonoid Mathlib.Algebra.GradedMulAction Mathlib.Algebra.Group.EvenFunction Mathlib.Algebra.Group.Pointwise.Set.BigOperators Mathlib.Algebra.Group.Pointwise.Set.Finite Mathlib.Algebra.Order.Field.Basic Mathlib.Algebra.Order.Group.Bounds Mathlib.Algebra.Order.Group.Pointwise.Interval Mathlib.Algebra.Order.GroupWithZero.Bounds Mathlib.Basic.Finite.Prod Mathlib.Basic.Finite.Sum Mathlib.Basic.Rel.Cover Mathlib.Basic.Rel.Separated Mathlib.Basic.Rel Mathlib.Combinatorics.HalesJewett Mathlib.Computability.StateTransition Mathlib.Computability.TuringMachine.PostTuringMachine Mathlib.Computability.TuringMachine.StackTuringMachine Mathlib.Control.LawfulFix Mathlib.Data.DFinsupp.FiniteInfinite Mathlib.Data.Fin.Tuple.Curry Mathlib.Data.Fin.Tuple.Finset Mathlib.Data.FinEnum.Option Mathlib.Data.Finite.Prod Mathlib.Data.Finite.Sum Mathlib.Data.Finset.NoncommProd Mathlib.Data.Finset.Option Mathlib.Data.Finset.PImage Mathlib.Data.Finset.Pi Mathlib.Data.Finset.Prod Mathlib.Data.Finset.Union Mathlib.Data.Finset.Update Mathlib.Data.Fintype.Option Mathlib.Data.Fintype.Pi Mathlib.Data.Fintype.Pigeonhole Mathlib.Data.Fintype.Prod Mathlib.Data.Fintype.Sum Mathlib.Data.Fintype.WithTopBot Mathlib.Data.FunLike.Fintype Mathlib.Data.Holor Mathlib.Data.Multiset.Fintype Mathlib.Data.Nat.Cast.Order.Field Mathlib.Data.Nat.Prime.Infinite Mathlib.Data.PFun Mathlib.Data.Rel.Cover Mathlib.Data.Rel.Separated Mathlib.Data.Rel Mathlib.Dynamics.BirkhoffSum.Average Mathlib.Dynamics.BirkhoffSum.Basic Mathlib.GroupTheory.Perm.List Mathlib.GroupTheory.Perm.Support Mathlib.LinearAlgebra.ConvexSpace.AffineSpace Mathlib.Logic.Embedding.Set Mathlib.Logic.Equiv.Embedding Mathlib.Logic.Equiv.Fin.Basic Mathlib.Logic.Equiv.Fin.Rotate Mathlib.NumberTheory.Harmonic.Defs Mathlib.Order.Antichain Mathlib.Order.Bounds.Basic Mathlib.Order.Bounds.Image Mathlib.Order.Bounds.OrderIso Mathlib.Order.Interval.Set.Fin Mathlib.Order.Interval.Set.IsoIoo Mathlib.Order.Interval.Set.OrderEmbedding Mathlib.Order.Interval.Set.UnorderedInterval Mathlib.Order.LatticeIntervals Mathlib.Order.Monotone.Odd Mathlib.Order.Monotone.Union Mathlib.Order.OmegaCompletePartialOrder Mathlib.Order.Rel.GaloisConnection Mathlib.Order.RelIso.Set Mathlib.Order.ScottContinuity Mathlib.Order.SetNotation Mathlib.Order.UpperLower.Relative Mathlib.RingTheory.FilteredAlgebra.Basic Mathlib.RingTheory.Prime Mathlib.SetTheory.ZFC.Basic Mathlib.SetTheory.ZFC.PSet Mathlib.Tactic.NormNum.BigOperators Mathlib.Topology.ContinuousMap.Defs Mathlib.Topology.Defs.Basic |
1 |
Declarations diff (regex)
+ IsLUB.isLUB_sSup
+ OrderDual.orderSupSet
+ OrderInfSet
+ OrderInfSet.ofOrderSupSet
+ OrderSupSet
+ OrderSupSet.choose
+ exists_isLUB_iff_isLUB_sSup
+ instance (priority := 100) CompleteSemilatticeSup.toOrderSupSet :
+ instance [Preorder α] [OrderSupSet α] [Preorder β] [OrderSupSet β] : OrderSupSet (α × β)
+ instance {α : Type*} {β : α → Type*} [∀ i, Preorder (β i)] [∀ i, OrderSupSet (β i)] :
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
063c5ac).
- +38 new declarations
- −0 removed declarations
+CompleteSemilatticeInf.toOrderInfSet
+CompleteSemilatticeSup.toOrderSupSet
+IsGLB.isGLB_sInf
+IsLUB.isLUB_sSup
+OrderDual.orderInfSet
+OrderDual.orderSupSet
+OrderInfSet
+OrderInfSet.casesOn
+OrderInfSet.choose
+OrderInfSet.ctorIdx
+OrderInfSet.isGLB_sInf_of_isGLB
+OrderInfSet.mk
+OrderInfSet.mk.noConfusion
+OrderInfSet.noConfusion
+OrderInfSet.noConfusionType
+OrderInfSet.ofOrderSupSet
+OrderInfSet.rec
+OrderInfSet.recOn
+OrderInfSet.toInfSet
+OrderSupSet
+OrderSupSet.casesOn
+OrderSupSet.choose
+OrderSupSet.ctorIdx
+OrderSupSet.isLUB_sSup_of_isLUB
+OrderSupSet.mk
+OrderSupSet.mk.noConfusion
+OrderSupSet.noConfusion
+OrderSupSet.noConfusionType
+OrderSupSet.ofOrderInfSet
+OrderSupSet.rec
+OrderSupSet.recOn
+OrderSupSet.toSupSet
+Prod.instOrderInfSet
+Prod.instOrderSupSet
+exists_isGLB_iff_isGLB_sInf
+exists_isLUB_iff_isLUB_sSup
+instOrderInfSetForall
+instOrderSupSetForallNo changes to strong technical debt.
No changes to weak technical debt.
Current commit 063c5accb9
Reference commit f71bd379b2
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
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
|
This pull request has conflicts, please merge |
|
|
||
| /-- `OrderSupSet α` expresses that `α` is equipped with the operation `sSup` that returns | ||
| the least upper bound of a set whenever one exists. -/ | ||
| class OrderSupSet (α : Type*) [LE α] extends SupSet α where |
There was a problem hiding this comment.
IIUC, only this and OrderInfSet need to live in this file, the rest can be further down the import hierarchy.
There was a problem hiding this comment.
The file is only meant for notation, so arguably nothing should be added here in this PR
vihdzp
left a comment
There was a problem hiding this comment.
I really like this new design. Not sure if the conversation has quite converged on whether we want it, but I do personally find it to be an improvement.
|
Can you add something to the PR description here describing the motivation? The linked Zulip thread is (very) long and discusses a number of other things. |
@astrainfinita I've just suggested a rough outline in Zulip; feel free to use / not use at your leisure |
| /-- `OrderSupSet α` expresses that `α` is equipped with the operation `sSup` that returns | ||
| the least upper bound of a set whenever one exists. -/ | ||
| class OrderSupSet (α : Type*) [LE α] extends SupSet α where | ||
| protected isLUB_sSup_of_isLUB s a : IsLUB s a → IsLUB s (sSup s) |
There was a problem hiding this comment.
The problem with OrderSupSet using extends is that you either have to add it into all the order classes (ConditionallyCompletePartialOrder, ConditionallyCompleteLinearOrder, etc.) or else you can't have any theorems about those classes which assume OrderSupSet because taking both as arguments will give you 2 distinct SupSet instances.
There was a problem hiding this comment.
The problem with
OrderSupSetusingextendsis that you either have to add it into all the order classes
I think the idea is to eventually redefine the order classes so as to extend OrderSupSet and OrderInfSet, and instead of characterizing the functions sSup and sInf directly, we characterize what sets have suprema and infima.
There was a problem hiding this comment.
Yes, I expect their usage to be similar to OrderBot. Any typeclass that provides sSup should either directly extend OrderSupSet or imply it.
|
This pull request has conflicts, please merge |
|
This pull request has conflicts, please merge |
Vierkantor
left a comment
There was a problem hiding this comment.
Overall I think this is the right way to go. Do you have any followup PRs so I can see the effects of this PR in action?
| (∃ a, IsLUB s a) → IsLUB s (sSup s) := | ||
| fun ⟨_, h⟩ ↦ h.isLUB_sSup | ||
|
|
||
| @[to_dual] |
There was a problem hiding this comment.
This seems like a good simp lemma, replacing an arbitrary witness a with a specific value sSup s.
| @[to_dual] | |
| @[to_dual (attr := simp)] |
There was a problem hiding this comment.
I don't know if I agree with this. We might have a scenario where the LUB of s has an explicit characterization, so that the LHS is easier to work with then the RHS.
There was a problem hiding this comment.
If the LUB has an explicit characterisation, then why would we be writing down the statement ∃ a, IsLUB s a which hides any characterisation?
There was a problem hiding this comment.
Because you can use your explicit characterization, rather than having to show that sSup s, which might or might not have useful def-eqs, equals this characterization.
To put it another way, the LHS is more syntactically general.
There was a problem hiding this comment.
I'm not totally convinced by that reasoning (for example, mul_zero would be an unhelpful simp lemma when you have a characterization of (. * .)). But I'm not that much attached to the idea of making this @[simp] that I want to block the PR over this discussion. Let's instead see what happens downstream when this PR gets merged!
|
Thank you, let's get it merged! 🎉 bors r+ |
This PR introduces `OrderSupSet` and `OrderInfSet`, which are typeclasses expressing that `sSup` (resp., `sInf`) returns the least upper bound (resp., the greatest lower bound) of a set whenever one exists. This allows us to prove properties about the `sSup` of specific sets (such as `∅`, singletons, finite sets, and `univ`) without any typeclasses asserting the existence of LUBs. For example, `sSup ∅ = ⊥` holds for any type equipped with `OrderBot` `OrderSupSet`, no longer requiring typeclasses like `ConditionallyCompleteLinearOrderBot`. For a general set `s`, this gives a uniform way to extend results about `IsLUB s a → motive a` to `motive (sSup s)`, `motive (⨆ i, f i)`, `motive (a ⊔ b)`, etc., which allows proof reuse for basic API such as [`csSup_insert`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Order/ConditionallyCompleteLattice/Basic.html#csSup_insert), [`iSup_insert`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Order/CompleteLattice/Basic.html#iSup_insert), and [`sSup_insert`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Order/CompleteLattice/Basic.html#sSup_insert) and downstream code like [`csSup_add`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Order/Group/Pointwise/CompleteLattice.html#csSup_add), [`sSup_add`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Order/Group/Pointwise/CompleteLattice.html#sSup_add), and [`sup_add`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Order/Group/Lattice.html#sup_add). Furthermore, this allows us to refactor incrementally, reducing the dependency of results about various completeness typeclasses on the specific implementation of `sSup`.
|
Pull request successfully merged into master. Build succeeded:
|
OrderSupSetOrderSupSet
| the greatest lower bound of a set whenever one exists. -/ | ||
| @[to_dual existing] | ||
| class OrderInfSet (α : Type*) [LE α] extends InfSet α where | ||
| protected isGLB_sInf_of_isGLB s a : IsGLB s a → IsGLB s (sInf s) |
There was a problem hiding this comment.
I think we usually prefer explicit types:
| protected isGLB_sInf_of_isGLB s a : IsGLB s a → IsGLB s (sInf s) | |
| protected isGLB_sInf_of_isGLB (s : Set α) (a : α) : IsGLB s a → IsGLB s (sInf s) |
This PR introduces
OrderSupSetandOrderInfSet, which are typeclasses expressing thatsSup(resp.,sInf) returns the least upper bound (resp., the greatest lower bound) of a set whenever one exists.This allows us to prove properties about the
sSupof specific sets (such as∅, singletons, finite sets, anduniv) without any typeclasses asserting the existence of LUBs. For example,sSup ∅ = ⊥holds for any type equipped withOrderBotOrderSupSet, no longer requiring typeclasses likeConditionallyCompleteLinearOrderBot.For a general set
s, this gives a uniform way to extend results aboutIsLUB s a → motive atomotive (sSup s),motive (⨆ i, f i),motive (a ⊔ b), etc., which allows proof reuse for basic API such ascsSup_insert,iSup_insert, andsSup_insertand downstream code likecsSup_add,sSup_add, andsup_add.Furthermore, this allows us to refactor incrementally, reducing the dependency of results about various completeness typeclasses on the specific implementation of
sSup.Zulip