Library Stdlib.micromega.ZCoeff
From Stdlib Require Import OrderedRing.
From Stdlib Require Import RingMicromega.
From Stdlib Require Import BinInt.
From Stdlib Require Import InitialRing.
From Stdlib Require Import Setoid.
From Stdlib Require Import ZArithRing.
Import OrderedRingSyntax.
Set Implicit Arguments.
Section InitialMorphism.
Variable R : Type.
Variables rO rI : R.
Variables rplus rtimes rminus: R -> R -> R.
Variable ropp : R -> R.
Variables req rle rlt : R -> R -> Prop.
Variable sor : SOR rO rI rplus rtimes rminus ropp req rle rlt.
Notation "0" := rO.
Notation "1" := rI.
Notation "x + y" := (rplus x y).
Notation "x * y " := (rtimes x y).
Notation "x - y " := (rminus x y).
Notation "- x" := (ropp x).
Notation "x == y" := (req x y).
Notation "x ~= y" := (~ req x y).
Notation "x <= y" := (rle x y).
Notation "x < y" := (rlt x y).
Lemma req_refl : forall x, req x x.
Lemma req_sym : forall x y, req x y -> req y x.
Lemma req_trans : forall x y z, req x y -> req y z -> req x z.
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) }.
Instance rplus_morph_Proper : Morphisms.Proper (req ==> req ==> req) rplus.
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.
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.
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.
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.
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.
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.
Definition gen_order_phi_Z : Z -> R := gen_phiZ 0 1 rplus rtimes ropp.
Notation "[ x ]" := (gen_order_phi_Z x).
Lemma ring_ops_wd : ring_eq_ext rplus rtimes ropp req.
Lemma Zring_morph :
ring_morph 0 1 rplus rtimes rminus ropp req
0%Z 1%Z Z.add Z.mul Z.sub Z.opp
Z.eqb gen_order_phi_Z.
Lemma phi_pos1_pos : forall x : positive, 0 < phi_pos1 x.
Lemma phi_pos1_succ : forall x : positive, phi_pos1 (Pos.succ x) == 1 + phi_pos1 x.
Lemma clt_pos_morph : forall x y : positive, (x < y)%positive -> phi_pos1 x < phi_pos1 y.
Lemma clt_morph : forall x y : Z, (x < y)%Z -> [x] < [y].
Lemma Zcleb_morph : forall x y : Z, Z.leb x y = true -> [x] <= [y].
Lemma Zcneqb_morph : forall x y : Z, Z.eqb x y = false -> [x] ~= [y].
End InitialMorphism.