Definition omap := match o with Some a => Some (h a) | None => None end.Definition obnd := match o with Some a => f a | None => None end.Definition isSome {A : Type} (o : option A) :=
  match o with Some _ => true | _ => false end.Definition compose := g (f a).Notation "[ x , .. , y ]" := (cons x .. (cons y []) ..).Fixpoint zip_with_acc {A B : Type} acc (l1 : list A) (l2 : list B) :=
  match l1, l2 with
    | a :: l1', b :: l2' => (a, b) :: zip_with_acc acc l1' l2'
    | _, _ => acc
  end.Definition zip {A B : Type} := @zip_with_acc A B [].Fixpoint iter (n : nat) (a : A) :=
  match n with
    | O => a
    | S n' => iter n' (f n' a)
  end.Fixpoint tryfind (err : E) (l : list A) :=
  match l with
    | nil => inl _ err
    | a :: l' => match f a with
                   | inl err' => tryfind err' l'
                   | inr success as r => r
                 end
  end.Definition max (n m : nat) := if leb n m then m else n.Definition maxs (l : list nat) := fold_left (fun m n => max m n) l 0.Definition elemb (n : nat) := existsb (fun m => beq_nat n m).

Lemma Ppred_decrease n : (n<>1)%positive -> (nat_of_P (Ppred n)<nat_of_P n)%nat.