Professional Documents
Culture Documents
SET Chapter
SET Chapter
1. Basic Definitions
2. Empty Set, Partitions, Power Set
3. Properties of Sets
5.1.2
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.6
Natural Numbers
• We define the Natural Numbers to be:
N = {0, 1, 2, 3, …}
The Integers
• We define the Integers to be:
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.14
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.15
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}, but
A = {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.16
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.17
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.19
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.21
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.3.24
Section 5.3
• The Empty Set
• Partitions
• Power Sets
• Boolean Algebras
5.3.25
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.28
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.30
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
1.1.31
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.34
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.35
Logical Operations
• Negation: p ~p
T F
F T
• Conjunction: • Disjunction:
p q (p q) p q (p q)
T T T T T T
T F F T F T
F T F F T T
F F F F F F
1.1.38
Example: (p q) ~r
• Proceed from left to right:
p q r (p q) ~r (p q) ~r
T T T T F F
T T F T T T
T F T T F F
T F F T T T
F T T T F F
F T F T T T
F F T F F F
F F F F T F
1.1.39
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 T
F T F hence p ~(~p).
• ~(p q) ~p ~q ?
No, since ~(T F) T, but (~T ~F) F.
1.1.40
Section 1.2
• Conditional Statements
• Logical Equivalences Involving Conditionals
• Converses, Inverses, and Contrapositives
• Biconditional Statements
1.2.45
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 pq
T T T
T F F
F T T
F F T
• Example: If you mow my lawn, I’ll pay $20.
1.2.46
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.48
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.49
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.50
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.51
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.52
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.53
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.54
Section 1.3
• Valid and invalid argument forms.
• Special valid argument forms.
• Dilemmas
• Fallacies.
• Contradictions and valid arguments.
1.3.56
A Valid Argument
p (q r)
~r
(p q)
Truth Table: p q r [p (q r)] ~r (p q)
TTT T F T
TTF T T T
TFT T F T
TFF T T T
FTT T F T
FTF T T T
FFT T F F
FFF F T F
1.3.60
An Invalid Argument
p (q r)
~r
(p r)
Truth Table: p q r [p (q r)] ~r (p r)
TTT T F T
TTF T T T
TFT T F T
TFF T T T
FTT T F T
FTF T T F
FFT T F T
FFF F T F
1.3.61
Modus Tollens
Modus Tollens: p q
~q
~p
Truth Table: p q p q ~q ~p
T T T F F
T F F T F
F T T F T
F 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.63
Disjunctive Addition
Disjunctive Addition: p
p q
Truth Table: p q p q
T T T
T F T
F T T
F F F
Premise: Today is Sunday.
Conclusion: Today is Sunday or I wash my car.
1.3.64
Conjunctive Simplification
Conjunctive Simplification: pq
p
also q
Truth Table: p q p q
T T T
T F F
F T F
F F F
Premise: Today is Sunday and I wash my car.
Conclusion 1: Today is Sunday.
Conclusion 2: I wash my car.
1.3.65
Disjunctive Syllogism
Disjunctive Syllogism: p q pq
~p ~q
q p
Truth Table: p q p q ~p
T T T F
T F T F
F T T T
F F F T
Premises: Today is Sunday or Saturday.
Today is not Sunday.
Conclusion: Today is Saturday.
1.3.66
Hypothetical Syllogism
Hypothetical Syllogism: p q
q r
pr
Premises: 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.67
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.72
Converse Error
If 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.73
Inverse Error
If 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.74
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.4.75
Section 1.4
• Digital Logic Circuits
• Boolean Polynomials
• Normal Forms (Disjunctive/Conjunctive)
• Designing Circuits with Specified
Conditions
• Showing Two Circuits Are Equivalent
1.4.76
Logical Gates
• Instead of working with switches, we model
digital circuits using gates: AND-gates, OR-
gates, and NOT-gates.
• We draw these as:
x
OR x+y
y
x NOT x’
x
AND xy
y
1.4.78
Notation
• Modeling digital circuits leads to the
equivalent analysis of symbolic logic.
• Symbolic Logic Digital Circuits
T, t 1, 1
F, c 0, 0
p, q, r, ... x, y, z, ...
~p x’
pq xy
pq x+y
1.4.79
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.80
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.83
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.
5.2.89
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.90
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.92
Set Identities
Commutative 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.94
Example 1:
A (B C) = (A B) (A C)
First, show A (B C) (A B) (A C).
Example 2: If A B, then
A B = B and A B = A
First, show A B A.
Then, show A A B.
5.2.99
(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 )
2.1.100
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.103
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.104
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.106
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.108
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.109
Examples of Negations
• The negation of:
Some people are sad.
is
All people are not sad.
• The negation of:
All integers are rational.
is
At least one integer is irrational.
• Which of each pair is true?
2.1.110
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.111
Examples
• The formal statement:
xR+ yR+, y < x
can 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.115
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.116
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.3.120
• Argument Forms;
• Diagrams to Test for Validity;
• Quantified Converse and Inverse Errors;
• Abduction.
2.3.121
Universal Instantiation
• Consider the following statement:
All men are mortal
Socrates 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.122
Examples
• Universal Modus Ponens or Tollens???
Mortals
Men
Socrates
2.3.126
{x | P(x)}
a
2.3.127
Humans
2.3.128
{x | P(x)}
2.3.129
Felix?
Humans
Felix?
2.3.130
Felix?
Humans
2.3.131
Quantified Form of Converse
and 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.132
k
2.3.133
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.
3.1.134
Theorem 3.1.1
Prove: 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.143
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.2.145
A Corollary
• Corollary: Double a rational is rational.
• Proof: Let r = s in the previous theorem.
3.3.149
Section 3 - Divisibility
• Definition: If n and d are integers and d 0, then
n is divisible by d provided n = d k for some
integer k.
• Alternatively, we say:
n is a multiple of d
d is a factor of n
d is a divisor of n
d divides n (denoted with d | n).
3.3.150
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.151
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.155
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 + 27
27 = 1 5 + 22
27 = 2 5 + 17
27 = 3 5 + 12
27 = 4 5 + 7
27 = 5 5 + 2 here, r = 2 and q = 5.
27 = 6 5 + (3)
3.4.160
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.173
Example of Contraposition
Theorem: 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.7.175
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.177
Calculating GCDs
• Find gcd(72,63)
72 = 98 = 3324 = 2334
63 = 97 = 33 7
hence 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.184
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.
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.190
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.191
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.192
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 + ... + an
i=1
4.1.193
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.195
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 that
k = 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.196
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.197
• 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.2.
200
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.
In Pictures 203
Induction
Induction
Induction
Induction
Basis
4.2.
204
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.
Mathematical 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.
Congruence Modulo 2
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.231
Graphs of a Relation
• R = {(x,y) | x,y R and x2 + y2 = 1}
1
1 x
y
• Arrow Diagrams: R = {(1,a),(1,b),(2,b),(3,a)}
1 a
2
b
3
10.1.232
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.233
Violates Property 2
1
2 a
3 b
4
10.1.234
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.235
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:
2
1 3
4
Section 2: Reflexivity, 10.2.236
4 3
4 3
10.2.241
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.242
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) ...
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 ...,
3 2
1 6
5
4
7.1.258
Chapter 7: Functions
1
2 a X = {1,2,3} Y = {a,b}
3 b f(A) = {a}
f = {(1,a),(2,a),(3,a)}
7.1.261
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 by
f(x) = x2) and g(x) = |x|. In this instance, f = g.
• Consider f:R R and g:R R given by
f(x) = x (the identity function) and g(x) = |x|.
In this case, f and g are equal only for x 0, but
f(1) = 1 and g(1) = 1, hence f g.
7.1.262
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, and
H(101100,100110) = 2.
7.1.263
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.264
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.265
Boolean Function Example
• In this case, the function f(x,y,z) = xy + z’ is:
111
110
101
100 0
011
010 1
001
000
7.1.266
X Z
Y
7.5.278
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)}
1
2
1
3 1
2
4 2
3
5 3
4
6 4
5 g
f 5
7.5.279
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.
f g
X Y Z
6.1.284
Chapter 6: Counting
Heads Tail
1 2 3 4 5 6 1 2 3 4 5 6
D C C B B A A E E D
6.2.299
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.300
A AB B
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.315
The Division Rule
• Theorem: Suppose a set A has n elements and is
partitioned by the collection {A 1, 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.316
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.317
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 n!
()=
k k!(n k)!
6.4.318
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.319
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.
Counting Teams 6.4.320
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.326
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.327
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!
When to Use Generalized 6.5.330
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:
Summary
• Theorem: The number of integer solutions to:
a1 + a2 + a3 +...+ an = r,
when a1 b1, a2 b2, a3 b3 , ..., an bn is
C(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.6.335
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.337
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.338
Pascal’s Triangle
Recall 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.339
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).
8.1.341
Chapter 8: Recursion
• Recursively defined sequences;
• The Iteration Method to solve recurrence
relations;
• Solve linear, homogeneous recurrence relations;
• Count Fibonacci’s bunnies.
Section 1: Recursively Defined 8.1.342
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.343
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.345
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.349
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 + 0
so an = n(n+1)/2.
• Plugging in n = 100: a100 = 100(101)/2 = 5050.
8.2.355
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.356
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.358
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), and
21 1 = 2 1 = 1, therefore m1 = 21 1.
• Inductive Step: Recall the recurrence relation is mk
= 2mk1 + 1. Assume mk = 2k 1.
8.2.359
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.364
An Example
• Let ak = 5ak1 6ak2. Find the general solution.
• The relation has characteristic equation:
x2 = 5x 6,
so x2 5x 6 = 0
hence (x 2)(x 3) = 0
implying either (x 2) = 0 or (x 3) = 0
thus x = 2,3
• General Solution is an = C(2n) + D(3n).
8.3.365
An Example
• For the last example, we found the recurrence relation
ak = 5ak1 6ak2 has general solution
an = 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.367
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.374
Board Example #1
• Given the recurrence relation an 4an1 3an2,
find a999 when a0 = 5 and a1 = 7.
8.3.375
Board Example #2
• Given the recurrence relation an 4an1 4an2,
find a999 when a0 = 5 and a1 = 7.
8.3.376
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.377
Board Example #4
• Given the LHRRCC an 2an1 5an2 6an3, find
a999 when a0 = 17, a1 = 14, and a2 = 110.
8.3.378
Validity of the General Solution I
Prove: 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 satisfy
Ax2 + 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.379
Validity of the General Solution II
Prove: 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.380
Validity of the General Solution II
Thus, 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