-
Notifications
You must be signed in to change notification settings - Fork 455
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.(getElem_umod_of_lt, getElem_umod, getLsbD_umod, getMsbD_umod)
#6795
base: master
Are you sure you want to change the base?
Conversation
and support
BitVec.le_zero_eq_zero`BitVec.(getElem_umod_of_lt, getElem_umod, getLsbD_umod, getMsbD_umod)
and support BitVec.le_zero_eq_zero
Mathlib CI status (docs):
|
Thank you. Could you add 1-2 sentences of motivation of why you choose these right-hand-sides that you see here. |
…tMsbD_umod)` and support `BitVec.le_zero_eq_zero` This PR adds theorems `BitVec.(getElem_umod_of_lt, getElem_umod, getLsbD_umod, getMsbD_umod)` and support theorem `BitVec.le_zero_eq_zero`. For the defiition of these theorems we rely on `divRec`, excluding the case where `d=0#w`, which is treated separately because there is no infrastructure to reason about this case within `divRec`. In particular, our implementation follows the mathlib standard [where division by 0 yields 0](https://github.com/leanprover/lean4/blob/c7c1e091c9f07ae6f8e8ff7246eb7650e2740dcb/src/Init/Data/BitVec/Basic.lean#L217), while in [SMTLIB this yields `allOnes`](https://github.com/leanprover/lean4/blob/c7c1e091c9f07ae6f8e8ff7246eb7650e2740dcb/src/Init/Data/BitVec/Basic.lean#L237). Co-authored by @bollu.
c0f8403
to
2c3028e
Compare
BitVec.(getElem_umod_of_lt, getElem_umod, getLsbD_umod, getMsbD_umod)
and support BitVec.le_zero_eq_zero
BitVec.(getElem_umod_of_lt, getElem_umod, getLsbD_umod, getMsbD_umod)
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.
LGTM, modulo my comments about proof reuse. It would be nice to not repeat the same proof, as that's a bit brittle.
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.
LGTM. These straightforwardly use the bitblasting theorems as getElem
/getLsbD
/getMsb
.
Co-authored-by: Siddharth <[email protected]>
awaiting-review |
changelog-library |
src/Init/Data/BitVec/Bitblast.lean
Outdated
· have := (BitVec.not_le (x := d) (y := 0#w)).mp | ||
simp only [le_zero_iff] at this | ||
rw [← BitVec.umod_eq_divRec (by simp [hd, this])] | ||
simp [hd] |
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.
Why don't we reuse getElem_umod_of_(lt/pos)
here? That lemmas seems to describe exactly this case, no?
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.
so it's actually interesting, using that theorem in the proof seems to only make the proof longer. I guess we don't need getElem_umod_of_pos
in the first place.
This PR adds theorems
BitVec.(getElem_umod_of_lt, getElem_umod, getLsbD_umod, getMsbD_umod)
. For the defiition of these theorems we rely ondivRec
, excluding the case whered=0#w
, which is treated separately because there is no infrastructure to reason about this case withindivRec
. In particular, our implementation follows the mathlib standard where division by 0 yields 0, while in SMTLIB this yieldsallOnes
.Co-authored by @bollu.