The ability to predict is the most important ability of the brain. Somehow, the cortex is able to extract regularities from the environment and use those regularities as a basis for prediction. This is a most remarkable skill, considering that behaviourally significant environmental regularities are not easy to discern: they operate not only between pairs of simple environmental conditions, as traditional associationism has assumed, but among complex functions of conditions that are orders of complexity removed from raw sensory inputs. We propose that the brain's basic mechanism for discovering such complex regularities is implemented in the dendritic trees of individual pyramidal cells in the cerebral cortex. Pyramidal cells have 5-8 principal dendrites, each of which is capable of learning nonlinear input to- output transfer functions. We propose that each dendrite is trained, in learning its transfer function, by all the other principal dendrites of the same cell. These dendrites teach each other to respond to their separate inputs with matching outputs. Exposed to different but related information about the sensory environment, principal dendrites of the same cell tune to functions over environmental conditions that, while different, are correlated. As a result, the cell as a whole tunes to the source of the regularities discovered by the cooperating dendrites, creating a new representation. When organized into feedforward/ feedback layers, pyramidal cells can build their discoveries on the discoveries of other cells, gradually uncovering nature's hidden order. The resulting associative network is powerful enough to meet a troubling traditional objection to associationism: that it is too simple an architecture to implement rational processes.