test_ID stringlengths 3 3 | test_file stringlengths 14 119 | ground_truth stringlengths 70 28.7k | hints_removed stringlengths 58 28.7k |
|---|---|---|---|
000 | 630-dafny_tmp_tmpz2kokaiq_Solution.dfy |
function sorted(a: array<int>) : bool
reads a
{
forall i,j : int :: 0 <= i < j < a.Length ==> a[i] <= a[j]
}
method BinarySearch(a: array<int>, x: int) returns (index: int)
requires sorted(a)
ensures 0 <= index < a.Length ==> a[index] == x
ensures index == -1 ==> forall i : int :: 0 <= i < a.Length... |
function sorted(a: array<int>) : bool
reads a
{
forall i,j : int :: 0 <= i < j < a.Length ==> a[i] <= a[j]
}
method BinarySearch(a: array<int>, x: int) returns (index: int)
requires sorted(a)
ensures 0 <= index < a.Length ==> a[index] == x
ensures index == -1 ==> forall i : int :: 0 <= i < a.Length... |
001 | 703FinalProject_tmp_tmpr_10rn4z_DP-GD.dfy | method DPGD_GradientPerturbation (size:int, learning_rate:real, noise_scale:real, gradient_norm_bound:real, iterations:int) returns (Para:real, PrivacyLost:real)
requires iterations>=0
requires size>=0
requires noise_scale >= 1.0
requires -1.0 <= gradient_norm_bound <= 1.0
{
var thetha:array<real> := new real... | method DPGD_GradientPerturbation (size:int, learning_rate:real, noise_scale:real, gradient_norm_bound:real, iterations:int) returns (Para:real, PrivacyLost:real)
requires iterations>=0
requires size>=0
requires noise_scale >= 1.0
requires -1.0 <= gradient_norm_bound <= 1.0
{
var thetha:array<real> := new real... |
002 | 703FinalProject_tmp_tmpr_10rn4z_gaussian.dfy | // VERIFY USING DAFNY:
// /Applications/dafny/dafny /Users/apple/GaussianDP/Dafny/gaussian.dfy
method gaussian (size:int, q: array<real>, q_hat: array<real>) returns (out: array<real>)
requires q_hat.Length==size
requires q.Length==size
requires size > 0
requires arraySquaredSum(q_hat[..]) <= 1.0
{
var i : int := 0;
... | // VERIFY USING DAFNY:
// /Applications/dafny/dafny /Users/apple/GaussianDP/Dafny/gaussian.dfy
method gaussian (size:int, q: array<real>, q_hat: array<real>) returns (out: array<real>)
requires q_hat.Length==size
requires q.Length==size
requires size > 0
requires arraySquaredSum(q_hat[..]) <= 1.0
{
var i : int := 0;
... |
003 | AssertivePrograming_tmp_tmpwf43uz0e_DivMode_Unary.dfy | // Noa Leron 207131871
// Tsuri Farhana 315016907
// definitions borrowed from Rustan Leino's Program Proofs Chapter 7
// (https://program-proofs.com/code.html example code in Dafny; source file 7-Unary.dfy)
datatype Unary = Zero | Suc(pred: Unary)
ghost function UnaryToNat(x: Unary): nat {
match x
case Zero => ... | // Noa Leron 207131871
// Tsuri Farhana 315016907
// definitions borrowed from Rustan Leino's Program Proofs Chapter 7
// (https://program-proofs.com/code.html example code in Dafny; source file 7-Unary.dfy)
datatype Unary = Zero | Suc(pred: Unary)
ghost function UnaryToNat(x: Unary): nat {
match x
case Zero => ... |
004 | AssertivePrograming_tmp_tmpwf43uz0e_Find_Substring.dfy | // Noa Leron 207131871
// Tsuri Farhana 315016907
ghost predicate ExistsSubstring(str1: string, str2: string) {
// string in Dafny is a sequence of characters (seq<char>) and <= on sequences is the prefix relation
exists offset :: 0 <= offset <= |str1| && str2 <= str1[offset..]
}
ghost predicate Post(str1: string,... | // Noa Leron 207131871
// Tsuri Farhana 315016907
ghost predicate ExistsSubstring(str1: string, str2: string) {
// string in Dafny is a sequence of characters (seq<char>) and <= on sequences is the prefix relation
exists offset :: 0 <= offset <= |str1| && str2 <= str1[offset..]
}
ghost predicate Post(str1: string,... |
005 | AssertivePrograming_tmp_tmpwf43uz0e_MergeSort.dfy | // Noa Leron 207131871
// Tsuri Farhana 315016907
predicate Sorted(q: seq<int>) {
forall i,j :: 0 <= i <= j < |q| ==> q[i] <= q[j]
}
/*
Goal: Implement the well known merge sort algorithm in O(a.Length X log_2(a.Length)) time, recursively.
- Divide the contents of the original array into two local arrays
- After ... | // Noa Leron 207131871
// Tsuri Farhana 315016907
predicate Sorted(q: seq<int>) {
forall i,j :: 0 <= i <= j < |q| ==> q[i] <= q[j]
}
/*
Goal: Implement the well known merge sort algorithm in O(a.Length X log_2(a.Length)) time, recursively.
- Divide the contents of the original array into two local arrays
- After ... |
006 | BPTree-verif_tmp_tmpq1z6xm1d_Utils.dfy |
// method CountLessThan(numbers: set<int>, threshold: int) returns (count: int)
// // ensures count == |set i | i in numbers && i < threshold|
// ensures count == |SetLessThan(numbers, threshold)|
// {
// count := 0;
// var ss := numbers;
// while ss != {}
// decreases |ss|
// {
// var i: int :| ... |
// method CountLessThan(numbers: set<int>, threshold: int) returns (count: int)
// // ensures count == |set i | i in numbers && i < threshold|
// ensures count == |SetLessThan(numbers, threshold)|
// {
// count := 0;
// var ss := numbers;
// while ss != {}
// decreases |ss|
// {
// var i: int :| ... |
007 | BinarySearchTree_tmp_tmp_bn2twp5_bst4copy.dfy | datatype Tree = Empty | Node(left: Tree, value: int, right: Tree)
predicate BinarySearchTree(tree: Tree)
decreases tree
{
match tree
case Empty => true
case Node(_,_,_) =>
(tree.left == Empty || tree.left.value < tree.value)
&& (tree.right == Empty || tree.right.value > tree.value)
&& BinarySearchT... | datatype Tree = Empty | Node(left: Tree, value: int, right: Tree)
predicate BinarySearchTree(tree: Tree)
{
match tree
case Empty => true
case Node(_,_,_) =>
(tree.left == Empty || tree.left.value < tree.value)
&& (tree.right == Empty || tree.right.value > tree.value)
&& BinarySearchTree(tree.left) &&... |
008 | CO3408-Advanced-Software-Modelling-Assignment-2022-23-Part-2-A-Specification-Spectacular_tmp_tmp4pj4p2zx_car_park.dfy | class {:autocontracts} CarPark {
const totalSpaces: nat := 10;
const normalSpaces: nat:= 7;
const reservedSpaces: nat := 3;
const badParkingBuffer: int := 5;
var weekend: bool;
var subscriptions: set<string>;
var carPark: set<string>;
var reservedCarPark: set<string>;
constructor()... | class {:autocontracts} CarPark {
const totalSpaces: nat := 10;
const normalSpaces: nat:= 7;
const reservedSpaces: nat := 3;
const badParkingBuffer: int := 5;
var weekend: bool;
var subscriptions: set<string>;
var carPark: set<string>;
var reservedCarPark: set<string>;
constructor()... |
009 | CS494-final-project_tmp_tmp7nof55uq_bubblesort.dfy | //Bubblesort CS 494 submission
//References: https://stackoverflow.com/questions/69364687/how-to-prove-time-complexity-of-bubble-sort-using-dafny/69365785#69365785
// predicate checks if elements of a are in ascending order, two additional conditions are added to allow us to sort in specific range within array
predic... | //Bubblesort CS 494 submission
//References: https://stackoverflow.com/questions/69364687/how-to-prove-time-complexity-of-bubble-sort-using-dafny/69365785#69365785
// predicate checks if elements of a are in ascending order, two additional conditions are added to allow us to sort in specific range within array
predic... |
010 | CS5232_Project_tmp_tmpai_cfrng_LFUSimple.dfy | class LFUCache {
var capacity : int;
var cacheMap : map<int, (int, int)>; //key -> {value, freq}
constructor(capacity: int)
requires capacity > 0;
ensures Valid();
{
this.capacity := capacity;
this.cacheMap := map[];
}
predicate Valid()
reads this;
// reads... | class LFUCache {
var capacity : int;
var cacheMap : map<int, (int, int)>; //key -> {value, freq}
constructor(capacity: int)
requires capacity > 0;
ensures Valid();
{
this.capacity := capacity;
this.cacheMap := map[];
}
predicate Valid()
reads this;
// reads... |
011 | CS5232_Project_tmp_tmpai_cfrng_test.dfy | iterator Gen(start: int) yields (x: int)
yield ensures |xs| <= 10 && x == start + |xs| - 1
{
var i := 0;
while i < 10 invariant |xs| == i {
x := start + i;
yield;
i := i + 1;
}
}
method Main() {
var i := new Gen(30);
while true
invariant i.Valid() && fresh(i._new)
decreases 10 - |i.xs|
... | iterator Gen(start: int) yields (x: int)
yield ensures |xs| <= 10 && x == start + |xs| - 1
{
var i := 0;
while i < 10 invariant |xs| == i {
x := start + i;
yield;
i := i + 1;
}
}
method Main() {
var i := new Gen(30);
while true
{
var m := i.MoveNext();
if (!m) {break; }
print i.x;... |
012 | CSC8204-Dafny_tmp_tmp11yhjb53_stack.dfy | /*
Dafny Tutorial 2: Sequences and Stacks, Predicates and Assertions
In this tutorial we introduce a simple stack model using the functional
style of programming.
*/
type intStack = seq<int>
function isEmpty(s: intStack): bool
{
|s| == 0
}
function push(s: intStack, x: int): intStack
{
s + [x]
}
... | /*
Dafny Tutorial 2: Sequences and Stacks, Predicates and Assertions
In this tutorial we introduce a simple stack model using the functional
style of programming.
*/
type intStack = seq<int>
function isEmpty(s: intStack): bool
{
|s| == 0
}
function push(s: intStack, x: int): intStack
{
s + [x]
}
... |
013 | CSU55004---Formal-Verification_tmp_tmp4ki9iaqy_Project_Project_Part_1_project_pt_1.dfy | //This method should return true iff pre is a prefix of str. That is, str starts with pre
method isPrefix(pre:string, str:string) returns(res:bool)
requires 0 < |pre| <= |str| //This line states that this method requires that pre is less than or equal in length to str. Without this line, an out of bounds error is s... | //This method should return true iff pre is a prefix of str. That is, str starts with pre
method isPrefix(pre:string, str:string) returns(res:bool)
requires 0 < |pre| <= |str| //This line states that this method requires that pre is less than or equal in length to str. Without this line, an out of bounds error is s... |
014 | CVS-Projto1_tmp_tmpb1o0bu8z_Hoare.dfy | method Max (x: nat, y:nat) returns (r:nat)
ensures (r >= x && r >=y)
ensures (r == x || r == y)
{
if (x >= y) { r := x;}
else { r := y;}
}
method Test ()
{
var result := Max(42, 73);
assert result == 73;
}
method m1 (x: int, y: int) returns (z: int)
requires 0 < x < y
ensures z >= 0 && z <= y ... | method Max (x: nat, y:nat) returns (r:nat)
ensures (r >= x && r >=y)
ensures (r == x || r == y)
{
if (x >= y) { r := x;}
else { r := y;}
}
method Test ()
{
var result := Max(42, 73);
}
method m1 (x: int, y: int) returns (z: int)
requires 0 < x < y
ensures z >= 0 && z <= y && z != x
{
//assume ... |
015 | CVS-Projto1_tmp_tmpb1o0bu8z_fact.dfy | function fact (n:nat): nat
decreases n
{if n == 0 then 1 else n * fact(n-1)}
function factAcc (n:nat, a:int): int
decreases n
{if (n==0) then a else factAcc(n-1,n*a)}
function factAlt(n:nat):int
{factAcc(n,1)}
lemma factAcc_correct (n:nat, a:int)
ensures factAcc(n, a) == a*fact(n)
{
}
lemma factAlt_correct (n:na... | function fact (n:nat): nat
{if n == 0 then 1 else n * fact(n-1)}
function factAcc (n:nat, a:int): int
{if (n==0) then a else factAcc(n-1,n*a)}
function factAlt(n:nat):int
{factAcc(n,1)}
lemma factAcc_correct (n:nat, a:int)
ensures factAcc(n, a) == a*fact(n)
{
}
lemma factAlt_correct (n:nat)
ensures factAlt(n) == ... |
016 | CVS-Projto1_tmp_tmpb1o0bu8z_proj1_proj1.dfy | //Exercicio 1.a)
function sum (a:array<int>, i:int, j:int) :int
decreases j
reads a
requires 0 <= i <= j <= a.Length
{
if i == j then
0
else
a[j-1] + sum(a, i, j-1)
}
//Exercicio 1.b)
method query (a:array<int>, i:int, j:int) returns (s:int)
requires 0 <= i <= j <= a.Length
ensures s == sum(a, ... | //Exercicio 1.a)
function sum (a:array<int>, i:int, j:int) :int
reads a
requires 0 <= i <= j <= a.Length
{
if i == j then
0
else
a[j-1] + sum(a, i, j-1)
}
//Exercicio 1.b)
method query (a:array<int>, i:int, j:int) returns (s:int)
requires 0 <= i <= j <= a.Length
ensures s == sum(a, i, j)
{
... |
017 | CVS-Projto1_tmp_tmpb1o0bu8z_searchSort.dfy | method fillK(a: array<int>, n: int, k: int, c: int) returns (b: bool)
requires 0 <= c <= n
requires n == a.Length
{
if c == 0 {
return true;
}
var p := 0;
while p < c
invariant 0 <= p <= c
{
if a[p] != k
{
return false;
... | method fillK(a: array<int>, n: int, k: int, c: int) returns (b: bool)
requires 0 <= c <= n
requires n == a.Length
{
if c == 0 {
return true;
}
var p := 0;
while p < c
{
if a[p] != k
{
return false;
}
p := p + 1;
... |
018 | CVS-handout1_tmp_tmptm52no3k_1.dfy | /* Cumulative Sums over Arrays */
/*
Daniel Cavalheiro 57869
Pedro Nunes 57854
*/
//(a)
function sum(a: array<int>, i: int, j: int): int
reads a
requires 0 <= i <= j <= a.Length
decreases j - i
{
if (i == ... | /* Cumulative Sums over Arrays */
/*
Daniel Cavalheiro 57869
Pedro Nunes 57854
*/
//(a)
function sum(a: array<int>, i: int, j: int): int
reads a
requires 0 <= i <= j <= a.Length
{
if (i == j) then 0
else a... |
019 | CVS-handout1_tmp_tmptm52no3k_2.dfy | /* Functional Lists and Imperative Arrays */
/*
Daniel Cavalheiro 57869
Pedro Nunes 57854
*/
datatype List<T> = Nil | Cons(head: T, tail: List<T>)
function length<T>(l: List<T>): nat
{
match l
case Nil => 0
case Cons(_... | /* Functional Lists and Imperative Arrays */
/*
Daniel Cavalheiro 57869
Pedro Nunes 57854
*/
datatype List<T> = Nil | Cons(head: T, tail: List<T>)
function length<T>(l: List<T>): nat
{
match l
case Nil => 0
case Cons(_... |
020 | Clover_abs.dfy | method Abs(x: int) returns (y: int)
ensures x>=0 ==> x==y
ensures x<0 ==> x+y==0
{
if x < 0 {
return -x;
} else {
return x;
}
}
| method Abs(x: int) returns (y: int)
ensures x>=0 ==> x==y
ensures x<0 ==> x+y==0
{
if x < 0 {
return -x;
} else {
return x;
}
}
|
021 | Clover_all_digits.dfy | method allDigits(s: string) returns (result: bool)
ensures result <==> (forall i :: 0 <= i < |s| ==> s[i] in "0123456789")
{
result:=true ;
for i := 0 to |s|
invariant result <==> (forall ii :: 0 <= ii < i ==> s[ii] in "0123456789")
{
if ! (s[i] in "0123456789"){
return false;
}
}
}
| method allDigits(s: string) returns (result: bool)
ensures result <==> (forall i :: 0 <= i < |s| ==> s[i] in "0123456789")
{
result:=true ;
for i := 0 to |s|
{
if ! (s[i] in "0123456789"){
return false;
}
}
}
|
022 | Clover_array_append.dfy | method append(a:array<int>, b:int) returns (c:array<int>)
ensures a[..] + [b] == c[..]
{
c := new int[a.Length+1];
var i:= 0;
while (i < a.Length)
invariant 0 <= i <= a.Length
invariant forall ii::0<=ii<i ==> c[ii]==a[ii]
{
c[i] := a[i];
i:=i+1;
}
c[a.Length]:=b;
}
| method append(a:array<int>, b:int) returns (c:array<int>)
ensures a[..] + [b] == c[..]
{
c := new int[a.Length+1];
var i:= 0;
while (i < a.Length)
{
c[i] := a[i];
i:=i+1;
}
c[a.Length]:=b;
}
|
023 | Clover_array_concat.dfy | method concat(a:array<int>, b:array<int>) returns (c:array<int>)
ensures c.Length==b.Length+a.Length
ensures forall k :: 0 <= k < a.Length ==> c[k] == a[k]
ensures forall k :: 0 <= k < b.Length ==> c[k+a.Length] == b[k]
{
c := new int[a.Length+b.Length];
var i:= 0;
while (i < c.Length)
invariant 0 <= i ... | method concat(a:array<int>, b:array<int>) returns (c:array<int>)
ensures c.Length==b.Length+a.Length
ensures forall k :: 0 <= k < a.Length ==> c[k] == a[k]
ensures forall k :: 0 <= k < b.Length ==> c[k+a.Length] == b[k]
{
c := new int[a.Length+b.Length];
var i:= 0;
while (i < c.Length)
{
c[i] := if i<... |
024 | Clover_array_copy.dfy | method iter_copy<T(0)>(s: array<T>) returns (t: array<T>)
ensures s.Length==t.Length
ensures forall i::0<=i<s.Length ==> s[i]==t[i]
{
t := new T[s.Length];
var i:= 0;
while (i < s.Length)
invariant 0 <= i <= s.Length
invariant forall x :: 0 <= x < i ==> s[x] == t[x]
{
t[i] := s[i];
i:=i+1;
... | method iter_copy<T(0)>(s: array<T>) returns (t: array<T>)
ensures s.Length==t.Length
ensures forall i::0<=i<s.Length ==> s[i]==t[i]
{
t := new T[s.Length];
var i:= 0;
while (i < s.Length)
{
t[i] := s[i];
i:=i+1;
}
}
|
025 | Clover_array_product.dfy | method arrayProduct(a: array<int>, b: array<int>) returns (c: array<int> )
requires a.Length==b.Length
ensures c.Length==a.Length
ensures forall i:: 0 <= i< a.Length==> a[i] * b[i]==c[i]
{
c:= new int[a.Length];
var i:=0;
while i<a.Length
invariant 0<=i<=a.Length
invariant forall j:: 0 <= j< i==> a[... | method arrayProduct(a: array<int>, b: array<int>) returns (c: array<int> )
requires a.Length==b.Length
ensures c.Length==a.Length
ensures forall i:: 0 <= i< a.Length==> a[i] * b[i]==c[i]
{
c:= new int[a.Length];
var i:=0;
while i<a.Length
{
c[i]:=a[i]*b[i];
i:=i+1;
}
}
|
026 | Clover_array_sum.dfy | method arraySum(a: array<int>, b: array<int>) returns (c: array<int> )
requires a.Length==b.Length
ensures c.Length==a.Length
ensures forall i:: 0 <= i< a.Length==> a[i] + b[i]==c[i]
{
c:= new int[a.Length];
var i:=0;
while i<a.Length
invariant 0<=i<=a.Length
invariant forall j:: 0 <= j< i==> a[j] +... | method arraySum(a: array<int>, b: array<int>) returns (c: array<int> )
requires a.Length==b.Length
ensures c.Length==a.Length
ensures forall i:: 0 <= i< a.Length==> a[i] + b[i]==c[i]
{
c:= new int[a.Length];
var i:=0;
while i<a.Length
{
c[i]:=a[i]+b[i];
i:=i+1;
}
}
|
027 | Clover_avg.dfy | method ComputeAvg(a: int, b: int) returns (avg:int)
ensures avg == (a+b)/2
{
avg:= (a + b) / 2;
}
| method ComputeAvg(a: int, b: int) returns (avg:int)
ensures avg == (a+b)/2
{
avg:= (a + b) / 2;
}
|
028 | Clover_below_zero.dfy | method below_zero(operations: seq<int>) returns (s:array<int>, result:bool)
ensures s.Length == |operations| + 1
ensures s[0]==0
ensures forall i :: 0 <= i < s.Length-1 ==> s[i+1]==s[i]+operations[i]
ensures result == true ==> (exists i :: 1 <= i <= |operations| && s[i] < 0)
ensures result == false ==> forall... | method below_zero(operations: seq<int>) returns (s:array<int>, result:bool)
ensures s.Length == |operations| + 1
ensures s[0]==0
ensures forall i :: 0 <= i < s.Length-1 ==> s[i+1]==s[i]+operations[i]
ensures result == true ==> (exists i :: 1 <= i <= |operations| && s[i] < 0)
ensures result == false ==> forall... |
029 | Clover_binary_search.dfy | method BinarySearch(a: array<int>, key: int) returns (n: int)
requires forall i,j :: 0<=i<j<a.Length ==> a[i]<=a[j]
ensures 0<= n <=a.Length
ensures forall i :: 0<= i < n ==> a[i] < key
ensures n == a.Length ==> forall i :: 0 <= i < a.Length ==> a[i] < key
ensures forall i :: n<= i < a.Length ==> a[i]>=key
{
... | method BinarySearch(a: array<int>, key: int) returns (n: int)
requires forall i,j :: 0<=i<j<a.Length ==> a[i]<=a[j]
ensures 0<= n <=a.Length
ensures forall i :: 0<= i < n ==> a[i] < key
ensures n == a.Length ==> forall i :: 0 <= i < a.Length ==> a[i] < key
ensures forall i :: n<= i < a.Length ==> a[i]>=key
{
... |
030 | Clover_bubble_sort.dfy | method BubbleSort(a: array<int>)
modifies a
ensures forall i,j::0<= i < j < a.Length ==> a[i] <= a[j]
ensures multiset(a[..])==multiset(old(a[..]))
{
var i := a.Length - 1;
while (i > 0)
invariant i < 0 ==> a.Length == 0
invariant -1 <= i < a.Length
invariant forall ii,jj::i <= ii< jj <a.Length ==... | method BubbleSort(a: array<int>)
modifies a
ensures forall i,j::0<= i < j < a.Length ==> a[i] <= a[j]
ensures multiset(a[..])==multiset(old(a[..]))
{
var i := a.Length - 1;
while (i > 0)
{
var j := 0;
while (j < i)
{
if (a[j] > a[j + 1])
{
a[j], a[j + 1] := a[j + 1], a[j];
... |
031 | Clover_cal_ans.dfy | method CalDiv() returns (x:int, y:int)
ensures x==191/7
ensures y==191%7
{
x, y := 0, 191;
while 7 <= y
invariant 0 <= y && 7 * x + y == 191
{
x := x+1;
y:=191-7*x;
}
}
| method CalDiv() returns (x:int, y:int)
ensures x==191/7
ensures y==191%7
{
x, y := 0, 191;
while 7 <= y
{
x := x+1;
y:=191-7*x;
}
}
|
032 | Clover_cal_sum.dfy | method Sum(N:int) returns (s:int)
requires N >= 0
ensures s == N * (N + 1) / 2
{
var n := 0;
s := 0;
while n != N
invariant 0 <= n <= N
invariant s == n * (n + 1) / 2
{
n := n + 1;
s := s + n;
}
}
| method Sum(N:int) returns (s:int)
requires N >= 0
ensures s == N * (N + 1) / 2
{
var n := 0;
s := 0;
while n != N
{
n := n + 1;
s := s + n;
}
}
|
033 | Clover_canyon_search.dfy | method CanyonSearch(a: array<int>, b: array<int>) returns (d:nat)
requires a.Length !=0 && b.Length!=0
requires forall i,j :: 0<=i<j<a.Length ==> a[i]<=a[j]
requires forall i,j :: 0<=i<j<b.Length ==> b[i]<=b[j]
ensures exists i,j:: 0<=i<a.Length && 0<=j<b.Length && d==if a[i] < b[j] then (b[j]-a[i]) else (a[i]-... | method CanyonSearch(a: array<int>, b: array<int>) returns (d:nat)
requires a.Length !=0 && b.Length!=0
requires forall i,j :: 0<=i<j<a.Length ==> a[i]<=a[j]
requires forall i,j :: 0<=i<j<b.Length ==> b[i]<=b[j]
ensures exists i,j:: 0<=i<a.Length && 0<=j<b.Length && d==if a[i] < b[j] then (b[j]-a[i]) else (a[i]-... |
034 | Clover_compare.dfy | method Compare<T(==)>(a: T, b: T) returns (eq: bool)
ensures a==b ==> eq==true
ensures a!=b ==> eq==false
{
if a == b { eq := true; } else { eq := false; }
}
| method Compare<T(==)>(a: T, b: T) returns (eq: bool)
ensures a==b ==> eq==true
ensures a!=b ==> eq==false
{
if a == b { eq := true; } else { eq := false; }
}
|
035 | Clover_convert_map_key.dfy | method convert_map_key(inputs: map<nat, bool>, f: nat->nat) returns(r:map<nat, bool>)
requires forall n1: nat, n2: nat :: n1 != n2 ==> f(n1) != f(n2)
ensures forall k :: k in inputs <==> f(k) in r
ensures forall k :: k in inputs ==> r[f(k)] == inputs[k]
{
r:= map k | k in inputs :: f(k) := inputs[k];
}
| method convert_map_key(inputs: map<nat, bool>, f: nat->nat) returns(r:map<nat, bool>)
requires forall n1: nat, n2: nat :: n1 != n2 ==> f(n1) != f(n2)
ensures forall k :: k in inputs <==> f(k) in r
ensures forall k :: k in inputs ==> r[f(k)] == inputs[k]
{
r:= map k | k in inputs :: f(k) := inputs[k];
}
|
036 | Clover_copy_part.dfy | method copy( src: array<int>, sStart: nat, dest: array<int>, dStart: nat, len: nat) returns (r: array<int>)
requires src.Length >= sStart + len
requires dest.Length >= dStart + len
ensures r.Length == dest.Length
ensures r[..dStart] == dest[..dStart]
ensures r[dStart + len..] == dest[dStart + len..]
ensures... | method copy( src: array<int>, sStart: nat, dest: array<int>, dStart: nat, len: nat) returns (r: array<int>)
requires src.Length >= sStart + len
requires dest.Length >= dStart + len
ensures r.Length == dest.Length
ensures r[..dStart] == dest[..dStart]
ensures r[dStart + len..] == dest[dStart + len..]
ensures... |
037 | Clover_count_lessthan.dfy | method CountLessThan(numbers: set<int>, threshold: int) returns (count: int)
ensures count == |set i | i in numbers && i < threshold|
{
count := 0;
var shrink := numbers;
var grow := {};
while |shrink | > 0
decreases shrink
invariant shrink + grow == numbers
invariant grow !! shrink
invariant ... | method CountLessThan(numbers: set<int>, threshold: int) returns (count: int)
ensures count == |set i | i in numbers && i < threshold|
{
count := 0;
var shrink := numbers;
var grow := {};
while |shrink | > 0
{
var i: int :| i in shrink;
shrink := shrink - {i};
var grow' := grow+{i};
grow := g... |
038 | Clover_double_array_elements.dfy | method double_array_elements(s: array<int>)
modifies s
ensures forall i :: 0 <= i < s.Length ==> s[i] == 2 * old(s[i])
{
var i:= 0;
while (i < s.Length)
invariant 0 <= i <= s.Length
invariant forall x :: i <= x < s.Length ==> s[x] == old(s[x])
invariant forall x :: 0 <= x < i ==> s[x] == 2 * old(s[x... | method double_array_elements(s: array<int>)
modifies s
ensures forall i :: 0 <= i < s.Length ==> s[i] == 2 * old(s[i])
{
var i:= 0;
while (i < s.Length)
{
s[i] := 2 * s[i];
i := i + 1;
}
} |
039 | Clover_double_quadruple.dfy | method DoubleQuadruple(x: int) returns (a: int, b: int)
ensures a == 2 * x && b == 4 * x
{
a := 2 * x;
b := 2 * a;
}
| method DoubleQuadruple(x: int) returns (a: int, b: int)
ensures a == 2 * x && b == 4 * x
{
a := 2 * x;
b := 2 * a;
}
|
040 | Clover_even_list.dfy | method FindEvenNumbers (arr: array<int>) returns (evenNumbers: array<int>)
ensures forall x {:trigger (x%2) }:: x in arr[..] && (x%2==0)==> x in evenNumbers[..]
ensures forall x :: x !in arr[..] ==> x !in evenNumbers[..]
ensures forall k :: 0 <= k < evenNumbers.Length ==> evenNumbers[k] % 2 == 0
ensures forall... | method FindEvenNumbers (arr: array<int>) returns (evenNumbers: array<int>)
ensures forall x {:trigger (x%2) }:: x in arr[..] && (x%2==0)==> x in evenNumbers[..]
ensures forall x :: x !in arr[..] ==> x !in evenNumbers[..]
ensures forall k :: 0 <= k < evenNumbers.Length ==> evenNumbers[k] % 2 == 0
ensures forall... |
041 | Clover_find.dfy | method Find(a: array<int>, key: int) returns (index: int)
ensures -1<=index<a.Length
ensures index!=-1 ==> a[index]==key && (forall i :: 0 <= i < index ==> a[i] != key)
ensures index == -1 ==> (forall i::0 <= i < a.Length ==> a[i] != key)
{
index := 0;
while index < a.Length
invariant 0<=index<=a.Length
... | method Find(a: array<int>, key: int) returns (index: int)
ensures -1<=index<a.Length
ensures index!=-1 ==> a[index]==key && (forall i :: 0 <= i < index ==> a[i] != key)
ensures index == -1 ==> (forall i::0 <= i < a.Length ==> a[i] != key)
{
index := 0;
while index < a.Length
{
if a[index] == key { retur... |
042 | Clover_has_close_elements.dfy | method has_close_elements(numbers: seq<real>, threshold: real) returns (res: bool)
requires threshold >= 0.0
ensures res ==> exists i: int, j: int :: 0 <= i < |numbers| && 0 <= j < |numbers| && i != j && (if numbers[i] - numbers[j] < 0.0 then numbers[j] - numbers[i] else numbers[i] - numbers[j]) < threshold
ensur... | method has_close_elements(numbers: seq<real>, threshold: real) returns (res: bool)
requires threshold >= 0.0
ensures res ==> exists i: int, j: int :: 0 <= i < |numbers| && 0 <= j < |numbers| && i != j && (if numbers[i] - numbers[j] < 0.0 then numbers[j] - numbers[i] else numbers[i] - numbers[j]) < threshold
ensur... |
043 | Clover_insert.dfy | method insert(line:array<char>, l:int, nl:array<char>, p:int, at:int)
requires 0 <= l+p <= line.Length
requires 0 <= p <= nl.Length
requires 0 <= at <= l
modifies line
ensures forall i :: (0<=i<p) ==> line[at+i] == nl[i]
ensures forall i :: (0<=i<at) ==> line[i] == old(line[i])
ensures forall i :: (at+p<=... | method insert(line:array<char>, l:int, nl:array<char>, p:int, at:int)
requires 0 <= l+p <= line.Length
requires 0 <= p <= nl.Length
requires 0 <= at <= l
modifies line
ensures forall i :: (0<=i<p) ==> line[at+i] == nl[i]
ensures forall i :: (0<=i<at) ==> line[i] == old(line[i])
ensures forall i :: (at+p<=... |
044 | Clover_integer_square_root.dfy | method SquareRoot(N:nat) returns (r:nat)
ensures r*r <= N < (r+1)*(r+1)
{
r:=0;
while (r+1)*(r+1)<=N
invariant r*r<=N
{
r:=r+1;
}
}
| method SquareRoot(N:nat) returns (r:nat)
ensures r*r <= N < (r+1)*(r+1)
{
r:=0;
while (r+1)*(r+1)<=N
{
r:=r+1;
}
}
|
045 | Clover_is_even.dfy | method ComputeIsEven(x:int) returns (is_even:bool)
ensures (x % 2 == 0)==is_even
{
is_even:=false;
if x%2==0{
is_even:=true;
}
}
| method ComputeIsEven(x:int) returns (is_even:bool)
ensures (x % 2 == 0)==is_even
{
is_even:=false;
if x%2==0{
is_even:=true;
}
}
|
046 | Clover_is_palindrome.dfy | method IsPalindrome(x: seq<char>) returns (result: bool)
ensures result <==> (forall i :: 0 <= i < |x| ==> x[i] == x[|x| - i - 1])
{
if |x|==0 {
return true;
}
var i := 0;
var j := |x| - 1;
result := true;
while (i < j)
invariant 0<=i<=j+1 && 0<=j < |x|
invariant i+j==|x|-1
invariant (fora... | method IsPalindrome(x: seq<char>) returns (result: bool)
ensures result <==> (forall i :: 0 <= i < |x| ==> x[i] == x[|x| - i - 1])
{
if |x|==0 {
return true;
}
var i := 0;
var j := |x| - 1;
result := true;
while (i < j)
{
if x[i] != x[j] {
result := false;
return;
}
i := i + ... |
047 | Clover_linear_search1.dfy | method LinearSearch(a: array<int>, e: int) returns (n:int)
ensures 0<=n<=a.Length
ensures n==a.Length || a[n]==e
ensures forall i::0<=i < n ==> e!=a[i]
{
n :=0;
while n!=a.Length
invariant 0<=n<=a.Length
invariant forall i::0<=i<n ==> e!=a[i]
{
if e==a[n]{
return;
}
n:=n+1;
}
}
| method LinearSearch(a: array<int>, e: int) returns (n:int)
ensures 0<=n<=a.Length
ensures n==a.Length || a[n]==e
ensures forall i::0<=i < n ==> e!=a[i]
{
n :=0;
while n!=a.Length
{
if e==a[n]{
return;
}
n:=n+1;
}
}
|
048 | Clover_linear_search2.dfy | method LinearSearch(a: array<int>, e: int) returns (n:int)
requires exists i::0<=i<a.Length && a[i]==e
ensures 0<=n<a.Length && a[n]==e
ensures forall k :: 0 <= k < n ==> a[k]!=e
{
n :=0;
while n!=a.Length
invariant 0<=n<=a.Length
invariant forall i::0<=i<n ==> e!=a[i]
{
if e==a[n]{
retur... | method LinearSearch(a: array<int>, e: int) returns (n:int)
requires exists i::0<=i<a.Length && a[i]==e
ensures 0<=n<a.Length && a[n]==e
ensures forall k :: 0 <= k < n ==> a[k]!=e
{
n :=0;
while n!=a.Length
{
if e==a[n]{
return;
}
n:=n+1;
}
}
|
049 | Clover_linear_search3.dfy | method LinearSearch3<T>(a: array<T>, P: T -> bool) returns (n: int)
requires exists i :: 0 <= i < a.Length && P(a[i])
ensures 0 <= n < a.Length && P(a[n])
ensures forall k :: 0 <= k < n ==> !P(a[k])
{
n := 0;
while true
invariant 0 <= n < a.Length
invariant exists i :: n <= i < a.Length && P(a[i])
... | method LinearSearch3<T>(a: array<T>, P: T -> bool) returns (n: int)
requires exists i :: 0 <= i < a.Length && P(a[i])
ensures 0 <= n < a.Length && P(a[n])
ensures forall k :: 0 <= k < n ==> !P(a[k])
{
n := 0;
while true
{
if P(a[n]) {
return;
}
n := n + 1;
}
}
|
050 | Clover_longest_prefix.dfy | method LongestCommonPrefix(str1: seq<char>, str2: seq<char>) returns (prefix: seq<char>)
ensures |prefix| <= |str1| && prefix == str1[0..|prefix|]&& |prefix| <= |str2| && prefix == str2[0..|prefix|]
ensures |prefix|==|str1| || |prefix|==|str2| || (str1[|prefix|]!=str2[|prefix|])
{
prefix := [];
var minLength :=... | method LongestCommonPrefix(str1: seq<char>, str2: seq<char>) returns (prefix: seq<char>)
ensures |prefix| <= |str1| && prefix == str1[0..|prefix|]&& |prefix| <= |str2| && prefix == str2[0..|prefix|]
ensures |prefix|==|str1| || |prefix|==|str2| || (str1[|prefix|]!=str2[|prefix|])
{
prefix := [];
var minLength :=... |
051 | Clover_match.dfy | method Match(s: string, p: string) returns (b: bool)
requires |s| == |p|
ensures b <==> forall n :: 0 <= n < |s| ==> s[n] == p[n] || p[n] == '?'
{
var i := 0;
while i < |s|
invariant 0 <= i <= |s|
invariant forall n :: 0 <= n < i ==> s[n] == p[n] || p[n] == '?'
{
if s[i] != p[i] && p[i] != '?'
... | method Match(s: string, p: string) returns (b: bool)
requires |s| == |p|
ensures b <==> forall n :: 0 <= n < |s| ==> s[n] == p[n] || p[n] == '?'
{
var i := 0;
while i < |s|
{
if s[i] != p[i] && p[i] != '?'
{
return false;
}
i := i + 1;
}
return true;
}
|
052 | Clover_max_array.dfy | method maxArray(a: array<int>) returns (m: int)
requires a.Length >= 1
ensures forall k :: 0 <= k < a.Length ==> m >= a[k]
ensures exists k :: 0 <= k < a.Length && m == a[k]
{
m := a[0];
var index := 1;
while (index < a.Length)
invariant 0 <= index <= a.Length
invariant forall k :: 0 <= k < index ==... | method maxArray(a: array<int>) returns (m: int)
requires a.Length >= 1
ensures forall k :: 0 <= k < a.Length ==> m >= a[k]
ensures exists k :: 0 <= k < a.Length && m == a[k]
{
m := a[0];
var index := 1;
while (index < a.Length)
{
m := if m>a[index] then m else a[index];
index := index + 1;
}
}
|
053 | Clover_min_array.dfy | method minArray(a: array<int>) returns (r:int)
requires a.Length > 0
ensures forall i :: 0 <= i < a.Length ==> r <= a[i]
ensures exists i :: 0 <= i < a.Length && r == a[i]
{
r:=a[0];
var i:=1;
while i<a.Length
invariant 0 <= i <= a.Length
invariant forall x :: 0 <= x < i ==> r <= a[x]
invariant ... | method minArray(a: array<int>) returns (r:int)
requires a.Length > 0
ensures forall i :: 0 <= i < a.Length ==> r <= a[i]
ensures exists i :: 0 <= i < a.Length && r == a[i]
{
r:=a[0];
var i:=1;
while i<a.Length
{
if r>a[i]{
r:=a[i];
}
i:=i+1;
}
}
|
054 | Clover_min_of_two.dfy | method Min(x: int, y:int) returns (z: int)
ensures x<=y ==> z==x
ensures x>y ==> z==y
{
if x < y {
return x;
} else {
return y;
}
}
| method Min(x: int, y:int) returns (z: int)
ensures x<=y ==> z==x
ensures x>y ==> z==y
{
if x < y {
return x;
} else {
return y;
}
}
|
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
- Downloads last month
- 50