Basic operations on bitvectors #
This is a work-in-progress, and contains additions to other theories.
This file was moved to mathlib from core Lean in the switch to Lean 3.20.0c. It is not fully in compliance with mathlib style standards.
@[reducible]
Create a bitvector of length n
whose n-1
st entry is 1 and other entries are 0.
Instances For
Bitvec
specific version of Vector.append
Instances For
Shift operations #
Bitwise operations #
Arithmetic operators #
Comparison operators #
Conversion to nat
and int
#
Create a bitvector from a nat
Equations
- Bitvec.ofNat 0 x = Vector.nil
- Bitvec.ofNat (Nat.succ n) x = Vector.append (Bitvec.ofNat n (x / 2)) (decide (x % 2 = 1) ::ᵥ Vector.nil)
Instances For
add_lsb r b
is r + r + 1
if b
is true
and r + r
otherwise.
Instances For
Return the natural number encoded by the input bitvector
Instances For
Return the integer encoded by the input bitvector