Owing to the complexity of neuronal circuits, precise mathematical descriptions of brain functions remain an elusive ambition. A more modest focus of many neuroscientists, central pattern generators, are more tractable neuronal circuits specialized to generate rhythmic movements, including locomotion. The relative simplicity and welldefined motor functions of these circuits provide an opportunity for uncovering fundamental principles of neuronal information processing. Here we present the culmination of mathematical analysis that captures the adaptive behaviors emerging from interactions between a central pattern generator, the body, and the physical environment during locomotion. The biologically realistic model describes the undulatory motions of swimming leeches with quantitative accuracy and, without further parameter tuning, predicts the sweeping changes in oscillation patterns of leeches undulating in air or swimming in high-viscosity fluid. The study demonstrates that central pattern generators are capable of adapting oscillations to the environment through sensory feedback, but without guidance from the brain.A long-term ambition in neuroscience is to generate a detailed, complete model of the human brain (1). Still ambitious, and certainly more realistic, is the aim to model components of vertebrate nervous systems. Most advanced in this arena are models based on the circuits underlying motor functions, such as rhythmic body movements during locomotion. These movements are generated by spinal neural oscillator circuits called central pattern generators (CPGs) (2, 3). The enormous number of neurons in the vertebrate central nervous system currently prevents analysis at the level of defined circuits between individual neurons. However, the simpler, accessible CPGs underlying locomotion in the invertebrates provide dynamically rich platforms amenable to detailed analysis that can lead to deep understanding of how neuronal circuits generate extremely robust and adaptive oscillatory behaviors. The leech CPG for undulatory swimming provides such a platform. The isolated nerve cord, with most (4, 5), a few (6, 7), or even a single segmental ganglion (8, 9), displays "fictive swimming," where the rhythmic motor pattern closely resembles that recorded in intact animals. Moreover, the leech continues to swim without the brain (10, 11), with the nerve cord severed in midbody (5), or with the body cut in half (7).Our study addresses the following question: How does the leech swimming system achieve its astonishing robustness and adaptability? A detailed explanation of the mechanisms underlying such complex phenomena requires mathematical modeling and analysis because a unidirectional sequence of cause-andeffect relationships alone cannot explain dynamical properties arising from multiple feedback loops. An obstacle in exploring the emergence of the functional properties from highly interconnected neuronal circuits through model-based analysis is the lack of biological realism (1). We, therefore, have focused on the...