End Internals.
Module PredInstances.
Canonical pos_mulrPred.
Canonical pos_divrPred.
Canonical nneg_addrPred.
Canonical nneg_mulrPred.
Canonical nneg_divrPred.
Canonical nneg_semiringPred.
Canonical real_addrPred.
Canonical real_opprPred.
Canonical real_zmodPred.
Canonical real_mulrPred.
Canonical real_smulrPred.
Canonical real_divrPred.
Canonical real_sdivrPred.
Canonical real_semiringPred.
Canonical real_subringPred.
Canonical real_divringPred.
End PredInstances.
Module Import ExtraDef.
Definition archi_bound {R} x := sval (sigW (@archi_bound_subproof R x)).
Definition sqrtr {R} x := s2val (sig2W (@sqrtr_subproof R x)).
End ExtraDef.
Notation bound := archi_bound.
Notation sqrt := sqrtr.
Module Theory.
Section NumIntegralDomainTheory.
Variable R : numDomainType.
Implicit Types x y z t : R.
(* Lemmas from the signature (reexported from internals). *)
Definition ler_norm_add x y : `|x + y| <= `|x| + `|y| := ler_norm_add x y.
Definition addr_gt0 x y : 0 < x -> 0 < y -> 0 < x + y := @addr_gt0 R x y.
Definition normr0_eq0 x : `|x| = 0 -> x = 0 := @normr0_eq0 R x.
Definition ger_leVge x y : 0 <= x -> 0 <= y -> (x <= y) || (y <= x) :=
@ger_leVge R x y.
Definition normrM : {morph normr : x y / x * y : R} := @normrM R.
Definition ler_def x y : (x <= y) = (`|y - x| == y - x) := @ler_def R x y.
Definition ltr_def x y : (x < y) = (y != x) && (x <= y) := @ltr_def R x y.
(* Predicate and relation definitions. *)

(* Specifications: *)
Lemma gerE x y : ge x y = (y <= x). Proof. by []. Qed.
Lemma gtrE x y : gt x y = (y < x). Proof. by []. Qed.
Lemma posrE x : (x \is pos) = (0 < x). Proof. by []. Qed.
Lemma negrE x : (x \is neg) = (x < 0). Proof. by []. Qed.
Lemma nnegrE x : (x \is nneg) = (0 <= x). Proof. by []. Qed.
Lemma realE x : (x \is real) = (0 <= x) || (x <= 0). Proof. by []. Qed.
(* General properties of <= and < *)
Lemma lerr x : x <= x. Proof. exact: lerr. Qed.
Lemma ltrr x : x < x = false. Proof. by rewrite ltr_def eqxx. Qed.
Lemma ltrW x y : x < y -> x <= y. Proof. exact: ltrW. Qed.
Hint Resolve lerr ltrr ltrW : core.
Lemma ltr_neqAle x y : (x < y) = (x != y) && (x <= y).
(* Integer comparisons and characteristic 0. *)
Lemma ler01 : 0 <= 1 :> R. Proof. exact: ler01. Qed.
Lemma ltr01 : 0 < 1 :> R. Proof. exact: ltr01. Qed.
Lemma ler0n n : 0 <= n%:R :> R. Proof. by rewrite -nnegrE rpred_nat. Qed.
Hint Resolve ler01 ltr01 ler0n : core.
Lemma ltr0Sn n : 0 < n.+1%:R :> R.
Lemma normrV : {in GRing.unit, {morph (@normr R) : x / x ^-1}}.
Lemma normr0P {x} : reflect (`|x| = 0) (x == 0).
Lemma normrN x : `|- x| = `|x|.
Lemma normr_ge0 x : 0 <= `|x|. Proof. by rewrite ger0_def normr_id. Qed.
Hint Resolve normr_ge0 : core.
Lemma ler0_norm x : x <= 0 -> `|x| = - x.
Lemma eqr_le x y : (x == y) = (x <= y <= x).
Lemma ler_lt_trans y x z : x <= y -> y < z -> x < z.
Definition lter01 := (ler01, ltr01).