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

Verify String::remove in alloc::string #22

Merged
merged 41 commits into from
Dec 6, 2024
Merged

Conversation

szlee118
Copy link
Collaborator

@szlee118 szlee118 commented Dec 3, 2024

Intro

This verification harness is designed to validate the behavior of the remove method on Rust's String type. The remove method removes a character at a specified index from a string and returns it. The harness leverages Kani's verification capabilities to ensure correctness under various constraints.

Key Pointer Functions Related:

  • *const T::add / *mut T::add:
    • Used in self.vec.as_ptr().add(next) and self.vec.as_mut_ptr().add(idx) to compute the addresses of the source and destination pointers for the copy operation.
  • *const T::sub / *mut T::sub:
    • Conceptually used for addressing adjustments (e.g., computing len - next).

Purpose

The primary goal of this harness is to verify:
The remove method correctly decreases the string length by one.
The character removed from the string is valid and remains consistent with the original input constraints.

Resolves model-checking#76

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

xsxszab and others added 30 commits October 7, 2024 12:44
implemented integer type proof for contract for fn add, sub and offset
Combines macros for different types.
…allocation api, modified their proof for harness accordingly
library/alloc/src/string.rs Outdated Show resolved Hide resolved
library/alloc/src/string.rs Outdated Show resolved Hide resolved
library/alloc/src/string.rs Outdated Show resolved Hide resolved
@stogaru stogaru merged commit f552676 into usage_proofs Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants