repo stringclasses 966
values | path stringlengths 5 283 | license stringclasses 13
values | stars int64 0 3.47k | default_branch stringclasses 15
values | commit_sha stringclasses 966
values | pushed_at stringdate 2015-04-17 10:56:12 2026-07-22 05:29:38 | size_bytes int64 0 1.91M | sha256 stringlengths 64 64 | content stringlengths 0 1.91M |
|---|---|---|---|---|---|---|---|---|---|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/630-dafny_tmp_tmpz2kokaiq_Solution.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 814 | adda18437b531e1dba736b618cfeaf95f9975f6b9272984eb60b2fb1dff80171 |
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 ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/703FinalProject_tmp_tmpr_10rn4z_DP-GD.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,497 | e10dbfc5ab18bd2d823eb2f2c928a72c53011281e4100a2ebf4b80e2540f1d0a | 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> := ne... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/703FinalProject_tmp_tmpr_10rn4z_gaussian.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,069 | a23bfddab22ad02466e59fc6578e93b695cdb6d3a14fde64d3da0d77d9a5acc6 | // 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/assertive-programming-assignment-1_tmp_tmp3h_cj44u_FindRange.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,051 | 6c8242c5a5b04fed8e52f489b20d1d345b15d5b32d2e964285147e9b7400c9e6 | method Main()
{
var q := [1,2,2,5,10,10,10,23];
assert Sorted(q);
assert 10 in q;
var i,j := FindRange(q, 10);
print "The number of occurrences of 10 in the sorted sequence [1,2,2,5,10,10,10,23] is ";
print j-i;
print " (starting at index ";
print i;
print " and ending in ";
print j;
print ").\n"... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/assertive-programming-assignment-1_tmp_tmp3h_cj44u_ProdAndCount.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 9,070 | 2fcfb195817014e30c0d4b0a1f6ec5765bbe7f4123269e03dbcaa40519a92d6f | method Main() {
var q := [7, -2, 3, -2];
var p, c := ProdAndCount(q, -2);
print "The product of all positive elements in [7,-2,3,-2] is ";
print p;
assert p == RecursivePositiveProduct(q) == 21;
print "\nThe number of occurrences of -2 in [7,-2,3,-2] is ";
print c;
assert c == RecursiveCount(-2, q) ==... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/assertive-programming-assignment-1_tmp_tmp3h_cj44u_SearchAddends.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,160 | 938cda09236fbcea07b3b338c18abdf0262f1a545495cd3b74bcadb705a9f67a | method Main()
{
var q := [1,2,4,5,6,7,10,23];
assert Sorted(q);
assert HasAddends(q,10) by { assert q[2]+q[4] == 4+6 == 10; }
var i,j := FindAddends(q, 10);
print "Searching for addends of 10 in q == [1,2,4,5,6,7,10,23]:\n";
print "Found that q[";
print i;
print "] + q[";
print j;
print "] == ";
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/AssertivePrograming_tmp_tmpwf43uz0e_DivMode_Unary.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 9,865 | fa558174456d29b4d75529ddc566f1f9a1e81ba51243c751c10034840fde0059 | // 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
cas... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/AssertivePrograming_tmp_tmpwf43uz0e_Find_Substring.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 10,539 | cf1920fa552902c699a7199e8a0ff842309f0ac782be84eec400bda9a1a33f5c | // 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/AssertivePrograming_tmp_tmpwf43uz0e_MergeSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,557 | ddd794da99071a0c1a41068950ea412e2221739676bb0ed8fc5acb8ff03dd356 | // 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 arr... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/bbfny_tmp_tmpw4m0jvl0_enjoying.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,146 | fa714f039c4776143231cb3c20611dc88e0b6e7493bcce8da3dc812c2a71d889 | // shenanigans going through the dafny tutorial
method MultipleReturns(x: int, y: int) returns (more: int, less: int)
requires 0 < y
ensures less < x < more
{
more := x + y;
less := x - y;
}
method Max(a: int, b: int) returns (c: int)
ensures a <= c && b <= c
ensures a == c || b == c
{
if ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/BelowZero.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,010 | cd145cfad0c1c0d62391aa2c27d201c6c197bb47db5a3a03c408d4cea02d2ee6 | /*
HumanEvalX 3
You're given a list of deposit and withdrawal operations on a bank account that starts with zero balance.
Your task is to detect if at any point the balance of account falls below zero, and at that point function
should return True. Otherwise it should return False.
*/
function sum(s: seq<int... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/BinaryAddition.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,224 | ba0127e99d7c21355bc3cb2d78450c847ea5aa2f98dd726436c61f659da694be | /*
MIPS 0
We implement the following with bitvectors in Dafny.
here s' and t' are converted to decimal scalars
s = [1,1,1], t = [1,0,1], ys = [1, 0, 0], s' = 7, t' = 5, ys' = 4
ys' % 2 ^ (len(s)) = (s' + t') % 2 ^ (len(s))
4 % 8 = 12 % 8
def f(s,t):
a = 0;b = 0;
ys = []
for i in range(10):
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/BinarySearchTree_tmp_tmp_bn2twp5_bst4copy.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,649 | 91a952cb371d1f3b2a79fab4b5e1a763879b111d5d400e506feaaf731cab3786 | 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)
&& Bin... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/BPTree-verif_tmp_tmpq1z6xm1d_Utils.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 12,747 | 4bb0d3cc0290b0b1359a82d0e8bf418aa7c1f61554099268bef7ab8ec30704ba |
// 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 ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/circular-queue-implemetation_tmp_tmpnulfdc9l_Queue.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,833 | fd81b96ae4b695171571508b8a2e6c48f965cdf847368898e44b910096a9e1b7 | class {:autocontracts} Queue {
// Atributos
var circularQueue: array<int>;
var rear: nat; // cauda
var front: nat; // head
var counter: nat;
// Abstração
ghost var Content: seq<int>;
// Predicado
ghost predicate Valid()
{
0 <= counter <= circularQueue.Length &&
0 <= front ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_abs.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 156 | 3135656fdd9304a7d404c00515091a8d9d449cabc89d34f20c60ea582073223b | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_all_digits.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 327 | 5cb195143990735cd15cd9f74694f015f5d3183b78206d474798cf4e6b6a307c | 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;
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_array_append.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 311 | cd34667c4991bbeeeff7c381fe8f9067cf65a45caf2af5ad2c3394f055a05564 | 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;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_array_concat.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 510 | 64b7a0fc31547ab46ebc41b164e78a3e96f23046624f50514db9aee5d8574c9e | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_array_copy.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 339 | a3c2f39d3058401fdb9459b6d5f57fa21ee975d0f3c310f7c2429de2921090f3 | 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];
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_array_product.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 394 | d9eb7da51c23baa273141937557772f6fd930a7c349aa623ad8f86818599dc1e | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_array_sum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 390 | 472e17cff49f45604695afd84700642e673a5e914058eab619809ce74fb4930c | 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=... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_avg.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 107 | 95b30bd2cbfc3668e9e025bfe4aa881752abe87866f549f3ee03d33dbff2da79 | method ComputeAvg(a: int, b: int) returns (avg:int)
ensures avg == (a+b)/2
{
avg:= (a + b) / 2;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_below_zero.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 948 | 31e7543623fde113f1f4879af400d5a66861a0649a674da640b4bdba3e1b7208 | 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 ==> f... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_binary_search.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 658 | 6239a9c7d3b6c73f091c4325c430777ba6b58987518b9b078c2f7ed3c4369e8f | 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]>=k... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_bubble_sort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 950 | 1ab24c80531c642c1b739387bfbcd12d95ef57c97c38e1383ef806c15eb0eb94 | 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.... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_cal_ans.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 207 | a48ee168d4cf65f6c654a56f58d38c0fd273cde6c4eda7cbe28f6427c4549b5a | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_cal_sum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 241 | 65d911cb74022458a7b1cd9ca6118c625ed3c8f5c94ab894ad50ceeef80b48fe | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_canyon_search.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,081 | 2e607522773a8c6bb2513d55370cbf93468c025db48dfb8805cbfb972429b198 | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_compare.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 170 | 28f48c96dc41c3b9ab45595bed1c124b66a99c4f8cdfdb61cef9bc7ca37b37d4 | 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; }
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_convert_map_key.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 319 | 879c76512b838d9d7fa13d72a82f4e278fabf90a1503b16e9b46c31337d1d5c5 | 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];
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_copy_part.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 982 | 49019a85d5f6e66939161922553de60fa7625c14a281143b278c0bbd07a186ed | 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..]
e... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_count_lessthan.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 701 | 604a115c71b27c5c0f5f5f6f5a0d843b444b62be5cab7e45fc3158fd830f161a | 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
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_double_array_elements.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 386 | 1a39cc0dedbf24d2223fafaa268132f52faf07d521aa359d64ef5436611b8233 | 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 *... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_double_quadruple.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 129 | 99e8223e5246886ce990cc2aae6031ea75c214c0f73b1073d91f27bc5013f00c | method DoubleQuadruple(x: int) returns (a: int, b: int)
ensures a == 2 * x && b == 4 * x
{
a := 2 * x;
b := 2 * a;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_even_list.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,450 | e23498003ef7e6c3ab2e2720e6d8637b0f14a9f78a992d94d6ce8566c3396f83 | 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 fo... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_find.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 507 | 333c9d627f7a370395552bab00b4d9ba8fd2cfde2ac17c3780f8acd1b99bc770 | 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.L... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_has_close_elements.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,430 | bdfd77043ef18298dfe87bb090b91e79190b5ea81e1b9447cc8796bda51b8223 | 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
en... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_insert.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,098 | 077fbf3c1552470555950601e138a462abc1825ff467ac7cc418347b883eba03 | 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 :: ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_integer_square_root.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 160 | 1facc004d0075ec7071d787a69a593184d34146ba9f985ec25c201bef96ccf73 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_is_even.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 149 | 6547cc990fad3369a12fe7e0c40cc9390efca3053c22d1d4524bd26a02e47116 | method ComputeIsEven(x:int) returns (is_even:bool)
ensures (x % 2 == 0)==is_even
{
is_even:=false;
if x%2==0{
is_even:=true;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_is_palindrome.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 496 | d7e4d6dca050861c1e75379158f534d5226fc2edc5275f3865e2a4316f9828aa | 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
inv... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_linear_search1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 335 | 1a57f59eb91ccf446d45e4ec6bdbaff73d1ca961b3944f3c6875ef6fe213e5a6 | 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:... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_linear_search2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 364 | b38695107c0974f3bc9df11128788aa852ac50730aa8be04811e9bef40988088 | 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]{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_linear_search3.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 476 | 56e9193fd28b314495cc5cba217686b81b1e42f6f9bf354d00c123a7591ac58f | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_longest_prefix.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 694 | 64238f0c05a30211bde80a75f25d49abb5279c062c3a187d4a484b62b479b6b9 | 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 minLeng... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_match.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 403 | 533684d6c2247c0e7e945695c3a98fc5d58f16af79df9a06bd5f989f057bb025 | 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] !... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_max_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 514 | 33206f3d6cdfcdadfbd1be0a360fbda1edfc438a93946198e1a5fb961ca0dba0 | 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 <... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_min_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 432 | dd0ad0bab42395c336efa7e7268e8b44cea77e9908a7422f788d4ebf0feb4707 | 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]
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_min_of_two.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 160 | 6e72f8c568fa9e9c6a6baa044d044b5ea1e1f138450ce840f287f0613b622ce0 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_modify_2d_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 581 | c197c273195de116fc0a48afe374ba940db5c1f587d50278f7be18d356b95632 | method modify_array_element(arr: array<array<nat>>, index1: nat, index2: nat, val: nat)
requires index1 < arr.Length
requires index2 < arr[index1].Length
requires forall i: nat, j:nat :: i < arr.Length && j < arr.Length && i != j ==> arr[i] != arr[j]
modifies arr[index1]
ensures forall i: nat :: 0 <= i <... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_multi_return.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 159 | 5f32c66d1ffb53a2e2b8079410fcb355f4ebe03ec3eb16ea6c3f1b1fdab4717b | method MultipleReturns(x: int, y: int) returns (more: int, less: int)
ensures more == x+y
ensures less == x-y
{
more := x + y;
less := x - y;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_online_max.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 813 | 7a3ef5fd285a81eb986f6db629e01cb639865b117aaf6aefa16000252d57c0c8 | method onlineMax(a: array<int>, x: int) returns (ghost m:int, p:int)
requires 1<=x<a.Length
requires a.Length!=0
ensures x<=p<a.Length
ensures forall i::0<=i<x==> a[i]<=m
ensures exists i::0<=i<x && a[i]==m
ensures x<=p<a.Length-1 ==> (forall i::0<=i<p ==> a[i]<a[p])
ensures (forall i::x<=i<a.Lengt... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_only_once.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 517 | aec8fed3af6bf016c31817f6c15f700c3e477691d46f2392cf51ce6e296bdc15 | method only_once<T(==)>(a: array<T>, key: T) returns (b:bool)
ensures (multiset(a[..])[key] ==1 ) <==> b
{
var i := 0;
b := false;
var keyCount := 0;
while i < a.Length
invariant 0 <= i <= a.Length
invariant multiset(a[..i])[key] == keyCount
invariant b <==> (keyCount == 1)
{
if (... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_quotient.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 249 | f6404f6dae096bf192776419c21923b0ed689e46541dde79790091ce8f2cc261 | method Quotient(x: nat, y:nat) returns (r:int, q:int)
requires y != 0
ensures q * y + r == x && 0 <= r < y && 0 <= q
{
r:=x;
q:=0;
while y<=r
invariant q*y+r==x && r>=0
decreases r
{
r:=r-y;
q:=q+1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_remove_front.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 313 | ab752b4b2db293684fd7432778da10277d1d4839dfc46e60e87a1e633059e76b | method remove_front(a:array<int>) returns (c:array<int>)
requires a.Length>0
ensures a[1..] == c[..]
{
c := new int[a.Length-1];
var i:= 1;
while (i < a.Length)
invariant 1 <= i <= a.Length
invariant forall ii::1<=ii<i ==> c[ii-1]==a[ii]
{
c[i-1] := a[i];
i:=i+1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_replace.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 647 | 923f5b3a758b955b95cfd37717bb2df46d9edf7eb10ea8127a58989bbe5d341c | method replace(arr: array<int>, k: int)
modifies arr
ensures forall i :: 0 <= i < arr.Length ==> old(arr[i]) > k ==> arr[i] == -1
ensures forall i :: 0 <= i < arr.Length ==> old(arr[i]) <= k ==> arr[i] == old(arr[i])
{
var i := 0;
while i < arr.Length
decreases arr.Length - i
invariant 0 <= i ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_return_seven.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 80 | 09076ecfd1df4d2f9fc4534f7c5c3117b32245ede3acb1e0df43ad204ad06fa4 | method M(x: int) returns (seven: int)
ensures seven==7
{
seven := 7;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_reverse.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 462 | 40e051d230bb1fbeb802641e002799b0190ddbdca2ee3503158d507c364ac364 | method reverse(a: array<int>)
modifies a
ensures forall i :: 0 <= i < a.Length ==> a[i] == old(a[a.Length - 1 - i])
{
var i := 0;
while i <a.Length / 2
invariant 0 <= i <= a.Length/2
invariant forall k :: 0 <= k < i || a.Length-1-i < k <= a.Length-1 ==> a[k] == old(a[a.Length-1-k])
invariant... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_rotate.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 406 | 0b0ac638305c3b60037a5ba2b196d0594bcb524f6dbbbb655641ab7dd84cd6f5 | method rotate(a: array<int>, offset:int) returns (b: array<int> )
requires 0<=offset
ensures b.Length==a.Length
ensures forall i::0<=i<a.Length ==> b[i]==a[(i+offset)%a.Length]
{
b:= new int[a.Length];
var i:=0;
while i<a.Length
invariant 0<=i<=a.Length
invariant forall j ::0<=j<i ==> b[j... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_selectionsort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 752 | 50eaf34063ae839dcce903d02bba0edb925f04ec32dbbf656aac5bb104798453 | method SelectionSort(a: array<int>)
modifies a
ensures forall i,j :: 0 <= i < j < a.Length ==> a[i] <= a[j]
ensures multiset(a[..]) == old(multiset(a[..]))
{
var n:= 0;
while n != a.Length
invariant 0 <= n <= a.Length
invariant forall i, j :: 0 <= i < n <= j < a.Length ==> a[i] <= a[j]
in... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_seq_to_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 220 | 47399b6e90060a39aa4feb787bc62d6a92e20c2ab1c8e369d56c4ee9ae966773 | method ToArray<T>(xs: seq<T>) returns (a: array<T>)
ensures fresh(a)
ensures a.Length == |xs|
ensures forall i :: 0 <= i < |xs| ==> a[i] == xs[i]
{
a := new T[|xs|](i requires 0 <= i < |xs| => xs[i]);
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_set_to_seq.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 297 | c2e89c5bd08ff0a36d3e22b5a348b7772b476786b556a3ad2d72945a4aef297e | method SetToSeq<T>(s: set<T>) returns (xs: seq<T>)
ensures multiset(s) == multiset(xs)
{
xs := [];
var left: set<T> := s;
while left != {}
invariant multiset(left) + multiset(xs) == multiset(s)
{
var x :| x in left;
left := left - {x};
xs := xs + [x];
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_slope_search.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 661 | c193b2eb1815ed0919242780eb494911b769f6ed0bb2163f689dbefb84dcf406 | method SlopeSearch(a: array2<int>, key: int) returns (m:int, n:int)
requires forall i,j,j'::0<=i<a.Length0 && 0<=j<j'<a.Length1 ==> a[i,j]<=a[i,j']
requires forall i,i',j::0<=i<i'<a.Length0 && 0<=j<a.Length1 ==> a[i,j]<=a[i',j]
requires exists i,j :: 0<=i<a.Length0 && 0<=j<a.Length1 && a[i,j]==key
ensures 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_swap.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 181 | fab8f21b6aa418e80367d20393e0631d7a1e49d80f20ef3c9deb47d17aaba592 | method Swap(X: int, Y: int) returns(x: int, y: int)
ensures x==Y
ensures y==X
{
x, y := X, Y;
var tmp := x;
x := y;
y := tmp;
assert x == Y && y == X;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_swap_arith.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 169 | 3514b5564d9cff3d7abb713f5e9813cf44596c19110ea73ed89a6b36c9755977 | method SwapArithmetic(X: int, Y: int) returns(x: int, y: int)
ensures x==Y
ensures y==X
{
x, y := X, Y;
x := y - x;
y := y - x;
x := y + x;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_swap_bitvector.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 167 | 74f25e2f9daa287010a77c8179908792287a2de3a6bec9264122b1a16dddfade | method SwapBitvectors(X: bv8, Y: bv8) returns(x: bv8, y: bv8)
ensures x==Y
ensures y==X
{
x, y := X, Y;
x := x ^ y;
y := x ^ y;
x := x ^ y;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_swap_in_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 331 | 897ebb10b2f8e5c25e8d925dc99bc5c9144d6ffcdcd08cc43735d19c6af45011 | method swap(arr: array<int>, i: int, j: int)
requires 0 <= i < arr.Length && 0 <= j < arr.Length
modifies arr
ensures arr[i] == old(arr[j]) && arr[j] == old(arr[i])
ensures forall k :: 0 <= k < arr.Length && k != i && k != j ==> arr[k] == old(arr[k])
{
var tmp := arr[i];
arr[i] := arr[j];
arr[j] :... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_swap_sim.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 137 | 6225a9dc04cbc3786ba745278f59517f2234f109dfa6778e037398f244423ee0 | method SwapSimultaneous(X: int, Y: int) returns(x: int, y: int)
ensures x==Y
ensures y==X
{
x, y := X, Y;
x, y := y, x;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_test_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 206 | 6f22f13c7ce79486dc1f96b5c0d6aba3131b9a6d9ee71e14bc4b6decfbf9e6ab | method TestArrayElements(a:array<int>, j: nat)
requires 0<=j < a.Length
modifies a
ensures a[j] == 60
ensures forall k :: 0 <= k < a.Length && k != j ==> a[k] == old(a[k])
{
a[j] := 60;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_triple.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 75 | e81044f829f0ba05d358f4db6573b26630cd8942c6369c6698bba5a657d01d7e | method Triple (x:int) returns (r:int)
ensures r==3*x
{
r:= x*3;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_triple2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 194 | cd8d31a25838a20c7549f435e0ec311fa3924e68a242c2ccf4c3760b810467e6 | method Triple (x:int) returns (r:int)
ensures r==3*x
{
if {
case x<18 =>
var a,b := 2*x, 4*x;
r:=(a+b)/2;
case 0<=x =>
var y:=2*x;
r:= x+y;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_triple3.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 137 | ed5f73597cf8b0535a5529df1c487fc163905b317ba36aa3b4b63bae3b37b33c | method Triple (x:int) returns (r:int)
ensures r==3*x
{
if x==0 {
r:=0;
}
else{
var y:=2*x;
r:= x+y;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_triple4.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 92 | f1d38c3afeeda3fe58130df04e6d1e45b03245e59e525951b6e957654222559d | method Triple (x:int) returns (r:int)
ensures r==3*x
{
var y:= x*2;
r := y+x;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_two_sum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 879 | 445f63bb12018d1b96c44e217dd71b651952214a1e6960387397f4ebec819259 | method twoSum(nums: array<int>, target: int) returns (i: int, j: int)
requires nums.Length > 1
requires exists i,j::0 <= i < j < nums.Length && nums[i] + nums[j] == target
ensures 0 <= i < j < nums.Length && nums[i] + nums[j] == target
ensures forall ii,jj:: (0 <= ii < i && ii < jj < nums.Length) ==> nums... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_update_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 254 | 43e7e3aea34430455f388d31ff120f070e327b69243969abbbe98010e2b36e74 | method UpdateElements(a: array<int>)
requires a.Length >= 8
modifies a
ensures old(a[4]) +3 == a[4]
ensures a[7]==516
ensures forall i::0 <= i<a.Length ==> i != 7 && i != 4 ==> a[i] == old(a[i])
{
a[4] := a[4] + 3;
a[7] := 516;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Clover_update_map.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 438 | 5c168c9c8ce124e17d99d3b31ca79e564a820df26d0a8e9dcf23e4eaa2ae887e | method update_map<K(!new), V>(m1: map<K, V>, m2: map<K, V>) returns (r: map<K, V>)
ensures (forall k :: k in m2 ==> k in r)
ensures (forall k :: k in m1 ==> k in r)
ensures (forall k :: k in m2 ==> r[k] == m2[k])
ensures (forall k :: !(k in m2) && k in m1 ==> r[k] == m1[k])
ensures (forall k :: !(k in... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cmsc433_tmp_tmpe3ob3a0o_dafny_project1_p1-assignment-2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,516 | 4d7274fab58865bd9e180e37acf790b1b99e5cd5d9817512fb7d5b8a27ff7d92 | // ASSIGNMENT P1
// CMSC 433 FALL 2023
// PERFECT SCORE: 100 POINTS
//
// This assignment contains nine questions, each of which involves writing Dafny
// code. You should include your solutions in a single Dafny file and submit it using
// Gradescope.
//
// Revision history
//
// 2023-09-22 2:50 pm Fixed ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CO3408-Advanced-Software-Modelling-Assignment-2022-23-Part-2-A-Specification-Spectacular_tmp_tmp4pj4p2zx_car_park.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 11,668 | 8cca6151f3beec20dc6aeb04a3fe3b963e4af15a737d8072e3b262dd7c3b9e7b | 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>;
co... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Correctness_tmp_tmpwqvg5q_4_HoareLogic_exam.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,000 | c0d683d99740422d4160422d458ad7bbac2a2bc00b6be1b9b07d62d28a910022 | // Redo for exam
function gcd(a: nat, b: nat): nat
lemma r1(a: nat)
ensures gcd(a, 0) == a
lemma r2(a:nat)
ensures gcd(a, a) == a
lemma r3(a: nat, b: nat)
ensures gcd(a, b) == gcd(b, a)
lemma r4 (a: nat, b: nat)
ensures b > 0 ==> gcd(a, b) == gcd(b, a % b)
method GCD1(a: int, b: in... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Correctness_tmp_tmpwqvg5q_4_MethodCalls_q1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,752 | 010e28fa3a1ac2728b1fcf0cec0f8762d8ebcd72d18a41420da1a0902fecb2f0 | /**
(a) Verify whether or not the following program
satisfies total correctness.
You should use weakest precondition reasoning
and may extend the loop invariant if required.
You will need to add a decreases clause to prove termination
(a) Weakest precondition proof (without termination... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Correctness_tmp_tmpwqvg5q_4_Sorting_Tangent.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,937 | e5e7ccb618bcfceca4e5de13ad7f02f47c704906efa6d57704e09e007c9790d6 | /**
Ather, Mohammad Faiz (s4648481/3)
CSSE3100
Assignemnt 3
The University of Queensland
*/
// Question 1
method Tangent(r: array<int>, x: array<int>)
returns (found: bool)
requires forall i:: 1 <= i < x.Length ==>
x[i-1] < x[i]
requires forall i, j ::
0 <= i < j < x.... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_A8_Q1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,602 | 5ec27849ec68c0a01ef2d0f0af1f7016ee8b762934bb77a831c2d0aebb4df2ab | // A8Q1 — Steph Renee McIntyre
// Following the solutions from Carmen Bruni
// There is no definition for power, so this function will be used for validating that our imperative program is correct. This is just for Dafny.
function power(a: int, n: int): int //function for a to the power of n
requires 0 <= n;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_A8_Q2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,717 | 468c47480c938023a1c149b8ed33e77faae680c72fc6845bef0a8b65ce9261fd | // A8Q2 — Steph Renee McIntyre
// Following the solutions from Carmen Bruni
method A8Q1(x: int, y: int, z: int) returns (m: int)
/*Pre-Condition*/ requires true;
/*Post-Condition*/ ensures m<=x && m<=y && m<=z;
{
/* (| true |) - Pre-Condition */
if(z<y){
/* (| z... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_Assignments_simple.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 561 | 9061d5d26b0fde6ddc49b6575eedd7916f525404b008c39178351d9300dedbba | //Simple Assignment Example -- Steph Renee McIntyre
//Based on the code used in the course overheads for Fall 2018
method simple(y: int) returns (x: int)
requires y==6;
ensures x==7;
{
/* (| y = 6 |) //This is from the requires statement.*/
/* (| y + 1 = 7 |) - implied (a) */ assert y+1 == 7;... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_power.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,357 | 84bee63c1e7e47cd8b676ce9de4957f49819820c8c54e3d10ac040758ee48ac8 | //power -- Stephanie Renee McIntyre
//Based on the code used in the course overheads for Fall 2018
//There is no definition for power, so this function will be used for validating that our imperative program is correct.
function power(a: int, n: int): int //function for a to the power of n
requires 0 <= a && 0 ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_quicksort-partition.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,436 | 70276750d27ce6bcc3d1de7a7067fee61bca122b5cef0a2f0b25c20d71e0430b | // Quicksort Partition -- Stephanie McIntyre
// Based on examples in class
// Parts have been modified cause you know, arrays are different...
method QuicksortPartition(X: array<int>, n: int, p: int) returns (a: int, b: int)
modifies X;
/*Pre-Condition*/ requires X.Length>=1 && n == X.Length;
/*Post-Condi... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_SortingIssues_BubbleSortCode.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 724 | 4d06c7ada2b65dca91fd4e24412b546697f246b44ee0529d03e5dc54eca1ec14 | // Sorting:
// Pre/Post Condition Issues - An investigation
// -- Stephanie McIntyre
// Based on examples in class
// The following is just plain old bubble sort.
//
// Can you find the invariants for the while loops?
// Can you annotate this?
// What about the pre... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs245-verification_tmp_tmp0h_nxhqp_SortingIssues_FirstAttempt.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 849 | fcd12494a9af709fb2057b90aa6e525b87176d74c0582223960b0da7cf41806b | // Sorting:
// Pre/Post Condition Issues - An investigation
// -- Stephanie McIntyre
// Based on examples in class
// First Attempt at specifying requirements for sorting array A in incrementing order
// We want our Hoare triple of (|Pre-Condition|) Code (|Post-Cond... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs357_tmp_tmpn4fsvwzs_lab7_question2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 239 | 69f371cb2b6b71b7f9435330a1815273252c8757f8518381148a245ea703e1f9 | method Two(x: int) returns (y: int)
ensures y == x + 1
{
assert true;
var a:= x+1;
assert (a - 1 == 0 ==> x == 0) && (x - 1!= 0 ==> a == x +1);
if(a - 1 == 0){
y:= 1;
} else {
y:= a;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs357_tmp_tmpn4fsvwzs_lab7_question5.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 723 | 174816655239ddfbd38183a53f74f927f4204167b1fa79d6bdb77b9e890cb6b9 | method M1(x: int, y: int) returns (r: int)
ensures r == x*y
decreases x < 0, x
{
if (x == 0){
r:= 0;
} else if( x < 0){
r:= M1(-x, y);
r:= -r;
} else {
r:= M1(x-1, y);
r:= A1(r, y);
}
}
method A1(x: int, y: int) returns (r: int)
ensures r == x + ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CS494-final-project_tmp_tmp7nof55uq_bubblesort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,862 | 9e8a8f2c9750d0b653e8f4df649c2fc92b5cd2f47e2c87dd3e84f90494a443aa | //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
p... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CS5232_Project_tmp_tmpai_cfrng_LFUSimple.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,314 | c53d04b388ec404a4875479754ab32c558618e0094f05ae00595dd17e81e74de | 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;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CS5232_Project_tmp_tmpai_cfrng_test.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 416 | 2a98d790e77daac4ddeb26c58e13a180b8e5f044fc22c64eb5e09a93ef720519 | 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)
decreas... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/cs686_tmp_tmpdhuh5dza_classNotes_notes-9-8-21.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,452 | 92142270a66170ec6746557d509da0a1c4025dc542960c10e14eac15aa4dd882 | // Forall
method Q1(){
var a := new int[6];
a[0], a[1], a[2], a[3], a[4], a[5] := 1,0,0,0,1,1;
var b := new int[3];
b[0], b[1], b[2] := 1, 0, 1;
var j,k := 1,3;
var p,r := 4,5;
// a) All elements in the range a[j..k] == 0
assert(forall i : int :: j<= i <= k ==> a[i] == 0);... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CSC8204-Dafny_tmp_tmp11yhjb53_stack.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 723 | bac2230d8321b247a728335c77d9610c10fe0d2b837a2bb116d96f9f87a641c8 | /*
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
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CSU55004---Formal-Verification_tmp_tmp4ki9iaqy_Project_Project_Part_1_project_pt_1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 7,730 | 45a0b071009585963f1d093b2576a9aab308850deec2e08850ef8ad7e87e64db | //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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CVS-handout1_tmp_tmptm52no3k_1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,930 | 8d27e09600a094ca4a4abba6fe63b81a1cc127097af8304417585ca9c99a2f98 | /* 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
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CVS-handout1_tmp_tmptm52no3k_2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,506 | 382fc572d55dc5a750086dbac17585d70ecad44eaaf1c6a28d0afc4db9b84ab0 | /* 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
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CVS-Projto1_tmp_tmpb1o0bu8z_fact.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,531 | 1e12c44151cf3f11d20554b13a82ef68476c8c865a10d6598092c36060085d46 | 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 factA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.