chapter 5 - set theory 1. basic definitions 2. empty set, partitions, power set 3. properties of...

380
Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Upload: preston-brooks

Post on 26-Dec-2015

230 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 5 - Set Theory

1. Basic Definitions

2. Empty Set, Partitions, Power Set

3. Properties of Sets

5.1.1

Page 2: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1. Basic Definitions

• A Set is a collection of items, called elements.

• {1, 2, 3}

• {x R | x2 > 5}

• S = {Tom, Sue, Jim}

5.1.2

Page 3: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

• We use ellipses to simplify things:

• {1, 2, 3, …, 10}

• {1, 2, 3, …}

• {…, -2, -1, 0, 1, 2, …}

• Be careful! ({1, 2, …}???)

5.1.3

Page 4: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

• We relate an item in the set with the set using the “(element of)” relation.

• x {x, y, z}

• {1, 2} {{1, 2}, {1, 2, 3}}.

5.1.4

Page 5: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Special Sets

• We refer to specific sets of numbers so often that we give them special names.

• These sets, and their corresponding symbols, will be referenced throughout this course.

5.1.5

Page 6: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Natural Numbers

• We define the Natural Numbers to be:

N = {0, 1, 2, 3, …}

• Note that the Naturals are “closed” under addition and multiplication.

5.1.6

Page 7: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Integers

• We define the Integers to be:

Z = {…, -2, -1, 0, 1, 2, 3, …}

• Note that Z is “closed” under addition, subtraction, and multiplication.

5.1.7

Page 8: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Rational Numbers

• We define the Rationals to be:

Q = {p/q | p,q Z and q 0}

• Note that Q is “closed” under addition, subtraction, multiplication, and non-zero division.

5.1.8

Page 9: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Rational Numbers

• Alternatively, we can view Q as the set of all infinite, repeating decimal expansions.

• 7.35 = 7.3500000… Q

• 1.234234234… Q

• However, Q

5.1.9

Page 10: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Irrational Numbers

• I = {all infinite, nonrepeating decimals}

• Obviously, irrational numbers are impossible to write down exactly.

• We use symbols to represent special values such as , e, and 2.

• The Irrationals are not closed under + or .

5.1.10

Page 11: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Real Numbers• R = {all decimal expansions}

• The Real Numbers are created by adjoining the Rationals with the Irrationals.

• The Reals are closed under all operations and satisfy the Field Axioms (see Appendix A, p. 695).

• The Reals form a continuum: we use the Real Number Line to represent this.

5.1.11

Page 12: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Complex Numbers• The Reals fall short when solving simple

polynomial equations like x2 + 1 = 0.

• The Complex Numbers patch this hole.

• C = {a + bi | a,b R and i = (1)}

• Use the Complex Plane to represent these numbers.

• The Complex Numbers are also a field.

5.1.12

Page 13: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Subsets• If A and B are sets, A is called a subset of

B, denoted A B, provided every element of A is an element of B.

• So, A B means x, if x A, then x B.

• We also say, “A is contained in B” or “B contains A” to show this relationship.

• Equivalently, we denote A B provided x x A and x B.

5.1.13

Page 14: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples of Subsets• If A = {1, 2, 3} and B = {0, 1, 2, 3, 4}, then

clearly A B.

• {{1}, {2}} {{1}, {2}, {1,2}}.

• Q R and Z Q and N Z.

• {a, b, c} is a proper subset of {a, b, c, d}.

• {a, b, c} is an improper subset of {a, b, c}.

• We denote interval subsets of R as[a, b) = {x R | a x b}. So [2, 5) [0,5].

5.1.14

Page 15: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Set Equality• We say sets A and B are equal (A = B) if

every element of A is in B and every element of B is in A.

• Thus, A = B means A B and B A.

• For example {1, 2, 3} = {1, 2, 3}, butA = {1, 2, 3} {1, 2, 3, 4} = B, since 4 B but 4 A.

• Also, [a, b) [a, b] since b is only in [a, b].

5.1.15

Page 16: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Operations on Sets• Given sets A and B, which are subsets of a

universal set, U, we define the following:

• (Union) A B = {x U | x A or x B}.

• (Intersection) A B = {x U | x A and x B}.

• (Difference or Relative Complement) A B = {x U | x A and x B}.

• (Complement) Ac = {x U | x A}.

• Note that Ac = U A.

5.1.16

Page 17: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples of Set Operations• Let U = R, A = [1, 3] and B = (2, 4).

• A B = [1, 4)

• A B = (2, 3]

• A B = [1, 2]

• B A = (3, 4)

• Ac = (, 1) (3, )

• Bc = (, 2] [4, )

5.1.17

Page 18: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Cartesian Products• Given two sets, A and B, we define the Cartesian

Product, A B = {(a, b) | a A and b B}.

• The element (a, b) is called an ordered pair, since (a, b) and (b, a) are distinct if a b.

• If A = {1, 2, 3} and B = {8, 9}, then:A B = {(1, 8), (1, 9), (2, 8), (2, 9), (3, 8), (3, 9)}B A = {(8, 1), (8, 2), (8, 3), (9, 1), (9, 2), (9, 3)}

5.1.18

Page 19: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalized Cartesian Products• Given three sets, A, B, and C, we define their

Cartesian Product byA B C = {(a, b, c) | a A, b B and c C}.

• Although similar, we note that A B C and (A B) C are not, technically, the same since one contains (a, b, c) and the other ((a, b), c).

• In general, we define A1A2A3...An to be{(a1,a2,a3,…,an) | a1A1,a2A2,a3A3,…, anAn}

5.1.19

Page 20: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Formal Languages

• Let be a finite set, which we will, henceforth, call an alphabet.

• A string of characters of the alphabet (or a string over ) is either: (1) an ordered n-tuple of elements of written without parentheses or commas, or (2) the null string , which has no characters.

5.1.20

Page 21: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Formal Languages (cont’d.)

• If , then 131221 is a string of length 6 over

• 131221 (1, 3, 1, 2, 2, 1)

• Clearly, the length of a string, s, over an alphabet , is the number of characters of that are in s.

• We denote the function L(s) to be this length.

• Hence, if = {0, 1}, then L(101100111) = 9.

5.1.21

Page 22: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Formal Languages (cont’d.)

• Any set of strings over an alphabet is called a formal language over the alphabet.

• Let be an alphabet and n N :

n = {strings over with L(s) = n};

n = {strings over with L(s) n};

* = {strings over of finite length}.

5.1.22

Page 23: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples

Let = {0, 1}:

3 = {000, 001, 010, 011, 100, 101, 110, 111}

3 = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111}

* = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, …, 000000, …, 111111, ...}.

5.1.23

Page 24: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 5.3

• The Empty Set

• Partitions

• Power Sets

• Boolean Algebras

5.3.24

Page 25: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Empty Set

• The unique set containing no elements is called the empty set, denoted or {}.

• Theorem: If A is a set, then A• Corollary: is unique.

• Why? Since and we conclude = .

5.3.25

Page 26: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Set Operations With • For any set A from a universal set U:

A = A = A

A Ac= A Ac= U

Uc= andc= U.

5.3.26

Page 27: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Partitions of a Set

• Two sets are called disjoint if they have no elements in common. That is, A and B are disjoint provided A B= .

• Theorem: If A and B are any sets, then (A B) and B are disjoint.

• A collection of sets {A1,A2,…,An} is called mutually or pairwise disjoint if Ai Aj = whenever i j.

5.3.27

Page 28: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Partitions of a Set (cont’d.)

• A collection of sets {A1,A2,…,An} is called a partition of a set A provided:

1. {A1,A2,…,An} is mutually disjoint;2. A1 A2 ... An = A.

• {{1, 2, 3},{4, 5},{6, 7, 8}} partitions?

• {{1,2,3,...},{-1,-2,-3,...},{0}} partitions?

• {Q, I} partitions?

5.3.28

Page 29: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Power Sets

• If A is a set, the Power Set of A, denoted P (A), is the set of all subsets of A.

• Since A, we conclude P (A), and AA implies A P (A).

• If A = {0,1}, P (A) = {{0},{1},{0,1}}

• Theorem: If A and B are sets with A B, then P (A) P (B).

• Theorem: If |A| = n, then | P (A) | = 2n.

5.3.29

Page 30: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Boolean Algebras• If A is a set, the collection {A, +, } is called

a Boolean Algebra if:

1. a,bA, a + b = b + a and a b = b a

2. a,b,cA, (a + b) + c = a + (b + c) and (a b) c = a (b c)

3. a,b,cA, a + (b c) = (a + b) (a + c) and a b +c) = (a b) + (a c)

4. ! 0,1A aA, a + 0 = a and a 1 = a

5. aA, bA a + b = 1 and a b = 0

5.3.30

Page 31: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 1. Symbolic Logic

• Logical Form and Equivalence

• Conditional Statements

• Valid and Invalid Arguments

• Digital Logic Circuits (Boolean Polynomials)

1.1.31

Page 32: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Logic of Compound Statements

• A statement (or proposition) is a sentence that is true (T) or false (F), but not both or neither.

• Examples:

Today is Monday.

x is even and x > 7.

If x2 = 4, then x = 2 or x = 2.

1.1.32

Page 33: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counterexamples

• If a sentence cannot be judged to be T or F or is not even a sentence, it cannot be a statement.

• Examples:

Open the door! (imperative)

Did you open the door? (interrogative)

If x2 = 4. (fragment)

1.1.33

Page 34: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Compound Statements

• Denote statements using the symbols p, q, r, ...

• Denote the operations ~, (to be defined shortly), where:

p q - conjunction of p and q (p and q);

p q - disjunction of p and q (p or q);

~ p - negation of p (not p);

p q - implication of p and q (p implies q);

1.1.34

Page 35: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Compound Statements (cont’d.)

• A Compound statement (or statement form) is a statement which includes at least one operation and one other “atomic” statement.

• For example, “x = 7 and y = 2” is a compound statement based on the “atomic” statements p = “x = 7” and q = “y = 2”.

• In this instance, we can symbolize the compound statement as r = p q.

1.1.35

Page 36: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Compound Statements (cont’d.)

• The Truth Table of a compound statement is the collection of all the output truth values corresponding to all possible combinations of input truth values of the atomic statements.

• Since each atomic statement can take on 1 of 2 values, 2 inputs have 4 combinations, 3 inputs have 8, 4 inputs have 16, 5 inputs have 32, etc.

1.1.36

Page 37: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Logical Operations

• Negation: p ~pT FF T

• Conjunction: • Disjunction:p q (p q) p q (p q)T T T T T TT F F T F TF T F F T TF F F F F F

1.1.37

Page 38: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example: (p q) ~r• Proceed from left to right:

p q r (p q) ~r (p q) ~r T T T T F FT T F T T TT F T T F FT F F T T TF T T T F FF T F T T TF F T F F FF F F F T F

1.1.38

Page 39: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Logical Equivalence• Two compound statements are logically

equivalent if they have the same truth table. We denote this as p q.

• p ~p ~(~p)T F TF T F hence p ~(~p).

• ~(p q) ~p ~q ?

No, since ~(T F) T, but (~T ~F) F.

1.1.39

Page 40: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Tautology & Contradiction

• A statement whose truth table is all “T” is called a tautology, denoted as p t.

• A statement whose truth table is all “F” is called a contradiction, denoted as p c.

• Clearly, ~t c and ~c t.

• Are all logical statements either tautology or contradiction?

1.1.40

Page 41: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Algebra of Symbolic Logic• Commutative Laws:

p q q pp q q p

• Associative Laws:

(p q) r p (q r)

(p q) r p (q r)

• Distributive Laws:

p (q r) (p q) (p r)

p (q r) (p q) (p r)

1.1.41

Page 42: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Algebra of Symbolic Logic

• Identity Laws:

p t p

p c p

• Negation Laws:

p ~p c

p ~p t

• Double Negative Laws: ~(~p) p

• Negations of t and c: ~t c ~c t

1.1.42

Page 43: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Algebra of Symbolic Logic

• Idempotent Laws: p p p p p p

• DeMorgan’s Laws:

~(p q) ~p ~q

~(p q) ~p ~q

• Universal Bound Laws: p c c p t t

• Absorption Laws:

p (p q) p

p (p q) p

1.1.43

Page 44: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1.2

• Conditional Statements

• Logical Equivalences Involving Conditionals

• Converses, Inverses, and Contrapositives

• Biconditional Statements

1.2.44

Page 45: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Conditional Statements

• If p and q are statement variables, the conditional or implication of q by p is “If p then q” or “p implies q” and is denoted by p q.

• The truth table of the implication operator is:p q p q

T T T

T F F

F T T

F F T

• Example: If you mow my lawn, I’ll pay $20.

1.2.45

Page 46: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Hypotheses & Conclusions

• In the form “If p then q” the statement p is called the hypothesis and the statement q is the conclusion.

• Conditionals form the basis of “deductive” reasoning. (Aristotilean Logic)

• In looking at the truth table, we consider the cases where the hypothesis is false to yield vacuous results. The interesting cases are when the hypothesis is true.

1.2.46

Page 47: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Logical Equivalences

• In the framework of symbolic logic, the implication operator would seem to be a new and distinct process.

• However, this is not the case!

• Theorem: p q ~p q.

• Thus, we can always rewrite an implication as a disjunction.

• Corollary: ~(p q) p ~q.

1.2.47

Page 48: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Negation of a Conditional

• From the previous corollary, the negation of p q is p ~q.

• For example, the negation of

If today is Sunday, then I wash my car.

is:

Today is Sunday and I do not wash my car.

1.2.48

Page 49: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Converse of a Conditional

• Given the statement p q, we define its converse to be the statement q p.

• For example, the converse of

If today is Sunday, then I wash my car.

is:

If I wash my car, then today is Sunday.

1.2.49

Page 50: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Contrapositive of a Conditional

• Given the statement p q, we define its contrapositive to be the statement ~q ~p.

• For example, the contrapositive of

If today is Sunday, then I wash my car.

is:

If I do not wash my car, then today is not Sunday.

1.2.50

Page 51: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inverse of a Conditional

• Given the statement p q, we define its inverse to be the statement ~p ~q.

• For example, the inverse of

If today is Sunday, then I wash my car.

is:

If today is not Sunday, then I do not wash my car.

1.2.51

Page 52: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Equivalent Forms

• Theorem: Given the statement p q, we have that p q ~q ~p.

• Corollary: Given the statement p q, we have that q p ~p ~q.

• Therefore from the above, we see that a conditional and its contrapositive are logically equivalent.

• Moreover, the statement’s converse and inverse forms are logically equivalent to each other.

1.2.52

Page 53: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Biconditional Statements

• Definition: Given the statement variables p and q, the biconditional of p and q is read, “p if and only if q,” denoted p q and means that both p q and q p .

• By direct calculation: p q p q

T T T

T F F

F T F

F F T

1.2.53

Page 54: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Using the Biconditional

• Looking closely at the truth table, we see that p q is T whenever p and q have the same truth value.

• Theorem: p q is a tautology implies p q and conversely, p q implies p q is a tautology.

• This gives us a systematic way to calculate logical equivalence, rather then just scan the matches of truth values by eye.

1.2.54

Page 55: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1.3

• Valid and invalid argument forms.

• Special valid argument forms.

• Dilemmas

• Fallacies.

• Contradictions and valid arguments.

1.3.55

Page 56: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Valid and Invalid Arguments

• An argument (or argument form) is a sequence of statements.

• All statements but the final one are called premises, assumptions, or hypotheses.

• The final statement is called the conclusion.

• An argument form is valid provided its conclusion is always true whenever all of its premises are true.

1.3.56

Page 57: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Valid and Invalid Arguments

• An argument (or argument form) is a sequence of statements.

• All statements but the final one are called premises, assumptions, or hypotheses.

• The final statement is called the conclusion.

• An argument form is valid provided its conclusion is always true whenever all of its premises are true.

• The truth of the conclusion follows inescapably from the truth of the hypotheses.

1.3.57

Page 58: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Testing for Validity• Identify the premises and conclusion.

• Construct a truth table for the premises and conclusion.

• Find the critical rows, where all premises are T.

• For each critical row, if the conclusion is also T, then the argument is valid.

• If at least one critical row leads to a conclusion being F, the argument is invalid.

• If there are no critical rows, the argument is vacuously valid.

1.3.58

Page 59: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Valid Argumentp (q r)

~r

(p q)

Truth Table: p q r [p (q r)] ~r (p q)T T T T F TT T F T T TT F T T F TT F F T T TF T T T F TF T F T T TF F T T F FF F F F T F

1.3.59

Page 60: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

An Invalid Argumentp (q r)

~r

(p r)

Truth Table: p q r [p (q r)] ~r (p r)T T T T F TT T F T T TT F T T F TT F F T T TF T T T F TF T F T T FF F T T F TF F F F T F

1.3.60

Page 61: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Special Argument FormsModus Ponens: p q

p

q

Truth Table: p q p q p qT T T T TT F F T FF T T F TF F T F F

Premises: If today is Sunday, then I was my car. Today is Sunday.

Conclusion: I wash my car.

1.3.61

Page 62: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Modus TollensModus Tollens: p q

~q

~p

Truth Table: p q p q ~q ~pT T T F FT F F T FF T T F TF F T T T

Premises: If today is Sunday, then I was my car. I do not wash my car.

Conclusion: Today is not Sunday.

1.3.62

Page 63: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Disjunctive AdditionDisjunctive Addition: p

p qTruth Table: p q p q

T T TT F TF T TF F F

Premise: Today is Sunday.Conclusion: Today is Sunday or I wash my car.

1.3.63

Page 64: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Conjunctive SimplificationConjunctive Simplification: p q p

also q

Truth Table: p q p qT T TT F FF T FF F F

Premise: Today is Sunday and I wash my car.Conclusion 1: Today is Sunday.Conclusion 2: I wash my car.

1.3.64

Page 65: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Disjunctive SyllogismDisjunctive Syllogism: p q p q~p ~q

q p

Truth Table: p q p q ~pT T T FT F T FF T T TF F F T

Premises: Today is Sunday or Saturday.Today is not Sunday.

Conclusion: Today is Saturday.

1.3.65

Page 66: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Hypothetical SyllogismHypothetical Syllogism: p q

q r

p rPremises: If x is an integer, then x is a rational.

If x is a rational, then x is a real.Conclusion: If x is an integer, then x is real.

1.3.66

Page 67: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Dilemma: Division Into CasesDilemma: p q

p r

q r

rPremises: x is positive or x is negative.

If x is positive , then x2 is positive.If x is negative, then x2 is positive.

Conclusion: x2 is positive.

1.3.67

Page 68: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Application: Find My Glasses1. If my glasses are on the kitchen table, then I saw them at

breakfast.

2. I was reading in the kitchen or I was reading in the living room.

3. If I was reading in the living room, then my glasses are on the coffee table.

4. I did not see my glasses at breakfast.

5. If I was reading in bed, then my glasses are on the bed table.

6. If I was reading in the kitchen, then my glasses are on the kitchen table.

1.3.68

Page 69: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Find My Glasses (cont’d.)

Let: p = My glasses are on the kitchen table.

q = I saw my glasses at breakfast.

r = I was reading in the living room.

s = I was reading in the kitchen.

t = My glasses are on the coffee table.

u = I was reading in bed.

v = My glasses are on the bed table.

1.3.69

Page 70: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Find My Glasses (cont’d.)

Then the original statements become:

1. p q 2. r s 3. r t

4. ~q 5. u v 6. s p

and we can deduce (why?):

1. p q 2. s p 3. r s 4. r t

~q ~p ~s r

~p ~s r t

Hence the glasses are on the coffee table!

1.3.70

Page 71: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Fallacies• A fallacy is an error in reasoning that

results in an invalid argument.

• Three common fallacies:– Using vague or ambiguous premises;

– Begging the question;

– Jumping to a conclusion.

• Two dangerous fallacies:– Converse error;

– Inverse error.

1.3.71

Page 72: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Converse ErrorIf Zeke cheats, then he sits in the back row.

Zeke sits in the back row.

Zeke cheats.

• The fallacy here is caused by replacing the impication (Zeke cheats sits in back) with its biconditional form (Zeke cheats sits in back), implying the converse (sits in back Zeke cheats).

1.3.72

Page 73: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inverse ErrorIf Zeke cheats, then he sits in the back row.

Zeke does not cheat.

Zeke does not sit in the back row.

• The fallacy here is caused by replacing the impication (Zeke cheats sits in back) with its inverse form (Zeke does not cheat does not sit in back), instead of the contrapositive (does not sit in back Zeke does not cheat).

1.3.73

Page 74: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Contradiction Rule• If you can show that assuming statement p

is false leads logically to a contradiction, then you can conclude that p is true.

• In argument form: ~p c p

• This is the logical heart of the proof method called Proof by Contradiction.

1.3.74

Page 75: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1.4• Digital Logic Circuits

• Boolean Polynomials

• Normal Forms (Disjunctive/Conjunctive)

• Designing Circuits with Specified Conditions

• Showing Two Circuits Are Equivalent

1.4.75

Page 76: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Digital Logic Circuits• Developed by Claude Shannon in 1938 to

model telephone switching circuits:

x y

Series Switch

x AND y

x

yParallel Switch

x OR y

1.4.76

Page 77: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Logical Gates• Instead of working with switches, we model

digital circuits using gates: AND-gates, OR-gates, and NOT-gates.

• We draw these as:

xy

x + yOR

xy

xyAND

x x’NOT

1.4.77

Page 78: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Notation• Modeling digital circuits leads to the

equivalent analysis of symbolic logic.

• Symbolic Logic Digital CircuitsT, t 1, 1F, c 0, 0p, q, r, ... x, y, z, ...~p x’p q xyp q x + y

1.4.78

Page 79: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Boolean Polynomials• When modeling, we use Boolean

polynomials to describe algebraically the function of a combinatorial circuit.

• A combinatorial circuit is one in which the output at any time depends on the inputs at the previous time. (i.e. no feedback loops)

• A Boolean polynomial is a function which takes 0,1 inputs and outputs a 0 or 1 using the operations AND, OR, and NOT.

1.4.79

Page 80: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples of Boolean Polynomials• When working with Boolean polynomials,

we must first know the specific input variables.

• Examples:

f(x,y,z) = x + y + z

f(x,y) = x’ + xy

f(x,y,z) = x(y + z’)

1.4.80

Page 81: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Evaluating Boolean Polynomials• Using: x y x’ y’ (x + y) xy

1 1 0 0 1 11 0 0 1 1 00 1 1 0 1 00 0 1 1 0 1

• Examples: Find f(x,y) = x’ + xy

x y x’ xy (x’ + xy)1 1 0 1 11 0 0 0 00 1 1 0 10 0 1 0 1

1.4.81

Page 82: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Normal Forms• Expressing a Boolean Polynomial in its

normal form provides an easy method to calculate its truth table.

• We can create two different normal forms for Boolean Polynomials: the disjunctive and the conjunctive normal form.

• These forms are made up of special terms called minterms or maxterms.

1.4.82

Page 83: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Disjunctive Normal Form• A minterm is a Boolean polynomial that is

only the product of each variable or its negation (but not both).

• Examples: f(x,y) = xy’f(x,y,z) = x’yz’f(w,x,y,z) = wx’y’z

• The disjunctive normal form (DNF) is a Boolean polynomial that is the sum of minterms (sum of products).

1.4.83

Page 84: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Disjunctive Normal Form (cont’d.)

• Express f(x,y,z) = x + x’z in its DNF.

f(x,y,z) = x + x’z

= x(y + y’)(z + z’) + x’(y + y’)z

= (xy + xy’)(z + z’) + (x’y + x’y’)z

= xyz + xyz’ + xy’z + xy’z’ + x’yz + x’y’z

• The thing to note here is that each minterm has an output of 1 at only a single, particular line of the truth table.

• i.e. xy’z = 1 at 101 and = 0 elsewhere.

1.4.84

Page 85: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Disjunctive Normal Form (cont’d.)

• We can now think of the inputs, in fact, as their associated minterms to get outputs:

x y z x y z f(x,y,z)1 1 1 x y z 11 1 0 x y z’ 11 0 1 x y’z 11 0 0 x y’z’ 10 1 1 x’y z 10 1 0 x’y z’ 00 0 1 x’y’z 10 0 0 x’y’z’ 0

1.4.85

Page 86: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Designing Circuits with Specified Conditions

• In the other direction:x y z f(x,y,z)1 1 1 0 0 0 0 01 1 0 0 0 0 0 01 0 1 1 1 0 0 01 0 0 0 0 + 0 + 0 + 00 1 1 1 0 1 0 00 1 0 1 0 0 1 00 0 1 1 0 0 0 10 0 0 0 0 0 0 0f(x,y,z) = xy’z + x’yz + x’yz’ + x’y’z

1.4.86

Page 87: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Conjunctive Normal Form• In a similar fashion, we can analyze

functions using the conjunctive normal form - the product of sums.

• In this case, we look for the 0’s in the function’s output and associate each with a maxterm, whose output is 0 at that row.

1.4.87

Page 88: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Equivalent Circuits

• Two logical circuits are equivalent if and only if they have the same truth table.

• This can be thought similarly as holding when the two circuits have the same disjunctive (conjunctive) normal form.

1.4.88

Page 89: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 5.2• Properties of sets

• Methods to show one set is a subset of another

• Set identities

• Methods to show two sets are equal

5.2.89

Page 90: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Some Subset Relations

• For all sets A, B, and C:

1. A B A and A B B

2. A A B and B A B

3. If A B and B C, then A C.

5.2.90

Page 91: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Procedural Versions of the Set Operations

• x A B means x A or x B.

• x A B means x A and x B.

• x A B means x A and x B.

• x Ac means x A.

• (x, y) A B means x A and y B.

5.2.91

Page 92: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example: Show A B A

• Let x A B. Show x A.

• x A B means x A and x B.

• In particular, this means x A.

• Hence, given x A B, we deduce that x A.

• Therefore A B A.

5.2.92

Page 93: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Set IdentitiesCommutative Laws

A B = B A and A B = B A

Associative Laws

(A B) C = A (B C)

(A B) C = A (B C)

Distributive Laws

A (B C) = (A B) (A C)

A (B C) = (A B) (A C)

5.2.93

Page 94: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Set Identities (cont’d.)

Intersection with U

A U = A

Universal Bound

A U = U

Double Complement Law

(Ac)c = A

Idempotent Laws

A A = A and A A = A

5.2.94

Page 95: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Set Identities (cont’d.)

DeMorgan’s Laws

(A B)c = Ac Bc and (A B)c = Ac Bc

Set Difference Law

A B = A Bc

Absorption Laws

A (A B) = A

A (A B) = A

5.2.95

Page 96: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Basic Method to Show Set Equality

• Let sets A and B be given. Show A = B.

• First, show A B.

• Second, show B A.

• If the “” holds in both directions, then we can conclude that A = B.

5.2.96

Page 97: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example 1: A (B C) = (A B) (A

C) First, show A (B C) (A B) (A C).

Then, show (A B) (A C) A (B C).

5.2.97

Page 98: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example 2: If A B, thenA B = B and A B = A

First, show A B A.

Then, show A A B.

5.2.98

Page 99: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

(A B) C = (A C) (B C)

• To show these sets are equal, we will simply apply the Properties of Sets.

(A B) C

= (A B) Cc

= (A Cc) (B Cc )

= (A C) (B C )

5.2.99

Page 100: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 2. The Logic ofQuantified Statements

• Predicates

• Quantified Statements

• Valid Arguments and Quantified Statements

2.1.100

Page 101: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1. Predicates andQuantified Statements I

• In Chapter 1, we studied the logic of compound statements, but the argument reasoning in there cannot show the validity of the following simple argument:

All men are mortal.

Socrates is a man.

Therefore, Socrates is mortal.

2.1.101

Page 102: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Predicates• To study these types of logical arguments, we

turn to predicate calculus.

• A predicate is a sentence that contains a finite number of variables and becomes a statement when specific values are substituted for the variables.

• The domain of a predicate variable is the set of all values that may be substituted in place of the variable.

2.1.102

Page 103: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Predicate Notation• If P(x) is a predicate and x has a domain D, the

truth set of P(x) is the set of all elements of D that make P(x) true when substituted for x.

• The truth set is denoted {x D | P(x)}.

• If P(x) and Q(x) are predicates and the common domain of x is D, then the notation P(x) Q(x) denotes that the truth set of P(x) is a subset of the truth set of Q(x).

• If P(x) and Q(x) have the same truth set, we denote this as P(x) Q(x).

2.1.103

Page 104: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Universal Quantifier• We often find predicates involved when we are

making claims about properties that some or all the elements of a set obey. This leads us to look at statements using one of two quantifiers.

• The Universal Quantifier: If P(x) is a predicate over a domain D, we say a universal statement is one of the form “x D, P(x).”

• This universal statement is true provided P(x) is true for every x in D.

• Any x D with P(x) false, is a counterexample.

2.1.104

Page 105: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples• Example 1: Let D = {1,2,3,4,5} and let P(x) be

the predicate x2 x. Using the Method of Exhaustion, we find that 12 1, 22 2, 32 3, 42 4, and 52 5 are all true, hence the universal statement x {1,2,3,4,5}, x2 x is true.

• Example 2: If we change this universal statement to: x R, x2 x, it is no longer true since x = 1/2 is a counterexample.

2.1.105

Page 106: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Existential Quantifier• The Existential Quantifier: If P(x) is a predicate

over a domain D, we say an existential statement is one of the form “x D P(x).”

• This existential statement is true provided P(x) is true for at least one x in D, and is false if P(x) is false for every x in D.

• From this, we see that the negation of an existential statement is a universal statement, and, likewise, the negation of a universal statement is an existential one.

2.1.106

Page 107: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

More Examples• Consider: x D x2 < 0.

• Example 1: If D = C (the Complex numbers), then x = i yields i2 = (1) < 0, hence the existential statement is true.

• Example 2: If D = R, then by the properties of R, we know that x2 0 for all x in R, hence the existential statement is false.

• This second example show us the negation of x R x2 < 0 is the universal statement x R, x2 0.

2.1.107

Page 108: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Negations of Quantifiers• As seen in the previous example, the negation of

an existential statement is a universal statement.• Formally, we denote:

~[x D P(x)] x D, ~P(x).• By the same process, we have that:

~[x D, P(x)] x D ~P(x).• Intuitively, the first says the opposite of at least

one thing satisfying a property is that none do, and the opposite of all things satisfying the property is that at least one does not.

2.1.108

Page 109: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples of Negations• The negation of:

Some people are sad.is

All people are not sad.

• The negation of:All integers are rational.

isAt least one integer is irrational.

• Which of each pair is true?

2.1.109

Page 110: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Universal Conditional• The statement:

x, if P(x), then Q(x)is called the universal conditional.

• Many mathematical statements are universal conditionals.

• Example: x R, if x > 2 then x2 > 4 (formal)is equivalent to: (informally)– Every real number greater than 2 has a square

greater than 4.– The square of any real number greater than 2 is

greater than 4.

2.1.110

Page 111: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Negation of Quantified Conditionals

• Since we see the properties of symbolic logic carry over when dealing with quantified logic, we deduce that:

~[x D, if P(x), then Q(x)]is x D P(x) and ~Q(x).

• Similarly, ~[x D if P(x), then Q(x)]is x d, P(x) and ~Q(x).

• Negate: 1. Every CS student studies CMSC203.2. Some CS students study CMSC203.

2.1.111

Page 112: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 2 - More Quantified Statements

• Statements with multiple quantifiers;

• Negations of multiply quantified statements;

• Equivalent forms of universal conditionals.

2.2.112

Page 113: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Multiply Quantified Statements

• Consider the following statement:Given any real number, there is a

smaller real number.

• This is equivalent to the formal statement:xR, yR y < x.

• This is an example of a multiply quantified statement.

2.2.113

Page 114: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples• The formal statement:

xR+ yR+, y < xcan be interpreted informally as:

• There is a non-negative real number with the property that all other non-negative real numbers are smaller than this number;

• There is a non-negative real number that is larger than all other non-negative real numbers.

2.2.114

Page 115: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Another Example• INFORMAL:

Everybody loves somebody.

• FORMAL: people x, a person y x loves y.

• INFORMAL:Somebody loves everybody.

• FORMAL: a person x people y, x loves y.

2.2.115

Page 116: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Negation of Universal Existentials• What is the negation of the statement:

people x, a person y such that x loves y?

• Recall this is “Everybody loves somebody,” so its negation would be the case of “Somebody who does not love anybody.”

• In formal terms: a person x people y, x does not love y.

• Thus:~ [x, y P(x,y) ] x y, ~P(x,y)

2.2.116

Page 117: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Negation of Existential Universals • What is the negation of the statement:

a person x such that people y, x loves y?

• Recall this is “Somebody loves everybody,” so its negation would be the case of “Everybody has at least one person they do not love.”

• In formal terms: people x, person y x does not love y.

• Thus:~ [x y, P(x,y) ] x, y ~P(x,y)

2.2.117

Page 118: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Equivalent Forms of Universal Conditionals

• Given the statement: xD, if P(x), then Q(x)

analogous to our definitions from propositional calculus, we can construct the following.

• Contrapositive: xD, if ~Q(x), then ~P(x).

• Converse: xD, if Q(x), then P(x).

• Inverse: xD, if ~P(x), then ~Q(x).

• Negation: xD P(x), and ~Q(x).

2.2.118

Page 119: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example• Statement: xR, if x > 2, then x2 > 4.

• Converse: xR, if x2 > 4, then x > 2.

• Inverse: xR, if x 2, then x2 4.

• Contrapositive: xR, if x2 4, then x 2.

• Negation: xR x > 2 and/but x2 4.

2.2.119

Page 120: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3 - Valid Arguments

• Argument Forms;

• Diagrams to Test for Validity;

• Quantified Converse and Inverse Errors;

• Abduction.

2.3.120

Page 121: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Universal Instantiation

• Consider the following statement:All men are mortalSocrates is a man.Therefore, Socrates is mortal.

• This argument form is valid and is called universal instantiation.

• In summary, it states that if P(x) is true for all xD and if aD, then P(a) must be true.

2.3.121

Page 122: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Universal Modus Ponens• Formal Version: xD, if P(x), then Q(x).

P(a) for some aD. Q(a).

• Informal Version:If x makes P(x) true, then x makes Q(x) true.a makes P(x) true. a makes Q(x) true.

• The first line is called the major premise and the second line is the minor premise.

2.3.122

Page 123: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Universal Modus Tollens• Formal Version: xD, if P(x), then Q(x).

~Q(a) for some aD. ~P(a).

• Informal Version:If x makes P(x) true, then x makes Q(x)

true.a makes Q(x) false. a makes P(x) false.

2.3.123

Page 124: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples• Universal Modus Ponens or Tollens???

If a number is even, then its square is even.

10 is even.

Therefore, 100 is even.

If a number is even, then its square is even.

25 is odd.

Therefore, 5 is odd.

2.3.124

Page 125: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Using Diagrams to Show Validity• Does this diagram portray the argument of the

second slide?

Mortals

Men

Socrates

2.3.125

Page 126: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Modus Ponens in Pictures• For all x, P(x) implies Q(x).

P(a).Therefore, Q(a).

{x | Q(x)}

{x | P(x)}

a

2.3.126

Page 127: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Modus Tollens Example• All humans are mortal.

Zeus is not mortal.Therefore, Zeus is not human.

Mortals

Humans

Zeus

2.3.127

Page 128: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Modus Tollens in Pictures• For all x, P(x) implies Q(x).

~Q(a).Therefore, ~P(a).

{x | Q(x)}

{x | P(x)}

a

2.3.128

Page 129: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Converse Error in Pictures• All humans are mortal.

Felix the cat is mortal.Therefore, Felix the cat is human.

Mortals

HumansFelix?

Felix?

2.3.129

Page 130: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inverse Error in Pictures• All humans are mortal.

Felix the cat is not human.Therefore, Felix the cat is not mortal.

Mortals

Humans

Felix?

Felix?

2.3.130

Page 131: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Quantified Form of Converseand Inverse Errors

• Converse Error:x, P(x) implies Q(x).Q(a), for a particular a. P(a).

• Inverse Error:x, P(x) implies Q(x).~P(a), for a particular a. ~Q(a).

2.3.131

Page 132: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

An Argument with “No”• Major Premise: No Naturals are negative.

• Minor Premise: k is a negative number.

• Conclusion: k is not a Natural number.

Natural numbers Negative numbers

k

2.3.132

Page 133: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Abduction• Major Premise: All thieves go to Paul’s Bar.

Minor Premise: Tom goes to Paul’s Bar.

Converse Error: Therefore, Tom is a thief.

• Although we can’t conclude decisively if Tom is a thief or not, if we have further information that 99 of the 100 people in Paul’s Bar are thieves, then the odds are that Tom is a thief and the converse error is actually valid here.

• This is called abduction by Artificial Intelligence researchers.

2.3.133

Page 134: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 3 - Elementary NumberTheory and Proofs

• Direct & Indirect Proofs;

• Properties of Primes, Integers, Rationals, and Reals;

• Divisibility (Unique Factorization Theorem);

• Modular Forms (Quotient-Remainder Theorem);

• The Division & Euclidean Algorithms.

3.1.134

Page 135: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1 - Direct Proof and Counterexample

• Mathematics is built on the Axiomatic Method.

• Start with Definitions and Axioms.

• Use these in valid arguments to demonstrate Theorems.

• Use all of the above to deduce NEW Theorems.

• Continue ad infinitum.

• Get paid! (or pass course!)

3.1.135

Page 136: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Even and Odd Integers• Definition: An integer n is even provided there

exists an integer k such that n = 2k.

• Definition: An integer n is odd provided there exists an integer k such that n = 2k + 1.

• 38 is even since 38 = 2(19) and 19 is an integer.

• 417 is odd since 417 = 2(208) + 1 and 208 Z.

• 417 is not even since 417 = 2(208.5) but 208.5 Z.

3.1.136

Page 137: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Prime and Composite Integers• Definition: An integer n is prime if, and only if,

n > 1, and for all positive integers r and s, if n = rs, then r = 1 or s = 1.

• Definition: An integer n is composite if, and only if, n > 1, and for all positive integers r and s, if n = rs, then r 1 and s 1.

• Every natural number > 1 is either prime or composite.

• 2 is the only even prime number.

3.1.137

Page 138: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proving Existential Statements• To show: There exists an a such that P(a).

• Demonstrate an Example: Prove there is an even integer that can be written in two ways as the sum of two primes.

Proof: 10 = 3 + 7 = 5 + 5.

• Construct an Example: Prove if r,s Z, then 4r + 6s is even.

Proof: Let r,s Z. Thus 2r + 3s = k Z, and 4r + 6s = 2k, therefore (4r + 6s) is even.

3.1.138

Page 139: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proving Universal Statements• Most theorems are of the form:

xD, if P(x), then Q(x).

• If D is a finite set, we can just exhaust over each element n to verify that Q(n) holds.

• Example: Prove all n {4, 6, 8, 10, 12} can be written as the sum of two primes.

Proof: 4 = 2 + 2 6 = 3 + 3

8 = 3 + 5 10 = 3 + 7

12 = 5 + 7.

3.1.139

Page 140: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalizing from theGeneric Particular

• When it is not feasible to exhaust over each element of the domain, we turn to the method of generalizing from the generic particular:– To show that every element of a domain satisfies a

certain property, suppose x is a particular, but arbitrarily chosen element of the domain, and show that x satisfies the property.

• This is the strategy we employ in the method of direct proof.

3.1.140

Page 141: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Method of Direct Proof• Express the statement to be proved in the form:

xD, if P(x), then Q(x) if possible. (Often, this is done mentally)

• Start the proof by supposing that n is a particular but arbitrary element of D for which P(n) is true. (Suppose nD and P(n))

• Show that the conclusion Q(n) follows from P(n) by using definitions, axioms, previously established results, and the rules for logical inference.

3.1.141

Page 142: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Theorem 3.1.1Prove: If the sum of two integers is even, then

so is their difference.

Proof: Let m and n be any integers with (m + n) even. This means there is an integer k such that (m + n) = 2k.

Now, (m n) = (m + n) 2n = 2k 2n = 2 (k n) = 2p,

where k n = p is an integer. Thus (m n) is even. Also, (n m) = (m n) = 2(p), so (n m) is also even. Therefore, the difference of m and n is even. QED

3.1.142

Page 143: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Directions for Writing Proofs• Write the statement to be proved.

• Clearly mark the beginning of your proof with the word Proof.

• Make your proof self-contained:– Identify each variable used in the body of the proof;– Introduce only necessary variables and notation;– Use Lemmas to show significant but related ideas.

• Write proofs in complete (English) sentences.

3.1.143

Page 144: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Common Mistakes• Arguing from examples;

• Using the same letter to mean different things;

• Jumping to a conclusion;

• Begging the question (i.e. assuming true that which you want to prove);

• Using if when you mean since, hence, thus, therefore, hencely, thusly, hereforthwith, etc.

3.1.144

Page 145: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 2 - Rational Numbers

• Recall the definition of a Rational Number:A real number r is rational provided thereexist integers a and b such that r = a/b andb 0.

• Theorem: Every integer is a rational number.Proof: Let a be an integer, then a = a/1. Moreover, 1 is an integer and 1 0. Therefore a is a rational number. QED

3.2.145

Page 146: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proving Properties of Rationals• We will now look at some theorems and

corollaries (theorems that follow essentially trivially from another theorem) about rational numbers.

• We will rely on the Closure Properties of the Integers under +, , and :

If a,b are integers, then (a+b), (ab), (ba), and ab are also integers.

• We will also use their Zero-Product Property: If a,b Z, with a 0 and b 0, then ab

0.

3.2.146

Page 147: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Closure of the Rationals Under +• Theorem: If r, s Q, then (r + s) Q.

• Proof: Let r, s Q. Thus a, b, c, d Z such that r = a/b with b 0 and s = c/d with d 0.

Now, (r + s) = a/b + c/d = (ad + bc)/bd. Since a, b, c, d Z, we have that (ad + bc) Z and that bd Z. Moreover, since b 0 and d 0, we conclude that bd 0. Consequently, (r + s) is the quotient of integers with non-zero denominator. Therefore (r + s) Q. QED

3.2.147

Page 148: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Corollary• Corollary: Double a rational is rational.

• Proof: Let r = s in the previous theorem.

3.2.148

Page 149: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3 - Divisibility

• Definition: If n and d are integers and d 0, thenn is divisible by d provided n = d k for some integer k.

• Alternatively, we say:n is a multiple of dd is a factor of nd is a divisor of nd divides n (denoted with d | n).

3.3.149

Page 150: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Properties of Divisibility• Divisors of 0: If k is a non-zero integer, then

k divides 0 since 0 = k 0.

• Positive Divisors of a Positive Number:If a and b are positive integers and a | b, is a b?

Yes. Since a | b, k Z,such that b = a k. Moreover, 0 < k, since a and b are, so 1 k.Thus: a = a 1 a k = b.

Therefore a b.

• Divisors of 1: The only divisors of 1 are 1 and 1.

3.3.150

Page 151: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Divisibility of Algebraic Terms• Let a and b be integers.

• Does 3 | (3a + 3b)?

Yes, since (3a + 3b) = 3(a + b) and (a + b) Z.

• Does 5 | 10ab?

Yes again, since 10ab = 5(2ab) and (2ab) Z.

• If m Z and m | (a + b), does m | a and m | b?

No. 2 | 8 but 2 | 5 and 2 | 3.

3.3.151

Page 152: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Divisibility and Non-divisibility• There is another way to test for divisibility:

If d | n, there is integer k with n = dk, thenk = (n/d). So, if (n/d) is an integer, then d | n.

• This leads to an easy way to test for non-divisibility: If (n/d) is not an integer, then d cannot divide n.

• Examples: 3 | 12 since 12/3 = 4 Z.5 | 12 since 12/5 = 2.4 Z.

3.3.152

Page 153: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proving Properties of Divisibility• Theorem: Transitivity of Divisibility

For all a,b,c Z, if a | b and b | c, then a | c.

• Proof: Let a, b, and c be integers, and assumea | b and b | c. Thus there exist m,n Z with b = ma and c = nb.

Now, c = nb = n(ma) = (nm)a. Since m,n Z, we have nm Z, therefore a | c. QED

• Example: 3 | 9 and 9 | 909, therefore 3 | 909.

3.3.153

Page 154: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Divisibility by a Prime• Theorem: Every positive integer greater than 1

is divisible by a prime number.

• Proof: Let n Z with n > 1. Then either n is prime or composite. If n is prime, it is divisible by itself, and we are done.

Now, assume n is composite. Thus there are integers (greater than 1) a and b, such that n = ab. If a is prime, we are done. If not, factor a, .... Will we eventually get to a prime factor?

3.3.154

Page 155: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Standard Factored Form• Definition: Given any integer n > 1, the

standard factored form of n is an expression of the form: n = (p1)e1 (p2)e2 (p3)e3...(pk)ek,where k is a positive integer ; p1,p2,...,pk are prime numbers with p1 < p2 < ... < pk; and e1,e2,...,ek are positive integers.

• Example: 3300 = 33 100 = 3 11 102 = 22 3 52 11.

3.3.155

Page 156: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Unique Factorization Theorem• Theorem: Given any integer n > 1, there exist

positive integer k; prime numbers p1,p2,...,pk; and positive integers e1,e2,...,ek, with n = (p1)e1 (p2)e2 (p3)e3...(pk)ek,and any other expression of n as a product of prime numbers is identical to this except, perhaps, for the order in which the factors appears.

• This is also referred to as the Fundamental Theorem of Arithmetic.

3.3.156

Page 157: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Fundamental Theorem of Arithmetic

• Theorem: Every positive integer greater than 1 has a unique factorization as the product of primes.

• Proof: (outline)

1. Apply the previous theorem to each composite factor encountered.

2. Sort the final listing to get the prime factors in increasing (decreasing?) numeric order.

3. Rewrite using exponents.

3.3.157

Page 158: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 4 - The QuotientRemainder Theorem

• The Quotient-Remainder Theorem;

• Modular Arithmetic (div and mod functions);

• Proofs Requiring Division into Cases;

• Representations of the Integers.

• The Parity Theorem

3.4.158

Page 159: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Quotient-Remainder Theorem• Theorem: Given any integer n and a positive

integer d, there exist unique integers q and r such that: n = dq+ r, and 0 r < d.

• Example: If n = 27 and d = 5, then consider:27 = 0 5 + 2727 = 1 5 + 2227 = 2 5 + 1727 = 3 5 + 1227 = 4 5 + 727 = 5 5 + 2 here, r = 2 and q = 5.27 = 6 5 + (3)

3.4.159

Page 160: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

div and mod Functions• Definition: Given a nonnegative integer n and a

positive integer d,n div d = the integer quotient obtained

when n is divided by d;n mod d = the integer remainder obtained

when n is divided by d.

• Symbolically, if n and d are positive integers:n div d = q and n mod d = r, where n, d, q, and r are as described in the Quotient-Remainder Theorem.

3.4.160

Page 161: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

div and mod Examples• Consider the previous example of n = 27 and

d = 5. Since 27 = 55 + 2 yields q = 5 and r = 2, we have that:

27 div 5 = 5;27 mod 5 = 2.

• More: 100 div 10 = 10 100 mod 10 = 0

100 div 8 = 12 100 mod 8 = 4

10 div 100 = 0 10 mod 100 = 10

365 div 7 = 52 365 mod 7 = 1

3.4.161

Page 162: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Representations of the Integers• Recall, we have claimed previously that every

integer is either even or odd.

• Consider:Even: ... 10 8 6 4 2 0 2 4 6 8 10 ...Odd: ... 9 7 5 3 1 1 3 5 7 9 11 ...

• We note that all the evens are n = 2q = 2q + 0 and all the odds are n = 2q + 1.

• Moreover, each successive integer alternates parity (its mod 2 value).

3.4.162

Page 163: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

More Representations of Integers• If we continue representing integers via the

Quotient-Remainder Theorem, we observe:

Modulus Forms

2 2n 2n + 1

3 3n 3n + 1 3n + 2

4 4n 4n + 1 4n + 2 4n + 3

...

k kn kn + 1 kn + 2 ... kn + (k1)

3.4.163

Page 164: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Division into Cases• Sometimes when proving a theorem, the logical

flow will fork into different directions, each of which need investigation.

• This is analogous to needing IF THEN ELSE instead of just IF THEN in programming flow.

• An example is the Parity Theorem.

• Theorem: Any two consecutive integers have opposite parity.

3.4.164

Page 165: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Division into Cases (cont’d.)Proof: Let m be an integer, so its successor is

(m+1). Show m and (m+1) have opposite parity.

Case 1 (m even): If m is even, there is an integer k such that m = 2k, hence (m+1) = 2k + 1, thus (m+1) is odd. So, m even implies (m+1) is odd.

Case 2 (m odd): If m is odd, there is integer k such that m = 2k + 1. Hence: (m+1) = (2k + 1) + 1 = 2k + 2 = 2(k +1), and so (m+1) is even. So, m odd implies (m+1) is even.

Therefore, consecutive integers have opposite parity. QED

3.4.165

Page 166: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Square of an Odd IntegerTheorem: If n is an odd integer, (n2 mod 8) = 1.

Proof: Let n be an odd integer, so it has the representation modulo 4 of n = 4q+1 or 4q+3.

Case 1: Let n = 4q+1. Thus n2 = (4q+1)2

= 16q2 + 8q + 1 = 8(2q2 + q) + 1.

Case 2: Let n = 4q+3. Thus n2 = (4q+3)2

= 16q2 + 24q + 9 = 16q2 + 24q + 8 + 1= 8(2q2 + 3q + 1) + 1.

Therefore, in either case, (n2 mod 8) = 1. QED

3.4.166

Page 167: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 6 - Indirect Argument

• Method of Proof by Contradiction;

• Method of Proof by Contraposition;

• Examples of Each Method.

3.6.167

Page 168: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proof by Contradiction• Instead of the Universal Modus Ponens argument

form: x, [P(x) Q(x) AND P(x)] Q(x), a Proof by Contradiction (reductio ad absurdum) follows the Universal Modus Tollens form: x, [P(x) Q(x) AND ~Q(x)] ~P(x).

• We obtain a contradiction when the conclusion of this form is combined with our standard assumption in a direct proof the P(x) holds.

• This differs marginally from the Method of Contraposition which proves directly the validity of the comtrapositive statement.

3.6.168

Page 169: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Method of Proof By Contradiction• Suppose the statement to be proved is FALSE;

• Show this supposition leads logically to a contradiction (either to the original hypotheses or to some other statement of fact);

• Conclude that the original statement to be proved is TRUE.

3.6.169

Page 170: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example: No Greatest IntegerTheorem: There is no greatest integer.

Proof: (Contradiction) Suppose there is a greatest integer N. Thus for every integer k, k N.

Now, since N is an integer, by closure, (N+1) is an integer. Thus: N + 1 N ,hence 1 0.*

Therefore, there is no greatest integer. QED

3.6.170

Page 171: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Sums of Rationals and IrrationalsTheorem: The sum of a rational and an irrational

is irrational.

Proof: (Contradiction) Let r be rational, s be irrational, and assume (r + s) is rational. Thus there exist a,b,c,d Z, with r = a/b, (r + s) = c/d and b,d 0.

Now, s = (r + s) r = c/d a/b = (bc ad)/bd.

Since a,b,c,d Z and b,d 0, we have s Q.*

Therefore (r + s) is irrational. QED

3.6.171

Page 172: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Argument by Contraposition• Since we know that a statement and its

contrapositive are logically equivalent, if we can pose our conjecture in the form of a conditional, we can work, equivalently, with its contrapositive form.

• We call this strategy, simply enough, Argument by Contraposition.

3.6.172

Page 173: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Method of Proof by Contraposition• Express the statement to be proved in the form

x, if P(x) then Q(x).

• Rewrite this as its contrapositivex, if ~Q(x) then ~P(x).

• Prove the contrapositive form directly:– Suppose x is such that Q(x) is FALSE.– Show that P(x) is FALSE.

3.6.173

Page 174: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example of ContrapositionTheorem: Given any integer n, if n2 is even, then

n is even.

(Contrapositive: If n is odd, then n2 is odd.)

Proof: (Contraposition) Let n be an integer and assume that n is odd. Thus, there is an integer k such that n = 2k + 1. Show that n2 is odd.

Now, n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1.

Since k is an integer, (2k2 + 2k) is an integer.

Therefore n2 is odd. QED

3.6.174

Page 175: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 7 - Two Classical TheoremsProve: The 2 is irrational.

Proof: (Contradiction) Assume 2 is rational. Then, there exist p,q Z in “lowest terms” with 2 = p/q and q 0.

Now, 2 = p/q implies 2q2 = p2, hence p2 is even. From a previous result, this yields that p is even, so we deduce m Z with p = 2m.

Thus 2q2 = (2m)2 = 4m2, so q2 = 2m2. This time, we get that q2 is even, hence q is even.*

Therefore 2 is irrational.

3.7.175

Page 176: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Corollary

Corollary: (1 + 32) is irrational.

Proof: (Contradiction) Assume (1 + 32) is rational. Then, there exist p,q Z in “lowest terms” with (1 + 32) = p/q and q 0.

Now, solving for 2, we get 2 = (p q)/3q,

which implies 2 is rational.*

Therefore (1 + 32) is irrational.

3.7.176

Page 177: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Infinitude of the Primes

Theorem: The set of prime numbers is infinite.

Lemma: If a Z and p is prime with p | a, then p | (a + 1).

Proof: (Contradiction) Let a Z and p be prime with p | a. Assume that p | (a + 1). Then there are m,n Z such that a = mp and (a + 1) = np.

Now, (a + 1) = np implies 1 = np mp, so 1 = p(n m), thus p | 1. However, this means p = 1,1.* Therefore, p | (a + 1).

3.7.177

Page 178: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Infinitude of the Primes

Proof: (Contradiction) Assume there are a finite number of primes, say p1, p2, ..., pk.

Now, consider a = p1p2...pk. Since each pi is an integer, a is likewise an integer, and so is (a+1). Thus, by a previous result, (a+1) is divisible by some prime, pj.

Since pj is a prime, it must divide a, and by assumption, pj divides (a+1).*

Therefore the collection of primes is infinite. QED

3.7.178

Page 179: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 8 - Two Algorithms• We look at two algorithms to obtain values of

use in number theory.

• The Division Algorithm is a process to calculate (n div d) and (n mod d) as specified in the Quotient-Remainder Theorem.

• The Euclidean Algorithm uses the Quotient-Remainder Theorem to calculate Greatest Common Divisors.

3.8.179

Page 180: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Division AlgorithmInput: Integers n and d.

Output: Integers q (= n div d) and r (= n mod d).Begin

set r = n;set q = 0;while (r d)

set r = r d;set q = q + 1;

endwhileoutput q, r;

End

3.8.180

Page 181: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Tracing the Division AlgorithmCalculate: (19 div 4) and (19 mod 4)

Iteration Number

0 1 2 3 4

n 19

d 4

r 19 15 11 7 3

q 0 1 2 3 4

Thus (19 div 4) = 4 and (19 mod 4) = 3.

3.8.181

Page 182: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Greatest Common DivisorsDefinition: An integer d is a common divisor of

integers m and n provided d | n and d | m.

Example: Since 6 | 12 and 6 | 30, 6 is a common divisor of 12 and 30.

Definition: If m,n Z not both 0, then d Z is the greatest common divisor of m and n when:

1. d is a common divisor of m and n;

2. if c is also a common divisor of m and n, then c d.

We denote d = gcd(m,n).

3.8.182

Page 183: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Calculating GCDs

• Find gcd(72,63)

72 = 98 = 3324 = 233463 = 97 = 33 7hence gcd(72,63) = 33 = 9.

• Find gcd(1020,630)

1020 = (25)20 = 220 520

630 = (23)30 = 230 330 = 220 210

330 hence gcd(1020,630) = 220.

3.8.183

Page 184: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Two Lemmas

• Lemma1: If r is a positive integer, then gcd(r,0) = r.

Why? Everything divides 0 and r is the biggest thing to divide r.

• Lemma 2: If a,b Z, b 0 and q,r Z+ witha = bq + r,

then gcd(a,b) = gcd(b,r).

3.8.184

Page 185: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proof of Lemma 2Proof: Let a,bZ, b 0, and q,rZ+ with a = bq+r.

Case 1: Show gcd(a,b) gcd(b,r).

Let x = gcd(a,b), so that x | a and x | b.

Now, since a = bq + r, we have r = a bq, thus x | r. But x | b, hence gcd(a,b) = x gcd(b,r).

Case 2: Show gcd(a,b) gcd(b,r).

Let y = gcd(b,r), so that y | b and y | r.

Now, since a = bq + r, we see that y | a. But y | b, hence gcd(a,b) y = gcd(b,r).

Therefore gcd(a,b) = gcd(b,r). QED

3.8.185

Page 186: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Calculating GCDs a la Euclid

• Find gcd(330,156).

• 330 = 156 2 + 18

• 156 = 18 8 + 12

• 18 = 12 1 + 6

• 12 = 6 2 + 0

• Hence gcd(330,156) = gcd(156,18)= gcd(18,12) = gcd(12,6) = gcd(6,0) = 6.

3.8.186

Page 187: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Euclidean AlgorithmInput: Integers A and B.

Output: gcd(A,B).Begin

set a = A;set b = B;while (b 0)

set r = a mod b;set a = b;set b = r;

endwhileoutput a;

End

3.8.187

Page 188: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 4 - Sequences andMathematical Induction

• Sequences & Series (Summations);

• Principle of Mathematical Induction;

• Weak Form of Induction;

• Strong Form of Induction.

4.1.188

Page 189: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1 - Sequences• A sequence is a list of elements called terms.

• We think of each term as occupying a specific position within the sequence, so we may use an index variable to denote specific but arbitrary terms in the sequence.

• For example, if we have the sequence:1, 2, 4, 8, 16, 32, 64, 128, ...

we can denote a0 = 1, a1 = 2, a2 = 4, a3 = 8, ...

• This is useful since we can now describe the sequence as {ai = 2i}

4.1.189

Page 190: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Explicit Formulas• Define the sequences {ai} and {bj} as:

ai = i / (i + 1) for i > 0; bj = (j 1) / j for j > 1.

• Thus ai = 1/2, 2/3, 3/4, 4/5, 5/6, ...and bj = 1/2, 2/3, 3/4, 4/5, 5/6, ...

• Are these the same sequence?

• This indicates a natural way to check if two sequences are equal:

Two sequences {ai} and {bi} are equal if ai = bi for each value of i.

4.1.190

Page 191: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Alternating Sequences• Consider the sequence defined as:

ai = (1)i, for all positive integers i.

• We get: a1 = 1 a2 = 1 a3 = 1 a4 = 1, etc.

• Such a sequence in which successive terms have opposite sign is called an alternating sequence.

4.1.191

Page 192: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Summation Notation• Often, it is useful to sum up the terms of a

sequence. This expression of summation is called a series.

• To save the tedium of continually writing a1 + a2 + a3 + ... + an, we will use the summation notation:

n ai = a1 + a2 + a3 + ... + ani=1

4.1.192

Page 193: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Working with Summations

• Given

we call i the index of summation, m the lower limit, and n the upper limit.

• To compute a summation, we perform the substitutions and calculations called for by the formula: 5 9 i2 = 22 + 32 + 42 + 52 = 54, i2 = 92. i=2 i=9

n ai = am + am+1 + am+2 + ... + ani=m

4.1.193

Page 194: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Telescoping Series

Consider: n k _ k + 1 k=1 k + 1 k + 2

Plugging into the formula, we get:

(1/2 2/3) + (2/3 3/4) + (3/4 4/5) + ...... + [(n1)/n n/(n+1)] + [n/(n+1) (n+1)/(n+2)]

= 1/2 (n+1)/(n+2).

This type of series is called a telescoping series.

4.1.194

Page 195: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Changing Variables• Rewrite:

n k / (k + 1) as a sum from 3 to

(n+2). k =1• To do this, we use a change of variables from

k to j using the transformation j = k + 2 (so thatk = j 2).

• Thus k = 1 becomes j = 3; k = n becomes j = n+2;and k + 1 becomes (j 1). Consequently:

n n+2 k / (k + 1) = j 2) / (j 1) k =1 j =1

4.1.195

Page 196: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Product Notation• Instead of summing the terms of a sequence, if we

want to multiply each term, we use the product notation:

n

ak = a1a2a3... an

k =1

• For example: 12

3k = 353637... 312 = 368

k =5

4.1.196

Page 197: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Properties of Sums and Products• If {ak} and {bk} are sequences of real numbers,

and c is a non-zero real number, then for m n: n n n 1. ak + bk = ak + bk) k = m k = m k = m n n 2. c ak)= c ak) k = m k = m n n n 3. ak bk = akbk k = m k = m k = m

4.1.197

Page 198: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Factorial Notation• Although products of the terms of a sequence do

not arise in problems as much as summations, one particular type of product does.

• Definition: For each positive integer n, the quantity n factorial, denoted n!, is defined to be the product of all integers from 1 to n.

• Thus, n! = n(n1)(n2)...321.

• For completeness, we define 0! = 1.

4.1.198

Page 199: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Computing with Factorials• 8!/7! = 87!/7! = 8.

• 5!/(2!3!) = (543!)/2!3! = 54/21 = 52 = 10.

• 1/(2!4!) + 1/(3!3!) = 13/(32!4!) + 14/(3!43!)

= (3 + 4)/(3!4!)= 7/(624)= 7/144.

• n!/(n 3)! = [n(n 1)(n 2)(n 3)!]/(n 3)! = n(n 1)(n 2) = n(n2 3n + 2) = n3 3n2 + 2n.

4.1.199

Page 200: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 2: Mathematical Induction

• Principle of Mathematical Induction;

• Formula for the Sum of the First n Integers;

• Formula for the Sum of a Geometric Series.

4.2.200

Page 201: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

What Is Induction

• One of the more recently developed proof techniques;

• Used to verify conjectures about processes that occur repeatedly, according to definite patterns;

• Used to prove statements indexed on the Natural Numbers (i.e. For all integers n 0, ...)

4.2.201

Page 202: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Climbing Infinite Staircases• Consider the problem of trying to climb an

infinitely tall staircase.

• How can I know that this staircase is climbable?

• First, show the staircase exists. (Basis)

• Second, show standing at any arbitrary step implies I can climb to the next step. (Induction)

• The basis shows there is an initial step.

• The induction validates a rule of motion from one step to another.

4.2.202

Page 203: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

In Pictures

Basis

Induction

Induction

Induction

Induction

4.2.203

Page 204: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Principle of Mathematical Induction

• Let P(n) be a predicate that is defined for integers n, and let a be a fixed integer.

• Suppose the following two statements are true:1. P(a) is true;

2. For all integers k a, if P(k) is true, then P(k + 1) is true.

• Then, for all integers n a, P(n) is true.

4.2.204

Page 205: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Outline of an Inductive Proof

• Basis step says to show P(initial value) is true.

• Inductive step says:– Assume P(k) is true for an arbitrary k. – Use this to show P(k + 1) is true.

• This assumption of P(k) is called the inductive hypothesis.

4.2.205

Page 206: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Tuppence and Nickels

• Show that any monetary value of 4 cents or more can be composed of tuppence (a two-cent coin) and nickels.

• BASIS: 4 cents = tuppence + tuppence.

• INDUCTION: Assume k-cents can be made up from tuppence and nickels (k = 2t + 5n). Show (k+1) can too.

4.2.206

Page 207: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Tuppence and Nickels (cont’d.)

• Case 1: (At least one of each coin: k = 2t + 5n)k + 1 = 2t + 5n + 1 = 2t + 5n + 6 5

= (2t + 6) + (5n 5) = 2(t + 3) + 5(n 1).

• Case 2: (No tuppence: k = 5n)k + 1 = 5n + 1 = 5n + 6 5 = 2(3) + 5(n 1).

• Case 3: (No nickels and t > 2: k = 2t)k + 1 = 2t + 1 = 2t + 5 4 = 2(t 2) + 5(1).

4.2.207

Page 208: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Sum of the First n Integers

• Carl Friederich Gauss is bored in school.

• Teach instructs him to add together the numbers from 1 to 100.

• Zip! Carl is done. Sum is 5050. How?

• 1 + 2 + 3 + ... + 100 = (1 + 100) + (2 + 99) + (3 + 98) +...+ (50 + 51)

= 101 + 101 + 101 +...+ 101= 50(101)

= 5050.

4.2.208

Page 209: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Sum of the First n Integers (cont’d.)Prove: n

k = n(n + 1) / 2 . k =1

Proof: (Induction) Basis: Show: 1

k = 1(2) / 2 . k =1

1 k = 1 and 1(2)/2 = 2/2 = 1, so they are equal.k =1

4.2.209

Page 210: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Sum of the First n Integers (cont’d.)

Inductive: Assume for some p: 1 + 2 +...+ p = p(p + 1)/2.

Show: (1 + 2 +...+ p) + (p + 1) = (p + 1)(p + 2)/2.

Now, (1 +...+ p) + (p + 1) = p(p + 1)/2 + (p + 1)

= (p + 1)[p/2 + 1]

= (p + 1)[p/2 + 2/2]

= (p + 1)(p + 2)/2.

Therefore 1 + 2 +...+ n = n(n+1)/2 for all integers n. QED

4.2.210

Page 211: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Geometric Series• Any sum of the form: 1 + r + r2 + r3 +...+ rn is

called a Geometric Series.

• Thus, 1 + 2 + 4 + 8 + 16 +...+ 2n is a geometric series.

• To find the sum of this series, consider: S = 1 + r + r2 + r3 +...+ rn.So rS = r r2 r3 ... r(n + 1).and (1 r)S = 1 r(n + 1).

Therefore, 1 + r + r2 +...+ rn = 1 r(n + 1) . 1 r

4.2.211

Page 212: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proof of the Geometric Series• Prove: 1 + r + r2 +...+ rn = [r(n + 1) 1] / (r 1)

• Proof: (Induction) Basis: Show true for n = 0. LHS = 1. RHS = [r(0+1) 1]/(r 1) = (r1)/(r1) = 1.Therefore LHS = RHS.

Induction: Assume 1+r+r2+...+rk = r(k+1)1/r1.

Show 1+r+r2+...+rk+r(k+1) = [r(k+2) 1]/(r 1).

Now, 1+r+r2+...+rk+r(k+1) = r(k+1)1/r1 + r(k+1) = [r(k+1) 1 + (r 1)r(k+1) ]/(r 1)

= [r(k+1) 1 + rr(k+1) r(k+1) ]/(r 1)

= [r(k+2) 1]/(r 1). QED

4.2.212

Page 213: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3: Mathematical Induction IIProve: 22n 1 is divisible by 3, for integers n > 0.

Proof: (Induction) Basis: 22(1) 1 = 22 1 = 4 1 = 3, which is clearly divisible by 3.

Induction: Assume for some integer k, 22k 1 is divisible by 3.

Now, 22(k + 1) 1 = 2(2k + 2) 1 = 22k22 1= 22k(4) 1 = 22k(3 + 1) 1 = 3(22k) + 22k 1

= 3(22k) + (22k 1).

Since each term in parentheses is divisible by 3, we have therefore that 22(k + 1) 1 is also. QED

4.3.213

Page 214: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proving An InequalityProve: 2n 1 < 2n, for all integers n 3.

Proof: (Induction) Basis: LHS = 2(3) + 1 = 7, and RHS = 23 = 8, so clearly 2n 1 < 2n for n = 3.

Induction: Assume for some integer k, 2k 1 < 2k. Show 2(k 1) + 1 < 2(k+1).

Now, 2(k + 1) + 1 = (2k + 1) + 2 < 2k + 2 < 2k + 2k = 2(k+1).

Therefore, 2n 1 < 2n, for all integers n 3.. QED

4.3.214

Page 215: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Number of SubsetsProve: A set with n elements has 2n subsets.

Proof: (Induction) Basis: Since the empty set has 1 subset (itself), and 20 = 1, then a set with 0 elements has 20 subsets.

Induction: Assume every k-element set has 2k subsets. Show every (k+1)-element set has 2(k+1) subsets.

Now let A = {a1, a2, a3,..., ak, b}, so that A has (k+1) elements. We partition P(A) into two sub-collections where the first contains subsets of A which don’t have b in them and the second contains

4.3.215

Page 216: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Number of Subsets (cont’d.)

subsets of A which do have b in them. Thus:

First Sub-collection Second Sub-collection

{} {b}

{a1} {a1, b}

{a1, a2} {a1, a2, b}

{a1, a2, ..., ak} {a1, a2, ..., ak, b}

Clearly, the first collection is made up of all the subsets from the k-element set {a1, a2, ..., ak} so it has 2k entries.

4.3.216

Page 217: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Number of Subsets (cont’d.)

Now, by construction, it follows that the second collection must have the same number of entries as the first, so it too must have 2k entries.

Since the collection of all subsets of A has been partitioned into these two sub-collections, we see that A must have 2k + 2k = 2(k+1) subsets. QED

4.3.217

Page 218: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 4: Strong Induction

• The Principle of Mathematical Induction asserts that P(k) being true implies P(k+1) is true.

• However, sometimes we need to “look” further back than 1 step to obtain P(k+1).

• That’s where the Strong Form of Mathematical Induction comes in useful.

4.4.218

Page 219: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Principle of StrongMathematical Induction

Let P(n) be a predicate defined over all integers n, and let a and b be fixed integers with a b.

Suppose the following two statements are true:

1. P(a), P(a+1),..., P(b) are all true. (Basis step)

2. For any integer k > b, if P(i) is true for all integers i with a i < k, then P(k) is true. (Inductive step)

Then the statement P(n) is true for all integers n a.

4.4.219

Page 220: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Divisibility by a Prime

To see, via strong induction, that every integer greater than 1 is divisible by a prime number, we note that the basis value of 2 is trivially divisible by a prime (itself).

Now, if we assume the strong inductive hypothesis that every integer up to k is divisible by a prime, when we look at k itself, either it is prime (and hence divisible by itself), or can be factored as lesser integers, each of which having a prime factor. Thus k is divisible by a prime.

4.4.220

Page 221: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Binary Representation TheoremTheorem: Every positive integer n can be expressed

as: n = cr2r + cr12r1 + ... + c222 + c12 + c0.

Proof: (Strong Induction) Clearly n = 1 corresponds to just c0 = 1.

Assume every integer up to k has a binary representation. Show k does too.

If k is even, then k/2 is an integer which is less than k, so it has a binary expansion of the form: k/2 = cr2r + cr12r1 + ... + c222 + c12 + c0.

Therefore, k = cr2r+1 + cr12r +...+ c223 + c122 + c02.

4.4.221

Page 222: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Binary Representation Theorem (cont’d.)

In the case where k is odd, then (k1)/2 is an integer which is less than k, so it has a binary expansion of the form:

(k1)/2 = cr2r + cr12r1 + ... + c222 + c12 + c0.

Solving for k, we have:

k = cr2r+1 + cr12r +...+ c223 + c122 + c02 + 1.

Therefore k has a binary representation. QED

4.4.222

Page 223: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Property of a SequenceConsider the sequence a1, a2, a3, ... defined as:

a1 = 1, a2 = 2, a3 = 3 and an = an1 + an2 + an3.

Show that an < 2n.

Basis: a4 = a1 + a2 + a3 = 1 + 2 + 3 = 6 < 16.

Inductive: Assume ai < 2i for i = 5, 6, 7, ..., (k 1).Show ak < 2k .

Now, ak = ak1 + ak2 + ak3, so applying the inductive hypothesis: ak1 < 2k, ak2 < 2k2, and ak3 < 2k3, we get:

4.4.223

Page 224: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Property of a Sequence (cont’d.)

ak = ak1 + ak2 + ak3 < 2k + 2k2 + 2k3

< (22 + 2 + 1)2k3

= 72k3

< 82k3

< 232k3 = 2k.

Therefore ak < 2k. QED

4.4.224

Page 225: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Why Use Strong Induction?

• In the first proof, we could not use weak induction since factoring a composite number yields values which are strictly less than the composite number minus 1.

• In the second theorem, we apply strong induction to a value (k/2 or (k 1)/2) which is clearly much less than k 1.

• In the sequence problem, we need to apply the inductive hypothesis to values at the three stages k 1, k 2, and k 3.

4.4.225

Page 226: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 10: Relations

• Relations from one set to another;

• Relations on a set;

• Graphs of relations;

• Congruence Modulo n;

• Properties of Relations;

• Equivalence Relations and Classes;

• Partitions and Relations.

10.1.226

Page 227: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1: Relations on Sets

• Definition: Let A and B be sets. A (binary) relation R from A to B is a subset of A B.

• If A = B, then we say R is a relation on A.

• Given an ordered pair (x,y) in A B, x is related to y by R, written x R y, if and only if (x,y) R.

• Think of the usual relations we deal with and replace for R in the notation x R y:

x = y, x y, x > y, x | y, etc.

10.1.227

Page 228: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Binary Relation as a Subset

• Let A = {1,2} and let B = {1,2,3} and define the binary relation from A to B as: R = {(x,y) | x A and y B and x y is even}.

• What is R?

• (1,1) 0 is even (2,1) 1 is even (1,2) 1 is even (2,2) 0 is even (1,3) 2 is even (2,3) 1 is even

• Hence R = {(1,1), (2,2), (1,3)}.

10.1.228

Page 229: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Congruence Modulo 2

• If we generalize the last example to relate Z to Z by: R = {(x,y) | x,y Z and x y is even}, we get the relation congruence modulo 2:

R = {(x,y) | x,y Z and x y mod 2}.

• If we look hard at this relation, we see that:even R even, since 2m 2n = 2(m n), andodd R odd, since 2m+1 (2n+1) = 2(m n).

10.1.229

Page 230: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Relations on Strings

• Recall that if is an alphabet, then n = {all strings over of length n}.

• Now, let = {0,1} and define the relation on 6 to be: R = {(s,t) | s,t 6 and first four characters of s = first four characters of t}.

• (110011,110011) R.

• (100000,100001) R and (100001,100000) R.

• (000000,000001), (000001,000011) and(000000,000011) are all in R.

10.1.230

Page 231: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Graphs of a Relation

• R = {(x,y) | x,y R and x2 + y2 = 1}

1

1

x

y

1

2

3

a

b

10.1.231

• Arrow Diagrams: R = {(1,a),(1,b),(2,b),(3,a)}

Page 232: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Functions

• A function from A to B is a relation that satisfies the properties:1. For each x in A, there is a y in B such that (x,y)

is in the function;2. If (x,y) and (x,z) are in the function, then y = z.

10.1.232

Page 233: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples of Functions (Not)

• To understand functions, it is easier to study what are not:

Violates Property 1

Violates Property 2

1234

ab

1234

ab

10.1.233

Page 234: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inverse Relations

• Definition: If R is a relation from set A to set B, then the inverse relation of R, denoted R1, is

R1 = {(y,x) | (x,y) R}.

• For example, if R = {(1,3), (2,1), (4,5), (6,6)}, then R1 = {(3,1), (1,2), (5,4), (6,6)}.

• Could R = R1?

• Sure - let R = {(1,2), (2,1), (2,3), (3,2), (4,4)}.

10.1.234

Page 235: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Directed Graph of a Relation

• When R is a relation on a set A, we draw it using a directed graph. For example, if

R = {(1,1), (2,4), (3,2), (4,1), (4,3)},then its directed graph is:

1

23

4

10.1.235

Page 236: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 2: Reflexivity,Symmetry, and Transitivity

• Definition: Let R be a binary relation on A.

• R is reflexive if for all x A, (x,x) R.(Equivalently, for all x e A, x R x.)

• R is symmetric if for all x,y A, (x,y) R implies (y,x) R. (Equivalently, for all x,y A, x R y implies that y R x.)

• R is transitive if for all x,y,z A, (x,y) R and (y,z) R implies (x,z) R. (Equivalently, for all x,y,z A, x R y and y R z implies x R z.)

10.2.236

Page 237: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples

• Reflexive: The relation R on {1,2,3} given byR = {(1,1), (2,2), (2,3), (3,3)} is reflexive. (All loops are present.)

• Symmetric: The relation R on {1,2,3} given byR = {(1,1), (1,2), (2,1), (1,3), (3,1)} is symmetric.(All paths are 2-way.)

• Transitive: The relation R on {1,2,3} given byR = {(1,1), (1,2), (2,1), (2,2), (2,3), (1,3)} is transitive. (If I can get from one point to another in 2 steps, then I can get there in 1 step.)

10.2.237

Page 238: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Violations of the Properties• Why is R = {(1,1), (2,2), (3,3)} not reflexive on

{1,2,3,4}?

Because (4,4) is missing.

• Why is R = {(1,2), (2,1), (3,1)} not symmetric?

Because (1,3) is missing.

• Why is R = {(1,2), (2,3), (1,3), (2,1)} not transitive?

Because (1,1) and (2,2) are missing.

• Is {(1,1), (2,2), (3,3)} symmetric? transitive?

Yes! Yes!

10.2.238

Page 239: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Transitive Closure

• Definition: Let R be a binary relation on a set A. The transitive closure of R is the binary relation Rt on A satisfying the following three properties:

1. Rt is transitive;

2. R is a subset of Rt;

3. If S is any other transitive relation that contains R, then S contains Rt.

• In other words, the transitive closure of R is the smallest transitive relation containing R.

10.2.239

Page 240: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example of the Transitive Closure

• Given the relation R on {1,2,3,4},

its transitive closure is:

1 2

4 3

1 2

4 3

10.2.240

Page 241: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Properties of Equality

• Consider the Equality (=) relation on R:

Equality is reflexive since for each x R, x = x.

Equality is symmetric since for each x,y R, if x = y, then y = x.

Equality is transitive since for each x,y,z R, if x = y and y = z, then x = z.

• As a graph, the relation contains only loops, so symmetry and transitivity are vacuously satisfied!

10.2.241

Page 242: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Properties of Congruence Mod p

• Let p be an integer greater than 1, and consider the relation on Z given by:

R = {(x,y) | x,y Z and x y mod p}.

• When we say x y mod p, this means (x y) = kp for some integer k.

• Now, R is reflexive since (x x) = 0 = 0p, for all integers x.

• Moreover, R is symmetric, since if x y mod p, then (x y) = kp, thus (y x) = (k)p, implying that y x mod p.

10.2.242

Page 243: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Congruence Mod p (cont’d.)

• Finally, R is transitive. Why?

• Let x y mod p and y z mod p. This means there are integers k and j such that (x y) = kp and (y z) = jp. Hence, (x z) = (x y) + (y z) = kp + jp = (k + j)p. Therefore, x z mod p.

10.2.243

Page 244: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Properties of Inequality

• Consider the Inequality (< or >) relation on R:

Inequality is not reflexive since for no x R is it true that x < x.

Inequality is not symmetric since for each x,y R, if x < y is true, then y < x is false.

Inequality is transitive since for each x,y,z R, if x < y and y < z, then x < z.

• Inequality is so pathelogically unsymmetric, that we define a special property to describe it.

10.2.244

Page 245: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Anti-symmetry Property

• Definition: A relation R on a set A is called anti-symmetric if (x,y) R and (y,x) R implies x = y.

• This is equivalent to requiring that if x y and (x,y) R, then (y,x) R. (All streets are one-way.)

• Example: R = {(1,1), (1,2), (3,2), (3,3)} is anti-symmetric.

• Is every relation symmetric or anti-symmetric?

• No! Consider R = {(1,2), (2,1), (1,3)}.

10.2.245

Page 246: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3: Equivalence Relations

• Definition: Let R be a binary relation on A. R is an equivalence relation on A if R is reflexive, symmetric, and transitive.

• From the last section, we demonstrated that Equality on the Real Numbers and Congruence Modulo p on the Integers were reflexive, symmetric, and transitive, so we can describe them as equivalence relations.

10.3.246

Page 247: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples

• What is the “smallest” equivalence relation on a set A?

R = {(a,a) | a A}, so that n(R) = n(A).

• What is the “largest” equivalence relation on a set A?

R = A A, so that n(R) = [n(A)]2.

10.3.247

Page 248: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Equivalence Classes• Definition: If R is an equivalence relation on a set

A, and a A, then the equivalence class of a is defined to be:

[a] = {b A | (a,b) R}.

• In other words, [a] is the set of all elements which relate to a by R.

• For example: If R is congruence mod 5, then[3] = {..., 12, 7, 2, 3, 8, 13, 18, ...}.

• Another example: If R is equality on Q, then[2/3] = {2/3, 4/6, 6/9, 8/12, 10/15, ...}.

• Observation: If b [a], then [b] = [a].

10.3.248

Page 249: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A String Example• Let = {0,1} and denote L(s) = length of s, for any

string s *. Consider the relation:R = {(s,t) | s,t * and L(s) = L(t)}

• R is an equivalence relation. Why?

• REF: For all s *, L(s) = L(s);SYM: If L(s) = L(t), then L(t) = L(s);TRAN: If L(s) = L(t) and L(t) = L(u), L(s) = L(u).

• What are the equivalence classes of R?

• [], [0], [00], [000], [0000], ...in other words, 0, 1, 2, 3, 4, ...

10.3.249

Page 250: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Relations and Partitions• Recall that a partition of a set is a collection of

mutually disjoint subsets whose union is the original set.

• Equivalence relations and partitions are tied together by the following:

• Definition: Given a partition of a set A, the binary relation induced by the partition isR = {(x,y) | x and y are in the same partition set}.

• Theorem: If A is a set with a partition and R is the relation induced by the partition, then R is an equivalence relation.

10.3.250

Page 251: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Making Equivalence Relations• This example shows how to apply this theorem to

create the induced equivalence relation.

• The collection {{1,2,3}, {4,5}, {6}} is a partition of {1,2,3,4,5,6}. To find the induced equivalence relation, observe:

• {1,2,3} {1,2,3} = {(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3)}

{4,5} {4,5} = {(4,4), (4,5), (5,4), (5,5)}{6} {6} = {(6,6)}

• R = {(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3), (4,4), (4,5), (5,4), (5,5), (6,6)}

10.3.251

Page 252: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Formally Making Equivalence Relations

• Theorem: Let A be a set partitioned by the collection {A1, A2, A3, ...}. Then the equivalence relation induced by the partition is given by: R = (A1 A1) (A2 A2) (A3 A3) ...

• From the last example, the collection{{1,2,3}, {4,5}, {6}} partitioned {1,2,3,4,5,6}, so the induced relation is: R = {1,2,3}{1,2,3} {4,5}{4,5} {6}{6}

10.3.252

Page 253: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Equivalence Classes and Partitions• Theorem: Let A be a set partitioned by the

collection {A1, A2, A3, ...}. If a1A1, a2A2, a3A3, etc., then the equivalence relation induced by the partition is given by:R = ([a1][a1]) ([a2][a2]) ([a3][a3]) ...

• From the last example, the collection{{1,2,3}, {4,5}, {6}} partitioned {1,2,3,4,5,6}, so the induced relation is: R = ([1] [1]) [4] [4]) [6] [6])

10.3.253

Page 254: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Going the Other Way• Theorem: Let A be a non-empty set and let R be

an equivalence relation on A. Then the distinct equivalence classes of R partition A.

• For example, given the relation of congruence mod 5 on the Integers, we obtain the partition:

Z = [0] [1] [2] [3] [4].

• If = {0,1}, what partition of 4 is induced byR = {(s,t) | s,t 4 and density(s) = density(t)}?

4 = [0000][0001][0011][0111][1111]

10.3.254

Page 255: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Functions, Relations & Partitions

• Let f be a function defined on a set A, and consider the relation R={(a,b) | f(a) = f(b)}. Show R is an equivalence relation and describe the partition of A induced by R.

• REF: f(a) = f(a) for all a A;SYM: If f(a) = f(b), then f(b) = f(a);TRAN: If f(a) = f(b) and f(b) = f(c), f(a) = f(c).

• Each partition set contains those elements whose output from f is the same.

10.3.255

Page 256: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

An Example

• Let f be the function on Z, given by f(x) = x4 + 1.

• x: 0 1 2 3 4 ...f(x): 1 2 9 82 257 ...,

• This function induces the partition:Z = {0} {1, 1} {2, 2}

{3, 3} {4,4}...

10.3.256

Page 257: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Graphs & Partitions

• If we generate the directed graph of an equivalence relation just right, then the induced partition jumps out:

1

3

4

2

5

6

10.3.257

Page 258: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 7: Functions

• Functions defined on general sets;

• One-to-one, onto, and inverse functions;

• Composition of functions;

• Cardinality and functions.

7.1.258

Page 259: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1: Functions on General Sets

• Definitions: A function f from set X to set Y is a relation such that each x in X is related to a unique y in Y. We denote this action as f:X Y.

• We call the set X the domain of f, denoted dom(f ), and the set Y, the range of f, denoted ran(f ). The set of actual elements of Y that appear as outputs of f is called the image of f, denoted im(f ) or f(X).

• In summary, dom(f ) = X, ran(f ) = Y and im(f ) = f(X) = {y Y | x X, f(x) = y}.

7.1.259

Page 260: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Arrow Diagrams of Functions

• We use arrow diagrams to illustrate the behaviour of the function:

X = {1,2,3,4} Y={a,b}f = {(1,a),(2,a),(3,b),(4,b)}

X = {1,2,3} Y = {a,b} f(A) = {a}f = {(1,a),(2,a),(3,a)}

123

ab

1234

ab

7.1.260

Page 261: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Equality of Functions

• If f:X Y and g:X Y are functions, then we say f = g provided f(x) = g(x) for each x X.

• Consider f:R R and g:R R given byf(x) = x2) and g(x) = |x|. In this instance, f = g.

• Consider f:R R and g:R R given byf(x) = x (the identity function) and g(x) = |x|.In this case, f and g are equal only for x 0, butf(1) = 1 and g(1) = 1, hence f g.

7.1.261

Page 262: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Functions on Binary Strings

• Let = {0,1} represent the binary alphabet. We consider the following functions involving binary strings:

• Length: L:* N defined as L(s) = length of s.

• Density: d:* N defined as d(s) = # 1’s in s.

• Hamming Distance Function: H:n x n N defined as H(s,t) = # places where s and t disagree.

• For example, L(101100) = 6, d(101100) = 3, andH(101100,100110) = 2.

7.1.262

Page 263: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Hamming Distance Function

• The Hamming Distance function is of fundamental importance in the world of Error Correcting Codes, to find the distance between binary codewords in digital communications.

• H(s,t) can be calculated in two steps:1. Set w = s t;2. Calculate d(w);

• In other words: H(s,t) = d(s t).

• Thus H(101100,100110) = d(001010) = 2.

7.1.263

Page 264: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Boolean Functions

• We can consider the boolean functions we studied in Chapter 1 in the context of our function definition.

• Notation: {0,1}n = {0,1} {0,1} ...{0,1} (n cross products)

• Definition: An (n-place) Boolean function is any f:{0,1}n {0,1}.

• Thus, we can think of the function f(x,y,z) = xy + z’ as a function f:{0,1}3 {0,1}

7.1.264

Page 265: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Boolean Function Example

• In this case, the function f(x,y,z) = xy + z’ is:

111110101100011010001000

0

1

7.1.265

Page 266: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Relations Which Are Not Functions

• The following is an example of a relation that is not a function. Why?

f:R R given by f(x) = (x2).

Not defined for any value in the domain!

• Here is another relation that is not a function. Why?

f:Q Z given by f(p/q) = p.

1/2 = 2/4 = ..., but f(1/2) = 1, f(2/4) = 2, etc.

7.1.266

Page 267: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3: One-to-one, Onto,and Inverse Functions

• In this section, we will look at three special classes of functions and see how their properties lead us to the theory of counting.

• So far, we have the general notion of a function f:X Y, but in terms of the comparative sizes of the three sets involved (X, Y and f ), all we can say is that |f | = |X|.

• In this section, we compare |X| with |Y|.

7.3.267

Page 268: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

One-to-one Functions

• Definition: A one-to-one (injective) function f from set X to set Y is a function such that each x in X is related to a different y in Y.

• More formally, we can restate this definition as either: f :X Y is 1-1 provided

f(x1) = f(x2) implies x1 = x2,or f :X Y is 1-1 provided

x1 x2 implies f(x1) f(x2).

7.3.268

Page 269: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Illustrative Examples

• The function below is 1-1:

This function is not:123

ab

1234

abcde

7.3.269

Page 270: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Proving Functions Are 1-1

• If f:R R is given by f(x) = 3x + 7, prove it is one-to-one.

• Proof: Assume f(a) = f(b). Show a = b.Now f(a) = f(b) means 3a + 7 = 3b + 7, so

3a = 3b, therefore a = b.

• Why is f:R R given by f(x) = x2 not 1-1?

• Since 9 = f(3) = f(-3), but 3 -3, the definition is violated.

7.3.270

Page 271: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Onto Functions

• Definition: A function f:X Yis said to be onto (surjective) if for every y in Y, there is an x in X such that f(x) = y.

• This can be restated as: A function is onto when its image equals its range, i.e. f(X) = Y.

• Examples:

ONTO NOT ONTO

123

01

123

1234

7.3.271

Page 272: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Testing Onto For Infinite Functions

• Show that f:R R given by f(x) = 5x 7 is onto.

• Let y be in R. Then (y + 7) and (y + 7)/5 are also real numbers.

Now f( (y + 7)/5 ) = 5[(y + 7)/5] 7 = y, henceif y is in R, there exists an x in R such that f(x) = y.

• Is f:R R given by f(x) = 1/x onto?

• No! There is no x in R that has output = 0.

7.3.272

Page 273: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

One-to-one Correspondences

• Definition: A function is called a one-to-one correspondence (bijection) if it is one-to-one and onto.

• One-to-one correspondences define the theory of counting. Why?

• If f:X Y is one-to-one, then |X| |Y|, and if fis onto, then |X| |Y|, so if f is both, |X| = |Y|.

• Hence, to count the elements of an unknown set, we create a 1-1 correspondence between the set and a set of known size. Simple!

7.3.273

Page 274: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inverse Functions• Recall that the inverse relation is created by

inverting all the ordered pairs that comprise the original relation.

• When is the inverse of a function itself a function?

1-1 onto both not onto not 1-1 (f 1 is a function)(f 1 not def.) (f 1 not well-def.)

123

1234

1234

123

1234

1234

7.3.274

Page 275: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Finding Inverse Functions

• Theorem: If f:X Y is a one-to-one and onto, then f 1 is a one-to-one and onto function.

• Given f , how do we find f 1?

• Let f:R R be given by f(x) = 4x - 1 = y. Now, swap x and y and solve for y:

4y - 1 = x4y = x + 1y = x + 1

4.

• Thus f 1(x) = (x + 1)/4.

7.3.275

Page 276: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 5: Composition of Functions

• Recall the Hamming distance function, which we calculated as the density of the XOR of two equal length binary strings.

• This functions is calculated by chaining or composing two functions in such a way that the output of the first becomes the input of the second.

• This chaining process demonstrates the composition of two functions.

7.5.276

Page 277: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Composition of Functions

• Definition: Let f:X Y and g:Y Z be functions such that the image of f is a subset of the domain of g. Define the new functiong f:X Z as (g f )(x) = g( f (x)) for all x in X.We call g f the composition of f and g, putting f first since it acts upon x first.

x f (x) g f (x)

XY Z

7.5.277

Page 278: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example on Finite Sets

• Let f = {(1,4),(2,3),(3,4),(4,5),(5,6)} and g = {(1,3),(2,5),(3,1),(4,2),(5,3),(6,4)}. Then g f = {(1,2),(2,1),(3,2),(4,3),(5,4)}

12345

12345

123456

f g

7.5.278

Page 279: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Example on Infinite Sets

• If f:R R is given by f (x) = 3x + 7, and g:R R given by g(x) = x2, then

(g f )(x) = g(f (x)) = g(3x + 7) = (3x + 7)2, and

(f g )(x) = f (g(x)) = f (x2) = 3x2 + 7.

• Note: this example illustrates that in general: (g f )(x) (f g )(x),

since (3x + 7)2 3x2 + 7

7.5.279

Page 280: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Identity Functions• Definition: Given a set X, the identity function on

X, iX:X X is the function iX(x) = x.

• In pictures: If X = {1,2,3,4} then

• When composing the identity function with a general function f:X Y, we see f iX = f andiY f = f.

1234

1234

iX

7.5.280

Page 281: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inverse Functions

• Definition: Given a one-to-one and onto function f:X Y, the inverse function of f, is the function f 1:Y X such that f f 1 = iY and f 1 f = iX.

• In pictures:

1234

1234

1234

f f 1

7.5.281

Page 282: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Composition of 1-1 Functions

• Theorem: Given one-to-one functions f:X Y, and g:Y Z, then the composition g f: X Z is a one-to-one function.

• In pictures:

1234

56789

101112131415

f g

7.5.282

Page 283: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Composition of Onto Functions

• Theorem: Given onto functions f:X Y, and g:Y Z, then the composition g f: X Z is an onto function.

• In pictures:

f gX Y Z

7.5.283

Page 284: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 6: Counting

• Counting and probability;

• Possibility trees & the Multiplication Rule;

• The Addition Rule;

• Inclusion/Exclusion Rule;

• Permutations and combinations;

• Generalized permutations and combinations;

• Pascal’s Triangle & Combinatorial Identities.

6.1.284

Page 285: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1: Counting and Probablilty

• Imagine tossing a coin and noting the results (Heads or Tails) repeatedly.

• You expect the outcome of each toss to be independent of any previous toss.

• You expect that either H or T is equally likely at any toss, so a given collection of outcomes occurred at random.

• A sample space is the set of all possible outcomes of a random process, and an event is a subset of the sample space.

6.1.285

Page 286: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Probability

• If S is a finite sample space in which all outcomes are equally likely and E is an event in S, then the probability of event E is P(E) = |E| / |S|.

• For example, if we toss our coin twice and record the outcomes, then S = {HH, HT, TH, TT}. Now if we ask what is the probability the two tosses match, then E = {HH, TT}, so P(E) = 2/4 = 0.5.

• The odds of an event are (# way for):(# ways not) so O(E) = |E|:(|S| |E|). Thus the odds of flipping the coin twice to match is 2:(4 2) = 2:2 = 1:1.

6.1.286

Page 287: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Probabilities for Playing Cards

• Many interesting counting problems involve the standard 52-card deck of playing cards: 2 red suits (Diamonds and Hearts), 2 black suits (Clubs and Spades) with 13 values (2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace) in each suit. The Jack, Queen, King, and Ace cards are called face cards.

• P(Black face card) = 8/52 = 2/13.

• P(Ace) = 4/52 = 1/13.

• P(Royal Straight Flush) = ???

6.1.287

Page 288: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Probablilties for Dice

• Consider the case of rolling two 6-sided dice:

1 2 3 4 5 6 1 2 3 4 5 6 7 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 6 7 8 9 10 11 12

• P(7) = 6/36 = 1/6 P(12) = 1/36

• P(at least 1 die = 6) = 11/36

6.1.288

Page 289: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Elements in a List

• How many integers from 1 to 100, inclusive?

• 100 is the answer, but 100 1 = 99. Need to correct for the missing endpoint.

• Theorem: If m and n are integers with m n, then there are (n m + 1) integers from m to n.

• Hence 100 1 + 1 = 100.

• From 5 to 18? 18 (5) + 1 = 24.

6.1.289

Page 290: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 2: The Multiplication Rule

• Consider the game of tossing a coin, then rolling a die, then picking a card. One possible event would be (H, 2, 2clubs). How many events are in the sample space?

• One way to visualize this counting problem is to construct a possibility tree, where each intermediate leaf branches out successively according to the type of event generated at that stage.

6.2.290

Page 291: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Coin - Die - Card Possibility Tree(Start)

Heads Tail

1 2 3 4 5 6 1 2 3 4 5 6

2c...As 2c...As ... 2c...As

6.2.291

Page 292: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Multiplication Rule

• The total number of ways of generating output from this last example is obtained by counting the number of leaves at the end of the tree. Clearly in this case the number is 2652 = 624 events.

• The Multiplication Rule: If event1 can be done e1 ways and event2 can be done e2 ways, then the number of ways to complete event1 AND event2 is e1e2 ways.

• The key observations is that AND leads us to multiply the counts.

6.2.292

Page 293: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

License Plates

• Suppose Maryland issued auto license plates using the following scheme:

Letter Letter Letter Digit Digit Digit(where Letter = A,B,...,Z and Digit = 0,1,2,...,9).

• How many possible license plates could be issued without duplication?

Answer: 26

• How about Letter Digit Letter Digit Letter Digit?

Answer: 26

6.2.293

Page 294: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Cartesian Products & Strings• If a set A has m elements and a set B has n

elements, how many elements are in A B?

• We view this as taking an element from A and then taking an element from B, the multiplication rule applies: |A B| = |A||B| = mn.

• If is an alphabet, how many elements in 6?

• We model this as: __ __ __ __ __ __, where each slot can be filled in one of the elements of .Therefore |6| = |||||||||||| = ||6.

• In general, we see that |n| = ||n.

6.2.294

Page 295: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Permutations

• A permutation of a collection of objects is an ordering of the objects in a row.

• Equivalently, a permutation is a one-to-one and onto mapping of a set to itself.

List: abcde acdbe

abcde

abcde

BijectiveFunction:

6.2.295

Page 296: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Permutations

• To count how many permutations (orderings) of n things there are, consider it in terms of filling in slots:

n (n-1) (n-2) ... 3 2 1 .

• We denote this product n(n1)(n2)... 321 as n! (read “n factorial”).

• Hence the number of different orderings of 6 distinct books on a shelf is 6! = 654321 = 720.

• We define 0! = 1 because it makes things work.

6.2.296

Page 297: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

More Counting Permutations• How many orderings of the letters of the word

COMPUTER are there? C O M P U T E R

Answer: 8! = 40,320

• How many orderings of the letters of the word COMPUTER are there if the letters CO must stay together in this order? CO M P U T E R

Answer: 7! = 5,040

• What is the probablilty the CO will appear in a given permutation of the letters of COMPUTER?

Answer: 7!/8! = 7!/(87!) = 1/8.

6.2.297

Page 298: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Circular Permutations• Permutations are a linear ordering. However, we

can ask how many ways can we order things around a circle (or other closed polygon).

• In this case, the number of ways to arrange n things in a circle (square, hexagon, etc.) is (n1)! since placing the first element does not matter.

• Consider ABCDE around a circle: A E B

D C

E D A

C B

D C E

B A

C B D

A E

B A C

E D

6.2.298

Page 299: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Partial Permutations• What happens if we don’t want to list out all n

elements in a linear permutation. Suppose we only want the first r elements, where r < n.

______ ______ ______ ... ______ n0 n1 n2 nr1)

• Total = n(n1)(n2)...(nr+1) = n(n1)(n2)...(nr+1)[(nr)!/(nr)!] = n!/(nr)!

• We denote the partial permutation P(n,r).

• Theorem: P(n,r) = n(n1)...(nr+1) = n!/(nr)!

6.2.299

Page 300: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Evaluating of Partial Permutations• How many 5-letter strings can be formed from the

letters of COMPUTER?

Answer: P(8,5) = 8!/(85)! = 8!/3! = 87654

• How many 6-character license plates can be made if a character can be a letter or digit, but no character can repeat?

Answer: P(36,6) = 36!/30! = 363534333231

• When do you use which formula:– Use n!/(nr)! when the form of the answer counts.– Use the expanded product to actually calculate.

6.2.300

Page 301: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Summary• Multiplication Rule: If there are m ways to do A

and n ways to do B, then there are (mn) ways to do A and B. (order matters & repetition allowed)

• Permutations (order matters & NO repetition): – There are n! linear orderings of n things.– There are n!/n = (n1)! circular orderings of n things.– There are P(n,r) = n!/(nr)! orderings of r things from

a total of n things.

6.2.301

Page 302: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3: Counting Elements in Disjoint Sets

• In the last section, we looked at counting events that branch from one state to the next. These events we modelled using possibility trees and obtained counts using the Multiplication Rule.

• In this section, we will learn how to count elements in the union, difference, or intersection of two sets using the Addition Rule.

• We will also look at counting when set operations are acting upon subset structures.

6.3.302

Page 303: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Addition Rule• Theorem: Suppose a finite set A is partitioned by

the collection {A1, A2, ..., An}. Then:n(A) = n(A1) + n(A2) +...+ n(An).

• How many binary strings of length up to and including 4 are there?

Answer: 4 = 0 1 2 3 4, and i j = if i j, so

|4| = |0| + |1| + |2| + |3| + |4|

= 20 + 21 + 22 + 23 + 24 = 1 + 2 + 4 + 8 + 16 = 31.

6.3.303

Page 304: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Another Example

• Let D be set of 3-digit integers (from 100 to 999) which are divisible by 5. How big is D?

• Solution: We know an integer is divisible by 5 if it ends in a 0 or 5. Let’s call a typical 3-digit integer abc, where a is one of {1,2,3,4,5,6,7,8,9},and b is one of {0,1,2,3,4,5,6,7,8,9}.

• Now, we partition D into those integers of the form ab0 and those of the form ab5. The first set has 910 elements and the second set has 910 elements, hence D has 180 elements.

6.3.304

Page 305: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

License Plates

• We have already used the addition rule without realizing it in the last section. When we are counting the number of license plates with certain properties and allow a particular character to be either a digit or a letter, we have applied the addition rule:

• The slot drawing (Digit or Letter) (Digit or Letter) ...

gives us the counts (26 + 10) (26 + 10)...

6.3.305

Page 306: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Difference Rule• Consider the following:

so |A| = |A1| + |A2|.

• Now, in the addition rule, we know |A1| and |A2| and use this to find |A|. But if we know |A| and either |A1| or |A2|, then we get:

• Difference Rule: If A1 and A2 partition A, then|A2| = |A| |A1| and |A1| = |A| |A2|.

A1 A2

A

6.3.306

Page 307: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Things Without a Condition

• How many 3-digit integers are not divisible by 5?

• Before, we saw that there are 180 3-digit integers which are divisible by 5, hence:

{all 3-digit integers not divisible by 5}= {all 3-digit integers}

{all 3-digit integers divisible by 5}.

• Therefore there are (999 100 + 1) 180 = 720 3-digit integers which are not divisible by 5.

6.3.307

Page 308: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Another Complement Example• How many ways can 4 couples sit around a

circular table if one couple cannot be seated next to each other?

• Solution: We see that {seatings w/ couple apart} = {all seatings} {seating w/ couple together}

• Label the people abcdefgh and suppose couple ab cannot sit together. Thus we want to count how to seat Xcdefgh around a table, then repeat it since X represents both the ab and ba orderings.

• Answer = 7! 6! 6! = 7! 26!.

6.3.308

Page 309: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Probability Example• Suppose there are 10,000 total ways to carry out

an experiment with 2,123 of those experiments leading to success. What is the probability the experiment will fail?

• Solution: Starting from the sample space, we get: |{all experiments}| = |{successes}| + |{failures}|,

• Dividing boths sides by the LHS, we see that:1 = P(success) + P(failure), so

P(failure) = 1 P(success) = 1 0.2123 = 0.7877.

• We find there is a 78.77% probability of failure.

6.3.309

Page 310: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inclusion/Exclusion Rule• So far, our counting under the addition and

subtraction rules have required that the files in question are disjoint.

• This is an unreasonable requirement in general.

• How do we account for the aggregrate knowing the parts that make it up?

• Inclusion/Exclusion Rule: For any sets A and B,|A B| = |A| + |B| |A B|.

A A B B

A B

6.3.310

Page 311: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inclusion/Exclusion Example• How many 6-character license plates begin with

“A” or end with “9”?

• Effectively, we want to count all plates of the forms Axxxxx or xxxxx9, but recognizing that these individual cases overlap for plates of the form Axxxx9.

• Now |{Axxxxx}| = 365, and |{xxxxx9}| = 365, and |{Axxxx9}| = 364, hence the total number of plates is 2365 - 364.

6.3.311

Page 312: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

What About For 3 Sets?

• Thus |A B C| = |A| + |B| + |C| (1+4+6+7+2+4+5+7+3+5+6+7) |AB| |AC| |BC| (475767)+ |ABC| (+7)

• 1+4+6+7+2+4+5+7+3+5+6+7475767+7= 1+2+3+4+5+6+7.

1 4

76

2

5

3

• Using the labeling in the above drawing, we see that A = 1 4 6 7, B = 2 4 5 7, and C = 3 5 6 7.

6.3.312

Page 313: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Inclusion/Exclusion Rule for 3 Sets• If A, B, and C are sets, then: |A B C| = |A|+|

B|+|C||AB||AC||BC|+|ABC|.

• Example: The CS department teaches Algol, Basic, and C languages. Suppose:– 22 students study Algol; 30 study Basic; 42 study C;– 12 study Algol and Basic;– 18 study Basic and C;– 16 study Algol and C;– 9 study all three.

• How many students study a language?

• Answer: 57 = 22+30+42121816+9.

6.3.313

Page 314: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 4: Counting Subsets of a Set

• In Section 2, we looked at counting events with or without repetition, but in either instance the order of the elements mattered.

• Now, we shall relax the order restriction to allow counting set structures where events are not distinguished by the order of elements, but by the mere clustering of elements together.

• This will lead to the last rule, the Division Rule (not in the text!).

6.4.314

Page 315: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Division Rule• Theorem: Suppose a set A has n elements and is

partitioned by the collection {A1, A2, ..., Ap}, where each partition set has m elements. Then:

p = n/m.

• In other words, if a set is partitioned into equal-sized partition sets, then the number of partition sets is the quotient of the size of the set with the size of any partition set.

• For example, if a set has 100 elements and is partitioned in 20-element subsets, then there must be 5 subsets (equivalence classes).

6.4.315

Page 316: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Subsets

• How many 3-element subsets of a 4-element set are there:

• Let A = {1,2,3,4} then all 3-permutations are:123, 132, 213, 231, 312, 321 {1,2,3}124, 142, 214, 241, 412, 421 {1,2,4}134, 143, 314, 341, 413, 431 {1,3,4}234, 243, 324, 342, 423, 432 {2,3,4}.

• Hence # 3-element subsets= (# 3-permutations) / (# 3-orderings)= P(4,3) / 3! = 4! / (1!3!) = 4! / 3! = 4.

6.4.316

Page 317: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Combinations

• What we have just counted is a combination. In this instance, it was a combination of 4 elements taken 3 at a time.

• We use the Division Rule to negate the order condition of the permutation counts.

• In general, C(n,k) = P(n,k) / k!

• Equivalently, we use the “choose” notation to get: n!k!(n k)!

nk( ) =

6.4.317

Page 318: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

More Counting Subsets• How many subsets of a 10-element set have 3

elements? How many have 7 elements?

• Solution: C(10,3) = 10! / (3!7!)C(10,7) = 10! / (7!3!), the same!

• Note: Counting subsets containing 3 elements is the same as counting subsets NOT containing the other 7 elements!

• Theorem: C(n,k) = C(n,nk).

• How many subsets have at least 8 elements?

• Solution: C(10,8) + C(10,9) + C(10,10)

6.4.318

Page 319: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Binary Strings

• How many 10-bit strings have three 1’s?

• Solution: We model this as requiring us to choose three of the ten slots to place a 1 then the other seven remaining slots will get a 0. Thus the number of 10-bit strings that have three 1’s is C(10,3) = 10! / (3!7!).

• In general, the number of n-bit binary strings with density k is C(n,k).

• As before, having k 1’s is the same thing as having (n k) 0’s.

6.4.319

Page 320: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Teams • Suppose a group of 5 men and 7 women want to

pick a 5-person team.

• How many teams can they make with 3 men and 2 women?• C(5,3)C(7,2) = [5!/(3!2!)][7!/(5!2!)] = 7!/(3!2!2!).

• How many teams have at least 1 man?• (All teams w/no man) = C(12,5) C(7,5)

= [12!/(7!5!)] [7!/(5!2!)]

• How many teams have at most 1 man?• (teams w/no man) + (teams w/1 man)

= C(7,5) + C(5,1)C(7,4) = 7!/(5!2!) + [5!/4!][7!/(3!4!)]

6.4.320

Page 321: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalized Permutations• In Section 2, we learned how to count the number

of orderings of the letters of COMPUTER. What about the number of orderings of the letters of MISSISSIPPI?

• In this case, we note that not all the letters are distinct. In particular,

MISSISSIPPI IIIISSSSPPM, so although we are still searching for an ordering structures, there are sub-unorderings present, induced by the repeated letters, for which we have to account.

6.4.321

Page 322: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalized Permutations Take 1• Let’s apply the Division Rule to negate the effect

of the unordering portions of the overall order problem.

• This leaves us with a total count of 11!/4!4!2!.

• Here, the first quotient of 4! “mods” out the effect of the unordered I’s, the second quotient of 4! “mods” out the effect of the unordered S’s, and the last quotient of 2! “mods” out the effect of the unordered P’s.

6.4.322

Page 323: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalized Permutations Take 2• If we model this problem, purely as a combination,

and not a permutation at all, we can reason the task as:

1. Choose 4 slots from 11 for the I’s;2. Choose 4 slots from the remaining 7 for the S’s;3. Choose 2 slots from the remaining 3 for the P’s;4. Place the M (only 1 way remaining).

• This yields: C(11,4)C(7,4)C(3,2)C(1,1) =(11!7!3!)/(7!4!4!3!2!1!) = 11!/(4!4!2!).

6.4.323

Page 324: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalized Permutation Theorem• Theorem: Suppose a collection consists of n

objects of which:n1 are of type 1, indistinguishable from each other; n2 are of type 2, indistinguishable from each other; ...nk are of type k, indistinguishable from each other;and n1 + n2 + ... + nk = n. Then the number of distinct permutations of the n objects is:C(n,n1)C(nn1,n2)C(nn1n2,n3)...C(nk,nk) =

n! / (n1!n2!n3!...nk!).

6.4.324

Page 325: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 5: Combinations with Repetition

• In the last section, we saw how to count combinations, where order does not matter, based on permutation counts, and we saw how to count permutations where repetitions occur.

• Now, we shall consider the case where we don’t want order to matter, but we will allow repetitions to occur.

• This will complete the matrix of counting formulae, indexed by order and repetition.

6.5.325

Page 326: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Motivating Example• How many ways can I select 15 cans of soda

from a cooler containing large quantities of Coke, Pepsi, Diet Coke, Root Beer and Sprite?

• We have to model this problem using the chart: Coke Pepsi Diet Coke Root Beer Sprite

A: 111 111 111 111 111 =15

B: 11 111111 111111 1 =15

C: 1111 1111111 1111 =15

• Here, we set an order of the categories and just count how many from each category are chosen.

6.5.326

Page 327: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Motivating Example (cont’d.)• Now, each event will contain fifteen 1’s, but we

need to indicate where we transition from one category to the next. If we use 0 to mark our transitions, then the events become:

A: 1110111011101110111

B: 1100111111011111101

C: 0011110111111101111

• Thus, associated with each event is a binary string with #1’s = #things to be chosen and #0’s = #transitions between categories.

6.5.327

Page 328: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Counting Generalized Combinations

• From this example we see that the number of ways to select 15 sodas from a collection of 5 types of soda is C(15 + 4,15) = C(19,15) = C(19,4).

• Note that #zeros = #transitions = #categories 1.

• Theorem: The number of ways to fill r slots from n catgories with repetition allowed is:

C(r + n 1, r) = C(r + n 1, n 1).

• In words, the counts are:C(#slots + #transitions, #slots)

or C(#slots + #transitions, #transitions).

6.5.328

Page 329: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Another Example

• How many ways can I fill a box holding 100 pieces of candy from 30 different types of candy?

Solution: Here #slots = 100, #transitions = 30 1,so there are C(100+29,100) = 129!/(100!29!) different ways to fill the box.

• How many ways if I must have at least 1 piece of each type?

Solution: Now, we are reducing the #slots to choose over to (100 30) slots, so there are C(70+29,70) = 99!/70!29!

6.5.329

Page 330: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

When to Use Generalized Combinations

• Besides categorizing a problem based on its order and repetition requirements as a generalized combination, there are a couple of other characteristics which help us sort:

– In generalized combinations, having all the slots filled in by only selections from one category is allowed;

– It is possible to have more slots than categories.

6.5.330

Page 331: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Integer Solutions to Equations• One other type of problem to be solved by the

generalized combination formula is of the form:How many non-negative integer solutionsare there to the equation a + b + c + d =

100.• In this case, we could have 100 a’s or 99 a’s and 1

b, or 98 a’s and 2 d’s, etc.• We see that the #slots = 100 and we are ranging

over 4 categories, so #transitions = 3.• Therefore, there are C(100+3,100) = 103!/100!3!

non-negative solutions to a + b + c + d = 100.

6.5.331

Page 332: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Integer Solutions with Restrictions

• How many integer solutions are there to:a + b + c + d = 15,

when a 3, b 0, c 2 and d 1?

• Now, solution “strings” are 111a0b011c01d, where the a,b,c,d are the remaining numbers of each category to fill in the remaining slots.

• However, the number of slots has effectively been reduced to 9 after accounting for a total of 6 restrictions.

• Thus there are C(9+3,9) = 12!/(9!3!) solutions.

6.5.332

Page 333: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

More Integer Solutions & Restrictions

• How many integer solutions are there to:a + b + c + d = 15,

when a 3, b 0, c 2 and d 1?

• In this case, we alter the restrictions and equation so that the restrictions “go away.” To do this, we need each restriction 0 and balance the number of slots accordingly.

• Hence a 3+3, b 0, c 2+2 and d 1+1,yields a + b + c + d = 15+3+2+1 = 21

• So, there are C(21+3,21) = 24!/(21!3!) solutions.

6.5.333

Page 334: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Summary

• Theorem: The number of integer solutions to:a1 + a2 + a3 +...+ an = r,

when a1 b1, a2 b2, a3 b3 , ..., an bn isC(r+n1b1b2b3...bn , rb1b2b3...bn).

• Theorem: The number of ways to select r things from n categories with b total restrictions on the r things is C(r + n 1 b , r b).

• Corollary: The number of ways to select r things from n categories with at least 1 thing from each category is C(r 1 , r n) (set b = n).

6.5.334

Page 335: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 6: The Algebra of Combinations

• In this section, we will look at some identities involving the choosery function. We will also resurrect Pascal’s Triangle and see how it relates to combinations.

• Three Simple Calculations:

C(n,n) = n! / [n!(nn)!] = n!/(n!0!) = n!/n! = 1.

C(n,1) = n! / [1!(n1)!] = [n(n1)!] / (n1)! = n.

C(n,2) = n! / [2!(n2)!] = [n(n1)(n2)!] / [2(n2)!]= n(n1)/2.

6.6.335

Page 336: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Half-empty Set• We have already seen and used the identity:

C(n,r) = C(n,nr).

• This identity is easy to demonstrate algebraically.

• However, we can reason it combinatorically.

• We use C(n,r) to count how many subset of size r an n-element set A has. But we can identify uniquely with any r-element subset B of A the (nr)-element subset that is its complement, AB. Moreover, this identification is a bijection. (Why?) Hence, the number of r-element subsets equals the number of (nr)-element subsets.

6.6.336

Page 337: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Using Substitutions• We have seen the identity C(n,2) = n(n1)/2.

• Combining this with C(n,2) = C(n,n2), we see that C(n,n2) = n(n1)/2.

• We can now use this to get related identities by substituting “interesting” values for n:

n n+1: C(n+1,n1) = n(n+1)/2.

n n1: C(n1,n3) = (n1)(n2)/2.

n n+2: C(n+2,n) = (n+2)(n+1)/2.

6.6.337

Page 338: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Pascal’s TriangleRecall the number array we call Pascal’s Triangle:

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

Rule of generation: T(n,r) = T(n1,r1) + T(n1,r).

6.6.338

Page 339: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Using Pascal’s Triangle• One application of Pascal’s Triangle is to find the

coefficients of the binomial expansion (a + b)n.

• For example, to expand (a + b)5 we look at the 6th row: 1,5,10,10,5,1 to get:

1a5 + 5a4b + 10a3b2 + 10a2b3 + 5ab4 + 1b5.

• However, the Binomial Theorem tells us each of these coefficients is of the form C(5,r).

• Thus each term of Pascal’s Triangle is actually a combination, that is T(n,r) = C(n,r).

6.6.339

Page 340: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Pascal’s Formula• Now, if we replace the the T(n,r) terms of the rule

of generation with the binomial coefficients, we get: C(n,r) = C(n1,r1) + C(n1,r).

• Proof: C(n1,r1) + C(n1,r)

= (n1)!/(r1)!(n1r+1)! + (n1)!/r!(nr1)!

= (n1)!/(r1)!(nr)! + (n1)!/r!(nr1)!

[want (r1)! r! want (nr1)! (nr)!]

= (n1)!r/r!(nr)! + (n1)!(nr)/r!(nr)!

= [(n1)!(r + n r)] / r!(nr)!

= (n1)!n / r(nr)! = n!/r!(nr)! = C(n,r).

6.6.340

Page 341: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Chapter 8: Recursion

• Recursively defined sequences;

• The Iteration Method to solve recurrence relations;

• Solve linear, homogeneous recurrence relations;

• Count Fibonacci’s bunnies.

8.1.341

Page 342: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 1: Recursively Defined Sequences

• In Chapter 4, we looked at sequences, although most of them were generated by a function.

• In this section, we will study sequences where new terms are calculated based on the values of predecessor terms.

• Definition: A recurrence relation for a sequence a1, a2, ..., an, is a formula that calculates each term ak in terms of ak1,ak2,...,aki, for some integer i. The initial conditions for a recurrence relation specify values for a1, a2, ..., ak1.

8.1.342

Page 343: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Examples of Recurrence Relations• To actually determine the sequence specified by a

recurrence relation, you need:(1) the relation: an = an1 + an2, and(2) initial conditions: a0 = 1 and a1 = 3.

This example yields the sequence: 1, 3, 4, 7, 11, 18, 29, ...

• If we keep the same recurrence relation, but change our initial conditions (say a0 = 2, a1 = 5), we get a completely different sequence:

2, 5, 3, 8, 11, 19, 30, ...

8.1.343

Page 344: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Different Representations• We can specify a sequence using essentially the

same recurrence relation, but in different ways if we get “unstuck” in time.

• Consider these two descriptions of the same sequence:

(1) sk = (3sk1 1), for all integers k 1;(2) sk+1 = (3sk 1), for all integers k 0.

• If we let s1 = 1, (1) becomes 1, 2, 5, 14, 41, ...

• If we let s0 = 1, (2) becomes 1, 2, 5, 14, 41, ...

8.1.344

Page 345: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Tower of Hanoi• Here is a game that generates a recurrence

relation.

• The Tower of Hanoi consist of a collection of disks with holes in the middle placed on a board with three vertical posts. The disks are such that they can be placed on a single post and from the bottom up, each successive disk has decreasing diameter.

8.1.345

Page 346: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Tower of Hanoi (cont’d.)

• The game is to move the tower of disks from one post to another using the rules that you can only move 1 disk at a time and you cannot place a disk of larger diameter on top of a smaller disk.

• How many moves (mn) will it take to solve the n-disk Tower of Hanoi?

• Clearly m1 = 1.

• Now, claim m2 = 3. Why?

• (1,2)()() (2)(1)() ()(1)(2) ()()(1,2).

8.1.346

Page 347: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Tower of Hanoi (cont’d.)

• How about the 3-disk Tower of Hanoi?

• (1,2,3)()() (2,3)(1)() (3)(1)(2) (3)()(1,2) ()(3)(1,2) (1)(3)(2) (1)(2,3)() ()(1,2,3)().

• Thus, m3 = 7.

• This example illustrates the recursive nature of the game: To solve the 3-disk problem, we solve the 2-disk problem, then move disk 3, then solve the 2-disk problem again. So m3 = 2m2 + 1.

• Continuing this logic, we see mn= 2mn1 + 1.

8.1.347

Page 348: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Fibonacci Numbers• Leonardo of Pisa, son of Bonacci (and hence,

Fibonacci), posed the following in 1202:– A single pair of rabbits (a male and a female) are born

at the beginning of the year. Rabbit pairs are fertile one month after their birth, and produce one mixed pair each month thereafter. The rabbit population suffers no deaths during the course of the year.

• How many rabbits will there be at the end of the year?

• Clearly, at the end of any given month:#rabbits = #alive at the beginning + #babies.

8.1.348

Page 349: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Fibonacci Numbers (cont’d.)• Suppose the number of pairs of rabbits alive at the

beginning of month k is Fk. Then:

(a) F0 = 1

(A) F1 = 1

(A,b) F2 = 1 + 1 = 2

(A,B,c) F3 = 1 + 1 + 1 = 3 = F2 + 1 = F2 + F1

(A,B,C,d,e) F4 = 3 + 1 + 1 = 3 + 2 = 5 = F3 + F2

(A,B,C,D,E,f,g,h) F5 = 5 + 3 = F4 + F3.

• In general: Fk = Fk1 + Fk2 , so the sequence is:1,1,2,3,5,8,13,21,34,55,89,144,233 = 1 year!

8.1.349

Page 350: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Solving Recurrence Relations• The last example nicely illustrates why we want to

“solve” recurrence relations; that is, obtain an expression for the general term (Fn) that only depends on n and not Fn1, Fn2, Fn3, ...

• To find a term like F13, it requires us to find all the predecessor terms, a tedious and uninteresting task.

• What if we had to find F1,000,000?????

• From here on, we will develop methods to solve recurrence relations, so we won’t need to plug in values again and again.

8.1.350

Page 351: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 2: Solving RecurrenceRelations by Iteration

• As we noted at the end of the last lecture, when analyzing recurrence relations, we want to rewrite the general term as a function of the index and independent of predecessor terms.

• This will allow us to compute any arbitrary term in the sequence without having to compute all the previous terms.

• In this section, we will look at one method for solving recurrence relations.

8.2.351

Page 352: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Method of Iteration• Let {ai} be the sequence defined by:

ak = ak1 + 2 with a0 = 1.

• Plugging values of k into the relation, we get:a1 = a0 + 2 = 1 + 2a2 = a1 + 2 = 1 + 2 + 2 = 1 + 2(2)a3 = a2 + 2 = 1 + 2 + 2 + 2 = 1 + 3(2)a4 = a3 + 2 = 1 + 2 + 2 + 2 + 2 = 1 + 4(2)

• Continuing in this fashion reinforces the apparent pattern that an = 1 + n(2) = 1 + 2n.

• This brute force technique is the Method of Iteration.

8.2.352

Page 353: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

The Tower of Hanoi• Recall the Tower of Hanoi relation:

mk = 2mk1 + 1 with m1 = 1.

• Plugging values of k into the relation, we get:m2 = 2m1 + 1 = 2 + 1m3 = 2m2 + 1 = 2(2 + 1) + 1 = 22 + 2 + 1m4 = 2m3 + 1 = 2(22 + 2 + 1) + 1

= 23 + 22 + 2 + 1 m5 = 2m4 + 1 = 2(23 + 22 + 2 + 1)

= 24 + 23 + 22 + 2 + 1.

• Thus, we guess: mn = 2n1 + 2n2 +...+ 22 + 2 + 1.

• This is a Geometric Series, so mn = 2n 1.

8.2.353

Page 354: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Another Example• Let {ai} be the sequence given by:

ak = ak1 + k with a0 = 0.

• Solve this recurrence relation and find a100.

• Now,a1 = a0 + 1 = 1 + 0

a2 = a1 + 2 = 2 + 1 + 0

a3 = a2 + 3 = 3 + 2 + 1 + 0

a4 = a3 + 4 = 4 + 3 + 2 + 1 + 0

• Thus an = n + (n1) + (n2) +...+ 3 + 2 + 1 + 0so an = n(n+1)/2.

• Plugging in n = 100: a100 = 100(101)/2 = 5050.

8.2.354

Page 355: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Geometric Sequence• Let a and b be non-zero constants, and consider:

sk = ask-1 with s0 = b.

• Thus: s1 = as0 = ab

s2 = as1 = a(ab) = a2b

s3 = as2 = a(a2b) = a3b

s4 = as3 = a(a3b) = a4b.

• From this, we can make the conjecture that:sn = anb.

• Note: if b = 1, then sn = an.

8.2.355

Page 356: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

A Perturbed Geometric Sequence• Let a be non-zero constants, and consider:

sk = ask-1 + 1 with s0 = 1.

• Thus: s1 = as0 + 1 = a + 1

s2 = as1 + 1 = a(a + 1) + 1 = a2 + a + 1

s3 = as2 + 1 = a(a2 + a + 1) + 1 = a3 + a2 + a + 1

s4 = as3 + 1 = a(a3 + a2 + a + 1) = a4 + a3 + a2 + a + 1.

• It appears that sn = an + an1 +...+ a2 + a + 1, so sn = (an1 1) / (a 1) .

8.2.356

Page 357: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Some Observations• In solving these recurrence relations, we point out

the following observations:1. Each recurrence relation looks only 1 step back; that is

each relation has been of the form sn = F(sn1);

2. We have relied on luck to solve the relation, in that we have needed to observe a pattern of behavior and formulated the solution based on the pattern;

3. The initial condition has played a role in making this pattern evident;

4. Generating a formula from the generalization of the pattern looks back to our study of induction.

8.2.357

Page 358: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Verifying Solutions• Once we “guess” the form of the solution for a

recurrence relation, we need to verify it is, in fact, the solution.

• We use Mathematical Induction to do this.

• For example, in the Tower of Hanoi game, we conjecture that the solution is mn = 2n 1.

• Basis Step: m1 = 1 (by playing the game), and21 1 = 2 1 = 1, therefore m1 = 21 1.

• Inductive Step: Recall the recurrence relation is mk = 2mk1 + 1. Assume mk = 2k 1.

8.2.358

Page 359: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Verifying Solutions (cont’d.)

• Inductive Step: Show mk+1 = 2k+1 1.

Now, mk+1 = 2mk + 1= 2(2k 1) + 1= 22k 2 + 1= 2k+1 1.

Therefore mk = 2k 1 is the solution tomk = 2mk1 + 1, when m1 = 1. QED

• A similar verification process will work for all the other formulas we discovered in this section.

8.2.359

Page 360: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Section 3: Linear, HomogeneousRecurrence Relations

• So far, we have seen that certain simple recurrence relations can be solved merely by interative evaluation and keen observation.

• In this section, we seek a more methodical solution to recurrence relations.

• In particular, we shall introduce a general technique to solve a broad class of recurrence relations, which will encompass those of the last section as well as the tougher Fibonnaci relation.

8.3.360

Page 361: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Linear, Homogeneous Recurrence Relations with Constant Coefficients• If A and B (0) are constants, then a recurrence

relation of the form: ak = Aak1 + Bak2

is called a linear, homogeneous, second order, recurrence relation with constant coefficients.

• We will use the acronym LHSORRCC.

• Linear: All exponents of the ak’s are 1;

• Homogeneous: All the terms have the same exponent.

• Second order: ak depends on ak1 and ak2;

8.3.361

Page 362: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Higher Order Linear, Homogeneous Recurrence Relations

• If we let C1, C2, C3, ..., Cn be constants (Clast 0), we can create LHRRCC’s of arbitrary order.

• As we shall see, the techniques the book develops for second order relations generalizes nicely to higher order recurrence relations.

• Third order: ak = C1ak1 + C2ak2 + C3ak3

• Fourth order: ak = C1ak1 + C2ak2 + C3ak3 + C4ak4

• nth order: ak = C1ak1 + C2ak2 + ... + Cnakn;

8.3.362

Page 363: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Solving LHSORRCC’s• Let’s start with the second order case before we

generalize to higher orders.

• Definition: Given ak = Aak1 + Bak2, the characteristic equation of the recurrence relation is x2 = Ax + B, and the characteristic polynomial of the relation is x2 Ax B.

• Theorem: Given ak = Aak1 + Bak2, if s,t,C,D are non-zero real numbers, with s t, and s,t satisfy the characteristic equation of the relation, then its General Solution is an = C(sn)+ D(tn).

8.3.363

Page 364: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

An Example• Let ak = 5ak1 6ak2. Find the general solution.

• The relation has characteristic equation: x2 = 5x 6,

so x2 5x 6 = 0hence (x 2)(x 3) = 0implying either (x 2) = 0 or (x 3) = 0 thus x = 2,3

• General Solution is an = C(2n) + D(3n).

8.3.364

Page 365: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Finding Particular Solutions• Once we have found the general solution to a

recurrence relation, if we have a sufficient number of initial conditions, we can find the particular solution.

• This means we find the values for the arbitrary constants C and D, so that the solution for the recurrence relation takes on those initial conditions.

• The required number of initial conditions is the same as the order of the relation.

8.3.365

Page 366: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

An Example• For the last example, we found the recurrence relation

ak = 5ak1 6ak2 has general solutionan = C(2n) + D(3n). Find the particular solution when a0 = 9 and a1 = 20.

a0 = C(20)+ D(30) = C + D = 9

a1 = C(21)+ D(31) = 2C + 3D = 20, so

2C + 2D = 18

2C + 3D = 20, so D = 2 and C = 7.

Therefore, the particular solution is:an = 7(2n) + 2(3n).

8.3.366

Page 367: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Generalizing These Methods• We can extend these techniques to higher order

LHRRCC quite naturally. Suppose we have a LHRRCC whose charateristic poylnomial has roots x = 2, 3,5,7,11, and 13. Then its general solution is:

an = C2n + D(3)n + E5n + F7n + G11n + H13n.

• Moreover, if we have initial conditions specified for a0, a1, a2, a3, a4, and a5, we can plug them into the general solution and get a 66 system of equations to solve for C, D, E, F, G, and H.

8.3.367

Page 368: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Solving The Fibonacci Relation• Solve: an = an1 + an2 when a0 = 1 and a1 = 1.

• Solution: In this case, the characteristic polynomial is x2 x 1, which doesn’t factor nicely. We turn to the quadratic formula to find the roots.

• Quadratic Formula: If ax2 + bx + c = 0, thenx = [b (b2 4ac)]/2a.

• In our case, we have a = 1, b = 1 and c = 1, so x = [(1) ((1)2 4(1)(1))]/2(1) = (1 5)/2.

• Thus an = C[(1 + 5)/2]n + D[(1 5)/2]n.

8.3.368

Page 369: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Solving The Fibonacci Relation (cont’d.)

• If we apply the initial conditions a0 = 1 and a1 = 1 to an = C[(1 + 5)/2]n + D[(1 5)/2]n, we get:

a0 = C + D = 1

a1 = [(1 + 5)/2]C + [(1 5)/2]D = 1, yielding

C = (1 + 5)/(25) and D = (1 5)/(25).

• Therefore an = [(1 + 5)/(25)][(1 + 5)/2]n + [(1 5)/(25)][(1 5)/2]n

• This simplifies toan = (1/5){[(1 + 5)/2]n+1 (1 5)/2]n+1

8.3.369

Page 370: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Single Root Case• So far, our technique for solving LHSORRCCs

has depended on the fact that the two roots of the characteristic polynomial are distinct.

• This is not always the case, however. We can find that a polynomial has only one root, s, whenever the polynomial factors as (x s)2.

• In this case, our solution takes on a special variant to ensure “linear independence” of the solutions.

• Theorem: If an LHSORRCC has a repeated root s, then the general solution is an = (A + Bn)sn.

8.3.370

Page 371: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Single Root Case Example• Find the general solution of an 6an1 + 9an2 = 0.

• This LHSORRCC has a characteristic polynomial equation of x2 6x + 9 = 0, so (x 3)2 = 0, which yields the sole root x 3.

• Therefore, the general solution is an = (A + Bn)3n.

• If we add initial conditions a0 = 2 and a1 = 21, we get: a0 = (A + B(0))30 = A = 2, and

a1 = (A + B(1))31 = 3(A + B) = 3(2 + B) = 21,so 2 + B = 7, hence B = 5.

• Therefore the particular solution is an = (2 + 5n)3n

8.3.371

Page 372: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Higher Order Repeated Root Case• This method of building up the “coefficient” when

the variable part degenerates because of repeated roots extends nicely to higher order problems as well.

• Example: If a LHRRCC has characteristic polynomial with roots x = 7,7,7,7,7,7,7,9,9,9 then its general solution is:

• an = (A + Bn + Cn2 + Dn3 + En4 + Fn5 + Gn6)7n

+ (H + In + Jn2)9n.

• How many IC are needed for a particular solution?

8.3.372

Page 373: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Summary• Our general technique for solving LHRRCCs is a

two-step process.

• Step 1: Find the roots of the characteristic polynomial and use them to develop the general solution.

How do I find roots of polynomials?

• Step 2: Use the initial conditions to make and solve a system of linear equations that determine the arbitrary constants in the general solution to get the particular solution.

How do I solve systems of linear equations?

8.3.373

Page 374: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Board Example #1• Given the recurrence relation an 4an1 3an2,

find a999 when a0 = 5 and a1 = 7.

8.3.374

Page 375: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Board Example #2• Given the recurrence relation an 4an1 4an2,

find a999 when a0 = 5 and a1 = 7.

8.3.375

Page 376: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Board Example #3• What is the general solution for the LHRRCC

whose characteristic polynomial is:(x + 5)6(x 3)4(x + 8)2

8.3.376

Page 377: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Board Example #4• Given the LHRRCC an 2an1 5an2 6an3, find

a999 when a0 = 17, a1 = 14, and a2 = 110.

8.3.377

Page 378: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Validity of the General Solution IProve: If Aan +Ban1 +Can2 , and s t satisfy

Ax2 + Bx + C = 0, then ak = Msk + Ntk satisfies the relation.

Proof: Let Aan Ban1 Can2 , and s t satisfyAx2 + Bx + C = 0. Thus:

As2 + Bs + C = At2 + Bt + C = 0.

Now, an = Msn + Ntn, an1 = Msn1 + Ntn1, and an2 = Msn2 + Ntn2 hence Aan Ban1 Can2

= A(Msn + Ntn) B(Msn1 + Ntn1) C(Msn2 + Ntn2)

= M(Asn +Bsn1 + Csn2) + N(Atn +Btn1 + Ctn2)= Msn2(As2 +Bs + C) + Ntn2(At2 +Btn1 + C) = 0.QED

8.3.378

Page 379: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Validity of the General Solution IIProve: If Aan +Ban1 +Can2 , and s is the only

solution of Ax2 + Bx + C = 0, then ak = (P + Qk)sk satisfies the relation.

Proof: Let Aan Ban1 Can2 , and s be the only solution of Ax2 + Bx + C = 0, so As2 + Bs + C = 0.

Now, an = (P + Qn)sn, an1 = [P + Q(n1)]sn1, and an2 = [P + Q(n2)]sn2 hence Aan Ban1 Can2

= A(P + Qn)sn B[P + Q(n1)]sn1

C[P + Q(n2)]sn2

= P(Asn +Bsn1 + Csn2) + Q[Ansn +B(n1)sn1 + C(n2)sn2]

8.3.379

Page 380: Chapter 5 - Set Theory 1. Basic Definitions 2. Empty Set, Partitions, Power Set 3. Properties of Sets 5.1.1

Validity of the General Solution IIThus, Aan Ban1 Can2

= Psn2(As2 +Bs + C) + Q(Ansn + Bnsn1 Bsn1

+ Cnsn2 2Csn2)

= Qnsn2(As2 + Bs + C ) +Qsn2(Bs 2C)

= Qsn2(Bs 2C) = 0?????

However, since s is the only root of the characteristic polynomial, from the Quadratic Formula, we have that (B2 4AC) = 0 and s = B/2A.

Thus (Bs 2C) = B(B/2A) 2C = B2/2A 2C(2A/2A) = (B2 4AC)/2A = 0. QED

8.3.380