The premise of the series is that mathematician Hari Seldon spent his life developing a branch of mathematics known as psychohistory, a concept of mathematical sociology (analogous to mathematical physics). Using the law of mass action, it can predict the future, but only on a large scale; it is error-prone on a small scale. It works on the principle that the behaviour of a mass of people is predictable if the quantity of this mass is very large (equal to the population of the galaxy, which has a population of quadrillions of humans, inhabiting millions of star systems). The larger the number, the more predictable is the future.
Using these techniques, Seldon foresees the imminent fall of the Galactic Empire, which encompasses the entire Milky Way, and a dark age lasting thirty thousand years before a second great empire arises. Seldon's psychohistory also foresees an alternative where the intermittent period will only last one thousand years. To ensure Seldon's vision of a second great Empire comes to fruition, Seldon creates two Foundations - small, secluded havens of all human knowledge - at "opposite ends of the galaxy".