The chapter describes a mathematical theory of sapience and consciousness: higher mental abilities including abilities for concepts, emotions, instincts, understanding, imagination, intuition, beauty, and sublimity. The knowledge instinct drives our understanding of the world. Aesthetic emotions, our needs for beauty and sublimity, are related to the knowledge instinct. I briefly discuss neurobiological grounds as well as difficulties encountered since the 1950s by previous attempts at mathematical modeling of the mind. Dynamic logic, the mathematics of the knowledge instinct, is related to cognitive and philosophical discussions about the mind and sapience.