(*******************)
(** * Delocations  *)
(*******************)

(** Let (X, A) and (Y, B) be two graphs.  A delocation from (X, A) to
    (Y, B) is a function f : X->Y such that:

    1. (x,x':X)    (A x' x) -> (B (f x') (f x))

    2. (x:X; y':Y) (B y' (f x)) -> (Ex x':X | (A x' x) /\ y'=(f x'))

    Intuitively, a delocation is a morphism of graphs in which any edge
    of the target graph (Y, B) which points to an element of the image
    of f can be tracked back as an edge in the source graph via f.
    This notion is formalized as follows: *)

Definition deloc (X : Typ1) (A : Rel X) (Y : Typ1) 
  (B : Rel Y) (f : X -> Y) : Prop :=
  and (forall x x' : X, A x' x -> B (f x') (f x))
    (forall (x : X) (y' : Y),
     B y' (f x) -> ex2 X (fun x' => A x' x) (fun x' => eq Y y' (f x'))).

Lemma EQV_deloc : forall (X : Typ1) (A : Rel X) (Y : Typ1) (B : Rel Y) (f : X -> Y), deloc X A Y B f -> forall x : X, EQV X A x Y B (f x).