int
data IntThe integers: pos n stands for n and negsucc n stands for -(n + 1).
Int.succ
Section titled “Int.succ”def succ (n : Int) : IntInteger successor: n + 1.
Int.pred
Section titled “Int.pred”def pred (n : Int) : IntInteger predecessor: n - 1.
Int.neg
Section titled “Int.neg”def neg (n : Int) : IntInteger negation: -n.
Int.abs
Section titled “Int.abs”def abs (n : Int) : NatAbsolute value of an integer, as a natural number.
Int.addNat
Section titled “Int.addNat”def addNat (m : Nat) (n : Int) : IntAdd a natural number to an integer by applying Int.succ m times.
Int.subNat
Section titled “Int.subNat”def subNat (m : Nat) (n : Int) : IntSubtract a natural number from an integer by applying Int.pred m times.
Int.add
Section titled “Int.add”def add (m : Int) (n : Int) : IntInteger addition, by recursion on the first argument.
Int.sub
Section titled “Int.sub”def sub (m : Int) (n : Int) : IntInteger subtraction: m + (-n).
Int.mulNat
Section titled “Int.mulNat”def mulNat (m : Nat) (n : Int) : IntMultiply an integer by a natural number, as repeated addition.
Int.mul
Section titled “Int.mul”def mul (m : Int) (n : Int) : IntInteger multiplication, by recursion on the first argument.
Int.beq
Section titled “Int.beq”def beq (m : Int) (n : Int) : BoolBoolean equality test on integers.
Int.blt
Section titled “Int.blt”def blt (m : Int) (n : Int) : BoolBoolean strict less-than test on integers.
Int.ble
Section titled “Int.ble”def ble (m : Int) (n : Int) : BoolBoolean less-than-or-equal test on integers.
Int.isPos
Section titled “Int.isPos”def isPos (n : Int) : BoolBoolean test for whether an integer is strictly positive.
Int.isNeg
Section titled “Int.isNeg”def isNeg (n : Int) : BoolBoolean test for whether an integer is strictly negative.
Int.isZero
Section titled “Int.isZero”def isZero (n : Int) : BoolBoolean test for whether an integer is zero.
Int.toNat
Section titled “Int.toNat”def toNat (n : Int) : NatConvert an integer to a natural number, sending negative integers to zero.
Int.ofNat
Section titled “Int.ofNat”def ofNat (n : Nat) : IntEmbed a natural number into the integers.
Int.double
Section titled “Int.double”def double (n : Int) : IntDouble an integer: n + n.
Int.min
Section titled “Int.min”def min (m : Int) (n : Int) : IntThe smaller of two integers.
Int.max
Section titled “Int.max”def max (m : Int) (n : Int) : IntThe larger of two integers.
Int.sign
Section titled “Int.sign”def sign (n : Int) : IntSign of an integer: 1, 0 or -1.
Int.pow
Section titled “Int.pow”def pow (base : Int) (exp : Nat) : IntInteger power with a natural-number exponent: base ^ exp.
Int.zero
Section titled “Int.zero”def zero : IntThe integer 0.
Int.one
Section titled “Int.one”def one : IntThe integer 1.
Int.two
Section titled “Int.two”def two : IntThe integer 2.
Int.negOne
Section titled “Int.negOne”def negOne : IntThe integer -1.
Int.negTwo
Section titled “Int.negTwo”def negTwo : IntThe integer -2.
Int.iterate
Section titled “Int.iterate”def iterate (f : Int -> Int) (n : Nat) (x : Int) : IntApply an integer function n times to x.
Int.lit
Section titled “Int.lit”def lit (n : Nat) : IntThe integer literal for a natural number n.
Int.triple
Section titled “Int.triple”def triple (n : Int) : IntTriple an integer: n + (n + n).
Int.square
Section titled “Int.square”def square (n : Int) : IntSquare an integer: n * n.
Int.dist
Section titled “Int.dist”def dist (m : Int) (n : Int) : IntDistance between two integers: |m - n|, as an integer.
Int.addNatZero
Section titled “Int.addNatZero”def addNatZero (n : Int) : Int.addNat Nat.zero n = nAdding zero by Int.addNat leaves an integer unchanged.
Int.subNatZero
Section titled “Int.subNatZero”def subNatZero (n : Int) : Int.subNat Nat.zero n = nSubtracting zero by Int.subNat leaves an integer unchanged.
Int.addNatSucc
Section titled “Int.addNatSucc”def addNatSucc (k : Nat) (n : Int) : Int.addNat (Nat.succ k) n = Int.succ (Int.addNat k n)Unfolding of Int.addNat at a successor: Int.addNat (k + 1) n = Int.succ (Int.addNat k n).
Int.addPosSucc
Section titled “Int.addPosSucc”def addPosSucc (k : Nat) (n : Int) : Int.add (pos (Nat.succ k)) n = Int.succ (Int.add (pos k) n)Unfolding of integer addition at a positive successor: (k + 1) + n = Int.succ (k + n).
Int.addNatPosZero
Section titled “Int.addNatPosZero”def addNatPosZero (k : Nat) : Int.addNat k (pos Nat.zero) = pos kAdding k to zero gives the integer k: Int.addNat k 0 = pos k.
Int.subNatNegZero
Section titled “Int.subNatNegZero”def subNatNegZero (k : Nat) : Int.subNat (Nat.succ k) (pos Nat.zero) = negsucc kSubtracting k + 1 from zero gives -(k + 1): Int.subNat (k + 1) 0 = negsucc k.
Int.succAddNat
Section titled “Int.succAddNat”def succAddNat (k : Nat) (n : Int) : Int.succ (Int.addNat k n) = Int.addNat k (Int.succ n)Successor commutes with adding a natural number: Int.succ (Int.addNat k n) = Int.addNat k (Int.succ n).
Int.addNatSuccL
Section titled “Int.addNatSuccL”def addNatSuccL (k : Nat) (n : Int) : Int.addNat (Nat.succ k) n = Int.addNat k (Int.succ n)Adding k + 1 is adding k to the successor: Int.addNat (k + 1) n = Int.addNat k (Int.succ n).
Int.predSubNat
Section titled “Int.predSubNat”def predSubNat (k : Nat) (n : Int) : Int.pred (Int.subNat k n) = Int.subNat k (Int.pred n)Predecessor commutes with subtracting a natural number: Int.pred (Int.subNat k n) = Int.subNat k (Int.pred n).
Int.negInvolPos
Section titled “Int.negInvolPos”def negInvolPos (k : Nat) : Int.neg (Int.neg (pos k)) = pos kDouble negation of a non-negative integer is itself: -(-(pos k)) = pos k.
Int.negInvolNeg
Section titled “Int.negInvolNeg”def negInvolNeg (k : Nat) : Int.neg (Int.neg (negsucc k)) = negsucc kDouble negation of a negative integer is itself: -(-(negsucc k)) = negsucc k.
Int.negInvol
Section titled “Int.negInvol”def negInvol (n : Int) : Int.neg (Int.neg n) = nInteger negation is an involution: -(-n) = n.
Int.beqRefl
Section titled “Int.beqRefl”def beqRefl (n : Int) : Int.beq n n = trueBoolean integer equality is reflexive: Int.beq n n = true.
Int.sucPred
Section titled “Int.sucPred”def sucPred (n : Int) : Int.succ (Int.pred n) = nSuccessor undoes predecessor: Int.succ (Int.pred n) = n.
Int.predSucc
Section titled “Int.predSucc”def predSucc (n : Int) : Int.pred (Int.succ n) = nPredecessor undoes successor: Int.pred (Int.succ n) = n.
Int.mulZeroL
Section titled “Int.mulZeroL”def mulZeroL (n : Int) : Int.mul (pos Nat.zero) n = pos Nat.zeroZero absorbs integer multiplication on the left: 0 * n = 0.
Int.mulNatZero
Section titled “Int.mulNatZero”def mulNatZero (n : Int) : Int.mulNat Nat.zero n = pos Nat.zeroMultiplying an integer by the natural number zero gives zero.
Int.mulNatOne
Section titled “Int.mulNatOne”def mulNatOne (n : Int) : Int.mulNat (Nat.succ Nat.zero) n = Int.add n (pos Nat.zero)Unfolding of multiplication by the natural number one: Int.mulNat 1 n = n + 0.
Int.succIsAddOne
Section titled “Int.succIsAddOne”def succIsAddOne (n : Int) : Int.succ n = Int.add (pos (Nat.succ Nat.zero)) nThe integer successor is adding one: Int.succ n = 1 + n.
Int.predIsAddNegOne
Section titled “Int.predIsAddNegOne”def predIsAddNegOne (n : Int) : Int.pred n = Int.add (negsucc Nat.zero) nThe integer predecessor is adding minus one: Int.pred n = -1 + n.
Int.absPos
Section titled “Int.absPos”def absPos (k : Nat) : Int.abs (pos k) = kThe absolute value of pos k is k.
Int.absNegsucc
Section titled “Int.absNegsucc”def absNegsucc (k : Nat) : Int.abs (negsucc k) = Nat.succ kThe absolute value of negsucc k is k + 1.
Int.isZeroPos
Section titled “Int.isZeroPos”def isZeroPos (k : Nat) : Int.isZero (pos (Nat.succ k)) = falseA positive integer is not zero: Int.isZero (pos (k + 1)) = false.
Int.isZeroNeg
Section titled “Int.isZeroNeg”def isZeroNeg (k : Nat) : Int.isZero (negsucc k) = falseA negative integer is not zero: Int.isZero (negsucc k) = false.
Int.toNatPos
Section titled “Int.toNatPos”def toNatPos (k : Nat) : Int.toNat (pos k) = kConverting pos k to a natural number gives k.
Int.toNatNeg
Section titled “Int.toNatNeg”def toNatNeg (k : Nat) : Int.toNat (negsucc k) = Nat.zeroConverting a negative integer to a natural number gives zero.
Int.ofNatSucc
Section titled “Int.ofNatSucc”def ofNatSucc (k : Nat) : Int.ofNat (Nat.succ k) = pos (Nat.succ k)Embedding a successor natural gives the positive integer pos (k + 1).
Int.mulNatZeroR
Section titled “Int.mulNatZeroR”def mulNatZeroR (k : Nat) : Int.mulNat k (pos Nat.zero) = pos Nat.zeroMultiplying the integer zero by a natural number gives zero: k * 0 = 0.
Int.mulNatOneR
Section titled “Int.mulNatOneR”def mulNatOneR (k : Nat) : Int.mulNat k (pos (Nat.succ Nat.zero)) = pos kMultiplying the integer one by a natural number k gives pos k.
Int.negSuc
Section titled “Int.negSuc”def negSuc (n : Int) : Int.neg (Int.succ n) = Int.pred (Int.neg n)Negation turns successor into predecessor: -(Int.succ n) = Int.pred (-n).
Int.negPred
Section titled “Int.negPred”def negPred (n : Int) : Int.neg (Int.pred n) = Int.succ (Int.neg n)Negation turns predecessor into successor: -(Int.pred n) = Int.succ (-n).
Int.addNatSuccR
Section titled “Int.addNatSuccR”def addNatSuccR (k : Nat) (n : Int) : Int.addNat k (Int.succ n) = Int.succ (Int.addNat k n)Adding a natural number commutes with successor: Int.addNat k (Int.succ n) = Int.succ (Int.addNat k n).
Int.subNatPred
Section titled “Int.subNatPred”def subNatPred (k : Nat) (n : Int) : Int.subNat k (Int.pred n) = Int.pred (Int.subNat k n)Subtracting a natural number commutes with predecessor: Int.subNat k (Int.pred n) = Int.pred (Int.subNat k n).
Int.succSubNat
Section titled “Int.succSubNat”def succSubNat (k : Nat) (n : Int) : Int.succ (Int.subNat k n) = Int.subNat k (Int.succ n)Successor commutes with subtracting a natural number: Int.succ (Int.subNat k n) = Int.subNat k (Int.succ n).
Int.predAddNat
Section titled “Int.predAddNat”def predAddNat (k : Nat) (n : Int) : Int.pred (Int.addNat k n) = Int.addNat k (Int.pred n)Predecessor commutes with adding a natural number: Int.pred (Int.addNat k n) = Int.addNat k (Int.pred n).
Int.addNatComm
Section titled “Int.addNatComm”def addNatComm (k : Nat) (m : Nat) : Int.addNat k (pos m) = Int.addNat m (pos k)Adding naturals onto non-negative integers is commutative: Int.addNat k (pos m) = Int.addNat m (pos k).
Int.addZeroL
Section titled “Int.addZeroL”def addZeroL (n : Int) : Int.add (pos Nat.zero) n = nZero is a left identity for integer addition: 0 + n = n.
Int.posCong
Section titled “Int.posCong”def posCong {m n : Nat} (p : m = n) : pos m = pos nCongruence for pos: m = n implies pos m = pos n.
Int.negSuccCong
Section titled “Int.negSuccCong”def negSuccCong {m n : Nat} (p : m = n) : negsucc m = negsucc nCongruence for negsucc: m = n implies negsucc m = negsucc n.
Int.congNeg
Section titled “Int.congNeg”def congNeg {m n : Int} (p : m = n) : Int.neg m = Int.neg nCongruence for integer negation: m = n implies -m = -n.
Int.congAbs
Section titled “Int.congAbs”def congAbs {m n : Int} (p : m = n) : Int.abs m = Int.abs nCongruence for integer absolute value: m = n implies |m| = |n|.
Int.congSucc
Section titled “Int.congSucc”def congSucc {m n : Int} (p : m = n) : Int.succ m = Int.succ nCongruence for integer successor: m = n implies Int.succ m = Int.succ n.
Int.congPred
Section titled “Int.congPred”def congPred {m n : Int} (p : m = n) : Int.pred m = Int.pred nCongruence for integer predecessor: m = n implies Int.pred m = Int.pred n.
Int.addZeroR
Section titled “Int.addZeroR”def addZeroR (n : Int) : Int.add n (pos Nat.zero) = nZero is a right identity for integer addition: m + 0 = m.
Int.mulNatOneV2
Section titled “Int.mulNatOneV2”def mulNatOneV2 (n : Int) : Int.mulNat (Nat.succ Nat.zero) n = nMultiplying an integer by the natural number one gives it back: Int.mulNat 1 n = n.
Int.absNegPos
Section titled “Int.absNegPos”def absNegPos (k : Nat) : Int.abs (Int.neg (pos k)) = Int.abs (pos k)Negating a non-negative integer keeps its absolute value: |-(pos k)| = |pos k|.
Int.absNegNegsucc
Section titled “Int.absNegNegsucc”def absNegNegsucc (k : Nat) : Int.abs (Int.neg (negsucc k)) = Int.abs (negsucc k)Negating a negative integer keeps its absolute value: |-(negsucc k)| = |negsucc k|.
Int.absNeg
Section titled “Int.absNeg”def absNeg (n : Int) : Int.abs (Int.neg n) = Int.abs nNegation preserves absolute value: |-n| = |n|.
Int.mulZeroR
Section titled “Int.mulZeroR”def mulZeroR (n : Int) : Int.mul n (pos Nat.zero) = pos Nat.zeroZero absorbs integer multiplication on the right: m * 0 = 0.
Int.mulOneL
Section titled “Int.mulOneL”def mulOneL (n : Int) : Int.mul (pos (Nat.succ Nat.zero)) n = nOne is a left identity for integer multiplication: 1 * m = m.
Int.mulOneR
Section titled “Int.mulOneR”def mulOneR (n : Int) : Int.mul n (pos (Nat.succ Nat.zero)) = nOne is a right identity for integer multiplication: m * 1 = m.
Int.powZero
Section titled “Int.powZero”def powZero (n : Int) : Int.pow n Nat.zero = pos (Nat.succ Nat.zero)Any integer to the power zero is one: n ^ 0 = 1.
Int.powOne
Section titled “Int.powOne”def powOne (n : Int) : Int.pow n (Nat.succ Nat.zero) = nAny integer to the power one is itself: n ^ 1 = n.
Int.powOneBase
Section titled “Int.powOneBase”def powOneBase (k : Nat) : Int.pow (pos (Nat.succ Nat.zero)) k = pos (Nat.succ Nat.zero)Every power of the integer one is one: 1 ^ k = 1.
Int.doubleIsAdd
Section titled “Int.doubleIsAdd”def doubleIsAdd (n : Int) : Int.double n = Int.add n nInt.double n unfolds to n + n.
Int.squareIsMul
Section titled “Int.squareIsMul”def squareIsMul (n : Int) : Int.square n = Int.mul n nInt.square n unfolds to n * n.
Int.ofNatToNatPos
Section titled “Int.ofNatToNatPos”def ofNatToNatPos (k : Nat) : Int.ofNat (Int.toNat (pos k)) = pos kRound-tripping a non-negative integer through Nat gives it back: Int.ofNat (Int.toNat (pos k)) = pos k.
Int.intToOfNat
Section titled “Int.intToOfNat”def intToOfNat (k : Nat) : Int.toNat (Int.ofNat k) = kRound-tripping a natural number through Int gives it back: Int.toNat (Int.ofNat k) = k.
Int.five
Section titled “Int.five”def five : IntThe integer 5.
Int.negFive
Section titled “Int.negFive”def negFive : IntThe integer -5.
Int.cube
Section titled “Int.cube”def cube (n : Int) : IntCube an integer: n * (n * n).
Int.absAs
Section titled “Int.absAs”def absAs (n : Int) : IntAbsolute value of an integer, as a non-negative integer.
Int.clamp
Section titled “Int.clamp”def clamp (lo : Int) (hi : Int) (n : Int) : IntClamp an integer into the range [lo, hi].
Int.eqDec
Section titled “Int.eqDec”def eqDec (m : Int) (n : Int) : BoolBoolean equality test on integers (an alias for Int.beq).
Int.litNeg
Section titled “Int.litNeg”def litNeg (n : Nat) : IntThe negative integer -(n + 1), as a literal shorthand for negsucc n.
Int.succN
Section titled “Int.succN”def succN (n : Nat) (x : Int) : IntApply Int.succ n times to x: x + n.
Int.predN
Section titled “Int.predN”def predN (n : Nat) (x : Int) : IntApply Int.pred n times to x: x - n.
Int.three
Section titled “Int.three”def three : IntThe integer 3.
Int.four
Section titled “Int.four”def four : IntThe integer 4.
Int.ten
Section titled “Int.ten”def ten : IntThe integer 10.
Int.negThree
Section titled “Int.negThree”def negThree : IntThe integer -3.
Int.negFour
Section titled “Int.negFour”def negFour : IntThe integer -4.
Int.congAdd
Section titled “Int.congAdd”def congAdd {m1 m2 n1 n2 : Int} (p : m1 = m2) (q : n1 = n2) : Int.add m1 n1 = Int.add m2 n2Congruence for integer addition in both arguments.
Int.congSub
Section titled “Int.congSub”def congSub {m1 m2 n1 n2 : Int} (p : m1 = m2) (q : n1 = n2) : Int.sub m1 n1 = Int.sub m2 n2Congruence for integer subtraction in both arguments.
Int.congMul
Section titled “Int.congMul”def congMul {m1 m2 n1 n2 : Int} (p : m1 = m2) (q : n1 = n2) : Int.mul m1 n1 = Int.mul m2 n2Congruence for integer multiplication in both arguments.
Int.congBeq
Section titled “Int.congBeq”def congBeq {m1 m2 n1 n2 : Int} (p : m1 = m2) (q : n1 = n2) : Int.beq m1 n1 = Int.beq m2 n2Congruence for boolean integer equality in both arguments.
Int.congBlt
Section titled “Int.congBlt”def congBlt {m1 m2 n1 n2 : Int} (p : m1 = m2) (q : n1 = n2) : Int.blt m1 n1 = Int.blt m2 n2Congruence for boolean integer less-than in both arguments.
Int.congSign
Section titled “Int.congSign”def congSign {m n : Int} (p : m = n) : Int.sign m = Int.sign nCongruence for the integer sign function.
Int.congAbsAs
Section titled “Int.congAbsAs”def congAbsAs {m n : Int} (p : m = n) : Int.absAs m = Int.absAs nCongruence for Int.absAs.
Int.indPos
Section titled “Int.indPos”def indPos (P : Int -> Type) (z : P (pos Nat.zero)) (s : (m : Int) -> P m -> P (Int.succ m)) (k : Nat) : P (pos k)Integer induction on the non-negative part: from P 0 and a successor step, P holds at every pos k.
Int.indNeg
Section titled “Int.indNeg”def indNeg (P : Int -> Type) (z : P (pos Nat.zero)) (p : (m : Int) -> P m -> P (Int.pred m)) (k : Nat) : P (negsucc k)Integer induction on the negative part: from P 0 and a predecessor step, P holds at every negsucc k.
Int.ind
Section titled “Int.ind”def ind (P : Int -> Type) (z : P (pos Nat.zero)) (s : (m : Int) -> P m -> P (Int.succ m)) (p : (m : Int) -> P m -> P (Int.pred m)) (m : Int) : P mInteger induction: from P 0, a successor step and a predecessor step, P holds at every integer.
Int.addNatPred
Section titled “Int.addNatPred”def addNatPred (k : Nat) (n : Int) : Int.addNat k (Int.pred n) = Int.pred (Int.addNat k n)Adding a natural number commutes with predecessor: Int.addNat k (Int.pred n) = Int.pred (Int.addNat k n).
Int.subNatSuc
Section titled “Int.subNatSuc”def subNatSuc (k : Nat) (n : Int) : Int.subNat k (Int.succ n) = Int.succ (Int.subNat k n)Subtracting a natural number commutes with successor: Int.subNat k (Int.succ n) = Int.succ (Int.subNat k n).
Int.addSucR
Section titled “Int.addSucR”def addSucR (m : Int) (n : Int) : Int.add m (Int.succ n) = Int.succ (Int.add m n)Successor in the right summand moves outside: m + Int.succ n = Int.succ (m + n).
Int.addPredR
Section titled “Int.addPredR”def addPredR (m : Int) (n : Int) : Int.add m (Int.pred n) = Int.pred (Int.add m n)Predecessor in the right summand moves outside: m + Int.pred n = Int.pred (m + n).
Int.addSucL
Section titled “Int.addSucL”def addSucL (m : Int) (n : Int) : Int.add (Int.succ m) n = Int.succ (Int.add m n)Successor in the left summand moves outside: Int.succ m + n = Int.succ (m + n).
Int.addPredL
Section titled “Int.addPredL”def addPredL (m : Int) (n : Int) : Int.add (Int.pred m) n = Int.pred (Int.add m n)Predecessor in the left summand moves outside: Int.pred m + n = Int.pred (m + n).
Int.addComm
Section titled “Int.addComm”def addComm (m : Int) (n : Int) : Int.add m n = Int.add n mCommutativity of integer addition: m + n = n + m.
Int.addAssoc
Section titled “Int.addAssoc”def addAssoc (m : Int) (n : Int) (o : Int) : Int.add (Int.add m n) o = Int.add m (Int.add n o)Associativity of integer addition: (m + n) + o = m + (n + o).
Int.negAdd
Section titled “Int.negAdd”def negAdd (m : Int) (n : Int) : Int.neg (Int.add m n) = Int.add (Int.neg m) (Int.neg n)Negation distributes over integer addition: -(m + n) = -m + -n.
Int.addNegR
Section titled “Int.addNegR”def addNegR (m : Int) : Int.add m (Int.neg m) = pos Nat.zeroAn integer plus its negation is zero: m + (-m) = 0.
Int.addNegL
Section titled “Int.addNegL”def addNegL (m : Int) : Int.add (Int.neg m) m = pos Nat.zeroThe negation of an integer plus the integer is zero: -m + m = 0.
Int.addSwap
Section titled “Int.addSwap”def addSwap (a : Int) (b : Int) (c : Int) : Int.add a (Int.add b c) = Int.add b (Int.add a c)Swap the first two summands of a right-nested sum: a + (b + c) = b + (a + c).
Int.mulSucL
Section titled “Int.mulSucL”def mulSucL (m : Int) (n : Int) : Int.mul (Int.succ m) n = Int.add n (Int.mul m n)Successor in the left factor adds one copy: Int.succ m * n = n + m * n.
Int.mulPredL
Section titled “Int.mulPredL”def mulPredL (m : Int) (n : Int) : Int.mul (Int.pred m) n = Int.add (Int.neg n) (Int.mul m n)Predecessor in the left factor subtracts one copy: Int.pred m * n = -n + m * n.
Int.mulDistribR
Section titled “Int.mulDistribR”def mulDistribR (m : Int) (n : Int) (o : Int) : Int.mul (Int.add m n) o = Int.add (Int.mul m o) (Int.mul n o)Integer multiplication distributes over addition on the left factor: (m + n) * o = m * o + n * o.
Int.mulSucR
Section titled “Int.mulSucR”def mulSucR (m : Int) (n : Int) : Int.mul m (Int.succ n) = Int.add m (Int.mul m n)Successor in the right factor adds one copy: m * Int.succ n = m + m * n.
Int.mulPredR
Section titled “Int.mulPredR”def mulPredR (m : Int) (n : Int) : Int.mul m (Int.pred n) = Int.add (Int.neg m) (Int.mul m n)Predecessor in the right factor subtracts one copy: m * Int.pred n = -m + m * n.
Int.mulComm
Section titled “Int.mulComm”def mulComm (m : Int) (n : Int) : Int.mul m n = Int.mul n mCommutativity of integer multiplication: m * n = n * m.
Int.mulDistribL
Section titled “Int.mulDistribL”def mulDistribL (m : Int) (n : Int) (o : Int) : Int.mul m (Int.add n o) = Int.add (Int.mul m n) (Int.mul m o)Integer multiplication distributes over addition on the right factor: m * (n + o) = m * n + m * o.
Int.mulNegL
Section titled “Int.mulNegL”def mulNegL (m : Int) (n : Int) : Int.mul (Int.neg m) n = Int.neg (Int.mul m n)Negation of the left factor negates the product: (-m) * n = -(m * n).
Int.mulAssoc
Section titled “Int.mulAssoc”def mulAssoc (m : Int) (n : Int) (o : Int) : Int.mul (Int.mul m n) o = Int.mul m (Int.mul n o)Associativity of integer multiplication: (m * n) * o = m * (n * o).
Int.addNatPos
Section titled “Int.addNatPos”def addNatPos (k : Nat) (m : Nat) : Int.addNat k (pos m) = pos (Nat.add k m)Adding a natural to a non-negative integer stays non-negative: Int.addNat k (pos m) = pos (k + m).
Int.mulNatPos
Section titled “Int.mulNatPos”def mulNatPos (n : Nat) (m : Nat) : Int.mulNat n (pos m) = pos (Nat.mul n m)Multiplying a non-negative integer by a natural stays non-negative: Int.mulNat n (pos m) = pos (n * m).
Int.quot
Section titled “Int.quot”def quot (a : Int) (b : Int) : IntTruncating integer division (C++ semantics): divides the absolute values and gives the quotient the product of the signs; division by zero gives zero.
Int.rem
Section titled “Int.rem”def rem (a : Int) (b : Int) : IntInteger remainder matching truncating division (C++ semantics): takes the sign of the dividend; division by zero returns the dividend.
Int.negOfNat
Section titled “Int.negOfNat”def negOfNat (k : Nat) : IntThe negation of a natural number, as an integer: -k.
Int.subNatNat
Section titled “Int.subNatNat”def subNatNat (m : Nat) (n : Nat) : IntSubtract two naturals into an integer, m - n, using fast natural-number subtraction instead of step-by-step recursion.
Int.addFast
Section titled “Int.addFast”def addFast (a : Int) (b : Int) : IntFast integer addition built on accelerated natural-number operations; provably equal to Int.add.
Int.subFast
Section titled “Int.subFast”def subFast (a : Int) (b : Int) : IntFast integer subtraction built on Int.addFast; provably equal to Int.sub.
Int.mulFast
Section titled “Int.mulFast”def mulFast (a : Int) (b : Int) : IntFast integer multiplication built on accelerated natural-number operations; provably equal to Int.mul.
Int.subNatSlow
Section titled “Int.subNatSlow”def subNatSlow (m : Nat) (n : Nat) : IntNatural subtraction m - n into an integer, peeling both arguments in step; a proof intermediate for Int.subNatNat.
Int.subNatNatSlow
Section titled “Int.subNatNatSlow”def subNatNatSlow (m : Nat) (n : Nat) : Int.subNatNat m n = Int.subNatSlow m nThe fast and the step-by-step natural subtraction agree: Int.subNatNat m n = Int.subNatSlow m n.
Int.subNatSlowZero
Section titled “Int.subNatSlowZero”def subNatSlowZero (a : Nat) : Int.subNatSlow a Nat.zero = pos aSubtracting zero gives the non-negative integer itself: Int.subNatSlow a 0 = pos a.
Int.succSubNatSlow
Section titled “Int.succSubNatSlow”def succSubNatSlow (j : Nat) (n : Nat) : Int.succ (Int.subNatSlow j (Nat.succ n)) = Int.subNatSlow j nSuccessor of j - (n + 1) is j - n, for natural subtraction into the integers.
Int.predSubNatSlow
Section titled “Int.predSubNatSlow”def predSubNatSlow (n : Nat) (j : Nat) : Int.pred (Int.subNatSlow n j) = Int.subNatSlow n (Nat.succ j)Predecessor of n - j is n - (j + 1), for natural subtraction into the integers.
Int.addNatNegsucc
Section titled “Int.addNatNegsucc”def addNatNegsucc (m : Nat) (n : Nat) : Int.addNat m (negsucc n) = Int.subNatSlow m (Nat.succ n)Adding m to -(n + 1) is m - (n + 1): Int.addNat m (negsucc n) = Int.subNatSlow m (n + 1).
Int.subNatPos
Section titled “Int.subNatPos”def subNatPos (k : Nat) (n : Nat) : Int.subNat k (pos n) = Int.subNatSlow n kSubtracting k from a non-negative integer n is n - k: Int.subNat k (pos n) = Int.subNatSlow n k.
Int.subNatNegsucc
Section titled “Int.subNatNegsucc”def subNatNegsucc (k : Nat) (n : Nat) : Int.subNat k (negsucc n) = negsucc (Nat.add k n)Subtracting k from -(n + 1) gives -(k + n + 1): Int.subNat k (negsucc n) = negsucc (k + n).
Int.addEqAddFast
Section titled “Int.addEqAddFast”def addEqAddFast (a : Int) (b : Int) : Int.add a b = Int.addFast a bThe fast integer addition agrees with integer addition: Int.add a b = Int.addFast a b.
Int.subEqSubFast
Section titled “Int.subEqSubFast”def subEqSubFast (a : Int) (b : Int) : Int.sub a b = Int.subFast a bThe fast integer subtraction agrees with integer subtraction: Int.sub a b = Int.subFast a b.
Int.addNegsuccNegOfNat
Section titled “Int.addNegsuccNegOfNat”def addNegsuccNegOfNat (n : Nat) (k : Nat) : Int.add (negsucc n) (Int.negOfNat k) = Int.negOfNat (Nat.add (Nat.succ n) k)Adding two negative quantities: -(n + 1) + (-k) = -((n + 1) + k).
Int.mulNatNegsucc
Section titled “Int.mulNatNegsucc”def mulNatNegsucc (m : Nat) (n : Nat) : Int.mulNat m (negsucc n) = Int.negOfNat (Nat.mul m (Nat.succ n))Multiplying a negative integer by a natural: Int.mulNat m (negsucc n) = -(m * (n + 1)).
Int.mulEqMulFast
Section titled “Int.mulEqMulFast”def mulEqMulFast (a : Int) (b : Int) : Int.mul a b = Int.mulFast a bThe fast integer multiplication agrees with integer multiplication: Int.mul a b = Int.mulFast a b.
Int.andTrueI
Section titled “Int.andTrueI”def andTrueI (b : Bool) (c : Bool) (hb : b = true) (hc : c = true) : and b c = trueBoolean conjunction introduction: if b = true and c = true then and b c = true.
Int.emod
Section titled “Int.emod”def emod (v : Int) (m : Nat) : NatEuclidean remainder of an integer modulo m + 1, always in [0, m].
Int.emodLt
Section titled “Int.emodLt”def emodLt (v : Int) (m : Nat) : Nat.blt (Int.emod v m) (Nat.succ m) = trueThe Euclidean remainder is in range: Int.emod v m < m + 1.
Int.bleZeroPos
Section titled “Int.bleZeroPos”def bleZeroPos (e : Nat) : Int.ble (pos 0) (pos e) = trueZero is at most every non-negative integer: 0 <= pos e.
Int.bleOfLtSucc
Section titled “Int.bleOfLtSucc”def bleOfLtSucc (e : Nat) (m : Nat) (h : Nat.blt e (Nat.succ m) = true) : Int.ble (pos e) (pos m) = trueA strict bound by a successor gives a non-strict bound: e < m + 1 implies pos e <= pos m.
Int.bleNegOfLt
Section titled “Int.bleNegOfLt”def bleNegOfLt (k : Nat) (a : Nat) (h : Nat.blt k (Nat.succ a) = true) : Int.ble (negsucc a) (negsucc k) = trueOrdering of negative integers reverses: k < a + 1 implies -(a + 1) <= -(k + 1).
Int.subAddLt
Section titled “Int.subAddLt”def subAddLt (a : Nat) (b : Nat) (e : Nat) (h : Nat.blt e (Nat.succ a) = false) : Nat.blt (Nat.sub (Nat.add a (Nat.succ b)) e) (Nat.succ b) = trueIf e ≥ a + 1 then (a + (b + 1)) - e < b + 1, with truncated subtraction.
Int.twos
Section titled “Int.twos”def twos (h : Nat) (e : Nat) : IntTwo’s-complement reading of an unsigned value e modulo 2h, where h = 2^(w-1): e itself when e < h, otherwise e - 2h.
Int.twosStep
Section titled “Int.twosStep”def twosStep (h0 : Nat) (e : Nat) (c : Bool) : IntOne branch step of Int.twos, chosen by the boolean c (the result of e < h0 + 1); a proof helper for Int.twosIn.
Int.twosIn
Section titled “Int.twosIn”def twosIn (h0 : Nat) (e : Nat) : and (Int.ble (negsucc h0) (Int.twos (Nat.succ h0) e)) (Int.ble (Int.twos (Nat.succ h0) e) (pos h0)) = trueThe two’s-complement reading for h = h0 + 1 lies in [-(h0 + 1), h0].
Int.signedRange
Section titled “Int.signedRange”def signedRange (h : Nat) (hp : Nat.blt 0 h = true) (e : Nat) : and (Int.ble (Int.negOfNat h) (Int.twos h e)) (Int.ble (Int.twos h e) (pos (Nat.pred h))) = trueFor positive h, the two’s-complement reading Int.twos h e lies in [-h, h - 1].
Int.twosMod
Section titled “Int.twosMod”def twosMod (h : Nat) (v : Int) : IntWrap an integer into two’s-complement range: the representative of v modulo 2h in [-h, h - 1].
Int.twosModRange
Section titled “Int.twosModRange”def twosModRange (h : Nat) (hp : Nat.blt 0 h = true) (v : Int) : and (Int.ble (Int.negOfNat h) (Int.twosMod h v)) (Int.ble (Int.twosMod h v) (pos (Nat.pred h))) = trueFor positive h, Int.twosMod h v lies in [-h, h - 1].
Int.toString
Section titled “Int.toString”def toString (v : Int) : StringDecimal string representation of an integer, with a leading minus sign when negative.
Int.toStringInt
Section titled “Int.toStringInt”instance toStringInt : ToString IntDecimal rendering of integers, with a leading - for negatives.
Int.parse
Section titled “Int.parse”def parse (s : String) : Option IntParse a decimal integer with an optional leading minus sign, returning nothing for anything else.
Int.floorDiv
Section titled “Int.floorDiv”def floorDiv (v : Int) (d : Nat) : IntDivision by a positive natural number rounded toward negative infinity; dividing by zero gives zero.