We develop a general approximation scheme for calculating quantum
informational properties of a pure state that has equilibrated in a
non-integrable quantum many-body system. For gravity systems, such as
those involving black holes, this approximation gives a prescription for
calculating entanglement entropies using Euclidean path integrals which
is manifestly consistent with unitarity. Applied to recent models of
evaporating black holes and eternal black holes coupled to baths, it
provides a derivation of replica wormholes, and elucidates their
mathematical and physical origins. In particular, it shows that replica
wormholes can arise in a system with a fixed Hamiltonian, without the
need for ensemble averages.