mathlib documentation

data.​num.​bitwise

data.​num.​bitwise

Equations

Equations

Equations

Equations

Equations

Equations
def pos_num.​shiftr  :
pos_numnum

Equations
def num.​lor  :
numnumnum

Equations
def num.​land  :
numnumnum

Equations
def num.​ldiff  :
numnumnum

Equations
def num.​lxor  :
numnumnum

Equations
def num.​shiftl  :
numnum

Equations
def num.​shiftr  :
numnum

Equations
def num.​test_bit  :
numbool

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  :
boolsnumsnum

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

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

Equations
def snum.​head  :

Equations
def snum.​tail  :

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

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

Equations
def snum.​test_bit  :
snumbool

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  :
snumsnumboolsnum

Equations
def snum.​add  :
snumsnumsnum

Equations
@[instance]

Equations
def snum.​sub  :
snumsnumsnum

Equations
@[instance]

Equations
def snum.​mul  :
snumsnumsnum

Equations
@[instance]

Equations