(** ** 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.

(* Specifications: *)
Lemma rel_incr_rintro {W A B} (acc: rel W W) (R: W -> rel A B) w w' m n: RExists (R w' m n /\ acc w w') (rel_incr acc R w) m n.
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)).