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 ghost_join_inv: forall PRED m1 m2 m3, ghost_join PRED m1 m2 m3 ->
match m1, m2 with
| nil, _ => m3 = m2
| _, nil => m3 = m1
| a1 :: m1, a2 :: m2 => match m3 with nil => False
| a3 :: m3 => join a1 a2 a3 /\ ghost_join PRED m1 m2 m3 end
end.