There are set formulas for defining infallibility in a Papal Bull (the declaration of infallible doctines, aka dogmas, if proclaimed by the pope, usually are set forth in bulls, the strongest form of a papal declaration). The dogma is clearly defined in the bull. Take, for example, the bull of Boniface VIII “Unam Sanctam”, in which the supreme authority of the Roman Pope is defined:
[quote=Boniface VIII, “Unam Sanctam”]…we declare, we proclaim, we define that it is absolutely necessary for salvation that every human creature be subject to the Roman Pontiff.
and another example from Pius XII who defined the Dogma of the Assumption
[quote=Pius XII, “Munificentissimus Deus”]…by the authority of our Lord Jesus Christ, of the Blessed Apostles Peter and Paul, and by our own authority, we pronounce, declare, and define it to be a divinely revealed dogma: that the Immaculate Mother of God, the ever Virgin Mary, having completed the course of her earthly life, was assumed body and soul into heavenly glory
Infallibility may also be claimed by a general council of bishops in union with the pope, in which the definition of the dogma follows a similar formula to the declarations above.
Papal infallibility only works under a certain set of conditions.
1.) The Pope is only infallible if he speaks on matters of Catholic faith and morals. Which means he can’t tell the world “Everyone should give me money or you will go to hell”, and be right.
2.) The Pope must officially declare that he is teaching infallibly by speaking ex cathedra, or from the chair (the chair of Peter). This is a symbol that the pope is teaching with the authority conferred on Peter by Christ which is passed down to each successing bishop of Rome. There are certain and set methods of officially declaring an infallible teaching, as demostrated before.
3.) There must be a spiritual punishment, known as anathema, attached to the teaching if it is to be infallible. For example:
[quote=Pius XII, Munificentissimus Deus]Hence if anyone, which God forbid, should dare willfully to deny or to call into doubt that which we have defined, let him know that he has fallen away completely from the divine and Catholic Faith.
4.) The Pope must intend for the teaching to apply to the whole Church, not certain people or places. Thus, infallibility cannot be used to target individuals or nations.
5.) The teaching which is being preached infallibly cannot contradict prior official Church teachings.
By the way, John Paul’s declaration on women priests is not ex cathedra; the issue is a matter of discipline and practice, not faith and morals. Nevertheless, it is nearly impossible for that decision to be reversed, so the practical effects of the declaration are pretty much the same as a true ex cathedra statement.
Hope this helps.