DISCRETE MATHS - Lecture 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 107

Lecture 2

 Propositions
 Truth value
 Propositional calculus/propositional logic
 Negation, conjunction, disjunction
 Compound proposition
 Exclusive or, inclusive or
 Implications
 Converse, contrapositive, inverse
Propositional Equivalence
• Sometimes it is necessary, in a
mathematical argument to replace one
statement with a statement with the same
truth value.
Definition
• A compound proposition that is always true,
no matter what the truth values of the
propositions that occur in it, is called a
tautology. A compound proposition that is
always false is called a contradiction. Finally,
a proposition that is neither a tautology nor a
contradiction is called a contingency.
From the below table we can see that
p  5p is a tautology
p  5p is a contradiction

p 5p p  5p p 5p

T F T F

F T T F
Logical Equivalence
• Compound propositions that have the
same truth values in all possible cases
are called logically equivalent.
Definition
• The propositions p and q are called
logically equivalent if p  q is a
tautology. The notation p  q denotes
that p and q are logically equivalent.
• Example: Show that 5 (p  q) and 5p 
5q are logically equivalent.

• Solution: The solution is given using a truth


table below. Since the truth values of the
propositions 5 (p  q) and 5p  5q are the
same in all possible combination of truth
values of p and q, it follows that these
propositions are logically equivalent.
p q p q 5 (p  q) 5p 5q 5p  5q

T T T F F F F

T F T F F T F

F T T F T F F

F F F T T T T

Note: It can easily be shown that that 5 (p  q)  (5p  5q) is a tautology.


LOGICAL EQUAVALENCES

• See handout
• We can use a truth table to show that
compound propositions are logically
equivalent OR we can use a series of logical
equivalences.

• Example: Show that 5 (p  (5p  q)) and


5p  5q are logically equivalent.
• Here we’ll show that 5 (p  (5p  q))  5p 
5q
5 (p  (5p  q))  5p  5(5p  q)
Demogans 2nd law
 5p  [5(5p)  5q)] Demorgan’s 1st Law
 5p  ( p  5q) Double negation
 (5p  p)  (5p 5q) Distributive laws
 F  (5p 5q) p  p  F
 (5p 5q)  F Commutative Laws
 (5p 5q) Identity Laws
• Show that (p  q)  (p  q) is a tautology.

• Solution:

• To show this statement is a tautology, we


will use logical equivalences to demonstrate
that it is logically equivalent to T.
(p  q)  (p  q)  5(p  q)  (p  q)
Implication
 (5p  5q)  (p  q) De Morgans Laws

 (5p  p)  (5q  q) Associative Law

 TT Complement property

 T Domination Laws
Next we will look at:

• Predicates and Quantifiers


• More translation of English sentences into
logical expressions

• Methods of Proofs
– Rules of Inference
– Rules of Inference for Quantified Statements
– Methods of proving theorems
Predicates and Quantifiers
Consider the statement: “x < 5” which is found in computer
programs.
“x < 5” has two parts:
• The variable “x” is the subject of the statement.
• While “is less than 5” is the predicate and refers to
the property that the subject of the statement can
have.

The statement “x < 5” can be denoted by P(x) where


P denotes “is less than 5” and x is the variable.
• P(x) is also said to be the value of the propositional
function P at x. Once a value has been assigned to
the variable x, the statement P(x) becomes a
proposition and has a truth value.

• To create a proposition from a propositional


function we use quantifiers.
Definition
• The universal quantification of P(x) is the
proposition “P(x) is true for all values of x in the
universe of discourse”.
• The notation: œx P(x) denotes the universal
quantification of P(x) and reads “for all x P(x)”

• Here œ denotes the universal quantifier.


Example 1:1
• Let P(x) be the statement “x * 0 = 0”. What is the
truth value of the quantification œx P(x), where the
universe of discourse is the set of real numbers?

Solution:
• Since P(x) is true for all real numbers x, (any
number multiplied by zero is zero) then œx P(x) is
true.
Example 2
• What is the truth value of the function œx Q(x),
where Q(x) is the statement “x2 < 10” and the
universe of discourse consist of

• (i) positive integers not exceeding 4.

• (ii) integers not exceeding 3?


Solution:

• (i) The statement œx Q(x) is the same as Q(1) 


Q(2)  Q(3)  Q(4) since the universe consist of
the integers 1, 2, 3, 4. Since Q(4) is false, œx Q(x)
is false.

• (ii) false. Why???


Definition
• The existential quantification of P(x) is the
proposition “ There exist an element in the
universe of discourse such that P(x) is true”.

• The notation: ›x P(x) denotes the


existential quantification of P(x) and reads “for
some x P(x)”

• Here › denotes the existential quantifier


Example:
• Let P(x) be the statement “x2 > 10 ”. What is the truth
value of quantification ›x P(x) where the universe of
discourse consists of the positive integers not
exceeding 4?
Solution:
• The universe of discourse is {1, 2, 3, 4}, the
proposition ›x P(x) is the same as P(1)  P(2)  P(3)
 P(4).
• Since P(4) , which is the statement “42 > 10” is true, it
follows that ›x P(x) is true.
Translating more involved sentences into logical
expressions
We can now use logical connectives and quantifiers to
express English sentences.
Example 1
• Express the statement “If a person is a male and is a
parent, then this person is someone’s father” using
predicates, quantifiers and logical connectives.

Solution:
• Let M(x) : x is a male.
• Let P(x): x is a parent.
• Let F(x, y): x is the father of y.
• The statement given may be rephrased as follows:

• For every person x, if person x is a male and


person x is a parent, then there exists a person y
such that person x is the father of person y.

Hence the require expression is:


œx ›y [(M(x)  P(x))  F(x, y)]
Translating sentences into logical expressions

Example 2 (a)
• Express the statement “Everyone has a best friend” using
quantifiers and logical connectives.

Solution:
• Let B(x, y) : y is the best friend of x. The statement
given may be rephrased as follows.
• For every person x there is another person y, such
that y is the best friend of x.

Hence the require expression is:


œx ›y ( B( x, y) )
Translating sentences into logical expressions

Example 2 (b)
• Express the statement “Everyone has exactly one best
friend” using quantifiers and logical connectives.

Solution:
• Let B(x, y) : y is the best friend of x. The statement
given may be rephrased as follows.
• For every person x there is another person y, such
that y is the best friend of x and if z is another
person other than y, then z is not the best friend of
x.

Hence the require expression is:


œx ›y œz [B( x, y)  (( z != y)  5B(x, z))]
Example : Translate the statement “The product of
any two negative integers is positive” into a logical
expression.

(œ x, y 0 Z) [( x < 0)  ( y < 0)  (x * y > 0)]


Example 3
• Consider the following statements. The first two
are premises while the third is called the
conclusion. The entire set is called an argument.

• “All lions are fierce”

• “Some lions do not drink coffee”

• “Some fierce creatures do not drink coffee”


Solution:
• Let P(x) be the statement “ x is a lion”
• Let Q(x) be the statement “ x is fierce”
• Let R(x) be the statement “ x drinks coffee”
We can express these statements as:
• “All lions are fierce”
• œx (P(x)  Q(x))
• “Some lions do not drink coffee”
• ›x (P(x)  5R(x))
• “Some fierce creatures do not drink coffee”
• ›x (Q(x)  5R(x))
Note:
• “Some lions do not drink coffee”
• ›x (P(x)  5R(x))

• Note that the second statement cannot be written as


›x (P(x)  5R(x)).
• The reason is that P(x)  5R(x) is true whenever x
is not a lion, so ›x (P(x)  5R(x)) is true as long as
there is at least one creature that is not a lion.

• NEVER USE THE IMPLICATION “” WITH ›.


Lets look at
Multiple Quantification of Propositional functions

NB. The order in which quantifiers appear makes a


difference:
Example:
Let Q(x, y) denote “x + y = 0”. What is the truth
value of the following quantifications, for x, y
real numbers.
(i) œx›y Q(x, y)
(ii) ›yœx Q(x, y)
(iii) œxœy Q(x, y)
Solution
(i) œx›y Q(x, y) : For every real number x there is a
real number y such that Q(x, y) is true. This
statement is true since y = -x.
(ii) ›y œx Q(x, y): there is a real number y such that
for every real x, Q(x, y) is true. This statement
is false since when y is chosen it will only apply
to only one value of x.

(iii) œxœy Q(x, y) : false , a consequence of (ii)


above.
• Note, if ›y œx Q(x,y) is true then œx ›y Q(x,y) is
also true.

• However if œx ›y Q(x,y) is true, it is not


necessarily that ›y œx Q(x,y) is true.
Negation
Example: “Every student in the class likes Discrete Maths”
Let P(x) be the statement ‘x likes Discrete Maths”.
Therefore this statement is a universal quantification,
namely: œx P(x).

The negation of this statement is: “It is not the case that
every student in the class likes Discrete Maths”. 5œx P(x)

This is equivalent to “ There is a student in the class who


does not like Discrete Maths”.
Therefore the existential quantification of the negation of
the original proposition is: ›x 5P(x)
Negation
Therefore in general:

•5œx P(x)  ›x 5P(x)

•5›x Q(x)  œx 5Q(x)


Methods of Proofs
• How do we know that a mathematical argument is
correct?
• What methods can we use to ensure that it is
correct?
• A theorem is a statement that can be shown to be
true.
• We demonstrate that a theorem is true with a
sequence statements that form an argument, called
a proof
• To construct proofs – we need methods that would
allow us to construct new statements from old
ones.
Methods of Proofs
• Here we introduce the rules of inference for
propositional logic.

• These rules provide the justification of the steps


used to show that a conclusion follows logically
from a set of hypotheses.

• See handout
Methods of Proofs
Addition:
• 1. p
2. Therefore, p or q.

1. It is raining
2. Therefore, either it is raining or the sun is
shining.
Simplification:
• 1. p and q.
2. Therefore, p.
1. It is raining in both Barbados and St. Lucia.
2. Therefore, it is raining in Barbados.

Conjunction:
• 1. p
2. q
3. Therefore, p and q.
1. It is raining in Barbados.
2. It is raining in St. Lucia
3. Therefore, it is raining in both Barbados and St. Lucia
Modus Ponens:
• 1. p.
2. If p then q.
3. Therefore, q.
1. It is raining.
2. If it is raining, then I will get wet.
3. Therefore, I will get wet.

Modus Tollens:
• 1. If p then q.
2. Not q. (q).
3. Therefore, not p (p).
1. If I get a racket then I would play tennis.
2. I did not play tennis.
3. Therefore, I never got a racket.
Hypothetical Syllogism:
• 1. If p then q.
2. If q then r.
3. Therefore, if p then r.
1. If it rains, then I will get wet.
2. If I get wet, then my shirt will be ruined.
3. If it rains, then my shirt will be ruined.

Disjunctive Syllogism:
• 1. Either p or q.
2. Not p (p).
3. Therefore, q.
1. Either it rained or I took a ride to the park.
2. It did not rain.
3. Therefore, I took a ride to the park.
Lets look at some examples of how these rules are used:
Example 1:1
• Given the hypotheses r  s and s, show that r is a
valid conclusion.
Solution:
1. rs hypothesis (premise)
2. s  r 1, contrapositive
3. s hypothesis (premise)
4. r 2, 3 modus ponens

Note that we could have simply invoked modus tollens


Example 2:
2
• Given the hypotheses p  (r  s), p and  r  p,
show that s is a valid conclusion.

Solution:
1. p  (r  s) hypothesis (premise)
2. p hypothesis
3. r  s 1, 2 modus ponens
4.  r  p hypothesis
5. p  r 4, contrapositive
6. p  s 3, 5 hypothetical syllogism
7. s 2, 6 modus ponens
Example 2b:
2b

Given the hypotheses


(s  r)  t, t  q

Show that s  q is a valid conclusion.


Example 2b:
2b
1. (s  r)  t hyp.
2. t  q, hyp.
3. (s  t )  (r  t ) 1, Distribution
4. (s  t ) 3, simplification
5. ~s  t 4, implication
6. ~s  q 2, 5, hypothetical
Syllogism
7. sq 6, implication
Example 3:
3
• Show that the hypotheses “It is not sunny this afternoon
and it is colder than yesterday”, “ We will go swimming
only if it is sunny”, “If we do not go swimming, then we
will take a canoe trip”, “If we take a canoe trip, then we
will be home by sunset” lead to the conclusion “We will
be home by sunset”.

Solution:
• Let p be the proposition “It is sunny this afternoon”
• Let q be the proposition “It is colder than yesterday”
• Let r be the proposition “We will go swimming”
• Let s be the proposition “We will take a canoe trip”
• Let t be the proposition “We will be home by sunset”
Example 4:
Show that the hypotheses:
• “It is not sunny this afternoon and it is colder than
yesterday” p q
• “We will go swimming only if it is sunny” r  p
• “If we do not go swimming, then we will take a
canoe trip” r  s
• “If we take a canoe trip, then we will be home by
sunset” st
lead to the conclusion “We will be home by
sunset”. t
• Then the hypotheses become  p  q, r  p,
 r  s and s  t. The conclusion is t. We
construct the argument as follows:
1. p  q hypothesis
2. p 1, simplification
3. rp hypothesis
4. r 2, 3 modus tollens
5. r  s hypothesis
6. s 4, 5 modus ponens
7. st hypothesis
8. t 6, 7 modus ponens
• Excercise

• Given the hypotheses p  r, p  q and  r  s


show that  q  s is a valid conclusion.

• Given the hypotheses (p  q)  r, and r  s show


that p  s is a valid conclusion.
• Next we will look at the Rules of Inference for
Quantified statements
Rule of Inference Name

x P(x) Universal instantiation



P(c) if c  U

P(c) for an arbitrary c  U Universal generalisation



 x P(x)

 x P(x) Existential instantiation



 P(c) for some element c  U

P(c) for some element c  U Existential generalisation



  x P(x)
Again lets look at examples of how these rules are used:
Example:
Example Universal instantiation
• Let P(x) : “ x has done Tutorial 1” be a propositional
function, where the universe of discourse is the set of all
students. If x P(x) is true and Ryan is a student, the we
can conclude that Ryan has done Tutorial 1. That is
P(Ryan)
Example:
Example Universal generalization.
• Let P(x) : “ x is has passed the exam” be a propositional
function, where the universe of discourse is the set of all
students. If the statement is true for an arbitrary x we
can conclude that the statement is true for all x.
Therefore x P(x)
Example: Existential instantiation
• Let P(x) be the statement “ x is a odd number between 10
and 20”; given that there exist such numbers;  x P(x) is
true. Therefore, we can select one such number and
reason or argue about it; for example P(13).

Example: Existential generalisation


• Let P(x) be the statement “ x is a prime number between
150 and 200”; given that P(151) is true we can conclude
 x P(x).
Example: We go back to a previous example:
• “ All lions are fierce”
• “Some lions do not drink coffee”
• “Some fierce creatures do not drink coffee”
where the universe of discourse is the set of all
creatures.
Solution:
We will show that the conclusion is valid
• Let P(x) denote “x is a lion”
• Let Q(x) denote “x is a fierce”
• Let R(x) denote “x drinks coffee”
• Note the conclusion is ›x (Q(x)  5R(x))
• “ All lions are fierce”
œx (P(x)  Q(x))

• “Some lions do not drink coffee”


›x (P(x)  5R(x))

• “Some fierce creatures do not drink coffee”


›x (Q(x)  5R(x)) which is the conclusion
1. œx (P(x)  Q(x)) hypothesis
2. ›x (P(x)  5R(x)) hypothesis
3. P(i)  Q(i) 1, Universal instantiation
4. P(i)  5R(i) 2, Existential instantiation
5. P(i) 4, simplification
6. Q(i) 3, 5 modus ponens
7. 5R(i) 4, simplification
8. Q(i)  5R(i) 6, 7 conjunction
9. ›x (Q(x)  5R(x)) 8, existential generalization
• Consider the following statements, with the last
statement being the conclusion.

• “All humming birds are richly coloured”


• “No large birds live on honey”
• “Birds that do not live on honey are dull in
colour”
• “Humming birds are small”

where the universe of discourse is the set of all birds.


• Let P(x) denote “x is a hummingbird”
• Let Q(x) denote “x is large”
• Let R(x) denote “x lives on honey”
• Let S(x) denote “x is richly coloured”

• “All hummingbirds are richly


coloured” œx (P(x)  S(x))
• “No large birds live on honey” 5›x (Q(x)  R(x))
• “Birds that do not live on honey are dull in
colour” œx (5R(x)  5S(x))
• “Hummingbirds are small” œx (P(x) 5Q(x))
• Solution:
1. œx (P(x)  S(x)) Hypothesis
2. 5›x (Q(x)  R(x)) Hypothesis
3. œx (5R(x)  5S(x)) Hypothesis
4. P(i)  S(i) 1,Universal Inst.
5. œx 5 (Q(x)  R(x)) 2, negation
6. œx ( 5 Q(x)  5 R(x)) 5, De Morgans
7. œx (Q(x)  5R(x)) 6, Implication
8. Q(i)  5R(i) 7, Universal Inst.
9. 5R(i)  5S(i) 3, Universal Inst
10. Q(i)  5S(i) 8, 9 Hyp. syllogism
11. S(i)  5Q(i) 10, contrapositive
12. P(i)  5Q(i) 4, 11 Hyp. syllogism
13. œx (P(x) 5Q(x)) 12, universal gen.
• Excercise

• Show that the premises:


• “A student in this class has not read the notes,” and
“Everyone in this class passed the first exam”
imply the conclusion
• “Someone who passed the first exam has not read the
notes”
• Let C(x): x is in the class.
• Let N(x): x has read the notes.
• Let P(x) : x has passed the first exam
• Excercise

• “A student in this class has not read the notes,”


• ›x (C(x)  5N(x))
• “Everyone in this class passed the first exam”
• œx (C(x)  P(x))

• “Someone who passed the first exam has not


read the notes”
• ›x (P(x)  5N(x))
Methods of proving theorems

• A theorem is a statement that can be shown to be


true. We demonstrate that a theorem is true with a
sequence of statements that form an argument
called a proof.

Some methods used for proving theorems are:


1. Direct Proof
2. Indirect proof
3. Proof by contradiction
• Because many theorems are implications, the
techniques for proving implications are
important.
• The implication p  q can be proved by showing
that if p is true, then q must also be true. This
shows that the combination p true and q false
never occurs.

• A proof of this kind is called a direct proof.


Example:

Give a direct proof of the theorem

“If n is odd, then n2 is odd”.


Solution:
• Assume that the hypothesis of the implication is
true, that is n is odd.

• Then n = 2k + 1, where k is an integer. It follows


that n2 = (2k + 1)2
= 4k2 + 4k + 1
= 2(2k2 + 2k)+ 1.

• Therefore n2 is odd ( it is 1 more than twice an


integer)
Indirect proof

Since p  q is logically equivalent to q  p


(contrapositive), p  q can be proven indirectly
by showing that the contrapositive q  p is
true.
Example:
Give an indirect proof of the theorem

“If 3n + 2 is odd then n is odd”.


Solution.
Let p: 3n + 2 is odd and q: n is odd
• The theorem translates to p  q. For an indirect
proof we prove the contrapositive, q  p,
that is if n is not odd then 3n + 2 is not odd.
• If n is not odd then n is even therefore n = 2k,
where k is an integer. Hence,
3n + 2 = 3(2k) + 2
= 2(3k + 1) which is even. Since we have
proven the contrapositive, the original
implication must be true.
Proof by contradiction
• In a proof by contradiction we assume that both
p and 5q are true. We then use the steps from
the direct proof q  p to show that p is also
true. This leads to the contradiction p  5p.
Example:
Give a proof by contradiction of the theorem:
“If n3 + 5 is odd then n is even”.

Solution:
Let p: n3 + 5 is odd and q: n is even.
• The theorem can be stated as p  q. In a proof
by contradiction we assume p and q. We then
use indirect proof (q  p) to prove p.
• Now q: n is not even i.e. n is odd.
Therefore n = 2k + 1 for some integer k.
Then n3 + 5 = (2k + 1)3 + 5
= 8k3 + 12k2 + 6k + 1 + 5
= 2(4k3 + 6k2 + 3k + 3)
which is even, which contradicts the assumption
that n3 + 5 is odd.
Excercise

• Give an indirect proof of the theorem


“ If 5n + 1 is odd then n is even”.

• Give a proof by contradiction


contr of the theorem
“If 3n +2 is even then n is even”.
• Mathematical Induction

• Growth of Functions
Mathematical Induction
• A proof by mathematical induction that P(n) is
true for every positive integer n consists of two
steps:
• Basis step The proposition P(1) is shown to
be true.
• Inductive step The implication P(n)  P(n + 1)
is shown to be true for every
positive integer n.
• Expressed as a rule of inference, this proof
technique can be stated as:
[P(1)  œn (P(n)  P(n + 1))]  œn P(n)
Example 1
Prove that the following statement P(n) is true for all n $ 1

1+2+3+… +n =
n ( n  1)
Solution: 2
1 (1  1 )
Basis step: (n = 1)  1
2

we now need to show that P(n + 1) is true that is

1 + 2 + 3 + … + n + (n + 1) = (n 1)(n  2)
2
Now
[1 + 2 + 3 + … + n ]+ (n + 1) = n(n  1) + (n + 1)
2
n(n  1)  2(n  1)
=
2

=
n  3n  2
2

2
(n 1)(n  2)
=
2
Since P(1) is true and the implication P(n)  P(n + 1) is
true for all positive integers n, P(n) is true for all n $ 1.
Example 2: Prove by mathematical induction that
n1
n
k 1

i 0
k 
i

k 1


i0
k  k  k  k  ...  k
i 0 1 2 n
n
k n 1  1
Let P(n) be the statement 
i0
k 
i

k 1

01
k 1 k 1
Solution: Basis step: (n = 0) P(0)  k 
0
 1
k 1 k 1
Inductive step n
k n1
1
Assume that P(n) is true that is 
i0
k 
i

k 1
we need to show that P(n +1) is also true, that is

n2
n1
k 1
 k  k 1
i

i0
Now
n1 n

k i
=  k
i0
i
 k n1

i 0

k n1 1 n1
= k
k 1
= k n1 1 k n2  k n1
k 1
n2
=
k 1
k 1
Since P(1) is true and the implication P(n)  P(n + 1)
is true for all integers n, P(n) is true for all n $ 0.
Exercise

Use mathematical induction to show that


1 + 2 + 22 + 23 + … + 2n = 2n+1 – 1
for all nonnegative integers n.

Solution:
Basis step: (n = 0): 20 = 20+1 – 1 => 1 = 1

Inductive step: Assume


1 + 2 + 22 + 23 + … + 2n = 2n+1 – 1 is true
We need to show that:
1 + 2 + 22 + 23 + … + 2n + 2n+1 = 2n+2 – 1

Now
[1 + 2 + 22 + 23 + … + 2n] + 2n+1
= 2n+1 – 1 + 2n+1

= 2n+1 + 2n+1 – 1
= 2(2n+1 ) – 1 = 2n+2 – 1
• Example 3:

Prove that the following statement 5n – 1 is divisible by 4.


Solution:
Let P(n) be the statement “5n – 1 is divisible by 4”

• Basis step: P(1) = 51 – 1 = 4 which is divisible by 4.

• Inductive step:
Assume that P(n) is true, that is 5n – 1 is divisible by 4

5n+1 – 1 = 5n+1 – 1
= 5.5n – 1
= 5 (5n – 1) + 4

• Since 5n – 1 is divisible by 4 (the assumption) and 4


is also divisible by 4;

Then 5n+1 – 1 is also divisible by 4.


• Another approach
5n+1 – 1 = 4.5n + 5n -1 (since 5.5n = 4.5n + 5n )
= 4.5n + (5n -1)

• Since 5n – 1 is divisible by 4 (the assumption) and


4.5n is also divisible by 4;

Then 5n+1 – 1 is also divisible by 4.


Exercise

Use mathematical induction to show that


15n - 8n is divisible by 7 for all positive integers n.

Let P(n) be the statement “15n - 8n is divisible by 7”


Let P(n) be the statement “15n - 8n is divisible by 7”

• Basis step: P(1): 151 – 81 = 7 which is divisible by


7

• Inductive step:
Assume that P(n) is true, that is “15n - 8n is divisible
by 7”
Therefore
P(n+1): 15n+1 – 8n+1 = 15(15n ) – 8(8n )

= 15(15n – 8n ) + 7(8n )

Since (15n – 8n ) is divisible by 7 (assumption)


and 7(8n ) is also divisible by 7 then
15n+1 – 8n+1 is divisible by 7

• Since P(1) is true and the implication P(n)  P(n +


1) is true for all positive integers n, P(n) is true for
all positive integers n.
Example 4:4 Prove that the following statement P(n) is
true for all n $ 3.
2n + 1 # n2

Solution: Let P(n) be the statement “2n + 1 # n2”

• Basis step: P(3) = 2 * 3 + 1 # 32. Therefore


P(3) is true

• Inductive step:
Assume that P(n) is true, that is 2n + 1 # n2
• Therefore for P(n + 1) we get
• 2(n + 1) + 1 = 2n + 2 + 1
= 2n + 1 + 2
# n2 + 2
from the assumption 2n + 1 # n2
# n2 + 2n + 1 since 2n +1 $2 œn $3
# (n + 1)2
• Since P(3) is true and the implication P(n)  P(n
+ 1) is true for all integers n $ 3, P(n) is true for
all n $ 3.
Functions
• Definition of a function, sum function, product function
• composition of the functions
• ceiling and floor functions

Definition
• Let A and B be sets. A function f from A to B is an
assignment of exactly one element of B to each element
of A. We write f(a) = b if b is the unique element of B
assigned by the function f to the element a of A. If f is the
function from A to B, we write f : AB.
Definition
• If f is a function from A to B, we say that A is the
domain of f and B is called the codomain of f. If
f(a) = b, then b is the image of a under f and a is
the preimage of b. The range of f is the set of all
images of f.
Example 1
• Let f be a function from A to B as defined below.
• A B
1 3
2 6
3 9
12
Domain of f = { 1, 2, 3}
codomain f = { 3, 6, 9, 12}
Range f = { 3, 6}
Image of 2 = 6
Preimage of 6 = 2, 3
Definition
• Let f1 and f2 be functions from A to R. Then the sum
function f1 + f2; and product function f1 f2, are also
functions from A to R defined by:
(f1 + f2)(x) = f1(x) + f2(x)
(f1 f2)(x) = f1(x) f2(x).
Example:
Let f1 and f2 be functions from R to R such that
f1(x) = x2 and f2(x) = x – x2. What are the functions
f1 + f2 (sum function) and f1 f2 (product function)?
Solution:
From the definition the sum and product functions, it
follows that

• (f1 + f2)(x) = f1(x) + f2(x) = x2 + ( x – x2) = x

• (f1 f2)(x) = f1(x) f2(x) = x2( x – x2) = x3 – x4


Definition
• Let g be a function from the set A to the set B and
let f be a function from the set B to the set C. The
composition of the functions f and g, denoted by
f B g, is defined by:
f B g(a) = f (g(a))
Example:
• Let f and g be functions from the set of integers to
the set of integers defined by f(x) = 2x + 3 and g(x)
= 3x + 2. What is the composition of f and g? What
is the composition of g and f ?
Solution:
(f B g)(x) = f (g(x)) = f(3x + 2)
= 2(3x + 2) + 3
= 6x + 7
(g B f)(x) = g (f(x)) = g(2x + 3)
= 3(2x + 3) + 2
= 6x + 11
• Note that even though f B g and g B f are defined for
the functions f and g they are not equal. In other
words, the commutative law does not hold for the
composition of functions.
Definition
• The floor function assigns to the real number x, the largest
integer that is less than or equal to x. The value of the floor
function at x is defined by lxm. The ceiling function assigns
to the real number x the smallest integer that is greater than
or equal to x. The value of the ceiling function at x is
defined by jxk.
Example:
Some values of floor functions:

l½m = 0 l-½m = -1 l7m = 7 l3.1m = 3


Some values of ceiling functions:
• j½k = 1 j-½k = 0 j7k = 7 j3.1k = 4
The growth of Functions (±, Ω and Θ)
• Suppose that a computer program reorders any list
of n or x integers into a list where the integers are
in increasing order.
• One important consideration concerning the
practicality of this program is how long the
computer takes to solve this problem.
• One analysis might show that the time used to
reorder (bubble sort) a list of n integers is less than
f(n) microseconds, where f(n) = n(n – 1 )/2. To
analyse the practicality of the program, we need to
understand how quickly this function grows as n
grows.
• Here we introduce the big-± notation to assist
us in analysing the growth of functions.

Definition
• Let f and g be functions from the set of integers
to the set of integers or the set of real numbers to
the set of real numbers. We say that f(x) is
±(g(x)) if there are constants C and k such that
*f(x)*#C*g(x)* whenever x > k.
This reads “f(x) is big-oh of g(x)”.
• Note that in order to show that f(x) is ±(g(x)), we
need only find one pair of constants C and k such
that *f(x)*#C*g(x)* whenever x > k. However a
pair C, k that satisfies the definition is never
unique, there are infinitely many pairs.

Example: Show that f(x) = x2 + 2x + 1 is ±(x2).

Solution:
Since
0 # x2 + 2x + 1 # x2 + 2x2 + x2 = 4x2
• Whenever x >1, it follows that f(x) is ±(x2). Here
C = 4 and k = 1 and g(x) = x2
• Another approach is to note that when x >2 it
follows that 2x # x2.
• Therefore 0 # x2 + 2x + 1 # x2 + x2 + x2 = 3x2.
Here C = 3 and k = 2 and g(x) = x2

• Polynomials can often be used to estimate the


growth of functions.
• Theorem Let f(x) = anxn + an-1xn-1 + … + a1x
+ a0, where ao, a1, … an-1, an are real numbers.
Then f(x) = ±(xn).
Example:
• Give the big-± estimates for the factorial
function and the logarithm of the factorial
function where the factorial function f(n) = n!
• Solution
• n! = 1 A 2 A 3 A A A A A n. (Note each term in the
product does not exceed n.)
#nAnAnAAAAAn
= nn
This inequality shows that n! is ±(nn). We take
C = k = 1 in the definition.
• Taking logs of both sides we get:
log n! # log nn = n log n
• Which implies that log n! is ±(n log n).

• The Growth of Combinations of Functions


• Some algorithms are made up of two or more sub-
procedures. In this case we need to know the big-±
for the number of steps or length of time used by
each sub-procedure and then combine these
estimates.
• Theorem: Suppose that f1(x) is ±(g1(x)), and
f2(x) is ±(g2(x)), then (f1 + f2)(x) is
±(max(g1(x), g2(x))).

• Theorem: Suppose that f1(x) is ±(g1(x)), and


f2(x) is ±(g2(x)), then (f1 f2)(x) is ±((g1(x)g2(x))).

Example:
• Give a big-± estimate for f(x) = 3x log (x!) +
(x2 +3)log x.
• Solution:
First we deal with the product 3x log (x!).

• We know that log (x!) is ±(x log x) and 3x is ±(x)


– theorem associated with polynomials. Therefore
3x log (x!) is ±(x Ax log x) = ±(x2 log x)

Next we deal with the product (x2 + 3)log x

• (x2 + 3) # 2x2 when x > 2, it follows that (x2 + 3) is


±(x2) and therefore (x2 +3)log x is ±( x2 log x)
So we get
• f(x) = 3x log (x!) + (x2 +3)log x is ±( max (x2 log
x, x2 log x)) which is ±( x2 log x)

Example:
Give a big-± estimate for
f(x) = (x + 1) log (x2 + 1) + 3x2 .

• Note: log x + log y = log xy


log x – log y = log x/y
log x y = y log x
Solution:
First, a big-± estimate for (x + 1) log (x2 + 1).
Note that (x + 1) is ±(x)
Now (x2 + 1) # 2x2 when x > 1.
Hence
log (x2 + 1) # log (2x2) = log 2 + log x2
= log 2 + 2 log x
# log x + 2 log x if x > 2
# 3log x
This shows that log (x2 + 1) is ± (log x).
Therefore
(x + 1) log (x2 + 1) is ± (x . log x)
is ± (x log x)
• Since 3x2 is ± (x2),
we get f(x) is ±( max (x log x, x2)).
• Now x log x # x2 for x > 1, so it follows that ±( x2).

You might also like