Skip to content

Challenge 22: Verify safety of str iter with Kani - #741

Open
v3risec wants to merge 2 commits into
model-checking:mainfrom
v3risec:challenge-22-str-iter
Open

v3risec wants to merge 2 commits into
model-checking:mainfrom
v3risec:challenge-22-str-iter

Conversation

@v3risec

@v3risec v3risec commented Oct 27, 2026

Copy link
Copy Markdown

Summary

  • Add Kani safety verification for Chars, SplitInternal, MatchIndicesInternal, MatchesInternal, and SplitAsciiWhitespace, and prove the existing Bytes::__iterator_get_unchecked contract with proof_for_contract.
  • Check constructor states, iterator transitions, returned slice ranges, UTF-8 boundaries, and non-overlap during mixed forward/backward iteration.
  • Add a shared searcher interval model and concrete integration cases for char, empty/non-empty string needles, and character slices. Empty-string cases execute the real searcher filtering methods.
  • Extend Chars::advance_by verification with independent character-rank references, multiple chunk iterations, boundary restoration, and tail handling. Selected bounded prefix and window domains cover the full usize request range.
  • Audit all assumptions and add reachability covers after every explicit assume, together with completion covers for every harness.
  • Keep production code unchanged.

Verification

Verified locally using the repository-pinned Kani and Rust toolchain:

  • 42 Challenge 22 harnesses and 2 existing pattern harnesses passed.
  • All 357 coverage goals were satisfied.
  • All 55 remaining unwinding checks passed.

Limitations

  • String lengths, iterator windows, and concrete pattern inputs remain bounded.
  • Searcher abstractions rely on Challenge 22's permitted Pattern correctness assumption; general refinement of these abstractions is not mechanically proved.
  • Reachability covers establish feasible paths, not the validity of the assumptions themselves.

Resolves #279

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

@v3risec
v3risec requested a review from a team as a code owner October 27, 2026 09:07
@v3risec v3risec changed the title challenge 22 proof Challenge 22: Verify safety of str iter with Kani Oct 27, 2026
@feliperodri feliperodri added the Maintenance Maintenance related issues for the challange label Oct 31, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance Maintenance related issues for the challange

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Challenge 22: Verify the safety of str iter functions

2 participants