Hint Extern 1 (RElim (rel_ex _) _ _ _ _) =>
eapply rel_ex_relim : typeclass_instances.
(** ** 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.
(** While it's possible to define a more general monotonicity property for [rel_incr], this one is well-behaved and usually corresponds to what we want. *)
Global Instance rel_incr_subrel {W A B} acc:
Transitive acc ->
Monotonic (@rel_incr W A B acc) ((- ==> subrel) ++> acc --> subrel).
Global Instance rel_incr_subrel_params:
Params (@rel_incr) 4.
(** Note the order of the premises in our intro rule. We want to first determine what [w'] should be, then prove [acc w w']. *)

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