Simulate Hilbert's Hotel thought experiment — accommodate new guests in a fully-occupied infinite hotel and explore cardinal arithmetic interactively.
Hilbert's Hotel is one of the most famous thought experiments in mathematics. Proposed by the German mathematician David Hilbert in the 1920s, it illustrates the counter-intuitive properties of infinite sets. Imagine a hotel with infinitely many rooms — one for every natural number — and every room is occupied. A new guest arrives. Can the hotel accommodate them?
Surprisingly, the answer is yes. The manager simply asks every existing guest to move from room n to room n + 1, freeing room 1 for the newcomer. In fact, this trick extends far beyond a single guest: the hotel can accommodate any finite number of new guests, a countably infinite bus of passengers, or even countably many infinite buses — all without anyone leaving.
This simulator lets you explore each scenario step by step. Watch existing guests shift rooms, see new guests fill in the gaps, and trace the bijection that makes it all work. The tool also covers the one scenario that *fails*: when uncountably many guests arrive, Cantor's diagonal argument proves that no rearrangement can make room for everyone. It is a vivid demonstration of the difference between ℵ₀ and 𝔠.
Hilbert's Hotel is a cornerstone example in set theory and mathematical logic courses. However, reading about room reassignment in a textbook can feel abstract. This interactive simulator makes the bijections concrete — you see which guest moves where, watch the color-coded room cards rearrange, and verify that every room ends up occupied.
Whether you are a student preparing for a discrete mathematics exam, a teacher building a lecture demonstration, or a curious mind exploring the nature of infinity, this tool turns an abstract paradox into a tangible, explorable experience.
1 guest: f(n) = n + 1. n guests: f(n) = n + k. Infinite bus: existing f(n) = 2n, new g(k) = 2k − 1. K buses: use prime powers f_j(n) = p_j^n. Cardinal arithmetic: ℵ₀ + ℵ₀ = ℵ₀, ℵ₀ × ℵ₀ = ℵ₀, 2^ℵ₀ = 𝔠 > ℵ₀.
Result: All ∞ bus passengers accommodated
Existing guest n moves to room 2n (even rooms). Bus passenger k goes to room 2k−1 (odd rooms). Every natural number is either even or odd, so every room is filled exactly once.
Hilbert's Hotel rests on a simple but profound truth: a countably infinite set can be put in bijection with a proper subset of itself. This is, in fact, the *definition* of an infinite set (Dedekind's criterion). The natural numbers ℕ = {1, 2, 3, …} are countably infinite, and the hotel's rooms are in bijection with ℕ. Any operation that produces another countable set from ℕ (shifting, doubling, prime-power encoding) preserves countability, so the rearranged hotel still has exactly one guest per room.
When uncountably many guests arrive — say, one for every real number between 0 and 1 — no room-assignment function works. Cantor's diagonal argument constructs a real number that differs from the guest in room n at the nth decimal digit, proving it cannot appear anywhere in the list. This is the fundamental result that 2^ℵ₀ = 𝔠 > ℵ₀.
Hilbert's Hotel has analogs throughout mathematics. In functional analysis, an infinite-dimensional Hilbert space has the property that removing a finite-dimensional subspace leaves a space of the same dimension. In computability theory, the set of all computable functions is countable, while the set of all functions is not — echoing the hotel's countable-vs-uncountable divide. The paradox also connects to Zermelo-Fraenkel set theory and the Axiom of Choice, which is needed to handle some of the more exotic rearrangement scenarios.
A thought experiment by David Hilbert illustrating properties of infinite sets: a fully-occupied hotel with infinitely many rooms can still accommodate new guests through clever reassignment. Use this as a practical reminder before finalizing the result.
Because the hotel has ℵ₀ rooms, shifting guests by a finite or countable amount still leaves ℵ₀ rooms. In infinite arithmetic, ℵ₀ + n = ℵ₀ and ℵ₀ + ℵ₀ = ℵ₀.
They cannot be accommodated. Cantor's diagonal argument proves no bijection exists between the real numbers (cardinality 𝔠) and the naturals (cardinality ℵ₀).
Each bus is assigned a unique prime p. Passenger n from that bus gets room p^n. Since prime powers are all distinct, no two passengers share a room.
Absolutely — Hilbert's Hotel illustrates concepts central to set theory, topology, and functional analysis. It's a standard teaching tool in university math courses.
ℵ₀ (aleph-null) is the cardinality of the set of all natural numbers. It is the smallest infinite cardinal number.