Zulip Chat Archive
Stream: Is there code for X?
Topic: Multiset.sum_lt_sum
Martin Dvořák (Oct 31 2023 at 17:11):
We have List.sum_lt_sum
for lists. Do we have a similar thing for multisets?
import Mathlib
variable {ι M : Type} [AddCommMonoid M] [LinearOrder M]
[CovariantClass M M (· + ·) (· ≤ ·)]
[CovariantClass M M (· + ·) (· < ·)]
example {l : List ι} (f g : ι → M)
(h₁ : ∀ i ∈ l, f i ≤ g i) (h₂ : ∃ i ∈ l, f i < g i) :
List.sum (List.map f l) < List.sum (List.map g l) :=
List.sum_lt_sum f g h₁ h₂
example {s : Multiset ι} (f g : ι → M)
(h₁ : ∀ i ∈ s, f i ≤ g i) (h₂ : ∃ i ∈ s, f i < g i) :
Multiset.sum (Multiset.map f s) < Multiset.sum (Multiset.map g s) :=
sorry
Alex J. Best (Oct 31 2023 at 17:13):
I think with loogle we can be fairly confident the answer is no https://loogle.lean-lang.org/?q=Multiset.sum%2C+LT.lt
Martin Dvořák (Oct 31 2023 at 17:14):
Is there a straightforward way to translate the List
version to the Multiset
version?
Junyan Xu (Oct 31 2023 at 18:49):
rcases s
?
Notification Bot (Oct 31 2023 at 20:38):
Martin Dvořák has marked this topic as resolved.
Notification Bot (Nov 03 2023 at 18:13):
Martin Dvořák has marked this topic as unresolved.
Martin Dvořák (Nov 03 2023 at 18:17):
I just noticed that the Finset.prod_lt_prod'
assumes OrderedCancelCommMonoid
whereäs the List.prod_lt_prod'
assumes [CovariantClass M M (· * ·) (· ≤ ·)]
and [CovariantClass M M (Function.swap (· * ·)) (· < ·)]
instead. Similar situation for Finset.sum_lt_sum
and List.sum_lt_sum
respectively.
I think we should first unify the assumptions and then create the Multiset
version.
Yaël Dillies (Nov 03 2023 at 18:26):
You should use OrderedCancelCommMonoid
in both cases.
Martin Dvořák (Nov 03 2023 at 18:32):
I think this is asking for a major refactor of
https://github.com/leanprover-community/mathlib4/blob/baa7aa8c9b30292fb7aa93b5724d0c2ea7c1948b/Mathlib/Data/List/BigOperators/Basic.lean#L267
(until line 377).
Eric Wieser (Nov 03 2023 at 18:35):
It might be worth checking the mathlib3 history to see if the extra generality was deliberate
Martin Dvořák (Nov 03 2023 at 18:39):
Martin Dvořák (Nov 03 2023 at 18:43):
At least some of them were added in this commit:
https://github.com/leanprover-community/mathlib/commit/2541387ecc6183f4d40a3ff6d059c5dfbdbd5192
Martin Dvořák (Nov 09 2023 at 10:04):
Now that #8170 has been merged, I would like to refactor the List
big-operator lemmas:
https://github.com/leanprover-community/mathlib4/blob/master/Mathlib/Data/List/BigOperators/Basic.lean#L267
Can somebody please confirm that there was no good reason for using CovariantClass
instead of our algebraic-hierarchy classes?
Scott Morrison (Nov 09 2023 at 10:24):
Lemmas are often usefully more general when stated in terms of CovariantClass
?
Martin Dvořák (Nov 09 2023 at 10:30):
Seems @Yaël Dillies and @Scott Morrison have a disagreement.
Yaël Dillies (Nov 09 2023 at 10:32):
Here I doubt it ever was useful. We're not caring about non-commutative ordered stuff.
Yaël Dillies (Nov 09 2023 at 10:35):
Certainly it doesn't cost much to leave the lemmas as they are.
Martin Dvořák (Nov 09 2023 at 10:36):
Martin Dvořák said:
I just noticed that the
Finset.prod_lt_prod'
assumesOrderedCancelCommMonoid
whereäs theList.prod_lt_prod'
assumes[CovariantClass M M (· * ·) (· ≤ ·)]
and[CovariantClass M M (Function.swap (· * ·)) (· < ·)]
instead. Similar situation forFinset.sum_lt_sum
andList.sum_lt_sum
respectively.I think we should first unify the assumptions and then create the
Multiset
version.
As they are?
Eric Wieser (Nov 09 2023 at 11:01):
Yaël Dillies said:
Here I doubt it ever was useful. We're not caring about non-commutative ordered stuff.
Here's one we should care about: the quaternions under the order induced by the difference of the real part when the imaginary parts agree (aka a docs#StarOrderedRing)
Eric Wieser (Nov 09 2023 at 11:02):
Though maybe it has no relevant properties here
Yaël Dillies (Nov 09 2023 at 12:03):
@Martin Dvořák, one reason the assumptions between the List
and Finset
versions are different is because Finset.sum
requires commutativity while List.sum
doesn't.
Martin Dvořák (Nov 09 2023 at 12:14):
Got it.
However, you claimed that I should use OrderedCancelCommMonoid
in both cases.
Do you no longer have this opinion?
Either way, for the Multiset
version, I will use the same setting as the Finset
version has.
Martin Dvořák (Nov 13 2023 at 19:40):
Can we make a decision? Should the big-operator lemmas for List
stay as they are?
Martin Dvořák (Nov 29 2023 at 11:30):
Last updated: Dec 20 2023 at 11:08 UTC