Definition singleton {A} k (x : A) : list (option A) := repeat None k ++ Some x :: nil.Definition gname := nat.Definition list_set {A} (m : list (option A)) k v : list (option A) :=
  firstn k m ++ repeat None (k - length m) ++ Some v :: skipn (S k) m.

Lemma singleton_join_inv_gen: forall k a (b c: ghost), join (singleton k a) b c -> join (Some a) (nth k b None) (nth k c None) /\ exists c', nth k c None = Some c' /\ c = list_set b k c'.