Foundations of Psychohistory