(** * Iterated differential *)

Fixpoint ex_diff_n f n x y :=
  continuity_2d_pt f x y /\
  match n with
  | O => True
  | S n =>
    ex_derive (fun z => f z y) x /\
    ex_derive (fun z => f x z) y /\
    ex_diff_n (fun u v => Derive (fun z => f z v) u) n x y /\
    ex_diff_n (fun u v => Derive (fun z => f u z) v) n x y
  end.

(* Specifications: *)
Lemma ex_diff_n_ext_loc: forall f g n x y, locally_2d (fun u v => f u v = g u v) x y -> ex_diff_n f n x y -> ex_diff_n g n x y.
Lemma ex_diff_n_m : forall n m, (m <= n)%nat -> forall f x y, ex_diff_n f n x y -> ex_diff_n f m x y.
Lemma ex_diff_n_deriv_aux1: forall f n x y, ex_diff_n f (S n) x y -> ex_diff_n (fun u v => Derive (fun z => f z v) u) n x y.
Lemma ex_diff_n_deriv_aux2: forall f n x y, ex_diff_n f (S n) x y -> ex_diff_n (fun u v => Derive (fun z => f u z) v) n x y.
Lemma ex_diff_n_deriv: forall n p q, (p+q <= n)%nat -> forall f x y, ex_diff_n f n x y-> ex_diff_n (partial_derive p q f) (n -(p+q)) x y.
Lemma ex_diff_n_ex_deriv_inf_1 : forall n p k, (p+k < n)%nat -> forall f x y, ex_diff_n f n x y -> ex_derive (fun z : R => partial_derive p k f z y) x.
Lemma ex_diff_n_ex_deriv_inf_2 : forall n p k, (p+k < n)%nat -> forall f x y, ex_diff_n f n x y -> ex_derive (fun z => partial_derive p k f x z) y.
Lemma ex_diff_n_continuity_inf_1 : forall n p k, (p+k < n)%nat -> forall f x y, ex_diff_n f n x y -> continuity_2d_pt (fun u v => Derive (fun z : R => partial_derive p k f z v) u) x y.
Lemma Derive_partial_derive_aux1: forall p f x y, locally_2d (ex_diff_n f (S p)) x y -> partial_derive 1 p f x y = partial_derive 0 p (partial_derive 1 0 f) x y.
Lemma Derive_partial_derive_aux2: forall p k f x y, locally_2d (ex_diff_n f (p+S k)) x y -> partial_derive 0 1 (partial_derive p k f) x y = partial_derive p (S k) f x y.
Lemma Derive_partial_derive: forall p k f x y, locally_2d (ex_diff_n f (p+S k)) x y -> Derive (fun v : R => partial_derive p k f x v) y = partial_derive p (S k) f x y.
Lemma ex_diff_n_continuity_inf_2 : forall n p k, (p+k < n)%nat -> forall f x y, ex_diff_n f n x y -> continuity_2d_pt (fun u v => Derive (fun z : R => partial_derive p k f u z) v) x y.