(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \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)         *)
(************************************************************************)
(** John Major's Equality as proposed by Conor McBride  Reference:  [McBride] Elimination with a Motive, Proceedings of TYPES 2000, LNCS 2277, pp 197-216, 2002.  *)
Set Implicit Arguments.
Unset Elimination Schemes.
Inductive JMeq (A:Type) (x:A) : forall B:Type, B -> Prop :=
JMeq_refl : JMeq x x.
Set Elimination Schemes.
Arguments JMeq_refl {A x} , [A] x.
Register JMeq as core.JMeq.type.
Register JMeq_refl as core.JMeq.refl.
Hint Resolve JMeq_refl : core.
Definition JMeq_hom {A : Type} (x y : A) := JMeq x y.
Register JMeq_hom as core.JMeq.hom.
Hint Immediate JMeq_sym : core.
Register JMeq_sym as core.JMeq.sym.
Register JMeq_trans as core.JMeq.trans.
Register JMeq_ind as core.JMeq.ind.
Register JMeq_congr as core.JMeq.congr.
(** [JMeq] is equivalent to [eq_dep Type (fun X => X)] *)
(** [eq_dep U P p x q y] is strictly finer than [JMeq (P p) x (P q) y] *)
(** However, when the dependencies are equal, [JMeq (P p) x (P q) y] is as strong as [eq_dep U P p x q y] (this uses [JMeq_eq]) *)

Lemma JMeq_eq_dep :
forall U (P:U->Type) p q (x:P p) (y:P q),
p = q -> JMeq x y -> eq_dep U P p x q y.