-
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
fix: don't use modulo for UInt upcasting #3960
Conversation
Mathlib CI status (docs):
|
(Removed from queue due to mathlib failures; were they expected?) |
Yes, they are expected. Should I make a bump PR? The breakage should be minimal, because mathlib doesn't do much with fixed size integers. |
Just checked, it is from theorems in Std like this: @[simp] theorem UInt8.toUInt16_toNat (x : UInt8) : x.toUInt16.toNat = x.toNat :=
Nat.mod_eq_of_lt (Nat.lt_of_lt_of_le x.toNat_lt (by decide))
@[simp] theorem UInt8.toUInt32_toNat (x : UInt8) : x.toUInt32.toNat = x.toNat :=
Nat.mod_eq_of_lt (Nat.lt_of_lt_of_le x.toNat_lt (by decide))
@[simp] theorem UInt8.toUInt64_toNat (x : UInt8) : x.toUInt64.toNat = x.toNat :=
Nat.mod_eq_of_lt (Nat.lt_of_lt_of_le x.toNat_lt (by decide)) which are exactly the ones that are rfl after this PR. So it should be easily fixable. |
If you say it's fine I can merge, although it doesn't hurt to have the fixes ready ahead of time, by pushing to the lean-pr-testing branches. Then whoever updates nightly-testing has less to think about, don't they? |
I did encounter the errors on Std's nightly-testing before reading this thread, but found it pretty quickly. I think a good option, when not having a |
This makes
(v : UInt8).toUInt16.toNat = (v : UInt8).toNat
a defeq, which simplifies proofs.