Metric Spaces: Completeness, Compactness, Connectedness, Baire and Contractions

Real Analysis is Section 3 of the GATE Mathematics (MA) paper and the section most given to “which of the following is true” questions, because its theorems come with hypotheses that can be removed one at a time to produce counterexamples. It is large enough to take three chapters here. This first one is the metric-space layer: completeness, compactness and connectedness, the Baire category theorem, continuity and uniform continuity, and the contraction mapping principle. The rule for this chapter is to learn every theorem with the example that shows each hypothesis is needed — ℚ for completeness, the closed unit ball of ℓ² for “closed and bounded is not compact”, x² on ℝ for uniform continuity, and x + 1/x on [1, ∞) for the strict inequality that is not a contraction. The second chapter takes sequences and series of functions, power series and the inverse and implicit function theorems; the third takes Lebesgue measure and integration and the Lᵖ spaces.

1. Metric spaces and completeness

A metric d on X is positive, symmetric, zero only on the diagonal and satisfies the triangle inequality. A sequence is Cauchy if d(xₘ, xₙ) → 0 as m, n → ∞, and X is complete if every Cauchy sequence converges in X. A closed subset of a complete space is complete, and a complete subspace of any metric space is closed.

Complete and not complete
CompleteNot complete, and a Cauchy sequence that escapes
ℝⁿ with any norm; ℤ (a Cauchy sequence is eventually constant)ℚ: the decimal truncations of √2
C[a, b] with the sup metricC[0, 1] with d(f, g) = ∫|f − g|: continuous ramps converging to a step
ℓᵖ and Lᵖ for 1 ≤ p ≤ ∞(0, 1) with the usual metric: xₙ = 1/n
any closed subset of ℝⁿthe polynomials on [0, 1] under the sup metric: Taylor partial sums of eˣ
⚠️ Completeness is not a topological property
(0, 1) and ℝ are homeomorphic (by x ↦ tan(π(x − 1/2))), yet ℝ is complete and (0, 1) is not. So completeness depends on the metric, not only on the open sets. Two metrics that give the same open sets can disagree about which sequences are Cauchy.

2. Compactness: Heine–Borel and Bolzano–Weierstrass

K is compact if every open cover has a finite subcover. In a metric space the following are equivalent: K is compact; K is sequentially compact (every sequence has a convergent subsequence with limit in K); K is complete and totally bounded (for every ε > 0, finitely many ε-balls cover K). A compact set is closed and bounded; a closed subset of a compact set is compact.

  • Heine–Borel: a subset of ℝⁿ is compact if and only if it is closed and bounded.
  • Bolzano–Weierstrass: every bounded sequence in ℝⁿ has a convergent subsequence; equivalently every bounded infinite subset of ℝⁿ has a limit point.
  • A continuous image of a compact set is compact, so a continuous real function on a compact set is bounded and attains its maximum and minimum.
⚠️ Heine–Borel is a theorem about ℝⁿ
In ℓ² the closed unit ball is closed and bounded but not compact: the unit vectors eₙ satisfy ‖eₙ − eₘ‖ = √2 for n ≠ m, so no subsequence is Cauchy. The same happens in C[0, 1] with the sup norm. In fact the closed unit ball of a normed space is compact exactly when the space is finite-dimensional (Riesz). In a discrete metric space an infinite set is closed and bounded and never compact.

3. Connectedness

X is connected if it is not the union of two disjoint non-empty open sets; path-connected if any two points are joined by a continuous path. The connected subsets of ℝ are exactly the intervals. Continuous images of connected sets are connected — the intermediate value theorem is the case X = [a, b] — and the closure of a connected set is connected. Path-connected implies connected; open connected subsets of ℝⁿ are path-connected.

  • Topologist’s sine curve: S = {(x, sin(1/x)) : 0 < x ≤ 1} ∪ ({0} × [−1, 1]) is connected (the closure of a connected graph) but not path-connected.
  • ℚ and ℝ ∖ ℚ are totally disconnected: their only connected subsets are points.
  • Cut points: removing a point disconnects ℝ but not ℝ², so ℝ and ℝ² are not homeomorphic; [0, 1) and (0, 1) are not homeomorphic either, since removing 0 from [0, 1) leaves it connected.

4. The Baire category theorem

A set is nowhere dense if its closure has empty interior. Baire: in a non-empty complete metric space, a countable intersection of dense open sets is dense; equivalently, the space is not a countable union of nowhere dense sets (it is of the second category in itself).

  • A non-empty complete metric space with no isolated points is uncountable: otherwise it would be the countable union of its singletons, each nowhere dense. This proves ℝ is uncountable.
  • ℚ is not a Gδ subset of ℝ (not a countable intersection of open sets), so no function f: ℝ → ℝ is continuous exactly on ℚ; Thomae’s function is continuous exactly on the irrationals.
  • Baire is the engine of functional analysis: the uniform boundedness principle and the open mapping theorem are both proved from it.

5. Continuity and uniform continuity

f: X → Y is uniformly continuous if for every ε > 0 there is one δ > 0 with d(f(x), f(y)) < ε whenever d(x, y) < δ, the same δ for all x. Heine–Cantor: a continuous function on a compact metric space is uniformly continuous. Lipschitz ⇒ uniformly continuous ⇒ continuous, and uniformly continuous maps send Cauchy sequences to Cauchy sequences. A function on a bounded interval (a, b) is uniformly continuous exactly when it extends continuously to [a, b].

Standard verdicts
Function and domainUniformly continuous?Reason
x² on ℝnoxₙ = n, yₙ = n + 1/n: |f(yₙ) − f(xₙ)| = 2 + 1/n² ↛ 0
√x on [0, ∞)yes, but not Lipschitz|√x − √y| ≤ √|x − y|; slope unbounded at 0
sin(1/x) on (0, 1)nono continuous extension to 0
x sin(1/x) on (0, 1)yesextends continuously by 0 at x = 0
1/x on (0, 1)nomaps the Cauchy sequence 1/n to n

6. The contraction mapping principle

Banach fixed-point theorem. Let (X, d) be a non-empty complete metric space and T: X → X with d(Tx, Ty) ≤ k d(x, y) for all x, y and a fixed k < 1. Then T has exactly one fixed point x∗, the iterates xₙ₊₁ = Txₙ converge to it from any x₀, and d(xₙ, x∗) ≤ kⁿ d(x₁, x₀)/(1 − k). On an interval, a C¹ map into itself with |T′| ≤ k < 1 is a contraction by the mean value theorem.

Remove a hypothesis and the conclusion fails
Hypothesis removedCounterexample
completenessT(x) = x/2 on (0, 1]: a contraction with no fixed point in (0, 1]
a uniform k < 1T(x) = x + 1/x on [1, ∞): |Tx − Ty| = |x − y|(1 − 1/(xy)) < |x − y| for x ≠ y, yet Tx = x has no solution
T maps X into XT(x) = x/2 + 1 on [0, 1] has fixed point 2, outside [0, 1]
🧠 Counting iterations from the a priori bound
T(x) = (1 + x²)/4 maps [0, 1] into [1/4, 1/2] with |T′(x)| = x/2 ≤ 1/2, so k = 1/2. From x₀ = 0, x₁ = 1/4, and the bound is (1/2)ⁿ · (1/4)/(1/2) = (1/2)ⁿ⁺¹. To guarantee an error at most 10⁻³ we need 2ⁿ⁺¹ ≥ 1000, i.e. n ≥ 9. The fixed point is 2 − √3 ≈ 0.268, the root of x² − 4x + 1 = 0 in [0, 1].

Key takeaways

  • Complete means every Cauchy sequence converges; closed subsets of complete spaces are complete, and ℚ, (0, 1) and (C[0, 1], L¹ metric) are the standard incomplete spaces.
  • In a metric space compact ⇔ sequentially compact ⇔ complete and totally bounded; closed and bounded suffices only in ℝⁿ.
  • Connected subsets of ℝ are intervals; path-connected ⇒ connected, and the topologist’s sine curve breaks the converse.
  • Baire: a complete metric space is not a countable union of nowhere dense sets, so a perfect complete space is uncountable.
  • A contraction on a complete space has a unique fixed point with error ≤ kⁿd(x₁, x₀)/(1 − k); without completeness or a uniform k < 1 it can have none.

Practice questions (13)

Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.

  1. Which of the following metric spaces, with the metric stated, are complete?

    1. ℚ with d(x, y) = |x − y|
    2. C[0, 1] with d(f, g) = sup |f(x) − g(x)|
    3. (0, 1) with d(x, y) = |x − y|
    4. ℤ with d(x, y) = |x − y|
    Show answer

    Answer: B — C[0, 1] with d(f, g) = sup |f(x) − g(x)|; D — ℤ with d(x, y) = |x − y|

    (1) The truncations 1, 1.4, 1.41, … of √2 are Cauchy in ℚ with no limit in ℚ. (2) A uniformly Cauchy sequence of continuous functions converges uniformly, and the limit is continuous. (3) 1/n is Cauchy with limit 0 ∉ (0, 1). (4) If |xₘ − xₙ| < 1 for m, n ≥ N then the integers are equal, so a Cauchy sequence in ℤ is eventually constant.
  2. Which of the following subsets of ℝ² are compact?

    1. {(x, y) : x² + y² ≤ 1}
    2. {(x, y) : xy = 1}
    3. {(x, sin(1/x)) : 0 < x ≤ 1}
    4. {(x, y) : x⁴ + y⁴ = 1}
    Show answer

    Answer: A — {(x, y) : x² + y² ≤ 1}; D — {(x, y) : x⁴ + y⁴ = 1}

    Heine–Borel: compact ⇔ closed and bounded. (1) is closed and bounded. (2) is closed but unbounded (x → ∞). (3) is bounded but not closed: (0, 0) is a limit point not in the set, since sin(1/x) = 0 at x = 1/(nπ). (4) is closed (a level set of a continuous function) and bounded (|x|, |y| ≤ 1).
  3. In the Hilbert space ℓ² of square-summable real sequences, the closed unit ball {x : ‖x‖ ≤ 1} is

    1. closed and bounded but not compact
    2. compact, by the Heine–Borel theorem
    3. not closed
    4. compact but not complete
    Show answer

    Answer: A — closed and bounded but not compact

    The ball is closed and bounded, but the unit vectors eₙ lie in it with ‖eₙ − eₘ‖ = √2 for n ≠ m, so (eₙ) has no Cauchy, hence no convergent, subsequence and the ball is not sequentially compact. Heine–Borel is special to ℝⁿ; the ball is complete, being closed in a complete space.
  4. Which statements hold in every metric space?

    1. every compact subset is closed and bounded
    2. every closed and bounded subset is compact
    3. a sequentially compact metric space is complete
    4. a complete and totally bounded metric space is compact
    Show answer

    Answer: A — every compact subset is closed and bounded; C — a sequentially compact metric space is complete; D — a complete and totally bounded metric space is compact

    (1) is true in any metric space (Hausdorff, and finitely many unit balls cover a compact set). (3) A Cauchy sequence with a convergent subsequence converges. (4) is the metric characterisation of compactness. (2) fails in ℓ² (the unit ball) and in any infinite discrete space, where every set is closed and bounded.
  5. Which subset of ℝ, with the usual topology, is connected?

    1. [0, ∞)
    2. [0, 1] ∪ [2, 3]
    3. ℚ
    4. ℝ ∖ {0}
    Show answer

    Answer: A — [0, ∞)

    The connected subsets of ℝ are exactly the intervals, and [0, ∞) is an interval. [0, 1] ∪ [2, 3] and ℝ ∖ {0} each split into two disjoint relatively open pieces, and ℚ is totally disconnected: (−∞, √2) and (√2, ∞) separate it.
  6. Which statements are true?

    1. a continuous image of a connected space is connected
    2. the closure of a connected subset of a metric space is connected
    3. every connected subset of ℝ² is path-connected
    4. ℝ and ℝ² are homeomorphic
    Show answer

    Answer: A — a continuous image of a connected space is connected; B — the closure of a connected subset of a metric space is connected

    (1) A separation of f(X) pulls back to a separation of X. (2) If cl A = U ∪ V is a separation, A lies wholly in one piece, whose closure then misses the other. (3) is false: the topologist’s sine curve is connected and not path-connected. (4) is false: ℝ minus a point is disconnected, ℝ² minus a point is not.
  7. The number of connected components of the set {x ∈ ℝ : x² − 3x + 2 ≠ 0} is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 3

    x² − 3x + 2 = (x − 1)(x − 2) vanishes at 1 and 2, so the set is ℝ ∖ {1, 2} = (−∞, 1) ∪ (1, 2) ∪ (2, ∞), three disjoint open intervals, each connected. Removing k points from ℝ leaves k + 1 components.
  8. Which of the following is a consequence of the Baire category theorem?

    1. a non-empty complete metric space with no isolated points is uncountable
    2. every bounded sequence in ℝ has a convergent subsequence
    3. every continuous function on [0, 1] is uniformly continuous
    4. every closed and bounded subset of ℝⁿ is compact
    Show answer

    Answer: A — a non-empty complete metric space with no isolated points is uncountable

    If such a space were countable it would be the countable union of its singletons; each singleton is closed with empty interior (no isolated points), hence nowhere dense, contradicting Baire. The other three are Bolzano–Weierstrass, Heine–Cantor and Heine–Borel, which need no category argument.
  9. Which of the following functions are uniformly continuous on the stated domain?

    1. f(x) = x² on [0, ∞)
    2. f(x) = √x on [0, ∞)
    3. f(x) = sin(1/x) on (0, 1)
    4. f(x) = x sin(1/x) on (0, 1)
    Show answer

    Answer: B — f(x) = √x on [0, ∞); D — f(x) = x sin(1/x) on (0, 1)

    (1) No: with xₙ = n and yₙ = n + 1/n, |yₙ − xₙ| → 0 but |yₙ² − xₙ²| = 2 + 1/n². (2) Yes: |√x − √y| ≤ √|x − y|. (3) No: it has no continuous extension to [0, 1]. (4) Yes: setting f(0) = 0 and f(1) = sin 1 gives a continuous function on the compact [0, 1] (Heine–Cantor).
  10. The sequence x₀ = 1, xₙ₊₁ = 1 + 1/(1 + xₙ) converges. Its limit, correct to two decimal places, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 1.41

    T(x) = 1 + 1/(1 + x) maps [1, 2] into [4/3, 3/2] and |T′(x)| = 1/(1 + x)² ≤ 1/4 there, so T is a contraction of the complete space [1, 2] and the iterates converge to its fixed point: x(1 + x) = (1 + x) + 1 gives x² = 2, x = √2 = 1.414, i.e. 1.41.
  11. Let T(x) = (1 + x²)/4 on [0, 1], x₀ = 0 and xₙ₊₁ = T(xₙ). Using the a priori estimate d(xₙ, x∗) ≤ kⁿ d(x₁, x₀)/(1 − k) with the best Lipschitz constant k of T on [0, 1], the least n that guarantees d(xₙ, x∗) ≤ 10⁻³ is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 9

    T′(x) = x/2, so k = sup |T′| = 1/2 on [0, 1], and T([0, 1]) = [1/4, 1/2] ⊆ [0, 1]. x₁ = 1/4, so the bound is (1/2)ⁿ(1/4)/(1/2) = (1/2)ⁿ⁺¹. We need 2ⁿ⁺¹ ≥ 1000: 2¹⁰ = 1024 works and 2⁹ = 512 does not, so n + 1 = 10 and n = 9.
  12. Which statements about fixed points are true?

    1. T(x) = x + 1/x on [1, ∞) satisfies |Tx − Ty| < |x − y| for x ≠ y and has no fixed point
    2. T(x) = x/2 on (0, 1] is a contraction with no fixed point in (0, 1]
    3. every contraction of a non-empty complete metric space has exactly one fixed point
    4. if T² is a contraction of a complete metric space, then T has no fixed point
    Show answer

    Answer: A — T(x) = x + 1/x on [1, ∞) satisfies |Tx − Ty| < |x − y| for x ≠ y and has no fixed point; B — T(x) = x/2 on (0, 1] is a contraction with no fixed point in (0, 1]; C — every contraction of a non-empty complete metric space has exactly one fixed point

    (1) Tx − Ty = (x − y)(1 − 1/(xy)) with 0 ≤ 1 − 1/(xy) < 1, and x + 1/x = x is impossible; the ratio tends to 1, so no uniform k < 1 exists. (2) (0, 1] is not complete; the fixed point 0 is missing. (3) is Banach’s theorem. (4) is false: if T²x∗ = x∗ uniquely, then T²(Tx∗) = T(T²x∗) = Tx∗, so Tx∗ = x∗ and T has a (unique) fixed point.
  13. Which statement about f(x) = x² on ℝ is correct?

    1. f is continuous but not uniformly continuous on ℝ, though it is uniformly continuous on every bounded interval
    2. f is uniformly continuous on ℝ because it is differentiable
    3. f is Lipschitz on ℝ
    4. f maps some Cauchy sequence of reals to a non-Cauchy sequence
    Show answer

    Answer: A — f is continuous but not uniformly continuous on ℝ, though it is uniformly continuous on every bounded interval

    On [−M, M], |x² − y²| ≤ 2M|x − y|, so f is Lipschitz there; on ℝ the slope 2x is unbounded and xₙ = n, yₙ = n + 1/n defeat every δ. Differentiability does not give uniform continuity. Cauchy sequences in ℝ are bounded and f is uniformly continuous on bounded sets, so it maps them to Cauchy sequences.