msb #
cast #
@[simp]
theorem
BitVec.toNat_cast
{w : Nat}
{v : Nat}
(h : w = v)
(x : BitVec w)
:
(BitVec.cast h x).toNat = x.toNat
@[simp]
theorem
BitVec.toFin_cast
{w : Nat}
{v : Nat}
(h : w = v)
(x : BitVec w)
:
(BitVec.cast h x).toFin = Fin.cast ⋯ x.toFin
@[simp]
theorem
BitVec.getLsb_cast
{w : Nat}
{v : Nat}
{i : Nat}
(h : w = v)
(x : BitVec w)
:
(BitVec.cast h x).getLsb i = x.getLsb i
@[simp]
theorem
BitVec.getMsb_cast
{w : Nat}
{v : Nat}
{i : Nat}
(h : w = v)
(x : BitVec w)
:
(BitVec.cast h x).getMsb i = x.getMsb i
@[simp]
theorem
BitVec.msb_cast
{w : Nat}
{v : Nat}
(h : w = v)
(x : BitVec w)
:
(BitVec.cast h x).msb = x.msb
toInt/ofInt #
@[simp]
@[simp]
zeroExtend and truncate #
@[simp]
theorem
BitVec.toNat_zeroExtend'
{m : Nat}
{n : Nat}
(p : m ≤ n)
(x : BitVec m)
:
(BitVec.zeroExtend' p x).toNat = x.toNat
theorem
BitVec.toNat_zeroExtend
{n : Nat}
(i : Nat)
(x : BitVec n)
:
(BitVec.zeroExtend i x).toNat = x.toNat % 2 ^ i
theorem
BitVec.zeroExtend'_eq
{w : Nat}
{v : Nat}
{x : BitVec w}
(h : w ≤ v)
:
BitVec.zeroExtend' h x = BitVec.zeroExtend v x
@[simp]
theorem
BitVec.toNat_truncate
{n : Nat}
{i : Nat}
(x : BitVec n)
:
(BitVec.truncate i x).toNat = x.toNat % 2 ^ i
@[simp]
@[simp]
theorem
BitVec.getLsb_zeroExtend'
{m : Nat}
{n : Nat}
(ge : m ≥ n)
(x : BitVec n)
(i : Nat)
:
(BitVec.zeroExtend' ge x).getLsb i = x.getLsb i
theorem
BitVec.msb_truncate
{w : Nat}
{k : Nat}
(x : BitVec w)
:
(BitVec.truncate (k + 1) x).msb = x.getLsb k
@[simp]
theorem
BitVec.zeroExtend_zeroExtend_of_le
{w : Nat}
{k : Nat}
{l : Nat}
(x : BitVec w)
(h : k ≤ l)
:
BitVec.zeroExtend k (BitVec.zeroExtend l x) = BitVec.zeroExtend k x
@[simp]
theorem
BitVec.truncate_truncate_of_le
{w : Nat}
{k : Nat}
{l : Nat}
(x : BitVec w)
(h : k ≤ l)
:
BitVec.truncate k (BitVec.truncate l x) = BitVec.truncate k x
@[simp]
theorem
BitVec.truncate_cast
{w : Nat}
{v : Nat}
{x : BitVec w}
{k : Nat}
{h : w = v}
:
BitVec.truncate k (BitVec.cast h x) = BitVec.truncate k x
extractLsb #
allOnes #
@[simp]
or #
@[simp]
theorem
BitVec.truncate_or
{w : Nat}
{k : Nat}
{x : BitVec w}
{y : BitVec w}
:
BitVec.truncate k (x ||| y) = BitVec.truncate k x ||| BitVec.truncate k y
and #
@[simp]
theorem
BitVec.truncate_and
{w : Nat}
{k : Nat}
{x : BitVec w}
{y : BitVec w}
:
BitVec.truncate k (x &&& y) = BitVec.truncate k x &&& BitVec.truncate k y
xor #
@[simp]
theorem
BitVec.truncate_xor
{w : Nat}
{k : Nat}
{x : BitVec w}
{y : BitVec w}
:
BitVec.truncate k (x ^^^ y) = BitVec.truncate k x ^^^ BitVec.truncate k y
not #
@[simp]
theorem
BitVec.truncate_not
{w : Nat}
{k : Nat}
{x : BitVec w}
(h : k ≤ w)
:
BitVec.truncate k (~~~x) = ~~~BitVec.truncate k x
cast #
@[simp]
theorem
BitVec.not_cast
{w : Nat}
{w' : Nat}
{x : BitVec w}
(h : w = w')
:
~~~BitVec.cast h x = BitVec.cast h (~~~x)
@[simp]
theorem
BitVec.and_cast
{w : Nat}
{w' : Nat}
{x : BitVec w}
{y : BitVec w}
(h : w = w')
:
BitVec.cast h x &&& BitVec.cast h y = BitVec.cast h (x &&& y)
@[simp]
theorem
BitVec.or_cast
{w : Nat}
{w' : Nat}
{x : BitVec w}
{y : BitVec w}
(h : w = w')
:
BitVec.cast h x ||| BitVec.cast h y = BitVec.cast h (x ||| y)
@[simp]
theorem
BitVec.xor_cast
{w : Nat}
{w' : Nat}
{x : BitVec w}
{y : BitVec w}
(h : w = w')
:
BitVec.cast h x &&& BitVec.cast h y = BitVec.cast h (x &&& y)
shiftLeft #
@[simp]
theorem
BitVec.toFin_shiftLeft
{w : Nat}
{n : Nat}
(x : BitVec w)
:
(x <<< n).toFin = Fin.ofNat' (x.toNat <<< n) ⋯
theorem
BitVec.shiftLeftZeroExtend_eq
{w : Nat}
{n : Nat}
{x : BitVec w}
:
x.shiftLeftZeroExtend n = BitVec.zeroExtend (w + n) x <<< n
ushiftRight #
append #
theorem
BitVec.append_def
{v : Nat}
{w : Nat}
(x : BitVec v)
(y : BitVec w)
:
x ++ y = x.shiftLeftZeroExtend w ||| BitVec.zeroExtend' ⋯ y
@[simp]
theorem
BitVec.truncate_append
{w : Nat}
{v : Nat}
{k : Nat}
{x : BitVec w}
{y : BitVec v}
:
BitVec.truncate k (x ++ y) = if h : k ≤ v then BitVec.truncate k y else BitVec.cast ⋯ (BitVec.truncate (k - v) x ++ y)
@[simp]
theorem
BitVec.truncate_cons
{w : Nat}
{a : Bool}
{x : BitVec w}
:
BitVec.truncate w (BitVec.cons a x) = x
rev #
cons #
@[simp]
theorem
BitVec.toNat_cons
{w : Nat}
(b : Bool)
(x : BitVec w)
:
(BitVec.cons b x).toNat = b.toNat <<< w ||| x.toNat
theorem
BitVec.toNat_cons'
{w : Nat}
{a : Bool}
{x : BitVec w}
:
(BitVec.cons a x).toNat = a.toNat <<< w + x.toNat
Variant of toNat_cons
using +
instead of |||
.
@[simp]
theorem
BitVec.getLsb_cons
(b : Bool)
{n : Nat}
(x : BitVec n)
(i : Nat)
:
(BitVec.cons b x).getLsb i = if i = n then b else x.getLsb i
@[simp]
@[simp]
theorem
BitVec.getMsb_cons_zero
{a : Bool}
:
∀ {w : Nat} {x : BitVec w}, (BitVec.cons a x).getMsb 0 = a
@[simp]
theorem
BitVec.truncate_succ
{w : Nat}
{i : Nat}
(x : BitVec w)
:
BitVec.truncate (i + 1) x = BitVec.cons (x.getLsb i) (BitVec.truncate i x)
theorem
BitVec.eq_msb_cons_truncate
{w : Nat}
(x : BitVec (w + 1))
:
x = BitVec.cons x.msb (BitVec.truncate w x)
@[simp]
theorem
BitVec.not_cons
{w : Nat}
(x : BitVec w)
(b : Bool)
:
~~~BitVec.cons b x = BitVec.cons (!b) (~~~x)
@[simp]
theorem
BitVec.cons_or_cons
{w : Nat}
(x : BitVec w)
(y : BitVec w)
(a : Bool)
(b : Bool)
:
BitVec.cons a x ||| BitVec.cons b y = BitVec.cons (a || b) (x ||| y)
@[simp]
theorem
BitVec.cons_and_cons
{w : Nat}
(x : BitVec w)
(y : BitVec w)
(a : Bool)
(b : Bool)
:
BitVec.cons a x &&& BitVec.cons b y = BitVec.cons (a && b) (x &&& y)
@[simp]
theorem
BitVec.cons_xor_cons
{w : Nat}
(x : BitVec w)
(y : BitVec w)
(a : Bool)
(b : Bool)
:
BitVec.cons a x ^^^ BitVec.cons b y = BitVec.cons (xor a b) (x ^^^ y)
concat #
add #
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
instance
BitVec.instLawfulIdentityHAddOfNatOfNatNat
{n : Nat}
:
Std.LawfulIdentity (fun (x x_1 : BitVec n) => x + x_1) 0#n
Equations
- ⋯ = ⋯
theorem
BitVec.truncate_add
{w : Nat}
{i : Nat}
(x : BitVec w)
(y : BitVec w)
(h : i ≤ w)
:
BitVec.truncate i (x + y) = BitVec.truncate i x + BitVec.truncate i y
theorem
BitVec.ofInt_add
{n : Nat}
(x : Int)
(y : Int)
:
BitVec.ofInt n (x + y) = BitVec.ofInt n x + BitVec.ofInt n y
sub/neg #
mul #
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
instance
BitVec.instLawfulCommIdentityHMulOfNatOfNatNat
{w : Nat}
:
Std.LawfulCommIdentity (fun (x y : BitVec w) => x * y) 1#w
Equations
- ⋯ = ⋯
theorem
BitVec.ofInt_mul
{n : Nat}
(x : Int)
(y : Int)
:
BitVec.ofInt n (x * y) = BitVec.ofInt n x * BitVec.ofInt n y
le and lt #
intMax #
The bitvector of width w
that has the largest value when interpreted as an integer.
Equations
- BitVec.intMax w = (2 ^ w - 1)#w
Instances For
ofBoolList #
@[simp]
theorem
BitVec.getMsb_ofBoolListBE
{bs : List Bool}
{i : Nat}
:
(BitVec.ofBoolListBE bs).getMsb i = bs.getD i false
@[simp]
theorem
BitVec.getLsb_ofBoolListLE
{bs : List Bool}
{i : Nat}
:
(BitVec.ofBoolListLE bs).getLsb i = bs.getD i false