chore: Nat.testBit_add_one should not be a global simp lemma (#5262)
This commit is contained in:
parent
c8c35ad3b9
commit
3ec55d3d49
2 changed files with 9 additions and 3 deletions
|
|
@ -1391,14 +1391,14 @@ theorem eq_msb_cons_truncate (x : BitVec (w+1)) : x = (cons x.msb (x.truncate w)
|
|||
cases b
|
||||
· simp
|
||||
· rintro (_ | i)
|
||||
<;> simp [Nat.add_mod, Nat.add_comm, Nat.add_mul_div_right]
|
||||
<;> simp [Nat.add_mod, Nat.add_comm, Nat.add_mul_div_right, Nat.testBit_add_one]
|
||||
|
||||
theorem getLsbD_concat (x : BitVec w) (b : Bool) (i : Nat) :
|
||||
(concat x b).getLsbD i = if i = 0 then b else x.getLsbD (i - 1) := by
|
||||
simp only [concat, getLsbD, toNat_append, toNat_ofBool, Nat.testBit_or, Nat.shiftLeft_eq]
|
||||
cases i
|
||||
· simp [Nat.mod_eq_of_lt b.toNat_lt]
|
||||
· simp [Nat.div_eq_of_lt b.toNat_lt]
|
||||
· simp [Nat.div_eq_of_lt b.toNat_lt, Nat.testBit_add_one]
|
||||
|
||||
@[simp] theorem getLsbD_concat_zero : (concat x b).getLsbD 0 = b := by
|
||||
simp [getLsbD_concat]
|
||||
|
|
|
|||
|
|
@ -96,7 +96,13 @@ theorem testBit_succ (x i : Nat) : testBit x (succ i) = testBit (x/2) i := by
|
|||
unfold testBit
|
||||
simp [shiftRight_succ_inside]
|
||||
|
||||
@[simp] theorem testBit_add_one (x i : Nat) : testBit x (i + 1) = testBit (x/2) i := by
|
||||
/--
|
||||
Depending on use cases either `testBit_add_one` or `testBit_div_two`
|
||||
may be more useful as a `simp` lemma, so neither is a global `simp` lemma.
|
||||
-/
|
||||
-- We turn `testBit_add_one` on as a `local simp` for this file.
|
||||
@[local simp]
|
||||
theorem testBit_add_one (x i : Nat) : testBit x (i + 1) = testBit (x/2) i := by
|
||||
unfold testBit
|
||||
simp [shiftRight_succ_inside]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue