Perception and decision rely on internal models of the world. In primary sensory areas of cortex, joint activity of neural populations likely represents the statistical structure of the external environment. Unknown is whether internal neural models are a general computational principle of cortex, extending to learning, higher-order cortices, and actions. We tested that generality by examining changes of population activity patterns from rat prefrontal cortex in the course of learning rules in a maze. The statistical distributions of activity patterns converged between waking and slow-wave sleep during rule learning. Changes were greatest for patterns predicting correct choice and expressed at the choice point. Together, our results are consistent with the convergence over learning of inferred (in waking) and prior (in sleep) expectations of a task derived from an internal model. The construction and use of an internal model may be a recurring theme of cortical computation.