Skip to content

Commit

Permalink
Further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasgrosser committed Dec 7, 2024
1 parent 4b6b2ce commit 03782d8
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/Init/Data/BitVec/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1831,8 +1831,8 @@ theorem msb_append {x : BitVec w} {y : BitVec v} :
ext
simp only [getLsbD_append, getLsbD_zero, Bool.cond_self]

@[simp] theorem append_zero {n m : Nat} {x : BitVec n} :
x ++ 0#m = x.setWidth (n + m) <<< m := by
theorem append_zero {n m : Nat} {x : BitVec n} :
x ++ 0#m = x.signExtend (n + m) <<< m := by
induction m
case zero =>
simp
Expand Down Expand Up @@ -1866,9 +1866,25 @@ private theorem Nat.lt_mul_of_le_of_lt_of_lt {a b c : Nat} (hab : a ≤ b) (ha :

private theorem Nat.two_pow_lt_two_pow_add {n m : Nat} (h : m ≠ 0) :
2 ^ n < 2 ^ (n + m) := by
rw [Nat.pow_add]
have : 0 < 2 ^ n := Nat.pow_pos (by omega)
apply Nat.lt_mul_of_le_of_lt_of_lt (by omega) (by omega) (by simp [h])
apply Nat.pow_lt_pow_of_lt (by omega) (by omega)

@[simp] theorem toInt_append_zero {n m : Nat} {x : BitVec n} :
(x ++ 0#m).toInt = x.toInt * (2 ^ m) := by
by_cases m0 : m = 0
· subst m0
simp
·
simp only [ofNat_eq_ofNat, append_zero]
rw [toInt_eq_msb_cond]
rw [toInt_eq_msb_cond]
split
<;> split

simp





@[simp] theorem toInt_append {x : BitVec n} {y : BitVec m} :
(x ++ y).toInt = if n == 0 then y.toInt else x.toInt * (2 ^ m) + y.toNat := by
Expand All @@ -1894,7 +1910,6 @@ private theorem Nat.two_pow_lt_two_pow_add {n m : Nat} (h : m ≠ 0) :
omega


sorry
simp only [y0]
simp only [ofNat_eq_ofNat, append_zero]
rw [toInt_eq_toNat_cond]
Expand Down

0 comments on commit 03782d8

Please sign in to comment.