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/DafnyProjects_tmp_tmp2acw_s4s_longestPrefix.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 813 | d8f132e92502bbe7619bc6011d2ca39ae329f4b506ea2986be40fdfa89c5813a | // MFES, Exam 8/Sept/20201, Exercise 5
// Computes the length (i) of the longest common prefix (initial subarray)
// of two arrays a and b.
method longestPrefix(a: array<int>, b: array <int>) returns (i: nat)
ensures i <= a.Length && i <= b.Length
ensures a[..i] == b[..i]
ensures i < a.Length && i < b.Le... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_partitionOddEven.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,119 | d789e533361cd43ea9531bb4de7e17c175af2a4bd0d83fde7c282cf42bd6fee6 | // Rearranges the elements in an array 'a' of natural numbers,
// so that all odd numbers appear before all even numbers.
method partitionOddEven(a: array<nat>)
modifies a
ensures multiset(a[..]) == multiset(old(a[..]))
ensures ! exists i, j :: 0 <= i < j < a.Length && even(a[i]) && odd(a[j])
{
var ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_Power.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,568 | 664dfc3d96b5c4f60afc6467140ee2a592c2081a2be4645a319e11890d176718 | /*
* Formal verification of an O(log n) algorithm to calculate the natural power of a real number (x^n),
* illustrating the usage of lemmas and automatic induction in Dafny.
* J. Pascoal Faria, FEUP, Jan/2022.
*/
// Recursive definition of x^n in functional style, with time and space complexity O(n).
functio... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_RawSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,313 | 0fd4e10762dd58cf022f5dcaf598b8ebeafcc33b705b3ed8fc6b53542e77efd0 | /**
* Proves the correctness of a "raw" array sorting algorithm that swaps elements out of order, chosen randomly.
* FEUP, MFES, 2020/21.
*/
// Type of each array element; can be any type supporting comparision operators.
type T = int
// Checks if array 'a' is sorted by non-descending order.
ghost predic... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_sqrt.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 507 | 096541262bcb76ada2722fbc6d6c480f5ead21fc2e079b6106871c039baa04d1 |
method sqrt(x: real) returns (r: real)
requires x >= 0.0
ensures r * r == x && r >= 0.0
method testSqrt() {
var r := sqrt(4.0);
//if (2.0 < r) { monotonicSquare(2.0, r); }
if (r < 2.0) { monotonicSquare(r, 2.0); }
assert r == 2.0;
}
lemma monotonicMult(c: real, x: real, y: real)
requires x... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_leetcode_0001-two-sum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,199 | 54b9a4840abaff1be8f5d2a7bf5022f6129a81c281f202ef93f3f7c3109ec1af | // If this invariant is added explicitly to the loop then the verfication never finishes.
// It could be {:opaque} for a more controlled verification:
// assert InMap([], m, target) by {
// reveal InMap();
// }
predicate InMap(nums: seq<int>, m: map<int, int>, t: int) {
forall j :: 0 <= j < |nums| ==> t - num... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_leetcode_0027-remove-element.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 725 | 9c77564341540b23105b87102a5bd2b63220d5c87f10a9a50df183caa5678dc5 | method RemoveElement(nums: array<int>, val: int) returns (newLength: int)
modifies nums
ensures 0 <= newLength <= nums.Length
ensures forall x :: x in nums[..newLength] ==> x != val
ensures multiset(nums[..newLength]) == multiset(old(nums[..]))[val := 0]
{
var i := 0;
var j := 0;
whi... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_leetcode_0069-sqrt.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 745 | 0cdf072e4011f0c34878a8796fee399dfde1215855cf37bc292cff798f0935c3 | // Author: Shaobo He
predicate sqrt(x: int, r: int) {
r*r <= x && (r+1)*(r+1) > x
}
lemma uniqueSqrt(x: int, r1: int, r2: int)
requires x >= 0 && r1 >= 0 && r2 >= 0;
ensures sqrt(x, r1) && sqrt(x, r2) ==> r1 == r2
{}
method mySqrt(x: int) returns (res: int)
requires 0 <= x;
ensures sqrt(x, res);
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_leetcode_0070-climbing-stairs.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 406 | 55dbc7c19c46f131376176f1d971d4afa6d40c3358172696daa1f2e4e7d4851d | function Stairs(n: nat): nat {
if n <= 1 then 1 else Stairs(n - 2) + Stairs(n - 1)
}
// A simple specification
method ClimbStairs(n: nat) returns (r: nat)
ensures r == Stairs(n)
{
var a, b := 1, 1;
var i := 1;
while i < n
invariant i <= n || i == 1
invariant a == Stairs(i - 1)
invari... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_leetcode_0277-find-the-celebrity.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,603 | f276c0c387fde89337c30687cb8cca814cbd6d9c00d959685c61f5156a025229 | // Author: Shaobo He
predicate knows(a: int, b: int)
predicate isCelebrity(n : int, i : int)
requires n >= 0 && 0 <= i < n;
{
forall j :: 0 <= j < n && i != j ==> knows(j, i) && !knows(i, j)
}
lemma knowerCannotBeCelebrity(n: int, i: int)
requires n >= 0 && 0 <= i < n
ensures (exists j :: 0 <= j < n ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_lib_math_DivMod.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,052 | 95a6a593b678f39007ca613305aec7cbe7bc0b5068e0debc54e3e193f3ec82cb | module DivMod {
function {:opaque} DivSub(a: int, b: int): int
requires 0 <= a && 0 < b
{
if a < b then 0 else 1 + DivSub(a - b, b)
}
function {:opaque} ModSub(a: int, b: int): int
requires 0 <= a && 0 < b
{
if a < b then a else ModSub(a - b, b)
}
lemma DivModAdd1(a: int, ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_examples_tmp_tmp8qotd4ez_test_shuffle.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,601 | 44e42c36545bf8f0f7d3c75184a11e63f0aa2c6cf63a3e4f913cf32097d2b072 |
method random(a: int, b: int) returns (r: int)
// requires a <= b
ensures a <= b ==> a <= r <= b
lemma eqMultiset_t<T>(t: T, s1: seq<T>, s2: seq<T>)
requires multiset(s1) == multiset(s2)
ensures t in s1 <==> t in s2
{
calc <==> {
t in s1;
t in multiset(s1);
// Not necessary:
// t ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_experiments_tmp_tmpz29_3_3i_circuit.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 15,023 | ce68cd3c1ceb8acf6c25bd6fdc8f7f04573b9de08d013cf9a2f2926460ac31c8 | module Base
{
// We want to represent circuits.
// A Circuit is composed of nodes.
// Each node can have input ports and output ports.
// The ports are represented just by the index of the node, and the index
// of the port on the node.
datatype INodePort = inodeport(node_id: nat, port_... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week1_7_A2_Q1_trimmed copy - 副本.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,935 | 2c3ebe60c3a31782c8d60cc110d3b46ca96d23ace139bfcf0b8fa2bfa44d09e6 | ghost function Count(hi: nat, s:seq<int>): int
requires 0 <= hi <= |s|
decreases hi
{
if hi == 0 then 0
else if s[hi-1]%2 == 0 then 1 + Count(hi-1, s) else Count(hi-1, s)
}
method FooCount(CountIndex:nat, a:seq<int>,b:array<int>) returns (p:nat)
requires CountIndex == 0 || (|a| == b.Lengt... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week1_7_MaxSum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 402 | 20df4ac51be147d82de54aa431751b123d50d279f7a9d265d0ac9f748d4d90fb | method MaxSum(x:int, y:int) returns (s:int, m:int)
ensures s == x+y
ensures (m == x || m == y) && x <= m && y <= m
{
s := x+y;
if x > y{
m := x;
} else if y > x{
m := y;
} else {
m := x;
}
assert m >= y;
}
method Main()
{
var m, n := 4,5;
var a,... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week1_7_week4_tute_ex4.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,089 | 3b6a85899803db263f3081fc47a5fd3622bf661f3882f5bf7858698389f873c5 | method LinearSearch<T>(a: array<T>, P: T -> bool) returns (n: int)
ensures -1 <= n < a.Length
ensures n == -1 || P(a[n])
ensures n != -1 ==> forall i :: 0 <= i < n ==> ! P(a[i])
ensures n == -1 ==> forall i :: 0 <= i < a.Length ==> ! P(a[i])
{
n := 0;
while n != a.Length
decrea... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week1_7_Week4__LinearSearch.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,064 | a292d3aa721113a73e04bd4c60894eafb46c31da5abf43c5536f4434086dbc0f | method LinearSeach0<T>(a: array<T>, P: T -> bool) returns (n: int)
ensures 0 <= n <= a.Length
ensures n == a.Length || P(a[n])
{
n := 0;
while n != a.Length
invariant 0 <= n <= a.Length
{
if P(a[n]) {return;}
n := n + 1;
}
}
predicate P(n: in... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week1_7_week5_ComputePower.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 420 | 7ff5652828a2bd16d62da8afcd2b847ceb4f0e549e41787d4a03f675d176af59 | function Power(n:nat):nat
{
if n == 0 then 1 else 2 * Power(n-1)
}
method CalcPower(n:nat) returns (p:nat)
ensures p == 2*n;
{
p := 2*n;
}
method ComputePower(n:nat) returns (p:nat)
ensures p == Power(n)
{
p:=1;
var i:=0;
while i!=n
invariant 0 <= i <= n
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_a3 copy 2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,062 | df453fad8673cfd9c024c55e0830966924e20a0262dd97afa03fba6d3100d988 | class TwoStacks<T(0)(==)>
{
//abstract state
ghost var s1 :seq<T>
ghost var s2 :seq<T>
ghost const N :nat // maximum size of the stacks
ghost var Repr : set<object>
//concrete state
var data: array<T>
var n1: nat // number of elements in the stack 1
var n2: nat // number o... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_a3_search_findPositionOfIndex.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,845 | 7e0caa44dfbe0319a5ac1a51439b9322f458282cda25e09e58e6e1f68d781f60 | method FindPositionOfElement(a:array<int>,Element:nat,n1:nat,s1:seq<int>) returns (Position:int,Count:nat)
requires n1 == |s1| && 0 <= n1 <= a.Length
requires forall i:: 0<= i < |s1| ==> a[i] == s1[i]
ensures Position == -1 || Position >= 1
ensures |s1| != 0 && Position >= 1 ==> exis... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_week10_BoundedQueue_01.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,076 | 6d4e823fd8cb6ba661cda7cddf781d8fe92d082538e99493d0f4ab7283fc1d34 | class BoundedQueue<T(0)>
{
// abstract state
ghost var contents: seq<T> // the contents of the bounded queue
ghost var N: nat // the (maximum) size of the bounded queue
ghost var Repr: set<object>
// concrete state
var data: array<T>
var wr: nat
var rd: nat
ghost predicate Valid()
reads this, ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_week10_ExtensibleArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,962 | b3fcf112a6638584a71dc57da02265030bde529969452263f5c6b8f97b51455c | class ExtensibleArray<T(0)> {
// abstract state
ghost var Elements: seq<T>
ghost var Repr: set<object>
//concrete state
var front: array?<T>
var depot: ExtensibleArray?<array<T>>
var length: int // number of elements
var M: int // number of elements in depot
ghost predicate Valid()
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_week8_CheckSumCalculator.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,451 | 94acbcbb786b752b0aa72e34bdb8c021b4476111592aeb859a01f8bd3698a14b | ghost function Hash(s:string):int {
SumChars(s) % 137
}
ghost function SumChars(s: string):int {
if |s| == 0 then 0 else
s[|s| - 1] as int + SumChars(s[..|s| -1])
}
class CheckSumCalculator{
var data: string
var cs:int
ghost predicate Valid()
reads this
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_week8_CoffeeMaker2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,580 | 0cab341aaee2762ec40508817fe2e76dfdfc40e24928a0a60991016280fcc7cd | class Grinder {
ghost var hasBeans: bool
ghost var Repr: set<object>
ghost predicate Valid()
reads this, Repr
ensures Valid() ==> this in Repr
constructor()
ensures Valid() && fresh(Repr) && !hasBeans
function Ready(): bool
requires Valid()
reads Repr
ensures Ready(... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Learning_Experience_tmp_tmpuxvcet_u_week8_12_week9_lemma.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,537 | ff4c49844c1a386c9bd02cfe9a06ebbb52fdc9ef19fb34f093a0a5d58d14a3fb | method AssignmentsToMark(students:int, tutors: int) returns (r:int)
requires students > 0 && tutors > 1
ensures r < students
{
assert students > 0 && tutors > 1;
assert students > 0 && tutors > 1 && true;
assert students > 0 && tutors > 1 && students/tutors < students ==> students/tutors < stu... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_misc_tmp_tmpg4vzlnm1_rosetta_code_factorial.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 434 | b79fb24cfb4be846ab8c6ea38f5a197848d809c6b540966f4350cf555e3ffd1b | // recursive definition of factorial
function Factorial(n: nat): nat {
if n == 0 then 1 else n * Factorial(n - 1)
}
// iterative implementation of factorial
method IterativeFactorial(n: nat) returns (result: nat)
ensures result == Factorial(n)
{
result := 1;
var i := 1;
while i <= n
invariant... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_misc_tmp_tmpg4vzlnm1_rosetta_code_fibonacci_sequence.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 563 | 196257e1616e0fbed6290c88ae6db4e8e175958b7a5ab7d4c943e8a1d2481e2f | // definition of Fibonacci numbers
function Fibonacci(n: nat): nat {
match n {
case 0 => 0
case 1 => 1
case _ => Fibonacci(n - 1) + Fibonacci(n - 2)
}
}
// iterative calculation of Fibonacci numbers
method FibonacciIterative(n: nat) returns (f: nat)
ensures f == Fibonacci(n)
{
if n < 2... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_ProgrammingLanguages_tmp_tmp82_e0kji_ExtraCredit.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,583 | d31f43786df0f68f6affa7f4d8b3cee38f3905512a86ac227ef8d64da0ceff70 | datatype Exp = Const(int) | Var(string) | Plus(Exp, Exp) | Mult(Exp, Exp)
function eval(e:Exp, store:map<string, int>):int
{
match(e)
case Const(n) => n
case Var(s) => if(s in store) then store[s] else -1
case Plus(e1, e2) => eval(e1, store) + eval(e2, store)
case Mult(e1, e2) => eval(e1, store) * ev... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Programs_tmp_tmp99966ew4_binary_search.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 882 | 16944f2949346d35614b92c58250af6e241a2c783f4ce229d85fde51d2d2c4f0 | predicate sorted(a: array<int>)
requires a != null
reads a
{
forall j, k :: 0 <= j < k < a.Length ==> a[j] <= a[k]
}
method BinarySearch(a: array<int>, value: int) returns (index: int)
requires a != null && 0 <= a.Length && sorted(a)
ensures 0 <= index ==> index < a.Length && a[index] == value
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Programs_tmp_tmp99966ew4_lemma.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,179 | 1951a6ea100c9a7c1316a6bddf785209cd815ec1f19879ee2b4328288b635a68 | lemma SkippingLemma(a : array<int>, j : int)
requires a != null
requires forall i :: 0 <= i < a.Length ==> 0 <= a[i]
requires forall i :: 0 < i < a.Length ==> a[i-1]-1 <= a[i]
requires 0 <= j < a.Length
ensures forall k :: j <= k < j + a[j] && k < a.Length ==> a[k] != 0
{
var i := j;
while ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Programs_tmp_tmp99966ew4_mymax.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 253 | f9654a99adf4430f9c6effee673bde9b8344a971f6f303057dfb216683a6e8cf | method Max(a: int, b:int) returns (c: int)
ensures c >= a && c>= b
{
if (a < b)
{ c := b; }
else
{ c := a; }
assert a <= c && b <= c;
}
method Testing()
{
var v := Max(2, 3);
assert v >= 3;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Programs_tmp_tmp99966ew4_trig.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 158 | ab59217b863465c33ddda71d4e244767a1762301ee3885719a05a7d372f09d5d | predicate P(x: int)
predicate Q(x: int)
method test()
requires forall x {:trigger P(x)} :: P(x) && Q(x)
ensures Q(0)
{
assert P(0);
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_projects_tmp_tmpjutqwjv4_tutorial_tutorial.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,048 | 89b860a54d7ed139ad145fdfa8efb1eb67efa2cabc88fd598d3454d8b48b65b1 | // Working through https://dafny.org/dafny/OnlineTutorial/guide
function fib(n: nat): nat
{
if n == 0 then 0
else if n == 1 then 1
else fib(n - 1) + fib(n - 2)
}
method ComputeFib(n: nat) returns (ret: nat)
ensures ret == fib(n)
{
var a := 0;
var b := 1;
var i := 0;
while i < n
invar... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_Heimaverkefni 1_LinearSearch.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,240 | 5234baf556dd5c2cedecbcc2068aa446dca5a91947c9139fd160365d85ac0eec | // Author of question: Snorri Agnarsson
// Permalink of question: https://rise4fun.com/Dafny/0HRr
// Author of solution: Alexander Guðmundsson
// Permalink of solution: https://rise4fun.com/Dafny/8pxWd
// Use the command
// dafny LinearSearch-skeleton.dfy
// or
// compile LinearSearch-skeleton.dfy
//... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_Heimaverkefni 2_BinarySearchDec.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,301 | 8515a81018c9d23c176859e1bdb06af2954c143a86b5911c20d601eb05fceeab | // Author of question: Snorri Agnarsson
// Permalink of question: https://rise4fun.com/Dafny/CGB1z
// Authors of solution: Alexander Guðmundsson
// Permalink of solution: https://rise4fun.com/Dafny/VnB5
// Use the command
// dafny H2-skeleton.dfy
// or
// compile H2-skeleton.dfy
// to compile the file... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_Heimaverkefni 3_InsertionSortMultiset.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,301 | 7e954122ac818c65f8ac907bc99a98629b691e909ba1299737130595c2d136ea | // Höfundur spurningar: Snorri Agnarsson, snorri@hi.is
// Permalink spurningar: https://rise4fun.com/Dafny/G4sc3
// Höfundur lausnar: Alexander Guðmundsson
// Permalink lausnar: https://rise4fun.com/Dafny/nujsu
// Insertion sort með hjálp helmingunarleitar.
method Search( s: seq<int>, x: int ) return... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_Heimaverkefni 3_SelectionSortMultiset.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,673 | 8731245284212c4f8afbfd3873589f59eeced437072f0d3c82b6cb26e1663afd | // Höfundur spurningar: Snorri Agnarsson, snorri@hi.is
// Permalink spurningar: https://rise4fun.com/Dafny/dtcnY
// Höfundur lausnar: Alexander Guðmundsson
// Permalink lausnar: https://rise4fun.com/Dafny/ybUCz
///////////////////////////////////////////////////////////////
// Hér byrjar óbreytanlegi h... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_Heimaverkefni 8_H8.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,218 | 53b554163fed14e4efedd94aaf089a048dc19cd43dba918f203ea5698068cd68 | // Höfundur spurningar: Snorri Agnarsson, snorri@hi.is
// Permalink spurningar: https://rise4fun.com/Dafny/GW7a
// Höfundur lausnar: Alexander Guðmundsson
// Permalink lausnar: https://www.rise4fun.com/Dafny/JPGct
// Klárið að forrita föllin tvö.
method Partition( m: multiset<int> )
returns(... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_tests_F1a.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 448 | 43d66391537dfd3a7a330f63eb171f4cc5e665f870bb0a28db387c10d09420b3 | method F() returns ( r: int)
ensures r <= 0
{
r := 0;
}
method Main()
{
var x := F();
assert x <= 0;
x := x-1;
assert x <= -1;
print x;
}
method Mid( p: int, q: int) returns ( m: int )
// | ... | ??? | ... |
// p m q
requires p <= q;
ensures p... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_tests_InsertionSortSeq.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 839 | e8df0d24f2eaeaadc45412d82202d0e40a618ea851b35934587cee669eb992c6 | // Insertion sort.
//
// Author: Snorri Agnarsson, snorri@hi.is
predicate IsSorted( s: seq<int> )
{
forall p,q | 0<=p<q<|s| :: s[p]<=s[q]
}
method InsertionSort( s: seq<int> ) returns ( r: seq<int> )
ensures multiset(r) == multiset(s);
ensures IsSorted(r);
{
r := [];
var rest := s;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_tests_Search1000.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,926 | c41056005be92f5af7627a8447d109ffbcfdee6c9f5dd0f9854bb38aab2da9fb | // Author: Snorri Agnarsson, snorri@hi.is
// Search1000 is a Dafny version of a function shown
// by Jon Bentley in his old Programming Pearls
// column in CACM. Surprisingly Dafny needs no help
// to verify the function.
method Search1000( a: array<int>, x: int ) returns ( k: int )
requires a.Length >= 10... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmp0wu8wmfr_tests_SumIntsLoop.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 566 | 7b549ffddf6a0cb8a679352016111ce7a1519711c6574ae868fb0da6faed1a47 | function sumInts( n: int ): int
requires n >= 0;
{
if n == 0 then
0
else
sumInts(n-1)+n
}
method SumIntsLoop( n: int ) returns ( s: int )
requires n >= 0;
ensures s == sumInts(n)
ensures s == n*(n+1)/2;
{
s := 0;
var k := 0;
while k != n
de... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp2ewu6s7x_ListReverse.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,314 | 4d85b1cb886e25c364270a67a1aebd3c35e8b0aa7a61c419ff45936710f16df7 | function reverse(xs: seq<nat>): seq<nat>
{
if xs == [] then [] else reverse(xs[1..]) + [xs[0]]
}
lemma ReverseAppendDistr(xs: seq<nat>, ys: seq<nat>)
ensures reverse(xs + ys) == reverse(ys) + reverse(xs)
{
if {
case xs == [] =>
calc {
reverse([] + ys);
calc {... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp49a6ihvk_m4.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 899 | 2668d9fa1cb86f3a362f1a6036f1421ed87df70bfabe734e16639a8a4fb86c21 | datatype Color = Red | White | Blue
predicate Below(c: Color, d: Color)
{
c == Red || c == d || d == Blue
}
method DutchFlag(a: array<Color>)
modifies a
ensures forall i, j :: 0 <= i < j < a.Length ==> Below(a[i], a[j])
ensures multiset(a[..]) == multiset(old(a[..]))
{
var r,w,b :=... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp59p638nn_examples_derangement.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,833 | 6ca68bddb8f5e7ec700751bb231dbcbe2f857d7dd24523059698d83bfec04461 |
predicate derangement(s: seq<nat>) {
forall i :: 0 <= i < |s| ==> s[i] != i
}
predicate permutation(s: seq<nat>) {
forall i :: 0 <= i < |s| ==> i in s
}
function multisetRange(n: nat): multiset<nat> {
multiset(seq(n, i => i))
}
predicate distinct<A(==)>(s: seq<A>) {
forall x,y :: x != ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp59p638nn_examples_GenericSelectionSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,690 | 487e1d3242702f1044501063deb28a1a277cdac433240c926b6c6e7812c26369 |
trait Comparable<T(==)> {
function Lt(x: T, y: T): bool
}
trait Sorted<T(==)> extends Comparable<T> {
ghost predicate Ordered(a: array<T>, left: nat, right: nat)
reads a
requires left <= right <= a.Length
{
forall i: nat :: 0 < left <= i < right ==> Lt(a[i-1],a[i]) || a[i... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp59p638nn_examples_minmax2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,120 | 3edc3134a947e3f58c05a127581e1a38b20dbd64d27924188cea48fd2bb28705 | method DifferenceMinMax(a: array<int>) returns (diff: int)
requires a.Length > 0
ensures diff == (Max(a[..]) - Min(a[..]))
{
var minVal := a[0];
var maxVal := a[0];
for i := 1 to a.Length
invariant 1 <= i <= a.Length
invariant minVal <= maxVal
invariant forall k :: 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp59p638nn_examples_realExponent.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,783 | 859dc2a70216e12812591a7c7900a8c6b3deea51a3799e6548f42f4753a1bffb |
ghost function power(n: real, alpha: real): real
requires n > 0.0 && alpha > 0.0
ensures power(n, alpha) > 0.0
ghost function log(n: real, alpha: real): real
requires n > 0.0 && alpha > 0.0
ensures log(n, alpha) > 0.0
lemma consistency(n: real, alpha: real)
requires n > 0.0 && alpha > 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny_tmp_tmp59p638nn_examples_SelectionSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,845 | e4b6472bab1b7be96095598c406e8cbe1d2f8c62f79a13ce556f224b30d82d31 |
twostate predicate Preserved(a: array<int>, left: nat, right: nat)
reads a
requires left <= right <= a.Length
{
multiset(a[left..right]) == multiset(old(a[left..right]))
}
ghost predicate Ordered(a: array<int>, left: nat, right: nat)
reads a
requires left <= right <= a.Length
{
for... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpj88zq5zt_2-Kontrakte_max.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 526 | 30e276fa7af69ee164f00979359907a94abd3a5e4a7a7d27c9c2211956e1bc48 | method max(a: array<int>, b: array<int>, i: int, j: int)
returns (m: int)
requires 0 <= i < a.Length
requires 0 <= j < b.Length
ensures a[i] > b[j] ==> m == a[i]
ensures a[i] <= b[j] ==> m == b[j]
{
if a[i] > b[j] {
m := a[i];
} else {
m := b[j];
}
}
method testMax(a:array<int>... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpj88zq5zt_2-Kontrakte_reverse3.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 888 | eefb485aae58d7f22aa309fd2bab832d69c4cf53e7504a96ac66d4995c625ec3 | method swap3(a: array<int>, h: int, i: int, j: int)
modifies a
requires 0 <= h < a.Length
requires 0 <= i < a.Length
requires 0 <= j < a.Length
requires i != j && j != h && h != i;
ensures a[h] == old(a[i]);
ensures a[j] == old(a[h]);
ensures a[i] == old(a[j]);
ensures forall k: int :: 0 <= k... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpmvs2dmry_examples1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 768 | df1170075366b8bc33b9d1e692cab34191b44e32f8778bba4205d62e4873d0ad | method Abs(x:int) returns (y:int)
ensures y>=0;
ensures x>=0 ==> x == y;
ensures x<0 ==> -x == y;
ensures y == abs(x); // use this instead of line 3,4
{
if(x<0)
{
return -x;
}
else{
return x;
}
}
function abs(x: int): int{
if x>0 then x else -x
}
method Testin... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpmvs2dmry_examples2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,940 | c85453a422ea5ec39732d5c59a37ad30e245ee47523c6efe3d14f0f5791786a8 | method add_by_inc(x: nat, y:nat) returns (z:nat)
ensures z == x+y;
{
z := x;
var i := 0;
while (i < y)
decreases y-i;
invariant 0 <= i <= y;
invariant z == x + i;
{
z := z+1;
i := i+1;
}
assert (z == x+y);
assert (i == y);
}
method Product(m: n... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpmvs2dmry_pancakesort_findmax.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 633 | 2febf96dd7c30deb1dd9a1254b0fe56d0164a1d8539b2d241543225643ba4d5f | // returns an index of the largest element of array 'a' in the range [0..n)
method findMax (a : array<int>, n : int) returns (r:int)
requires a.Length > 0
requires 0 < n <= a.Length
ensures 0 <= r < n <= a.Length;
ensures forall k :: 0 <= k < n <= a.Length ==> a[r] >= a[k];
ensures multiset(a[..]) == multiset(old... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpmvs2dmry_pancakesort_flip.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 904 | 0f117c122d4dfa73479347a664aab6b509d1fb1c5528c65ae297e08243b46ed3 | // flips (i.e., reverses) array elements in the range [0..num]
method flip (a: array<int>, num: int)
requires a.Length > 0;
requires 0 <= num < a.Length;
modifies a;
ensures forall k :: 0 <= k <= num ==> a[k] == old(a[num-k])
ensures forall k :: num < k < a.Length ==> a[k] == old(a[k])
// ensures multiset(a[..])... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpmvs2dmry_SlowMax.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 464 | 135d5cb6e8638a50f5d40f4006d2d964e8dbbacd617d05f5fa646d19c5520323 | function max(x:nat, y:nat) : nat
{
if (x < y) then y else x
}
method slow_max(a: nat, b: nat) returns (z: nat)
ensures z == max(a, b)
{
z := 0;
var x := a;
var y := b;
while (z < x && z < y)
invariant x >=0;
invariant y >=0;
invariant z == a - x && z == b - y;
invariant a-x ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpv_d3qi10_2_min.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,307 | 86a0dee81183d2a69172919b8a4a87c71bc1c18582e05f7a62a144be23a74a4b |
function min(a: int, b: int): int
ensures min(a, b) <= a && min(a, b) <= b
ensures min(a, b) == a || min(a, b) == b
{
if a < b then a else b
}
method minMethod(a: int, b: int) returns (c: int)
ensures c <= a && c <= b
ensures c == a || c == b
// Ou encore:
ensures c == min(a, b... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_tmp_tmpv_d3qi10_3_cumsum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 763 | 349faa09850ed3a93b74de62c82d451ce6cb9c2cdb77cb0652f5e48480dc88ce | function sum(a: array<int>, i: int): int
requires 0 <= i < a.Length
reads a
{
a[i] + if i == 0 then 0 else sum(a, i - 1)
}
method cumsum(a: array<int>, b: array<int>)
requires a.Length == b.Length && a.Length > 0 && a != b
// when you change a , that's not the same object than b .
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_validation_examples.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 13,145 | 98d27e3f5b41b28ca15ad5c87aec9feebcddfd0f7a8db62089274fadb24269f3 | function Power(n: nat): nat {
if n == 0 then 1 else 2 * Power(n - 1)
}
method ComputePower(N: int) returns (y: nat) requires N >= 0
ensures y == Power(N)
{
y := 1;
var x := 0;
while x != N
invariant 0 <= x <= N
invariant y == Power(x)
decreases N - x
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_verify_examples_ComputePower.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 361 | 63357ea121552b73c51f0aadba8e76d3fa50a61f994856a8b4cfd7b9d9204cd6 | function Power(n: nat): nat {
if n == 0 then 1 else 2 * Power(n - 1)
}
method ComputePower(N: int) returns (y: nat) requires N >= 0
ensures y == Power(N)
{
y := 1;
var x := 0;
while x != N
invariant 0 <= x <= N
invariant y == Power(x)
decreases N - x
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_verify_examples_CopyMatrix.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,036 | e70f247fbaf67cb8db2333ddfe0f0c991bd20d4f02193b9392ab7228ac39e584 | method CopyMatrix(src: array2, dst: array2)
requires src.Length0 == dst.Length0 && src.Length1 == dst.Length1
modifies dst
ensures forall i, j :: 0 <= i < src.Length0 && 0 <= j < src.Length1 ==> dst[i,j] == old(src[i,j])
{
var m := 0;
while m != src.Length0
invariant 0 <= m <= src.Le... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_verify_examples_Cube.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 373 | b1e7b232a665691b61e120ea6ef6ac04afe9342f061ee26a175a522e1d8d4898 | method Cube(n: nat) returns (c: nat)
ensures c == n * n * n
{
c := 0;
var i := 0;
var k := 1;
var m := 6;
while i != n
invariant 0 <= i <= n
invariant c == i * i * i
invariant k == 3*i*i + 3*i + 1
invariant m == 6 * i + 6
{
c, k, m := c... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_verify_examples_DoubleArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 472 | 7a4b0caa12fb54d565ab3641d63d4ad5328e5a15ba9832fc454022e215239f24 | method DoubleArray(src: array<int>, dst: array<int>)
requires src.Length == dst.Length
modifies dst
ensures forall i :: 0 <= i < src.Length ==> dst[i] == 2 * old(src[i])
{
var n := 0;
while n != src.Length
invariant 0 <= n <= src.Length
invariant forall i :: 0 <= i < n ==> dst[i] == ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_verify_examples_IncrementMatrix.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,015 | ad3330998f7eebdd073fc9f06da5b59d4380b848306b2bd067a2ac34a76853b6 | method IncrementMatrix(a: array2<int>)
modifies a
ensures forall i, j :: 0 <= i < a.Length0 && 0 <= j < a.Length1 ==> a[i,j] == old(a[i,j]) + 1
{
var m := 0;
while m != a.Length0
invariant 0 <= m <= a.Length0
invariant forall i, j :: 0 <= i < m && 0 <= j < a.Length1 ==> a[i,j] == ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_AI_agent_verify_examples_RotateRight.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 510 | e3f4012dcb677546768ca48bda850e80b9b99458e9fdaf583601380b088b6f98 | method RotateRight(a: array)
requires a.Length > 0
modifies a
ensures forall i :: 1<= i < a.Length ==> a[i] == old(a[(i-1)])
ensures a[0] == old(a[a.Length-1])
{
var n := 1;
while n != a.Length
invariant 1 <= n <= a.Length
invariant forall i :: 1 <= i < n ==> a[i] == ol... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_bql_exampls_Min.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 500 | f7fb67aa5cdcec24612ce8ad390a86c3ad65c9c7f7043c970e8feb9caa3ff18e | method min(a: array<int>, n : int) returns (min : int)
requires 0 < n <= a.Length;
ensures (exists i : int :: 0 <= i && i < n && a[i] == min);
ensures (forall i : int :: 0 <= i && i < n ==> a[i] >= min);
{
var i : int;
min := a[0];
i := 1;
while (i < n)
invariant i <= n;
invariant (exists j ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_bql_exampls_SmallNum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 361 | fac1a18bad5d5212b40c4a5bc5bbadb6a1019aa6e00cc071b7e3495d00001493 | method add_small_numbers (a: array<int>, n: int, max: int) returns (r: int)
requires n > 0;
requires n <= a.Length;
requires (forall i: int :: 0 <= i && i < n ==> a[i] <= max);
ensures r <= max * n;
{
var i: int;
i := 0;
r := 0;
while (i < n)
invariant i <= n;
invariant r <= max * i;
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_bql_exampls_Square.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 288 | c4a4534d4b6fb584e71d92f56faaa55096856a3fdbcfeda28dec62c0383547d0 | method square (n: int) returns (r: int)
requires 0 <= n;
ensures r == n*n;
{
var x: int;
var i: int;
r := 0;
i := 0;
x := 1;
while (i < n)
invariant i <= n;
invariant r == i*i;
invariant x == 2*i + 1;
{
r := r + x;
x := x + 2;
i := i + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_C_convert_examples_01.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 286 | 6937c929b0d338dcec65daae03a16f2872b19c3908baff1d23fb334e7908decb | method main() returns (t1: int, t2: int, x: int, y: int)
ensures y >= 1
{
x := 1;
y := 1;
t1 := 0;
t2 := 0;
while(x <= 100000)
invariant x == y;
{
t1 := x;
t2 := y;
x := t1 + t2;
y := t1 + t2;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_C_convert_examples_06_n.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,150 | dcb9e42e0320ec6451032c9c3a0485eca0dc297dbdd812ce9a6a82898146a3f9 | // MODULE main
// int x;
// int y;
// int w;
// int z;
// int turn;
// assume(x == 0);
// assume(y == 0);
// assume(z == 0);
// assume(w == 1);
// assume(turn == 0);
// while(*){
// if(turn == 0){
// if(*){
// turn = 1;
// }
// else{
// turn = 2;
// }
// }
//... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_C_convert_examples_07.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,133 | 06276fb5c51ab738aac59b22ee2fbb5b6e45a9fa5521eb50ddda5a2a33054d9d | // MODULE main
// int i;
// int n;
// int a;
// int b;
// assume(i == 0);
// assume(a == 0);
// assume(b == 0);
// assume(n >= 0);
// while(i < n){
// if(*) {
// a = a+1;
// b = b+2;
// }
// else {
// a = a+2;
// b = b+1;
// }
// i = i+1;
//... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_C_convert_examples_11.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 897 | 7bbfddb9887628e56a6a52d1e3ddb2749e35951fc0d07971e773bbad55504ffd | method main(x :int) returns (j :int, i :int)
requires x > 0
ensures j == 2 * x
{
i := 0;
j := 0;
while i < x
invariant 0 <= i <= x
invariant j == 2 * i
{
j := j + 2;
i := i + 1;
}
}
// MODULE main
// int i;
// int j;
// int x;
// assume(j... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_C_convert_examples_15.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 680 | 4b88eef9107fd74c00b468677c35e274be47c60b0f097ab687355c668fdee573 | method main(n: int, k: int) returns (k_out: int)
requires n > 0;
requires k > n;
ensures k_out >= 0;
{
k_out := k;
var j: int := 0;
while(j < n)
invariant 0 <= j <= n;
invariant j + k_out == k;
{
j := j + 1;
k_out := k_out - 1;
}
}
// C code:
// MODULE main... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_C_convert_examples_23_x.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 472 | cb550ac989905e100c3816f983862a92e83fe75c4579e5792b787a1ab233cf8d | method main(n: int) returns (sum: int, i: int)
requires n >= 0
{
sum := 0;
i := 0;
while(i < n)
invariant sum >= 0
invariant 0 <= i <= n
{
sum := sum + i;
i := i + 1;
}
}
// MODULE main
// int i;
// int sum;
// int n;
// assume(sum == 0);
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_detailed_examples_SelectionSort.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,907 | 42f90d45876b203d31eb23d4798c12e0298fb22597c4962decbeaab9a496a295 | // Works by dividing the input list into two parts: sorted and unsorted. At the beginning,
// the sorted part is empty and the unsorted part contains all the elements.
method SelectionSort(a: array<int>)
modifies a
// Ensures the final array is sorted in ascending order
ensures forall i,j :: 0 <= i < j < a.... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_dataset_error_data_real_error_IsEven_success_1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 341 | cb0735ddebbcce621a96ed678309cc968133cae9650107f46b74eb775f224bc8 | function even(n: int): bool
requires n >= 0
{
if n == 0 then true else !even(n-1)
}
method is_even(n: int) returns (r: bool)
requires n >= 0;
ensures r <==> even(n);
{
var i: int := 0;
r := true;
while i < n
invariant 0 <= i <= n;
invariant r <==> even(i);
{
r := !r;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_50_examples_28.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 356 | 9b234e4c710c0aabcecacd12fe297a1c15f5fddee93f41be4641602b58d0a207 | method main(x: int, y: int) returns (x_out: int, y_out: int, n: int)
requires x >= 0
requires y >= 0
requires x == y
ensures y_out == n
{
x_out := x;
y_out := y;
n := 0;
while (x_out != n)
invariant x_out >= 0
invariant x_out == y_out
{
x_out := x_out - 1;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_50_examples_37.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 322 | 6b35001d5582d3089632b75c511e02d38e23eeb2416cb340c40674647b64e2b4 | method main(n: int) returns(x: int, m: int)
requires n > 0
ensures (n <= 0) || (0 <= m && m < n)
{
x := 0;
m := 0;
while(x < n)
invariant 0 <= x <= n
invariant 0 <= m < n
{
if(*)
{
m := x;
}
else{}
x := x + 1;
}
}... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_50_examples_38.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 416 | 876ac8b8252b382f7bc00b5ef99a6905d9440b5df64e9ccecc81d5e41745d934 | method main(n : int) returns (i: int, x: int, y:int)
requires n >= 0
ensures (i % 2 != 0) || (x == 2 * y)
{
i := 0;
x := 0;
y := 0;
while (i < n)
invariant 0 <= i <= n
invariant x == i
invariant y == i / 2
{
i := i + 1;
x := x + 1;
if (... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_50_examples_41.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 315 | 8b4dedba65c899f650e336553d21f0d4bc4ea6f5c68accfec37e26ce22c92cc2 | method main(n: int, k: int) returns (i :int, j: int)
requires n >= 0
requires k == 1 || k >= 0
ensures k + i + j >= 2 * n
{
i := 0;
j := 0;
while(i < n)
invariant 0 <= i <= n
invariant j == i * (i + 1) / 2
{
i := i + 1;
j := j + i;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_50_examples_BinarySearch.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 678 | 51b78ca057e570da74d2f0c475670226e932eb7b29f70501b408d11829e8aa66 | method BinarySearch(a: array<int>, key: int) returns (n: int)
requires forall i, j :: 0 <= i < j < a.Length ==> a[i] <= a[j]
ensures 0 <= n <= a.Length
ensures forall i :: 0 <= i < n ==> a[i] < key
ensures forall i :: n <= i < a.Length ==> key <= a[i]
{
var lo, hi := 0, a.Length;
while ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_50_examples_SumArray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 512 | 912cec3084ded77acf601d60ae13a05c05b504d2f40b4b43e618ffd5cf00bf92 | function Sum(arr: array<int>, len: int): int
reads arr
requires arr.Length > 0 && 0 <= len <= arr.Length
{
if len == 0 then 0 else arr[len-1] + Sum(arr, len-1)
}
method SumArray(arr: array<int>) returns (sum: int)
requires arr.Length > 0
ensures sum == Sum(arr, arr.Length)
{
sum := 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_error_data_completion_06_n.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 659 | ac785831422d726b1a1103b82805928826489d96c9ccb077fc2b96dbd9bb0ae4 | method Main() returns (x: int, y: int)
ensures x == y;
{
x := 0;
y := 0;
var w := 1;
var z := 0;
var turn := 0;
while(x != y)
invariant x == y ==> !(0 <= -z*2/2 && 1 <= -(w-1)*2/2)
invariant !((x != y && x - y <= -1) || (x - y >= 1 && -z*2/2 <= 0 && (w-1)*2/2 <= 1))
invariant !(w*2/2 <= 0 ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_error_data_completion_07.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 448 | a93a4b661f3200029e41a91b3727af3b12c25a793e531f2c4cf5c6ad9e8bacae | method main(n: int) returns (a: int, b: int)
requires n >= 0
ensures a + b == 3 * n
{
var i: int := 0;
a := 0;
b := 0;
while(i < n)
invariant 0 <= i <= n
invariant a + b == 3 * i
{
if(*)
{
a := a + 1;
b := b + 2;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_error_data_completion_11.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 250 | a5df6f45f2806cd4547003c8ac25503d67f05b7005d9be5a62c352acd61b8314 | method main(x :int) returns (j :int, i :int)
requires x > 0
ensures j == 2 * x
{
i := 0;
j := 0;
while i < x
invariant 0 <= i <= x
invariant j == 2 * i
{
j := j + 2;
i := i + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Fine_Tune_Examples_normal_data_completion_MaxPerdV2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 729 | 0f53e3bc9e8bc3fb3dbc7d2ff848665c0529e345e0603e358bfe75f9a892451e | function contains(v: int, a: array<int>, n: int): bool
reads a
requires n <= a.Length
{
exists j :: 0 <= j < n && a[j] == v
}
function upper_bound(v: int, a: array<int>, n: int): bool
reads a
requires n <= a.Length
{
forall j :: 0 <= j < n ==> a[j] <= v
}
function is_max(m: int, a: array<int>, n... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_15.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 302 | 55ea667fcca21ade8780ff785858ffb429b58ad0f424a11b99ebbc8307bb996b | method main(n: int, k: int) returns (k_out: int)
requires n > 0;
requires k > n;
ensures k_out >= 0;
{
k_out := k;
var j: int := 0;
while(j < n)
invariant 0 <= j <= n;
invariant k_out == k - j;
{
j := j + 1;
k_out := k_out - 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_ComputePower.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 311 | 1d66f1bdf44520a8117a7434bdbf76705eda7076c41d2e3cd74d2afa2b403ddb | function Power(n: nat): nat {
if n == 0 then 1 else 2 * Power(n - 1)
}
method ComputePower(n: nat) returns (p: nat)
ensures p == Power(n)
{
p := 1;
var i := 0;
while i != n
invariant 0 <= i <= n && p == Power(i)
{
i := i + 1;
p := p * 2;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_Count.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 681 | 28a024e37b0082671f9f775ed2deccdc92611adc83c56c1d30a215069f485d25 | function has_count(v: int, a: array<int>, n: int): int
reads a // This allows the function to read from array 'a'
requires n >= 0 && n <= a.Length
{
if n == 0 then 0 else
(if a[n-1] == v then has_count(v, a, n-1) + 1 else has_count(v, a, n-1))
}
method count (v: int, a: array<int>, n: int) r... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_LinearSearch.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 413 | f405882a71559d89a492ec8c9fd9a0cdb5fdc1067d98f12b51b7bcaca3126a46 | method LinearSearch<T>(a: array<T>, P: T -> bool) returns (n: int)
ensures 0 <= n <= a.Length
ensures n == a.Length || P(a[n])
ensures forall i :: 0 <= i < n ==> !P(a[i])
{
n := 0;
while n != a.Length
invariant 0 <= n <= a.Length
invariant forall i :: 0 <= i < n ==> !P(a[i])
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_Minimum.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 433 | 7329889dafa469872140f2dd179a2161319ac453de77ef866fa630f1be98d3ce | method Minimum(a: array<int>) returns (m: int)
requires a.Length > 0
ensures exists i :: 0 <= i < a.Length && m == a[i]
ensures forall i :: 0 <= i < a.Length ==> m <= a[i]
{
var n := 0;
m := a[0];
while n != a.Length
invariant 0 <= n <= a.Length
invariant exists i :: 0 <= i < a.Length && m == a[i]
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_Mult.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 212 | 33dbbe6fc09a1b13741db59716f4f7005775a3a0e9cf9d5bb893e60ec8059e4c | method mult(a:int, b:int) returns (x:int)
requires a >= 0 && b >= 0
ensures x == a * b
{
x := 0;
var y := a;
while y > 0
invariant x == (a - y) * b
{
x := x + b;
y := y - 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Generated_Code_rand.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 278 | a97be60e904cb218d6f0838c2c5dc34fd7e7549615dd26fbeae4b5f0b2991747 | method Main(xInit: int, y: int) returns (z: int)
requires xInit >= 0
requires y >= 0
ensures z == 0
{
var x := xInit;
z := x * y;
while x > 0
invariant x >= 0
invariant z == x * y
decreases x
{
x := x - 1;
z := z - y;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Test_Cases_Function.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 486 | 974c614a460ae7dcc91122c1f1a8a2ee17aa51db6d570ea68b7dc15d1138cf84 | function Average (a: int, b: int): int
{
(a + b) / 2
}
method TripleConditions(x: int) returns (r: int)
ensures r == 3 * x
{
r := 3 * x;
assert r == 3 * x;
}
method Triple' (x: int) returns (r: int)
ensures Average(r, 3 * x) == 3 * x
ensures r == 3 * x
{
r:= 3 * x;
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Test_Cases_Ghost.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 920 | 4fa001a8bcd2843d786f18e6ce2e128e8ad5abc1861c20796af19459947401b8 | function Average(a: int, b: int): int
{
(a + b) / 2
}
ghost method Triple(x: int) returns (r: int)
ensures r == 3 * x
{
r := Average(2 * x, 4 * x);
}
method Triple1(x: int) returns (r: int)
ensures r == 3 * x
{
var y := 2 * x;
r := x + y;
ghost var a, b := DoubleQuadruple... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Test_Cases_Index.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,254 | 51aa9abd266cd3b05a8331af8ccb48894fc1b3080b395c0bb38b1af98edb792b | method Index(n: int) returns (i: int)
requires 1 <= n
ensures 0 <= i < n
{
i := n/2;
}
method Min(x: int, y: int) returns (m: int)
ensures m <= x && m <= y
ensures m == x || m == y
{
if (x >= y) {
m := y;
} else {
m := x;
}
assert m <= x && m <= y;
}
method Max... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Test_Cases_LoopInvariant.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,218 | 42fb1884ebc21e1d3f8f2bef639e0b9ec1dbd9a20ca1766223fff327613b471e | method UpWhileLess(N: int) returns (i: int)
requires 0 <= N
ensures i == N
{
i := 0;
while i < N
invariant 0 <= i <= N
decreases N - i
{
i := i + 1;
}
}
method UpWhileNotEqual(N: int) returns (i: int)
requires 0 <= N
ensures i == N
{
i := 0;
while i != N
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Test_Cases_solved_1_select.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 912 | 7659edccb3bd9d59f44e4882782a374f48fc21721852165dd3a0e48a6ca07597 | method SelectionSort(a: array<int>)
modifies a
ensures forall i,j :: 0 <= i < j < a.Length ==> a[i] <= a[j]
ensures multiset(a[..]) == old(multiset(a[..]))
{
var n := 0;
while n != a.Length
invariant 0 <= n <= a.Length
invariant forall i,j :: 0 <= i < j < a.Length && j < n ==> a[i] <= a[j]
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny_Verify_tmp_tmphq7j0row_Test_Cases_Triple.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 776 | b4b4deedb8fe2c786394c8e521073b51c1c712ad2fae0e47977375cc72b18154 | method Triple(x: int) returns (r: int)
{
var y := 2 * x;
r := x + y;
assert r == 3 * x;
}
method TripleIf(x: int) returns (r: int) {
if (x == 0) {
r := 0;
} else {
var y := 2 * x;
r := x + y;
}
assert r == 3 * x;
}
method TripleOver(x: int) returns ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/eth2-dafny_tmp_tmpcrgexrgb_src_dafny_utils_SetHelpers.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,323 | c7d576ce715ef32f083bdb8e7cd116ecd4602698889ecd68116d2a2948bacda3 | /*
* Copyright 2021 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.