Definition optSwap (A : Set)(opt : option (A * A)) :=
  match opt with
    | None => None
    | Some (a1, a2) =>
      Some (a2, a1)
  end.

(* Specifications: *)
Theorem optSwap_involutive : forall (A : Set)(opt : option (A * A)), optSwap (optSwap opt) = opt.
Theorem nth_listReplace_nil_eq : forall (A : Set) i (a def1 def2 : A), nth i (listReplace nil i a def1) def2 = a.
Theorem nth_listReplace_eq : forall (A : Set) i (ls : list A) a def1 def2, nth i (listReplace ls i a def1) def2 = a.
Theorem nth_NoDup : forall (A : Set)(ls : list (list A)) i, (forall e, In e ls -> NoDup e) -> NoDup (nth i ls nil).
Lemma listReplace_twice_nil : forall (A : Set)(n : nat) (a1 a2 def : A), listReplace (listReplace nil n a1 def) n a2 def = listReplace nil n a2 def.
Lemma listReplace_twice : forall (A : Set)(n : nat)(ls : list A) a1 a2 def, listReplace (listReplace ls n a1 def) n a2 def = listReplace ls n a2 def.
Lemma Bvector_ne_exists : forall (n : nat)(v : Bvector n), n > 0 -> exists v', v <> v'.
Lemma map_eq_inv : forall (A B : Set)(f1 f2 : A -> B)(ls : list A), map f1 ls = map f2 ls -> forall a, In a ls -> f1 a = f2 a.
Lemma nth_lt_length : forall (A : Set)(ls : list A)(i : nat) a def, nth i ls def = a -> def <> a -> i < length ls.
Lemma map_eq_nth_h : forall (A B C : Set) (f1 : A -> C)(f2 : B -> C)(lsa : list A)(lsb : list B), length lsa = length lsb -> map f1 lsa = map f2 lsb -> forall i def1 def2, i < length lsa -> f1 (nth i lsa def1) = f2 (nth i lsb def2).
Lemma map_eq_nth : forall (A B C : Set) i def1 def2 (f1 : A -> C)(f2 : B -> C)(lsa : list A)(lsb : list B), length lsa = length lsb -> map f1 lsa = map f2 lsb -> i < length lsa -> f1 (nth i lsa def1) = f2 (nth i lsb def2).
Lemma list_pred_flatten_both : forall (A B : Set)(P : A -> B -> Prop)(lsa : list (list A))(lsb : list (list B)), list_pred (list_pred P) lsa lsb -> list_pred P (flatten lsa) (flatten lsb).
Theorem compMap_wf : forall (A B : Set){eqdb : EqDec B}(c : A -> Comp B)(ls : list A), (forall a, In a ls -> well_formed_comp (c a)) -> well_formed_comp (compMap _ c ls).
Theorem list_pred_listReplace : forall n (A B : Set) P (lsa : list A)(lsb : list B), list_pred P lsa lsb -> forall a b defa defb, P a b -> P defa defb -> list_pred P (listReplace lsa n a defa) (listReplace lsb n b defb).
Theorem list_pred_nth : forall n (A B : Set) P (lsa : list A)(lsb : list B) defa defb, list_pred P lsa lsb -> P defa defb -> P (nth n lsa defa) (nth n lsb defb).
Theorem compFold_support_h : forall (A B : Set)(eqda : EqDec A)(P : A -> list B -> list B -> Prop)(c : A -> B -> Comp A) (ls1 ls2 ls3 : list B)(a z : A), In z (getSupport (compFold _ c a ls1)) -> P a ls2 (ls1 ++ ls3) -> (forall a1 a2 b ls1 ls2, In a2 (getSupport (c a1 b)) -> P a1 ls1 (b :: ls2) -> P a2 (ls1 ++ (b :: nil)) ls2 ) -> P z (ls2 ++ ls1) ls3.
Theorem compFold_support : forall (A B : Set)(eqda : EqDec A)(P : A -> list B -> list B -> Prop)(c : A -> B -> Comp A) (ls1 : list B)(a z : A), In z (getSupport (compFold _ c a ls1)) -> P a nil ls1 -> (forall a1 a2 b ls1 ls2, In a2 (getSupport (c a1 b)) -> P a1 ls1 (b :: ls2) -> P a2 (ls1 ++ (b :: nil)) ls2 ) -> P z ls1 nil.
Theorem list_pred_app_both_if : forall (A B : Set) P (x y : list A)(z q : list B), length x = length z -> list_pred P (x ++ y) (z ++ q) -> list_pred P x z /\ list_pred P y q.
Theorem compMap_seq_map : forall (A B C : Set)(eqdc : EqDec C)(ls : list A)(f : A -> B)(c : B -> Comp C), comp_spec eq (compMap _ c (map f ls)) (compMap _ (fun x => c (f x)) ls).
Theorem compFold_ret_eq : forall (A B : Set)(eqdb : EqDec B)(ls : list A)(f : B -> A -> B) init, comp_spec eq (compFold _ (fun b a => ret (f b a)) init ls) (ret (fold_left f ls init)).