Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -40,7 +40,7 @@ jobs:

deploy:
needs: build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
if: ${{ github.event_name == 'push' && startsWith('refs/heads/main', github.ref) }}

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
check-flux-on-core:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goto-transcoder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defaults:
jobs:
verify-rust-std:
name: Verify contracts with goto-transcoder
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
# Step 1: Check out the repository
- name: Checkout Repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kani-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
contents: write
pull-requests: write
if: github.repository == 'model-checking/verify-rust-std'
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Remove unnecessary software to free up disk space
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/kani.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: Verify std library (partition ${{ matrix.partition }})
# When called for autoharness only, the partitions already ran for this commit.
if: ${{ !inputs.autoharness }}
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
# This job is a required check under its matrix name, and a job skipped by a job-level
# `if:` reports without the "(os)" suffix, which would leave PRs pending. So the gate is
# on each step instead: on a PR the job starts, skips every step and passes in seconds.
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
run_kani_metrics:
name: Kani Metrics
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
name: Build JSON from logs
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
needs: [run_kani_metrics, kani_autoharness]
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand Down Expand Up @@ -373,7 +373,7 @@ jobs:
run-kani-list:
name: Kani List
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Remove unnecessary software to free up disk space
run: |
Expand Down Expand Up @@ -419,7 +419,7 @@ jobs:
run-autoharness-analyzer:
name: Kani Autoharness Analyzer
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
# Step 1: Check out the repository
- name: Checkout Repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kmir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
jobs:
run-kmir-proofs:
name: Run KMIR proofs
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
container_name: "kmir-${{ github.run_id }}"

Expand All @@ -37,7 +37,7 @@ jobs:
run-kmir-proofs-negative:
name: Run KMIR negative proofs
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
container_name: "kmir-neg-${{ github.run_id }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
check-approvals:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rapx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
verify-slice:
name: Verify core::slice with RAPx
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rustc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defaults:

jobs:
upstream_test:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}
strategy:
matrix:
# Note windows-latest is currently failing.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testable-simd-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defaults:
jobs:
testable-simd-models:
name: Test testable simd models
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout Repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verifast-negative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defaults:
jobs:
check-verifast-on-std:
name: Verify std library
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout Repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verifast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defaults:
jobs:
check-verifast-on-std:
name: Verify std library
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout Repository
Expand All @@ -29,7 +29,7 @@ jobs:

notify-btj:
name: Notify @btj
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: check-verifast-on-std
if: failure()
permissions:
Expand Down
1 change: 1 addition & 0 deletions doc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
- [27: Verify atomically reference-counted Cell implementation](./challenges/0027-arc.md)
- [28: Verify float to decimal conversion module](./challenges/0028-flt2dec.md)
- [29: Safety of `boxed`](./challenges/0029-boxed.md)
- [30: Safety and Correctness of Integer Logarithms](./challenges/0030-integer-logarithms.md)
68 changes: 68 additions & 0 deletions doc/src/challenges/0030-integer-logarithms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Challenge 30: Safety and Correctness of Integer Logarithms
Comment thread
feliperodri marked this conversation as resolved.
Resolved

- **Status:** *Open*
- **Solution:** *Option field to point to the PR that solved this challenge.*
- **Tracking Issue:** [#728](https://github.com/model-checking/verify-rust-std/issues/728)
- **Start date:** *2026/11/02*
- **Reward:** *TBD*

-------------------

## Goal

Verify the safety and correctness of `ilog10`, `ilog2`, and their checked variants in `core::num`,
including `NonZero<T>::ilog2` and `NonZero<T>::ilog10` for unsigned types and the internal
`int_log10` helpers they rely on.

## Motivation

Decimal logarithms make unsafe promises about arithmetic result bounds; binary logarithms
call intrinsics that require nonzero inputs; the `usize` decimal-logarithm wrapper creates a
`NonZero` value without checking it. Violating any of these requirements is undefined
behavior, even though the public APIs are safe.

## Description

| Function | Integer Types | Location |
|---------|---------------|----------|
| `ilog10`, `checked_ilog10`, `ilog2`, `checked_ilog2` | All signed and unsigned integer types | [int_macros.rs](https://github.com/model-checking/verify-rust-std/blob/main/library/core/src/num/int_macros.rs), [uint_macros.rs](https://github.com/model-checking/verify-rust-std/blob/main/library/core/src/num/uint_macros.rs) |
| `NonZero<T>::ilog2`, `NonZero<T>::ilog10` | All unsigned integer types | [nonzero.rs](https://github.com/model-checking/verify-rust-std/blob/main/library/core/src/num/nonzero.rs) |
| `u8_impl`, `u16_impl`, `u32_impl`, `u64_impl`, `u128_impl`, `less_than_5` | Each helper's documented input domain | [int_log10.rs](https://github.com/model-checking/verify-rust-std/blob/main/library/core/src/num/imp/int_log10.rs) |
| Internal wrappers `u8`, `u16`, `u32`, `u64`, `u128`, `usize`, `i8`, `i16`, `i32`, `i64`, `i128` | Corresponding integer types | [int_log10.rs](https://github.com/model-checking/verify-rust-std/blob/main/library/core/src/num/imp/int_log10.rs) |
Comment thread
feliperodri marked this conversation as resolved.
Resolved

- **Signed:** `i8`, `i16`, `i32`, `i64`, `i128`, `isize`.
- **Unsigned:** `u8`, `u16`, `u32`, `u64`, `u128`, `usize`.

Arbitrary-base `ilog` is excluded: its general calculation contains no direct unsafe
operations, and its unsafe dependencies overlap with the implementations above.

This extends [Challenge 11](0011-floats-ints.md) to logarithm methods, which are not
in that challenge's target list. NonZero constructor verification belongs to
[Challenge 12](0012-nonzero.md) and is not repeated here.

### Assumptions

- Existing verified NonZero contracts and documented layout guarantees may be reused.
- The repository's CI runs only 64-bit targets, so proofs need only run on the 64-bit
configuration of pointer-width-dependent code: the `usize` wrapper and the `isize` methods.
For the 16- and 32-bit configurations, it suffices to verify the `u16`/`u32` wrappers that
`usize` selects and the `i16`/`i32` wrappers that `isize` uses, and to argue that the
`NonZero::new_unchecked` conversion in the `usize` wrapper is safe for each pointer width.

### Success Criteria

Cover every input to the public methods and each internal helper's documented input domain:

- Verify the safety conditions of all unsafe operations, including result-bound assertions, nonzero-input requirements, and the `NonZero::new_unchecked` conversion in the `usize` wrapper.
- For positive input `n`, prove the result is the greatest nonnegative integer `r` with `b^r <= n`, where `b` is 2 or 10 and powers are interpreted mathematically.
Comment thread
feliperodri marked this conversation as resolved.
Resolved
- Prove checked methods return `None` for zero or negative inputs, and `ilog2` and `ilog10` panic on those inputs.
- Prove the calculations do not overflow or underflow.

All proofs must automatically ensure the absence of the following
[undefined behaviors](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):

- Invoking undefined behavior through compiler intrinsics.
- Producing an invalid value.
Comment thread
feliperodri marked this conversation as resolved.
Resolved

Note: All solutions to verification challenges need to satisfy the criteria established in the
[challenge book](../general-rules.md) in addition to the ones listed above.
Loading