(**
This file is part of the Coquelicot formalization of real
analysis in Coq: http://coquelicot.saclay.inria.fr/

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Copyright (C) 2011-2015 Sylvie Boldo
#<br />#
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Copyright (C) 2011-2015 Catherine Lelay
#<br />#
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
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.
*)

Require Import Reals.
Require Import mathcomp.ssreflect.ssreflect.
Require Import Rcomplements Rbar Hierarchy.
Require Import Compactness Lim_seq.

(** 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 *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Definition is_lim (f : R -> R) (x l : Rbar) :=
  filterlim f (Rbar_locally' x) (Rbar_locally l).

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Definition is_lim' (f : R -> R) (x l : Rbar) :=
  match l with
    | Finite l =>
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      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)).

Lemma is_lim_spec :
  forall f x l,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim' f x l <-> is_lim f x l.
Proof.
(* Goal: forall (f : forall _ : R, R) (x l : Rbar), iff (is_lim' f x l) (is_lim f x l) *)
destruct l as [l| |] ; split.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros H P [eps LP].
(* Goal: @filtermap R R f (Rbar_locally' x) P *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  unfold filtermap.
(* Goal: Rbar_locally' x (fun x : R => P (f x)) *)
(* Goal: forall _ : is_lim f x (Finite l), is_lim' f x (Finite l) *)
(* Goal: forall _ : is_lim' f x p_infty, is_lim f x p_infty *)
(* Goal: forall _ : is_lim f x p_infty, is_lim' f x p_infty *)
(* Goal: forall _ : is_lim' f x m_infty, is_lim f x m_infty *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  generalize (H eps).
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
  apply filter_imp.
(* Goal: forall (x : R) (_ : Rlt (f x) M), P (f x) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  intros u.
(* Goal: forall _ : Rlt (f u) M, P (f u) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  apply LP.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros H eps.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  apply (H (fun y => Rabs (y - l) < eps)).
(* Goal: @locally R_UniformSpace (f x y) (fun z : R => Rlt (Rabs (Rminus z (f x y))) (pos eps)) *)
  now exists eps.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros H P [M LP].
(* Goal: @filtermap R R f (Rbar_locally' x) P *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  unfold filtermap.
(* Goal: Rbar_locally' x (fun x : R => P (f x)) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  generalize (H M).
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
  apply filter_imp.
(* Goal: forall (x : R) (_ : Rlt (f x) M), P (f x) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  intros u.
(* Goal: forall _ : Rlt (f u) M, P (f u) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  apply LP.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros H M.
(* Goal: Rbar_locally' x (fun y : R => Rlt M (f y)) *)
(* Goal: forall _ : is_lim' f x m_infty, is_lim f x m_infty *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  apply (H (fun y => M < y)).
(* Goal: Rbar_locally m_infty (fun y : R => Rlt y M) *)
  now exists M.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros H P [M LP].
(* Goal: @filtermap R R f (Rbar_locally' x) P *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  unfold filtermap.
(* Goal: Rbar_locally' x (fun x : R => P (f x)) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  generalize (H M).
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
  apply filter_imp.
(* Goal: forall (x : R) (_ : Rlt (f x) M), P (f x) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  intros u.
(* Goal: forall _ : Rlt (f u) M, P (f u) *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  apply LP.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros H M.
(* Goal: Rbar_locally' x (fun y : R => Rlt (f y) M) *)
  apply (H (fun y => y < M)).
(* Goal: Rbar_locally m_infty (fun y : R => Rlt y M) *)
  now exists M.
Qed.

(** Equivalence with standard library Reals *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_Reals_0 (f : R -> R) (x l : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> limit1_in f (fun y => y <> x) l x.
Proof.
(* Goal: forall _ : is_lim f (Finite x) (Finite l), limit1_in f (fun y : R => not (@eq R y x)) l x *)
  intros H e He.
(* Goal: @ex R (fun alp : R => and (Rgt alp (IZR Z0)) (forall (x0 : Base R_met) (_ : and (not (@eq R x0 x)) (Rlt (dist R_met x0 x) alp)), Rlt (dist R_met (f x0) l) e)) *)
  apply is_lim_spec in H.
(* Goal: @ex R (fun alp : R => and (Rgt alp (IZR Z0)) (forall (x0 : Base R_met) (_ : and (not (@eq R x0 x)) (Rlt (dist R_met x0 x) alp)), Rlt (dist R_met (f x0) l) e)) *)
  destruct (H (mkposreal e He)) as [d Hd].
(* Goal: @ex R (fun alp : R => and (Rgt alp (IZR Z0)) (forall (x0 : Base R_met) (_ : and (not (@eq R x0 x)) (Rlt (dist R_met x0 x) alp)), Rlt (dist R_met (f x0) l) e)) *)
  exists d ; split.
(* Goal: Rlt (IZR Z0) (pos eps) *)
  apply cond_pos.
(* Goal: forall (x0 : Base R_met) (_ : and (not (@eq R x0 x)) (Rlt (dist R_met x0 x) (pos d))), Rlt (dist R_met (f x0) l) e *)
  intros y [H1 H2].
(* Goal: Rlt (dist R_met (f y) l) e *)
  now apply (Hd y).
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_Reals_1 (f : R -> R) (x l : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  limit1_in f (fun y => y <> x) l x -> is_lim f x l.
Proof.
(* Goal: forall _ : limit1_in f (fun y : R => not (@eq R y x)) l x, is_lim f (Finite x) (Finite l) *)
  intros H.
(* Goal: is_lim f (Finite x) (Finite l) *)
  apply is_lim_spec.
(* Goal: is_lim' f (Finite x) (Finite l) *)
  intros [e He].
(* Goal: Rbar_locally' (Finite x) (fun y : R => Rlt (Rabs (Rminus (f y) l)) (pos (mkposreal e He))) *)
  destruct (H e He) as [d [Hd H']].
(* Goal: Rbar_locally' (Finite x) (fun y : R => Rlt (Rabs (Rminus (f y) l)) (pos (mkposreal e He))) *)
  exists (mkposreal d Hd).
(* Goal: forall (y : UniformSpace.sort R_UniformSpace) (_ : @ball R_UniformSpace x (pos (mkposreal d Hd)) y) (_ : not (@eq (UniformSpace.sort R_UniformSpace) y x)), Rlt (Rabs (Rminus (f y) l)) (pos (mkposreal e He)) *)
  intros y Hy Hxy.
(* Goal: Rlt (Rabs (Rminus (f y) l)) (pos (mkposreal e He)) *)
  apply (H' y).
(* Goal: and (not (@eq R y x)) (Rlt (dist R_met y x) d) *)
  now split.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_Reals (f : R -> R) (x l : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l <-> limit1_in f (fun y => y <> x) l x.
Proof.
(* Goal: iff (is_lim f (Finite x) (Finite l)) (limit1_in f (fun y : R => not (@eq R y x)) l x) *)
  split ; [apply is_lim_Reals_0|apply is_lim_Reals_1].
Qed.

(** Composition *)

Lemma is_lim_comp' :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall {T} {F} {FF : @Filter T F} (f : T -> R) (g : R -> R) (x l : Rbar),
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  filterlim f F (Rbar_locally x) -> is_lim g x l ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  F (fun y => Finite (f y) <> x) ->
  filterlim (fun y => g (f y)) F (Rbar_locally l).
Proof.
(* Goal: forall (T : Type) (F : forall _ : forall _ : T, Prop, Prop) (_ : @Filter T F) (f : forall _ : T, R) (g : forall _ : R, R) (x l : Rbar) (_ : @filterlim T R f F (Rbar_locally x)) (_ : is_lim g x l) (_ : F (fun y : T => not (@eq Rbar (Finite (f y)) x))), @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
intros T F FF f g x l Lf Lg Hf.
(* Goal: @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
revert Lg.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
apply filterlim_comp.
(* Goal: is_lim (fun _ : R => a) x (Finite a) *)
intros P HP.
(* Goal: @filtermap T R f F P *)
destruct x as [x| |] ; try now apply Lf.
(* Goal: @filtermap T R f F P *)
specialize (Lf _ HP).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
unfold filtermap in Lf |- *.
(* Goal: F (fun x : T => P (f x)) *)
generalize (filter_and _ _ Hf Lf).
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
apply filter_imp.
(* Goal: forall (x0 : T) (_ : and (not (@eq Rbar (Finite (f x0)) (Finite x))) (forall _ : not (@eq (UniformSpace.sort R_UniformSpace) (f x0) x), P (f x0))), P (f x0) *)
intros y [H Hi].
(* Goal: P (f y) *)
apply Hi.
(* Goal: not (@eq (UniformSpace.sort R_UniformSpace) (f y) x) *)
contradict H.
(* Goal: @eq Rbar (Finite (f y)) (Finite x) *)
now apply f_equal.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_comp_seq (f : R -> R) (u : nat -> R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  eventually (fun n => Finite (u n) <> x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim_seq u x -> is_lim_seq (fun n => f (u n)) l.
Proof.
(* Goal: forall (_ : is_lim f x l) (_ : eventually (fun n : nat => not (@eq Rbar (Finite (u n)) x))) (_ : is_lim_seq u x), is_lim_seq (fun n : nat => f (u n)) l *)
intros Lf Hu Lu.
(* Goal: is_lim_seq (fun n : nat => f (u n)) l *)
exact (is_lim_comp' u f x l Lu Lf Hu).
Qed.

(** Uniqueness *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_unique (f : R -> R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> Lim f x = l.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @eq Rbar (Lim f x) l *)
  unfold Lim.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite (is_lim_seq_unique _ l) //.
(* Goal: is_lim_seq (fun n : nat => f (Rbar_loc_seq x n)) l *)
  apply (is_lim_comp_seq f _ x l H).
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists 1%nat => n Hn.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: x {H} => [x | | ] //=.
(* Goal: not (@eq Rbar (Finite (Rplus x (Rinv (Rplus (INR n) (IZR (Zpos xH)))))) (Finite x)) *)
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
  apply Rbar_finite_neq, Rgt_not_eq, Rminus_lt_0.
(* Goal: Rlt (IZR Z0) (Rminus (Rplus x (Rinv (Rplus (INR n) (IZR (Zpos xH))))) x) *)
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
  ring_simplify.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply RinvN_pos.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_seq_Rbar_loc_seq.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_correct (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> is_lim f x (Lim f x).
Proof.
(* Goal: forall _ : ex_lim f x, is_lim f x (Lim f x) *)
  intros (l,H).
(* Goal: is_lim f x (Lim f x) *)
  replace (Lim f x) with l.
(* Goal: @continuous U (NormedModule.UniformSpace K V) f x *)
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun x : UniformSpace.sort U => @opp (NormedModule.AbelianGroup K V) (g x)) x *)
    apply H.
(* Goal: @eq Rbar l (Lim f x) *)
  apply sym_eq, is_lim_unique, H.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_finite_lim_correct (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_finite_lim f x <-> ex_lim f x /\ is_finite (Lim f x).
Proof.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  split.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case => l Hf.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move: (is_lim_unique f x l Hf) => Hf0.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  split.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by exists l.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by rewrite Hf0.
(* Goal: forall _ : and (ex_lim f x) (is_finite (Lim f x)), ex_finite_lim f x *)
  case ; case => l Hf Hf0.
(* Goal: ex_finite_lim f x *)
  exists (real l).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -(is_lim_unique _ _ _ Hf).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Hf0.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by rewrite (is_lim_unique _ _ _ Hf).
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_correct' (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_finite_lim f x -> is_lim f x (real (Lim f x)).
Proof.
(* Goal: forall _ : ex_finite_lim f x, is_lim f x (Finite (real (Lim f x))) *)
  intro Hf.
(* Goal: is_lim f x (Finite (real (Lim f x))) *)
  apply ex_finite_lim_correct in Hf.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite (proj2 Hf).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_correct, Hf.
Qed.

(** ** Operations and order *)

(** Extensionality *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_ext_loc (f g : R -> R) (x l : Rbar) :
  Rbar_locally' x (fun y => f y = g y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> is_lim f x l -> is_lim g x l.
Proof.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => @eq R (f y) (g y))) (_ : is_lim f x l), is_lim g x l *)
apply filterlim_ext_loc.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_ext_loc (f g : R -> R) (x : Rbar) :
  Rbar_locally' x (fun y => f y = g y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> ex_lim f x -> ex_lim g x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => H [l Hf].
(* Goal: ex_lim g x *)
  exists l.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_ext_loc with f.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_ext_loc (f g : R -> R) (x : Rbar) :
  Rbar_locally' x (fun y => f y = g y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Lim g x = Lim f x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => H.
(* Goal: @eq Rbar (Lim g x) (Lim f x) *)
  apply sym_eq.
(* Goal: @eq Rbar (Lim f x) (Lim g x) *)
  apply Lim_seq_ext_loc.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
  apply: filterlim_Rbar_loc_seq H.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_ext (f g : R -> R) (x l : Rbar) :
  (forall y, f y = g y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> is_lim f x l -> is_lim g x l.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => H.
(* Goal: forall _ : is_lim f x l, is_lim g x l *)
  apply is_lim_ext_loc.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply filter_forall.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_ext (f g : R -> R) (x : Rbar) :
  (forall y, f y = g y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> ex_lim f x -> ex_lim g x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => H [l Hf].
(* Goal: ex_lim g x *)
  exists l.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_ext with f.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_ext (f g : R -> R) (x : Rbar) :
  (forall y, f y = g y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Lim g x = Lim f x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => H.
(* Goal: @eq Rbar (Lim g x) (Lim f x) *)
  apply Lim_ext_loc.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply filter_forall.
Qed.

(** Composition *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_comp (f g : R -> R) (x k l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f l k -> is_lim g x l -> Rbar_locally' x (fun y => Finite (g y) <> l)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    -> is_lim (fun x => f (g x)) x k.
Proof.
(* Goal: forall (_ : is_lim f l k) (_ : is_lim g x l) (_ : Rbar_locally' x (fun y : R => not (@eq Rbar (Finite (g y)) l))), is_lim (fun x : R => f (g x)) x k *)
intros Lf Lg Hg.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
by apply (is_lim_comp' g f l k Lg Lf Hg).
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_comp (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f (Lim g x) -> ex_lim g x -> Rbar_locally' x (fun y => Finite (g y) <> Lim g x)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    -> ex_lim (fun x => f (g x)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: ex_lim (fun x : R => f (g x)) x *)
  exists (Lim f (Lim g x)).
(* Goal: is_lim (fun x : R => f (g x)) x (Lim f (Lim g x)) *)
  apply is_lim_comp with (Lim g x).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_correct.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_correct.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply H1.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_comp (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f (Lim g x) -> ex_lim g x -> Rbar_locally' x (fun y => Finite (g y) <> Lim g x)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    -> Lim (fun x => f (g x)) x = Lim f (Lim g x).
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: is_lim (fun x : R => f (g x)) x (Lim f (Lim g x)) *)
  apply is_lim_comp with (Lim g x).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_correct.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_correct.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply H1.
Qed.

(** Identity *)

Lemma is_lim_id (x : Rbar) :
  is_lim (fun y => y) x x.
Proof.
(* Goal: is_lim (fun _ : R => a) x (Finite a) *)
intros P HP.
(* Goal: @continuous U U (fun y : UniformSpace.sort U => y) x *)
apply filterlim_id.
(* Goal: Rbar_locally' x P *)
now apply Rbar_locally'_le.
Qed.
Lemma ex_lim_id (x : Rbar) :
  ex_lim (fun y => y) x.
Proof.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  exists x.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_id.
Qed.
Lemma Lim_id (x : Rbar) :
  Lim (fun y => y) x = x.
Proof.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_id.
Qed.

(** Constant *)

Lemma is_lim_const (a : R) (x : Rbar) :
  is_lim (fun _ => a) x a.
Proof.
(* Goal: is_lim (fun _ : R => a) x (Finite a) *)
intros P HP.
(* Goal: @filtermap R R (fun _ : R => a) (Rbar_locally' x) P *)
now apply filterlim_const.
Qed.
Lemma ex_lim_const (a : R) (x : Rbar) :
  ex_lim (fun _ => a) x.
Proof.
(* Goal: ex_lim (fun _ : R => a) x *)
  exists a.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_const.
Qed.
Lemma Lim_const (a : R) (x : Rbar) :
  Lim (fun _ => a) x = a.
Proof.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_const.
Qed.

(** *** Additive operators *)

(** Opposite *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_opp (f : R -> R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> is_lim (fun y => - f y) x (Rbar_opp l).
Proof.
intros Cf.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
eapply filterlim_comp.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
apply Cf.
apply filterlim_Rbar_opp.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_opp (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim (fun y => - f y) x.
Proof.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case => l Hf.
(* Goal: ex_lim (fun y : R => Ropp (f y)) x *)
  exists (Rbar_opp l).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_opp.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_opp (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Lim (fun y => - f y) x = Rbar_opp (Lim f x).
Proof.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -Lim_seq_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_seq_ext.
Qed.

(** Addition *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_plus (f g : R -> R) (x lf lg l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_Rbar_plus lf lg l ->
  is_lim (fun y => f y + g y) x l.
Proof.
(* Goal: forall (_ : is_lim f x lf) (_ : is_lim g x lg) (_ : ex_Rbar_mult lf lg), is_lim (fun y : R => Rmult (f y) (g y)) x (Rbar_mult lf lg) *)
intros Cf Cg Hp.
(* Goal: is_lim (fun y : R => Rmult (f y) (g y)) x (Rbar_mult lf lg) *)
eapply filterlim_comp_2 ; try eassumption.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
by apply filterlim_Rbar_plus.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_plus' (f g : R -> R) (x : Rbar) (lf lg : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg ->
  is_lim (fun y => f y + g y) x (lf + lg).
Proof.
(* Goal: forall (_ : is_lim f x (Finite lf)) (_ : is_lim g x (Finite lg)), is_lim (fun y : R => Rminus (f y) (g y)) x (Finite (Rminus lf lg)) *)
  intros Hf Hg.
  eapply is_lim_plus.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hf.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hg.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by [].
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_plus (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_plus (Lim f x) (Lim g x) ->
  ex_lim (fun y => f y + g y) x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => /Lim_correct Hf /Lim_correct Hg Hl.
(* Goal: ex_lim (fun y : R => Rplus (f y) (g y)) x *)
  exists (Rbar_plus (Lim f x) (Lim g x)).
(* Goal: is_lim (fun y : R => Rminus (f y) (g y)) x l *)
  eapply is_lim_plus ; try eassumption.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Rbar_plus_correct.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_plus (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_plus (Lim f x) (Lim g x) ->
  Lim (fun y => f y + g y) x = Rbar_plus (Lim f x) (Lim g x).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => /Lim_correct Hf /Lim_correct Hg Hl.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: is_lim (fun y : R => Rminus (f y) (g y)) x l *)
  eapply is_lim_plus ; try eassumption.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Rbar_plus_correct.
Qed.

(** Subtraction *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_minus (f g : R -> R) (x lf lg l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_Rbar_minus lf lg l ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim (fun y => f y - g y) x l.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Hg Hl.
(* Goal: is_lim (fun y : R => Rminus (f y) (g y)) x l *)
  eapply is_lim_plus ; try eassumption.
(* Goal: is_lim (fun y : R => Ropp (g y)) x (Rbar_opp lg) *)
  now apply is_lim_opp.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_minus' (f g : R -> R) (x : Rbar) (lf lg : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim (fun y => f y - g y) x (lf - lg).
Proof.
(* Goal: forall (_ : is_lim f x (Finite lf)) (_ : is_lim g x (Finite lg)), is_lim (fun y : R => Rminus (f y) (g y)) x (Finite (Rminus lf lg)) *)
  intros Hf Hg.
(* Goal: is_lim (fun y : R => Rminus (f y) (g y)) x (Finite (Rminus lf lg)) *)
  eapply is_lim_minus ; try eassumption.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by [].
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_minus (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_minus (Lim f x) (Lim g x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim (fun y => f y - g y) x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Hg Hl.
(* Goal: ex_lim (fun y : R => Rminus (f y) (g y)) x *)
  apply ex_lim_plus.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hf.
(* Goal: ex_lim (fun y : R => Ropp (g y)) x *)
(* Goal: ex_Rbar_plus (Lim f x) (Lim (fun y : R => Ropp (g y)) x) *)
  apply ex_lim_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hg.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Lim_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hl.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_minus (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_minus (Lim f x) (Lim g x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Lim (fun y => f y - g y) x = Rbar_minus (Lim f x) (Lim g x).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Hg Hl.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Lim_plus.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  by rewrite Lim_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hf.
(* Goal: ex_lim (fun y : R => Ropp (g y)) x *)
(* Goal: ex_Rbar_plus (Lim f x) (Lim (fun y : R => Ropp (g y)) x) *)
  apply ex_lim_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hg.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Lim_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hl.
Qed.

(** ** Multiplicative operators *)
(** Multiplicative inverse *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_inv (f : R -> R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> l <> 0 -> is_lim (fun y => / f y) x (Rbar_inv l).
Proof.
(* Goal: forall (_ : is_lim f x l) (_ : not (@eq Rbar l (Finite (IZR Z0)))), is_lim (fun y : R => Rinv (f y)) x (Rbar_inv l) *)
  intros Hf Hl.
(* Goal: is_lim (fun y : R => Rinv (f y)) x (Rbar_inv l) *)
  apply filterlim_comp with (1 := Hf).
(* Goal: @filterlim R R Rinv (Rbar_locally l) (Rbar_locally (Rbar_inv l)) *)
  now apply filterlim_Rbar_inv.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_inv (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> Lim f x <> 0 -> ex_lim (fun y => / f y) x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => /Lim_correct Hf Hlf.
(* Goal: ex_lim (fun y : R => Rinv (f y)) x *)
  exists (Rbar_inv (Lim f x)).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_inv.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_inv (f : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> Lim f x <> 0 -> Lim (fun y => / f y) x = Rbar_inv (Lim f x).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => /Lim_correct Hf Hlf.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_inv.
Qed.

(** Multiplication *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_mult (f g : R -> R) (x lf lg : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_mult lf lg ->
  is_lim (fun y => f y * g y) x (Rbar_mult lf lg).
Proof.
(* Goal: forall (_ : is_lim f x lf) (_ : is_lim g x lg) (_ : ex_Rbar_mult lf lg), is_lim (fun y : R => Rmult (f y) (g y)) x (Rbar_mult lf lg) *)
intros Cf Cg Hp.
(* Goal: is_lim (fun y : R => Rmult (f y) (g y)) x (Rbar_mult lf lg) *)
eapply filterlim_comp_2 ; try eassumption.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
by apply filterlim_Rbar_mult, Rbar_mult_correct.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_mult (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_mult (Lim f x) (Lim g x) ->
  ex_lim (fun y => f y * g y) x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => /Lim_correct Hf /Lim_correct Hg Hl.
(* Goal: ex_lim (fun y : R => Rmult (f y) (g y)) x *)
  exists (Rbar_mult (Lim f x) (Lim g x)).
(* Goal: is_lim (fun y : R => Rmult (f y) (g y)) x (Rbar_mult (Lim f x) (Lim g x)) *)
  now apply is_lim_mult.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_mult (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_mult (Lim f x) (Lim g x) ->
  Lim (fun y => f y * g y) x = Rbar_mult (Lim f x) (Lim g x).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => /Lim_correct Hf /Lim_correct Hg Hl.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: is_lim (fun y : R => Rmult (f y) (g y)) x (Rbar_mult (Lim f x) (Lim g x)) *)
  now apply is_lim_mult.
Qed.

(** Scalar multiplication *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_scal_l (f : R -> R) (a : R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> is_lim (fun y => a * f y) x (Rbar_mult a l).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case: (Req_dec 0 a) => [<- {a} | Ha].
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Rbar_mult_0_l.
(* Goal: is_lim (fun y : R => Rmult (IZR Z0) (f y)) x (Finite (IZR Z0)) *)
(* Goal: is_lim (fun y : R => Rmult a (f y)) x (Rbar_mult (Finite a) l) *)
  apply is_lim_ext with (fun _ => 0).
(* Goal: forall y : R, @eq R (f b) (f (Rplus (Rmult (IZR Z0) y) b)) *)
(* Goal: ex_lim (fun _ : R => f b) x *)
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult a y) b)) x *)
  move => y ; by rewrite Rmult_0_l.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_const.

(* Goal: is_lim (fun y : R => Rmult a (f y)) x (Rbar_mult (Finite a) l) *)
  apply is_lim_mult.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_const.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hf.
(* Goal: ex_Rbar_mult (Finite a) l *)
  apply sym_not_eq in Ha.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: l {Hf} => [l | | ] //=.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_scal_l (f : R -> R) (a : R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim (fun y => a * f y) x.
Proof.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case => l Hf.
(* Goal: ex_lim (fun y : R => Rmult a (f y)) x *)
  exists (Rbar_mult a l).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_scal_l.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_scal_l (f : R -> R) (a : R) (x : Rbar) :
  Lim (fun y => a * f y) x = Rbar_mult a (Lim f x).
Proof.
(* Goal: @eq Rbar (Lim (fun y : R => Rmult a (f y)) x) (Rbar_mult (Finite a) (Lim f x)) *)
  apply Lim_seq_scal_l.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_scal_r (f : R -> R) (a : R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> is_lim (fun y => f y * a) x (Rbar_mult l a).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Rbar_mult_comm.
(* Goal: is_lim (fun y : R => Rmult (f y) a) x (Rbar_mult (Finite a) l) *)
  apply is_lim_ext with (fun y => a * f y).
(* Goal: forall y : R, @eq R (f b) (f (Rplus (Rmult (IZR Z0) y) b)) *)
(* Goal: ex_lim (fun _ : R => f b) x *)
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult a y) b)) x *)
  move => y ; by apply Rmult_comm.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_scal_l.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_scal_r (f : R -> R) (a : R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim (fun y => f y * a) x.
Proof.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case => l Hf.
(* Goal: ex_lim (fun y : R => Rmult (f y) a) x *)
  exists (Rbar_mult l a).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_scal_r.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_scal_r (f : R -> R) (a : R) (x : Rbar) :
  Lim (fun y => f y * a) x = Rbar_mult (Lim f x) a.
Proof.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite Rbar_mult_comm -Lim_seq_scal_l.
(* Goal: @eq Rbar (Lim (fun y : R => Rmult (f y) a) x) (Lim_seq (fun n : nat => Rmult a (f (Rbar_loc_seq x n)))) *)
  apply Lim_seq_ext.
(* Goal: forall y : R, @eq R (f b) (f (Rplus (Rmult (IZR Z0) y) b)) *)
(* Goal: ex_lim (fun _ : R => f b) x *)
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult a y) b)) x *)
  move => y ; by apply Rmult_comm.
Qed.

(** Division *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_div (f g : R -> R) (x lf lg : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg -> lg <> 0 ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_div lf lg ->
  is_lim (fun y => f y / g y) x (Rbar_div lf lg).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Hg Hlg Hl.
(* Goal: is_lim (fun y : R => Rdiv (f y) (g y)) x (Rbar_div lf lg) *)
  apply is_lim_mult ; try assumption.
(* Goal: is_lim (fun y : R => Rinv (g y)) x (Rbar_inv lg) *)
  now apply is_lim_inv.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_div (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x -> Lim g x <> 0 ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_div (Lim f x) (Lim g x) ->
  ex_lim (fun y => f y / g y) x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Hg Hlg Hl.
(* Goal: ex_lim (fun y : R => Rdiv (f y) (g y)) x *)
  apply ex_lim_mult ; try assumption.
(* Goal: ex_lim (fun y : R => Rinv (g y)) x *)
(* Goal: ex_Rbar_mult (Lim f x) (Lim (fun y : R => Rinv (g y)) x) *)
  now apply ex_lim_inv.
(* Goal: ex_Rbar_mult (Lim f x) (Lim (fun y : R => Rinv (g y)) x) *)
  now rewrite Lim_inv.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_div (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f x -> ex_lim g x -> Lim g x <> 0 ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_Rbar_div (Lim f x) (Lim g x) ->
  Lim (fun y => f y / g y) x = Rbar_div (Lim f x) (Lim g x).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Hg Hlg Hl.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: is_lim (fun y : R => Rdiv (f y) (g y)) x (Rbar_div (Lim f x) (Lim g x)) *)
  apply is_lim_div ; try apply Lim_correct ; assumption.
Qed.

(** Composition by linear functions *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_comp_lin (f : R -> R) (a b : R) (x l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f (Rbar_plus (Rbar_mult a x) b) l -> a <> 0
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> is_lim (fun y => f (a * y + b)) x l.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Ha.
  apply is_lim_comp with (Rbar_plus (Rbar_mult a x) b).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hf.
  eapply is_lim_plus.
  apply is_lim_scal_l.
  apply is_lim_id.
  apply is_lim_const.
  apply Rbar_plus_correct.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: (Rbar_mult a x) => //.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: x {Hf} => [x | | ] //=.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists (mkposreal _ Rlt_0_1) => y _ Hy.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  apply Rbar_finite_neq, Rminus_not_eq ; ring_simplify (a * y + b - (a * x + b)).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -Rmult_minus_distr_l.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  apply Rmult_integral_contrapositive ; split.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by [].
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Rminus_eq_contra.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists 0 => x Hx.
(* Goal: ex_Rbar_mult (Finite a) l *)
  apply sym_not_eq in Ha.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: Rle_dec => // H.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: Rle_lt_or_eq_dec => //.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists 0 => x Hx.
(* Goal: ex_Rbar_mult (Finite a) l *)
  apply sym_not_eq in Ha.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: Rle_dec => // H.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: Rle_lt_or_eq_dec => //.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_comp_lin (f : R -> R) (a b : R) (x : Rbar) :
  ex_lim f (Rbar_plus (Rbar_mult a x) b)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> ex_lim (fun y => f (a * y + b)) x.
Proof.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case => l Hf.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case: (Req_dec a 0) => [-> {a Hf} | Ha].
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult (IZR Z0) y) b)) x *)
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult a y) b)) x *)
  apply ex_lim_ext with (fun _ => f b).
(* Goal: forall y : R, @eq R (f b) (f (Rplus (Rmult (IZR Z0) y) b)) *)
(* Goal: ex_lim (fun _ : R => f b) x *)
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult a y) b)) x *)
  move => y ; by rewrite Rmult_0_l Rplus_0_l.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply ex_lim_const.
(* Goal: ex_lim (fun y : R => f (Rplus (Rmult a y) b)) x *)
  exists l ; by apply is_lim_comp_lin.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_comp_lin (f : R -> R) (a b : R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  ex_lim f (Rbar_plus (Rbar_mult a x) b) -> a <> 0 ->
  Lim (fun y => f (a * y + b)) x = Lim f (Rbar_plus (Rbar_mult a x) b).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf Ha.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: is_lim (fun y : R => f (Rplus (Rmult a y) b)) x (Lim f (Rbar_plus (Rbar_mult (Finite a) x) (Finite b))) *)
  apply is_lim_comp_lin.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Lim_correct.
(* Goal: continuity_2d_pt f x y *)
(* Goal: continuity_2d_pt (fun u v : R => Ropp (g u v)) x y *)
  exact: Ha.
Qed.

(** Continuity and limit *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_continuity (f : R -> R) (x : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_pt f x -> is_lim f x (f x).
Proof.
(* Goal: forall _ : continuity_pt f x, is_lim f (Finite x) (Finite (f x)) *)
intros cf.
(* Goal: is_lim f (Finite x) (Finite (f x)) *)
now apply continuity_pt_filterlim'.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma ex_lim_continuity (f : R -> R) (x : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_pt f x -> ex_finite_lim f x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf.
(* Goal: ex_finite_lim f (Finite x) *)
  exists (f x).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_continuity.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma Lim_continuity (f : R -> R) (x : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_pt f x -> Lim f x = f x.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hf.
(* Goal: @eq Rbar (Lim f (Finite x)) (Finite (f x)) *)
  apply is_lim_unique.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_continuity.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma C0_extension_right {T : UniformSpace} (f : R -> T) lb (a b : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   a < b ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (forall c : R, a < c < b -> filterlim f (locally c) (locally (f c))) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (filterlim f (at_left b) (locally lb)) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   {g : R -> T | (forall c, a < c -> filterlim g (locally c) (locally (g c)))
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
     /\ (forall c : R, c < b -> g c = f c) /\ g b = lb}.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros Hab ; intros.

  set g := fun x => match Rlt_dec x b with
                    | left _ => f x
                    | right _ => lb
                    end.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  assert (Gab : forall c : R, c < b -> g c = f c).
    intros c Hcb.
    unfold g.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by (case: Rlt_dec).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  assert (Gb : forall c : R, b <= c -> g c = lb).
    intros c Hbc.
    unfold g.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: Rlt_dec (Rle_not_lt _ _ Hbc) => //.

(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  exists g ; split.
  intros c Hac.
  case: (Rlt_le_dec c b) ; (try case) => Hbc.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - apply filterlim_ext_loc with f.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    apply locally_interval with m_infty b => //= y _ Hyb.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply sym_eq, Gab.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
    rewrite Gab //.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    apply H ; by split.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - rewrite Gb.
    2: by apply Rlt_le.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => @eq R (f y) (g y))) (_ : is_lim f x l), is_lim g x l *)
    eapply filterlim_ext_loc.
    2: by apply filterlim_const.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    apply locally_interval with b p_infty => //= y Hby _.
    apply sym_eq, Gb.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Rlt_le.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - rewrite -Hbc => {c Hbc Hac}.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
    rewrite Gb.
    2: by apply Rle_refl.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    apply filterlim_locally => eps /= {H}.
    destruct (proj1 (filterlim_locally _ _) H0 eps) as [d Hd].
    simpl in Hd.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    exists d => x Hx.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: (Rlt_le_dec x b) => Hxb.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
    rewrite Gab //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Hd.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
    rewrite Gb //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply ball_center.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - split.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Gab.
    apply Gb ; by apply Rle_refl.
Qed.
Lemma filterlim_Ropp_left (x : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  filterlim Ropp (at_left x) (at_right (- x)).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => P [d /= Hd].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists d => y /= Hy Hy'.
(* Goal: P (Ropp y) *)
  apply Hd.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -Ropp_plus_distr Rabs_Ropp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hy.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Ropp_lt_contravar.
Qed.
Lemma filterlim_Ropp_right (x : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  filterlim Ropp (at_right x) (at_left (- x)).
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => P [d /= Hd].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists d => y /= Hy Hy'.
(* Goal: P (Ropp y) *)
  apply Hd.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -Ropp_plus_distr Rabs_Ropp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hy.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Ropp_lt_contravar.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma C0_extension_left {T : UniformSpace} (f : R -> T) la (a b : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   a < b ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (forall c : R, a < c < b -> filterlim f (locally c) (locally (f c))) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (filterlim f (at_right a) (locally la)) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   {g : R -> T | (forall c, c < b -> filterlim g (locally c) (locally (g c)))
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
     /\ (forall c : R, a < c -> g c = f c) /\ g a = la}.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  destruct (C0_extension_right (fun x => f (- x)) la (-b) (-a)) as [g Hg].
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Ropp_lt_contravar.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
  eapply filterlim_comp.
  apply (filterlim_opp c).
  apply H0.
  split ; apply Ropp_lt_cancel ; rewrite Ropp_involutive ; by apply H2.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
  eapply filterlim_comp.
  apply filterlim_Ropp_left.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by rewrite Ropp_involutive.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  exists (fun x => g (- x)) ; split.
(* Goal: forall (c : R) (_ : and (Rlt a c) (Rlt c b)), @filterlim R (UniformSpace.sort T) f (@locally R_UniformSpace c) (@locally T (f c)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_right a) (@locally T (f a)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_left b) (@locally T (f b)) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intros c Hc.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
  eapply filterlim_comp.
  apply (filterlim_opp c).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hg, Ropp_lt_contravar.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  split.
(* Goal: forall (c : R) (_ : and (Rlt a c) (Rlt c b)), @filterlim R (UniformSpace.sort T) f (@locally R_UniformSpace c) (@locally T (f c)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_right a) (@locally T (f a)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_left b) (@locally T (f b)) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intros c Hc.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite (proj1 (proj2 Hg)).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by rewrite Ropp_involutive.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Ropp_lt_contravar.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hg.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma C0_extension_lt {T : UniformSpace} (f : R -> T) la lb (a b : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a < b ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (forall c : R, a < c < b -> filterlim f (locally c) (locally (f c))) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (filterlim f (at_right a) (locally la)) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (filterlim f (at_left b) (locally lb)) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   {g : R -> T | (forall c, filterlim g (locally c) (locally (g c)))
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
     /\ (forall c : R, a < c < b -> g c = f c) /\ g a = la /\ g b = lb}.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  destruct (C0_extension_left f la a b) as [g [Cg [Gab Ga]]] => //.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  destruct (C0_extension_right g lb a b) as [h [Ch [Hab Hb]]] => //.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
  apply Cg, H3.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => @eq R (f y) (g y))) (_ : is_lim f x l), is_lim g x l *)
  eapply filterlim_ext_loc.
  2: by apply H2.
  apply Rminus_lt_0 in H.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists (mkposreal _ H) => y /= Hy Hy'.
  apply sym_eq, Gab.
  apply Ropp_lt_cancel, (Rplus_lt_reg_l b).
  eapply Rle_lt_trans, Hy.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -abs_opp opp_minus.
  apply Rle_abs.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  exists h ; repeat split.
  intros c.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: (Rlt_le_dec a c) => Hac.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Ch.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Hab.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => @eq R (f y) (g y))) (_ : is_lim f x l), is_lim g x l *)
  eapply filterlim_ext_loc.
  2: apply Cg.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  apply locally_interval with m_infty b => //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by eapply Rle_lt_trans, H.
  intros y _ Hy ; by apply sym_eq, Hab.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by eapply Rle_lt_trans, H.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by eapply Rle_lt_trans, H.
(* Goal: forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intros c [Hac Hcb].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  rewrite Hab => //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Gab.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  by rewrite Hab.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by [].
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma C0_extension_le {T : UniformSpace} (f : R -> T) (a b : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   (forall c : R, a <= c <= b -> filterlim f (locally c) (locally (f c))) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
   {g : R -> T | (forall c, filterlim g (locally c) (locally (g c)))
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
     /\ (forall c : R, a <= c <= b -> g c = f c)}.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: (Rlt_le_dec a b) => Hab.

(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  destruct (C0_extension_lt f (f a) (f b) a b Hab) as [g [Cg [Gab [Ga Gb]]]].
(* Goal: forall (c : R) (_ : and (Rlt a c) (Rlt c b)), @filterlim R (UniformSpace.sort T) f (@locally R_UniformSpace c) (@locally T (f c)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_right a) (@locally T (f a)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_left b) (@locally T (f b)) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intros c Hc.
(* Goal: @filterlim R (UniformSpace.sort T) f (@locally R_UniformSpace c) (@locally T (f c)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_right a) (@locally T (f a)) *)
(* Goal: @filterlim R (UniformSpace.sort T) f (at_left b) (@locally T (f b)) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  apply H ; split ; apply Rlt_le, Hc.
(* Goal: @filterlim R (UniformSpace.sort T) f (at_left b) (@locally T (f b)) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  eapply filterlim_filter_le_1, H.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply filter_le_within.
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intuition.
(* Goal: @filterlim R (UniformSpace.sort T) f (at_left b) (@locally T (f b)) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  eapply filterlim_filter_le_1, H.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply filter_le_within.
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intuition.
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  exists g ; repeat split => //.
(* Goal: forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  intros c [Hac Hcb].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case: Hac => [ Hac | <-] //.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case: Hcb => [ Hcb | ->] //.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  apply Gab ; by split.

(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  exists (fun _ => f a) ; split ; simpl.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => c.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply filterlim_const.
(* Goal: forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (f a) (f c) *)
  intros c [Hac Hca].
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: Hab => Hab.
(* Goal: @eq (UniformSpace.sort T) (f a) (f c) *)
(* Goal: @eq (UniformSpace.sort T) (f a) (f c) *)
  contradict Hab ; apply Rle_not_lt.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Rle_trans with c.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Hab in Hca.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply f_equal, Rle_antisym.
Qed.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma bounded_continuity {K : AbsRing} {V : NormedModule K}
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (f : R -> V) a b :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, a <= x <= b -> filterlim f (locally x) (locally (f x)))
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> {M : R | forall x, a <= x <= b -> norm (f x) < M}.
Proof.
  destruct (Rle_dec b a) as [Hab|Hab].
    exists (norm (f a) + 1).
    intros x [Hax Hxb].
    replace x with a.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    rewrite -{1}(Rplus_0_r (norm (f a))).
    apply Rplus_lt_compat_l, Rlt_0_1.
    apply Rle_antisym with (1 := Hax).
    now apply Rle_trans with b.
  apply Rnot_le_lt in Hab.

(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  wlog: f / (forall x, filterlim f (locally x) (locally (f x))) => [ Hw Cf | Cf _ ].
    destruct (C0_extension_le f a b) as [g [Cg Hg]].
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
    by apply Cf.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    destruct (Hw g) as [M HM] => //.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    exists M ; intros.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    rewrite -Hg //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply HM.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  assert (forall x : R, locally x (fun y : R => Rabs (norm (f y) - norm (f x)) < 1)).
    intro x.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    generalize (proj1 (filterlim_locally_ball_norm _ _) (Cf x)) => {Cf} Cf.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
    apply: filter_imp (Cf (mkposreal _ Rlt_0_1)) => y Hy.
    apply Rle_lt_trans with (2 := Hy).
    apply norm_triangle_inv.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  assert (forall x y : R, Rabs (norm (f y) - norm (f x)) < 1 \/ ~ Rabs (norm (f y) - norm (f x)) < 1).
    intros x y ; edestruct Rlt_dec.
    left ; by apply r.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by right.

  set delta := (fun (x : R) => proj1_sig (locally_ex_dec x _ (H0 x) (H x))).
  destruct (compactness_value_1d a b delta) as [d Hd].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  destruct (nfloor_ex ((b - a) / d)) as [N HN].
    apply Rdiv_le_0_compat.
    now apply Rlt_le, Rlt_Rminus.
(* Goal: Rlt (IZR Z0) (pos eps) *)
    apply cond_pos.
  set (M := (fix g n := match n with O => 0 | S n => Rmax (norm (f (a + INR n * d)) + 3) (g n) end) (S N)).
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists M => x Hx.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  apply Rnot_le_lt => H2.
  apply (Hd x Hx) ; case => t.
  unfold delta.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: locally_ex_dec => e /= He [Ht [Hxt Hde]].
  contradict H2 ; apply Rlt_not_le.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move: (fun (y : R) Hy => He y (norm_compat1 _ _ _ Hy)) => {He} He.
  apply He in Hxt.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -(Rabs_pos_eq (norm _) (norm_ge_0 _)).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (norm (f x)) with ((norm (f x) - norm (f t)) + norm (f t))%R by ring.
  eapply Rle_lt_trans.
  apply Rabs_triang.
  eapply Rlt_trans.
  apply Rplus_lt_compat_r.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hxt.
  rewrite Rplus_comm ; apply Rlt_minus_r.
  clear x Hx Hxt.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  destruct (nfloor_ex ((t - a) / d)) as [n Hn].
    apply Rdiv_le_0_compat.
    apply Rplus_le_reg_r with a.
(* Goal: Rlt (IZR Z0) (Rminus (Rplus x (Rinv (Rplus (INR n) (IZR (Zpos xH))))) x) *)
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    now ring_simplify.
(* Goal: Rlt (IZR Z0) (pos eps) *)
    apply cond_pos.
  set (y := a + INR n * d).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (norm (f t)) with (-(norm (f y) - norm (f t)) + norm (f y))%R by ring.
  eapply Rle_lt_trans.

  apply Rabs_triang.
  eapply Rlt_trans.
  apply Rplus_lt_compat_r.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Rabs_Ropp.
(* Goal: forall _ : Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) (f x y))) (pos eps), P (f (@fst R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  apply He.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  change (Rabs (a + INR n * d - t) < e).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (a + INR n * d - t) with (-((t - a) / d - INR n) * d).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Rabs_mult (Rabs_pos_eq d).
  2: apply Rlt_le, cond_pos.
  apply Rlt_le_trans with (1 * d).
  apply Rmult_lt_compat_r with (1 := cond_pos d).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Rabs_Ropp Rabs_pos_eq.
  apply Rplus_lt_reg_r with (INR n).
(* Goal: ex_Rbar_mult (Lim f x) (Lim (fun y : R => Rinv (g y)) x) *)
  now rewrite /Rminus Rplus_assoc Rplus_opp_l Rplus_0_r (Rplus_comm 1).
  apply Rplus_le_reg_r with (INR n).
(* Goal: Rlt (IZR Z0) (Rminus (Rplus x (Rinv (Rplus (INR n) (IZR (Zpos xH))))) x) *)
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
  now ring_simplify.
(* Goal: ex_Rbar_mult (Lim f x) (Lim (fun y : R => Rinv (g y)) x) *)
  now rewrite Rmult_1_l.
  field.
  apply Rgt_not_eq, cond_pos.

  apply Rplus_lt_reg_l with 1.
(* Goal: Rlt (IZR Z0) (Rminus (Rplus x (Rinv (Rplus (INR n) (IZR (Zpos xH))))) x) *)
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
  ring_simplify.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  rewrite -> Rabs_pos_eq by apply norm_ge_0.
  assert (n < S N)%nat.
  apply INR_lt.
  apply Rle_lt_trans with (1 := proj1 Hn).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite S_INR.
  apply Rle_lt_trans with (2 := proj2 HN).
  apply Rmult_le_compat_r.
  apply Rlt_le, Rinv_0_lt_compat, cond_pos.
  now apply Rplus_le_compat_r.
  unfold M, y.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  clear -H1.
  induction N.
  apply Rlt_le_trans with (2 := Rmax_l _ _).
  destruct n.
  apply Rplus_lt_compat_l, Rplus_lt_compat_l.
  now apply (IZR_lt 1 2).
  now apply lt_S_n in H1.
  destruct (le_lt_eq_dec _ _ (lt_n_Sm_le _ _ H1)) as [H2|H2].
  apply Rlt_le_trans with (2 := Rmax_r _ _).
  now apply IHN.
  apply Rlt_le_trans with (2 := Rmax_l _ _).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite H2.
  apply Rplus_lt_compat_l, Rplus_lt_compat_l.
  now apply (IZR_lt 1 2).
Qed.

(** *** Order *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_le_loc (f g : R -> R) (x lf lg : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rbar_locally' x (fun y => f y <= g y) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x lf -> is_lim g x lg ->
  Rbar_le lf lg.
Proof.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => Rle (f y) (g y))) (_ : is_lim f x lf) (_ : is_lim g x lg), Rbar_le lf lg *)
  apply filterlim_le.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_le_p_loc (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rbar_locally' x (fun y => f y <= g y) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x p_infty ->
  is_lim g x p_infty.
Proof.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => Rle (f y) (g y))) (_ : is_lim f x p_infty), is_lim g x p_infty *)
  apply filterlim_ge_p_infty.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_le_m_loc (f g : R -> R) (x : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rbar_locally' x (fun y => g y <= f y) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x m_infty ->
  is_lim g x m_infty.
Proof.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => Rle (g y) (f y))) (_ : is_lim f x m_infty), is_lim g x m_infty *)
  apply filterlim_le_m_infty.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_le_le_loc (f g h : R -> R) (x : Rbar) (l : Rbar) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rbar_locally' x (fun y => f y <= h y <= g y) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> is_lim g x l ->
  is_lim h x l.
Proof.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => and (Rle (f y) (h y)) (Rle (h y) (g y)))) (_ : is_lim f x l) (_ : is_lim g x l), is_lim h x l *)
  apply filterlim_le_le.
Qed.

(** ** Generalized intermediate value theorem *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma IVT_gen (f : R -> R) (a b y : R) :
  Ranalysis1.continuity f
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Rmin (f a) (f b) <= y <= Rmax (f a) (f b)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> { x : R | Rmin a b <= x <= Rmax a b /\ f x = y }.
Proof.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case: (Req_EM_T a b) => [ <- {b} | Hab].
    rewrite /Rmin /Rmax ; case: Rle_dec (Rle_refl a) (Rle_refl (f a)) ;
    case: Rle_dec => // _ _ _ _ Cf Hy.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    exists a ; split.
(* Goal: and (Rle a a) (Rle a a) *)
(* Goal: @eq R (f a) y *)
(* Goal: forall (_ : continuity f) (_ : and (Rle (Rmin (f a) (f b)) y) (Rle y (Rmax (f a) (f b)))), @sig R (fun x : R => and (and (Rle (Rmin a b) x) (Rle x (Rmax a b))) (@eq R (f x) y)) *)
    split ; by apply Rle_refl.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    apply Rle_antisym ; by apply Hy.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  wlog: a b Hab / (a < b) => [Hw | {Hab} Hab].
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: (Rle_lt_dec a b) => Hab'.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: (Rle_lt_or_eq_dec _ _ Hab') => {Hab'} // Hab'.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Hw.
    rewrite (Rmin_comm (f a)) (Rmin_comm a) (Rmax_comm (f a)) (Rmax_comm a) ;
    apply Hw => //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Rlt_not_eq.
(* Goal: forall (_ : Rle (f a) (f b)) (_ : continuity f) (_ : and (Rle (Rmin (f a) (f b)) y) (Rle y (Rmax (f a) (f b)))), @sig R (fun x : R => and (and (Rle a x) (Rle x b)) (@eq R (f x) y)) *)
  rewrite /(Rmin a) /(Rmax a) ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  wlog: f y / (f a <= f b) => [Hw |].
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: (Rle_lt_dec (f a) (f b)) => Hf' Hf Hy.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Hw.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    case: (Hw (fun y => - f y) (- y)).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Ropp_le_contravar, Rlt_le.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Ranalysis1.continuity_opp.
    rewrite Rmin_opp_Rmax Rmax_opp_Rmin ;
    split ; apply Ropp_le_contravar, Hy.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
    move => x [Hx Hfx].
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
    exists x ; intuition.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    by rewrite -(Ropp_involutive y) -Hfx Ropp_involutive.
  rewrite /Rmin /Rmax ; case: Rle_dec =>  // _ _.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  wlog: y / (f a < y < f b) => [Hw Hf Hy | Hy Hf _].
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: Hy => Hay Hyb.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    case: (Rle_lt_or_eq_dec _ _ Hay) => {Hay} [Hay | <- ].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    case: (Rle_lt_or_eq_dec _ _ Hyb) => {Hyb} [Hyb | -> ].
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
    apply Hw ; intuition.
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
    exists b ; intuition.
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
    exists a ; intuition.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case (IVT (fun x => f x - y) a b).
(* Goal: continuity (fun x : R => Rminus (f x) y) *)
(* Goal: Rlt a b *)
(* Goal: Rlt (Rminus (f a) y) (IZR Z0) *)
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  apply Ranalysis1.continuity_minus.
(* Goal: continuity f *)
(* Goal: continuity (fun _ : R => y) *)
(* Goal: Rlt a b *)
(* Goal: Rlt (Rminus (f a) y) (IZR Z0) *)
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  exact Hf.
(* Goal: continuity (fun _ : R => y) *)
(* Goal: Rlt a b *)
(* Goal: Rlt (Rminus (f a) y) (IZR Z0) *)
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  apply continuity_const.
(* Goal: constant (fun _ : R => y) *)
(* Goal: Rlt a b *)
(* Goal: Rlt (Rminus (f a) y) (IZR Z0) *)
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  intros _ _ ; reflexivity.
(* Goal: Rlt a b *)
(* Goal: Rlt (Rminus (f a) y) (IZR Z0) *)
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  exact Hab.
(* Goal: Rlt (Rminus (f a) y) (IZR Z0) *)
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  apply Rlt_minus_l ; rewrite Rplus_0_l ; apply Hy.
(* Goal: Rlt (IZR Z0) (Rminus (f b) y) *)
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  apply Rlt_minus_r ; rewrite Rplus_0_l ; apply Hy.
(* Goal: forall (x : R) (_ : and (and (Rle a x) (Rle x b)) (@eq R (Rminus (f x) y) (IZR Z0))), @sig R (fun x0 : R => and (and (Rle a x0) (Rle x0 b)) (@eq R (f x0) y)) *)
  intros x [Hx Hfx].
(* Goal: @sig R (fun x : R => and (and (Rle a x) (Rle x b)) (@eq R (f x) y)) *)
  apply Rminus_diag_uniq in Hfx.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  by exists x.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma IVT_Rbar_incr (f : R -> R) (a b la lb : Rbar) (y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f a la -> is_lim f b lb
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> (forall (x : R), Rbar_lt a x -> Rbar_lt x b -> continuity_pt f x)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Rbar_lt a b
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Rbar_lt la y /\ Rbar_lt y lb
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> {x : R | Rbar_lt a x /\ Rbar_lt x b /\ f x = y}.
Proof.
(* Goal: forall (_ : is_lim f a la) (_ : is_lim f b lb) (_ : forall (x : R) (_ : Rbar_lt a (Finite x)) (_ : Rbar_lt (Finite x) b), continuity_pt f x) (_ : Rbar_lt a b) (_ : and (Rbar_lt la (Finite y)) (Rbar_lt (Finite y) lb)), @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
intros Hfa Hfb Cf Hab Hy.
assert (Hb' : exists b' : R, Rbar_lt b' b /\
        is_upper_bound (fun x => Rbar_lt a x /\ Rbar_lt x b /\ f x <= y) b').
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
{ assert (Hfb' : Rbar_locally' b (fun x => y < f x)).
(* Goal: Rbar_locally' b (fun x : R => Rlt y (f x)) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') b) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) b')) *)
    apply Hfb.
(* Goal: Rbar_locally lb (Rlt y) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') b) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) b')) *)
    now apply (open_Rbar_gt' _ y).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  clear -Hab Hfb'.
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') b) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) b')) *)
  destruct b as [b| |].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - destruct Hfb' as [eps He].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    exists (b - eps).
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    split.
(* Goal: Rlt (Rminus x (pos eps)) x *)
    apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    replace (b - (b - eps)) with (pos eps) by ring.
(* Goal: Rlt (IZR Z0) (pos eps) *)
    apply cond_pos.
(* Goal: is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) p_infty) (Rle (f x) y))) M *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    intros u [_ [H1 H2]].
(* Goal: Rle u (Rminus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
    apply Rnot_lt_le.
(* Goal: not (Rlt (Rminus x (pos eps)) u) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
    intros Hu.
(* Goal: False *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    apply Rle_not_lt with (1 := H2).
(* Goal: forall _ : Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) (f x y))) (pos eps), P (f (@fst R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    apply He.
(* Goal: @ball R_UniformSpace x (pos eps) u *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
    apply Rabs_lt_between'.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    split.
(* Goal: Rlt (Rminus x (pos eps)) u *)
(* Goal: Rlt u (Rplus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
    exact Hu.
(* Goal: Rlt u (Rplus b (pos eps)) *)
(* Goal: not (@eq (UniformSpace.sort R_UniformSpace) u b) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') p_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) p_infty) (Rle (f x) y))) b')) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    apply Rlt_le_trans with (1 := H1).
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    apply Rlt_le.
(* Goal: Rlt (Rminus x (pos eps)) x *)
    apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    replace (b + eps - b) with (pos eps) by ring.
(* Goal: Rlt (IZR Z0) (pos eps) *)
    apply cond_pos.
(* Goal: not (@eq (UniformSpace.sort R_UniformSpace) u b) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') p_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) p_infty) (Rle (f x) y))) b')) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    now apply Rlt_not_eq.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - destruct Hfb' as [M HM].
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') p_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) p_infty) (Rle (f x) y))) b')) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    exists M.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    repeat split.
(* Goal: is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) p_infty) (Rle (f x) y))) M *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    intros u [_ [H1 H2]].
(* Goal: Rle u (Rminus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
    apply Rnot_lt_le.
(* Goal: not (Rlt (Rminus x (pos eps)) u) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
    intros Hu.
(* Goal: False *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    apply Rle_not_lt with (1 := H2).
(* Goal: Rlt y (f u) *)
(* Goal: @ex R (fun b' : R => and (Rbar_lt (Finite b') m_infty) (is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) m_infty) (Rle (f x) y))) b')) *)
    now apply HM.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - now destruct a. }
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
assert (Hex : exists x : R, Rbar_lt a x /\ Rbar_lt x b /\ f x <= y).
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
{ assert (Hfa' : Rbar_locally' a (fun x => Rbar_lt x b /\ f x < y)).
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => and (Rbar_lt a (Finite x)) (Rbar_lt (Finite x) b)) *)
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rlt (f x) y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    apply filter_and.
(* Goal: Rbar_locally' a (fun x : R => Rbar_lt (Finite x) b) *)
(* Goal: Rbar_locally' a (fun x : R => Rlt (f x) y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    apply Rbar_locally'_le.
(* Goal: Rbar_locally a (fun x : R => Rbar_lt (Finite x) b) *)
(* Goal: Rbar_locally' a (fun x : R => Rlt (f x) y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    now apply open_Rbar_lt'.
(* Goal: Rbar_locally' a (fun x : R => Rlt (f x) y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    apply (Hfa (fun u => u < y)).
(* Goal: Rbar_locally la (fun u : R => Rlt u y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    now apply (open_Rbar_lt' _ y).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  clear -Hab Hfa'.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
  destruct a as [a| |].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - destruct Hfa' as [eps He].
(* Goal: @ex R (fun x : R => and (Rbar_lt (Finite a) (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    exists (a + eps / 2).
(* Goal: and (Rbar_lt (Finite a) (Finite (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    assert (Ha : a < a + eps / 2).
(* Goal: Rlt (Rminus x (pos eps)) x *)
      apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      replace (a + eps / 2 - a) with (eps / 2) by ring.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
      apply is_pos_div_2.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    split.
(* Goal: Rbar_lt (Finite a) (Finite (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) *)
(* Goal: and (Rbar_lt (Finite (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    exact Ha.
(* Goal: and (Rbar_lt (Finite (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
    assert (H : Rbar_lt (a + eps / 2) b /\ (f (a + eps / 2) < y)).
(* Goal: forall _ : Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) (f x y))) (pos eps), P (f (@fst R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      apply He.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
      rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      replace (a + eps / 2 + - a) with (eps / 2) by ring.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
      rewrite Rabs_pos_eq.
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
      apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
      apply cond_pos.
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
      apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
      apply is_pos_div_2.
(* Goal: not (@eq (UniformSpace.sort R_UniformSpace) (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH))))) a) *)
(* Goal: and (Rbar_lt (Finite (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus a (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
      now apply Rgt_not_eq.
(* Goal: and (Rbar_lt m_infty (Finite (Rminus M (IZR (Zpos xH))))) (and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rle (f (Rminus M (IZR (Zpos xH)))) y)) *)
    destruct H as [H1 H2].
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    split.
(* Goal: Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) *)
(* Goal: and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    exact H1.
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    now apply Rlt_le.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - easy.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  - destruct Hfa' as [M HM].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    exists (M - 1).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    assert (H : Rbar_lt (M - 1) b /\ f (M - 1) < y).
(* Goal: and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rlt (f (Rminus M (IZR (Zpos xH)))) y) *)
(* Goal: and (Rbar_lt m_infty (Finite (Rminus M (IZR (Zpos xH))))) (and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rle (f (Rminus M (IZR (Zpos xH)))) y)) *)
      apply HM.
(* Goal: Rlt (Rminus x (pos eps)) x *)
      apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      replace (M - (M - 1)) with 1 by ring.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: and (Rbar_lt m_infty (Finite (Rminus M (IZR (Zpos xH))))) (and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rle (f (Rminus M (IZR (Zpos xH)))) y)) *)
      apply Rlt_0_1.
(* Goal: and (Rbar_lt m_infty (Finite (Rminus M (IZR (Zpos xH))))) (and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rle (f (Rminus M (IZR (Zpos xH)))) y)) *)
    destruct H as [H1 H2].
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
    repeat split.
(* Goal: Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) *)
(* Goal: and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    exact H1.
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    now apply Rlt_le. }
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
destruct (completeness (fun x => Rbar_lt a x /\ Rbar_lt x b /\ f x <= y)) as [x [Hub Hlub]].
(* Goal: bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
destruct Hb' as [b' Hb'].
(* Goal: bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
now exists b'.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
exact Hex.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
exists x.
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
destruct Hb' as [b' [Hb Hb']].
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
destruct Hex as [x' Hx'].
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
assert (Hax : Rbar_lt a x).
(* Goal: Rbar_lt a (Finite x) *)
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
  apply Rbar_lt_le_trans with x'.
(* Goal: Rbar_lt a (Finite x') *)
(* Goal: Rbar_le (Finite x') (Finite x) *)
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
  apply Hx'.
(* Goal: Rbar_le (Finite x') (Finite x) *)
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
  now apply Hub.
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
assert (Hxb : Rbar_lt x b).
(* Goal: Rbar_lt (Finite x) b *)
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
  apply Rbar_le_lt_trans with b'.
(* Goal: Rbar_le (Finite x) (Finite b') *)
(* Goal: Rbar_lt (Finite b') b *)
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
  now apply Hlub.
(* Goal: Rbar_lt (Finite b') b *)
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
  exact Hb.
(* Goal: and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y)) *)
repeat split ; try assumption.
(* Goal: @eq R (f x) y *)
specialize (Cf _ Hax Hxb).
(* Goal: continuity_2d_pt (fun x y : R => f (g x y)) x y *)
apply continuity_pt_filterlim in Cf.
(* Goal: @eq R (f x) y *)
destruct (total_order_T (f x) y) as [[H|H]|H].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- assert (H': locally x (fun u => (Rbar_lt a u /\ Rbar_lt u b) /\ f u < y)).
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => and (Rbar_lt a (Finite x)) (Rbar_lt (Finite x) b)) *)
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rlt (f x) y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    apply filter_and.
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => and (Rbar_lt a (Finite x)) (Rbar_lt (Finite x) b)) *)
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rlt (f x) y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    apply filter_and.
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rbar_lt a (Finite x)) *)
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rbar_lt (Finite x) b) *)
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rlt (f x) y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    now apply open_Rbar_gt.
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rbar_lt (Finite x) b) *)
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rlt (f x) y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    now apply open_Rbar_lt.
(* Goal: @locally R_UniformSpace x (fun x : UniformSpace.sort R_UniformSpace => Rlt (f x) y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    apply (Cf (fun u => u < y)).
(* Goal: @locally R_UniformSpace (f x) (fun u : R => Rlt u y) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
    now apply open_lt.
(* Goal: @eq R (f x) y *)
  destruct H' as [eps H'].
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  elim Rle_not_lt with x (x + eps / 2).
(* Goal: Rle (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) x *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  apply Hub.
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  destruct (H' (x + eps / 2)) as [[H1 H2] H3].
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (x + eps / 2 + - x) with (eps / 2) by ring.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite Rabs_pos_eq.
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
  apply cond_pos.
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  apply is_pos_div_2.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  split.
(* Goal: Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) *)
(* Goal: and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  exact H1.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  split.
(* Goal: Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b *)
(* Goal: Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  exact H2.
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  now apply Rlt_le.
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (x + eps / 2 - x) with (eps / 2) by ring.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
  apply is_pos_div_2.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- exact H.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- assert (H': locally x (fun u => y < f u)).
(* Goal: @locally R_UniformSpace x (fun u : UniformSpace.sort R_UniformSpace => Rlt y (f u)) *)
(* Goal: @eq R (f x) y *)
    apply (Cf (fun u => y < u)).
(* Goal: @locally R_UniformSpace (f x) (fun u : R => Rlt y u) *)
(* Goal: @eq R (f x) y *)
    now apply open_gt.
(* Goal: @eq R (f x) y *)
  destruct H' as [eps H'].
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  elim Rle_not_lt with (x - eps) x.
(* Goal: Rle x (Rminus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Hlub.
(* Goal: is_upper_bound (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) (Rminus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  intros u Hfu.
(* Goal: Rle u (Rminus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rnot_lt_le.
(* Goal: not (Rlt (Rminus x (pos eps)) u) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  intros Hu.
(* Goal: False *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rle_not_lt with (1 := proj2 (proj2 Hfu)).
(* Goal: Rlt y (f u) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply H'.
(* Goal: @ball R_UniformSpace x (pos eps) u *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rabs_lt_between'.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  split.
(* Goal: Rlt (Rminus x (pos eps)) u *)
(* Goal: Rlt u (Rplus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  exact Hu.
(* Goal: Rlt u (Rplus x (pos eps)) *)
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rle_lt_trans with (1 := Hub u Hfu).
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (x + eps - x) with (pos eps) by ring.
(* Goal: Rlt (IZR Z0) (pos eps) *)
  apply cond_pos.
(* Goal: Rlt (Rminus x (pos eps)) x *)
  apply Rminus_lt_0.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  replace (x - (x - eps)) with (pos eps) by ring.
(* Goal: Rlt (IZR Z0) (pos eps) *)
  apply cond_pos.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma IVT_Rbar_decr (f : R -> R) (a b la lb : Rbar) (y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f a la -> is_lim f b lb
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> (forall (x : R), Rbar_lt a x -> Rbar_lt x b -> continuity_pt f x)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Rbar_lt a b
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> Rbar_lt lb y /\ Rbar_lt y la
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> {x : R | Rbar_lt a x /\ Rbar_lt x b /\ f x = y}.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Hla Hlb Cf Hab Hy.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  case: (IVT_Rbar_incr (fun x => - f x) a b (Rbar_opp la) (Rbar_opp lb) (-y)).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_opp.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply is_lim_opp.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => x Hax Hxb.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply continuity_pt_opp, Cf.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hab.
  split ; apply Rbar_opp_lt ;
  rewrite Rbar_opp_involutive /Rbar_opp Ropp_involutive ;
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hy.
(* Goal: and (Rle a b) (Rle b b) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
(* Goal: @sig (forall _ : R, UniformSpace.sort T) (fun g : forall _ : R, UniformSpace.sort T => and (forall c : UniformSpace.sort R_UniformSpace, @filterlim R (UniformSpace.sort T) g (@locally R_UniformSpace c) (@locally T (g c))) (forall (c : R) (_ : and (Rle a c) (Rle c b)), @eq (UniformSpace.sort T) (g c) (f c))) *)
  move => x Hx ; exists x ; intuition.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  by rewrite -(Ropp_involutive y) -H4 Ropp_involutive.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
(** * 2D-continuity *)

(** ** Definitions *)

Definition continuity_2d_pt f x y :=
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), 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 continuity_2d_pt_filterlim :
  forall f x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y <->
  filterlim (fun z : R * R => f (fst z) (snd z)) (locally (x,y)) (locally (f x y)).
Proof.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
split.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros Cf P [eps He].
(* Goal: @filtermap (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) P *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  specialize (Cf eps).
(* Goal: @filtermap (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) P *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  apply locally_2d_locally in Cf.
(* Goal: @filtermap (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) P *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  apply filter_imp with (2 := Cf).
(* Goal: forall (x0 : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace)) (_ : Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) x0) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) x0)) (f x y))) (pos eps)), P (f (@fst R R x0) (@snd R R x0)) *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  intros [u v].
(* Goal: forall _ : Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) (f x y))) (pos eps), P (f (@fst R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v)) (@snd R R (@pair (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) u v))) *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  apply He.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
- intros Cf eps.
(* Goal: locally_2d (fun u v : R => @eq R (f u v) (g u v)) x y *)
  apply locally_2d_locally.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  specialize (Cf (fun z => Rabs (z - f x y) < eps)).
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
  unfold filtermap in Cf.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
  apply Cf.
(* Goal: @locally R_UniformSpace (f x y) (fun z : R => Rlt (Rabs (Rminus z (f x y))) (pos eps)) *)
  now exists eps.
Qed.

Lemma uniform_continuity_2d :
  forall f a b c d,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (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,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a <= x <= b -> c <= y <= d ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a <= u <= b -> c <= v <= d ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rabs (u - x) < delta -> Rabs (v - y) < delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rabs (f u v - f x y) < eps.
Proof.
intros f a b c d Cf eps.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
set (P x y u v := Rabs (f u v - f x y) < pos_div_2 eps).
refine (_ (fun x y Hx Hy => locally_2d_ex_dec (P x y) x y _ (Cf x y Hx Hy _))).
intros delta1.
set (delta2 x y := match Rle_dec a x, Rle_dec x b, Rle_dec c y, Rle_dec y d with
  left Ha, left Hb, left Hc, left Hd => pos_div_2 (proj1_sig (delta1 x y (conj Ha Hb) (conj Hc Hd))) |
  _, _, _, _ => mkposreal _ Rlt_0_1 end).
destruct (compactness_value_2d a b c d delta2) as (delta,Hdelta).
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
exists (pos_div_2 delta) => x y u v Hx Hy Hu Hv Hux Hvy.
specialize (Hdelta x y Hx Hy).
apply Rnot_le_lt.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: false_not_not Hdelta => Hdelta.
apply Rlt_not_le.
destruct Hdelta as (p&q&(Hap,Hpb)&(Hcq,Hqd)&Hxp&Hyq&Hd).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
replace (f u v - f x y) with (f u v - f p q + (f p q - f x y)) by ring.
apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite (double_var eps).
revert Hxp Hyq Hd.
unfold delta2.
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
case Rle_dec => Hap' ; try easy.
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
case Rle_dec => Hpb' ; try easy.
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
case Rle_dec => Hcq' ; try easy.
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
case Rle_dec => Hqd' ; try easy.
clear delta2.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
case delta1 => /= r Hr Hxp Hyq Hd.
apply Rplus_lt_compat.
apply Hr.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
replace (u - p) with (u - x + (x - p)) by ring.
apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite (double_var r).
apply Rplus_lt_compat with (2 := Hxp).
apply Rlt_le_trans with (2 := Hd).
apply Rlt_trans with (1 := Hux).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
replace (v - q) with (v - y + (y - q)) by ring.
apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite (double_var r).
apply Rplus_lt_compat with (2 := Hyq).
apply Rlt_le_trans with (2 := Hd).
apply Rlt_trans with (1 := Hvy).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite Rabs_minus_sym.
apply Hr.
apply Rlt_trans with (1 := Hxp).
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
apply Rlt_trans with (1 := Hyq).
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
intros u v.
unfold P.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
destruct (Rlt_dec (Rabs (f u v - f x y)) (pos_div_2 eps)) ; [left|right]; assumption.
Qed.

Lemma uniform_continuity_2d_1d :
  forall f a b c,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, a <= x <= b -> continuity_2d_pt f x c) ->
  forall eps : posreal, exists delta : posreal,
  forall x y u v,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a <= x <= b -> c - delta <= y <= c + delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a <= u <= b -> c - delta <= v <= c + delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rabs (u - x) < delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rabs (f u v - f x y) < eps.
Proof.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (a b c : R) (_ : forall (x : R) (_ : and (Rle a x) (Rle x b)), continuity_2d_pt f c x) (eps : posreal), @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
intros f a b c Cf eps.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
set (P x y u v := Rabs (f u v - f x y) < pos_div_2 eps).
refine (_ (fun x Hx => locally_2d_ex_dec (P x c) x c _ (Cf x Hx _))).
intros delta1.
set (delta2 x := match Rle_dec a x, Rle_dec x b with
  left Ha, left Hb => pos_div_2 (proj1_sig (delta1 x (conj Ha Hb))) |
  _, _ => mkposreal _ Rlt_0_1 end).
destruct (compactness_value_1d a b delta2) as (delta,Hdelta).
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
exists (pos_div_2 delta) => x y u v Hx Hy Hu Hv Hux.
specialize (Hdelta x Hx).
apply Rnot_le_lt.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: false_not_not Hdelta => Hdelta.
apply Rlt_not_le.
destruct Hdelta as (p&(Hap,Hpb)&Hxp&Hd).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
replace (f u v - f x y) with (f u v - f p c + (f p c - f x y)) by ring.
apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite (double_var eps).
revert Hxp Hd.
unfold delta2.
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
case Rle_dec => Hap' ; try easy.
(* Goal: @ex R (fun x : R => and (Rbar_lt p_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @ex R (fun x : R => and (Rbar_lt m_infty (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
case Rle_dec => Hpb' ; try easy.
clear delta2.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
case delta1 => /= r Hr Hxp Hd.
apply Rplus_lt_compat.
apply Hr.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
replace (u - p) with (u - x + (x - p)) by ring.
apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite (double_var r).
apply Rplus_lt_compat with (2 := Hxp).
apply Rlt_le_trans with (2 := Hd).
apply Rlt_trans with (1 := Hux).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
apply Rle_lt_trans with (pos_div_2 delta).
now apply Rabs_le_between'.
apply Rlt_le_trans with(1 := Rlt_eps2_eps _ (cond_pos delta)).
apply Rle_trans with (1 := Hd).
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_le.
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
rewrite Rabs_minus_sym.
apply Hr.
apply Rlt_trans with (1 := Hxp).
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
apply Rle_lt_trans with (pos_div_2 delta).
now apply Rabs_le_between'.
apply Rlt_le_trans with(1 := Rlt_eps2_eps _ (cond_pos delta)).
apply Rle_trans with (1 := Hd).
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_le.
(* Goal: Rlt (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (pos eps) *)
(* Goal: Rle (IZR Z0) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rbar_lt a (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))))) (and (Rbar_lt (Finite (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) b) (Rle (f (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH)))))) y)) *)
(* Goal: Rlt x (Rplus x (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: @eq R (f x) y *)
(* Goal: @eq R (f x) y *)
apply Rlt_eps2_eps.
(* Goal: Rlt (IZR Z0) (pos eps) *)
apply cond_pos.
intros u v.
unfold P.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
destruct (Rlt_dec (Rabs (f u v - f x c)) (pos_div_2 eps)); [left|right] ; assumption.
Qed.

Lemma uniform_continuity_2d_1d' :
  forall f a b c,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, a <= x <= b -> continuity_2d_pt f c x) ->
  forall eps : posreal, exists delta : posreal,
  forall x y u v,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a <= x <= b -> c - delta <= y <= c + delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  a <= u <= b -> c - delta <= v <= c + delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rabs (u - x) < delta ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  Rabs (f v u - f y x) < eps.
Proof.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (a b c : R) (_ : forall (x : R) (_ : and (Rle a x) (Rle x b)), continuity_2d_pt f c x) (eps : posreal), @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
intros f a b c Cf eps.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
assert (T:(forall x : R, a <= x <= b -> continuity_2d_pt (fun x0 y : R => f y x0) x c) ).
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), continuity_2d_pt (fun x0 y : R => f y x0) x c *)
(* Goal: @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
intros x Hx e.
(* Goal: locally_2d (fun u v : R => Rlt (Rabs (Rminus (f v u) (f c x))) (pos e)) x c *)
(* Goal: @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
destruct (Cf x Hx e) as (d,Hd).
(* Goal: locally_2d (fun u v : R => Rlt (Rabs (Rminus (f v u) (f c x))) (pos e)) x c *)
(* Goal: @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
exists d.
(* Goal: P (Ropp y) *)
intros; now apply Hd.
(* Goal: @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
destruct (uniform_continuity_2d_1d (fun x y => f y x) a b c T eps) as (d,Hd).
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
exists d; intros.
(* Goal: P (Ropp y) *)
now apply Hd.
Qed.

Lemma continuity_2d_pt_neq_0 :
  forall f x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y -> f x y <> 0 ->
  locally_2d (fun u v => f u v <> 0) x y.
Proof.
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R) (_ : continuity_2d_pt f x y) (_ : not (@eq R (f x y) (IZR Z0))), locally_2d (fun u v : R => not (@eq R (f u v) (IZR Z0))) x y *)
intros f x y Cf H.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim in Cf.
(* Goal: locally_2d (fun u v : R => @eq R (f u v) (g u v)) x y *)
apply locally_2d_locally.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => not (@eq R (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (IZR Z0))) *)
apply (Cf (fun y => y <> 0)).
(* Goal: @locally R_UniformSpace (f x y) (fun y : R => not (@eq R y (IZR Z0))) *)
now apply open_neq.
Qed.

(** ** Operations *)

(** Identity *)

Lemma continuity_pt_id :
  forall x, continuity_pt (fun x => x) x.
Proof.
(* Goal: forall x : R, continuity_pt (fun x0 : R => x0) x *)
intros x.
(* Goal: continuity_pt g x *)
apply continuity_pt_filterlim.
(* Goal: @filterlim R R (fun x : R => x) (@locally R_UniformSpace x) (@locally R_UniformSpace x) *)
now intros P.
Qed.

Lemma continuity_2d_pt_id1 :
  forall x y, continuity_2d_pt (fun u v => u) x y.
Proof.
(* Goal: forall x y : R, continuity_2d_pt (fun _ v : R => v) x y *)
  intros x y eps; exists eps; tauto.
Qed.

Lemma continuity_2d_pt_id2 :
  forall x y, continuity_2d_pt (fun u v => v) x y.
Proof.
(* Goal: forall x y : R, continuity_2d_pt (fun _ v : R => v) x y *)
  intros x y eps; exists eps; tauto.
Qed.

(** Constant functions *)

Lemma continuity_2d_pt_const :
  forall x y c, continuity_2d_pt (fun u v => c) x y.
Proof.
(* Goal: forall x y c : R, continuity_2d_pt (fun _ _ : R => c) x y *)
  intros x y c eps; exists eps; rewrite Rminus_eq_0 Rabs_R0.
(* Goal: Rlt (IZR Z0) (pos eps) *)
  intros; apply cond_pos.
Qed.

(** *** Extensionality *)

Lemma continuity_pt_ext_loc :
  forall f g x,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  locally x (fun x => f x = g x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_pt f x -> continuity_pt g x.
Proof.
(* Goal: forall (f g : forall _ : UniformSpace.sort R_UniformSpace, R) (x : UniformSpace.sort R_UniformSpace) (_ : @locally R_UniformSpace x (fun x0 : UniformSpace.sort R_UniformSpace => @eq R (f x0) (g x0))) (_ : continuity_pt f x), continuity_pt g x *)
intros f g x Heq Cf.
(* Goal: continuity_2d_pt (fun x y : R => f (g x y)) x y *)
apply continuity_pt_filterlim in Cf.
(* Goal: continuity_pt g x *)
apply continuity_pt_filterlim.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
rewrite -(locally_singleton _ _ Heq).
by apply filterlim_ext_loc with f.
Qed.

Lemma continuity_pt_ext :
  forall f g x,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, f x = g x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_pt f x -> continuity_pt g x.
Proof.
(* Goal: forall (f g : forall _ : R, R) (x : R) (_ : forall x0 : R, @eq R (f x0) (g x0)) (_ : continuity_pt f x), continuity_pt g x *)
intros f g x Heq.
(* Goal: forall _ : continuity_pt f x, continuity_pt g x *)
apply continuity_pt_ext_loc.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
by apply filter_forall.
Qed.

Lemma continuity_2d_pt_ext_loc :
  forall f g x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  locally_2d (fun u v => f u v = g u v) x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y -> continuity_2d_pt g x y.
Proof.
(* Goal: forall (f g : forall (_ : R) (_ : R), R) (x y : R) (_ : locally_2d (fun u v : R => @eq R (f u v) (g u v)) x y) (_ : continuity_2d_pt f x y), continuity_2d_pt g x y *)
intros f g x y Heq Cf.
(* Goal: continuity_2d_pt g x y *)
apply locally_2d_locally in Heq.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim in Cf.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
rewrite -(locally_singleton _ _ Heq).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair R R x y)) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) (@pair R R x y)))) *)
apply filterlim_ext_loc with (2 := Cf).
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
by apply Heq.
Qed.

Lemma continuity_2d_pt_ext :
  forall f g x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x y, f x y = g x y) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y -> continuity_2d_pt g x y.
Proof.
(* Goal: forall (f g : forall (_ : R) (_ : R), R) (x y : R) (_ : forall x0 y0 : R, @eq R (f x0 y0) (g x0 y0)) (_ : continuity_2d_pt f x y), continuity_2d_pt g x y *)
intros f g x y Heq.
(* Goal: forall _ : continuity_2d_pt f x y, continuity_2d_pt g x y *)
apply continuity_2d_pt_ext_loc.
(* Goal: locally_2d (fun u v : R => @eq R (f u v) (g u v)) x y *)
apply locally_2d_locally.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => @eq R (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (g (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z))) *)
apply filter_forall.
(* Goal: forall (x0 : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace)) (_ : Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) x0) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) x0)) (f x y))) (pos eps)), P (f (@fst R R x0) (@snd R R x0)) *)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
now intros [u v].
Qed.

(** *** Composition *)

Lemma continuity_1d_2d_pt_comp :
  forall f g x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_pt f (g x y) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt g x y ->
  continuity_2d_pt (fun x y => f (g x y)) x y.
Proof.
(* Goal: forall (f : forall _ : R, R) (g : forall (_ : R) (_ : R), R) (x y : R) (_ : continuity_pt f (g x y)) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun x0 y0 : R => f (g x0 y0)) x y *)
intros f g x y Cf Cg.
(* Goal: continuity_2d_pt (fun x y : R => f (g x y)) x y *)
apply continuity_pt_filterlim in Cf.
(* Goal: continuity_2d_pt (fun x y : R => f (g x y)) x y *)
apply continuity_2d_pt_filterlim in Cg.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: filterlim_comp Cg Cf.
Qed.

(** *** Additive operators *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuity_2d_pt_opp (f : R -> R -> R) (x y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt (fun u v => - f u v) x y.
Proof.
(* Goal: forall _ : continuity_2d_pt f x y, continuity_2d_pt (fun u v : R => Ropp (f u v)) x y *)
apply continuity_1d_2d_pt_comp.
(* Goal: continuity_pt Ropp (f x y) *)
apply continuity_pt_opp.
(* Goal: continuity_pt (fun x : R => x) (f x y) *)
apply continuity_pt_id.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuity_2d_pt_plus (f g : R -> R -> R) (x y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt g x y ->
  continuity_2d_pt (fun u v => f u v + g u v) x y.
Proof.
intros Cf Cg.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim in Cf.
(* Goal: continuity_2d_pt (fun x y : R => f (g x y)) x y *)
apply continuity_2d_pt_filterlim in Cg.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim.
eapply filterlim_comp_2.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
apply Cf.
apply Cg.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => f (g (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f (g x y))) *)
apply: filterlim_plus.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuity_2d_pt_minus (f g : R -> R -> R) (x y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt g x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt (fun u v => f u v - g u v) x y.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => Cf Cg.
(* Goal: continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  apply continuity_2d_pt_plus.
(* Goal: continuity_2d_pt f x y *)
(* Goal: continuity_2d_pt (fun u v : R => Ropp (g u v)) x y *)
  exact: Cf.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply continuity_2d_pt_opp.
Qed.

(** *** Multiplicative operators *)

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuity_2d_pt_inv (f : R -> R -> R) (x y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  f x y <> 0 ->
  continuity_2d_pt (fun u v => / f u v) x y.
Proof.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : not (@eq R (f x y) (IZR Z0))), continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
intros Cf Df.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim in Cf.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => Rinv (f (@fst R R z) (@snd R R z))) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (Rinv (f x y))) *)
apply filterlim_comp with (1 := Cf).
(* Goal: @filterlim R R Rinv (@locally R_UniformSpace (f x y)) (@locally R_UniformSpace (Rinv (f x y))) *)
apply (filterlim_Rbar_inv (f x y)).
(* Goal: not (@eq Rbar (Finite (f x y)) (Finite (IZR Z0))) *)
contradict Df.
(* Goal: @eq R (f x y) (IZR Z0) *)
now injection Df.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuity_2d_pt_mult (f g : R -> R -> R) (x y : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt f x y ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuity_2d_pt g x y ->
  continuity_2d_pt (fun u v => f u v * g u v) x y.
Proof.
intros Cf Cg.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim in Cf.
(* Goal: continuity_2d_pt (fun x y : R => f (g x y)) x y *)
apply continuity_2d_pt_filterlim in Cg.
(* Goal: continuity_2d_pt (fun u v : R => Rinv (f u v)) x y *)
apply continuity_2d_pt_filterlim.
eapply filterlim_comp_2.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
apply Cf.
apply Cg.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
by apply (filterlim_Rbar_mult (f x y) (g x y) (f x y * g x y)).
Qed.

(** * Continuity in Uniform Spaces *)

(** ** Continuity *)

Section Continuity.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Context {T U : UniformSpace}.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Definition continuous_on (D : T -> Prop) (f : T -> U) :=
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall x, D x -> filterlim f (within D (locally x)) (locally (f x)).

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Definition continuous (f : T -> U) (x : T) :=
  filterlim f (locally x) (locally (f x)).

Lemma continuous_continuous_on :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall (D : T -> Prop) (f : T -> U) (x : T),
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  locally x D ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous_on D f ->
  continuous f x.
Proof.
(* Goal: forall (D : forall _ : UniformSpace.sort T, Prop) (f : forall _ : UniformSpace.sort T, UniformSpace.sort U) (x : UniformSpace.sort T) (_ : @locally T x D) (_ : continuous_on D f), continuous f x *)
intros D f x Dx CD P Pfx.
(* Goal: @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@locally T x) P *)
assert (Dx' := locally_singleton _ _ Dx).
(* Goal: @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@locally T x) P *)
generalize (filter_and _ _ Dx (CD x Dx' P Pfx)).
(* Goal: forall _ : @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@locally T x) P, @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@within (UniformSpace.sort T) D (@locally T x)) P *)
unfold filtermap, within.
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
apply filter_imp.
(* Goal: forall (x : UniformSpace.sort T) (_ : and (D x) (forall _ : D x, P (f x))), P (f x) *)
intros t [H1 H2].
(* Goal: P (f t) *)
now apply H2.
Qed.

Lemma continuous_on_subset :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall (D E : T -> Prop) (f : T -> U),
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, E x -> D x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous_on D f ->
  continuous_on E f.
Proof.
(* Goal: forall (D E : forall _ : UniformSpace.sort T, Prop) (f : forall _ : UniformSpace.sort T, UniformSpace.sort U) (_ : forall (x : UniformSpace.sort T) (_ : E x), D x) (_ : continuous_on D f), continuous_on E f *)
intros D E f H CD x Ex P Pfx.
(* Goal: @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@within (UniformSpace.sort T) E (@locally T x)) P *)
generalize (CD x (H x Ex) P Pfx).
(* Goal: forall _ : @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@locally T x) P, @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@within (UniformSpace.sort T) D (@locally T x)) P *)
unfold filtermap, within.
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
apply filter_imp.
(* Goal: forall (x : UniformSpace.sort T) (_ : forall _ : D x, P (f x)) (_ : E x), P (f x) *)
intros t H' Et.
(* Goal: P (f t) *)
now apply H', H.
Qed.

Lemma continuous_on_forall :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall (D : T -> Prop) (f : T -> U),
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, D x -> continuous f x) ->
  continuous_on D f.
Proof.
(* Goal: forall (D : forall _ : UniformSpace.sort T, Prop) (f : forall _ : UniformSpace.sort T, UniformSpace.sort U) (_ : forall (x : UniformSpace.sort T) (_ : D x), continuous f x), continuous_on D f *)
intros D f H x Dx P Pfx.
(* Goal: @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@within (UniformSpace.sort T) D (@locally T x)) P *)
generalize (H x Dx P Pfx).
(* Goal: forall _ : @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@locally T x) P, @filtermap (UniformSpace.sort T) (UniformSpace.sort U) f (@within (UniformSpace.sort T) D (@locally T x)) P *)
unfold filtermap, within.
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
now apply filter_imp.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_ext_loc (f g : T -> U) (x : T) :
  locally x (fun y : T => g y = f y)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> continuous g x -> continuous f x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: forall (_ : Rbar_locally' x (fun y : R => @eq R (f y) (g y))) (_ : is_lim f x l), is_lim g x l *)
  eapply filterlim_ext_loc.
(* Goal: @continuous U (NormedModule.UniformSpace K V) f x *)
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun x : UniformSpace.sort U => @opp (NormedModule.AbelianGroup K V) (g x)) x *)
  by apply H.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  by rewrite -(locally_singleton _ _ H).
Qed.
Lemma continuous_ext :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall (f g : T -> U) (x : T),
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, f x = g x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x ->
  continuous g x.
Proof.
(* Goal: forall (f g : forall _ : UniformSpace.sort T, UniformSpace.sort U) (x : UniformSpace.sort T) (_ : forall x0 : UniformSpace.sort T, @eq (UniformSpace.sort U) (f x0) (g x0)) (_ : continuous f x), continuous g x *)
intros f g x H Cf.
(* Goal: continuous g x *)
apply filterlim_ext with (1 := H).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
now rewrite <- H.
Qed.

Lemma continuous_on_ext :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  forall (D : T -> Prop) (f g : T -> U),
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, D x -> f x = g x) ->
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous_on D f ->
  continuous_on D g.
Proof.
(* Goal: forall (D : forall _ : UniformSpace.sort T, Prop) (f g : forall _ : UniformSpace.sort T, UniformSpace.sort U) (_ : forall (x : UniformSpace.sort T) (_ : D x), @eq (UniformSpace.sort U) (f x) (g x)) (_ : continuous_on D f), continuous_on D g *)
intros D f g H Cf x Dx.
(* Goal: @filterlim (UniformSpace.sort T) (UniformSpace.sort U) g (@within (UniformSpace.sort T) D (@locally T x)) (@locally U (g x)) *)
apply filterlim_within_ext with (1 := H).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
rewrite <- H with (1 := Dx).
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
now apply Cf.
Qed.

End Continuity.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_comp {U V W : UniformSpace} (f : U -> V) (g : V -> W) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous g (f x)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> continuous (fun x => g (f x)) x.
Proof.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
  by apply filterlim_comp.
Qed.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma continuous_comp_2 {U V W X : UniformSpace}
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (f : U -> V) (g : U -> W) (h : V -> W -> X) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous g x
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> continuous (fun (x : V * W) => h (fst x) (snd x)) (f x,g x)
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> continuous (fun x => h (f x) (g x)) x.
Proof.
  intros Cf Cg Ch.
  eapply filterlim_comp_2.
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
  by apply Cf.
  by apply Cg.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  apply filterlim_locally => eps.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: (proj1 (filterlim_locally _ _) Ch eps) => /= del Hdel.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  rewrite {1}/ball /= /prod_ball /= in Hdel.
  exists (fun y => ball (f x) (pos del) y) (fun y => ball (g x) (pos del) y).
  apply locally_ball.
  apply locally_ball.
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
  move => y z /= Hy Hz.
  apply (Hdel (y,z)).
(* Goal: forall (f : forall (_ : R) (_ : R), R) (x y : R), iff (continuity_2d_pt f x y) (@filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y))) *)
  by split.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma is_lim_comp_continuous (f g : R -> R) (x : Rbar) (l : R) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  is_lim f x l -> continuous g l
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    -> is_lim (fun x => g (f x)) x (g l).
Proof.
(* Goal: forall (_ : is_lim f x (Finite lf)) (_ : is_lim g x (Finite lg)), is_lim (fun y : R => Rminus (f y) (g y)) x (Finite (Rminus lf lg)) *)
  intros Hf Hg.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  apply filterlim_locally => eps.
  destruct (proj1 (filterlim_locally _ _) Hg eps) as [e He] ; clear Hg.
(* Goal: forall _ : @locally T x (fun x : UniformSpace.sort T => forall _ : D x, P (f x)), @locally T x (fun x : UniformSpace.sort T => forall _ : E x, P (f x)) *)
  eapply filter_imp.
  intros y Hy.
  apply He, Hy.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hf, locally_ball.
Qed.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma continuous_fst {U V : UniformSpace} (x : U) (y : V) :
  continuous (fst (B:=V)) (x, y).
Proof.
(* Goal: @continuous (prod_UniformSpace U V) V (@snd (UniformSpace.sort U) (UniformSpace.sort V)) (@pair (UniformSpace.sort U) (UniformSpace.sort V) x y) *)
  intros P [d Hd].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists d => z [/= Hz1 Hz2].
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hd => /=.
Qed.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma continuous_snd {U V : UniformSpace} (x : U) (y : V) :
  continuous (snd (B:=V)) (x, y).
Proof.
(* Goal: @continuous (prod_UniformSpace U V) V (@snd (UniformSpace.sort U) (UniformSpace.sort V)) (@pair (UniformSpace.sort U) (UniformSpace.sort V) x y) *)
  intros P [d Hd].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists d => z [/= Hz1 Hz2].
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply Hd => /=.
Qed.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma continuous_const {U V : UniformSpace} (c : V) (x : U) :
  continuous (fun _ => c) x.
Proof.
(* Goal: @continuous U V (fun _ : UniformSpace.sort U => c) x *)
  apply filterlim_const.
Qed.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma continuous_id {U : UniformSpace} (x : U) :
  continuous (fun y => y) x.
Proof.
(* Goal: @continuous U U (fun y : UniformSpace.sort U => y) x *)
  apply filterlim_id.
Qed.

Section Continuity_op.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Context {U : UniformSpace} {K : AbsRing} {V : NormedModule K}.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_opp (f : U -> V) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x ->
  continuous (fun x : U => opp (f x)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: forall _ : is_lim g x l, @filterlim T R (fun y : T => g (f y)) F (Rbar_locally l) *)
  eapply filterlim_comp.
(* Goal: @continuous U (NormedModule.UniformSpace K V) f x *)
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun x : UniformSpace.sort U => @opp (NormedModule.AbelianGroup K V) (g x)) x *)
  by apply H.
  apply (filterlim_opp (f x)).
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_plus (f g : U -> V) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous g x ->
  continuous (fun x : U => plus (f x) (g x)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
  eapply filterlim_comp_2.
(* Goal: @continuous U (NormedModule.UniformSpace K V) f x *)
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun x : UniformSpace.sort U => @opp (NormedModule.AbelianGroup K V) (g x)) x *)
  by apply H.
  by apply H0.
  apply (filterlim_plus (f x) (g x)).
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_minus (f g : U -> V) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous g x ->
  continuous (fun x : U => minus (f x) (g x)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun x : UniformSpace.sort U => @minus (NormedModule.AbelianGroup K V) (f x) (g x)) x *)
  apply continuous_plus.
(* Goal: @continuous U (NormedModule.UniformSpace K V) f x *)
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun x : UniformSpace.sort U => @opp (NormedModule.AbelianGroup K V) (g x)) x *)
  apply H.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply continuous_opp.
Qed.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_scal (k : U -> K) (f : U -> V) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous k x -> continuous f x -> continuous (fun y => scal (k y) (f y)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by eapply filterlim_comp_2, filterlim_scal.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_scal_r (k : K) (f : U -> V) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous (fun y => scal k (f y)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply continuous_comp, filterlim_scal_r.
Qed.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma continuous_scal_l (f : U -> K) (k : V) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous (fun y => scal (f y) k) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  apply (continuous_comp f (fun y => scal y k)) => //.
(* Goal: @continuous (AbsRing_UniformSpace K) (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort (AbsRing_UniformSpace K) => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y k) (f x) *)
  apply filterlim_scal_l.
Qed.

End Continuity_op.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Lemma continuous_mult {U : UniformSpace} {K : AbsRing}
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (f g : U -> K) (x : U) :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  continuous f x -> continuous g x
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  -> continuous (fun y => mult (f y) (g y)) x.
Proof.
(* Goal: forall (_ : @continuous U (AbsRing_UniformSpace K) f x) (_ : @continuous U (AbsRing_UniformSpace K) g x), @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  intros.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by eapply filterlim_comp_2, filterlim_mult.
Qed.

Section UnifCont.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Context {V : UniformSpace}.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma unifcont_1d (f : R -> V) a b :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, a <= x <= b -> continuous f x) ->
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  forall eps : posreal, {delta : posreal | forall x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    a <= x <= b -> a <= y <= b -> ball x delta y -> ~~ ball (f x) eps (f y)}.
Proof.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  intros Cf eps.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  wlog: f Cf / (forall z : R, continuous f z) => [ Hw | {Cf} Cf ].
    destruct (C0_extension_le f a b) as [g [Cg Hg]].
(* Goal: @locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y) (fun z : UniformSpace.sort (prod_UniformSpace R_UniformSpace R_UniformSpace) => Rlt (Rabs (Rminus (f (@fst (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z) (@snd (UniformSpace.sort R_UniformSpace) (UniformSpace.sort R_UniformSpace) z)) (f x y))) (pos eps)) *)
    by apply Cf.
    destruct (Hw g) as [d Hd].
    intros x Hx ; apply Cg.
    apply Cg.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    exists d => x y Hx Hy Hxy.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    rewrite -!Hg //.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Hd.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  assert (forall (x : R), {delta : posreal | forall y : R,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    ball x delta y -> ~~ ball (f x) (pos_div_2 eps) (f y)}).
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    move: (pos_div_2 eps) => {eps} eps x.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    assert (Rbar_lt 0 (Lub.Lub_Rbar (fun d => forall y : R, ball x d y -> ball (f x) eps (f y)))).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      case: (Lub.Lub_Rbar_correct (fun d => forall y : R, ball x d y -> ball (f x) eps (f y))).
(* Goal: forall (_ : continuity_2d_pt f x y) (_ : continuity_2d_pt g x y), continuity_2d_pt (fun u v : R => Rminus (f u v) (g u v)) x y *)
      move: (Lub.Lub_Rbar _) => l H1 H2.
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
      case: (proj1 (filterlim_locally _ _) (Cf x) eps) => d Hd.
      eapply Rbar_lt_le_trans, H1.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
      by apply d.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
      by apply Hd.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    assert (0 < Rbar_min 1 (Lub.Lub_Rbar (fun d => forall y : R, ball x d y -> ball (f x) eps (f y)))).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
      move: H ; case: (Lub.Lub_Rbar (fun d => forall y : R, ball x d y -> ball (f x) eps (f y))) => [l | | ] //= H0.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
      apply Rmin_case => //.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: and (Rbar_lt m_infty (Finite (Rminus M (IZR (Zpos xH))))) (and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rle (f (Rminus M (IZR (Zpos xH)))) y)) *)
      by apply Rlt_0_1.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: and (Rbar_lt m_infty (Finite (Rminus M (IZR (Zpos xH))))) (and (Rbar_lt (Finite (Rminus M (IZR (Zpos xH)))) b) (Rle (f (Rminus M (IZR (Zpos xH)))) y)) *)
      by apply Rlt_0_1.
    set d := mkposreal _ H0.
(* Goal: locally_2d (fun u v : R => Rlt (Rabs (Rminus (f v u) (f c x))) (pos e)) x c *)
(* Goal: @ex posreal (fun delta : posreal => forall (x y u v : R) (_ : and (Rle a x) (Rle x b)) (_ : and (Rle (Rminus c (pos delta)) y) (Rle y (Rplus c (pos delta)))) (_ : and (Rle a u) (Rle u b)) (_ : and (Rle (Rminus c (pos delta)) v) (Rle v (Rplus c (pos delta)))) (_ : Rlt (Rabs (Rminus u x)) (pos delta)), Rlt (Rabs (Rminus (f v u) (f y x))) (pos eps)) *)
    exists d.
    unfold d ; clear d ; simpl.
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    case: (Lub.Lub_Rbar_correct (fun d => forall y : R, ball x d y -> ball (f x) eps (f y))).
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    move: (Lub.Lub_Rbar (fun d => forall y : R, ball x d y -> ball (f x) eps (f y))) H => {H0} l H0 H1 H2 y Hy.
    contradict Hy.
    apply Rle_not_lt.
    apply (Rbar_le_trans (Finite _) l (Finite _)).
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    case: (l) H0 => [r | | ] //= H0.
    apply Rmin_r.
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
    apply H2 => d /= Hd.
    apply Rnot_lt_le ; contradict Hy.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by apply Hd.
  destruct (compactness_value_1d a b (fun x => pos_div_2 (proj1_sig (H x)))) as [d Hd].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists d => x y Hx Hy Hxy Hf.
  apply (Hd x Hx).
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case => {Hd} t [Ht].
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  case: H => /= delta Hdelta [Htx Hdt].
  apply (Hdelta x).
    eapply ball_le, Htx.
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
    rewrite {2}(double_var delta).
(* Goal: Rlt (IZR Z0) (Rminus (Rplus x (Rinv (Rplus (INR n) (IZR (Zpos xH))))) x) *)
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    apply Rminus_le_0 ; ring_simplify.
    apply Rlt_le, is_pos_div_2.
  intro Hftx.
  apply (Hdelta y).
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
    rewrite (double_var delta).
    apply ball_triangle with x.
    apply Htx.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
    by eapply ball_le, Hxy.
  contradict Hf.
(* Goal: @filterlim (prod R R) R (fun z : prod R R => g (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (g x y)) *)
  rewrite (double_var eps).
  eapply ball_triangle, Hf.
(* Goal: @continuous U (AbsRing_UniformSpace K) (fun y : UniformSpace.sort U => @mult (AbsRing.Ring K) (f y) (g y)) x *)
  by apply ball_sym.
Qed.

End UnifCont.

Section UnifCont_N.

(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
Context {K : AbsRing} {V : NormedModule K}.

(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
Lemma unifcont_normed_1d (f : R -> V) a b :
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
  (forall x, a <= x <= b -> continuous f x) ->
(* Goal: @ex R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (Rle (f x) y))) *)
(* Goal: @sig R (fun x : R => and (Rbar_lt a (Finite x)) (and (Rbar_lt (Finite x) b) (@eq R (f x) y))) *)
  forall eps : posreal, {delta : posreal | forall x y,
(* Goal: forall _ : @filterlim (prod R R) R (fun z : prod R R => f (@fst R R z) (@snd R R z)) (@locally (prod_UniformSpace R_UniformSpace R_UniformSpace) (@pair R R x y)) (@locally R_UniformSpace (f x y)), continuity_2d_pt f x y *)
    a <= x <= b -> a <= y <= b -> ball x delta y -> ball_norm (f x) eps (f y)}.
Proof.
(* Goal: forall _ : is_lim f x (Finite l), is_lim' f x (Finite l) *)
(* Goal: forall _ : is_lim' f x p_infty, is_lim f x p_infty *)
(* Goal: forall _ : is_lim f x p_infty, is_lim' f x p_infty *)
(* Goal: forall _ : is_lim' f x m_infty, is_lim f x m_infty *)
(* Goal: forall _ : is_lim f x m_infty, is_lim' f x m_infty *)
  intros H eps.
  assert (0 < eps / (@norm_factor _ V)).
    apply Rdiv_lt_0_compat.
(* Goal: Rlt (IZR Z0) (pos eps) *)
    apply cond_pos.
    exact norm_factor_gt_0.
  destruct (unifcont_1d f a b H (mkposreal _ H0)) as [d Hd].
(* Goal: @continuous U (NormedModule.UniformSpace K V) (fun y : UniformSpace.sort U => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (f y) k) x *)
  exists d => x y Hx Hy Hxy.
  specialize (Hd x y Hx Hy Hxy).
  apply Rnot_le_lt.
  contradict Hd ; contradict Hd.
  apply Rlt_not_le.
  evar_last.
  apply norm_compat2, Hd.
  simpl ; field.
  apply Rgt_not_eq, norm_factor_gt_0.
Qed.

End UnifCont_N.
