(** Addition of functions *)

(* Specifications: *)
Lemma Derive_n_plus (f g : R -> R) (n : nat) (x : R) :
locally x (fun y => forall k, (k <= n)%nat -> ex_derive_n f k y) ->
locally x (fun y => forall k, (k <= n)%nat -> ex_derive_n g k y) ->
Derive_n (fun x => f x + g x) n x = Derive_n f n x + Derive_n g n x.
Lemma ex_derive_n_plus (f g : R -> R) (n : nat) (x : R) :
locally x (fun y => forall k, (k <= n)%nat -> ex_derive_n f k y) ->
locally x (fun y => forall k, (k <= n)%nat -> ex_derive_n g k y) ->
ex_derive_n (fun x => f x + g x) n x.
Lemma is_derive_n_plus (f g : R -> R) (n : nat) (x lf lg : R) :
locally x (fun y => forall k, (k <= n)%nat -> ex_derive_n f k y) ->
locally x (fun y => forall k, (k <= n)%nat -> ex_derive_n g k y) ->
is_derive_n f n x lf -> is_derive_n g n x lg ->
is_derive_n (fun x => f x + g x) n x (lf + lg).
Lemma is_derive_n_iter_plus {I : Type} (l : list I) (f : I -> R -> R) (n: nat) (x : R) :
locally x (fun y => forall (j : I) (k : nat), List.In j l -> (k <= n)%nat -> ex_derive_n (f j) k y) ->
is_derive_n (fun y => iter Rplus 0 l (fun j => f j y)) n x
(iter Rplus 0 l (fun j => Derive_n (f j) n x)).
Lemma ex_derive_n_iter_plus {I : Type} (l : list I) (f : I -> R -> R) (n: nat) (x : R) :
locally x (fun y => forall (j : I) (k : nat), List.In j l -> (k <= n)%nat -> ex_derive_n (f j) k y) ->
ex_derive_n (fun y => iter Rplus 0 l (fun j => f j y)) n x.
Lemma Derive_n_iter_plus {I : Type} (l : list I) (f : I -> R -> R) (n: nat) (x : R) :
locally x (fun y => forall (j : I) (k : nat), List.In j l -> (k <= n)%nat -> ex_derive_n (f j) k y) ->
Derive_n (fun y => iter Rplus 0 l (fun j => f j y)) n x =
iter Rplus 0 l (fun j => Derive_n (f j) n x).
Lemma is_derive_n_sum_n_m n m (f : nat -> R -> R) (k: nat) (x : R) :
locally x (fun t => forall l j , (n <= l <= m)%nat ->(j <= k)%nat -> ex_derive_n (f l) j t) ->
is_derive_n (fun y => sum_n_m (fun j => f j y) n m) k x
(sum_n_m (fun j => Derive_n (f j) k x) n m).
Lemma ex_derive_n_sum_n_m n m (f : nat -> R -> R) (k: nat) (x : R) :
locally x (fun t => forall l j , (n <= l <= m)%nat ->(j <= k)%nat -> ex_derive_n (f l) j t) ->
ex_derive_n (fun y => sum_n_m (fun j => f j y) n m) k x.
Lemma Derive_n_sum_n_m n m (f : nat -> R -> R) (k: nat) (x : R) :
locally x (fun t => forall l j , (n <= l <= m)%nat ->(j <= k)%nat -> ex_derive_n (f l) j t) ->
Derive_n (fun y => sum_n_m (fun j => f j y) n m) k x
= sum_n_m (fun j => Derive_n (f j) k x) n m.
Lemma is_derive_n_sum_n n (f : nat -> R -> R) (k: nat) (x : R) :
locally x (fun t => forall l j , (l <= n)%nat ->(j <= k)%nat -> ex_derive_n (f l) j t) ->
is_derive_n (fun y => sum_n (fun j => f j y) n) k x
(sum_n (fun j => Derive_n (f j) k x) n).
Lemma ex_derive_n_sum_n n (f : nat -> R -> R) (k: nat) (x : R) :
locally x (fun t => forall l j , (l <= n)%nat ->(j <= k)%nat -> ex_derive_n (f l) j t) ->
ex_derive_n (fun y => sum_n (fun j => f j y) n) k x.
Lemma Derive_n_sum_n n (f : nat -> R -> R) (k: nat) (x : R) :
locally x (fun t => forall l j , (l <= n)%nat ->(j <= k)%nat -> ex_derive_n (f l) j t) ->
Derive_n (fun y => sum_n (fun j => f j y) n) k x =
(sum_n (fun j => Derive_n (f j) k x) n).