/* Geometric Series computes x=(z-1)* sum(z^k)[k=0..k-1] , y = z^k returns 1+x-y == 0 */ void abort() { }; extern void abort(); extern int __VERIFIER_nondet_int(); /*@ requires (1); ensures ((cond != 0)); @*/ void assume_abort_if_not(int cond) { if(!cond) {abort();} } /*@ requires ((1 <= cond)) && (cond != 0); ensures ((1 <= cond)) && (1); @*/ void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: {/*@ assert(0); */;} } return; } int main() { int z, k; unsigned long long x, y, c; z = __VERIFIER_nondet_int(); assume_abort_if_not(z>=0 && z<=50); k = __VERIFIER_nondet_int(); assume_abort_if_not(k>=0 && k<=50); assume_abort_if_not(z >= 1); assume_abort_if_not(k >= 1); x = 1; y = z; c = 1; /*@ loop invariant ((((((((((((__int128) 18446744073709551615U * z) * y) + z) + ((__int128) ((long long) z * z) * x)) + (((__int128) 18446744073709551615U * z) * x)) % ((unsigned __int128) 1 << 64)) == 0) && (1 <= z)) && (((((((__int128) z * x) + ((unsigned __int128) 18446744073709551615U * x)) + ((unsigned __int128) 18446744073709551615U * y)) + 1) % ((unsigned __int128) 1 << 64)) == 0)) && (z <= 50))); @*/ while (1) { __VERIFIER_assert(x*z - x - y + 1 == 0); if (!(c < k)) break; c = c + 1; x = x * z + 1; y = y * z; } //geo1 x = x * (z - 1); __VERIFIER_assert(1 + x - y == 0); return 0; }