Discrete Mathematics and its Applications

Slides:



Advertisements
Similar presentations
The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
Advertisements

1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
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.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
CSE115/ENGR160 Discrete Mathematics 03/15/11
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Integers Number Theory = Properties of Integers
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
7.1 CompSci 102© Michael Frank Today’s topics Integers & Number TheoryIntegers & Number Theory – –Integers – –Division, GCD – –Euclidean Alg – –Mod! Reading:
9/2/2015Discrete Structures1 Let us get into… Number Theory.
Module #8: Basic Number Theory
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
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.
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
MATH 224 – Discrete Mathematics
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics)  정수와 나눗셈 (The Integers and Division)
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/37 Module.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
資訊科學數學 9 : Integers, Algorithms & Orders 陳光琦助理教授 (Kuang-Chi Chen)
이산수학 (Discrete Mathematics) 2.5 정수와 알고리즘 (Integers and Algorithms) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
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.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: 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.
Module #9 – Number Theory 6/11/20161 Chapter 3 Algorithms, Integers and Matrices.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Number-Theoretic Algorithms
COT 3100, Spring 2001 Applications of Discrete Structures
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
B504/I538: Introduction to Cryptography
CSE15 Discrete Mathematics 03/15/17
COT 3100, Spring 2001 Applications of Discrete Structures
Integers and Division Section 3.4.
Number-Theoretic Algorithms (UNIT-4)
CMSC Discrete Structures
CSE 504 Discrete Mathematics & Foundations of Computer Science
Number Theory and Cryptography
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 3: Algorithms
Applied Discrete Mathematics Week 4: Number Theory
Applied Discrete Mathematics Week 4: Number Theory
Number Theory (Chapter 7)
Module #8: Basic Number Theory
Number Theory.
Foundations of Discrete Mathematics
Enough Mathematical Appetizers!
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Module #8: Basic Number Theory
CSE 311 Foundations of Computing I
The Integers & Division
Discrete Mathematics and its Applications
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Applied Discrete Mathematics Week 10: Introduction to Counting
Discrete Mathematics and its Applications
Discrete Mathematics and its Applications
Number Theory.
Discrete Mathematics and its Applications
Module #9: Basic Number Theory
Presentation transcript:

Discrete Mathematics and its Applications 2018-11-30 Yonsei Univ. at Wonju Dept. of Mathematics 이산수학 Discrete Mathematics Prof. Gab-Byung Chae Slides for a Course Based on the Text Discrete Mathematics & Its Applications (6th Edition) by Kenneth H. Rosen A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different paces, rather than dividing the material up into fixed-length lectures, we will divide it up into “modules” which correspond to major topic areas and will generally take 1-3 lectures to cover. Within modules, we have smaller “topics”. Within topics are individual slides. 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Module #8: Basic Number Theory Rosen 5th ed., ~31 slides, ~2 lectures 2018-11-30 (c)2001-2003, Michael P. Frank

§2.4: The Integers and Division Of course you already know what the integers are, and what division is… But: There are some specific notations, terminology, and theorems associated with these concepts which you may not know. These form the basics of number theory. Vital in many important algorithms today (hash functions, cryptography, digital signatures). 2018-11-30 (c)2001-2003, Michael P. Frank

Divides, Factor, Multiple 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.” Example: 312  True, but 37  False. Iff a divides b, then we say a is a factor or a divisor of b, and b is a multiple of a. “b is even” :≡ 2|b. Is 0 even? Is −4? 2018-11-30 (c)2001-2003, Michael P. Frank

Facts re: the Divides Relation a,b,c  Z: 1. a|0 2. (a|b  a|c)  a | (b + c) 3. a|b  a|bc 4. (a|b  b|c)  a|c Proof of (2): a|b means there is an s such that b=as, and a|c means that there is a t such that c=at, so b+c = as+at = a(s+t), so a|(b+c) also.■ 2018-11-30 (c)2001-2003, Michael P. Frank

More Detailed Version of Proof Show a,b,c  Z: (a|b  a|c)  a | (b + c). Let a, b, c be any integers such that a|b and a|c, and show that a | (b + c). By defn. of |, we know s: b=as, and t: c=at. Let s, t, be such integers. Then b+c = as + at = a(s+t), so u: b+c=au, namely u=s+t. Thus a|(b+c). 2018-11-30 (c)2001-2003, Michael P. Frank

Prime Numbers An integer p>1 is prime iff it is not the product of any two integers greater than 1: p>1  a,bN: a>1, b>1, ab=p. The only positive factors of a prime p are 1 and p itself. Some primes: 2,3,5,7,11,13... Non-prime integers greater than 1 are called composite, because they can be composed by multiplying two integers greater than 1. 2018-11-30 (c)2001-2003, Michael P. Frank

Review of §2.4 So Far a|b  “a divides b”  cZ: b=ac “p is prime”  p>1  aN: (1 < a < p  a|p) Terms factor, divisor, multiple, composite. 2018-11-30 (c)2001-2003, Michael P. Frank

Fundamental Theorem of Arithmetic Its "Prime Factorization" Every positive integer has a unique representation as the product of a non-decreasing series of zero or more primes. 1 = (product of empty series) = 1 2 = 2 (product of series with one element 2) 4 = 2·2 (product of series 2,2) 2000 = 2·2·2·2·5·5·5; 2001 = 3·23·29; 2002 = 2·7·11·13; 2003 = 2003 2018-11-30 (c)2001-2003, Michael P. Frank

An Application of Primes Discrete Mathematics and its Applications 2018-11-30 An Application of Primes When you visit a secure web site (https:… address, indicated by padlock icon in IE, key icon in Netscape), the browser and web site may be using a technology called RSA encryption. This public-key cryptography scheme involves exchanging public keys containing the product pq of two random large primes p and q (a private key) which must be kept secret by a given party. So, the security of your day-to-day web transactions depends critically on the fact that all known factoring algorithms are intractable! Note: There is a tractable quantum algorithm for factoring; so if we can ever build big quantum computers, RSA will be insecure. Here 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

The Division “Algorithm” Discrete Mathematics and its Applications 2018-11-30 The Division “Algorithm” Really just a theorem, not an algorithm… The name is used here for historical reasons. For any integer dividend a and divisor d≠0, there is a unique integer quotient q and remainder rN  a = dq + r and 0  r < |d|. a,dZ, d>0: !q,rZ: 0r<|d|, a=dq+r. We can find q and r by: q=ad, r=aqd. (such that) The symbol that looks like a backwards “set-membership” relational operator is an abbreviation for “such that”. 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Greatest Common Divisor The greatest common divisor gcd(a,b) of integers a,b (not both 0) is the largest (most positive) integer d that is a divisor both of a and of b. d = gcd(a,b) = max(d: d|a  d|b)  d|a  d|b  eZ, (e|a  e|b) → d ≥ e Example: gcd(24,36)=? Positive common divisors: 1,2,3,4,6,12… Greatest is 12. 2018-11-30 (c)2001-2003, Michael P. Frank

GCD shortcut If the prime factorizations are written as and , then the GCD is given by: Example: a=84=2·2·3·7 = 22·31·71 b=96=2·2·2·2·2·3 = 25·31·70 gcd(84,96) = 22·31·70 = 2·2·3 = 12. 2018-11-30 (c)2001-2003, Michael P. Frank

Relative Primality Integers a and b are called relatively prime or coprime iff their gcd = 1. Example: Neither 21 and 10 are prime, but they are coprime. 21=3·7 and 10=2·5, so they have no common factors > 1, so their gcd = 1. A set of integers {a1,a2,…} is (pairwise) relatively prime if all pairs ai, aj, ij, are relatively prime. 2018-11-30 (c)2001-2003, Michael P. Frank

Least Common Multiple lcm(a,b) of positive integers a, b, is the smallest positive integer that is a multiple both of a and of b. E.g. lcm(6,10)=30 m = lcm(a,b) = min(m: a|m  b|m)  a|m  b|m  nZ: (a|n  b|n) → (m ≤ n) If the prime factorizations are written as and , then the LCM is given by 2018-11-30 (c)2001-2003, Michael P. Frank

The mod operator An integer “division remainder” operator. Let a,dZ with d>1. Then a mod d denotes the remainder r from the division “algorithm” with dividend a and divisor d; i.e. the remainder when a is divided by d. (Using e.g. long division.) We can compute (a mod d) by: a  d·a/d. In C programming language, “%” = mod. 2018-11-30 (c)2001-2003, Michael P. Frank

Modular Congruence Let Z+={nZ | n>0}, the positive integers. Let a,bZ, mZ+. Then a is congruent to b modulo m, written “ab (mod m)”, iff m | ab . Also equivalent to: (ab) mod m = 0. (Note: this is a different use of “” than the meaning “is defined as” I’ve used before.) 2018-11-30 (c)2001-2003, Michael P. Frank

Spiral Visualization of mod Discrete Mathematics and its Applications 2018-11-30 Spiral Visualization of mod Example shown: modulo-5 arithmetic ≡ 0 (mod 5) 20 15 ≡ 1 (mod 5) 10 ≡ 4 (mod 5) 19 5 21 14 16 9 11 4 6 1 3 2 8 7 13 12 Do another example on the board. 18 17 22 ≡ 2 (mod 5) ≡ 3 (mod 5) 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Useful Congruence Theorems Let a,bZ, mZ+. Then: ab (mod m)  kZ a=b+km. Let a,b,c,dZ, mZ+. Then if ab (mod m) and cd (mod m), then: ▪ a+c  b+d (mod m), and ▪ ac  bd (mod m) 2018-11-30 (c)2001-2003, Michael P. Frank

Rosen §2.5: Integers & Algorithms Topics: Euclidean algorithm for finding GCD’s. Base-b representations of integers. Especially: binary, hexadecimal, octal. Also: Two’s complement representation of negative numbers. Algorithms for computer arithmetic: Binary addition, multiplication, division. 2018-11-30 (c)2001-2003, Michael P. Frank

Euclid’s Algorithm for GCD Finding GCDs by comparing prime factorizations can be difficult if the prime factors are unknown. Euclid discovered: For all integers a, b, gcd(a, b) = gcd((a mod b), b). Sort a,b so that a>b, and then (given b>1) (a mod b) < a, so problem is simplified. Euclid of Alexandria 325-265 B.C. 2018-11-30 (c)2001-2003, Michael P. Frank

Euclid’s Algorithm Example Discrete Mathematics and its Applications 2018-11-30 Euclid’s Algorithm Example gcd(372,164) = gcd(372 mod 164, 164). 372 mod 164 = 372164372/164 = 372164·2 = 372328 = 44. gcd(164,44) = gcd(164 mod 44, 44). 164 mod 44 = 16444164/44 = 16444·3 = 164132 = 32. gcd(44,32) = gcd(44 mod 32, 32) = gcd(12, 32) = gcd(32 mod 12, 12) = gcd(8,12) = gcd(12 mod 8, 8) = gcd(4,8) = gcd(8 mod 4, 4) = gcd(0,4) = 4. Have students come up with other examples and work through them. Maybe start with a 2-digit example. 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Euclid’s Algorithm Pseudocode procedure gcd(a, b: positive integers) while b  0 r := a mod b; a := b; b := r return a Sorting inputs not needed because order will be reversed each iteration. Fast! Number of while loop iterations turns out to be O(log(max(a,b))). 2018-11-30 (c)2001-2003, Michael P. Frank

Discrete Mathematics and its Applications 2018-11-30 Base-b number systems Ordinarily we write base-10 representations of numbers (using digits 0-9). 10 isn’t special; any base b>1 will work. For any positive integers n,b there is a unique sequence ak ak-1… a1a0 of digits ai<b such that The “base b expansion of n” We’ll deal with summation notation in detail later. For now, explain what it means in this particular case. See module #12 for summation notation. 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Particular Bases of Interest Used only because we have 10 fingers Base b=10 (decimal): 10 digits: 0,1,2,3,4,5,6,7,8,9. Base b=2 (binary): 2 digits: 0,1. (“Bits”=“binary digits.”) Base b=8 (octal): 8 digits: 0,1,2,3,4,5,6,7. Base b=16 (hexadecimal): 16 digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Used internally in all modern computers Octal digits correspond to groups of 3 bits 2018-11-30 (c)2001-2003, Michael P. Frank Hex digits give groups of 4 bits

Discrete Mathematics and its Applications 2018-11-30 Converting to Base b (Algorithm, informally stated) To convert any integer n to any base b>1: To find the value of the rightmost (lowest-order) digit, simply compute n mod b. Now replace n with the quotient n/b. Repeat above two steps to find subsequent digits, until n is gone (=0). Have students write out pseudocode in class? Exercise for student: Write this out in pseudocode… 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Addition of Binary Numbers Discrete Mathematics and its Applications 2018-11-30 Addition of Binary Numbers procedure add(an−1…a0, bn−1…b0: binary representations of non-negative integers a,b) carry := 0 for bitIndex := 0 to n−1 {go through bits} begin bitSum := abitIndex+bbitIndex+carry {2-bit sum} sbitIndex := bitSum mod 2 {low bit of sum} carry := bitSum / 2 {high bit of sum} end sn := carry return sn…s0: binary representation of integer s Show 3-input full adder truth table on board. Have students try this or one of the following algorithms by hand. 2018-11-30 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Multiplication of Binary Numbers procedure multiply(an−1…a0, bn−1…b0: binary representations of a,bN) for j := 0 to n−1 begin if bi = 1 then c j := (a shifted j places) else c j := 0 end p:=0 for j:=0 to n-1 p := p + c j Use previous binary addition 2018-11-30 (c)2001-2003, Michael P. Frank

Example Find the product of a = (110)2 and b =(101)2 ab0*2 = (110)2 *1*2^0 = (110)2 = c1 ab1*2^1 = (110)2 *0*2^1 = (0000)2 = c2 ab2*2^2 = (110)2 *1*2^2 = (11000)2 = c3 P = c1 + c2 + c3 = (11110)2 2018-11-30 (c)2001-2003, Michael P. Frank