| 1 |
(************************************************************************) |
| 2 |
(* * The Rocq Prover / The Rocq Development Team *) |
| 3 |
(* v * Copyright INRIA, CNRS and contributors *) |
| 4 |
(* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 |
(* \VV/ **************************************************************) |
| 6 |
(* // * This file is distributed under the terms of the *) |
| 7 |
(* * GNU Lesser General Public License Version 2.1 *) |
| 8 |
(* * (see LICENSE file for the text of the license) *) |
| 9 |
(************************************************************************) |
| 10 |
|
| 11 |
Require Import Prelude. |
| 12 |
|
| 13 |
Set Universe Polymorphism. |
| 14 |
|
| 15 |
Reserved Notation "x ~ y" (at level 70, no associativity). |
| 16 |
|
| 17 |
Inductive obseq@{α;u} (A:Type@{α;u}) (x:A) : A -> SProp := |
| 18 |
obseq_refl : x ~ x |
| 19 |
|
| 20 |
where "x ~ y" := (@obseq _ x y) : type_scope. |
| 21 |
|
| 22 |
Arguments obseq {A} x _. |
| 23 |
Arguments obseq_refl {A x} , [A] x. |
| 24 |
|
| 25 |
Instance obseq_Has_refl@{α;l} : Has_refl@{α SProp;l Set} (@obseq) := |
| 26 |
fun A x => obseq_refl. |
| 27 |
|
| 28 |
Instance obseq_Has_J_elim_SProp@{α;l} : Has_J@{α SProp SProp;l Set Set} (@obseq) _ |
| 29 |
:= @obseq_sind. |
| 30 |
|
| 31 |
Hint Resolve obseq_Has_J_elim_SProp : rewrite_instances. |
| 32 |
|
| 33 |
Instance obseq_Has_Leibniz_elim_SProp@{α;l} : Has_Leibniz@{α SProp SProp;l Set Set} (@obseq) |
| 34 |
:= fun A x P t y e => @obseq_sind A x (fun x _ => P x) t y e. |
| 35 |
|
| 36 |
Hint Resolve obseq_Has_Leibniz_elim_SProp : rewrite_instances. |
| 37 |
|
| 38 |
Instance obseq_Has_Leibniz_r_elim_SProp@{α;l +} : Has_Leibniz_r@{α SProp SProp;l Set Set} (@obseq) |
| 39 |
:= fun A x P t y e => @obseq_sind A x (fun x _ => P x) t y (sym@{α SProp;l Set} e). |
| 40 |
|
| 41 |
Hint Resolve obseq_Has_Leibniz_r_elim_SProp : rewrite_instances. |
| 42 |
|
| 43 |
Parameter cast@{α;u u' | u<u'} : forall (A B : Type@{α;u}), obseq@{Type;u'} A B -> A -> B. |
| 44 |
|
| 45 |
Notation "e # a" := (cast _ _ e a) (at level 55, only parsing). |
| 46 |
|
| 47 |
Instance obseq_Has_Leibniz_elim@{α β;l l' +} : Has_Leibniz@{α SProp β;l Set l'} (@obseq) := |
| 48 |
{ leibniz := fun A x P px y e => cast (P x) (P y) (ap P e) px}. |
| 49 |
|
| 50 |
Hint Resolve obseq_Has_Leibniz_elim : rewrite_instances. |
| 51 |
|
| 52 |
Instance obseq_Has_Leibniz_r_elim@{α β;l l' +} : Has_Leibniz_r@{α SProp β;l Set l'} (@obseq) := |
| 53 |
{ leibniz_r := fun A x P px y e => cast (P x) (P y) (ap P (sym e)) px}. |
| 54 |
|
| 55 |
Hint Resolve obseq_Has_Leibniz_r_elim : rewrite_instances. |
| 56 |
|
| 57 |
Definition obseq_apd@{sa sb; la lb lb' +} |
| 58 |
{A : Type@{sa;la}} {a} (P : forall b : A, a ~ b -> Type@{sb ; lb}) |
| 59 |
(b : A) (e : a ~ b) : @obseq _ (P a (refl A a)) (P b e) := |
| 60 |
J_eliminator _ a (fun b e => @obseq _ (P a (refl _ _)) (P b e)) (refl _ _) b e. |
| 61 |
|
| 62 |
Instance obseq_Has_J_elim@{α β;l l' +} : Has_J@{α SProp β;l l l'} (@obseq) _ := |
| 63 |
fun A a P t b e => cast (P a (refl _ _)) (P b e) (obseq_apd@{α β ;l l' _ _} P b e) t. |
| 64 |
|
| 65 |
Hint Resolve obseq_Has_J_elim : rewrite_instances. |
| 66 |
|
| 67 |
Lemma test {A:Type} (a b : A) (P : A -> Type) : a ~ b -> P a -> P b. |
| 68 |
Proof. |
| 69 |
intros e Pa. rewrite <- e. auto. |
| 70 |
Defined. |
| 71 |
|
| 72 |
Lemma test2 {A:Type} (a b : A) (P : A -> Type) : a ~ b -> P a -> P b. |
| 73 |
Proof. |
| 74 |
intros e Pa. symmetry in e. rewrite e. auto. |
| 75 |
Defined. |