What is an integer?
When we define an integer, we say it is a whole number that can be positive or negative or equivalently it is a number with no fractional part. Does that mean it is a number with no fractional part in base $10$ or in any base? Because if so, then the definition would be fine since it is impossible to represent an integer in a different base that has a fractional part. I am just confused how we define what an integer is.
$\endgroup$ 25 Answers
$\begingroup$As you say, it doesn't matter whether we insist the number be whole just in base 10 or in every base (at least every integer base...!) The Babylonians, modern people, and computer languages all agree on what the integers are. So it doesn't really matter which definition we choose. In fact, there's no need for bringing in number bases at all in defining integers. It's less worrying to do it this way: define the natural numbers as a system of numbers in which induction holds (the details of this are called Peano arithmetic), and then construct the integers from them, without ever mentioning that we can actually write down numbers as numerals in a fixed base! Or, if you like to think of all numbers as already given, the integers are all the numbers you can get to from $0$ and $1$ by adding, subtracting, and multiplying-but never dividing. This is perhaps the clearest explanation for why the apparently different definitions in different number bases all agree.
$\endgroup$ 2 $\begingroup$You're mixing up two things:
- How is a number defined?
- How is a number represented with symbols?
An integer can be defined as the difference between two natural numbers. Natural numbers can be defined as the number of elements in a set. There are more mathematically robust definitions, normally using set theory, but they're complicated.
Anyway, these definitions have no idea of base.
The base comes in when you want to represent a number by a sequence of digits. Then the base determines the formula that combines the values of the digits.
$\endgroup$ $\begingroup$I am just confused how we define what an integer is.
Perhaps that is because there's more than one way and, because different definitions have been popular at different times in history.
Wikipedia gives one formalism, grounded in set theory and simple rules of algebra, that defines the set of integers in terms of the natural numbers without assuming anything about what "negative" or "opposite" means.
$\endgroup$ 1 $\begingroup$Natural numbers are those suited to count the times anything happens in the real world.
The closest thing to natural number I ever met in CS are lambda-calculus Church encodings: say you want to express FOUR: well, all you have to do is apply four times a function of your liking to another, also arbitrary function you decided to call ZERO. FOUR = f(f(f(f(ZERO)))).
It makes indeed sense to bring zero into the picture, as things on our planet may also never happen.
It makes also sense to think about opposites: there is certainly a relation between putting things inside a box and taking them out of it.
Having done all this, I'd say we have in our hands a very nice, round and useful set of entities. Let's give it a name. How about integers? It's a name that conveys purity, completeness, trustfulness and I believe it wasn't chosen by chance.
This is the definition. The rest is implementation details. As long the implementation does not lead to conflicts with the definition, it is valid.
$\endgroup$ 2 $\begingroup$That's not a proper definition of $\mathbb{Z}$. Here's a rigorous (enough) definition.
Definition 0.
- The elements of $\mathbb{Z}$ are formal expression of the form $b-a$, where $b$ and $a$ are elements of $\mathbb{N}$.
- We declare that $b-a = b'-a'$ in $\mathbb{Z}$ iff $b+a' = b'+a$ in $\mathbb{N}$.
For example:
- $3-0$ can be viewed as an integer
- $4-1$ can be viewed as an integer
- as integers, these expressions are equal, because: $$3-0 = 4-1 : \mathbb{Z} \iff 3+1 =4+0 : \mathbb{N}$$
The first thing that needs to be checked is that equality is an equivalence relation on the integers.
Reflexivity. We're trying to prove $$b-a = b-a$$ in the integers. But this is equivalent to $$b+a = b+a$$ in the naturals, which is obviously true.
Symmetry. We're trying to prove the implication $$\frac{b-a = b'-a'}{b'-a' = b-a}$$ in the integers. But this is equivalent to the implication $$\frac{b+a'= b'+a}{b'+a = b+a'}$$ in the natural numbers, which is obviously true.
Transitivity.
We want to show that $$\frac{b-a = b'-a' \qquad b'-a' = b''-a''}{b-a = b''-a''}$$ in the integers.
But this is equivalent to $$\frac{b+a' = b'+a \qquad b'+a'' = b''+a'}{b+a'' = b''+a}$$ in the natural numbers.
So assume $$b+a' = b'+a \qquad b'+a'' = b''+a'$$
Now do $+a''$ to the left-expression and $a+$ to the right expression. We obtain: $$b+a'+a'' = b'+a+a'' \qquad a+b'+a'' = a+b''+a'$$
Hence $$b+a'+a'' = a+b''+a'$$
Hence using that addition is cancellative on $\mathbb{N}$, we can remove the $a'$ terms, and we thereby deduce $$b+a'' = b'' + a,$$ as required.
This completes the proof.
Unfortunately, we're really just getting started. Knowing whether or not two integers are equal doesn't give us very much; to make our definition of $\mathbb{Z}$ useful, we need to explain how to do arithmetic inside our new set.
The following specifications do the trick:
Definition 1. Addition and multiplication in $\mathbb{Z}$ work as follows:
$$(b-a)+(b'-a') = (b+b')-(a+a')$$
$$(b-a)(b'-a') = (bb'+aa')-(ba'+b'a)$$
These are well-defined prefunctions, but we need to check they're genuine functions. In other words, we need to check that these definitions play nice with the equality relation on $\mathbb{Z}$.
Proposition 0. Addition on $\mathbb{Z}$ is a function.
Proof. The trick is to reduce this to an arithmetical statement in the natural numbers, that we can then prove using our knowledge of $\mathbb{N}$.
Assume that we're given natural numbers $$b_0,a_0,b_0',b_0',b_1,a_1,b_1',b_1'$$
We need to show that the following implication holds in the integers:
$$\frac{b_0-a_0 = b_1-a_1 \qquad b_0'-a_0' = b_1'-a_1'}{(b_0-a_0)+(b_0'-a_0') = (b_1-a_1)+(b_1'-a_1')}$$
Observe that our two assumptions can be rephrased as saying that in the naturals.
Regarding our goal, observe that it can be rephrased as saying: show that $$(b_0+b_0')-(a_0+a_0') = (b_1+b_1')-(a_1+a_1')$$ in the integers.
In other words: show that $$(b_0+b_0')+(a_1+a_1') = (b_1+b_1')+(a_0+a_0')$$ in the naturals.
So we can reduce the problem to proving the following implication in the naturals:
$$\frac{b_0+a_1 = b_1+a_0 \qquad b_0'+a_1'=b_1'+a_0'}{(b_0+b_0')+(a_1+a_1') = (b_1+b_1')+(a_0+a_0')}$$
Proof. Assuming the two conditions on the top of the line, and using our knowledge of $\mathbb{N}$, we get the following chain of equalities:
- $(b_0+b_0')+(a_1+a_1')$
- $(b_0+a_1)+(b_0'+a_1')$
- $(b_1+a_0)+(b_1'+a_0')$
- $(b_1+b_1')+(a_0+a_0')$
Hence $(b_0+b_0')+(a_1+a_1') = (b_1+b_1')+(a_0+a_0'),$ as required.
This completes the proof of Proposition 0.
Proposition 1. Multiplication on $\mathbb{Z}$ is a function.
This is left as an exercise to the reader.
Lets go ahead and name certain special elements of $\mathbb{Z}$:
Definition 2. Zero and one in $\mathbb{Z}$ are given as follows:
$$0_\mathbb{Z} = 0-0$$
$$1_\mathbb{Z} = 1-0$$
Now for the last part: showing that everything we've defined so far plays nice together!
Theorem. $\mathbb{Z}$ satisfies the axioms for a commutative, unital ring.
Proof. Sorry, I've run out of steam. Maybe I'll add this bit later.
$\endgroup$