Instance preds_join PRED : Join _ := Join_equiv (fpreds PRED).
Inductive ghost_elem_join : Join {g: Ghost & {a: @G g | ghost.valid a}} :=
| elem_join_I g a b c va vb vc: join a b c ->
ghost_elem_join (existT _ g (exist _ a va)) (existT _ g (exist _ b vb))
(existT _ g (exist _ c vc)).
Existing Instance ghost_elem_join.
Inductive ghost_join PRED : Join (ghost PRED) :=
| ghost_join_nil_l m: ghost_join PRED nil m m
| ghost_join_nil_r m: ghost_join PRED m nil m
| ghost_join_cons a1 a2 m1 m2 a3 m3: join a1 a2 a3 -> ghost_join PRED m1 m2 m3 ->
ghost_join PRED (a1 :: m1) (a2 :: m2) (a3 :: m3).
Hint Constructors ghost_join.
Existing Instance ghost_join.

Lemma elem_join_inv: forall a1 a2 a3, ghost_elem_join a1 a2 a3 ->
match a1, a2, a3 with
| existT g1 (exist x1 _), existT g2 (exist x2 _), existT g3 (exist x3 _) =>
exists H: g2 = g1, exists H': g3 = g1, join x1 (eq_rect _ _ x2 _ H) (eq_rect _ _ x3 _ H')
end.