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/dafny-synthesis_task_id_555.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 518 | e6f869fc343b534e64515a46d242d991b9e723c6e469d627d51165c3376fdb16 | method DifferenceSumCubesAndSumNumbers(n: int) returns (diff: int)
requires n >= 0
ensures diff == (n * n * (n + 1) * (n + 1)) / 4 - (n * (n + 1)) / 2
{
var sumCubes := 0;
var sumNumbers := 0;
for i := 1 to n + 1
invariant 0 <= i <= n + 1
invariant sumCubes == (i - 1) * (i - ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_557.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,426 | eaa4fba6ca11b9d14efb0aa8e1b6d174926e78b4c1ddc5ff5d800e05db39a688 | predicate IsLowerCase(c : char)
{
97 <= c as int <= 122
}
predicate IsUpperCase(c : char)
{
65 <= c as int <= 90
}
predicate IsLowerUpperPair(c : char, C : char)
{
(c as int) == (C as int) + 32
}
predicate IsUpperLowerPair(C : char, c : char)
{
(C as int) == (c as int) - 32
}
fun... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_565.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 343 | b12afc88faa4f9122ab05239c3d40e70421b12afd8a1923352d20b80d786ee93 | method SplitStringIntoChars(s: string) returns (v: seq<char>)
ensures |v| == |s|
ensures forall i :: 0 <= i < |s| ==> v[i] == s[i]
{
v := [];
for i := 0 to |s|
invariant 0 <= i <= |s|
invariant |v| == i
invariant forall k :: 0 <= k < i ==> v[k] == s[k]
{
v :... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_566.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,339 | 42b653fcf15eca33fabacb0c57f91ff8017ee5ea7ca9885b2e7f156a43e39c58 | method SumOfDigits(number: nat) returns (sum: nat)
requires number >= 0
ensures sum >= 0
ensures sum == SumDigits(number)
{
sum := 0;
var n: nat := number;
// Let's find out the number of digits, which is the same as powers of ten for the given number
ghost var ndigits := NumberOfDigits(number);... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_567.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 616 | 29db4f2dd0006c9e544cd90e3d92cbc85445cdc398d9950404576c7c09b4e53a | method IsSorted(a: array<int>) returns (sorted: bool)
requires a.Length > 0
ensures sorted <== forall i, j :: 0 <= i < j < a.Length ==> a[i] <= a[j]
ensures !sorted ==> exists i, j :: 0 <= i < j < a.Length && a[i] > a[j]
{
sorted := true;
for i := 0 to a.Length - 1
invariant 0 <= i < ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_572.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 623 | 50bcb6e26e30cfe301a0cf01b61561a2f9f60fa2513186d2be6ca94a6bdd26aa | method RemoveDuplicates(a: array<int>) returns (result: seq<int>)
requires a != null
ensures forall x :: x in result <==> exists i :: 0 <= i < a.Length && a[i] == x
ensures forall i, j :: 0 <= i < j < |result| ==> result[i] != result[j]
{
var res: seq<int> := [];
for i := 0 to a.Length
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_573.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,612 | 58027fe3af3ef05605055a99a5104530fb9f71ee4b5058944483b93671b51b39 | method UniqueProduct (arr: array<int>) returns (product: int)
ensures product == SetProduct((set i | 0 <= i < arr.Length :: arr[i]))
{
var p := 1;
var seen: set<int> := {};
for i := 0 to arr.Length
invariant 0 <= i <= arr.Length
invariant seen == (set k | 0 <= k < i :: arr[k]... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_574.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 275 | 7a8aefe6daa7cbe58e4fea24106a006ad2f7508e6ad6b59eab93a27548d965d6 | method CylinderSurfaceArea(radius: real, height: real) returns (area: real)
requires radius > 0.0 && height > 0.0
ensures area == 2.0 * 3.14159265358979323846 * radius * (radius + height)
{
area := 2.0 * 3.14159265358979323846 * radius * (radius + height);
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_576.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 507 | a011334ff10262dcb72ccd80423424079783b676b1a621c11a15a79094865a97 | method IsSublist(sub: seq<int>, main: seq<int>) returns (result: bool)
ensures true <== (exists i :: 0 <= i <= |main| - |sub| && sub == main[i..i + |sub|])
{
if |sub| > |main| {
return false;
}
for i := 0 to |main| - |sub| + 1
invariant 0 <= i <= |main| - |sub| + 1
inva... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_577.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 366 | 67a9ba6ba2ef868689f39ed610c479a2a10585a22e4e5a5ece38c7405d4d499d | function Factorial(n: int): int
requires n >= 0
ensures 0 <= Factorial(n)
{
if n == 0 then 1
else n * Factorial(n-1)
}
method FactorialOfLastDigit(n: int) returns (fact: int)
requires n >= 0
ensures fact == Factorial(n % 10)
{
var lastDigit := n % 10;... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_578.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 531 | 54fc93429846f7673fa326251029561f63d9d614b08ed72e462cf3e42ecd5782 | method Interleave(s1: seq<int>, s2: seq<int>, s3: seq<int>) returns (r: seq<int>)
requires |s1| == |s2| && |s2| == |s3|
ensures |r| == 3 * |s1|
ensures forall i :: 0 <= i < |s1| ==> r[3*i] == s1[i] && r[3*i + 1] == s2[i] && r[3*i + 2] == s3[i]
{
r := [];
for i := 0 to |s1|
invariant 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_579.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,395 | 449387cf976dd2583198d09b065dc904eb67fa9ff8f97f2e12b285450737059e | predicate InArray(a: array<int>, x: int)
reads a
{
exists i :: 0 <= i < a.Length && a[i] == x
}
method DissimilarElements(a: array<int>, b: array<int>) returns (result: seq<int>)
// All elements in the output are either in a or b, but not in both or neither
ensures forall x :: x in result ==> (... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_58.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 178 | 9c1d3b3305b9cbbecf81b8d93fa7deecea63b8e546bdb16718121208f4d0d3fb | method HasOppositeSign(a: int, b: int) returns (result: bool)
ensures result <==> (a < 0 && b > 0) || (a > 0 && b < 0)
{
result := (a < 0 && b > 0) || (a > 0 && b < 0);
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_581.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 260 | 73e29c4f31f74d299af5c5b79abb3135b9d777556a545fa447c37c4d28d8e57d | method SquarePyramidSurfaceArea(baseEdge: int, height: int) returns (area: int)
requires baseEdge > 0
requires height > 0
ensures area == baseEdge * baseEdge + 2 * baseEdge * height
{
area := baseEdge * baseEdge + 2 * baseEdge * height;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_586.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 308 | ab64b5c904b6b554e08709eabba3934dedb40347d30fd1dff901be9cea010112 | method SplitAndAppend(l: seq<int>, n: int) returns (r: seq<int>)
requires n >= 0 && n < |l|
ensures |r| == |l|
ensures forall i :: 0 <= i < |l| ==> r[i] == l[(i + n) % |l|]
{
var firstPart: seq<int> := l[..n];
var secondPart: seq<int> := l[n..];
r := secondPart + firstPart;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_587.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 380 | 76d22c745333bb1aab66f0d410e89b508747ecaeb2c3d80acfe520a74a523258 | method ArrayToSeq(a: array<int>) returns (s: seq<int>)
requires a != null
ensures |s| == a.Length
ensures forall i :: 0 <= i < a.Length ==> s[i] == a[i]
{
s := [];
for i := 0 to a.Length
invariant 0 <= i <= a.Length
invariant |s| == i
invariant forall j :: 0 <= j < i... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_588.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,251 | 8c8e181a0ef76ee950c90673afca1e65da9c0f7f0d8bfe63a8a86bce2e752d8c | 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-synthesis_task_id_59.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 180 | 48b15ed5f0ac367efaa153ef089c9a5eb7e04ff7396ac7dcd7459b2df18cb71e | method NthOctagonalNumber(n: int) returns (octagonalNumber: int)
requires n >= 0
ensures octagonalNumber == n * (3 * n - 2)
{
octagonalNumber := n * (3 * n - 2);
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_591.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 326 | 58f7d2071cc098c40b87eab3bf693bab27215255827a789cd458705e913a323e | method SwapFirstAndLast(a: array<int>)
requires a != null && a.Length > 0
modifies a
ensures a[0] == old(a[a.Length - 1]) && a[a.Length - 1] == old(a[0])
ensures forall k :: 1 <= k < a.Length - 1 ==> a[k] == old(a[k])
{
var temp := a[0];
a[0] := a[a.Length - 1];
a[a.Length - 1] := te... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_594.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,498 | d988d73557f9cec035d0f49bd7a31b0df871433fdb476516fef7803551423d31 | predicate IsEven(n: int)
{
n % 2 == 0
}
predicate IsOdd(n: int)
{
n % 2 != 0
}
method FirstEvenOddDifference(a: array<int>) returns (diff: int)
requires a.Length >= 2
requires exists i :: 0 <= i < a.Length && IsEven(a[i])
requires exists i :: 0 <= i < a.Length && IsOdd(a[i])
ensu... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_598.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 373 | 3d61ba22a2ad80af36773c6225440c6b03ca018ac624b5be0fa79da7088207db | method IsArmstrong(n: int) returns (result: bool)
requires 100 <= n < 1000
ensures result <==> (n == ((n / 100) * (n / 100) * (n / 100) + ((n / 10) % 10) * ((n / 10) % 10) * ((n / 10) % 10) + (n % 10) * (n % 10) * (n % 10)))
{
var a := n / 100;
var b := (n / 10) % 10;
var c := n % 10;
r... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_599.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 361 | 26c81e06ffd4a1c8cb3d41f57ee4a9d49fc8195c91c112c7064dc78c90b19953 | method SumAndAverage(n: int) returns (sum: int, average: real)
requires n > 0
ensures sum == n * (n + 1) / 2
ensures average == sum as real / n as real
{
sum := 0;
for i := 1 to n + 1
invariant 0 <= i <= n + 1
invariant sum == (i - 1) * i / 2
{
sum := sum + i;
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_600.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 113 | 0319d68fa2770bb84d80a2d7d3da08356e77a31b23c6420b549bf7ad0a8b76c6 | method IsEven(n: int) returns (result: bool)
ensures result <==> n % 2 == 0
{
result := n % 2 == 0;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_602.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,496 | 0fe0fe3feae1e8c9961a798523e45d03d510e82d8a7f69130a10dc5ab8f3bdbb | method FindFirstRepeatedChar(s: string) returns (found: bool, c: char)
ensures found ==> exists i, j :: 0 <= i < j < |s| && s[i] == s[j] && s[i] == c && (forall k, l :: 0 <= k < l < j && s[k] == s[l] ==> k >= i)
ensures !found ==> (forall i, j :: 0 <= i < j < |s| ==> s[i] != s[j])
{
c := ' ';
found... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_603.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 690 | 153862b34095745d7012f01333126962b8ea5166cb1a82cc5f1946a5cc3d9180 | method LucidNumbers(n: int) returns (lucid: seq<int>)
requires n >= 0
ensures forall i :: 0 <= i < |lucid| ==> lucid[i] % 3 == 0
ensures forall i :: 0 <= i < |lucid| ==> lucid[i] <= n
ensures forall i, j :: 0 <= i < j < |lucid| ==> lucid[i] < lucid[j]
{
lucid := [];
var i := 0;
while... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_605.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 422 | f1e51c3e2061540de9e3158ac28b71f4e2fc2ea6f3ce70542674905f0ff8a864 | method IsPrime(n: int) returns (result: bool)
requires n >= 2
ensures result <==> (forall k :: 2 <= k < n ==> n % k != 0)
{
result := true;
var i := 2;
while i <= n/2
invariant 2 <= i
invariant result <==> (forall k :: 2 <= k < i ==> n % k != 0)
{
if n % i == 0
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_606.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 191 | a1fc6c2c35821b4d5ca85dbf722185897399c41811b073799bc437fe8090818c | method DegreesToRadians(degrees: real) returns (radians: real)
ensures radians == degrees * 3.14159265358979323846 / 180.0
{
radians := degrees * 3.14159265358979323846 / 180.0;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_61.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 744 | b692d1f0786c2b8f1c043904fb661ae85a56770e8ca4ab74580fde143875eb81 | predicate IsDigit(c: char)
{
48 <= c as int <= 57
}
method CountSubstringsWithSumOfDigitsEqualToLength(s: string) returns (count: int)
ensures count >= 0
{
count := 0;
for i := 0 to |s|
invariant 0 <= i <= |s|
{
var sum := 0;
for j := i to |s|
invar... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_610.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 774 | 0d8d04409b0b60f2f2da29e4d706104478830074500d7759b3fd458114cd7abf | method RemoveElement(s: array<int>, k: int) returns (v: array<int>)
requires 0 <= k < s.Length
ensures v.Length == s.Length - 1
ensures forall i :: 0 <= i < k ==> v[i] == s[i]
ensures forall i :: k <= i < v.Length ==> v[i] == s[i + 1]
{
v := new int[s.Length - 1];
var i := 0;
while i... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_616.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 662 | eaa8f01065e72a5f62cc7f8f79a7cf4b860739975a8ed68ab0b23a5ee29f7979 | method ElementWiseModulo(a: array<int>, b: array<int>) returns (result: array<int>)
requires a != null && b != null
requires a.Length == b.Length
requires forall i :: 0 <= i < b.Length ==> b[i] != 0
ensures result != null
ensures result.Length == a.Length
ensures forall i :: 0 <= i < resul... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_618.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 498 | 431aa8524dc2115cde6c10c9b4e5487d8c7dea2b41b78c3542730c1a20dac9f9 | method ElementWiseDivide(a: seq<int>, b: seq<int>) returns (result: seq<int>)
requires |a| == |b|
requires forall i :: 0 <= i < |b| ==> b[i] != 0
ensures |result| == |a|
ensures forall i :: 0 <= i < |result| ==> result[i] == a[i] / b[i]
{
result := [];
for i := 0 to |a|
invariant... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_62.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 443 | 003bc4562371dbe46ad49bd0ff53a4528e4484a341c3fee8f72373428481672c | method FindSmallest(s: array<int>) returns (min: int)
requires s.Length > 0
ensures forall i :: 0 <= i < s.Length ==> min <= s[i]
ensures exists i :: 0 <= i < s.Length && min == s[i]
{
min := s[0];
for i := 1 to s.Length
invariant 0 <= i <= s.Length
invariant forall k :: 0 <= k < i ==> min <= ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_622.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 557 | 6117851ce11542792eb98113d40e33222bbfa82e31b651cdf9d18fd78dc8e851 | method FindMedian(a: array<int>, b: array<int>) returns (median: int)
requires a != null && b != null
requires a.Length == b.Length
requires a.Length > 0
requires forall i :: 0 <= i < a.Length - 1 ==> a[i] <= a[i + 1]
requires forall i :: 0 <= i < b.Length - 1 ==> b[i] <= b[i + 1]
ensures ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_623.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 595 | a19bbb7b6796c18536756624589c0caf7b332804135e5f3b8b0a4b1c3045838b | method PowerOfListElements(l: seq<int>, n: int) returns (result: seq<int>)
requires n >= 0
ensures |result| == |l|
ensures forall i :: 0 <= i < |l| ==> result[i] == Power(l[i], n)
{
result := [];
for i := 0 to |l|
invariant 0 <= i <= |l|
invariant |result| == i
invar... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_624.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 916 | 71c6440519c392eb394b7b1e54538d6c7f3e1daf245ed677bac6fec5676ca7cf | predicate IsLowerCase(c : char)
{
97 <= c as int <= 122
}
predicate IsLowerUpperPair(c : char, C : char)
{
(c as int) == (C as int) + 32
}
function ShiftMinus32(c : char) : char
{
((c as int - 32) % 128) as char
}
method ToUppercase(s: string) returns (v: string)
ensures |v| == |s|
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_625.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 321 | 0553949c13cf872021199442e3c7cc79c30448245f3c9418fe446bb6fd204d1e | method SwapFirstAndLast(a: array<int>)
requires a.Length > 0
modifies a
ensures a[0] == old(a[a.Length - 1])
ensures a[a.Length - 1] == old(a[0])
ensures forall k :: 1 <= k < a.Length - 1 ==> a[k] == old(a[k])
{
var tmp := a[0];
a[0] := a[a.Length - 1];
a[a.Length - 1] := tmp;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_626.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 171 | fe49276cfb399de09243516675957eb72ef575682c95f17886d22426f6c17982 | method AreaOfLargestTriangleInSemicircle(radius: int) returns (area: int)
requires radius > 0
ensures area == radius * radius
{
area := radius * radius;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_627.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 730 | 9d3caf9b2b4a620006e025efb51bc2066eed6bf6f7802e2de56226d80ca2e5f9 | method SmallestMissingNumber(s: seq<int>) returns (v: int)
requires forall i, j :: 0 <= i < j < |s| ==> s[i] <= s[j]
requires forall i :: 0 <= i < |s| ==> s[i] >= 0
ensures 0 <= v
ensures v !in s
ensures forall k :: 0 <= k < v ==> k in s
{
v := 0;
for i := 0 to |s|
invariant... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_629.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 854 | 1ddf4a0b62949c916ca8188ed714a3000ddfd912ee807eec60347329454f42e6 | predicate IsEven(n: int)
{
n % 2 == 0
}
method FindEvenNumbers(arr: array<int>) returns (evenList: seq<int>)
// All numbers in the output are even and exist in the input
ensures forall i :: 0 <= i < |evenList| ==> IsEven(evenList[i]) && evenList[i] in arr[..]
// All even numbers in the input a... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_632.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,237 | 25135d31819c670ee0dc9021f413bf2f224f8011f1b2e5eab48c0db056da0a5d | method MoveZeroesToEnd(arr: array<int>)
requires arr.Length >= 2
modifies arr
// Same size
ensures arr.Length == old(arr.Length)
// Zeros to the right of the first zero
ensures forall i, j :: 0 <= i < j < arr.Length && arr[i] == 0 ==> arr[j] == 0
// The final array is a permutation of... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_637.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 225 | b5ab723ef4e2d497f2d8bee4e0ff7cca5349fecab000fa5ad6efbebe2d61ef11 | method IsBreakEven(costPrice: int, sellingPrice: int) returns (result: bool)
requires costPrice >= 0 && sellingPrice >= 0
ensures result <==> costPrice == sellingPrice
{
result := costPrice == sellingPrice;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_641.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 161 | 472838e7ee2dfb82860b44cc5392f7cf9cb8592107fdf469cb67eb16862fe0a3 | method NthNonagonalNumber(n: int) returns (number: int)
requires n >= 0
ensures number == n * (7 * n - 5) / 2
{
number := n * (7 * n - 5) / 2;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_644.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 993 | e4656c4d1585b04ef173dcc5a51922217f0f1936932e2c33315fd1c2a3a9f121 | method Reverse(a: array<int>)
modifies a;
ensures forall k :: 0 <= k < a.Length ==> a[k] == old(a[(a.Length-1) - k]);
{
var l := a.Length - 1;
var i := 0;
while (i < l-i)
invariant 0 <= i <= (l+1)/2;
invariant forall k :: 0 <= k < i || l-i < k <= l ==> a[k] == old(a[l-k]);
invariant forall k :: i <=... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_69.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 422 | 1efc4916d7acdb2bb22ac2af6b8f0c520e0c4f82a3d332605fe3489f2db3e6ef | method ContainsSequence(list: seq<seq<int>>, sub: seq<int>) returns (result: bool)
ensures result <==> (exists i :: 0 <= i < |list| && sub == list[i])
{
result := false;
for i := 0 to |list|
invariant 0 <= i <= |list|
invariant result <==> (exists k :: 0 <= k < i && sub == list[k])
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_70.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 607 | 0960244a617d1dfb2523d136dda6b1fb7c6ff2d7b492ab7121585a33aa0f5c28 | method AllSequencesEqualLength(sequences: seq<seq<int>>) returns (result: bool)
ensures result <==> forall i, j :: 0 <= i < |sequences| && 0 <= j < |sequences| ==> |sequences[i]| == |sequences[j]|
{
if |sequences| == 0 {
return true;
}
var firstLength := |sequences[0]|;
result := tr... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_728.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 436 | 011fb2b14281ce812846a2a11ffbe03397de80a044ffda26563fc56e275cc834 | method AddLists(a: seq<int>, b: seq<int>) returns (result: seq<int>)
requires |a| == |b|
ensures |result| == |a|
ensures forall i :: 0 <= i < |result| ==> result[i] == a[i] + b[i]
{
result := [];
for i := 0 to |a|
invariant 0 <= i <= |a|
invariant |result| == i
invar... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_732.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 713 | d5061aa0711d53142805d428472cc8bdd2cd300dcd7a1f8ed5dec67ebe7f0887 | predicate IsSpaceCommaDot(c: char)
{
c == ' ' || c == ',' || c == '.'
}
method ReplaceWithColon(s: string) returns (v: string)
ensures |v| == |s|
ensures forall i :: 0 <= i < |s| ==> (IsSpaceCommaDot(s[i]) ==> v[i] == ':') && (!IsSpaceCommaDot(s[i]) ==> v[i] == s[i])
{
var s' : string := [];
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_733.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 881 | 0c59358ebfd5ea8ddbeb63b828ec3784ebf3bc4b892efc6f3ac742cdbbf185f7 | method FindFirstOccurrence(arr: array<int>, target: int) returns (index: int)
requires arr != null
requires forall i, j :: 0 <= i < j < arr.Length ==> arr[i] <= arr[j]
ensures 0 <= index < arr.Length ==> arr[index] == target
ensures index == -1 ==> forall i :: 0 <= i < arr.Length ==> arr[i] != targe... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_741.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 598 | db7c2c98f444faf5ee551bf20367904d6b9904f189ec8f7810cfc2021b268b89 | method AllCharactersSame(s: string) returns (result: bool)
ensures result ==> forall i, j :: 0 <= i < |s| && 0 <= j < |s| ==> s[i] == s[j]
ensures !result ==> (|s| > 1) && (exists i, j :: 0 <= i < |s| && 0 <= j < |s| && i != j && s[i] != s[j])
{
if |s| <= 1 {
return true;
}
var firs... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_743.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 483 | baef1ec190163e9d96f43806bee5a1a970d54155475a47349f10a09ffb9a833f | method RotateRight(l: seq<int>, n: int) returns (r: seq<int>)
requires n >= 0
ensures |r| == |l|
ensures forall i :: 0 <= i < |l| ==> r[i] == l[(i - n + |l|) % |l|]
{
var rotated: seq<int> := [];
for i := 0 to |l|
invariant 0 <= i <= |l|
invariant |rotated| == i
inva... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_750.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 222 | 13e6d6a44ba079df667c9a95be104b4f0ae7c236cfaf4a87e893775c83b1043a | method AddTupleToList(l: seq<(int, int)>, t: (int, int)) returns (r: seq<(int, int)>)
ensures |r| == |l| + 1
ensures r[|r| - 1] == t
ensures forall i :: 0 <= i < |l| ==> r[i] == l[i]
{
r := l + [t];
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_751.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 711 | 328597f524756330e4efb3603a47c52834c43dadfb83f4a173c7979d0e8a6a3a | method IsMinHeap(a: array<int>) returns (result: bool)
requires a != null
ensures result ==> forall i :: 0 <= i < a.Length / 2 ==> a[i] <= a[2*i + 1] && (2*i + 2 == a.Length || a[i] <= a[2*i + 2])
ensures !result ==> exists i :: 0 <= i < a.Length / 2 && (a[i] > a[2*i + 1] || (2*i + 2 != a.Length && a[i] ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_755.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,623 | 99b54910ae9da74206b47e93ac5c0cdb196b58343092e13d3ac27cd726cf0a89 | function MinPair(s: seq<int>) : (r: int)
requires |s| == 2
ensures s[0] <= s[1] <==> r == s[0]
ensures s[0] > s[1] ==> r == s[1]
{
if s[0] <= s[1] then s[0] else s[1]
}
function min(s: seq<int>) : (r: int)
requires |s| >= 2
ensures forall i :: 0 <= i < |s| ==> r <= s[i]
{
if ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_759.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 535 | 12580b15e239032b9b94e834a1f99898dcca445119d25d0451c9823c081be4cd | method IsDecimalWithTwoPrecision(s: string) returns (result: bool)
ensures result ==> (exists i :: 0 <= i < |s| && s[i] == '.' && |s| - i - 1 == 2)
ensures !result ==> !(exists i :: 0 <= i < |s| && s[i] == '.' && |s| - i - 1 == 2)
{
result := false;
for i := 0 to |s|
invariant 0 <= i <= |s... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_760.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 653 | 7b10af5c553f1cc68a0d4466fdd1b2542541edb4d425b1d6afb992e46880ce61 | method HasOnlyOneDistinctElement(a: array<int>) returns (result: bool)
requires a != null
ensures result ==> forall i, j :: 0 <= i < a.Length && 0 <= j < a.Length ==> a[i] == a[j]
ensures !result ==> exists i, j :: 0 <= i < a.Length && 0 <= j < a.Length && a[i] != a[j]
{
if a.Length == 0 {
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_762.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 245 | f72c53cc2d6b78e2db91c684a67404a655e369e88abf9245941764e16c9bf953 | method IsMonthWith30Days(month: int) returns (result: bool)
requires 1 <= month <= 12
ensures result <==> month == 4 || month == 6 || month == 9 || month == 11
{
result := month == 4 || month == 6 || month == 9 || month == 11;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_764.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 303 | ba50afb5d3ebcd46460bf3c1bc868093f8771ff78aa4f06e85fb791465f955d9 | predicate IsDigit(c: char)
{
48 <= c as int <= 57
}
method CountDigits(s: string) returns (count: int)
ensures count >= 0
ensures count == | set i: int | 0 <= i < |s| && IsDigit(s[i])|
{
var digits := set i: int | 0 <= i < |s| && IsDigit(s[i]);
count := |digits|;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_769.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 538 | 850588f1c348d826045a20e228fe410dc9850e3778d50786b81c49eef59f37f5 | method Difference(a: seq<int>, b: seq<int>) returns (diff: seq<int>)
ensures forall x :: x in diff <==> (x in a && x !in b)
ensures forall i, j :: 0 <= i < j < |diff| ==> diff[i] != diff[j]
{
diff := [];
for i := 0 to |a|
invariant 0 <= i <= |a|
invariant forall x :: x in diff <==... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_77.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 120 | f80999d424bdf4ff2e87dac783f6fa6275c7e5ca09c2f59cc2a12b5b144e4324 | method IsDivisibleBy11(n: int) returns (result: bool)
ensures result <==> n % 11 == 0
{
result := n % 11 == 0;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_770.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 458 | c2677722147635ce4f5ac26cb8940cf48f5dd01a7ffbb2b86fe07d63d6ff760f | method SumOfFourthPowerOfOddNumbers(n: int) returns (sum: int)
requires n > 0
ensures sum == n * (2 * n + 1) * (24 * n * n * n - 12 * n * n - 14 * n + 7) / 15
{
sum := 0;
var i := 1;
for k := 0 to n
invariant 0 <= k <= n
invariant i == 2 * k + 1
invariant sum == k *... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_775.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 496 | 964639f401796462fc1d05b19b939c928c4daa9e0fdb5d1fda9305f8968edc21 | predicate IsOdd(n: int)
{
n % 2 == 1
}
method IsOddAtIndexOdd(a: array<int>) returns (result: bool)
ensures result <==> forall i :: 0 <= i < a.Length ==> (IsOdd(i) ==> IsOdd(a[i]))
{
result := true;
for i := 0 to a.Length
invariant 0 <= i <= a.Length
invariant result <==> for... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_776.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 387 | 0d385b172f611d2a3f0c47efa0205a8fe28ff443e7e8ddba990103cf225b4b45 | predicate IsVowel(c: char)
{
c in {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
}
method CountVowelNeighbors(s: string) returns (count: int)
ensures count >= 0
ensures count == | set i: int | 1 <= i < |s|-1 && IsVowel(s[i-1]) && IsVowel(s[i+1]) |
{
var vowels := set i: int | 1 <= i < |s|-... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_784.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,973 | 51aa5829123ff7078dee173a02db384ae7c6b7b0fbc747ed7eaa633a804b74ba | predicate IsEven(n: int)
{
n % 2 == 0
}
predicate IsOdd(n: int)
{
n % 2 != 0
}
predicate IsFirstEven(evenIndex: int, lst: seq<int>)
requires 0 <= evenIndex < |lst|
requires IsEven(lst[evenIndex])
{
forall i :: 0 <= i < evenIndex ==> IsOdd(lst[i])
}
predicate IsFirstOdd(oddIndex: ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_79.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 125 | 91cc5082d7b43f36a6619e440904138071a73d0d4188715031ac3a898bfd17d2 | method IsLengthOdd(s: string) returns (result: bool)
ensures result <==> |s| % 2 == 1
{
result := |s| % 2 == 1;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_790.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 502 | 5a8cd30643e90c6ad70d50c777a8c30b621c781730ec7ae59a56addb35ba10c5 | predicate IsEven(n: int)
{
n % 2 == 0
}
method IsEvenAtIndexEven(lst: seq<int>) returns (result: bool)
ensures result <==> forall i :: 0 <= i < |lst| ==> (IsEven(i) ==> IsEven(lst[i]))
{
result := true;
for i := 0 to |lst|
invariant 0 <= i <= |lst|
invariant result <==> foral... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_792.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 143 | af5c5c905017f1b5bd7bf978a74a57d48b0f5eb51f13860406a947ca860e6250 | method CountLists(lists: seq<seq<int>>) returns (count: int)
ensures count >= 0
ensures count == |lists|
{
count := |lists|;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_793.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 727 | 10f5c086e4c5e160ce460da431f6b98fb3ff5eaa64485857deff95346e517d3f | method LastPosition(arr: array<int>, elem: int) returns (pos: int)
requires arr.Length > 0
requires forall i, j :: 0 <= i < j < arr.Length ==> arr[i] <= arr[j]
ensures pos == -1 || (0 <= pos < arr.Length && arr[pos] == elem && (pos <= arr.Length - 1 || arr[pos + 1] > elem))
ensures forall i :: 0 <= ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_798.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 466 | ab14a2b593afea64f08bf91feb9d876a478b2e80506a883a0c631970507be781 | function sumTo( a:array<int>, n:int ) : int
requires a != null;
requires 0 <= n && n <= a.Length;
decreases n;
reads a;
{
if (n == 0) then 0 else sumTo(a, n-1) + a[n-1]
}
method ArraySum(a: array<int>) returns (result: int)
ensures result == sumTo(a, a.Length)
{
result := 0;
for i :=... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_799.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 190 | f66cf66268afb95c967bdc5b2f371befa34aee96e17269516e5ee781119a52c5 | method RotateLeftBits(n: bv32, d: int) returns (result: bv32)
requires 0 <= d < 32
ensures result == ((n << d) | (n >> (32 - d)))
{
result := ((n << d) | (n >> (32 - d)));
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_8.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 454 | 10765f23e327eb86fc0ef34564f243bb4ec936202c24886cbe0bf15f6375cc3a | method SquareElements(a: array<int>) returns (squared: array<int>)
ensures squared.Length == a.Length
ensures forall i :: 0 <= i < a.Length ==> squared[i] == a[i] * a[i]
{
squared := new int[a.Length];
for i := 0 to a.Length
invariant 0 <= i <= a.Length
invariant squared.Length ==... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_80.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 157 | cb190710459b1ee1968680ede5fe8b71f2d3db32b925a8fc76fa23e1b774ace0 | method TetrahedralNumber(n: int) returns (t: int)
requires n >= 0
ensures t == n * (n + 1) * (n + 2) / 6
{
t := n * (n + 1) * (n + 2) / 6;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_801.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 511 | ef000bf9b2c3af21985dd605bb84934f544bf72443cc6b73af9ba67c7ce51139 | method CountEqualNumbers(a: int, b: int, c: int) returns (count: int)
ensures count >= 0 && count <= 3
ensures (count == 3) <==> (a == b && b == c)
ensures (count == 2) <==> ((a == b && b != c) || (a != b && b == c) || (a == c && b != c))
ensures (count == 1) <==> (a != b && b != c && a != c)
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_803.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 420 | 6b5d681721bb35c8e8bf3b51476450682cacbe94c139447e87a62454bd6c09d5 | method IsPerfectSquare(n: int) returns (result: bool)
requires n >= 0
ensures result == true ==> (exists i: int :: 0 <= i <= n && i * i == n)
ensures result == false ==> (forall a: int :: 0 < a*a < n ==> a*a != n)
{
var i := 0;
while (i * i < n)
invariant 0 <= i <= n
invarian... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_804.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 453 | 475c16f79ff72738ebf8fb200b1a6603e44562a1d15ef7fb55cd494cdaad1a0b | predicate IsEven(n: int)
{
n % 2 == 0
}
method IsProductEven(a: array<int>) returns (result: bool)
ensures result <==> exists i :: 0 <= i < a.Length && IsEven(a[i])
{
result := false;
for i := 0 to a.Length
invariant 0 <= i <= a.Length
invariant result <==> exists k :: 0 <= k... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_807.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 755 | 0438d9f8ec3163caeb48a26a59067f3d50f743d7fa2a595c829992f0d425f4c4 | predicate IsOdd(x: int)
{
x % 2 != 0
}
method FindFirstOdd(a: array<int>) returns (found: bool, index: int)
requires a != null
ensures !found ==> forall i :: 0 <= i < a.Length ==> !IsOdd(a[i])
ensures found ==> 0 <= index < a.Length && IsOdd(a[index]) && forall i :: 0 <= i < index ==> !IsOdd(a[... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_808.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 343 | d53b0bd0da67acd653af635abaf01834b5df6a328f3e2224d586c81220668f71 | method ContainsK(s: seq<int>, k: int) returns (result: bool)
ensures result <==> k in s
{
result := false;
for i := 0 to |s|
invariant 0 <= i <= |s|
invariant result <==> (exists j :: 0 <= j < i && s[j] == k)
{
if s[i] == k {
result := true;
brea... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_809.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 558 | 2aa8431c2e7ab8c38df3b856a5ca74225c0cadc9a5d1ed45703a2c6a47c5128b | method IsSmaller(a: seq<int>, b: seq<int>) returns (result: bool)
requires |a| == |b|
ensures result <==> forall i :: 0 <= i < |a| ==> a[i] > b[i]
ensures !result <==> exists i :: 0 <= i < |a| && a[i] <= b[i]
{
result := true;
for i := 0 to |a|
invariant 0 <= i <= |a|
invaria... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_82.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 228 | 604bbab6e50c79e9eff68e7fd7ef6d3069a6d7676b39ca5a73aaae5d81159a04 | method SphereVolume(radius: real) returns (volume: real)
requires radius > 0.0
ensures volume == 4.0/3.0 * 3.1415926535 * radius * radius * radius
{
volume := 4.0/3.0 * 3.1415926535 * radius * radius * radius;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_85.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 221 | deb9eb4b9202784ddc5461a5296c28bd2c3d413b1c0de66850d30908a0a064bb | method SphereSurfaceArea(radius: real) returns (area: real)
requires radius > 0.0
ensures area == 4.0 * 3.14159265358979323846 * radius * radius
{
area := 4.0 * 3.14159265358979323846 * radius * radius;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_86.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 166 | 8398d7424bff82850dbb784e10bd17cdef6aeb3dd63a096f28b7a273b887ac67 | method CenteredHexagonalNumber(n: nat) returns (result: nat)
requires n >= 0
ensures result == 3 * n * (n - 1) + 1
{
result := 3 * n * (n - 1) + 1;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_89.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 113 | 046457faa6fd877976685deab2ad2b67da1ba59a9656a5523c2c72c8f8540eff | method ClosestSmaller(n: int) returns (m: int)
requires n > 0
ensures m + 1 == n
{
m := n - 1;
} |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_94.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 690 | 21499cee8bd4766e67ad410e5c150267f7397a005078a7d6ab15c5f703fd3045 | method MinSecondValueFirst(s: array<seq<int>>) returns (firstOfMinSecond: int)
requires s.Length > 0
requires forall i :: 0 <= i < s.Length ==> |s[i]| >= 2
ensures exists i :: 0 <= i < s.Length && firstOfMinSecond == s[i][0] &&
(forall j :: 0 <= j < s.Length ==> s[i][1] <= s[j][1])
{
var ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-synthesis_task_id_95.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 469 | a2237308043d2155f47157f5ac03bf3fd5fe40ef98ee002ed609ac2743261391 | method SmallestListLength(s: seq<seq<int>>) returns (v: int)
requires |s| > 0
ensures forall i :: 0 <= i < |s| ==> v <= |s[i]|
ensures exists i :: 0 <= i < |s| && v == |s[i]|
{
v := |s[0]|;
for i := 1 to |s|
invariant 0 <= i <= |s|
invariant forall k :: 0 <= k < i ==> v <= |s... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-training_tmp_tmp_n2kixni_session1_training1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,748 | bc68f03fb3d3580652fac23e069a2d17d1c73bb5ff0a0c7865d07a2d456c2a33 | /*
* 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-VMC_tmp_tmpzgqv0i1u_src_Math_Exponential.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,085 | 2ed277a3367a2828245687f8e10e180b90994f6e65ce7884d62faf1c18549ca2 | module Exponential {
ghost function {:axiom} Exp(x: real): real
lemma {:axiom} FunctionalEquation(x: real, y: real)
ensures Exp(x + y) == Exp(x) * Exp(y)
lemma {:axiom} Increasing(x: real, y: real)
requires x < y
ensures Exp(x) < Exp(y)
lemma {:axiom} EvalOne()
ensures 2.718281828 ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/Dafny-VMC_tmp_tmpzgqv0i1u_src_Math_Helper.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,818 | 97f1d2cae8436806aad0c66bad8d098e3ef893871d3cc635dcb6f6accae5b6eb | /*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
module Helper {
/************
Definitions
***********... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-workout_tmp_tmp0abkw6f8_starter_ex01.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 399 | 35e5f350730ded30c786516d21d72bda64d6a5549a9e6afaa27c547e10ef11e0 | method Max(a: int, b: int) returns (c: int)
ensures c >= a && c >= b && (c == a || c == b)
{
if (a >= b)
{
return a;
} else {
return b;
}
}
method Main()
{
print "Testing max...\n";
var max := Max(3, 4);
assert max == 4;
max := Max(-3, 4);
assert max == 4;
max := Max(-3, -4);
a... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-workout_tmp_tmp0abkw6f8_starter_ex02.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 169 | 05fd6ed6ea622cdb299bbaf4ce1fa3e7b1bd74997d804ccd71b69a1046ede253 | method Abs(x: int) returns (y: int)
requires x < 0
ensures 0 < y
ensures y == -x
{
return -x;
}
method Main()
{
var a := Abs(-3);
assert a == 3;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-workout_tmp_tmp0abkw6f8_starter_ex03.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 423 | 2549ca58da45850079d9971ce8e9e2224d9976078d24da14c8ed93962f4934b6 | method Abs(x: int) returns (y: int)
requires x == -1
ensures 0 <= y
ensures 0 <= x ==> y == x
ensures x < 0 ==> y == -x
{
return x + 2;
}
method Abs2(x: real) returns (y: real)
requires x == -0.5
ensures 0.0 <= y
ensures 0.0 <= x ==> y == x
ensures x < 0.0 ==> y == -x
{
return x + 1.0;
}
m... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-workout_tmp_tmp0abkw6f8_starter_ex09.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 488 | acd44e0aacf52ffe495f37a6169616757c4829cadfd7b6b1e55fb045df0d19c0 | 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 (b: nat)
ensures b == fib(n)
{
var i: int := 1;
if 0 <= n < 2 { return n; }
b := 1;
var c := 1;
while i < n
decreases n - i
invariant 0 < i <= n
invari... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/dafny-workout_tmp_tmp0abkw6f8_starter_ex12.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 767 | 9380df2872616d3b0819eeb400e6e1bcebc6e4dd7a6ac55a0aecb112f1de15bd |
method FindMax(a: array<int>) returns (max_idx: nat)
requires a.Length > 0
ensures 0 <= max_idx < a.Length
ensures forall j :: 0 <= j < a.Length ==> a[max_idx] >= a[j]
{
max_idx := 0;
var i: nat := 1;
while i < a.Length
decreases a.Length - i
invariant 1 <= i <= a.Length
invariant 0 <= max_idx <... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyExercises_tmp_tmpd6qyevja_Part1_Q1.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 472 | 1963104a2a56ad521ca801abcfc55bebde40d5fa3a5b54f9563caef0d39f3e96 | method addArrays(a : array<int>, b : array<int>) returns (c : array<int>)
requires a.Length == b.Length
ensures b.Length == c.Length
ensures forall i:int :: 0 <= i <c.Length ==> c[i] == a[i] + b[i]
{
c := new int[a.Length];
var j := 0;
while (j < a.Length)
invariant 0 <= j <= c.Length
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyExercises_tmp_tmpd6qyevja_QuickExercises_testing2.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 13,065 | 7f6c84291413cf07d1bad408f304dc0cc48bff6c8c76658d780db82a04aa4397 |
// predicate recSorted(s : string) decreases s
// {
// if (|s| <=1) then true else if(s[0] > s[1]) then false else recSorted(s[1..])
// }
// predicate forallSorted (s : string)
// {
// forall x,y::0<x<y<|s|==>s[x]<s[y]
// }
// lemma forallEQrec(a:string)
// ensures forallSorted(a) == recS... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyPrograms_tmp_tmp74_f9k_c_automaton.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,008 | ead968decc759e033429ad727f1fdc45c4092ded92f00b8ff36f5722198b8ff0 | /**
Consider cellular automata: a row of cells is repeatedly updated according to a rule. In this exercise I dabbled with,
each cell has the value either false or true. Each cell's next state depends only on the immediate neighbours, in the
case where the cell is at the edges of the row, the inexistent neighbours a... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyPrograms_tmp_tmp74_f9k_c_invertarray.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 949 | fa1f940ceed70e996c4bb938a102de949908289933f82d790dc6c7fed60cee8d | /**
Inverts an array of ints.
*/
method InvertArray(a: array<int>)
modifies a
ensures forall i | 0 <= i < a.Length :: a[i] == old(a[a.Length-1-i])
{
var index := 0;
while index < a.Length / 2
invariant 0 <= index <= a.Length / 2
// the elements i before position index are already switched... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyPrograms_tmp_tmp74_f9k_c_map-multiset-implementation.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,112 | b295a666254ac662ba0352657dd81116b1be730291551c4b80b69d5aa66878a7 | /**
This ADT represents a multiset.
*/
trait MyMultiset {
// internal invariant
ghost predicate Valid()
reads this
// abstract variable
ghost var theMultiset: multiset<int>
method Add(elem: int) returns (didChange: bool)
modifies this
requires Valid()
ensures Valid()
... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyPrograms_tmp_tmp74_f9k_c_prime-database.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,373 | bd319a1e132cbf1a6abdcaf480e48df33a09f41e9439ea0e97fa62b0bb41a067 | //predicate for primeness
ghost predicate prime(n: nat)
{ n > 1 && (forall nr | 1 < nr < n :: n % nr != 0) }
datatype Answer = Yes | No | Unknown
//the class containing a prime database, if a number is prime it returns Yes, if it is not No and if the number
//is not in the database it returns Unknown
class ... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_CombNK.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,570 | a6d6e7aa87e4dfd0b97d60c065e464e556a8da710f7daea60428a32d192a880a |
/*
* Formal specification and verification of a dynamic programming algorithm for calculating C(n, k).
* FEUP, MIEIC, MFES, 2020/21.
*/
// Initial recursive definition of C(n, k), based on the Pascal equality.
function comb(n: nat, k: nat): nat
requires 0 <= k <= n
{
if k == 0 || k == n then 1 else co... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_findMax.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,394 | 8bab189decdd02753f773a05b3a912b2085d857b8d44475a0978aa51fa1baf48 | /*
* Formal verification of a simple algorithm to find the maximum value in an array.
* FEUP, MIEIC, MFES, 2020/21.
*/
// Finds the maximum value in a non-empty array.
method findMax(a: array<real>) returns (max: real)
requires a.Length > 0
ensures exists k :: 0 <= k < a.Length && max == a[k]
ensures f... |
sun-wendy/DafnyBench | DafnyBench/dataset/ground_truth/DafnyProjects_tmp_tmp2acw_s4s_Graph.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,730 | 879ba665f16994c0699fdad8a46eaec9f4b824d88626081672064cb377d37d37 | // Simple directed graph with vertices of any type T.
class {:autocontracts} Graph<T(==)> {
var V: set<T>; // vertex-set
var E: set<(T, T)>; // edge-set
// Class invariant.
ghost predicate Valid() {
// edges must refer to vertices that belong to the vertex-set
// and self-loops (edge... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.