Ltac hypInv :=
      try (match goal with
          | [H: Some _ = Some _ |-_ ] => inversion H; clear H; subst
      end); try pairInv.Fixpoint lookupIndex (A : Set)(eqd : eq_dec A)(ls : list A)(a : A) def :=
  match ls with
    | nil => def
    | a' :: ls' =>
      if (eqd a a') then O else S (lookupIndex eqd ls' a def)
  end.

Lemma fold_left_add_removePresent : forall (B : Set)(eqd : eq_dec B)(f : B -> nat)(ls u : list B), NoDup ls -> NoDup u -> fold_left (fun acc b => (acc + (f b))%nat) (removePresent eqd u ls) O = minus (fold_left (fun acc b => (acc + (f b))%nat) ls O) (fold_left (fun acc b => (acc + (f b))%nat) (intersect eqd ls u) O).