Dataset Viewer
Auto-converted to Parquet Duplicate
filefolder_name
stringlengths
4
88
file_name
stringlengths
1
77
input
stringlengths
84
5.03k
output
stringlengths
136
5.55k
source
stringclasses
3 values
instruct
stringclasses
1 value
reverse_copy
reverse_copy
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Reverse { predicate Reverse{...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Reverse { predicate Reverse{...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
ranilakshmi_is_sorted
is_sorted
int is_sorted(int a[],int n){ for (int i=1;i<n;i++){ if (a[i-1]>a[i]){ //@ assert \exists integer j; 1<=j<=i && a[j]< a[j-1]; return 0; } } //@ assert \forall integer j; 1<=j<n ==> a[j]>=a[j-1]; return 1; }
/*@ requires n>0; requires \valid_read(a + (0..n-1)); behavior sorted: assumes \forall integer i; 1<=i<n ==> a[i]>=a[i-1]; ensures \result ==1; behavior unsorted: assumes \exists integer i; 1<=i<n && a[i]< a[i-1]; ensures \result ==0; complete ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
immutable_array_check_evens_in_array
check_evens_in_array
int areElementsEven(int *a, int n) { int p = 0; while (p < n) { if (a[p] % 2 != 0) { return 0; } p = p + 1; } return 1; } void main() { int arr[] = {2,4,6,8,10}; int res = areElementsEven(arr, 5); //@ assert res == 1; }
/*@ requires n > 0; requires \valid_read(a+(0..(n-1))); assigns \nothing; behavior all_even: assumes \forall integer k; 0 <= k < n ==> a[k]%2 == 0; ensures \result == 1; behavior some_not_even: assumes \exists integer k; 0 <= k < n && a[k]%2 != 0; ensures \result == 0...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
evdenis_acsl-examples_10_rec
10_rec
//@ logic integer sum_upto(integer n) = n*(n+1) / 2; /*@ lemma sum_rec: \forall integer n; n >=0 ==> sum_upto(n+1) == sum_upto(n)+n+1; */ long sum(int x) { if (x == 0) return 0; else return x + sum (x-1); } int main () { long i = sum(8); //@ assert i == 36; }
//@ logic integer sum_upto(integer n) = n*(n+1) / 2; /*@ lemma sum_rec: \forall integer n; n >=0 ==> sum_upto(n+1) == sum_upto(n)+n+1; */ /*@ requires x >= 0; requires x <= 1000; decreases x; ensures \result == sum_upto(x); */ long sum(int x) { if (x == 0) return 0; else return x + sum (x-1); } int ma...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
more_arrays_equal_arrays
equal_arrays
int check(int *a, int *b, int n) { for (int i = 0; i < n; i++) { if (a[i] != b[i]) { return 0; } } return 1; } int main() { int a[] = {1,2,3,4,5}; int b[] = {1,2,3,4,5}; int res = check(a, b, 5); //@ assert res == 1; }
/*@ requires n > 0; requires \valid_read (a + (0..n-1)); requires \valid_read (b + (0..n-1)); assigns \nothing; behavior equal: assumes \forall integer k; 0 <= k < n ==> b[k] == a[k]; ensures \result == 1; behavior not_equal: assumes \exists integer k; 0 <= k < n && b[...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
21176_BL.EN.U4CSE21176_14
BL.EN.U4CSE21176_14
#include<limits.h> int check(int val){ if(val>0) return val; else if(val<0) return -val; else return 0; } int main(){ int x=4; int r=check(x); //@assert x==4; }
#include<limits.h> /*@ requires val>INT_MIN; assigns \nothing; behavior pos: assumes val>0; ensures \result==val; behavior neg: assumes val<0; ensures \result==-val; behavior eq: assumes val==0; ensures \result==0; complete behaviors; disjoint behaviors; */ int check(int val){ if(val>0) return val; else if(val<0) retur...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_82
82
/*@ requires x >= 0; requires y >= 0; requires x >= y; */ void foo(int x, int y) { int i = 0; while (unknown()) { if (i < y) { i = i + 1; } } if (i >= x) { if (0 > i) { //@ assert i >= y; } } }
/*@ requires x >= 0; requires y >= 0; requires x >= y; */ void foo(int x, int y) { int i = 0; /*@ loop invariant i <= y; loop invariant i <= x; loop invariant 0 <= i; loop assigns i; */ while (unknown()) { if (i < y) { i = i + 1; } } if (i >= x) { if (0 > i) { //@ assert ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_minus-4
minus-4
void minus_loop_2() { int x = -20 ; int rm = 5; while (x < 0){ x += 4 ; rm -- ; } //@ assert x == 0 && rm == 0; }
void minus_loop_2() { int x = -20 ; int rm = 5; /*@ loop invariant -20 <= x <= 0; loop invariant (-rm) * 4 == x; loop variant rm ; */ while (x < 0){ x += 4 ; rm -- ; } //@ assert x == 0 && rm == 0; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
MarcoGrillo_Minimum-Period-of-a-String_period
period
/*@ predicate is_periodic(char* x, unsigned int p, unsigned int l) = (\forall unsigned int i; 0 <= i < (l-p-1) ==> x[i] == x[i+p]) && (l%p == 0) || (p == l); */ /*@ requires \valid(x+(0..l-1)); requires l > 0; requires p > 0; assigns \nothing; ensures is_periodic(x,p,l) ==> \result == 1; ...
/*@ predicate is_periodic(char* x, unsigned int p, unsigned int l) = (\forall unsigned int i; 0 <= i < (l-p-1) ==> x[i] == x[i+p]) && (l%p == 0) || (p == l); */ /*@ requires \valid(x+(0..l-1)); requires l > 0; requires p > 0; assigns \nothing; ensures is_periodic(x,p,l) ==> \result == 1; ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_48
48
int unknown(); /*@ requires n > 0; */ void foo(int n) { int c = 0; while (unknown()) { if(unknown()) { if(c != n) { (c = (c + 1)); } } else { if (c == n) { c = 1; } } } if(c == n) { //@ assert n > -1; } }
int unknown(); /*@ requires n > 0; */ void foo(int n) { int c = 0; /*@ loop invariant c == n ==> \forall integer k; 0 <= k < c ==> k != n; loop invariant c != n || c <= n; loop invariant 0 <= c; loop invariant (c == n) ==> (n > -1); loop assigns n,c; */ while (unknown()) { if(unknown()) { ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_109
109
/*@ requires c>0; */ void foo(int a, int m, int c) { int j = 0; int k = 0; while ( k < c) { if(m < a) { m = a; } k = k + 1; } if(c > 0) { //@ assert a <= m; } }
/*@ requires c>0; */ void foo(int a, int m, int c) { int j = 0; int k = 0; /*@ loop invariant m >= a || k == 0; loop invariant k <= c; loop invariant \forall integer l; 0 <= l < k ==> m >= a; loop invariant \forall integer l; 0 <= l < k ==> a <= m; loop invariant 0 <= k; loop assigns...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_7
7
/*@ requires 0 <= x <= 10; requires 0 <= y <= 10; */ void foo(int x, int y) { while (unknown()) { x = x + 10; y = y + 10; } if (x == 20) { //@ assert y != 0; } }
/*@ requires 0 <= x <= 10; requires 0 <= y <= 10; */ void foo(int x, int y) { /*@ loop invariant x == 20 ==> y != 0; loop invariant 0 <= y; loop invariant 0 <= x; loop assigns y,x; */ while (unknown()) { x = x + 10; y = y + 10; } if (x == 20) { //@ assert y != 0; } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_124
124
void foo(int x, int y) { int i = x; int j = y; while (x != 0) { x = x - 1; y = y - 1; } if(i == j) { //@ assert y == 0; } }
void foo(int x, int y) { int i = x; int j = y; /*@ loop invariant y <= j; loop invariant x <= i; loop invariant i - x == j - y; loop assigns x,y,i,j; */ while (x != 0) { x = x - 1; y = y - 1; } if(i == j) { //@ assert y == 0; } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
suman1406_ArrayDoubling1
ArrayDoubling1
void arraydouble(int *a, int n) { for (int p = 0; p < n; p++) { a[p] = a[p] * 2; } } int main(){ int a[] = {0, 1, 2, 3, 4}; int n = sizeof(a) / sizeof(a[0]); //@ assert \forall integer k; 0 <= k < n ==> a[k] == k; arraydouble(a, 5); //@ assert a[0] == 0 && a[1] == 2 && a[2] == 4 ...
/*@ requires n > 0; requires \valid(a + (0..n-1)); requires \forall integer k; 0 <= k < n ==> a[k] == k; ensures \forall integer k; 0 <= k < n ==> a[k] == 2*k; */ void arraydouble(int *a, int n) { /*@ loop invariant 0 <= p <= n; loop invariant \forall integer k; 0 <= k < p ==> a[k] == 2*k; loop invariant \...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
evdenis_acsl-examples_11_gcd
11_gcd
/*@ inductive is_gcd(integer a, integer b, integer d) { case gcd_zero: \forall integer n; is_gcd(n,0,n); case gcd_succ: \forall integer a,b,d; is_gcd(b, a % b, d) ==> is_gcd(a,b,d); } */ /*@ axiomatic gcd { logic integer gcd(integer a, integer b); axiom nil: ...
/*@ inductive is_gcd(integer a, integer b, integer d) { case gcd_zero: \forall integer n; is_gcd(n,0,n); case gcd_succ: \forall integer a,b,d; is_gcd(b, a % b, d) ==> is_gcd(a,b,d); } */ /*@ axiomatic gcd { logic integer gcd(integer a, integer b); axiom nil: ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_86
86
int main() { int x = -50; int y = 0; while (x < 0) { x = x + y; y = y + 1; } //@ assert y > 0; }
int main() { int x = -50; int y = 0; /*@ loop invariant x < 0 || 0 < y; loop invariant 0 <= y; loop assigns y,x; */ while (x < 0) { x = x + y; y = y + 1; } //@ assert y > 0; }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
adjacent_find
adjacent_find
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic HasEqualNeighbors { predicate ...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic HasEqualNeighbors { predicate ...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
is_heap_until
is_heap_until
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic HeapNodes { logic integer HeapLe...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic HeapNodes { logic integer HeapLe...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
general_wp_problem_simple_interest
simple_interest
#include<limits.h> int simple(int p,int n,int r) { int si; si = p*n*r/100; return si; } int main() { int s = simple(10000, 3,10); //@ assert s == 3000; return 0; }
#include<limits.h> /*@ requires p>=5000; requires r> 0 && r <15; requires n > 0 && n < 5; ensures \result == p*n*r/100; @*/ int simple(int p,int n,int r) { int si; si = p*n*r/100; return si; } int main() { int s = simple(10000, 3,10); //@ assert s == 3000; return 0; }
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
frama-c-wp-tutorial-en_7
7
void reset_1st_if_2nd_is_true(int* a, int const* b){ if(*b) *a = 0; } int main(){ int a = 10; int b = 1; // true reset_1st_if_2nd_is_true(&a, &b); //@ assert a == 0; }
/*@ requires \valid(a) && \valid_read(b); requires \separated(a, b); assigns *a; ensures \old(*b) ==> *a == 0; ensures !\old(*b) ==> *a == \old(*a); ensures *b == \old(*b); */ void reset_1st_if_2nd_is_true(int* a, int const* b){ if(*b) *a = 0; } int main(){ int a = 10; int b = 1;...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_73
73
/*@ requires y >= 127; */ void foo(int y) { int c = 0; int z = 36 * y; while (unknown()) { if (c < 36) { z = z + 1; c = c + 1; } } if (z < 0) { if(z >= 4608) { //@ assert (c >= 36) ; } } }
/*@ requires y >= 127; */ void foo(int y) { int c = 0; int z = 36 * y; /*@ loop invariant z == 36*y + c; loop invariant z == 36 * y + c; loop invariant c <= 36; loop invariant \forall integer i; 0 <= i < c ==> z >= 36*y + i; loop invariant 36 * y <= z; loop invariant 0 <= z; loop invariant 0 <= c; ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_53
53
/*@ requires n > 0; */ void foo(int n) { int c = 0; while (unknown()) { if (unknown()) { if (c > n) { c = c + 1; } } else { if (c == n) { c = 1; } } } if (c != n) { //@ assert c >= 0; } }
/*@ requires n > 0; */ void foo(int n) { int c = 0; /*@ loop invariant n - c; loop invariant c == n ==> c == 1; loop invariant 0 <= c <= n; loop assigns n,c; */ while (unknown()) { if (unknown()) { if (c > n) { c = c + 1; } } else { if (c == n) { c = 1; } ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
general_wp_problem_ani
ani
#include <stdio.h> int fun(int n) { int i = 7; int x = 1; while(i <= n) { x += 1; i += 3; } return x; } int main() { int a = fun(10); //@ assert a == 3; }
#include <stdio.h> /*@ requires n > 7; ensures \result == (n-1)/3; assigns \nothing; */ int fun(int n) { int i = 7; int x = 1; /*@ loop invariant i == 4 + 3*x; loop invariant i <= n + 3; loop assigns x, i; */ while(i <= n) { x += 1; i += 3; } return x; } int...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
miscellaneous_array_swap
array_swap
void array_swap(int* arr, int n, int n1, int n2) { int temp = arr[n1]; arr[n1] = arr[n2]; arr[n2] = temp; } int main(){ int arr[] = {1, 2, 3, 4, 5}; array_swap(arr, 5, 1, 3); //@ assert arr[1] == 4; //@ assert arr[3] == 2; }
/*@ requires n >= 0; requires 0 <= n1 < n && 0 <= n2 < n; requires \valid(arr+(0..n-1)); ensures (arr[n2] == \old(arr[n1])) && (arr[n1] == \old(arr[n2])); */ void array_swap(int* arr, int n, int n1, int n2) { int temp = arr[n1]; arr[n1] = arr[n2]; arr[n2] = temp; } int main(){ int arr[] ...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_125
125
void foo(int x, int y) { int i = x; int j = y; while (x != 0) { x = x - 1; y = y - 1; } if(y != 0) { //@ assert i != j; } }
void foo(int x, int y) { int i = x; int j = y; /*@ loop invariant y <= j; loop invariant x <= i; loop invariant i - x == j - y; loop invariant i - j == x - y; loop assigns x,y,i,j; */ while (x != 0) { x = x - 1; y = y - 1; } if(y != 0) { //@ assert i != j; } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
21176_BL.EN.U4CSE21176_3
BL.EN.U4CSE21176_3
#include<limits.h> int abs(int val){ if(val<0) return -val; else return val; } int main(){ int x=4; int r=abs(x); //@assert x==4; }
#include<limits.h> /*@ requires INT_MIN<=val<INT_MAX; ensures (val>=0 ==> \result == val) && (val<0 ==> \result == -val); */ int abs(int val){ if(val<0) return -val; else return val; } int main(){ int x=4; int r=abs(x); //@assert x==4; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
reverse
reverse
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Unchanged { predicate Unchan...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Unchanged { predicate Unchan...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
array_double
array_double
void arrayDouble(int *a, int n) { int p = 0; while (p < n) { a[p] = a[p] * 2; p = p + 1; } } int main() { int arr[] = {0,1,2,3,4,5}; arrayDouble(arr, 6); //@ assert \forall integer k; 0 <= k < 6 ==> arr[k] == 2*k; }
/*@ requires n > 0; requires \valid_read(a+(0..n-1)); requires \forall integer k; 0 <= k < n ==> a[k] == k; ensures \forall integer k; 0 <= k < n ==> a[k] == 2*k; */ void arrayDouble(int *a, int n) { int p = 0; /*@ loop invariant 0 <= p <= n; loop invariant \forall integer k; p <...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nabinkrsah_minimum element in the array
minimum element in the array
#include<limits.h> int min_in_array(int arr[],int n) { int min=arr[0]; for(int i=0;i<n;i++) { if(arr[i]<min) { min=arr[i]; } } return min; } int main() { int len=5; int arr[]={5,3,1,33,22}; int k=min_in_array(arr,len); //@ assert \forall integer i; 0<=i<len ==> k<=arr[i]; return 0; }
#include<limits.h> /*@ requires 0<n<INT_MAX; requires \valid_read(arr+(0..n-1)); ensures \forall integer i; 0<=i<n ==> \result<=arr[i]; */ int min_in_array(int arr[],int n) { int min=arr[0]; /*@ loop invariant \forall integer x;0<=x<i ==> min<=arr[x]; loop invariant 0<=i<=n; loop assigns i,min; loop variant n...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nabinkrsah_To check the given no. is odd or even and is divisible by 3
To check the given no. is odd or even and is divisible by 3
#include<stdio.h> #include<limits.h> int div(int a) { if(a%2==0 || a%3==0) return 0; else return 1; } int main() { int m=div(6); //@ assert m==0; }
//name:-Nabin kumar sah //reg no:-BL.EN.U4CSE21129 #include<stdio.h> #include<limits.h> /*@ requires INT_MIN<a<=INT_MAX; assigns \nothing; ensures (a%2==0) ==> \result==0 || ( a%3==0) ==> \result==0; ensures (a%2!=0) ==> \result==1 || (a%3!=0) ==> \result==1; */ int div(int a) { if(a%2==0 || a%3==0) return 0; else ret...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
mutable_arrays_bubble_sort
bubble_sort
#include <stdio.h> void bubbleSort(int *a, int n) { if (n <= 0) { return; } int i, j, temp; for(i=n-1; i>0; i--) { for(j=0; j<i; j++) { if (a[j] > a[j+1]) { temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } ...
#include <stdio.h> /*@ requires \valid(a+(0..n-1)); requires n > 0; ensures \forall integer i,j; 0<=i<=j<=n-1 ==> a[i]<=a[j]; */ void bubbleSort(int *a, int n) { if (n <= 0) { return; } int i, j, temp; /*@ loop invariant \forall integer p,q; i<=p<=q<=n-1 ==> a[p]<=a[q]; ...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_68
68
/*@ requires n > 0; */ void foo(int n) { int y = 0; int x = 1; while (x <= n) { y = n - x; x = x +1; } if (n > 0) { //@ assert y <= n; } }
/*@ requires n > 0; */ void foo(int n) { int y = 0; int x = 1; /*@ loop invariant y <= n; loop invariant x <= n+1; loop invariant x <= n + 1; loop invariant 1 <= x; loop invariant 0 <= y; loop invariant 0 <= x; loop assigns y; loop assigns x; */ while (x <= n) { ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
X509-parser_verify_correct_time_use
verify_correct_time_use
#include <stdint.h> #include <unistd.h> #include <string.h> typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef enum { CLASS_UNIVERSAL = 0x00, CLASS_APPLICATION = 0x01, CLASS_CONTEXT_SPECIFIC = 0x02, CLASS_PRIVATE = 0x03 } tag_class; typedef enum { A...
#include <stdint.h> #include <unistd.h> #include <string.h> typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef enum { CLASS_UNIVERSAL = 0x00, CLASS_APPLICATION = 0x01, CLASS_CONTEXT_SPECIFIC = 0x02, CLASS_PRIVATE = 0x03 } tag_class; typedef enum { A...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_74
74
/*@ requires y >= 127; */ void foo(int y) { int c = 0; int z = 36 * y; while (unknown()) { if(c < 36) { z = z + 1; c = c + 1; } } if (c < 36) { //@ assert z >= 0; } }
/*@ requires y >= 127; */ void foo(int y) { int c = 0; int z = 36 * y; /*@ loop invariant z == 36*y + c; loop invariant z == 36 * y + c; loop invariant c <= 36; loop invariant c < 36 || z >= 0; loop invariant c < 36 ==> z >= 0; loop invariant 36 * y <= z; loop invariant 0 <= c; loop assigns z; l...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
more_arrays_replace_evens
replace_evens
void func(int *a, int n) { for (int i = 0; i < n; i++) { if (i%2==0) a[i] = 0; } } void main() { int arr[5] = {1, 2, 3, 4, 5}; func(arr, 5); //@ assert arr[0] == 0; //@ assert arr[2] == 0; //@ assert arr[4] == 0; }
/*@ requires n > 0; requires \valid_read(a + (0..n-1)); ensures \forall integer k; (0<=k<n) && (k%2==0) ==> (a[k] == 0); */ void func(int *a, int n) { /*@ loop invariant 0 <= i <= n; loop invariant \forall integer k; (0 <= k < i) && (k%2==0) ==> a[k] == 0; loop invariant \foral...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
find_first_of
find_first_of
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic SomeNone { predicate SomeEqu...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic SomeNone { predicate SomeEqu...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_119
119
/*@ requires size >= 1; */ void foo(int size) { int i = 1; int sn = 0; while (i <= size) { i = i + 1; sn = sn + 1; } if (sn != 0) { //@ assert sn == size; } }
/*@ requires size >= 1; */ void foo(int size) { int i = 1; int sn = 0; /*@ loop invariant sn == i-1; loop invariant sn == i - 1; loop invariant i <= size+1; loop invariant i <= size + 1; loop invariant 1 <= i; loop invariant 0 <= i; loop assigns sn; loop assigns i; */ while (i <= size) { ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_50
50
void main() { int c = 0; while (unknown()) { if (unknown()) { if (c != 4) { c = c + 1; } } else { if (c == 4) { c = 1; } } } if (c != 4) { //@ assert c >= 0; } }
void main() { int c = 0; /*@ loop invariant c <= 4; loop invariant c != 4 || c >= 0; loop invariant 0 <= c; loop invariant (c == 4) || (c != 4); loop assigns c; */ while (unknown()) { if (unknown()) { if (c != 4) { c = c + 1; } } else { if (c == 4) { c = 1; ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
arepina_distance
distance
unsigned distance(unsigned a, unsigned b) { return (a > b) ? (a - b) : (b - a); } #ifdef OUT_OF_TASK #include <stdio.h> int main(void) { int a = distance(5, 3); //@ assert a == 2; int b = distance(3, 5); //@ assert b == 2; } #endif
/*@ requires \true; assigns \nothing; ensures \result == \max(a, b) - \min(a, b); */ unsigned distance(unsigned a, unsigned b) { return (a > b) ? (a - b) : (b - a); } #ifdef OUT_OF_TASK #include <stdio.h> int main(void) { int a = distance(5, 3); //@ assert a == 2; int b = distance(3, 5); //...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
frama-c-wp-tutorial-en_11
11
#include<limits.h> /*@ logic integer ax_b(integer a, integer x, integer b) = a * x + b; */ int restricted(int x){ return 3*x + 4; } int main(){ int x = 10; int result = restricted(x); //@ assert result == 34; return 0; }
#include<limits.h> /*@ logic integer ax_b(integer a, integer x, integer b) = a * x + b; */ /*@ requires INT_MIN <= 3*x; requires INT_MIN <= ax_b(3, x, 4) <= INT_MAX; assigns \nothing; ensures \result == ax_b(3, x, 4); */ int restricted(int x){ return 3*x + 4; } int main(){ int x = 10; in...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_122
122
/*@ requires size >= 1; */ void foo(int size) { int i = 1; int sn = 0; while (i <= size) { i = i + 1; sn = sn + 1; } if (sn != size) { //@ assert sn == 0; } }
/*@ requires size >= 1; */ void foo(int size) { int i = 1; int sn = 0; /*@ loop invariant sn == i-1; loop invariant sn == i - 1; loop invariant i <= size+1; loop invariant i <= size + 1; loop invariant 1 <= i; loop assigns sn; loop assigns i; */ while (i <= size) { i = i + 1; sn = sn + 1...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
copy_backward
copy_backward
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Unchanged { predicate Unchan...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Unchanged { predicate Unchan...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_triangle
triangle
int last_angle(int first, int second){ return 180 - first - second ; } int main(){ int first = 45; int second = 45; int result = last_angle(first, second); //@ assert result == 90; }
/*@ requires inputs: range: 0 < first < 180 && 0 < second < 180; requires positive_remainder: first + second < 180; ensures sum_180: first + second + \result == 180; assigns \nothing; */ int last_angle(int first, int second){ return 180 - first - second ; } int main(){...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
arrays_and_loops_3
3
int func(int a) { int x, y; int sum, res; if (a == 0){ x = 0; y = 0; } else { x = 5; y = 5; } sum = x + y; res = 10/sum; return res; } int main(){ int a = 1; int result = func(a); //@ assert result == 1; return 0; }
/*@ requires a!=0; ensures \result == 1; assigns \nothing; */ int func(int a) { int x, y; int sum, res; if (a == 0){ x = 0; y = 0; } else { x = 5; y = 5; } sum = x + y; res = 10/sum; return res; } int main(){ int a = 1; int result = func(a); ...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_condit-set
condit-set
void reset_1st_if_2nd_is_true(int* a, int const* b){ if(*b) *a = 0 ; } int main(){ int a = 5 ; int x = 0 ; reset_1st_if_2nd_is_true(&a, &x); //@ assert a == 5 ; //@ assert x == 0 ; int const b = 1 ; reset_1st_if_2nd_is_true(&a, &b); //@ assert a == 0 ; //@ assert b == 1 ; }
/*@ requires valid_ptrs: \valid(a) && \valid_read(b); requires diff_ptrs: \separated(a, b); assigns val_to_first: *a; ensures unchanged_second: \old(*b) == *b; behavior second_true: assumes *b; ensures *a == 0; behavior second_false: assumes !*b; ensures...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_93
93
/*@ requires n >= 0; */ void foo(int n) { int i = 0; int x = 0; int y = 0; while (i < n) { i = i + 1; if (unknown()) { x = x + 1; y = y + 2; } else { x = x + 2; y = y + 1; } } //@ assert (3 * n) == (x + y); }
/*@ requires n >= 0; */ void foo(int n) { int i = 0; int x = 0; int y = 0; /*@ loop invariant x + y == 3 * i; loop invariant i <= n; loop invariant 0 <= i; loop assigns x,y,i; */ while (i < n) { i = i + 1; if (unknown()) { x = x + 1; y = y + 2; } else { x = x + 2; ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
loops_mult
mult
#include <stdio.h> int mul(int a, int b) { int x = a, y = b, prod = 0; while(x >= 0) { prod = prod + y; x--; } return prod; } int main() { int pdt = mul(2, 5); //@ assert pdt == 15; }
#include <stdio.h> /*@ requires a >= 0 && b >= 0; requires a == 2 && b == 5; ensures \result == \old(a+1) * \old(b); assigns \nothing; */ int mul(int a, int b) { int x = a, y = b, prod = 0; /*@ loop invariant prod == (a-x)*y; loop invariant x == a - prod/y; loop invarian...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
immutable_array_search
search
int arraysearch(int* a, int x, int n) { for (int p = 0; p < n; p++) { if (x == a[p]) return 1; } return 0; } void main() { int arr[5] = {1, 2, 3, 4, 5}; int sum = arraysearch(arr, 3, 5); //@ assert sum == 1; }
/*@ requires n > 0; requires \valid_read(a + (0..n-1)); assigns \nothing; behavior present: assumes \exists integer k; 0 <= k < n && x == a[k]; ensures \result == 1; behavior not_present: assumes \forall integer k; 0 <= k < n ==> x != a[k]; ensures \result == 0; disjoint behaviors; complete behaviors...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_63
63
int main() { int x = 1; int y = 0; while (x <= 10) { y = 10 - x; x = x +1; } //@ assert y >= 0; //@ assert y <= 10; }
int main() { int x = 1; int y = 0; /*@ loop invariant 0 <= y <= 10; loop invariant 1 <= x <= 11; loop assigns y,x; */ while (x <= 10) { y = 10 - x; x = x +1; } //@ assert y >= 0; //@ assert y <= 10; }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_66
66
int main() { int x = 1; int y = 0; while (x <= 100) { y = 100 - x; x = x +1; } //@ assert y < 100; }
int main() { int x = 1; int y = 0; /*@ loop invariant y <= 100; loop invariant y <= 100 || y <= 100 - x; loop invariant y <= 100 || y < 100; loop invariant y <= 100 || 0 <= y; loop invariant y <= 100 - x || y < 100; loop invariant y <= 100 - x || 0 <= y; loop invariant y < 100; ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_17
17
/*@ requires n > 1; */ void foo(int n) { int x = 1; int m = 1; while (x < n) { if (unknown()) { m = x; } x = x + 1; } if(n > 1) { //@ assert m < n; //@ assert m >= 1; } }
/*@ requires n > 1; */ void foo(int n) { int x = 1; int m = 1; /*@ loop invariant 1 <= x <= n; loop invariant 1 <= m <= x; loop invariant m < x || m == 1; loop invariant m < n; loop assigns x,m; */ while (x < n) { if (unknown()) { m = x; } x = ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
evdenis_small-examples_indaddr
indaddr
void indaddr(unsigned size, int arr[size], unsigned addr) { arr[arr[addr]] = 0; } int main(){ unsigned size = 5; int arr[5] = {1, 2, 3, 4, 5}; indaddr(size, arr, 2); //@ assert arr[3] == 0; }
/*@ requires \valid(arr + (0..size-1)); requires 0 <= addr < size; ensures arr[\at(arr[addr],Pre)] == 0; */ void indaddr(unsigned size, int arr[size], unsigned addr) { arr[arr[addr]] = 0; } int main(){ unsigned size = 5; int arr[5] = {1, 2, 3, 4, 5}; indaddr(size, arr, 2); //@ assert arr[3] == 0; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
frama-c-wp-tutorial-en_10
10
void order_3(int* a, int* b, int* c){ if(*a > *b){ int tmp = *b; *b = *a; *a = tmp; } if(*a > *c){ int tmp = *c; *c = *a; *a = tmp; } if(*b > *c){ int tmp = *b; *b = *c; *c = tmp; } } int main(){ int x = 10, y = 20, z = ...
/*@ requires \valid(a) && \valid(b) && \valid(c); requires \separated(a, b, c); assigns *a, *b, *c; ensures *a <= *b <= *c; ensures { *a, *b, *c } == \old({ *a, *b, *c }); ensures (\old(*a == *b < *c) || *a == *c < *b || *b == *c < *a) ==> *a == *b; ensures (\old(*a == *b > *c) || *a == *c > *b ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_21
21
int main() { int z1,z2,z3; int x = 1; int m = 1; int n; while (x < n) { if (unknown()) { m = x; } x = x + 1; } if(n > 1) { //@ assert m < n; //@ assert m >= 1; } }
int main() { int z1,z2,z3; int x = 1; int m = 1; int n; /*@ loop invariant n > 1 ==> 1 <= m < n; loop invariant m <= x; loop invariant 1 <= x; loop assigns x,m; */ while (x < n) { if (unknown()) { m = x; } x = x + 1; } //post-condit...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_19
19
/*@ requires n > 0; */ void foo(int n) { int x = 0; int m = 0; while (x < n) { if (unknown()) { m = x; } x = x + 1; } if(n > 0) { //@ assert m < n; //@ assert m >= 0; } }
/*@ requires n > 0; */ void foo(int n) { int x = 0; int m = 0; /*@ loop invariant x == n ==> m >= 0; loop invariant x == n ==> m < n; loop invariant 0 <= x <= n; loop invariant m >= 0 && m <= x; loop assigns x,m; */ while (x < n) { if (unknown()) { m = x; ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_abs
abs
#include <limits.h> int abs(int val){ if (val < 0) { /*@ assert rte: signed_overflow: -2147483647 <= val; */ return -val; } return val; } /*@ requires d_input_not_min: INT_MIN < a; assigns \nothing; */ void foo(int a){ int b = abs(42); int c = abs(-42); //@ assert c == 42; int...
#include <limits.h> /*@ requires INT_MIN < val; ensures positive_value: function_result: \result >= 0; ensures (\old(val) >= 0 ==> \result == \old(val)) && (\old(val) < 0 ==> \result == -\old(val)); assigns \nothing; */ int abs(int val){ if (val < 0) { /*@ assert rte: signed_overflow: ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nikunjjain02_Basics_5
Basics_5
#include<stdio.h> #include<limits.h> int check(int d) { if(d%10==0) { return (d+5); } else { return (d-2); } } void main() { int a = 20; //@ assert a == 20; int b = check(a); //@ assert b == 25; int c = 34; //@ assert c == 34; int e = check(c); //@ assert e == 32; }
#include<stdio.h> #include<limits.h> /*@ requires -1000<d<1000; ensures d % 10 == 0 ==> \result == d + 5; ensures d % 10 != 0 ==> \result == d - 2; */ int check(int d) { if(d%10==0) { return (d+5); } else { return (d-2); } } void main() { int a = 20; //@ assert a == 20; int b = check(a); //@ assert b...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_52
52
int main() { int c = 0; while (unknown()) { if (unknown()) { if (c != 4) { c = c + 1; } } else { if (c == 4) { c = 1; } } } if (c < 0) { if (c > 4) { //@ assert c == 4; } } }
int main() { int c = 0; /*@ loop invariant c <= 4; loop invariant \exists integer k; 0 <= k <= 4 && c == k; loop invariant 0 <= c; loop invariant (c >= 0 && c <= 4) || (c == 0); loop assigns c; */ while (unknown()) { if (unknown()) { if (c != 4) { c = c + 1; } } else { ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_minus-loop
minus-loop
void minus_loop() { int x = 0 ; while (x > -10){ -- x ; } //@ assert x == -10 ; }
void minus_loop() { int x = 0 ; /*@ loop invariant -10 <= x <= 0 ; loop assigns x ; loop variant x + 10 ; */ while (x > -10){ -- x ; } //@ assert x == -10 ; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_12
12
/*@ requires 0 <= x <= 10; requires 0 <= y <= 10; */ void foo(int x, int y) { int z1; int z2; int z3; while (unknown()) { x = x + 10; y = y + 10; } if (y == 0) { //@ assert x != 20; } }
/*@ requires 0 <= x <= 10; requires 0 <= y <= 10; */ void foo(int x, int y) { int z1; int z2; int z3; /*@ loop invariant y != 0 || x != 20; loop invariant 0 <= y; loop invariant 0 <= x; loop assigns x,y; */ while (unknown()) { x = x + 10; y = y + 10; } if (y == 0) { //@ assert ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
fill
fill
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic AllSomeNot { predicate AllEq...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic AllSomeNot { predicate AllEq...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_alphabet-letter
alphabet-letter
#include <limits.h> int alphabet_letter(char c){ if( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') ) return 1 ; else return 0 ; } int main(){ int r ; r = alphabet_letter('x') ; //@ assert r ; r = alphabet_letter('H') ; //@ assert r ; r = alphabet_letter(' ') ; //@ assert !r ; }
#include <limits.h> /*@ requires INT_MIN < c < INT_MAX; ensures character: function_result: 'a' <= c <= 'z' || 'A' <= c <= 'Z' <==> \result == 1; ensures non_character: function_result: INT_MIN < c < 'A' || 'Z' < c < 'a' || 'z' < c < INT_MA...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_22
22
int main() { int x = 1; int m = 1; int n; while (x < n) { if (unknown()) { m = x; } x = x + 1; } if(n > 1) { ////@ assert m < n; //@ assert m >= 1; } }
int main() { int x = 1; int m = 1; int n; /*@ loop invariant n > 1 ==> m >= 1; loop invariant n > 1 ==> m < n; loop invariant m <= x; loop invariant 1 <= x; loop invariant 1 <= m; loop assigns x,n,m; */ while (x < n) { if (unknown()) { m = x; }...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_120
120
int main() { int i = 1; int sn = 0; while (i <= 8) { i = i + 1; sn = sn + 1; } if (sn != 8) { //@ assert sn == 0; } }
int main() { int i = 1; int sn = 0; /*@ loop invariant sn == i-1; loop invariant sn == i - 1; loop invariant i <= 9; loop invariant 1 <= i; loop assigns sn; loop assigns i; */ while (i <= 8) { i = i + 1; sn = sn + 1; } if (sn != 8) { //@ assert sn == 0; } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
random_number
random_number
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic C_Bit { lemma RandomNumberModulo...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic C_Bit { lemma RandomNumberModulo...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_16
16
/*@ requires n > 0; */ void foo(int n) { int x = 0; int m = 0; while (x < n) { if (unknown()) { m = x; } x = x + 1; } if(n > 0) { //@ assert m >= 0; } }
/*@ requires n > 0; */ void foo(int n) { int x = 0; int m = 0; /*@ loop invariant 0 <= x <= n; loop invariant 0 <= m <= x; loop invariant m <= n; loop invariant (m < x) || (m >= x); loop assigns x,m; */ while (x < n) { if (unknown()) { m = x; } ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_77
77
/*@ requires x >= 0; requires y >= 0; requires x >= y; */ void foo(int x, int y) { int i = 0; while (unknown()) { if (i < y) { i = i + 1; } } if (i <= y) { //@ assert i <= x; } }
/*@ requires x >= 0; requires y >= 0; requires x >= y; */ void foo(int x, int y) { int i = 0; /*@ loop invariant y <= x; loop invariant i <= x; loop invariant 0 <= y; loop invariant 0 <= x; loop invariant i <= y; loop invariant 0 <= i; loop assigns y; loop assigns x; loop assigns i; */ while (...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_98
98
void foo(int x) { int i = 0; int j = 0; int y = 2; while (i <= x) { i = i + 1; j = j + y; } if (i != j) { //@ assert y != 1; } }
void foo(int x) { int i = 0; int j = 0; int y = 2; /*@ loop invariant y == 2; loop invariant j == y*i; loop invariant j == i*y; loop invariant j == 2*i; loop invariant 0 <= i; loop assigns y,i,j; */ while (i <= x) { i = i + 1; j = j + y; } if (i != j) { //@ assert y != 1; } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nabinkrsah_Maximum_element_in_an_array
Maximum_element_in_an_array
#include<limits.h> int Max_in_Array(int arr[],int n) { int max=arr[0]; for(int j=0;j<n;j++) { if(arr[j]>max) { max=arr[j]; } } return max; } int main() { int n=5; int arr[]={50,44,33,2,88}; int k=Max_in_Array(arr,n); //@ assert \forall integer i; 0<=i<n ==> k>=arr[i]; }
#include<limits.h> /*@ requires 0<n<INT_MAX; requires \valid_read(arr+(0..n-1)); ensures \forall integer i; 0<=i<n ==> \result>=arr[i]; */ int Max_in_Array(int arr[],int n) { int max=arr[0]; /*@ loop invariant \forall integer i; 0<=i<j ==> max>=arr[i]; loop invariant 0<=j<=n; loop assigns j,max; loop varian...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_25
25
/*@ requires (x == 10000); */ void foo(int x) { while ((x > 0)) { (x = (x - 1)); } //@ assert (x == 0) ; }
/*@ requires (x == 10000); */ void foo(int x) { // loop body /*@ loop invariant x <= 10000; loop invariant 0 <= x; loop assigns x; */ while ((x > 0)) { (x = (x - 1)); } // post-condition //@ assert (x == 0) ; }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_add-ptr
add-ptr
#include <limits.h> int add(int* p, int* q, int* r){ int result = *p + *q; *r = result; return result; } int main(){ int a = 24 ; int b = 42 ; int res; int x; x = add(&a, &b, &res) ; //@ assert x == a + b ; //@ assert x == 66 ; x = add(&a, &a, &res) ; //@ assert x == a + a ; //@ assert x == ...
#include <limits.h> /*@ requires \valid_read(p) && \valid_read(q) && \valid(r); requires INT_MIN < *p < INT_MAX && INT_MIN < *q < INT_MAX && INT_MIN < *p + *q < INT_MAX; requires separate_r: \separated(p, r) && \separated(q, r); assigns *r; ensures correct_r: *r == \old(...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_43
43
int unknown(); /*@ requires n > 0; */ void foo(int n) { int c = 0; while (unknown()) { if (unknown()) { if (c > n) { c = c + 1; } } else { if (c == n) { c = 1; } } } if (c == n) { //@ assert n > -1; } }
int unknown(); /*@ requires n > 0; */ void foo(int n) { int c = 0; /*@ loop invariant n-c; loop invariant n - c; loop invariant c >= 0 && c <= n; loop invariant c == n ==> n > -1; loop invariant 0 <= c <= n; loop assigns n,c; */ while (unknown()) { if (unknown()) { if (c > n) { c ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nikunjjain02_Arrays_9
Arrays_9
#include<stddef.h> void search_and_replace(int* array, size_t length, int old, int new) { for(size_t i = 0;i < length; ++i) { if(array[i]==old) array[i]=new; } } void main() { int a[] = {1, 2, 4, 5}; search_and_replace(a, 4, 2, 3); //@ assert a[0] == 1 && a[1] == 3 && a[2] == 4 && a[3] == 5; }
#include<stddef.h> /*@ requires \valid(array+(0..length-1)); assigns array[0..length-1]; ensures \forall size_t i;0<=i<length&&\old(array[i])==old==>array[i]==new; ensures \forall size_t i;0<=i<length&&\old(array[i])!=old==>array[i]==\old(array[i]); */ void search_and_replace(int* array, size_t length, int old, int...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_103
103
int main() { int x = 0; while (x < 100) { x = x + 1; } //@ assert x == 100; }
int main() { int x = 0; /*@ loop invariant x <= 100; loop invariant 0 <= x; loop assigns x; */ while (x < 100) { x = x + 1; } //@ assert x == 100; }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_97
97
void foo(int x) { int i = 0; int j = 0; int y = 2; while (i <= x) { i = i + 1; j = j + y; } if (y == 1) { //@ assert i == j; } }
void foo(int x) { int i = 0; int j = 0; int y = 2; /*@ loop invariant y == 2; loop invariant j == i*2; loop invariant j == i * 2; loop invariant j == 2*i; loop invariant 0 <= j; loop invariant 0 <= i; loop assigns y,i,j; */ while (i <= x) { i = i + 1; j = j + y; } if (y == 1) { ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_108
108
/*@ requires a <= m; */ void foo(int a, int m, int c) { int j = 0; int k = 0; while (k < c) { if(m < a) { m = a; } k = k + 1; } //@ assert a <= m; }
/*@ requires a <= m; */ void foo(int a, int m, int c) { int j = 0; int k = 0; /*@ loop invariant a <= m; loop invariant 0 <= k; loop invariant (m < a ==> m == a); loop assigns m,k,a; */ while (k < c) { if(m < a) { m = a; } k = k + 1; } //@ ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_11
11
/*@ requires 0 <= x <= 10; requires 0 <= y <= 10; */ void foo(int x, int y) { while (unknown()) { x = x + 10; y = y + 10; } if (x == 20) { //@ assert y != 0; } }
/*@ requires 0 <= x <= 10; requires 0 <= y <= 10; */ void foo(int x, int y) { /*@ loop invariant x != 20 || y != 0; loop invariant 0 <= y + 10; loop invariant 0 <= x + 10; loop invariant 0 <= y; loop invariant 0 <= x; loop assigns y,x; */ while (unknown()) { x = x + 10; y = y + 10; } ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
corinnt_max-ptr
max-ptr
#include <stddef.h> #include <limits.h> void max_ptr(int* a, int* b) { if(*a < *b) { int tmp = *b ; *b = *a ; *a = tmp; } } extern int h ; int main() { h = 42 ; int a = 24 ; int b = 42 ; max_ptr(&a, &b) ; //@ assert a == 42 ; //@ assert b == 24 ; }
#include <stddef.h> #include <limits.h> /*@ requires \valid(a) && \valid(b); assigns *a, *b; ensures a_in_nums: *a \in { \old(*a), \old(*b) } ; ensures b_in_nums: *b \in { \old(*a), \old(*b) } ; ensures a_is_max: *a >= \old(*a) && *a >= \old(*b); ensures b_is_min: *b <= \old(*a) && *b <= \old(*...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nabinkrsah_Compute the factorial of a given no. with precondition and postcondition
Compute the factorial of a given no. with precondition and postcondition
#include<stdio.h> /*@ logic integer fact(integer n)=(n<1)? 1:n*fact(n-1); */ int fact(int n) { if(n<2) return 1; int f=1; int i; for(i=1;i<=n;i++) { f=f*i; } return f; } int main() { int k=fact(5); //@ assert k==120; }
#include<stdio.h> /*@ logic integer fact(integer n)=(n<1)? 1:n*fact(n-1); */ /*@ assigns \nothing; ensures \result==fact(n); */ int fact(int n) { if(n<2) return 1; int f=1; int i; /*@ loop invariant 1<=i<=n+1; loop invariant f==fact(i-1); loop assigns i,f; loop variant n-i; */ for(i=1;i<=n;i++) { f=f*i; } return f; } ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
ranilakshmi_last_angle
last_angle
int last_angle(int first,int second){ if(first < 0 || first > 180 || second < 0 || second > 180 || first + second > 180){ return -1; } return 180 - first - second; } int main(){ int first = 60; int second = 90; int result = last_angle(first,second); //@ assert result == 30; firs...
/*@ behavior error: assumes first < 0 || first > 180 || second < 0 || second > 180 || first + second > 180; ensures \result == -1; behavior valid: assumes first >= 0 && first <= 180 && second >= 0 && second <= 180 && first + second <= 180; ensures \result == 180 - first - second;...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_79
79
/*@ requires x >= 0; requires y >= 0; requires x >= y; */ void foo(int x, int y) { int i = 0; while (unknown()) { if (i < y) { i = i + 1; } } if (i >= x) { if (0 > i) { //@ assert i >= y; } } }
/*@ requires x >= 0; requires y >= 0; requires x >= y; */ void foo(int x, int y) { int i = 0; /*@ loop invariant i <= y; loop invariant 0 <= i; loop assigns x,y,i; */ while (unknown()) { if (i < y) { i = i + 1; } } if (i >= x) { if (0 > i) { //@ assert i >= y; } } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nabinkrsah_Sum of first n numbers using ‘while’ loop with precondition and postcondition
Sum of first n numbers using ‘while’ loop with precondition and postcondition
#include<stdio.h> #include<limits.h> int add(int n) { int i=1; int s=0; while(i<=n) { s=s+i; i++; } return s; } int main() { int k; k=add(5); //@ assert k==15; }
#include<stdio.h> #include<limits.h> /*@ requires n>0; ensures \result==n*(n+1)/2; */ int add(int n) { int i=1; int s=0; /*@ loop invariant s==(i-1)*i/2; loop invariant 1<=i<=n+1; loop assigns i,s; loop variant n-i; */ while(i<=n) { s=s+i; i++; } return s; } int main() { int k; k=add(5); //@ assert k==15; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
21176_BL.EN.U4CSE21176_2
BL.EN.U4CSE21176_2
#include<limits.h> int foo(int a,int b){ if(a>=0){ a++; } else{ a+=b; } return a; } int main(){ int x=-99; int y=100; int r=foo(x,y); //@assert x==-99 && y==100 && r==1; }
#include<limits.h> /*@ requires INT_MIN<=a<INT_MAX; requires INT_MIN<=b<INT_MAX; assigns \nothing; behavior a_pos: assumes a>=0; ensures \result == a + 1; behavior a_neg: assumes a < 0; ensures \result == a + b; disjoint behaviors; complete behaviors; */ int foo(int a,int b){ if(a>=0){ a++; } else{ a+=b...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
nabinkrsah_sum of number divisble by 3
sum of number divisble by 3
#include<stdio.h> int dsum(int n) { int i=1; int sum=0; for(i=1;i<=n;i++) { sum=sum+3*i; } return sum; } int main() { int k=dsum(3); //@ assert k==18; }
#include<stdio.h> /*@ requires n>0; ensures \result==(3*(n*(n+1)/2)); */ int dsum(int n) { int i=1; int sum=0; /*@ loop invariant 1<=i<=n+1; loop invariant sum==(3*((i-1)*i/2)); loop assigns sum,i; loop variant n-i; */ for(i=1;i<=n;i++) { sum=sum+3*i; } return sum; } int main() { int k=dsum(3); //@ assert k==18; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
loops_3
3
#include <stdio.h> int func(int c) { int x = c; int y = 0; while(x > 0) { x = x - 1; y = y + 1; } return y; } void main() { int t = func(5); //@ assert t == 5; }
#include <stdio.h> /*@ requires c > 0; ensures \result == c; assigns \nothing; */ int func(int c) { int x = c; int y = 0; /*@ loop invariant c == x + y && x >= 0; loop assigns x, y; */ while(x > 0) { x = x - 1; y = y + 1; } return y; } void main() ...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
evdenis_acsl-examples_04_max_seq
04_max_seq
/*@ requires n >= 0; requires \valid(a + (0..n-1)); assigns \nothing; behavior empty: assumes n == 0; ensures \result == 0; behavior not_empty: assumes 0 < n; ensures 0 <= \result < n; ensures \forall integer i; 0 <= i < n ==> a[i] <= a[\result]; ensures \forall integ...
/*@ requires n >= 0; requires \valid(a + (0..n-1)); assigns \nothing; behavior empty: assumes n == 0; ensures \result == 0; behavior not_empty: assumes 0 < n; ensures 0 <= \result < n; ensures \forall integer i; 0 <= i < n ==> a[i] <= a[\result]; ensures \forall integ...
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_69
69
/*@ requires n > 0; */ void foo(int n) { int x = 1; int y = 0; while (x <= n) { y = n - x; x = x +1; } if (n > 0) { //@ assert y >= 0; } }
/*@ requires n > 0; */ void foo(int n) { int x = 1; int y = 0; /*@ loop invariant y <= n - 1; loop invariant 0 <= y; loop assigns n; loop invariant x <= n+1; loop invariant x <= n + 1; loop invariant 1 <= x; loop invariant 0 <= x; loop assigns y; loop assigns x; */ ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
max_element
max_element
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX size_type max_element(const value_type* a, size_type n...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ requires valid: \valid_read(a + (0..n-1)); a...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_92
92
int main(){ int x = 0; int y = 0; while(y >= 0){ y = y + x; } //@ assert y >= 0; }
int main(){ int x = 0; int y = 0; /*@ loop invariant x == 0; loop invariant \forall integer k; 0<= k < x ==> y >= 0; loop invariant 0 <= y; loop invariant 0 <= x; loop assigns y; loop assigns x; */ while(y >= 0){ y = y + x; } //@ assert y >= 0; }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_128
128
void foo(int y) { int x = 1; while (x < y) { x = x + x; } //@ assert x >= 1; }
void foo(int y) { int x = 1; /*@ loop invariant 1 <= x; loop assigns y; loop assigns x; */ while (x < y) { x = x + x; } //@ assert x >= 1; }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
immutable_array_sample
sample
int fun(int x, int y) { int r = x; int d = 0; while (r >= y) { printf("r = %d d = %d y = %d x = %d\n", r, d, y, x); r = r - y; d = d + 1; } //@ assert r + d*y == x; return d; }
int fun(int x, int y) { int r = x; int d = 0; /*@ loop invariant r + d*y == x; */ while (r >= y) { printf("r = %d d = %d y = %d x = %d\n", r, d, y, x); r = r - y; d = d + 1; } //@ assert r + d*y == x; return d; }
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
search
search
int arraysearch(int* a, int x, int n) { for (int p = 0; p < n; p++) { if (x == a[p]) //@ assert \exists integer k; 0 <= k <= p && x == a[k]; return 1; } return 0; }
/*@ requires n > 0; requires \valid_read(a + (0..n-1)); assigns \nothing; behavior present: assumes \exists integer k; 0 <= k < n && x == a[k]; ensures \result == 1; behavior not_present: assumes \forall integer k; 0 <= k < n ==> x != a[k]; ensures \result == 0; disjoint behaviors; complete behaviors...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_114
114
int main() { int sn = 0; int x = 0; while (unknown()) { x = x + 1; sn = sn + 1; } if(sn != x) { //@ assert sn == -1; } }
int main() { int sn = 0; int x = 0; /*@ loop invariant x == sn; loop invariant x <= sn; loop invariant sn == x; loop invariant sn <= x; loop invariant 0 <= x; loop invariant 0 <= sn; loop assigns x; loop assigns sn; */ while (unknown()) { x = x + 1; sn = sn + 1; } if(sn != x) { ...
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
axiom_size_of_push
axiom_size_of_push
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX struct Stack { value_type* obj; size_type capaci...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX struct Stack { value_type* obj; size_type capaci...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
iota
iota
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic IotaGenerate { predicate Iot...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic IotaGenerate { predicate Iot...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
pointers_incr_a_by_b
incr_a_by_b
int incr_a_by_b(int* a, int const* b){ *a += *b; return *a; } void main() { int a = 10; int b = 20; incr_a_by_b(&a, &b); //@ assert a == 30; //@ assert b == 20; }
/*@ requires \valid(a) && \valid_read(b); requires \separated(a, b); assigns *a; ensures *a == \old(*a) + *b; ensures *b == \old(*b); */ int incr_a_by_b(int* a, int const* b){ *a += *b; return *a; } void main() { int a = 10; int b = 20; incr_a_by_b(&a, &b); //@ assert a == 30...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
21176_BL.EN.U4CSE21176_8
BL.EN.U4CSE21176_8
#include<math.h> double Sqrt(double x){ return sqrt(x); } int main(){ double x = 9; double y; y = Sqrt(x); //@assert y == sqrt(x); return 0; }
#include<math.h> /*@ requires \is_finite(x); requires x >= -0.; ensures \result >= -0.; ensures \is_finite(\result); ensures \result == sqrt(x); assigns \result; */ double Sqrt(double x){ return sqrt(x); } int main(){ double x = 9; double y; y = Sqrt(x); //@assert y == sqrt(x); return 0; }
githubRepository
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
max_element2
max_element2
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic ArrayBounds { predicate Lowe...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic ArrayBounds { predicate Lowe...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
code2_58
58
/*@ requires n > 0; */ void foo(int n) { int c = 0; while (unknown()) { if (unknown()) { if (c != n) { c = c + 1; } } else { if (c == n) { c = 1; } } } if(c != n) { //@ assert c >= 0; } }
/*@ requires n > 0; */ void foo(int n) { int c = 0; /*@ loop invariant 0 <= c; loop assigns n,c; */ while (unknown()) { if (unknown()) { if (c != n) { c = c + 1; } } else { if (c == n) { c = 1; } } } if(c != n) { //@ assert c >= 0; } }
autospec
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
count2
count2
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Equal { predicate Equal{K,L}...
#include <limits.h> #ifndef __cplusplus typedef int bool; #define false ((bool)0) #define true ((bool)1) #endif typedef int value_type; #define VALUE_TYPE_MAX INT_MAX #define VALUE_TYPE_MIN INT_MIN typedef unsigned int size_type; #define SIZE_TYPE_MAX UINT_MAX /*@ axiomatic Equal { predicate Equal{K,L}...
fmbench
Please write ACSL specification for the given C code ensuring its correctness. You only need to return the completed ACSL formal specification together with C program without explanation.
End of preview. Expand in Data Studio

YAML Metadata Warning:The task_categories "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

Introduction

This dataset FM-Bench-Verified is a manual-cleaned and verified benchmark which contains 280 C programs, properties under verification, together with ground-truth ACSL specifications.

This dataset can be used for:

  • Specification generation task (Code2Proof): given program and properties to be verified as input, output program with specification that can pass the prover.

It comes from three sources:

Statistics of FM-Bench-Verified

FM-Bench-Verified contains 280 cases. Each case contains:

  • A program written in C
  • At least one property under verification
  • Formal specifications that can verify that the program satisfies the target property

All 280 cases (C program + specification) can be verified through Frama-C's WP (Weakest Precondition) verification.

The table below shows the statistics of the 280 cases in FM-Bench-Verified:

Source Repo Name Number Avg-LoC Ave-LoS Max_LoC Max_LoS
FM-Bench ACSL-by-Example 45 24.4 59.6 43 130
FRAMA-C-problems 40 11.5 8.5 20 25
Github evdenis 16 12.6 9.6 25 25
corinnt 16 11.9 14.7 21 45
nabinkrsah 12 14.8 9.9 20 20
21176 9 10.7 7.2 15 14
arepina 9 18.4 11.4 32 19
frama-c-wp-tutorial 7 11.5 7.5 22 15
nikunjjain02 6 15.6 11.5 26 19
suman1406 5 18.2 14.6 22 25
others(number <=3) 8 13.5 12.5 20 22
AutoSpec SyGuS 102 11.8 10.8 20 18
X509 5 40.4 16.6 55 24
All 280 16.6 15.0 55 130

Annotations:

  • Source: the data source
  • Repo Name: the repository name
  • Number: number of programs from the corresponding repository
  • Ave-LoC: average lines of code
  • Ave-LoS: average lines of specification
  • Max-LoC: maximum lines of code
  • Max-LoS: maximum lines of specification
Downloads last month
97