Repository navigation
Challenge 22: Verify the safety of str iter functions with Kani - #764
Open
DevinWatson wants to merge 5 commits into
Open
DevinWatson wants to merge 5 commits into
DevinWatson wants to merge 5 commits into
Conversation
…13-constructor invariants) - Replace ModelSearcher global static mut NMB_CALLS/NMB_RES with safe struct fields - Replace string literal in check_chars_nth_caller with symbolic 8-byte buffer (2 arbitrary chars + symbolic ASCII tail) - Add check_str_iter_initial_invariants covering all 13 public &str iterator constructors and len > 2^48 witness - Add exact 0..=32 range surjectivity covers to check_kani_fold_bounded32_soundness and remove internal helper cover
…at they actually do Two verification-only renames, no semantic change to any proof: - array/iter/iter_inner.rs: kani_fold_bounded32 -> kani_fold_arity32, and check_kani_fold_bounded32_soundness -> check_kani_fold_arity32_soundness. The 32 is the chunk ARITY of as_chunks::<32>(), not a bound on the input string; Chars::advance_by still runs on a str of symbolic length up to MAX_ALLOCATION_BYTES. The doc comment now says so, and says the model is an over-approximation of the per-chunk reduction whose output range 0..=32 is still exact (soundness + range surjectivity in the same harness). - str/iter.rs: check_split_internal_next_match_back -> check_split_internal_next_back_via_matcher, with a comment naming the arm it covers (self.matcher.next_match_back() inside SplitInternal::next_back). SplitInternal has no method of that name; issue model-checking#279 notes the page's wording. Re-verified on the new bytes at the pinned tools (nightly-2026-10-23, Kani c5e65fdfc3e1, CI flags, --object-bits 12, 8 GiB per CBMC process): 26/26 SUCCESSFUL (25 str::iter::verify + array::iter), 7m13s wall, 6.68 GB peak RSS.
…loop invariant, and arbitrary-subslice Bytes proof
DevinWatson
force-pushed
the
ch22-str-iter-solution
branch
2 times, most recently
from
November 23, 2026 17:03
726126f to
f0bb11e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #279
This pull request verifies Challenge 22 (
library/core/src/str/iter.rs) with Kani over strings of unbounded symbolic length (0..=2^51 - 1bytes) and arbitraryusizecounts and byte offsets. It proves memory safety, pointer provenance, slice/char-boundary invariants, and safety postconditions for all15safe target functions withunsafeblocks, verifiesBytes::__iterator_get_uncheckedagainst its safety contract via#[kani::proof_for_contract](including arbitrary byte subslices starting mid-multibyte character, and additionally checked under-Z uninit-checks), checks initial constructor invariants across all13public&striterator constructors (check_str_iter_initial_invariants), and adds harnesses forCharIndices::{next, next_back}and symbolic callerChars::nth.Key properties of the solution:
#[cfg(not(kani))]body swaps: The diff adds+1,596 / -0lines acrosslibrary/core/src/str/iter.rs(+1,347 / -0),library/core/src/array/iter/iter_inner.rs(+239 / -0), andlibrary/core/src/slice/iter.rs(+10 / -0). Only#[cfg(kani)]bindings/assertions,#[safety::loop_invariant]/#[cfg_attr(kani, kani::loop_modifies(...))]attributes onChars::advance_by, and verification modules/helpers are added;library/core/src/ops/index_range.rsand every workflow/script are untouched.#[kani::unwind]attributes and zerostatic mutvariables: All four loops inChars::advance_by(the 32-byte chunk loop, its 32-elementstart_bytesfill loop, the continuation-byte skip loop, and the trailing char-by-char loop) are discharged inductively via loop invariants, andModelSearcherstores its call/result bookkeeping in safe struct fields (nmb_calls,nmb_res) with zero global mutable statics.Chars::advance_byloop invariants & local state: Entry state (initial_remainder,original,original_ptr,original_full) is captured locally under#[cfg(kani)]insideChars::advance_byso external callers (s.chars().nth(k),core::fmt, etc.) compose without harness setup.kani_char_loop_invcontains zerokani::assumecalls; Challenge Assumption (4) is instantiated outside the invariant predicate on the immutable entry sliceoriginal(assume_original_utf8_at).core::slice::Itermethod stubs:check_chars_advance_byruns the real shippedslice::Iterimplementation (as_chunks::<32>(),chunks.next(),as_slice(),next(),advance_by());slice/iter.rsadds only a read-only#[cfg(kani)]projectionIter::kani_parts_for_ch22for loop invariants, and all72/72existingslice::iterharnesses pass.PolymorphicIter::kani_fold_arity32& exact per-chunk tally (M3andM5closed):kani_fold_arity32computes the exact Boolean sum of the 32-element chunk via branch-free row-first SWAR[u64; 4]read_unaligned(0kani::any()nondeterminism) and drainsself.alivetoend..endidentically to realPolymorphicIter::fold.check_kani_fold_arity32_soundnessproves bit-for-bit equality against both realPolymorphicIter::foldand.into_iter().map(|v| v as u8).sum::<u8>()across all2^32[bool; 32]arrays and all valid subranges0 <= start <= end <= 32(16.64 s,6/6covers). InsideChars::advance_by, the fill loop verifiesstart_bytes[i] == !utf8_is_cont_byte(chunk[i])and the chunk step verifiesremainder == rem_before_chunk - sum_bool32(&start_bytes), catching both fill-loop corruption (M5) and per-chunk under-counting (M3:remainder -= 1).-Z uninit-checksonBytes:any_allocinitializes symbolic allocations viawrite_bytes+__CPROVER_havoc_slice, everychar-producing harness explicitly asserts Unicode scalar validity (u <= 0x10FFFF && !(0xD800..=0xDFFF).contains(&u)), andcheck_bytes_iterator_get_uncheckedalso passes under-Z uninit-checks(0/323failed,3/3covers,3.36 s).Disclosure: this solution was produced with AI assistance and verified against the repository's CI checks and fault-injection suite.
Rebase update (2026-11-23, commit
f0bb11e63ce)main(1feeadd9379, pinned tonightly-2026-11-19and Kani9834c96ce90f) with zero conflicts.impl Pattern for ModelPatterninlibrary/core/src/str/iter.rstounsafe impl Pattern for ModelPatternwith a// SAFETY:justification forrust-lang/rust#165681/verify-rust-std#753.+1,596 / -0zero production edits (str/iter.rs+1,347 / -0,array/iter/iter_inner.rs+239 / -0,slice/iter.rs+10 / -0); all harnesses, loop invariants, and postconditions are unchanged from8276932eda2below and re-checked onnightly-2026-11-19/ Kani9834c96ce90fvia CI.Hardening update (2026-11-19, commit
8276932eda2)Addressing every remaining gap from the 2026-11-18 revision (
6fd1aafd04c) while keeping strict+N / -0zero production edits,0unwinds, and0static mut:M3(remainder -= 1per-chunk tally) andM5(fill-loop inversion) on unbounded strings: Replaced the nondeterministickani_fold_arity32over-approximation with an exact row-first SWAR[u64; 4]sum (bool32_valid,sum_bool32, andkani_fold_arity32), proved bit-for-bit equal to realPolymorphicIter::foldandIterator::sumover all2^32inputs and all subranges0 <= start <= end <= 32(check_kani_fold_arity32_soundness,16.64 s,6/6covers). BothM3andM5are now caught directly by explicit CBMC property failures oncheck_chars_advance_by.kani::assumefromkani_char_loop_inv:kani_char_loop_invis now completely side-effect-free (checkingkani_valid_utf8_step(original, cur)purely), with Challenge Assumption (4) (assume_original_utf8_at) applied outside the invariant predicate on the immutable entry sliceoriginal(at loop-4 entry and after the unsafe step). This also reducedcheck_chars_nth_callerfrom129 s / 6.69 GiBto85.64 s / 6.20 GiB.Bytes::__iterator_get_unchecked(proof_for_contract) &-Z uninit-checks: Upgraded to an arbitrary byte subslices.as_bytes()[lo..hi](0 <= lo <= hi <= s.len()), explicitly covering mid-multibyte cursors (lo > 0 && !s.is_char_boundary(lo)), and verified under-Z uninit-checks(0/323failed,3/3covers,3.36 s).Chars::advance_by&SplitInternalpostconditions:check_chars_advance_bynow also assertschars.as_str()length (total_len - consumed) and pointer (s.as_ptr().add(consumed));SplitInternal::{next, next_inclusive, next_back, next_back_inclusive}now additionally verify exactmatcher.front/matcher.backcursor transitions on both match and exhausted arms.Re-verification on the exact pushed bytes (
8276932eda2) (same pins and flags:nightly-2026-10-23, Kanic5e65fdfc3e1, CBMC6.11.0, exactscripts/run-kani.shflags,--object-bits 12,8 GiBper CBMC process,--jobs=2):str::iter::verify::(--jobs=2):25 / 25SUCCESSFUL,0 / 10,555checks failed,109 / 109covers satisfied, wall6m37.90s, peak RSS6.20 GiB(down from7m13s/6.68 GiB).array::iter::iter_inner::check_kani_fold_arity32_soundness:1 / 1SUCCESSFUL,0 / 437checks failed,6 / 6covers satisfied,16.64 s,1.67 GiBRSS.slice::iter::verify::(--jobs=2):72 / 72SUCCESSFUL,0 / 26,932checks failed, wall4m40.92s, max11.56 s, peak RSS2.77 GiB.Bytes::__iterator_get_uncheckedwith-Z uninit-checks:1 / 1SUCCESSFUL,0 / 323checks failed,3 / 3covers satisfied,3.36 s../scripts/check_rustc.sh(./x fmt --checkonnightly-2026-10-23,7,389files): exit0(0:43).RUSTC_BOOTSTRAP=1 cargo check -p core -p alloc: exit0.Fault injection on exact final bytes (
8276932eda2,6 / 6caught strictly by explicit CBMC property failures,0survivors):M2bytes_skipped += CHUNK_SIZE->+= CHUNK_SIZE - 1check_chars_advance_by407.19 s,Check invariant after step for loop advance_by.1)M3remainder -= start_bytes.into_iter()...sum::<u8>() as usize->remainder -= 1check_chars_advance_by202.37 s,chunk remainder decremented by exact start_bytes count)M4let slurp = super::validations::utf8_char_width(b)->let slurp = 1usizecheck_chars_advance_by145.35 s,Check invariant after step for loop advance_by.3)M5start_bytes[i] = !utf8_is_cont_byte(chunk[i])->utf8_is_cont_byte(chunk[i])check_chars_advance_by235.16 s,fill loop records !utf8_is_cont_byte(chunk[i]))M6SplitInternal::next:self.start = b->self.start = acheck_split_internal_next10.19 s, assertion failure)M7Bytes::__iterator_get_unchecked:#[requires(idx < self.0.len())]-><=check_bytes_iterator_get_unchecked3.24 s, dereference / out-of-bounds failure)(Plus the 27-mutant baseline suite across all targets from the initial verification.)
What is assumed
All target harnesses construct strings using
any_haystack(), allocating a symbolic byte length0..=(1 << 51) - 1(MAX_ALLOCATION_BYTES, matching--cbmc-args --object-bits 12;check_str_iter_initial_invariantsalso includescover!(s.len() > (1usize << 48))) initialized viawrite_bytes(p, 0, len)followed by__CPROVER_havoc_slice(p, len)(check_arbitrary_initialized_buffer). No harness assumes a maximum string length or concrete byte content (see Limits for the 8-byte symbolic caller buffer incheck_chars_nth_caller).Where Challenge 22 permits assumptions 1–4 (
doc/src/challenges/0022-str-iter.md), they are scoped as follows:slicemodule is safe and functionally correct): Realslice::Itermethods run unstubbed everywhere. Only the read-only accessorIter::kani_parts_for_ch22(&self) -> (*const T, *const T)is added under#[cfg(kani)]inlibrary/core/src/slice/iter.rssoChars::advance_byloop invariants can state pointer arithmetic obligations. All72/72slice::iterharnesses pass.str::patternis safe and functionally correct):SplitInternal,MatchIndicesInternal, andMatchesInternalharnesses instantiatePatternwithModelPattern/ModelSearcher, a nondeterministic over-approximation yielding arbitrary ranges[a, b)that satisfySearcherandReverseSearchersafety contracts (lo <= a <= b <= hi,is_char_boundary(a) && is_char_boundary(b), zero-width matches/rejects permitted,Doneallowed only oncefront == back). Inductive preservation of the searcher range invariant across all 4 operations is verified bycheck_model_searcher_step, and base-case initialization across all 13 public&striterator constructors is verified bycheck_str_iter_initial_invariants. Compatibility with realCharSearcher(0..=4bytes) andStrSearcher(1..=2byte needles) was separately cross-checked in isolated out-of-patch bounded harnesses (9/9passing).str::validationsis functionally correct):Chars::{next, next_back},CharIndices::{next, next_back}, andChars::advance_byexecute realnext_code_point,next_code_point_reverse, andutf8_is_cont_byte. Onlyvalidations::utf8_char_widthis stubbed incheck_chars_advance_byandcheck_chars_nth_callerby the assumption-free branch tablestub_utf8_char_width, proved identical tovalidations::utf8_char_widthfor all256possibleu8values bycheck_utf8_char_width_refinement.str::iteriterators derive from valid UTF-8&str): Harnesses encode local valid-UTF-8 facts at the cursor positions inspected:Chars::next/CharIndices::next:is_valid_first_utf8_char(RFC 3629 Table 3-7 at the current front cursor).Chars::next_back/CharIndices::next_back:is_valid_last_utf8_char(RFC 3629 Table 3-7 within the last1..=4bytes).Chars::advance_by: entry byte0(if non-empty) is not a continuation byte (assume_original_utf8_at(&original, 0)), andassume_original_utf8_atis invoked outside the invariant predicate at loop-4 entry and after each unsafe step on the immutable entry sliceoriginalcaptured at entry (never consulting mutatedself.iter,slurp, orremainder).kani_char_loop_invitself is pure and side-effect-free. Out-of-patch bounded checks verified thatcore::str::from_utf8impliesassume_original_utf8_atandis_valid_{first,last}_utf8_charat every char boundary across all0..=6byte buffers.Per-function results (
8276932eda2,--jobs=2, 8 GiB CBMC cap)--jobs=2(s)Chars::nextstr::iter::verify::check_chars_next1..=4bytes matchesch.len_utf8(); equals RFC-3629decode_first; coversNoneand widths1..=42.33Chars::advance_bystr::iter::verify::check_chars_advance_byremainder: usize; inductive invariants on all 4 loops (purekani_char_loop_inv); exact fill-loop check (M5) & exact SWAR chunk tally (M3);consumed <= len;tail.len()&tail.as_ptr();Ok(()) => consumed >= remainder,Err(n) => len == 0 && remainder - n.get() <= len;6/6covers (4.73 GiBsolo RSS)236.33Chars::advance_by(caller)str::iter::verify::check_chars_nth_callerk: usize = kani::any()passed to.chars().nth(k)on 8-byte buffer populated from two arbitrarykani::any::<char>()scalars at offsets0and4plus symbolic ASCII fill bytes; scalar validity & membership;6/6covers (85.64 s/6.20 GiBsolo)86.64Chars::next_backstr::iter::verify::check_chars_next_back1..=4bytes matcheslast_char_lenandch.len_utf8(); equalsdecode_first; coversNoneand widths1..=430.80Chars::as_strstr::iter::verify::check_chars_as_str[start, end)preserves valid slice range, pointer, length, and boundaries2.79SplitInternal::get_endstr::iter::verify::check_split_internal_get_endsplit_invariant; setsfinished = true; exact trailing slice[start, end)iff!was_finished && (allow_trailing_empty || end > start)7.25SplitInternal::nextstr::iter::verify::check_split_internal_nextsplit_invariant,allow_trailing_empty,end,matcher.back; yields exact prefix/trailing slice[so, a)or[so, eo)and exactmatcher.frontcursor17.90SplitInternal::next_inclusivestr::iter::verify::check_split_internal_next_inclusive[so, b)and exactmatcher.front/matcher.backtransitions12.49SplitInternal::next_match_back(next_back)*str::iter::verify::check_split_internal_next_back_via_matchersplit_invariant; matchesassert_next_back_specvia safe struct fields (nmb_calls/nmb_res) including!allow_trailing_emptyempty-tail skip (2nd search) and exactmatcher.front/matcher.backtransitions; idempotent oncefinished23.38SplitInternal::next_back_inclusivestr::iter::verify::check_split_internal_next_back_inclusive[b, eo)/[b, e1), exact matcher cursors, and idempotence oncefinished24.78SplitInternal::remainderstr::iter::verify::check_split_internal_remainder[start, end)iff!finishedon valid pointer and char boundaries17.59MatchIndicesInternal::nextstr::iter::verify::check_match_indices_internal_nextsearcher_invariant; returned(idx, sub)matches reported(a, b)ats.as_ptr().add(idx)on char boundaries5.27MatchIndicesInternal::next_backstr::iter::verify::check_match_indices_internal_next_back(idx, sub)equals(a, s[a..b])on valid char boundaries6.76MatchesInternal::nextstr::iter::verify::check_matches_internal_nextsearcher_invariant; returnedsubequalss[a..b]on valid char boundaries5.06MatchesInternal::next_backstr::iter::verify::check_matches_internal_next_backsubequalss[a..b]preservingsearcher_invariant7.27SplitAsciiWhitespace::remainderstr::iter::verify::check_split_ascii_whitespace_remainder[start, end)view iff!finishedover valid subslice1.54Bytes::__iterator_get_uncheckedstr::iter::verify::check_bytes_iterator_get_unchecked(proof_for_contract)#[requires(idx < self.0.len())]over arbitrary byte subslices.as_bytes()[lo..hi](covering mid-multibyte!is_char_boundary(lo)) and returnss.as_bytes()[lo + idx]; also passes under-Z uninit-checks(3.36 s)2.2913public&striterator constructorsstr::iter::verify::check_str_iter_initial_invariantsstart == 0,end == s.len(),!finished) and O(1).as_ptr()/.len()remainder()/as_str()equality +s.len() > 2^48witness2.41CharIndices::next(extra)str::iter::verify::check_char_indices_nextstart, updatedoffset() == start + ch.len_utf8(), RFC-3629decode_first25.94CharIndices::next_back(extra)str::iter::verify::check_char_indices_next_backend - k, remaining byte count(end - start) - k, RFC-3629decode_first56.40PolymorphicIter::kani_fold_arity32array::iter::iter_inner::check_kani_fold_arity32_soundnessPolymorphicIter::fold,kani_fold_arity32, andIterator::sumacross all2^32[bool; 32]arrays and all subranges0 <= start <= end <= 32, exact drainedend..end, and surjectivity (6/6covers)16.64(solo)bool32_validequivalencestr::iter::verify::check_bool32_valid_equivalence[u64; 4]((w[0] | w[1] | w[2] | w[3]) & 0xFEFE_FEFE_FEFE_FEFE) == 0equalskani::mem::can_dereference::<[bool; 32]>(5/5covers)1.25utf8_char_widthrefinementstr::iter::verify::check_utf8_char_width_refinementvalidations::utf8_char_width(b)andraw_utf8_char_width(b)for all256u8values0.29ModelSearcherstep invariantstr::iter::verify::check_model_searcher_stepnext,next_back,next_match,next_match_back9.44str::iter::verify::check_chunk_pointer_expressionarith_offsetandwrapping_addover symbolic offsets0.03str::iter::verify::check_arbitrary_initialized_bufferany_allocbuffers0.14*Note:
doc/src/challenges/0022-str-iter.mdlistsSplitInternal::next_match_back; inlibrary/core/src/str/iter.rs, the corresponding method callingself.matcher.next_match_back()isSplitInternal::next_back, which is the method verified here.Proof of
Chars::advance_by(zero unwinds, zero globals, pure invariants)#[safety::loop_invariant]reading(cp, ce) = chunks.kani_parts_for_ch22()(read-only pointer accessor inlibrary/core/src/slice/iter.rs) to trackbytes_skipped % 32 == 0,bytes_skipped <= original_full, exactarith_offsetpointer endpoints, andinitial_remainder - remainder <= bytes_skipped.#[cfg_attr(kani, kani::loop_modifies(&raw mut start_bytes))]and#[cfg_attr(kani, kani::loop_invariant(... && verify::bool32_valid(&raw const start_bytes)))](SWAR[u64; 4]validity predicate proved equal tokani::mem::can_dereferenceon[bool; 32]), plus an in-bodykani::assert(start_bytes[i] == !utf8_is_cont_byte(chunk[i]))catching fill-loop corruption (M5), avoiding any#[kani::unwind(32)].bool/u8fold: Calls#[cfg(kani)] PolymorphicIter::kani_fold_arity32(library/core/src/array/iter/iter_inner.rs, avoidingindex_range.rsedits orkani#4084generic-trait contract issues), computing the exact row-first SWAR Boolean sum overself.data[start..end]and drainingself.alivetoend..end, proved bit-for-bit identical to realPolymorphicIter::foldandIterator::sumincheck_kani_fold_arity32_soundness. Immediately after the subtraction,kani::assert(remainder == rem_before_chunk - sum_bool32(&start_bytes))catches per-chunk tally bugs (M3).kani_cont_loop_inv(cur >= skipped && cur <= total_len) and the pure side-effect-freekani_char_loop_inv(cur <= total_len,kani_valid_utf8_step(original, cur), andinitial_remainder - remainder <= cur), with Challenge Assumption (4) (assume_original_utf8_at) instantiated outside the invariant predicate on the immutable entry sliceoriginal.Not proved, and limits
2^51 - 1bytes): CBMC's pointer offset model under--cbmc-args --object-bits 12limits allocations to(1 << 51) - 1bytes on 64-bit targets. All lengths are symbolic below this bound and no arithmetic assumes a smaller bound. Termination is not proved.is_valid_{first,last}_utf8_char,assume_original_utf8_at, andkani_valid_utf8_stepencode Assumption(4)locally on inspected cursor bytes rather than asserting whole-string UTF-8 well-formedness;kani_valid_utf8_stepconstrains leading-byte width to the next boundary without trailing-byte surrogate checks (sufficient foradvance_by, and cross-checked out-of-patch up to6bytes againstcore::str::from_utf8).-Z loop-contractsrequires a loop contract on the innerfor i in 0..32loop nested inside the contracted chunk loop,start_bytesis havoced to arbitrary valid[bool; 32]at fill-loop exit: every fill-loop iteration is verified to write!utf8_is_cont_byte(chunk[i])(catchingM5), and the subsequent fold/subtraction is verified to decrementremainderby the exact sum ofstart_bytes(catchingM3), while full end-to-end whole-string exact character counting across an unbounded number of 32-byte chunks is not claimed (the challenge criteria are memory safety and contract compliance).check_chars_nth_caller: Tests symbolic unboundedk: usize = kani::any()against.chars().nth(k)over an 8-bytemalloc(8)buffer containing two arbitrarykani::any::<char>()Unicode scalars (c0at offset0,c1at offset4) and symbolic ASCII fill bytes (kani::any::<u8>() & 0x7F), keeping constant length8 < 32soChars::advance_by's local loop invariants andChars::nextdecoding compose without concrete literals (Iterator::nthis not a Challenge 22 target, andChars::advance_byitself is verified over unbounded symbolic strings up toMAX_ALLOCATION_BYTESincheck_chars_advance_by).Split*/Match*proofs:Split*,Matches*, andMatchIndices*are proved inductively for one arbitrary transition from any invariant-satisfying state (next_backalso proves idempotence whenfinished == true) againstModelPattern/ModelSearcher, whilecheck_str_iter_initial_invariantsproves the base-case initial invariants across all13public&striterator constructors. RealCharSearcher(0..=4bytes) andStrSearcher(1..=2byte needles) compatibility was cross-checked out-of-patch (9/9passing).scripts/run-kani.sh,-Z valid-value-checks,-Z uninit-checks, and aliasing checks are not passed in CI (#733); allocations are explicitly zero-initialized and havoced,charvalidity is asserted explicitly, andcheck_bytes_iterator_get_uncheckedwas additionally verified under-Z uninit-checks(3.36 s,0/323failed). Pre-existingBytes::__iterator_get_uncheckedcarries#[requires(idx < self.0.len())]only without#[ensures], whilecheck_bytes_iterator_get_uncheckedassertsval == s.as_bytes()[lo + idx]insideproof_for_contract. Alsoslice/iter.rs(+10lines) andarray/iter/iter_inner.rs(+239lines) carry#[cfg(kani)]helpers/proofs outsidestr/iter.rs.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.