Library NumAnalysis.FEM.R_compl

This file is part of the Rocq Numerical Analysis library
Copyright (C) Boldo, Clément, Faissole, Martin, Mayero
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details.

From NumAnalysis Require Import stdlib_wR ssr_wMC.

From Coquelicot Require Import Hierarchy.
Close Scope R_scope.

From NumAnalysis Require Import Algebra_wDep.

Local Open Scope R_scope. Local Open Scope Monoid_scope.
Local Open Scope Group_scope.
Local Open Scope Ring_scope.

Section INR_Facts.

Lemma INR_eq_equiv : ∀ m n, INR m = INR n ↔ m = n.
Proof. intros; split; [apply INR_eq | intros; subst; easy]. Qed.

Lemma INR_0_equiv : ∀ n, INR n = 0 ↔ n = 0.
Proof. intros; rewrite -INR_eq_equiv INR_0; easy. Qed.

Lemma INR_minus :
  ∀ {m n}, (m ≤ n)%coq_nat → INR (n - m) = INR n - INR m.
Proof. move=>>; apply minus_INR. Qed.

Lemma INR_inv_n0 : ∀ {n}, n ≠ 0 → / INR n ≠ 0.
Proof. intros; rewrite inv_eq_R; apply Rinv_neq_0_compat, not_0_INR; easy. Qed.

Lemma INR_invertible : ∀ {n}, n ≠ 0 → invertible (INR n).
Proof. intros; apply invertible_equiv_R, not_0_INR; easy. Qed.

Lemma INR_pred_invertible :
  ∀ {n}, (1 < n)%coq_nat → invertible (INR n.-1).
Proof.
intros [| n]; [easy |]; intro; apply INR_invertible.
apply nat_neq_0_lt_S; easy.
Qed.

Lemma INR_ratio_invertible :
  ∀ {n}, (1 < n)%coq_nat → invertible (INR n.-1 / INR n).
Proof.
move=>> Hn; move: (Nat.lt_succ_l _ _ Hn) ⇒ Hn'.
apply invertible_equiv_R, is_integral_R;
    [apply not_0_INR; lia | apply INR_inv_n0, Nat.neq_0_lt_0; easy].
Qed.

End INR_Facts.