(** * Results on joining lists and the necessary algebras *)

Fixpoint joinlist {A} {JA : Join A} (l : list A) (x : A) :=
  match l with
  | nil => identity x
  | h :: l => exists y, joinlist l y /\ join h y x
  end.

Lemma joinlist_permutation {A} {JA : Join A} {PA : Perm_alg A} l1 l2 r : Permutation l1 l2 -> joinlist l1 r -> joinlist l2 r.