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/hints_removed/FlexWeek_tmp_tmpc_tfdj_3_reverse_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,517 | dac3f670b9a4437f76ad6f4661eb14b0c987afd69ee295b3fe3743387ed4b063 | // 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/hints_removed/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab10_Lab10_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 12,828 | 01a9374e611e4e94490a4249148af817f8c45db760d4b7bd54bb14677c1d650e | 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/hints_removed/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab1_Lab1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,019 | 27618949fc4fcc66f297bfa8b5c6fd03a5da493e252d624ceb4a8ecab562cadc | /// 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/hints_removed/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab2_Lab2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 10,465 | a67ae43b49d6f591f107273f4b8d3de9ccbd1726c03d59438e7345234843ca25 | /*
* 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/hints_removed/FMSE-2022-2023_tmp_tmp6_x_ba46_Lab3_Lab3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,386 | dfd38c13a1a2e08c90eb0b8099c2c1e6c702af536d5e235655367e95c242ca94 | /*
* 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/hints_removed/formal-methods-in-software-engineering_tmp_tmpe7fjnek6_Labs2_gr2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,029 | 8167847341c0c7447324d8fa2f0e77764831fba0880a32bda41ff6ae2901e67c | 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
{
match m
case Zero => n
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/formal-methods-in-software-engineering_tmp_tmpe7fjnek6_Labs2_hw1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 805 | 8957118ebfb9b168ab2edb2708bde6eaaa38422de679cba236fdd9db87e8e6f8 | /*
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
{
match m
case Zero => n
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/formal-methods-in-software-engineering_tmp_tmpe7fjnek6_Labs4_gr2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,776 | d37cb3b050057b4a7b21d8b952cceddb6f7537f613f904166cbe7eb14da56c5e | /*
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/hints_removed/Formal-methods-of-software-development_tmp_tmppryvbyty_Bloque 1_Lab3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,813 | 6739985b48b1b12e3255139854b7cf35e511a647234d269c3f12450cc8d735f5 |
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/hints_removed/Formal-methods-of-software-development_tmp_tmppryvbyty_Bloque 2_Lab6_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,189 | 8bc12a8c809ecd3c48184bf0aa68252650d4a37662fb026e5d3e6bf94ac71fd5 | /*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
{
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)
ensures x == sum... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Formal-methods-of-software-development_tmp_tmppryvbyty_Examenes_Beni_Heusel-Benedikt-Ass-1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,674 | 9f69677edd65f1f0e930aa03aee790f8c2b3aacf7a0702c880857a35024f5c00 | // 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/hints_removed/Formal-Methods-Project_tmp_tmphh2ar2xv_BubbleSort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 875 | 54bd03a74dd6bd4a98991e72d8238afacf078850b10bdadd9cfbbea378f5d6cf | 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/hints_removed/Formal-Methods-Project_tmp_tmphh2ar2xv_Factorial_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 234 | 5bc3a9625b2b18daec451dab8a51c88fec680c8a95b57c431741624bc1473945 |
method Fact(x: int) returns (y: int)
requires x >= 0;
{
y := 1;
var z := 0;
while(z != x)
{
z := z + 1;
y := y * z;
}
}
method Main() {
var a := Fact(87);
print a;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Formal-Verification-Project_tmp_tmp9gmwsmyp_strings3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,096 | ff12cade7abed887fda0dbf78741f710a3dc4dd2d8633bdfb27058c142b8e7d4 | 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/hints_removed/formal-verification_tmp_tmpoepcssay_strings3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,326 | b80e76bf181a994830cb5137e25b730a3446531e82f969f19aec9c5eead74cd3 | 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/hints_removed/Formal-Verification_tmp_tmpuyt21wjt_Dafny_strings1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,208 | 61a9b4a9a7aff07cbdae0221bc6c0e5789c01003150425ad56edab12a62071b6 | 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/hints_removed/Formal-Verification_tmp_tmpuyt21wjt_Dafny_strings3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,334 | 8922089b1a425b4972147875b45d37d28641e3e49071c29fff5c01f84b853b5e | // 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/hints_removed/FormalMethods_tmp_tmpvda2r3_o_dafny_Invariants_ex1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 676 | b40612cc3f48adc25fb1ae8b0e0521c564c8cc2db760854f3aa9269f422afdc2 | 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
{
r := r + n;
m := m - 1;
}
return r; // NOT(m>0) ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/FormalMethods_tmp_tmpvda2r3_o_dafny_Invariants_ex2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 588 | 62c23a23f9acf6bf8f0b57c1c25e870067d09d987471c0144b1ddb3d5d4d2268 | 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
{
r := r * b;
e := e - 1;
}
return r;
}
/*
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,004 | 982299e61b4f2eaa2f99ca1e8711e71a009aeb8629e3e2a801aa98942f7b0614 | // 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/hints_removed/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,267 | 4839b53ded6213adf363cfea52b1887d16bc05629fe81b285294a4fe3b8d812f | /*
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/hints_removed/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex6_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,786 | ef0007abdfec11ac5f81adc4a354c9cb49623259a1085f08ff5a3b6bb7c14f74 | // 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/hints_removed/formal_verication_dafny_tmp_tmpwgl2qz28_Challenges_ex7_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,613 | 20a971dc4252c4a21806d1f6b92796fad7ec3b330ae9829af365d61b6690a9d1 | // 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/hints_removed/Formal_Verification_With_Dafny_tmp_tmp5j79rq48_Counter_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 673 | 3792b361a1b2c08f48bd864f84d8abef2d829a8296712f3e01d4d5aaf6681738 | 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/hints_removed/Formal_Verification_With_Dafny_tmp_tmp5j79rq48_LimitedStack_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,098 | e2d96de669b3dc584082857c3c2ea7da4032ed61344d38053ac8d47ac65a50f3 | // 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/hints_removed/fv2020-tms_tmp_tmpnp85b47l_modeling_concurrency_safety_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,813 | 1226effe2171cbcf9ae74db6f37a88bfb8665663146dffe285f249c3187e3e52 | /*
* 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/hints_removed/fv2020-tms_tmp_tmpnp85b47l_simple_tm_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 19,050 | 9e3a763011e404a68d730ee553d725e6e33f984ded967bf923e674f77de0993c | 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/hints_removed/groupTheory_tmp_tmppmmxvu8h_assignment1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,401 | b3cb85802679e109ae2a46789f77c9c3b09a25eac0a423b43ce3e7355ffbf67d | /*
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/hints_removed/groupTheory_tmp_tmppmmxvu8h_tutorial2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 732 | 140091fec03cb636af179cee816cabd9c46c003dd52eb263ff9cff2ba25c0f44 | ghost method M1()
{
// assert 1 == 2;
assume 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
{}
const s0 := {3,8,1}
//var s2... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/groupTheory_tmp_tmppmmxvu8h_yair_yair2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,309 | ddec64ce6839d7b402fd5ccf201b266fa3fbf925dc7b1c618284d10ef8a4d44e |
///////////////////////////
// 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/hints_removed/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Binary Search_binary_search_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,580 | ddb835334eb4c1ed43ce6ee8af3f453ed14c5fecf6493f1693c3d3a57b622284 | // 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/hints_removed/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Largest Sum_largest_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,192 | decb5fe91cdc771b7cbc710958e7ace7f8b8a5615b76bee7cb8e5c0e8921efdc | // 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)
{
current... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Sort Array_sort_array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,388 | 5c114d4398c35545c1063e94dc6b76a7f457be2e229237b0550d67a403a1bc58 | 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/hints_removed/HATRA-2022-Paper_tmp_tmp5texxy8l_copilot_verification_Two Sum_two_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 653 | 0d5efb78236b2f098780c79ef5fb8b3d4a47e8ee58377efa893540173f9ada00 | 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/hints_removed/Invoker_tmp_tmpypx0gs8x_dafny_abstract-interpreter_SimpleVerifier_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 7,125 | bfc41b96e3f840883d63ab9537501bf981afe627682e463bbcdc908dd507bd93 | 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/hints_removed/iron-sync_tmp_tmps49o3tyz_lib_Base_MapRemove_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 976 | a365fd5c0e6a54f097fe8af9094814806b2604115a44e4422aaeccfc8bdb5567 | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_lib_Marshalling_Math_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,328 | 81f27f497f5facd8722792c3e63901ad3ebff8a3057b1a6e6ab6fc456fcfdfe6 | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_lib_Math_div_def_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,015 | 09e1dcbee81fc97500bd683403512e494692a46c041e79205cf94dcdb331ec76 | //- 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 514 | bed4e86e2841e0a689618cef2828b2829559ce4fb016f7e52d011edbea14ba5b | 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 372 | b4ecacb879bc217129f9d49d0b33d0932ebba37d4602f245eb7b24d10198d0b0 | 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;
a := z2;
z2[0] := 27;
// z2; in pre-state z2[0] == 17
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 498 | 0b549f66ce89da9a840662d1b6acf969d2681ba8a338b8f1aa955ea369d25a04 | 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:
// value is this.value; 'this' is the same
// same reference in current and pre state ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_arrays_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,953 | 418a8a5ef8a7e42906dcc6f779780ad9dbc0931a6cb07383c9b2b4e04feb0262 | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_maps_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,429 | 9f41f9ad52707d4e7a54709549fd7f6b2dde8d819efa0d54aca31018869ba9af | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_sets_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,216 | 0e2c29fe16a3015b4b8c491681b63eaaaa1f9656e46b2e4507b0b6975d7e9172 | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-1158_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 466 | 929ff0f3e8068d5b4e83b0a7b3577338ef5d06766f9569aeb93368772fffebe2 | // 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)];
forall i
ensures i in a.Keys <==> i in b.Keys
{
calc {
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-283_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,422 | dbb3a6040612c890dd712bce1bbb2b9c9360ade76436a43eb5758ced210dc7ef | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-506_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,479 | e69837e7489e9ad11104fcc298fb08dd5b83b487c232feffb83fc424a6b5e916 | // 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/hints_removed/ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-975_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 214 | b936cbb41f7f650666387f3cfb11c3fe45906a1352eccea6afd55c54e0330a84 | // 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
0
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/laboratory_tmp_tmps8ws6mu2_dafny-tutorial_exercise12_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 560 | bb9026ee60f8c34bd9d0f90b65711d145a8854f1a15584f651fab847657769d4 | 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/hints_removed/laboratory_tmp_tmps8ws6mu2_dafny-tutorial_exercise9_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 512 | ccd98088af513b03e8ae42dc8ef523a9a28f742d8dae8d84e0b91c24fbf1ed23 | 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/hints_removed/lets-prove-blocking-queue_tmp_tmptd_aws1k_dafny_prod-cons_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,609 | 9cb14d21f754315b7c037cae1a2dc710f34f44cbdf81772baef3cf4675996ea1 | /**
* 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/hints_removed/libraries_tmp_tmp9gegwhqj_examples_MutableMap_MutableMapDafny_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,791 | 1da4d1c9f666b63fa623ef42451c4d648ff6889a23baf7294f628b939cf2640d | /*******************************************************************************
* 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/hints_removed/llm-verified-eval_tmp_tmpd2deqn_i_dafny_0_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,083 | 3a623fea8b9837e64a6b0c22759e00711025c867b12b4a3b826a5f4e9ab40dfe | 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/hints_removed/llm-verified-eval_tmp_tmpd2deqn_i_dafny_160_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 964 | 888c42eb53602b90c4b6116fb45cc99e18a31be0fea6874e7ef82c70176b5e26 | function pow(base: int, exponent: int): int
requires exponent >= 0
{
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)
requires operators != [] ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/llm-verified-eval_tmp_tmpd2deqn_i_dafny_161_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,603 | e6d097848cb103994bd91687473e2d4a10432d6ca399bf1cc12b3dd008481ba0 | 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/hints_removed/llm-verified-eval_tmp_tmpd2deqn_i_dafny_3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 616 | 35a87608126554f1399f88d4d094d3794d78119179df5e435644417b7381ac2d | 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/hints_removed/llm-verified-eval_tmp_tmpd2deqn_i_dafny_5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 718 | 4b66951a704e392dd95da40dca89c1a4cb8cbced885304a7e956d44a3a189c45 | 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/hints_removed/llm-verified-eval_tmp_tmpd2deqn_i_dafny_9_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 802 | 37b42b57d115c19110e4b40028d01a1d5871f3776d45b5844c4c9d646270c942 | 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|
{
i... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/M2_tmp_tmp2laaavvl_Software Verification_Exercices_Exo4-CountAndReturn_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 181 | 927245c46d7c8409d244301751f9d5dd552ed226403268309c101f399f7c0d65 | method CountToAndReturnN(n: int) returns (r: int)
requires n >= 0
ensures r == n
{
var i := 0;
while i < n
{
i := i + 1;
}
r := i;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/M2_tmp_tmp2laaavvl_Software Verification_Exercices_Exo7-ComputeSum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 253 | 64fbc0abbfe285ad75e1ff4106203fea8934890c62ee44b7318e27407fcd8112 | 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
{
s := s + i + 1;
i := i+1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/M2_tmp_tmp2laaavvl_Software Verification_Exercices_Exo9-Carre_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 160 | 131470c8f72709080a3cdb37fefab07c42f12ae1a7af1081e2cb86a742017d93 | method Carre(a: nat) returns (c: nat)
ensures c == a*a
{
var i := 0;
c := 0;
while i != a
{
c := c + 2*i +1;
i := i + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/metodosFormais_tmp_tmp4q2kmya4_T1-MetodosFormais_examples_ex1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 419 | dc0898a057cc0cfbe5b9de2a62092365a4a7d03c73647d7a675f42935b30f663 | /*
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
{
if a[r] =... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/metodosFormais_tmp_tmp4q2kmya4_T1-MetodosFormais_examples_somatoriov2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 330 | 3145b47400629190d730a6c5b6c8e1a25e4cbd801808fee5c3e29be4e59f0316 | 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
{
s := s + a[i];
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpbez22nnn_Aula_2_ex1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 207 | 0339318bb3d882a2d42dae84ffef8d9b8710a9b8ae473523ffd02adab68865f2 | method Mult(x:nat, y:nat) returns (r: nat)
ensures r == x * y
{
var m := x;
var n := y;
r:=0;
while m > 0
{
r := r + n;
m := m - 1;
}
return r;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpbez22nnn_Aula_2_ex2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 325 | ad330a26478cd00a46d6bdb9b680054ef09db5ce833a782bd2eff545c54efaaa | 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
{
r := b * r;
e := e - 1;
}
return r;... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpbez22nnn_Aula_4_ex1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 236 | 8bf612b61aa575b1eaebb9e2fc02c1e535c3a17d7970830e496df43ed0fdd8cf | 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
{
x := x - 1;
y := y + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpbez22nnn_Aula_4_ex3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 354 | 68f31a42282eb6e3bfb540669efec6db73b63db3a07437b86b56c78502fa8b26 | 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
{
x, y := y, x + y;
i := i + 1;
}
}
method Teste()
{
var n := 3;... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpql2hwcsh_Arrays_explicacao_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,230 | 2c682512b98652e39ca22e6d4ec2b9f41e2f842fe3ade27fa88512e4655b978e | // 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/hints_removed/Metodos_Formais_tmp_tmpql2hwcsh_Arrays_somatorioArray_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,046 | c3f44c756699f14b7a1044168795b9f33ea9edd60dc1bb96571a8f077a8c11c0 | // 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/hints_removed/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_fatorial2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 394 | 301e1d1694b4eef8032635fc0dacfe7583d87f9f9758ea7c8150d247a5fa92a6 | 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
{
f := f * i;
i := i + 1;
}
return f;
}
// i | n | variante
// 1 | 3 | 2
// 2 | 3 | 1
// 3 | 3 | 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_fibonacci_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 836 | 4495ba96dd9f1fe8f1133cf318a89d929269c9aee9a8e87f24ea6d1181e420a2 | // 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
{
x, y := y, x + y; //multiplas atribuições
i := i + 1;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_multiplicador_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,323 | cb56d0855618b8a716454ec4c9f97e81d8cb967f88c839878a0215dec8a9a92d | // 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/hints_removed/Metodos_Formais_tmp_tmpql2hwcsh_Invariantes_potencia_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,392 | 2b198cadff5d051433f4a093c3dd54890b7365d723396c4bb0502e5541d661e6 | // 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/hints_removed/MFDS_tmp_tmpvvr5y1t9_Assignments_Ass-1-2020-21-Sol-eGela_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,992 | 195e9caca62b02aa7160b4992e99a56268f96900cd9bac29582fe2d093105f0c | // 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);
}
}
// Ejercicio 2: Demostrar por inducci�n el siguiente lema
// Indicaciones: (1) Puedes llamar al lema del... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MFES_2021_tmp_tmpuljn8zd9_Exams_Special_Exam_03_2020_4_CatalanNumbers_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 329 | ffea4ae8991fe793406c2c2ecb1b0ad30dcce6581eaee037bd0c5b05f2ae4815 | function C(n: nat): nat
{
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;
while i < n
{
ghost var v0 := n - i;
i := i + 1;
res := (4 * i - 2) * res / (i + 1);
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MFES_2021_tmp_tmpuljn8zd9_FCUL_Exercises_10_find_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 288 | 2372203a8d06defa1b712aeca7047453c59ce2398e596cb9e5816ff83b0f69fe | 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
{
index := index + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MFES_2021_tmp_tmpuljn8zd9_FCUL_Exercises_8_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 244 | 1f736c39ccc5392c09fe8f2ea0d600cd978d01a2feda335e45a1827e6b2d700d | 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
{
i := i + 1;
s := s + i;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MFES_2021_tmp_tmpuljn8zd9_PracticalClasses_TP3_2_Insertion_Sort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 785 | 946ed8b17353b6acd1b9e208f41a2427c2f39afeada13ec09b966a4683410693 | // 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
{
var j := i;
while j > 0 && a[j-1] > a[j]
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MFES_2021_tmp_tmpuljn8zd9_TheoreticalClasses_Power_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,820 | b1fdc15071305f5149b370710757cb65536e388e281f52116d50ef16d767c08e | /*
* 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/hints_removed/MFS_tmp_tmpmmnu354t_Praticas_TP9_Power_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,147 | a21f3744a4a8735a053cd7174aa6cdd79c129e8982da102d3643d1c6f148847a | /*
* 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/hints_removed/MFS_tmp_tmpmmnu354t_Testes anteriores_T2_ex5_2020_2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 913 | d73b5ab25d744319fa8646e233f8bfc2ccc7c898e9d3361c795dcc6550eb676d | 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
{
if a[i] < b[i] { r... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MIEIC_mfes_tmp_tmpq3ho7nve_exams_appeal_20_p4_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 275 | 3c22d62ebe7333c86cdc3ec8ca0b72c17a56f47d5dc3e3f5bceca46868071e1f | 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
{
a, b, c := b, c, a + c;
i := i + 1;
}
res := a;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MIEIC_mfes_tmp_tmpq3ho7nve_exams_mt2_19_p4_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 362 | 63a3d0be401370b288f9b27d63b274ddb02632b45ad31096f6a77279b44025c7 | 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
{
i := i + 1;
if r > i {
r := r - i;
}
else {
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MIEIC_mfes_tmp_tmpq3ho7nve_exams_mt2_19_p5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,235 | 10fc63a676f4e282adda3049b0d35078b8d1e282775d6c0faac044cffb91cd6b | 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/hints_removed/MIEIC_mfes_tmp_tmpq3ho7nve_exams_special_20_p5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,347 | cc377d914a2af63ca4239820c6e66e1de42fcbad9af34fc24ced634eb124db17 | 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... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/MIEIC_mfes_tmp_tmpq3ho7nve_TP3_binary_search_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,403 | 0f71716d95e08dddd2def4f158896f85eb9ec596e51a5597d14b7cb96e2208ec | // Checks if array 'a' is sorted.
predicate isSorted(a: array<int>)
reads a
{
forall i, j :: 0 <= i < j < a.Length ==> a[i] <= a[j]
}
// Finds a value 'x' in a sorted array 'a', and returns its index,
// or -1 if not found.
method binarySearch(a: array<int>, x: int) returns (index: int)
requires ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/nitwit_tmp_tmplm098gxz_nit_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,694 | be0e6c7b7b355036db267521680e2e6a008ff2e3f6f90b1e066aaef8464c8136 | // Liam Wynn, 3/13/2021, CS 510p
/*
In this program, I'm hoping to define
N's complement: a generalized form of 2's complement.
I ran across this idea back in ECE 341, when I asked
the professor about a crackpot theoretical "ternary machine".
Looking into it, I came across a general form of 2's comp... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/paxos_proof_tmp_tmpxpmiksmt_triggers_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 261 | fe4891e6f38e45860ad2e79ddddbf7edbc3273fb1e73eb2529a4f43b71161981 | // predicate P(x:int)
// predicate Q(x:int)
lemma M(a: seq<int>, m: map<bool,int>)
requires 2 <= |a|
requires false in m && true in m
{
assume forall i {:trigger a[i]} :: 0 <= i < |a|-1 ==> a[i] <= a[i+1];
var x :| 0 <= x <= |a|-2;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_extra_mod2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 326 | 18fc26fceec33002eeb9cbfee137988257084062b9716f7e17da3934e05c6537 |
ghost function f2(n: nat): nat {
if n == 0 then 0
else 5*f2(n/3) + n%4
}
method mod2(n:nat) returns (a:nat)
ensures a == f2(n)
{
var x:nat := 1;
var y:nat := 0;
var k:nat := n;
while k > 0
{
y := x*(k%4) + y;
x := 5*x;
k := k/3;
}
a := y... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_extra_mod_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 411 | 202bb37504a9566111ae3a8dd6751c75142b6aeaa515af3d97eb797bc110230f | ghost function f(n: nat): nat {
if n == 0 then 1
else if n%2 == 0 then 1 + 2*f(n/2)
else 2*f(n/2)
}
method mod(n:nat) returns (a:nat)
ensures a == f(n)
{
var x:nat := 0;
var y:nat := 1;
var k:nat := n;
while k > 0
{
if (k%2 == 0) {
x := x + y;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_extra_pow_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 307 | 9bfdc98f4a4d777f568abae6bb1c35f4202e1267a9981942edbbac072bfc339c | ghost function pow(a: int, e: nat): int {
if e == 0 then 1 else a*pow(a, e-1)
}
method Pow(a: nat, n: nat) returns (y: nat)
ensures y == pow(a, n)
{
var x:nat := 1;
var k:nat := 0;
while k < n
{
x := a*x;
k := k + 1;
}
y := x;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_extra_sum_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 314 | eac8cc7750cc995856dc9bb91add6c2d9de3fdd1e134c123f139a6b16a4d9154 |
ghost function sum(n: nat): int
{
if n == 0 then 0 else n + sum(n - 1)
}
method Sum(n: nat) returns (s: int)
ensures s == sum(n)
{
var x:nat := 0;
var y:nat := 1;
var k:nat := n;
while k > 0
{
x := x + y*k;
k := k-1;
}
s := x;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_mockExam2_p2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 311 | 11c63444f72a56fcca8b28e3b665c8970ba5fbf48a02f887d70d0d526f7c9128 | // problem 2:
// name: Gabriele Berardi
// s-number: s4878728
// table: XXX
method problem2(p:int, q:int, X:int, Y:int) returns (r:int, s:int)
requires p == 2*X + Y && q == X + 3
ensures r == X && s == Y
{
r, s := p, q;
r := r - 2*s + 6;
s := s - 3;
r,s := s, r;
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_mockExam2_p3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 404 | aa191247c5fb45940cdbe90efd514a9d13245d0afb68fae84f92140154210819 | // problem 3:
// name: ....... (fill in your name)
// s-number: s....... (fill in your student number)
// table: ....... (fill in your table number)
method problem3(m:int, X:int) returns (r:int)
requires X >= 0 && (2*m == 1 - X || m == X + 3)
ensures r == X
{
r := m;
if (1-2*r >= 0) {
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_mockExam2_p5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 404 | ffb39593a44d722762504729cfbf9e799526ebfbdbd63edc4fa27321769306c0 | // problem 5:
// name: Gabriele Berardi
// s-number: s4878728
// table: XXXX
ghost function f(n: int): int {
if n < 0 then 0 else 3*f(n-5) + n
}
method problem5(n:nat) returns (x: int)
ensures x == f(n)
{
var a := 1;
var b := 0;
var k := n;
while k >= 0
{
b ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Prog-Fun-Solutions_tmp_tmp7_gmnz5f_mockExam2_p6_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 560 | 5b46a89093919242bec6137f0c53f1d80f1bb935cff7085ccea7bc258e5a0a1c | // problem 6:
// name: Gabriele Berardi
// s-number: s4878728
// table: XXXXX
ghost function f(n: int): int {
if n <= 0 then 1 else n + f(n-1)*f(n-2)
}
ghost function fSum(n: nat): int {
// give the body of this function
// it should return Sum(i: 0<=i < n: f(i))
if n <= 0 then 0 else f(n-... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Program-Verification-Dataset_tmp_tmpgbdrlnu__Dafny_advanced examples_ArrayMap_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 926 | 645f34c944dd43e2b5f7fb11a4627983ed257de64090f29b2c01848528982128 | // RUN: /print:log.bpl
method ArrayMap<A>(f: int -> A, a: array<A>)
requires a != null
requires forall j :: 0 <= j < a.Length ==> f.requires(j)
requires forall j :: 0 <= j < a.Length ==> a !in f.reads(j)
modifies a
ensures forall j :: 0 <= j < a.Length ==> a[j] == f(j)
{
var i := 0;
while i < a... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Program-Verification-Dataset_tmp_tmpgbdrlnu__Dafny_advanced examples_demo_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 694 | 766d9dc46d9dbb060bafa6767ba934054f23f8944489ee3b4761c717f4f8a555 | method Partition(a: array<int>) returns (lo: int, hi: int)
modifies a
ensures 0 <= lo <= hi <= a.Length
ensures forall x | 0 <= x < lo :: a[x] < 0
ensures forall x | lo <= x < hi :: a[x] == 0
ensures forall x | hi <= x < a.Length :: a[x] > 0
{
var i := 0;
var j := a.Length;
var k := a.Length;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Program-Verification-Dataset_tmp_tmpgbdrlnu__Dafny_advanced examples_EvenPredicate_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,156 | 73681cc33cf5f85c66cab0cc8b14e013e3a292170832377c54b622697c3de808 | // RUN: /compile:0 /nologo
function IsEven(a : int) : bool
requires a >= 0
{
if a == 0 then true
else if a == 1 then false
else IsEven(a - 2)
}
lemma EvenSquare(a : int)
requires a >= 0
ensures IsEven(a) ==> IsEven(a * a)
{
if a >= 2 && IsEven(a) {
Even... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Program-Verification-Dataset_tmp_tmpgbdrlnu__Dafny_advanced examples_GenericMax_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 593 | 99c61e2b2313b06a9baa7144ed8a4269d859028e0c8581a6508d08682525d70c | method GenericMax<A>(cmp: (A, A) -> bool, a: array<A>) returns (max: A)
requires a != null && a.Length > 0
requires forall x, y :: cmp.requires(x, y)
requires forall x, y :: cmp(x, y) || cmp(y, x);
requires forall x, y, z :: cmp(x, y) && cmp(y, z) ==> cmp(x, z);
ensures forall x :: 0 <= x < a.Length ==... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.