void abort() { }; /* * recHanoi.c * * Created on: 17.07.2013 * Author: Stefan Wissert */ extern int __VERIFIER_nondet_int(); /* * This function returns the optimal amount of steps, * needed to solve the problem for n-disks */ /*@ requires (1); ensures ((((((((3 <= \result) && (n <= 2)) || (126 < \result)) || ((((long long) n + 11) <= \result) && (31 <= \result))) || ((\result == 1) && (n == 1))) || ((7 <= \result) && (n <= 3))) || ((15 <= \result) && (n <= 4)))); @*/ int hanoi(int n) { if (n == 1) { return 1; } return 2 * (hanoi(n-1)) + 1; } int main() { int n = __VERIFIER_nondet_int(); if (n < 1 || n > 31) { return 0; } int result = hanoi(n); if (result >= n) { return 0; } else { ERROR: {/*@ assert(0); */;abort();} } }