Course objectives We will focus on two major goals:

Slides:



Advertisements
Similar presentations
Introduction to Proofs
Advertisements

Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Mathematics Lecture 4 Harper Langston New York University.
1 Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2011 Suprakash Datta Office: CSEB 3043 Phone: ext
Methods of Proof & Proof Strategies
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
MATH 224 – Discrete Mathematics
Review I Rosen , 3.1 Know your definitions!
CSci 2011 Discrete Mathematics Lecture 6
10/17/2015 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(1) Dr.Saad Alabbad Department of Computer Science
CSE 311 Foundations of Computing I Lecture 8 Proofs and Set Theory Spring
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
1 Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2011 Suprakash Datta Office: CSEB 3043 Phone: ext
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
DISCRETE COMPUTATIONAL STRUCTURES
Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems or solving problems, creativity and insight.
CS201: Data Structures and Discrete Mathematics I
MATH 224 – Discrete Mathematics
CompSci 102 Discrete Math for Computer Science
1/10/ Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007 Suprakash Datta Office: CSEB 3043 Phone:
Mathematical Preliminaries
CSE 311 Foundations of Computing I Lecture 9 Proofs and Set Theory Autumn 2012 CSE
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Chapter 2 With Question/Answer Animations. Section 2.1.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
CSci 2011 Discrete Mathematics Lecture 4 CSci 2011.
CS104:Discrete Structures Chapter 2: Proof Techniques.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
Chapter 1 Logic and proofs
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2010 Most slides modified from Discrete Mathematical Structures: Theory and Applications by D.S. Malik.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Harper Langston New York University Summer 2017
The Foundations: Logic and Proofs
Chapter 2 Sets and Functions.
Discrete Mathematics Lecture 3 (and 4)
Advanced Algorithms Analysis and Design
CSE15 Discrete Mathematics 02/08/17
CSE15 Discrete Mathematics 01/23/17
CS 2210:0001 Discrete Structures Sets and Functions
Methods of proof Section 1.6 & 1.7 Wednesday, June 20, 2018
6/20/2018 Arab Open University Faculty of Computer Studies M131 - Discrete Mathematics 6/20/2018.
Chapter 1 Logic and Proofs Homework 2 Given the statement “A valid password is necessary for you to log on to the campus server.” Express the statement.
(CSC 102) Discrete Structures Lecture 2.
MATH 224 – Discrete Mathematics
Predicate Calculus Validity
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Propositional Calculus: Boolean Algebra and Simplification
CS100: Discrete structures
The Foundations: Logic and Proofs
Lesson 5 Relations, mappings, countable and uncountable sets
CHAPTER 1: LOGICS AND PROOF
CS201: Data Structures and Discrete Mathematics I
CSE 311: Foundations of Computing
A Brief Summary for Exam 1
First Order Logic Rosen Lecture 3: Sept 11, 12.
Lesson 5 Relations, mappings, countable and uncountable sets
MA/CSSE 474 More Math Review Theory of Computation
Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007
Foundations of Discrete Mathematics
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
CS201: Data Structures and Discrete Mathematics I
Presentation transcript:

Course objectives We will focus on two major goals: Basic tools and techniques in discrete mathematics Propositional logic Set Theory Simple algorithms Induction, recursion Counting techniques (Combinatorics) Precise and rigorous mathematical reasoning Writing proofs 1

To do well you should: Study with pen and paper Ask for help immediately Practice, practice, practice… Follow along in class rather than take notes Ask questions in class Keep up with the class Read the book, not just the slides 2

Reasoning about problems 0.999999999999999….=1? There exists integers a,b,c that satisfy the equation a2+b2 = c2 The program below that I wrote works correctly for all possible inputs….. The program that I wrote never hangs (i.e. always terminates)… 3

Tools for reasoning: Logic Ch. 1: Introduction to Propositional Logic Truth values, truth tables Boolean logic:    Implications:   4

Why study propositional logic? A formal mathematical “language” for precise reasoning. Start with propositions. Add other constructs like negation, conjunction, disjunction, implication etc. All of these are based on ideas we use daily to reason about things. 5

Propositions Declarative sentence Must be either True or False. York University is in Toronto York University is in downtown Toronto All students at York are Computer Sc. majors. Not propositions: Do you like this class? There are x students in this class. 6

Propositions - 2 Truth value: True or False Variables: p,q,r,s,… Negation: p (“not p”) Truth tables p p T F 7

Caveat: negating propositions p: “it is not the case that p is true” p: “it rained more than 20 inches in TO” p: “John has many iPads” Practice: Questions 1-7 page 12. Q10 (a) p: “the election is decided” 8

Conjunction, Disjunction Conjunction: p  q [“and”] Disjunction: p  q [“or”] p q p  q p  q T F 9

Examples Q11, page 13 p: It is below freezing q: It is snowing It is below freezing and snowing It is below freezing but now snowing (d) It is either snowing or below freezing (or both) 10

Exclusive OR (XOR) p  q – T if p and q have different truth values, F otherwise Colloquially, we often use OR ambiguously – “an entrée comes with soup or salad” implies XOR, but “students can take MATH XXXX if they have taken MATH 2320 or MATH 1019” usually means the normal OR (so a student who has taken both is still eligible for MATH XXXX). 11

Conditional p  q [“if p then q”] p: hypothesis, q: conclusion E.g.: “If you turn in a homework late, it will not be graded”; “If you get 100% in this course, you will get an A+”. TRICKY: Is p  q TRUE if p is FALSE? YES!! Think of “If you get 100% in this course, you will get an A+” as a promise – is the promise violated if someone gets 50% and does not receive an A+? 12

Note the truth table of  p  q Conditional - 2 p  q [“if p then q”] Truth table: p q p  q  p  q T F Note the truth table of  p  q 13

Logical Equivalence p  q and  p  q are logically equivalent Truth tables are the simplest way to prove such facts. We will learn other ways later. 14

Contrapositive Contrapositive of p  q is q  p Any conditional and its contrapositive are logically equivalent (have the same truth table) – Check by writing down the truth table. E.g. The contrapositive of “If you get 100% in this course, you will get an A+” is “If you do not get an A+ in this course, you did not get 100%”. 15

E.g.: Proof using contrapositive Prove: If x2 is even, x is even Proof 1: x2 = 2a for some integer a. Since 2 is prime, 2 must divide x. Proof 2: if x is not even, x is odd. Therefore x2 is odd. This is the contrapositive of the original assertion. 16

Converse Converse of p  q is q  p Not logically equivalent to conditional Ex 1: “If you get 100% in this course, you will get an A+” and “If you get an A+ in this course, you scored 100%” are not equivalent. Ex 2: If you won the lottery, you are rich. 17

Other conditionals Inverse: inverse of p  q is p  q How is this related to the converse? Biconditional: “If and only if” True if p,q have same truth values, false otherwise. Q: How is this related to XOR? Can also be defined as (p  q)  (q  p) 18

Example Q16(c) 1+1=3 if and only if monkeys can fly. 19

Readings and notes Read pages 1-12. Think about the notion of truth tables. Master the rationale behind the definition of conditionals. Practice translating English sentences to propositional logic statements. 20

Next Ch. 1.2, 1.3: Propositional Logic - contd Compound propositions, precedence rules Tautologies and logical equivalences Read only the first section called “Translating English Sentences” in 1.2. 21

Compound Propositions Example: p  q  r : Could be interpreted as (p  q)  r or p  (q  r) precedence order:      (IMP!) (Overruled by brackets) We use this order to compute truth values of compound propositions. 22

Tautology A compound proposition that is always TRUE, e.g. q  q Logical equivalence redefined: p,q are logical equivalences if p  q is a tautology. Symbolically p  q. Intuition: p  q is true precisely when p,q have the same truth values. 23

Manipulating Propositions Compound propositions can be simplified by using simple rules. Read page 25 - 28. Some are obvious, e.g. Identity, Domination, Idempotence, double negation, commutativity, associativity Less obvious: Distributive, De Morgan’s laws, Absorption 24

Distributive Laws p  (q  r)  (p  q)  (p  r) Intuition (not a proof!) – For the LHS to be true: p must be true and q or r must be true. This is the same as saying p and q must be true or p and r must be true. p  (q  r)  (p  q)  (p  r) Intuition (less obvious) – For the LHS to be true: p must be true or both q and r must be true. This is the same as saying p or q must be true and p or r must be true. Proof: use truth tables. 25

De Morgan’s Laws (q  r)  q  r (q  r)  q  r Intuition – For the LHS to be true: neither q nor r can be true. This is the same as saying q and r must be false. (q  r)  q  r Intuition – For the LHS to be true: q  r must be false. This is the same as saying q or r must be false. Proof: use truth tables. 26

Using the laws Q: Is p  (p  q) a tautology? Can use truth tables Can write a compound proposition and simplify 27

Limitations of Propositional Logic What can we NOT express using predicates? Ex: How do you make a statement about all even integers? If x >2 then x2 >4 A more general language: Predicate logic (Sec 1.4) 28

Next: Predicate Logic Ch 1.4 Predicates and quantifiers Rules of Inference 29

Predicate Logic A predicate is a proposition that is a function of one or more variables. E.g.: P(x): x is an even number. So P(1) is false, P(2) is true,…. Examples of predicates: Domain ASCII characters - IsAlpha(x) : TRUE iff x is an alphabetical character. Domain floating point numbers - IsInt(x): TRUE iff x is an integer. Domain integers: Prime(x) - TRUE if x is prime, FALSE otherwise. 30

Quantifiers describes the values of a variable that make the predicate true. E.g. x P(x) Domain or universe: range of values of a variable (sometimes implicit) 31

Two Popular Quantifiers Universal: x P(x) – “P(x) for all x in the domain” Existential: x P(x) – “P(x) for some x in the domain” or “there exists x such that P(x) is TRUE”. Either is meaningless if the domain is not known/specified. Examples (domain real numbers) x (x2 >= 0) x (x >1) (x>1) (x2 > x) – quantifier with restricted domain 32

Aside: summation notation Using Quantifiers Domain integers: Using implications: The cube of all negative integers is negative. x (x < 0) (x3 < 0) Expressing sums : n n ( i = n(n+1)/2) i=1 Aside: summation notation 33

Scope of Quantifiers   have higher precedence than operators from Propositional Logic; so x P(x)  Q(x) is not logically equivalent to x (P(x)  Q(x))  x (P(x)  Q(x))  x R(x) Say P(x): x is odd, Q(x): x is divisible by 3, R(x): (x=0) (2x >x) Logical Equivalence: P  Q iff they have same truth value no matter which domain is used and no matter which predicates are assigned to predicate variables. 34

Negation of Quantifiers “There is no student who can …” “Not all professors are bad….” “There is no Toronto Raptor that can dunk like Vince …”  x P(x)   x P(x) why?   x P(x)   x P(x) Careful: The negation of “Every Canadian loves Hockey” is NOT “No Canadian loves Hockey”! Many, many students make this mistake! 35

Nested Quantifiers Allows simultaneous quantification of many variables. E.g. – domain integers,  x  y  z x2 + y2 = z2 n  x  y  z xn + yn = zn (Fermat’s Last Theorem) Domain real numbers: x  y  z (x < z < y)  (y < z < x) Is this true? 36

Nested Quantifiers - 2 x y (x + y = 0) is true over the integers Assume an arbitrary integer x. To show that there exists a y that satisfies the requirement of the predicate, choose y = -x. Clearly y is an integer, and thus is in the domain. So x + y = x + (-x) = x – x = 0. Since we assumed nothing about x (other than it is an integer), the argument holds for any integer x. Therefore, the predicate is TRUE. 37

Nested Quantifiers - 3 Caveat: In general, order matters! Consider the following propositions over the integer domain: x y (x < y) and y x (x < y) x y (x < y) : “there is no maximum integer” y x (x < y) : “there is a maximum integer” Not the same meaning at all!!! 38

Course page: http://www.cse.yorku.ca/course/1019 Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2011 Suprakash Datta datta@cse.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cse.yorku.ca/course/1019 39 39

Last class: quick recap Sections 1.1 -- 1.3 Why logic? Why Propositional logic? What is a proposition? Tautology, contradiction Manipulating propositions –not, and, or, implication, biconditional Truth tables Propositional equivalences Table 6 (page 27) 40

Last class: quick recap – contd. Sections 1.4 -- 1.5: Predicate logic Why Predicate logic? What is a predicate? Translating English sentences to predicates Negation of quantifiers 41

Translation into predicates “All students in this class are from FSE” “There are digital media majors in this class” “Every student has a smartphone or has a friend that owns a smartphone” “There are no students in this class that does not send text messages daily” 42

Scope of Quantifiers   have higher precedence than operators from Propositional Logic; so x P(x)  Q(x) x (P(x)  Q(x)) Use brackets E.g.  x (P(x)  Q(x))  x R(x) Say P(x): x is odd, Q(x): x is divisible by 3, R(x): (x=0) (2x >x) / 43

Negation of Quantifiers Consider the statement Q: x P(x) where P(x) is a given predicate over a given domain. What does “Q is false” mean? Similarly what does “ x P(x) is false” mean? 44

Negation of Quantifiers - contd  x P(x)   x P(x)   x P(x)   x P(x) E.g.: “There is no student who can …” “Not all professors are bad” “There is no Toronto Raptor that can dunk like Vince …” Caution: The negation of “Every Canadian loves Hockey” is NOT “No Canadian loves Hockey”! Many, many students make this mistake! 45

Allows simultaneous quantification of many variables. Nested Quantifiers Allows simultaneous quantification of many variables. E.g. – domain positive integers,  x  y  z x2 + y2 = z2 n>2  x  y  z xn + yn = zn (Fermat’s Last Theorem) Domain real numbers: x y z (x < z < y)  (y < z < x) x y z (x=y) (x < z < y)  (y < z < x) x y z (xy) (x < z < y)  (y < z < x) Is it true? 46

x y (x + y = 0) is true over the integers Nested Quantifiers - 2 x y (x + y = 0) is true over the integers Proof: Assume an arbitrary integer x. To show that there exists a y that satisfies the requirement of the predicate, choose y = -x. Clearly y is an integer, and thus is in the domain. So x + y = x + (-x) = x – x = 0. Since we assumed nothing about x (other than it is an integer), the argument holds for any integer x. Therefore, the predicate is TRUE. 47

p,j have different domains Nested Quantifiers - 3 Analogy: quantifiers are like loops: An inner quantified variable can depend on the outer quantified variable. E.g. in x y (x + y = 0) we chose y=-x, so for different x we need different y to satisfy the statement. p j Accept (p,j) does NOT say that there is a j that will accept all p. p,j have different domains 48

x y (x < y) and y x (x < y) Nested Quantifiers - 4 Caution: In general, order matters! Consider the following propositions over the integer domain: x y (x < y) and y x (x < y) x y (x < y) : “there is no maximum integer” y x (x < y) : “there is a maximum integer” Not the same meaning at all!!! 49

Negation of Nested Quantifiers Use the same rule as before carefully. Ex 1:  x y (x + y = 0) This is equivalent to x y (x + y = 0) This is equivalent to x  y (x + y = 0) This is equivalent to x  y (x + y  0) Ex 2: x y (x < y) This is equivalent to x y (x < y) This is equivalent to x y (x < y) This is equivalent to x y (x  y) 50

Logical Equivalence of statements Page 45: P  Q if and only if they have same truth value no matter which domain is used and no matter which predicates are assigned to predicate variables. 51

Truth tables may not help Domain may be infinite (e.g. integers) How to prove  Truth tables may not help Domain may be infinite (e.g. integers) Prove each direction separately Use intuitive ideas (example 19 on page 45). 52

Proof and counterexamples To prove a statement of the form x P(x) it is not enough to show that P(a) is true for one or some a’s. To show that a statement of the form x P(x) is FALSE, it is enough to show that P(a) is false for one a (“counterexample”). To prove a statement of the form  x P(x) it is enough to show that P(a) is true for one a. 53

Exercises Check that: x y (x + y = 0) is not true over the positive integers. x y (x + y = 0) is not true over the integers. x  0 y (y = 1/x) is true over the real numbers. 54

Readings and problems Read 1.4-1.5. Practice: Q2,8,16,30 (pg 65-67) Next: Rules of inference (1.6). 55

Inference rules Recall: the reason for studying logic was to formalize derivations and proofs. How can we infer facts using logic? Let’s start with Propositional logic. 56

Inference rules - 2 Simple inference rule (Modus Ponens) : From (a) p  q and (b) p is TRUE, we can infer that q is TRUE. Example: (a) if these lecture slides (ppt) are online then you can print them out (b) these lecture slides are online Similarly, From p  q, q  r and p is TRUE, we can infer that r is TRUE. 57

Inference rules - 3 ((p  q)  p )  q is a TAUTOLOGY. Modus Tollens, Hypothetical syllogism and disjunctive syllogism can be seen as alternative forms of Modus Ponens Other rules like “From p is true we can infer p  q” are very intuitive 58

Inference rules - 4 q  r ((p  q)  ( p  r))  (q  r) Resolution: From (a) p  q and (b)  p  r, we can infer that q  r Exercise: check that ((p  q)  ( p  r))  (q  r) is a TAUTOLOGY. Very useful in computer generated proofs. 59

Inference rules - 5 Read rules on page 72. Understanding the rules is crucial, memorizing is not. You should be able to see that the rules make sense and correspond to our intuition about formal reasoning. 60

Inference rules for quantified statements Very intuitive, e.g. Universal instantiation – If x P(x) is true, we infer that P(a) is true for any given a E.g.: Universal Modus Ponens: x P(x)  Q(x) and P(a) imply Q(a) If x is odd then x2 is odd, a is odd. So a2 is odd. 61

Inference rules for quantified statements-2 Read rules on page 76 Again, understanding is required, memorization is not. 62

Aside: Inference and Planning The steps in an inference are useful for planning an action. Example: your professor has assigned reading from an out-of-print book. How do you do it? Example 2: you are participating in the television show “Amazing race”. How do you play? 63

Aside 2: Inference and Automatic Theorem-Proving The steps in an inference are useful for proving assertions from axioms and facts. Why is it important for computers to prove theorems? Proving program-correctness Hardware design Data mining ….. 64

Aside 2: Inference and Automatic Theorem-Proving – contd. Sometimes the steps of an inference (proof) are useful. E.g. on Amazon book recommendations are made. You can ask why they recommended a certain book to you (reasoning). 65

Next Introduction to Proofs (Sec 1.7) What is a (valid) proof? Why are proofs necessary? 66

Introduction to Proof techniques Why are proofs necessary? What is a (valid) proof? What details do you include/skip? “Obviously”, “clearly”… 67

Assertions Axioms Proposition, Lemma, Theorem Corollary Conjecture 68

Logic-based proof Every step should follow from axioms or previous step(s) using an inference rule. Problems: Axiomatization is hard and often long (see Appendix 1) Proofs are often very long and tedious Intuitive proofs : 69

Types of Proofs Direct proofs (including Proof by cases) Proof by contraposition Proof by contradiction Proof by construction Proof by Induction Other techniques 70

Direct Proofs The average of any two primes greater than 2 is an integer. Every prime number greater than 2 can be written as the difference of two squares, i.e. a2 – b2. 71

Proof by cases If n is an integer, then n(n+1)/2 is an integer Case 1: n is even. or n = 2a, for some integer a So n(n+1)/2 = 2a*(n+1)/2 = a*(n+1), which is an integer. Case 2: n is odd. n+1 is even, or n+1 = 2a, for an integer a So n(n+1)/2 = n*2a/2 = n*a, 72

Proof by contraposition If (pq)  (p+q)/2, then p  q Direct proof left as exercise Contrapositive: If p = q, then (pq) = (p+q)/2 Easy: (pq) = (pp) = (p2) = p = (p+p)/2 = (p+q)/2. 73

Proof by contraposition- 2 Prove: If x2 is even, x is even Proof: if x is not even, x is odd. Therefore x2 is odd. This is the contrapositive of the original assertion. Note that the problem is to prove an implication. Universal generalization 74

Proof by Contradiction 2 is irrational Suppose 2 is rational. Then 2 = p/q, such that p, q have no common factors. Squaring and transposing, p2 = 2q2 (even number) So, p is even (previous slide) Or p = 2x for some integer x So 4x2 = 2q2 or q2 = 2x2 So, q is even (previous slide) So, p,q are both even – they have a common factor of 2. CONTRADICTION. So 2 is NOT rational. Q.E.D. 75

Proof by Contradiction - 2 In general, start with an assumption that statement A is true. Then, using standard inference procedures infer that A is false. This is the contradiction. Recall: for any proposition p, p  p must be false 76

Existence Proofs There exists integers x,y,z satisfying x2+y2 = z2 Proof: x = 3, y = 4, z = 5. This is a constructive proof (produce an example). 77

Existence Proofs - 2 There exists irrational b,c, such that bc is rational (page 97) Nonconstructive proof: Consider 22. Two cases are possible: Case 1: 22 is rational – DONE (b = c = 2). Case 2: 22 is irrational – Let b = 22, c = 2. Then bc = (22)2 = (2)2*2 = (2)2 = 2 78

Uniqueness proofs E.g. the equation ax+b=0, a,b real, a0 has a unique solution. 79

The Use of Counterexamples All prime numbers are odd Every prime number can be written as the difference of two squares, i.e. a2 – b2. 80

Examples Show that if n is an odd integer, there is a unique integer k such that n is the sum of k-2 and k+3. Prove that there are no solutions in positive integers x and y to the equation 2x2 + 5y2 = 14. If x3 is irrational then x is irrational Prove or disprove – if x, y are irrational, x + y is irrational. 81

Alternative problem statements “show A is true if and only if B is true” “show that the statements A,B,C are equivalent” 82

Exercises Q8, 10, 26, 28 on page 91 83

What can we prove? The statement must be true We must construct a valid proof 84

The role of conjectures 3x+1 conjecture Game: Start from a given integer n. If n is even, replace n by n/2. If n is odd, replace n with 3n+1. Keep doing this until you hit 1. e.g. n=5  16  8  4  2  1 Q: Does this game terminate for all n? 85

Elegance in proofs Q: Prove that the only pair of positive integers satisfying a+b=ab is (2,2). Many different proofs exist. What is the simplest one you can think of? 86

Next Ch. 2: Introduction to Set Theory Set operations Functions Cardinality 87

Course page: http://www.cse.yorku.ca/course/1019 Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011 Suprakash Datta datta@cse.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cse.yorku.ca/course/1019 88 88

Last class: proofs Different techniques Proofs vs counterexamples (connections with quantifiers) 89

Uniqueness proofs E.g. the equation ax+b=0, a,b real, a0 has a unique solution. 90

The Use of Counterexamples All prime numbers are odd Every prime number can be written as the difference of two squares, i.e. a2 – b2. 91

The role of conjectures 3x+1 conjecture Game: Start from a given integer n. If n is even, replace n by n/2. If n is odd, replace n with 3n+1. Keep doing this until you hit 1. e.g. n=5  16  8  4  2  1 Q: Does this game terminate for all n? 92

Elegance in proofs Q: Prove that the only pair of positive integers satisfying a+b=ab is (2,2). Many different proofs exist. What is the simplest one you can think of? 93

More proof exercises If n+1 balls are distributed among n bins prove that at least one bin has more than 1 ball A game 94

Meaningful diagrams Pythagoras 95

Meaningful diagrams - 2 Sum of an arithmetic series (from http://www.tonydunford.com/images/math-and- geometry/sum-of-number-series/SumOfOdd.jpg) 96

Meaningful diagrams - 3 Sum of a geometric series (from http://math.rice.edu/~lanius/Lessons/Series/one.g if) 97

Meaningful diagrams - 4 1/4 + 1/16 + 1/64 + 1/256 + ... = 1/3 (from http://www.billthelizard.com/2009/07/six- visual-proofs_25.html) 98

Next Ch. 2: Introduction to Set Theory Set operations Functions Cardinality 99

Sets Unordered collection of elements, e.g., Equality of sets Single digit integers Nonnegative integers faces of a die sides of a coin students enrolled in 1019N, W 2007. Equality of sets Note: Connection with data types 100

Describing sets English description Set builder notation Note: The elements of a set can be sets, pairs of elements, pairs of pairs, triples, …!! Cartesian product: A x B = {(a,b)| a  A and b  B} 101

Sets of numbers Natural numbers Whole numbers Integers Rational numbers Real numbers Complex numbers Co-ordinates on the plane 102

Sets - continued Cardinality – number of (distinct) elements Finite set – cardinality some finite integer n Infinite set - a set that is not finite Special sets Universal set Empty set  (cardinality = ?) 103

Sets vs Sets of sets {1,2} vs {{1,},{2}} {} vs {{}} = {} 104

Similarly, P({}) = {, {}} Subsets A  B: x ( x  A  x  B) Theorem: For any set S,   S and S  S. Proper subset: A  B: x ( x  A  x  B)   x ( x  B  x  A) Power set P(S) : set of all subsets of S. P(S) includes S, . Tricky question – What is P() ? P() = {} Similarly, P({}) = {, {}} 105

Set operations Union – A  B = { x | (x  A)  (x  B)} Intersection - A  B = { x | (x  A)  (x  B)} Disjoint sets - A, B are disjoint iff A  B =  Difference – A – B = {x | (x  A)  (x  B)} Symmetric difference Complement – Ac or Ā = {x | x A} = U - A Venn diagrams 106

Laws of set operations Page 130 – notice the similarities with the laws for Boolean operators Remember De Morgan’s Laws and distributive laws. Proofs can be done with Venn diagrams. E.g.: (A  B) c = Ac  Bc Proofs via membership tables (page 131) 107

Cartesian products A x B 108

Introduction to functions A function from A to B is an assignment of exactly one element of B to each element of A. E.g.: Let A = B = integers, f(x) = x+10 Let A = B = integers, f(x) = x2 Not a function A = B = real numbers f(x) = x A = B = real numbers, f(x) = 1/x 109

Terminology A = Domain, B = Co-domain f: A  B (not “implies”) range(f) = {y|  x  A f(x) = y}  B int floor (float real){ … } f1 + f2, f1f2 One-to-one INJECTIVE Onto SURJECTIVE One-to-one correspondence BIJECTIVE 110

Operations with functions Inverse f-1(x)  1/f(x) f -1(y) = x iff f(x) = y Composition: If f: A  B, g: C  A, then f ° g: C  B, f°g(x) = f(g(x)) 111

Graphs of functions 112

Special functions All domains: identity (x) Note: f ° f –1 = f -1 ° f =  Integers: floor, ceiling, DecimalToBinary, BinaryToDecimal Reals: exponential, log 113

Special functions DecimalToBinary, BinaryToDecimal E.g. 7 = 1112 , 10012 = 9 BinaryToDecimal – n = 10012 : n = 1*23 + 0*22 +0*21 + 1*20 = 9 DecimalToBinary – n = 7: b1 = n rem 2 = 1, n = n div 2 = 3 b2 = n rem 2 = 1, n = n div 2 = 1 b3 = n rem 2 = 1, n = n div 2 = 0. STOP 114

Special functions – contd. Changing bases: In general need to go through the decimal representation E.g: 1017 = ?9 1017 = 1*72 +0*71 + 1*70 = 50 Decimal to Base 9: d1 = n rem 9 = 5, n = n div 9 = 5 b2 = n rem 9 = 5, n = n div 9 = 0. STOP So 1017 = 559 115

Special functions – tricks Changing bases that are powers of 2: Can often use shortcuts. Binary to Octal: 10111101 = 2758 Binary to Hexadecimal: 10111101 = BD16 Hexadecimal to Octal: Go through binary, not decimal. 116

Sequences Finite or infinite Calculus – limits of infinite sequences (proving existence, evaluation…) E.g. Arithmetic progression (series) 1, 4, 7, 10, … Geometric progression (series) 3, 6, 12, 24, 48 … 117

Similarity with series S = a1 + a2 + a3 + a4 + ….. (n terms) Consider the sequence S1, S2, S3, … Sn, where Si = a1 + a2 + … + ai In general we would like to evaluate sums of series – useful in algorithm analysis. e.g. what is the total time spent in a nested loop? 118

Sums of common series Arithmetic series e.g. 1 + 2 + … + n (occurs in the analysis of running time of simple for loops) general form iti, ti= a + ib Geometric series e.g. 1 + 2 + 22 + 23 + … + 2n general form iti, ti= ari More general series (not either of the above) 12 + 22 + 32 + 42 + … + n2 119

Sums of common series - 2 Technique for summing arithmetic series Technique for summing geometric series More general series – more difficult 120

Caveats Need to be very careful with infinite series In general, tools from calculus are needed to know whether an infinite series sum exists. There are instances where the infinite series sum is much easier to compute and manipulate, e.g. geometric series with r < 1. 121

Cardinality revisited A set is finite (has finite cardinality) if its cardinality is some (finite) integer n. Two sets A,B have the same cardinality iff there is a one-to-one correspondence from A to B E.g. alphabet (lower case) a b c ….. 1 2 3 ….. 122

Infinite sets Why do we care? Cardinality of infinite sets Do all infinite sets have the same cardinality? 123

Countable sets Defn: Is finite OR has the same cardinality as the positive integers. Why do we care? E.g. The algorithm works for “any n” Induction! 124

Countable sets – contd. Proving this involves (usually) constructing an explicit bijection with positive integers. Fact (Will not prove): Any subset of a countable set is countable. Will prove that The rationals are countable! The reals are not countable 125

The integers are countable Write them as 0, 1, -1, 2, -2, 3, -3, 4, -4, …… Find a bijection between this sequence and 1,2,3,4,….. Notice the pattern: 1  0 2  1 So f(n) = n/2 if n even 3  -1 4  2 -(n-1)/2 o.w. 5  -2 6  3 126

Other simple bijections Odd positive integers 1  1 2  3 3  5 4  7 …. Union of two countable sets A, B is countable: Say f: N  A, g:N  B are bijections New bijection h: N  A  B h(n) = f(n/2) if n is even = g((n-1)/2) if n is odd. 127

The rationals are countable Show that Z+ x Z+ is countable. Trivial injection between Q+, Z+ x Z+. To go from Q+ to Q, use the trick used to construct a bijection from Z to Z+. Details on the board. 128

The reals are not countable Wrong proof strategy: Suppose it is countable Write them down in increasing order Prove that there is a real number between any two successive reals. WHY is this incorrect? (Note that the above “proof” would show that the rationals are not countable!!) 129

The reals are not countable - 2 Cantor diagonalization argument (1879) VERY powerful, important technique. Proof by contradiction. Sketch (details done on the board) - Assume countable - look at all numbers in the interval [0,1) - list them in ANY order - show that there is some number not listed 130

Notes The cardinality of neither the reals nor the integers are finite, yet one set is countable, the other is not. Q: Is there a set whose cardinality is “in-between”? Q: Is the cardinality of R the same as that of [0,1) ? 131