Skip to content

Quantifier failure in loop invariant #4282

@thanhnguyen-aws

Description

@thanhnguyen-aws

I tried this code:

#[kani::proof]
fn main() {
    let a: [usize; 60] = kani::any();
    kani::assume(kani::forall!(|i in (0,60)| a[i] <= 20));
    let mut b: [usize; 60] = a.clone();
    let mut i = 0;
    #[kani::loop_invariant( i<= 60 && kani::forall!(|j in (0, i)| b[j] == a[j]+ 1))]
    while i < 60 {
        b[i] = a[i] + 1;
        i += 1;
    }
} 

using the following command line invocation:

kani main.rs -Z loop-contracts -Z quantifiers

with Kani version: 0.64.0

I expected to see this happen: VERIFICATION:- SUCCESSFUL

Instead, this happened:

warning: ignoring forall
  * type: bool
  0: tuple
... (very long)

Failed Checks: Check invariant after step for loop main2.0

When I try to add #[kani::solver(cvc5)]

The output is:

Running SMT2 ALL (with FPA) using CVC5
SMT2 solver returned "unknown"
Runtime Solver: 0.216097s
Runtime decision procedure: 0.222155s

thread '<unnamed>' panicked at kani-driver/src/cbmc_output_parser.rs:470:25:
called `Result::unwrap()` on an `Err` value: Error("unknown variant `ERROR`, expected one of `FAILURE`, `COVERED`, `SATISFIED`, `SUCCESS`, `UNDETERMINED`, `UNKNOWN`, `UNREACHABLE`, `UNCOVERED`, `UNSATISFIABLE`", line: 12, column: 25)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    Z-QuantifiersIssues related to quantifiers[C] BugThis is a bug. Something isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions