File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -235,4 +235,20 @@ theorem sle_eq_carry (x y : BitVec w) :
235
235
x.sle y = !((x.msb == y.msb).xor (carry w y (~~~x) true )) := by
236
236
rw [sle_eq_not_slt, slt_eq_not_carry, beq_comm]
237
237
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
+
238
254
end BitVec
You can’t perform that action at this time.
0 commit comments