Skip to content

Commit 0921179

Browse files
committed
2 parents 3dae93a + 53e2a93 commit 0921179

File tree

180 files changed

+375
-476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+375
-476
lines changed

.git-blame-ignore-revs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
40ba9a26ce77a4720a5a2ee00007c8c5acb4ea1c

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ scripts/processed
2727
scripts/processed/*
2828
*dump.txt
2929
**/.verus-log
30+
.env

benches/HumanEval-RustBench/008-sum_product.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ spec fn product(numbers: Seq<u32>) -> (result:int) {
1212
// pure-end
1313

1414
proof fn sum_bound(numbers: Seq<u32>)
15+
// post-conditions-start
1516
ensures
1617
sum(numbers) <= numbers.len() * u32::MAX,
1718
decreases numbers.len(),
19+
// post-conditions-end
1820
{
1921
// impl-start
2022
if numbers.len() == 0 {

benches/HumanEval-RustBench/009-rolling_max.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use vstd::prelude::*;
22

33
verus! {
44

5-
spec fn seq_max(a: Seq<i32>) -> i32
5+
spec fn seq_max(a: Seq<i32>) -> (ret: i32)
66
decreases a.len(),
77
{
88
if a.len() == 0 {

benches/HumanEval-RustBench/011-string_xor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use vstd::prelude::*;
22
use vstd::slice::*;
33

44
verus! {
5-
spec fn is_binary_digit(c: char) -> bool {
5+
spec fn is_binary_digit(c: char) -> (ret: bool) {
66
c == '0' || c == '1'
77
}
88
// pure-end

benches/HumanEval-RustBench/034-unique.rs

+8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ use vstd::seq_lib::lemma_seq_contains_after_push;
66
verus! {
77

88
proof fn swap_preserves_multiset_helper(s: Seq<i32>, i: int, j: int)
9+
// pre-conditions-start
910
requires
1011
0 <= i < j < s.len(),
12+
// pre-conditions-end
13+
// post-conditions-start
1114
ensures
1215
(s.take(j + 1)).to_multiset() =~= s.take(i).to_multiset().add(
1316
s.subrange(i + 1, j).to_multiset(),
1417
).insert(s.index(j)).insert(s.index(i)),
18+
// post-conditions-end
1519
{
1620
// impl-start
1721
let fst = s.take(i);
@@ -36,13 +40,17 @@ proof fn swap_preserves_multiset_helper(s: Seq<i32>, i: int, j: int)
3640
// pure-end
3741

3842
proof fn swap_preserves_multiset(s1: Seq<i32>, s2: Seq<i32>, i: int, j: int)
43+
// pre-conditions-start
3944
requires
4045
0 <= i < j < s1.len() == s2.len(),
4146
forall|x: int| 0 <= x < s1.len() && x != i && x != j ==> s1.index(x) == s2.index(x),
4247
s1.index(i) == s2.index(j),
4348
s1.index(j) == s2.index(i),
49+
// pre-conditions-end
50+
// post-conditions-start
4451
ensures
4552
s1.to_multiset() == s2.to_multiset(),
53+
// post-conditions-end
4654
{
4755
// impl-start
4856
calc! {

benches/HumanEval-RustBench/074-total_match.rs

+6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@ spec fn spec_sum(s: Seq<nat>) -> (ret: int) {
88
// pure-end
99

1010
proof fn lemma_increasing_sum(s: Seq<nat>, i: int, j: int)
11+
// pre-conditions-start
1112
requires
1213
0 <= i <= j <= s.len(),
14+
// pre-conditions-end
15+
// post-conditions-start
1316
ensures
1417
spec_sum(s.subrange(0, i)) <= spec_sum(s.subrange(0, j)),
1518
decreases j - i,
19+
// post-conditions-end
1620
{
21+
// impl-start
1722
if (i < j) {
1823
assert(spec_sum(s.subrange(0, j - 1)) <= spec_sum(s.subrange(0, j))) by {
1924
assert(s.subrange(0, j).drop_last() == s.subrange(0, j - 1));
2025
}
2126
lemma_increasing_sum(s, i, j - 1);
2227
}
28+
// impl-end
2329
}
2430
// pure-end
2531

benches/HumanEval-RustBench/additional/largest_prime_factor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn is_prime(n: u32) -> (result: bool)
3434
// impl-end
3535
}
3636

37-
spec fn is_prime_pred(n: u32) -> bool {
37+
spec fn is_prime_pred(n: u32) -> (ret: bool) {
3838
forall|k: int| 2 <= k < n ==> #[trigger] (n as int % k) != 0
3939
}
4040

benches/HumanEval-RustBench/additional/remove_duplicates.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use vstd::prelude::*;
22

33
verus! {
44

5-
spec fn in_array(a: Seq<i32>, x: i32) -> bool {
5+
spec fn in_array(a: Seq<i32>, x: i32) -> (ret: bool) {
66
exists|i: int| 0 <= i < a.len() && a[i] == x
77
}
88

benches/HumanEval-RustBench/additional/remove_elements.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use vstd::prelude::*;
22

33
verus! {
44

5-
spec fn in_array(a: Seq<i32>, x: i32) -> bool {
5+
spec fn in_array(a: Seq<i32>, x: i32) -> (ret: bool) {
66
exists|i: int| 0 <= i < a.len() && a[i] == x
77
}
88

benches/HumanEval-RustBench/additional/rolling_max.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use vstd::prelude::*;
22

33
verus! {
44

5-
spec fn seq_max(a: Seq<i32>) -> i32
5+
spec fn seq_max(a: Seq<i32>) -> (ret: i32)
66
decreases a.len(),
77
{
88
if a.len() == 0 {
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `has_close_elements`: Check if in given list of numbers, are any two numbers closer to each other than given threshold.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `separate_paren_groups`: Input to this function is a string containing multiple groups of nested parentheses. Your goal is to separate those group into separate strings and return the list of those. Separate groups are balanced (each open brace is properly closed) and not nested within each other Ignore any spaces in the input string.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `truncate_number`: Given a positive floating point number, it can be decomposed into and integer part (largest integer smaller than given number) and decimals (leftover part always smaller than 1). Return the decimal part of the number.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `below_zero`: You're given a list of deposit and withdrawal operations on a bank account that starts with zero balance. Your task is to detect if at any point the balance of account fallls below zero, and at that point function should return True. Otherwise it should return False.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `mean_absolute_deviation`: For a given list of input numbers, calculate Mean Absolute Deviation around the mean of this dataset. Mean Absolute Deviation is the average absolute difference between each element and a centerpoint (mean in this case): MAD = average | x - x_mean |
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `intersperse`: Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `parse_nested_parens`: Input to this function is a string represented multiple groups for nested parentheses separated by spaces. For each of the group, output the deepest level of nesting of parentheses. E.g. (()()) has maximum two levels of nesting while ((())) has three.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `filter_by_substring`: Filter an input list of strings only for ones that contain given substring
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `sum_product`: For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list. Empty sum should be equal to 0 and empty product should be equal to 1.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `rolling_max`: From a given list of integers, generate a list of rolling maximum element found until given moment in the sequence.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You have to write 2 functions in dafny, using the given helper functions
1+
You have to write 2 functions in verus, using the given helper functions
22
The descriptions are as follows:
33
function `is_palindrome`: Test if given string is a palindrome
44
function `make_palindrome`: Find the shortest palindrome that begins with a supplied string. Algorithm idea is simple: - Find the longest postfix of supplied string that is a palindrome. - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `string_xor`: Input are two strings a and b consisting only of 1s and 0s. Perform binary XOR on these inputs and return result also as a string.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `longest`: Out of list of strings, return the longest one. Return the first one in case of multiple strings of the same length. Return None in case the input list is empty.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `greatest_common_divisor`: Return a greatest common divisor of two integers a and b
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `all_prefixes`: Return list of all prefixes from shortest to longest of the input string
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `count_distinct_characters`: Given a string, find out how many distinct characters (regardless of case) does it consist of
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `how_many_times`: Find how many times a given substring can be found in the original string. Count overlaping cases.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `find_closest_elements`: From a supplied list of numbers (of length at least two) select and return two that are the closest to each other and return them in order (smaller number, larger number).
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `rescale_to_unit`: Given list of numbers (of at least two elements), apply a linear transform to that list, such that the smallest number will become 0 and the largest will become 1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `strlen`: Return length of given string
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `largest_divisor`: For a given number n, find the largest number that divides n evenly, smaller than n
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `factorize`: Return list of prime factors of given integer in the order from smallest to largest. Each of the factors should be listed number of times corresponding to how many times it appeares in factorization. Input number should be equal to the product of all factors
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `remove_duplicates`: From a list of integers, remove all elements that occur more than once. Keep order of elements left the same as in the input.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `flip_case`: For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `filter_by_prefix`: Filter an input list of strings only for ones that start with a given prefix.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `get_positive`: Return only positive numbers in the list.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `is_prime`: Return true if a given number is prime, and false otherwise.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `sort_third`: This function takes a list l and returns a list l' such that l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal to the values of the corresponding indicies of l, but sorted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `unique`: Return sorted unique elements in a list
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `max_element`: Return maximum element in the list.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `fizz_buzz`: Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `sort_even`: This function takes a list l and returns a list l' such that l' is identical to l in the odd indicies, while its values at the even indicies are equal to the values of the even indicies of l, but sorted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `triples_sum_to_zero`: triples_sum_to_zero takes a list of integers as an input. it returns True if there are three distinct elements in the list that sum to zero, and False otherwise.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `car_race_collision`: Imagine a road that's a perfectly straight infinitely long line. n cars are driving left to right; simultaneously, a different set of n cars are driving right to left. The two sets of cars start out being very far from each other. All cars move in the same speed. Two cars are said to collide when a car that's moving left to right hits a car that's moving right to left. However, the cars are infinitely sturdy and strong; as a result, they continue moving in their trajectory as if they did not collide. This function outputs the number of such collisions.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `incr_list`: Return list with elements incremented by 1.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `pairs_sum_to_zero`: pairs_sum_to_zero takes a list of integers as an input. it returns True if there are two distinct elements in the list that sum to zero, and False otherwise.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `triangle_area`: Given length of a side and high return area for a triangle.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `fib4`: The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: fib4(0) -> 0 fib4(1) -> 0 fib4(2) -> 2 fib4(3) -> 0 fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4). Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `is_palindrome`: Checks if given string is a palindrome
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `is_palindrome`: Checks if given string is a palindrome
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `modp`: Return 2^n modulo p (be aware of numerics).
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You have to write 2 functions in dafny, using the given helper functions
1+
You have to write 2 functions in verus, using the given helper functions
22
The descriptions are as follows:
33
function `encode_shift`: returns encoded string by shifting every character by 5 in the alphabet.
44
function `decode_shift`: takes as input string encoded with encode_shift function. Returns decoded string.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `remove_vowels`: remove_vowels is a function that takes string and returns string without vowels.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `below_threshold`: Return True if all numbers in the list l are below threshold t.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `add`: Add two numbers x and y
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `same_chars`: Check if two words have the same characters.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
You have to write 1 function in dafny, using the given helper functions
1+
You have to write 1 function in verus, using the given helper functions
22
The description is as follows:
33
function `fib`: Return n-th Fibonacci number.

0 commit comments

Comments
 (0)