:= 0. #[
.
:= 1.
diff --git a/test-suite/coqdoc/bug11353.tex.out b/test-suite/coqdoc/bug11353.tex.out
index 1a6eb36f3aca..47a95bcb03fa 100644
--- a/test-suite/coqdoc/bug11353.tex.out
+++ b/test-suite/coqdoc/bug11353.tex.out
@@ -24,9 +24,9 @@
\coqdocnoindent
\coqdockw{Inductive} \coqdef{Coqdoc.bug11353.mysum}{mysum}{\coqdocinductive{mysum}} (\coqdef{Coqdoc.bug11353.A:1}{A}{\coqdocbinder{A}} \coqdef{Coqdoc.bug11353.B:2}{B}{\coqdocbinder{B}}:\coqdockw{Type}) : \coqdockw{Type} :=\coqdoceol
\coqdocindent{1.00em}
-\ensuremath{|} \coqdef{Coqdoc.bug11353.myinl}{myinl}{\coqdocconstructor{myinl}} : \coqref{Coqdoc.bug11353.A:1}{\coqdocvariable{A}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Logic}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.bug11353.mysum:3}{\coqdocinductive{mysum}} \coqref{Coqdoc.bug11353.A:1}{\coqdocvariable{A}} \coqref{Coqdoc.bug11353.B:2}{\coqdocvariable{B}}\coqdoceol
+\ensuremath{|} \coqdef{Coqdoc.bug11353.myinl}{myinl}{\coqdocconstructor{myinl}} : \coqref{Coqdoc.bug11353.A:1}{\coqdocvariable{A}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Notations}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.bug11353.mysum:3}{\coqdocinductive{mysum}} \coqref{Coqdoc.bug11353.A:1}{\coqdocvariable{A}} \coqref{Coqdoc.bug11353.B:2}{\coqdocvariable{B}}\coqdoceol
\coqdocindent{1.00em}
-\ensuremath{|} \coqdef{Coqdoc.bug11353.myinr}{myinr}{\coqdocconstructor{myinr}} : \coqref{Coqdoc.bug11353.B:2}{\coqdocvariable{B}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Logic}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.bug11353.mysum:3}{\coqdocinductive{mysum}} \coqref{Coqdoc.bug11353.A:1}{\coqdocvariable{A}} \coqref{Coqdoc.bug11353.B:2}{\coqdocvariable{B}}.\coqdoceol
+\ensuremath{|} \coqdef{Coqdoc.bug11353.myinr}{myinr}{\coqdocconstructor{myinr}} : \coqref{Coqdoc.bug11353.B:2}{\coqdocvariable{B}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Notations}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.bug11353.mysum:3}{\coqdocinductive{mysum}} \coqref{Coqdoc.bug11353.A:1}{\coqdocvariable{A}} \coqref{Coqdoc.bug11353.B:2}{\coqdocvariable{B}}.\coqdoceol
\coqdocemptyline
\coqdocnoindent
\#[\coqdocvar{local}]\coqdockw{Definition} \coqdef{Coqdoc.bug11353.b}{b}{\coqdocdefinition{b}} := 1.\coqdoceol
diff --git a/test-suite/coqdoc/links.html.out b/test-suite/coqdoc/links.html.out
index 13e8b8c10b38..05bd88914357 100644
--- a/test-suite/coqdoc/links.html.out
+++ b/test-suite/coqdoc/links.html.out
@@ -68,7 +68,7 @@ Various checks for coqdoc
.
diff --git a/test-suite/coqdoc/links.tex.out b/test-suite/coqdoc/links.tex.out
index 5a035db885b4..63d2b7c367d8 100644
--- a/test-suite/coqdoc/links.tex.out
+++ b/test-suite/coqdoc/links.tex.out
@@ -60,7 +60,7 @@ Various checks for coqdoc
\coqdockw{Notation} \coqdef{Coqdoc.links.:::x ''' ''' '++' 'x' x}{"}{"}n '\_' ++ 'x' m" := (\coqexternalref{plus}{http://coq.inria.fr/stdlib/Corelib.Init.Peano}{\coqdocabbreviation{plus}} \coqdocvar{n} \coqdocvar{m}) (\coqdoctac{at} \coqdockw{level} 3).\coqdoceol
\coqdocemptyline
\coqdocnoindent
-\coqdockw{Inductive} \coqdef{Coqdoc.links.eq}{eq}{\coqdocinductive{eq}} (\coqdef{Coqdoc.links.A:3}{A}{\coqdocbinder{A}}:\coqdockw{Type}) (\coqdef{Coqdoc.links.x:4}{x}{\coqdocbinder{x}}:\coqref{Coqdoc.links.A:3}{\coqdocvariable{A}}) : \coqdocvar{A} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Logic}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqdockw{Prop} := \coqdef{Coqdoc.links.eq refl}{eq\_refl}{\coqdocconstructor{eq\_refl}} : \coqref{Coqdoc.links.x:4}{\coqdocvariable{x}} \coqref{Coqdoc.links.::type scope:x '=' x ':>' x}{\coqdocnotation{=}} \coqref{Coqdoc.links.x:4}{\coqdocvariable{x}} \coqref{Coqdoc.links.::type scope:x '=' x ':>' x}{\coqdocnotation{:>}}\coqref{Coqdoc.links.A:3}{\coqdocvariable{A}}\coqdoceol
+\coqdockw{Inductive} \coqdef{Coqdoc.links.eq}{eq}{\coqdocinductive{eq}} (\coqdef{Coqdoc.links.A:3}{A}{\coqdocbinder{A}}:\coqdockw{Type}) (\coqdef{Coqdoc.links.x:4}{x}{\coqdocbinder{x}}:\coqref{Coqdoc.links.A:3}{\coqdocvariable{A}}) : \coqdocvar{A} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Notations}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqdockw{Prop} := \coqdef{Coqdoc.links.eq refl}{eq\_refl}{\coqdocconstructor{eq\_refl}} : \coqref{Coqdoc.links.x:4}{\coqdocvariable{x}} \coqref{Coqdoc.links.::type scope:x '=' x ':>' x}{\coqdocnotation{=}} \coqref{Coqdoc.links.x:4}{\coqdocvariable{x}} \coqref{Coqdoc.links.::type scope:x '=' x ':>' x}{\coqdocnotation{:>}}\coqref{Coqdoc.links.A:3}{\coqdocvariable{A}}\coqdoceol
\coqdocnoindent
\coqdoceol
\coqdocnoindent
diff --git a/test-suite/coqdoc/multiple_links.html.out b/test-suite/coqdoc/multiple_links.html.out
index 66a4dc1f9f3d..3f5df5f2e3ff 100644
--- a/test-suite/coqdoc/multiple_links.html.out
+++ b/test-suite/coqdoc/multiple_links.html.out
@@ -19,7 +19,7 @@
diff --git a/test-suite/coqdoc/multiple_links.tex.out b/test-suite/coqdoc/multiple_links.tex.out
index c4541f778afa..38242e649fd2 100644
--- a/test-suite/coqdoc/multiple_links.tex.out
+++ b/test-suite/coqdoc/multiple_links.tex.out
@@ -20,7 +20,7 @@
\begin{coqdoccode}
\coqdocnoindent
-\coqdockw{Inductive} \coqdef{Coqdoc.multiple links.t}{t}{\coqdocinductive{t}} := \coqdef{Coqdoc.multiple links.X}{X}{\coqdocconstructor{X}} \ensuremath{|} \coqdef{Coqdoc.multiple links.T}{T}{\coqdocconstructor{T}} : \coqref{Coqdoc.multiple links.t:1}{\coqdocinductive{t}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Logic}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.multiple links.t:1}{\coqdocinductive{t}}.\coqdoceol
+\coqdockw{Inductive} \coqdef{Coqdoc.multiple links.t}{t}{\coqdocinductive{t}} := \coqdef{Coqdoc.multiple links.X}{X}{\coqdocconstructor{X}} \ensuremath{|} \coqdef{Coqdoc.multiple links.T}{T}{\coqdocconstructor{T}} : \coqref{Coqdoc.multiple links.t:1}{\coqdocinductive{t}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Notations}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.multiple links.t:1}{\coqdocinductive{t}}.\coqdoceol
\coqdocnoindent
\coqdockw{Check} \coqref{Coqdoc.multiple links.X}{\coqdocconstructor{X}}.\coqdoceol
\coqdocnoindent
diff --git a/test-suite/coqdoc/typeclasses.html.out b/test-suite/coqdoc/typeclasses.html.out
index 29a342468d89..23260cb349b4 100644
--- a/test-suite/coqdoc/typeclasses.html.out
+++ b/test-suite/coqdoc/typeclasses.html.out
@@ -19,7 +19,7 @@
-
Class EqDec T := {
eqb :
T → T → bool }.
+
Class EqDec T := {
eqb :
T → T → bool }.
Section TC.
diff --git a/test-suite/coqdoc/typeclasses.tex.out b/test-suite/coqdoc/typeclasses.tex.out
index f1c94d43aa9c..1a20ef4f3b8d 100644
--- a/test-suite/coqdoc/typeclasses.tex.out
+++ b/test-suite/coqdoc/typeclasses.tex.out
@@ -20,7 +20,7 @@
\begin{coqdoccode}
\coqdocnoindent
-\coqdockw{Class} \coqdef{Coqdoc.typeclasses.EqDec}{EqDec}{\coqdocrecord{EqDec}} \coqdef{Coqdoc.typeclasses.T:1}{T}{\coqdocbinder{T}} := \{ \coqdef{Coqdoc.typeclasses.eqb}{eqb}{\coqdocprojection{eqb}} : \coqref{Coqdoc.typeclasses.T:1}{\coqdocvariable{T}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Logic}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.typeclasses.T:1}{\coqdocvariable{T}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Logic}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqexternalref{bool}{http://coq.inria.fr/stdlib/Corelib.Init.Datatypes}{\coqdocinductive{bool}} \}.\coqdoceol
+\coqdockw{Class} \coqdef{Coqdoc.typeclasses.EqDec}{EqDec}{\coqdocrecord{EqDec}} \coqdef{Coqdoc.typeclasses.T:1}{T}{\coqdocbinder{T}} := \{ \coqdef{Coqdoc.typeclasses.eqb}{eqb}{\coqdocprojection{eqb}} : \coqref{Coqdoc.typeclasses.T:1}{\coqdocvariable{T}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Notations}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqref{Coqdoc.typeclasses.T:1}{\coqdocvariable{T}} \coqexternalref{::type scope:x '->' x}{http://coq.inria.fr/stdlib/Corelib.Init.Notations}{\coqdocnotation{\ensuremath{\rightarrow}}} \coqexternalref{bool}{http://coq.inria.fr/stdlib/Corelib.Init.Datatypes}{\coqdocinductive{bool}} \}.\coqdoceol
\coqdocemptyline
\coqdocnoindent
\coqdockw{Section} \coqdef{Coqdoc.typeclasses.TC}{TC}{\coqdocsection{TC}}.\coqdoceol
diff --git a/test-suite/output/Arguments_renaming.out b/test-suite/output/Arguments_renaming.out
index af123329ebf4..44d996320118 100644
--- a/test-suite/output/Arguments_renaming.out
+++ b/test-suite/output/Arguments_renaming.out
@@ -23,7 +23,7 @@ eq_refl is template universe polymorphic
Arguments eq_refl {B}%_type_scope {y}, [_] _
(where some original arguments have been renamed)
Expands to: Constructor Corelib.Init.Logic.eq_refl
-Declared in library Corelib.Init.Logic, line 382, characters 4-11
+Declared in library Corelib.Init.Logic, line 380, characters 4-11
Inductive myEq (B : Type) (x : A) : A -> Prop := myrefl : B -> myEq B x x.
Arguments myEq B%_type_scope x _
diff --git a/test-suite/output/Inductive.out b/test-suite/output/Inductive.out
index 62d1e8d0089b..fac27879494a 100644
--- a/test-suite/output/Inductive.out
+++ b/test-suite/output/Inductive.out
@@ -40,7 +40,7 @@ or is not universe polymorphic
or may only be eliminated to produce values whose type is SProp or Prop.
Arguments or (A B)%_type_scope
Expands to: Inductive Corelib.Init.Logic.or
-Declared in library Corelib.Init.Logic, line 89, characters 10-12
+Declared in library Corelib.Init.Logic, line 87, characters 10-12
sunit : SProp
sunit is not universe polymorphic
diff --git a/test-suite/output/PrintInfos.out b/test-suite/output/PrintInfos.out
index a472dfd39e04..aa8a989b7526 100644
--- a/test-suite/output/PrintInfos.out
+++ b/test-suite/output/PrintInfos.out
@@ -21,7 +21,7 @@ eq_refl : forall {A : Type} {x : A}, x = x
eq_refl is template universe polymorphic
Arguments eq_refl {A}%_type_scope {x}, [_] _
Expands to: Constructor Corelib.Init.Logic.eq_refl
-Declared in library Corelib.Init.Logic, line 382, characters 4-11
+Declared in library Corelib.Init.Logic, line 380, characters 4-11
eq_refl : forall {A : Type} {x : A}, x = x
When applied to no arguments:
@@ -84,7 +84,7 @@ Arguments bar {x}
Module Corelib.Init.Peano
Notation sym_eq := eq_sym
Expands to: Notation Corelib.Init.Logic.sym_eq
-Declared in library Corelib.Init.Logic, line 754, characters 0-45
+Declared in library Corelib.Init.Logic, line 764, characters 0-45
eq_sym : forall [A : Type] [x y : A], x = y -> y = x
@@ -115,14 +115,14 @@ Alias.eq is template universe polymorphic
Arguments Alias.eq {A}%_type_scope x _
Expands to: Inductive PrintInfos.Alias.eq (syntactically equal to
Corelib.Init.Logic.eq)
-Declared in library Corelib.Init.Logic, line 381, characters 10-12
+Declared in library Corelib.Init.Logic, line 379, characters 10-12
Alias.eq_refl : forall {A : Type} {x : A}, x = x
Alias.eq_refl is template universe polymorphic
Arguments Alias.eq_refl {A}%_type_scope {x}, [_] _
Expands to: Constructor PrintInfos.Alias.eq_refl (syntactically equal to
Corelib.Init.Logic.eq_refl)
-Declared in library Corelib.Init.Logic, line 382, characters 4-11
+Declared in library Corelib.Init.Logic, line 380, characters 4-11
Alias.eq_ind :
forall [A : Type] (x : A) (P : A -> Prop), P x -> forall y : A, x = y -> P y
@@ -132,7 +132,7 @@ Arguments Alias.eq_ind [A]%_type_scope x P%_function_scope eq_refl y e
Alias.eq_ind is transparent
Expands to: Constant PrintInfos.Alias.eq_ind (syntactically equal to
Corelib.Init.Logic.eq_ind)
-Declared in library Corelib.Init.Logic, line 381, characters 0-115
+Declared in library Corelib.Init.Logic, line 379, characters 0-115
fst : forall A B : Type, prod A B -> A
fst is not universe polymorphic
diff --git a/test-suite/output/SearchPattern.out b/test-suite/output/SearchPattern.out
index c4407cec2a00..4a06c5c6eb78 100644
--- a/test-suite/output/SearchPattern.out
+++ b/test-suite/output/SearchPattern.out
@@ -95,6 +95,9 @@ iff_refl: forall A : Prop, A <-> A
le_n: forall n : nat, n <= n
eq_refl: forall {A : Type} {x : A}, x = x
Nat.divmod: nat -> nat -> nat -> nat -> nat * nat
+refl:
+ forall {eq : forall A : Type@{β0 ; _}, A -> A -> Type@{β1 ; _}},
+ Has_refl eq -> forall (A : Type@{β0 ; _}) (x : A), eq A x x
(use "About" for full details on the implicit arguments of eq_refl)
conj: forall [A B : Prop], A -> B -> A /\ B
pair: forall {A B : Type}, A -> B -> A * B
diff --git a/test-suite/output/bug_15020.out b/test-suite/output/bug_15020.out
index 609550bd1989..4f0b6afc8cdf 100644
--- a/test-suite/output/bug_15020.out
+++ b/test-suite/output/bug_15020.out
@@ -7,4 +7,4 @@ Arguments eq_rect {A}%_type_scope {x} P%_function_scope eq_refl {y} e
(where some original arguments have been renamed)
eq_rect is transparent
Expands to: Constant Corelib.Init.Logic.eq_rect
-Declared in library Corelib.Init.Logic, line 381, characters 0-115
+Declared in library Corelib.Init.Logic, line 379, characters 0-115
diff --git a/test-suite/success/Discriminate_HoTT.v b/test-suite/success/Discriminate_HoTT.v
index c889caf78f23..a5eb564c3cea 100644
--- a/test-suite/success/Discriminate_HoTT.v
+++ b/test-suite/success/Discriminate_HoTT.v
@@ -9,6 +9,8 @@ Unset Elimination Schemes.
Set Universe Polymorphism.
+Require Import Equality.
+
Declare ML Module "rocq-runtime.plugins.ltac".
Global Set Default Proof Mode "Classic".
@@ -47,6 +49,11 @@ Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
Arguments ap {A B} f {x y} p.
Register ap as core.identity.congr.
+Definition paths_Has_Leibniz_elim@{l l' l''} : Has_Leibniz@{Type Type Type;l l' l''} (@paths) :=
+ fun A x P t y e => match e with idpath => t end.
+
+Hint Resolve paths_Has_Leibniz_elim : rewrite_instances.
+
Variant Empty : Type :=.
Register Empty as core.False.type.
diff --git a/test-suite/success/Observational.v b/test-suite/success/Observational.v
new file mode 100644
index 000000000000..dd4e5f789a56
--- /dev/null
+++ b/test-suite/success/Observational.v
@@ -0,0 +1,75 @@
+(************************************************************************)
+(* * The Rocq Prover / The Rocq Development Team *)
+(* v * Copyright INRIA, CNRS and contributors *)
+(*
SProp :=
+ obseq_refl : x ~ x
+
+where "x ~ y" := (@obseq _ x y) : type_scope.
+
+Arguments obseq {A} x _.
+Arguments obseq_refl {A x} , [A] x.
+
+Instance obseq_Has_refl@{α;l} : Has_refl@{α SProp;l Set} (@obseq) :=
+ fun A x => obseq_refl.
+
+Instance obseq_Has_J_elim_SProp@{α;l} : Has_J@{α SProp SProp;l Set Set} (@obseq) _
+ := @obseq_sind.
+
+Hint Resolve obseq_Has_J_elim_SProp : rewrite_instances.
+
+Instance obseq_Has_Leibniz_elim_SProp@{α;l} : Has_Leibniz@{α SProp SProp;l Set Set} (@obseq)
+ := fun A x P t y e => @obseq_sind A x (fun x _ => P x) t y e.
+
+Hint Resolve obseq_Has_Leibniz_elim_SProp : rewrite_instances.
+
+Instance obseq_Has_Leibniz_r_elim_SProp@{α;l +} : Has_Leibniz_r@{α SProp SProp;l Set Set} (@obseq)
+ := fun A x P t y e => @obseq_sind A x (fun x _ => P x) t y (sym@{α SProp;l Set} e).
+
+Hint Resolve obseq_Has_Leibniz_r_elim_SProp : rewrite_instances.
+
+Parameter cast@{α;u u' | u A -> B.
+
+Notation "e # a" := (cast _ _ e a) (at level 55, only parsing).
+
+Instance obseq_Has_Leibniz_elim@{α β;l l' +} : Has_Leibniz@{α SProp β;l Set l'} (@obseq) :=
+ { leibniz := fun A x P px y e => cast (P x) (P y) (ap P e) px}.
+
+Hint Resolve obseq_Has_Leibniz_elim : rewrite_instances.
+
+Instance obseq_Has_Leibniz_r_elim@{α β;l l' +} : Has_Leibniz_r@{α SProp β;l Set l'} (@obseq) :=
+ { leibniz_r := fun A x P px y e => cast (P x) (P y) (ap P (sym e)) px}.
+
+Hint Resolve obseq_Has_Leibniz_r_elim : rewrite_instances.
+
+Definition obseq_apd@{sa sb; la lb lb' +}
+ {A : Type@{sa;la}} {a} (P : forall b : A, a ~ b -> Type@{sb ; lb})
+ (b : A) (e : a ~ b) : @obseq _ (P a (refl A a)) (P b e) :=
+ J_eliminator _ a (fun b e => @obseq _ (P a (refl _ _)) (P b e)) (refl _ _) b e.
+
+Instance obseq_Has_J_elim@{α β;l l' +} : Has_J@{α SProp β;l l l'} (@obseq) _ :=
+ fun A a P t b e => cast (P a (refl _ _)) (P b e) (obseq_apd@{α β ;l l' _ _} P b e) t.
+
+Hint Resolve obseq_Has_J_elim : rewrite_instances.
+
+Lemma test {A:Type} (a b : A) (P : A -> Type) : a ~ b -> P a -> P b.
+Proof.
+ intros e Pa. rewrite <- e. auto.
+Defined.
+
+Lemma test2 {A:Type} (a b : A) (P : A -> Type) : a ~ b -> P a -> P b.
+Proof.
+ intros e Pa. symmetry in e. rewrite e. auto.
+Defined.
diff --git a/test-suite/success/RegisterScheme.v b/test-suite/success/RegisterScheme.v
index b4ee34b3fdd8..04636e1ac519 100644
--- a/test-suite/success/RegisterScheme.v
+++ b/test-suite/success/RegisterScheme.v
@@ -1,25 +1,3 @@
-(* use our own eq instead of the corelib one (which has rewriting schemes already declared) *)
-Inductive eq (A:Type) (x:A) : A -> Prop :=
- eq_refl : x = x :>A
-
-where "x = y :> A" := (@eq A x y) : type_scope.
-
-Arguments eq {A} x _.
-Arguments eq_refl {A x} , [A] x.
-
-Arguments eq_ind [A] x P _ y _ : rename.
-Arguments eq_rec [A] x P _ y _ : rename.
-Arguments eq_rect [A] x P _ y _ : rename.
-
-Notation "x = y" := (eq x y) : type_scope.
-Notation "x <> y :> T" := (~ x = y :>T) : type_scope.
-Notation "x <> y" := (~ (x = y)) : type_scope.
-
-Register eq as core.eq.type.
-Register eq_refl as core.eq.refl.
-Register eq_ind as core.eq.ind.
-Register eq_rect as core.eq.rect.
-
Set Universe Polymorphism.
Definition paths_rew_r_dep (A : Type) (x y : A) (P : forall y0 : A, y0 = y -> Type)
@@ -64,11 +42,8 @@ Module Test1.
Theorem upd_nop (a : A) (x : A) (e : a = x) (H: e = e)
: eq_refl a = eq_refl.
Proof.
+ (* The problem does not appear anymore *)
(* neither TestLocal or TestExport registered the scheme *)
- Fail subst.
- Export TestLocal.
- Fail subst.
- Export TestExport.
subst.
exact H.
Qed.
@@ -81,8 +56,9 @@ Section GenMem.
Theorem upd_nop (a : A) (x : A) (e : a = x) (H: e = e)
: eq_refl a = eq_refl.
Proof.
+ (* The problem does not appear anymore *)
(* Export reverted by section end *)
- Fail subst.
+ subst.
Abort.
End GenMem.
diff --git a/test-suite/success/eqtacticsnois.v b/test-suite/success/eqtacticsnois.v
index 7869532c67a4..2ffa4873b63c 100644
--- a/test-suite/success/eqtacticsnois.v
+++ b/test-suite/success/eqtacticsnois.v
@@ -8,6 +8,8 @@ Require Import Ltac.
Register eq as core.eq.type.
Register sym as core.eq.sym.
+Scheme Rewriting for eq.
+
Goal forall A (x y:A) (_ : forall z, eq y z), eq x x.
intros * H. replace x with y.
- reflexivity.
diff --git a/theories/Corelib/Init/Equality.v b/theories/Corelib/Init/Equality.v
new file mode 100644
index 000000000000..a331edb2b0fd
--- /dev/null
+++ b/theories/Corelib/Init/Equality.v
@@ -0,0 +1,138 @@
+(************************************************************************)
+(* * The Rocq Prover / The Rocq Development Team *)
+(* v * Copyright INRIA, CNRS and contributors *)
+(* A -> Type@{se;le})
+:= refl : forall A x, eq A x x.
+
+(* This class register a Martin-Löf like elimination principle *)
+
+Class Has_J@{sa se sp;la le lp} (eq : forall A : Type@{sa ; la}, A -> A -> Type@{se;le})
+ (Has_refl : Has_refl eq) :=
+ J_eliminator : forall (A : Type@{sa ; la}) (x : A) (P : forall y : A, eq A x y -> Type@{sp ; lp}),
+ P x (refl A x) -> forall y e, P y e.
+
+(* This class is for forward dependent rewriting *)
+
+Class Has_J_r@{sa se sp;la le lp} (eq : forall A : Type@{sa ; la}, A -> A -> Type@{se;le})
+ (Has_refl : Has_refl eq) :=
+ J_r_eliminator: forall (A : Type@{sa ; la}) (x : A) (P : forall y : A, eq A y x -> Type@{sp ; lp}),
+ P x (refl A x) -> forall y e, P y e.
+
+(* Those two classes are for dependent rewriting in an hypotesis *)
+
+Class Has_J_forward@{sa se sp;la le lp} (eq : forall A : Type@{sa ; la}, A -> A -> Type@{se;le})
+ (Has_refl : Has_refl eq) :=
+ J_forward : forall (A : Type@{sa ; la}) (x : A) (P : forall y : A, eq A x y -> Type@{sp ; lp}) y e,
+ P y e -> P x (refl A x).
+
+Class Has_J_r_forward@{sa se sp;la le lp} (eq : forall A : Type@{sa ; la}, A -> A -> Type@{se;le})
+ (Has_refl : Has_refl eq) :=
+ J_r_forward : forall (A : Type@{sa ; la}) (x : A) (P : forall y : A, eq A y x -> Type@{sp ; lp}) y e,
+ P y e -> P x (refl A x).
+
+(* Those two classes are for non-dependent rewriting *)
+
+Class Has_Leibniz@{sa se sp;la le lp} (eq : forall A : Type@{sa ; la}, A -> A -> Type@{se;le}) :=
+ leibniz : forall (A : Type@{sa ; la}) (x : A) (P : A -> Type@{sp ; lp}), P x -> forall y, eq A x y -> P y.
+
+Class Has_Leibniz_r@{sa se sp;la le lp} (eq : forall A : Type@{sa ; la}, A -> A -> Type@{se;le}) :=
+ leibniz_r : forall (A : Type@{sa ; la}) (x : A) (P : A -> Type@{sp ; lp}), P x -> forall y, eq A y x -> P y.
+
+Register Has_refl as core.Has_refl.
+Typeclasses Opaque Has_refl.
+
+Register Has_J as core.Has_J.
+Typeclasses Opaque Has_J.
+
+Register Has_J_r as core.Has_J_r.
+Typeclasses Opaque Has_J_r.
+
+Register Has_J_forward as core.Has_J_forward.
+Typeclasses Opaque Has_J_forward.
+
+Register Has_J_r_forward as core.Has_J_r_forward.
+Typeclasses Opaque Has_J_r_forward.
+
+Register Has_Leibniz as core.Has_Leibniz.
+Typeclasses Opaque Has_Leibniz.
+
+Register Has_Leibniz_r as core.Has_Leibniz_r.
+Typeclasses Opaque Has_Leibniz_r.
+
+Definition J_no_dep@{s s' sp;l l' lp} {eq} {refl} (eqr : Has_J@{s s' sp;l l' lp} eq refl) :
+ forall (A : Type@{s ; l}) (x : A) (P : A -> Type@{sp ; lp}), P x -> forall y (e : eq A x y), P y :=
+ fun A x P px y e => J_eliminator _ x (fun y _ => P y) px y e.
+
+Definition Has_J_Has_Leibniz@{s s' sp;l l' lp} {eq} {refl} (eqr : Has_J@{s s' sp;l l' lp} eq refl) : Has_Leibniz@{s s' sp;l l' lp} eq :=
+ fun A x P px y e => J_no_dep eqr A x P px y e.
+
+Section ap.
+ Sort sa se sb se'.
+ Universe la le lb le'.
+ Context {eq : forall A : Type@{sa;la}, A -> A -> Type@{se;le} }
+ {eq' : forall A : Type@{sb; lb}, A -> A -> Type@{se';le'} }
+ {_refl: Has_refl@{sb se';lb le'} eq'}
+ {_leibniz: Has_Leibniz@{sa se se';la le le'} eq}.
+
+ Definition ap [A : Type@{sa;la}] [B:Type@{sb;lb}] (f : A -> B) [x y : A] (e : eq _ x y) : eq' _ (f x) (f y) :=
+ leibniz A x (fun y => eq' B (f x) (f y)) (refl _ _) y e.
+
+End ap.
+
+Register ap as core.ap.
+
+Section sym.
+ Sort sa se.
+ Universe la le.
+ Context {eq : forall A : Type@{sa;la}, A -> A -> Type@{se;le} }
+ {A : Type@{sa;la} }
+ {_refl: Has_refl@{sa se;la le} eq}
+ {_leibniz: Has_Leibniz@{sa se se;la le le} eq}.
+
+ Definition sym {x y : A} (e : eq _ x y) : eq _ y x :=
+ leibniz _ _ (fun y => eq A y _) (refl _ _) _ e.
+
+End sym.
+
+Definition Has_J_Has_J_forward@{sa se sp;la le lp} eq Has_refl
+ {has_J : Has_J@{sa se sp;la le lp} eq Has_refl} :
+ forall (A : Type@{sa ; la}) (x : A) (P : forall y : A, eq A x y -> Type@{sp ; lp}) y e,
+ P y e -> P x (refl A x) :=
+ fun A x P y e => J_eliminator _ _ (fun y e => P y e -> P _ _) (fun x => x) _ _.
+
+Definition _Has_J_Has_J_forward@{sa se sp;la le lp} eq Has_refl
+ {has_J : Has_J@{sa se sp;la le lp} eq Has_refl} : Has_J_forward@{sa se sp;la le lp} eq Has_refl
+ := Has_J_Has_J_forward _ _.
+
+Hint Resolve _Has_J_Has_J_forward : rewrite_instances.
+
+Definition Has_J_r_Has_J_r_forward@{sa se sp;la le lp} eq Has_refl
+ {has_J : Has_J_r@{sa se sp;la le lp} eq Has_refl} :
+ forall (A : Type@{sa ; la}) (x : A) (P : forall y : A, eq A y x -> Type@{sp ; lp}) y e,
+ P y e -> P x (refl A x) :=
+ fun A x P y e => J_r_eliminator _ _ (fun y e => P y e -> P _ _) (fun x => x) _ _.
+
+Definition _Has_J_r_Has_J_r_forward@{sa se sp;la le lp} eq Has_refl
+ {has_J : Has_J_r@{sa se sp;la le lp} eq Has_refl} : Has_J_r_forward@{sa se sp;la le lp} eq Has_refl
+ := Has_J_r_Has_J_r_forward _ _.
+
+Hint Resolve _Has_J_r_Has_J_r_forward : rewrite_instances.
diff --git a/theories/Corelib/Init/Logic.v b/theories/Corelib/Init/Logic.v
index 6d981c1feb6b..d89b2e54c8fb 100644
--- a/theories/Corelib/Init/Logic.v
+++ b/theories/Corelib/Init/Logic.v
@@ -13,8 +13,6 @@ Set Implicit Arguments.
Require Export Notations.
Require Import Ltac.
-Notation "A -> B" := (forall (_ : A), B) : type_scope.
-
(** * Propositional connectives *)
(** [True] is the always true proposition *)
@@ -404,10 +402,17 @@ Hint Resolve ex_intro ex_intro2: core.
Register eq as core.eq.type.
Register eq_refl as core.eq.refl.
Register eq_ind as core.eq.ind.
+Register eq_sind as core.eq.sind.
Register eq_rect as core.eq.rect.
+Register eq_rec as core.eq.rec.
Scheme Rewriting for eq.
+Register eq_rew_dep as core.eq.rect_dep.
+Register eq_rew_dep as core.eq.ind_dep.
+Register eq_rew_r_dep as core.eq.rect_r_dep.
+Register eq_rew_r_dep as core.eq.ind_r_dep.
+
Arguments eq_sym_involutive [A]%_type_scope [x y] e : rename.
Section Logic_lemmas.
@@ -463,6 +468,7 @@ Section Logic_lemmas.
Defined.
Register eq_ind_r as core.eq.ind_r.
+ Register eq_sind_r as core.eq.sind_r.
Definition eq_rec_r :
forall (A:Type) (x:A) (P:A -> Set), P x -> forall y:A, y = x -> P y.
@@ -473,6 +479,10 @@ Section Logic_lemmas.
forall (A:Type) (x:A) (P:A -> Type), P x -> forall y:A, y = x -> P y.
intros A x P H y H0; elim eq_sym with (1 := H0); assumption.
Defined.
+
+ Register eq_rect_r as core.eq.rect_r.
+ Register eq_rec_r as core.eq.rec_r.
+
End Logic_lemmas.
Module EqNotations.
diff --git a/theories/Corelib/Init/Notations.v b/theories/Corelib/Init/Notations.v
index 3c59d5715e44..b97e86a166d5 100644
--- a/theories/Corelib/Init/Notations.v
+++ b/theories/Corelib/Init/Notations.v
@@ -137,3 +137,8 @@ Bind Scope type_scope with Sortclass.
Open Scope core_scope.
Open Scope function_scope.
Open Scope type_scope.
+
+
+Notation "A -> B" := (forall (_ : A), B) : type_scope.
+
+Create HintDb typeclass_instances discriminated.
diff --git a/theories/Corelib/Init/Prelude.v b/theories/Corelib/Init/Prelude.v
index a7106ac0f05d..f7041e993b61 100644
--- a/theories/Corelib/Init/Prelude.v
+++ b/theories/Corelib/Init/Prelude.v
@@ -9,6 +9,7 @@
(************************************************************************)
Require Export Notations.
+Require Export Equality.
Require Export Logic.
Require Export Datatypes.
Require Export Specif.
diff --git a/theories/Corelib/Init/Tactics.v b/theories/Corelib/Init/Tactics.v
index ee8d0e2590bf..b6f8d48c5451 100644
--- a/theories/Corelib/Init/Tactics.v
+++ b/theories/Corelib/Init/Tactics.v
@@ -341,7 +341,6 @@ Tactic Notation "assert_fails" tactic3(tac) :=
Create HintDb rewrite discriminated.
#[global]
Hint Variables Opaque : rewrite.
-Create HintDb typeclass_instances discriminated.
(** A variant of [apply] using [refine], doing as much conversion as necessary. *)
diff --git a/theories/Corelib/extraction/ExtrOcamlBasic.v b/theories/Corelib/extraction/ExtrOcamlBasic.v
index 44dd2f627c6a..6aef76570ff9 100644
--- a/theories/Corelib/extraction/ExtrOcamlBasic.v
+++ b/theories/Corelib/extraction/ExtrOcamlBasic.v
@@ -35,3 +35,5 @@ Extract Inductive sumor => option [ Some None ].
Extract Inlined Constant andb => "(&&)".
Extract Inlined Constant orb => "(||)".
+(* for the dependent principle of equality*)
+Extract Inlined Constant eq_rew_r_dep => "(fun _ _ t -> t)".