Skip to content

Commit 9da1baa

Browse files
thanhnguyen-awscarolynzechtautschnig
authored
Add Challenge 16: Iterator (#260)
In this PR, I add a challenge for Iterator functions in (library/core/src/iter/adapters) By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Carolyn Zech <[email protected]> Co-authored-by: Michael Tautschnig <[email protected]>
1 parent d2b6a64 commit 9da1baa

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

doc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
- [13: Safety of `CStr`](./challenges/0013-cstr.md)
3030
- [14: Safety of Primitive Conversions](./challenges/0014-convert-num.md)
3131
- [15: Contracts and Tests for SIMD Intrinsics](./challenges/0015-intrinsics-simd.md)
32+
- [16: Verify the safety of Iterator functions](./challenges/0016-iter.md)
3233
- [17: Verify the safety of slice functions](./challenges/0017-slice.md)
3334
- [18: Verify the safety of slice iter functions](./challenges/0018-slice-iter-pt1.md)

doc/src/challenges/0016-iter.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Challenge 16: Verify the safety of Iterator functions
2+
3+
- **Status:** Open
4+
- **Tracking Issue:** [#280](https://github.com/model-checking/verify-rust-std/issues/280)
5+
- **Start date:** *2025-03-07*
6+
- **End date:** *2025-10-17*
7+
- **Reward:** *10,000 USD*
8+
9+
-------------------
10+
11+
12+
## Goal
13+
14+
Verify the safety of iter functions that are defined in (library/core/src/iter/adapters):
15+
16+
17+
18+
### Success Criteria
19+
20+
Write and prove the contract for the safety of the following unsafe functions:
21+
22+
| Function | Defined in |
23+
|---------| ---------|
24+
|__iterator_get_unchecked| clone.rs|
25+
|next_unchecked| clone.rs|
26+
|__iterator_get_unchecked| copied.rs|
27+
|__iterator_get_unchecked| enumerate.rs|
28+
|__iterator_get_unchecked | fuse.rs|
29+
|__iterator_get_unchecked | map.rs|
30+
|next_unchecked | map.rs|
31+
|__iterator_get_unchecked | skip.rs|
32+
|__iterator_get_unchecked | zip.rs|
33+
|get_unchecked| zip.rs|
34+
35+
Prove the absence of undefined behavior for following safe abstractions:
36+
37+
| Function | Defined in |
38+
|---------| ---------|
39+
|next_back_remainder| array_chunks.rs|
40+
|fold| array_chunks.rs|
41+
|spec_next_chunk| copied.rs|
42+
|next_chunk_dropless| filter.rs|
43+
|next_chunk| filter_map.rs|
44+
|as_array_ref | map_windows.rs|
45+
|as_uninit_array_mut | map_windows.rs|
46+
|push | map_windows.rs|
47+
|drop | map_windows.rs|
48+
|original_step | step_by.rs|
49+
|spec_fold| take.rs|
50+
|spec_for_each| take.rs|
51+
|fold| zip.rs|
52+
|next| zip.rs|
53+
|nth| zip.rs|
54+
|next_back| zip.rs|
55+
|spec_fold| zip.rs|
56+
57+
58+
59+
The verification must be unbounded---it must hold for slices of arbitrary length.
60+
61+
The verification must hold for generic type `T` (no monomorphization).
62+
63+
### List of UBs
64+
65+
All proofs must automatically ensure the absence of the following undefined behaviors [ref](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):
66+
67+
* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
68+
* Reading from uninitialized memory except for padding or unions.
69+
* Mutating immutable bytes.
70+
* Producing an invalid value
71+
72+
73+
Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md)
74+
in addition to the ones listed above.

0 commit comments

Comments
 (0)