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/CVS-Projto1_tmp_tmpb1o0bu8z_Hoare.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,897 | 6cc509dc6e319dc9837a605ce9d43a4faa00e7365c6dfe224e5b014459973b03 | method Max (x: nat, y:nat) returns (r:nat)
ensures (r >= x && r >=y)
ensures (r == x || r == y)
{
if (x >= y) { r := x;}
else { r := y;}
}
method Test ()
{
var result := Max(42, 73);
assert result == 73;
}
method m1 (x: int, y: int) returns (z: int)
requires 0 < x < y
ensures z... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CVS-Projto1_tmp_tmpb1o0bu8z_proj1_proj1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,795 | 35f8feee3ab3fae4dab55cefcd0cfbf198d24815ae4bb4e96f2b6b4b55c565f1 | //Exercicio 1.a)
function sum (a:array<int>, i:int, j:int) :int
decreases j
reads a
requires 0 <= i <= j <= a.Length
{
if i == j then
0
else
a[j-1] + sum(a, i, j-1)
}
//Exercicio 1.b)
method query (a:array<int>, i:int, j:int) returns (s:int)
requires 0 <= i <= j <= a.Length
ensur... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/CVS-Projto1_tmp_tmpb1o0bu8z_searchSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,163 | 2ca3a7485e9100acbd826f266bd1c2528fe3835c04965e147995a4bbb90a26cd | method fillK(a: array<int>, n: int, k: int, c: int) returns (b: bool)
requires 0 <= c <= n
requires n == a.Length
{
if c == 0 {
return true;
}
var p := 0;
while p < c
invariant 0 <= p <= c
{
if a[p] != k
{
return fa... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafleet_tmp_tmpa2e4kb9v_0001-0050_0001-two-sum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,627 | a03943864adca0403581230e561494fd7f7f02e3a331aa20bafa1d2d0cdaa531 | /* 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/ground_truth/dafleet_tmp_tmpa2e4kb9v_0001-0050_0003-longest-substring-without-repeating-characters.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,194 | 02d0c4778c86257222530d5bbbc166a5e4507d3293fdaf841f6798fea52c86b6 | /* 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/ground_truth/dafleet_tmp_tmpa2e4kb9v_0001-0050_0005-longest-palindromic-substring.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 17,733 | caa7b8dd074b6de6db999102a131d20be080bd41eb3c69fd7b28d6980275389f | /* 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_ContainerRanks.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 885 | 661d3cab7cb0a8c6909e4a18edc220ebb45c9df35d8eaf2e2c46da70eb2d7704 | // 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])
{
assert [a][0] == a; // TODO: one could consider strengthening axioms to eliminate the need for this assert
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_DividedConstructors.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,319 | 8937c014f3ae88facce95c1d73160601dd822a710f217f27a84283d6fd9f350c | // 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();
assert r0.b != r1.b;
print r0.b, ", ", r1.b, "\n";
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_ForallCompilationNewSyntax.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,184 | 89a3b3494d66e005d69dfcac6f88843aa36e7d7b3053cdf89cbde68676ab7441 | // 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_InSetComprehension.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,078 | 8e350eade51076042d2a3ffe75aeb4e6a49e5f1befb9ccbde0b06d2988a0a632 | // 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_PrecedenceLinter.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 11,965 | d3ff66c8d9d46f303adea04e2b5550d779d20d6c4bf0d9e52cad42133b902a41 | // 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_SeqFromArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,605 | c2388caec0051a1bb5c9d93a104b08e25371beb91c85651829f0179f508382d6 | // 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_dafny0_SharedDestructorsCompile.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,960 | 451b7fbeb1ba25755273c77c46eae4df474bfb263f140206c81faa8ff9f8523f | // 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_binary-search.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,852 | ffaad6adb5d6e8a712a9da7b3a25371c1385f492162bf2b260a1be8ac80e57e2 |
///////////////////
// 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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_fibonacci.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 847 | 60704d130a008d294907d6bc858a02b95fb7a4a4c446f5b1374370cf27621cc0 | /*
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
decrease... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_find.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,125 | fc3c2622e529554d2594ac50bdca72ad4938244c3d3c12b79beadc067bb47280 | /*
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/ground_truth/dafl_tmp_tmp_r3_8w3y_dafny_examples_uiowa_modifying-arrays.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,551 | 94a250a5a261d24f441c741eb3b8033c60403172ac103f546cc4ea8fa37831a3 | /*
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/ground_truth/dafny-aoc-2019_tmp_tmpj6suy_rv_parser_split.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,435 | b4399a725546018a70d95b09117750e326bb0ea15c4d29f5cf2fb6d8b6e84a1a | 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/ground_truth/Dafny-demo_tmp_tmpkgr_dvdi_Dafny_BinarySearch.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 789 | d4f7e91318f5a430ccd7ac7873be3b0153cdf9f0b4dec64fbdf66098fb05ead3 |
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/ground_truth/dafny-duck_tmp_tmplawbgxjo_ex3.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,381 | c28bec5dddde20eb0e850655f8974558eecc5db0334c54b37710ad0af1bc8d95 | // 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/ground_truth/dafny-duck_tmp_tmplawbgxjo_ex5.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,158 | 1a836fca2d0b53c982e260cf45086e9735524e6ab4d32f0869679da42a8948d3 | // 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) {
assert (expo(2,3*0)-expo(3,0)) % 5 == 0;
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-duck_tmp_tmplawbgxjo_p1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 524 | 0bc9183d996977d5454fa74606f31a0ca8797441b38025a77785cbc110f63dc2 | // 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
invari... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-duck_tmp_tmplawbgxjo_p2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,259 | 1e3af3830df5682ddd28a881b5448a184de6f0aeca6e8de8ed278e3573a9bc3c | // 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/ground_truth/dafny-duck_tmp_tmplawbgxjo_p3.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 889 | c5468931b2ef028ac2ffe03ca0261521b461a50ac50febaaa2bc9a474e4dc3b0 | //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/ground_truth/dafny-duck_tmp_tmplawbgxjo_p4.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,418 | 843197a426124f32f6a8bff217dcccffa7db86a97f60186a1da734e268af33ef | //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/ground_truth/dafny-duck_tmp_tmplawbgxjo_p6.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,421 | 2a5c1aa0e22256d8f41b310c458581c3d85674ba61ab44d556019d806c07f5d5 | //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/ground_truth/dafny-exercises_tmp_tmp5mvrowrx_leetcode_26-remove-duplicates-from-sorted-array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,543 | 77cefe90fa722f81b268400ead7390fb869a2b675b4a9e4a79dc4613154d3183 |
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/ground_truth/dafny-exercises_tmp_tmp5mvrowrx_paper_krml190.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,418 | 6f065f3b667c2d1d90ee6a599f9ff025c66cc2408b41ce528fc10700548afaf9 | // 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/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session10Exercises_ExerciseBarrier.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,291 | 673b968c1c6318de23a3a84d1e31186c5f12d57936ca221662dc1ee81d2c1a7e |
//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/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExerciseExp.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 649 | 9c19f1183d35eaaa4818d2cc6defb53891e722ef4c35ad209cd8594194010c0c | function exp(x:int, e:int):int
decreases e
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)
decreases n
requires n >= 1
ensures (exp(3,n)-1)%2 == 0
{}
lemma mult8_Lemma(n:int)
decreases n
requires n >= 1
ensures ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExerciseFibonacci.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,204 | fc13e72f67f66dd158fb1382bd1ccf802322820e24127665f584d5b800e7dd89 | function fib(n: nat): nat
decreases n
{
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
decreases n - i//write the bound
inva... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExercisePositive.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,631 | 9f408f7dc836da82daed66599b9ec65be4ade87c8fbeb196c9e5741f703ce7ea | 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
decreases v.Length - i
invariant 0<=i<=v.Length
inva... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session2Exercises_ExerciseSquare_root.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 929 | 3dc55a16d1998b960f4222ea4ab4b16e7833c333bb7692761c2c8f501be4fc37 | 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
invariant r>=0 && r*r <=n
decreases n-r*r
{
r:=r+1;
}
}
method mroot2(n:int) returns (r:int) //Cost O(n)
requires n>=0
ensures r>=0 && r*r <= n ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session3Exercises_ExerciseMaximum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,411 | 03b239663baa21dc4db8c9db6edcaa81119647107764b31d2aec615bdd9a728a | //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)
decreases v.Length - j
invariant 0<=j<=v.Length
inva... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExerciseAllEqual.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,843 | 568e4c31839c1edb70b15164a01f8ef31f8d8e053ed5af3b1b80536af99545a7 | 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/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExerciseContained.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,021 | ab986b0b2a90e0e70f0972ef425cb5354262a5edc85fa76183c2b1b16c172bad |
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/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExerciseFirstNegative.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 999 | 07896b73a987862c26fc939bfd083e850c68097f73b2d3ed66f6a956f506715d | 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)
invariant 0<=i<=v.Length... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session4Exercises_ExercisefirstZero.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 312 | 9bc816a25e2eddecc8c0f8f2ef689eead5397c57f39825ea8bdd1232049fce49 |
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)
invariant 0<=i<=v.Length
invariant forall j:: 0<=j<i ==> v[j]!=0
decreases v.Length -i
{i:=i+1;}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session5Exercises_ExerciseSumElems.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,065 | 3cb8b639944a65e12ef8dea8e1ba716b0f7c81d3d7681ed79254539a368f5473 | function SumR(s:seq<int>):int
decreases s
{
if (s==[]) then 0
else SumR(s[..|s|-1])+s[|s|-1]
}
function SumL(s:seq<int>):int
decreases s
{
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])
{}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session6Exercises_ExerciseCountEven.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,071 | 1f9bfb7a62d620d0f3bdb279a63243e29192eb1b578bd4c84287d818d633c059 |
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
decreases s
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 ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session6Exercises_ExerciseCountMin.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 984 | ba9505bf24134ddb08bc8b553af3895fc8a33b351413d96506d367c0acd2ad36 | function min(v:array<int>,i:int):int
decreases i
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
decreases i
reads v
requires 0<=i<=v.L... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session6Exercises_ExercisePeekSum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 823 | 367a87d64e17c1ab4f86b5c6ec527e1074fa822104aa17b2e1ec583289f3f291 |
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
decreases i
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)
}
met... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session7Exercises_ExerciseBinarySearch.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,239 | 40c61f9cdb3a33ed2c9620ad5c139a17ea4b4ee12725c90deaa148fc473cd035 | predicate sorted(s : seq<int>) {
forall u, w :: 0 <= u < w < |s| ==> s[u] <= s[w]
}
method binarySearch(v:array<int>, elem:int) returns (p:int)
requires sorted(v[0..v.Length])
ensures -1<=p<v.Length
ensures (forall u::0<=u<=p ==> v[u]<=elem) && (forall w::p<w<v.Length ==> v[w]>elem)
{
var c,f:=0,v.Leng... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session7Exercises_ExerciseBubbleSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,782 | c40124d09e77f79e087e8a17920a53df516af3f40af82ab763d6490094b86477 | predicate sorted_seg(a:array<int>, i:int, j:int) //j excluded
requires 0 <= i <= j <= a.Length
reads a
{
forall l, k :: i <= l <= k < j ==> a[l] <= a[k]
}
method bubbleSorta(a:array<int>, c:int, f:int)//f excluded
modifies a
requires 0 <= c <= f <= a.Length //when c==f empty sequence
ensures sorted_seg(... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session7Exercises_ExerciseReplace.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 583 | 34301c39de1ee808de77b186c9a36deb8cd25f8128741450b6b481d1d435374f |
method replace(v:array<int>, x:int, y:int)
modifies v
ensures forall k::0<=k<old(v.Length) && old(v[k])==x ==> v[k]==y
ensures forall k::0<=k<old(v.Length) && old(v[k])!=x ==> v[k]==old(v[k])
{
var i:=0;
while(i<v.Length)
decreases v.Length - i
invariant 0<=i<=v.Length
invariant foral... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session7Exercises_ExerciseSelSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,299 | 1dbd66715c4022e3360dfb5cf9d3e0ccd849a681beb38d95073698817405f931 | predicate sorted_seg(a:array<int>, i:int, j:int) //j not included
requires 0 <= i <= j <= a.Length
reads a
{
forall l, k :: i <= l <= k < j ==> a[l] <= a[k]
}
method selSort (a:array<int>, c:int, f:int)//f excluded
modifies a
requires 0 <= c <= f <= a.Length //when c==f empty sequence
ensures sorted_s... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session7Exercises_ExerciseSeparate.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,157 | 8141cfe0fc1501b4b5bbdcb1cb5661b7f8ef70764c523d15dda3603529374ad0 | predicate strictNegative(v:array<int>,i:int,j:int)
reads v
requires 0<=i<=j<=v.Length
{forall u | i<=u<j :: v[u]<0}
predicate positive(s:seq<int>)
{forall u::0<=u<|s| ==> s[u]>=0}
predicate isPermutation(s:seq<int>, t:seq<int>)
{multiset(s)==multiset(t)}
/**
returns an index st new array is a permutation... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session8Exercises_ExerciseInsertionSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,291 | b084619357841026c3ff436131a25b9f3de1da335e8bf201c389c8089541ae04 |
predicate sorted_seg(a:array<int>, i:int, j:int) //i and j included
requires 0 <= i <= j+1 <= a.Length
reads a
{
forall l, k :: i <= l <= k <= j ==> a[l] <= a[k]
}
method InsertionSort(a: array<int>)
modifies a;
ensures sorted_seg(a,0,a.Length-1)
ensures multiset(a[..]) == old(multiset(a[..])) /... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Exercises_tmp_tmpjm75muf__Session9Exercises_ExerciseSeqMaxSum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,670 | 63900a7d8500240f8f55f252454761ac8b3567e7aa3d79e9dd7dc0bdd3f5d432 |
function Sum(v:array<int>,i:int,j:int):int
reads v
requires 0<=i<=j<=v.Length
decreases j
{
if (i==j) then 0
else Sum(v,i,j-1)+v[j-1]
}
predicate SumMaxToRight(v:array<int>,i:int,s:int)
reads v
requires 0<=i<v.Length
{
forall l,ss {:induction l}::0<=l<=i && ss==i+1==> Sum(v,l,ss)<=s
}
meth... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_absIt.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,569 | ea79d0820694d96bb10c9fa9012195a64533b23e73e749822bad1e6605e08916 | method AbsIt(s: array<int>)
modifies s
ensures forall i :: 0 <= i < s.Length ==> if old(s[i]) < 0 then s[i] == -old(s[i]) else s[i] == old(s[i])
ensures s.Length == old(s).Length
{
var i: int := 0;
while i < s.Length
invariant 0 <= i <= s.Length
invariant forall j :: 0 <= j < i ==> if old(s[j]) < 0 then... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_appendArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 708 | 47016b66d7dfd26d86b8eab3a0272f6e05f994fa6ea62186a80caf4665fdfc18 | method appendArray(a: array<int>, b: array<int>) returns (c: array<int>)
ensures c.Length == a.Length + b.Length
ensures forall i :: 0 <= i < a.Length ==> a[i] == c[i]
ensures forall i :: 0 <= i < b.Length ==> b[i] == c[a.Length + i]
{
c := new int[a.Length + b.Length];
var i := 0;
while i < a.Length
inv... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_countNeg.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 605 | 8bef167e61cc376dbdc4a7c61d1d5b7e97c8e6275a0b4994f41341e3091d7007 | function verifyNeg(a: array<int>, idx: int) : nat
reads a
requires 0 <= idx <= a.Length
{
if idx == 0 then 0
else verifyNeg(a, idx - 1) + (if a[idx - 1] < 0 then 1 else 0)
}
method CountNeg(a: array<int>) returns (cnt: nat)
ensures cnt == verifyNeg(a, a.Length)
{
var i := 0;
cnt := 0;
while i < a.L... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_filter.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,188 | ac2060eab88c0774e67e9f637147639ab9b7fc9d28c72ecc589b82c3b12f4c5a | method Filter(a:seq<char>, b:set<char>) returns(c:set<char>)
ensures forall x :: x in a && x in b <==> x in c
{
var setA: set<char> := set x | x in a;
c := setA * b;
}
method TesterFilter()
{
var v:set<char> := {'a','e','i','o','u'}; // vowels to be used as a filter
var s:seq<char> := "ant-egg-ink... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_firstE.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 703 | 4e640c3309eaf8f57399b90a5c4d9254a9d6c6dab379d9493099cef541d981d2 | method firstE(a: array<char>) returns (x: int)
ensures if 'e' in a[..] then 0 <= x < a.Length && a[x] == 'e' && forall i | 0 <= i < x :: a[i] != 'e' else x == -1
{
var i: int := 0;
while i < a.Length
invariant 0 <= i <= a.Length
invariant forall j :: 0 <= j < i ==> a[j] != 'e'
{
if (a[i] == 'e') {
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_maxArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 634 | 04cfe7b17271f302147c3b7ad6264a55941e24a676f1778e0ce34b8df2242ffb | method MaxArray(a: array<int>) returns (max:int)
requires a.Length > 0
ensures forall i :: 0 <= i < a.Length ==> a[i] <= max
ensures exists i :: 0 <= i < a.Length && a[i] == max
{
var i: nat := 1;
max := a[0];
while i < a.Length
invariant 0 <= i <= a.Length
invariant forall j :: 0 <= j < i ==> a[j] <= max... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_prac1_ex1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 454 | ce5ea75fe424f4227eb7616c6ec5fdb400349cfee4a281788ad81145acc917ee | predicate acheck(a: array<int>, n: int)
reads a
requires n >= 1
{
a.Length % 2 == 0 &&
forall i :: 0 <= i < a.Length ==>
if i % n == 0 then a[i] == 0 else a[i] != 0
}
method Main()
{
var arr: array<int> := new int[][0,42,0,42];
var res := acheck(arr, 2);
assert res;
arr := new int[][];
res... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_prac1_ex2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,006 | cf843db1ea316df630c5e71711bcabd5c97798e0ba0677333eed13b86b5d70ae | method Deli(a: array<char>, i: nat)
modifies a
requires a.Length > 0
requires 0 <= i < a.Length
ensures forall j :: 0 <= j < i ==> a[j] == old(a[j])
ensures forall j :: i <= j < a.Length - 1 ==> a[j] == old(a[j + 1])
ensures a[a.Length - 1] == '.'
{
var c := i;
while c < a.Length - 1
invariant i <= c <= a.... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_prac3_ex2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 676 | 618e6152f6eee168a2e626a6f01d00381950eb4a01235c5bf7a2b8753e9d4750 | method GetEven(s: array<nat>) modifies s
ensures forall i :: 0 <= i < s.Length ==>
if old(s[i]) % 2 == 1 then s[i] == old(s[i]) + 1
else s[i] == old(s[i])
{
var i := 0;
while i < s.Length
invariant 0 <= i <= s.Length
invariant forall j :: 0 <= j < i ==>
if old(s[j]) % 2 == 1 then s[j] ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_prac4_ex2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,885 | b1b2b43947a7022444c59d276c0f23314c6d33e6f54a56a650f4715dbdea1c5a | predicate triple(a: array<int>)
reads a
{
exists i :: 0 <= i < a.Length - 2 && a[i] == a[i + 1] == a[i + 2]
}
method GetTriple(a: array<int>) returns (index: int)
ensures 0 <= index < a.Length - 2 || index == a.Length
ensures index == a.Length <==> !triple(a)
ensures 0 <= index < a.Length - 2 <==> triple(a)... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_reverse.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 700 | b18a6aac48db0422c20a00ecc26126212c5cf4e68067060b9c0a3d9f0faf48c0 | method Reverse(a: array<char>) returns (b: array<char>)
requires a.Length > 0
ensures a == old(a)
ensures b.Length == a.Length
ensures forall i :: 0 <= i < a.Length ==> b[i] == a[a.Length - i - 1]
{
b := new char[a.Length];
var i := 0;
while i < a.Length
invariant 0 <= i <= a.Length
invariant forall j ::... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-exercise_tmp_tmpouftptir_zapNegatives.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 732 | 98988dfce824a46da0302a05ee169316dce22f6cb2113f777deaf8f88af03ffc | method ZapNegatives(a: array<int>)
modifies a
ensures forall i :: 0 <= i < a.Length ==> if old(a[i]) < 0 then a[i] == 0
else a[i] == old(a[i])
ensures a.Length == old(a).Length
{
var i := 0;
while i < a.Length
invariant 0 <= i <= a.Length
invariant forall j :: 0 <= j < i ==> if old(a[j]) < 0 t... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-experiences_tmp_tmp150sm9qy_dafny_started_tutorial_dafny_tutorial_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 585 | c19421f1b9bd81d9cd8b0678e7cb0e3d5933ccf67b851d06d6d85c00a7798303 | method FindMax(a: array<int>) returns (i: int)
// Annotate this method with pre- and postconditions
// that ensure it behaves as described.
requires a.Length > 0
ensures 0<= i < a.Length
ensures forall k :: 0 <= k < a.Length ==> a[k] <= a[i]
{
// Fill in the body that calculates the INDEX of the maxi... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-Grind75_tmp_tmpsxfz3i4r_problems_twoSum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,622 | d9e5cb5722baf94a0c1252db903be3ce0977b3de8ec4ef2cf92ab3fce16da6ef | /*
https://leetcode.com/problems/two-sum/
function twoSum(nums: number[], target: number): number[] {
const n = nums.length;
for(let i = 0; i < n; i++) {
for(let k = i+1; k < n; k++) {
if(nums[i] + nums[k] == target) return [i,k];
}
}
};
*/
predicate summingPair(i: na... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_allocated1_dafny0_fun-with-slices.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,756 | 46682387d7896fe51c437362c1c0e46c723dcb38895ea41c116f45953b3136d2 | // RUN: %dafny /verifyAllModules /allocated:1 /compile:0 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// This test was contributed by Bryan. It has shown some instabilities in the past.
method seqIntoArray<A>(s: seq<A>, a: array<A>, index: nat)
requires index + |s| <= a.Len... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_comp_Arrays.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,509 | c1f33cb6e99be028d53add2ffb91dbec6b57edb99a291acf5c5ec8db76a881b0 | // RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cs "%s" > "%t"
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:js "%s" >> "%t"
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:go "%s" >> "%t"
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:java "%s" >> "%t"
// RUN: %di... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny0_FuelTriggers.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 539 | 2e243c2b9cee34859d7c6635d76a7cae7d5ff1dd5bab72493d9a232320db7b7a | // RUN: %dafny /ironDafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// In one version of opaque + fuel, the following failed to verify
// because the quantifier in the requires used a trigger that included
// StartFuel_P, while the assert used StartFuelAssert_P. ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny0_snapshots_Inputs_Snapshots0.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 83 | 2caa72d99a98d0a86cc4eed81ea3eda0c828847070385c0ff3ffeee3920c3d61 | method foo()
{
bar();
assert false;
}
method bar()
ensures false;
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny1_Cubes.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 559 | 2093dae790e260605731efbe974877f6b929541ccbf4d9548135c304cc7e8279 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
method Cubes(a: array<int>)
modifies a
ensures forall i :: 0 <= i < a.Length ==> a[i] == i*i*i
{
var n := 0;
var c := 0;
var k := 1;
var m := 6;
while n < a.Length
invariant 0 <= n <= a.Length
in... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny1_ListReverse.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 954 | 36bac0ecbbf8cdb6ab099fa8c5ffea230fd34e93338bb591453340b81c79d166 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class Node {
var nxt: Node?
method ReverseInPlace(x: Node?, r: set<Node>) returns (reverse: Node?)
requires x == null || x in r;
requires (forall y :: y in r ==> y.nxt == null || y.nxt in r); // region closur... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny1_MatrixFun.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,883 | d2a780a7387945ed222511ff865318f610c475a6da48ff80112ea62fec3d4a83 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
method MirrorImage<T>(m: array2<T>)
modifies m
ensures forall i,j :: 0 <= i < m.Length0 && 0 <= j < m.Length1 ==>
m[i,j] == old(m[i, m.Length1-1-j])
{
var a := 0;
while a < m.Length0
invariant a <... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny2_COST-verif-comp-2011-1-MaxArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,204 | 8376a449215f59ef158c6997df4e662047b3d9fa1fb92b376a8a6f62f7426335 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
/*
Rustan Leino, 5 Oct 2011
COST Verification Competition, Challenge 1: Maximum in an array
http://foveoos2011.cost-ic0701.org/verification-competition
Given: A non-empty integer array a.
Verify that the index return... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny2_Intervals.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,918 | 47b93725a5cb0f265f4ca1455f0107aee3c8c7c4465c915b00a5dadeb2a7063e | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// The RoundDown and RoundUp methods in this file are the ones in the Boogie
// implementation Source/AbsInt/IntervalDomain.cs.
class Rounding {
var thresholds: array<int>
function Valid(): bool
reads this, thr... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny2_SegmentSum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 942 | 15c2d2bdca1e125633bb507dbb6736447d3b2bb740ba96829141554ed90475e6 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function Sum(a: seq<int>, s: int, t: int): int
requires 0 <= s <= t <= |a|
{
if s == t then 0 else Sum(a, s, t-1) + a[t-1]
}
method MaxSegSum(a: seq<int>) returns (k: int, m: int)
ensures 0 <= k <= m <= |a|
ens... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny2_TreeBarrier.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,175 | 78e686c35572ed2704039a18aa7e20b178c5753cdc1664a36ef3b576afa25c8d | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class Node {
var left: Node?
var right: Node?
var parent: Node?
var anc: set<Node>
var desc: set<Node>
var sense: bool
var pc: int
predicate validDown()
reads this, desc
{
this !in desc ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny2_TuringFactorial.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 601 | 9a04f162833735e8a91c41211d0e34a4dde1989256bf75b0a565ad1268b6c66f | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function Factorial(n: nat): nat
{
if n == 0 then 1 else n * Factorial(n-1)
}
method ComputeFactorial(n: int) returns (u: int)
requires 1 <= n;
ensures u == Factorial(n);
{
var r := 1;
u := 1;
while (r < ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny3_InductionVsCoinduction.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,229 | 5f302d9e563da8b46df415aafda8514b9014f41436343d8b0a57ef8f229bb340 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// A definition of a co-inductive datatype Stream, whose values are possibly
// infinite lists.
codatatype Stream<T> = SNil | SCons(head: T, tail: Stream<T>)
/*
A function that returns a stream consisting of all integer... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Bug144.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 493 | 9bb45c7e93f187f50f251a01578c64a50273a9c7417fa739624aa4306150d0e9 | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
predicate p(i:int)
method m1()
method m2()
{
assume exists i :: p(i);
assert exists i :: p(i);
m1();
assert exists i :: p(i); // FAILS
}
class Test
{
var arr : array<int>;
predicate p(i: int)
method foo()
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Bug165.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 436 | fad70e4896f4666712027194c43e6427636be4a44aae2b21b6d9891743d2aafd | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
type T
function f(a: T) : bool
method Select(s1: seq<T>) returns (r: seq<T>)
ensures (forall e: T :: f(e) ==> multiset(s1)[e] == multiset(r)[e])
ensures (forall e: T :: (!f(e)) ==> 0 == multiset(r)[e])
method Main(s1: seq<T>)
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Bug58.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 387 | 526377e63db15a382cd988b8fbee3cf10215bd3c3d74966cae792ece6c550da2 | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function M1(f:map<int, bool>, i:int):bool
function M2(f:map<int, bool>, i:int):bool
{
M1(map j | j in f :: f[j], i)
}
lemma L(f:map<int, bool>, i:int)
requires i in f;
requires M2(f, i);
requires forall j:int, f:map<in... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Bug92.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,978 | 853d5a406188367e08513321bedf7cfc4e659f19bf2c120fd45d9d93c1b2606e | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
module ModOpaque {
function {:opaque} Hidden(x:int) : (int, int)
{
(5, 7)
}
function Visible(x:int) : (int, int)
{
Hidden(x)
}
lemma foo(x:int, y:int, z:int)
requires (y, z) == Visib... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Fstar-QuickSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,315 | 75b61189272f2c56592d7642d8768ab435a6d85bbf0d8d5aa189ed4bb21f4980 | // RUN: %dafny /compile:0 /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// A Dafny rendition of an F* version of QuickSort (included at the bottom of this file).
// Unlike the F* version, Dafny also proves termination and does not use any axioms. However,
// Dafny needs help with a couple of lem... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_git-issue133.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,039 | c6a81e58fe5cb71236086ae86b62c7544b06ef7ddc4abf5505aebf03ee3b26f2 | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
datatype State = State(m:map<int, bool>)
lemma Test(s:State)
requires 42 in s.m
ensures s.(m := s.m[42 := s.m[42]]) == s
{
var s' := s.(m := s.m[42 := s.m[42]]);
assert s'.m == s.m;
}
datatype MyDt = MakeA(x: int, bool) | MakeB... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_git-issue40.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 498 | ebc3fb51c0e257dfd252615aa73958851452b7506ec6e3a60ce13d653521340c | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function SeqRepeat<T>(count:nat, elt:T) : seq<T>
ensures |SeqRepeat<T>(count, elt)| == count
ensures forall i :: 0 <= i < count ==> SeqRepeat<T>(count, elt)[i] == elt
datatype Maybe<T> = Nothing | Just(v: T)
type Num = x | 0 <= x < 1... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_git-issue41.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,547 | 9d68426fd887d0a625f594f0d2123759572f8d19f079a2288b7b29633ed11326 | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
type uint32 = i:int | 0 <= i < 0x1_0000_0000
function last<T>(s:seq<T>):T
requires |s| > 0;
{
s[|s|-1]
}
function all_but_last<T>(s:seq<T>):seq<T>
requires |s| > 0;
ensures |all_but_last(s)| == |s| - 1;
{
s[..|s|... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_git-issue67.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 516 | 009917bcecbcc38c6a394333e6dc97fe646aadceaa25cdbed5711797ab40e248 | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class Node { }
predicate Q(x: Node)
predicate P(x: Node)
method AuxMethod(y: Node)
modifies y
method MainMethod(y: Node)
modifies y
{
AuxMethod(y); // remove this call and the assertion below goes through (as it should)
f... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_git-issue74.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 292 | a625f1d1a84259ee7ba7c363cdcadddc925dcb1c41f04cf82af4f2147433be74 | // RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function{:opaque} f(x:int):int { x }
lemma L()
ensures forall x:int :: f(x) == x
{
forall x:int
ensures f(x) == x
{
reveal f();
}
assert forall x:int :: f(x) == x;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_git-issue76.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 682 | 7768d72923701ee9fc2f28611611d8a2b1245d83554a9b5259d7b601be0dc999 | // RUN: %dafny /compile:3 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
method Main() {
M0();
M1();
EqualityOfStrings0();
EqualityOfStrings1();
}
// The verification of the following methods requires knowledge
// about the injectivity of sequence displays.
method M0()
{
assert {"x","y","z"}-{"... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Lucas-down.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,002 | 7d6983e1f1bdcffd272ab377199fdf1b8dd01f727f2c7edd1bd8f98f4711c745 | // RUN: %dafny /compile:0 /arith:1 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// Proof of the Lucas theorem
// Rustan Leino
// 9 March 2018
//
// Instead of the lemmas doing "up", like:
// P(k) == P(2*k)
// P(k) == P(2*k + 1)
// (see Lucas-up.dfy), the lemmas in this version go "down", like:
// P(k%2)... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_MonadicLaws.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,162 | 4f6c6b952853a0c512a74ab554da9a76d5ecd9f43d8d496a98f9597710d5eb16 | // RUN: %dafny /compile:0 /rprint:"%t.rprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// Monadic Laws
// Niki Vazou and Rustan Leino
// 28 March 2016
datatype List<T> = Nil | Cons(head: T, tail: List)
function append(xs: List, ys: List): List
{
match xs
case Nil => ys
case Cons(x, xs') => Cons(... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_dafny4_Regression19.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,392 | 92bf66f9d9d86d7bc6d62c6b609ed10c2b7836dfbe9b145e401b0f3b577362fb | // RUN: %dafny "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
predicate ContainsNothingBut5(s: set<int>)
{
forall q :: q in s ==> q == 5
}
predicate YeahContains5(s: set<int>)
{
exists q :: q in s && q == 5
}
predicate ViaSetComprehension(s: set<int>) {
|set q | q in s && q == 5| != 0
}
predicate... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_git-issues_git-issue-336.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 813 | f161668861e711b18dc97d2c0eb927e8cbcbd623e763abdb67e3e28552ad947f | // RUN: %dafny "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
lemma TestMap(a: map<int, (int,int)>) {
// The following assertion used to not prove automatically
assert (map k | k in a :: k := a[k].0)
// the following map comprehension implicitly uses k as the key
== (map k | k in a :: a[k].0);
}... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_hofs_Compilation.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,123 | 5f3bd3247797c7ab571c757f5082538429b548ad1daa04fa63e1220740815693 | // RUN: %dafny /compile:3 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class Ref<A> {
var val : A
constructor (a : A)
ensures val == a
{
val := a;
}
}
method Main() {
// simple
print "1 = ", (x => x)(1), "\n";
print "3 = ", (x => y => x + y)(1)(2), "\n";
print "3 = ", ((x,y) => y... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_hofs_Requires.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,597 | 126ccc7f490f10c0c112034d42857833cf7d764699ba80bbdf5a944c0fb8f5ee | // RUN: %dafny /compile:3 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
method Main()
{
test0(10);
test5(11);
test6(12);
test1();
test2();
}
predicate valid(x:int)
{
x > 0
}
function ref1(y:int) : int
requires valid(y);
{
y - 1
}
lemma assumption... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_hofs_SumSum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,887 | 3ee1e9a99709cc1e02488df236e168719919e11927a645b1a4b8f08fb38c827a | // RUN: %dafny /compile:0 /rprint:"%t.rprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// Tests that come down to comparing the bodies of (possibly nested) functions.
// Many of these currently require far more effort than one would like.
// KRML, 2 May 2016
function Sum(n: nat, f: int -> int): int
{
if ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_hofs_WhileLoop.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,303 | 9895bd7667499926eded94aaf5f24a8eac2c7b31ff63f9d28785ad46cfd24e55 | // RUN: %dafny /compile:3 /print:"%t.print" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class Ref<A(0)> {
var val: A
}
method Nice(n: int) returns (k: int) {
var f : int -> int := x => x;
var i := new Ref<int>;
i.val := 0;
while i.val < n
invariant forall u :: f.requires(u)
invariant for... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_LanguageServerTest_DafnyFiles_symbolTable_15_array.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 499 | 1e3a66812105fdf334b6e524f139b9ce5ec5d3203eb265a08ed167da73ef12c1 | method Main() {
var i := 2;
var s := [1, i, 3, 4, 5];
print |s|; //size
assert s[|s|-1] == 5; //access the last element
assert s[|s|-1..|s|] == [5]; //slice just the last element, as a singleton
assert s[1..] == [2, 3, 4, 5]; // everything but the first
assert s[..|s|-1] == [1, 2, 3, 4]; // ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_triggers_auto-triggers-fix-an-issue-listed-in-the-ironclad-notebook.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 965 | 5f4b3a74d68fd4faec0b5c40f11f4cdf4c83bcf2318b0b8df2e8c3784acbe5f9 | // RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" /printTooltips "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// This example was listed in IronClad's notebook as one place were z3 picked
// much too liberal triggers. THe Boogie code for this is shown below:
//
// forall k#2: Seq Box :: $Is(k#2, TSeq... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_triggers_function-applications-are-triggers.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 569 | a509d5a11e808d42e17cfb516967e6c86024ec2b4206f283c0398ff6bd680fae | // RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" /printTooltips "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// This file checks that function applications yield trigger candidates
method M(P: (int -> int) -> bool, g: int -> int)
requires P.requires(g)
requires P(g) {
assume forall f: int -... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_triggers_large-quantifiers-dont-break-dafny.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,060 | 1a6fa57de0d4cfc1fb7489eb349df0e419a6a36796d94025bf8e499fe9124366 | // RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" /printTooltips "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// This test ensures that the trigger collector (the routine that picks trigger
// candidates) does not actually consider all subsets of terms; if it did, the
// following would take horrib... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-language-server_tmp_tmpkir0kenl_Test_triggers_loop-detection-looks-at-ranges-too.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 510 | 42d2ffe256ef77623274d03e3b813b75472d5ac76d521689c8b44352247082de | // RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" /printTooltips "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// This file checks that loops between the range and the term of a quantifier
// are properly detected.
predicate P(x: int)
method M(x: int) {
// This will be flagged as a loop even wi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.