Skip to content
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

Add support for in_range #3711

Open
Yenyun035 opened this issue Nov 12, 2024 · 0 comments
Open

Add support for in_range #3711

Yenyun035 opened this issue Nov 12, 2024 · 0 comments
Assignees
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@Yenyun035
Copy link

Yenyun035 commented Nov 12, 2024

Requested feature: in_range to check if a float is in the range of the targeting integer type, e.g.

kani::in_range(IntType, floatType, float) or something similar
Example: f32::to_int_unchecked contract
#[requires(self.is_finite() && kani::in_range(Int, Self, self))]
pub unsafe fn to_int_unchecked<Int>(self) -> Int where Self: FloatToInt<Int> {...}

Full Discussion:

Thank you for sharing this. Is it possible to have Kani support this? E.g. expose an in_range(float, floatType, IntType) API that we can directly call. We saw that the Kani internally has codegen_in_range_expr which we think useful.
Thank you! @zhassan-aws

Yes, I think it would be possible. This would likely need to be done through providing a trait and its implementation for different float types so that it can be used with the generic Int. Can you file a feature request in the Kani repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants