Section tryfind.
Variables (A E B : Type) (f : A -> E + B).
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.
End tryfind.
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).
(*positive lemmas*)
(* N lemmas *)
Definition Nleb (x y : N) :=
match Ncompare x y with
| Lt => true
| Eq => true
| Gt => false
end.

Lemma Nleb_Nle (x y : N) : Nleb x y = true <-> Nle x y.