Skip to content

Commit a9c0977

Browse files
committed
wip: bitblast shifts
1 parent f4f2c09 commit a9c0977

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Init/Data/BitVec/Bitblast.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,20 @@ theorem sle_eq_carry (x y : BitVec w) :
235235
x.sle y = !((x.msb == y.msb).xor (carry w y (~~~x) true)) := by
236236
rw [sle_eq_not_slt, slt_eq_not_carry, beq_comm]
237237

238+
/- ## Shift left for arbitrary bit width -/
239+
240+
def shiftLeftRec (x : BitVec w) (y : BitVec w) (n : Nat) : BitVec w :=
241+
let val := if y.getLsb n then x <<< n else 0#w
242+
match n with
243+
| 0 => val
244+
| n + 1 => val + shiftLeftRec val y n
245+
246+
@[simp]
247+
theorem shiftLeftRec_zero (x y : BitVec w) :
248+
shiftLeftRec x y 0 = if y.getLsb 0 then x else 0 := by
249+
simp [shiftLeftRec]
250+
251+
theorem shiftLeftRec_eq (x y : BitVec w) (n : Nat) :
252+
shiftLeftRec x y n = x <<< (y.truncate n).zeroExtend w := sorry
253+
238254
end BitVec

0 commit comments

Comments
 (0)