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

More floating point theorems #1082

Open
michael-roe opened this issue Dec 28, 2022 · 3 comments
Open

More floating point theorems #1082

michael-roe opened this issue Dec 28, 2022 · 3 comments

Comments

@michael-roe
Copy link
Contributor

michael-roe commented Dec 28, 2022

(Feature request)

Add proofs of the following floating point theorems:

!x . not float_equal x x <=> float_is_nan x

!x . float_unordered x x <=> float_is_nan x

!x . (float_equal x (float_plus_infinity (:'t # 'w))) \/ (float_equal x (float_minus_infinity (:'t # 'w))) <=> float_is_infinite x;

!x . float_equal x (float_plus_zero (:'w # 't)) <=> float_is_zero x

These theorems prove that the typical implementations of fp_is_nan etc. (if you don't have fp_classify) are correct.

@michael-roe
Copy link
Contributor Author

michael-roe commented Jan 7, 2023

The third one of these theorems is closely related to float_infinities in binary_ieeeScript.sml. The critical difference is that it uses float_equal rather than =.

(testing for x = float_minus_infinity is equivalent to testing for float_equal x float_minus_infinity, but you need to prove that)

@michael-roe
Copy link
Contributor Author

michael-roe commented Jan 8, 2023

We might also need:

! x y . (float_is_infinite x) ==> ((float_equal x y) <=> (x = y))

float_equal is not the same as = for zeros and nans, but is is for infinities, normal numbers and submormal numbers.

P.S. I had a try at proving this, but it turned out to be difficult:

Basic plan:

Case split on float_value x
simp[float_is_infinite_def] deals with cases where x is not an infinity

in remaining case, simp[float_equal_def,float_compare_def]
Case split on float value y

... which gets us down to the tricky case where x and y are both infinities

@mn200
Copy link
Member

mn200 commented Jan 11, 2023

First in the list now done (by 02db589)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants