CMSC 250 Discrete Structures Number Theory

advertisement
CMSC 250
Discrete Structures
Number Theory
Exactly one car in the plant has color
H(a) := “a has color”
 xCars

– H(x) 
 aCars
– a  x  ~ H(a)
H(a,b) := “a has color b”
 xCars

– yColors
 H(x,y) 
– aCars, bColors
 a  x  ~ H(a,b)
20 June 2007
Number Theory
2
At most one car in the plant has color
H(a,b) := “a has color b”
 x,aCars

– y,bColors
 [H(x,y)  H(a,b)]  x = a
20 June 2007
Number Theory
3
At least two cars in the plant have color
H(a,b) := “a has color b”
 x,aCars

– y,bColors
 H(x,y)  H(a,b)  x  a
20 June 2007
Number Theory
4
Existential Gen/Inst

Existential Generalization
– P(value)
– value  D
xD such that P(x)

Existential Instantiation
– xD such that P(x)
P(a), aD such that P(a) is true
20 June 2007
Number Theory
5
Proofs Must Have!







Clear statement of what you are proving
Clear indication you are starting the proof
Clear indication of flow
Clear indication of reason for each step
Careful notation, completeness and order
Clear indication of the conclusion and why it is
valid.
Suggest pencil and good erasure when needed
20 June 2007
Number Theory
6
Mathematical Proofs

For any real number x, x – 1 = x – 1
– Can you prove that?

For any real number x, x + y = x + y
– Can you prove that?
20 June 2007
Number Theory
7
Domains
Z – integers
 Q – rational numbers (quotients of
integers)

– rQ  a,bZ, (r = a/b)  (b  0)
– Irrational = not rational
R – real numbers
 Superscripts: Z+, Z-, Zeven, Zodd, Q>5

20 June 2007
Number Theory
8
Closure of Sets (Integers)

Addition
– If aZ and bZ, then (a + b)  Z

Subtraction
– If aZ and bZ, then (a – b)  Z

Multiplication
– If aZ and bZ, then (a * b)  Z
– If aZ and bZ, then abZ
20 June 2007
Number Theory
9
Integer Definitions

Even integer
– nZeven  kZ, n = 2k

Odd integer
– nZodd  kZ, n = 2k+1

Prime integer (Z>1)
– nZprime  r,sZ+, (n=r*s)  (r=1)  (s=1)

Composite integer (Z>1)
– nZcomposite  r,sZ+, (n=r*s)  (r1)  (s1)
20 June 2007
Number Theory
10
Examples









Prove 4 is even
Prove 5100 is even
Is 0 even?
Is -301 even?
If aZ and bZ, then is 6a2b even?
Is every integer either even or odd? Prove?
Is 1 prime?
What are the first 6 primes?
Is it true that every integer greater than 1 is
either composite or prime? Prove?
20 June 2007
Number Theory
11
Constructive Proofs of Existence

Proving an xD, such that Q(x):
– Finding an x in D that makes Q(x) true
– Giving a set of directions (such as a formula
or algorithm) that will give an x in D that
makes Q(x) true
20 June 2007
Number Theory
12
kZ such that 22r + 18s = 2k
Where rZ and sZ
 k,r,sZ, such that 22r + 18s = 2k
 Prove?

20 June 2007
Number Theory
13
Constructive Proof of Existence
If we want to prove:
 nZeven, p,q,r,sZprime
n=p+q  n=r+s  pr  ps  qr  qs
– Let n=10
 n Zeven by definition of even
– Let p = 5 and the q = 5
 p,q Zprime by definition of prime
 10 = 5+5
– Let r = 3 and s = 7
 r,s Zprime by definition of prime
 10 = 3+7
– And all of the inequalities hold
20 June 2007
Number Theory
14
Proving Universal Statements

Proof by exhaustion
– Can only be used on finite domains
 rZ+ where 23<r<29  p,qZ+ (r=pq)  (p q)
 But not even all of those

Proof by Generalizing from the Generic Particular
– Let x represent a particular but arbitrarily chosen
element in the domain
– Show that x satisfies the predicate
– This does not mean you choose an element at
random
20 June 2007
Number Theory
15
The sum of any two integers is even

Formally
– m,nZeven, (m + n)Zeven
– m,nZ, (mZeven  nZeven)  (m + n)Zeven

Proof:
– Start
 Let m be a generic particular even number
 Let n be a generic particular even number
– Show that (m + n)Zeven (on the board)
20 June 2007
Number Theory
16
Proofs Must Have!







Clear statement of what you are proving
Clear indication you are starting the proof
Clear indication of flow
Clear indication of reason for each step
Careful notation, completeness and order
Clear indication of the conclusion and why it is
valid.
Suggest pencil and good erasure when needed
20 June 2007
Number Theory
17
An even number times an integer
yields an even number
20 June 2007
Number Theory
18
The product of any two odd
integers is odd
20 June 2007
Number Theory
19
Prove Universal False by
Counterexample

a,bR, a2=b2  a=b

Let a = 2; b = -2
a2=b2
22 = (-2)2
4 = 4 – is TRUE
a=b
2 = -2 – is FALSE
TRUE  FALSE
FALSE







20 June 2007
Number Theory
20
Rational Numbers

Q – rational numbers (quotients of integers)
– rQ  a,bZ, (r = a/b)  (b  0)
– Irrational = not rational

Which of the following are rational?
–
–
–
–
–
–
–
10/3
0.281
7
0
2/0
0.1212
5.1212
20 June 2007
Number Theory
21
Prove 7 is a rational number

rQ  a,bZ, (r = a/b)  (b  0)
Let a = 7
 Let b = 1
 7 = 7/1 (by algebra)
7Z
1Z
10

20 June 2007
Number Theory
22
Prove nZ, n is rational (i.e. nQ)
20 June 2007
Number Theory
23
Sum of any two rational numbers is rational




r,sQ, r + s  Q
Let r = a/b
Let s = c/d
r + s = a/b + c/d = (ad + cb)/bd

Theorem
– Statement that is known to be true because it has
been proved.

Corollary
– Statement whose truth can be immediately deduced
from a proved theorem
– E.g.: The double of a ration number is rational
20 June 2007
Number Theory
24
Division Definitions

If n and d are integers, then
– N is divisible by d if, and only if, n=dk for
some integer k
– d|n  kZ, n=dk (read – “d divides n”)

Alternatively, we say that
–n
–n
–d
–d
–d
20 June 2007
is a multiple of d, or
is divisible by d, or
is a factor of n, or
is a divisor of n, or
divides n.
Number Theory
32 a multiple of -16?
21 divisible by 3?
7 a factor of -7?
5 divide 40?
7|42?
25
Transitivity of Divisibility
a,b,cR (a|b  b|c)  a|c
 Need to show: a|c  c = a*k, where a  0
 Choose generic particulars a,b,c s.t. a|b  b|c

– a|b  b = ar, where a,rZ and a  0
– b|c  c = bs, where b,sZ and b  0

Substitution
–
–
–
–
–
c = bs
c = (ar)s
c = a(rs)
k = (rs)
c = ak
20 June 2007
Number Theory
26
Proof Using Contrapositive

For all positive integers, if n does not
divide a number to which d is a factor,
then n cannot divide d.
n,d,cZ+, ndc  nd
 n,d,cZ+, n|d  n|dc (Contrapositive)


Prove …
20 June 2007
Number Theory
27
a,bZ, (a|b  b|a)  a=b
Choose general particular a,bZ s.t. a|b  b|a
 a|b  b = a*r, where a,rZ and a  0
 b|a  a = b*s, where b,sZ and b  0
 Algebra

–
–
–
–

a = bs
a = (ar)s
a = a(rs)
1 = rs (since a  0)
Is there a unique solution?
– No; r=s=1, r=s=-1

Substitution
– a=b or a=-b
20 June 2007
Number Theory
28
Proof by Contradiction
Suppose the statement to be proven is
FALSE
 Show that this leads to a logical
contradiction
 Conclude the original statement is TRUE


We can do this since every statement is
TRUE or FALSE, but not BOTH.
20 June 2007
Number Theory
29
There is no largest integer.
Suppose there is.
 Let P represent that integer.
 This means that nZ P ≥ n
 Show this leads to a contradiction:

– Let m = P + 1
– mZ by closure of addition
– m > p, by algebra; CONTRADICTION
– So P, is not the largest integer.
20 June 2007
Number Theory
30
Sum of any rational number and
any irrational number is irrational
Suppose there exists a rational number r and an
irrational number s such that r + s is rational
 This means:

–
–
–
–
–
–
–
r = a/b for a,bZ b0
r + s = c/dZ for d0
r + s = c/dZ fo
a/b + s = c/d
s = c/d – a/b
s = (cb – ad)/bd, num integer, denom int0
Contradiction!
20 June 2007
Number Theory
31
Proof by Contradiction
Every integer is rational
 Suppose every integer is irrational
 From supposition, 1 is irrational, but 1 = 1/1
which is rational
 Since our supposition led to a contradiction, then
our original statement must be true


ERROR
– nZ, nQ
– nZ, nQ
– There is some integer that is irrational
20 June 2007
Number Theory
32
Unique Factorization
n p p p p
e1
1

e2
2
e3
3
ek
k
Example:
– 72
–222
–233
–322
– 32  23
– 23  32
20 June 2007
33
22
32
(Standard Factored Form)
Number Theory
33
2 Q
20 June 2007
Number Theory
34
1 3 2 Q
20 June 2007
Number Theory
35
More Integer Definitions

Div and mod operators
– n div d – integer quotient for n  d
– n div d – integer remainder for n  d
– (n div d = q)  (n mod d = r)  n = qd + r
where nZ0, dZ+, rZ, qZ, 0r<d
– (Quotient Remainder Theorem)

Relating “mod” to “divides”
– d|n  0 = n mod d
– d|n  0 d n
20 June 2007
Number Theory
36
Modular Notation
For p,q,rZ
 Equivalent notations:

– p x q
– (p mod x) = (q mod x)
– x|(p – q)
20 June 2007
Number Theory
37
Proofs Using this Notation

mZ+, a,bZ
a m b  kZ a = b + km

mZ+, a,b,c,dZ
(a m b)  (c m d)  (a + c) m (b + d)
20 June 2007
Number Theory
38
Proof by Division into Cases

nZ, 3n  n2 3 1
20 June 2007
Number Theory
39
The square of any integer has form
4k or 4k + 1 for some integer k
20 June 2007
Number Theory
40
Floor & Ceiling Definitions

n is the floor of x where xR  nZ
– x = n  n  x < n + 1

n is the ceiling of x where xR  nZ
– x = n  n – 1 < x  n
20 June 2007
Number Theory
41
Floor Proofs

x,yR x + y = x + y

xR yZ x + y = x + y
20 June 2007
Number Theory
42
Another Floor Proof

The floor of n/2 is either:
– n/2 when n is even
– (n-1)/2 when n is odd

Prove by division into cases
20 June 2007
Number Theory
43
nZ, pZprime, p|n  p(n + 1)
Suppose n,p s.t. p|n  p|(n + 1)
 Let n = pi, n + 1 = pj
 pj = pi + 1
 pj – pi = 1
 p(j – i) = 1
 p|1
 p can be 1 or -1, neither of which is prime

20 June 2007
Number Theory
44
Is the set of primes infinite?

Assume finite set of primes of size N
– {p1, p2,  ,pN}
Construct x = p1  p2  …  pN
 Prime factorization says:

– pi, such that pi|(x+1)
That pi must be in {p1, p2,  ,pN} so pi|x
 pi|x  pi|(x+1)
 Which contradicts the previous theorem

20 June 2007
Number Theory
45
Summary of Proof Methods

Constructive Proof of Existence
Proof by Exhaustion
 Proof by Generalizing from the Generic
Particular
 Proof by Contraposition
 Proof by Contradiction
 Proof by Division into Cases

20 June 2007
Number Theory
46
Errors in Proofs
Arguing from example for universal proof.
 Misuse of Variables
 Jumping to the Conclusion (missing steps)
 Begging the Question
 Using "if" about something that is known

20 June 2007
Number Theory
47
Applications

Programming
– If … then …
– Loops …
– Algorithms (e.g. gcd) …

More examples
– Calculator
 Sqrt(2) = 1.414213562
 40.72727272727
–=?
– Cryptography …
20 June 2007
Number Theory
48
Using the Unique Prime
Factorization Theorem

Prove: aZ+ 3 | a2  3 | a

Prove: aZ+qZprime q|a2  q|a
20 June 2007
Number Theory
49
nZ,
20 June 2007
2
odd
odd
n Z nZ
Number Theory
50
nZ,
20 June 2007
odd
a,bZ ,
Number Theory
n=a+b
51
Download