-
Notifications
You must be signed in to change notification settings - Fork 450
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: add BitVec.(msb, getMsbD)_(rotateLeft, rotateRight)
#6120
Conversation
Co-authored-by: Siddharth <[email protected]>
Mathlib CI status (docs):
|
src/Init/Data/BitVec/Lemmas.lean
Outdated
|
||
@[simp] | ||
theorem msb_rotateLeft {m w : Nat} {x : BitVec w} : | ||
(x.rotateLeft m).msb = decide (0 < w && x.getMsbD (m % w)) := 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.
(x.rotateLeft m).msb = decide (0 < w && x.getMsbD (m % w)) := by | |
(x.rotateLeft m).msb = (decide (0 < w) && x.getMsbD (m % w)) := 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.
Is the decide (0 < w)
needed here? I think it gives the correct answer without.
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.
AFAIU it is: if I remove it I get x.getMsbD (m % w) = true → 0 < w
, which intro
and omega
can not solve
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.
I managed to drop it with a minor extension of the proof.
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.
thank you!
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.
A proof not working is not proof that the statement is wrong. :-)
@luisacicolini, just a quick request re: the PR description. Thanks for adding a paragraph beginning "This PR ..." --- we know automatically extract these to incorporate in the draft release notes. Having PR authors write them saves us lots of time! But it means that things like "cc: @bollu" need to go in a separate paragraph, otherwise they may end up in the release notes! |
got it @kim-em! And thanks for reviewing this :) |
…er#6120) This PR adds theorems `BitVec.(getMsbD, msb)_(rotateLeft, rotateRight)`. We follow the same strategy taken for `getLsbD`, constructing the necessary auxilliary theorems first (relying on different hypotheses) and then generalizing. --------- Co-authored-by: Siddharth <[email protected]> Co-authored-by: Tobias Grosser <[email protected]>
This PR adds theorems
BitVec.(getMsbD, msb)_(rotateLeft, rotateRight)
.We follow the same strategy taken for
getLsbD
, constructing the necessary auxilliary theorems first (relying on different hypotheses) and then generalizing.