Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
DISCRETE STRUCTURES
WonSook Lee
wslee@uottawa.ca
EECS, Univ. of Ottawa
The lecture note is collaborative work, and
large contribution is from Prof. Nejib Zaguia
3/26/18 1
CSI2101 / Introduction
to Number Theory
Let a,bÎZ with a¹0.
a|b º “a divides b” :º ($ cÎZ: b=ac)
“There is an integer c such that c times a equals b.”
5
Introduction to Number
Theory
Proof of Division Algorithm : (we’ll
use the well-ordering property
directly that states that every set of
nonnegative integers has a least
element.)
[The proof will be done when we discuss
Induction]
6
Introduction to Number
Theory
• Existence:
– We want to show the existence of q and r, with the
property that a = dq+r, 0 ≤r <d
– Consider the set S of non-negative numbers of the form a
- dq, where q is an integer. By the well-ordering property, S
has a least element r where r = a - d q0.
– r is non-negative; also, r < d.
• Otherwise if r≥ d, there would be a smaller nonnegative
element in S, namely a-d(q0+1)≥0. But then a-d(q0+1), which is
smaller than a-dq0, is an element of S, contradicting that a-
dq0 was the smallest element of S.
– So, it cannot be the case that r ≥ d, proving the existence
of 0 ≤ r < d and q.
QED 7
Introduction to Number
Theory
Uniqueness:
Suppose $ q, Q, R, 0≤r<d, 0≤R<d such that a= dq + r
and a = dQ+ R. Without loss of generality we may
assume that q ≤ Q. Subtracting both equations we
have: d (q-Q) = (R – r).
So d divides (R-r); so, either |d| ≤ |(R –r)| or (R – r) =
0. Since 0 ≤ r, R<d then –d < R - r < d i.e., |R-r| < d,
thus we must have R – r = 0.
So, R = r. Substituting into the original two
equations, we have dq = d Q (note d≠0) and thus q=Q,
proving uniqueness.
QE 8
D
Modular Arithmetic
If a and b are integers and m is a
positive integer, then
“a is congruent to b modulo m” if m
divides a-b
(denoted: a ≡ b (mod m) ; a mod m = b
mod m)
9
Modular Arithmetic
≡0 As 6 divides 17-5, 17 is
(mod 5)20 congruent to 5 modulo 6,
15
≡1 17 ≡ 5 (mod 6)
10
≡ 4 19 5
(mod
21 5)
14 16
9 11
(mod 5) 4 0
1
6
3 2
8 7
13 12 Congruence classes modulo 5.
18 17
222 ≡
≡3
(mod 5) (mod 5)
10
Modular Arithmetic
“a is congruent to b modulo m” if m
divides a-b
Theorem: Let m be a positive integer.
The integers a and b are congruent
modulo m if and only if there is an
integer k such that a = b + km
11
Modular Arithmetic
“a is congruent to b modulo m” if m
divides a-b
Theorem: Let m be a positive integer.
If a ≡ b (mod m) and c ≡ d (mod m), then
a+c ≡ (b+d) (mod m) and
ac≡ bd (mod m)
15
Hashing Functions
• Also known as:
– hash functions, hash codes, or just hashes.
• Two major uses:
– Indexing hash tables
• Data structures which support O(1)-time
access.
– Creating short unique IDs for long documents.
• Used in digital signatures – the short ID can
be signed, rather than the long document.
16
Hash Function Requirements
• A hash function h: A→B is a map from a set A to a
smaller set B (i.e., |A| ≥ |B|).
18
Hash Function Requirements
• Furthermore, for a cryptographically secure hash
function:
19
A Simple Hash Using mod
• Let the domain and codomain be the sets of all
natural numbers below certain bounds:
A = {aÎN | a < alim}, B = {bÎN | b < blim}
• Then an acceptable (although not great!) hash
function from A to B (when alim≥blim) is h(a) = a
mod blim.
• It has the following desirable hash function
properties:
– It covers or is onto its codomain B (its range is
B).
– When alim ≫ blim, then each bÎB has a pre-image
of about the same size,
• Specifically, |h−1(b)| = ëalim/blimû or éalim/blimù.
20
A Simple Hash Using mod
• However, it has the following limitations:
– It is not very random. Why not?
For example, if all a’s encountered happen to have the
same residue mod blim, they will all map to the same b!
(see also “spiral view”)
22
Digital Signature Application
• Document signing procedure:
o Given a document a to sign, quickly compute its hash b = h(a).
o Compute a certain function c = f(b) that is known only to the signer
o This step is generally slow, so we don’t want to apply it to the
whole document.
o Deliver the original document together with the digital signature c.
28
The Caesar cipher
• Encrypt “go cavaliers”
– Translate to numbers: g = 6, o = 14, etc.
• Full sequence: 6, 14, 2, 0, 21, 0, 11, 8, 4, 17, 18
– Apply the cipher to each number: f(6) = 9, f(14) = 17, etc.
• Full sequence: 9, 17, 5, 3, 24, 3, 14, 11, 7, 20, 21
– Convert the numbers back to letters 9 = j, 17 = r, etc.
• Full sequence: jr wfdydolhuv
33
Fundamental Theorem of
Arithmetic
34