-
Notifications
You must be signed in to change notification settings - Fork 432
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
feat: BitVec.[toFin|getMsbD]_setWidth and [getMsbD|msb]_signExtend #6338
Conversation
936d569
to
cd2dee9
Compare
changelog-library |
3c600d0
to
fd427df
Compare
0271ec3
to
1052987
Compare
This patch adds BitVec.[toFin|getMsbD]_setWidth and [getMsb|msb]_signExtend as well as ofInt_toInt and toInt_cast.
1052987
to
f0e300c
Compare
Mathlib CI status (docs):
|
lgtm! |
Co-authored-by: Siddharth <[email protected]>
@@ -645,6 +652,20 @@ theorem getElem?_setWidth (m : Nat) (x : BitVec n) (i : Nat) : | |||
getLsbD (setWidth m x) i = (decide (i < m) && getLsbD x i) := by | |||
simp [getLsbD, toNat_setWidth, Nat.testBit_mod_two_pow] | |||
|
|||
theorem getMsbD_setWidth {m : Nat} {x : BitVec n} {i : Nat} : | |||
getMsbD (setWidth m x) i = (decide (m - n ≤ i) && getMsbD x (i + n - m)) := by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objection on this PR, but increasingly I am skeptical that decide inequality && boolean
is really what we want on the RHS of all these lemmas. It probably should just be if inequality then boolean else false
. Without a mixed linear arithmetic + SAT solver, this is doing us no favours, and the if
style makes it much easier to use split
to get the inequalities in usable form (e.g. for omega
).
Something to consider; it would be a big refactor.
This PR adds
BitVec.[toFin|getMsbD]_setWidth
and[getMsb|msb]_signExtend
as well asofInt_toInt
.Also correct renamed the misnamed theorem for
signExtend_eq_setWidth_of_msb_false
.