(************************************************************************)
(*         *      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.
(*******************************************)
(*            Newton's Integral            *)
(*******************************************)
Definition Newton_integrable (f:R -> R) (a b:R) : Type :=
{ g:R -> R | antiderivative f g a b \/ antiderivative f g b a }.
Definition NewtonInt (f:R -> R) (a b:R) (pr:Newton_integrable f a b) : R :=
let (g,_) := pr in g b - g a.

(* Specifications: *)
(* If f is differentiable, then f' is Newton integrable (Tautology ?) *)
Lemma FTCN_step1 :
forall (f:Differential) (a b:R),
Newton_integrable (fun x:R => derive_pt f x (cond_diff f x)) a b.
(* $\int_a^a f$ exists forall a:R and f:R->R *)
Lemma NewtonInt_P1 : forall (f:R -> R) (a:R), Newton_integrable f a a.
(* $\int_a^a f = 0$ *)
Lemma NewtonInt_P2 :
forall (f:R -> R) (a:R), NewtonInt f a a (NewtonInt_P1 f a) = 0.
(* If $\int_a^b f$ exists, then $\int_b^a f$ exists too *)
Lemma NewtonInt_P3 :
forall (f:R -> R) (a b:R) (X:Newton_integrable f a b),
Newton_integrable f b a.
(* The set of Newton integrable functions is a vectorial space *)
Lemma NewtonInt_P5 :
forall (f g:R -> R) (l a b:R),
Newton_integrable f a b ->
Newton_integrable g a b ->
Newton_integrable (fun x:R => l * f x + g x) a b.
(**********)
Lemma antiderivative_P1 :
forall (f g F G:R -> R) (l a b:R),
antiderivative f F a b ->
antiderivative g G a b ->
antiderivative (fun x:R => l * f x + g x) (fun x:R => l * F x + G x) a b.
(* $\int_a^b \lambda f + g = \lambda \int_a^b f + \int_a^b f *)
Lemma NewtonInt_P6 :
forall (f g:R -> R) (l a b:R) (pr1:Newton_integrable f a b)
(pr2:Newton_integrable g a b),
NewtonInt (fun x:R => l * f x + g x) a b (NewtonInt_P5 f g l a b pr1 pr2) =
l * NewtonInt f a b pr1 + NewtonInt g a b pr2.
Lemma antiderivative_P2 :
forall (f F0 F1:R -> R) (a b c:R),
antiderivative f F0 a b ->
antiderivative f F1 b c ->
antiderivative f
(fun x:R =>
match Rle_dec x b with
| left _ => F0 x
| right _ => F1 x + (F0 b - F1 b)
end) a c.
Lemma antiderivative_P3 :
forall (f F0 F1:R -> R) (a b c:R),
antiderivative f F0 a b ->
antiderivative f F1 c b ->
antiderivative f F1 c a \/ antiderivative f F0 a c.
Lemma antiderivative_P4 :
forall (f F0 F1:R -> R) (a b c:R),
antiderivative f F0 a b ->
antiderivative f F1 a c ->
antiderivative f F1 b c \/ antiderivative f F0 c b.
Lemma NewtonInt_P7 :
forall (f:R -> R) (a b c:R),
a < b ->
b < c ->
Newton_integrable f a b ->
Newton_integrable f b c -> Newton_integrable f a c.
Lemma NewtonInt_P8 :
forall (f:R -> R) (a b c:R),
Newton_integrable f a b ->
Newton_integrable f b c -> Newton_integrable f a c.
(* Chasles' relation *)
Lemma NewtonInt_P9 :
forall (f:R -> R) (a b c:R) (pr1:Newton_integrable f a b)
(pr2:Newton_integrable f b c),
NewtonInt f a c (NewtonInt_P8 f a b c pr1 pr2) =
NewtonInt f a b pr1 + NewtonInt f b c pr2.