Local Lemma compare_helper_eq {a b : ascii} (E : cmp a b = Eq):
a = b.
Local Lemma compare_helper_gt {a b : ascii} (G : cmp a b = Gt):
lt b a.
Definition compare (a b : ascii) : Compare lt eq a b :=
match cmp a b as z return _ = z -> _ with
| Lt => fun E => LT E
| Gt => fun E => GT (compare_helper_gt E)
| Eq => fun E => EQ (compare_helper_eq E)
end Logic.eq_refl.
Definition eq_dec (x y : ascii): {x = y} + { ~ (x = y)} := ascii_dec x y.
End Ascii_as_OT.
(** [String] is an ordered type with respect to the usual lexical order. *)
Module String_as_OT <: UsualOrderedType.
Definition t := string.
Definition eq := @eq string.
Definition eq_refl := @eq_refl t.
Definition eq_sym := @eq_sym t.
Definition eq_trans := @eq_trans t.
Inductive lts : string -> string -> Prop :=
| lts_empty : forall a s, lts EmptyString (String a s)
| lts_tail : forall a s1 s2, lts s1 s2 -> lts (String a s1) (String a s2)
| lts_head : forall (a b : ascii) s1 s2,
lt (nat_of_ascii a) (nat_of_ascii b) ->
lts (String a s1) (String b s2).
Definition lt := lts.

Lemma nat_of_ascii_inverse a b : nat_of_ascii a = nat_of_ascii b -> a = b.