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/feup-mfes_tmp_tmp6_a1y5a5_examples_SelectionSort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,034
074dd8b560b0803e93d060689b97e3d41190a69b28027dee975df8f1e28b39ee
/* * Formal verification of the selection sort algorithm with Dafny. * FEUP, MIEIC, MFES, 2020/21. */ // Checks if array 'a' is sorted between positions 'from' (inclusive) and 'to' (exclusive). predicate isSorted(a: array<real>, from: nat, to: nat) requires 0 <= from <= to <= a.Length reads a { fora...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Exercise3_Increment_Array.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
632
0a2dff318de617317c0fab2d353899ed4f2f4066df6e760986c0718a2d6f03cc
method incrementArray(a:array<int>) requires a.Length > 0 ensures forall i :: 0 <= i < a.Length ==> a[i] == old(a[i]) + 1 modifies a { var j : int := 0; while(j < a.Length) invariant 0 <= j <= a.Length invariant forall i :: j <= i < a.Length ==> a[i] == old(a[i]) invariant forall i :: 0 <...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Exercise4_Find_Max.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
736
bedc1022300f181fdfafd31f0727b1c0cb64cba3d8bf861a3b7825eadd1b65dd
method findMax(a:array<int>) returns (pos:int, maxVal: int) requires a.Length > 0; requires forall i :: 0 <= i < a.Length ==> a[i] >= 0; ensures forall i :: 0 <= i < a.Length ==> a[i] <= maxVal; ensures exists i :: 0 <= i < a.Length && a[i] == maxVal; ensures 0 <= pos < a.Length ensures a[pos] == max...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Exercise6_Binary_Search.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
901
5a250d9c22776e27612e4651eca4071ac7d43bd64a2830fd6e97f63e84bd1317
method binarySearch(a:array<int>, val:int) returns (pos:int) requires a.Length > 0 requires forall i, j :: 0 <= i < j < a.Length ==> a[i] <= a[j] ensures 0 <= pos < a.Length ==> a[pos] == val ensures pos < 0 || pos >= a.Length ==> forall i :: 0 <= i < a.Length ==> a[i] != val { var left := 0; va...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Insertion_Sorted_Standard.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
876
4e3a46709db944d31f8181d8cfed72463b0c7452b518a7050c166cff829d156d
predicate InsertionSorted(Array: array<int>, left: int, right: int) requires 0 <= left <= right <= Array.Length reads Array { forall i,j :: left <= i < j < right ==> Array[i] <= Array[j] } method sorting(Array: array<int>) requires Array.Length > 1 ensures InsertionSort...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Insertion_Sort_Normal.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,025
32f02dfa415f3378083c2c51873899e6ad03c36402026ebc44ff6f8135215b1d
predicate sorted (a: array<int>) reads a { sortedA(a, a.Length) } predicate sortedA (a: array<int>, i: int) requires 0 <= i <= a.Length reads a { forall k :: 0 < k < i ==> a[k-1] <= a[k] } method lookForMin (a: array<int>, i: int) returns (m: int) requires 0 <= i < a.Length ensures i <= m ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Merge_Sort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,698
e519db7aa0e15a6543728acda080ae1bbef6314c05d35ceb666e04d18d32dd5d
method mergeSort(a: array<int>) modifies a { sorting(a, 0, a.Length-1); } method merging(a: array<int>, low: int, medium: int, high: int) requires 0 <= low <= medium <= high < a.Length modifies a { var x := 0; var y := 0; var z := 0; var a1: array<int> := new [medium - low + 1]; var a2: array...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Quick_Sort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,888
2d1624d3e65c4f2d94a40fbd5555ab4b7c45a34335d5f6b2b39e7be04dbee469
predicate quickSorted(Seq: seq<int>) { forall idx_1, idx_2 :: 0 <= idx_1 < idx_2 < |Seq| ==> Seq[idx_1] <= Seq[idx_2] } method threshold(thres:int,Seq:seq<int>) returns (Seq_1:seq<int>,Seq_2:seq<int>) ensures (forall x | x in Seq_1 :: x <= thres) && (forall x | x in Seq_2 :: x >= thres) ensures |Seq_1| + ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Attempts_Selection_Sort_Standard.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
916
6893defa648c1500649172b486c6a329bad5810e9b2a6215705b2213cddcd231
method selectionSorted(Array: array<int>) modifies Array ensures multiset(old(Array[..])) == multiset(Array[..]) { var idx := 0; while (idx < Array.Length) invariant 0 <= idx <= Array.Length invariant forall i,j :: 0 <= i < idx <= j < Array.Length ==> Array[i] <= Array[j] invariant forall ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Final-Project-Dafny_tmp_tmpmcywuqox_Final_Project_3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
215
8172d5abdf6a880aa2a026737348549a919975a1a714541559d3ad6193c94adb
method nonZeroReturn(x: int) returns (y: int) ensures y != 0 { if x == 0 { return x + 1; } else { return -x; } } method test() { var input := nonZeroReturn(-1); assert input != 0; }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FlexWeek_tmp_tmpc_tfdj_3_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
815
a13088c143ff34c152b0604741313d075bbc34d1ca09b12bca93319bc8026cfb
// 2. Given an array of positive and negative integers, it returns an array of the absolute value of all the integers. [-4,1,5,-2,-5]->[4,1,5,2,5] function abs(a:int):nat { if a < 0 then -a else a } method aba(a:array<int>)returns (b:array<int>) ensures a.Length == b.Length // needed for next line ensure...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FlexWeek_tmp_tmpc_tfdj_3_ex3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,142
b4bb951a4fb4133948a208985e48152d167b8bfcf332e7759c80286682486733
method Max(a:array<nat>)returns(m:int) ensures a.Length > 0 ==> forall k :: 0<=k<a.Length ==> m >= a[k]// not strong enough ensures a.Length == 0 ==> m == -1 ensures a.Length > 0 ==> m in a[..] // finally at the top // approach did not work for recusrive function { if(a.Length == 0){ return -1; }...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FlexWeek_tmp_tmpc_tfdj_3_ex4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,017
5b18c2dbfc0981ba4859646ff147795761673624e0aa91350d85682a9098425f
method join(a:array<int>,b:array<int>) returns (c:array<int>) ensures a[..] + b[..] == c[..] ensures multiset(a[..] + b[..]) == multiset(c[..]) ensures multiset(a[..]) + multiset(b[..]) == multiset(c[..]) ensures a.Length+b.Length == c.Length // Forall ensures forall i :: 0<=i<a.Length ==> c[i] == a[i] ensur...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FlexWeek_tmp_tmpc_tfdj_3_reverse.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,742
c875e4650e458b65c3ede2af9e258640b868cd3e9faa72da1d526ba913b26840
// Write an *iterative* Dafny method Reverse with signature: // method Reverse(a: array<char>) returns (b: array<char>) // which takes an input array of characters 'a' and outputs array 'b' consisting of // the elements of the input array in reverse order. The following conditions apply: // - the input ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab10_Lab10.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
13,531
d2fef05fcf590b758b32ef505c826221d1c6bb6777cb31d7964902253b340ed0
predicate IsOdd(x: int) { x % 2 == 1 } newtype Odd = n : int | IsOdd(n) witness 3 trait OddListSpec { var s: seq<Odd> var capacity: nat predicate Valid() reads this { 0 <= |s| <= this.capacity && forall i :: 0 <= i < |s| ==> IsOdd(s[i] as int) } ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab1_Lab1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,105
3492533f11549a46830e9c8e465cf34f2d664f71c956d4affe711a83b0d0b4b3
/// Types defined as part of Tasks 3, 5 and 9 // Since we have created the IsOddNat predicate we use it to define the new Odd subsort newtype Odd = n : int | IsOddNat(n) witness 1 // Since we have created the IsEvenNat predicate we use it to define the new Even subsort newtype Even = n : int | IsEvenNat(n) witn...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab2_Lab2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
11,282
7d3df4fcb1bddbb90ba78d5c99040c7d6519e79f2a9e0c2607dca01a07a9becd
/* * Task 2: Define the natural numbers as an algebraic data type * * Being an inductive data type, it's required that we have a base case constructor and an inductive one. */ datatype Nat = Zero | S(Pred: Nat) /// Task 2 // Exercise (a'): proving that the successor constructor is injective /* * It's k...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab3_Lab3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,448
5092da921c534e3e6d802de1bc2b0b4d11b5d215696ccd09ccd5c8edb339737c
/* * Task 2: Define in Dafny the conatural numbers as a coinductive datatype * * Being a coinductive data type, it's required that we have a base case constructor and an inductive one * (as is the case with inductive ones as well) */ codatatype Conat = Zero | Succ(Pred: Conat) // Exercise (a): explain w...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal-methods-in-software-engineering_tmp_tmpe7fjnek6_Labs2_gr2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,190
55c30241544eefd6280d423cfe4f346ca6e592750d1dcdab512d009149417b32
datatype Nat = Zero | Succ(Pred: Nat) /* Nat: Zero, Succ(Zero), Succ(Succ(Zero)), ... */ lemma Disc(n: Nat) ensures n.Succ? || n.Zero? { // } lemma LPred(n: Nat) ensures Succ(n).Pred == n { // } // Succ(m') > m' function add(m: Nat, n: Nat) : Nat decreases m { match m ca...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal-methods-in-software-engineering_tmp_tmpe7fjnek6_Labs2_hw1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
844
ff1c2a959b0e7c6e9d35b400012e1cae00ab0d8ffd4cd8a91ed7bf7871e0d1ee
/* HW1: Define over naturals (as an algebraic data type) the predicates odd(x) and even(x) and prove that the addition of two odd numbers is an even number. Deadline: Tuesday 12.10, 14:00 */ datatype Nat = Zero | Succ(Pred: Nat) function add(m: Nat, n: Nat) : Nat decreases m { match m case Z...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal-methods-in-software-engineering_tmp_tmpe7fjnek6_Labs4_gr2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,507
aa6b3976d35f76bc4334265120ef59ae779baa2c1b2b16db1cfdf05a75b6e3ef
/* Dafny include 2 limbaje: * un limbaj pentru specificare MSFOL (ce am discutat până acum) adnotări care să ajute în procesul de verificare * un limbaj pentru scris programe */ // Exemplu de program method SqrSum(n: int) returns (s: int) { var i,k : int; s := 0; k := 1; i ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-methods-of-software-development_tmp_tmppryvbyty_Bloque 1_Lab3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,306
233e02b45df4841bd8ea639b8d9c34ba2f85ee8e81cfde40146bd7cd848dc65a
method multipleReturns (x:int, y:int) returns (more:int, less:int) requires y > 0 ensures less < x < more method multipleReturns2 (x:int, y:int) returns (more:int, less:int) requires y > 0 ensures more + less == 2*x // TODO: Hacer en casa method multipleReturns3 (x:int, y:int) returns (more:int, less:int...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-methods-of-software-development_tmp_tmppryvbyty_Bloque 2_Lab6.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
10,727
fabda5a88d8805ab5026b6dc2d6f65b1d27e9970674cec9dd69bb8b535227853
/*predicate palindrome<T(==)> (s:seq<T>) { forall i:: 0<=i<|s| ==> s[i] == s[|s|-i-1] } */ // SUM OF A SEQUENCE OF INTEGERS function sum(v: seq<int>): int decreases v { if v==[] then 0 else if |v|==1 then v[0] else v[0]+sum(v[1..]) } /* method vector_Sum(v:seq<int>) returns (x:int) ens...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-methods-of-software-development_tmp_tmppryvbyty_Examenes_Beni_Heusel-Benedikt-Ass-1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
7,128
9756e5a767204b359c29a7545abd7516961c77a2c4593560593ce5a700afac69
// APELLIDOS: Heusel // NOMBRE: Benedikt // ESPECIALIDAD: ninguna (Erasmus) // ESTÁ PERFECTO, NO HAY NINGUN COMENTARIO MAS ABAJO // EJERCICIO 1 // Demostrar el lemma div10_Lemma por inducción en n // y luego usarlo para demostrar el lemma div10Forall_Lemma function exp (x:int,e:nat):int { if e == 0 the...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-Methods-Project_tmp_tmphh2ar2xv_BubbleSort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,138
0dc65070befda1d0fba31d838fbad2767d6b61e3c824c72741731f78aa6ad173
predicate sorted(a: array?<int>, l: int, u: int) reads a; requires a != null; { forall i, j :: 0 <= l <= i <= j <= u < a.Length ==> a[i] <= a[j] } predicate partitioned(a: array?<int>, i: int) reads a requires a != null { forall k, k' :: 0 <= k <= i < k' < a.Length ==> a[k] <= a[k'] }...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-Methods-Project_tmp_tmphh2ar2xv_Factorial.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
283
5454b72c383bf7a202bdc293b53ebb97ce957f0b8cbf03859caa0d77d1625843
method Fact(x: int) returns (y: int) requires x >= 0; { y := 1; var z := 0; while(z != x) decreases x - z; invariant 0 <= x-z; { z := z + 1; y := y * z; } } method Main() { var a := Fact(87); print a; }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-Verification-Project_tmp_tmp9gmwsmyp_strings3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,926
333ad0b893166da540dc57f9cc81aee44576488560a09a39b523945b11e59609
predicate isPrefixPred(pre:string, str:string) { (|pre| <= |str|) && pre == str[..|pre|] } predicate isNotPrefixPred(pre:string, str:string) { (|pre| > |str|) || pre != str[..|pre|] } lemma PrefixNegationLemma(pre:string, str:string) ensures isPrefixPred(pre,str) <==> !isNotPrefixPred(pre,str) ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal-verification_tmp_tmpoepcssay_strings3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,933
049f9ea13253b25e506ed2b59ac4a7c61ea28c3551cd91a72b42f07d3753d1e1
predicate isPrefixPred(pre:string, str:string) { (|pre| <= |str|) && pre == str[..|pre|] } predicate isNotPrefixPred(pre:string, str:string) { (|pre| > |str|) || pre != str[..|pre|] } lemma PrefixNegationLemma(pre:string, str:string) ensures isPrefixPred(pre,str) <==> !isNotPrefixPred(pre,str) ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-Verification_tmp_tmpuyt21wjt_Dafny_strings1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,738
8eae1cc0b0d59e6ef3f9d5586554308bc34663485c7f67a49002b33b271059d8
predicate isPrefixPredicate(pre: string, str:string) { |str| >= |pre| && pre <= str } method isPrefix(pre: string, str: string) returns (res: bool) ensures |pre| > |str| ==> !res ensures res == isPrefixPredicate(pre, str) { if |pre| > |str| {return false;} var i := 0; while i < |pre| ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal-Verification_tmp_tmpuyt21wjt_Dafny_strings3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,909
04f8c50eb862162332bc8e9b6016c414b79e3d81df2d7dd04ae35f1b6fc9c9f8
// We spent 2h each on this assignment predicate isPrefixPred(pre:string, str:string) { (|pre| <= |str|) && pre == str[..|pre|] } predicate isNotPrefixPred(pre:string, str:string) { (|pre| > |str|) || pre != str[..|pre|] } lemma PrefixNegationLemma(pre:string, str:string) ensures isPrefixPred(...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FormalMethods_tmp_tmpvda2r3_o_dafny_Invariants_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
724
9584d6d1252fb59185c77e154020d75655aea21789c677d7daf7ed315470db15
method Mult(x:nat, y:nat) returns (r:nat) ensures r == x * y { // Valores passados por parâmetros são imutáveis var m := x; var n := y; r := 0; // Soma sucessiva para multiplicar dois números. while m > 0 invariant m*n+r == x*y invariant m>=0 { r := r + n; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/FormalMethods_tmp_tmpvda2r3_o_dafny_Invariants_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
638
0117cf7c1838080e949fccea9b35c22ed5f1c35b2b44542139a77d067ea54bde
function Potencia(x:nat, y:nat):nat { if y == 0 then 1 else x * Potencia(x, y-1) } method Pot(x:nat, y:nat) returns (r:nat) ensures r == Potencia(x,y) { r := 1; var b := x; var e := y; while e > 0 invariant Potencia(b,e) * r == Potencia(x,y) { r := r * b; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,311
9af369e1f3ecfb79d2377770ca14f8cf404911093017354f16a02be8ce0b92aa
// ex3errors.dfy in Assignment 1 // verify that an array of characters is a Palindrome /* A Palindrome is a word that is the same when written forwards and when written backwards. For example, the word ”refer” is a Palindrome. The method PalVerify is supposed to verify whether a word is a Palindrome, where the ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,499
b238110e361785835ba5cbf9b112e75ac624e5fbbc5342f3a9e3b35cc6d21939
/* i) Write a verified method with signature method Forbid42(x:int, y:int) returns (z: int) that returns x/(42 − y). The method is not defined for y = 42. ii) Write a verified method with signature method Allow42(x:int, y:int) returns (z: int, err:bool) If y is n...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex6.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,378
3559590c0d6a387eeeef371abc31592cfc4c0f980f8da71d22b282a03ac2f22f
// see pdf 'ex6 & 7 documentation' for excercise question function bullspec(s:seq<nat>, u:seq<nat>): nat requires 0 <= |u| == |s| && nomultiples(u) {reccbull(s, u, 0)} function cowspec(s:seq<nat>, u:seq<nat>): nat requires 0 <= |u| == |s| && nomultiples(u) {recccow(s, u, 0)} function reccbull(s: seq<nat>, ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex7.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,654
95d1319da3f80376614f7ad19ff6dec9aef5db72d857e403b6c78e1cc1a738f7
// see pdf 'ex6 & 7 documentation' for excercise question datatype Bases = A | C | G | T //swaps two sequence indexes method Exchanger(s: seq<Bases>, x:nat, y:nat) returns (t: seq<Bases>) requires 0 < |s| && x < |s| && y < |s| ensures |t| == |s| ensures forall b:nat :: 0 <= b < |s| && b != x && b != y ==> t[b...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal_Verification_With_Dafny_tmp_tmp5j79rq48_Counter.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
697
d59236d8df66154ee05ddc1b6993680642d48ae7604dd255340ca77e22b5eb52
class Counter { var value : int ; constructor init() ensures value == 0; { value := 0 ; } method getValue() returns (x:int) ensures x == value; { x := value ; } method inc() modifies this`value requires value >= 0; ensures value == old(value) + 1; { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Formal_Verification_With_Dafny_tmp_tmp5j79rq48_LimitedStack.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,783
3c45128cc282eb8bd2bcfc8e33c1016569a670a7d48fb36d6b809b7decaf3b9f
// A LIFO queue (aka a stack) with limited capacity. class LimitedStack{ var capacity : int; // capacity, max number of elements allowed on the stack. var arr : array<int>; // contents of stack. var top : int; // The index of the top of the stack, or -1 if the stack is empty // This pr...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/fv2020-tms_tmp_tmpnp85b47l_modeling_concurrency_safety.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,040
af73a577902403068dff8219616244ad8fb6ea62456c706f46368f25ab50ca52
/* * Model of the ticket system and correctness theorem * Parts 4 and 5 in the paper */ type Process(==) = int // Philosopher datatype CState = Thinking | Hungry | Eating // Control states // A class can have state, with multiple fields, methods, a constructor, and declare functions and lemmas class Tic...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/fv2020-tms_tmp_tmpnp85b47l_simple_tm.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
19,409
821bd75c0b86fa3cc2f8ba23c99cc5a6ca4dccd2c864597f863a79ae4947b650
module ModelingTM { type ProcessId = nat type MemoryObject = nat type TimeStamp = nat class Operation { const isWrite: bool const memObject: MemoryObject } class Transaction { const ops: seq<Operation> } // Process state : transaction progress and...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/groupTheory_tmp_tmppmmxvu8h_assignment1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,787
6a4fe7b56f0c92637bf819fb77ffe12a49a93de99f4a440f944477fe0a552cab
/* Student name: Mark Valman Id: 342439593 */ /* Question/Exercise 1 of 4 */ lemma Q1_logical_equivalence_as_a_conjunction_of_two_implications__PROOF_BY_TRUTH_TABLE__in_a_comment(L: bool, R: bool) ensures (L <==> R) <==> (L ==> R) && (!L ==> !R) { /* This lemma states that logical equivalence (L <==> R) ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/groupTheory_tmp_tmppmmxvu8h_tutorial2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
983
5bba44b5d33ed7660075ef21f1dc3c634092bb164cb8abfb6a84f4ff88005e42
ghost method M1() { assert 1 != 3; // assert 1 == 2; assume 1 == 2; assert 1 == 2; } lemma IntersectionIsSubsetOfBoth(A: set, B: set, C: set) requires C == A*B ensures C <= A && C <= B {} lemma BothSetsAreSubsetsOfTheirUnion(A: set, B: set, C: set) requires C == A+B ensures A <= C && B <= C {...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/groupTheory_tmp_tmppmmxvu8h_yair_yair2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,431
4be831f1a38d71e2b9ee7ab705030c33cf9db7643a4a85ed20210ca9f304e8f0
/////////////////////////// // Lemma to prove Transitive // Got A<B, B<C. // Prove A<C /////////////////////////// predicate IsSubset(A: set, B: set) // <= { forall n :: n in A ==> n in B // same as the next line //forall n :: if n in A then n in B else true // same as "A <= B" } // lemma - משפט // subse...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Binary Search_binary_search.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,758
0f80e5df829e5778b079719c6eb727cd06e141c2ff9fa62fb1b75a2592407d7b
// Dafny verification of binary search alogirthm from binary_search.py // Inspired by: https://ece.uwaterloo.ca/~agurfink/stqam/rise4fun-Dafny/#h211 method BinarySearch(arr: array<int>, target: int) returns (index: int) requires distinct(arr) requires sorted(arr) ensures -1 <= index < arr.Length ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Largest Sum_largest_sum.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,464
d8baafb2b5602fcf2c86a450bc4d66c2a3558528d3f933d918744a37a8107ce7
// CoPilot function converted to dafny method largest_sum(nums: array<int>, k: int) returns (sum: int) requires nums.Length > 0 ensures max_sum_subarray(nums, sum, 0, nums.Length) { var max_sum := 0; var current_sum := 0; var i := 0; while (i < nums.Length) invariant 0 <=...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Sort Array_sort_array.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,964
ce9613416a2ce23670d340ad28068063e3c979c15fcb062c0927ea5790ec5888
method sortArray(arr: array<int>) returns (arr_sorted: array<int>) // Requires array length to be between 0 and 10000 requires 0 <= arr.Length < 10000 // Ensuring the arry has been sorted ensures sorted(arr_sorted, 0, arr_sorted.Length) // Ensuring that we have not modified elements but have on...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Two Sum_two_sum.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,207
17362eb26ae91f737cc94b8571a722a3c143bbcb500fda0deda8542fd2c2233f
method twoSum(nums: array<int>, target: int) returns (index1: int, index2: int) requires 2 <= nums.Length requires exists i, j :: (0 <= i < j < nums.Length && nums[i] + nums[j] == target) ensures index1 != index2 ensures 0 <= index1 < nums.Length ensures 0 <= index2 < nums.Length ensures n...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Invoker_tmp_tmpypx0gs8x_dafny_abstract-interpreter_SimpleVerifier.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
7,522
3edeb1be573a7a4b298121dc7899c2c46322acd06cc2db566b20dfc026bb5514
module Ints { const U32_BOUND: nat := 0x1_0000_0000 newtype u32 = x:int | 0 <= x < 0x1_0000_0000 newtype i32 = x: int | -0x8000_0000 <= x < 0x8000_0000 } module Lang { import opened Ints datatype Reg = R0 | R1 | R2 | R3 datatype Expr = | Const(n: u32) // overflow during addition i...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/iron-sync_tmp_tmps49o3tyz_concurrency_docs_code_ShardedStateMachine.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,725
fe3fbc3c1c6a9d59c2fea0f874adf311e8773e39ecca6b7e3c7a27be38806da4
// General form of a ShardedStateMachine // To instantiate one, fill in the 'Shard' type, the 'glue' function // provide the 'Next' predicate and the invariant 'Inv', // and then meet various proof obligations in the form of lemmas. abstract module ShardedStateMachine { /* * A ShardedStateMachine contains ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/iron-sync_tmp_tmps49o3tyz_Impl_CommitterCommitModel.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
29,563
26cd536f3425189ff9139bac91cc814455fa7a57ac785690398a4130f33b484c
// include "IOModel.i.dfy" // include "../lib/DataStructures/LinearMutableMap.i.dfy" // module CommitterCommitModel { // import opened NativeTypes // import opened Options // import opened DiskLayout // import opened InterpretationDiskOps // import opened ViewOp // import JC = JournalCache // ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/iron-sync_tmp_tmps49o3tyz_lib_Base_MapRemove.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,013
94c9cdd34eb50df53c308acb78703769ca487778a0670e1f6238b412c03f071c
// Defines a MapRemove1 operation for removing a key from a // the built-in map<K,V> type, and declares a trusted, compilable // version. // // TODO On principle, it'd be nice to remove our dependence // on compiling the built-in map<K, V> entirely, and just // replace them with our own hash tables. There are onl...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_lib_Marshalling_Math.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,899
931794ea6cc3bc0b5ac50d46d123e16c72f9692842581dcd50c5edfa0a6af036
// Based on IronFleet's math library. // I pulled out only the functions we need for the marshalling code, // and in a few cases rewrote the proof from scratch to avoid pulling in // a lot of dependencies. module Math { function {:opaque} power2(exp: nat) : nat ensures power2(exp) > 0; { if (e...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_lib_Math_div_def.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,252
fffeda606841915724cc3e2d313e5671de343e12947bead7b9baadd0dc374f4f
//- Specs/implements mathematical div and mod, not the C version. //- This may produce "surprising" results for negative values //- For example, -3 div 5 is -1 and -3 mod 5 is 2. //- Note this is consistent: -3 * -1 + 2 == 5 module Math__div_def_i { /* function mod(x:int, m:int) : int requires m > 0; ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
810
ab755bb90567622488d27c0d53a6f76bdcccbb04fb2d43fcf03b28daf04a802c
class A { var value: int method m(i: int) requires i == 6 requires value == 42 modifies this { var j: int := 17; value := 43; label L: j := 18; value := 44; label M: assert old(i) == 6; // i is local, but can't be changed anyway assert old(j) == 18; //...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
993
5d97e55183bc3306f14c43789d141937e9ed1fa1e3f9350b0d8381b985a4e2c4
class A { var value: int constructor () ensures value == 10 { value := 10; } } class B { var a: A constructor () { a := new A(); } method m() requires a.value == 11 modifies this, this.a { label L: a.value := 12; label M: a := new A(); //...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
608
2f5b022ad3fdcf072a9f750eb49176842eb5a1747cc1035ca989bd6520f1dd68
class A { var z1: array<nat> var z2: array<nat> method mm() requires z1.Length > 10 && z1[0] == 7 requires z2.Length > 10 && z2[0] == 17 modifies z2 { var a: array<nat> := z1; assert a[0] == 7; a := z2; assert a[0] == 17; assert old(a[0]) == 17; // a is local with v...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_arrays.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,977
3fe1e6d7f2248bb10113ddfc42158caf2fce669685e29059b06d29d01e019b85
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 method returnANullArray() returns (a: array?<uint32>) ensures a == null { a := null; } method returnANonNullArray() returns (a: array?<uint32>) en...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_maps.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,628
318ff0283f6c25118a4536450005e16a130fc01d8ab2766c9f39e8f1ad69f25a
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 method Test(name:string, b:bool) requires b { if b { print name, ": This is expected\n"; } else { print name, ": This is *** UNEXPECTED *** ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_sets.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,292
4e2057c591d17dbbe1d9011c07c85788a7c068932fc8d9def7763520135a92ba
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 datatype Example0 = Example0(u:uint32, b:bool) method Test0(e0:Example0) { var s := { e0 }; } datatype Example1 = Ex1a(u:uint32) | Ex1b(b:bool) met...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-1158.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
531
f7c81f30526c0ac67131e0e95032d35588f6613fac811986f606dd933f51c182
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" type Id(==) function F(s: set<Id>): int lemma Test(x: Id) { var X := {x}; var a := map i | i <= X :: F(i); var b := map[{} := F({}), X := F(X)]; assert a.Keys == b.Keys by { // spurious error reported here forall i ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-283.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,603
80ed82d2559ecf696e57f9b87a6b0ec4331502c3d961fb8fd65f3ba5e7726767
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:cs "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:js "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:go "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:java "%s" >> "%t" // RUN:...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-506.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,876
600397ec1ba5eb5bcddf4ce1644cefa9a1f6896f5a6ce34455d68922b9c366a2
// RUN: %dafny /compile:4 /compileTarget:cs "%s" > "%t" // RUN: %dafny /compile:4 /compileTarget:js "%s" >> "%t" // RUN: %dafny /compile:4 /compileTarget:go "%s" >> "%t" // RUN: %dafny /compile:4 /compileTarget:java "%s" >> "%t" // RUN: %diff "%s.expect" "%t" method Main() { var a := new int[10]; var ind...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-975.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
235
78ac66c7319d0c9e741851b5fb5877de9875fc95e63e7c5bcc6bfb0e3aee6b03
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" function f():nat ensures f() == 0 { // no problem for methods var x := 0; // no problem without this assert true by {} 0 }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/laboratory_tmp_tmps8ws6mu2_dafny-tutorial_exercise12.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
761
cb49e935f3d1f7977a238845bc301e978aa722831e216eebc30a37486de3b445
method FindMax(a: array<int>) returns (i: int) // Annotate this method with pre- and postconditions // that ensure it behaves as described. requires 0 < a.Length ensures 0 <= i < a.Length ensures forall k: int :: 0 <= k < a.Length ==> a[k] <= a[i] { // Fill in the body that calculates the...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/laboratory_tmp_tmps8ws6mu2_dafny-tutorial_exercise9.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
609
3600a4bd09e0a88107c21b7ea9916e359dd6671267d7e756f482ec70a0382c9f
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) // Do not change this postcondition { // Change the method body to instead use c as described. // You will ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/lets-prove-blocking-queue_tmp_tmptd_aws1k_dafny_prod-cons.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
4,783
1bc0b3dd8f3a57d8a71b1f2f672d8ea11791b84de4b9015560688ed54320ab25
/** * A proof in Dafny of the non blocking property of a queue. * @author Franck Cassez. * * @note: based off Modelling Concurrency in Dafny, K.R.M. Leino * @link{http://leino.science/papers/krml260.pdf} */ module ProdCons { // A type for process id that supports equality (i.e. p == q is define...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/libraries_tmp_tmp9gegwhqj_examples_MutableMap_MutableMapDafny.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
5,271
8de2f484719f446ec127dc04eb3490481de1c77eb5b0961cdffa19151939e573
/******************************************************************************* * Copyright by the contributors to the Dafny Project * SPDX-License-Identifier: MIT *******************************************************************************/ // RUN: %verify "%s" /** * Implements mutable maps in Da...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/llm-verified-eval_tmp_tmpd2deqn_i_dafny_0.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,298
526e26369d7ba4798526975c80ac16918262ca9260becd4430e80f05799d781c
function abs(x: real): real { if x < 0.0 then -x else x } method has_close_elements(numbers: seq<real>, threshold: real) returns (result: bool) ensures result <==> exists i, j :: 0 <= i < |numbers| && 0 <= j < |numbers| && i != j && abs(numbers[i] - numbers[j]) < threshold ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/llm-verified-eval_tmp_tmpd2deqn_i_dafny_160.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,054
71584ca4dac9f6590b831057eeb53836595f2e71d6efd2f19ebd20118c91c102
function pow(base: int, exponent: int): int requires exponent >= 0 decreases exponent { if exponent == 0 then 1 else if exponent % 2 == 0 then pow(base * base, exponent / 2) else base * pow(base, exponent - 1) } method do_algebra(operators: seq<char>, operands: seq<int>) returns (result: int) req...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/llm-verified-eval_tmp_tmpd2deqn_i_dafny_161.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,902
f37b4eb013e56b1ac778d16cbc18fb489ae098b13649910dabc0662617cabbef
function IsLetter(c: char): bool { (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') } function NoLetters(s: string, n: nat): bool requires n <= |s| { forall c :: 0 <= c < n ==> !IsLetter(s[c]) } function ToggleCase(c: char): char { if c >= 'a' && c <= 'z' then (c - 'a' + 'A') else...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/llm-verified-eval_tmp_tmpd2deqn_i_dafny_3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
716
b8365c4805fa9d027f9884670ae2ec1f4f00c44701e4544f3e0c14f6018d6f55
function sum(s: seq<int>, n: nat): int requires n <= |s| { if |s| == 0 || n == 0 then 0 else s[0] + sum(s[1..], n-1) } lemma sum_plus(s: seq<int>, i: nat) requires i < |s| ensures sum(s, i) + s[i] == sum(s, i+1) { } method below_zero(ops: seq<int>) returns (result: b...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/llm-verified-eval_tmp_tmpd2deqn_i_dafny_5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
929
03d3f0438e9d24b3203c11ec847196371243eb89c8720da95579144886774a78
method intersperse(numbers: seq<int>, delimiter: int) returns (interspersed: seq<int>) ensures |interspersed| == if |numbers| > 0 then 2 * |numbers| - 1 else 0 ensures forall i :: 0 <= i < |interspersed| ==> i % 2 == 0 ==> interspersed[i] == numbers[i / 2] ensures forall i :: 0 <= i < |...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/llm-verified-eval_tmp_tmpd2deqn_i_dafny_9.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
985
d59b6b47d3704edd4b52f596e3be195093624ca6cd38e9bdbaec83e3e1a52008
function isMax(m: int, numbers: seq<int>): bool { m in numbers && forall i :: 0 <= i < |numbers| ==> numbers[i] <= m } method max(numbers: seq<int>) returns (result: int) requires numbers != [] ensures isMax(result, numbers) { result := numbers[0]; for i := 1 to |numbers| invariant is...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/M2_tmp_tmp2laaavvl_Software Verification_Exercices_Exo4-CountAndReturn.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
208
668fce6e62cecfbefe63a6ecdcc2ceb10c5d20a9d5f0f2aa06095d7e2e8008b0
method CountToAndReturnN(n: int) returns (r: int) requires n >= 0 ensures r == n { var i := 0; while i < n invariant 0 <= i <= n { i := i + 1; } r := i; }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/M2_tmp_tmp2laaavvl_Software Verification_Exercices_Exo7-ComputeSum.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
311
e984232635fe014fb0445fe5c677aac231a384f817f66b8103c393d280f31ee2
function Sum(n:nat):nat { if n==0 then 0 else n + Sum(n-1) } method ComputeSum(n:nat) returns (s:nat) ensures s ==Sum(n) { s := 0; var i := 0; while i< n invariant 0 <= i <= n invariant s == Sum(i) { s := s + i + 1; i := i+1; } }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/M2_tmp_tmp2laaavvl_Software Verification_Exercices_Exo9-Carre.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
232
c7cee0201769db7c1faf2290c3592581014f910bc44a59ee1a330008a4155e4d
method Carre(a: nat) returns (c: nat) ensures c == a*a { var i := 0; c := 0; while i != a invariant 0 <= i <= a invariant c == i*i decreases a - i { c := c + 2*i +1; i := i + 1; } }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/metodosFormais_tmp_tmp4q2kmya4_T1-MetodosFormais_examples_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
533
e66f50730cb8704134466e720f1d1c5e9b0c87cc9a34c5801fc9ffb18f3d2655
/* Buscar r = 0 enquanto(r<|a|){ se (a[r] == x) retorne r r = r+1 } retorne -1 */ method buscar(a:array<int>, x:int) returns (r:int) ensures r < 0 ==> forall i :: 0 <= i <a.Length ==> a[i] != x ensures 0 <= r < a.Length ==> a[r] == x { r := 0; while r < a.Length decreases a.Length -...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/metodosFormais_tmp_tmp4q2kmya4_T1-MetodosFormais_examples_somatoriov2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
369
c1ccc23edeb971cb5f8dd7e08204d01135d5cb21571f36f1939807b5f5619de2
function somaAteAberto(a:array<nat>, i:nat):nat requires i <= a.Length reads a { if i ==0 then 0 else a[i-1] + somaAteAberto(a,i-1) } method somatorio(a:array<nat>) returns (s:nat) ensures s == somaAteAberto(a, a.Length) { s := 0; for i:= 0 to a.Length invariant s == somaAteAberto...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpbez22nnn_Aula_2_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
257
fd78e3837110b2aa1b312875a990d5466783640b34040f7cf26a023e4491c899
method Mult(x:nat, y:nat) returns (r: nat) ensures r == x * y { var m := x; var n := y; r:=0; while m > 0 invariant m >= 0 invariant m*n+r == x*y { r := r + n; m := m - 1; } return r; }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpbez22nnn_Aula_2_ex2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
376
e113e45cdb259d1cc19c17a15e435fb4618b69716083353ae23b2b45a91fdbf5
function Potencia(x: nat, y: nat): nat { if y == 0 then 1 else x * Potencia(x, y-1) } method Pot(x: nat, y: nat) returns (r: nat) ensures r == Potencia(x,y) { var b := x; var e := y; r := 1; while e > 0 invariant Potencia(b, e) * r == Potencia(x,y) { r := ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpbez22nnn_Aula_4_ex1.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
301
4a6256f738d0e4c716a94a4b741cff9bbaf1c2655b341b34bbb8f725e0456d2d
predicate Par(n:int) { n % 2 == 0 } method FazAlgo (a:int, b:int) returns (x:int, y:int) requires a >= b && Par (a-b) { x := a; y := b; while x != y invariant x >= y invariant Par(x-y) decreases x-y { x := x - 1; y := y + 1; } }
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpbez22nnn_Aula_4_ex3.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
478
8a482ccad34c652f9f3a888207669be7966f3549f4c93b04cba34468fe92eb6c
function Fib(n:nat):nat { if n < 2 then n else Fib(n-2) + Fib(n-1) } method ComputeFib(n:nat) returns (x:nat) ensures x == Fib(n) { var i := 0; x := 0; var y := 1; while i < n decreases n - i invariant 0 <= i <= n invariant x == Fib(i) invariant y == Fib(i+1...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpql2hwcsh_Arrays_explicacao.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,467
81a91fbf29edfe2f4bacf4e0e257f6bd2d724e35ca9507b7e2da98c35af0c3ea
// Array<T> = visualização de um array // Uma busca ordenada em um array // Buscar: Array<Z>xZ -> Z (Z é inteiro) // Pré: True (pré-condição é sempre verdadeira) // Pos: R < 0 => Para todo i pertencente aos naturais(0 <= i < A.length => A[i] != X) e // 0 <= R < A.length => A[R] = x // // método em qualquer ling...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpql2hwcsh_Arrays_somatorioArray.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,084
2cd98cee86d46391ad9a37a9973ff6f03775da210c3d35ecf055608df23b0f91
// Deve ser criado uma função explicando o que é um somatório // Somatorio: Array<N> -> N // Pre: True // Pos: Somatorio(A) = somatório de i = 0 até |A|-1 os valores das posições do array pelo i // // function é uma fórmula matemática, ele não possui variaveis globais // Soma: Array<N>xN -> N // { Soma(A,0) = ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_fatorial2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
520
c5917649f26d9f1f4e6cd7194f63535e9fd4b80ff2d7a6fb1f3ebb72a3979305
function Fat(n:nat):nat { if n == 0 then 1 else n*Fat(n-1) } method Fatorial(n:nat) returns (f:nat) ensures f == Fat(n) { f := 1; var i := 1; while i <= n decreases n-i //variante invariant 1 <= i <= n+1 //invariante invariant f == Fat(i-1) //invariante { ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_fibonacci.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
938
ff86114c026cf051ee83121b98b8f478eb18c7d7a2c9f759f25158185d695bb4
// Provando fibonacci function Fib(n:nat):nat { if n < 2 then n else Fib(n-2) + Fib(n-1) } method ComputeFib(n:nat) returns (x:nat) ensures x == Fib(n) { var i := 0; x := 0; var y := 1; while i < n decreases n-i invariant 0 <= i <= n invariant x == Fib(i) i...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_multiplicador.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,373
925f33a2dc117db568bb2dfa9e57aae94036e3cc313f196e85465e8cec99f1ad
// Exemplo de invariantes // Invariante significa que o valor não muda desde a pré-condição até a pós-condição method Mult(x:nat, y:nat) returns (r:nat) ensures r == x * y { // parâmetros de entrada são imutáveis, por isso // é preciso a atribuir a variáveis locais para usar em blocos de códigos para mu...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_potencia.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,442
70c9450ca4ed800937c27691a2ae147ed6f1a8d0d074ede9e456d7fb53b93f1a
// Potência // deve ser especificado a potência, porque ele não existe n dafny // Função recursiva da potência function Potencia(x:nat, y:nat):nat { if y == 0 then 1 else x * Potencia(x,y-1) } // Quero agora implementar como uma função não recursiva method Pot(x:nat, y:nat) returns (r:nat) ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFDS_tmp_tmpvvr5y1t9_Assignments_Ass-1-2020-21-Sol-eGela.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
3,649
0f68fbaea6121e81d4d1d3f7af503f310c025691971b88652e3e391c83ff8221
// Ejercicio 1: Demostrar por inducci�n el siguiente lema: lemma EcCuadDiv2_Lemma (x:int) requires x >= 1 ensures (x*x + x) % 2 == 0 { if x != 1 { EcCuadDiv2_Lemma(x-1); assert x*x+x == ((x-1)*(x-1) + (x-1)) + 2*x; } } // Ejercicio 2: Demostrar por inducci�n el siguient...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFES_2021_tmp_tmpuljn8zd9_Exams_Special_Exam_03_2020_4_CatalanNumbers.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
672
e144d9de0a0d64c2116abd986e53c89da39d99b25b36765ed0eec23d92c9bfae
function C(n: nat): nat decreases n { if n == 0 then 1 else (4 * n - 2) * C(n-1) / (n + 1) } method calcC(n: nat) returns (res: nat) ensures res == C(n) { var i := 0; res := 1; assert res == C(i) && 0 <= i <= n; while i < n decreases n - i //a - loop variant ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFES_2021_tmp_tmpuljn8zd9_FCUL_Exercises_10_find.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
429
431f258b52c96e01838aec134b1a95a81d416a1ae98d3798ba226706e9391e21
method find(a: array<int>, key: int) returns(index: int) requires a.Length > 0; ensures 0 <= index <= a.Length; ensures index < a.Length ==> a[index] == key; { index := 0; while index < a.Length && a[index] != key decreases a.Length - index invariant 0 <= index <= a.Length ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFES_2021_tmp_tmpuljn8zd9_FCUL_Exercises_8_sum.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
339
7fffc0ca6f75a6ecdd6ca4f93def4794aa6548f0a35e638e3cbdf313c9deadec
function calcSum(n: nat) : nat { n * (n - 1) / 2 } method sum(n: nat) returns(s: nat) ensures s == calcSum(n + 1) { s := 0; var i := 0; while i < n decreases n - i invariant 0 <= i <= n invariant s == calcSum(i + 1) { i := i + 1; s :=...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFES_2021_tmp_tmpuljn8zd9_PracticalClasses_TP3_2_Insertion_Sort.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,229
4bd6e53cba8e76733973f4159d77a1c438b94be59997793205b043cad82bcc0a
// Sorts array 'a' using the insertion sort algorithm. method insertionSort(a: array<int>) modifies a ensures isSorted(a, 0, a.Length) ensures multiset(a[..]) == multiset(old(a[..])) { var i := 0; while i < a.Length decreases a.Length - i invariant 0 <= i <= a.Length ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFES_2021_tmp_tmpuljn8zd9_TheoreticalClasses_Power.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,971
306c56561bef814aadd3dc2afe7c1b20f955584f256de8029de5ea79a01f2ab4
/* * Formal verification of O(n) and O(log n) algorithms to calculate the natural * power of a real number (x^n), illustrating the usage of lemmas. * FEUP, MIEIC, MFES, 2020/21. */ // Initial specification/definition of x^n, recursive, functional style, // with time and space complexity O(n). function power(...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFS_tmp_tmpmmnu354t_Praticas_TP9_Power.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
2,278
59ff0ed82fcf4c01d8e8c6dae2592f3c56b8528201f353f82be8655a1842923c
/* * Formal verification of O(n) and O(log n) algorithms to calculate the natural * power of a real number (x^n), illustrating the usage of lemmas. * FEUP, M.EIC, MFS, 2021/22. */ // Initial specification/definition of x^n, recursive, functional style, // with time and space complexity O(n). function power(x...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MFS_tmp_tmpmmnu354t_Testes anteriores_T2_ex5_2020_2.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,041
0497747bb4884f54b50fdae469d07b18dbd67b1db708765f5894c52375cab2b1
method leq(a: array<int>, b: array<int>) returns (result: bool) ensures result <==> (a.Length <= b.Length && a[..] == b[..a.Length]) || (exists k :: 0 <= k < a.Length && k < b.Length && a[..k] == b[..k] && a[k] < b[k]) { var i := 0; while i < a.Length && i < b.Length decreases a.Length - i ...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MIEIC_mfes_tmp_tmpq3ho7nve_exams_appeal_20_p4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
376
0076c3834377bda264e6d9e58209ed53e383e96cc68dbf1e24df637f98029582
function F(n: nat): nat { if n <= 2 then n else F(n-1) + F(n-3)} method calcF(n: nat) returns (res: nat) ensures res == F(n) { var a, b, c := 0, 1, 2; var i := 0; while i < n decreases n-i invariant 0 <= i <= n invariant a == F(i) && b == F(i+1) && c == F(i+2) { a, b, c := b, c...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MIEIC_mfes_tmp_tmpq3ho7nve_exams_mt2_19_p4.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
445
9ed61e1fb59442a4b1e0aca30efd3a7e8969fbe70a84ee759a9415f6610c49ef
function R(n: nat): nat { if n == 0 then 0 else if R(n-1) > n then R(n-1) - n else R(n-1) + n } method calcR(n: nat) returns (r: nat) ensures r == R(n) { r := 0; var i := 0; while i < n decreases n-i invariant 0 <= i <= n invariant r == R(i) { i :=...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MIEIC_mfes_tmp_tmpq3ho7nve_exams_mt2_19_p5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,500
1a9153ad4830034c5ab0ec7834ee8ac9565497b900cfaf450f9b566ce2aacb34
type T = int // example // Partitions a nonempty array 'a', by reordering the elements in the array, // so that elements smaller than a chosen pivot are placed to the left of the // pivot, and values greater or equal than the pivot are placed to the right of // the pivot. Returns the pivot position. method par...
sun-wendy/DafnyBench
DafnyBench/dataset/ground_truth/MIEIC_mfes_tmp_tmpq3ho7nve_exams_special_20_p5.dfy
Apache-2.0
67
main
0cd28feed9cd0179b07fdb9d002f8c39063658e4
2024-12-12T07:08:20Z
1,640
b5bd001396797eaaa4bcbb071ba52b3c3f25d5a40b8b8db35964bcde10d91962
type T = int // for demo purposes, but could be another type predicate sorted(a: array<T>, n: nat) requires n <= a.Length reads a { forall i,j :: 0 <= i < j < n ==> a[i] <= a[j] } // Use binary search to find an appropriate position to insert a value 'x' // in a sorted array 'a', so that it remai...