(************************************************************************)
(*         *   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)         *)
(************************************************************************)
(************************************************************************)
(*********************************************************)
(** * Basic lemmas for the classical real numbers        *)
(*********************************************************)
Require Export Raxioms.
Require Export ZArithRing.
Require Export RealField.
Local Open Scope Z_scope.
Local Open Scope R_scope.
Implicit Type r : R.
(*********************************************************)
(** ** Relation between orders and equality              *)
(*********************************************************)
(** Reflexivity of the large order *)
Hint Immediate Rle_refl: rorders.
Hint Resolve Rlt_irrefl: real.
Hint Resolve Rlt_dichotomy_converse: real.
(** Reasoning by case on equality and order *)
Hint Resolve Req_dec: real.
(*********************************************************)
(** ** Relating [<], [>], [<=] and [>=]                  *)
(*********************************************************)
(*********************************************************)
(** ** Order                                             *)
(*********************************************************)
(** *** Relating strict and large orders *)
Hint Resolve Rlt_le: real.
Hint Immediate Rle_ge: real.
Hint Resolve Rle_ge: rorders.
Hint Resolve Rge_le: real.
Hint Immediate Rge_le: rorders.
Hint Resolve Rlt_gt: rorders.
Hint Immediate Rgt_lt: rorders.
(**********)
Hint Immediate Rnot_le_lt: real.
Hint Immediate Rlt_not_le: real.
Hint Immediate Req_le: real.
Hint Immediate Req_ge: real.
Hint Immediate Req_le_sym: real.
Hint Immediate Req_ge_sym: real.
(** *** Asymmetry *)
(** Remark: [Rlt_asym] is an axiom *)
Hint Resolve Rle_antisym: real.
(** *** Compatibility with equality *)
(*********************************************************)
(** ** Addition                                          *)
(*********************************************************)
(** Remark: [Rplus_0_l] is an axiom *)
Hint Resolve Rplus_0_r: real.
Hint Resolve Rplus_ne: real.
(**********)
(** Remark: [Rplus_opp_r] is an axiom *)
Hint Resolve Rplus_opp_l: real.
Definition f_equal_R := (f_equal (A:=R)).
Hint Resolve f_equal_R : real.
Hint Resolve Rplus_eq_reg_l: real.
(*********************************************************)
(** ** Multiplication                                    *)
(*********************************************************)
Hint Resolve Rinv_r: real.
Hint Resolve Rinv_l_sym: real.
Hint Resolve Rinv_r_sym: real.
Hint Resolve Rmult_0_r: real.
Hint Resolve Rmult_0_l: real.
Hint Resolve Rmult_ne: real.
Hint Resolve Rmult_1_r: real.
Hint Resolve Rmult_eq_0_compat: real.
Hint Resolve Rmult_integral_contrapositive: real.
(*********************************************************)
(** ** Square function                                   *)
(*********************************************************)
(***********)
Definition Rsqr r : R := r * r.
Notation "r ²" := (Rsqr r) (at level 1, format "r ²") : R_scope.
unfold Rsqr; auto with real.
Qed.
unfold Rsqr; intros; elim (Rmult_integral r r H); trivial.
Qed.
(*********************************************************)
(** ** Opposite                                          *)
(*********************************************************)
Hint Resolve Ropp_eq_compat: real.
Hint Resolve Ropp_0: real.
Hint Resolve Ropp_eq_0_compat: real.
Hint Resolve Ropp_involutive: real.
Hint Resolve Ropp_neq_0_compat: real.
Hint Resolve Ropp_plus_distr: real.
(*********************************************************)
(** ** Opposite and multiplication                       *)
(*********************************************************)
Hint Resolve Ropp_mult_distr_l_reverse: real.
Hint Resolve Rmult_opp_opp: real.
(*********************************************************)
(** ** Subtraction                                       *)
(*********************************************************)
Hint Resolve Rminus_0_r: real.
Hint Resolve Rminus_0_l: real.
Hint Resolve Ropp_minus_distr: real.
Hint Resolve Rminus_diag_eq: real.
Hint Immediate Rminus_diag_uniq: real.
Hint Immediate Rminus_diag_uniq_sym: real.
Hint Resolve Rplus_minus: real.
Hint Resolve Rminus_eq_contra: real.
Hint Resolve Rminus_not_eq: real.
Hint Resolve Rminus_not_eq_right: real.
(*********************************************************)
(** ** Inverse                                           *)
(*********************************************************)
Hint Resolve Rinv_1: real.
Hint Resolve Rinv_neq_0_compat: real.
Hint Resolve Rinv_involutive: real.
Hint Resolve Rinv_r_simpl_l Rinv_r_simpl_r Rinv_r_simpl_m: real.
(*********************************************************)
(** ** Order and addition                                *)
(*********************************************************)
(** *** Compatibility *)
(** Remark: [Rplus_lt_compat_l] is an axiom *)
Hint Resolve Rplus_lt_compat_r: real.
Hint Resolve Rplus_le_compat_l Rplus_le_compat_r: real.
Hint Immediate Rplus_lt_compat: real.
Hint Immediate Rplus_le_compat: real.
Hint Immediate Rplus_lt_le_compat Rplus_le_lt_compat: real.
(** *** Cancellation *)
(*********************************************************)
(** ** Order and opposite                                *)
(*********************************************************)
(** *** Contravariant compatibility *)
Hint Resolve Ropp_gt_lt_contravar : core.
Hint Resolve Ropp_lt_gt_contravar: real.
Hint Resolve Ropp_lt_contravar: real.
Hint Resolve Ropp_le_ge_contravar: real.
Hint Resolve Ropp_ge_le_contravar: real.
Hint Resolve Ropp_le_contravar: real.
Hint Resolve Ropp_0_lt_gt_contravar: real.
Hint Resolve Ropp_0_gt_lt_contravar: real.
Hint Resolve Ropp_lt_gt_0_contravar: real.
Hint Resolve Ropp_gt_lt_0_contravar: real.
Hint Resolve Ropp_0_le_ge_contravar: real.
Hint Resolve Ropp_0_ge_le_contravar: real.
(** *** Cancellation *)
Hint Immediate Ropp_lt_cancel: real.
Hint Immediate Ropp_le_cancel: real.
Hint Resolve Rmult_lt_compat_r : core.
Hint Resolve Rmult_le_compat_l: real.
Hint Resolve Rmult_le_compat_r: real.
Hint Resolve Rmult_le_compat: real.
Hint Resolve Rmult_le_compat_neg_l: real.
Hint Resolve Rmult_le_ge_compat_neg_l: real.
(** *** Cancellation *)
(*********************************************************)
(** ** Order and subtraction                             *)
(*********************************************************)
Hint Resolve Rlt_minus: real.
Hint Immediate tech_Rplus: real.
(*********************************************************)
(** ** Order and square function                         *)
(*********************************************************)
Hint Resolve Rle_0_sqr Rlt_0_sqr: real.
(*********************************************************)
(** ** Zero is less than one                             *)
(*********************************************************)
Hint Resolve Rlt_0_1: real.
(*********************************************************)
(** ** Order and inverse                                 *)
(*********************************************************)
Hint Resolve Rinv_0_lt_compat: real.
Hint Resolve Rinv_lt_0_compat: real.
Hint Resolve Rinv_1_lt_contravar: real.
(*********************************************************)
(** ** Miscellaneous                                     *)
(*********************************************************)
Hint Resolve Rle_lt_0_plus_1: real.
Hint Resolve Rlt_plus_1: real.
(*********************************************************)
(** ** Injection from [N] to [R]                         *)
(*********************************************************)
Hint Resolve plus_INR: real.
Hint Resolve minus_INR: real.
Hint Resolve mult_INR: real.
Hint Resolve lt_0_INR: real.
Hint Resolve lt_INR: real.
Hint Resolve lt_1_INR: real.
Hint Resolve pos_INR_nat_of_P: real.
Hint Resolve pos_INR: real.
Hint Resolve INR_lt: real.
Hint Resolve le_INR: real.
Hint Immediate INR_not_0: real.
Hint Resolve not_0_INR: real.
Hint Resolve not_INR: real.
Hint Resolve INR_eq: real.
Hint Resolve INR_le: real.
Hint Resolve not_1_INR: real.
(*********************************************************)
(** ** Injection from [Z] to [R]                         *)
(*********************************************************)
Definition Ropp_Ropp_IZR := opp_IZR.
Hint Extern 0 (IZR _ <= IZR _) => apply IZR_le, Zle_bool_imp_le, eq_refl : real.
Hint Extern 0 (IZR _ >= IZR _) => apply Rle_ge, IZR_le, Zle_bool_imp_le, eq_refl : real.
Hint Extern 0 (IZR _ <  IZR _) => apply IZR_lt, eq_refl : real.
Hint Extern 0 (IZR _ >  IZR _) => apply IZR_lt, eq_refl : real.
Hint Extern 0 (IZR _ <> IZR _) => apply IZR_neq, Zeq_bool_neq, eq_refl : real.
intros x y; unfold Rdiv; ring.
Qed.
Add Field RField : Rfield
(completeness Zeq_bool_IZR, morphism R_rm, constants [IZR_tac], power_tac R_power_theory [Rpow_tac]).
(*********************************************************)
(** ** Other rules about < and <=                        *)
(*********************************************************)
intros a b c; apply Rmult_plus_distr_r.
Qed.

Lemma Rdiv_minus_distr : forall a b c, (a - b)/c = a/c - b/c.