(0) Obligation:
JBC Problem based on JBC Program:
/**
* The classical recursive definition of factorial.
*
* All calls terminate.
*
* Julia + BinTerm prove that all calls terminate
*
* Note that we have to express the basic case as n < 0
* in order to prove termination.
*
* @author <A HREF="mailto:fausto.spoto@univr.it">Fausto Spoto</A>
*/
public class Factorial {
public static int factorial(int n) {
if (n < 0) return 1;
else return n * factorial(n - 1);
}
public static void main(String[] args) {
factorial(10);
}
}
(1) JBCToGraph (SOUND transformation)
Constructed TerminationGraph.
(2) Obligation:
Termination Graph based on JBC Program:
Factorial.main([Ljava/lang/String;)V: Graph of 131 nodes with 0 SCCs.
(3) TerminationGraphToSCCProof (SOUND transformation)
Proven termination by absence of SCCs
(4) TRUE