The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.

Slides:



Advertisements
Similar presentations
Discrete Mathematics Lecture 3
Advertisements

Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Having Proofs for Incorrectness
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Basic properties of the integers
Discrete Mathematics Lecture 4 Harper Langston New York University.
Elementary Number Theory and Methods of Proof. Basic Definitions An integer n is an even number if there exists an integer k such that n = 2k. An integer.
Chapter 4 Properties of the integers: mathematical induction Yen-Liang Chen Dept of IM NCU.
3 Gallon Jug5 Gallon Jug Greatest Common Divisor Lecture 8: Sep 30.
Chapter II. THE INTEGERS
Inverses and GCDs Supplementary Notes Prepared by Raymond Wong
Discrete Structures Chapter 2 Part B Mathematical Induction
Lecture 4 Discrete Mathematics Harper Langston. Algorithms Algorithm is step-by-step method for performing some action Cost of statements execution –Simple.
Properties of the Integers: Mathematical Induction
Section 7.6: Partial Orderings Def: A relation R on a set S is called a partial ordering (or partial order) if it is reflexive, antisymmetric, and transitive.
Partially Ordered Sets (POSets)
Chapter 6. Order Relations and Structure
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
CS555Spring 2012/Topic 61 Cryptography CS 555 Topic 6: Number Theory Basics.
BY MISS FARAH ADIBAH ADNAN IMK
The Integers and Division
Quiz 2 key.
CSCI 1900 Discrete Structures
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
Copyright © Cengage Learning. All rights reserved.
Mathematics of Cryptography Part I: Modular Arithmetic
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
The Integers & Division. a divides b if a is not zero there is a m such that a.m = b “a is a factor of b” “b is a multiple of a” a|b Division.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Greatest Common Divisor
CompSci 102 Discrete Math for Computer Science
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Rational Numbers and Fields
MAT 320 Spring 2008 Section 1.2.  Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
AF2. Turn off your phones Primes, gcd, some examples, reading.
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
If more pigeons than pigeonholes, Pigeonhole Principle.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Advanced Algorithms Analysis and Design
CMSC Discrete Structures
Greatest Common Divisor
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
Foundations of Discrete Mathematics
Applied Discrete Mathematics Week 9: Integer Properties
Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Copyright © Zeph Grunschlag,
Application: Algorithms
Application: Algorithms
Applied Discrete Mathematics Week 10: Introduction to Counting
Number Theory.
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
Presentation transcript:

The Integers

The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3 remainder 7”. In other words, the quotient is 3 and the remainder is 7. It is also true that 58 = 2(17) + 24, but 24 > 17, and remainder must always be < divisor. (otherwise the “quotient” is not a quotient).

Quotient and Remainder are Unique

Representation is Unique Proof (Continue): Now we need to show that q, r are unique. Assume, for the sake of contradiction, that there are two such presentations for a, that is: a = q b+r, a = m b + n, where 0  r < b, 0  n < b. Then q b+r = m b + n implies b(q-m) = n – r. Next, since q  m, we have b(q-m) is an integral multiple of b. But since 0  r < b, 0  n < b we have –b < (n – r) < b always! Then |b(q-m)| is at least b, and (n-r) is at most b-1. So they cannot be equal: contradiction! Conclusion: a cannot have two presentations as above.

Proof of Uniqueness Remark: The standard approach in uniqueness proofs is to assume by contradiction that there are two forms, and then apply a sequence of arguments leading to a contradiction. Here we assumed a is two forms: a = q b+r and a = m b + n, and then concluded this results in a contradiction.

Quotient and Remainder

An Extension to Integer Numbers The property a = q b+r, 0  r < b can be extended to all integers (so far we discussed only natural numbers). Exception: b cannot be 0, why? Theorem (The Division Algorithm): Given integer numbers a and b, b  0, there are unique integers q and r, with 0  r < |b|, s.t., a = q b+r Proof: By case analysis. We already showed the case where a, b are both positive. If a=0, then q = r = 0 is the only solution. Consider next the other cases:

An Extension to Integer Numbers: Proof Proof (continue): Case 1: b > 0, a < 0. In this case, since –a > 0, we have unique integers q, r s.t., (-a) = q b + r, 0  r < b a = (-q) b – r. Recall that our goal is to have a non-negative remainder term. Therefore, if r = 0, we just have a = (-q) b. Otherwise, r > 0, then write a as follows: a = (-q -1)b + (b-r). Here (-q-1) is an integer, and 0 < b-r < b = |b|. Thus we have the desired form.

An Extension to Integer Numbers: Proof Proof (continue): Case 2: b 0. In this case, since –b > 0, we have unique integers q, r s.t., a = q(-b) + r, 0  r < |b|. [Here we apply the Theorem on the natural numbers if a > 0, and case 1 of this proof if a < 0.] Thus a has the desired form and we are done! QED Remarks: 1.The proof indeed covers all cases of all values of a, b (recall that b  0 always). 2.This proof is strongly relying on the same Theorem for natural number (proved before).

Example

The Sign of b

Divisibility and the Euclidean Algorithm

Three consecutive integers Problem: Given three consecutive integers a, a+1, a+2, prove that one of them must be divisible by 3. proof: By the division algorithm we have: a = 3 q + r, where 0  r < 3. That is, there are three possible values for r, r = 0, 1, 2. We follow each of these cases: Case 1, r = 0: here we have a = 3 q is divisible by 3. Case 2, r = 1: here we have a = 3 q +1, and thus a+2 = 3 q + 3 is divisible by 3. Case 3, r = 2: here we have a = 3 q +2, and thus a+1 = 3 q + 3 is divisible by 3.

Division and Partial Orders Let us define a binary relation on the natural numbers: R = { (a,b)  a, b  and a | b } [That is, we consider only those pairs (a,b) of naturals s.t. a divides b.] Proposition: The binary relation R is a partial order. proof: For partial orders, one needs to show reflexivisity, antisymmetry, and transitivity.

Division and Partial Orders Proof (continue): R is reflexive: For any a , a | a, since a/a = 1. R is antisymmetric: Suppose we are given a pair a, b , s.t. a | b and b | a. Then a = m b, for some natural number m, and b = q a, for some natural number q. a = m b = m (q a) = (m q) a. Since a > 0 we must have m q = 1, but since m, q are natural numbers then we must have m = q =1. Thus a = m b = b.

Division and Partial Orders Proof (continue): R is transitive: Suppose a, b, c , s.t. a | b and b | c. Then b = q a, for some natural number q, and c = m b, for some natural number m. c = m b = m (q a) = (m q) a, and (m q) is a natural number. We thus conclude a | c. QED Remark: The proposition implies that ( , | ) is a partially ordered set (POSET).

Division and Partial Orders Example: A = {1, 2, 3, 4, 5, 6}. In the poset (A, | ) what are the maximal elements? - 4 is maximal because there is no other a  A s.t. 4 | a. -5, 6 are also maximal since they do not divide any other number. However, 4 does not divide 5 nor 6 and thus it is NOT maximum. -3 is NOT maximal as 3 | is NOT maximal as 2 | 4, 2 | is minimum, as 1 divides each number in A.

Division and Partial Orders Proposition: Suppose a, b, c are integers such that c | a, a | b. Then c | (xa +yb), for any integers x, y. Proof: Since c | a we have a = q c, for some integer q. Since c | b we also have b = m c, for some integer m. Thus xa +yb = x (q c) + y (m c) = (xq + ym) c. Since (xq + ym) is an integer, we indeed have c | (xa +yb).

The greatest common divisor Definition: Let a, b be integers, s.t. at least one of them is not 0. An integer g is the greatest common divisor (gcd) of a and b iff g is the largest common divisor of a and b, that is: 1.g | a, g | b. 2.If c is any integer s.t. c | a, c | b, then c  g. We write g = gcd(a,b) to imply that g is the greatest common divisor of a and b. In this notation, a  b.

The greatest common divisor Examples: 1.gcd(15, 3) = 3. 2.gcd(-24, 18) = 6. 3.gcd(756, 210) = gcd(-756, 210) = gcd(-756, -210) = 42 If a, b are integers and a | b, we have gcd(b, a) = a. Suppose a is non zero, then gcd(a, 0) = a. Why? Claim: dcg(a, b)  1 always! (when one of a, b is nonzero) [1 is always a common divisor.]

The Euclidean Algorithm In general, an algorithm is a computational procedure that computes/reports an output given an input. Given two integers a, b, we would like to computer their gcd. This computation relies on the following key property: Based on the Division algorithm, we have a = q b + r, (recall a  b ) Lemma (proved below) : gcd(a, b) = gdc(b, r)

The Euclidean Algorithm We first discuss the consequences of the lemma, and only then prove it. This lemma implies that we can reduce the problem to a pair of smaller numbers, intuitively, this should make the problem easier, and it does! Example: 58 = 3 (17) + 7, therefore gcd(58,17) = gcd(17,7). On the next iteration, we have 17 = 2(7) + 3, then gcd(17,7) = gcd(7,3). Next, we have 7 = 2(3) + 1, then gcd(7,3) = gcd(3,1) = 1.

The Euclidean Algorithm Lemma (proved now) : If a = q b + r, for naturals a, b, q, and r. Assume a  b. Then gcd(a, b) = gdc(b, r). Proof: By assumption, none of a, b are zero. This in particular implies that both g 1 = gcd(a, b), and g 2 = gcd(b, r) are well defined (i.e., we do not divide by 0). By definition, g 2 | b and g 2 | r so g 2 | (q b + r), (why?) and therefore g 2 | a. Thus g 2 is a common divisor of a and b.

The Euclidean Algorithm Proof (continue): But since g 1 is the largest common divisor of a, b we must have g 2  g 1. Similarly, since g 1 | a and g 1 | b, we have g 1 | (a – q b) (Why?) That is, g 1 | r. So g 1 divides both r and b. Once again, since g 2 is the greatest common divisor of b and r: g 1  g 2. Then we conclude: g 1 = g 2.

The Euclidean Algorithm First, observe that it is sufficient to assume a, b are natural numbers, as we can change the sign of the gcd if exactly one of a or b is negative. [For example, gcd(756, 210) = 42, gcd(-756, 210) = 42, etc. ] Input: Two natural numbers a, b, with a  b. Output: gcd(a, b). We need to describe a procedure to compute gcd(a, b)

The Euclidean Algorithm: The actual procedure procedure to compute gcd(a, b): Write a = q 1 b + r 1, with 0  r 1 < b. If r 1  0, write b = q 2 r 1 + r 2, with 0  r 2 < r 1. If r 2  0, write r 1 = q 3 r_2 + r 3, with 0  r 3 < r 2. If r 3  0, write r 2 = q 4 r 3 + r 4, with 0  r 4 < r 3. Continue in this manner until some remainder r k = 0. Then gcd(a, b) is r k-1 (the last non-zero reminder). But why does the process must converge?

The Euclidean Algorithm: Convergence Why do we always end up with a remainder 0? In the process, we always have r 1 > r 2 > r 3 > r 4 > … That is, at every iteration the value of r k decreases by at least one, but all remainders are non-negative. Therefore, sooner or later one of the remainders r k will become 0. [This is called the “Well-Ordering Principle”.] At that step, we have r k-2 = q k r k-1 + r k, Then since r k = 0 we have gcd(a, b) = gcd(r k-2, r k-1 ) = r k-1.

The Euclidean Algorithm: Convergence More specifically, since r k = 0 we have gcd(a, b) = gcd(n, r 1 ) = gcd (r 1, r 2 ) = gcd (r 2, r 3 ) = … gcd(r k-2, r k-1 ) = gcd(r k-1, 0) = r k-1. Problem: Find gcd(630, 196). Solution: 630 = 3(196) = 4(42) = 1(28) = 2(14) + 0 The last non-zero reminder is 14, and thus gcd(630, 196)=14.

The Euclidean Algorithm Same Problem: Find gcd(630, 196). We now write the same equations slightly differently, expressing each remainder in terms of a and b. 42 = 630 – 3(196) : r 1 = a – 3b 28 = 196 – 4(42) : r 2 = b – 4r 1 = b – 4(a – 3b) = -4a + 13b 14 = 42 – 28 : r 3 = r 1 - r 2 = (a – 3b) – (-4a + 13b) = 5a – 16b Then we have: gcd(630, 196) = 14 = 5a – 16b = 5(630) – 16(196).

The Euclidean Algorithm This example shows that gcd(a, b) can be expressed as an integral linear combination of a and b. That is, each remainder can be written as: m a + n b, for some integers m, n. In particular, this is the form of the greatest common divisor. In our example we have: gcd(630, 196) = 14 = 5a – 16b = 5(630) – 16(196). More examples: gcd(1800, 756) = 36 and here gcd(1800, 756) = 36 = 8(1800) – 19(756). (Check!)

The Euclidean Algorithm This example shows that gcd(a, b) can be expressed as an integral linear combination of a and b. That is, each remainder can be written as: m a + n b, for some integers m, n. In particular, this is the form of the greatest common divisor. In our example we have: gcd(630, 196) = 14 = 5a – 16b = 5(630) – 16(196). More examples: gcd(1800, 756) = 36 and here gcd(1800, 756) = 36 = 8(1800) – 19(756). (Check!)

The Euclidean Algorithm This principle is summarized in the following theorem: Theorem [An important property!]: The greatest common divisor of integers a, b is an integral linear combination of them. That is, there are integers m, n such that: gcd(a, b) = m a + n b Remark: The sign of n, m is determined by the sign of a, b. If a, b, are naturals then n must be negative. If, for example, only b is negative, then m, n are positive etc. gcd(1800, 756) = 36 = 8(1800) - 19(756) gcd(1800, -756) = 36 = 8(1800) + 19(-756)

The Euclidean Algorithm Definition (Relatively prime): Two non-zero integers a, b are relatively prime iff gcd(a, b) = 1, that is, 1 is the only positive integer that divides both of them. Example: gcd(15, 4) = 1, gcd(21, 6) = 1. Note that a, b, are not necessarily prime, only their dcg is 1. Corollary of previous therem: Let a, b, x be integers with a | b x. If a, b are relatively prime, then a | x.

The Euclidean Algorithm Proof: Since a, b, are relatively primes, gcd(a, b) = 1. Then, by previous theorem, there are integers, m, n s.t.: 1 = m a + n b. Multiplying by x: x = x m a + x n b. Clearly, a | (x m a). We also have a | (x n b), as we assumed a | b x (and x n b = n (b x).) So a | (x m a) + (x n b), but the latter is x, thus: a | x. QED

The Euclidean Algorithm Problem: Suppose a, b, c are three non-zero integers, with a and c being relatively prime. Show that gcd(a, bc) = gcd(a, b). Solution: Let g 1 = gcd(a, bc), g 2 = gcd(a, b). Since g 2 | b we have g 2 | bc, and since also g 2 | a, we have g 2 is a divisor of a, and bc. Thus g 2  g 1. Next we show g 2  g 1. Since gcd(a, c) = 1 (a, c are relatively primes), there are integers m, n s.t. 1 = m a + n c.

The Euclidean Algorithm Solution (continue): 1 = m a + n c. Multiplying by b, we obtain: b = b m a + b n c. By definition, g 1 | a, g 1 | b c, then we must have g 1 | b m a + b n c (similarly to the corollary above). Thus g 1 | b. Thus g 1 is a divisor of a and b and we indeed have g 1  g 2. Therefore g 1 = g 2. QED

gcd and glb in Posets Consider the partial ordered set (N, | ) [That is, all ordered pairs of natural numbers (a,b) s.t. a | b. We showed that it is reflexive, anti-symmetric, and transitive.] Greatest lower bound: A greatest lower bound (glb, for short) of two elements a, b  N (in the poset (N, | ) ) is an element g  N, s.t. 1.g | a, and g | b. 2.If c | a, and c | b for some c  N, then c | g. What is the meaning of g in this case? - This is exactly gcd(a, b) ! In fact, it is divisible by any other common divisor of a and b.

The least common Multiple We now would like to consider the smallest positive integer l that is divisible by two integer numbers a, b: this is the least common multiple. Least common multiple: A least common multiple (lcm) of two integers a, b is an element l  N, s.t. 1.a | l, and b | l. 2.If there is m  N s.t. a | m, and b | m then m  l. Examples: lcm(4, 14) = 28, lcm(-6, 21) = 42, lcm(-5, -25) = 25.

The least common Multiple For two integers a, b, we have that |a| |b| is always a common multiple of a and b. Therefore lcm(a, b) always exists and lcm(a, b)  |a| |b|. Lemma: For any two integers a, b : gcd(a, b) lcm(a, b) = |a| |b|. Proof sketch: When gcd(a, b) = 1, it is clear that lcm(a, b) = |a| |b|, as a, b are relatively primes (e.g., think about lcm(5, 7)=35 ). In this case, We indeed have gcd(a, b) lcm(a, b) = lcm(a, b) = |a| |b|.

The least common Multiple Proof sketch (continue): When gcd(a, b) > 1, we make two observations: b / gcd(a,b) and b do not have any common divisor greater than 1. That is: gcd(a, b / gcd(a,b) ) = 1. (*) Indeed, if gcd(a, b / gcd(a,b) ) = g > 1 then a, b are both divided by g  gcd(a, b), which is impossible, as gcd(a, b) is the greatest common divisor. lcm (a, b) = lcm (a, b / gcd(a,b) ) (we do not prove this part).

The least common Multiple Proof sketch (continue): Putting these observations together, let c = b / gcd(a,b). Then: lcm(a, b) = lcm(a, c). Since gcd(a, c) = 1 (shown in (*) ), we obtain lcm (a, c) = |a| |c| = |a| |b| / gcd(a,b) Thus, we obtain: lcm (a, b) = |a| |b| / gcd(a,b) QED

The least common Multiple The lemma gives an easy way to compute lcm(a, b): Just compute gcd(a, b), and then extract |a| |b| / gcd(a, b). Examples: gcd(6, 12) = 3, thus lcm(6, 21) = 6(21)/3 = 6(7) = 42. gcd(630, -196) = 14, thus lcm(630, -196) = 630 (196)/14 = 8820.

The least common Multiple gcd(630, -196) = 14, thus lcm(630, -196) = 630 (196)/14 = Claim (w/o proof): Let a, b be integers lcm(a, b) is a divisor of all multiples of a and b. That is, least common multiple actually divides any other common multiple of a, b. Examples: lcm(6, 21) = 6(21)/3 = 6(7) = 42, and 6(21)/42 = 3. lcm(8, 12) = 8(12)/4 = 24, and 8(12)/24 = 4, but also 48 is a common multiple, and then 48/24 = 2.

lub and lcm in Posets Consider the partial ordered set (N, | ) as above. Least upper bound: A least upper bound (lub, for short) of two elements a, b  N (in the poset (N, | ) ) is an element l  N, s.t. 1.a | l, and b | l. 2.If a | m, and b | m for some m  N, then l | m. What is the meaning of l in this case? - This is exactly lub(a, b) ! Due to the claim that lcm(a,b) divides any other (larger) common multiple of a and b.

The Poset (N, | ) is a lattice Recall that a partial ordered set is a lattice if every two elements have a glb and a lub. Thus: Proposition: The Poset (N, | ) is a lattice. [Any pair of elements a, b  N have a gcd (glb) and a lcm (lub).]