Library defining natural numbers in Peano representation and some operations on this representation.
Exported Datatypes: Nat
data Nat
Natural numbers defined in Peano representation.
Thus, each natural number is constructor by a Z
(zero)
or S
(successor) constructor.
Constructors:
Z
:: Nat
S
:: Nat -> Nat
Known instances:
Transforms a natural number into a standard integer.
n = fromNat _
satisfies
n >= 0
(fromNat'post)
Transforms a standard integer into a natural number.
(toNat n)
requires
n >= 0
(toNat'pre)
Addition on natural numbers.
add x y -=- add y x
(addIsCommutative)
add (add x y) z -=- add x (add y z)
(addIsAssociative)
Subtraction defined by reversing addition.
Multiplication on natural numbers.
mul x y -=- mul y x
(mulIsCommutative)
mul (mul x y) z -=- mul x (mul y z)
(mulIsAssociative)
mul x (add y z) -=- add (mul x y) (mul x z)
(distMulAddL)
mul (add y z) x -=- add (mul y x) (mul z x)
(distMulAddR)
always $ leq x (add x y)
(leqAdd)