AFTD Auto-Formalizing Theoretical Domains

multiset_sum_apply

theoremverified

For any finite family of additive commutative monoids G_i over i in Fin t, any multiset W of dependent functions x : (i : Fin t) -> G_i, and any coordinate j in Fin t, the sum of the projections of the elements of W to coordinate j equals the j-th coordinate of the sum of W.

Statement

lemma multiset_sum_apply {t : ℕ} {G : Fin t → Type*}
    [∀ i, AddCommMonoid (G i)] (W : Multiset ((i : Fin t) → G i)) (j : Fin t) :
    (W.map (fun x => x j)).sum = W.sum j
Source
arXiv:2610.35819 Section 4
Verified
29 Oct 2026
Axioms
Quot.soundpropext
Used by 1

Read back from the Lean

For any natural number $t$, any family of types $G : \mathrm{Fin}(t) \to \mathrm{Type}^*$ such that each $G(i)$ is an additive commutative monoid, any multiset $W$ of dependent functions in $\prod_{i : \mathrm{Fin}(t)} G(i)$, and any index $j \in \mathrm{Fin}(t)$, the sum in $G(j)$ of the multiset obtained by evaluating each function $x \in W$ at $j$ is equal to the multiset sum of $W$ evaluated at $j$.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The result follows directly from the fact that additive monoid homomorphisms commute with multiset sums. Since evaluating a function at coordinate $j$ is an additive monoid homomorphism (`Pi.evalAddMonoidHom`), applying `map_multiset_sum` and taking the symmetric equality immediately equates the sum of coordinate projections to the projection of the sum.

  1. The sum of the $j$-th coordinates of the functions in $W$ equals the $j$-th coordinate of the multiset sum $\sum W$.

    Coordinate projection at index $j$ is an additive monoid homomorphism (`Pi.evalAddMonoidHom G j`). By `map_multiset_sum`, applying this homomorphism to the multiset sum $W.\text{sum}$ equals the sum of the mapped multiset $(W.\text{map } (\lambda x, x(j))).\text{sum}$. Inverting the equality via `.symm` establishes the theorem.

    line 4

    uses map_multiset_sum, Pi.evalAddMonoidHom

        (W.map (fun x => x j)).sum = W.sum j := (map_multiset_sum (Pi.evalAddMonoidHom G j) W).symm
map_multiset_sum
An additive monoid homomorphism preserves multiset sums: $f(\sum s) = \sum (s.\text{map } f)$.
Pi.evalAddMonoidHom
Evaluation at an index $j$, sending $x \mapsto x(j)$, is an additive monoid homomorphism from a dependent function space into the coordinate space.

Written by a model (gemini-3.8-flash) from the Lean source alone (no goal states were available). Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

/-- Pointwise coordinate evaluation commutes with multiset sum of functions. -/lemma multiset_sum_apply {t : ℕ} {G : Fin t → Type*}    [∀ i, AddCommMonoid (G i)] (W : Multiset ((i : Fin t) → G i)) (j : Fin t) :    (W.map (fun x => x j)).sum = W.sum j := (map_multiset_sum (Pi.evalAddMonoidHom G j) W).symm
See it in the graphDiscuss this resultChallenge it