The emergence of thinking in systems