Commit ddc86b8
copilot-theorem: Correctly display special Float values in counterexamples. Refs #697.
`copilot-theorem`'s counterexample-reporting machinery up-casts `Float` values
to `Double` values using the `realToFrac` function. `realToFrac` incorrectly
handles special floating-point values such as negative zero, infinity, and NaN
values, causing `copilot-theorem` to generate incorrect counterexamples when
these special values are involved.
This commit removes the use of `realToFrac` in favor of an alternative approach
based on `GHC.Float.double2Float`, which correctly handles most special
floating-point values. A notable exception is NaN values, as `double2Float`
does not reliably preserve the payload of a NaN value. As such, we include a
special case for NaN values that takes care to preserve payloads.
Co-authored-by: Ryan Scott <rscott@galois.com>1 parent aaca8d1 commit ddc86b8
2 files changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
707 | 708 | | |
708 | 709 | | |
709 | 710 | | |
710 | | - | |
| 711 | + | |
711 | 712 | | |
712 | 713 | | |
713 | 714 | | |
| |||
757 | 758 | | |
758 | 759 | | |
759 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
0 commit comments