(** * Interoperation with [Coq.Classes.Morphisms] *)
(** Although ultimately we will reimplement a [rewrite] tactic, and our system is largely designed to replace the setoid rewriting support in [Coq.Classes.Morphisms], we still want to be compatible with it so that:  - we can take advantage of the relational properties declared in the old system; - the generalized [setoid_rewrite] can take advantage of our library for answering its [Morphisms.Proper] queries.  This compatibility layer is pretty straightforward: we simply declare the instances we need in order to use the properties declared in the old system, and use [rauto] to handle [Morphisms.Proper] queries. *)
(** ** Using [Morphisms]-style relational properties *)
(** *** Relators *)
(** While [Coq.Classes.Morphisms] uses a distinct set of relators from ours, we don't try to map them into our language. Instead, we hook them into our system the same way we do our generalized versions, so that [respectful] and the like can be used as just another set of "native" Coqrel relators. *)
Global Instance respectful_subrel A B:
Monotonic (@respectful A B) (subrel --> subrel ++> subrel).
Global Instance respectful_params:
Params (@respectful) 4.
Defined.
Hint Extern 0 (RIntro _ (respectful _ _) _ _) =>
eapply respectful_rintro : typeclass_instances.

Lemma respectful_relim {A B} (RA: relation A) (RB: relation B) f g m n P Q:
RElim RB (f m) (g n) P Q ->
RElim (respectful RA RB) f g (RA m n /\ P) Q.