Mathlib.Data.Num.Basic
137 declarations. Mathlib docs · Source
theorem ZNum.pos.inj E1 #
∀ {a a_1 : PosNum}, ZNum.pos a = ZNum.pos a_1 → a = a_1
theorem ZNum.pos.injEq E0 #
∀ (a a_1 : PosNum), (ZNum.pos a = ZNum.pos a_1) = (a = a_1)
def PosNum.ctorIdx E1 #
PosNum → ℕ
def ZNum.ctorIdx E1 #
ZNum → ℕ
theorem Num.pos.inj E1 #
∀ {a a_1 : PosNum}, Num.pos a = Num.pos a_1 → a = a_1
def Num.ctorIdx E1 #
Num → ℕ
abbrev ZNum.ctorElimType E1 #
{motive : ZNum → Sort u} → ℕ → Sort (max 1 u)
theorem PosNum.brecOn.eq E1 #
∀ {motive : PosNum → Sort u} (t : PosNum) (F_1 : (t : PosNum) → PosNum.below t → motive t),
PosNum.brecOn t F_1 = F_1 t (PosNum.brecOn.go t F_1).2
theorem PosNum.bit0.inj E1 #
∀ {a a_1 : PosNum}, a.bit0 = a_1.bit0 → a = a_1
theorem ZNum.neg.injEq E0 #
∀ (a a_1 : PosNum), (ZNum.neg a = ZNum.neg a_1) = (a = a_1)
theorem PosNum.bit0.injEq E0 #
∀ (a a_1 : PosNum), (a.bit0 = a_1.bit0) = (a = a_1)
theorem PosNum.bit1.injEq E0 #
∀ (a a_1 : PosNum), (a.bit1 = a_1.bit1) = (a = a_1)
abbrev PosNum.brecOn.go E1 #
{motive : PosNum → Sort u} → (t : PosNum) → ((t : PosNum) → PosNum.below t → motive t) → motive t ×' PosNum.below t
theorem Num.pos.injEq E0 #
∀ (a a_1 : PosNum), (Num.pos a = Num.pos a_1) = (a = a_1)
abbrev Num.ctorElimType E1 #
{motive : Num → Sort u} → ℕ → Sort (max 1 u)
theorem PosNum.bit1.inj E1 #
∀ {a a_1 : PosNum}, a.bit1 = a_1.bit1 → a = a_1
abbrev PosNum.ctorElimType E1 #
{motive : PosNum → Sort u} → ℕ → Sort (max 1 u)
theorem ZNum.neg.inj E1 #
∀ {a a_1 : PosNum}, ZNum.neg a = ZNum.neg a_1 → a = a_1
inductive PosNum E1 #
Type
The type of positive binary numbers.
13 = 1101(base 2) = bit1 (bit0 (bit1 one))
ctor PosNum.one E0 #
PosNum
ctor PosNum.bit1 E0 #
PosNum → PosNum
ctor PosNum.bit0 E0 #
PosNum → PosNum
instance instDecidableEqPosNum E0 #
DecidableEq PosNum
def instDecidableEqPosNum.decEq E1 #
(x x_1 : PosNum) → Decidable (x = x_1)
instance instOnePosNum E0 #
One PosNum
instance instInhabitedPosNum E0 #
Inhabited PosNum
inductive Num E1 #
Type
The type of nonnegative binary numbers, using PosNum.
13 = 1101(base 2) = pos (bit1 (bit0 (bit1 one)))
ctor Num.zero E0 #
Num
ctor Num.pos E0 #
PosNum → Num
instance instDecidableEqNum E0 #
DecidableEq Num
def instDecidableEqNum.decEq E1 #
(x x_1 : Num) → Decidable (x = x_1)
instance instZeroNum E0 #
Zero Num
instance instOneNum E0 #
One Num
instance instInhabitedNum E0 #
Inhabited Num
inductive ZNum E1 #
Type
Representation of integers using trichotomy around zero.
13 = 1101(base 2) = pos (bit1 (bit0 (bit1 one)))
-13 = -1101(base 2) = neg (bit1 (bit0 (bit1 one)))
ctor ZNum.zero E0 #
ZNum
ctor ZNum.pos E0 #
PosNum → ZNum
ctor ZNum.neg E0 #
PosNum → ZNum
def instDecidableEqZNum.decEq E1 #
(x x_1 : ZNum) → Decidable (x = x_1)
instance instDecidableEqZNum E0 #
DecidableEq ZNum
instance instZeroZNum E0 #
Zero ZNum
instance instOneZNum E0 #
One ZNum
instance instInhabitedZNum E0 #
Inhabited ZNum
def PosNum.bit E1 #
Bool → PosNum → PosNum
bit b n appends the bit b to the end of n, where bit tt x = x1 and bit ff x = x0.
def PosNum.succ E1 #
PosNum → PosNum
The successor of a PosNum.
def PosNum.isOne E1 #
PosNum → Bool
Returns a Boolean for whether the PosNum is one.
def PosNum.add E1 #
PosNum → PosNum → PosNum
Addition of two PosNums.
instance PosNum.instAdd E0 #
Add PosNum
def PosNum.pred' E1 #
PosNum → Num
The predecessor of a PosNum as a Num.
def PosNum.pred E1 #
PosNum → PosNum
The predecessor of a PosNum as a PosNum. This means that pred 1 = 1.
def PosNum.size E1 #
PosNum → PosNum
The number of bits of a PosNum, as a PosNum.
def PosNum.natSize E1 #
PosNum → ℕ
The number of bits of a PosNum, as a Nat.
def PosNum.mul E1 #
PosNum → PosNum → PosNum
Multiplication of two PosNums.
instance PosNum.instMul E0 #
Mul PosNum
def PosNum.ofNatSucc E1 #
ℕ → PosNum
ofNatSucc n is the PosNum corresponding to n + 1.
def PosNum.ofNat E1 #
ℕ → PosNum
ofNat n is the PosNum corresponding to n, except for ofNat 0 = 1.
instance PosNum.instOfNatHAddNatOfNat E0 #
{n : ℕ} → OfNat PosNum (n + 1)
def PosNum.cmp E1 #
PosNum → PosNum → Ordering
Ordering of PosNums.
instance PosNum.instLT E0 #
LT PosNum
instance PosNum.instLE E0 #
LE PosNum
instance PosNum.decidableLT E0 #
DecidableLT PosNum
instance PosNum.decidableLE E0 #
DecidableLE PosNum
def castPosNum E1 #
{α : Type u_1} → [One α] → [Add α] → PosNum → α
castPosNum casts a PosNum into any type which has 1 and +.
def castNum E1 #
{α : Type u_1} → [One α] → [Add α] → [Zero α] → Num → α
castNum casts a Num into any type which has 0, 1 and +.
instance posNumCoe E0 #
{α : Type u_1} → [One α] → [Add α] → CoeHTCT PosNum α
instance numNatCoe E0 #
{α : Type u_1} → [One α] → [Add α] → [Zero α] → CoeHTCT Num α
instance instReprPosNum E0 #
Repr PosNum
instance instReprNum E0 #
Repr Num
def Num.succ' E1 #
Num → PosNum
The successor of a Num as a PosNum.
def Num.succ E1 #
Num → Num
The successor of a Num as a Num.
def Num.add E1 #
Num → Num → Num
Addition of two Nums.
instance Num.instAdd E0 #
Add Num
def Num.bit0 E1 #
Num → Num
bit0 n appends a 0 to the end of n, where bit0 n = n0.
def Num.bit1 E1 #
Num → Num
bit1 n appends a 1 to the end of n, where bit1 n = n1.
def Num.bit E1 #
Bool → Num → Num
bit b n appends the bit b to the end of n, where bit tt x = x1 and bit ff x = x0.
def Num.size E1 #
Num → Num
The number of bits required to represent a Num, as a Num. size 0 is defined to be 0.
def Num.natSize E1 #
Num → ℕ
The number of bits required to represent a Num, as a Nat. size 0 is defined to be 0.
def Num.mul E1 #
Num → Num → Num
Multiplication of two Nums.
instance Num.instMul E0 #
Mul Num
def Num.cmp E1 #
Num → Num → Ordering
Ordering of Nums.
instance Num.instLT E0 #
LT Num
instance Num.instLE E0 #
LE Num
instance Num.decidableLT E0 #
DecidableLT Num
instance Num.decidableLE E0 #
DecidableLE Num
def Num.toZNum E1 #
Num → ZNum
Converts a Num to a ZNum.
def Num.toZNumNeg E1 #
Num → ZNum
Converts x : Num to -x : ZNum.
def Num.ofNat' E1 #
ℕ → Num
Converts a Nat to a Num.
def ZNum.zNeg E1 #
ZNum → ZNum
The negation of a ZNum.
instance ZNum.instNeg E0 #
Neg ZNum
def ZNum.abs E1 #
ZNum → Num
The absolute value of a ZNum as a Num.
def ZNum.succ E1 #
ZNum → ZNum
The successor of a ZNum.
def ZNum.pred E1 #
ZNum → ZNum
The predecessor of a ZNum.
def ZNum.bit0 E1 #
ZNum → ZNum
bit0 n appends a 0 to the end of n, where bit0 n = n0.
def ZNum.bit1 E1 #
ZNum → ZNum
bit1 x appends a 1 to the end of x, mapping x to 2 * x + 1.
def ZNum.bitm1 E1 #
ZNum → ZNum
bitm1 x appends a 1 to the end of x, mapping x to 2 * x - 1.
def ZNum.ofInt' E1 #
ℤ → ZNum
Converts an Int to a ZNum.
def PosNum.sub' E1 #
PosNum → PosNum → ZNum
Subtraction of two PosNums, producing a ZNum.
def PosNum.ofZNum' E1 #
ZNum → Option PosNum
Converts a ZNum to Option PosNum, where it is some if the ZNum was positive and none
otherwise.
def PosNum.ofZNum E1 #
ZNum → PosNum
Converts a ZNum to a PosNum, mapping all out of range values to 1.
def PosNum.sub E1 #
PosNum → PosNum → PosNum
Subtraction of PosNums, where if a < b, then a - b = 1.
instance PosNum.instSub E0 #
Sub PosNum
def Num.ppred E1 #
Num → Option Num
The predecessor of a Num as an Option Num, where ppred 0 = none
def Num.pred E1 #
Num → Num
The predecessor of a Num as a Num, where pred 0 = 0.
def Num.div2 E1 #
Num → Num
Divides a Num by 2
def Num.ofZNum' E1 #
ZNum → Option Num
Converts a ZNum to an Option Num, where ofZNum' p = none if p < 0.
def Num.ofZNum E1 #
ZNum → Num
Converts a ZNum to an Option Num, where ofZNum p = 0 if p < 0.
def Num.sub' E1 #
Num → Num → ZNum
Subtraction of two Nums, producing a ZNum.
def Num.psub E1 #
Num → Num → Option Num
Subtraction of two Nums, producing an Option Num.
def Num.sub E1 #
Num → Num → Num
Subtraction of two Nums, where if a < b, a - b = 0.
instance Num.instSub E0 #
Sub Num
def ZNum.add E1 #
ZNum → ZNum → ZNum
Addition of ZNums.
instance ZNum.instAdd E0 #
Add ZNum
def ZNum.mul E1 #
ZNum → ZNum → ZNum
Multiplication of ZNums.
instance ZNum.instMul E0 #
Mul ZNum
def ZNum.cmp E1 #
ZNum → ZNum → Ordering
Ordering on ZNums.
instance ZNum.instLT E0 #
LT ZNum
instance ZNum.instLE E0 #
LE ZNum
instance ZNum.decidableLT E0 #
DecidableLT ZNum
instance ZNum.decidableLE E0 #
DecidableLE ZNum
def PosNum.divModAux E0 #
PosNum → Num → Num → Num × Num
Auxiliary definition for PosNum.divMod.
def PosNum.divMod E1 #
PosNum → PosNum → Num × Num
divMod x y = (y / x, y % x).
def PosNum.div' E1 #
PosNum → PosNum → Num
Division of PosNum
def PosNum.mod' E1 #
PosNum → PosNum → Num
Modulus of PosNums.
def Num.div E1 #
Num → Num → Num
Division of Nums, where x / 0 = 0.
def Num.mod E1 #
Num → Num → Num
Modulus of Nums.
instance Num.instDiv E0 #
Div Num
instance Num.instMod E0 #
Mod Num
def Num.gcdAux E0 #
ℕ → Num → Num → Num
Auxiliary definition for Num.gcd.
def Num.gcd E1 #
Num → Num → Num
Greatest Common Divisor (GCD) of two Nums.
def ZNum.div E1 #
ZNum → ZNum → ZNum
Division of ZNum, where x / 0 = 0.
def ZNum.mod E1 #
ZNum → ZNum → ZNum
Modulus of ZNums.
instance ZNum.instDiv E0 #
Div ZNum
instance ZNum.instMod E0 #
Mod ZNum
def ZNum.gcd E1 #
ZNum → ZNum → Num
Greatest Common Divisor (GCD) of two ZNums.
def castZNum E1 #
{α : Type u_1} → [Zero α] → [One α] → [Add α] → [Neg α] → ZNum → α
castZNum casts a ZNum into any type which has 0, 1, + and neg
instance znumCoe E0 #
{α : Type u_1} → [Zero α] → [One α] → [Add α] → [Neg α] → CoeHTCT ZNum α
instance instReprZNum E0 #
Repr ZNum