forked from model-checking/kani
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable powf*, exp*, sqrt* intrinsics
CBMC provides approximating implementations of these. Resolves: model-checking#2763, model-checking#2966
- Loading branch information
1 parent
8a1b550
commit f6af818
Showing
3 changed files
with
50 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
pub fn f(a: u64) -> u64 { | ||
const C: f64 = 0.618; | ||
(a as f64).powf(C) as u64 | ||
} | ||
|
||
#[cfg(kani)] | ||
mod verification { | ||
use super::*; | ||
|
||
#[kani::proof] | ||
fn verify_f() { | ||
const LIMIT: u64 = 10; | ||
let x: u64 = kani::any(); | ||
let y: u64 = kani::any(); | ||
// outside these limits our approximation may yield spurious results | ||
kani::assume(x > LIMIT && x < LIMIT * 3); | ||
kani::assume(y > LIMIT && y < LIMIT * 3); | ||
kani::assume(x > y); | ||
let x_ = f(x); | ||
let y_ = f(y); | ||
assert!(x_ >= y_); | ||
} | ||
} |