/* Author: Yihao Download LCP.zip from: http://fm2012.verifythis.org/challenges ----------------- Problem decription: Longest Common Prefix (LCP) Input: an integer array X1[n], and two indices x and y into this array Output: length of the longest common prefix of the subarrays of a starting at x and y respectively. ----------------- Verification task: Implement the lcp function, and verify that it behaves in the way described above. result: the problem is solved */ #include $input int N_BOUND=4; $input int n; $input int x; $input int y; $input int X1[n]; $assume (x < n && y < n && x >=0 && y>=0 && n > 0 && n <= N_BOUND); int lcp(int *arr, int n, int x, int y){ int l=0; while (x+l y ? x : y; if(result + maxXY < n){ $assert(X1[x+result] != X1[y+result]); } }