Die Traumdeutung
Freud used the idea that the mind seeks pleasure and avoids pain in his "Project for a Scientific Psychology" of 1895, as well as in the theoretical portion of "The Interpretation of Dreams" of 1900, where he termed it the 'unpleasure principle'.