The 20th century witnessed a major revolution in the mathematics of computation and logic. This revolution was, of course, prepared by the work of the 19th century British mathematician George Boole, the inventor of what has come to be called Boolean Logic or Boolean Algebra. Boole's work showed that logic, itself, which had first been studied systematically by Aristotle, could be considered as an area of mathematical computation.
In the 20th century, the work of Alan Turing and Alonzo Church, et. al., systematically characterized the computability of logic. In particular, Alan Turing proved that their does not exist a general algorithm for determining whether any given program will come to a halt on a given input, or run forever on that input.
When this result is applied to the special case of a computer program intended to determine the validity or truth-value of a given proposition (expressed in a generalization of Boolean logic known as predicate logic), the conclusion is a special case of Godel's Incompleteness Theorem, so that Turing found a deep relationship between computer computation and general mathematical logic.
I bring this up because it seems to me there is a kind of "halting problem" in the area of the philosophical notion of ultimate justice (note: it seems that there is no philosophical treatment of this concept on Wikipedia; the article on the so-called "just world hypothesis" treats only the psychological and positivist perspectives). It arises in the consideration of human free will, reincarnation and the ultimate decision between good and evil.
Consider a series of reincarnations of a given human spirit, endowed with a capacity to choose between good and evil. In the theory of reincarnation, a spirit that continually chooses evil simply continues to reincarnate in a lower form. One can think of this concretely as a soul that, as a human being (with a human body as well as a soul capable of moral choice) ends a given life in a state of evil, and is reincarnated, say, as a slug. This slug eventually dies, and the soul is reincarnated as, say, a grasshopper. This grasshopper dies and the soul reincarnates as a frog, etc., so that the soul eventually works its way back up to reincarnate as a human being. While in the new human body the soul again chooses evil and starts the cycle all over again.
One of the reasons human beings came to contemplate the notion of reincarnation, it seems to me, is the inability to tolerate the notion of ultimate perdition. That is to say, the irretrievable loss of a human soul is too horrible to contemplate, and so the notion of reincarnation was invented to give even the most evil of us another chance.
Obviously, a human being, with the capacity for moral choice, is, by definition, not reducible to a computational function in the sense of Turing or Church. Nevertheless, there is an interesting analogy here between the soul that never halts (but keeps reincarnating) and a computer program that never halts. Such a soul, it seems to me, lives what can only be described as a kind of hell, forever lived in estrangement from ultimate good. In effect, it receives ultimate justice for a life of evil. In other words, it suffers perdition, so that the notion of reincarnation does not effectively deny perdition.
In Catholic moral theology, a human soul is only in a state of mortal sin when it is incapable of choosing moral good. This idea, of course, needs to be qualified. It only makes sense in the context of a consideration of motive. It can be stated more precisely by saying that a morally dead soul cannot choose good from a good motive. Even if God always chose to reincarnate a soul that had failed to choose ultimate good during its life, there would still be the problem of the morally dead soul that, no matter how many times it was reincarnated, it would not choose to live a good life, so that even God could not save it.
From God's perspective, then, it would seem obvious that reincarnation doesn't solve the problem of saving a soul that has chosen not to be saved.
This brings us to a consideration of the fate of the angels. As purely spiritual beings, their choice between good and evil is simultaneously existential and decisive. That is to say, it is not something arrived at "over time." Their choice is made on the basis of perfect knowledge about the choice.
A soul that eternally reincarnates never achieves perfect knowledge of the choice between good and evil because it is always limited to carnate, and therefore inherently defective, cognition. Once freed from the body, however, a soul meets God, and ultimate knowledge of the choice that it faces. That choice, of course, is conditioned in some way by the choices it has made during its life. If, during its life, it has decisively chosen evil, a choice that can be made in the absence of knowledge of ultimate good, it is no longer capable of choosing good and it must suffer perdition.
There is no logical reason, then, to assume that God cannot determine a just solution to the problem of a soul's ultimate destination given its experience with only one lifetime, because the problem of ultimate fate reduces to the problem of the fate of the angels and the problem of the possibility of making an ultimate choice between good and evil based upon incomplete knowledge.
One further hypotheses is needed to resolve the question of God's justice, however, and that is that God intervenes, whenever necessary, to ensure that a soul has sufficient knowledge to make the ultimate choice between good and evil. We need not assume that the soul receives that knowledge prior to death, but only that it always receives that knowledge prior to its choice of ultimate evil. In effect, when a soul is about to choose evil, God intervenes. This realization gives an existential perspective to the biblical story of Cain and Abel in Genesis 4.