Skip to content

Add assume_ieee_float#2232

Draft
Chris-Hawblitzel wants to merge 2 commits into
mainfrom
ieee-float-axioms
Draft

Add assume_ieee_float#2232
Chris-Hawblitzel wants to merge 2 commits into
mainfrom
ieee-float-axioms

Conversation

@Chris-Hawblitzel
Copy link
Copy Markdown
Collaborator

I split off assume_ieee_float from the main pull request #2229 :

In general, we do not assume that Rust floating point semantics match IEEE floating point semantics (see https://github.com/rust-lang/rfcs/blob/master/text/3514-float-semantics.md for details). However, if users are working on a platform where they are willing to make this assumption, they can use the module assume_ieee_float, which contains broadcast axioms that express this assumption. Here is a small example that uses assume_ieee_float in combination with assert-by-bit_vector to prove a simple property of a Rust f32 operation:

fn test(x: f32, y: f32) -> (z: f32)
    requires
        1.0f32 <= x <= 2.0f32,
        4.0f32 <= y <= 8.0f32,
    ensures
        5.0f32 <= z <= 10f32,
{
    broadcast use vstd::contrib::assume_ieee_float::assume_ieee_float;

    let z = x + y;
    assert(5.0f32 <= x + y <= 10.0f32) by(bit_vector)
        requires
            1.0f32 <= x <= 2.0f32,
            4.0f32 <= y <= 8.0f32;
    z
}

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Copy link
Copy Markdown
Collaborator

@jaylorch jaylorch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refers to things in a different PR (#2229), so we should make sure not to merge it until that other PR is merged.

@Chris-Hawblitzel
Copy link
Copy Markdown
Collaborator Author

I'm copying this comment over from #2229 so we don't forget to address it:

@tjhance said:

It's unfortunate that the new axioms aren't meaningfully distinct from the other axioms in vstd. There's no indication that this is a platform specific assumption other than via the name. Is there a way we could unify this, design-wise, with our global directive for specifying platform assumptions?

Base automatically changed from ieee-float to main March 16, 2026 17:11
@Chris-Hawblitzel Chris-Hawblitzel removed the request for review from tjhance March 24, 2026 17:07
@Chris-Hawblitzel Chris-Hawblitzel marked this pull request as draft March 24, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants