(************************************************************************)
(*         *   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)         *)
(************************************************************************)
(*i Due to L.Thery i*)
(************************************************************)
(* Definitions of log and Rpower : R->R->R; main properties *)
(************************************************************)
Local Open Scope R_scope.
(******************************************************************)
(** *                     Properties of  Exp                      *)
(******************************************************************)
(* Definition of log R+* -> R *)
Definition Rln (y:posreal) : R :=
let (a,_) := ln_exists (pos y) (cond_pos y) in a.
(* Extension on R *)
Definition ln (x:R) : R :=
match Rlt_dec 0 x with
| left a => Rln (mkposreal x a)
| right a => 0
end.
(******************************************************************)
(** *                     Properties of  Ln                       *)
(******************************************************************)
(******************************************************************)
(** *                     Definition of  Rpower                   *)
(******************************************************************)
Definition Rpower (x y:R) := exp (y * ln x).
Local Infix "^R" := Rpower (at level 30, right associativity) : R_scope.
(******************************************************************)
(** *                     Properties of  Rpower                   *)
(******************************************************************)
(** Note: [Rpower] is prolongated to [1] on negative real numbers and it thus does not extend integer power. The next two lemmas, which hold for integer power, accidentally hold on negative real numbers as a side effect of the default value taken on negative real numbers. Contrastingly, the lemmas that do not hold for the integer power of a negative number are stated for [Rpower] on the positive numbers only (even if they accidentally hold due to the default value of [Rpower] on the negative side, as it is the case for [Rpower_O]). *)
(*****************************************)
(** * Differentiability of Ln and Rpower *)
(*****************************************)
(* added later. *)
intros x y z x0 y0; unfold Rpower.
rewrite <- exp_plus, ln_mult, Rmult_plus_distr_l; auto.
Qed.
(* arcsinh function *)
Definition arcsinh x := ln (x + sqrt (x ^ 2 + 1)).
intros x; unfold sinh, arcsinh.
assert (Rminus_eq_0 : forall r, r - r = 0) by (intros; ring).
rewrite <- exp_0, <- (Rminus_eq_0 x); unfold Rminus.
rewrite exp_plus.
match goal with |- context[sqrt ?a] =>
replace a with (((exp x + exp(-x))/2)^2) by field
end.
rewrite sqrt_pow2;
[|apply Rlt_le, Rmult_lt_0_compat;[apply Rplus_lt_0_compat; apply exp_pos |
apply Rinv_0_lt_compat, Rlt_0_2]].
match goal with |- context[ln ?a] => replace a with (exp x) by field end.
rewrite ln_exp; reflexivity.
Qed.
unfold sinh, arcsinh.
assert (cmp : 0 < x + sqrt (x ^ 2 + 1)).
destruct (Rle_dec x 0).
replace (x ^ 2) with ((-x) ^ 2) by ring.
assert (sqrt ((- x) ^ 2) < sqrt ((-x)^2+1)).
apply sqrt_lt_1_alt.
split;[apply pow_le | ]; lra.
pattern x at 1; replace x with (- (sqrt ((- x) ^ 2))).
assert (t:= sqrt_pos ((-x)^2)); lra.
simpl; rewrite Rmult_1_r, sqrt_square, Ropp_involutive;[reflexivity | lra].
apply Rplus_lt_le_0_compat;[apply Rnot_le_gt; assumption | apply sqrt_pos].
rewrite exp_ln;[ | assumption].
rewrite exp_Ropp, exp_ln;[ | assumption].
assert (Rmult_minus_distr_r :
forall x y z, (x - y) * z = x * z - y * z) by (intros; ring).
apply Rminus_diag_uniq; unfold Rdiv; rewrite Rmult_minus_distr_r.
assert (t: forall x y z, x - z = y -> x - y - z = 0);[ | apply t; clear t].
intros a b c H; rewrite <- H; ring.
apply Rmult_eq_reg_l with (2 * (x + sqrt (x ^ 2 + 1)));[ |
apply Rgt_not_eq, Rmult_lt_0_compat;[apply Rlt_0_2 | assumption]].
assert (pow2_sqrt : forall x, 0 <= x -> sqrt x ^ 2 = x) by
(intros; simpl; rewrite Rmult_1_r, sqrt_sqrt; auto).
field_simplify;[rewrite pow2_sqrt;[field | ] | apply Rgt_not_eq; lra].
apply Rplus_le_le_0_compat;[simpl; rewrite Rmult_1_r; apply (Rle_0_sqr x)|apply Rlt_le, Rlt_0_1].
Qed.
intros x; unfold arcsinh.
assert (0 < x + sqrt (x ^ 2 + 1)).
destruct (Rle_dec x 0);
[ | assert (0 < x) by (apply Rnot_le_gt; assumption);
apply Rplus_lt_le_0_compat; auto; apply sqrt_pos].
replace (x ^ 2) with ((-x) ^ 2) by ring.
assert (sqrt ((- x) ^ 2) < sqrt ((-x)^2+1)).
apply sqrt_lt_1_alt.
split;[apply pow_le|]; lra.
pattern x at 1; replace x with (- (sqrt ((- x) ^ 2))).
assert (t:= sqrt_pos ((-x)^2)); lra.
simpl; rewrite Rmult_1_r, sqrt_square, Ropp_involutive; auto; lra.
assert (0 < x ^ 2 + 1).
apply Rplus_le_lt_0_compat;[simpl; rewrite Rmult_1_r; apply Rle_0_sqr|lra].
replace (/sqrt (x ^ 2 + 1)) with
(/(x + sqrt (x ^ 2 + 1)) *
(1 + (/(2 * sqrt (x ^ 2 + 1)) * (INR 2 * x ^ 1 + 0)))).
apply (derivable_pt_lim_comp (fun x => x + sqrt (x ^ 2 + 1)) ln).
apply (derivable_pt_lim_plus).
apply derivable_pt_lim_id.
apply (derivable_pt_lim_comp (fun x => x ^ 2 + 1) sqrt x).
apply derivable_pt_lim_plus.
apply derivable_pt_lim_pow.
apply derivable_pt_lim_const.
apply derivable_pt_lim_sqrt; assumption.
apply derivable_pt_lim_ln; assumption.
replace (INR 2 * x ^ 1 + 0) with (2 * x) by (simpl; ring).
replace (1 + / (2 * sqrt (x ^ 2 + 1)) * (2 * x)) with
(((sqrt (x ^ 2 + 1) + x))/sqrt (x ^ 2 + 1));
[ | field; apply Rgt_not_eq, sqrt_lt_R0; assumption].
apply Rmult_eq_reg_l with (x + sqrt (x ^ 2 + 1));
[ | apply Rgt_not_eq; assumption].
rewrite <- Rmult_assoc, Rinv_r;[field | ]; apply Rgt_not_eq; auto;
apply sqrt_lt_R0; assumption.
Qed.

Lemma arcsinh_lt : forall x y, x < y -> arcsinh x < arcsinh y.