We propose a mathematical model of the process of thinking based on dynamical systems over a configuration space of ideas. These dynamical systems are assumed to be located in the human subconscious and are controlled by the human conscious which fixes parameters of the dynamical systems in the subconscious and transmits to the subconscious generating ideas which initiate iterations of the dynamical systems in the subconscious. Thus, we present the mathematical model which is not based on the rule of reason. Mathematically the space of ideas is described by so-called p-adic numbers. In fact, a p-adic metric on the space of ideas corresponds to the following nearness between ideas: two ideas x and y are close if they have sufficiently long common root. Already the simplest p-adic dynamical systems might describe some sides of human psychological and social behaviour.