0 JBC
↳1 JBCToGraph (⇒, 410 ms)
↳2 JBCTerminationGraph
↳3 TerminationGraphToSCCProof (⇒, 0 ms)
↳4 JBCTerminationSCC
↳5 SCCToIntTRSProof (⇒, 48 ms)
↳6 intTRS
↳7 PolynomialOrderProcessor (⇔, 10 ms)
↳8 YES
/**
* Example taken from "A Term Rewriting Approach to the Automated Termination
* Analysis of Imperative Programs" (http://www.cs.unm.edu/~spf/papers/2009-02.pdf)
* and converted to Java.
*/
public class PastaB8 {
public static void main(String[] args) {
Random.args = args;
int x = Random.random();
if (x > 0) {
while (x != 0) {
if (x % 2 == 0) {
x = x/2;
} else {
x--;
}
}
}
}
}
public class Random {
static String[] args;
static int index = 0;
public static int random() {
String string = args[index];
index++;
return string.length();
}
}
Generated rules. Obtained 19 IRules
P rules:
f330_0_main_EQ(EOS, i52, i52) → f335_0_main_EQ(EOS, i52, i52)
f335_0_main_EQ(EOS, i52, i52) → f341_0_main_Load(EOS, i52) | >(i52, 0)
f341_0_main_Load(EOS, i52) → f352_0_main_ConstantStackPush(EOS, i52, i52)
f352_0_main_ConstantStackPush(EOS, i52, i52) → f358_0_main_IntArithmetic(EOS, i52, i52, 2)
f358_0_main_IntArithmetic(EOS, i52, i52, matching1) → f363_0_main_NE(EOS, i52, %(i52, 2)) | =(matching1, 2)
f363_0_main_NE(EOS, i52, matching1) → f367_0_main_NE(EOS, i52, 1) | =(matching1, 1)
f363_0_main_NE(EOS, i52, matching1) → f368_0_main_NE(EOS, i52, 0) | =(matching1, 0)
f367_0_main_NE(EOS, i52, matching1) → f371_0_main_Inc(EOS, i52) | &&(>(1, 0), =(matching1, 1))
f371_0_main_Inc(EOS, i52) → f375_0_main_JMP(EOS, +(i52, -1)) | >(i52, 0)
f375_0_main_JMP(EOS, i58) → f396_0_main_Load(EOS, i58)
f396_0_main_Load(EOS, i58) → f318_0_main_Load(EOS, i58)
f318_0_main_Load(EOS, i40) → f330_0_main_EQ(EOS, i40, i40)
f368_0_main_NE(EOS, i52, matching1) → f372_0_main_Load(EOS, i52) | =(matching1, 0)
f372_0_main_Load(EOS, i52) → f377_0_main_ConstantStackPush(EOS, i52)
f377_0_main_ConstantStackPush(EOS, i52) → f399_0_main_IntArithmetic(EOS, i52, 2)
f399_0_main_IntArithmetic(EOS, i52, matching1) → f740_0_main_Store(EOS, /(i52, 2)) | &&(>=(i52, 1), =(matching1, 2))
f740_0_main_Store(EOS, i137) → f742_0_main_JMP(EOS, i137)
f742_0_main_JMP(EOS, i137) → f749_0_main_Load(EOS, i137)
f749_0_main_Load(EOS, i137) → f318_0_main_Load(EOS, i137)
Combined rules. Obtained 2 IRules
P rules:
f330_0_main_EQ(EOS, x0, x0) → f330_0_main_EQ(EOS, -(x0, 1), -(x0, 1)) | &&(>(x0, 0), =(%(x0, 2), 1))
f330_0_main_EQ(EOS, x0, x0) → f330_0_main_EQ(EOS, /(x0, 2), /(x0, 2)) | &&(=(%(x0, 2), 0), >(+(x0, 1), 1))
Filtered ground terms:
f330_0_main_EQ(x1, x2, x3) → f330_0_main_EQ(x2, x3)
Cond_f330_0_main_EQ(x1, x2, x3, x4) → Cond_f330_0_main_EQ(x1, x3, x4)
Cond_f330_0_main_EQ1(x1, x2, x3, x4) → Cond_f330_0_main_EQ1(x1, x3, x4)
Filtered duplicate terms:
f330_0_main_EQ(x1, x2) → f330_0_main_EQ(x2)
Cond_f330_0_main_EQ(x1, x2, x3) → Cond_f330_0_main_EQ(x1, x3)
Cond_f330_0_main_EQ1(x1, x2, x3) → Cond_f330_0_main_EQ1(x1, x3)
Prepared 2 rules for path length conversion:
P rules:
f330_0_main_EQ(x0) → f330_0_main_EQ(-(x0, 1)) | &&(>(x0, 0), =(%(x0, 2), 1))
f330_0_main_EQ(x0) → f330_0_main_EQ(/(x0, 2)) | &&(=(%(x0, 2), 0), >(+(x0, 1), 1))
Finished conversion. Obtained 4 rules.
P rules:
f330_0_main_EQ(x0) → f330_0_main_EQ'(x0) | &&(=(-(x0, *(2, div)), 1), >(x0, 0))
f330_0_main_EQ'(x0) → f330_0_main_EQ(-(x0, 1)) | &&(&&(&&(>(x0, 0), >=(-(x0, *(2, div)), 0)), <(-(x0, *(2, div)), 2)), =(-(x0, *(2, div)), 1))
f330_0_main_EQ(x1) → f330_0_main_EQ'(x1) | &&(=(-(x1, *(2, div)), 0), >(x1, 0))
f330_0_main_EQ'(x1) → f330_0_main_EQ(arith) | &&(&&(&&(&&(&&(>(x1, 0), >=(-(x1, *(2, div)), 0)), =(-(x1, *(2, div)), 0)), <(-(x1, *(2, div)), 2)), <(-(x1, *(2, arith)), 2)), >=(-(x1, *(2, arith)), 0))
Found the following polynomial interpretation:
Therefore the following rule(s) have been dropped: