Theory of nuclear reactions: II. The foundation of the optical model