(** Comparison functions. *)
Require Char.
(** Total order on strings. *)
Fixpoint compare (x y : t) : comparison :=
match x, y with
| [], [] => Eq
| [], _ => Lt
| _, [] => Gt
| x :: xs, y :: ys =>
match Char.compare x y with
| Eq => compare xs ys
| c => c
end
end.

Lemma compare_implies_eq : forall (x y : t), compare x y = Eq -> x = y.
induction x as [|a x HI]; destruct y as [|b y]; simpl; try congruence.