The way you're thinking about things is very natural in the realm of computers and math, but insane in life at large.
We do not follow universal, perfect rules. Humans make judgements on what is appropriate or not based on preference.
It would be perfectly in keeping with sanity and normal behavior to decide something is worth the regrettable extinction of an intelligent species, while maintaining actual codes of morality.