Skip to content

Commit cb5edce

Browse files
committed
one more
1 parent 9211694 commit cb5edce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,15 @@ theorem extractLsb'_eq_extractLsb {w : Nat} (x : BitVec w) (start len : Nat) (h
604604
@[simp] theorem getLsbD_allOnes : (allOnes v).getLsbD i = decide (i < v) := by
605605
simp [allOnes]
606606

607+
@[simp] theorem ofFin_add_rev (x : Fin (2^n)) : ofFin (x + x.rev) = allOnes n := by
608+
ext
609+
simp only [Fin.rev, getLsbD_ofFin, getLsbD_allOnes, Fin.is_lt, decide_True]
610+
rw [Fin.add_def]
611+
simp only [Nat.testBit_mod_two_pow, Fin.is_lt, decide_True, Bool.true_and]
612+
have h : (x : Nat) + (2 ^ n - (x + 1)) = 2 ^ n - 1 := by omega
613+
rw [h, Nat.testBit_two_pow_sub_one]
614+
simp
615+
607616
/-! ### or -/
608617

609618
@[simp] theorem toNat_or (x y : BitVec v) :

0 commit comments

Comments
 (0)