Discrete Mathematics: Propositional Logic

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 46

Discrete Mathematics

Module- I (14 Hours)


Propositional logic, Propositional Equivalence, Predicates and Quantifiers, Nested Quantifiers, Rules of
Inference, Proof methods and Strategies, Sequences and Summations, Mathematical Induction, Recursive
definition and structural induction, Program Correction
Recurrence relation, Solution to recurrence relation, Generating functions, Inclusion and exclusion,
Application of Inclusion and Exclusion Principle, Relation and their properties, Closure of relations,
Equivalence relations, Partial orderings.
Propositional logic
A proposition is a declarative sentence that is either true or false.
Examples of propositions:
The Moon is made of green cheese.
Trenton is the capital of New Jersey.
Toronto is the capital of Canada.
1+0=1
0+0=2
Examples that are not propositions.
Sit down!
What time is it?
x+1=2
x+y=z
Propositional Logic
Constructing Propositions
Propositional Variables: p, q, r, s, . . .
The proposition that is always true is denoted by T and the proposition that is always false is denoted by F.
Compound Propositions; constructed from logical connectives and other propositions
Negation ¬
Conjunction ∧
Disjunction ∨
Implication →
Biconditional ↔

1
Disjunction

Conjunction
The disjunction of propositions p and q is denoted by p ∧ q and has this truth table:

Implication
If p and q are propositions, then p → q is a conditional statement or implication which is read as “if p, then q”
and has this truth table:

In p → q, p is the hypothesis (antecedent or premise) and q is the conclusion (or consequence).


Implication can be expressed by disjunction and negation: p → q ≡ ¬p ∨ q
Understanding Implication
In p → q there does not need to be any connection between the antecedent or the consequent. The meaning
depends only on the truth values of p and q.
This implication is perfectly fine, but would not be used in ordinary English. “If the moon is made of green
cheese, then I have more money than Bill Gates.”
One way to view the logical conditional is to think of an obligation or contract. “If I am elected, then I will
lower taxes.”

2
Different Ways of Expressing p → q

if p, then q p implies q
if p, q p only if q
q unless ¬p q when p
q if p q whenever p
p is sufficient for q q follows from p
q is necessary for p a necessary condition for p is q
a sufficient condition for q is p
Converse, Contrapositive, and Inverse

q → p is the converse of p → q
¬q → ¬p is the contrapositive of p → q
¬p → ¬q is the inverse of p → q
Example: Find the converse, inverse, and contrapositive of
“It is raining is a sufficient condition for my not going to town.”
Solution:
converse: If I do not go to town, then it is raining.
inverse: If it is not raining, then I will go to town.
contrapositive: If I go to town, then it is not raining.
How do the converse, contrapositive, and inverse relate to p → q ?

converse ≡ contrapositive ?
converse ≡ inverse ?
contrapositive ≡ inverse ?

Biconditional
If p and q are propositions, then the biconditional proposition p ↔ q has this truth table

3
p ↔ q also reads as
p if and only if q
p iff q.
p is necessary and sufficient for q
if p then q, and conversely
p implies q, and vice-versa
Precedence of Logical Operators

2∧
3∨
4→
5↔
Thus p ∨ q → ¬r is equivalent to (p ∨ q) → ¬r. If the intended meaning is p ∨ (q → ¬r) then parentheses
must be used.
Satisfiability, Tautology, Contradiction
A proposition is
satisfiable, if its truth table contains true at least once. Example:
p ∧ q.
a tautology, if it is always true. Example: p ∨ ¬p.
a contradiction, if it always false. Example: p ∧ ¬p.
a contingency, if it is neither a tautology nor a contradiction.
Example: p.

Logical Equivalence

Definition: Two compound propositions p and q are logically equivalent if the columns in a truth table
giving their truth values agree.
This is written as p ≡ q.
It is easy to show:
Fact p ≡ q if and only if p ↔ q is a tautology.

De Morgan’s Laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q

4
Truth table proving De Morgan’s second law.

Important Logical Equivalences


Domination laws: p ∨ T ≡ T, p ∧ F ≡ F
Identity laws: p ∧ T ≡ p, p ∨ F ≡ p
Idempotent laws: p ∧ p ≡ p, p ∨ p ≡ p
Double negation law: ¬(¬p) ≡ p
Negation laws: p ∨ ¬p ≡ T, p ∧ ¬p ≡ F
The first of the Negation laws is also called “law of excluded middle”.
Latin: “tertium non datur”.
Commutative laws: p ∧ q ≡ q ∧ p, p ∨ 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)
Absorption laws: p ∨ (p ∧ q) ≡ p, p ∧ (p ∨ q) ≡ p

More Logical Equivalences

5
A Proof in Propositional Logic
To prove: ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬q
¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬(¬p ∧ q) by De Morgan’s 2nd law
≡ ¬p ∧ (¬(¬p) ∨ ¬q) by De Morgan’s first law
≡ ¬p ∧ (p ∨ ¬q) by the double negation law
≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) by the 2nd distributive law
≡ F ∨ (¬p ∧ ¬q) because ¬p ∧ p ≡ F
≡ (¬p ∧ ¬q) ∨ F by commutativity of disj.
≡ ¬p ∧ ¬q by the identity law for F

Conjunctive and Disjunctive Normal Form

A literal is either a propositional variable, or the negation of one.


Examples: p, ¬p.
A clause is a disjunction of literals.
Example: p ∨ ¬q ∨ r.
A formula in conjunctive normal form (CNF) is a conjunction of clauses.
Example: (p ∨ ¬q ∨ r) ∧ (¬p ∨ ¬r)
Similarly, one defines formulae in disjunctive normal form (DNF) by swapping the words ‘conjunction’
and ‘disjunction’ in the definitions above.
Example: (¬p ∧ q ∧ r) ∨ (¬q ∧ ¬r) ∨ (p ∧ r).

Transformation into Conjunctive Normal Form


Fact
For every propositional formula one can construct an equivalent one in conjunctive normal form.
1 Express all other operators by conjunction, disjunction and negation.
2 Push negations inward by De Morgan’s laws and the double negation law until negations appear only
in literals.
3 Use the commutative, associative and distributive laws to obtain the correct form.
4 Simplify with domination, identity, idempotent, and negation laws.
(A similar construction can be done to transform formulae into disjunctive normal form.)

6
Example: Transformation into CNF
Transform the following formula into CNF.
¬(p → q) ∨ (r → p)
1 Express implication by disjunction and negation.
¬(¬p ∨ q) ∨ (¬r ∨ p)
2 Push negation inwards by De Morgan’s laws and double negation.
(p ∧ ¬q) ∨ (¬r ∨ p)
3 Convert to CNF by associative and distributive laws.
(p ∨ ¬r ∨ p) ∧ (¬q ∨ ¬r ∨ p)
4 Optionally simplify by commutative and idempotent laws.
(p ∨ ¬r) ∧ (¬q ∨ ¬r ∨ p)
and by commutative and absorbtion laws
(p ∨ ¬r)

Predicates and Quantifiers


A generalization of propositions - propositional functions or predicates. : Propositions which contain
variables
Predicates become propositions once every variable is bound- by
• assigning it a value from the Universe of Discourse U Or
• quantifying
Examples:
Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2, 3, . . .}
• P(x): x > 0 is the predicate. It has no truth value until the variable x is bound.
Examples of propositions where x is assigned a value:
• P(-3) is false,
• P(0) is false,
• P(3) is true.
The collection of integers for which P(x) is true are the positive integers.
P(y) P(0) is not a proposition. The variable y has not been bound.

However, P(3) P(0) is a proposition which is true.


• Let R be the three-variable predicate R(x, y z): x + y = z
Find the truth value of
R(2, -1, 5), R(3, 4, 7), R(x, 3, z)

7
Quantifiers
• Universal
P(x) is true for every x in the universe of discourse.
Notation: universal quantifier

" xP(x)
‘For all x, P(x)’, ‘For every x, P(x)’
The variable x is bound by the universal quantifier producing a proposition.
Example: U={1,2,3}

Existential
P(x) is true for some x in the universe of discourse.
Notation: existential quantifier

‘There is an x such that P(x),’ ‘For some x, P(x)’, ‘For at least one x, P(x)’, ‘I can find an x such that
P(x).’

Unique Existential
P(x) is true for one and only one x in the universe of discourse.
Notation: unique existential quantifier

‘There is a unique x such that P(x),’ ‘There is one and only one x such that P(x),’ ‘One can find only one
x such that P(x).’

Example: U={1,2,3}
Truth Table:

8
How many minterms are in the DNF?

Distributing a negation operator across a quantifier changes a universal to an existential and vice versa.
Multiple Quantifiers: read left to right . . .
Example: Let U = R, the real numbers, P(x,y): xy= 0

9
The only one that is false is the first one. Suppose P(x,y) is the predicate x/y=1?
Example:
Let U = {1,2,3}. Find an expression equivalent to

where the variables are bound by substitution instead:


Expand from inside out or outside in.
Outside in:

Nested Quantifiers
In the domain of integers, P(x,y). predicate "xy=12"
I'm not sure why

(∀x)(∃y)P(x,y) is false statement.


"For all x, there are some y, such that xy=12".
ex.: 6⋅2=12. let x be 6 and y be 2.
Isn't this true?

If P(x,y) is the statement xy=12, then over the domain of integers the


statement ∀x∃yP(x,y)says:
 for each integer x there is an integer y such that xy=12.
Informally this says that no matter what integer I pick for x, you can find an integer y such
that xy=12. From elementary arithmetic you know that this means that y=12x. But 12x isn’t
always an integer even when x is. In fact, it’s an integer if and only
if x is ±1,±2,±3,±4,±6, or ±12. If I give you x=5, for instance, the only y that
makes xy equal to 12 is 125, which is not an integer. And if I give you x=0, your situation is
truly hopeless: there isn’t even a real number y such that 0⋅y=12.
The statement ∃x∀yP(x,y) means:
 there is some integer x such that no matter what integer y is, xy=12.
This is clearly false. No matter what x you try, if xn=12 for some integer n,
then x(2n)=24≠12, so it’s not true that xy=12 for every integer y.

10
Rules of Inference
• Theorem: a statement that can be shown to be true
• Proof: demonstration of truth of theorem
– consists of series of arguments called axioms or postulates
– these are statements of underlying assumptions about mathematical structures,
hypotheses of theorem to be proved, and previously proved theorems
Addition
A true hypothesis implies that the disjunction of that hypothesis and another are true

Simplification
If the conjunction of 2 propositions is true, then each proposition is true

Conjunction
If p is true and q is true, then p Ù q is true

Modus Ponens
If a hypothesis and implication are both true, then the conclusion is true

11
Modus Tollens
If a conclusion is false and its implication is true, then the hypothesis must be false

Hypothetical Syllogism
If an implication is true, and the implication formed using its conclusion as the hypothesis is
also true, then the implication formed using the original hypothesis and the new conclusion is
also true

Disjunctive Syllogism
If a proposition is false, and the disjunction of it and another proposition is true, the second
proposition is true.

Proofs: Methods and Strategies

A proof is a valid argument that establishes the truth of a theorem (as the conclusion)
Statements in a proof can include the axioms (something assumed to be true), the premises,
and previously proved theorems

12
Methods of Proving:
A direct proof of a conditional statement
p  q first assumes that p is true, and uses axioms,definitions, previously proved theorems, with
rules of inference, to show that q is also true
The above targets to show that the case where p is true and q is false never occurs
Thus, p  q is always true
Direct Proof (Example 1)
Show that if n is an odd integer, then n2 is odd.
Proof : Assume that n is an odd integer. This implies that there is some integer k such that n = 2k + 1.
Then n2 = (2k+1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1. Thus, n2 is odd.
Direct Proof (Example 2)
Show that if m and n are both square numbers, then mn is also a square number.
• Proof : Assume that m and n are both squares. This implies that there are integers u and v such that
m = u2 and n = v2.
Then mn = u2 v2 = (uv)2. Thus, mn is a square.

The proof by contraposition method makes use of the equivalence

To show that the conditional statement p  q is true, we first assume is true, and use
axioms, definitions, proved theorems, with

rules of inference, to show is also true

Proof by Contraposition (Example 1)


• Show that if 3n + 2 is an odd integer, then n is odd.
• Proof : Assume that n is even. This implies that n = 2k for some integer k.
Then, 3n + 2 = 3(2k) + 2 = 6k + 2 = 2(3k + 1),so that 3n + 2 is even. Since the negation of conclusion
implies the negation of hypothesis,the original conditional statement is true.
Proof by Contraposition (Example 2)
• Show that if n = ab, where a and b are positive,

then .

13
• Proof : Assume that both a and b are larger than .

Thus, . Since the


negation of conclusion implies the negation of hypothesis, the original conditional statement
is true.
The proof by contradiction method makes use

of the equivalence
where F0 is any contradiction
• One way to show that the latter is as follows: First assume ¬ p is true, and then show that
for some proposition r, r is true and ¬ r is true
• That is, we show ¬ p  ( r ˄ ¬ r ) is true

Proof by Contradiction (Example 1)


• Show that if 3n + 2 is an odd integer, then n is odd.
• Proof : Assume that the statement is false. Then we have 3n + 2 is odd, and n is even.
The latter implies that n = 2k for some integer k, so that 3n + 2 = 3(2k) + 2 = 2(3k + 1).
Thus, 3n + 2 is even. A contradiction occurs (where ?), so the original statement is true
The proof by cases method makes use of the equivalence

Sometimes, to prove p  q is true, it may be easy to use an equivalent disjunction p1˅p2


˅ … ˅ pk instead of p as the hypothesis

14
Proof Strategies
Adapting Existing Proof

• Show that is irrational.


• Instead of searching for a proof from nowhere, we may recall some similar theorem, and see
if we can slightly modify (adapt) its proof to obtain what we want.
Sometimes, it may be difficult to prove a statement q directly
• Instead, we may find a statement p with the property that p  q, and then prove p
Note: If this can be done, by Modus Ponens, q is true
• This strategy is called backward reasoning.
Backward Reasoning (Example)
• Show that for distinct positive real numbers x and y,
0.5 ( x + y ) ˃ ( x y )0.5
• Proof: By backward reasoning strategy, we find that

Thus, the original statement is true.

Sequences and summations


Sequences
Definition:A sequence is a function from a subset of the set of integers (typically the set
{0,1,2,...} or the set {1,2,3,...} to a set S. We use the notation an to denote the image of the
integer n. We call an a term of the sequence.
Notation: {an} is used to represent the sequence (note {} is the same notation used for sets, so be
careful). {an} represents the ordered list a1, a2, a3, ...

15
Examples:
(1) an = n2, where n = 1,2,3...– What are the elements of the sequence?
1, 4, 9, 16, 25, ...
(2) an = (-1) n, where n=0,1,2,3,... – Elements of the sequence?
1, -1, 1, -1, 1, ...
3) an = 2 n, where n=0,1,2,3,... – Elements of the sequence?
1, 2, 4, 8, 16, 32, ...
Arithmetic progression
Definition: An arithmetic progression is a sequence of the form
a, a+d,a+2d, …, a+nd where a is the initial term and d is common difference, such that
both belong to R.
Example:
sn= -1+4n for n=0,1,2,3, …
members: -1, 3, 7, 11, …
Geometric progression
DefinitionA geometric progression is a sequence of the form:
a, ar, ar2, ..., ark, where a is the initial term, and r is the common ratio. Both a and r belong to R.
Example:
an = ( ½ )n for n = 0,1,2,3, …
members: 1,½, ¼, 1/8, …..

Given a sequence finding a rule for generating the sequence is not always straightforward.
Example:
Assume the sequence: 1,3,5,7,9, ….
What is the formula for the sequence?
Each term is obtained by adding 2 to the previous term.
1, 1+2=3, 3+2=5, 5+2=7
What type of progression this suggest?
Example:
Assume the sequence: 1,3,5,7,9, ….
What is the formula for the sequence?
Each term is obtained by adding 2 to the previous term.
1, 1+2=3, 3+2=5, 5+2=7
It suggests an arithmetic progression: a+nd
with a=1 and d=2
an=1+2n

16
Example 2:
Assume the sequence: 1, 1/3, 1/9, 1/27, …
What is the sequence?
The denominators are powers of 3.
1, 1/3= 1/3, (1/3)/3=1/(3*3)=1/9, (1/9)/3=1/27
This suggests a geometric progression: ark
with a=1 and r=1/3
(1/3 )n
Recursively defined sequences
The n-th element of the sequence {an} is defined recursively in terms of the previous
elements of the sequence and the initial elements of the sequence.
Example :
an = an-1 + 2 assuming a0 = 1;
a0 = 1;
a1 = 3;
a2 = 5;
a3 = 7;
Can you write an non-recursively using n?
an = 1 + 2n.

Fibonacci sequence
Recursively defined sequence, where
f0 = 0;
f1 = 1;
fn = fn-1 + fn-2 for n = 2,3, …
f2 = 1
f3 = 2
f4 = 3
f5 = 5
Summations
Summation of the terms of a sequence:

The variable j is referred to as the index of summation.


m is the lower limit and
n is the upper limit of the summation.
Example:
1) Sum the first 7 terms of {n2} where n=1,2,3, ... .

17
2) What is the value of

Arithmetic series
Definition: The sum of the terms of the arithmetic progression
a, a+d,a+2d, …, a+nd is called an arithmetic series.
Theorem: The sum of the terms of the arithmetic progression
a, a+d,a+2d, …, a+nd is

Theorem: The sum of the terms of the arithmetic progression


a, a+d,a+2d, …, a+nd is

18
Example:

Example 2:

19
Double summations
Example:

Geometric series
Definition: The sum of the terms of a geometric progression a, ar,
Ar2, ..., ark is called a geometric series.
Theorem: The sum of the terms of a geometric progression a, ar,
Ar , ..., arn is
2

Geometric series
Theorem: The sum of the terms of a geometric progression a, ar,ar2.......arn is

20
Infinite geometric series
Infinite geometric series can be computed in the closed form
for x<1
How?

Mathematical Induction

Here we have well-founded on N.


Principle of Mathematical Induction: To prove that P(n) is true for all n € N, we complete these
steps:
Basis Step: Show that P(0) is true.
(In the instantiation of the formula for well-founded induction this is the only case where there
are no R-“smaller” elements y.)
Inductive Step: Show that P(k)  P(k + 1) is true for all k € N.
To complete the inductive step, we assume the inductive hypothesis that P(k) holds for an
arbitrary integer k, and then, under this assumption, show that P(k + 1) must be true.

21
Note: Proofs by mathematical induction do not always start at the integer 0. In such a case, the
basis step begins at a starting point b where b is an integer. In this case we prove the property
only for integers ≥ b instead of for all of N.
Proving a Summation Formula by Mathematical Ind.
Show that the following property P(n) that

Proving Inequalities by Mathematical Induction


Example: Use mathematical induction to prove that 2n < n! for every
integer n ˃4.
Solution: Let P(n) be the proposition that 2n < n!.
Basis step: P(4) is true since 24 = 16 < 4! = 24.
Inductive step: Assume P(k) holds, i.e., 2k < k! for an arbitrary integer
k ≥ 4. To show that P(k + 1) holds:
2k+1 = 2. 2k
< 2 . k! by the inductive hypothesis
< (k + 1)k!
= (k + 1)!
Therefore, 2n < n! holds, for every integer n ≥4.
Note that the basis step is P(4), since P(0)………P(3) are all false.

Recursively Defined Functions


Definition
A recursive or inductive definition of a function consists of two steps.
Basis step: Specify the value of the function at zero.
Recursive step: Give a rule for finding its value at an integer from its values at smaller integers.
A function f : N  N corresponds to sequence a0; a1…….where
ai = f (i).

22
Example: Give a recursive definition of the factorial function n!.
f (0) = 1
f (n + 1) = (n + 1) . f (n)
Example: Fibonacci numbers. f (0) = 0, f (1) = 1 and
f (n + 2) = f (n + 1) + f (n).
Recursively Defined Sets and Structures
Recursive definitions of sets have two parts:
The basis step specifies an initial collection of elements. The recursive step gives the rules for forming
new elements in the set from those already known to be in the set.
Sometimes the recursive definition has an exclusion rule, which specifies that the set contains nothing
other than those elements specified in the basis step and generated by applications of the rules in
the recursive step.
We will always assume that the exclusion rule holds, even if it is not explicitly mentioned.
We will later develop a form of induction, called structural induction, to prove results about recursively
defined sets.
Example: A subset of Integers S:
Basis step: 3 ϵ S.
Recursive step: If x ϵS and y ϵS, then x + y ϵ S.
Initially 3 is in S, then 3 + 3 = 6, then 3 + 6 = 9, etc.
Example: The natural numbers N.
Basis step: 0 ϵN.
Recursive step: If n ϵN then n + 1 ϵN.
*
Example: The set Σ of strings over alphabet Σ.
*
Basis step: λϵΣ . (λ is the empty string.)
*
Recursive step: If w ϵΣ and x ϵΣ then wx ϵΣ
Structural Induction
Here we instantiate well-founded induction with a relation R defined as “is used as a part in the
recursive step of the construction of”.
To prove a property of the elements of a recursively defined set, we use structural induction.
Basis step: Show that the property holds for all elements specified in the basis step of the
recursive definition.
Recursive step: Show that if the property is true for each of the parts used to construct new
elements in the recursive step of the definition, then the property also holds for these new
elements.
Functions on Full Binary Trees
Definition
The height h(T) of a full binary tree T is defined recursively as follows:
Basis step: The height of a full binary tree T consisting of only a root r is h(T) = 0.
Recursive step: If T1 and T2 are full binary trees, then the full binary tree T = T 1 .T2 has height
h(T) = 1 + max(h(T1); h(T2)).
Definition
The number of vertices n(T) of a full binary tree T is defined recursively as follows:
Basis step: The number of vertices n(T) of a full binary tree T consisting of only a root r is n(T) = 1.
Recursive step: If T1 and T2 are full binary trees, then the full binary tree T = T 1 _ T2 has number of
vertices n(T) = 1 + n(T1) + n(T2).

23
Structural Induction on Binary Trees
Theorem
If T is a full binary tree, then n(T) ≤2 h(T)+1-1.
Proof by structural induction.
Basis step: The result holds for a full binary tree consisting only of a root n(T) = 1 and h(T) = 0. Hence,
n(T) = 1≤20+1-1=1
Recursive step: By induction hypothesis we assume

Recurrence relation
A recurrence relation for {an} is an equation that expresses an in terms of a0……….an -1. A sequence is
called a solution of a recurrence relation if its terms satisfy the recurrence relation.
For instance, the relation fn = fn-1 + fn-2 of Fibonacci numbers is a recurrence relation.
Example
(The Tower of Hanoi) Consider moving a stack of disks with di_erent sizes with three pegs. Initially, all
disks are sorted and placed on the _rst peg.
One can only move the topmost disk from a peg to another peg. At any time, disks on each peg must be
sorted as well. How many steps does it take to move all disks from one peg to another?
Solution: Let Hn be the number of steps to solve the problem of n disks.
Clearly, H1 = 1. Now consider moving n disks from peg 1 to peg 2. If we can move the
Top most n - 1 disks from peg 1 to peg 3, we can solve the puzzle by moving the bottom disk from peg 1
to peg 2 and then the n -1 disks

from peg 3 to peg 2. In other words,

Hence

24
THYen

CATALAN NUMBERS
Example
Find the number of ways to parenthesize the product of n + 1 numbers x 0; x1……xn.
Solution: Let Cn denote the number of ways to parenthesize the product
of n + 1 numbers. For instance, C3 = 5 because
x0 .(x1 . (x2 . x3)) x0 .((x1 .x2) . x3) (x0 .(x1 .x2)) .x3 ((x0 .x1) . x2) .x3

Homogeneous Linear recurrence relations with constant coefficients


Definition :A linear homogeneous recurrence relation of degree k with constant
coefficients is of the form.

25
Theorem:

Proof.

Fibonacci numbers
Example
Recall the recurrence relation for Fibonacci numbers fn = fn-1 + fn-2 with f0 = 0 and f1 = 1. Find an explicit
formula for the Fibonacci numbers.

26
Characteristic Equations with Multiple Roots:
Theorem:

Example
What is the solution of the recurrence relation

27
GENERATING FUNCTIONS
Any sequence a0, a1, a2, . . . can be encoded as a formal infinite power series
a 0x 0 + a 1x 1+ a 2x2 + . . .
def: An (ordinary) generating function for a sequence a0, a1, a2, . . . is a function whose formal
power series (Maclaurin series) has that sequence as its sequence of coefficients.
Example : The generating function for the sequence 1, 1, 1, . . . is the function

RATIONAL FUNCTIONS
def: A rational function is the quotient of two finite polynomials.

Example
Remark: Rational functions are among the most frequently encountered generating functions.
One may think of a closed form as a way of “generating” the coefficients of a power series. In
particular, division of polynomials generates the power series.
Example: Long division of polynomials

28
Prop: Every rational function is the OGF for a sequence.
Proof: As illustrated by Example
ENCODING A GIVEN SEQUENCE AS AN OGF
Several principles are valuable in constructing an OGF for a given sequence. Proofs are omitted .
Prop: Two generating functions

Example:

is the sum of the OGF’s

Inclusion-Exclusion
Principle: The number of elements in the union of the two sets A and B is the sum of the numbers of
elements in the sets minus the number of elements in their intersection. That is,

Theorem:

Proof: Suppose that a is a member of exactly r of the sets. Then a is counted times by the

first sum, times by the second sum and counted by the m th sum. Thus, a is counted

29
times in all. Considering the expansion of (1 -1) r , we see that the above expression is equal to 1. Thus,

each member of A is counted exactly once by the right-hand sequence of sums, so it equals
Example: Give a formula for the number of elements in the union of four
arbitrary sets: A1,A2, A3,A4.
Give a formula for the number of elements in the union of four arbitrary sets: A1,A2, A3,A4.

Relations, Their Properties and Representations

Review: Ordered n-tuple :


Definition :The ordered n-tuple (a1, a2, ..., an) is the ordered collection that has a1 as its first
element, a2 as its second element, ..., and an as its nth element.
Two n-tuples are equal if and only if each corresponding pair of their elements is equal.
We call 2-tuples couples or ordered pairs.
Definition: Cartesian Product
Let A and B be sets. The Cartesian product of A and B, denoted
by A × B, is the set of all ordered pairs (a, b), where a ∈A and b ∈ B. Hence,
A × B = {(a, b) | a ∈ A ∧b ∈ B}.
Example: Let A = {1, 2} and B = {a, b, c}.
Then A × B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}.
Note: The Cartesian products A × B and B × A are, in general, not equal.
Definition: Binary Relation
Definition
Let A and B be sets. A binary relation from A to B is a subset of A × B.
Example: Let A = {0, 1, 2} and B = {a, b}. Then
R = {(0, a), (0, b), (1, a), (2, b)} ⊆ A × B
is a binary relation from A to B.
In other words, a binary relation from A to B is a set R of ordered pairs where the first element of each ordered
pair comes from A

30
and the second element comes from B. We use the notation a R b to denote that (a, b) ∈ R and a6R b to denote
that (a, b) /∈ R. Moreover, when (a, b) ∈ R, a is said to be related to b by R.

Representing Relations Using Digraphs


Definition
A directed graph G = (V , E), or digraph, consists of a set V of vertices (or nodes) together with a
set E of edges (or arcs). The vertex a is called the initial vertex of the edge (a, b), and the
vertex b is called the terminal vertex of this edge.
Example: Let A = {0, 1, 2}, B = {a, b} and the relation R = {(0, a), (0, b), (1, a), (2, b)} from A
to B.

Representing Relations Using Tables


Let R be a binary relation from A to B. Rows of a table representing the relation are an
enumeration of the elements of the set A and the columns, an enumeration of the elements of the
set B. There is a × at a given row and column of this table if the corresponding element of this
row is related to the corresponding element of this column.
Example of a Table Representing a Relation
Example: Let A = {0, 1, 2}, B = {a, b} and the relation
R = {(0, a), (0, b), (1, a), (2, b)} from A to B.

Representing Relations Using Matrices


Suppose that R is a relation from A = {a1, a2, ..., am} to B= {b1, b2, ..., bn}. Here, the elements
of the sets A and B have been listed in a particular, but arbitrary, order. Furthermore, when A =
B, we use the same ordering for A and B. The relation R can be represented by the matrix MR =
[mij ], where

31
In other words, the zero-one matrix representing R has a 1 as its (i , j) entry when ai is related to
bj , and a 0 in this position if ai is not related to bj . Such a representation depends on the
ordering used for A and B.
Example: Let A = {0, 1, 2}, B = {a, b} and the relation
R = {(0, a), (0, b), (1, a), (2, b)} from A to B.

Definition: Relation On a Set


Definition
A relation on a set A is a relation from A to A.
Example: Let A be the set {1, 2, 3, 4} and R be the relation
R = {(a, b) | a divides b} ⊆ A × A.
The ordered pairs of this relation are given by
R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.
Representing a Relation Using a Directed Graph
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(a, b) | a divides b} ⊆ A × A. This relation is the set
R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.

Representing a Relation on a Set Using a Directed Graph


Let A be the set {1, 2, 3, 4} and R be the relation on the set A given by R = {(a, b) | a divides b}
⊆ A×A. This relation is the set R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.

An edge of the form (a, a) is represented using an arc from the vertex a back to itself. Such an
edge is called a loop.

32
Representing Relations on a Set Using Tables
Let A be the set {1, 2, 3, 4} and R be the relation on the set A given by R = {(a, b) | a divides b}
⊆ A×A. This relation is the set R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.

Representing Relations on a Set Using Matrices


Let A be the set {1, 2, 3, 4} and R be the relation on the set A given by R = {(a, b) | a divides b}
⊆ A×A. This relation is the set R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.

Reflexive Relation
Definition
A relation R on a set A is called reflexive if (a, a) ∈ R for all element a ∈ A.
Remark: Using quantifiers, a relation R on a set A is reflexive if ∀a((a, a) ∈ R), where the universe of
discourse is the set of all elements in A.
Example: Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation reflexive?

33
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
reflexive?

Let A be the set {1, 2, 3, 4} and R be the relation


R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
reflexive?

Symmetric Relation
Definition
A relation R on a set A is called symmetric if (a, b) ∈ R implies that (b, a) ∈ R for all a, b ∈ A.
Remark: Using quantifiers, a relation R on a set A is symmetric if ∀a ∀b ((a, b) ∈ R → (b, a) ∈ R).
Example: Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation symmetric?
Representing a Relation on a Set Using a Directed Graph
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
symmetric?
Representing a Relation on a Set Using a Directed Graph
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation symmetric?

Using set matrices


Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
symmetric?

34
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
symmetric?

Antisymmetric Relation
Definition
A relation R on a set A is called antisymmetric if, for all a, b ∈ A, (a, b) ∈ R and (b, a) ∈ R then a = b.
Remark: Using quantifiers, a relation R on a set A is antisymmetric if ∀a ∀b (((a, b) ∈ R ∧ (b, a) ∈ R) → (a = b)).
The contrapositive is ∀a ∀b ((a 6= b) → ((a, b) /∈ R ∨ (b, a) /∈ R)).
Example: Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation antisymmetric?

Let A be the set {1, 2, 3, 4} and R be the relation


R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
antisymmetric?

Representing a Relation on a Set Using a Directed Graph


Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
antisymmetric?

35
Representing Relations on a Set Using Matrices
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
antisymmetric?

Representing Relations on a Set Using Matrices


Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
anti symmetric?

Transitive Relation
Definition
A relation R on a set A is called transitive if, whenever (a, b) ∈ R and (b, c) ∈ R, then (a, c) ∈ R,
for all a, b, c ∈ A.
Remark: Using quantifiers, a relation R on a set A is transitive if ∀a ∀b ∀c(((a, b) ∈ R ∧ (b, c) ∈ R)
→ (a, c) ∈ R).
Example: Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
transitive?
Representing a Relation on a Set Using a Directed Graph
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
transitive?

36
Representing a Relation on a Set Using a Directed Graph , Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation transitive?

Representing Relations on a Set Using Matrices


Let A be the set {1, 2, 3, 4} and R be the relation, R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this
relation transitive?

Representing Relations on a Set Using Matrices Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation transitive.

Combining Relations
Because relations from A to B are subsets of A × B, two relations form A to B can be combined in any way two sets
can be combined.
Example: A = {1, 2, 3}, B = {1, 2, 3, 4}. The relations
R1 = {(1, 1), (2, 2), (3, 3)} and R2 = {(1, 1), (1, 2), (1, 3), (1, 4)} can be combined to obtain
R1 ∪ R2 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (3, 3)}.
R1 ∩ R2 = {(1, 1)}.

37
R1 − R2 = {(2, 2), (3, 3)}.
R2 − R1 = {(1, 2), (1, 3), (1, 4)}.

Closures of Relations
Let R be a relation on a set A. The relation R may or may not have some property P such as reflexivity, symmetry or
transitivity.
If there is a relation S
◮ with property P,
◮ containing R,
◮ and such that S is a subset of every relation with property P
containing R, then S is called the closure of R with respect to P.

Reflexive Relation
Definition
A relation R on a set A is called reflexive if (a, a) ∈ R for every
element a ∈ A.
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}.

Reflexive Closure
Let R be a relation on a set A. The reflexive closure of R is R ∪ Δ where Δ = {(a, a) | a ∈ A} is called the diagonal
relation on A.
Symmetric Relation
Definition
A relation R on a set A is called symmetric if (a, b) ∈ R implies
that (b, a) ∈ R for all a, b ∈ A.
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}.

Symmetric Closure
Let R be a relation on a set A. The symmetric closure of R is R ∪ R-1
Where R -1 = {(b, a) | (a, b) ∈ R} is inverse relation of R.
Transitive Relation
Definition
A relation R on a set A is called transitive if, whenever (a, b) ∈ R
and (b, c) ∈ R, then (a, c) ∈ R, for all a, b, c ∈ A.
Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. Is this relation
transitive? If not, what is the transitive closure of R?

38
Composite of Relations
Definition
Let R be a relation from a set A to a set B, and S a relation from B to a set C. The composite of R and S is the
relation consisting of ordered pairs (a, c), where a ∈ A, c ∈ C, and for which there exists an element b ∈ B such that
(a, b) ∈ R and (b, c) ∈ S. We denote the composite of R and S by S ◦ R.

Path and Length


Definition
A path from a to b in a directed graph G is a sequence of edges (x0, x1), (x1, x2), ..., (xn−1, xn) in G, where n is a
non negative integer, and x0 = a and xn = b, that is, a sequence of edges where
the terminal vertex of an edge is the same as the initial vertex of the next edge in the path. This path is denoted by
x0, x1, x2, ..., xn−1, xn and has length n. We view the empty set of edges as a path from a to a. A path of length n ≥
1 that begins and ends at the same vertex is called a circuit or cycle.
Definition
There is a path from a to b in a relation R if there is a sequence of elements a, x1, x2, ..., xn−1, b with (a, x1) ∈ R,
(x1, x2) ∈ R, ..., (xn−1, b) ∈ R. This path is of length n.
Definition
Let R be a relation on the set A. The powers Rn, n = 1, 2, ..., are defined recursively by
R1 = R and Rn+1 = Rn ◦ R.
Theorem
Let R be a relation on the set A. There is a path of length n,
where n is a positive integer, from a to b if and only if (a, b) ∈ Rn.

Join Matrix
Definition
Let A = [aij ] and B = [bij ] be m × n zero-one matrices. Then, the
join of A and B, denoted by A ∨ B, is the m × n zero-one matrix
with (i , j)th entry aij ∨ bij .
Example. Let

Definition
Let A = [aij ] be an m ×k zero-one matrix and B = [bij ] be a k ×n
zero-one matrix. Then, the Boolean product of A and B, denoted

39
Paths and Connectivity
Definition
Let R be a relation on the set A. The connectivity relation R * consists of pairs (a, b) such that there is a path of
length at least one from a to b in R.
Theorem
The transitive closure of a relation R equals the connectivity relation R *.
Theorem
Let MR be the zero-one matrix of the relation R on a set with n elements. Then the zero-one matrix of the transitive
closure R * is

Procedure for Computing the Transitive Closure

Example of Transitive Closure, Step 1 of 4


Let A be the set {1, 2, 3, 4} and R be the relation
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}. What is the
transitive closure of R?

40
Example of Transitive Closure, Step 2 of 4

Partial Orders

Total orderings: single sequence of elements.


Partial orderings: some elements may come before/after others, but some need not be ordered
Examples of partial orderings:

41
Total Order

A total ordering is a partial ordering in which every element is related to every other element.
(This forces a linear order or chain.)

Hasse Diagrams

We produce Hasse Diagrams from directed graphs of relations by doing a transitive reduction
plus a reflexive reduction (if weak) and (usually) dropping arrowheads (using, instead, “above”
to give direction)

1) Transitive reduction ¾ discard all arcs except those that “directly cover” an element.

2) Reflexive reduction ¾ discard all self loops.

42
Descending Sequence

Descending sequence: A sequence <x1, x2, …, xn> where for i < j, x i “is strictly above” xj on a
path in a Hasse diagram; xi need not, however, be “immediately above” xj.

Well Founded Poset

A poset is well founded if it has no infinite descending sequence.

43
Application of Well Founded Posets

Has anyone ever gotten into an infinite loop in a program?

We use well founded sets to prove that loops terminate.

e.g. The following clearly terminates.

for i=1 to n do …

n-i for i=1, …, n is a descending sequence on a well founded set (the natural numbers): <n-1,
n-2, …, n-n = 0>.

Upper and Lower Bounds

If a poset is built from relation R on set A, then any x Î A satisfying xRy is an upper bound of y,
and any x Î A satisfying yRx is a lower bound of y.

• Examples: If A = {a, b, c} and R is Ê, then {a, c}

- is an upper bound of {a}, {c}, and Æ.

- is also an upper bound of {a, c} (weak poset).

- is a lower bound of {a, b, c}.

- is also a lower bound of {a, c} (weak poset).

Maximal and Minimal Elements

44
Least Upper and Greatest Lower Bounds

A least upper bound of two elements x and y is a minimal element in the intersection of the
upper bounds of x and y.

A greatest lower bound is a maximal element in the intersection of the lower bounds of x and y.

45
46

You might also like