Logic as the outcome of an evolutionary process