Skip to content

Add support for Floating-Point theory (currently cvc5 only)#428

Open
augustomafra wants to merge 8 commits intostanford-centaur:mainfrom
augustomafra:floating_point_theory_v2
Open

Add support for Floating-Point theory (currently cvc5 only)#428
augustomafra wants to merge 8 commits intostanford-centaur:mainfrom
augustomafra:floating_point_theory_v2

Conversation

@augustomafra
Copy link
Copy Markdown

Adding sort and operation definitions for Floating-Point support on smt-switch.

This is a first step for other upcoming changes on pono's SMV frontend encoding problems on the theory of Floating-Point arithmetic.

@augustomafra
Copy link
Copy Markdown
Author

Hi, @CyanoKobalamyne ,

I see that one CI test failed on my fork with "ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device". Is there anything I can set on my end to have this test running on github? I relaunched it a couple of times but still hit the same issue.

Thanks!

@augustomafra augustomafra force-pushed the floating_point_theory_v2 branch from 95dfc7a to 63258f7 Compare January 17, 2026 19:04
@augustomafra
Copy link
Copy Markdown
Author

Hi, @CyanoKobalamyne ,

Could you or other project maintainers share feedback about this PR?
I have merged it to the latest commit in main (version 1.0.6), so please let me know if there is anything else I can adjust on my request.
I'm currently working on my thesis to wrap up my Master's project at https://github.com/augustomafra/pono, so any thoughts from the Pono maintainers would be greatly appreciated, if possible.

Thanks!

Copy link
Copy Markdown
Collaborator

@yoni206 yoni206 left a comment

Choose a reason for hiding this comment

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

Hi @augustomafra and thanks for this PR, and sorry for the delay!
It would be great for smt-switch to support floating points.

In addition to the inline comments, could you add tests to the PR? I think it would make sense to add cvc5 tests here:
https://github.com/augustomafra/smt-switch/tree/63258f708b798a34a46a6ddaf7252ece4612af5b/tests/cvc5

and more generic tests (though they would now only run with cvc5) here:
https://github.com/augustomafra/smt-switch/tree/63258f708b798a34a46a6ddaf7252ece4612af5b/tests

This would include updating this file:
https://github.com/augustomafra/smt-switch/blob/63258f708b798a34a46a6ddaf7252ece4612af5b/tests/available_solvers.cpp

Comment thread include/ops.h
UBV_To_FP,
FP_To_UBV,
FP_To_SBV,
FP_To_REAL,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you also add python bindings as mentioned in the line below?

Comment thread include/sort.h
Comment on lines +54 to +55
FLOAT32,
FLOAT64,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason only these two are added, and not generic floats, indexed by integer parameters? This would be then more consistent with the SMT-LIB standard, and can be done similarly to bit-vectors.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed, I will work on switching to the generic float type.
At first I assumed specialized types would be easier to adopt for my application, but when advancing in the project I noticed that I spent more effort in getting the indexes for each type when translating to the solver APIs. The templates were a way to work around that, but as you commented below, they shouldn't be needed anymore after changing to general floats.

Comment thread include/sort.h
Comment on lines +64 to +81
template <SortKind sk>
struct FPSizes;

template <>
struct FPSizes<FLOAT32>
{
static constexpr uint32_t exp = 8;
static constexpr uint32_t sig = 24;
static constexpr uint32_t size = exp + sig;
};

template <>
struct FPSizes<FLOAT64>
{
static constexpr uint32_t exp = 11;
static constexpr uint32_t sig = 53;
static constexpr uint32_t size = exp + sig;
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

templates are rare in smt-switch so far, and i wonder if we really need them here.

@augustomafra
Copy link
Copy Markdown
Author

Hi, @yoni206 , thanks for the directions!
I will work on the changes you suggested and update the PR. Right now I'm focused on writing my thesis, so I may take a while to return to the code.

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