(** *** Concatenating lists of strings *)
(** [concat sep sl] concatenates the list of strings [sl], inserting the separator string [sep] between each. *)
Fixpoint concat (sep : string) (ls : list string) :=
match ls with
| nil => EmptyString
| cons x nil => x
| cons x xs => x ++ sep ++ concat sep xs
end.
(** *** Test functions *)
(** Test if [s1] is a prefix of [s2] *)
Fixpoint prefix (s1 s2 : string) {struct s2} : bool :=
match s1 with
| EmptyString => true
| String a s1' =>
match s2 with
| EmptyString => false
| String b s2' =>
match ascii_dec a b with
| left _ => prefix s1' s2'
| right _ => false
end
end
end.
(** If [s1] is a prefix of [s2], it is the [substring] of length [length s1] starting at position [O] of [s2] *)

(* Specifications: *)
Theorem prefix_correct :
forall s1 s2 : string,
prefix s1 s2 = true <-> substring 0 (length s1) s2 = s1.