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 opaque types for Double and Float #1413

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mario-bucev
Copy link
Collaborator

No description provided.

@samarion
Copy link
Member

samarion commented May 8, 2023

I'm pretty sure Z3 and CVC4 support floating-point arithmetic. Why not add solver support?

@mario-bucev
Copy link
Collaborator Author

For context, there is a project that would require converting between FP and their bits representation (for serialization & deserialization). @vkuncak and I settled on this first approach towards adding some FP support in Stainless. But maybe doing that in this way is not the best way (another approach would be by extracting these methods and handle them separately).

@samarion
Copy link
Member

samarion commented May 8, 2023

The SMT standard [1] has support for FP <-> BV conversions but it seems like the -> direction is not injective (which might break your doubleToRawLongBits post-condition). They recommend using

(declare-fun b () (_ BitVec m))
(assert (= ((_ to_fp eb sb) b) f))

Note that it shouldn't be too much work to add FP support throughout the stack, just need to

  1. define some new trees in Inox and the corresponding embeddings, and
  2. adapt the extraction logic.

Maybe a useful first step in the project?

[1] http://smtlib.cs.uiowa.edu/theories-FloatingPoint.shtml

@mario-bucev
Copy link
Collaborator Author

Yes, this looks like a good direction, thank you for the research! I will discuss it with @vkuncak

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