-
Notifications
You must be signed in to change notification settings - Fork 468
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.(toInt, toFin)_twoPow
#7225
base: master
Are you sure you want to change the base?
Conversation
Bitvec.(toInt, toFin)_twoPow
changelog-library |
Mathlib CI status (docs):
|
950c7a9
to
bc3be0a
Compare
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 @tobiasgrosser for this cute proof! looks good to me :)
Co-authored-by: Luisa Cicolini <[email protected]>
Co-authored-by: Luisa Cicolini <[email protected]> Co-authored-by: Siddharth <[email protected]>
a4e02fe
to
b42e538
Compare
apply Nat.mod_eq_of_lt | ||
apply Nat.pow_lt_pow_of_lt (by omega) (by omega) | ||
|
||
theorem toNat_twoPow_eq_if {i w : Nat} : (twoPow w i).toNat = if i < w then 2^i else 0 := 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.
I would like for us to contemplate, in a subsequent PR, whether this should be the simp
normal form of toNat_twoPow
.
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 looked into this, but this breaks a couple of proofs in non-trivial ways, as several proofs use % 2 ^ ?
instead of an if statement to express that the RHS can be zero. I am happy to investigate this further, but given that this is not a clear-cut, we should investigate this more broadly and likely in a future PR.
Co-authored-by: Luisa Cicolini <[email protected]>
awaiting-review |
This PR contains
BitVec.(toInt, toFin)_twoPow
theorems, completing the API forBitVec.*_twoPow
. It also expands thetoNat_twoPow
API withtoNat_twoPow_of_le
,toNat_twoPow_of_lt
, as well astoNat_twoPow_eq_if
and movesmsb_twoPow
up, as it is used in thetoInt_msb
proof.