(* -*- coding: utf-8 -*- *)
(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \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)         *)
(************************************************************************)
Local Open Scope R_scope.
Set Implicit Arguments.
(********************************************)
(**           Riemann's Integral            *)
(********************************************)
Definition Riemann_integrable (f:R -> R) (a b:R) : Type :=
forall eps:posreal,
{ phi:StepFun a b &
{ psi:StepFun a b |
(forall t:R,
Rmin a b <= t <= Rmax a b -> Rabs (f t - phi t) <= psi t) /\
Rabs (RiemannInt_SF psi) < eps } }.
Definition phi_sequence (un:nat -> posreal) (f:R -> R)
(a b:R) (pr:Riemann_integrable f a b) (n:nat) :=
projT1 (pr (un n)).

(* Specifications: *)
Lemma phi_sequence_prop :
forall (un:nat -> posreal) (f:R -> R) (a b:R) (pr:Riemann_integrable f a b)
(N:nat),
{ psi:StepFun a b |
(forall t:R,
Rmin a b <= t <= Rmax a b ->
Rabs (f t - phi_sequence un pr N t) <= psi t) /\
Rabs (RiemannInt_SF psi) < un N }.
Lemma RiemannInt_P1 :
forall (f:R -> R) (a b:R),
Riemann_integrable f a b -> Riemann_integrable f b a.
Lemma RiemannInt_P2 :
forall (f:R -> R) (a b:R) (un:nat -> posreal) (vn wn:nat -> StepFun a b),
Un_cv un 0 ->
a <= b ->
(forall n:nat,
(forall t:R, Rmin a b <= t <= Rmax a b -> Rabs (f t - vn n t) <= wn n t) /\
Rabs (RiemannInt_SF (wn n)) < un n) ->
{ l:R | Un_cv (fun N:nat => RiemannInt_SF (vn N)) l }.
Lemma RiemannInt_P3 :
forall (f:R -> R) (a b:R) (un:nat -> posreal) (vn wn:nat -> StepFun a b),
Un_cv un 0 ->
(forall n:nat,
(forall t:R, Rmin a b <= t <= Rmax a b -> Rabs (f t - vn n t) <= wn n t) /\
Rabs (RiemannInt_SF (wn n)) < un n) ->
{ l:R | Un_cv (fun N:nat => RiemannInt_SF (vn N)) l }.
Lemma RiemannInt_exists :
forall (f:R -> R) (a b:R) (pr:Riemann_integrable f a b)
(un:nat -> posreal),
Un_cv un 0 ->
{ l:R | Un_cv (fun N:nat => RiemannInt_SF (phi_sequence un pr N)) l }.
Lemma RiemannInt_P4 :
forall (f:R -> R) (a b l:R) (pr1 pr2:Riemann_integrable f a b)
(un vn:nat -> posreal),
Un_cv un 0 ->
Un_cv vn 0 ->
Un_cv (fun N:nat => RiemannInt_SF (phi_sequence un pr1 N)) l ->
Un_cv (fun N:nat => RiemannInt_SF (phi_sequence vn pr2 N)) l.
Lemma RinvN_pos : forall n:nat, 0 < / (INR n + 1).
Definition RinvN (N:nat) : posreal := mkposreal _ (RinvN_pos N).
Lemma RinvN_cv : Un_cv RinvN 0.
Lemma Riemann_integrable_ext :
forall f g a b,
(forall x, Rmin a b <= x <= Rmax a b -> f x = g x) ->
Riemann_integrable f a b -> Riemann_integrable g a b.