(** * Topology on [R]² *)
Definition locally_2d (P : R -> R -> Prop) x y :=
exists delta : posreal, forall u v, Rabs (u - x) < delta -> Rabs (v - y) < delta -> P u v.

(* Specifications: *)
Lemma locally_2d_locally :
forall P x y,
locally_2d P x y <-> locally (x,y) (fun z => P (fst z) (snd z)).
Lemma locally_2d_impl_strong :
forall (P Q : R -> R -> Prop) x y, locally_2d (fun u v => locally_2d P u v -> Q u v) x y ->
locally_2d P x y -> locally_2d Q x y.
Lemma locally_2d_singleton :
forall (P : R -> R -> Prop) x y, locally_2d P x y -> P x y.
Lemma locally_2d_impl :
forall (P Q : R -> R -> Prop) x y, locally_2d (fun u v => P u v -> Q u v) x y ->
locally_2d P x y -> locally_2d Q x y.
Lemma locally_2d_forall :
forall (P : R -> R -> Prop) x y, (forall u v, P u v) -> locally_2d P x y.
Lemma locally_2d_and :
forall (P Q : R -> R -> Prop) x y, locally_2d P x y -> locally_2d Q x y ->
locally_2d (fun u v => P u v /\ Q u v) x y.
Lemma locally_2d_align :
forall (P Q : R -> R -> Prop) x y,
( forall eps : posreal, (forall u v, Rabs (u - x) < eps -> Rabs (v - y) < eps -> P u v) ->
forall u v, Rabs (u - x) < eps -> Rabs (v - y) < eps -> Q u v ) ->
locally_2d P x y -> locally_2d Q x y.
Lemma locally_2d_1d_const_x :
forall (P : R -> R -> Prop) x y,
locally_2d P x y ->
locally y (fun t => P x t).
Lemma locally_2d_1d_const_y :
forall (P : R -> R -> Prop) x y,
locally_2d P x y ->
locally x (fun t => P t y).
Lemma locally_2d_1d_strong :
forall (P : R -> R -> Prop) x y,
locally_2d P x y ->
locally_2d (fun u v => forall t, 0 <= t <= 1 ->
locally t (fun z => locally_2d P (x + z * (u - x)) (y + z * (v - y)))) x y.
Lemma locally_2d_1d :
forall (P : R -> R -> Prop) x y,
locally_2d P x y ->
locally_2d (fun u v => forall t, 0 <= t <= 1 -> locally_2d P (x + t * (u - x)) (y + t * (v - y))) x y.
Lemma locally_2d_ex_dec :
forall P x y,
(forall x y, P x y \/ ~P x y) ->
locally_2d P x y ->
{d : posreal | forall u v, Rabs (u-x) < d -> Rabs (v-y) < d -> P u v}.