Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(fv): Add target programs for quantifiers feat #145

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "exists_big_element_sum"
type = "bin"
authors = [""]
compiler_version = ">=0.35.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[requires(exists(|i| 0 <= i < 20 & arr[i] > 100))]
#[ensures(result > 100)] // We require that an element bigger than 100 exists in the array.
// Therefore we expect the sum to be bigger than 100.
fn main(arr: [u16; 20]) -> pub u64 {
let mut sum: u64 = 0;
for i in 0..20 {
sum += arr[i] as u64;
}
sum
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "exists_zero_in_array"
type = "bin"
authors = [""]
compiler_version = ">=0.35.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[requires(exists(|i| (0 <= i < 7) & (arr[i] == 0) ) )]
#[ensures(result == 0)]
fn main(arr: [u8; 7]) -> pub u64 {
let mut mul: u64 = 0;
for i in 0..7 {
mul *= arr[i] as u64;
}
mul
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "forall_max_is_max"
type = "bin"
authors = [""]
compiler_version = ">=0.35.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[requires(forall(|i, j| 0 <= i < j < 15 ==> v[i] <= v[j]))]
#[ensures(forall(|i| 0 <= i < 15 ==> v[i] <= result))]
fn main(v: [u64; 15], k: u64) -> pub u64 {
v[14] // The array is sorted and this is the last element, therefore it's the maximum element.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "forall_sum_of_evens"
type = "bin"
authors = [""]
compiler_version = ">=0.35.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#[requires(forall(|i| 0 <= i < 10 ==> arr[i] % 2 == 0)
& forall(|i| 0 <= i < 10 ==> arr[i] < 100) )]
#[ensures((result % 2 == 0) & (result < 1000))]
// The sum of an array which constist of even elements upper bounded by 100
// will be even and upper bounded by 1000
fn foo(arr: [u32; 10]) -> pub u32 {
let mut sum = 0;
for i in 0..10 {
sum += arr[i];
}
sum
}