Documentation

Mathlib.Data.BitVec.Lemmas

Basic Theorems About Bitvectors #

This file contains theorems about bitvectors.

theorem BitVec.toFin_inj {w : } {x : BitVec w} {y : BitVec w} :
x.toFin = y.toFin x = y
theorem BitVec.toNat_inj {w : } {x : BitVec w} {y : BitVec w} :
theorem BitVec.toNat_lt_toNat {w : } {x : BitVec w} {y : BitVec w} :

x < y as natural numbers if and only if x < y as BitVec w.

theorem BitVec.toNat_ofNat_of_lt {w : } {m : } (h : m < 2 ^ w) :
@[simp]
theorem BitVec.extractLsb_eq {w : } (hi : ) (lo : ) (a : BitVec w) :
BitVec.extractLsb hi lo a = BitVec.extractLsb' lo (hi - lo + 1) a
theorem BitVec.toNat_extractLsb' {w : } {i : } {j : } {x : BitVec w} :
theorem BitVec.ofFin_val {n : } (i : Fin (2 ^ n)) :
BitVec.toNat { toFin := i } = i
theorem BitVec.addLsb_eq_twice_add_one {x : } {b : Bool} :
BitVec.addLsb x b = 2 * x + bif b then 1 else 0
theorem BitVec.addLsb_div_two {x : } {b : Bool} :
BitVec.addLsb x b / 2 = x
theorem BitVec.ofNat_toNat' {w : } (x : BitVec w) :
(BitVec.toNat x)#w = x
theorem BitVec.ofNat_toNat_of_eq {w : } {v : } (x : BitVec w) (h : w = v) :
theorem BitVec.toFin_val {n : } (v : BitVec n) :
v.toFin = BitVec.toNat v
theorem BitVec.toFin_le_toFin_of_le {n : } {v₀ : BitVec n} {v₁ : BitVec n} (h : v₀ v₁) :
v₀.toFin v₁.toFin
theorem BitVec.ofFin_le_ofFin_of_le {n : } {i : Fin (2 ^ n)} {j : Fin (2 ^ n)} (h : i j) :
{ toFin := i } { toFin := j }
theorem BitVec.toFin_ofFin {n : } (i : Fin (2 ^ n)) :
{ toFin := i }.toFin = i
theorem BitVec.ofFin_toFin {n : } (v : BitVec n) :
{ toFin := v.toFin } = v

Distributivity of BitVec.ofFin #

@[simp]
theorem BitVec.ofFin_neg {w : } (x : Fin (2 ^ w)) :
{ toFin := -x } = -{ toFin := x }
@[simp]
theorem BitVec.ofFin_and {w : } (x : Fin (2 ^ w)) (y : Fin (2 ^ w)) :
{ toFin := x &&& y } = { toFin := x } &&& { toFin := y }
@[simp]
theorem BitVec.ofFin_or {w : } (x : Fin (2 ^ w)) (y : Fin (2 ^ w)) :
{ toFin := x ||| y } = { toFin := x } ||| { toFin := y }
@[simp]
theorem BitVec.ofFin_xor {w : } (x : Fin (2 ^ w)) (y : Fin (2 ^ w)) :
{ toFin := x ^^^ y } = { toFin := x } ^^^ { toFin := y }
@[simp]
theorem BitVec.ofFin_mul {w : } (x : Fin (2 ^ w)) (y : Fin (2 ^ w)) :
{ toFin := x * y } = { toFin := x } * { toFin := y }
theorem BitVec.ofFin_zero {w : } :
{ toFin := 0 } = 0
theorem BitVec.ofFin_one {w : } :
{ toFin := 1 } = 1
theorem BitVec.ofFin_nsmul {w : } (n : ) (x : Fin (2 ^ w)) :
{ toFin := n x } = n { toFin := x }
theorem BitVec.ofFin_zsmul {w : } (z : ) (x : Fin (2 ^ w)) :
{ toFin := z x } = z { toFin := x }
@[simp]
theorem BitVec.ofFin_pow {w : } (x : Fin (2 ^ w)) (n : ) :
{ toFin := x ^ n } = { toFin := x } ^ n
@[simp]
theorem BitVec.ofFin_natCast {w : } (n : ) :
{ toFin := n } = n
@[simp]
theorem BitVec.ofFin_ofNat {w : } (n : ) :
{ toFin := OfNat.ofNat n } = OfNat.ofNat n

Distributivity of Std.BitVec.toFin #

@[simp]
theorem BitVec.toFin_neg {w : } (x : BitVec w) :
(-x).toFin = -x.toFin
theorem BitVec.toFin_zero {w : } :
0.toFin = 0
theorem BitVec.toFin_one {w : } :
1.toFin = 1
theorem BitVec.toFin_nsmul {w : } (n : ) (x : BitVec w) :
(n x).toFin = n x.toFin
theorem BitVec.toFin_zsmul {w : } (z : ) (x : BitVec w) :
(z x).toFin = z x.toFin
@[simp]
theorem BitVec.toFin_pow {w : } (x : BitVec w) (n : ) :
(x ^ n).toFin = x.toFin ^ n
theorem BitVec.toFin_natCast {w : } (n : ) :
(n).toFin = n

IntCast #

Ring #

Equations