Cognitive flexibility allows us to adjust behavior when environmental rules change and to recombine prior knowledge in novel situations. However, the computations underlying rule discovery remain unclear: how do rule representations emerge as we interact with the environment? While it is often considered a hallmark of human behavior, converging evidence highlights comparable forms of abstract learning in rodents. Across species, prefrontal activity patterns encode structured representations that support generalization and monitor for rule switches. In this review, we synthesize recent behavioral, neural, and computational work highlighting models that formalize rule inference and creation. We consider how a translational framework linking circuit-level mechanisms to computational principles can help us understand disruptions in cognitive flexibility in disorders such as schizophrenia.