### Nuprl Lemma : bag-summation-filter

`∀[T,R:Type]. ∀[add:R ⟶ R ⟶ R]. ∀[zero:R]. ∀[b:bag(T)]. ∀[p:T ⟶ 𝔹]. ∀[f:T ⟶ R].`
`  Σ(x∈[x∈b|p[x]]). f[x] = Σ(x∈b). if p[x] then f[x] else zero fi  ∈ R supposing IsMonoid(R;add;zero) ∧ Comm(R;add)`

Proof

Definitions occuring in Statement :  bag-summation: `Σ(x∈b). f[x]` bag-filter: `[x∈b|p[x]]` bag: `bag(T)` comm: `Comm(T;op)` ifthenelse: `if b then t else f fi ` bool: `𝔹` uimplies: `b supposing a` uall: `∀[x:A]. B[x]` so_apply: `x[s]` and: `P ∧ Q` function: `x:A ⟶ B[x]` universe: `Type` equal: `s = t ∈ T` monoid_p: `IsMonoid(T;op;id)`
Definitions unfolded in proof :  uall: `∀[x:A]. B[x]` member: `t ∈ T` uimplies: `b supposing a` and: `P ∧ Q` prop: `ℙ` squash: `↓T` so_apply: `x[s]` so_lambda: `λ2x.t[x]` all: `∀x:A. B[x]` cand: `A c∧ B` true: `True` subtype_rel: `A ⊆r B` guard: `{T}` iff: `P `⇐⇒` Q` rev_implies: `P `` Q` implies: `P `` Q` infix_ap: `x f y` bool: `𝔹` unit: `Unit` it: `⋅` btrue: `tt` ifthenelse: `if b then t else f fi ` uiff: `uiff(P;Q)` bfalse: `ff` bnot: `¬bb` not: `¬A` false: `False` exists: `∃x:A. B[x]` or: `P ∨ Q` sq_type: `SQType(T)` assert: `↑b` monoid_p: `IsMonoid(T;op;id)` ident: `Ident(T;op;id)`
Lemmas referenced :  bag-summation-split monoid_p_wf comm_wf bool_wf bag_wf equal_wf squash_wf true_wf bag-summation_wf assert_wf bag-filter_wf ifthenelse_wf iff_weakening_equal eqtt_to_assert bag-summation-is-zero bnot_wf assert_elim bfalse_wf and_wf btrue_neq_bfalse eqff_to_assert bool_cases_sqequal subtype_base_sq bool_subtype_base assert-bnot bag-member_wf set_wf assoc_wf not_assert_elim
Rules used in proof :  cut introduction extract_by_obid sqequalSubstitution sqequalTransitivity computationStep sqequalReflexivity isect_memberFormation hypothesis sqequalHypSubstitution isectElimination thin hypothesisEquality productElimination productEquality cumulativity functionExtensionality applyEquality sqequalRule isect_memberEquality axiomEquality because_Cache equalityTransitivity equalitySymmetry functionEquality universeEquality lambdaEquality imageElimination setEquality lambdaFormation setElimination rename independent_isectElimination independent_pairFormation natural_numberEquality imageMemberEquality baseClosed independent_functionElimination unionElimination equalityElimination dependent_functionElimination addLevel levelHypothesis dependent_set_memberEquality applyLambdaEquality voidElimination dependent_pairFormation promote_hyp instantiate

Latex:
\mforall{}[T,R:Type].  \mforall{}[add:R  {}\mrightarrow{}  R  {}\mrightarrow{}  R].  \mforall{}[zero:R].  \mforall{}[b:bag(T)].  \mforall{}[p:T  {}\mrightarrow{}  \mBbbB{}].  \mforall{}[f:T  {}\mrightarrow{}  R].
\mSigma{}(x\mmember{}[x\mmember{}b|p[x]]).  f[x]  =  \mSigma{}(x\mmember{}b).  if  p[x]  then  f[x]  else  zero  fi