(自然数の表現)

https://www.sw.it.aoyama.ac.jp/2022/Math1/lecture2.html

© 2005-22 Martin J. Dürst Aoyama Gakuin University

Only use two outer seats of each table

各テーブルの外側ノイズのみ使用！

- Moodle registration, last lecture's homework
- History of numbers and numerals
- The historic origin of numbers: 1
- Creating natural numbers starting from 1 (Peano arithmetic)
- The discovery of 0
- Positional notation (decimal, binary, hexadecimal, ...)
- Base conversion

Teaching Assistant (TA): Tensho Miyashita (宮下 天祥, M1)

(apologies for delay on September 16 (Friday); reason: software troubles)

- Mathematics is an important base for Information Technology
- Discrete Mathematics I mainly covers number representation, logic, sets, relations, proofs
- Mathematics is a tool, a language, and a way of thinking
- English is very important for Information Technology
- English is best learned by diving in and practicing

- Students listed in Course Power: 180
- Students enrolled in Moodle Course: 154
- Homework 1 (5' limit)
- Solution submitted: 132
- Solution non-empty: 112

- Homework 2 (repeat until 100% correct)
- Solutions submitted: 128
- Solutions 100% correct: 118

- Make sure you are officially registered for the course and enrolled in Discrete Mathematics I (https://moo.sw.it.aoyama.ac.jp/course/view.php?id=58)
- Review decimal number representation, binary number representation, and
`n`-ary number representation based on high-school notes and Web resources - Solve the Quiz Languages
Necessary for Information Technology (one attempt, maximum 5 minutes;
**deadline: September 27, 22:00**(no extensions)) - Solve the Quiz Simple
Arithmetic in English (repeat until you get it 100% correct;
**deadline: September 27, 22:00**(no extensions)) - Check out/buy/borrow a textbook or reference book

(4 in total, order irrelevant)

- Mathematics
- English
- Mother tongue (e.g. Japanese)
- Programming language(s)

Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer.

Edsger W. Dijkstra, EWD498, Selected Writings on Computing: A Personal Perspective, Springer-Verlag, 1982, pp. 129-131.

(Georges Ifrah: The Universal History of Numbers, John Wiley & Sons, 1998)

- Humans have used many different representations of numbers throughout history
- The first number represented was 1
- Representations such as |, ||, |||,... are most frequent
- For bigger numbers, using groups of 10 is most frequent

(20 (French 80: quatre-vingt=4-20) and 60 (minutes, seconds) also exist

- Chinese numerals: 一、二、三、亖 (or 四)
- Roman numerals: I, II, III, IIII (or IV)
- (Arabic-)Indic numerals: ١, ٢, ٣ (used in Arabic)
- (European-)Arabic numerals: 1, 2, 3

- Chinese numerals: 十、廿、...
- Roman numerals: X, XX,...

Peano Axioms (Guiseppe Peano, 1858-1932):

- 1 is a natural number

(1∈ℕ) - If
`a`is a natural number, then`s`(`a`) is a natural number (`s`(`a`) is the*successor*of`a`)

(`a`∈ℕ ⇒`s`(`a`)∈ℕ) - There is no natural number
`x`so that`s`(`x`) = 1

- If two natural numbers are different, then their successors are
different

(`a`∈ℕ,`b`∈ℕ,`a`≠`b`⇒`s`(`a`) ≠`s`(`b`)) - If we can prove a property for 1,

and we can prove, for any natural number`a`, that if`a`has this property then`s`(`a`) also has this property,

then all natural numbers have this property.

(Nowadays, it is usual to start natural numbers with 0 rather than with 1.)

(We will learn how to express axioms 3 and 5 as formulæ in the lesson about Predicate Logic)

ℕ: The set of natural numbers

∈: Set membership (`a` ∈ `B`: `a` is an
element of set `B`)

=: Equality (a = b: `a` is equal to `b`)

≠: Inequality (`a` ≠ `b`: `a` is not equal to
`b`)

⇒: Implication (`a` ⇒ `b`: If `a`, then
`b`, or: `a` implies `b`)

1 | 1 |

2 | s(1) |

3 | s(s(1)) |

4 | s(s(s(1))) |

5 | s(s(s(s(1)))) |

6 | s(s(s(s(s(1))))) |

7 | s(s(s(s(s(s(1)))))) |

... | ... |

Axioms of addition:

- If
`a`is a natural number, then`a`+ 1 =`s`(`a`)

(`a`∈ℕ ⇒`a`+ 1 =`s`(`a`)) - If
`a`and`b`are natural numbers,`a`+`s`(`b`) =`s`(`a`+`b`)

(`a`∈ℕ,`b`∈ℕ ⇒`a`+`s`(`b`) =`s`(`a`+`b`))

Calculate 2 + 3 using Peano arithmetic:

(associative property)

A binary operation (represented by operator △) is *associative* if
and only if for all operands `a`, `b`, and `c`:

(`a`△`b`) △ `c` = `a` △
(`b`△`c`)

Examples:

- Addition of (natural) numbers is associative:

(`a`+`b`) +`c`=`a`+ (`b`+`c`) - Multiplication of (natural) numbers is associative:

(`a`·`b`) ·`c`=`a`· (`b`·`c`) - Multiplication of matrices is associative.

Counterexamples:

- Subtraction of (natural) numbers is not associative:

((`a`-`b`) -`c`≠`a`- (`b`-`c`)) - Exponentiation is not associative:

(`a`^{b})^{c}≠`a`^{(bc)}

What we want to prove:

Associative law for addition: (`d`+`e`) + `f` =
`d` + (`e`+`f`)

Let's prove this for all values of `f`.

- Let's distinguish two cases:
`f`=1 and`f`=`k`+1 - If
`f`= 1, then (`d`+`e`) + 1 =`s`(`d`+`e`) [by the 1st axiom of addition, with (`d`+`e`) for`a`]

=`d`+`s`(`e`) [by the 2nd axiom of addition, with`d`for`a`and`e`for`b`]

=`d`+ (`e`+1) [by the 1st axiom of addition, backwards, with`e`for`a`]

- Assuming that associativity holds for
`f`=`k`

(i.e. (`d`+`e`) +`k`=`d`+ (`e`+`k`)),

let's prove associativity for`f`=`k`+1,

i.e let's prove (`d`+`e`) +`k`=`d`+ (`e`+`k`) ⇒

⇒(`d`+`e`) + (`k`+1) =`d`+ (`e`+ (`k`+1)):(

`d`+`e`) + (`k`+1) = (`d`+`e`) +`s`(`k`) [by the 1st axiom of addition, with`k`for`a`]

=`s`((`d`+`e`) +`k`) [by the 2nd axiom of addition, with (`d`+`e`) for a and`k`for`b`]

=`s`(`d`+ (`e`+`k`)) [using the assumption]

=`d`+`s`(`e`+`k`) [by the 2nd axiom of addition, backwards, with`d`for a and (`e`+`k`) for b]

=`d`+ ((`e`+`k`) + 1) [by the 1st axiom of addition, with (`e`+`k`for`a`]

=`d`+ (`e`+ (`k`+1)) [using the case`f`=1, with`e`for`d`and`k`for`e`]

Q.E.D. [using the 5th Peano axiom, with`f`for`a`and the property (`d`+`e`) +`f`=`d`+ (`e`+`f`)]

- We have to be careful that we
**only use axioms**, not any 'general knowledge'. - Proofs include two aspects:
- Originality (human imagination)
- Mechanics (careful execution or automated proof checking)

- Because we have not yet established associativity, we always have to use parentheses.
- Once we have proved associativity, we can eliminate the parentheses.
- This proof uses
*mathematical induction*.

- Peano Axiom 5 can be seen as the basis for mathematical induction.
- We will look at mathematical induction more closely later.

- Mathematics tries to start with very few facts or rules
- These are usually called
*axioms* - The axioms should be self-evident
- Other facts and rules (theorems) are deduced from the axioms using
*proofs* - This is called the
*axiomatic method* - The less axioms and the more interesting theorems, the better

(from a mathematical viewpoint)

- The latest (natural/integer) number (and numeral) discovered by humans
- Discovered around 800 A.D. in India
- Discovery spread West to Arabia and Europe, East to China and Japan
- 0 is very important for positional notations such as decimal, binary,...

Two raised to the power of three is eight.

Two to the power of three is eight.

Two to the three (third) is eight.

The third power of two is eight.

Three raised to the power of three is twenty-seven.

Five to the power of four is six hundred twenty-five.

Twenty modulo six is two.

Twenty-five modulo seven is four.

(written "`25 % 7`

" in C and many other programming languages,
"25 mod 7" in Mathematics)

Number representations before positional notation:

Chinese (Han) numerals: 二百五十六、二千二十二

Roman numerals: CCLVI, MMXXII

Example of decimal notation (the *base* of a number is often given as
a subscript):

256_{10} = **2**·10^{2} +
**5**·10^{1} + **6**·10^{0}

Example containing 0: 206 = **2**·10^{2} +
**0**·10^{1} + **6**·10^{0}

Generalization:
`d`_{n}...`d`_{1}`d`_{0}
= `d`_{n}·10^{n}+...+`d`_{1}·10^{1}+`d`_{0}·10^{0}

(here the subscript indicates the position, not the base)

Example with decimal point:

34.56_{10} = 3·10^{1} + 4·10^{0} + 5·10^{-1}
+ 6·10^{-2}

1010011_{2} = 1·2^{6} + 0·2^{5} + 1·2^{4}
+ 0·2^{3} + 0·2^{2} + 1·2^{1} + 1·2^{0}
=

1·64 + 0·32 + 1·16 + 0·8 + 0·4 + 1·2 + 1·1 =

64 + 16 + 2 + 1 = 83

Calculate the sum of each of the digits multiplied by its positional weight.

The positional weight is a power of the base `b`, the 0th power for
the rightmost digit.

The power increases by one when moving one position to the left.

`d`_{n}...`d`_{1}`d`_{0}
(in base `b`) =
`d`_{n}·`b`^{n}+...+`d`_{1}·`b`^{1}+`d`_{0}·`b`^{0}
= ∑^{n}_{i=0}
`d`_{i}·`b`^{i}

Take the number to convert as the first quotient. Start with an empty list of result digits.

Repeatedly, as long as the quotient is positive:

- Take the quotient of the previous division as the dividend
- Divide that dividend by the base
`b` - Add the remainder of the division as a digit to the left of the previous result digits

dividend | divisor | quotient | remainder | result digits |
---|---|---|---|---|

65↙ | (empty) | |||

65 | 3 | 21↙ | 2↑ |
2 |

21 | 3 | 7↙ | 0↑ |
02 |

7 | 3 | 2↙ | 1↑ |
102 |

2 | 3 | 0→done! | 2↑ |
2102 |

65 divided by 3 is 21 remainder 2

21 divided by 3 is 7 remainder 0

7 divided by 3 is 2 remainder 1

2 divided by 3 is 0 remainder 2

65 = 65·3^{0}

= 21·3^{1} + 2·3^{0}

= 7·3^{2} + 0·3^{1} + 2·3^{0}

= **2**·3^{3} + **1**·3^{2} +
**0**·3^{1} + **2**·3^{0} =
**2102**_{3}

Using Horner's rule: 65 = (((**2**×3^{} +
**1**)×3^{} + **0**)×3^{} +
**2**)

left operand | operator | right operand | result | |
---|---|---|---|---|

Addition | augend (also: summand or addend) | + | addend (also: summand) | sum |

Subtraction | minuend | - | subtrahend | difference |

Multiplication | multiplicand (also: factor) | ×, ·, `*` , nothing |
multiplier (also: factor) | product |

Division | dividend | ÷, / | divisor | quotient |

Modulo operation | dividend | mod, `%` |
divisor | remainder |

Exponentiation | base | (superscript), `^` , `**` |
exponent | power |

Start with the number to convert (`a`) as the first remainder.
Start with an empty list of result digits.

Determine the first exponent `n` so that
`b`^{n} ≦ `a` <
`b`^{n+1}

Repeatedly, as long as the exponent is ≧0:

- Take the remainder of the previous division as the dividend
- Divide the dividend by
`b`^{n}, then by`b`^{n-1}, and so on - Add the quotient of the division as a digit to the right of the previous result digits

dividend | exponent | divisor | quotient | remainder | digits of the result |
---|---|---|---|---|---|

65↙ | |||||

65 | 3 (=n) |
3^{3}=27 |
2↓ |
11↙ | 2 |

11 | 2 | 3^{2}=9 |
1↓ |
2↙ | 21 |

2 | 1 | 3^{1}=3 |
0↓ |
2↙ | 210 |

2 | 0→done! | 3^{0}=1 |
2↓ |
0 | 2102 |

- General method: Convert via base 10

base`b`→ base 10 → base`c`

Example: base 3 → base 10 → base 5 - Shortcut 1: If
`b`is a power of`c`(`b`=`c`) or the other way around (^{n}`c`=`b`), then convert the digits in groups^{n}

Example 1: base 3 → base 9 (3^{2}= 9, therefore make groups of 2 digits and convert to a single digit)

Example 2: base 8 → base 2 (8 = 2^{3}, therefore convert each digit to a group of 3 digits) - Shortcut 2: If both
`b`and`c`are powers of`d`(`b`=`d`,^{n}`c`=`d`), then convert via base^{m}`d`

Example: base 4 → base 8

because 4 = 2^{2}and 8 = 2^{3},`d`= 2

therefore, convert base 4 → base 2 → base 8 (use shortcut 1 two times)

Convert 47623_{8} to base 4.

8 = 2^{3}, 4 = 2^{2}, therefore convert base 8 → base 2
→ base 4

47623_{8} →

4 | 7 | 6 | 2 | 3 | base 8 |

100 | 111 | 110 | 010 | 011 | convert each base-8 digit to 3 base-2 digits |

100111110010011_{2}

1 | 00 | 11 | 11 | 10 | 01 | 00 | 11 | split base 2 into groups of 2 digits (start at the right) |

1 | 0 | 3 | 3 | 2 | 1 | 0 | 3 | convert two base-2 digits to one base-4 digit |

→ 10332103_{4}

Works the same as in the decimal system:

- Progress from least signifinant digit to more significant digits
- Carry over when base (e.g. 10) is reached

Example (base 7):

Operand 1 | 3 | 6 | 5 | 1 | 2 | |

Operand 2 | 6 | 0 | 3 | 3 | 4 | |

carry | 1 | 1 | 1 | |||

sum in base 10 | 1 | 10 | 7 | 8 | 4 | 6 |

sum in base 7 | 1 | 13 | 10 | 11 | 4 | 6 |

Result | 1 | 3 | 0 | 1 | 4 | 6 |

1AF_{16} = 1×16^{2} + A×16^{1} + F×16^{0}
= 1×256 + 10×16 + 15×1 = 256 + 160 + 15 = 431

digit (upper case) | digit (lower case) | value (decimal) |

A | a | 10 |

B | b | 11 |

C | c | 12 |

D | d | 13 |

E | e | 14 |

F | f | 15 |

The number of different digits in base `b` is `b`.

The lowest digit is 0, the highest digit is `b`-1.

Base | Number of Digits | Lowest Digit | Highest Digit | Digits |

2 | 2 | 0 | 1 | 0, 1 |

3 | 3 | 0 | 2 | 0, 1, 2 |

4 | 4 | 0 | 3 | 0, 1, 2, 3 |

5 | 5 | 0 | 4 | 0, 1, 2, 3, 4 |

8 | 8 | 0 | 7 | 0, 1, 2, 3, 4, 5, 6, 7 |

10 | 10 | 0 | 9 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |

12 | 12 | 0 | B (11) | 0123456789 A B |

16 | 16 | 0 | F (15) | 0123456789 A B C D E F |

22 | 22 | 0 | L (21) | 0123456789 ABCDEFGHIJ KL |

base | name (adjective) and abbreviation | (reason for) use | constants in programming languages |
---|---|---|---|

2 | binary, bin | used widely in logic and circuits (computer hardware) | `0b` (Ruby,...) |

8 | octal, oct | shortened form of binary (rare these days) | `0` (C and many others) |

10 | decimal, dec | for humans | (all languages) |

16 | hexadecimal, hex | shortened form of binary, 1 byte (8 bits) can be represented with two digits | `0x` (C and many others) |

10 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 16 |
---|---|---|---|---|---|---|---|---|---|

0 | 0000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

1 | 0001 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |

2 | 0010 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 |

3 | 0011 | 10 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |

4 | 0100 | 11 | 10 | 4 | 4 | 4 | 4 | 4 | 4 |

5 | 0101 | 12 | 11 | 10 | 5 | 5 | 5 | 5 | 5 |

6 | 0110 | 20 | 12 | 11 | 10 | 6 | 6 | 6 | 6 |

7 | 0111 | 21 | 13 | 12 | 11 | 10 | 7 | 7 | 7 |

8 | 1000 | 22 | 20 | 13 | 12 | 11 | 10 | 8 | 8 |

9 | 1001 | 100 | 21 | 14 | 13 | 12 | 11 | 10 | 9 |

10 | 1010 | 101 | 22 | 20 | 14 | 13 | 12 | 11 | A/a |

11 | 1011 | 102 | 23 | 21 | 15 | 14 | 13 | 12 | B/b |

12 | 1100 | 110 | 20 | 22 | 20 | 15 | 14 | 13 | C/c |

13 | 1101 | 111 | 21 | 23 | 21 | 16 | 15 | 14 | D/d |

14 | 1110 | 112 | 22 | 24 | 22 | 20 | 16 | 15 | E/e |

15 | 1111 | 120 | 23 | 30 | 23 | 21 | 17 | 16 | F/f |

16 | 10000 | 121 | 100 | 31 | 24 | 22 | 20 | 17 | 10 |

n |
2^{n} |
in base 16 |
---|---|---|

0 | 1 | 1 |

1 | 2 | 2 |

2 | 4 | 4 |

3 | 8 | 8 |

4 | 16 | 10 |

5 | 32 | 20 |

6 | 64 | 40 |

7 | 128 | 80 |

8 | 256 | 100 |

9 | 512 | 200 |

10 | 1'024 ≈10^{3} (kilo) |
400 |

11 | 2'048 (the game) | 800 |

12 | 4'096 | 1000 |

16 | 65'536 | 1'0000 |

20 | 1'048'576 ≈ 10^{6} (mega) |
10'0000 |

30 | 1'073'741'824 ≈ 10^{9} (giga) |
4000'0000 |

40 | 1'099'511'627'776 ≈ 10^{12} (tera) |
100'0000'0000 |

Question: Why do computer scientist always think Christmas and Halloween are
the same?

(Hint: In the USA, Halloween is October 31st only)

Your answer:

Question: At what age do Information Technologists celebrate "Kanreki" (還暦)

Your answer:

- The history of numbers starts with the natural numbers 1, 2, 3,...
- Across different cultures, the numerals for 1, 2, 3,... and 10, 20,... look similar
- Peano created a set of 5 axioms using "1" and "successor" only
- These axioms form a base for arithmetic on natural numbers
- The numeral 0 was discovered very late.

It is important in positional number representation. - Positional number representation can use various bases, and these bases can be converted
- In Information Technology, the bases 2, (8,) 10, and 16 are used

- Register to Moodle and enroll in the course Discrete Mathematics I
- Solve Arithmetic
and Base Conversion (repeat until you get it 100% correct; deadline:
Thursday,
**October 6, 22:00**, 15 minutes time limit for each attempt) - Learn binary and hexadecimal numbers up to 16, and powers of 2 up to
2
^{12} - Try to find an answer to the joke questions (no need to submit)
- Use highschool texts or the Web to refresh your knowledge about propositions, logic, and functions

- Moodle と Discrete Mathematics I に登録
- Moodle で Arithmetic
and Base Conversion のクイズを解く
(満点まで繰り返す、
**締切: 10月 6日 (木) 22:00**, 一回ごとに15分の時間制限) - 16 までの二進法、16進法と 2
^{n}を`n`=12 までを暗記 - 冗談の問題の解答を考える (提出不要)
- 数学の「命題」、「論理演算」、「関数」について高校で学んだことを再確認し、ウェブで調べる

- number
- 数
- numeral
- 数字
- natural number
- 自然数
- discovery
- 発見
- origin
- 原点
- positional notation
- 位取り表現
- perfect score
- 満点
- confusion
- 混乱
- representation
- 表現
- exponentiation
- べき乗演算
- Modulo operation
- モジュロ演算
- remainder
- 剰余 (余り)
- decimal notation (decimal numeral system)
- 十進法
- Chinese numerals
- 漢数字
- Roman numerals
- ローマ数字
- discovery
- 発見
- axiom
- 公理
- Peano axioms
- ペアノの公理
- successor
- 後者
- formula (plural: formulæ)
- 式
- symbol
- 記号
- set membership
- 集合に属する (こと)
- equality (sign)
- 等式、等号
- inequality (sign)
- 不等式、不等号
- implication
- 含意
- property
- 性質
- arithmetic
- 算術
- associative law (property)
- 結合律
- counterexample
- 反例
- operation
- 演算
- operator
- 演算子
- operand
- 被演算子
- binary operation
- 二項演算
- proof
- 証明
- prove
- 証明する
- Q.E.D. (quod erat demonstrandum)
- 証明終了
- parenthesis
- (丸・小) 括弧、複数 parentheses
- mathematical induction
- 数学的帰納法
- originality
- 独創性、独創力
- automated proof checking
- 自動証明検証
- imagination
- 想像 (力)
- self-evident
- 自明
- axiomatic method
- 公理的方法
- integer
- 整数
- remainder
- 余り、剰余
- subscript
- 下付き文字 (添え字)
- generalization
- 一般化
- decimal point
- 小数点
- base
- 基数
- base conversion
- 奇数変換
- positional weight
- (その桁の) 重み
- dividend (or numerator)
- 被除数、実 (株の配当という意味も)
- divisor (or denominator, modulus)
- 除数、法
- quotient
- 商 (割り算の結果)
- Horner's rule
- ホーナー法
- digit
- 数字
- shortcut
- 近道
- upper case
- 大文字
- lower case
- 小文字
- binary
- 二進数 (形容詞)
- octal
- 八進数 (形容詞)
- decimal
- 十進数 (形容詞)
- hexadecimal
- 十六進数 (形容詞)
- circuit
- 回路
- constant
- 定数
- joke
- 冗談
- submit
- 提出する
- proposition
- 命題
- function
- 関数