-
Notifications
You must be signed in to change notification settings - Fork 6
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
Finished task 139 #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this! Looks like there was some tricky math involved in your proof.
use vstd::prelude::*; | ||
|
||
verus! { | ||
|
||
// TODO: Put your solution (the specification, implementation, and proof) to the task here | ||
// specification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit tricky to map this spec to the one in the prompt. Could we instead use something like this?
spec fn factorial(n: int) -> int
decreases n,
{
if n <= 1 {
0
} else {
n * factorial(n - 1)
}
}
spec fn brazilian_factorial(n: int) -> int
decreases n,
{
if n <= 1 {
factorial(1)
} else {
factorial(n) * brazilian_factorial(n - 1)
}
}
tasks/human_eval_139.rs
Outdated
|
||
pub fn brazilian_factorial_impl(n: u32) -> (bf: u32) | ||
requires | ||
0 < n < 4294967295, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace 4294967295 with u32::MAX
to make the intent clearer?
I also suspect that the next requirement is a strictly stronger requirement, no?
I'm also a bit reluctant to have a requirement that asks that you already know something about the thing you're about to compute. Could we instead use a strategy similar to this version of fib
?
The changes have been made. Thanks for the suggestion! This way is much simpler. I also changed 255 to u8::MAX in task025 (everything else stays the same) |
Great, thanks for the changes! |
No description provided.