source: CIVL/examples/verifyThisProblems/quantifiedComp.cvl@ 0e12c94

1.23 2.0 main test-branch
Last change on this file since 0e12c94 was f7e5282, checked in by Yihao Yan <yihaoyan1@…>, 10 years ago

minor changes

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@3142 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 738 bytes
Line 
1/*
2author: Yihao
3
4Link(LCP.zip): http://fm2012.verifythis.org/challenges
5
6This is a verifyThis problem in 2012.
7This task asks you to get the longest common prefix of
8two subStrings.
9
10Input: an integer array arr, the length of the array, and two indices x and y.
11
12command: civl verify quantifiedComp.cvl
13
14result: the problem is solved
15*/
16
17#include <civlc.cvh>
18#include <assert.h>
19
20$input int n=3;
21$input int x;
22$input int y;
23$input int X1[n];
24
25$assume (x < n && y < n && x >=0 && y>=0);
26
27int lcp (int *arr, int n, int x, int y) {
28 int l=0;
29
30 while (x+l<n && y+l<n && arr[x+l]==arr[y+l]) {
31 l++;
32 }
33 return l;
34}
35
36void main() {
37 int result = lcp(X1, n, x, y);
38
39 assert($forall {int i | i>=0 && i<result} X1[x+i] == X1[y+i]);
40}
Note: See TracBrowser for help on using the repository browser.