Lean: Fix an issue where fp_bits compilation was skipped in the float library#1617
Lean: Fix an issue where fp_bits compilation was skipped in the float library#1617nek0las wants to merge 4 commits intorems-project:sail2from
Conversation
|
You might find |
Test Results 16 files 36 suites 0s ⏱️ Results for commit 2e981cc. ♻️ This comment has been updated with latest results. |
|
This change fixes the specific case of existential types introduced via type abbreviations, and the corresponding if_bits tests now pass. The tests under test/coq/pass/existential*.sail still fail, because existential types arising from other definitions (e.g. union and struct types) are not handled yet. Supporting those cases requires a more general solution than I initially expected. I wanted to share this status update before proceeding further, and I’d appreciate any guidance on whether extending the fix to those cases is the right next step. |
|
You might find it useful to look at commit |
This PR aims to fix Issue #1472. The Lean 4 backend currently skips the compilation of fp_bits because the underscore placeholder cannot infer the current Nat in BitVec(_).
This problem seems unavoidable with the current Lean 4 backend implementation, because underscores (_) are used for automatic implicit inference in existential contexts. This works in most cases as long as Lean 4 can determine the exact length from the surrounding context (for example, in Issue #1136, where the value on the RHS is known). However, when the value is an abbreviation for a type related to the existential type, Lean cannot infer the length, and a dependent pair is required to satisfy the type checker.
To minimize the impact, I reused the dependent-pair generation logic and used it in Lean 4 only when it encountered the abbrev and existential type. Broadly changing the decision logic for when to use dependent pairs versus underscores would require significant refactoring of the backend, so this PR focuses on resolving the fp_bits/abrrev related issue specifically.
The code from sail will be compiled from
to