Introduction to CS Theory Lecture 2 – Discrete Math Revision Piotr Faliszewski

Slides:



Advertisements
Similar presentations
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
Advertisements

Primitive Recursive Functions (Chapter 3)
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Discrete Mathematics Math 6A Homework 9 Solution.
Recursive Definitions and Structural Induction
Recursively Defined Functions
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
UCI ICS/Math 6D5-Recursion -1 Strong Induction “Normal” Induction “Normal” Induction: If we prove that 1) P(n 0 ) 2) For any k≥n 0, if P(k) then P(k+1)
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
CSE115/ENGR160 Discrete Mathematics 03/31/11
1 Section 3.4 Recursive Definitions. 2 Recursion Recursion is the process of defining an object in terms of itself Technique can be used to define sequences,
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Introduction to CS Theory Lecture 1 – Introduction Piotr Faliszewski
Recursive Definitions and Structural Induction
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Week #7 – 7/9/11 October 2002 Prof. Marie desJardins
Chapter 4: Induction and Recursion
CSE 311 Foundations of Computing I Lecture 15 Recursive Definitions and Structural Induction Autumn 2011 CSE 3111.
Chapter 1 Introduction. Goals Why the choice of algorithms is so critical when dealing with large inputs Basic mathematical background Review of Recursion.
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
CSE 311 Foundations of Computing I Lecture 16 Recursively Defined Sets and Structural Induction Spring
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Lecture 3.4: Recursive Algorithms CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.
Mathematical Induction I Lecture 4: Sep 16. This Lecture Last time we have discussed different proof techniques. This time we will focus on probably the.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
Chap 3 –A theorem is a statement that can be shown to be true –A proof is a sequence of statements to show that a theorem is true –Axioms: statements which.
1 Lecture 3.3: Recursion CS 250, Discrete Structures, Fall 2012 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
1 CMSC 341 Math Review. 2 Exponents Identities (X A ) B = X AB X A * X B = X A+B X A / X B = X A-B X A + X B  X A+B.
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
More Induction Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois 1 A Pork-Butchers Shop Seen from a Window Van Gogh.
03/05/13 More Induction Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Artist: Frank.
9/29/2011Lecture Strong Induction1 Lecture 3.2: Strong Induction CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures.
6/12/2016 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(2) Mathematical Induction & Recursion Dr.Saad Alabbad Department of.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
1 Recursive Definitions and Structural Induction CS/APMA 202 Rosen section 3.4 Aaron Bloomfield.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
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.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
(Proof By) Induction Recursion
Chapter 4: Induction and Recursion
CS2210:0001Discrete Structures Induction and Recursion
Induction and Recursion
Recursively Defined Functions
Mathematical Induction Recursion
Chapter 5 Induction and Recursion
Discrete Structures for Computer Science
CS 250, Discrete Structures, Fall 2011 Nitesh Saxena
Applied Discrete Mathematics Week 9: Integer Properties
CS 250, Discrete Structures, Fall 2015 Nitesh Saxena
CS 250, Discrete Structures, Fall 2014 Nitesh Saxena
Discrete Mathematics and its Applications
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
CSE 311 Foundations of Computing I
Discrete Mathematics and its Applications
Recursion.
Presentation transcript:

Introduction to CS Theory Lecture 2 – Discrete Math Revision Piotr Faliszewski

Previous Class  The course Logistics Problems we study  What is computation?  What problems do we solve?  Languages Alphabet String Operations on strings Operations on languages  Mathematical background Discrete mathematics Inductive proofs

Inductive Proofs  Theorem statement P(k) – some predicate about an integer k Theorem: P(k) holds for every integer k  Induction base P(0) holds  Inductive step Hypothesis: There is a value k such that P(k) holds Step: P(k+1) holds.  Example: Prove that … + 2 n-1 = 2 n -1  Proof P(k) = [ … +2 k-1 = 2 k -1] Induction base 1 = Inductive step Hypothesis: There is a value k such that … +2 k-1 = 2 k -1 Step: Show that if the hypothesis holds then … +2 k = 2 k+1 -1

Strong Mathematical Induciton  Inductive step: We were showing that P[k] => P[k+1] Often this is limiting  Strong mathematical induction We can use a stronger inductive step (P[0] and P[1] and … and P[k]) => P[k+1] This way we can rely on all “previous” results

Strong Mathematical Induciton  Strong mathematical induction (P[0] and P[1] and … and P[k]) => P[k+1] Theorem. Every positive natural number n ≥ 2 is either prime or is a multiplication of several primes Proof. By induction on n. Base: n = 2.  2 is a prime, so theorem holds. Inductive step: Hypothesis: There is number k such that each number k’ ≤ k is either prime or can be factored into several primes Step: k+1 is either prime or a multiplication of several primes Consider cases a) k + 1 is prime  then we are done b) k + 1 is not a prime, thus k+1 = ab, where a and b are two positive integers. Our hypothesis applies to both a and b. Thus, the theorem holds for k+1.

Is Induction Really Correct?  Exercise: Prove that 2 n ≤ n!  Exercise: Prove that all horses are af the same color! A proof by induction.  Base step holds  Inductive step holds  Eh…?! Math is always right, so if you ever saw two horses of different colors then you are inconsistent with mathematics!

Is Induction Really Correct?  Exercise: Prove that 2 n ≤ n!  Exercise: Prove that all horses are af the same color! A proof by induction.  Base step holds  Inductive step holds NOT Oops! Be Very Careful with Induction!!!

Recursive Definitions  Recursive definition Define a small set of basic entities Show how to obtain larger ones from those already constructed A bit like induction! Examples Factorial 0! = 1 For each natural n, (n+1)! = (n+1)*n! Recursive definition of Σ * : 1.ε  Σ * 2.If x  Σ * and a  Σ then xa  Σ * 3.Nothing is in Σ * unless it is obtained by the two previous rules.

Recursive Definitions – Fibonacci Sequence  Fibonacci sequence f(0) = 0 f(1) = 1 For every n > 1: f(n+1) = f(n) + f(n-1)  Computing Fibonacci numbers Bottom-up Top-down  Exercise Show that for each natural n it holds that f(n) ≤ (5/3) n Show that 1 + ∑ 0 ≤ i ≤ n f i = f n+2

Recursive Definitions – Examples  Example Definition of |x| 1.|ε| = 0 2.|xa| = |x| + 1, for each x  Σ * and a  Σ. What is |aab|? Prove that for each two strings it holds that |xy| = |x| + |y|  An exercise Give a recursive definition of a reverse of a string. (x r ) Compute a reverse of a string based on this definition Prove that for every string x, |x| = |x r |

Language of Palindromes  Palindromes A string is a palindrome if it reads the same backward and forward Let’s define a language of palindromes!  Language L of palindromes, Σ = {a, b}. 1.ε  L 2.If x  L then both axa and bxb belong to L. 3.Nothing belongs to L unless it is obtained by rules 1 and 2. Hmm… This looks wrong to me!

Recursive Definitions – Examples  Language L of all strings with as many 0s as 1s. (Σ = {0,1}) 1.ε  L 2.For any x in L it holds that each of: 0x1 1x0 01x 10x x01 x10 belongs to L. Is this definition correct?

Bribery Problem  Consider the following setting C – set of candidates V – set of voters Each voter votes for one candidate Candidates with most points win  Bribery For a unit price you can buy a voter We want to make our preferred candidate p win How to do this most cheaply?  Example c1c1 c2c2 c3c3 p

Bribery Problem  Consider the following setting C – set of candidates V – set of voters Each voter votes for one candidate Candidates with most points win  Bribery For a unit price you can buy a voter We want to make our preferred candidate p win How to do this most cheaply?  Example c1c1 c2c2 c3c3 p

Bribery Problem  Consider the following setting C – set of candidates V – set of voters Each voter votes for one candidate Candidates with most points win  Bribery For a unit price you can buy a voter We want to make our preferred candidate p win How to do this most cheaply?  Example c1c1 c2c2 c3c3 p

Bribery Problem  Consider the following setting C – set of candidates V – set of voters Each voter votes for one candidate Candidates with most points win  Bribery For a unit price you can buy a voter We want to make our preferred candidate p win How to do this most cheaply?  Example c1c1 c2c2 c3c3 p

Bribery Problem  Consider the following setting C – set of candidates V – set of voters Each voter votes for one candidate Candidates with most points win  Bribery For a unit price you can buy a voter We want to make our preferred candidate p win How to do this most cheaply?  Example c1c1 c2c2 c3c3 p

Bribery Problem  Consider the following setting C – set of candidates V – set of voters Each voter votes for one candidate Candidates with most points win  Bribery For a unit price you can buy a voter We want to make our preferred candidate p win How to do this most cheaply?  Example  Proof of correctness? Induction! On what?  On the cost of the optimal solution! c1c1 c2c2 c3c3 p

Tournament Problem  Tournament A directed graph There is a single edge between any two vertices Vertices – players Edges – results of games (arrow points to the loser)  Example

Tournament Problem  Tournament Vertices – players Edges – results of games (arrow points to the loser)  Problem: We want to pick a team of players, who jointly defeat everyone How can we pick such a set? How large a set do we need?  Example

Tournament Problem  Algorithm Input: Tournament T Pick player u who defeats most players Form tournament T’ via removing T and all the players he/she defeats. If T’ is an empty graph the finish. Else, loop back using T’ instead of T  Questions Does this algorithm work? How large a set does it find? How to prove this?