(** This file is part of the Coquelicot formalization of real analysis in Coq: http://coquelicot.saclay.inria.fr/  Copyright (C) 2011-2015 Sylvie Boldo #<br /># Copyright (C) 2011-2015 Catherine Lelay #<br /># Copyright (C) 2011-2015 Guillaume Melquiond  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. *)
(** This file describes defineitions and properties of continuity on [R] and on uniform spaces. It also contains many results about the limit of a real function (predicates [is_lim] and [ex_lim] and total function [Lim]). This limit may be either a real or an extended real. *)
(** * Limit of fonctions *)
(** ** Definition *)
Definition is_lim (f : R -> R) (x l : Rbar) :=
filterlim f (Rbar_locally' x) (Rbar_locally l).
Definition is_lim' (f : R -> R) (x l : Rbar) :=
match l with
| Finite l =>
forall eps : posreal, Rbar_locally' x (fun y => Rabs (f y - l) < eps)
| p_infty => forall M : R, Rbar_locally' x (fun y => M < f y)
| m_infty => forall M : R, Rbar_locally' x (fun y => f y < M)
end.
Definition ex_lim (f : R -> R) (x : Rbar) := exists l : Rbar, is_lim f x l.
Definition ex_finite_lim (f : R -> R) (x : Rbar) := exists l : R, is_lim f x l.
Definition Lim (f : R -> R) (x : Rbar) := Lim_seq (fun n => f (Rbar_loc_seq x n)).
(** Equivalence with standard library Reals *)
(** Composition *)
(** Uniqueness *)
(** ** Operations and order *)
(** Extensionality *)
(** Composition *)
(** Identity *)
(** Constant *)
(** *** Additive operators *)
(** Opposite *)
(** Addition *)
(** Subtraction *)
(** ** Multiplicative operators *)
(** Multiplicative inverse *)
(** Multiplication *)
(** Scalar multiplication *)
(** Division *)
(** Composition by linear functions *)
(** Continuity and limit *)
(** *** Order *)
(** ** Generalized intermediate value theorem *)
(** * 2D-continuity *)
(** ** Definitions *)
Definition continuity_2d_pt f x y :=
forall eps : posreal, locally_2d (fun u v => Rabs (f u v - f x y) < eps) x y.

Lemma uniform_continuity_2d :
forall f a b c d,
(forall x y, a <= x <= b -> c <= y <= d -> continuity_2d_pt f x y) ->
forall eps : posreal, exists delta : posreal,
forall x y u v,
a <= x <= b -> c <= y <= d ->
a <= u <= b -> c <= v <= d ->
Rabs (u - x) < delta -> Rabs (v - y) < delta ->
Rabs (f u v - f x y) < eps.