Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)

(**********************************************************)
Complements for the reals.Integer and fractional part
(*                                                        *)
(**********************************************************)

Require Import Rbase.
Require Import Omega.
Local Open Scope R_scope.

(*********************************************************)

Fractional part

(*********************************************************)

(**********)
Definition Int_part (r:R) : Z := (up r - 1)%Z.

(**********)
Definition frac_part (r:R) : R := r - IZR (Int_part r).

(**********)

forall (r : R) (z : Z), r < IZR z -> IZR z <= r + 1 -> z = up r

forall (r : R) (z : Z), r < IZR z -> IZR z <= r + 1 -> z = up r
intros; generalize (archimed r); intro; elim H1; intros; clear H1; unfold Rgt in H2; unfold Rminus in H3; generalize (Rplus_le_compat_l r (IZR (up r) + - r) 1 H3); intro; clear H3; rewrite (Rplus_comm (IZR (up r)) (- r)) in H1; rewrite <- (Rplus_assoc r (- r) (IZR (up r))) in H1; rewrite (Rplus_opp_r r) in H1; elim (Rplus_ne (IZR (up r))); intros a b; rewrite b in H1; clear a b; apply (single_z_r_R1 r z (up r)); auto with zarith real. Qed. (**********)

forall (r : R) (z : Z), IZR z <= r -> r < IZR (z + 1) -> (z + 1)%Z = up r

forall (r : R) (z : Z), IZR z <= r -> r < IZR (z + 1) -> (z + 1)%Z = up r
r:R
z:Z
H:IZR z <= r
H0:r < IZR (z + 1)

(z + 1)%Z = up r
r:R
z:Z
H:IZR z <= r
H0:r < IZR (z + 1)

IZR (z + 1) <= r + 1
r:R
z:Z
H:IZR z <= r
H0:r < IZR (z + 1)

IZR z + 1 <= r + 1
now apply Rplus_le_compat_r. Qed. (**********)

frac_part 0 = 0

frac_part 0 = 0

0 - IZR (up 0 - 1) = 0

0 - IZR (1 - 1) = 0

1%Z = up 0

1%Z = up 0
H1:IZR (up 0) > 0
H2:IZR (up 0) - 0 <= 1

1%Z = up 0
H1:(0 < up 0)%Z
H2:IZR (up 0) - 0 <= 1

1%Z = up 0
H1:(0 < up 0)%Z
H2:IZR (up 0 - 0) <= 1

1%Z = up 0
H1:(0 < up 0)%Z
H2:(up 0 - 0 <= 1)%Z

1%Z = up 0
omega. Qed. (**********)

forall r : R, IZR (up r) - r > 0 /\ IZR (up r) - r <= 1

forall r : R, IZR (up r) - r > 0 /\ IZR (up r) - r <= 1
r:R

IZR (up r) > r /\ IZR (up r) - r <= 1 -> IZR (up r) - r > 0
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1 -> IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R
H:IZR (up r) > r /\ IZR (up r) - r <= 1
H0:IZR (up r) > r
H1:IZR (up r) - r <= 1

IZR (up r) - r > 0
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1 -> IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R

IZR (up r) > r /\ IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1 -> IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R

IZR (up r) > r /\ IZR (up r) - r <= 1 -> IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R
H:IZR (up r) > r /\ IZR (up r) - r <= 1
H0:IZR (up r) > r
H1:IZR (up r) - r <= 1

IZR (up r) - r <= 1
r:R
IZR (up r) > r /\ IZR (up r) - r <= 1
r:R

IZR (up r) > r /\ IZR (up r) - r <= 1
apply archimed. Qed. (**********)

forall r : R, frac_part r >= 0 /\ frac_part r < 1

forall r : R, frac_part r >= 0 /\ frac_part r < 1
r:R

r - IZR (up r - 1) >= 0
r:R
r - IZR (up r - 1) < 1
(*sup a O*)
r:R

r - IZR (up r) >= -1 -> r - IZR (up r - 1) >= 0
r:R
r - IZR (up r) >= -1
r:R
r - IZR (up r - 1) < 1
r:R

r - IZR (up r) >= -1
r:R
r - IZR (up r - 1) < 1
r:R

r - IZR (up r - 1) < 1
(*inf a 1*)
r:R

r - IZR (up r) < 0 -> r - IZR (up r - 1) < 1
r:R
r - IZR (up r) < 0
r:R

r - IZR (up r) < 0
elim (for_base_fp r); intros; rewrite <- Ropp_0; rewrite <- Ropp_minus_distr; apply Ropp_gt_lt_contravar; auto with zarith real. Qed. (*********************************************************)

Properties

(*********************************************************)

(**********)

forall r : R, IZR (Int_part r) <= r /\ IZR (Int_part r) - r > -1

forall r : R, IZR (Int_part r) <= r /\ IZR (Int_part r) - r > -1
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r - 1) <= r /\ IZR (up r - 1) - r > -1
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r) - 1 <= r
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1
IZR (up r) - 1 - r > -1
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r) - 1 - r <= 0
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1
IZR (up r) - 1 - r > -1
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r) - r - 1 <= 0
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1
IZR (up r) - 1 - r > -1
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r) - 1 - r > -1
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r) - 1 - r - -1 > 0
r:R
H:IZR (up r) > r
H0:IZR (up r) - r <= 1

IZR (up r) - r > 0
now apply Rgt_minus. Qed. (**********)

forall n : nat, Int_part (INR n) = Z.of_nat n

forall n : nat, Int_part (INR n) = Z.of_nat n
n:nat

(up (INR n) - 1)%Z = Z.of_nat n
n:nat

up (INR n) = (Z.of_nat n + Z.of_nat 1)%Z -> (up (INR n) - 1)%Z = Z.of_nat n
n:nat
up (INR n) = (Z.of_nat n + Z.of_nat 1)%Z
n:nat

up (INR n) = (Z.of_nat n + Z.of_nat 1)%Z
n:nat

INR n < IZR (Z.of_nat n + Z.of_nat 1)
n:nat
IZR (Z.of_nat n + Z.of_nat 1) <= INR n + 1
n:nat

INR n < IZR (Z.of_nat (S n))
n:nat
Z.of_nat (S n) = (Z.of_nat n + Z.of_nat 1)%Z
n:nat
IZR (Z.of_nat n + Z.of_nat 1) <= INR n + 1
n:nat

INR n < INR (S n)
n:nat
Z.of_nat (S n) = (Z.of_nat n + Z.of_nat 1)%Z
n:nat
IZR (Z.of_nat n + Z.of_nat 1) <= INR n + 1
n:nat

Z.of_nat (S n) = (Z.of_nat n + Z.of_nat 1)%Z
n:nat
IZR (Z.of_nat n + Z.of_nat 1) <= INR n + 1
n:nat

IZR (Z.of_nat n + Z.of_nat 1) <= INR n + 1
n:nat

IZR (Z.of_nat n) + 1 <= INR n + 1
repeat rewrite <- INR_IZR_INZ; auto with real. Qed. (**********)

forall r : R, frac_part r = 0 -> exists c : Z, r = IZR c

forall r : R, frac_part r = 0 -> exists c : Z, r = IZR c
unfold frac_part; intros; split with (Int_part r); apply Rminus_diag_uniq; auto with zarith real. Qed. (**********)

forall r : R, 0 <> frac_part r -> 0 <> r

forall r : R, 0 <> frac_part r -> 0 <> r
red; intros; rewrite <- H0 in H; generalize fp_R0; intro; auto with zarith real. Qed. (**********)

forall r1 r2 : R, frac_part r1 >= frac_part r2 -> Int_part (r1 - r2) = (Int_part r1 - Int_part r2)%Z

forall r1 r2 : R, frac_part r1 >= frac_part r2 -> Int_part (r1 - r2) = (Int_part r1 - Int_part r2)%Z
r1, r2:R
H0:IZR (Int_part r1 - Int_part r2) <= r1 - r2
H:r1 - r2 < IZR (Int_part r1 - Int_part r2) + 1

Int_part (r1 - r2) = (Int_part r1 - Int_part r2)%Z
rewrite <- (plus_IZR (Int_part r1 - Int_part r2) 1) in H; generalize (up_tech (r1 - r2) (Int_part r1 - Int_part r2) H0 H); intros; clear H H0; unfold Int_part at 1; omega. Qed. (**********)

forall r1 r2 : R, frac_part r1 < frac_part r2 -> Int_part (r1 - r2) = (Int_part r1 - Int_part r2 - 1)%Z

forall r1 r2 : R, frac_part r1 < frac_part r2 -> Int_part (r1 - r2) = (Int_part r1 - Int_part r2 - 1)%Z
r1, r2:R
H:IZR (Int_part r1 - Int_part r2) + -1 < r1 - r2
H0:r1 - r2 < IZR (Int_part r1 - Int_part r2) - 1 + 1

Int_part (r1 - r2) = (Int_part r1 - Int_part r2 - 1)%Z
change (_ + -1) with (IZR (Int_part r1 - Int_part r2) - 1) in H; rewrite (Z_R_minus (Int_part r1 - Int_part r2) 1) in H; rewrite (Z_R_minus (Int_part r1 - Int_part r2) 1) in H0; rewrite <- (plus_IZR (Int_part r1 - Int_part r2 - 1) 1) in H0; generalize (Rlt_le (IZR (Int_part r1 - Int_part r2 - 1)) (r1 - r2) H); intro; clear H; generalize (up_tech (r1 - r2) (Int_part r1 - Int_part r2 - 1) H1 H0); intros; clear H0 H1; unfold Int_part at 1; omega. Qed. (**********)

forall r1 r2 : R, frac_part r1 >= frac_part r2 -> frac_part (r1 - r2) = frac_part r1 - frac_part r2

forall r1 r2 : R, frac_part r1 >= frac_part r2 -> frac_part (r1 - r2) = frac_part r1 - frac_part r2
intros; unfold frac_part; generalize (Rminus_Int_part1 r1 r2 H); intro; rewrite H0; rewrite <- (Z_R_minus (Int_part r1) (Int_part r2)); unfold Rminus; rewrite (Ropp_plus_distr (IZR (Int_part r1)) (- IZR (Int_part r2))); rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2))); rewrite (Ropp_involutive (IZR (Int_part r2))); rewrite (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2))); rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2))); rewrite <- (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2))); rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2))); rewrite (Rplus_comm (- r2) (- IZR (Int_part r1))); auto with zarith real. Qed. (**********)

forall r1 r2 : R, frac_part r1 < frac_part r2 -> frac_part (r1 - r2) = frac_part r1 - frac_part r2 + 1

forall r1 r2 : R, frac_part r1 < frac_part r2 -> frac_part (r1 - r2) = frac_part r1 - frac_part r2 + 1
intros; unfold frac_part; generalize (Rminus_Int_part2 r1 r2 H); intro; rewrite H0; rewrite <- (Z_R_minus (Int_part r1 - Int_part r2) 1); rewrite <- (Z_R_minus (Int_part r1) (Int_part r2)); unfold Rminus; rewrite (Ropp_plus_distr (IZR (Int_part r1) + - IZR (Int_part r2)) (- IZR 1)) ; rewrite (Ropp_plus_distr r2 (- IZR (Int_part r2))); rewrite (Ropp_involutive (IZR 1)); rewrite (Ropp_involutive (IZR (Int_part r2))); rewrite (Ropp_plus_distr (IZR (Int_part r1))); rewrite (Ropp_involutive (IZR (Int_part r2))); simpl; rewrite <- (Rplus_assoc (r1 + - r2) (- IZR (Int_part r1) + IZR (Int_part r2)) 1) ; rewrite (Rplus_assoc r1 (- r2) (- IZR (Int_part r1) + IZR (Int_part r2))); rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (- r2 + IZR (Int_part r2))); rewrite <- (Rplus_assoc (- r2) (- IZR (Int_part r1)) (IZR (Int_part r2))); rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- r2) (IZR (Int_part r2))); rewrite (Rplus_comm (- r2) (- IZR (Int_part r1))); auto with zarith real. Qed. (**********)

forall r1 r2 : R, frac_part r1 + frac_part r2 >= 1 -> Int_part (r1 + r2) = (Int_part r1 + Int_part r2 + 1)%Z

forall r1 r2 : R, frac_part r1 + frac_part r2 >= 1 -> Int_part (r1 + r2) = (Int_part r1 + Int_part r2 + 1)%Z
r1, r2:R
H:IZR (Int_part r1) + IZR (Int_part r2) + 1 <= r1 + r2
H0:r1 + r2 < IZR (Int_part r1) + IZR (Int_part r2) + 1 + 1

Int_part (r1 + r2) = (Int_part r1 + Int_part r2 + 1)%Z
rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H; rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H0; rewrite <- (plus_IZR (Int_part r1 + Int_part r2) 1) in H; rewrite <- (plus_IZR (Int_part r1 + Int_part r2) 1) in H0; rewrite <- (plus_IZR (Int_part r1 + Int_part r2 + 1) 1) in H0; generalize (up_tech (r1 + r2) (Int_part r1 + Int_part r2 + 1) H H0); intro; clear H H0; unfold Int_part at 1; omega. Qed. (**********)

forall r1 r2 : R, frac_part r1 + frac_part r2 < 1 -> Int_part (r1 + r2) = (Int_part r1 + Int_part r2)%Z

forall r1 r2 : R, frac_part r1 + frac_part r2 < 1 -> Int_part (r1 + r2) = (Int_part r1 + Int_part r2)%Z
r1, r2:R
H0:IZR (Int_part r1) + IZR (Int_part r2) <= r1 + r2
H1:r1 + r2 < IZR (Int_part r1) + IZR (Int_part r2) + 1

Int_part (r1 + r2) = (Int_part r1 + Int_part r2)%Z
rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H0; rewrite <- (plus_IZR (Int_part r1) (Int_part r2)) in H1; rewrite <- (plus_IZR (Int_part r1 + Int_part r2) 1) in H1; generalize (up_tech (r1 + r2) (Int_part r1 + Int_part r2) H0 H1); intro; clear H0 H1; unfold Int_part at 1; omega. Qed. (**********)

forall r1 r2 : R, frac_part r1 + frac_part r2 >= 1 -> frac_part (r1 + r2) = frac_part r1 + frac_part r2 - 1

forall r1 r2 : R, frac_part r1 + frac_part r2 >= 1 -> frac_part (r1 + r2) = frac_part r1 + frac_part r2 - 1
intros; unfold frac_part; generalize (plus_Int_part1 r1 r2 H); intro; rewrite H0; rewrite (plus_IZR (Int_part r1 + Int_part r2) 1); rewrite (plus_IZR (Int_part r1) (Int_part r2)); simpl; unfold Rminus at 3 4; rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2))); rewrite (Rplus_comm r2 (- IZR (Int_part r2))); rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2); rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2); rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2))); rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2))); unfold Rminus; rewrite (Rplus_assoc (r1 + r2) (- (IZR (Int_part r1) + IZR (Int_part r2))) (-(1))) ; rewrite <- (Ropp_plus_distr (IZR (Int_part r1) + IZR (Int_part r2)) 1); trivial with zarith real. Qed. (**********)

forall r1 r2 : R, frac_part r1 + frac_part r2 < 1 -> frac_part (r1 + r2) = frac_part r1 + frac_part r2

forall r1 r2 : R, frac_part r1 + frac_part r2 < 1 -> frac_part (r1 + r2) = frac_part r1 + frac_part r2
intros; unfold frac_part; generalize (plus_Int_part2 r1 r2 H); intro; rewrite H0; rewrite (plus_IZR (Int_part r1) (Int_part r2)); unfold Rminus at 2 3; rewrite (Rplus_assoc r1 (- IZR (Int_part r1)) (r2 + - IZR (Int_part r2))); rewrite (Rplus_comm r2 (- IZR (Int_part r2))); rewrite <- (Rplus_assoc (- IZR (Int_part r1)) (- IZR (Int_part r2)) r2); rewrite (Rplus_comm (- IZR (Int_part r1) + - IZR (Int_part r2)) r2); rewrite <- (Rplus_assoc r1 r2 (- IZR (Int_part r1) + - IZR (Int_part r2))); rewrite <- (Ropp_plus_distr (IZR (Int_part r1)) (IZR (Int_part r2))); unfold Rminus; trivial with zarith real. Qed.