Skip to content

Non-nested quantifier predicates can silently discard default checks #5141

Open

Description

@v3risec

Summary

Kani can silently discard default verification checks when extracting a non-nested quantifier predicate into a pure Boolean expression. As a result, a harness can report VERIFICATION: SUCCESSFUL even though evaluating the predicate would violate an arithmetic or intrinsic check.

This issue focuses on compiler-generated default checks and the differences between ordinary Rust assertions and the property classes recognized by Kani's optional UB-check guards.

Issue #5010 already reports that an explicit assert! inside a quantifier predicate can be dropped. The cases below extend that finding to default arithmetic and intrinsic checks, without involving branches or nested quantifiers.

Environment

  • OS: x86_64 Linux
  • Kani: 0.68.0 (source builds at the revisions listed above)
  • Rust: rustc 1.101.0-nightly (nightly-2026-10-23)
  • CBMC: 6.11.0
  • CaDiCaL: 3.0.0

Reproduce

Save the following as repro.rs:

#![feature(core_intrinsics)]

#[kani::proof]
fn checked_addition() {
    assert!(kani::forall!(|i in (0, 2)| {
        let _ = i + usize::MAX;
        true
    }));
}

#[kani::proof]
fn exact_division() {
    assert!(kani::forall!(|i in (0, 2)| {
        let _ = unsafe { core::intrinsics::exact_div(i, 2) };
        true
    }));
}

#[kani::proof]
fn finite_inputs() {
    assert!(kani::forall!(|i in (0, 2)| {
        let _ = unsafe {
            core::intrinsics::fadd_fast(i as f64, f64::INFINITY)
        };
        true
    }));
}

Each harness has a statement-level verification obligation that should not disappear:

  • checked_addition: 1 + usize::MAX overflows at i = 1.
  • exact_division: exact_div(1, 2) violates the exact-division requirement at i = 1.
  • finite_inputs: fadd_fast receives an infinite operand, violating its finite-value requirement.

The returned predicate is simply true in all three cases. Therefore, verifying only the returned Boolean expression is insufficient.

Run each harness separately:

kani repro.rs -Z quantifiers --solver cadical --harness checked_addition --exact
kani repro.rs -Z quantifiers --solver cadical --harness exact_division --exact
kani repro.rs -Z quantifiers --solver cadical --harness finite_inputs --exact

Repeat each command with -Z valid-value-checks and -Z uninit-checks, one option at a time.

Expected behavior

Kani should preserve the relevant verification obligations or explicitly reject a predicate whose checks cannot be preserved.

In particular, none of these harnesses should verify successfully merely because the extraction process discarded the checks.

Observed behavior

The following results were reproduced and recorded on two specific revisions:

Upstream baseline

Harness No extra UB option -Z valid-value-checks -Z uninit-checks
checked_addition Incorrectly succeeds Incorrectly succeeds Incorrectly succeeds
exact_division Incorrectly succeeds Incorrectly succeeds Incorrectly succeeds
finite_inputs Incorrectly succeeds Incorrectly succeeds Incorrectly succeeds

All three report VERIFICATION: SUCCESSFUL, despite the relevant checks being violated.

PR #5136 at tested commit d2cb6388cb464bfa5a047c348cb2b29b6dfe198a

Harness No extra UB option -Z valid-value-checks -Z uninit-checks
checked_addition Incorrectly succeeds Incorrectly succeeds Incorrectly succeeds
exact_division Incorrectly succeeds Explicitly rejected Explicitly rejected
finite_inputs Incorrectly succeeds Explicitly rejected Explicitly rejected

The additional guard prevents some checks from being silently discarded when an extra UB option is enabled, but it does not cover all default verification obligations.

Importantly, the checked-addition overflow is emitted as an ordinary Rust Assertion, not one of the extra-UB guard's recognized safety property classes. Consequently, enabling either extra UB option does not prevent this false success.

These observations are tied to the tested commit above; they are not a claim that every later PR HEAD has been independently retested.

Likely cause

The pure-predicate extraction path in kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs extracts the returned Boolean expression without preserving all statement-level checks from the closure body.

The extra-UB guard recognizes selected property classes, including safety_check, arithmetic_overflow, exact_div, and finite_check, but does not cover ordinary Rust Assertion properties.

As a result, the presence of an additional UB-check option changes whether some predicates are rejected, even though the underlying verification obligations are present without those options.

A successful verification without extra UB flags therefore does not establish that all default checks in the predicate were satisfied.

Scope and related work

PR #5136 addresses a separate, newly exposed case: checked or call-containing nested quantifier predicates are conservatively rejected when extraction could discard their obligations. This prevents the observed nested-overflow false success, but is not a general fix for non-nested predicate check preservation.

The reproducer in this issue deliberately uses only non-nested predicates without branches, so that default-check loss can be investigated independently of other known quantifier limitations.

Related issues:

Related PR:

Activity

  1. added
    [C] Bug
    on Nov 9, 2026
  2. added
    Z-Quantifiers
    on Nov 9, 2026
  3. added this to the Contracts milestone on Nov 9, 2026
  4. added theissue type on Nov 9, 2026
  5. added
    [F] Soundness
    on Nov 10, 2026
  6. self-assigned this
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Z-Quantifiers[C] Bug[F] Soundness

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions