Mathematics of the mind