Discrete Mathematics
Ch t 4 P ti f th
- - Chapter 4: Properties of the
Integers: Mathematical Induction
Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University
Discrete Mathematics -- Chapter 4: Properties of the Ch t 4 P ti - - PowerPoint PPT Presentation
Discrete Mathematics -- Chapter 4: Properties of the Ch t 4 P ti f th Integers: Mathematical Induction Hung-Yu Kao ( ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U
Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University
4.1 The Well-Ordering Principle: Mathematical
4.2 Recursive Definitions
4.3 The Division Algorithm: Prime Numbers 4.4 The Greatest Common Divisor: The Euclidean
4 5 The fundamental Theorem of Arithmetic 4.5 The fundamental Theorem of Arithmetic
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
2
自然數要適合五點(Peano axioms):
有一起始自然數 0。 有一起始自然數 0 任一自然數 a 必有後繼,記作 a +1。 0 並非任何自然數的後繼 0 並非任何自然數的後繼。 不同的自然數有不同的後繼。
(數學歸納公設)有一與自然數有關的命題。設此
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
3
contains a smallest element. ( )
} 1 | { } | { ≥ ∈ = > ∈ =
+
x x x x Z Ζ Z
Z+ is well ordered
( )
f th i bl hi h t iti i t
} 1 | { } | { ≥ ∈ > ∈ x x x x Z Ζ Z
a)
If S(1) is true; and (basis step)
b)
If whenever S(k) is true, then S(k+1) is true. (inductive step)
b)
w e eve S(k) s ue, e S(k ) s
then S(n) is true for all
+
∈Z n
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
4
P(n0) P(n0+1) P(n0+2) . . .
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
5
More rigorously the validity of a proof by mathematical induction relies More rigorously, the validity of a proof by mathematical induction relies
Let S be a statement for which we have proven that S(1) holds and for
p ( ) all n∈ Z+ we have S(n)⇒S(n+1). Claim: S(n) holds for all n∈ Z+
Proof by contradiction: Define the set F⊆ Z+ of values for which S
does not hold: F = { m | S(m) does not hold}.
If F is non empt then F must have a smallest element ( ell ordering of
If F is non-empty, then F must have a smallest element (well-ordering of
Z+), let this number be z with ¬S(z). Because we know that S(1), it must hold that z>1. Because z is the smallest value, it must hold that S(z–1), hi h di f f ll
+
( ) ( ) which contradicts our proof for all n∈ Z+: S(n)⇒S(n+1).
Contradiction: F has to be empty: S holds for all Z+.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
6
2 ) 1 ( 1
3 2 1 ,
+ = +
= + ⋅ ⋅ ⋅ + + + = ∑ ∈
n n n i
n i n Z
) 1 ( 2 ) 1 1 ( 1 1 1 2 ) 1 ( 1
1 : ) 1 ( (i) 3 2 1 : ) ( Let
+ × = + =
= = ∑ = + ⋅ ⋅ ⋅ + + + = ∑
i n n n i
i S n i n S
1 2 ) 1 ( 1 2 1
) 1 ( 3 2 1 ) 1 ( Th (iii) i.e., true, is ) ( Assume (ii) ) ( ( )
+ + = =
∑ = ∑
k k k k i i
k k i k S i k S
2 ) 1 ( 1 1 1 1
) 1 ( ) 1 ( ) ( ) 1 ( 3 2 1 : ) 1 ( Then (iii)
+ = + =
+ + = + + ∑ = + + + ⋅ ⋅ ⋅ + + + = ∑ +
k k i k i
k k i k k i k S
2 ) 2 )( 1 ( + +
=
k k
2
2
3 2 1 t
+ + +
+ + + +
n n n i
Z
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
7
2 2 1
3 2 1 , try
+ + = +
= + ⋅ ⋅ ⋅ + + + = ∈
n n i
n i n Z
integer is the same whether it is read from left to right or from right to left are called palindromes Without actually determining all of these left, are called palindromes. Without actually determining all of these three-digit palindromes, we would like to determine their sum.
) 10 101 ( 10 101 10 100 : palindrome typical The
9 9 9 9
∑ ∑ + ∑ = ⎞ ⎜ ⎜ ⎛ ∑ + = + + = b a aba b a a b a aba
[ ]
45 10 1010 10 ) 101 ( 10 ) (
9 9 9 1 1
∑ ⋅ + = ∑ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ∑ + = ∑ ∑ ∑ ⎠ ⎜ ⎜ ⎝ ∑
= = = = a b a b
a b a
[ ]
500 , 49 450 9 1010 ) (
9 1 1
= ⋅ + ∑ = ⎥ ⎦ ⎢ ⎣
= = = a a b
a
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
8
1 = a
t =1+2+ +i= i(i+1)/2
2 2 1
1
1
⋅
= = t
2 3 2
3 2 1
2
⋅
= = + = t
2 4 3
6 3 2 1
3
⋅
= = + + = t
2 5 4
10 4 3 2 1
4
⋅
= = + + + = t
ti=1+2+…+i= i(i+1)/2
P f
] [ ] [ ) (
) 1 ( 1 ) 1 2 )( 1 ( 1 1 ) 1 (
2
+ = ∑ + = ∑ ∑ =
+ + + +
i i t
n n n n n n n i i n
] [ ] [ ) (
6 ) 2 )( 1 ( 2 2 6 2 1 2 1 2 1
= + = ∑ + = ∑ ∑ =
+ + = = =
i i t
n n n i i i i
Ex 4.4 prove it
700 , 171 ...
6 ) 102 )( 101 ( 100 6
100 2 1
= = + + + ∴ t t t
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
9
P d 1 dditi d lti li ti ( dditi ll t i)
procedure SumOfSquares1 begin procedure SumOfSquares2 begin ( 1) (2 1)/6 begin sum:= 0 for i:= 1 to n do sum := sum + i2 sum:= n*(n+1)*(2*n+1)/6 end end
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
10
4n n2-7 n 4n n2-7 1 4 -6 2 8
5 20 18 6 24 29
). 7 ( 4 , 6 For
2 −
< ≥ n n n
2 8 -3 3 12 2 4 16 9 6 24 29 7 28 42 8 32 57
). 7 ( 4 , 6 For < ≥ n n n
) 1 2 ( ) 7 ( 4 ) 7 ( 4 4 ) 1 ( 4 : ) 1 ( 6 ), 7 ( 4 : ) (
2 2 2
k k k k k k S k k k k S + + − < + − < + = + + ≥ − <
2*6+1=13 ≥4
. true is ) ( 7 ) 1 ( ) 1 2 ( ) 7 ( ) 1 ( 4 ) ( ) ( ) ( ) ( ) (
2 2
n S k k k k ∴ − + = + + − < + ⇒
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
11
n
n
H H H
1 2 1 2 1
1 , , 1 , 1
2 1
+ ⋅ ⋅ ⋅ + + = ⋅⋅ ⋅ + = =
n H n H
n j
n
− + = ∑ ) 1 ( n, all For
Ex 4.9 : Harmonic numbers
1 ) 1 1 ( 1 : ) 1 ( Verify
1 1
1 1
H H H S
j
j
− + = = =
=
j
j=1
Proof
) 1 ( : true ) ( Assume
1 1
k H k H k S
k j
k k k j j
− + =
=
1) (k ] ) 1 ( [ : ) 1 ( Verify
1 1
1 1 1
H k H H k H k H H H k S
k k k j j
k j k j
+ − + = + − + = + = +
+ +
+ = =
) 1 ( 2) (k ] 1 1 1)[ (k 1) (k
1 1 1
k H H k k H H k H
k k k k
+ + = + − + − + = + +
+ + +
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
12
. true is ) ( ) 1 ( 2) (k
1
n S k H k ∴ + − + =
+
Ex 4.10 :
we must compare r with no more than A r ∈
n+1 elements in An.
n
A r ∈
b r c c C b b B c c b b C B c c b b A S a a a a A S = = < < < ∪ = = ∴ < =
2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
with compare (i) } , { }, , { , , } , , , { : ) 2 ( Verify s comparison 2 most at }, , { : ) 1 ( Verify
1 1 1 1 2 1
n C B C r B r b r + = + ∴ ∴ = = ∈ ∈
2
s comparison 1 1 2 most at (iii) s comparison 2 most at 2 | | | | ,
, (ii) with compare (i)
1 1 1 1
k k k k
c c c b b b c c c b b b C B A k S k S
k k k
< ⋅ ⋅ ⋅ < < < < ⋅ ⋅ ⋅ < < ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ = ∪ = +
+
2 1 2 1 2 1 2 1
}, , , , , , , , { Let : ) 1 ( Verify : true ) ( Assume
1
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
13
k k
c c c b b b < < < < < < <
2 1 2 1
M th ti l i d ti l j l i i ifi ti
Ex 4.11 :
answer : true ) ( Assume answer : ) ( Verify xy k S xy x S
k
= = = find we now again loop while' ' the
top the return to and executed nsare instructio loop the , first time for the loop while' ' the
top the reach the program the 1, hen : ) 1 ( Verify k n w k S + = +
while n≠ 0 do begin x := x * y
1 ) 1 (k find we now again, loop while the
top the
1
k n xy x = − + =
end answer := x
true. is ) ( ) ( answer final The and with continue will loop while' ' the And
1 1 , 1
n S xy y xy y x k n y x
k k k
∴ = = = ∴ =
+
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
14
) ( S
Ex 4.13 :
summands (e g 14 = 3 + 3+ 8) 14 ≥ n
: true ) ( Assume k S While : ) 1 ( Verify : true ) ( Assume = + k n k S k S 1 for s 8' with two s 3' five replace , s 3' five least at have sum the 14, sum, in the appears 8 no (ii) case 1 for s 3' e with thre 8 replace sum, in the appears 8
least at (i) case + = ∴ ≥ + = k n k n Q ) 1 ( ) ( 1 for s 8 with two s 3 five replace + ⇒ ∴ + = k S k S k n
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
15
Consider the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,…
Consider the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,… which is defined by F1 = F2 = 1 and Fn+2 = Fn+1 + Fn
Clearly this sequence F1,F2,… will grow, but how fast?
C j t F ≥ (3/2)n f ll >10
Conjecture: Fn ≥ (3/2)n for all n>10 Proof by induction:
Base case: Indeed F11 = 89 ≥ (3/2)11 = 86.49756…
Inductive step for n>10:
Inductive step for n>10:
Assume Fn ≥ (3/2)n and Fn+1 ≥ (3/2)n+1, then indeed
Fn+2
= Fn + Fn+1 ≥ (3/2)n + (3/2)n+1 = (3/2)n(1 + (3/2))
2
By induction on n, the conjecture holds.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
16
We just saw a different kind of proof by induction where
the inductive step is ∀n>10: [P(n), P(n+1) ⇒ P(n+2)] This time the basis step is proving P(11) and P(12). p p g ( ) ( )
There are many variations of proof by induction:
Strong/ Complete induction: Here the inductive step is: Assume all of P(1),…,P(n), then prove P(n+1). The basis step is P(1) for this alternative form of induction. p ( )
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
17
The sequence 1,1,2,3,5,8,13,21,34,… defined by
Fn+2= Fn+Fn+1 is the famous Fibonacci sequence.
A closed expression of Fn is
n n
n
For large n, it grows like Fn ≈ 0.447214 × 1.61803n. This (1+√5)/2 ≈ 1.61803 is the Golden Ratio.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
18
Fibonacci numbers often occur in the natural world. Shape of shells:
htt // h tt / j / /i d ht l
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
19
http://www.research.att.com/~njas/sequences/index.html
Alternative Form: (or the Principle of Strong Mathematical I d ti ) Induction)
more occurrences of the variable n, which represents a positive p p integer.
a)
If S(n0), S(n0+1), …, S(n1-1), and S(n1) are true If h S( ) S( 1) S(k 1) d S(k) f
Basic step
b)
If whenever S(n0), S(n0+1), …, S(k-1), and S(k) are true for some , then S(k+1) is also true
1
where , n k k ≥ ∈
+
Z
inductive step
.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
20
Ex 4.14 :
(e g 14 = 3+3+8 15 = 3+3+3+3+3 16 = 8+8) 14 ≥ n (e.g., 14 3+3+8, 15 3+3+3+3+3, 16 8+8)
true are ) 16 ( and ) 15 ( ) 14 ( Verify S S S : ) 1 ( Verify 16 where true, are ) ( and ) 1 ( ), 2 ( , ), 15 ( ), 14 ( Assume true. are ) 16 ( and ), 15 ( ), 14 ( Verify + ≥ − − ⋅⋅ ⋅ k S k k S k S k S S S S S S true is ) 1 ( true is ) 2 ( , 2 14 and , 3 ) 2 ( 1 : ) 1 ( Verify + ∴ − ≤ − ≤ + − = + + k S k S k k k k k S Q ) (
14 15 16 17 18 19 20 21 22 …
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
21
Ex 4.15 :
⎧ ≤ where , 3 a
n n
⎩ ⎨ ⎧ ≥ ∈ + + = = = =
+
− − −
3 where all for , and , 3 , 2 , 1
3 2 1 2 1
n n a a a a a a a
n n n n
Z
1 1
3 3 2 3 3 1 (i) = ≤ = ≤ = = a a
2 1 1 2 2
(ii) 3 9 3
− − +
+ + = = ≤ =
k k k k
a a a a a
1 2 1
3 ) 3 ( 3 3 3 3 3 3 3
+ − −
= = + + ≤ + + ≤
k k k k k k k k Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
22
Towers of Hanoi: (1883) Towers of Hanoi: (1883)
How to move the disks from one pole to another? How to move the disks from one pole to another?
Call this number M(n) Call this number M(n).
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
23
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
24
To prove something by induction, you need a conjecture about the
general case M(n).
Here we have: M(1)=1, M(2)=3, M(3)=7,… Obvious conjecture… M(n) = 2n – 1 for all n > 0 Clearly, the basis step M(1)=1 holds. Feeling for general n case: Each additional disk
(almost) doubles the number of moves: M( +1) i t f t M( ) M(n+1) consists of two M(n) cases…
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
25
How to move n+1 disks, using an n-disk ‘subroutine’?
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
26
We just saw that for all n, we have M(n+1) = 2M(n)+1.
This enables our proof of the conjecture M(n)=2n–1.
Proof: Basis step: M(1) = 21–1 = 1 holds.
A th t M( ) 2n 1 h ld Th f t +1
Assume that M(n)=2n–1 holds. Then, for next n+1: M(n+1) = 2 M(n) + 1 = 2(2n–1) + 1 = 2n+1 – 1. Hence it holds for n+1 End of proof by induction on n Hence it holds for n+1. End of proof by induction on n.
With n=64 golden disks, and one move per second, this amounts to almost 600,000,000,000 years of work.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
27
1.
2.
your conjecture) your conjecture)
3.
4
4.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
28
Inductive proofs play an important role in computer science
Analyzing recursive algorithms often require the use of
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
29
Th th d f i d ti l b li d t t t
The method of induction can also be applied to structures
and so on.
The crucial property that must hold is the well-ordered
principle: there has to be a notion of size such that all
smallest object.
Examples: vertex size of graphs, dimension of matrices,
depth of trees, length of sequences and so on.
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
30
Take a 2n×2n square with one tile missing Can you tile it with L-shapes? y p
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
31
Basis step of 2×2 squares is easy. Inductive step: Assuming that 2n×2n tiling is possible, tile a 2n+1×2n+1 square by looking at 4 sub-squares:
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
32
1)
F0 = 0; F1 = 1;
2)
F = F + F 2 h ll f ≥
+
Z
2)
Fn = Fn-1 + Fn-2, 2 where all for ≥ ∈
+
n n Z
1 2 + = +
× = ∑ ∈ ∀
n n n i i
F F F n Z
= i
1 2 2 1 2
Assume 1 * 1 step, basis
+
× = = +
k k k i
F F F F F
2 1 2 1 2 1
Then Assume
+ + + =
+ = ×
k k i k i k k i i
F F F F F F
2 1 1
) (
+ + = =
+ × = + × =
k k k i i
F F F F F F
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
33
2 1 1 1
) (
+ + + +
× = + × =
k k k k k
F F F F F
1)
2)
2 where all for ≥ ∈
+
n n Z
1 1 + − +
+ = ∈ ∀
n n n
F F L n Z
3 1 2 2 1
2 1 3 , 1 1 step, basis : Proof + = + = = + = + = = F F L F F L
2 1 1 1 k k 1 k 1 1 n
) ( ) ( Then 2 k where k, 1,
1,2,3,..., n for Assume
− + − − + + −
+ + + = + = ≥ = + =
k k k k n n
F F F F L L L F F L
2 1 2 1
) ( ) (
+ + − −
+ = + + + =
k k k k k k
F F F F F F
Fn-2 Fn-1 Fn Fn+1 Fn+2 Ln-1 Ln Ln+1
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
34
1 ) 1 ( 1 ) 1 ( + + − +
+ =
k k
F F
E 4 21 E l i
b
1 , 1 , ) 1 ( ) (
, 1 1 , 1 ,
k k m k a k a k m a
k m k m k m
< ≥ − ≤ ≤ + + − =
− − −
m=1 m=2 m=3 1 1 1 1 4 1
Row sum
1=1! 2=2! 6=3!
! , , , , , 1
1 , , , ,
m a k a m k a a
m k k m k m k m
= ∑ < = ≥ = =
− =
m=3 m=4 m=5 1 4 1 1 11 11 1 1 26 66 26 1 6 3! 24=4! 120=5!
] 3 ) 1 [( ] 2 [ ] ) 1 [( ] ) 1 ( ) 1 [(
2 1 1 1 , 1 , , 1
⋅ ⋅ ⋅ + + − + + + + + = + + ∑ − + = ∑
= − = +
a a m a ma a a m a k a k m a
m m m m m m k m m k k m m k k m
] ) 1 ( 2 [ ] [ ] ) 1 ( [ ] 2 [ ] ) 1 ( 3 [ ] ) [( ] [ ] ) [(
1 , 1 , , , , 1 , 1 , 2 , 2 , 3 , 2 , 1 , 1 , , , 1 ,
⋅ ⋅ ⋅ + − + + + = + + + + + − + +
− − − − − −
a m a ma a a m a ma a a m a
m m m m m m m m m m m m m m m m m m m m m m
Induction on m
! ) 1 ( ) 1 ( ] [ ] 2 ) 1 [(
1 , 1 , 1 , 2 , 2 ,
+ = ∑ + = + + + − +
− = − − − −
m m a m a ma a a m
m k k m m m m m m m m m
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
35
)! 1 ( ) ( + = m
D fi iti 4 1 If b di id d it b| if
d b Z b
there is an integer n such that a = bn, then b is divisor of a, or a is multiple of b.
, and , ≠ ∈ b Z b a
We also say for b nonzero: b divides a or b is a factor of a
, and , , integers three the
two divides and , If e) all for | | d) | )] | ( ) | [( c) )] | ( ) | [( b) 0) (a | and | 1 a) z y x a z y x x bx a b a c a c b b a b a a b b a a a + = ∈ ⇒ ⇒ ∧ ± = ⇒ ∧ ≠ Ζ ) ( | then each divides If 1 For g) ) ,
n combinatio linear called is y ( y), ( | )] | ( ) | [( f) integer. remaining the divides then , , , g , ) x c x c x c a c a c n i c b c bx c bx a c a b a a y y + + + ∈ ≤ ≤ + + ⇒ ∧ Ζ
) ( | then , each divides If . , 1 For g)
2 2 1 1 n n i i
x c x c x c a c a c n i + ⋅ ⋅ ⋅ + + ∈ ≤ ≤ Ζ
and | and | If f) an c am b c a b a = = ⇒ y) ( | ) ( ) ( ) ( y c bx a ny mx a y an x am c bx + ∴ + = + = + ∴
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
36
Number theory is now an essential applicable tool in dealing
Primes are the positive integers that have only two positive
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
37
Sacks spiral, 1994 Ulam spiral, 1963
+
Lemma 4.1: If and n is composite, then there is a prime
Proof
+
∈ Z n
Proof
If no such a prime Let S be the set of all composite integers that have no prime divisors. By Well-Ordering Principle, S has a least element m. If m is composite, then m=m1m2, 1<m1<m, 1<m2<m. Since
, m1 is prime or divisible by a prime, so exists a prime p,
S m1 ∉
,
1
p y p , p p, p|m1.
Since p|m1 and m=m1m2, so p|m. (contradiction, Theorem 4.3 (d))
S m1 ∉
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
38
Th 4 4 Th i fi it l i (E lid B k IX)
Theorem 4.4: There are infinitely many primes. (Euclid, Book IX) Proof
If not If not Let p1 , p2, …, pk be the finite list of all primes. Let B = p1 p2 …pk+1.
Let B p1 p2 …pk 1.
Since B > pi , , B is not a prime. So B is composite, pj|B, . (Lemma 4.1)
k i ≤ ≤ 1
k j ≤ ≤ 1
j
Since pj|B and pj|p1 p2 …pk, so pj|1. (Contradiction, Theorem 4.3
(e))
integer. remaining the divides then , and , , integers three the
two divides and , If e) a z y x a z y x + =
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
39
integer. remaining the divides then a
Z ∈ b a ,
unique
. , with , b r r qb a r q < ≤ + = ∈Z
r | (b) , i.e. , | (a) > / = a b r a b
We call r the remainder when a is divided by b, and q the quotient when a is divided by b.
(1) q, r exist
φ ≠ ∈ = > > − ∈ − = b b b b S S a t a tb a Z t tb a S ) 1 ( ) 1 ( h 1 l d If (ii) , then , and If (i) } , | { Let r , | (b) > / a b b r , | (c) < / a b φ ≠ > − ∴ ≤ ≤ − + − = − − = − − = ≤ S tb a a b b b a b a a tb a a t a , and 1 ) 1 ( ) 1 ( then , 1 let and If (ii) Q b S S P i i l ) O d i W ll ( l l h φ S S b q a c qb a c b r b r a b b q a b r qb a r r S S ∈ + − = ⇒ − = + = > / + = = − − = < ∴ ≠ f l t l t th i i t di t , ) 1 ( then , If (ii) . | ing contradict , ) 1 ( then , If (i) Principle) Ordering Well ( , element least a has φ Q
(2) q, r are unique
b r S r < ∴ .
element least the is ing contradict
2 2 1 1
if i t di t | | | let , and
are there If b b| r b q r b q a r's q's + = + =
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
40
2 1 2 1 2 1 1 2 2 1
and if ing contradict , | | | r r q q q q b r r q b|q = = ∴ ≠ < − = − ⇒
Ex 4.25
15 and the remainder r = 5 (170=15*11+5) 15, and the remainder r = 5. (170=15*11+5)
and the remainder r = 0. (98=14*7) f h di id d d h di i b h h i
and the remainder r = 3. (-45=(-6)*8+3 or -45=(-5)*8-5?)
+
∈Z b a,
If a = qb, then -a = (-q)b. So, the quotient is -q, and the remainder is 0. If a = qb + r, then -a = (-q)b - r = (-q - 1)b + (b - r). So, the quotient
is -q -1, and the remainder is b - r. q ,
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
41
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
42
Ex 4.27 : Write 6137 in the octal system (base 8)
Here we seek nonnegative integers r0 , r1 , r2, …, rk , 0< rk <8,
such that 6137= (rk… r2 r1 r0)8.
2 1
8 8 8 6137 ⋅ + ⋅ ⋅ ⋅ + ⋅ + ⋅ + =
k k
r r r r
2 3 4 1 2 1
1 8 7 8 7 8 3 8 1 ) 8 8 ( 8 + ⋅ + ⋅ + ⋅ + ⋅ = ⋅ + ⋅ ⋅ ⋅ + ⋅ + + =
− k k
r r r r
remainders
8 6137
8
) 13771 ( 1 8 7 8 7 8 3 8 1 = + + + +
8 767 1(r0) 8 95 7(r1) 8 11 7(r2)
2
8 1 3(r3) 0 1(r4)
How about base 2 and base 16?
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
43
Ex 4.29 : Two’s Complement Method: binary representation of
negative integers
One’s Complement: interchange 0’s and 1’s. Add 1 to the prior result.
E l 6 1010 0001 1001 0110 6 ≡ → + → ≡
Example: Example: How do we perform the subtraction 33 – 15 in base 2
with patterns of 8-bits? 6 1010 0001 1001 0110 6 − ≡ → + → ≡ with patterns of 8 bits?
(-15) 11110001 (33) 00100001 +
00001111 (+15)
General formula: x – y = x + [(2n – 1) – y + 1] – 2n
100010010
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
44
One’s complement of y
E 4 31 If
d i i h h i i h
+
Ex 4.31 : If and n is composite, then there exists a prime p such
that p|n and
Proof
+
∈Z n
. n p ≤
Composite n = n1n2 We claim that one of n1 , n2 must be less than or equal to If not then
d
, n
If not, then
tion) (contradic and
2 1 2 1
n n n n n n n n n n = > = > >
So, assume
(i) If n1 is prime, the statement is true.
.
1
n n ≤
( )
1
p , (ii) If n1 is not prime, there exists a prime p < n1 where p|n1. (Lemma 4.1) then
So p|n and
. n p ≤ .
1
n n p ≤ <
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
45
p|
Definition 4.3: For , a positive integer c is called a greatest
common divisor of (最大公因數gcd(a,b) )
Z ∈ b a,
c d b a d b a c b c c|a | have we , and
divisor common any for (b) ) ,
divisor common a is ( | and (a)
| , y ( )
and b ?
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
46
Theorem 4.6: For all , there exists a unique that is the
greatest common divisor of a and b.
f
+
∈Z b a,
} | { l t Gi bt t bt S b
+
Z Z
+
∈Z c
. ,
divisor common greast a is that claim We : Existence (i) Principle) Ordering
element least a has } , , | { let , , Given b a c c S bt as t s bt as S b a > + ∈ + = ∈
+
Z Z , , | If | 4.3(f)) (Theorem then , and if , , c r r qc a a c c d by d|ax d|b d|a by ax c S c < < + = / ∴ + + = ∈ Q | similarly, , |
element least the is ng contrdicti , ) ( ) 1 ( ) ( then b c a c S c S r b qy a qx by ax q a qc a r ∴ ∈ ∴ − + − = + − = − = 4 3(b)) (Theorem | and n the divisors common greast the are both , If : s Uniquenes (ii) | similarly, , |
2 1 1 | 2 2 1
c c c c c c c c b c a c ∴ ∴
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
47
4.3(b)) (Theorem
2 1
c c = ∴
a a = ≠ ∈ 0) gcd(a then a if Z
b d b ll d l ti l i h d( b) 1
a a ≠ ∈ 0) gcd(a, then , a if , Z
. 1 with , = + ∈ by ax y x Z
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
48
and apply the division algorithm n times as follows:
. ,
+
∈Z b a
and apply the division algorithm n times as follows:
r r r r q r r r r r q r < < + = < < + =
1 2 2 1 1
r r r r q r r r r r q r < < + = < < + =
⋅ ⋅ ⋅ 3 4 4 3 3 2 2 3 3 2 2 1 n n n n n n n n n
r q r r r r r q r = < < + =
− − − − − 1 1 1 1 2
Then rn, the last nonzero remainder, equals gcd(a, b)
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
49
d ) ( | d | If ,
divisor any for , | Verify (i) ) , gcd( at verify th To b b a c r c b a r
n n =
| | and | Next ) (e) 4.3 Theorem ( | then and ), , ( | and | If
, 2 1 1 2 2 1 1 1 1
r c r c r c r r q r r c r r q r b r a r r c r c ⇒ + = + = = = Q
r r q r r r q r + = + =
3 2 2 1 2 1 1
| and | Verify (ii) | down Continuing | | and | Next
3 2 1
b r a r r c r c r c r c
n n n
⇒ ⇒
r r q r + + =
⋅ ⋅ ⋅ 4 3 3 2
) (e) 4.3 Theorem ( equation last the From
, 1 1 2 2 | 1 |
r r q r r r r r
n n n n n n n n
+ = ∴
− − − − −
Q
n n n n n n n
r q r r r q r = + =
− − − − 1 1 1 2
) gcd( ) , ( | [ ] | [ up, Continuing
1 | ] 1 2 | 1 | 2 3 |
b a r b r a r r r r r r r r r r r r r
n n n n n n
= ∴ = = ⇒ ∧ ⇒ ∧
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
50
) , gcd( b a rn = ∴
Ex 4.34 : find the gcd(250,111), and express the results as a linear
combination of these integers.
< < + ⋅ = 111 28 28 111 2 50 2
< < + ⋅ = < < + ⋅ = < < + ⋅ = 27 1 1 27 1 28 28 27 27 28 3 111 111 28 28 111 2 50 2
= ∴ + ⋅ = 1 ) 111 , 250 gcd( 1 7 2 27
⋅ − + − = ⋅ + − = ⋅ − − = ⋅ − = ) ( ] 111 2 250 [ 4 111 ) 1 ( 28 4 111 ) 1 ( 28] 3 111 [ 1 28 27 1 28 1
Z ∈ + + = − ⋅ + ⋅ = k k k ] 250 9 [ 111 ] 111 250[4 1 unique not is it fact, In ) 9 ( 111 4 250
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
51
Z ∈ + − + − = k k k ], 250 9 [ 111 ] 111 250[4 1 1. 111) gcd(250, 111)
111)
111) gcd(-250, = = = =
Ex 4.35 : the integers 8n+3 and 5n+2 are relatively prime.
1 3 1 2 ) 1 2 ( ) 1 3 ( 1 2 5 2 5 1 3 ) 1 3 ( ) 2 5 ( 1 3 8 + < + < + + + = + + < + < + + + = + n n n n n n n n n n 1 1 2 1 2 1 2 ) 1 2 ( 1 1 3 ) ( ) ( < < + ⋅ = + + < < + + = + n n n n n n n n 1 ) 2 5 , 3 8 gcd( 1 = + + + ⋅ = n n n n
(8n+3)(-5) + (5n+2)(8) = -15 + 16 = 1
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
52
type of problem, not just one special case.
E 4 36 U
E lid l ith t d l d (i d d )
Ex 4.36 : Use Euclidean algorithm to develop a procedure (in pseudocode)
that will find gcd(a, b) for all a, b ∈ Z+
procedure gcd(a,b: positive integers) p g ( , p g ) begin r:= a mod b d:= b while r > 0 do c:= d d:= r r:= c mod d end return(d) d { d( b) d}
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
53
end {gcd(a,b) = d}
Ex 4.37 : Griffin has two unmarked containers. One container holds 17
containers to measure exactly one ounce containers to measure exactly one ounce.
17 4 , 4 17 3 55 < < + ⋅ = ] 7 1 3 55 [ 4 17 4 4 17 1 4 1 , 1 4 4 17 ⋅ − − = ⋅ − = < < + ⋅ = 55 4 17 13 ] [ ⋅ − ⋅ =
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
54
Ex 4.38 : On the average, Brian debug a Java program in six minutes, but
it takes 10 minutes to debug a C++ program. If he works for 104 minutes and doesn’t waste any time how many programs can be debug in each and doesn t waste any time, how many programs can be debug in each language.
= + ⇒ = + 52 5 3 104 10 6 y x y x + ≤ ≤ + − + − = − ⋅ + ⋅ = ⇒ − ⋅ + ⋅ = ⇒ = 3 52 5 104 ) 3 52 ( 5 ) 5 104 ( 3 ) 52 ( 5 104 3 52 ) 1 ( 5 2 3 1 1 ) 5 , 3 gcd( k y k x k k Q ⎧ = = = ≤ ≤ ∴ + − = ≤ − = ≤ 2 14 : 18 3 52 , 5 104
5 104 3 52
y x k k k y k x Q ⎪ ⎩ ⎪ ⎨ ⎧ = = = = = = = = = ⇒ 8 , 4 : 20 5 , 9 : 19 2 , 14 : 18 y x k y x k y x k
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
55
⎩
integer solution x = x0, y = y0 if and only if gcd(a, b) divides c.
c is called a common multiple of a b
, , ,
+
∈Z c b a
+
∈Z c b a
if c is a multiple of both a and b. Furthermore, c is the least common multiple of a, b if it is the smallest of all positive integers that are common l i l f b W d b l ( b)
, , , ∈Z c b a
multiples of a, b. We denote c by lcm(a, b).
, , ,
+
∈Z c b a
, |
) , ( lcm , | If ma c b a c c r r qc d d c = ∴ = < < + = / Q | multiple common least the is that claim the contradict , but ) ( , also d c c c r r a qm n r qma na na d ∴ < < = − ⇒ + = =
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
56
. | d c ∴
Theorem 4.10: For ab = lcm(a, b).gcd(a, b)
Ex 4.40 : By Theorem 4.10 we have
, ,
+
∈Z b a
then lcm(a, b) = ab.
, ,
+
∈Z b a
fact that gcd(168,458) = 24. As a result we find that lcm(a, b)?
192 , 3 ) 456 , 168 ( lcm 24 ) 456 , 168 gcd(
24 456 168
= = ∴ =
⋅
Q
24
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
57
Lemma 4.2: If and p is prime, then
+
y) ( | )] | ( ) | [( c bx a c a b a + ⇒ ∧
Lemma 4.3:
. 1 some for | | and prime is If . Let
2 1
n i a p a a a p p a
i n i
≤ ≤ ⇒ ∈
⋅ ⋅ ⋅
+
Z
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
58
2 1 i n i
Ex 4.41 : Show that is irrational.
Proof
2
4 2) (Lemma | 2 | 2 2 2 1 ) , gcd( and , , where , 2 not If
2 2 2 2
⇒ ⇒ = ⇒ = ∴ = ∈ = ⇒
+
a a a b b a b a
a b a
Z i ) ( di ) d( | | 4.2) (Lemma | 2 | 2 , 2 4 2 2 4.2) (Lemma | 2 | 2 2 2
2 2 2 2 2 2 2
⇒ = ⇒ = = ⇒ = ∴ ⇒ ⇒ = ⇒ = ∴ b b b b c b c a b c a a a a b
b
tion) (Contradic 2 ) , gcd( | 2 | 2 ≥ ∴ ∧ b a b a Q
p prime every for irrational is p
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
59
y g p p uniquely, up to the order of the primes. ( )
k k
s s s
p p p n ⋅ ⋅ ⋅ =
2 2 1 1
existence (i) m m m m m m m m m m ) 1 ( primes
product as written be can , and , composite) is ( primes.
product a as e expressibl not integer smallest the is not, If existence (i)
2 1 2 1
< < = Q Q n- n m m m m true) are 1 , 2,3,4, for form, ve (alternati Induction al Mathematic use : uniqueness (ii) primes
product a as e expressibl be can ) , 1 (
2 1
⋅⋅ ⋅ = ∴ < < Q
j r t t t r k j i r t r t t k k
q p q q q p n p q q q p p p q p q q q p p p n
s s s
4.3) (Lemma | | | and , primes are , where Suppose
1 2 2 1 1 1 1 2 1 , 2 1 2 2 1 1 2 2 1 1
⇒ ⋅ ⋅ ⋅ ⇒ < ⋅ ⋅ ⋅ < < < ⋅ ⋅ ⋅ < < ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ = Q
. | | and prime is If
2 1 i n
a p a a a p p ⇒
⋅ ⋅ ⋅
i i j j j r
q p q p q p i if p q q p q p q p q q q p p
j
j find t can' we , 1 similarly, primes are and ) ( | | |
1 1 1 1 1 , 1 1 1 2 1 1 1
= ∴ = < = ∋ > = = ⇒ Q Q
. |
i
a p ⇒
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
60
i i i i r t r t t k k
t s t s q p r k n n q q q p p p n
s s s p n
, , , , hypothesis induction By
1 1 1 2 2 1 1 1 2 2 1 1 1 1 1
= = = = ∴ < ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ = = ⇒
− −
Q
Ex 4.44 : How many positive divisors do 29,338,848,000 have? How
Ex 4.44 : How many positive divisors do 29,338,848,000 have? How
many of the positive divisors are multiples of 360? How many of the positive divisors are perfect squares?
For (i)
2 1
p p p n
k
s s s
11 7 5 3 2 000 , 848 , 338 , 29 ) 1 ( ) 1 )( 1 ( is
divisors positive
number The For (i)
3 3 5 8 2 1 2 2 1 1
= + ⋅ ⋅ ⋅ + + ⋅ ⋅ ⋅ = s s s n p p p n
k k k
76 5 1) 1)(1 1)(3 1 1)(3 2 5 )( 1 3 8 ( 5 3 2 360 (ii) 1728 1) 1)(1 1)(3 1)(3 5 )( 1 8 ( answer
2 3
= = + + + + + = ∴ (0,2,4) choices 3 have we , 5 For ) (0,2,4,6,8 choices 5 have we , 8 For (iii) 76 5 1) 1)(1 1)(3 1 1)(3 2 5 )( 1 3 8 ( answer
2 1
= = = + + + − + − + − = ∴ s s 60 1 2 2 3 5 answer (0) choices 1 have we , 1 For (0,2) choices 2 have we , 3 For
5 4 , 3
∴ = = s s s
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
61
60 1 2 2 3 5 answer = ⋅ ⋅ ⋅ ⋅ = ∴
Ex 4.46 : Can we find three consecutive positive integers whose product is
a perfect square, i.e., m(m+1)(m+2) = n2 , ?
+
∈Z n m,
) 4 4 S ti f 21 E i ( ) 2 , 1 gcd( 1 ) 1 , ( gcd fact that the Use exist , such Suppose + + = = + m m m m n m square perfect a also is ) 1 ( square perfect a is | and ), 2 ( | , | then ), 1 ( | if , prime any For ) 4.4 Section
21 Exercise (
2 2
+ ∴ + / / + ∴ m n n p m p m p m p p Q ) 1 ( 1 2 ) 2 ( square perfect a also is ) 2 ( square perfect a also is ) 1 ( square perfect a is
2 2 2
+ = + + < + < + ∴ + ∴ m m m m m m m m m n Q Q integers. positive e consecutiv such three no are e that ther conclude we So, square perfect a be cannot ) 2 ( + ∴ m m
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
62
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
63
4-1 :18, 24
Discrete Mathematics Discrete Mathematics – – CH4 CH4 2009 Spring 2009 Spring
64