# Library Coq.Reals.R_Ifp

Complements for the reals.Integer and fractional part
Require Import Rbase.
Require Import Omega.
Open Local 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).
Lemma tech_up : forall (r:R) (z:Z), r < IZR z -> IZR z <= r + 1 -> z = up r.
Lemma up_tech :
forall (r:R) (z:Z), IZR z <= r -> r < IZR (z + 1) -> (z + 1)%Z = up r.
Lemma fp_R0 : frac_part 0 = 0.
Lemma for_base_fp : forall r:R, IZR (up r) - r > 0 /\ IZR (up r) - r <= 1.
Lemma base_fp : forall r:R, frac_part r >= 0 /\ frac_part r < 1.

# Properties

Lemma base_Int_part :
forall r:R, IZR (Int_part r) <= r /\ IZR (Int_part r) - r > -1.
Lemma Int_part_INR : forall n:nat, Int_part (INR n) = Z_of_nat n.
Lemma fp_nat : forall r:R, frac_part r = 0 -> exists c : Z , r = IZR c.
Lemma R0_fp_O : forall r:R, 0 <> frac_part r -> 0 <> r.
Lemma Rminus_Int_part1 :
forall r1 r2:R,
frac_part r1 >= frac_part r2 ->
Int_part (r1 - r2) = (Int_part r1 - Int_part r2)%Z.
Lemma Rminus_Int_part2 :
forall r1 r2:R,
frac_part r1 < frac_part r2 ->
Int_part (r1 - r2) = (Int_part r1 - Int_part r2 - 1)%Z.
Lemma Rminus_fp1 :
forall r1 r2:R,
frac_part r1 >= frac_part r2 ->
frac_part (r1 - r2) = frac_part r1 - frac_part r2.
Lemma Rminus_fp2 :
forall r1 r2:R,
frac_part r1 < frac_part r2 ->
frac_part (r1 - r2) = frac_part r1 - frac_part r2 + 1.
Lemma plus_Int_part1 :
forall r1 r2:R,
frac_part r1 + frac_part r2 >= 1 ->
Int_part (r1 + r2) = (Int_part r1 + Int_part r2 + 1)%Z.
Lemma plus_Int_part2 :
forall r1 r2:R,
frac_part r1 + frac_part r2 < 1 ->
Int_part (r1 + r2) = (Int_part r1 + Int_part r2)%Z.
Lemma plus_frac_part1 :
forall r1 r2:R,
frac_part r1 + frac_part r2 >= 1 ->
frac_part (r1 + r2) = frac_part r1 + frac_part r2 - 1.
Lemma plus_frac_part2 :
forall r1 r2:R,
frac_part r1 + frac_part r2 < 1 ->
frac_part (r1 + r2) = frac_part r1 + frac_part r2.