(th i t d di i i )(the integers and division)ysmoon/courses/2011_1/dm/12.pdf · 2016-06-02 ·...
TRANSCRIPT
이산수학이산수학(Discrete Mathematics) (Discrete Mathematics) 정수와정수와 나눗셈나눗셈
(Th I t d Di i i )(Th I t d Di i i )(The Integers and Division)(The Integers and Division)
20112011년년 봄학기봄학기
강원대학교강원대학교 컴퓨터과학전공컴퓨터과학전공 문양세문양세강원대학교강원대학교 컴퓨터과학전공컴퓨터과학전공 문양세문양세
IntroductionIntroduction2.4 The Integers and Division
Of course you already know what the integers are, and
h t di i i i (정수와 나누기 다 아는거 )what division is… (정수와 나누기… 다 아는거~)
But: There are some specific notations, terminology, and p , gy,
theorems associated with these concepts which you may
not know (몇 가지 주요 표기 용어 정리 등을 배웁시다 )not know. (몇 가지 주요 표기, 용어, 정리 등을 배웁시다.)
These form the basics of number theory. (정수론의 기초..)
• Vital in many important algorithms today (hash functions,
cryptography, digital signatures).yp g p y, g g )
Discrete Mathematicsby Yang-Sae MoonPage 2
Divides, Factor, and MultipleDivides, Factor, and Multiple2.4 The Integers and Division
Let a,bZ with a0.
a|b “a divides b” : “c Z: b ac”a|b “a divides b” : “cZ: b=ac”“There is an integer c such that c times a equals b.”(b가 a로 나누어짐(a로 b를 나눌 수 있음)을 의미하며, 이때 몫이 c이다.)(b가 a로 나누어짐(a로 b를 나눌 수 있음)을 의미하며, 이때 몫이 c이다.)
• Example: 312 True, but 37 False.
인수
If a divides b, then we say a is a factor or a divisor of b,
인수
and b is a multiple of a.배수
“b is even” :≡ 2b. Is 0 even? Is −4?
Discrete Mathematicsby Yang-Sae MoonPage 3
Some Facts of DivisionSome Facts of Division2.4 The Integers and Division
a,b,c Z:
1 a|0 (2|0 3|0 )1. a|0 (2|0, 3|0, …)
2. (a|b a|c) a | (b + c) (2|4 2|6 2|10)
3. a|b a|bc (2|4 2|4·3)
4 (a|b b|c) a|c (2|4 4|8 2|8)4. (a|b b|c) a|c (2|4 4|8 2|8)
Proof of (2):
• a|b means there is an s such that b=as,
• and a|c means that there is a t such that c=at,
• so b+c = as+at = a(s+t), so a|(b+c) also.□
Discrete Mathematicsby Yang-Sae MoonPage 4
( ), |( )
More Detailed Version of ProofMore Detailed Version of Proof2.4 The Integers and Division
Show a,b,c Z: (a|b a|c) a | (b + c).
Let a, b, c be any integers such that a|b and a|c, and show that a | (b + c).
By definition of |, we know s: b=as, and t: c=at.Let s t be such integersLet s, t, be such integers.
Then b+c = as + at = a(s+t)so u: b+c=au, namely u=s+t.Thus a|(b+c).
Discrete Mathematicsby Yang-Sae MoonPage 5
Prime Numbers (Prime Numbers (소수소수))2.4 The Integers and Division
An integer p>1 is prime iff it is not the product of any two integers greater than 1:integers greater than 1:
p>1 a,bN: a>1, b>1, ab=p.
The only positive factors of a prime p are 1 and p itself. Some primes: 2,3,5,7,11,13...(양의 인수(divisor)가 1과 자기 자신뿐이면 소수(prime)라 한다.)
Non-prime integers greater than 1 are called composite, p g g p ,because they can be composed by multiplying two integers greater than 1.greater than 1.
합성수
Discrete Mathematicsby Yang-Sae MoonPage 6
Fundamental Theorem of ArithmeticFundamental Theorem of Arithmetic((산술의산술의 기본기본 정리정리))
2.4 The Integers and Division((산술의산술의 기본기본 정리정리))
Every positive integer has a unique representation as the y p g q pproduct of a non-decreasing series of zero or more primes.(모든 양의 정수는 오름차순으로 정렬된 소수들의 곱으로 유일하게 표현된다.결국 Prime Factorization(소인수분해)를 이야기한다고 볼 수 있다.)
• 1 = (product of empty series) = 1
• 2 = 2 (product of series with one element 2)
4 2 2 (product of series 2 2)• 4 = 2·2 (product of series 2,2)
• 2000 = 2·2·2·2·5·5·5 = 24·53; 2001 = 3·23·29;2002 = 2·7·11·13; 2003 = 2003
Discrete Mathematicsby Yang-Sae MoonPage 7
소수의소수의 개수개수??2.4 The Integers and Division
“무한히 많은 소수가 존재함”을 증명하라.
1 유한 개의 소수 p p p 이 있다고 가정하자1. 유한 개의 소수 p1, p2, …, pn이 있다고 가정하자.
2. Q = p1·p2·…·pn + 1이라 하자.
3. “산술의 기본 정리”에 의하여 Q는 소수들의 곱으로 표현된다.
4. 따라서, pj | Q(1 j n)를 만족하는 소수 pj가 존재한다.
5. 그러면, 다음과 같은 전개가 이루어진다.
5.1 (pj | p1·p2·…·pn) (pj |-(p1·p2·…·pn)) [a|b a|bc]5.1 (pj | p1 p2 … pn) (pj | (p1 p2 … pn)) [a|b a|bc]
5.2 (pj | Q) = (pj | (p1·p2·…·pn + 1)) [by step 4]
5 3 ( | 1)? [( |b | ) | (b )]5.3 (pj | 1)? [(a|b a|c) a | (b + c)]
6. pj는1을 나눌 수 없으므로, 결국 가정(유한 개의 소수가 있다)이 잘못된 것이다.즉 소수의 개수는 무한하다 □
Discrete Mathematicsby Yang-Sae MoonPage 8
즉, 소수의 개수는 무한하다. □
The Division “Algorithm”The Division “Algorithm”2.4 The Integers and Division
Really just a theorem, not an algorithm…
• The name is used here for historical reasons.
For any integer dividend a and divisor d≠0, there is a For any integer dividend a and divisor d 0, there is a unique integer quotient q and remainder rNsuch that a = dq + r and 0 r < |d|. such that a dq + r and 0 r < |d|.
• dividend = “피제수”, divisor = “제수”
• quotient = “몫”, remainder = “나머지”
a dZ d>0: !q rZ: 0r<|d| a=dq+r (! means “unique”)a,dZ, d>0: !q,rZ: 0r<|d|, a=dq+r. (! means unique )
We can find q and r by: q=ad, r=aqd.
Discrete Mathematicsby Yang-Sae MoonPage 9
(e.g., if a = 14 and d = 3, then q = 143 = 4 and r = 14 - 3·4 = 2.
Greatest Common Divisor (Greatest Common Divisor (최대공약수최대공약수))2.4 The Integers and Division
The greatest common divisor gcd(a,b) of integers a,b (not both 0) is the largest (most positive) integer d that is a both 0) is the largest (most positive) integer d that is a divisor both of a and of b.(최대공약수는 두 수의 공약수 중에서 가장 큰 공약수이다 )(최대공약수는 두 수의 공약수 중에서 가장 큰 공약수이다.)
d = gcd(a,b) = max(d: d|a d|b)
Example: gcd(24,36)=?Positive common divisors: 1,2,3,4,6,12Positive common divisors: 1,2,3,4,6,12Greatest is 12.
Discrete Mathematicsby Yang-Sae MoonPage 10
GCD shortcutGCD shortcut2.4 The Integers and Division
If the prime factorizations are written asand
naaa pppa 21 nbbb pppb 21and ,then the GCD is given by:
npppa 21 npppb 21
)i ()i ()i ( bbb .),gcd( ),min(),min(2
),min(1
2211 nn ban
baba pppba
Example:
• a=84=2·2·3·7 = 22·31·71
b 96 2 2 2 2 2 3 25 31 70• b=96=2·2·2·2·2·3 = 25·31·70
• gcd(84,96) = 22·31·70 = 2·2·3 = 12.
Discrete Mathematicsby Yang-Sae MoonPage 11
Relatively Primality (Relatively Primality (서로서로 소소, , 상대상대 소수소수))2.4 The Integers and Division
Integers a and b are called relatively prime or coprime iff their gcd = 1their gcd = 1.(두 수의 최대공약수가 1인 경우, 두 수는 서로 소(상대 소수)라 한다.)
E l N i h 21 d 10 i b h Example: Neither 21 and 10 are prime, but they are coprime. 21=3·7 and 10=2·5, so they have no common factors > 1, so their gcd = 1.
A set of integers {a1,a2,…} is (pairwise) relatively prime if A set of integers {a1,a2,…} is (pairwise) relatively prime if all pairs ai, aj, ij, are relatively prime.(주어진 정수들의 모든 쌍이 서로 소이면, 해당 정수들은 서로 소라 한다.)( , )
• E.g., 10, 17, and 21 are relatively primes.
Discrete Mathematicsby Yang-Sae MoonPage 12
Least Common Multiple (Least Common Multiple (최소공배수최소공배수))2.4 The Integers and Division
lcm(a,b) of positive integers a, b, is the smallest positive
integer that is a multiple both of a and of b.
m = lcm(a,b) = min(m: a|m b|m)(최대공배수는 두 수의 공배수 중에서 가장 작은 공배수이다.)
• E g lcm(6 10)=30• E.g. lcm(6,10) 30
If the prime factorizations are written as
and ,
then the LCM is given by
nan
aa pppa 2121 nb
nbb pppb 2121
then the LCM is given by
.),(lcm ),max(),max(2
),max(1
2211 nn ban
baba pppba
Discrete Mathematicsby Yang-Sae MoonPage 13
A Useful RuleA Useful Rule2.4 The Integers and Division
If a and b are positive integers,
then ab = gcd(a,b)·lcm(a,b)
Prove it by yourself!
Discrete Mathematicsby Yang-Sae MoonPage 14
The The modmod OperatorOperator2.4 The Integers and Division
An integer “division remainder” operator.
Let a,dZ with d>1, then
a mod d denotes the remainder r;• a mod d denotes the remainder r;
• i.e. the remainder when a is divided by d.
• r = a mod d
We can compute (a mod d) by: a d a/d
q
We can compute (a mod d) by: a d·a/d.
In C programming language, “%” = mod.
Discrete Mathematicsby Yang-Sae MoonPage 15
Modular Congruence (Modular Congruence (모듈로모듈로 합동합동?)?)2.4 The Integers and Division
Let Z+={nZ | n>0}, the positive integers.
Let a,bZ, mZ+.
Then a is congruent to b modulo m written “a b(mod m)”Then a is congruent to b modulo m, written ab(mod m) ,iff m|(ab).
Also equivalent to: (ab) mod m = 0.
• m으로 나누었을 때 a와 b의 나머지가 동일(합동)하다• m으로 나누었을 때, a와 b의 나머지가 동일(합동)하다.
• m으로 나누어 나머지가 동일한 수의 차를 m으로 나누면 나머지가 0이다. 두 수의 차를 m으로 나눌 수 있으면, 두 수를 m으로 나눈 나머지는 동일하다.
Example: 175(mod 6) 6|(17–5), (17–5)%6 = 0
Discrete Mathematicsby Yang-Sae MoonPage 16
Spiral Visualization of Spiral Visualization of modmod2.4 The Integers and Division
≡ 0 (mod 5)Example shown:
modulo-5
10
15
20arithmetic
≡ 1 (mod 5)
≡ 4 (mod 5)04
5
9
10
1114 16
19 21
0
123
4 6
8
11
≡ 2 (mod 5)
78
1213
1718
≡ 3 (mod 5)≡ 2 (mod 5)
22
5로 나누어 나머지가 3인 수
Discrete Mathematicsby Yang-Sae MoonPage 17
Useful Congruence TheoremsUseful Congruence Theorems2.4 The Integers and Division
Let a,bZ, mZ+. Then:ab (mod m) kZ a=b+km
나머지
ab (mod m) kZ a=b+km.
Let a,b,c,dZ, mZ+. Then if 몫
ab (mod m) and cd (mod m), then: (a와 b가 m 모듈로 합동이고, c와 d가 m 모듈로 합동이면,)
• a+c b+d (mod m), and
• ac bd (mod m)
Discrete Mathematicsby Yang-Sae MoonPage 18
Applications of Congruence (Applications of Congruence (합동의합동의 응용응용))2.4 The Integers and Division
The mod operator is widely used in hash functions.
• h(key) = key mod m
Linear congruential methods is used to generate pseudo Linear congruential methods is used to generate pseudo random numbers.
• x[n+1] = (a·x[n] + c) mod m
Also, in cryptography, encryption, …Also, in cryptography, encryption, …
Discrete Mathematicsby Yang-Sae MoonPage 19