“I explained earlier that the ruling of Paul IV mentioned above [that the election of a heretic is invalid] is founded on the doctrinal principle that a heretic per se is an incapable subject of the papacy; and since no specific divine precept prescribing a remedy for the case of papal heresy can be found in divine revelation, we have what is a certain proof from reason that a pope cannot fall into formal heresy: It would contradict the divine wisdom if God were to permit that the Church should be ruled and governed by an illegitimate pastor and heretical destroyer of the Church, without prescribing any clear and infallible remedy for what Bordoni rightly calls the necessitas maxima of such a catastrophe of there being a pope, who exhibits the indicia of pertinacity in formal heresy, or in his words and actions exhibits the indicia of the gravest suspicion of heresy, without there being in place by divine institution an infallible juridical remedy to prevent the heretic from destroying the Church. The only remedy that does exist is the one prescribed by Paul IV — which is the same as what the medieval canonists referred to as an exceptio. This remedy could be practically applied to ferret out the heretic and expose his pertinacity by means of dubia, formal correction; and finally a declaratory sentence of heresy, nullity, and vacancy. By this means it would be proven that the ‘pope’ in question from the time he was elected was never a valid holder of the Petrine office.”
Kramer, Paul. On the true and the false pope: The case against Bergoglio (pp. 285-286). Gondolin Press. Kindle Edition.