Repository navigation
Commit efe9be5
Verify String functions (Challenge 10): unbounded receivers, exhaustive content, split panic harnesses
Rework of the Challenge 10 module per the 2026-09-12 review, on main at
cd371e0 (nightly-2026-09-25, Kani 1640445, CBMC 6.11.0).
- Every function runs on its real, unmodified body; no cfg(not(kani)),
no kani::assume. Two stubs, both on retain's debug_assert!: its new
PanicGuard::drop calls core::str::from_utf8, whose loop invariants
abstract the validator under -Z loop-contracts; the exact-content
harness replaces it by a per-character validator, the visits harness
by a proof-backed Ok.
- Symbolic length and capacity (bounded only by CBMC's allocation model,
the pattern of the VecDeque proofs) for pop, remove, insert, insert_str,
split_off, drain, into_boxed_str, leak and the receivers of replace_range
and remove_matches; no unwind bound on any receiver-length dimension.
The receivers are zeroed allocations: at this pin a region initialized
by a symbolic-length write_bytes makes CBMC run out of memory after the
properties are decided whenever the model's length is large.
- Exhaustive-content twins (<= 64 bytes, capacity still symbolic, a window
of symbolic multi-byte chars at a symbolic boundary) for pop, remove,
drain's iterator, remove_matches and replace_range, results asserted
exactly.
- remove_matches is verified against the most general Searcher the
contract admits (arbitrary char-boundary ranges, empty ranges allowed).
- retain: exact content on <= 4 characters, visit order and length on
<= 5, on fixed arrays (slice accesses in unrolled harness loops are
expensive at this pin: Kani's offset model encodes every address check
with a case split over the program's objects); from_utf16{le,be}{,_lossy}
(<= 12 bytes) carry functional specifications. The bounds and their
measured costs are stated where they are defined.
- 12 should_panic harnesses, one per documented panic cause (index inside a
multi-byte character; index past the end) for each index-taking function.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqLN2C9EzETaAMVsU7XsoC1 parent e290870 commit efe9be5
1 file changed
Lines changed: 1013 additions & 266 deletions
0 commit comments