Confabulation theory offers the first complete detailed explanation of the mechanism of cognition, i.e., thinking, an essential information processing capability of all enbrained Earth animals (bees, octopi, trout, ravens, humans, et al.). Concentrating on the human case, this book offers an hypothesis for the neuronal implementation of cognition, and explores the mathematics and methods of application of its mechanism. Thinking turns out to be starkly alien in comparison with all known technological approaches to information processing. While probably not yet scientifically testable, confabulation theory seems consistent with the facts of neuroscience. Beyond science, any complete detailed explanation of cognition can be investigated by applying it technologically. Multiple experiments of this nature are described in this book in complete detail. The results suggest that confabulation theory can provide the universal platform for building intelligent machines. In short, this book explains how thinking works and establishes the foundation for building machines that think.