Zulip Chat Archive

Stream: Is there code for X?

Topic: Finset.sum with proof of membership?


Michail Karatarakis (Nov 12 2024 at 00:00):

Do we have this, or is there a common way to handle this kind of setup ?

def Finset.sum' [AddCommMonoid β] (s : Finset α)
    (f :  x : α, x  s  β) : β := sorry

Andrew Yang (Nov 12 2024 at 00:03):

import Mathlib.Algebra.BigOperators.Group.Finset

def Finset.sum' {β} [AddCommMonoid β] (s : Finset α)
    (f :  x : α, x  s  β) : β :=  i  s.attach, f i.1 i.2

Andrew Yang (Nov 12 2024 at 00:05):

Or just ∑ i : s, f i.1 i.2. Pretty sure they are the same thing?

Michail Karatarakis (Nov 12 2024 at 00:10):

Yes, they are - thanks a lot


Last updated: May 02 2025 at 03:31 UTC