(** ** The [rel_incr] construction *)

(** XXX: this is on the way out, see KLR.v *)

(** When dealing with Kripke logical relations, we have a family of
  relations indexed by a type of worlds, as well as an accessibility
  relation over this type of worlds. We often want to state that there
  exists a world accessible from a base one in which the relation
  holds. The following construction expresses this. *)

Definition rel_incr {W A B} (acc: rel W W) (R: W -> rel A B): W -> rel A B :=
  fun w a b => exists w', acc w w' /\ R w' a b.Global Instance rel_incr_subrel_params:
  Params (@rel_incr) 4.

Lemma rel_incr_rdestruct {W A B} acc R w T: (forall w, exists Tw, RDestruct (R w) Tw /\ Convertible (T w) Tw) -> RDestruct (@rel_incr W A B acc R w) (fun P => forall w', acc w w' -> Delay.unpack (T w' P)).