“In the case in which the pope would become a heretic, he would find himself, by that fact alone and without any other sentence, separated from the Church. A head separated from a body cannot, as long as it remains separated, be head of the same body from which it was cut off.
“A pope who would be separated from the Church by heresy, therefore, would by that very fact itself cease to be head of the Church. He could not be a heretic and remain pope, because, since he is outside of the Church, he cannot possess the keys of the Church.”
(Summa Theologica, cited in Actes de Vatican I. V. Frond pub.)