/* Post-commit solution to matrixMultiplication, using CIVL. * Stephen Siegel */ #include #include // upper bound on N, the size of the matrices $input int BOUND = 8; // can go up to 16 if you have a few minutes $assume(BOUND >= 1); $input int N; // the size of the matrices $assume(1<=N && N<=BOUND); // some arbitrary input matrices... $input float A0[N][N]; $input float B0[N][N]; // the "leaf size" for Strassen... $input int LEAF_SIZE; $assume (1 <= LEAF_SIZE && LEAF_SIZE <= N); // impl: C is "out" variable void matrixMultiply(int n, float C[][], float A[][], float B[][]) { for (int i=0; i1) { if (n%2 != 0) return $false; n = n/2; } return $true; } /* main: runs the three tests */ int main() { $elaborate(N); // hint to verifier printf("N=%d\n", N); $assume(isPowerOf2(N)); float R1[N][N], R2[N][N]; matrixMultiply(N, R1, A0, B0); strassenR(N, R2, A0, B0); $assert($equals(&R1, &R2)); }