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/hints_removed/Clover_array_concat_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 390 | 5dc2bdd8861db2172c36e6413873a2e9c59e1482229ab90d2ae57493de53ade5 | 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]... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_array_copy_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 250 | d26c7699843c1f879153b1534db33997ef468f4f2a13274a3b2da2cdce1b1276 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_array_product_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 307 | 13ae56a5963397753c8b80d506c757ee0116a1b155be98d61d93e9426fe957b3 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_array_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 303 | a45525941325fbd04381d40ff51a1201b6418b880889e7a204f3100fcbc82e23 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_below_zero_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 690 | a867fbc0da575c155675230de8800b8084209961b28279dc9515722e95221c19 | 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/hints_removed/Clover_binary_search_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 510 | 4e9313a0d9439503ad0e3bc4fc4dcdd18d3d5cdb723606c1636680bf9c7ecb91 | 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/hints_removed/Clover_bubble_sort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 392 | 1dc6e50deaac74206fe4da59d41b468f096fbef4854aefb049ecab3ef36285af | 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 +... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_cal_ans_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 165 | d1112a8978b1b3d1ad095813dc4cb8e3cf2a7a6c4ceed55679bc9e8c3715cbbc | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_cal_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 178 | f9f28cea1729d0117370d7882517ee1d9e01b8f2ea207b7224733630ad5d8454 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_canyon_search_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 749 | 17331a47c2f38771e3f55b4e31355145ce2c690f4f34a18c43a33c71590801d8 | 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/hints_removed/Clover_copy_part_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 634 | 93a06e3c21dcf32fc5a90620ed985d06839fc4b4a05522e1d847e63306b7889a | 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/hints_removed/Clover_count_lessthan_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 409 | 1aa0db79f34056127f8bac19bc4a509d21fae49f05323874756170f08d562b2b | 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};
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_double_array_elements_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 221 | c9764ffdecf6ef63146d80c26d0d3a9bd75e57a5c1f46417893e95e3ed6ac340 | 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;
}
} |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_even_list_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 807 | 2eac86615b34fc21a19eb22cc8eff8be9f3c021432b138622d33fa9c603a4a8e | 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/hints_removed/Clover_find_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 417 | 1f9c34eb88560bef042bcfd970c61cadd2235bf5a75e0d7d3e8ee6d9cb0acb9a | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_has_close_elements_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 937 | a6ade02abab6f80b8d0405dcfecc4e8ecdb641d4342c8de305c4c98c0f20058f | 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/hints_removed/Clover_insert_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 583 | 22a13591fb2614e7c6f55b4e81d896979cfd3cf08cf008c22f22ceeb5bb13a80 | 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/hints_removed/Clover_integer_square_root_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 138 | 543771d64db93eb74e48d4cf044462adf15c2c027f4181038864b11be9d8fa19 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_is_palindrome_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 364 | 3595f462252c48b6d944e3406cbf6fc45e6b975c8da2ea782acbfa1fa53faa22 | 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;
}... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_linear_search1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 261 | fed5786305d88430fb0728582d3f897520c8fec25bf400dca34915040e744da3 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_linear_search2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 290 | bb3aa30ef275ef323d278531559638366218ec659bcae950417a89998321e4eb | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_linear_search3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 307 | 4659d1b5f31cc97e10821e5ea03998700e5838cf97a582a1919b7f69f1462fd6 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_longest_prefix_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 505 | cd0286edc4f73bb9ae0dfacbc79b33758478ba1fe72232ca42e4f24660647758 | 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/hints_removed/Clover_match_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 304 | cdcbe19b1991237c90952bdb48e1bb74bcc19c3093f67edea8657564adffa9f1 | 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;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_max_array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 333 | 5e31c4400999408f0c5fafbe4ae30c4a153dea832d022ce1e45382fc5e35efd7 | 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 +... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_min_array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 295 | 5064bd7fc6923ecf7c15c6c355b0fa16a2fb663efa60f094f4529a47d40fe9b9 | 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;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_online_max_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 624 | 2463b1b498dc5d1defc686bed9eedd02bdd88e8560e6d20550a2f1cbc59257a9 | 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/hints_removed/Clover_only_once_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 362 | adf9f36e152807f48f94263c1ed1112abc02aaf7282581c3c48e0eda2073d6f2 | 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
{
if (a[i] == key)
{
keyCount := keyCount + 1;
}
if (keyCount == 1)
{ b := true; }
else
{ ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_quotient_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 200 | 9cbd15b0e18885d359f5c75ee1dcb40d285333c56ff48b84fde9e4e6f777df48 | 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
{
r:=r-y;
q:=q+1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_remove_front_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 226 | 0b92a02836d52a7c8b2e1a56a1a466238b92eb1ccacb5bf956f1a7dd9ac32675 | 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)
{
c[i-1] := a[i];
i:=i+1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_replace_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 348 | 3f27a37ccd47dbdcca1869b5b76b329f904098941d1d54723d11b270da8e2f56 | 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
{
if arr[i] > k {
arr[i] := -1;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_reverse_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 249 | 674547bccf5178f386d532941175ec2a6578ea65855a67fd4f2f7d6c640d7f3d | 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
{
a[i], a[a.Length-1-i] := a[a.Length-1-i], a[i];
i := i + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_rotate_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 310 | 87e9e9a31f3caf49481b9bde801df4b8b698d1c4b0fa00aebc079ecfb3f9e6b9 | 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
{
b[i]:=a[(i+offset)%a.Length];
i:=i+1;
}
} |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_selectionsort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 421 | 718b5ba5d6586e95a22317df6596bf67d9af74499d3fe0cc8d8990e3144ec806 | 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
{
var mindex, m := n, n+1;
while m != a.Length
{
if a[m] < a[mindex] {
mindex := ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_set_to_seq_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 237 | fc8d5a6e8de11b0539960f67812ee9f7c41f145cb5725a002f1d89c0b017b64d | method SetToSeq<T>(s: set<T>) returns (xs: seq<T>)
ensures multiset(s) == multiset(xs)
{
xs := [];
var left: set<T> := s;
while left != {}
{
var x :| x in left;
left := left - {x};
xs := xs + [x];
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_slope_search_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 514 | 35f730c14f306a73d19508b31cd6c25a6e70d6db31afed1f0372abe432b11c5e | 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/hints_removed/Clover_swap_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 153 | 38149d3f3cc6ff27ec210c3de3fecc25cee2a9638adabe74718a8d7f6cbb08d0 | 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;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Clover_two_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 648 | 97cf9c2c69a1dd1608203a6365cca7bca8da421462785b83052a6d8b7f728f67 | 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/hints_removed/cmsc433_tmp_tmpe3ob3a0o_dafny_project1_p1-assignment-2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,962 | 23ad2b1a7485ca4d508daa903f9f048519077bd8dae968bbba1eb882ec376d24 | // 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/hints_removed/CO3408-Advanced-Software-Modelling-Assignment-2022-23-Part-2-A-Specification-Spectacular_tmp_tmp4pj4p2zx_car_park_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 10,022 | bac14bc6fc09e30a8add269df99f77dee133da63a471f100f9ac259ca51d92d9 | 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/hints_removed/Correctness_tmp_tmpwqvg5q_4_HoareLogic_exam_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,574 | b39ad447c0243fb9e26d8a384c2e65eeb6fe8d92d1aa26d4a51974885dfbd75c | // 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/hints_removed/Correctness_tmp_tmpwqvg5q_4_MethodCalls_q1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,495 | 78c18d29f6beefa20cc1c325bae75180df3b85fdf77526e127ff8763140876d3 | /**
(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/hints_removed/Correctness_tmp_tmpwqvg5q_4_Sorting_Tangent_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,668 | bca2d1c26b0867651c950181f201fba257a6004ab2804edd4aac64b81c5be3fc | /**
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/hints_removed/cs245-verification_tmp_tmp0h_nxhqp_A8_Q1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,430 | d1082857425adcd4fb6656054a8b6aec4dcbb16ece10ca17ecf20dda58d901ea | // 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/hints_removed/cs245-verification_tmp_tmp0h_nxhqp_power_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,195 | 90babc1ba9ba6fce0d3fb0eeb5a4e96b837c34bf1fa2631774a516131427f175 | //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/hints_removed/cs245-verification_tmp_tmp0h_nxhqp_quicksort-partition_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 978 | 207ecb46692c50ac5d5e9c562387913a849d21e541613aa0768164b78237fa79 | // 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/hints_removed/cs245-verification_tmp_tmp0h_nxhqp_SortingIssues_FirstAttempt_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 786 | 408f9a5619928e9faf0fc6ee26c457123b8ef463472dbd932ab28843c87f1541 | // 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/hints_removed/cs357_tmp_tmpn4fsvwzs_lab7_question2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 155 | 8d3b800320a3dc04e4e6c174c04fce930da091b056c30f139b0de50ae450abb9 | method Two(x: int) returns (y: int)
ensures y == x + 1
{
var a:= x+1;
if(a - 1 == 0){
y:= 1;
} else {
y:= a;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/cs357_tmp_tmpn4fsvwzs_lab7_question5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 583 | 1a1f9c7aedfc8a62317ff3efabaad5cde1be36402703f0e46db128fe08409a21 | method M1(x: int, y: int) returns (r: int)
ensures r == x*y
{
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 + y
{
r:= x;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/CS494-final-project_tmp_tmp7nof55uq_bubblesort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,175 | 196099c1b6f289a8fed433b2eed9cc10ea7bf6ea48944a5d75f5131a4d82ad22 | //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/hints_removed/CS5232_Project_tmp_tmpai_cfrng_LFUSimple_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,949 | 7e3c2ddf5248fddc4135e9274897aee9b1c3df1e56d83b09ae54e3781cd254e4 | 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/hints_removed/CS5232_Project_tmp_tmpai_cfrng_test_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 347 | 7cbf49485ebe43dea6475d2ed517cf9b82d3700681b629a5b6ed30c2933f1512 | 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; ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/cs686_tmp_tmpdhuh5dza_classNotes_notes-9-8-21_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,709 | 2d1930a965cc6d643d51327e5964056ddf5da5dbed6c38821c0cfa1aa749d110 | // 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
// b) All zeros in a occur in the interval a[j..k... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/CSC8204-Dafny_tmp_tmp11yhjb53_stack_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 636 | d32fba3576a15ee73274f7f363a227677e95377862c30c8bc3bb93c57cccca35 | /*
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/hints_removed/CSU55004---Formal-Verification_tmp_tmp4ki9iaqy_Project_Project_Part_1_project_pt_1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 7,256 | 5d4313b1045a2e7042c11a39dfd255b86a142065ffdbe33fa89fc19df196d55a | //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/hints_removed/CVS-handout1_tmp_tmptm52no3k_1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,790 | ffc1a7d01b1e9f19c639293950fd722f7e0639adf6485e42d6ddf64fef132a49 | /* 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) th... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/CVS-handout1_tmp_tmptm52no3k_2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,261 | 034a7a44898cedadd6a5cfcd3bcc37d34714bac0ea8bbeb53f7cda7cd4939572 | /* 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/hints_removed/CVS-Projto1_tmp_tmpb1o0bu8z_fact_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,260 | de2658aced5764c7402ca9a230ff6b9d2992ed9913d0861595d61a12eb079e7c | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/CVS-Projto1_tmp_tmpb1o0bu8z_Hoare_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,513 | 8710764f406968004aa13b1536e0e5630cb48b68955ffad4503fb744bdf85e66 | 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
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/CVS-Projto1_tmp_tmpb1o0bu8z_proj1_proj1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,584 | 7ec508e6cb77e9a3fcb6418b982f74be4bd98cd36ea5cc146f912a171be8f1b7 | //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... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/CVS-Projto1_tmp_tmpb1o0bu8z_searchSort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,098 | fed26700f430bc70bed15b29cb3b66901849d7ed777f0056c6a6e4ce4a58089c | 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;
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafleet_tmp_tmpa2e4kb9v_0001-0050_0001-two-sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,348 | 17b7492890f6adc6ad807edda45d180b7d4faf458ec05ba1dde2651546fc43d0 | /* https://leetcode.com/problems/two-sum/
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Ex... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafleet_tmp_tmpa2e4kb9v_0001-0050_0003-longest-substring-without-repeating-characters_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,295 | 4067a274dab8838aeafdac161e8fb03366a262c724217ddec724877efa3c2b8e | /* https://leetcode.com/problems/longest-substring-without-repeating-characters/
Given a string s, find the length of the longest substring without repeating characters.
Example 1:
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
*/
// a left-inclusive right-exclusive... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafleet_tmp_tmpa2e4kb9v_0001-0050_0005-longest-palindromic-substring_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 14,194 | 720867cf1340503cfe18caf76b3f174491f8b04e2619fd987e69de0630e23149 | /* https://leetcode.com/problems/longest-palindromic-substring/
Given a string s, return the longest palindromic substring in s.
Example 1:
Input: s = "babad"
Output: "bab"
Explanation: "aba" is also a valid answer.
*/
// Specifying the problem: whether `s[i..j]` is palindromic
ghost predicate palindromic... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_ContainerRanks_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 774 | f4f43288ae59ca204dbbfb1f66faac6a65de7d95cd2d93c854a6b92f952f08ec | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
datatype Abc = End | Wrapper(seq<Abc>)
lemma SeqRank0(a: Abc)
ensures a != Wrapper([a])
{
// The reason we need the assert is to match the trigger in the rank axioms produced
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_DividedConstructors_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,043 | d5dda24ec6ceb6a97ec2e36b18415e8c80c84a4226d4ae77caa5d0d5f3fb92c1 | // RUN: %dafny /compile:3 /env:0 /dprint:- "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
method Main() {
var m := new M0.MyClass.Init(20);
print m.a, ", ", m.b, ", ", m.c, "\n";
var r0 := new Regression.A.Make0();
var r1 := new Regression.A.Make1();
print r0.b, ", ", r1.b, "\n";
}
module M0 {
cla... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_ForallCompilationNewSyntax_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,130 | 43fcddb81979649f657ce4fb79ccb4b3d7680e58da92ae291517507f47ed2393 | // RUN: %baredafny run %args --relax-definite-assignment --quantifier-syntax:4 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
method Main() {
var c := new MyClass;
c.arr := new int[10,20];
c.K0(3, 12);
c.K1(3, 12);
c.K2(3, 12);
c.K3(3, 12);
c.K4(12);
c.M();
c.N();
c.P();
c.Q();
}
cl... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_InSetComprehension_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,001 | 55d1885a45602d192b7c1dde4f37587102ca3ed63517d42e92e78d7d6ce0e4ea | // RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" /printTooltips "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
lemma Tests<T>(t: T, uu: seq<T>) returns (z: bool)
requires 10 <= |uu| && uu[4] == t
ensures !z
{
if {
case true =>
z := 72 in set i | 0 <= i < 10;
case true =>
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_PrecedenceLinter_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 11,782 | 7b308d4c416895d3f7601c5ea2b20783abb5743b6038f760d9bccbd5483f3738 | // RUN: %dafny /compile:0 /functionSyntax:4 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
predicate P0(A: bool, B: bool, C: bool) {
A &&
B ==> C // warning: suspicious lack of parentheses (lhs of ==>)
}
predicate P1(A: bool, B: bool, C: bool) {
A && B ==>
C
}
predicate P2(A: bool, B: bool, C: boo... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_SeqFromArray_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,708 | 121e8fe46570f2a812f44fb73b1458a615d11ec4c34b90a1c61cb99cdf68b11a | // RUN: %dafny /compile:3 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// /autoTriggers:1 added to suppress instabilities
method Main() { }
method H(a: array<int>, c: array<int>, n: nat, j: nat)
requires j < n == a.Length == c.Length
{
var A := a[..];
var C := c[.... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_SharedDestructorsCompile_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,791 | 8d16a2d0e89ff7614ad89f67ea60fad52ab97aca762c73a86b67c094591bdad7 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %dafny /noVerify /compile:4 /compileTarget:cs "%s" >> "%t"
// RUN: %dafny /noVerify /compile:4 /compileTarget:py "%s" >> "%t"
// RUN: %diff "%s.expect" "%t"
datatype Dt =
| A(x: int, y: real)
| B(h: MyClass, x: int)
| C(y: real)
class M... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_binary-search_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,651 | 4933adeea3ddc90ea8b4bc22408d40340967a939d0038fb5dc36f40899f8a4df |
///////////////////
// Binary search
///////////////////
predicate isSorted(a:array<int>)
reads a
{
forall i:nat, j:nat :: i <= j < a.Length ==> a[i] <= a[j]
}
// a[lo] <= a[lo+1] <= ... <= a[hi-2] <= a[hi-1]
method binSearch(a:array<int>, K:int) returns (b:bool)
requires isSorted(a)
ensu... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_fibonacci_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 714 | 21a9efc0ba39f824ff54ed6ba623bdccebb9af99c8cefb8b5268e91da544d09e | /*
CS:5810 Formal Methods in Software Engineering
Fall 2017
The University of Iowa
Instructor: Cesare Tinelli
Credits: Example adapted from Dafny tutorial
*/
// n = 0, 1, 2, 3, 4, 5, 6, 7, 8, ...
// fib(n) = 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
function fib(n: nat): nat
{
if n ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_find_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,003 | a36fe3d252f69f748b71d4c5f7c5cfecbec75f50a4b775177e5f8d82b67c714e | /*
CS:5810 Formal Methods in Software Engineering
Fall 2017
The University of Iowa
Instructor: Cesare Tinelli
Credits: Example adapted from Dafny tutorial
*/
method Find(a: array<int>, key: int) returns (i: int)
requires a != null;
// if i is non-negative then
ensures 0 <= i ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_modifying-arrays_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,171 | d51dd3d37dc48cd23e0076d6cbfce2354524e55220973e84386af0db5786ce40 | /*
CS:5810 Formal Methods in Software Engineering
Fall 2021
The University of Iowa
Instructor: Cesare Tinelli
Credits: Example adapted from material by Graeme Smith
*/
/////////////////////
// Modifying arrays
/////////////////////
method SetEndPoints(a: array<int>, left: int, rig... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-aoc-2019_tmp_tmpj6suy_rv_parser_split_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,184 | 88b41705632a8b2983b5efe95dcd1428693427af40705c4506e10b6c6c3af8b8 | module Split {
function splitHelper(s: string, separator: string, index: nat, sindex: nat, results: seq<string>): seq<seq<char>>
requires index <= |s|
requires sindex <= |s|
requires sindex <= index
// requires forall ss: string :: ss in results ==> NotContains(ss,separator)
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-demo_tmp_tmpkgr_dvdi_Dafny_BinarySearch_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 721 | 8ab731820669aaf73f826dc25c054b5cb6efc206b3d285e0c20b590d58d7e285 |
predicate sorted(a: array?<int>, l: int, u: int)
reads a
requires a != null
{
forall i, j :: 0 <= l <= i <= j <= u < a.Length ==> a[i] <= a[j]
}
method BinarySearch(a: array?<int>, key: int)
returns (index: int)
requires a != null && sorted(a,0,a.Length-1);
ensures index >= 0 ==> index < a.Length &... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_ex3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 934 | 7e7128d10475d3d5981e49297a74a827fe6361c2fd2000d4c0789e629a48ec42 | // program verifies
predicate sortedbad(s: string)
{
// no b's after non-b's
forall i, j :: 0 <= i <= j < |s| && s[i] == 'b' && s[j] != 'b' ==> i < j &&
// only non-d's before d's
forall i, j :: 0 <= i <= j < |s| && s[i] != 'd' && s[j] == 'd' ==> i < j
}
method BadSort(a: string) returns (b: string)
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_ex5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 539 | 4f00a7feb1b8328615cd21166c82df2abe14ed5682a4aa314959787b981ea3bf | // program verifies
function expo(x:int, n:nat): int
{
if n == 0 then 1
else x * expo(x, n-1)
}
lemma {:induction false} Expon23(n: nat)
requires n >= 0
ensures ((expo(2,3*n) - expo(3,n)) % (2+3)) == 0
{
// base case
if (n == 0) {
}
else if (n == 1) {
}
else {
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_p1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 369 | 83107864a28e0e85c46d48851e197a8c3c9d66de389e8a8f613c86b8c55dd24b | // Given an array of integers, it returns the sum. [1,3,3,2]->9
function Sum(xs: seq<int>): int {
if |xs| == 0 then 0 else Sum(xs[..|xs|-1]) + xs[|xs|-1]
}
method SumArray(xs: array<int>) returns (s: int)
ensures s == Sum(xs[..])
{
s := 0;
var i := 0;
while i < xs.Length
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_p2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,092 | a0e9ce705dbf77a152800de8e4a94b86d759f276207088457ce70338be2d0d2f | // Given an array of positive and negative integers,
// it returns an array of the absolute value of all the integers. [-4,1,5,-2,-5]->[4,1,5,2,5]
function abs(x:int):nat {
if x < 0 then -x else x
}
method absx(x:array<int>) returns (y:array<int>)
ensures y.Length == x.Length
ensures forall i :: ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_p3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 734 | 0976815774ceb52e59f03f7f1f1e33a5b099e82beb7bf249baa823488167d803 | //Given an array of natural numbers, it returns the maximum value. [5,1,3,6,12,3]->12
method max(x:array<nat>) returns (y:nat)
// for index loop problems
requires x.Length > 0
// ensuring that we maintain y as greater than the elements in the array
ensures forall j :: 0 <= j < x.Length ==> y >= x[j]
// ensuri... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_p4_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,159 | 9c20028819dab0ea42101e5b8a1789ce24f1aaa69c5c348f8e2372538446674f | //Given two arrays of integers, it returns a single array with all integers merged.
// [1,5,2,3],[4,3,5]->[1,5,2,3,4,3,5]
method single(x:array<int>, y:array<int>) returns (b:array<int>)
requires x.Length > 0
requires y.Length > 0
// ensuring that the new array is the two arrays joined
ensures b[..] == x[..] ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-duck_tmp_tmplawbgxjo_p6_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 910 | 4abb3d2ce28508ca8e5ef6d8dbcdc9a7f32bacb898ec93c2cf244a35248495c0 | //Given an array of characters, it filters all the vowels. [‘d’,’e’,’l’,’i’,’g’,’h’,’t’]-> [’e’,’i’]
const vowels: set<char> := {'a', 'e', 'i', 'o', 'u'}
function FilterVowels(xs: seq<char>): seq<char>
{
if |xs| == 0 then []
else if xs[|xs|-1] in vowels then FilterVowels(xs[..|xs|-1]) + [xs[|xs|-1]]
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-exercises_tmp_tmp5mvrowrx_leetcode_26-remove-duplicates-from-sorted-array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,869 | 58f3a42bd9d1afbc07d6df519891c63b551c97156968c3491c0aa3b02f34b31a |
method RemoveDuplicates(nums: array<int>) returns (num_length: int)
modifies nums
requires forall i, j | 0 <= i < j < nums.Length :: nums[i] <= nums[j]
ensures nums.Length == old(nums).Length
ensures 0 <= num_length <= nums.Length
ensures forall i, j | 0 <= i < j < num_length :: nums[i] != nums[j]
e... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/dafny-exercises_tmp_tmp5mvrowrx_paper_krml190_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,903 | e3fa2f13136afe95db46beef980fcf9653a96568690fab0300213f2f1811d76b | // Examples used in paper:
// Specification and Verification of Object-Oriented Software
// by K. Rustan M. Leino
// link of the paper:
// http://leino.science/papers/krml190.pdf
// Figure 0. An example linked-list program written in Dafny.
class Data { }
class Node {
var list: seq<Data>;
var footp... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session10Exercises_ExerciseBarrier_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,015 | 591d0e706e0c0f695ccf0559ad2f08fccc38c45bbe390e6e63e240aa9507feaf |
//Method barrier below receives an array and an integer p
//and returns a boolean b which is true if and only if
//all the positions to the left of p and including also position p contain elements
//that are strictly smaller than all the elements contained in the positions to the right of p
//Examples:
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExerciseExp_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 548 | 56787b588aacf509971218dbeeab503b738dbf42ab4beb4b1b23a006a8aca88a | function exp(x:int, e:int):int
requires e >= 0
ensures x > 0 ==> exp(x,e) > 0
{
if e == 0 then 1 else x*exp(x,e-1)
}
lemma exp3_Lemma(n:int)
requires n >= 1
ensures (exp(3,n)-1)%2 == 0
{}
lemma mult8_Lemma(n:int)
requires n >= 1
ensures (exp(3,2*n) - 1)%8 == 0
{
if(n==1){
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExerciseFibonacci_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 802 | 746a30007ae2e15f05216795c07460daa790e54bb1b2371c03a9e7667b4053f2 | function fib(n: nat): nat
{
if n == 0 then 0 else
if n == 1 then 1 else
fib(n - 1) + fib(n - 2)
}
method fibonacci1(n:nat) returns (f:nat)
ensures f==fib(n)
{
var i := 0;
f := 0;
var fsig := 1;
while i < n
{
f, fsig := fsig, f + fsig;
i := i + 1;
}... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExercisePositive_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,105 | 8b14a5cea07566cda5340d59765978abe7ae3f76be98ef2c55bc75d74fe44073 | predicate positive(s:seq<int>)
{forall u::0<=u<|s| ==> s[u]>=0}
method mpositive(v:array<int>) returns (b:bool)
ensures b==positive(v[0..v.Length])
{
var i:=0;
//1. assert positive(v[..0])
while i<v.Length && v[i]>=0
{
//2. assert 0<=i<v.Length && positive(v[..i]);
i:=i+1;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExerciseSquare_root_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 653 | 9aba6764fd27151499cb511139c9690467b5957d5ab03a066e0ef352da3981a9 | method mroot1(n:int) returns (r:int) //Cost O(root n)
requires n>=0
ensures r>=0 && r*r <= n <(r+1)*(r+1)
{
r:=0;
while (r+1)*(r+1) <=n
{
r:=r+1;
}
}
method mroot2(n:int) returns (r:int) //Cost O(n)
requires n>=0
ensures r>=0 && r*r <= n <(r+1)*(r+1)
{
r:=n;
while n<r*r
{
r... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session3Exercises_ExerciseMaximum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,730 | 793fae39b50dfc81683b99ad69cc0d5338995d57f2c37dc0420e07abed95042c | //Algorithm 1: From left to right return the first
method mmaximum1(v:array<int>) returns (i:int)
requires v.Length>0
ensures 0<=i<v.Length
ensures forall k:: 0<=k<v.Length ==> v[i]>=v[k]
{
var j:=1; i:=0;
while(j<v.Length)
{
if(v[j] > v[i]){i:=j;}
j:=j+1;
}
}
//Algorith... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExerciseAllEqual_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,129 | daf2835c190ff1cb0e2d12448a74ab9e4cc9c539351f116c040df528fed3758e | predicate allEqual(s:seq<int>)
{forall i,j::0<=i<|s| && 0<=j<|s| ==> s[i]==s[j] }
//{forall i,j::0<=i<=j<|s| ==> s[i]==s[j] }
//{forall i::0<i<|s| ==> s[i-1]==s[i]}
//{forall i::0<=i<|s|-1 ==> s[i]==s[i+1]}
//Ordered indexes
lemma equivalenceNoOrder(s:seq<int>)
ensures allEqual(s) <==> forall i,j::0<=i<=j<|... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExerciseContained_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 747 | 8010cebfdf1adfbaf4eef658143ac416c91dcb92a58958905e08d7c27791019a |
predicate strictSorted(s : seq<int>) {
forall u, w :: 0 <= u < w < |s| ==> s[u] < s[w]
}
method mcontained(v:array<int>,w:array<int>,n:int,m:int) returns (b:bool)
//Specify and implement an O(m+n) algorithm that returns b
//v and w are strictly increasing ordered arrays
//b is true iff the first n elem... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExerciseFirstNegative_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 635 | 0662f30d69c33e19ecb3b2dd944df0a157bdfdf8452531e33bb547d31ed4c767 | predicate positive(s:seq<int>)
{forall u::0<=u<|s| ==> s[u]>=0}
method mfirstNegative(v:array<int>) returns (b:bool, i:int)
ensures b <==> exists k::0<=k<v.Length && v[k]<0
ensures b ==> 0<=i<v.Length && v[i]<0 && positive(v[0..i])
{
i:=0;
b:=false;
while (i<v.Length && !b)
{
b:=(v[i]<0);
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExercisefirstZero_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 210 | d5c63ecb52e60b27e1b9b9a59444bb1562cd112386622b1de8dbb35a87577eb7 |
method mfirstCero(v:array<int>) returns (i:int)
ensures 0 <=i<=v.Length
ensures forall j:: 0<=j<i ==> v[j]!=0
ensures i!=v.Length ==> v[i]==0
{
i:=0;
while (i<v.Length && v[i]!=0)
{i:=i+1;}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session5Exercises_ExerciseSumElems_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,516 | 3b5709b6ee636e3797cb63a9ca015d3ae6ac3b1e6b53b206339e292aa40ee8d8 | function SumR(s:seq<int>):int
{
if (s==[]) then 0
else SumR(s[..|s|-1])+s[|s|-1]
}
function SumL(s:seq<int>):int
{
if (s==[]) then 0
else s[0]+SumL(s[1..])
}
lemma concatLast(s:seq<int>,t:seq<int>)
requires t!=[]
ensures (s+t)[..|s+t|-1] == s+(t[..|t|-1])
{}
lemma concatFirst(s:seq<i... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session6Exercises_ExerciseCountEven_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 953 | 19d085bcf6bc4fcd618d12b5203661ff7d0b26a152c13c2c818b556c3da92cf9 |
predicate positive(s:seq<int>)
{forall u::0<=u<|s| ==> s[u]>=0}
predicate isEven(i:int)
requires i>=0
{i%2==0}
function CountEven(s:seq<int>):int
requires positive(s)
{if s==[] then 0
else (if (s[|s|-1]%2==0) then 1 else 0)+CountEven(s[..|s|-1])
}
lemma ArrayFacts<T>()
ensures forall v : array<T> ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session6Exercises_ExerciseCountMin_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 841 | 5e90c397ec36105410475d670f14c0f2475bf46becf08a3842aa6f0ebf7a607b | function min(v:array<int>,i:int):int
reads v
requires 1<=i<=v.Length
ensures forall k::0<=k<i==> v[k]>=min(v,i)
{if (i==1) then v[0]
else if (v[i-1]<=min(v,i-1)) then v[i-1]
else min(v,i-1)
}
function countMin(v:array<int>,x:int, i:int):int
reads v
requires 0<=i<=v.Length
ensures !(x in v[... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Dafny-Exercises_tmp_tmpjm75muf__Session6Exercises_ExercisePeekSum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 650 | c3e4b5c9d6e3099220110a4db6ab1c9c07291572c7942150bf6877c0c89c2bd3 |
predicate isPeek(v:array<int>,i:int)
reads v
requires 0<=i<v.Length
{forall k::0<=k<i ==> v[i]>=v[k]}
function peekSum(v:array<int>,i:int):int
reads v
requires 0<=i<=v.Length
{
if (i==0) then 0
else if isPeek(v,i-1) then v[i-1]+peekSum(v,i-1)
else peekSum(v,i-1)
}
method mPeekSum(v:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.