Fixpoint flatten(A : Type)(ls : list (list A)) :=
  match ls with
    | nil => nil
    | a :: ls' => a ++ (flatten ls')
  end.

(* Specifications: *)
Theorem in_flatten : forall (A : Set)(ls : list (list A)) a, In a (flatten ls) <-> exists x : _, In x ls /\ In a x.
Theorem length_flatten_nz : forall (A : Type)(ls : list (list A)) ls', In ls' ls -> length ls' > 0 -> length (flatten ls) > 0.