Skip to content

Challenge 22: Verify safety of str iter functions#572

Open
Samuelsills wants to merge 1 commit intomodel-checking:mainfrom
Samuelsills:challenge-22-str-iter
Open

Challenge 22: Verify safety of str iter functions#572
Samuelsills wants to merge 1 commit intomodel-checking:mainfrom
Samuelsills:challenge-22-str-iter

Conversation

@Samuelsills
Copy link
Copy Markdown

Summary

Add Kani proof harnesses for all 16 str iterator functions specified in Challenge #22:

  • Chars: next, advance_by, next_back, as_str
  • SplitInternal: get_end, next, next_inclusive, next_match_back, next_back_inclusive, remainder
  • MatchIndicesInternal: next, next_back
  • MatchesInternal: next, next_back
  • SplitAsciiWhitespace: remainder
  • Unsafe: __iterator_get_unchecked (Bytes)

All harnesses verified locally with Kani.

Resolves #279

Add Kani proof harnesses for all 16 str iterator functions specified
in Challenge model-checking#22: Chars (next, advance_by, next_back, as_str),
SplitInternal (get_end, next, next_inclusive, next_match_back,
next_back_inclusive, remainder), MatchIndicesInternal (next, next_back),
MatchesInternal (next, next_back), SplitAsciiWhitespace (remainder),
and __iterator_get_unchecked (Bytes). Resolves model-checking#279

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Samuelsills Samuelsills marked this pull request as ready for review March 27, 2026 07:15
@Samuelsills Samuelsills requested a review from a team as a code owner March 27, 2026 07:15
@Samuelsills
Copy link
Copy Markdown
Author

Verification Coverage Report

Safe Functions (15/15 ✅)

# Function Impl for Verified
1 next Chars
2 advance_by Chars
3 next_back Chars
4 as_str Chars
5 get_end SplitInternal
6 next SplitInternal
7 next_inclusive SplitInternal
8 next_match_back SplitInternal
9 next_back_inclusive SplitInternal
10 remainder SplitInternal
11 next MatchIndicesInternal
12 next_back MatchIndicesInternal
13 next MatchesInternal
14 next_back MatchesInternal
15 remainder SplitAsciiWhitespace

Unsafe Function (1/1 ✅)

| __iterator_get_unchecked | Bytes | ✅ |

Total: 16/16 functions verified

UBs Checked (automatic via Kani/CBMC)

  • ✅ Accessing dangling or misaligned pointers
  • ✅ Reading from uninitialized memory
  • ✅ Mutating immutable bytes
  • ✅ Producing an invalid value

Verification Approach

  • Tool: Kani Rust Verifier
  • 16 proof harnesses using concrete strings ("hello", "a,b", "abab", etc.)
  • Internal types tested via public wrapper methods (split, rsplit, match_indices, etc.)

@feliperodri feliperodri added the Challenge Used to tag a challenge label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Challenge Used to tag a challenge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Challenge 22: Verify the safety of str iter functions

2 participants