-
Notifications
You must be signed in to change notification settings - Fork 546
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.{toInt, toFin, msb}_udiv #6402
Conversation
theorem msb_udiv (x y : BitVec w) : | ||
(x / y).msb = (x.msb && y == 1#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.
theorem msb_udiv (x y : BitVec w) : | |
(x / y).msb = (x.msb && y == 1#w) := by | |
theorem msb_udiv {x y : BitVec w} : | |
(x / y).msb = (x.msb && y == 1#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.
I'm curious what rule people use to determine whether variable should be explicit or implicit; I think we do this pretty inconsistently in the file at the moment.
For me, I try to make variables implicit only if they can be inferred from the other hypotheses, not including the lhs of an equality or bi-implication, but make sure that any explicit variables that can be inferred from the lhs come at the end of the argument list. Hence, x
and y
here are explicit.
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 agree it is ambiguous, and inconsistent.
Note, however, that at least for a bi-implication the standard (at least, as enforced by a linter in Batteries) is that variables appearing on both sides of a bi-implication should be implicit.
I tend to follow (erratically!) the same rule for equalities, too.
Let's not get hung up on this for now.
Mathlib CI status (docs):
|
I tried to rebase on the suggested hash, but this fails because I've modified a file that didn't yet exist in that version. I could resolve the conflict, but that seems like it might cause annoying merge conflicts later down the line. Regardless, I've upstreamed a Nat lemma ( |
This should now be ready for review, but since I'm on holidays I'll keep it as a draft until I'm back and can respond to reviews timely. Hopefully by then |
awaiting-review I just rebased on nightly-with-mathlib also |
changelog-library |
Hm, that's said, the CI step checking labels didn't get triggered automatically. :-( |
This PR adds a `toFin` and `msb` lemma for unsigned bitvector modulus. Similar to #6402, we don't provide a general `toInt_umod` lemmas, but instead choose to provide more specialized rewrites, with extra side-conditions. --------- Co-authored-by: Kim Morrison <[email protected]>
This PR adds a `toFin` and `msb` lemma for unsigned bitvector division. We *don't* have `toInt_udiv`, since the only truly general statement we can make does no better than unfolding the definition, and it's not uncontroversially clear how to unfold `toInt` (see `toInt_eq_msb_cond`/`toInt_eq_toNat_cond`/`toInt_eq_toNat_bmod` for a few options currently provided). Instead, we do have `toInt_udiv_of_msb` that's able to provide a more meaningful rewrite given an extra side-condition (that `x.msb = false`). This PR also upstreams a minor `Nat` theorem (`Nat.div_le_div_left`) needed for the above from Mathlib. --------- Co-authored-by: Kim Morrison <[email protected]>
This PR adds a `toFin` and `msb` lemma for unsigned bitvector modulus. Similar to leanprover#6402, we don't provide a general `toInt_umod` lemmas, but instead choose to provide more specialized rewrites, with extra side-conditions. --------- Co-authored-by: Kim Morrison <[email protected]>
This PR adds a `toFin` and `msb` lemma for unsigned bitvector division. We *don't* have `toInt_udiv`, since the only truly general statement we can make does no better than unfolding the definition, and it's not uncontroversially clear how to unfold `toInt` (see `toInt_eq_msb_cond`/`toInt_eq_toNat_cond`/`toInt_eq_toNat_bmod` for a few options currently provided). Instead, we do have `toInt_udiv_of_msb` that's able to provide a more meaningful rewrite given an extra side-condition (that `x.msb = false`). This PR also upstreams a minor `Nat` theorem (`Nat.div_le_div_left`) needed for the above from Mathlib. --------- Co-authored-by: Kim Morrison <[email protected]>
This PR adds a `toFin` and `msb` lemma for unsigned bitvector modulus. Similar to leanprover#6402, we don't provide a general `toInt_umod` lemmas, but instead choose to provide more specialized rewrites, with extra side-conditions. --------- Co-authored-by: Kim Morrison <[email protected]>
This PR adds a
toFin
andmsb
lemma for unsigned bitvector division. We don't havetoInt_udiv
, since the only truly general statement we can make does no better than unfolding the definition, and it's not uncontroversially clear how to unfoldtoInt
(seetoInt_eq_msb_cond
/toInt_eq_toNat_cond
/toInt_eq_toNat_bmod
for a few options currently provided). Instead, we do havetoInt_udiv_of_msb
that's able to provide a more meaningful rewrite given an extra side-condition (thatx.msb = false
).This PR also upstreams a minor
Nat
theorem (Nat.div_le_div_left
) needed for the above from Mathlib.