Uh oh!
There was an error while loading. Please reload this page.
Add Kani harnesses for Challenge 18: slice iter functions - #651
Open
MavenRain wants to merge 1 commit into
Open
Conversation
Cover both success-criteria tables of challenge 0018-slice-iter. Part 1: prove the 16 iterator! functions for IterMut (Iter coverage already exists on main) and next/size_hint for SplitN, SplitNMut, RSplitN, and RSplitNMut through the forward_iterator! path. Part 2: add safety contracts for all 9 __iterator_get_unchecked impls that exist in the current snapshot (Windows, Chunks, ChunksMut, ChunksExact, ChunksExactMut, RChunks, RChunksMut, RChunksExact, RChunksExactMut). Each contract lives on a private contracted inherent method that the trait method delegates to, and is proved with proof_for_contract. ArrayChunks and ArrayChunksMut no longer exist in slice/iter.rs. Also prove all listed safe functions with unsafe bodies, plus ArrayWindows and the Split family. Proofs instantiate generic code over representative types ((), u8, char, (char, u8)). Element values are symbolic in every harness. Backing lengths are symbolic up to isize::MAX for () and u32::MAX for u8. Looping harnesses use verified kani::unwind bounds. Verified locally at the pinned Kani commit d4df833c (nightly-2025-11-25): 385 of 385 harnesses successful. Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
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 freeto 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.
Solution to Challenge 18: verify the safety of
sliceiter functions.Part 1
iterator!macro are proved forIterMut(make_slice,len,is_empty,next,size_hint,count,nth,advance_by,last,fold,for_each,position,rposition,next_back,nth_back,advance_back_by).Itercoverage already exists on main and stays green.nextandsize_hintare proved forSplitN,SplitNMut,RSplitN, andRSplitNMutthrough theforward_iterator!path.Part 2
slice/iter.rscontains 9__iterator_get_uncheckedimpls:Windows,Chunks,ChunksMut,ChunksExact,ChunksExactMut,RChunks,RChunksMut,RChunksExact,RChunksExactMut.ArrayChunksandArrayChunksMutno longer exist in this file.#[requires]/#[ensures]) on a private contracted inherent method. The__iterator_get_uncheckedtrait method delegates to it. Each contract is proved with#[kani::proof_for_contract]. This pattern sidesteps the known interaction betweenproof_for_contractand generic trait methods.Iter::new,IterMut::new,ChunksExact::new,ChunksExactMut::new,RChunksExact::new,RChunksExactMut::new),IterMut::{into_slice, as_mut_slice}, theSplitfamily,ArrayWindows, and the chunk-familynext/nth/last/next_back/nth_backmethods.Approach and disclosures
()(ZST),u8,char(validity invariant), and(char, u8)(padding). Kani cannot emit one proof for allT; this per-type spread is the same pattern the merged solutions for challenges 16 and 17 use.isize::MAXfor()andu32::MAXforu8;charand(char, u8)use smaller symbolic bounds to keep solver time practical.fold,for_each,position,rposition,last, and the split families) use#[kani::unwind]bounds. Kani verifies the unwinding assertion, so a bound that is too small fails loudly.d4df833c(toolchainnightly-2025-11-25): 385 of 385 harnesses successful, 0 failures.Resolves#282
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.