forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
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.neg_neg #14
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tobiasgrosser
force-pushed
the
bitvec_neg_neg
branch
2 times, most recently
from
August 9, 2024 02:31
1a90574
to
b001fcb
Compare
AtticusKuhn
approved these changes
Aug 9, 2024
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.
Looks good to me.
src/Init/Data/BitVec/Lemmas.lean
Outdated
Comment on lines
1251
to
1259
@[simp] | ||
theorem neg_neg {x : BitVec w} : - - x = x := by | ||
by_cases h : x = 0 | ||
· subst h | ||
simp | ||
· simp only [toNat_eq, toNat_neg] | ||
rw [toNat_eq] at h | ||
simp only [ofNat_eq_ofNat, toNat_ofNat, Nat.zero_mod] at h | ||
rw [Nat.mod_eq_of_lt (a := 2 ^ w - x.toNat) (by omega)] | ||
rw [Nat.mod_eq_of_lt (by omega)] | ||
omega |
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.
Perhaps this theorem could be made simpler?
@[simp]
theorem neg_neg2 {x : BitVec w} : - - x = x := by
have p : (- x) + (- -x) = x - x := by
simp [BitVec.sub_self, ← BitVec.sub_toAdd]
rw [BitVec.eq_sub_iff_add_eq , BitVec.add_comm, ← BitVec.add_assoc , ← BitVec.sub_toAdd x x , BitVec.sub_self x, BitVec.zero_add] at p
assumption
tobiasgrosser
force-pushed
the
bitvec_neg_neg
branch
from
August 10, 2024 04:51
b001fcb
to
a37c16d
Compare
.. as well as neg_neq_iff_neq_neg.
tobiasgrosser
force-pushed
the
bitvec_neg_neg
branch
2 times, most recently
from
August 10, 2024 05:51
3b8cdcf
to
ca08674
Compare
tobiasgrosser
force-pushed
the
bitvec_neg_neg
branch
from
August 10, 2024 05:53
ca08674
to
c75da23
Compare
Co-authored-by: Henrik Böving <hargonix@gmail.com>
Merged with leanprover#4951 into lean. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
... as well as neg_neq_iff_neq_neg.