-
Notifications
You must be signed in to change notification settings - Fork 41
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
Challenge 5: Verify functions iterating over inductive data type: linked_list
#29
Comments
alloc::collections::linked_list
linked_list
Hi @qinheping and @feliperodri , can I please give this a try, thank you. |
Hi @carolynzech, @celinval, @qinheping, @feliperodri; I've been working on the challenge to verify the memory safety for this challenge. Below is the code I have written so far to prove that undefined behavior doesn't exists for use kani;
#[cfg(kani)]
#[kani::proof]
fn unbounded_check_for_clear() {
let size: i8 = kani::any();
let mut size_copy: i8 = size.clone();
let mut list: LinkedList<i8> = LinkedList::new();
// create a arbitraty size linkedlist
loop {
if size_copy == 0 {
break;
}
list.push_back(size_copy);
match size_copy.is_positive() {
true => size_copy -= 1,
false => size_copy += 1,
}
}
// check if the original kani produced size aligns with the linked list
assert_eq!(list.contains(&size), true);
assert_eq!(list.len(), size.abs().try_into().unwrap());
// clear all the items
list.clear();
//check again
assert_eq!(list.contains(&size), false);
assert_eq!(list.len(), 0);
assert!(list.is_empty());
} I have some confusions:
thank you for your time and help. |
Hi @bp7968h. We're glad you're excited about the challenge! Kani is a bounded model checker, while this challenge explicitly requires unbounded proofs. Kani has been working on extending our support for unbounded proofs with loop invariants, but we do not yet have support for inductive data structures. |
I'm having a go at this with VeriFast: linked_list.rs Just got started; only verified |
Update: I am making good progress on this challenge. So far, I have verified soundness of
|
Update: I now verified split_off and extract_if as well. (This again required a few changes to the code, such as wrapping the FnMut call in an unverified helper function (because VeriFast does not yet support trait associated types).) Therefore, I have now verified safety of all functions required by the challenge (as well as their transitive callees). I am now proving some properties of the type interpretations, such as compliance with the Send trait. Then I need to do a bit of work on VeriFast so that it (more) properly checks the "not mutating immutable bytes" requirement. (The other requirements (no accesses of dangling or misaligned pointers, no reading from uninitialized memory, no producing invalid values) should already be taken care of (with the usual caveat that VeriFast is non-foundational so there may be unknown bugs that cause unsoundness).) |
Update: VeriFast now verifies that non- I guess the next step is to get VeriFast accepted as a tool. See a completed tool application form at verifast-tool-application.txt. |
OK; I opened #213 . |
Link to PR: #30
Link to challenge: 0005-linked-list.md
The text was updated successfully, but these errors were encountered: