-
Notifications
You must be signed in to change notification settings - Fork 354
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
[Merged by Bors] - chore: bump Std, changes for leanprover/std4#366 #8700
Closed
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
766c33e
chore: bump Std, changes for leanprover/std4#366
kim-em 9db8667
revert
kim-em 6240309
.
kim-em db5e363
fix a bit
kim-em bfc4612
blech
kim-em 82a3392
one more
kim-em 068ccf3
comment out broken and unused results
kim-em c43641c
chore: bump Std
kim-em 18e1a0c
merge
kim-em 8b31141
remove redundant simp lemmas
kim-em 2fd0cb4
cleanup
kim-em 5cad514
fix: make `Nat.testBit_bitwise` a simp-lemma again.
alexkeizer 1a433ef
fix `castNum_testBit`
alexkeizer da0024a
fix `testBit_eq_inth`
alexkeizer d0245fb
Merge branch 'master' into bump_std_20231129
eric-wieser 85c799e
fixes
eric-wieser f4100cf
golf
eric-wieser 7b6f1a3
Apply suggestions from code review
alexkeizer fcbe2e5
golf
eric-wieser a936ad1
Merge branch 'bump_std_20231129' of https://github.com/leanprover-com…
eric-wieser c3b7df4
fix whitespace
eric-wieser 3e71922
fix name conflict
eric-wieser e90cfb7
more efficient
eric-wieser 8c7c2d9
restore lemma
eric-wieser e8952a9
Merge remote-tracking branch 'origin/master' into bump_std_20231129
eric-wieser 3765c7e
fix breakage in BitVec lemmas
alexkeizer c731f15
remove simp from `ofNat_toNat'`
alexkeizer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,20 +31,10 @@ | |
theorem toNat_lt_toNat {x y : BitVec w} : x.toNat < y.toNat ↔ x < y := | ||
Iff.rfl | ||
|
||
@[simp] | ||
lemma ofNat_eq_mod_two_pow (n : Nat) : (BitVec.ofNat w n).toNat = n % 2^w := rfl | ||
|
||
lemma toNat_ofNat {m} (h : m < 2^w) : (BitVec.ofNat w m).toNat = m := Fin.val_cast_of_lt h | ||
|
||
@[simp] | ||
lemma toNat_ofFin (x : Fin (2^w)) : (ofFin x).toNat = x.val := rfl | ||
attribute [simp] toNat_ofNat toNat_ofFin | ||
|
||
theorem toNat_append (msbs : BitVec w) (lsbs : BitVec v) : | ||
(msbs ++ lsbs).toNat = msbs.toNat <<< v ||| lsbs.toNat := by | ||
rcases msbs with ⟨msbs, hm⟩ | ||
rcases lsbs with ⟨lsbs, hl⟩ | ||
simp only [HAppend.hAppend, append, toNat_ofFin] | ||
rw [toNat_ofNat (Nat.add_comm w v ▸ append_lt hl hm)] | ||
lemma toNat_ofNat_of_lt {m} (h : m < 2^w) : (BitVec.ofNat w m).toNat = m := by | ||
simp only [toNat_ofNat, mod_eq_of_lt h] | ||
|
||
#noalign bitvec.bits_to_nat_to_bool | ||
|
||
|
@@ -60,14 +50,9 @@ | |
|
||
theorem toNat_extractLsb' {i j} {x : BitVec w} : | ||
(extractLsb' i j x).toNat = x.toNat / 2 ^ i % (2 ^ j) := by | ||
simp only [extractLsb', ofNat_eq_mod_two_pow, shiftRight_eq_div_pow] | ||
|
||
theorem getLsb_eq_testBit {i} {x : BitVec w} : getLsb x i = x.toNat.testBit i := by | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did this go? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RHS is now the definition of |
||
simp only [getLsb, Nat.shiftLeft_eq, one_mul, Nat.and_two_pow] | ||
cases' testBit (BitVec.toNat x) i | ||
<;> simp [pos_iff_ne_zero.mp (two_pow_pos i)] | ||
simp only [extractLsb', toNat_ofNat, shiftRight_eq_div_pow] | ||
|
||
theorem ofFin_val {n : ℕ} (i : Fin <| 2 ^ n) : (ofFin i).toNat = i.val := by | ||
theorem ofFin_val {n : ℕ} (i : Fin <| 2 ^ n) : (ofFin i).toNat = i.val := | ||
rfl | ||
#align bitvec.of_fin_val Std.BitVec.ofFin_val | ||
|
||
|
@@ -91,16 +76,12 @@ | |
simp [addLsb] | ||
#align bitvec.to_bool_add_lsb_mod_two Std.BitVec.decide_addLsb_mod_two | ||
|
||
@[simp] | ||
lemma ofNat_toNat (x : BitVec w) : BitVec.ofNat w x.toNat = x := by | ||
rcases x with ⟨x⟩ | ||
simp [BitVec.ofNat] | ||
apply Fin.cast_val_eq_self x | ||
#align bitvec.of_nat_to_nat Std.BitVec.ofNat_toNat | ||
@[simp] lemma ofNat_toNat' (x : BitVec w) : (x.toNat)#w = x := by | ||
rw [ofNat_toNat, truncate_eq] | ||
|
||
lemma ofNat_toNat' (x : BitVec w) (h : w = v): | ||
lemma ofNat_toNat_of_eq (x : BitVec w) (h : w = v): | ||
BitVec.ofNat v x.toNat = x.cast h := by | ||
cases h; rw [ofNat_toNat, cast_eq] | ||
cases h; rw [ofNat_toNat', cast_eq] | ||
|
||
theorem toFin_val {n : ℕ} (v : BitVec n) : (toFin v : ℕ) = v.toNat := by | ||
rfl | ||
|
Oops, something went wrong.
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.
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.
https://github.com/leanprover/std4/pull/366/files#r1410924581