diff --git a/test-suite/bugs/bug_1448.v b/test-suite/bugs/bug_1448.v index 11e16585bd..974183a6bf 100644 --- a/test-suite/bugs/bug_1448.v +++ b/test-suite/bugs/bug_1448.v @@ -19,10 +19,9 @@ Axiom Req_refl : reflexive _ Req. Axiom Req_sym : symmetric _ Req. Axiom Req_trans : transitive _ Req. -Add Relation R Req - reflexivity proved by Req_refl - symmetry proved by Req_sym - transitivity proved by Req_trans - as Req_rel. +#[global] Instance Req_rel : @Equivalence R Req := { + Equivalence_Reflexive := Req_refl; + Equivalence_Symmetric := Req_sym; + Equivalence_Transitive := Req_trans }. Add Ring my_ring : my_ring_theory (abstract). diff --git a/test-suite/bugs/bug_1738.v b/test-suite/bugs/bug_1738.v index e79ec478ed..c50f980a9a 100644 --- a/test-suite/bugs/bug_1738.v +++ b/test-suite/bugs/bug_1738.v @@ -5,13 +5,12 @@ Module SomeSetoids (Import M:FSetInterface.S). Lemma Equal_refl : forall s, s[=]s. Proof. red; split; auto. Qed. -Add Relation t Equal - reflexivity proved by Equal_refl - symmetry proved by eq_sym - transitivity proved by eq_trans - as EqualSetoid. +#[global] Instance EqualSetoid : @Equivalence t Equal := { + Equivalence_Reflexive := Equal_refl; + Equivalence_Symmetric := eq_sym; + Equivalence_Transitive := eq_trans }. -Add Morphism Empty with signature Equal ==> iff as Empty_m. +#[global] Instance Empty_m : Proper (Equal ==> iff) Empty. Proof. unfold Equal, Empty; firstorder. Qed. diff --git a/test-suite/bugs/bug_2830.v b/test-suite/bugs/bug_2830.v index 792db24ebb..a66dc2c4c4 100644 --- a/test-suite/bugs/bug_2830.v +++ b/test-suite/bugs/bug_2830.v @@ -150,14 +150,10 @@ Coercion ob : Category >-> Sortclass. Open Scope category_scope. -Add Parametric Relation `(C:Category Ob Hom) (a b : Ob) : (hom a b) (eqv a b) - reflexivity proved by (@Equivalence_Reflexive _ _ (eqv_equivalence a b)) - symmetry proved by (@Equivalence_Symmetric _ _ (eqv_equivalence a b)) - transitivity proved by (@Equivalence_Transitive _ _ (eqv_equivalence a b)) - as parametric_relation_eqv. - -Add Parametric Morphism `(C:Category Ob Hom) (c b a : Ob) : (comp c b a) - with signature (eqv _ _ ==> eqv _ _ ==> eqv _ _) as parametric_morphism_comp. +#[global] Instance parametric_relation_eqv `(C:Category Ob Hom) (a b : Ob) : @Equivalence (hom a b) (eqv a b) := + eqv_equivalence a b. + +#[global] Instance parametric_morphism_comp `(C:Category Ob Hom) (c b a : Ob) : Proper (eqv _ _ ==> eqv _ _ ==> eqv _ _) (comp c b a). intros x y Heq x' y'. apply comp_respects. exact Heq. Defined. @@ -172,11 +168,9 @@ Class Functor `(C:Category) `(D:Category) (im : C -> D) := { Coercion functor_im : Functor >-> Funclass. Arguments fmap [Object Hom C Object0 Hom0 D im] _ [a b]. -Add Parametric Morphism `(C:Category) `(D:Category) - (Im:C->D) (F:Functor C D Im) (a b:C) : (@fmap _ _ C _ _ D Im F a b) - with signature (@eqv C _ C a b ==> @eqv D _ D (Im a) (Im b)) - as parametric_morphism_fmap. -intros. apply fmap_respects. assumption. Qed. +#[global] Instance parametric_morphism_fmap `(C:Category) `(D:Category) + (Im:C->D) (F:Functor C D Im) (a b:C) : Proper (@eqv C _ C a b ==> @eqv D _ D (Im a) (Im b)) (@fmap _ _ C _ _ D Im F a b). +intros x y H. apply fmap_respects. assumption. Qed. (* HERE IS THE PROBLEMATIC INSTANCE. If we change this to a regular Definition, then the problem goes away. *) diff --git a/test-suite/bugs/bug_3258.v b/test-suite/bugs/bug_3258.v index e2b1cad529..b1d830d044 100644 --- a/test-suite/bugs/bug_3258.v +++ b/test-suite/bugs/bug_3258.v @@ -14,12 +14,8 @@ Axiom refine : forall {A} (old : Comp A) (new : Comp A), Prop. #[global] Instance refine_PreOrder A : PreOrder (@refine A). Admitted. -Add Parametric Morphism A -: (@Pick A) - with signature - (pointwise_relation _ (flip impl)) - ==> (@refine A) - as refine_flip_impl_Pick. +#[global] Instance refine_flip_impl_Pick A +: Proper ((pointwise_relation _ (flip impl)) ==> (@refine A)) (@Pick A). admit. Defined. Definition remove_forall_eq' A x B (P : A -> B -> Prop) : pointwise_relation _ impl (P x) (fun z => forall y : A, y = x -> P y z). diff --git a/test-suite/success/setoid_ring_module.v b/test-suite/success/setoid_ring_module.v index 82d122f8c3..f434f3ffc3 100644 --- a/test-suite/success/setoid_ring_module.v +++ b/test-suite/success/setoid_ring_module.v @@ -1,4 +1,4 @@ -From Stdlib Require Import Setoid Ring Ring_theory. +From Stdlib Require Import Setoid Morphisms Ring Ring_theory. Module abs_ring. @@ -11,18 +11,18 @@ Parameters (Coef:Set)(c0 c1 : Coef) (ceq_refl : forall x, ceq x x). -Add Relation Coef ceq - reflexivity proved by ceq_refl symmetry proved by ceq_sym - transitivity proved by ceq_trans - as ceq_relation. +#[global] Instance ceq_relation : @Equivalence Coef ceq := { + Equivalence_Reflexive := ceq_refl; + Equivalence_Symmetric := ceq_sym; + Equivalence_Transitive := ceq_trans }. -Add Morphism cadd with signature ceq ==> ceq ==> ceq as cadd_Morphism. +#[global] Instance cadd_Morphism : Proper (ceq ==> ceq ==> ceq) cadd. Admitted. -Add Morphism cmul with signature ceq ==> ceq ==> ceq as cmul_Morphism. +#[global] Instance cmul_Morphism : Proper (ceq ==> ceq ==> ceq) cmul. Admitted. -Add Morphism copp with signature ceq ==> ceq as copp_Morphism. +#[global] Instance copp_Morphism : Proper (ceq ==> ceq) copp. Admitted. Definition cRth : ring_theory c0 c1 cadd cmul csub copp ceq. diff --git a/theories/FSets/FMapFacts.v b/theories/FSets/FMapFacts.v index b4940fe487..69608dd83f 100644 --- a/theories/FSets/FMapFacts.v +++ b/theories/FSets/FMapFacts.v @@ -648,88 +648,112 @@ Proof. constructor; red; [apply Equal_refl | apply Equal_sym | apply Equal_trans]. Qed. -Add Relation key E.eq - reflexivity proved by E.eq_refl - symmetry proved by E.eq_sym - transitivity proved by E.eq_trans - as KeySetoid. +#[global] Instance KeySetoid_relation : @RewriteRelation key E.eq := {}. +#[global] Instance KeySetoid_Reflexive : @Reflexive key E.eq := E.eq_refl. +#[global] Instance KeySetoid_Symmetric : @Symmetric key E.eq := E.eq_sym. +#[global] Instance KeySetoid_Transitive : @Transitive key E.eq := E.eq_trans. +#[global] Instance KeySetoid : @Equivalence key E.eq := { + Equivalence_Reflexive := E.eq_refl; + Equivalence_Symmetric := E.eq_sym; + Equivalence_Transitive := E.eq_trans }. Arguments Equal {elt} m m'. -Add Parametric Relation (elt : Type) : (t elt) Equal - reflexivity proved by (@Equal_refl elt) - symmetry proved by (@Equal_sym elt) - transitivity proved by (@Equal_trans elt) - as EqualSetoid. +#[global] Instance EqualSetoid_relation (elt : Type) : @RewriteRelation (t elt) Equal := {}. +#[global] Instance EqualSetoid_Reflexive (elt : Type) : @Reflexive (t elt) Equal := @Equal_refl elt. +#[global] Instance EqualSetoid_Symmetric (elt : Type) : @Symmetric (t elt) Equal := @Equal_sym elt. +#[global] Instance EqualSetoid_Transitive (elt : Type) : @Transitive (t elt) Equal := @Equal_trans elt. +#[global] Instance EqualSetoid (elt : Type) : @Equivalence (t elt) Equal := { + Equivalence_Reflexive := (@Equal_refl elt); + Equivalence_Symmetric := (@Equal_sym elt); + Equivalence_Transitive := (@Equal_trans elt) }. -Add Parametric Morphism elt : (@In elt) - with signature E.eq ==> Equal ==> iff as In_m. +#[global] Instance In_m_Proper elt : Proper (E.eq ==> Equal ==> iff) (@In elt). Proof. unfold Equal; intros k k' Hk m m' Hm. rewrite (In_iff m Hk), in_find_iff, in_find_iff, Hm; intuition. Qed. +Definition In_m elt : + forall x y, E.eq x y -> forall x0 y0, Equal x0 y0 -> iff (@In elt x x0) (@In elt y y0) := + @proper_prf _ _ _ (@In_m_Proper elt). -Add Parametric Morphism elt : (@MapsTo elt) - with signature E.eq ==> eq ==> Equal ==> iff as MapsTo_m. +#[global] Instance MapsTo_m_Proper elt : Proper (E.eq ==> eq ==> Equal ==> iff) (@MapsTo elt). Proof. -unfold Equal; intros k k' Hk e m m' Hm. +unfold Equal; intros k k' Hk e ? <- m m' Hm. rewrite (MapsTo_iff m e Hk), find_mapsto_iff, find_mapsto_iff, Hm; intuition. Qed. +Definition MapsTo_m elt : + forall x y, E.eq x y -> forall x0 y0, eq x0 y0 -> forall x1 y1, Equal x1 y1 -> iff (@MapsTo elt x x0 x1) (@MapsTo elt y y0 y1) := + @proper_prf _ _ _ (@MapsTo_m_Proper elt). -Add Parametric Morphism elt : (@Empty elt) - with signature Equal ==> iff as Empty_m. +#[global] Instance Empty_m_Proper elt : Proper (Equal ==> iff) (@Empty elt). Proof. unfold Empty; intros m m' Hm. split; intros; intro. - rewrite <-Hm in H0; eapply H, H0. - rewrite Hm in H0; eapply H, H0. Qed. +Definition Empty_m elt : + forall x y, Equal x y -> iff (@Empty elt x) (@Empty elt y) := + @proper_prf _ _ _ (@Empty_m_Proper elt). -Add Parametric Morphism elt : (@is_empty elt) - with signature Equal ==> eq as is_empty_m. +#[global] Instance is_empty_m_Proper elt : Proper (Equal ==> eq) (@is_empty elt). Proof. intros m m' Hm. rewrite eq_bool_alt, <-is_empty_iff, <-is_empty_iff, Hm; intuition. Qed. +Definition is_empty_m elt : + forall x y, Equal x y -> eq (@is_empty elt x) (@is_empty elt y) := + @proper_prf _ _ _ (@is_empty_m_Proper elt). -Add Parametric Morphism elt : (@mem elt) - with signature E.eq ==> Equal ==> eq as mem_m. +#[global] Instance mem_m_Proper elt : Proper (E.eq ==> Equal ==> eq) (@mem elt). Proof. intros k k' Hk m m' Hm. rewrite eq_bool_alt, <- mem_in_iff, <-mem_in_iff, Hk, Hm; intuition. Qed. +Definition mem_m elt : + forall x y, E.eq x y -> forall x0 y0, Equal x0 y0 -> eq (@mem elt x x0) (@mem elt y y0) := + @proper_prf _ _ _ (@mem_m_Proper elt). -Add Parametric Morphism elt : (@find elt) - with signature E.eq ==> Equal ==> eq as find_m. +#[global] Instance find_m_Proper elt : Proper (E.eq ==> Equal ==> eq) (@find elt). Proof. intros k k' Hk m m' Hm. rewrite eq_option_alt. intro e. rewrite <- 2 find_mapsto_iff, Hk, Hm. split; auto. Qed. +Definition find_m elt : + forall x y, E.eq x y -> forall x0 y0, Equal x0 y0 -> eq (@find elt x x0) (@find elt y y0) := + @proper_prf _ _ _ (@find_m_Proper elt). -Add Parametric Morphism elt : (@add elt) - with signature E.eq ==> eq ==> Equal ==> Equal as add_m. +#[global] Instance add_m_Proper elt : Proper (E.eq ==> eq ==> Equal ==> Equal) (@add elt). Proof. -intros k k' Hk e m m' Hm y. +intros k k' Hk e ? <- m m' Hm y. rewrite add_o, add_o; do 2 destruct eq_dec as [|?Hnot]; auto. - elim Hnot; rewrite <-Hk; auto. - elim Hnot; rewrite Hk; auto. Qed. +Definition add_m elt : + forall x y, E.eq x y -> forall x0 y0, eq x0 y0 -> forall x1 y1, Equal x1 y1 -> Equal (@add elt x x0 x1) (@add elt y y0 y1) := + @proper_prf _ _ _ (@add_m_Proper elt). -Add Parametric Morphism elt : (@remove elt) - with signature E.eq ==> Equal ==> Equal as remove_m. +#[global] Instance remove_m_Proper elt : Proper (E.eq ==> Equal ==> Equal) (@remove elt). Proof. intros k k' Hk m m' Hm y. rewrite remove_o, remove_o; do 2 destruct eq_dec as [|?Hnot]; auto. - elim Hnot; rewrite <-Hk; auto. - elim Hnot; rewrite Hk; auto. Qed. +Definition remove_m elt : + forall x y, E.eq x y -> forall x0 y0, Equal x0 y0 -> Equal (@remove elt x x0) (@remove elt y y0) := + @proper_prf _ _ _ (@remove_m_Proper elt). -Add Parametric Morphism elt elt' : (@map elt elt') - with signature eq ==> Equal ==> Equal as map_m. +#[global] Instance map_m_Proper elt elt' : Proper (eq ==> Equal ==> Equal) (@map elt elt'). Proof. -intros f m m' Hm y. +intros f ? <- m m' Hm y. rewrite map_o, map_o, Hm; auto. Qed. +Definition map_m elt elt' : + forall x y, eq x y -> forall x0 y0, Equal x0 y0 -> Equal (@map elt elt' x x0) (@map elt elt' y y0) := + @proper_prf _ _ _ (@map_m_Proper elt elt'). (* Later: Add Morphism cardinal *) @@ -1770,20 +1794,23 @@ Module WProperties_fun (E:DecidableType)(M:WSfun E). End Elt. - Add Parametric Morphism elt : (@cardinal elt) - with signature Equal ==> eq as cardinal_m. - Proof. intros; apply Equal_cardinal; auto. Qed. + #[global] Instance cardinal_m_Proper elt : Proper (Equal ==> eq) (@cardinal elt). + Proof. intros x y H; apply Equal_cardinal; auto. Qed. + Definition cardinal_m elt : + forall x y, Equal x y -> eq (@cardinal elt x) (@cardinal elt y) := + @proper_prf _ _ _ (@cardinal_m_Proper elt). - Add Parametric Morphism elt : (@Disjoint elt) - with signature Equal ==> Equal ==> iff as Disjoint_m. + #[global] Instance Disjoint_m_Proper elt : Proper (Equal ==> Equal ==> iff) (@Disjoint elt). Proof. intros m1 m1' Hm1 m2 m2' Hm2. unfold Disjoint. split; intros. - rewrite <- Hm1, <- Hm2; auto. - rewrite Hm1, Hm2; auto. Qed. + Definition Disjoint_m elt : + forall x y, Equal x y -> forall x0 y0, Equal x0 y0 -> iff (@Disjoint elt x x0) (@Disjoint elt y y0) := + @proper_prf _ _ _ (@Disjoint_m_Proper elt). - Add Parametric Morphism elt : (@Partition elt) - with signature Equal ==> Equal ==> Equal ==> iff as Partition_m. + #[global] Instance Partition_m_Proper elt : Proper (Equal ==> Equal ==> Equal ==> iff) (@Partition elt). Proof. intros m1 m1' Hm1 m2 m2' Hm2 m3 m3' Hm3. unfold Partition. rewrite <- Hm2, <- Hm3. @@ -1791,9 +1818,11 @@ Module WProperties_fun (E:DecidableType)(M:WSfun E). - rewrite <- Hm1, <- Hm2, <- Hm3; auto. - rewrite Hm1, Hm2, Hm3; auto. Qed. + Definition Partition_m elt : + forall x y, Equal x y -> forall x0 y0, Equal x0 y0 -> forall x1 y1, Equal x1 y1 -> iff (@Partition elt x x0 x1) (@Partition elt y y0 y1) := + @proper_prf _ _ _ (@Partition_m_Proper elt). - Add Parametric Morphism elt : (@update elt) - with signature Equal ==> Equal ==> Equal as update_m. + #[global] Instance update_m_Proper elt : Proper (Equal ==> Equal ==> Equal) (@update elt). Proof. intros m1 m1' Hm1 m2 m2' Hm2. setoid_replace (update m1 m2) with (update m1' m2); unfold update. @@ -1804,9 +1833,11 @@ Module WProperties_fun (E:DecidableType)(M:WSfun E). - apply fold_init with (eqA:=Equal); auto. intros k k' Hk e e' He m m' Hm; rewrite Hk,He,Hm; red; auto. Qed. + Definition update_m elt : + forall x y, Equal x y -> forall x0 y0, Equal x0 y0 -> Equal (@update elt x x0) (@update elt y y0) := + @proper_prf _ _ _ (@update_m_Proper elt). - Add Parametric Morphism elt : (@restrict elt) - with signature Equal ==> Equal ==> Equal as restrict_m. + #[global] Instance restrict_m_Proper elt : Proper (Equal ==> Equal ==> Equal) (@restrict elt). Proof. intros m1 m1' Hm1 m2 m2' Hm2. setoid_replace (restrict m1 m2) with (restrict m1' m2); @@ -1823,9 +1854,11 @@ Module WProperties_fun (E:DecidableType)(M:WSfun E). case_eq (mem k m2); case_eq (mem k' m2); intros; auto. rewrite !add_o; do 2 destruct eq_dec; auto. elim Hneq; eauto. Qed. + Definition restrict_m elt : + forall x y, Equal x y -> forall x0 y0, Equal x0 y0 -> Equal (@restrict elt x x0) (@restrict elt y y0) := + @proper_prf _ _ _ (@restrict_m_Proper elt). - Add Parametric Morphism elt : (@diff elt) - with signature Equal ==> Equal ==> Equal as diff_m. + #[global] Instance diff_m_Proper elt : Proper (Equal ==> Equal ==> Equal) (@diff elt). Proof. intros m1 m1' Hm1 m2 m2' Hm2. setoid_replace (diff m1 m2) with (diff m1' m2); @@ -1842,6 +1875,9 @@ Module WProperties_fun (E:DecidableType)(M:WSfun E). case_eq (mem k m2); case_eq (mem k' m2); intros; simpl; auto. rewrite !add_o; do 2 destruct eq_dec; auto. elim Hneq; eauto. Qed. + Definition diff_m elt : + forall x y, Equal x y -> forall x0 y0, Equal x0 y0 -> Equal (@diff elt x x0) (@diff elt y y0) := + @proper_prf _ _ _ (@diff_m_Proper elt). End WProperties_fun. diff --git a/theories/FSets/FSetFacts.v b/theories/FSets/FSetFacts.v index f8cc3448a1..f31757308b 100644 --- a/theories/FSets/FSetFacts.v +++ b/theories/FSets/FSetFacts.v @@ -422,10 +422,13 @@ Proof. red; auto. Qed. Lemma Subset_trans : forall s s' s'', s[<=]s'->s'[<=]s''->s[<=]s''. Proof. unfold Subset; eauto. Qed. -Add Relation t Subset - reflexivity proved by Subset_refl - transitivity proved by Subset_trans - as SubsetSetoid. +#[global] Instance SubsetSetoid_relation : @RewriteRelation t Subset := {}. + +#[global] Instance SubsetSetoid_Reflexive : @Reflexive t Subset := Subset_refl. +#[global] Instance SubsetSetoid_Transitive : @Transitive t Subset := Subset_trans. +#[global] Instance SubsetSetoid : @PreOrder t Subset := { + PreOrder_Reflexive := Subset_refl; + PreOrder_Transitive := Subset_trans }. #[global] Instance In_s_m : Morphisms.Proper (E.eq ==> Subset ++> Basics.impl) In | 1. @@ -433,40 +436,58 @@ Proof. simpl_relation. eauto with set. Qed. -Add Morphism Empty with signature Subset --> Basics.impl as Empty_s_m. +#[global] Instance Empty_s_m_Proper : Proper (Subset --> Basics.impl) Empty. Proof. unfold Subset, Empty, Basics.impl; firstorder. Qed. +Definition Empty_s_m : + forall x y, Basics.flip Subset x y -> Basics.impl (Empty x) (Empty y) := + @proper_prf _ _ _ Empty_s_m_Proper. -Add Morphism add with signature E.eq ==> Subset ++> Subset as add_s_m. +#[global] Instance add_s_m_Proper : Proper (E.eq ==> Subset ++> Subset) add. Proof. unfold Subset; intros x y H s s' H0 a. do 2 rewrite add_iff; rewrite H; intuition. Qed. +Definition add_s_m : + forall x y, E.eq x y -> forall x0 y0, Subset x0 y0 -> Subset (add x x0) (add y y0) := + @proper_prf _ _ _ add_s_m_Proper. -Add Morphism remove with signature E.eq ==> Subset ++> Subset as remove_s_m. +#[global] Instance remove_s_m_Proper : Proper (E.eq ==> Subset ++> Subset) remove. Proof. unfold Subset; intros x y H s s' H0 a. do 2 rewrite remove_iff; rewrite H; intuition. Qed. +Definition remove_s_m : + forall x y, E.eq x y -> forall x0 y0, Subset x0 y0 -> Subset (remove x x0) (remove y y0) := + @proper_prf _ _ _ remove_s_m_Proper. -Add Morphism union with signature Subset ++> Subset ++> Subset as union_s_m. +#[global] Instance union_s_m_Proper : Proper (Subset ++> Subset ++> Subset) union. Proof. unfold Equal; intros s s' H s'' s''' H0 a. do 2 rewrite union_iff; intuition. Qed. +Definition union_s_m : + forall x y, Subset x y -> forall x0 y0, Subset x0 y0 -> Subset (union x x0) (union y y0) := + @proper_prf _ _ _ union_s_m_Proper. -Add Morphism inter with signature Subset ++> Subset ++> Subset as inter_s_m. +#[global] Instance inter_s_m_Proper : Proper (Subset ++> Subset ++> Subset) inter. Proof. unfold Equal; intros s s' H s'' s''' H0 a. do 2 rewrite inter_iff; intuition. Qed. +Definition inter_s_m : + forall x y, Subset x y -> forall x0 y0, Subset x0 y0 -> Subset (inter x x0) (inter y y0) := + @proper_prf _ _ _ inter_s_m_Proper. -Add Morphism diff with signature Subset ++> Subset --> Subset as diff_s_m. +#[global] Instance diff_s_m_Proper : Proper (Subset ++> Subset --> Subset) diff. Proof. unfold Subset; intros s s' H s'' s''' H0 a. do 2 rewrite diff_iff; intuition. Qed. +Definition diff_s_m : + forall x y, Subset x y -> forall x0 y0, Basics.flip Subset x0 y0 -> Subset (diff x x0) (diff y y0) := + @proper_prf _ _ _ diff_s_m_Proper. (* [fold], [filter], [for_all], [exists_] and [partition] cannot be proved morphism without additional hypothesis on [f]. For instance: *) diff --git a/theories/FSets/FSetProperties.v b/theories/FSets/FSetProperties.v index 5b6156e7e9..e6d258554e 100644 --- a/theories/FSets/FSetProperties.v +++ b/theories/FSets/FSetProperties.v @@ -774,10 +774,13 @@ Module WProperties_fun (Import E : DecidableType)(M : WSfun E). rewrite (cardinal_2 (s:=remove x s') (s':=s') (x:=x)); eauto with set. Qed. - Add Morphism cardinal with signature (Equal ==> Logic.eq) as cardinal_m. + #[global] Instance cardinal_m_Proper : Proper (Equal ==> Logic.eq) cardinal. Proof. exact Equal_cardinal. Qed. + Definition cardinal_m : + forall x y, Equal x y -> Logic.eq (cardinal x) (cardinal y) := + @proper_prf _ _ _ cardinal_m_Proper. #[global] Hint Resolve Add_add Add_remove Equal_remove cardinal_inv_1 Equal_cardinal : fset. diff --git a/theories/QArith/Qabs.v b/theories/QArith/Qabs.v index 41ca8f7b61..592299ca8e 100644 --- a/theories/QArith/Qabs.v +++ b/theories/QArith/Qabs.v @@ -24,7 +24,7 @@ destruct x as [[|xn|xn] xd]; abstract (compute; discriminate). Defined. -Add Morphism Qabs with signature Qeq ==> Qeq as Qabs_wd. +#[global] Instance Qabs_wd_Proper : Proper (Qeq ==> Qeq) Qabs. Proof. intros [xn xd] [yn yd] H. simpl. @@ -35,6 +35,9 @@ change (Zpos xd)%Z with (Z.abs (Zpos xd)). repeat rewrite <- Z.abs_mul. congruence. Qed. +Definition Qabs_wd : + forall x y, Qeq x y -> Qeq (Qabs x) (Qabs y) := + @proper_prf _ _ _ Qabs_wd_Proper. Lemma Qabs_pos : forall x, 0 <= x -> Qabs x == x. Proof. diff --git a/theories/QArith/Qreduction.v b/theories/QArith/Qreduction.v index ffaf8b2b00..5bda0c4cc2 100644 --- a/theories/QArith/Qreduction.v +++ b/theories/QArith/Qreduction.v @@ -82,10 +82,13 @@ Proof. - apply Qred_complete. Qed. -Add Morphism Qred with signature (Qeq ==> Qeq) as Qred_comp. +#[global] Instance Qred_comp_Proper : Proper (Qeq ==> Qeq) Qred. Proof. - intros. now rewrite !Qred_correct. + intros x y H. now rewrite !Qred_correct. Qed. +Definition Qred_comp : + forall x y, Qeq x y -> Qeq (Qred x) (Qred y) := + @proper_prf _ _ _ Qred_comp_Proper. Definition Qplus' (p q : Q) := Qred (Qplus p q). Definition Qmult' (p q : Q) := Qred (Qmult p q). @@ -106,23 +109,32 @@ Proof. intros; unfold Qminus'; apply Qred_correct; auto. Qed. -Add Morphism Qplus' with signature (Qeq ==> Qeq ==> Qeq) as Qplus'_comp. +#[global] Instance Qplus'_comp_Proper : Proper (Qeq ==> Qeq ==> Qeq) Qplus'. Proof. intros ? ? H ? ? H0; unfold Qplus'. rewrite H, H0; auto with qarith. Qed. +Definition Qplus'_comp : + forall x y, Qeq x y -> forall x0 y0, Qeq x0 y0 -> Qeq (Qplus' x x0) (Qplus' y y0) := + @proper_prf _ _ _ Qplus'_comp_Proper. -Add Morphism Qmult' with signature (Qeq ==> Qeq ==> Qeq) as Qmult'_comp. +#[global] Instance Qmult'_comp_Proper : Proper (Qeq ==> Qeq ==> Qeq) Qmult'. Proof. intros ? ? H ? ? H0; unfold Qmult'. rewrite H, H0; auto with qarith. Qed. +Definition Qmult'_comp : + forall x y, Qeq x y -> forall x0 y0, Qeq x0 y0 -> Qeq (Qmult' x x0) (Qmult' y y0) := + @proper_prf _ _ _ Qmult'_comp_Proper. -Add Morphism Qminus' with signature (Qeq ==> Qeq ==> Qeq) as Qminus'_comp. +#[global] Instance Qminus'_comp_Proper : Proper (Qeq ==> Qeq ==> Qeq) Qminus'. Proof. intros ? ? H ? ? H0; unfold Qminus'. rewrite H, H0; auto with qarith. Qed. +Definition Qminus'_comp : + forall x y, Qeq x y -> forall x0 y0, Qeq x0 y0 -> Qeq (Qminus' x x0) (Qminus' y y0) := + @proper_prf _ _ _ Qminus'_comp_Proper. Lemma Qred_opp: forall q, Qred (-q) = - (Qred q). Proof. diff --git a/theories/QArith/Qround.v b/theories/QArith/Qround.v index caf6fba286..0b790983e8 100644 --- a/theories/QArith/Qround.v +++ b/theories/QArith/Qround.v @@ -122,21 +122,27 @@ Qed. #[global] Hint Resolve Qceiling_resp_le : qarith. -Add Morphism Qfloor with signature Qeq ==> eq as Qfloor_comp. +#[global] Instance Qfloor_comp_Proper : Proper (Qeq ==> eq) Qfloor. Proof. intros x y H. apply Z.le_antisymm. - auto with *. - symmetry in H; auto with *. Qed. +Definition Qfloor_comp : + forall x y, Qeq x y -> eq (Qfloor x) (Qfloor y) := + @proper_prf _ _ _ Qfloor_comp_Proper. -Add Morphism Qceiling with signature Qeq ==> eq as Qceiling_comp. +#[global] Instance Qceiling_comp_Proper : Proper (Qeq ==> eq) Qceiling. Proof. intros x y H. apply Z.le_antisymm. - auto with *. - symmetry in H; auto with *. Qed. +Definition Qceiling_comp : + forall x y, Qeq x y -> eq (Qceiling x) (Qceiling y) := + @proper_prf _ _ _ Qceiling_comp_Proper. Lemma Zdiv_Qdiv (n m: Z): (n / m)%Z = Qfloor (n / m). Proof. diff --git a/theories/Reals/Abstract/ConstructiveAbs.v b/theories/Reals/Abstract/ConstructiveAbs.v index 5511afa3e7..c6515fb2dc 100644 --- a/theories/Reals/Abstract/ConstructiveAbs.v +++ b/theories/Reals/Abstract/ConstructiveAbs.v @@ -51,12 +51,13 @@ Proof. apply H1. apply CRle_refl. Qed. -Add Parametric Morphism {R : ConstructiveReals} : (CRabs R) - with signature CReq R ==> CReq R - as CRabs_morph_prop. +#[global] Instance CRabs_morph_prop_Proper {R : ConstructiveReals} : Proper (CReq R ==> CReq R) (CRabs R). Proof. - intros. apply CRabs_morph, H. + intros x y H. apply CRabs_morph, H. Qed. +Definition CRabs_morph_prop (R : ConstructiveReals) : + forall x y, CReq R x y -> CReq R (CRabs R x) (CRabs R y) := + @proper_prf _ _ _ (@CRabs_morph_prop_Proper R). Lemma CRabs_right : forall {R : ConstructiveReals} (x : CRcarrier R), 0 <= x -> CRabs R x == x. diff --git a/theories/Reals/Abstract/ConstructiveMinMax.v b/theories/Reals/Abstract/ConstructiveMinMax.v index b3624badd8..8721babee4 100644 --- a/theories/Reals/Abstract/ConstructiveMinMax.v +++ b/theories/Reals/Abstract/ConstructiveMinMax.v @@ -56,15 +56,16 @@ Proof. rewrite CRmult_1_r. apply CRle_refl. Qed. -Add Parametric Morphism {R : ConstructiveReals} : CRmin - with signature (CReq R) ==> (CReq R) ==> (CReq R) - as CRmin_morph. +#[global] Instance CRmin_morph_Proper {R : ConstructiveReals} : Proper ((CReq R) ==> (CReq R) ==> (CReq R)) CRmin. Proof. - intros. unfold CRmin. + intros x y H x0 y0 H0. unfold CRmin. apply CRmult_morph. 2: reflexivity. unfold CRminus. rewrite H, H0. reflexivity. Qed. +Definition CRmin_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> forall x0 y0, CReq R x0 y0 -> CReq R (CRmin x x0) (CRmin y y0) := + @proper_prf _ _ _ (@CRmin_morph_Proper R). #[global] Instance CRmin_morphT @@ -365,14 +366,15 @@ Qed. Definition CRmax {R : ConstructiveReals} (x y : CRcarrier R) : CRcarrier R := (x + y + CRabs _ (y - x)) * CR_of_Q _ (1#2). -Add Parametric Morphism {R : ConstructiveReals} : CRmax - with signature (CReq R) ==> (CReq R) ==> (CReq R) - as CRmax_morph. +#[global] Instance CRmax_morph_Proper {R : ConstructiveReals} : Proper ((CReq R) ==> (CReq R) ==> (CReq R)) CRmax. Proof. - intros. unfold CRmax. + intros x y H x0 y0 H0. unfold CRmax. apply CRmult_morph. 2: reflexivity. unfold CRminus. rewrite H, H0. reflexivity. Qed. +Definition CRmax_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> forall x0 y0, CReq R x0 y0 -> CReq R (CRmax x x0) (CRmax y y0) := + @proper_prf _ _ _ (@CRmax_morph_Proper R). #[global] Instance CRmax_morphT diff --git a/theories/Reals/Abstract/ConstructiveReals.v b/theories/Reals/Abstract/ConstructiveReals.v index 5d53e11283..796531f58a 100644 --- a/theories/Reals/Abstract/ConstructiveReals.v +++ b/theories/Reals/Abstract/ConstructiveReals.v @@ -327,11 +327,14 @@ Proof. - intro abs. destruct (s _ y _ abs); contradiction. Qed. -Add Parametric Relation {R : ConstructiveReals} : (CRcarrier R) (CReq R) - reflexivity proved by (CReq_refl) - symmetry proved by (CReq_sym) - transitivity proved by (CReq_trans) - as CReq_rel. +#[global] Instance CReq_rel_relation {R : ConstructiveReals} : @RewriteRelation (CRcarrier R) (CReq R) := {}. +#[global] Instance CReq_rel_Reflexive {R : ConstructiveReals} : @Reflexive (CRcarrier R) (CReq R) := CReq_refl. +#[global] Instance CReq_rel_Symmetric {R : ConstructiveReals} : @Symmetric (CRcarrier R) (CReq R) := CReq_sym. +#[global] Instance CReq_rel_Transitive {R : ConstructiveReals} : @Transitive (CRcarrier R) (CReq R) := CReq_trans. +#[global] Instance CReq_rel {R : ConstructiveReals} : @Equivalence (CRcarrier R) (CReq R) := { + Equivalence_Reflexive := CReq_refl; + Equivalence_Symmetric := CReq_sym; + Equivalence_Transitive := CReq_trans }. #[global] Instance CReq_relT : forall {R : ConstructiveReals}, @@ -365,16 +368,17 @@ Proof. * contradiction. Qed. -Add Parametric Morphism {R : ConstructiveReals} : (CRle R) - with signature CReq R ==> CReq R ==> iff - as CRle_morph. +#[global] Instance CRle_morph_Proper {R : ConstructiveReals} : Proper (CReq R ==> CReq R ==> iff) (CRle R). Proof. - intros. split. + intros x y H x0 y0 H0. split. - intros H1 H2. unfold CRle in H1. rewrite <- H0 in H2. rewrite <- H in H2. contradiction. - intros H1 H2. unfold CRle in H1. rewrite H0 in H2. rewrite H in H2. contradiction. Qed. +Definition CRle_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> forall x0 y0, CReq R x0 y0 -> iff (CRle R x x0) (CRle R y y0) := + @proper_prf _ _ _ (@CRle_morph_Proper R). Lemma CRplus_0_l : forall {R : ConstructiveReals} (x : CRcarrier R), 0 + x == x. @@ -552,26 +556,29 @@ Proof. intros. apply (Radd_comm (CRisRing R)). Qed. -Add Parametric Morphism {R : ConstructiveReals} : (CRplus R) - with signature CReq R ==> CReq R ==> CReq R - as CRplus_morph. +#[global] Instance CRplus_morph_Proper {R : ConstructiveReals} : Proper (CReq R ==> CReq R ==> CReq R) (CRplus R). Proof. apply (CRisRingExt R). Qed. +Definition CRplus_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> forall x0 y0, CReq R x0 y0 -> CReq R (CRplus R x x0) (CRplus R y y0) := + @proper_prf _ _ _ (@CRplus_morph_Proper R). -Add Parametric Morphism {R : ConstructiveReals} : (CRopp R) - with signature CReq R ==> CReq R - as CRopp_morph. +#[global] Instance CRopp_morph_Proper {R : ConstructiveReals} : Proper (CReq R ==> CReq R) (CRopp R). Proof. apply (CRisRingExt R). Qed. +Definition CRopp_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> CReq R (CRopp R x) (CRopp R y) := + @proper_prf _ _ _ (@CRopp_morph_Proper R). -Add Parametric Morphism {R : ConstructiveReals} : (CRmult R) - with signature CReq R ==> CReq R ==> CReq R - as CRmult_morph. +#[global] Instance CRmult_morph_Proper {R : ConstructiveReals} : Proper (CReq R ==> CReq R ==> CReq R) (CRmult R). Proof. apply (CRisRingExt R). Qed. +Definition CRmult_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> forall x0 y0, CReq R x0 y0 -> CReq R (CRmult R x x0) (CRmult R y y0) := + @proper_prf _ _ _ (@CRmult_morph_Proper R). #[global] Instance CRplus_morph_T @@ -597,12 +604,13 @@ Proof. apply CRisRingExt. Qed. -Add Parametric Morphism {R : ConstructiveReals} : (CRminus R) - with signature (CReq R) ==> (CReq R) ==> (CReq R) - as CRminus_morph. +#[global] Instance CRminus_morph_Proper {R : ConstructiveReals} : Proper ((CReq R) ==> (CReq R) ==> (CReq R)) (CRminus R). Proof. - intros. unfold CRminus. rewrite H,H0. reflexivity. + intros x y H x0 y0 H0. unfold CRminus. rewrite H,H0. reflexivity. Qed. +Definition CRminus_morph (R : ConstructiveReals) : + forall x y, CReq R x y -> forall x0 y0, CReq R x0 y0 -> CReq R (CRminus R x x0) (CRminus R y y0) := + @proper_prf _ _ _ (@CRminus_morph_Proper R). #[global] Instance CRminus_morph_T @@ -974,12 +982,13 @@ Proof. exact (Qlt_not_le _ _ abs H). Qed. -Add Parametric Morphism {R : ConstructiveReals} : (CR_of_Q R) - with signature Qeq ==> CReq R - as CR_of_Q_morph. +#[global] Instance CR_of_Q_morph_Proper {R : ConstructiveReals} : Proper (Qeq ==> CReq R) (CR_of_Q R). Proof. split; apply CR_of_Q_le; rewrite H; apply Qle_refl. Qed. +Definition CR_of_Q_morph (R : ConstructiveReals) : + forall x y, Qeq x y -> CReq R (CR_of_Q R x) (CR_of_Q R y) := + @proper_prf _ _ _ (@CR_of_Q_morph_Proper R). Lemma eq_inject_Q : forall {R : ConstructiveReals} (q r : Q), CR_of_Q R q == CR_of_Q R r -> Qeq q r. diff --git a/theories/Reals/Cauchy/ConstructiveCauchyAbs.v b/theories/Reals/Cauchy/ConstructiveCauchyAbs.v index cf1885068d..51880b0454 100644 --- a/theories/Reals/Cauchy/ConstructiveCauchyAbs.v +++ b/theories/Reals/Cauchy/ConstructiveCauchyAbs.v @@ -192,11 +192,9 @@ Proof. + exact Hdec. Qed. -Add Parametric Morphism : CReal_abs - with signature CRealEq ==> CRealEq - as CReal_abs_morph. +#[global] Instance CReal_abs_morph_Proper : Proper (CRealEq ==> CRealEq) CReal_abs. Proof. - intros. split. + intros x y H. split. - intro abs. destruct (CReal_abs_appart_0 y). + apply (CReal_le_lt_trans _ (CReal_abs x)). * apply CReal_abs_pos. @@ -222,6 +220,9 @@ Proof. * apply CRealLt_asym, c. * rewrite <- H. apply CRealLt_asym, c. Qed. +Definition CReal_abs_morph : + forall x y, CRealEq x y -> CRealEq (CReal_abs x) (CReal_abs y) := + @proper_prf _ _ _ CReal_abs_morph_Proper. Lemma CReal_abs_le : forall a b:CReal, -b <= a <= b -> CReal_abs a <= b. Proof. @@ -438,21 +439,23 @@ Definition CReal_min (x y : CReal) : CReal Definition CReal_max (x y : CReal) : CReal := (x + y + CReal_abs (y - x)) * inject_Q (1#2). -Add Parametric Morphism : CReal_min - with signature CRealEq ==> CRealEq ==> CRealEq - as CReal_min_morph. +#[global] Instance CReal_min_morph_Proper : Proper (CRealEq ==> CRealEq ==> CRealEq) CReal_min. Proof. - intros. unfold CReal_min. + intros x y H x0 y0 H0. unfold CReal_min. rewrite H, H0. reflexivity. Qed. +Definition CReal_min_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> CRealEq (CReal_min x x0) (CReal_min y y0) := + @proper_prf _ _ _ CReal_min_morph_Proper. -Add Parametric Morphism : CReal_max - with signature CRealEq ==> CRealEq ==> CRealEq - as CReal_max_morph. +#[global] Instance CReal_max_morph_Proper : Proper (CRealEq ==> CRealEq ==> CRealEq) CReal_max. Proof. - intros. unfold CReal_max. + intros x y H x0 y0 H0. unfold CReal_max. rewrite H, H0. reflexivity. Qed. +Definition CReal_max_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> CRealEq (CReal_max x x0) (CReal_max y y0) := + @proper_prf _ _ _ CReal_max_morph_Proper. Lemma CReal_double : forall x:CReal, 2 * x == x + x. Proof. diff --git a/theories/Reals/Cauchy/ConstructiveCauchyReals.v b/theories/Reals/Cauchy/ConstructiveCauchyReals.v index 4586786ea1..a77d254e51 100644 --- a/theories/Reals/Cauchy/ConstructiveCauchyReals.v +++ b/theories/Reals/Cauchy/ConstructiveCauchyReals.v @@ -358,11 +358,14 @@ Proof. - intro contra. destruct (CRealLt_dec _ _ y contra); contradiction. Qed. -Add Parametric Relation : CReal CRealEq - reflexivity proved by CRealEq_refl - symmetry proved by CRealEq_sym - transitivity proved by CRealEq_trans - as CRealEq_rel. +#[global] Instance CRealEq_rel_relation : @RewriteRelation CReal CRealEq := {}. +#[global] Instance CRealEq_rel_Reflexive : @Reflexive CReal CRealEq := CRealEq_refl. +#[global] Instance CRealEq_rel_Symmetric : @Symmetric CReal CRealEq := CRealEq_sym. +#[global] Instance CRealEq_rel_Transitive : @Transitive CReal CRealEq := CRealEq_trans. +#[global] Instance CRealEq_rel : @Equivalence CReal CRealEq := { + Equivalence_Reflexive := CRealEq_refl; + Equivalence_Symmetric := CRealEq_sym; + Equivalence_Transitive := CRealEq_trans }. #[global] Instance CRealEq_relT : CRelationClasses.Equivalence CRealEq. @@ -421,9 +424,7 @@ Proof. + right. rewrite Hx0eqy0, Hxeqy. exact Hy0lty. Qed. -Add Parametric Morphism : CRealLtProp - with signature CRealEq ==> CRealEq ==> iff - as CRealLtProp_morph. +#[global] Instance CRealLtProp_morph_Proper : Proper (CRealEq ==> CRealEq ==> iff) CRealLtProp. Proof. intros x y Hxeqy x0 y0 Hx0eqy0. split. @@ -432,10 +433,11 @@ Proof. - intro Hylty0. apply CRealLtForget. apply CRealLtEpsilon in Hylty0. rewrite Hxeqy, Hx0eqy0. exact Hylty0. Qed. +Definition CRealLtProp_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> iff (CRealLtProp x x0) (CRealLtProp y y0) := + @proper_prf _ _ _ CRealLtProp_morph_Proper. -Add Parametric Morphism : CRealLe - with signature CRealEq ==> CRealEq ==> iff - as CRealLe_morph. +#[global] Instance CRealLe_morph_Proper : Proper (CRealEq ==> CRealEq ==> iff) CRealLe. Proof. intros x y Hxeqy x0 y0 Hx0eqy0. split. @@ -444,14 +446,18 @@ Proof. - intros Hxlex0 Hyley0. unfold CRealLe in Hxlex0. rewrite Hx0eqy0 in Hyley0. rewrite Hxeqy in Hyley0. contradiction. Qed. +Definition CRealLe_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> iff (CRealLe x x0) (CRealLe y y0) := + @proper_prf _ _ _ CRealLe_morph_Proper. -Add Parametric Morphism : CRealGe - with signature CRealEq ==> CRealEq ==> iff - as CRealGe_morph. +#[global] Instance CRealGe_morph_Proper : Proper (CRealEq ==> CRealEq ==> iff) CRealGe. Proof. intros x y Hxeqy x0 y0 Hx0eqy0. unfold CRealGe. apply CRealLe_morph; assumption. Qed. +Definition CRealGe_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> iff (CRealGe x x0) (CRealGe y y0) := + @proper_prf _ _ _ CRealGe_morph_Proper. Lemma CRealLt_proper_l : forall x y z : CReal, CRealEq x y @@ -556,14 +562,15 @@ Proof. all: apply Qabs_Qlt_condition in xcau; lra. Qed. -Add Parametric Morphism : inject_Q - with signature Qeq ==> CRealEq - as inject_Q_morph. +#[global] Instance inject_Q_morph_Proper : Proper (Qeq ==> CRealEq) inject_Q. Proof. intros x y Heq; split. all: intros [n Hapart]; cbn in Hapart; rewrite Heq in Hapart. all: assert(2^n>0)%Q by (apply Qpower_0_lt; lra); lra. Qed. +Definition inject_Q_morph : + forall x y, Qeq x y -> CRealEq (inject_Q x) (inject_Q y) := + @proper_prf _ _ _ inject_Q_morph_Proper. #[global] Instance inject_Q_morph_T @@ -845,9 +852,7 @@ Proof. destruct H. contradiction. Qed. -Add Parametric Morphism : CReal_plus - with signature CRealEq ==> CRealEq ==> CRealEq - as CReal_plus_morph. +#[global] Instance CReal_plus_morph_Proper : Proper (CRealEq ==> CRealEq ==> CRealEq) CReal_plus. Proof. intros x y H z t H0. apply (CRealEq_trans _ (CReal_plus x t)). - destruct H0. @@ -856,6 +861,9 @@ Proof. + intro abs. apply CReal_plus_lt_reg_l in abs. contradiction. - apply CReal_plus_proper_r. apply H. Qed. +Definition CReal_plus_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> CRealEq (CReal_plus x x0) (CReal_plus y y0) := + @proper_prf _ _ _ CReal_plus_morph_Proper. #[global] Instance CReal_plus_morph_T diff --git a/theories/Reals/Cauchy/ConstructiveCauchyRealsMult.v b/theories/Reals/Cauchy/ConstructiveCauchyRealsMult.v index aff8eb748b..9f89f84a36 100644 --- a/theories/Reals/Cauchy/ConstructiveCauchyRealsMult.v +++ b/theories/Reals/Cauchy/ConstructiveCauchyRealsMult.v @@ -462,12 +462,13 @@ Proof. - apply CReal_plus_opp_r. Qed. -Add Parametric Morphism : CReal_mult - with signature CRealEq ==> CRealEq ==> CRealEq - as CReal_mult_morph. +#[global] Instance CReal_mult_morph_Proper : Proper (CRealEq ==> CRealEq ==> CRealEq) CReal_mult. Proof. apply CReal_isRingExt. Qed. +Definition CReal_mult_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> CRealEq (CReal_mult x x0) (CReal_mult y y0) := + @proper_prf _ _ _ CReal_mult_morph_Proper. #[global] Instance CReal_mult_morph_T @@ -477,12 +478,13 @@ Proof. apply CReal_isRingExt. Qed. -Add Parametric Morphism : CReal_opp - with signature CRealEq ==> CRealEq - as CReal_opp_morph. +#[global] Instance CReal_opp_morph_Proper : Proper (CRealEq ==> CRealEq) CReal_opp. Proof. apply (Ropp_ext CReal_isRingExt). Qed. +Definition CReal_opp_morph : + forall x y, CRealEq x y -> CRealEq (CReal_opp x) (CReal_opp y) := + @proper_prf _ _ _ CReal_opp_morph_Proper. #[global] Instance CReal_opp_morph_T @@ -492,12 +494,13 @@ Proof. apply CReal_isRingExt. Qed. -Add Parametric Morphism : CReal_minus - with signature CRealEq ==> CRealEq ==> CRealEq - as CReal_minus_morph. +#[global] Instance CReal_minus_morph_Proper : Proper (CRealEq ==> CRealEq ==> CRealEq) CReal_minus. Proof. - intros. unfold CReal_minus. rewrite H,H0. reflexivity. + intros x y H x0 y0 H0. unfold CReal_minus. rewrite H,H0. reflexivity. Qed. +Definition CReal_minus_morph : + forall x y, CRealEq x y -> forall x0 y0, CRealEq x0 y0 -> CRealEq (CReal_minus x x0) (CReal_minus y y0) := + @proper_prf _ _ _ CReal_minus_morph_Proper. #[global] Instance CReal_minus_morph_T diff --git a/theories/micromega/EnvRing.v b/theories/micromega/EnvRing.v index bd157d2868..3dd64a751a 100644 --- a/theories/micromega/EnvRing.v +++ b/theories/micromega/EnvRing.v @@ -112,17 +112,29 @@ Section MakeRingPol. Infix "?=!" := ceqb. Notation "[ x ]" := (phi x). (* Useful tactics *) - Add Morphism radd with signature (req ==> req ==> req) as radd_ext. + Instance radd_ext_Proper : Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. + Definition radd_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @proper_prf _ _ _ radd_ext_Proper. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext. + Instance rmul_ext_Proper : Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. + Definition rmul_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @proper_prf _ _ _ rmul_ext_Proper. - Add Morphism ropp with signature (req ==> req) as ropp_ext. + Instance ropp_ext_Proper : Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. + Definition ropp_ext : + forall x y, req x y -> req (ropp x) (ropp y) := + @proper_prf _ _ _ ropp_ext_Proper. - Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext. + Instance rsub_ext_Proper : Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. + Definition rsub_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @proper_prf _ _ _ rsub_ext_Proper. Ltac rsimpl := gen_srewrite Rsth Reqe ARth. diff --git a/theories/micromega/OrderedRing.v b/theories/micromega/OrderedRing.v index 20692de848..a0a1977dff 100644 --- a/theories/micromega/OrderedRing.v +++ b/theories/micromega/OrderedRing.v @@ -86,43 +86,64 @@ Notation "x <= y" := (rle x y). Notation "x < y" := (rlt x y). -Add Relation R req - reflexivity proved by (@Equivalence_Reflexive _ _ (SORsetoid sor)) - symmetry proved by (@Equivalence_Symmetric _ _ (SORsetoid sor)) - transitivity proved by (@Equivalence_Transitive _ _ (SORsetoid sor)) -as sor_setoid. +Instance sor_setoid_relation : @RewriteRelation R req := {}. +Instance sor_setoid_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ (SORsetoid sor). +Instance sor_setoid_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ (SORsetoid sor). +Instance sor_setoid_Transitive : @Transitive R req := @Equivalence_Transitive _ _ (SORsetoid sor). +Instance sor_setoid : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ (SORsetoid sor); + Equivalence_Symmetric := @Equivalence_Symmetric _ _ (SORsetoid sor); + Equivalence_Transitive := @Equivalence_Transitive _ _ (SORsetoid sor) }. -Add Morphism rplus with signature req ==> req ==> req as rplus_morph. +Instance rplus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rplus. Proof. exact (SORplus_wd sor). Qed. -Add Morphism rtimes with signature req ==> req ==> req as rtimes_morph. +Definition rplus_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rplus x x0) (rplus y y0) := + @Morphisms.proper_prf _ _ _ rplus_morph_Proper. +Instance rtimes_morph_Proper : Morphisms.Proper (req ==> req ==> req) rtimes. Proof. exact (SORtimes_wd sor). Qed. -Add Morphism ropp with signature req ==> req as ropp_morph. +Definition rtimes_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rtimes x x0) (rtimes y y0) := + @Morphisms.proper_prf _ _ _ rtimes_morph_Proper. +Instance ropp_morph_Proper : Morphisms.Proper (req ==> req) ropp. Proof. exact (SORopp_wd sor). Qed. -Add Morphism rle with signature req ==> req ==> iff as rle_morph. +Definition ropp_morph : + forall x y, req x y -> req (ropp x) (ropp y) := + @Morphisms.proper_prf _ _ _ ropp_morph_Proper. +Instance rle_morph_Proper : Morphisms.Proper (req ==> req ==> iff) rle. Proof. exact (SORle_wd sor). Qed. -Add Morphism rlt with signature req ==> req ==> iff as rlt_morph. +Definition rle_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> iff (rle x x0) (rle y y0) := + @Morphisms.proper_prf _ _ _ rle_morph_Proper. +Instance rlt_morph_Proper : Morphisms.Proper (req ==> req ==> iff) rlt. Proof. exact (SORlt_wd sor). Qed. +Definition rlt_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> iff (rlt x x0) (rlt y y0) := + @Morphisms.proper_prf _ _ _ rlt_morph_Proper. Add Ring SOR : (SORrt sor). -Add Morphism rminus with signature req ==> req ==> req as rminus_morph. +Instance rminus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rminus. Proof. intros x1 x2 H1 y1 y2 H2. rewrite ((Rsub_def (SORrt sor)) x1 y1). rewrite ((Rsub_def (SORrt sor)) x2 y2). rewrite H1; now rewrite H2. Qed. +Definition rminus_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rminus x x0) (rminus y y0) := + @Morphisms.proper_prf _ _ _ rminus_morph_Proper. Theorem Rneq_symm : forall n m : R, n ~= m -> m ~= n. Proof. diff --git a/theories/micromega/RMicromega.v b/theories/micromega/RMicromega.v index 57b08fed44..54efea7249 100644 --- a/theories/micromega/RMicromega.v +++ b/theories/micromega/RMicromega.v @@ -232,10 +232,13 @@ Fixpoint R_of_Rcst (r : Rcst) : R := | COpp r => - (R_of_Rcst r) end. -Add Morphism Q2R with signature Qeq ==> @eq R as Q2R_m. +#[global] Instance Q2R_m_Proper : Proper (Qeq ==> @eq R) Q2R. Proof. exact Qeq_eqR. Qed. +Definition Q2R_m : + forall x y, Qeq x y -> @eq R (Q2R x) (Q2R y) := + @proper_prf _ _ _ Q2R_m_Proper. Lemma Q2R_pow_pos : forall q p, Q2R (pow_pos Qmult q p) = pow_pos Rmult (Q2R q) p. diff --git a/theories/micromega/RingMicromega.v b/theories/micromega/RingMicromega.v index a0d043ebc4..2d75e75603 100644 --- a/theories/micromega/RingMicromega.v +++ b/theories/micromega/RingMicromega.v @@ -82,37 +82,58 @@ Record SORaddon := mk_SOR_addon { Variable addon : SORaddon. -Add Relation R req - reflexivity proved by (@Equivalence_Reflexive _ _ (SORsetoid sor)) - symmetry proved by (@Equivalence_Symmetric _ _ (SORsetoid sor)) - transitivity proved by (@Equivalence_Transitive _ _ (SORsetoid sor)) -as micomega_sor_setoid. - -Add Morphism rplus with signature req ==> req ==> req as rplus_morph. +Instance micomega_sor_setoid_relation : @RewriteRelation R req := {}. +Instance micomega_sor_setoid_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ (SORsetoid sor). +Instance micomega_sor_setoid_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ (SORsetoid sor). +Instance micomega_sor_setoid_Transitive : @Transitive R req := @Equivalence_Transitive _ _ (SORsetoid sor). +Instance micomega_sor_setoid : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ (SORsetoid sor); + Equivalence_Symmetric := @Equivalence_Symmetric _ _ (SORsetoid sor); + Equivalence_Transitive := @Equivalence_Transitive _ _ (SORsetoid sor) }. + +Instance rplus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rplus. Proof. exact (SORplus_wd sor). Qed. -Add Morphism rtimes with signature req ==> req ==> req as rtimes_morph. +Definition rplus_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rplus x x0) (rplus y y0) := + @Morphisms.proper_prf _ _ _ rplus_morph_Proper. +Instance rtimes_morph_Proper : Morphisms.Proper (req ==> req ==> req) rtimes. Proof. exact (SORtimes_wd sor). Qed. -Add Morphism ropp with signature req ==> req as ropp_morph. +Definition rtimes_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rtimes x x0) (rtimes y y0) := + @Morphisms.proper_prf _ _ _ rtimes_morph_Proper. +Instance ropp_morph_Proper : Morphisms.Proper (req ==> req) ropp. Proof. exact (SORopp_wd sor). Qed. -Add Morphism rle with signature req ==> req ==> iff as rle_morph. +Definition ropp_morph : + forall x y, req x y -> req (ropp x) (ropp y) := + @Morphisms.proper_prf _ _ _ ropp_morph_Proper. +Instance rle_morph_Proper : Morphisms.Proper (req ==> req ==> iff) rle. Proof. exact (SORle_wd sor). Qed. -Add Morphism rlt with signature req ==> req ==> iff as rlt_morph. +Definition rle_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> iff (rle x x0) (rle y y0) := + @Morphisms.proper_prf _ _ _ rle_morph_Proper. +Instance rlt_morph_Proper : Morphisms.Proper (req ==> req ==> iff) rlt. Proof. exact (SORlt_wd sor). Qed. +Definition rlt_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> iff (rlt x x0) (rlt y y0) := + @Morphisms.proper_prf _ _ _ rlt_morph_Proper. -Add Morphism rminus with signature req ==> req ==> req as rminus_morph. +Instance rminus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rminus. Proof. exact (rminus_morph sor). (* We already proved that minus is a morphism in OrderedRing.v *) Qed. +Definition rminus_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rminus x x0) (rminus y y0) := + @Morphisms.proper_prf _ _ _ rminus_morph_Proper. Definition cneqb (x y : C) := negb (ceqb x y). Definition cltb (x y : C) := (cleb x y) && (cneqb x y). diff --git a/theories/micromega/Tauto.v b/theories/micromega/Tauto.v index fcd783f91a..59a9cd959d 100644 --- a/theories/micromega/Tauto.v +++ b/theories/micromega/Tauto.v @@ -235,35 +235,50 @@ Section S. - exact (eiff_trans k). Qed. - Add Parametric Morphism (k: kind) : (@eAND k) with signature eiff k ==> eiff k ==> eiff k as eAnd_morph. + Instance eAnd_morph_Proper (k: kind) : Morphisms.Proper (eiff k ==> eiff k ==> eiff k) (@eAND k). Proof. - intros. + intros x y H x0 y0 H0. destruct k ; simpl in *; intuition congruence. Qed. + Definition eAnd_morph (k: kind) : + forall x y, eiff k x y -> forall x0 y0, eiff k x0 y0 -> eiff k (@eAND k x x0) (@eAND k y y0) := + @Morphisms.proper_prf _ _ _ (@eAnd_morph_Proper k). - Add Parametric Morphism (k: kind) : (@eOR k) with signature eiff k ==> eiff k ==> eiff k as eOR_morph. + Instance eOR_morph_Proper (k: kind) : Morphisms.Proper (eiff k ==> eiff k ==> eiff k) (@eOR k). Proof. - intros. + intros x y H x0 y0 H0. destruct k ; simpl in *; intuition congruence. Qed. + Definition eOR_morph (k: kind) : + forall x y, eiff k x y -> forall x0 y0, eiff k x0 y0 -> eiff k (@eOR k x x0) (@eOR k y y0) := + @Morphisms.proper_prf _ _ _ (@eOR_morph_Proper k). - Add Parametric Morphism (k: kind) : (@eIMPL k) with signature eiff k ==> eiff k ==> eiff k as eIMPL_morph. + Instance eIMPL_morph_Proper (k: kind) : Morphisms.Proper (eiff k ==> eiff k ==> eiff k) (@eIMPL k). Proof. - intros. + intros x y H x0 y0 H0. destruct k ; simpl in *; intuition congruence. Qed. + Definition eIMPL_morph (k: kind) : + forall x y, eiff k x y -> forall x0 y0, eiff k x0 y0 -> eiff k (@eIMPL k x x0) (@eIMPL k y y0) := + @Morphisms.proper_prf _ _ _ (@eIMPL_morph_Proper k). - Add Parametric Morphism (k: kind) : (@eIFF k) with signature eiff k ==> eiff k ==> eiff k as eIFF_morph. + Instance eIFF_morph_Proper (k: kind) : Morphisms.Proper (eiff k ==> eiff k ==> eiff k) (@eIFF k). Proof. - intros. + intros x y H x0 y0 H0. destruct k ; simpl in *; intuition congruence. Qed. + Definition eIFF_morph (k: kind) : + forall x y, eiff k x y -> forall x0 y0, eiff k x0 y0 -> eiff k (@eIFF k x x0) (@eIFF k y y0) := + @Morphisms.proper_prf _ _ _ (@eIFF_morph_Proper k). - Add Parametric Morphism (k: kind) : (@eNOT k) with signature eiff k ==> eiff k as eNOT_morph. + Instance eNOT_morph_Proper (k: kind) : Morphisms.Proper (eiff k ==> eiff k) (@eNOT k). Proof. - intros. + intros x y H. destruct k ; simpl in *; intuition congruence. Qed. + Definition eNOT_morph (k: kind) : + forall x y, eiff k x y -> eiff k (@eNOT k x) (@eNOT k y) := + @Morphisms.proper_prf _ _ _ (@eNOT_morph_Proper k). Lemma eval_f_morph : forall (ev ev' : forall (k: kind), TA -> rtyp k), diff --git a/theories/micromega/ZCoeff.v b/theories/micromega/ZCoeff.v index 94d4738f76..10bbcb565d 100644 --- a/theories/micromega/ZCoeff.v +++ b/theories/micromega/ZCoeff.v @@ -61,36 +61,57 @@ Proof. Qed. -Add Relation R req - reflexivity proved by (@Equivalence_Reflexive _ _ (SORsetoid sor)) - symmetry proved by (@Equivalence_Symmetric _ _ (SORsetoid sor)) - transitivity proved by (@Equivalence_Transitive _ _ (SORsetoid sor)) -as sor_setoid. +Instance sor_setoid_relation : @RewriteRelation R req := {}. +Instance sor_setoid_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ (SORsetoid sor). +Instance sor_setoid_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ (SORsetoid sor). +Instance sor_setoid_Transitive : @Transitive R req := @Equivalence_Transitive _ _ (SORsetoid sor). +Instance sor_setoid : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ (SORsetoid sor); + Equivalence_Symmetric := @Equivalence_Symmetric _ _ (SORsetoid sor); + Equivalence_Transitive := @Equivalence_Transitive _ _ (SORsetoid sor) }. -Add Morphism rplus with signature req ==> req ==> req as rplus_morph. +Instance rplus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rplus. Proof. exact (SORplus_wd sor). Qed. -Add Morphism rtimes with signature req ==> req ==> req as rtimes_morph. +Definition rplus_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rplus x x0) (rplus y y0) := + @Morphisms.proper_prf _ _ _ rplus_morph_Proper. +Instance rtimes_morph_Proper : Morphisms.Proper (req ==> req ==> req) rtimes. Proof. exact (SORtimes_wd sor). Qed. -Add Morphism ropp with signature req ==> req as ropp_morph. +Definition rtimes_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rtimes x x0) (rtimes y y0) := + @Morphisms.proper_prf _ _ _ rtimes_morph_Proper. +Instance ropp_morph_Proper : Morphisms.Proper (req ==> req) ropp. Proof. exact (SORopp_wd sor). Qed. -Add Morphism rle with signature req ==> req ==> iff as rle_morph. +Definition ropp_morph : + forall x y, req x y -> req (ropp x) (ropp y) := + @Morphisms.proper_prf _ _ _ ropp_morph_Proper. +Instance rle_morph_Proper : Morphisms.Proper (req ==> req ==> iff) rle. Proof. exact (SORle_wd sor). Qed. -Add Morphism rlt with signature req ==> req ==> iff as rlt_morph. +Definition rle_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> iff (rle x x0) (rle y y0) := + @Morphisms.proper_prf _ _ _ rle_morph_Proper. +Instance rlt_morph_Proper : Morphisms.Proper (req ==> req ==> iff) rlt. Proof. exact (SORlt_wd sor). Qed. -Add Morphism rminus with signature req ==> req ==> req as rminus_morph. +Definition rlt_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> iff (rlt x x0) (rlt y y0) := + @Morphisms.proper_prf _ _ _ rlt_morph_Proper. +Instance rminus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rminus. Proof. exact (rminus_morph sor). Qed. +Definition rminus_morph : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rminus x x0) (rminus y y0) := + @Morphisms.proper_prf _ _ _ rminus_morph_Proper. Ltac le_less := rewrite (Rle_lt_eq sor); left; try assumption. Ltac le_equal := rewrite (Rle_lt_eq sor); right; try reflexivity; try assumption. diff --git a/theories/setoid_ring/Field_theory.v b/theories/setoid_ring/Field_theory.v index 60a79b53fb..7338d31ac0 100644 --- a/theories/setoid_ring/Field_theory.v +++ b/theories/setoid_ring/Field_theory.v @@ -58,16 +58,31 @@ Let rI_neq_rO := (AF_1_neq_0 AFth). Let rdiv_def := (AFdiv_def AFth). Let rinv_l := (AFinv_l AFth). -Add Morphism radd with signature (req ==> req ==> req) as radd_ext. +Instance radd_ext_Proper : Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. -Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext. +Definition radd_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @proper_prf _ _ _ radd_ext_Proper. +Instance rmul_ext_Proper : Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. -Add Morphism ropp with signature (req ==> req) as ropp_ext. +Definition rmul_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @proper_prf _ _ _ rmul_ext_Proper. +Instance ropp_ext_Proper : Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. -Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext. +Definition ropp_ext : + forall x y, req x y -> req (ropp x) (ropp y) := + @proper_prf _ _ _ ropp_ext_Proper. +Instance rsub_ext_Proper : Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. -Add Morphism rinv with signature (req ==> req) as rinv_ext. +Definition rsub_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @proper_prf _ _ _ rsub_ext_Proper. +Instance rinv_ext_Proper : Proper (req ==> req) rinv. Proof. exact SRinv_ext. Qed. +Definition rinv_ext : + forall x y, req x y -> req (rinv x) (rinv y) := + @proper_prf _ _ _ rinv_ext_Proper. Let eq_trans := Setoid.Seq_trans _ _ Rsth. Let eq_sym := Setoid.Seq_sym _ _ Rsth. @@ -1657,18 +1672,30 @@ Section Complete. Notation "x / y " := (rdiv x y). Notation "/ x" := (rinv x). Notation "x == y" := (req x y) (at level 70, no associativity). Variable Rsth : Setoid_Theory R req. - Add Parametric Relation : R req - reflexivity proved by (@Equivalence_Reflexive _ _ Rsth) - symmetry proved by (@Equivalence_Symmetric _ _ Rsth) - transitivity proved by (@Equivalence_Transitive _ _ Rsth) - as R_setoid3. + Instance R_setoid3_relation : @RewriteRelation R req := {}. + Instance R_setoid3_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ Rsth. + Instance R_setoid3_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ Rsth. + Instance R_setoid3_Transitive : @Transitive R req := @Equivalence_Transitive _ _ Rsth. + Instance R_setoid3 : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ Rsth; + Equivalence_Symmetric := @Equivalence_Symmetric _ _ Rsth; + Equivalence_Transitive := @Equivalence_Transitive _ _ Rsth }. Variable Reqe : ring_eq_ext radd rmul ropp req. - Add Morphism radd with signature (req ==> req ==> req) as radd_ext3. + Instance radd_ext3_Proper : Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext3. + Definition radd_ext3 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @proper_prf _ _ _ radd_ext3_Proper. + Instance rmul_ext3_Proper : Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. - Add Morphism ropp with signature (req ==> req) as ropp_ext3. + Definition rmul_ext3 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @proper_prf _ _ _ rmul_ext3_Proper. + Instance ropp_ext3_Proper : Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. + Definition ropp_ext3 : + forall x y, req x y -> req (ropp x) (ropp y) := + @proper_prf _ _ _ ropp_ext3_Proper. Section AlmostField. diff --git a/theories/setoid_ring/InitialRing.v b/theories/setoid_ring/InitialRing.v index 797c864e3e..952084da99 100644 --- a/theories/setoid_ring/InitialRing.v +++ b/theories/setoid_ring/InitialRing.v @@ -60,19 +60,31 @@ Section ZMORPHISM. Notation "x - y " := (rsub x y). Notation "- x" := (ropp x). Notation "x == y" := (req x y). Variable Rsth : Setoid_Theory R req. - Add Parametric Relation : R req - reflexivity proved by (@Equivalence_Reflexive _ _ Rsth) - symmetry proved by (@Equivalence_Symmetric _ _ Rsth) - transitivity proved by (@Equivalence_Transitive _ _ Rsth) - as R_setoid3. + Instance R_setoid3_relation : @RewriteRelation R req := {}. + Instance R_setoid3_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ Rsth. + Instance R_setoid3_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ Rsth. + Instance R_setoid3_Transitive : @Transitive R req := @Equivalence_Transitive _ _ Rsth. + Instance R_setoid3 : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ Rsth; + Equivalence_Symmetric := @Equivalence_Symmetric _ _ Rsth; + Equivalence_Transitive := @Equivalence_Transitive _ _ Rsth }. Ltac rrefl := gen_reflexivity Rsth. Variable Reqe : ring_eq_ext radd rmul ropp req. - Add Morphism radd with signature (req ==> req ==> req) as radd_ext3. + Instance radd_ext3_Proper : Morphisms.Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext3. + Definition radd_ext3 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @Morphisms.proper_prf _ _ _ radd_ext3_Proper. + Instance rmul_ext3_Proper : Morphisms.Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. - Add Morphism ropp with signature (req ==> req) as ropp_ext3. + Definition rmul_ext3 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @Morphisms.proper_prf _ _ _ rmul_ext3_Proper. + Instance ropp_ext3_Proper : Morphisms.Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. + Definition ropp_ext3 : + forall x y, req x y -> req (ropp x) (ropp y) := + @Morphisms.proper_prf _ _ _ ropp_ext3_Proper. Fixpoint gen_phiPOS1 (p:positive) : R := match p with @@ -122,8 +134,11 @@ Section ZMORPHISM. Section ALMOST_RING. Variable ARth : almost_ring_theory 0 1 radd rmul rsub ropp req. - Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext3. + Instance rsub_ext3_Proper : Morphisms.Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. + Definition rsub_ext3 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @Morphisms.proper_prf _ _ _ rsub_ext3_Proper. Ltac norm := gen_srewrite Rsth Reqe ARth. Ltac add_push := gen_add_push radd Rsth Reqe ARth. @@ -172,8 +187,11 @@ Section ZMORPHISM. Variable Rth : ring_theory 0 1 radd rmul rsub ropp req. Let ARth := Rth_ARth Rsth Reqe Rth. - Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext4. + Instance rsub_ext4_Proper : Morphisms.Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. + Definition rsub_ext4 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @Morphisms.proper_prf _ _ _ rsub_ext4_Proper. Ltac norm := gen_srewrite Rsth Reqe ARth. Ltac add_push := gen_add_push radd Rsth Reqe ARth. @@ -289,11 +307,14 @@ Section NMORPHISM. Notation "0" := rO. Notation "1" := rI. Notation "x + y" := (radd x y). Notation "x * y " := (rmul x y). Variable Rsth : Setoid_Theory R req. - Add Parametric Relation : R req - reflexivity proved by (@Equivalence_Reflexive _ _ Rsth) - symmetry proved by (@Equivalence_Symmetric _ _ Rsth) - transitivity proved by (@Equivalence_Transitive _ _ Rsth) - as R_setoid4. + Instance R_setoid4_relation : @RewriteRelation R req := {}. + Instance R_setoid4_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ Rsth. + Instance R_setoid4_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ Rsth. + Instance R_setoid4_Transitive : @Transitive R req := @Equivalence_Transitive _ _ Rsth. + Instance R_setoid4 : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ Rsth; + Equivalence_Symmetric := @Equivalence_Symmetric _ _ Rsth; + Equivalence_Transitive := @Equivalence_Transitive _ _ Rsth }. Ltac rrefl := gen_reflexivity Rsth. Variable SReqe : sring_eq_ext radd rmul req. Variable SRth : semi_ring_theory 0 1 radd rmul req. @@ -303,10 +324,16 @@ Section NMORPHISM. Let rsub := (@SRsub R radd). Notation "x - y " := (rsub x y). Notation "- x" := (ropp x). Notation "x == y" := (req x y). - Add Morphism radd with signature (req ==> req ==> req) as radd_ext4. + Instance radd_ext4_Proper : Morphisms.Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext4. + Definition radd_ext4 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @Morphisms.proper_prf _ _ _ radd_ext4_Proper. + Instance rmul_ext4_Proper : Morphisms.Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. + Definition rmul_ext4 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @Morphisms.proper_prf _ _ _ rmul_ext4_Proper. Ltac norm := gen_srewrite_sr Rsth Reqe ARth. Definition gen_phiN1 x := @@ -417,23 +444,38 @@ Section NWORDMORPHISM. Notation "x - y " := (rsub x y). Notation "- x" := (ropp x). Notation "x == y" := (req x y). Variable Rsth : Setoid_Theory R req. - Add Parametric Relation : R req - reflexivity proved by (@Equivalence_Reflexive _ _ Rsth) - symmetry proved by (@Equivalence_Symmetric _ _ Rsth) - transitivity proved by (@Equivalence_Transitive _ _ Rsth) - as R_setoid5. + Instance R_setoid5_relation : @RewriteRelation R req := {}. + Instance R_setoid5_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ Rsth. + Instance R_setoid5_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ Rsth. + Instance R_setoid5_Transitive : @Transitive R req := @Equivalence_Transitive _ _ Rsth. + Instance R_setoid5 : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ Rsth; + Equivalence_Symmetric := @Equivalence_Symmetric _ _ Rsth; + Equivalence_Transitive := @Equivalence_Transitive _ _ Rsth }. Ltac rrefl := gen_reflexivity Rsth. Variable Reqe : ring_eq_ext radd rmul ropp req. - Add Morphism radd with signature (req ==> req ==> req) as radd_ext5. + Instance radd_ext5_Proper : Morphisms.Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext5. + Definition radd_ext5 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @Morphisms.proper_prf _ _ _ radd_ext5_Proper. + Instance rmul_ext5_Proper : Morphisms.Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. - Add Morphism ropp with signature (req ==> req) as ropp_ext5. + Definition rmul_ext5 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @Morphisms.proper_prf _ _ _ rmul_ext5_Proper. + Instance ropp_ext5_Proper : Morphisms.Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. + Definition ropp_ext5 : + forall x y, req x y -> req (ropp x) (ropp y) := + @Morphisms.proper_prf _ _ _ ropp_ext5_Proper. Variable ARth : almost_ring_theory 0 1 radd rmul rsub ropp req. - Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext7. + Instance rsub_ext7_Proper : Morphisms.Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. + Definition rsub_ext7 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @Morphisms.proper_prf _ _ _ rsub_ext7_Proper. Ltac norm := gen_srewrite Rsth Reqe ARth. Ltac add_push := gen_add_push radd Rsth Reqe ARth. @@ -614,20 +656,35 @@ Section GEN_DIV. Variable morph : ring_morph rO rI radd rmul rsub ropp req cO cI cadd cmul csub copp ceqb phi. (* Useful tactics *) - Add Parametric Relation : R req - reflexivity proved by (@Equivalence_Reflexive _ _ Rsth) - symmetry proved by (@Equivalence_Symmetric _ _ Rsth) - transitivity proved by (@Equivalence_Transitive _ _ Rsth) - as R_set1. + Instance R_set1_relation : @RewriteRelation R req := {}. + Instance R_set1_Reflexive : @Reflexive R req := @Equivalence_Reflexive _ _ Rsth. + Instance R_set1_Symmetric : @Symmetric R req := @Equivalence_Symmetric _ _ Rsth. + Instance R_set1_Transitive : @Transitive R req := @Equivalence_Transitive _ _ Rsth. + Instance R_set1 : @Equivalence R req := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ Rsth; + Equivalence_Symmetric := @Equivalence_Symmetric _ _ Rsth; + Equivalence_Transitive := @Equivalence_Transitive _ _ Rsth }. Ltac rrefl := gen_reflexivity Rsth. - Add Morphism radd with signature (req ==> req ==> req) as radd_ext. + Instance radd_ext_Proper : Morphisms.Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext. + Definition radd_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @Morphisms.proper_prf _ _ _ radd_ext_Proper. + Instance rmul_ext_Proper : Morphisms.Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. - Add Morphism ropp with signature (req ==> req) as ropp_ext. + Definition rmul_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @Morphisms.proper_prf _ _ _ rmul_ext_Proper. + Instance ropp_ext_Proper : Morphisms.Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. - Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext. + Definition ropp_ext : + forall x y, req x y -> req (ropp x) (ropp y) := + @Morphisms.proper_prf _ _ _ ropp_ext_Proper. + Instance rsub_ext_Proper : Morphisms.Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. + Definition rsub_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @Morphisms.proper_prf _ _ _ rsub_ext_Proper. Ltac rsimpl := gen_srewrite Rsth Reqe ARth. Definition triv_div x y := diff --git a/theories/setoid_ring/Ring_polynom.v b/theories/setoid_ring/Ring_polynom.v index 4755a972b8..cf13dd5acb 100644 --- a/theories/setoid_ring/Ring_polynom.v +++ b/theories/setoid_ring/Ring_polynom.v @@ -63,17 +63,29 @@ Section MakeRingPol. Infix "?=!" := ceqb. Notation "[ x ]" := (phi x). (* Useful tactics *) - Add Morphism radd with signature (req ==> req ==> req) as radd_ext. + Instance radd_ext_Proper : Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. + Definition radd_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @proper_prf _ _ _ radd_ext_Proper. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext. + Instance rmul_ext_Proper : Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. + Definition rmul_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @proper_prf _ _ _ rmul_ext_Proper. - Add Morphism ropp with signature (req ==> req) as ropp_ext. + Instance ropp_ext_Proper : Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. + Definition ropp_ext : + forall x y, req x y -> req (ropp x) (ropp y) := + @proper_prf _ _ _ ropp_ext_Proper. - Add Morphism rsub with signature (req ==> req ==> req) as rsub_ext. + Instance rsub_ext_Proper : Proper (req ==> req ==> req) rsub. Proof. exact (ARsub_ext Rsth Reqe ARth). Qed. + Definition rsub_ext : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rsub x x0) (rsub y y0) := + @proper_prf _ _ _ rsub_ext_Proper. Ltac rsimpl := gen_srewrite Rsth Reqe ARth. diff --git a/theories/setoid_ring/Ring_theory.v b/theories/setoid_ring/Ring_theory.v index 8370258481..e0f6663d39 100644 --- a/theories/setoid_ring/Ring_theory.v +++ b/theories/setoid_ring/Ring_theory.v @@ -256,11 +256,17 @@ Section ALMOST_RING. Section SEMI_RING. Variable SReqe : sring_eq_ext radd rmul req. - Add Morphism radd with signature (req ==> req ==> req) as radd_ext1. + Instance radd_ext1_Proper : Proper (req ==> req ==> req) radd. Proof. exact (SRadd_ext SReqe). Qed. + Definition radd_ext1 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @proper_prf _ _ _ radd_ext1_Proper. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext1. + Instance rmul_ext1_Proper : Proper (req ==> req ==> req) rmul. Proof. exact (SRmul_ext SReqe). Qed. + Definition rmul_ext1 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @proper_prf _ _ _ rmul_ext1_Proper. Variable SRth : semi_ring_theory 0 1 radd rmul req. @@ -332,14 +338,23 @@ Section ALMOST_RING. Variable Reqe : ring_eq_ext radd rmul ropp req. - Add Morphism radd with signature (req ==> req ==> req) as radd_ext2. + Instance radd_ext2_Proper : Proper (req ==> req ==> req) radd. Proof. exact (Radd_ext Reqe). Qed. + Definition radd_ext2 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (radd x x0) (radd y y0) := + @proper_prf _ _ _ radd_ext2_Proper. - Add Morphism rmul with signature (req ==> req ==> req) as rmul_ext2. + Instance rmul_ext2_Proper : Proper (req ==> req ==> req) rmul. Proof. exact (Rmul_ext Reqe). Qed. + Definition rmul_ext2 : + forall x y, req x y -> forall x0 y0, req x0 y0 -> req (rmul x x0) (rmul y y0) := + @proper_prf _ _ _ rmul_ext2_Proper. - Add Morphism ropp with signature (req ==> req) as ropp_ext2. + Instance ropp_ext2_Proper : Proper (req ==> req) ropp. Proof. exact (Ropp_ext Reqe). Qed. + Definition ropp_ext2 : + forall x y, req x y -> req (ropp x) (ropp y) := + @proper_prf _ _ _ ropp_ext2_Proper. Section RING. Variable Rth : ring_theory 0 1 radd rmul rsub ropp req. @@ -409,27 +424,42 @@ Section ALMOST_RING. Variable Csth : Equivalence ceq. Variable Ceqe : ring_eq_ext cadd cmul copp ceq. - Add Parametric Relation : C ceq - reflexivity proved by (@Equivalence_Reflexive _ _ Csth) - symmetry proved by (@Equivalence_Symmetric _ _ Csth) - transitivity proved by (@Equivalence_Transitive _ _ Csth) - as C_setoid. + Instance C_setoid_relation : @RewriteRelation C ceq := {}. + Instance C_setoid_Reflexive : @Reflexive C ceq := @Equivalence_Reflexive _ _ Csth. + Instance C_setoid_Symmetric : @Symmetric C ceq := @Equivalence_Symmetric _ _ Csth. + Instance C_setoid_Transitive : @Transitive C ceq := @Equivalence_Transitive _ _ Csth. + Instance C_setoid : @Equivalence C ceq := { + Equivalence_Reflexive := @Equivalence_Reflexive _ _ Csth; + Equivalence_Symmetric := @Equivalence_Symmetric _ _ Csth; + Equivalence_Transitive := @Equivalence_Transitive _ _ Csth }. - Add Morphism cadd with signature (ceq ==> ceq ==> ceq) as cadd_ext. + Instance cadd_ext_Proper : Proper (ceq ==> ceq ==> ceq) cadd. Proof. exact (Radd_ext Ceqe). Qed. + Definition cadd_ext : + forall x y, ceq x y -> forall x0 y0, ceq x0 y0 -> ceq (cadd x x0) (cadd y y0) := + @proper_prf _ _ _ cadd_ext_Proper. - Add Morphism cmul with signature (ceq ==> ceq ==> ceq) as cmul_ext. + Instance cmul_ext_Proper : Proper (ceq ==> ceq ==> ceq) cmul. Proof. exact (Rmul_ext Ceqe). Qed. + Definition cmul_ext : + forall x y, ceq x y -> forall x0 y0, ceq x0 y0 -> ceq (cmul x x0) (cmul y y0) := + @proper_prf _ _ _ cmul_ext_Proper. - Add Morphism copp with signature (ceq ==> ceq) as copp_ext. + Instance copp_ext_Proper : Proper (ceq ==> ceq) copp. Proof. exact (Ropp_ext Ceqe). Qed. + Definition copp_ext : + forall x y, ceq x y -> ceq (copp x) (copp y) := + @proper_prf _ _ _ copp_ext_Proper. Variable Cth : ring_theory cO cI cadd cmul csub copp ceq. Variable Smorph : semi_morph 0 1 radd rmul req cO cI cadd cmul ceqb phi. Variable phi_ext : forall x y, ceq x y -> [x] == [y]. - Add Morphism phi with signature (ceq ==> req) as phi_ext1. + Instance phi_ext1_Proper : Proper (ceq ==> req) phi. Proof. exact phi_ext. Qed. + Definition phi_ext1 : + forall x y, ceq x y -> req (phi x) (phi y) := + @proper_prf _ _ _ phi_ext1_Proper. Lemma Smorph_opp x : [-!x] == -[x]. Proof.