Definition respectful {X} (P : dist X -> Prop) : Prop :=
  forall d1 d2, d1 ==d d2 -> P d1 <-> P d2.

Lemma part_lemma {X Y} (part : X -> Y -> bool) (f : Y -> Q) (xs : list X) : (forall x x' y, part x y = true -> part x' y = true -> x = x') -> NoDup xs -> forall ys : list Y, (forall y, In y ys -> exists x, In x xs /\ part x y = true) -> Qsum (map f ys) == Qsum (map (fun x => Qsum (map f (filter (part x) ys))) xs).