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/SENG2011_tmp_tmpgk5jq85q_p2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 588 | 3e6781970a17ce22304f63fb1ac4e81f7c4c82f8758c6b4ad3a8c12dc9e0e961 | method AbsIt(s: array<int>) modifies s;
//requires
ensures forall x :: 0 <= x < s.Length ==> old(s[x]) < 0 ==> s[x] == -old(s[x])
ensures forall x :: 0 <= x < s.Length ==> old(s[x]) >= 0 ==> s[x] == old(s[x])
{
var i:int := 0;
while i < s.Length
//invariant forall x :: 0 <= x < i ==> s[x] >= 0
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/SiLemma_tmp_tmpfxtryv2w_utils_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,758 | 1a96fbf430e403afdedd3508a825cff01024a23e7c9f98937390d19717cc3d0f | module Utils {
lemma AllBelowBoundSize(bound: nat)
ensures
var below := set n : nat | n < bound :: n;
|below| == bound
{
if bound == 0 {
} else {
AllBelowBoundSize(bound-1);
var belowminus := set n : nat | n < bound-1 :: n;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Simulink-To_dafny_tmp_tmpbcuesj2t_Tank_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,662 | 07be193d9ae7ad54ac2cba7f6f9146eff9c750fa95c1c0b89fc7c29bc4caac49 | datatype Valve = ON | OFF
class Pipe{
var v1: Valve; //outlet valve
var v2: Valve; //inlet Valve
var v3: Valve; //outlet valve
var in_flowv1: int; //flow in valve v1
var in_flowv2: int; //flow in vave v2
var in_flowv3: int; //flow in valve v3
constructor()
{
this.v1:= OFF;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,508 | bbe2475aa1b1d16cc79fddda22a4d1692da2793f6665bf59d255ab7ae92e268d | method factImp(n: int) returns (r: int)
{
r := 1;
var m := n;
while (m > 0) {
r := r*m;
m := m-1;
}
}
function power(n: int, m: nat) : int {
if m==0 then 1 else n*power(n,m-1)
}
function pow(n: int, m: nat,r: int) : int {
if m==0 then r else pow(n,m-1,r*n)
}
function powerAlt(n:... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,345 | 7076c3fc5d727255068a03c7b89677fdb11f2e7378a1ad70b8467278cd83af19 | //PRE-CONDITIONS -> REQUIRES
//POST-CONDITIONS -> ENSURES
method max(a: int, b: int) returns (z: int)
requires true
ensures z >= a || z >= b
{
if a > b {
z :=a;
}
else {
z := b;
}
}
method Main() {
var x;
x:=max(23,50);
}
// 3
method mystery1(n: nat,m: nat) returns (res... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,751 | fdd98d4490a70c7a9c33c8b8b08d947c19d7fd98ec8258d9b0530b7f35ae8dad | function fib(n : nat) : nat
{
if (n==0) then 1 else
if (n==1) then 1 else fib(n-1)+fib(n-2)
}
method Fib(n : nat) returns (r:nat)
ensures r == fib(n)
{
if (n == 0) {
return 1;
}
var next:= 2;
r:=1;
var i := 1;
while (i < n)
{
var tmp := next;
next := next + r;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_aula5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 10,623 | e0a1e5c41aafd866e876e9b26a005b17b3b19027ce681ddcd93dec6e898c50d0 | /*Ex1 Given the leaky specification of class Set found in Appendix ??, use the techniques from
class (the use of ghost state and dynamic frames) so that the specification no longer leaks
the internal representation. Produce client code that correctly connects to your revised
Set class. */
class Set {
var store... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_handout1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,596 | 821e41fa6e01e575f0d20c69ccf342961c3680342e5828aa8b53bf62d732b6fa | // 1 a)
// [ai, aj[
function sum(a: array<int>, i: int, j: int) : int
requires 0 <= i <= j <= a.Length
reads a
{
if i == j then 0
else a[j-1] + sum(a, i, j-1)
}
// 1 b)
method query(a: array<int>, i: int, j: int) returns (res : int)
requires 0 <= i <= j <= a.Length
ensures res == sum(a, i, j... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-building-and-verification-Projects_tmp_tmp5tm1srrn_CVS-projeto_handout2_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,931 | 37ae62a61bead0c8c8516f4427065d3450f83d5daff56cd3136fa937465fd6d6 | datatype List<T> = Nil | Cons(head:T,tail:List<T>)
datatype Option<T> = None | Some(elem:T)
ghost function mem<T>(x:T,l:List<T>) : bool {
match l {
case Nil => false
case Cons(y,xs) => x==y || mem(x,xs)
}
}
ghost function length<T>(l:List<T>) : int {
match l {
case Nil => 0
case Con... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/software-specification-p1_tmp_tmpz9x6mpxb_BoilerPlate_Ex1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,774 | 6d2875b2313fa4f56145c1c583b27e279b86874bae48ee574bb5671e8390a13a | datatype Tree<V> = Leaf(V) | SingleNode(V, Tree<V>) | DoubleNode(V, Tree<V>, Tree<V>)
datatype Code<V> = CLf(V) | CSNd(V) | CDNd(V)
function serialise<V>(t : Tree<V>) : seq<Code<V>>
{
match t {
case Leaf(v) => [ CLf(v) ]
case SingleNode(v, t) => serialise(t) + [ CSNd(v) ]
case DoubleNode(v, t1... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Best Time to Buy and Sell Stock_best_time_to_buy_and_sell_stock_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 675 | b93a40f6ec8e736173c8c0c6d06e722bfc838298d15f1e986d31c4dcefdf5efe | method best_time_to_buy_and_sell_stock(prices: array<int>) returns (max_profit: int)
requires 1 <= prices.Length <= 100000
requires forall i :: 0 <= i < prices.Length ==> 0 <= prices[i] <= 10000
ensures forall i, j :: 0 <= i < j < prices.Length ==> max_profit >= prices[j] - prices[i]
{
var min_pric... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Contains Duplicate_contains_duplicate_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 593 | 00f13c98fb45606b362fcd5da5b40999d9fb8ce5fc6d5d91033f5566f408e314 | method contains_duplicate(nums: seq<int>) returns (result: bool)
requires 1 <= |nums| <= 100000
requires forall i :: 0 <= i < |nums| ==> -1000000000 <= nums[i] <= 1000000000
ensures result <==> distinct(nums)
{
var i := 0;
var s: set<int> := {};
while (i < |nums|)
{
var nu... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Counting Bits_counting_bits_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 376 | 62de6a852a9c7ca8c8096f72609018b9f879ee151208461d137afbdc9ddcf8d0 | method counting_bits(n: int) returns (result: array<int>)
requires 0 <= n <= 100000
ensures result.Length == n + 1
ensures forall i :: 1 <= i < n + 1 ==> result[i] == result[i / 2] + i % 2
{
result := new int[n + 1](i => 0);
var i := 1;
while (i < n + 1)
{
result[i] := res... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Longest Increasing Subsequence_longest_increasing_subsequence_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 921 | 9e8428d65fb7996c42d74796e80c1f4fd8b57845c2df2ac89d1bd8acc6e6b33e | method longest_increasing_subsequence(nums: array<int>) returns (max: int)
requires 1 <= nums.Length <= 2500
requires forall i :: 0 <= i < nums.Length ==> -10000 <= nums[i] <= 10000
// TODO: modify the ensures clause so that max is indeed equal to the longest increasing subsequence
ensures max >= 1
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Non-overlapping Intervals_non_overlapping_intervals_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,817 | b239c1302ad84b20b1007fd916bc6160f959cc537e53f29e057ec9b3cb0cfa71 | method non_overlapping_intervals(intervals: array2<int>) returns (count: int)
modifies intervals
requires 1 <= intervals.Length0 <= 100000
requires intervals.Length1 == 2
requires forall i :: 0 <= i < intervals.Length0 ==> -50000 <= intervals[i, 0] <= 50000
requires forall i :: 0 <= i < interva... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Remove Duplicates from Sorted Array_remove_duplicates_from_sorted_array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 895 | fb4cd37f0014734dc7df076cfbccd56cfa6e86c06bb62201b8b769ddbae54b12 | method remove_duplicates_from_sorted_array(nums: seq<int>) returns (result: seq<int>)
requires is_sorted(nums)
requires 1 <= |nums| <= 30000
requires forall i :: 0 <= i < |nums| ==> -100 <= nums[i] <= 100
ensures is_sorted_and_distinct(result)
ensures forall i :: i in nums <==> i in result
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Remove Element_remove_element_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 722 | 389ad53c10b41899d5cdadbebbbd7ef4fb52a93502080f13f82c13ba9d4faec5 | method remove_element(nums: array<int>, val: int) returns (i: int)
modifies nums
requires 0 <= nums.Length <= 100
requires forall i :: 0 <= i < nums.Length ==> 0 <= nums[i] <= 50
requires 0 <= val <= 100
ensures forall j :: 0 < j < i < nums.Length ==> nums[j] != val
{
i := 0;
var end... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Valid Anagram_valid_anagram_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,648 | 22ee02ae89186855ccf07c88d3724279c51d23b22a447597232ebfcbeccfd2dd | method is_anagram(s: string, t: string) returns (result: bool)
requires |s| == |t|
ensures (multiset(s) == multiset(t)) == result
{
result := is_equal(multiset(s), multiset(t));
}
method is_equal(s: multiset<char>, t: multiset<char>) returns (result: bool)
ensures (s == t) <==> result
{
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Software-Verification_tmp_tmpv4ueky2d_Valid Palindrome_valid_panlindrome_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 416 | 45d4bd658b632af64672775e69dea32dfce0547f290c0f511b29f397444b3b07 | method isPalindrome(s: array<char>) returns (result: bool)
requires 1<= s.Length <= 200000
ensures result <==> (forall i:: 0 <= i < s.Length / 2 ==> s[i] == s[s.Length - 1 - i])
{
var length := s.Length;
var i := 0;
while i < length / 2
{
if s[i] != s[length - 1 - i]
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/software_analysis_tmp_tmpmt6bo9sf_ss_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,646 | 79fe0384d92c3b0cf08af6671ba7b078ffc370a0949f1515ee8816e09fb0467d | method find_min_index(a : array<int>, s: int, e: int) returns (min_i: int)
requires a.Length > 0
requires 0 <= s < a.Length
requires e <= a.Length
requires e > s
ensures min_i >= s
ensures min_i < e
ensures forall k: int :: s <= k < e ==> a[min_i] <= a[k]
{
min_i := s;
var i : int := s;
w... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/specTesting_tmp_tmpueam35lx_examples_binary_search_binary_search_specs_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 5,445 | 486a2deaefef5e0b74dafaa48e9b690f01f90bf745c6db42e739a109accc531b | lemma BinarySearch(intSeq:seq<int>, key:int) returns (r:int)
// original
requires forall i,j | 0 <= i <= j < |intSeq| :: intSeq[i] <= intSeq[j]
ensures r >= 0 ==> r < |intSeq| && intSeq[r] == key
ensures r < 0 ==> forall i:nat | i < |intSeq| :: intSeq[i] != key
{
var lo:nat := 0;
var hi... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/specTesting_tmp_tmpueam35lx_examples_increment_decrement_spec_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,193 | e6b2d5edb25f5fd9fe349555b600a084b38ec2750b686d6f8599b2437cc97cef | module OneSpec {
datatype Variables = Variables(value: int)
predicate Init(v: Variables)
{
v.value == 0
}
predicate IncrementOp(v: Variables, v': Variables)
{
&& v'.value == v.value + 1
}
predicate DecrementOp(v: Variables, v': Variables)
{
&... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/specTesting_tmp_tmpueam35lx_examples_max_max_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,399 | 7bb1bf629d7eb26d670a54134f6ea4834213020204f30c94386fbf5c689e230a | lemma max(a:int, b:int) returns (m:int)
ensures m >= a
ensures m >= b
ensures m == a || m == b
{
if (a > b) {
m := a;
} else {
m := b;
}
}
predicate post_max(a:int, b:int, m:int)
{
&& m >= a
&& m >= b
&& (m == a || m == b)
}
// to check if it is f... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/specTesting_tmp_tmpueam35lx_examples_sort_sort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,062 | 35da588db9221a32dfbac893973faaf0ee2be162a5a55441f77a388f83bfd336 | method quickSort(intSeq:array<int>)
modifies intSeq
ensures forall i:nat, j:nat | 0 <= i <= j < intSeq.Length :: intSeq[i] <= intSeq[j]
// ensures multiset(intSeq[..]) == multiset(old(intSeq[..]))
lemma sort(prevSeq:seq<int>) returns (curSeq:seq<int>)
ensures (forall i:nat, j:nat | 0 <= i <= j ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/stunning-palm-tree_tmp_tmpr84c2iwh_ch10_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 10,000 | 7ed30fd7f7765fdfaf0064391b14e5f7539db3fb3deb1f9266ff4031b2e449bc | // Ch. 10: Datatype Invariants
module PQueue {
export
// Impl
provides PQueue
provides Empty, IsEmpty, Insert, RemoveMin
// Spec
provides Valid, Elements, EmptyCorrect, IsEmptyCorrect
provides InsertCorrect, RemoveMinCorrect
reveals IsMin
// ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/stunning-palm-tree_tmp_tmpr84c2iwh_ch1_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,446 | 16f8d5b38e72a83d220eac8ac52e4d7a65de15a88eb9dfd1715c9b6e261fea9b | // Ex 1.3
method Triple (x: int) returns (r: int)
ensures r == 3*x {
var y := 2*x;
r := y + x;
}
method Caller() {
var t := Triple(18);
}
// Ex 1.6
method MinUnderSpec (x: int, y: int) returns (r: int)
ensures r <= x && r <= y {
if x <= y {
r := x - 1;
} else {
r := y - 1;
}
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/stunning-palm-tree_tmp_tmpr84c2iwh_ch5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 12,426 | b083c6a30c01d74dff4a49bb08e0df9bf3fac9fdba876a79f82c7b1e1a82de63 | function More(x: int): int {
if x <= 0 then 1 else More(x - 2) + 3
}
lemma {:induction false} Increasing(x: int)
ensures x < More(x)
{
if x <= 0 {}
else {
// x < More(x) <=> x < More(x - 2) + 3
// <=> x - 3 < More(x - 2)
// Increasing(x - 2) ==> x - 2 < More(x - 2)
// ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/stunning-palm-tree_tmp_tmpr84c2iwh_ch8_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,308 | 776259834d2b780fbfbcb1c9f02f3912cdbe3e481f90a8a0d271b291bb6b9a8a | // Ch. 8: Sorting
datatype List<T> = Nil | Cons(head: T, tail: List<T>)
function Length<T>(xs: List<T>): int
ensures Length(xs) >= 0
{
match xs
case Nil => 0
case Cons(_, tl) => 1 + Length(tl)
}
function At<T>(xs: List, i: nat): T
requires i < Length(xs)
{
if i == 0 then xs.head el... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/summer-school-2020_tmp_tmpn8nf7zf0_chapter01_solutions_exercise04_solution_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 531 | 5042e0c51c6fc5a6c6aa29a1892020ef3e6419e17897591dd3420bea152200f4 | // Predicates
// A common thing you'll want is a function with a boolean result.
function AtLeastTwiceAsBigFunction(a:int, b:int) : bool
{
a >= 2*b
}
// It's so fantastically common that there's a shorthand for it: `predicate`.
predicate AtLeastTwiceAsBigPredicate(a:int, b:int)
{
a >= 2*b
}
functio... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/summer-school-2020_tmp_tmpn8nf7zf0_chapter01_solutions_exercise11_solution_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,227 | 169d990c669ca4158dabbe75683c5a0e76aac822ea39c42e182bd7cf910d8d10 | // Algebraic datatypes in their full glory. The include statement.
// A struct is a product:
// There are 3 HAlign instances, and 3 VAlign instances;
// so there are 9 TextAlign instances (all combinations).
// Note that it's okay to omit the parens for zero-element constructors.
datatype HAlign = Left | Center ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise01_solution_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 188 | 4c523fd8dc74481c8464a21a372b34ca1079372be8a18b2b00cee809a6d93507 | predicate divides(f:nat, i:nat)
requires 1<=f
{
i % f == 0
}
predicate IsPrime(i:nat)
{
&& 1 < i
&& forall f :: 1 < f < i ==> !divides(f, i)
}
method Main()
{
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise02_solution_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,153 | f4a49d05cf30e0d8a69b3b0c4b143311edc42345cd608e1e1e0caa4bf2f62591 | predicate divides(f:nat, i:nat)
requires 1<=f
{
i % f == 0
}
predicate IsPrime(i:nat)
{
&& 1<i
&& ( forall f :: 1 < f < i ==> !divides(f, i) )
}
// Convincing the proof to go through requires adding
// a loop invariant and a triggering assert.
method test_prime(i:nat) returns (result:bool)
re... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise03_solution_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,366 | 64c016cebdf3d98ff7902e8fb3033128debf790f70c4500b9833f56cdda8a25f | predicate IsSorted(s:seq<int>)
{
forall i :: 0 <= i < |s|-1 ==> s[i] <= s[i+1]
}
predicate SortSpec(input:seq<int>, output:seq<int>)
{
&& IsSorted(output)
&& multiset(output) == multiset(input)
}
//lemma SequenceConcat(s:seq<int>, pivot:int)
// requires 0<=pivot<|s|
// ensures s[..pivot] + s[pivo... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/t1_MF_tmp_tmpi_sqie4j_exemplos_classes_parte1_contadorV1b_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 984 | 7f36dc60a1411aece885300211fd9fbe2ba6e1376a09eb5be97b69ce36e4efdd | class Contador
{
var valor: int;
//construtor anônimo
constructor ()
ensures valor == 0
{
valor := 0;
}
//construtor com nome
constructor Init(v:int)
ensures valor == v
{
valor := v;
}
method Incrementa()
modifies this
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_arrays_ex4_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 357 | 54e81fcb7bdc438b2c5f4ba0891441a1088a6207cd7580c50570db20b52c2fcf | function SomaAte(a:array<nat>, i:nat):nat
requires 0 <= i <= a.Length
reads a
{
if i == 0
then 0
else a[i-1] + SomaAte(a,i-1)
}
method Somatorio(a:array<nat>) returns (s:nat)
ensures s == SomaAte(a,a.Length)
{
var i := 0;
s := 0;
while i < a.Length
{
s := s + a... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_arrays_ex5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 322 | 08aa53b1d53ac306f9124d4c14ffd8b9c100c3a9358ddd17e0b228143a77d34b | method Busca<T(==)>(a:array<T>, x:T) returns (r:int)
ensures 0 <= r ==> r < a.Length && a[r] == x
ensures r < 0 ==> forall i :: 0 <= i < a.Length ==> a[i] != x
{
r :=0;
while r < a.Length
{
if a[r]==x
{
return;
}
r := r + 1;
}
r := -1;
}... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_conjuntos_ex5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 322 | e807e10bafb10245e12ae68212e5d79a6bc191b6a90961e1c893eea42884f921 | function to_seq<T>(a: array<T>, i: int) : (res: seq<T>)
requires 0 <= i <= a.Length
ensures res == a[i..]
reads a
{
if i == a.Length
then []
else [a[i]] + to_seq(a, i + 1)
}
method Main() {
var a: array<int> := new int[2];
a[0] := 2;
a[1] := 3;
var ms: multiset<int> := multiset(a[..]);
}... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_sequences_ex3_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 424 | 12fd97696a8f0fe01207d261464d7ae0c54923e72d128e70f7b88ce8480af3c0 | // line contém uma string de tamanho l
// remover p caracteres a partir da posição at
method Delete(line:array<char>, l:nat, at:nat, p:nat)
requires l <= line.Length
requires at+p <= l
modifies line
ensures line[..at] == old(line[..at])
ensures line[at..l-p] == old(line[at+p..l])
{
var i:nat := 0... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/t1_MF_tmp_tmpi_sqie4j_exemplos_introducao_ex4_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 247 | 067c20b852bda6cfe6678466f724a8e36ea2b35f160cb692c045139f1cea43bd | function Fat(n: nat): nat
{
if n == 0 then 1 else n * Fat(n-1)
}
method Fatorial(n:nat) returns (r:nat)
ensures r == Fat(n)
{
r := 1;
var i := 0;
while i < n
{
i := i + 1;
r := r * i;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/tangent-finder_tmp_tmpgyzf44ve_circles_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 980 | a44b699726199e835c2505c6934627d37f74646a232b262cd4cf129a0ad5457c | method Tangent(r: array<int>, x: array<int>) returns (b: bool)
requires forall i, j :: 0 <= i <= j < x.Length ==> x[i] <= x[j] // values in x will be in ascending order or empty
requires forall i, j :: (0 <= i < r.Length && 0 <= j < x.Length) ==> (r[i] >= 0 && x[j] >= 0) // x and r will contain no negat... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/test-generation-examples_tmp_tmptwyqofrp_IntegerSet_dafny_IntegerSet_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 6,381 | ab2ce46cb6e1fbd7a954cae1b572a01e1f0ac013e7dc9a5a8e75a39c22809adf | module IntegerSet {
class Set {
var elements: seq<int>;
constructor Set0()
ensures this.elements == []
ensures |this.elements| == 0
{
this.elements := [];
}
constructor Set(elements: seq<int>)
requires forall i, j | 0 <= ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/test-generation-examples_tmp_tmptwyqofrp_RussianMultiplication_dafny_RussianMultiplication_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 438 | 3b5e0666f01e35de152d5cda026271e372f8c24155dd1eacd4a46e6eb129c65e | module RussianMultiplication {
export provides mult
method mult(n0 : int, m0 : int) returns (res : int)
ensures res == (n0 * m0);
{
var n, m : int;
res := 0;
if (n0 >= 0) {
n,m := n0, m0;
}
else {
n,m := -n0, -m0;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/TFG_tmp_tmpbvsao41w_Algoritmos Dafny_div_ent_it_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 433 | 95665a14a52fdf16cb727cc809f87a078d532e2ec8eecdfe85397b831aeb4773 | method div_ent_it(a: int, b: int) returns (c: int, r: int)
// Algoritmo iterativo de la división de enteros
// que calcula su cociente y resto
requires a >= 0 && b > 0
ensures a == b*c + r && 0 <= r < b
{
c := 0; r := a ;
while (r >= b)
{
c := c + 1 ;
r := r - b ;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/TFG_tmp_tmpbvsao41w_Algoritmos Dafny_suma_it_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 870 | 55415f6f309f6954b9264dcc477a4db9d44c665db15fe383571f9f64b88b4f81 | method suma_it(V: array<int>) returns (x: int)
// Algoritmo iterativo que calcula la
// suma de las componentes de un vector
ensures x == suma_vector(V, 0)
{
var n := V.Length ;
x := 0 ;
while (n != 0)
{
x := x + V[n - 1] ;
n := n - 1 ;
}
}
function suma... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Trab1-Metodos-Formais_tmp_tmp_8fa4trr_circular-array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,325 | 0e7b553e37aedcd8b8f2a6e3bd29f7d62f1c34efe6c2d563880a839e4ecea36d | /*
Class CircularArray.
Names:
Arthur Sudbrack Ibarra,
Miguel Torres de Castro,
Felipe Grosze Nipper,
Willian Magnum Albeche,
Luiz Eduardo Mello dos Reis.
*/
class {:autocontracts} CircularArray {
/*
Implementation
*/
var arr: array<int>; // The array.
var start: nat; // The in... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/type-definition_tmp_tmp71kdzz3p_final_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 3,997 | e3d6fe590c3f506210f199064fd279922abe4330382e1cca875f0369ed9b0cd5 | // -------------------------------------------------------------
// 1. Implementing type inference
// -------------------------------------------------------------
// Syntax:
//
// τ := Int | Bool | τ1->τ2
// e ::= x | λx : τ.e | true| false| e1 e2 | if e then e1 else e2
// v ::= true | false | λx : τ.e
// E ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/veri-sparse_tmp_tmp15fywna6_dafny_concurrent_poc_6_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 8,800 | e549b9a748159d5687c10858e8ecefb907e89518b942b06e59b378ddeb92cd15 | class Process {
var row: nat;
var curColumn: nat;
var opsLeft: nat;
constructor (init_row: nat, initOpsLeft: nat)
ensures row == init_row
ensures opsLeft == initOpsLeft
ensures curColumn == 0
{
row := init_row;
curColumn := 0;
opsLeft := ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/veri-sparse_tmp_tmp15fywna6_dafny_dspmspv_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,017 | a2108dd684ed03639248d6d8262c472d9f437c091cde801c78cfbf8d26fb53ac | function sum(X_val : array<int>, X_crd : array<nat>,
v_val : array<int>, v_crd : array<nat>, kX : nat, kV : nat, pX_end : nat, pV_end : nat) : (s : int)
reads X_val, X_crd
requires X_val.Length == X_crd.Length
requires pX_end <= X_crd.Length
requires 0 <= kX <= X_crd.Length
reads v_crd, ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/veri-sparse_tmp_tmp15fywna6_dafny_spmv_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,080 | ee12fa19859138dc4ce2c85134ab7afe7e0428429a4f91b44ea54c26b37c3413 | function sum(X_val: array<int>, X_crd: array<nat>, v : array<int>, b : int, k : int) : (s : int)
reads X_val, X_crd, v
requires X_val.Length >= b >= 0
requires k <= X_val.Length
requires X_val.Length == X_crd.Length
requires forall i :: 0 <= i < X_crd.Length ==> 0 <= X_crd[i] < v.Length
{
if k <=... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/veribetrkv-osdi2020_tmp_tmpra431m8q_docker-hdd_src_veribetrkv-linear_lib_Base_SetBijectivity_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,740 | e4711481059d38357b64fcf6af0ba0f2dc8765c2a2f61bf3c62ea1f655de2c6d | module SetBijectivity {
lemma BijectivityImpliesEqualCardinality<A, B>(setA: set<A>, setB: set<B>, relation: iset<(A, B)>)
requires forall a :: a in setA ==> exists b :: b in setB && (a, b) in relation
requires forall a1, a2, b :: a1 in setA && a2 in setA && b in setB && (a1, b) in relation && (a2, b) in r... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/veribetrkv-osdi2020_tmp_tmpra431m8q_docker-hdd_src_veribetrkv-linear_lib_Base_Sets_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 895 | b2fa6a7aa2e20b2aceffd4c4f9b4d5355cb031f37ac006c84d25d14478c8ca42 | module Sets {
lemma {:opaque} ProperSubsetImpliesSmallerCardinality<T>(a: set<T>, b: set<T>)
requires a < b
ensures |a| < |b|
{
}
lemma {:opaque} SetInclusionImpliesSmallerCardinality<T>(a: set<T>, b: set<T>)
requires a <= b
ensures |a| <= |b|
{
}
lemma {:opaque} SetInclus... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/verification-class_tmp_tmpz9ik148s_2022_chapter05-distributed-state-machines_exercises_UtilitiesLibrary_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,136 | 3829699d828c68ba0f367affae04001c5ffdb0b6ec22f8ae39b4df0a4ac13bf3 | module UtilitiesLibrary {
function DropLast<T>(theSeq: seq<T>) : seq<T>
requires 0 < |theSeq|
{
theSeq[..|theSeq|-1]
}
function Last<T>(theSeq: seq<T>) : T
requires 0 < |theSeq|
{
theSeq[|theSeq|-1]
}
function UnionSeqOfSets<T>(theSets: seq<set<T>>) : set<T>
{
if |th... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/verified-using-dafny_tmp_tmp7jatpjyn_longestZero_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,580 | a2cb4376db983d1b394a9f13aaab142a310a6112e3ec4fff464e609b3a6730e2 | function getSize(i: int, j:int) : int
{
j - i + 1
}
// For a given integer array, let's find the longest subesquence of 0s.
// sz: size, pos: position. a[pos..(pos+sz)] will be all zeros
method longestZero(a: array<int>) returns (sz:int, pos:int)
requires 1 <= a.Length
ensures 0 <= sz <= ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/VerifiedMergeSortDafny_tmp_tmpva7qms1b_MergeSort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,325 | 461a348d52277785ca58b36544d7028fbcca4439a6def6a9f3e77520881e0134 | method mergeSimple(a1: seq<int>, a2: seq<int>, start: int, end: int, b: array<int>)
modifies b
requires sorted_seq(a1)
requires sorted_seq(a2)
requires 0 <= start <= end <= b.Length
requires |a1| + |a2| == end - start + 1
ensures sorted_slice(b, start, end)
{
var a1Pos := 0;
var a2Pos := 0;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/vfag_tmp_tmpc29dxm1j_mergesort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 2,358 | 80d80c555501234934223da0c142f83e17f9964257727fb2af6fb8e408add2f9 | method ordenar_mergesort(V : array?<int>)
requires V != null
modifies V
{
mergesort(V, 0, V.Length - 1) ;
}
method mergesort(V : array?<int>, c : int, f : int)
requires V != null
requires c >= 0 && f <= V.Length
modifies V
{
if c < f ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/vfag_tmp_tmpc29dxm1j_sumar_componentes_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 723 | 5964668fba22cbe72915e55c02ed9743942f291cd71af3b356f76186f58adf56 | method suma_componentes(V : array?<int>) returns (suma : int)
requires V != null
ensures suma == suma_aux(V, 0) // x = V[0] + V[1] + ... + V[N - 1]
{
var n : int ;
n := V.Length ; // n := N
suma := 0 ;
while n != 0
{
suma := suma + V[n - 1] ;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/vfag_tmp_tmpc29dxm1j_Verificacion_torneo_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 1,765 | b4180677ff5c9f3627c853734aa215f09c29cef7cc72c33e017c36d4b107c67c | method torneo(Valores : array?<real>, i : int, j : int, k : int) returns (pos_padre : int, pos_madre : int)
requires Valores != null && Valores.Length >= 20 && Valores.Length < 50 && i >= 0 && j >= 0 && k >= 0
requires i < Valores.Length && j < Valores.Length && k < Valores.Length && i != j && j != k && k !=... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/vmware-verification-2023_tmp_tmpoou5u54i_demos_leader_election_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 4,910 | d9c3dba8b510da36d198f126f8bcb4f516af3512474fc34b494f547160823709 | // Each node's identifier (address)
datatype Constants = Constants(ids: seq<nat>) {
predicate ValidIdx(i: int) {
0<=i<|ids|
}
ghost predicate UniqueIds() {
(forall i, j | ValidIdx(i) && ValidIdx(j) && ids[i]==ids[j] :: i == j)
}
ghost predicate WF() {
&& 0 < |ids|
&& UniqueIds()
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_max_array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 613 | 66d7c787811972c5dbbbf736c7851cd5a258d86cecf03e0a992c22efbbcbaffd | // http://verifythus.cost-ic0701.org/common-example/arraymax-in-dafny
method max(a:array<int>) returns(max:int)
requires a != null;
ensures forall j :: j >= 0 && j < a.Length ==> max >= a[j]; //max is larger then anything in the array
ensures a.Length > 0 ==> exists j :: j >= 0 && j < a.Length && max ... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_selection_sort_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 794 | d4f35b07e034e72b6846d468b9f7f04cfec09a867e0052c10a9a979012029324 | //https://homepage.cs.uiowa.edu/~tinelli/classes/181/Fall21/Tools/Dafny/Examples/selection-sort.shtml
predicate sorted (a: array<int>)
requires a != null
reads a
{
sorted'(a, a.Length)
}
predicate sorted' (a: array<int>, i: int)
requires a != null
requires 0 <= i <= a.Length
reads a
{
forall k ::... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_sum_array_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 400 | aa52694cddceef7e2f814756b9d330607a86f5db5cf38045980337558011e269 | function sumTo( a:array<int>, n:int ) : int
requires a != null;
requires 0 <= n && n <= a.Length;
reads a;
{
if (n == 0) then 0 else sumTo(a, n-1) + a[n-1]
}
method sum_array( a: array<int>) returns (sum: int)
requires a != null;
ensures sum == sumTo(a, a.Length);
{
var i := 0;
sum := 0;
... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Workshop_tmp_tmp0cu11bdq_Lecture_Answers_triangle_number_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 211 | 1316c4fd857ffecff18557fc240e90831a612521edcd5383a0b8d5feaa8fda87 | method TriangleNumber(N: int) returns (t: int)
requires N >= 0
ensures t == N * (N + 1) / 2
{
t := 0;
var n := 0;
while n < N
{
n:= n + 1;
t := t + n;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Workshop_tmp_tmp0cu11bdq_Workshop_Answers_Question5_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 310 | 88e9a55febc26b88e65f2b0102b3b840825b019b5d7e2fc18de9ffd4cd959ed7 | method rev(a : array<int>)
requires a != null;
modifies a;
ensures forall k :: 0 <= k < a.Length ==> a[k] == old(a[(a.Length - 1) - k]);
{
var i := 0;
while (i < a.Length - 1 - i)
{
a[i], a[a.Length - 1 - i] := a[a.Length - 1 - i], a[i];
i := i + 1;
}
}
|
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/Workshop_tmp_tmp0cu11bdq_Workshop_Answers_Question6_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 332 | 415ca0b4a6cd5017e3f21079bdeb8e23a4504c2fba6d3c234c7c7dc883b1c0bd | method arrayUpToN(n: int) returns (a: array<int>)
requires n >= 0
ensures a.Length == n
ensures forall j :: 0 < j < n ==> a[j] >= 0
ensures forall j, k : int :: 0 <= j <= k < n ==> a[j] <= a[k]
{
var i := 0;
a := new int[n];
while i < n
{
a[i] := i;
i := i + 1;... |
sun-wendy/DafnyBench | DafnyBench/dataset/hints_removed/WrappedEther_no_hints.dfy | Apache-2.0 | 67 | main | 0cd28feed9cd0179b07fdb9d002f8c39063658e4 | 2024-12-12T07:08:20Z | 21,137 | bc939a21b637418edc24e9e7d92da7268b79d005839b05410d9b537f6e94684b | /*
* Copyright 2022 ConsenSys Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
midspiral/lemmafit | kernels/Replay.dfy | MIT | 58 | main | 4b795ead3dde85eac2587d3d7d1294e7d9d48d67 | 2026-06-02T16:36:01Z | 3,547 | 8bcb89423e34fd814fd9df21b8677c5bc2fc5b5374dcb6833282baa60e56bf57 | abstract module {:compile false} Domain {
type Model
type Action
ghost predicate Inv(m: Model)
function Init(): Model
function Apply(m: Model, a: Action): Model
requires Inv(m)
function Normalize(m: Model): Model
lemma InitSatisfiesInv()
ensures Inv(Init())
lemma StepPreservesI... |
midspiral/lemmafit | blank-template/lemmafit/dafny/Domain.dfy | MIT | 58 | main | 4b795ead3dde85eac2587d3d7d1294e7d9d48d67 | 2026-06-02T16:36:01Z | 177 | fc9321e80222e4cfc3f37b588c2c5dd373431d06ac9ce3a9c6221673ea7ce320 | // Verified domain logic
// This file is the source of truth for your app's state machine.
// The daemon watches this file and recompiles on changes.
include "Replay.dfy"
|
Mondego/dafny-synthesis | MBPP-DFY-153/src/task_id_57.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 891 | 9a2af756385a4e695a2c870cf15329704939e0684866fc0fcc47b892055da9a9 | /*
* This problem is not straightforward to solve in Dafny because it involves string manipulation and sorting,
* which is not natively supported in Dafny. However, a pseudo-code for this problem would look like this:
*
* 1. Convert all integers in the array to strings
* 2. Sort the array of strings i... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_101.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 504 | 064e83b2f6246cd35bf72cd49460106c1c263c0f4a99378b7359342cd2f6bef3 | method KthElement(arr: array<int>, k: int) returns (result: int)
requires 1 <= k <= arr.Length
ensures result == arr[k - 1]
{
result := arr[k - 1];
}
method KthElementTest(){
var a1:= new int[] [12,3,5,7,19];
var out1:=KthElement(a1,2);
assert out1==3;
var a2:= new int[] [17,24,8,23];
var... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_105.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 863 | a95de393482d8b5b6ee5c60acc2fb69e11dbfda42f6ca629b6e8b666f80f6e9a | function countTo( a:array<bool>, n:int ) : int
requires a != null;
requires 0 <= n && n <= a.Length;
decreases n;
reads a;
{
if (n == 0) then 0 else countTo(a, n-1) + (if a[n-1] then 1 else 0)
}
method CountTrue(a: array<bool>) returns (result: int)
requires a != null
ensures result == countTo... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_106.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,012 | f0afb7dc35ad8ffa4283f23fa204552192dce11eff94fffba566dfdc51b19a68 | method AppendArrayToSeq(s: seq<int>, a: array<int>) returns (r: seq<int>)
requires a != null
ensures |r| == |s| + a.Length
ensures forall i :: 0 <= i < |s| ==> r[i] == s[i]
ensures forall i :: 0 <= i < a.Length ==> r[|s| + i] == a[i]
{
r := s;
for i := 0 to a.Length
invariant 0 <= i <= a.Length
... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_113.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 732 | 408ce090dbd83e43e05511b8a0c39268160da83405893ece7e62e3610b593437 | predicate IsDigit(c: char)
{
48 <= c as int <= 57
}
method IsInteger(s: string) returns (result: bool)
ensures result <==> (|s| > 0) && (forall i :: 0 <= i < |s| ==> IsDigit(s[i]))
{
result := true;
if |s| == 0 {
result := false;
} else {
for i := 0 to |s|
invariant 0 <= i <= |s|
... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_126.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 784 | 884f89e551364c5dd53907b93a559e7124bc1b3e70b9540222e1409d90bd1bb7 | method SumOfCommonDivisors(a: int, b: int) returns (sum: int)
requires a > 0 && b > 0
ensures sum >= 0
ensures forall d :: 1 <= d <= a && 1 <= d <= b && a % d == 0 && b % d == 0 ==> sum >= d
{
sum := 0;
var i := 1;
while i <= a && i <= b
invariant 1 <= i <= a + 1 && 1 <= i <= b + 1
invarian... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_127.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 331 | 840cb18e03f41093d7fcb9351445763ee35f5e6bd79e024aee98a36686e83df7 | method Multiply(a: int, b: int) returns (result: int)
ensures result == a * b
{
result := a * b;
}
method MultiplyTest(){
var out1:=Multiply(10,20);
assert out1==200;
var out2:=Multiply(5,10);
assert out2==50;
var out3:=Multiply(4,8);
assert out3==32;
}
method Main(){
MultiplyT... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_133.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 993 | 4ed13ce542dc3edf50c04a0e6ca2902b88d2f67d56cf6f7f8733c43dc26b1c02 | function sumNegativesTo( a:array<int>, n:int ) : int
requires a != null;
requires 0 <= n && n <= a.Length;
decreases n;
reads a;
{
if (n == 0) then 0 else if a[n-1] < 0 then sumNegativesTo(a, n-1) + a[n-1] else sumNegativesTo(a, n-1)
}
method SumOfNegatives(a: array<int>) returns (result: int)
en... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_135.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 497 | a4df6e9f100166bf718189fb34fb350c0765e41693c8760cc6a6babd5ecf3bba | method NthHexagonalNumber(n: int) returns (hexNum: int)
requires n >= 0
ensures hexNum == n * ((2 * n) - 1)
{
hexNum := n * ((2 * n) - 1);
}
method NthHexagonalNumberTest(){
var res1:= NthHexagonalNumber(10);
print(res1);print("\n");
assert res1==190;
var res2:= NthHexagonalNumber(5);
print... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_139.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 657 | 9280d626e20aa3a2427c7971e6c44fd42f8ceca628ff85f22647d65ef9c0a77a | method CircleCircumference(radius: real) returns (circumference: real)
requires radius > 0.0
ensures circumference == 2.0 * 3.14159265358979323846 * radius
{
circumference := 2.0 * 3.14159265358979323846 * radius;
}
method CircleCircumferenceTest(){
var res1:=CircleCircumference(10.0);
print(res1);p... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_14.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 625 | 1a8fbfdc194c34caf2261a7f8a205685aa836213c74ef19e2c47297d64b359a5 | method TriangularPrismVolume(base: int, height: int, length: int) returns (volume: int)
requires base > 0
requires height > 0
requires length > 0
ensures volume == (base * height * length) / 2
{
volume := (base * height * length) / 2;
}
method TriangularPrismVolumeTest(){
var out1:=TriangularPris... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_142.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,026 | 51e6666f4158a2da11609ffa0227db0078b26add44c3f60a9d97348cd209b572 | method CountIdenticalPositions(a: seq<int>, b: seq<int>, c: seq<int>) returns (count: int)
requires |a| == |b| && |b| == |c|
ensures count >= 0
ensures count == | set i: int | 0 <= i < |a| && a[i] == b[i] && b[i] == c[i]|
{
var identical := set i: int | 0 <= i < |a| && a[i] == b[i] && b[i] == c[i];
coun... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_143.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 663 | 50c7e0412175a1f5f8fe5df049576f9f37264b8db701f984486fa724e708fbc3 | method CountArrays(arrays: seq<array<int>>) returns (count: int)
ensures count >= 0
ensures count == |arrays|
{
count := |arrays|;
}
method CountArraysTest(){
var a1:= new int[][1,2,3,4];
var a2:= new int[][5, 6, 7, 8];
var s1:seq<array<int>> :=[a1,a2];
var res1:=CountArrays(s1);
expect r... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_145.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 875 | 5732a3f2a4d4076003a409eca96d1522c89aa2539a1dd9f11179cede1d647915 | method MaxDifference(a: array<int>) returns (diff: int)
requires a.Length > 1
ensures forall i, j :: 0 <= i < a.Length && 0 <= j < a.Length ==> a[i] - a[j] <= diff
{
var minVal := a[0];
var maxVal := a[0];
for i := 1 to a.Length
invariant 1 <= i <= a.Length
invariant minVal <= maxVal
in... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_161.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,370 | 27aa9ee48379e62733e82bcc72998a5a3163d07549b03c31aa41d0af610330ae | predicate InArray(a: array<int>, x: int)
reads a
{
exists i :: 0 <= i < a.Length && a[i] == x
}
method RemoveElements(a: array<int>, b: array<int>) returns (result: seq<int>)
// All elements in the output are in a and not in b
ensures forall x :: x in result ==> InArray(a, x) && !InArray(b, x)
// Th... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_17.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 482 | 7623c0a147d1696bf020cf0df5b26b058309ca209ae77aaa84f23b94c4049211 | method SquarePerimeter(side: int) returns (perimeter: int)
requires side > 0
ensures perimeter == 4 * side
{
perimeter := 4 * side;
}
method SquarePerimeterTest(){
var res1:= SquarePerimeter(10);
print(res1);print("\n");
assert res1==40;
var res2:= SquarePerimeter(5);
print(res2);print(... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_170.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,019 | 34c6f823190cda053c1ee1c45da54e28191e6b9215f616ba3e32e42f976698f5 | function sumTo( a:array<int>, start:int, end:int ) : int
requires a != null;
requires 0 <= start && start <= end && end <= a.Length;
decreases end;
reads a;
{
if (start == end) then 0 else sumTo(a, start, end-1) + a[end-1]
}
method SumInRange(a: array<int>, start: int, end: int) returns (sum: int)
... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_171.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 408 | e9529551b48463a28b72020b08032ef3342013805cd7875412fadd4220514009 | method PentagonPerimeter(side: int) returns (perimeter: int)
requires side > 0
ensures perimeter == 5 * side
{
perimeter := 5 * side;
}
method PentagonPerimeterTest(){
var res1:=PentagonPerimeter(5);
expect res1==25;
var res2:=PentagonPerimeter(10);
expect res2==50;
var res3:=Pentagon... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_18.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 884 | a85d3227fea6e91681fbcd2660d4036b3a9b3e4766f4d1357dcc3a459c7339a1 | method RemoveChars(s1: string, s2: string) returns (v: string)
ensures |v| <= |s1|
ensures forall i :: 0 <= i < |v| ==> (v[i] in s1) && !(v[i] in s2)
ensures forall i :: 0 <= i < |s1| ==> (s1[i] in s2) || (s1[i] in v)
{
var v' : string := [];
for i := 0 to |s1|
invariant 0 <= i <= |s1|
invaria... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_2.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,393 | bf6ff93b07ce2bd0e1ade77758111c62a137bb3acabfce5c2a3d1ec49ac4dd65 | predicate InArray(a: array<int>, x: int)
reads a
{
exists i :: 0 <= i < a.Length && a[i] == x
}
method SharedElements(a: array<int>, b: array<int>) returns (result: seq<int>)
// All elements in the output are in both a and b
ensures forall x :: x in result ==> (InArray(a, x) && InArray(b, x))
// The... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_227.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 532 | 33a4b54f16314005e680bd4b67837d871327c9df9712b021af823dad0e7921d1 | method MinOfThree(a: int, b: int, c: int) returns (min: int)
ensures min <= a && min <= b && min <= c
ensures (min == a) || (min == b) || (min == c)
{
if (a <= b && a <= c) {
min := a;
} else if (b <= a && b <= c) {
min := b;
} else {
min := c;
}
}
method MinOfThreeTest(){
var o... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_230.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 931 | 4cbbac96db7709a2e35d79c3ca7d7393df5812f27fcc14a70bf5fe9b627f730d | method ReplaceBlanksWithChar(s: string, ch: char) returns (v: string)
ensures |v| == |s|
ensures forall i :: 0 <= i < |s| ==> (s[i] == ' ' ==> v[i] == ch) && (s[i] != ' ' ==> v[i] == s[i])
{
var s' : string := [];
for i := 0 to |s|
invariant 0 <= i <= |s|
invariant |s'| == i
invariant forall... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_233.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 774 | 69dbb20d5a5ff6503c8e7b850958f424bce250b539240b61817cf2244397ed62 | method CylinderLateralSurfaceArea(radius: real, height: real) returns (area: real)
requires radius > 0.0 && height > 0.0
ensures area == 2.0 * (radius * height) * 3.14159265358979323846
{
area := 2.0 * (radius * height) * 3.14159265358979323846;
}
method CylinderLateralSurfaceAreaTest(){
var res1:= Cyl... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_234.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 379 | 0d764039e19cdafe03df5635cbb47f4f5bd3250cb99d7e01245de17a3405bd89 | method CubeVolume(size: int) returns (volume: int)
requires size > 0
ensures volume == size * size * size
{
volume := size * size * size;
}
method CubeVolumeTest(){
var out1:=CubeVolume(3);
expect out1==27;
var out2:=CubeVolume(2);
expect out2==8;
var out3:=CubeVolume(5);
expec... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_238.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 531 | 139c1381d65bad30718f5d50c4fe87b873bd4e557d99425c55540d86af7c6d0e | method CountNonEmptySubstrings(s: string) returns (count: int)
ensures count >= 0
ensures count == (|s| * (|s| + 1)) / 2 // Formula for the number of non-empty substrings of a string
{
count := (|s| * (|s| + 1)) / 2;
}
method CountNonEmptySubstringsTest(){
var res1:=CountNonEmptySubstrings("abc");
a... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_240.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 924 | 7a8ffb68c7179e0812c21356c533bb1bf4404677fad418d6312ff828f55178cf | method ReplaceLastElement(first: seq<int>, second: seq<int>) returns (result: seq<int>)
requires |first| > 0
ensures |result| == |first| - 1 + |second|
ensures forall i :: 0 <= i < |first| - 1 ==> result[i] == first[i]
ensures forall i :: |first| - 1 <= i < |result| ==> result[i] == second[i - |first| + 1]
... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_242.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 403 | 728726e6cc62352ae72f77343c784f4e3fbdbd936f661bd28d8fe2fbbc41e302 | method CountCharacters(s: string) returns (count: int)
ensures count >= 0
ensures count == |s|
{
count := |s|;
}
method CountCharactersTest(){
var res1:=CountCharacters("python programming");
assert res1==18;
var res2:=CountCharacters("language");
assert res2==8;
var res3:=CountCharac... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_249.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,421 | 5b923f28e55c9d01e1f9df7f5964e53024e7d34ee32f4e3a670446c45b5c4c3a | predicate InArray(a: array<int>, x: int)
reads a
{
exists i :: 0 <= i < a.Length && a[i] == x
}
method Intersection(a: array<int>, b: array<int>) returns (result: seq<int>)
// All elements in the output are in both a and b
ensures forall x :: x in result ==> (InArray(a, x) && InArray(b, x))
// The e... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_251.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,213 | 30b8b16afd33a5b74d3a1453484ba185536059de4d45940f866f0fccf6d84dc0 | method InsertBeforeEach(s: seq<string>, x: string) returns (v: seq<string>)
ensures |v| == 2 * |s|
ensures forall i :: 0 <= i < |s| ==> v[2*i] == x && v[2*i + 1] == s[i]
{
v := [];
for i := 0 to |s|
invariant 0 <= i <= |s|
invariant |v| == 2 * i
invariant forall j :: 0 <= j < i ==> v[2*j] ==... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_257.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 489 | a5abf6a0988478c6062656f5ec73ff31638dbb40e67bbc4197bca3f3e3b2f22e | method Swap(a: int, b: int) returns (result: seq<int>)
ensures |result| == 2
ensures result[0] == b
ensures result[1] == a
{
result := [b, a];
}
method SwapTest(){
var e1: seq<int> := [20,10];
var res1:=Swap(10,20);
print(res1);print("\n");
var e2: seq<int> := [15,17];
var res2:=Swap... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_261.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,153 | 4c602967139f7df5ff5b17c59bf4a66488fcbe28d4d34c99a603a23ee8b40ddb | method ElementWiseDivision(a: seq<int>, b: seq<int>) returns (result: seq<int>)
requires |a| == |b|
requires forall i :: 0 <= i < |b| ==> b[i] != 0
ensures |result| == |a|
ensures forall i :: 0 <= i < |result| ==> result[i] == a[i] / b[i]
{
result := [];
var i := 0;
while i < |a|
invariant 0 ... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_262.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 1,211 | 38ffe2e12cab233fc87209143041067eb7c47e366988fa0ac0cf945e7ae455a9 | method SplitArray(arr: array<int>, L: int) returns (firstPart: seq<int>, secondPart: seq<int>)
requires 0 <= L <= arr.Length
ensures |firstPart| == L
ensures |secondPart| == arr.Length - L
ensures firstPart + secondPart == arr[..]
{
firstPart := arr[..L];
secondPart := arr[L..];
}
method PrintS... |
Mondego/dafny-synthesis | MBPP-DFY-153/test/task_id_264.dfy | GPL-3.0 | 57 | master | 4a06e8b09f48825458458aeacbe1622c26df4461 | 2024-06-09T21:49:08Z | 496 | 1cfacfea7e8cea50cb3d3d7b49e078d15dbd258e03b2ce400f77246700136f62 | method DogYears(humanYears: int) returns (dogYears: int)
requires humanYears >= 0
ensures dogYears == 7 * humanYears
{
dogYears := 7 * humanYears;
}
method DogYearsTest(){
var res1:=DogYears(12);
print(res1);print("\n");
//assert res1==61;
var res2:=DogYears(15);
print(res2);pri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.