(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(** * Typeclass-based setoids, tactics and standard instances.  Author: Matthieu Sozeau Institution: LRI, CNRS UMR 8623 - University Paris Sud *)
Set Implicit Arguments.
Unset Strict Implicit.
Generalizable Variables A.
Require Export Stdlib.Classes.RelationClasses.
Require Export Stdlib.Classes.Morphisms.
(** A setoid wraps an equivalence. *)
Class Setoid A := {
equiv : relation A ;
#[global] setoid_equiv :: Equivalence equiv }.
(* Too dangerous instance *)
(* Program Instance [ eqa : Equivalence A eqA ] =>  *)
(*   equivalence_setoid : Setoid A := *)
(*   equiv := eqA ; setoid_equiv := eqa. *)
(** Shortcuts to make proof search easier. *)

(* Specifications: *)
Lemma setoid_refl `(sa : Setoid A) : Reflexive equiv.
Lemma equiv_nequiv_trans : forall `{Setoid A} (x y z : A), x == y -> y =/= z -> x =/= z.
Ltac setoid_simplify_one :=
match goal with
| [ H : (?x == ?x)%type |- _ ] => clear H
| [ H : (?x == ?y)%type |- _ ] => clsubst H
| [ |- (?x =/= ?y)%type ] => let name:=fresh "Hneq" in intro name
end.