mathlib documentation

data.​num.​bitwise

data.​num.​bitwise

Equations

Equations

Equations

Equations

Equations

Equations
def pos_num.​shiftr  :
pos_num → ℕ → num

Equations
def num.​lor  :
num → num → num

Equations
def num.​land  :
num → num → num

Equations
def num.​ldiff  :
num → num → num

Equations
def num.​lxor  :
num → num → num

Equations
def num.​shiftl  :
num → ℕ → num

Equations
def num.​shiftr  :
num → ℕ → num

Equations
def num.​test_bit  :
num → ℕ → bool

Equations
inductive nzsnum  :
Type

See snum.

@[instance]

@[instance]

inductive snum  :
Type

Alternative representation of integers using a sign bit at the end. The convention on sign here is to have the argument to msb denote the sign of the MSB itself, with all higher bits set to the negation of this sign. The result is interpreted in two's complement.

13  = ..0001101(base 2) = nz (bit1 (bit0 (bit1 (msb tt))))
-13 = ..1110011(base 2) = nz (bit1 (bit1 (bit0 (msb ff))))

As with num, a special case must be added for zero, which has no msb, but by two's complement symmetry there is a second special case for -1. Here the bool field indicates the sign of the number.

0  = ..0000000(base 2) = zero ff
-1 = ..1111111(base 2) = zero tt
@[instance]

Equations
@[instance]

Equations
@[instance]

Equations
@[instance]

Equations
def nzsnum.​sign  :

Equations

Equations
def nzsnum.​head  :

Equations
def nzsnum.​tail  :

Equations
def snum.​sign  :

Equations
def snum.​not  :

Equations
def snum.​bit  :
bool → snum → snum

Equations
theorem snum.​bit_one (b : bool) :

def nzsnum.​drec' {C : snum → Sort u_1} (z : Π (b : bool), C (snum.zero b)) (s : Π (b : bool) (p : snum), C p → C (b :: p)) (p : nzsnum) :
C ↑p

Equations
def snum.​head  :

Equations
def snum.​tail  :

Equations
def snum.​drec' {C : snum → Sort u_1} (z : Π (b : bool), C (snum.zero b)) (s : Π (b : bool) (p : snum), C p → C (b :: p)) (p : snum) :
C p

Equations
def snum.​rec' {α : Sort u_1} :
(bool → α) → (bool → snum → α → α) → snum → α

Equations
def snum.​test_bit  :
ℕ → snum → bool

Equations
def snum.​succ  :

Equations
def snum.​pred  :

Equations
def snum.​neg  :

Equations
@[instance]

Equations
def snum.​bits (a : snum) (n : ℕ) :

Equations
def snum.​cadd  :
snum → snum → bool → snum

Equations
def snum.​add  :
snum → snum → snum

Equations
@[instance]

Equations
def snum.​sub  :
snum → snum → snum

Equations
@[instance]

Equations
def snum.​mul  :
snum → snum → snum

Equations
@[instance]

Equations