Documentation

Mathlib.Data.BitVec

Basic Theorems About Bitvectors #

This file contains theorems about bitvectors which can only be stated in Mathlib or downstream because they refer to other notions defined in Mathlib.

Please do not extend this file further: material about BitVec needed in downstream projects can either be PR'd to Lean, or kept downstream if it also relies on Mathlib.

Injectivity #

Scalar Multiplication and Powers #

Having instance of SMul, SMul and Pow are prerequisites for a CommRing instance

instance BitVec.instSMulNat {w : } :
Equations
  • BitVec.instSMulNat = { smul := fun (x : ) (y : BitVec w) => { toFin := x y.toFin } }
instance BitVec.instSMulInt {w : } :
Equations
  • BitVec.instSMulInt = { smul := fun (x : ) (y : BitVec w) => { toFin := x y.toFin } }
Equations
  • BitVec.instPowNat_mathlib = { pow := fun (x : BitVec w) (n : ) => { toFin := x.toFin ^ n } }
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
theorem BitVec.toFin_pow {w : } (x : BitVec w) (n : ) :
(x ^ n).toFin = x.toFin ^ n

Ring #

Equations
@[simp]
theorem BitVec.ofFin_neg {w : } {x : Fin (2 ^ w)} :
{ toFin := -x } = -{ toFin := x }
@[simp]
theorem BitVec.ofFin_natCast {w : } (n : ) :
{ toFin := n } = n
theorem BitVec.toFin_natCast {w : } (n : ) :
(↑n).toFin = n
theorem BitVec.ofFin_intCast {w : } (z : ) :
{ toFin := z } = z
theorem BitVec.toFin_intCast {w : } (z : ) :
(↑z).toFin = z
Equations