Spouse, do you not know your theology yet?
By the heart we believe and by the mouth we confess THE ONE
CHURCH, NOT OF HERETICS, but the Holy Roman, Catholic, and
Apostolic Church outside of which we believe that no one is saved.
If a validly elected pope promulgates heresy, he loses all rights as the supreme shepherd of the flock, is no longer Catholic and becomes an ANTIPOPE.
If he declares that something which is immoral is actually moral (like if he says, "Oh it's actually okay to commit fornication, or to steal - OR TO PRAY WITH APOSTATES AND INFIDELS"), then he is likewise teaching heresy, and loses office.