Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
CMSC 250
Discrete Structures
Number Theory
Exactly one car in the plant has color
H(a) := “a has color”
xCars
– H(x)
aCars
– a x ~ H(a)
H(a,b) := “a has color b”
xCars
– yColors
H(x,y)
– aCars, bColors
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,aCars
– y,bColors
[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,aCars
– y,bColors
H(x,y) H(a,b) x a
20 June 2007
Number Theory
4
Existential Gen/Inst
Existential Generalization
– P(value)
– value D
xD such that P(x)
Existential Instantiation
– xD such that P(x)
P(a), aD 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)
– rQ a,bZ, (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 aZ and bZ, then (a + b) Z
Subtraction
– If aZ and bZ, then (a – b) Z
Multiplication
– If aZ and bZ, then (a * b) Z
– If aZ and bZ, then abZ
20 June 2007
Number Theory
9
Integer Definitions
Even integer
– nZeven kZ, n = 2k
Odd integer
– nZodd kZ, n = 2k+1
Prime integer (Z>1)
– nZprime r,sZ+, (n=r*s) (r=1) (s=1)
Composite integer (Z>1)
– nZcomposite r,sZ+, (n=r*s) (r1) (s1)
20 June 2007
Number Theory
10
Examples
Prove 4 is even
Prove 5100 is even
Is 0 even?
Is -301 even?
If aZ and bZ, 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 xD, 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
kZ such that 22r + 18s = 2k
Where rZ and sZ
k,r,sZ, such that 22r + 18s = 2k
Prove?
20 June 2007
Number Theory
13
Constructive Proof of Existence
If we want to prove:
nZeven, p,q,r,sZprime
n=p+q n=r+s pr ps qr qs
– 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
rZ+ where 23<r<29 p,qZ+ (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,nZeven, (m + n)Zeven
– m,nZ, (mZeven nZeven) (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,bR, 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)
– rQ a,bZ, (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
rQ a,bZ, (r = a/b) (b 0)
Let a = 7
Let b = 1
7 = 7/1 (by algebra)
7Z
1Z
10
20 June 2007
Number Theory
22
Prove nZ, n is rational (i.e. nQ)
20 June 2007
Number Theory
23
Sum of any two rational numbers is rational
r,sQ, 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 kZ, 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,cR (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,rZ and a 0
– b|c c = bs, where b,sZ 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,cZ+, ndc nd
n,d,cZ+, n|d n|dc (Contrapositive)
Prove …
20 June 2007
Number Theory
27
a,bZ, (a|b b|a) a=b
Choose general particular a,bZ s.t. a|b b|a
a|b b = a*r, where a,rZ and a 0
b|a a = b*s, where b,sZ 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 nZ P ≥ n
Show this leads to a contradiction:
– Let m = P + 1
– mZ 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,bZ b0
r + s = c/dZ for d0
r + s = c/dZ fo
a/b + s = c/d
s = c/d – a/b
s = (cb – ad)/bd, num integer, denom int0
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
– nZ, nQ
– nZ, nQ
– 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
–222
–233
–322
– 32 23
– 23 32
20 June 2007
33
22
32
(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 nZ0, dZ+, rZ, qZ, 0r<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,rZ
Equivalent notations:
– p x q
– (p mod x) = (q mod x)
– x|(p – q)
20 June 2007
Number Theory
37
Proofs Using this Notation
mZ+, a,bZ
a m b kZ a = b + km
mZ+, a,b,c,dZ
(a m b) (c m d) (a + c) m (b + d)
20 June 2007
Number Theory
38
Proof by Division into Cases
nZ, 3n 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 xR nZ
– x = n n x < n + 1
n is the ceiling of x where xR nZ
– x = n n – 1 < x n
20 June 2007
Number Theory
41
Floor Proofs
x,yR x + y = x + y
xR yZ 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
nZ, pZprime, 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: aZ+ 3 | a2 3 | a
Prove: aZ+qZprime q|a2 q|a
20 June 2007
Number Theory
49
nZ,
20 June 2007
2
odd
odd
n Z nZ
Number Theory
50
nZ,
20 June 2007
odd
a,bZ ,
Number Theory
n=a+b
51