(** * Merge *)
Definition double_measure (lss: list nat * list nat):= (length (fst lss) + length (snd lss)).
Function merge (lss: list nat * list nat)
{measure double_measure}:=
match lss with
| (ls1, ls2) =>
match ls1 with
nil => ls2
| cons n ls1' =>
match ls2 with
nil => ls1
| cons m ls2' =>
if n <? m then
cons n (merge (ls1', ls2))
else
cons m (merge (ls1, ls2'))
end
end
end.
- intros; simpl.
unfold double_measure; simpl.
omega.
- intros; simpl.
unfold double_measure; simpl.
omega.
Defined.

(* Specifications: *)
Lemma merge_length: forall lss,
length (merge lss) = length (fst lss) + length (snd lss).