Useful GCD Fact If a and b are positive integers, then gcd(a,b) = gcd(b, a mod b) Proof: By definition of mod, a = qb+ (a mod b) for.

Slides:



Advertisements
Similar presentations
Introduction to Proofs
Advertisements

Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
Induction Sections 41. and 4.2 of Rosen Fall 2008 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions:
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.
Induction Sections 4.1 and 4.2 of Rosen Fall 2010
Discrete Structures Chapter 2 Part B Mathematical Induction
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 12 Number theory Mathematical induction Proof by induction Examples.
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Reading and Writing Mathematical Proofs
CSNB143 – Discrete Structure Topic 5 – Induction Part I.
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
CSE 311: Foundations of Computing Fall 2013 Lecture 8: More Proofs.
CSE 311 Foundations of Computing I Lecture 15 Recursive Definitions and Structural Induction Autumn 2011 CSE 3111.
INDUCTION AND RECURSION. PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function,
1 Introduction to Abstract Mathematics Chapter 3: Elementary Number Theory and Methods of Proofs Instructor: Hayk Melikya Direct.
Cryptography Inverses and GCD Piotr Faliszewski. GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a –
Chinese Remainder Theorem Dec 29 Picture from ………………………
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
CSE 311 Foundations of Computing I Lecture 14 Euclid’s Algorithm Mathematical Induction Autumn 2012 CSE
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction Linda Shapiro Winter 2015.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
CSE 311 Foundations of Computing I Lecture 8 Proofs Autumn 2012 CSE
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
CSE 311 Foundations of Computing I Lecture 15 Strong Induction and Recursive Definitions Spring
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
If more pigeons than pigeonholes, Pigeonhole Principle.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division
Discrete Math II Howon Kim
B504/I538: Introduction to Cryptography
MA/CSSE 473 Day 06 Euclid's Algorithm.
Advanced Algorithms Analysis and Design
Prelude to Public-Key Cryptography
Advanced Algorithms Analysis and Design
CSE 311 Foundations of Computing I
CS2210:0001Discrete Structures Induction and Recursion
CSE 311 Foundations of Computing I
Induction and recursion
Greatest Common Divisor
CSE 311: Foundations of Computing
CSE 311 Foundations of Computing I
Hubert Chan (Chapters 1.6, 1.7, 4.1)
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction
CSE 311: Foundations of Computing
CSE 373 Data Structures and Algorithms
Mathematical Induction I
Applied Discrete Mathematics Week 9: Integer Properties
Copyright © Zeph Grunschlag,
Application: Algorithms
Application: Algorithms
Induction Chapter
Advanced Analysis of Algorithms
Modular Inverses Recall the simple encryption function
Mathematical Induction
Cryptography Lecture 16.
Cryptography Lecture 19.
Copyright © Cengage Learning. All rights reserved.
Agenda Proofs (Konsep Pembuktian) Direct Proofs & Counterexamples
CSE 311 Foundations of Computing I
Recursion.
Presentation transcript:

Useful GCD Fact If a and b are positive integers, then gcd(a,b) = gcd(b, a mod b) Proof: By definition of mod, a = qb+ (a mod b) for some integer q=a div b. Let d=gcd(a,b). Then d|a and d|b so a=kd and b=jd for some integers k and j. Therefore (a mod b) = a – qb = kd – qjd = d(k – qj). So, d | (a mod b) and since d | b we must have d ≤ gcd(b, a mod b). Now, let e=gcd(b, a mod b). Then e | b and e | (a mod b). It follows that b=me and (a mod b) = ne for some integers m and n. Therefore a = qb+ (a mod b) = qme + ne = e(qm+n) So, e | a and since e | b we must have e ≤ gcd(a, b). Therefore gcd(a, b)=gcd(b, a mod b).

Euclid’s Algorithm Repeatedly use the fact to reduce numbers until you get gcd(660,126) = gcd(126, 660 mod 126) = gcd(126, 30) = gcd(30, 126 mod 30) = gcd(30, 6) = gcd(6, 30 mod 6) = gcd(6, 0) = 6 gcd(660,126) 660 = 5 • 126 + 30 126 = 4 • 30 + 6 30 = 5 • 6

Euclid’s Algorithm GCD(x, y) = GCD(y, x mod y) int GCD(int a, int b){ /* a >= b, b > 0 */ int tmp; while (y > 0) { tmp = a % b; a = b; b = tmp; } return a; Example: GCD(660, 126)

CSE 311: Foundations of Computing Fall 2014 Lecture 13: Modular Inverses, Induction

Bézout’s theorem If a and b are positive integers, then there exist integers s and t such that gcd(a,b) = sa + tb.

Extended Euclidean algorithm Can use Euclid’s Algorithm to find 𝑠, 𝑡 such that gcd 𝑎,𝑏 =𝑠𝑎+𝑡𝑏 e.g. gcd(35,27): 35 = 1 • 27 + 8 35 - 1 • 27 = 8 27= 3 • 8 + 3 27- 3 • 8 = 3 8 = 2 • 3 + 2 8 - 2 • 3 = 2 3 = 1 • 2 + 1 3 - 1 • 2 = 1 2 = 2 • 1 + 0 Substitute back from the bottom 1= 3 - 1 • 2 = 3 – 1 (8 - 2 • 3) = (-1) • 8 + 3 • 3 = (-1) • 8 + 3 (27- 3 • 8 ) = 3 • 27 + (-10) • 8 =

multiplicative inverse mod 𝑚 Suppose GCD 𝑎,𝑚 =1 By Bézout’s Theorem, there exist integers 𝑠 and 𝑡 such that 𝑠𝑎+𝑡𝑚=1. 𝑠 mod 𝑚 is the multiplicative inverse of 𝑎: 1= 𝑠𝑎+𝑡𝑚 mod 𝑚=𝑠𝑎 mod 𝑚

Solving Modular Equations Solving 𝑎𝑥≡𝑏 (mod 𝑚) for unknown 𝑥 when gcd 𝑎,𝑚 =1 . Find 𝑠 such that 𝑠𝑎+𝑡𝑚=1 Compute 𝑎 −1 =𝑠 mod 𝑚, the multiplicative inverse of 𝑎 modulo 𝑚 Set 𝑥= 𝑎 −1 ⋅𝑏 mod 𝑚

multiplicative cipher: 𝑓(𝑥) = 𝑎𝑥 mod 𝑚 For a multiplicative cipher to be invertible: 𝑓 𝑥 =𝑎𝑥 𝑚𝑜𝑑 𝑚 : 0,…,𝑚−1 →{0,…,𝑚−1} must be one-to-one and onto Lemma: If there is an integer 𝑏 such that 𝑎𝑏 mod 𝑚 = 1, then the function 𝑓(𝑥) = 𝑎𝑥 mod 𝑚 is one-to-one and onto.

Example Solve: 7𝑥≡1 (mod 26)

Mathematical Induction Method for proving statements about all integers ≥ 0 A new logical inference rule! It only applies over the natural numbers The idea is to use the special structure of the naturals to prove things more easily Particularly useful for reasoning about programs! for(int i=0; i < n; n++) { … } Show P(i) holds after i times through the loop public int f(int x) { if (x == 0) { return 0; } else { return f(x – 1)+1; }} f(x) = x for all values of x ≥ 0 naturally shown by induction.

Prove for all n > 0, a is odd → an is odd Let n > 0 be arbitrary. Suppose that a is odd. We know that if a, b are odd, then ab is also odd. So, (…• ((a•a) •a) •…•a) = an (n times) Those “…”s are a problem! We’re trying to say “we can use the same argument over and over”… We’ll come back to this.

Induction Is A Rule of Inference Domain: Natural Numbers 𝑃(0)  𝑘 (𝑃(𝑘) → 𝑃(𝑘+1))   𝑛 𝑃(𝑛) Formal steps Show P(0) Assume P(k), Prove P(k+1), Conclude P(k) P(k+1) Conclude  k (P(k) P(k+1)) Conclude  n P(n)

Using The Induction Rule In A Formal Proof 𝑃(0)  𝑘 (𝑃(𝑘) → 𝑃(𝑘+1))   𝑛 𝑃(𝑛) 1. Prove P(0) Let k be an arbitrary integer ≥ 0 3. Assume that P(k) is true 4. ... 5. Prove P(k+1) is true P(k)  P(k+1) Direct Proof Rule 7.  k (P(k)  P(k+1)) Intro  from 2-6 8.  n P(n) Induction Rule 1&7

Instead, Let’s Use Induction 𝑃(0)  𝑘 (𝑃(𝑘) → 𝑃(𝑘+1))   𝑛 𝑃(𝑛) Base Case 1. Prove P(0) Let k be an arbitrary integer ≥ 0 3. Assume that P(k) is true 4. ... 5. Prove P(k+1) is true P(k)  P(k+1) Direct Proof Rule 7.  k (P(k)  P(k+1)) Intro  from 2-6 8.  n P(n) Induction Rule 1&7 Inductive Hypothesis Inductive Step Conclusion

5 Steps To Inductive Proofs In English Proof: 1. “We will show that P(n) is true for every n ≥ 0 by Induction.” 2. “Base Case:” Prove P(0) 3. “Inductive Hypothesis:” Assume P(k) is true for some arbitrary integer k ≥ 0” 4. “Inductive Step:” Want to prove that P(k+1) is true: Use the goal to figure out what you need. Make sure you are using I.H. and point out where you are using it. (Don’t assume P(k+1) !!) 5. “Conclusion: Result follows by induction”

What can we say about 1 + 2 + 4 + 8 + … + 2n 1 = 1 1 + 2 = 3 1 + 2 + 4 = 7 1 + 2 + 4 + 8 = 15 1 + 2 + 4 + 8 + 16 = 31 Can we describe the pattern? 1 + 2 + 4 + … + 2n = 2n+1 – 1

We could try proving it normally… Proving 1 + 2 + 4 + … + 2n = 2n+1 – 1 We could try proving it normally… We want to show that 1 + 2 + 4 + … + 2n = 2n+1. So, what do we do now? We can sort of explain the pattern, but that’s not a proof… We could prove it for n=1, n=2, n=3, …(individually), but that would literally take forever…

5 Steps To Inductive Proofs In English Proof: 1. “We will show that P(n) is true for every n ≥ 0 by Induction.” 2. “Base Case:” Prove P(0) 3. “Inductive Hypothesis:” Assume P(k) is true for some arbitrary integer k ≥ 0” 4. “Inductive Step:” Want to prove that P(k+1) is true: Use the goal to figure out what you need. Make sure you are using I.H. and point out where you are using it. (Don’t assume P(k+1) !!) 5. “Conclusion: Result follows by induction”

Proving 1 + 2 + … + 2n = 2n+1 – 1 Examples to show its true P(0) P(k)  P(k+1)

Proving 1 + 2 + … + 2n = 2n+1 – 1 Let P(n) be “1 + 2 + … + 2n = 2n+1 – 1”. We will show P(n) is true for all natural numbers by induction. Base Case (n=0): 20 = 1 = 2 – 1 = 20+1 – 1 Induction Hypothesis: Suppose that P(k) is true for some arbitrary k ≥ 0. Induction Step: Goal: Show P(k+1), i.e. show 1 + 2 + … + 2k + 2k+1 = 2k+2 – 1 1 + 2 + … + 2k = 2k+1 – 1 by IH Adding 2k+1 to both sides, we get: 1 + 2 + … + 2k + 2k+1 = 2k+1 + 2k+1 – 1 Note that 2k+1 + 2k+1 = 2(2k+1) = 2k+2. So, we have 1 + 2 + … + 2k + 2k+1 = 2k+2 – 1, which is exactly P(k+1). 5. Thus P(k) is true for all k ∈ℕ, by induction. Examples to show its true P(0) P(k)  P(k+1)

Another example of a pattern 20 − 1 = 1 − 1 = 0 = 3⋅0 22 − 1 = 4 − 1 = 3 = 3⋅1 24 − 1 = 16 − 1 = 15 = 3⋅5 26 − 1 = 64 − 1 = 63 = 3⋅21 28 − 1 = 256 − 1 = 255 = 3⋅85 …

Prove: 3 | 22n – 1 for all n ≥ 0 Examples to show its true P(0) P(k)  P(k+1)

For all n≥1: 1+2+⋯+𝑛= 𝑖=1 𝑛 𝑖 = 𝑛 𝑛+1 2