CADiZ

Reference manual / Standard toolkit / section number_toolkit


Numbers

section number_toolkit

Successor

function (succ _)


succ _ : \power (\nat \cross \nat)
\where
(succ _) = \lambda n : \nat @ n+1

The successor of a natural number n is equal to n+1.

Integers


\num : \power \arithmos

\num is the set of integers, that is, positive and negative whole numbers and zero. The set \num is characterised by axioms for its additive structure given in the prelude together with the next formal paragraph below.

Number systems that extend the integers may be specified as supersets of \num.

Addition of integers, arithmetic negation

function (- _)


- _ : \power (\arithmos \cross \arithmos)
\where
\forall x, y : \num @ \exists1 z : \num @ ((x,y),z) \in (_ + _)
\forall x : \num @ \exists1 y : \num @ (x,y) \in (- _)
\forall i , j , k : \num @
    ( i + j ) + k = i + ( j + k )
    \land i + j = j + i
    \land i + - i = 0
    \land i + 0 = i
\num = { z : \arithmos | \exists x : \nat @ z = x \lor z = - x }

The binary addition operator (_ + _) is defined in the prelude. The definition here introduces additional properties for integers. The addition and negation operations on integers are total functions that take integer values. The integers form a commutative group under (_ + _) with - as the inverse operation and 0 as the identity element. NOTE If function_toolkit notation were exploited, the negation operator could be defined as follows.


- _ : \arithmos \pfun \arithmos
\where
( \num \cross \num ) \dres ( _ + _ ) \in \num \cross \num \fun \num
\num \dres - \in \num \fun \num
\forall i , j , k : \num @
    ( i + j ) + k = i + ( j + k )
    \land i + j = j + i
    \land i + - i = 0
    \land i + 0 = i
\forall h : \power \num @
    1 \in h
\land ( \forall i , j : h @ i + j \in h \land - i \in h )
    \implies h = \num

Subtraction

function 30 leftassoc (_ - _)


_ - _ : \power ((\arithmos \cross \arithmos) \cross \arithmos)
\where
\forall x, y : \num @ \exists1 z : \num @ ((x,y),z) \in (_ - _)
\forall i , j : \num @ i - j = i + - j

Subtraction is a function whose domain includes all pairs of integers. For all integers i and j, i - j is equal to i + - j. NOTE If function_toolkit notation were exploited, the subtraction operator could be defined as follows.


_ - _ : \arithmos \cross \arithmos \pfun \arithmos
\where
( \num \cross \num ) \dres ( _ - _ ) \in \num \cross \num \fun \num
\forall i , j : \num @ i - j = i + - j

Less-than-or-equal

relation (_ \leq _)


_ \leq _ : \power (\arithmos \cross \arithmos)
\where
\forall i , j : \num @ i \leq j \iff j - i \in \nat

For all integers i and j, i \leq j if and only if their difference j - i is a natural number.

Less-than

relation (_ < _)


_ < _ : \power (\arithmos \cross \arithmos)
\where
\forall i , j : \num @ i < j \iff i + 1 \leq j

For all integers i and j, i < j if and only if i + 1 \leq j.

Greater-than-or-equal

relation (_ \geq _)


_ \geq _ : \power (\arithmos \cross \arithmos)
\where
\forall i , j : \num @ i \geq j \iff j \leq i

For all integers i and j, i \geq j if and only if j \leq i.

Greater-than

relation (_ > _)


_ > _ : \power (\arithmos \cross \arithmos)
\where
\forall i , j : \num @ i > j \iff j < i

For all integers i and j, i > j if and only if j < i.

Strictly positive natural numbers

\nat1 == { x : \nat | \lnot x = 0 }

The strictly positive natural numbers \nat1 are the natural numbers except zero.

Non-zero integers

\num1 == { x : \num | \lnot x = 0 }

The non-zero integers \num1 are the integers except zero.

Multiplication of integers

function 40 leftassoc (_ * _)


_ * _ : \power ((\arithmos \cross \arithmos) \cross \arithmos)
\where
\forall x, y : \num @ \exists1 z : \num @ ((x,y),z) \in (_ * _)
\forall i , j , k : \num @
    ( i * j ) * k = i * ( j * k )
    \land i * j = j * i
    \land i * ( j + k ) = i * j + i * k
    \land 0 * i = 0
    \land 1 * i = i

The binary multiplication operator (_ * _) is defined for integers. The multiplication operation on integers is a total function and has integer values. Multiplication on integers is characterised by the unique operation under which the integers become a commutative ring with identity element 1. NOTE If function_toolkit notation were exploited, the multiplication operator could be defined as follows.


_ * _ : (\arithmos \cross \arithmos) \pfun \arithmos
\where
( \num \cross \num ) \dres ( _ * _ ) \in \num \cross \num \fun \num
\forall i , j , k : \num @
    ( i * j ) * k = i * ( j * k )
    \land i * j = j * i
    \land i * ( j + k ) = i * j + i * k
    \land 0 * i = 0
    \land 1 * i = i

Division, modulus

function 40 leftassoc (_ div _)
function 40 leftassoc (_ mod _)


_ div _ , _ mod _ : \power ((\arithmos \cross \arithmos) \cross \arithmos)
\where
\forall x : \num; y : \num1 @ \exists1 z : \num @ ((x,y),z) \in (_ div _)
\forall x : \num; y : \num1 @ \exists1 z : \num @ ((x,y),z) \in (_ mod _)
\forall i : \num ; j : \num1 @
    i = ( i div j ) * j + i mod j
    \land ( 0 \leq i mod j < j \lor j < i mod j \leq 0 )

For all integers i and non-zero integers j, the pair (i, j) is in the domain of _ div _ and of _ mod _, and i div j and i mod j have integer values.

When not zero, i mod j has the same sign as j. This means that i div j is the largest integer no greater than the rational number i/j. NOTE If function_toolkit notation were exploited, the division and modulus operators could be defined as follows.


_ div _ , _ mod _ : \arithmos \cross \arithmos \pfun \arithmos
\where
( \num \cross \num1 ) \dres ( _ div _ ) \in \num \cross \num1 \fun \num
( \num \cross \num1 ) \dres ( _ mod _ ) \in \num \cross \num1 \fun \num
\forall i : \num ; j : \num1 @
    i = ( i div j ) * j + i mod j
    \land ( 0 \leq i mod j < j \lor j < i mod j \leq 0 )

IT 22-Jan-2002