-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sinf/Cosf not being correctly evaluated #1342
Comments
Hi @ssoudan , thank you for opening the issue! You're right: The CBMC model for the sine function is an over-approximation that returns 0 if the argument is 0, and a nondeterministic value between -1 and 1 otherwise. I agree that this is misleading and have opened diffblue/cbmc#6999 in order to get more precise models for these intrinsics. |
Thanks! |
Do you have a specific goal here? Or just trying things out? Just curious. It's really hard to accurately model many numerical functions. It might be feasible to get it right when it's given a constant (non-symbolic) value, but getting more accurate than that might be a non-goal for Kani. |
Hi Ted, it's a bit of both. I’m exploring to figure out how practical it is to use kani in addition to testing for service-like programs - not that likely to deal with floats, and ended up trying it on a pet drone flight controller project to verify the control logic is not going to burst into NaN/Inf. Understand the verification (even the definition) of FP operations can be challenging and would come at a cost that might be prohibitive. If this is a non-goal for Kani, I suggest updating the table in https://model-checking.github.io/kani/rust-feature-support/intrinsics.html with additional disclaimers for these operations. Just throwing ideas: best case would be to be able to specify what ‘theory’ to use for a verification and/or be able to refine it (not sure if an SMT-LIB 2 lib can readily be found and used, musl as a pure c version of sin() and libm as a pure rust implementation of it) but that might be too far fetched. In any case, thanks for the work being done here! |
|
Might have missed something but so far I think the following is happening:
Rust
intrinsics::sinf32()
is substituted with Csinf()
which itself seems to be substituted inside CBMC.This code does some __CPROVER_assume() but no actual calculation of the sinus (in https://github.com/diffblue/cbmc/blob/16240afb9a855951533a57a0343b1737dd3f0168/src/ansi-c/library/math.c#L508):
The result from kani perspective is that the following code fails the verification:
using the following command line invocation:
while:
Not sure what is a good solution here but this is misleading as is.
The text was updated successfully, but these errors were encountered: