Section Compactness.
Fixpoint Tn n T : Type :=
match n with
| O => unit
| S n => (T * Tn n T)%type
end.
Fixpoint bounded_n n : Tn n R -> Tn n R -> Tn n R -> Prop :=
match n return Tn n R -> Tn n R -> Tn n R -> Prop with
| O => fun a b x : Tn O R => True
| S n => fun a b x : Tn (S n) R =>
let '(a1,a2) := a in
let '(b1,b2) := b in
let '(x1,x2) := x in
a1 <= x1 <= b1 /\ bounded_n n a2 b2 x2
end.
Fixpoint close_n n d : Tn n R -> Tn n R -> Prop :=
match n return Tn n R -> Tn n R -> Prop with
| O => fun x t : Tn O R => True
| S n => fun x t : Tn (S n) R =>
let '(x1,x2) := x in
let '(t1,t2) := t in
Rabs (x1 - t1) < d /\ close_n n d x2 t2
end.
(** * Compactness: there is a finite covering of opens *)
(** * Compactness: there is a covering based on a gauge function *)
End Compactness.
(** * Specific instances of compactness for 1D and 2D spaces *)

Lemma compactness_value_2d :
forall a b a' b' (delta : R -> R -> posreal),
{ d : posreal | forall x y, a <= x <= b -> a' <= y <= b' ->
~~ exists u, exists v, a <= u <= b /\ a' <= v <= b' /\ Rabs (x - u) < delta u v /\ Rabs (y - v) < delta u v /\ d <= delta u v }.