-
Notifications
You must be signed in to change notification settings - Fork 54
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
Best way to prevent arithmetic overflow/underflows during rewriting? #404
Comments
Great question! |
Thank you for your answer !
Can that be done from the egglog DSL or do we need to do that through the Rust API ? The overflow conditions would require disjunctions and references to
Do you have a pointer to the API in question ? |
Here's the API I was thinking of: |
I was imagining doing 2 from the egglog DSL, defining a max and min int yourself using globals |
There's also a Line 58 in ecc3be5
It produces a boolean instead of an egglog filter |
Thank you ! |
If there was a way to add over/underflow protection to the builtins here as well I could see that being useful generally! |
Hi !
In this example I have a simple constant folding rule:
I can trigger overflows on
i64
additionIt seems like egglog does not try to detect overflows/underflows on either
i64
or rationals (which are pairs ofi64
), or occurences of nans/+inf onf64
.I'm trying to use egglog to simplify mathematical expressions over mathematical Ints and Rationals, so to ensure soundness I'd like to either (from worst to best):
.1 detect overflows during rewriting and trigger panics
.2 guard against applying constant folding rules if they would trigger overflows/underflows
.3 replace the i64, rationals and f64 with arbitrary precision equivalents (think GMP, MPFR, etc. )
I know that .3 is not possible without modifying the egglog source code, but would either 1 or 2 be possible as of today ?
How do people usually ensure soundness with that type of constant propagation rules ?
Thanks !
The text was updated successfully, but these errors were encountered: