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/se2011_tmp_tmp71eb82zt_ass1_ex4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
489
5a4afe4a3e1cffbaaf8ccb4d906e0bce7f84f5d991c8bd8bba7aac624d4ff8eb
method Eval(x:int) returns (r:int) // do not change requires x >= 0 ensures r == x*x { // do not change var y:int := x; // do not change var z:int := 0; // do not change while y>0 // do not change invariant 0 <= y <= x && z == x*(x-y) decreases y { // do not change z :...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/se2011_tmp_tmp71eb82zt_ass1_ex6.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
339
4920957073ae130f21c1e182b276ef182bc10314aba70b32295633cfbefa258a
method Ceiling7(n:nat) returns (k:nat) requires n >= 0 ensures k == n-(n%7) { k := n-(n%7); } method test7() { var k: nat; k := Ceiling7(43); assert k == 42; k := Ceiling7(6); assert k == 0; k := Ceiling7(1000); assert k == 994; k := Ceiling7(7); assert k == 7; k := Ceiling7(70); asse...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/se2011_tmp_tmp71eb82zt_ass2_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,021
bd46c11ab25fe6deb4430c5b8c1775b7d2fcde32920c3ab18a0b80b8fd955e1b
// ex2 // this was me playing around to try and get an ensures for the method /*predicate method check(a: array<int>, seclar:int) requires a.Length > 0 reads a { ensures exists i :: 0 <= i < a.Length && forall j :: (0 <= j < a.Length && j != i) ==> (a[i] >= a[j]) && (seclar <= a[i]) && ( if a[j] != a[i] then se...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_ass1_ex7.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
375
8b7bc012968882e6e5b2e5077cffb4b2537a4f074b403c6d5b28cca685d1ea77
// successfully verifies method BigFoot(step: nat) // DO NOT CHANGE requires 0 < step <= 42; { var indx := 0; // DO NOT CHANGE while indx<=42 // DO NOT CHANGE invariant 0 <= indx <= step + 42 && indx % step == 0 decreases 42 - indx { indx := indx+step; } // DO NOT CHANGE assert 0 <= ind...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_ass1_ex8.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
409
65b4cf34a71f1dbb033f4df0ceeab3dd8eb9d7cefe143da8fb12678249bb3e20
// successfully verifies method GetEven(a: array<nat>) requires true; ensures forall i:int :: 0<=i<a.Length ==> a[i] % 2 == 0 modifies a { var i := 0; while i < a.Length invariant 0 <= i <= a.Length && forall j:int :: 0<=j<i ==> a[j] % 2 == 0 decreases a.Length - i { if a[i] % 2 !...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_ass2_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
771
74c6194b986251e593bf79de94ffb06a2c5ca14a72f9aa29b1887f6c494482f4
// method verifies method StringSwap(s: string, i:nat, j:nat) returns (t: string) requires i >= 0 && j >= 0 && |s| >= 0; requires |s| > 0 ==> i < |s| && j < |s|; ensures multiset(s[..]) == multiset(t[..]); ensures |s| == |t|; ensures |s| > 0 ==> forall k:nat :: k != i && k != j && k < |s| ==> t[k] == s[k] ensure...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_ass2_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,689
efcc0b2548ce907c472aa4cc8da97efc61c5a031d77a44db177b0868cdf6f4a8
// verifies // check that string between indexes low and high-1 are sorted predicate Sorted(a: string, low:int, high:int) requires 0 <= low <= high <= |a| { forall j, k :: low <= j < k < high ==> a[j] <= a[k] } method String3Sort(a: string) returns (b: string) requires |a| == 3; ensures Sorted(b, 0, |...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_ass2_ex3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,101
8fbbfb7b8417219f19eac0e7f7cb1cf1385692b21f8780c5c419aa3170b1c70a
// verifies // all bs are before all as which are before all ds predicate sortedbad(s:string) { // all b's are before all a's and d's forall i,j :: 0 <= i < |s| && 0 <= j < |s| && s[i] == 'b' && (s[j] == 'a' || s[j] == 'd') ==> i < j && // all a's are after all b's forall i,j :: 0 <= i < |s| && ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_ass2_ex5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,360
6aab3188d2e1767a52044faacc551fb03c48116f71a605ee09074ee31444def6
// verifies function expo(x:int, n:nat): int requires n >= 0; { 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))) % 5 == 0; { if (n == 0) { assert (expo(2, 3 * 0) - expo(3, 0)) % 5 == 0; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_exam_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,160
34f0b50098696b91d2621b2eb12bb7b6608e0c88ef2adfd466fc21155f0e2071
method Getmini(a:array<int>) returns(mini:nat) requires a.Length > 0 ensures 0 <= mini < a.Length // mini is an index of a ensures forall x :: 0 <= x < a.Length ==> a[mini] <= a[x] // a[mini] is the minimum value ensures forall x :: 0 <= x < mini ==> a[mini] < a[x] // a[mini] is the first min { // find mini ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_exam_ex3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
862
a0e5b5fa27b9ca1ab78f983d2d78c483686642072b35e17032bcc8ed6a609f98
method Symmetric(a: array<int>) returns (flag: bool) ensures flag == true ==> forall x :: 0 <= x < a.Length ==> a[x] == a[a.Length - x - 1] ensures flag == false ==> exists x :: 0 <= x < a.Length && a[x] != a[a.Length - x - 1] { // empty == symmetrical if a.Length == 0 { return true; } ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_exam_ex4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
276
72d06996fdd83e9c6f490326b7772c0bfa817d9655d216ec32a435d3aa3b34af
lemma {:induction false} Divby2(n: nat) ensures (n*(n-1))%2 == 0 { if n == 0 { assert (1*(1-1))%2 == 0; // base case } else { Divby2(n - 1); // proved in case n - 1 assert (n-1)*(n-2) == n*n -3*n + 2; // expanded case n - 1 } }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_flex_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
827
5d1663f87f07963251fb2cbe097c2d4a5bd585be1801015c449bb2880a0dc8cb
// sums from index 0 -> i - 1 function sumcheck(s: array<int>, i: int): int requires 0 <= i <= s.Length reads s { if i == 0 then 0 else s[i - 1] + sumcheck(s, i - 1) } // returns sum of array method sum(s: array<int>) returns (a:int) requires s.Length > 0 ensures sumcheck(s, s.Length) == a { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_flex_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
946
98964e92399d1a1663a8377baf718f51204791f03d513568c016c04ba871e628
function maxcheck(s: array<nat>, i: int, max: int): int requires 0 <= i <= s.Length reads s { if i == 0 then max else if s[i - 1] > max then maxcheck(s, i - 1, s[i - 1]) else maxcheck(s, i - 1, max) } method max(s: array<nat>) returns (a:int) requires s.Length > 0 ensures forall x :: 0 <= x < s....
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_flex_ex5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
615
fdc92af4523378acdbe8ce6affe8abab8b9a54b818463716ab666b84c8dd258e
method firste(a: array<char>) returns (c:int) ensures -1 <= c < a.Length ensures 0 <= c < a.Length ==> a[c] == 'e' && forall x :: 0 <= x < c ==> a[x] != 'e' ensures c == -1 ==> forall x :: 0 <= x < a.Length ==> a[x] != 'e' { var i:int := 0; while i < a.Length invariant 0 <= i <= a.Length invaria...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_p1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,244
6ddaf44f25124f57918b6fd3f52059bd1a3176fb1e00ea6914629113e595856f
method Reverse(a: array<char>) returns (b: array<char>) requires a.Length > 0 ensures a.Length == b.Length ensures forall x :: 0 <= x < a.Length ==> b[x] == a[a.Length - x - 1] { // copy array a to new array b b := new char[a.Length]; var k := 0; while (k < a.Length) invariant 0 <= k <= a....
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SENG2011_tmp_tmpgk5jq85q_p2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
930
401dab902b29e2710cf42d2e113e342f9a736e037f657f419c119b39316e3823
method AbsIt(s: array<int>) modifies s; //requires ensures forall x :: 0 <= x < s.Length ==> old(s[x]) < 0 ==> s[x] == -old(s[x]) ensures forall x :: 0 <= x < s.Length ==> old(s[x]) >= 0 ==> s[x] == old(s[x]) { var i:int := 0; while i < s.Length invariant 0 <= i <= s.Length //invariant forall...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/SiLemma_tmp_tmpfxtryv2w_utils.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,049
7f0fa6dac9d6b385910a9899380974129852097aec7dd5954eabb4f3ae5e6e1f
module Utils { lemma AllBelowBoundSize(bound: nat) ensures var below := set n : nat | n < bound :: n; |below| == bound decreases bound { if bound == 0 { } else { AllBelowBoundSize(bound-1); var belowminus := set n : nat...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Simulink-To_dafny_tmp_tmpbcuesj2t_Tank.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,887
e0a607f9fa7341f47854750ac8b2ba902803f1fcd99ab2511b9c395688509e18
datatype Valve = ON | OFF class Pipe{ var v1: Valve; //outlet valve var v2: Valve; //inlet Valve var v3: Valve; //outlet valve var in_flowv1: int; //flow in valve v1 var in_flowv2: int; //flow in vave v2 var in_flowv3: int; //flow in valve v3 constructor() { this.v1:= OFF; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,666
8dea42cbc03dc39dfda0b8ba4372119b2e4263cb3ff073fde733a637f06be58b
method factImp(n: int) returns (r: int) { r := 1; var m := n; while (m > 0) { r := r*m; m := m-1; } } function power(n: int, m: nat) : int { if m==0 then 1 else n*power(n,m-1) } function pow(n: int, m: nat,r: int) : int { if m==0 then r else pow(n,m-1,r*n) } function powerAlt(n:...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,387
dda9cdd60e911171b33ecf3cf9ffd411cc09dcf858202f0a8e9bb05417c44710
//PRE-CONDITIONS -> REQUIRES //POST-CONDITIONS -> ENSURES method max(a: int, b: int) returns (z: int) requires true ensures z >= a || z >= b { if a > b { z :=a; } else { z := b; } } method Main() { var x; assert true; x:=max(23,50); assert x>=50 || x>=23; } // 3 m...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,338
9814fd3b0d9ceb47988f61149443166c528c8c8341e4d353574d9bf42d9b4dc6
function fib(n : nat) : nat { if (n==0) then 1 else if (n==1) then 1 else fib(n-1)+fib(n-2) } method Fib(n : nat) returns (r:nat) ensures r == fib(n) { if (n == 0) { return 1; } var next:= 2; r:=1; var i := 1; while (i < n) invariant next == fib(i+1) invariant r == ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
11,391
8ffae0d6bc3a3f905ad1421de1ec37cbd6235581328c75a6d66484bdd35a8464
/*Ex1 Given the leaky specification of class Set found in Appendix ??, use the techniques from class (the use of ghost state and dynamic frames) so that the specification no longer leaks the internal representation. Produce client code that correctly connects to your revised Set class. */ class Set { var store...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_handout1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,927
7cc8c560630790c1d8bd4b6100e5e8a011a935631b1ddae423c41510d0dd8fab
// 1 a) // [ai, aj[ function sum(a: array<int>, i: int, j: int) : int requires 0 <= i <= j <= a.Length reads a decreases j { if i == j then 0 else a[j-1] + sum(a, i, j-1) } // 1 b) method query(a: array<int>, i: int, j: int) returns (res : int) requires 0 <= i <= j <= a.Length ensures res...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_handout2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
9,096
5e067201fc618825a92f8f453f533b9aa189f124bdc93054b4dc15a44b1bae8d
datatype List<T> = Nil | Cons(head:T,tail:List<T>) datatype Option<T> = None | Some(elem:T) ghost function mem<T>(x:T,l:List<T>) : bool { match l { case Nil => false case Cons(y,xs) => x==y || mem(x,xs) } } ghost function length<T>(l:List<T>) : int { match l { case Nil => 0 case Con...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/software-specification-p1_tmp_tmpz9x6mpxb_BoilerPlate_Ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,559
94c3b2fb79e444349727c73e92edf9a980d2d32a47de41de73e9f72c291999d5
datatype Tree<V> = Leaf(V) | SingleNode(V, Tree<V>) | DoubleNode(V, Tree<V>, Tree<V>) datatype Code<V> = CLf(V) | CSNd(V) | CDNd(V) function serialise<V>(t : Tree<V>) : seq<Code<V>> decreases t { match t { case Leaf(v) => [ CLf(v) ] case SingleNode(v, t) => serialise(t) + [ CSNd(v) ] case ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Best Time to Buy and Sell Stock_best_time_to_buy_and_sell_stock.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
876
b157274970763da3f48f4eb42cefeb991c0fbb819885a6f2a6bcb31be6932977
method best_time_to_buy_and_sell_stock(prices: array<int>) returns (max_profit: int) requires 1 <= prices.Length <= 100000 requires forall i :: 0 <= i < prices.Length ==> 0 <= prices[i] <= 10000 ensures forall i, j :: 0 <= i < j < prices.Length ==> max_profit >= prices[j] - prices[i] { var min_pric...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Contains Duplicate_contains_duplicate.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
721
7df10a8e51f17e3aae21cd1188d0367d52a1d9409eba9f68d95dd5755b90575f
method contains_duplicate(nums: seq<int>) returns (result: bool) requires 1 <= |nums| <= 100000 requires forall i :: 0 <= i < |nums| ==> -1000000000 <= nums[i] <= 1000000000 ensures result <==> distinct(nums) { var i := 0; var s: set<int> := {}; while (i < |nums|) invariant i <...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Counting Bits_counting_bits.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
492
4ebdbf06eafdddba9db23f9a796b52cfeb3572a1b14d325e911fc2d006fb19cc
method counting_bits(n: int) returns (result: array<int>) requires 0 <= n <= 100000 ensures result.Length == n + 1 ensures forall i :: 1 <= i < n + 1 ==> result[i] == result[i / 2] + i % 2 { result := new int[n + 1](i => 0); var i := 1; while (i < n + 1) invariant 1 <= i <= n +...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Longest Increasing Subsequence_longest_increasing_subsequence.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,020
ef08e08276cef47abda2793238dff4fd5fab228df98773daf0bcbdb3069aea4d
method longest_increasing_subsequence(nums: array<int>) returns (max: int) requires 1 <= nums.Length <= 2500 requires forall i :: 0 <= i < nums.Length ==> -10000 <= nums[i] <= 10000 // TODO: modify the ensures clause so that max is indeed equal to the longest increasing subsequence ensures max >= 1 ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Non-overlapping Intervals_non_overlapping_intervals.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,296
31d0bc1098d2915485367aaef0005a51372c2bcbb39fa0606af7f2fc18b2aee0
method non_overlapping_intervals(intervals: array2<int>) returns (count: int) modifies intervals requires 1 <= intervals.Length0 <= 100000 requires intervals.Length1 == 2 requires forall i :: 0 <= i < intervals.Length0 ==> -50000 <= intervals[i, 0] <= 50000 requires forall i :: 0 <= i < interva...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Remove Duplicates from Sorted Array_remove_duplicates_from_sorted_array.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,202
4f7f915750e578da24da644f7bcdb7e1d76bafff8bf00ef1e311006e48ae749a
method remove_duplicates_from_sorted_array(nums: seq<int>) returns (result: seq<int>) requires is_sorted(nums) requires 1 <= |nums| <= 30000 requires forall i :: 0 <= i < |nums| ==> -100 <= nums[i] <= 100 ensures is_sorted_and_distinct(result) ensures forall i :: i in nums <==> i in result { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Remove Element_remove_element.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
861
6dab557cf122751ecc66348b8848dd05e5ee96d73a58bc37bf830df0347f3770
method remove_element(nums: array<int>, val: int) returns (i: int) modifies nums requires 0 <= nums.Length <= 100 requires forall i :: 0 <= i < nums.Length ==> 0 <= nums[i] <= 50 requires 0 <= val <= 100 ensures forall j :: 0 < j < i < nums.Length ==> nums[j] != val { i := 0; var end...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Valid Anagram_valid_anagram.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,902
bd3f53d73f28767afd81d483e793d9bcaf6cfb92c61214e3af6cf96eb6e2aa2e
method is_anagram(s: string, t: string) returns (result: bool) requires |s| == |t| ensures (multiset(s) == multiset(t)) == result { result := is_equal(multiset(s), multiset(t)); } method is_equal(s: multiset<char>, t: multiset<char>) returns (result: bool) ensures (s == t) <==> result { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Software-Verification_tmp_tmpv4ueky2d_Valid Palindrome_valid_panlindrome.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
523
4b965a676a571e061c0f7646172f0c16d9d1c83a081d38dc3602d42bcc24fcc8
method isPalindrome(s: array<char>) returns (result: bool) requires 1<= s.Length <= 200000 ensures result <==> (forall i:: 0 <= i < s.Length / 2 ==> s[i] == s[s.Length - 1 - i]) { var length := s.Length; var i := 0; while i < length / 2 invariant 0 <= i <= length invariant...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/software_analysis_tmp_tmpmt6bo9sf_ss.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,102
f1dab7d6eec109cbccd80b519f0a8bdffaead239bdf88cecb5eb5edd7bd63dc5
method find_min_index(a : array<int>, s: int, e: int) returns (min_i: int) requires a.Length > 0 requires 0 <= s < a.Length requires e <= a.Length requires e > s ensures min_i >= s ensures min_i < e ensures forall k: int :: s <= k < e ==> a[min_i] <= a[k] { min_i := s; var i : int := s; w...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/specTesting_tmp_tmpueam35lx_examples_binary_search_binary_search_specs.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,827
b76d4d25c3649bde60c118ef73329ff453a0098912f6cc8615c1e23850499a24
lemma BinarySearch(intSeq:seq<int>, key:int) returns (r:int) // original requires forall i,j | 0 <= i <= j < |intSeq| :: intSeq[i] <= intSeq[j] ensures r >= 0 ==> r < |intSeq| && intSeq[r] == key ensures r < 0 ==> forall i:nat | i < |intSeq| :: intSeq[i] != key { var lo:nat := 0; var hi...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/specTesting_tmp_tmpueam35lx_examples_increment_decrement_spec.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,393
cb42ceafd3f5c7b47dde7597e48d8efa2069881f5a41a34ba3f1e7bbb87e41a2
module OneSpec { datatype Variables = Variables(value: int) predicate Init(v: Variables) { v.value == 0 } predicate IncrementOp(v: Variables, v': Variables) { && v'.value == v.value + 1 } predicate DecrementOp(v: Variables, v': Variables) { &...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/specTesting_tmp_tmpueam35lx_examples_max_max.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,425
1c881cc54db97463bfba0c12d7d1fd6906b14989ca9ce40316a55fe0f321f64d
lemma max(a:int, b:int) returns (m:int) ensures m >= a ensures m >= b ensures m == a || m == b { if (a > b) { m := a; } else { m := b; } } predicate post_max(a:int, b:int, m:int) { && m >= a && m >= b && (m == a || m == b) } // to check if it is f...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/specTesting_tmp_tmpueam35lx_examples_sort_sort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,755
cf397c2b27501544edf90a3f294b41737a68d9ed6f5a7f032d3c9f4f31fa87a3
method quickSort(intSeq:array<int>) modifies intSeq ensures forall i:nat, j:nat | 0 <= i <= j < intSeq.Length :: intSeq[i] <= intSeq[j] // ensures multiset(intSeq[..]) == multiset(old(intSeq[..])) lemma sort(prevSeq:seq<int>) returns (curSeq:seq<int>) ensures (forall i:nat, j:nat | 0 <= i <= j ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/stunning-palm-tree_tmp_tmpr84c2iwh_ch1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,583
940b00a66e3bed2aef50c7b939f7cbb9fbd76003bf98ece20d6a4539ea0c2bca
// Ex 1.3 method Triple (x: int) returns (r: int) ensures r == 3*x { var y := 2*x; r := y + x; assert r == 3*x; } method Caller() { var t := Triple(18); assert t < 100; } // Ex 1.6 method MinUnderSpec (x: int, y: int) returns (r: int) ensures r <= x && r <= y { if x <= y { r := x ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/stunning-palm-tree_tmp_tmpr84c2iwh_ch10.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
11,455
d4d3156e73f11324b84bee1421ade71b96f33e4f0ab0f260738fad8fac91fcdb
// Ch. 10: Datatype Invariants module PQueue { export // Impl provides PQueue provides Empty, IsEmpty, Insert, RemoveMin // Spec provides Valid, Elements, EmptyCorrect, IsEmptyCorrect provides InsertCorrect, RemoveMinCorrect reveals IsMin // ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/stunning-palm-tree_tmp_tmpr84c2iwh_ch5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
12,811
6966e11d27713cda9784203a1e9389de24380fcc06e45e2c2c6bb54d05a26e07
function More(x: int): int { if x <= 0 then 1 else More(x - 2) + 3 } lemma {:induction false} Increasing(x: int) ensures x < More(x) { if x <= 0 {} else { // x < More(x) <=> x < More(x - 2) + 3 // <=> x - 3 < More(x - 2) // Increasing(x - 2) ==> x - 2 < More(x - 2) // ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/stunning-palm-tree_tmp_tmpr84c2iwh_ch8.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,128
9c5c1c160ffb0d8c6df12e018b8466fb77898bbb76a54ce31f0725eac629e9f1
// Ch. 8: Sorting datatype List<T> = Nil | Cons(head: T, tail: List<T>) function Length<T>(xs: List<T>): int ensures Length(xs) >= 0 { match xs case Nil => 0 case Cons(_, tl) => 1 + Length(tl) } function At<T>(xs: List, i: nat): T requires i < Length(xs) { if i == 0 then xs.head el...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/summer-school-2020_tmp_tmpn8nf7zf0_chapter01_solutions_exercise04_solution.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
670
89fc9bd197d5435d11c3308ca27d66c0ffa784792f84fdc238e71ebed14d6244
// Predicates // A common thing you'll want is a function with a boolean result. function AtLeastTwiceAsBigFunction(a:int, b:int) : bool { a >= 2*b } // It's so fantastically common that there's a shorthand for it: `predicate`. predicate AtLeastTwiceAsBigPredicate(a:int, b:int) { a >= 2*b } functio...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/summer-school-2020_tmp_tmpn8nf7zf0_chapter01_solutions_exercise11_solution.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,328
3857812e0cb79a9186e0ef92cd633f7bcfb73edf5a9bc5ef0b8ac56d17b94fd3
// Algebraic datatypes in their full glory. The include statement. // A struct is a product: // There are 3 HAlign instances, and 3 VAlign instances; // so there are 9 TextAlign instances (all combinations). // Note that it's okay to omit the parens for zero-element constructors. datatype HAlign = Left | Center ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise01_solution.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
396
8cc60262c311eecd64d21673ed7ade7527920fab74a6f2cca87982009e02c406
predicate divides(f:nat, i:nat) requires 1<=f { i % f == 0 } predicate IsPrime(i:nat) { && 1 < i && forall f :: 1 < f < i ==> !divides(f, i) } method Main() { assert !IsPrime(0); assert !IsPrime(1); assert IsPrime(2); assert IsPrime(3); assert divides(2, 6); assert !IsPrime(6); ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise02_solution.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,303
5cada6922688f4bca040a55c486d90f67737fd7d70aa2bd61ecaa72284e411f6
predicate divides(f:nat, i:nat) requires 1<=f { i % f == 0 } predicate IsPrime(i:nat) { && 1<i && ( forall f :: 1 < f < i ==> !divides(f, i) ) } // Convincing the proof to go through requires adding // a loop invariant and a triggering assert. method test_prime(i:nat) returns (result:bool) re...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise03_solution.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,125
0a66550e7fdb54b2455b133eeb8368207881e3e061edc018021dded1ab4a92c2
predicate IsSorted(s:seq<int>) { forall i :: 0 <= i < |s|-1 ==> s[i] <= s[i+1] } predicate SortSpec(input:seq<int>, output:seq<int>) { && IsSorted(output) && multiset(output) == multiset(input) } //lemma SequenceConcat(s:seq<int>, pivot:int) // requires 0<=pivot<|s| // ensures s[..pivot] + s[pivo...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/t1_MF_tmp_tmpi_sqie4j_exemplos_classes_parte1_contadorV1b.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,066
97339a37ca8eb23d752211c045c5bf97c4339eefa4a0da259ba87d3bb3f7a797
class Contador { var valor: int; //construtor anônimo constructor () ensures valor == 0 { valor := 0; } //construtor com nome constructor Init(v:int) ensures valor == v { valor := v; } method Incrementa() modifies this ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_arrays_ex4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
433
af3b06cbedc68c82db0e0533ec4834c9438d3db66e7e1849b35c9e17a00ebd30
function SomaAte(a:array<nat>, i:nat):nat requires 0 <= i <= a.Length reads a { if i == 0 then 0 else a[i-1] + SomaAte(a,i-1) } method Somatorio(a:array<nat>) returns (s:nat) ensures s == SomaAte(a,a.Length) { var i := 0; s := 0; while i < a.Length invariant 0 <= i &&...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_arrays_ex5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
412
3df99ab3886b1cf4f7954b544371e4ae9ea79dce3d48ff706659f2b349f0ca4f
method Busca<T(==)>(a:array<T>, x:T) returns (r:int) ensures 0 <= r ==> r < a.Length && a[r] == x ensures r < 0 ==> forall i :: 0 <= i < a.Length ==> a[i] != x { r :=0; while r < a.Length invariant 0 <= r <= a.Length invariant forall i :: 0 <= i < r ==> a[i] != x { if a[r]==...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_conjuntos_ex5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
419
41f9cfe7c1ce480fcb77f797854a272a62f672ec7980eace19e6baf1cfedee90
function to_seq<T>(a: array<T>, i: int) : (res: seq<T>) requires 0 <= i <= a.Length ensures res == a[i..] reads a decreases a.Length-i { if i == a.Length then [] else [a[i]] + to_seq(a, i + 1) } method Main() { var a: array<int> := new int[2]; a[0] := 2; a[1] := 3; var ms: multiset<int> ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_sequences_ex3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
671
187d744a94956fbe314fd220ae875d1f329c14f95b0326dd26bf49a90e84a8db
// line contém uma string de tamanho l // remover p caracteres a partir da posição at method Delete(line:array<char>, l:nat, at:nat, p:nat) requires l <= line.Length requires at+p <= l modifies line ensures line[..at] == old(line[..at]) ensures line[at..l-p] == old(line[at+p..l]) { var i:nat := 0...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/t1_MF_tmp_tmpi_sqie4j_exemplos_introducao_ex4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
305
085da7972f5939ea7639cb2b8e641fa3f9b159971d14011d0c4eb006a045fed6
function Fat(n: nat): nat { if n == 0 then 1 else n * Fat(n-1) } method Fatorial(n:nat) returns (r:nat) ensures r == Fat(n) { r := 1; var i := 0; while i < n invariant 0 <= i <= n invariant r == Fat(i) { i := i + 1; r := r * i; } }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/tangent-finder_tmp_tmpgyzf44ve_circles.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,613
54e7d3d5eb1e8982aa47e45cc3605dc771f61cb7884cf1ddf7cf3ac43e48ce20
method Tangent(r: array<int>, x: array<int>) returns (b: bool) requires forall i, j :: 0 <= i <= j < x.Length ==> x[i] <= x[j] // values in x will be in ascending order or empty requires forall i, j :: (0 <= i < r.Length && 0 <= j < x.Length) ==> (r[i] >= 0 && x[j] >= 0) // x and r will contain no negat...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/test-generation-examples_tmp_tmptwyqofrp_IntegerSet_dafny_IntegerSet.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
7,862
11ce510b2929eb0064ccf404ef04902144930ea3a3cc83f0f81a5f40bf60783e
module IntegerSet { class Set { var elements: seq<int>; constructor Set0() ensures this.elements == [] ensures |this.elements| == 0 { this.elements := []; } constructor Set(elements: seq<int>) requires forall i, j | 0 <= ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/test-generation-examples_tmp_tmptwyqofrp_IntegerSet_dafny_Utils.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
594
28f54b58b800eea70ec223cb88cc65ec003ffe1d3cc038bea9900cea00295d3e
module Utils { class Assertions<T> { static method {:extern} assertEquals(expected : T, actual : T) requires expected == actual static method {:extern} expectEquals(expected : T, actual : T) ensures expected == actual static method {:extern} assertTrue(condition : bool) requires con...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/test-generation-examples_tmp_tmptwyqofrp_ParamTests_dafny_Utils.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
706
d787e4eed2e16a5913c5f04a00f3279c82db9c9d7252c88f444c17aff1203894
module Utils { export reveals Assertions provides Assertions.assertEquals class Assertions { static method {:axiom} assertEquals<T>(left : T, right : T) requires left == right /* public static void assertEquals<T>(T a, T b) { Xunit.Assert.Equal(a, b)...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/test-generation-examples_tmp_tmptwyqofrp_RussianMultiplication_dafny_RussianMultiplication.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
508
14ff6e2e5fcbb36ea5856185021a1efc08421645746686776c94cee399687615
module RussianMultiplication { export provides mult method mult(n0 : int, m0 : int) returns (res : int) ensures res == (n0 * m0); { var n, m : int; res := 0; if (n0 >= 0) { n,m := n0, m0; } else { n,m := -n0, -m0; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/TFG_tmp_tmpbvsao41w_Algoritmos Dafny_div_ent_it.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
502
d206380af72ea8499406777b34a05f81d61ae9fdb6e586c753be8e6883f9604b
method div_ent_it(a: int, b: int) returns (c: int, r: int) // Algoritmo iterativo de la división de enteros // que calcula su cociente y resto requires a >= 0 && b > 0 ensures a == b*c + r && 0 <= r < b { c := 0; r := a ; while (r >= b) invariant a == b * c + r && r >= 0 && b > 0 d...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/TFG_tmp_tmpbvsao41w_Algoritmos Dafny_suma_it.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
985
e3e6de4b17ad08f8132cc666ac1c76220cd28f2a8310c58187a37a2ce39ad28c
method suma_it(V: array<int>) returns (x: int) // Algoritmo iterativo que calcula la // suma de las componentes de un vector ensures x == suma_vector(V, 0) { var n := V.Length ; x := 0 ; while (n != 0) invariant 0 <= n <= V.Length && x == suma_vector(V, n) decreases n ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Trab1-Metodos-Formais_tmp_tmp_8fa4trr_circular-array.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,701
66cb87048bb5eb53ec42ae1a024501c291ba70a26225b5ad0298b4b031ae5633
/* Class CircularArray. Names: Arthur Sudbrack Ibarra, Miguel Torres de Castro, Felipe Grosze Nipper, Willian Magnum Albeche, Luiz Eduardo Mello dos Reis. */ class {:autocontracts} CircularArray { /* Implementation */ var arr: array<int>; // The array. var start: nat; // The in...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/type-definition_tmp_tmp71kdzz3p_final.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,224
b27c1c8a4ff36cc3acdf515af775b040f36b6fda097ed4b26a307fcbcb59a41d
// ------------------------------------------------------------- // 1. Implementing type inference // ------------------------------------------------------------- // Syntax: // // τ := Int | Bool | τ1->τ2 // e ::= x | λx : τ.e | true| false| e1 e2 | if e then e1 else e2 // v ::= true | false | λx : τ.e // E ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/veri-sparse_tmp_tmp15fywna6_dafny_concurrent_poc_6.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
9,768
442c09c9ea470ff6f56214df4ebcd8db7657644528c4e1bfe6b47c255fa4f515
class Process { var row: nat; var curColumn: nat; var opsLeft: nat; constructor (init_row: nat, initOpsLeft: nat) ensures row == init_row ensures opsLeft == initOpsLeft ensures curColumn == 0 { row := init_row; curColumn := 0; opsLeft := ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/veri-sparse_tmp_tmp15fywna6_dafny_dspmspv.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,963
13fb6a928ebd174b9844f304b141331afdd86ef99410f9c1fa7230c363cc131f
function sum(X_val : array<int>, X_crd : array<nat>, v_val : array<int>, v_crd : array<nat>, kX : nat, kV : nat, pX_end : nat, pV_end : nat) : (s : int) reads X_val, X_crd requires X_val.Length == X_crd.Length requires pX_end <= X_crd.Length requires 0 <= kX <= X_crd.Length reads v_crd, ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/veri-sparse_tmp_tmp15fywna6_dafny_spmv.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,603
01c879f0d3c635960f22d1c6bc7391a21703028c9c2844afa74a17c964037016
function sum(X_val: array<int>, X_crd: array<nat>, v : array<int>, b : int, k : int) : (s : int) reads X_val, X_crd, v requires X_val.Length >= b >= 0 requires k <= X_val.Length requires X_val.Length == X_crd.Length requires forall i :: 0 <= i < X_crd.Length ==> 0 <= X_crd[i] < v.Length decreases k - ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/veri-titan_tmp_tmpbg2iy0kf_spec_crypto_fntt512.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,053
68669a194ab08197d5f4bbfbfd65dfa5357112c08a86ab464744347c2d3fcd16
// include "ct_std2rev_model.dfy" // abstract module ntt_impl { // import opened Seq // import opened Power // import opened Power2 // import opened DivMod // import opened Mul // import opened pows_of_2 // import opened ntt_index // import opened ntt_512_params // ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/veribetrkv-osdi2020_tmp_tmpra431m8q_docker-hdd_src_veribetrkv-linear_lib_Base_SetBijectivity.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,033
6e50838be400bd1bed5edcf8ea384375fbda30ccbecd3e17af132312842ce0d6
module SetBijectivity { lemma BijectivityImpliesEqualCardinality<A, B>(setA: set<A>, setB: set<B>, relation: iset<(A, B)>) requires forall a :: a in setA ==> exists b :: b in setB && (a, b) in relation requires forall a1, a2, b :: a1 in setA && a2 in setA && b in setB && (a1, b) in relation && (a2, b) in r...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/veribetrkv-osdi2020_tmp_tmpra431m8q_docker-hdd_src_veribetrkv-linear_lib_Base_Sets.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,043
73cf927dbe8883a94ffc45e79f775df0f3497914d781eb3b07305fe90c207d6f
module Sets { lemma {:opaque} ProperSubsetImpliesSmallerCardinality<T>(a: set<T>, b: set<T>) requires a < b ensures |a| < |b| { assert |b| == |a| + |b-a|; } lemma {:opaque} SetInclusionImpliesSmallerCardinality<T>(a: set<T>, b: set<T>) requires a <= b ensures |a| <= |b| { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/verification-class_tmp_tmpz9ik148s_2022_chapter05-distributed-state-machines_exercises_UtilitiesLibrary.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,213
00344d801456cd1d78b807d187d109a4a183934fffef2552f008483a70268d82
module UtilitiesLibrary { function DropLast<T>(theSeq: seq<T>) : seq<T> requires 0 < |theSeq| { theSeq[..|theSeq|-1] } function Last<T>(theSeq: seq<T>) : T requires 0 < |theSeq| { theSeq[|theSeq|-1] } function UnionSeqOfSets<T>(theSets: seq<set<T>>) : set<T> { if |th...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/verified-isort_tmp_tmp7hhb8ei__dafny_isort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,742
3600cc78eb809ce8bd3304640ea218f77622449da7e24a1bf0c4f00e54a41310
// Dafny is designed to be familiar to those programming in an OOP language like // Java, so, we have plain old ordinary mutable arrays rather than the functional // list data structures that we saw in Coq. This means that unlike our Coq // and Python examples, we can sort our array in-place and avoid needing a who...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/verified-using-dafny_tmp_tmp7jatpjyn_longestZero.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,353
b0dacffbf1233c739b9082568b4056d052d9844c8a1c647f4f3a646dbb073b08
function getSize(i: int, j:int) : int { j - i + 1 } // For a given integer array, let's find the longest subesquence of 0s. // sz: size, pos: position. a[pos..(pos+sz)] will be all zeros method longestZero(a: array<int>) returns (sz:int, pos:int) requires 1 <= a.Length ensures 0 <= sz <= ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/VerifiedMergeSortDafny_tmp_tmpva7qms1b_MergeSort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,392
940930fb89eb25fb7ef6282be0e464f00715a8cf86cb3cec93bed398c51ab7fa
method mergeSimple(a1: seq<int>, a2: seq<int>, start: int, end: int, b: array<int>) modifies b requires sorted_seq(a1) requires sorted_seq(a2) requires 0 <= start <= end <= b.Length requires |a1| + |a2| == end - start + 1 ensures sorted_slice(b, start, end) { var a1Pos := 0; var a2Pos := 0; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/vfag_tmp_tmpc29dxm1j_mergesort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,683
1a4fd24ca0b5e81cb768c8f104da8df1f28d37cca9f2f43c0b81a78c709b765b
method ordenar_mergesort(V : array?<int>) requires V != null modifies V { mergesort(V, 0, V.Length - 1) ; } method mergesort(V : array?<int>, c : int, f : int) requires V != null requires c >= 0 && f <= V.Length decreases f - c modifies V {...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/vfag_tmp_tmpc29dxm1j_sumar_componentes.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,573
112d2c3dce6eb41b0279e4a140f169036f8eebae4b775b3561e7dd51f269d23a
method suma_componentes(V : array?<int>) returns (suma : int) requires V != null ensures suma == suma_aux(V, 0) // x = V[0] + V[1] + ... + V[N - 1] { var n : int ; assert V != null ; // P assert 0 <= V.Length <= V.Length && 0 == suma_aux(V, V.Length) ; // P ==> pmd(n := V.Len...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/vfag_tmp_tmpc29dxm1j_Verificacion_torneo.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
8,429
b9c07a1161e60dd423a7d22fde537e6cd8e2f70cc593169f840e4294e5c4b3e9
method torneo(Valores : array?<real>, i : int, j : int, k : int) returns (pos_padre : int, pos_madre : int) requires Valores != null && Valores.Length >= 20 && Valores.Length < 50 && i >= 0 && j >= 0 && k >= 0 requires i < Valores.Length && j < Valores.Length && k < Valores.Length && i != j && j != k && k !=...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/vmware-verification-2023_tmp_tmpoou5u54i_demos_leader_election.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,275
1ccaf349c2b51be0b0190cb944c75e55094429a60c29539a1131d5a4abb24adf
// Each node's identifier (address) datatype Constants = Constants(ids: seq<nat>) { predicate ValidIdx(i: int) { 0<=i<|ids| } ghost predicate UniqueIds() { (forall i, j | ValidIdx(i) && ValidIdx(j) && ids[i]==ids[j] :: i == j) } ghost predicate WF() { && 0 < |ids| && UniqueIds() ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_max_array.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
905
618551da007c25c8003642f81c80b9b5d748ddd475b016e574570834dada47c2
// http://verifythus.cost-ic0701.org/common-example/arraymax-in-dafny method max(a:array<int>) returns(max:int) requires a != null; ensures forall j :: j >= 0 && j < a.Length ==> max >= a[j]; //max is larger then anything in the array ensures a.Length > 0 ==> exists j :: j >= 0 && j < a.Length && max ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_selection_sort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,396
99191b05bc0e5b5fc1b28933d05cd562131ac8ed33db691df6320d8ae21310c8
//https://homepage.cs.uiowa.edu/~tinelli/classes/181/Fall21/Tools/Dafny/Examples/selection-sort.shtml predicate sorted (a: array<int>) requires a != null reads a { sorted'(a, a.Length) } predicate sorted' (a: array<int>, i: int) requires a != null requires 0 <= i <= a.Length reads a { forall k ::...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_sum_array.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
470
65a8e86ebc2660c50f32f514ad43dd35b51488e573331201a2884bcea765f0c4
function sumTo( a:array<int>, n:int ) : int requires a != null; requires 0 <= n && n <= a.Length; reads a; { if (n == 0) then 0 else sumTo(a, n-1) + a[n-1] } method sum_array( a: array<int>) returns (sum: int) requires a != null; ensures sum == sumTo(a, a.Length); { var i := 0; sum := 0; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_triangle_number.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
367
0d6fc6d67bacedf33c715c932a1d2200f26433f2e02e63a7160de59ef15bd039
method TriangleNumber(N: int) returns (t: int) requires N >= 0 ensures t == N * (N + 1) / 2 { t := 0; var n := 0; while n < N invariant 0 <= n <= N invariant t == n * (n + 1) / 2 decreases N - n;// can be left out because it is guessed correctly by Dafny { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Workshop_tmp_tmp0cu11bdq_Workshop_Answers_Question5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
653
3b2b91c110b4a03c566f26bbe341be8c91cb75d3bca9257c87475d2193960eac
method rev(a : array<int>) requires a != null; modifies a; ensures forall k :: 0 <= k < a.Length ==> a[k] == old(a[(a.Length - 1) - k]); { var i := 0; while (i < a.Length - 1 - i) invariant 0 <= i <= a.Length/2; invariant forall k :: 0 <= k < i || a.Length - 1 - i < k <= a.Le...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Workshop_tmp_tmp0cu11bdq_Workshop_Answers_Question6.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
542
4288df7b177c82635242cdd5e51726bb34e3ea7ae939ec8a9bd6397720b6b128
method arrayUpToN(n: int) returns (a: array<int>) requires n >= 0 ensures a.Length == n ensures forall j :: 0 < j < n ==> a[j] >= 0 ensures forall j, k : int :: 0 <= j <= k < n ==> a[j] <= a[k] { var i := 0; a := new int[n]; while i < n invariant 0 <= i <= n invaria...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/WrappedEther.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
21,285
10c8cf7edc6be598890de375f13963225a7e1c2a38af8881223bf94764f247c6
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
sun-wendy/DafnyBench
DafnyBench/dataset/hints_removed/630-dafny_tmp_tmpz2kokaiq_Solution_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
705
2607cdcab744d0b36611a99b49cb759b205e3a611a5cd4628e3ee0a2aa72f44c
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/hints_removed/703FinalProject_tmp_tmpr_10rn4z_DP-GD_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,222
56c9e80c6350262a1ce304fa41ca18257af3feec1d1aea5ef19f3d3420f86e44
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/hints_removed/703FinalProject_tmp_tmpr_10rn4z_gaussian_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
770
60c255230dd282256368211b0a1cc7c762c517dd89e2e8edd1dc18ef94c15093
// 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/hints_removed/assertive-programming-assignment-1_tmp_tmp3h_cj44u_FindRange_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,466
9982961261b2e1cf8a70cda53ea926600f42847e8d839392c4389e0550c743f1
method Main() { var q := [1,2,2,5,10,10,10,23]; 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"; } // arr = [0, 1, 2] ...
sun-wendy/DafnyBench
DafnyBench/dataset/hints_removed/assertive-programming-assignment-1_tmp_tmp3h_cj44u_ProdAndCount_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
8,342
162983b7656a53ab98fc137cad9de459775ce026284a5bd18c46eb5f8a3b513c
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; print "\nThe number of occurrences of -2 in [7,-2,3,-2] is "; print c; calc { RecursiveCount(-2, q); == { assert q[3] == -2; AppendOne(q, 3); } ...
sun-wendy/DafnyBench
DafnyBench/dataset/hints_removed/assertive-programming-assignment-1_tmp_tmp3h_cj44u_SearchAddends_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,958
59f97bed2b90605912dfe9c372c5e4787e2972f719cbe82db1e85dc39dcaf8b4
method Main() { var q := [1,2,4,5,6,7,10,23]; 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 "] == "; print q[i]; print " + "; print q[j]; print " == 10"; } predicate Sorted(q:...
sun-wendy/DafnyBench
DafnyBench/dataset/hints_removed/AssertivePrograming_tmp_tmpwf43uz0e_DivMode_Unary_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
7,694
85168fe6b5ba4ec58c72087f95a2cad07337695b9a43ff59a286a828bc2f4d29
// 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/hints_removed/AssertivePrograming_tmp_tmpwf43uz0e_Find_Substring_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
6,435
2e279e03cc74964cc087ca1dc24b154c728e9380bd89930b7d5f4dee9dba7fa3
// 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/hints_removed/AssertivePrograming_tmp_tmpwf43uz0e_MergeSort_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,751
8d33c6c7d820186d20656767d879b4b704827f730889a10967b605a1b81271eb
// 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/hints_removed/bbfny_tmp_tmpw4m0jvl0_enjoying_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,715
2aa94fdc314de5e448c5a8d4e5084b0eeb8cd48f7b75cf026de15771a3083562
// 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/hints_removed/BinarySearchTree_tmp_tmp_bn2twp5_bst4copy_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,538
8bc5f6ec358669e586c048dcb6842378f70bb8aa30a4de0aa34f0677ee88c71a
datatype Tree = Empty | Node(left: Tree, value: int, right: Tree) predicate BinarySearchTree(tree: Tree) { match tree case Empty => true case Node(_,_,_) => (tree.left == Empty || tree.left.value < tree.value) && (tree.right == Empty || tree.right.value > tree.value) && BinarySearchTree(tree...
sun-wendy/DafnyBench
DafnyBench/dataset/hints_removed/BPTree-verif_tmp_tmpq1z6xm1d_Utils_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
10,163
16bc15b3095823e2d841a534bf23f9b41389b31eb261ffd106f6ae62636e18a9
// 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/hints_removed/circular-queue-implemetation_tmp_tmpnulfdc9l_Queue_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
7,607
a018d4ca8d3176e0c04a1a18555f40fd6943f66fdf70df41cd83157f4be8fd9a
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/hints_removed/Clover_all_digits_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
247
a37caf2df99022efd4532b695102b8cc5e984f3fc75bcdaaf0aa1171cd3b9dc6
method allDigits(s: string) returns (result: bool) ensures result <==> (forall i :: 0 <= i < |s| ==> s[i] in "0123456789") { result:=true ; for i := 0 to |s| { if ! (s[i] in "0123456789"){ return false; } } }
sun-wendy/DafnyBench
DafnyBench/dataset/hints_removed/Clover_array_append_no_hints.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
226
fe13d36943ce6d52c9904fafd599edd38ec55ae1dc615cabb7e51f1353043c42
method append(a:array<int>, b:int) returns (c:array<int>) ensures a[..] + [b] == c[..] { c := new int[a.Length+1]; var i:= 0; while (i < a.Length) { c[i] := a[i]; i:=i+1; } c[a.Length]:=b; }