-
Notifications
You must be signed in to change notification settings - Fork 108
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.ofFn and lemmas #1078
base: main
Are you sure you want to change the base?
Conversation
Mathlib CI status (docs):
|
Batteries/Data/BitVec.lean
Outdated
Fin.foldr n (fun i v => v.shiftConcat (f i)) 0 | ||
|
||
/-- `ofFn f` returns the `BitVec n` whose `i`th bit is `f i` -/ | ||
abbrev ofFn (f : Fin n → Bool) : BitVec n := ofFnAux n f |
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.
New functions creating BitVecs should have simp lemmas for toNat
, toFin
, and ideally also toInt
.
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.
Doesn't that need the Nat
/Fin
/Int
functions to already exist in some way? I would probably just implement those using the BitVec version.
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 added Nat.ofBits
and Fin.ofBits
, little endian only since that's the way Nat.testBit
works. I will try to think about what the right Int
version should be.
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.
Adding Int.ofBits
would require upstreaming Int.testBit
from Mathlib. Let me know if you think that's a good idea and I will get it done.
No description provided.