(******************************************************)
(** * Compatible relations and the collection scheme  *)
(******************************************************)

(** ** Binary relations **)

(** The type of binary relations over pointed graphs: *)

Definition REL : Typ2 :=
  forall X : Typ1, Rel X -> X -> forall Y : Typ1, Rel Y -> Y -> Prop.(** And the corresponding (left and right) compatibility properties: *)

Definition LCOMPAT (R : REL) : Prop :=
  forall (X : Typ1) (A : Rel X) (a : X) (Y : Typ1) 
    (B : Rel Y) (b : Y) (Z : Typ1) (C : Rel Z) (c : Z),
  EQV X A a Y B b -> R Y B b Z C c -> R X A a Z C c.Definition RCOMPAT (R : REL) : Prop :=
  forall (X : Typ1) (A : Rel X) (a : X) (Y : Typ1) 
    (B : Rel Y) (b : Y) (Z : Typ1) (C : Rel Z) (c : Z),
  R X A a Y B b -> EQV Y B b Z C c -> R X A a Z C c.(** It is convenient to define a relativized form (exG_rel X A a P) of
    the existential quantifier on the class of pointed graphs, that
    expresses that the predicate P holds for some element of the
    pointed graph (X, A, a). *)

Definition exG_rel (X : Typ1) (A : Rel X) (a : X)
  (P : forall Y : Typ1, Rel Y -> Y -> Prop) :=
  forall E : Prop,
  (forall (Y : Typ1) (B : Rel Y) (b : Y), ELT Y B b X A a -> P Y B b -> E) ->
  E.

Lemma exG_rel_intro : forall (X : Typ1) (A : Rel X) (a : X) (P : forall Y : Typ1, Rel Y -> Y -> Prop) (Y : Typ1) (B : Rel Y) (b : Y), ELT Y B b X A a -> P Y B b -> exG_rel X A a P.