Skip to content

Commit

Permalink
Completed task 082
Browse files Browse the repository at this point in the history
  • Loading branch information
MRHMisu committed Sep 27, 2024
1 parent 2133f8e commit 9fb6d06
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tasks/human_eval_082.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,33 @@ use vstd::prelude::*;

verus! {

// TODO: Put your solution (the specification, implementation, and proof) to the task here
spec fn is_divisible(n: int, divisor: int) -> bool {
(n % divisor) == 0
}

fn prime_length(str: &Vec<char>) -> (result: bool)
ensures
result == if str.len() < 2 {
false
} else {
(forall|k: int| 2 <= k < str.len() ==> !is_divisible(str.len() as int, k))
},
{
if str.len() < 2 {
return false;
}
for index in 2..str.len()
invariant
2 <= index <= str.len(),
forall|k: int| 2 <= k < index ==> !is_divisible(str.len() as int, k),
{
if ((str.len() % index) == 0) {
assert(is_divisible(str.len() as int, index as int));
return false;
}
}
true
}

} // verus!
fn main() {}
Expand Down

0 comments on commit 9fb6d06

Please sign in to comment.