# Back-and-forth method

In mathematical logic, especially set theory and model theory, the back-and-forth method is a method for showing isomorphism between countably infinite structures satisfying specified conditions. In particular it can be used to prove that
* any two countably infinite densely ordered sets (i.e., linearly ordered in such a way that between any two members there is another) without endpoints are isomorphic. An isomorphism between linear orders is simply a strictly increasing bijection. This result implies, for example, that there exists a strictly increasing bijection between the set of all rational numbers and the set of all real algebraic numbers.
* any two countably infinite atomless Boolean algebras are isomorphic to each other.
* any two equivalent countable atomic models of a theory are isomorphic.
* the Erdős–Rényi model of random graphs, when applied to countably infinite graphs, almost surely produces a unique graph, the Rado graph.
* any two many-complete recursively enumerable sets are recursively isomorphic.

## Application to densely ordered sets

As an example, the back-and-forth method can be used to prove Cantor's isomorphism theorem, although this was not Georg Cantor's original proof. This theorem states that two unbounded countable dense linear orders are isomorphic.
Suppose that
* (A, ≤$_A$) and (B, ≤$_B$) are linearly ordered sets;
* They are both unbounded, in other words neither A nor B has either a maximum or a minimum;
* They are densely ordered, i.e. between any two members there is another;
* They are countably infinite.
Fix enumerations (without repetition) of the underlying sets:
    A = { a$_1$, a$_2$, a$_3$, ... },
    B = { b$_1$, b$_2$, b$_3$, ... }.
Now we construct a one-to-one correspondence between A and B that is strictly increasing. Initially no member of A is paired with any member of B.
    (1) Let i be the smallest index such that a$_i$ is not yet paired with any member of B. Let j be some index such that b$_j$ is not yet paired with any member of A and a$_i$ can be paired with b$_j$ consistently with the requirement that the pairing be strictly increasing. Pair a$_i$ with b$_j$.
    (2) Let j be the smallest index such that b$_j$ is not yet paired with any member of A. Let i be some index such that a$_i$ is not yet paired with any member of B and b$_j$ can be paired with a$_i$ consistently with the requirement that the pairing be strictly increasing. Pair b$_j$ with a$_i$.
    (3) Go back to step (1).
It still has to be checked that the choice required in step (1) and (2) can actually be made in accordance to the requirements. Using step (1) as an example:
If there are already a$_p$ and a$_q$ in A corresponding to b$_p$ and b$_q$ in B respectively such that a$_p$ < a$_i$ < a$_q$ and b$_p$ < b$_q$, we choose b$_j$ in between b$_p$ and b$_q$ using density. Otherwise, we choose a suitable large or small element of B using the fact that B has neither a maximum nor a minimum. Choices made in step (2) are dually possible. Finally, the construction ends after countably many steps because A and B are countably infinite. Note that we had to use all the prerequisites.

## History

According to Hodges (1993):
    Back-and-forth methods are often ascribed to Cantor, Bertrand Russell and C. H. Langford [...], but there is no evidence to support any of these attributions.
While the theorem on countable densely ordered sets is due to Cantor (1895), the back-and-forth method with which it is now proved was developed by Edward Vermilye Huntington (1904) and Felix Hausdorff (1914). Later it was applied in other situations, most notably by Roland Fraïssé in model theory.