Module MyNat.
End MyNat.
Open Scope R_scope.
(** * Integers *)
(** Integer part in Z *)
Definition floor x := proj1_sig (floor_ex x).
Definition floor1 x := proj1_sig (floor1_ex x).
(** Interger part in nat *)
Definition nfloor x pr := proj1_sig (nfloor_ex x pr).
Definition nfloor1 x pr := proj1_sig (nfloor1_ex x pr).
(** More theorems about INR *)
Fixpoint pow2 (n : nat) : nat :=
match n with
| O => 1%nat
| S n => (2 * pow2 n)%nat
end.
(** * Rinv *)
(** * Rdiv *)
(** Rewritings *)
(** Order *)
(** * Rmult *)
(** * Rminus *)
(** Rewritings *)
(** Order *)
(** * Rplus *)
(** Sums *)
(** * Rmin and Rmax *)
(** Rewritings *)
intros x y z; unfold Rmin.
destruct (Rle_dec y z);
destruct (Rle_dec x y);
destruct (Rle_dec x z);
destruct (Rle_dec y z) ; try intuition.
contradict n.
apply Rle_trans with y ; auto.
contradict r.
apply Rlt_not_le, Rlt_trans with y ; apply Rnot_le_lt ; auto.
Qed.
intros x y z; unfold Rmax.
destruct (Rle_dec y z);
destruct (Rle_dec x y);
destruct (Rle_dec x z);
destruct (Rle_dec y z) ; try intuition.
contradict n.
apply Rle_trans with y ; auto.
contradict r.
apply Rlt_not_le, Rlt_trans with y ; apply Rnot_le_lt ; auto.
Qed.
(** Order *)
(** * Rabs *)
(** Rewritings *)
(** Order *)
(** * Req *)
(** * posreal *)
Definition pos_div_2 (eps : posreal) := mkposreal _ (is_pos_div_2 eps).
(** * The sign function *)
Definition sign (x : R) :=
match total_order_T 0 x with
| inleft (left _) => 1
| inleft (right _) => 0
| inright _ => -1
end.
(** * ssreflect.seq *)
(** Finite subdivision *)
Definition belast {T : Type} (s : seq T) :=
match s with
| [::] => [::]
| h :: s => belast h s
end.

(** zip and unzip *)
Lemma size_unzip1 {T T0 : Type} (s : seq (T * T0)) : size (unzip1 s) = size s.
Lemma size_unzip2 {T T0 : Type} (s : seq (T * T0)) : size (unzip2 s) = size s.
Lemma zip_cons {S T : Type} hs ht (s : seq S) (t : seq T) :
zip (hs :: s) (ht :: t) = (hs,ht) :: zip s t.