5 Discrete-Mathematics
5 Discrete-Mathematics
5 Discrete-Mathematics
Structures
( CS330 )
S Brunda,
Assistant Professor,
CS&E,
SJCE, Mysuru
1
Course Outcomes
CO1 : Knowledge of the concepts needed to test the
logic of the program.
CO2 : Demonstrate the understanding of relations and
able to determine the properties.
CO3 : Perceive, construct and decode group codes
based on the various methods.
CO4 : Demonstrate different traversal methods for
trees and graphs.
2
Course Contents
Unit Course Content No. of
No. Hours
1. 08
Fundamental of Logic: Basic Connectives and Truth Tables, Logical
Equivalence: The Laws of Logic, Logical Implication: Rules of
Inference, The Use of Quantifiers, Quantifiers, Definitions and the
Proofs of Theorems.
2. 08
Relations: Properties of relations, Computer Recognition: Zeros- One
Matrices and Directed Graphs, Partial; orders: Hasse diagrams ,
Equivalence Relations and Partitions , Lattices.
3 08
Elements of coding theory and Hamming Metric, generation of codes
using Parity check and Generator matrices.
4. 08
Graph theory: Definitions and Examples, Subgraphs, Complements,
and Graph Isomorphism, Vertex degree, Euler trail and circuits, Planar
Graphs, Hamiltonian Paths and cycles.
5.
Trees: Definitions, Properties and Examples, Rooted trees, trees and
sorting weighted trees and prefix Codes.
07
3
Text and Reference Books
Text Book:
1. Ralph.P.Grimaldi, B.V.Ramana, “Discrete and Combinatorial Mathematics”,
Reference Books:
1. Kenneth. H.Rosen, “Discrete Mathematical Structures Theory and
Application”, V Edition, PHI/Pearson, Education, 2004.
4
What is Discrete Mathematics?
Discrete mathematics is a study of discrete
structures which are abstract mathematical models
that deals with discrete objects and their
relationships.
5
Applications of Discrete Mathematics
6
Unit – 1
Fundamentals of Logic
7
What is Logic ?
• Logic deals with the methods of reasoning
• Logic is extremely useful in decision making
problems
• Logic theory forms the basics for Artificial
intelligence, Fuzzy logic, Expert Systems etc.,
8
Propositions
• A proposition is a statement or sentence that
can be determined to be either true or false
(but no both).
• Examples:
– The only positive integers that divide 7 are 1
and 7 itself. (True)
– Everybody likes chocolate.(False)
– It is raining outside (True or False)
9
Continued…
Not all sentences are proposition
Eg.,
❖ x + 3 > 7 /* we cannot decide whether True or False
unless we know the value of x */
❖ Give your book /* It’s a sentence but not statement ,
hence its not a proposition */
❖ What a beautiful garden ! /* exclamation and
commands are sentences but not statements */
10
Example
• Use variable(p, q, r..) to represent propositions
• p: 1+1=3
• q: It is raining outside
• r: Today is Tuesday
The statements represented by p, q, r are considered to be primitive
statements because they cannot be broken down into anything
simpler
11
Connectives
If p and q are propositions, new compound
propositions can be formed by using
connectives
• Most common connectives:
– Conjunction (and) ^
– Disjunction (or)
– Negation (not) ~ (¬)
– Exclusive-OR v
– Condition (if … then) →
– Bi-Condition
12
Example
• P: It is raining
• Q: It is cold
13
Truth table of conjunction
• The truth values of compound propositions
can be described by truth tables.
• Truth table of conjunction
P Q PQ
T T T
T F F
F T F
F F F
15
Truth table of disjunction
• The truth table of disjunction is
P Q PQ
T T T
T F T
F T T
F F F
16
Truth table of Negation
• Negation of P: in symbols ~P or ⌐P
P ~P
T F
F T
17
Negation Continued…
• E.g
• Example, P : "John is a programmer"
~P = "John is not a programmer"
18
Exclusive disjunction
• “Either P or Q” (but not both), in symbols P Q
P Q PvQ
T T F
T F T
F T T
F F F
• P Q is true only when P is true and Q is false,
or P is false and Q is true.
❑ Example: p = "John is programmer, q = "Mary is a lawyer"
❑ p v q = "Either John is a programmer or Mary is a lawyer"
19
More compound statements
• Let p, q, r be simple statements
• We can form other compound statements, such
as
(p q) r
p(q r)
(~p) (~q)
(p q) (~r)
and many others…
20
Example: truth table of (P Q)R
P Q R (P Q) R
T T T T
T T F F
T F T T
T F F F
F T T T
F T F F
F F T F
F F F F
21
Conditional (Implication)
• A conditional proposition is of the form
“If P then Q”
• In symbols: P → Q
• Example:
P = " A bottle contains acid"
Q = “A bottle has a label”
P → Q = “If a bottle contains acid then it
has a label "
22
Truth table of P → Q
P Q P→Q
T T T
T F F
F T T
F F T
• Let
P: The Mathematics Department gets an additional
Rs. 40,000
Q: The mathematics Department will hire one new
faculty member.
24
Hypothesis and conclusion
• In a conditional proposition P → Q,
P is called the hypothesis
Q is called the conclusion
25
Example
• For all real number x if x > 0 then x2 > 0
• P: x>0
• Q: x2 > 0
For example x=3 , 3 > 0 then 32 > 0 both are true.
P→Q=T →T=T
x = -2 , -2 > 0 is false but -22 > 0 is true
P→Q=F→T=T
26
Bi-Conditional
• The double implication “p if and only if q” is
defined in symbols as p q
p q pq (p → q) ^ (q → p)
T T T T
T F F F
F T F F
F F T T
28
(p → q) [(q ¬ r) → (p r)]
p q r p→q q¬r p r [(q ¬ r) → (p r)] a b
(a) (b)
0 0 0 1 0 0 1 1
0 0 1 1 0 1 1 1
0 1 0 1 1 0 0 0
0 1 1 1 0 1 1 1
1 0 0 0 0 1 1 0
1 0 1 0 0 1 1 0
1 1 0 1 1 1 1 1
1 1 1 1 0 1 1 1
29
Exercise Problems continues…
Let s, t and u denote the following primitive
statements
s : Phyllis goes out for walk
t : The moon is out
u : It is snowing
Express the following compound proposition in words
a) (t ¬u) → s
b) t → (¬u → s)
c) ¬(s ↔ (u t))
30
Solution
a) If the moon is out and it is not snowing, then
Phyllis goes out for walk.
b) If the moon is out then if it is not snowing
then Phyllis goes out for a walk.
c) It is not that Phyllis goes out for a walk if and
only if it is snowing or the moon is out.
31
Exercise problems continues…
Write the compound proposition for the following
sentences.
d) Phyllis will go out for walking if and only if the
moon is out. (s ↔ t)
e) If it is snowing and moon is not out, then
Phyllis will not go out for walk (u ¬t) → ¬ s
f)It is snowing but Phyllis will still go out for a
walk. (u s)
32
Exercise problems continues…
Let p and q be primitive statement for which the
conditional p → q is false.
Determine the truth values of the following
compound propositions.
1. p л q
2. (¬p q)
3. q → p
4. ¬q → ¬p
33
Exercise problems continues…
Find the possible truth values of p, q and r in the
following cases
1. p →(q r) is false
2. p л (q →r) is true
34
Exercise problems continues…
If a proposition q has the true value 1, determine
all the truth assignment for the primitive
proposition p, q, r and s for which the truth value
of the following proposition is 1
[q→{(¬p r) л ¬s}] л {¬s → (¬r л q)}
35
Solution :
36
Solution…
37
Tautology
• A proposition is a tautology if its truth table
contains only true values for every case
– Example: p → p v q
p q p→pvq
T T T
T F T
F T T
F F T
38
Contradiction
• A proposition is a Contradiction or
absurdity if its truth table contains only
false values for every case
– Example: p ^ ~p p p ^ (~p)
T F
F F
39
Contingency
A compound proposition that can be true or false
( depending upon the truth values of its
components) is called Contingency.
40
Exercise problems :
1. Prove that, for any proposition p,q,r the
following compound propositions are Tautology
a) [(p → q) Л (q → r)] → (p → r)
b) [p →(q →r)] → [(p →q) → (p →r)]
41
Logical equivalence (⇔)
❑ Two propositions are said to be logically
equivalent ⇔ if their truth tables are identical.
P Q P→Q ~P Q
T T T T
T F F F
F T T T
F F T T
❑Example: P → Q is logically equivalent to ~P Q
P → Q ⇔ ~P Q
42
Problems:
1. Prove that [(p q) → r] ⇔ [( p →r)ᴧ (q →r)]
2. pᴧ(¬q r) and p (q ᴧ ¬r) are not logically
equivalent
43
Definitions
• Implication p→q
• contrapositive, q→ p
• converse, q→ p
• inverse p → q
Converse
• The converse of p → q is q → p
p q p→q q→p
T T T T
T F F T
F T T F
F F T T
p q p→q ~q → ~p
T T T T
T F F F
F T T T
F F T T
They are logically equivalent.
46
The Laws of Logic
We can prove whether the given Compound
proposition is Tautology, Contradiction ,
contingency or logically equivalent using Truth table
method.
But this method becomes tedious when the
number of primitive proposition involved is more.
Hence easiest method is to prove using the Laws of
Logic
47
1. De Morgan’s laws for logic
~ (p q) and (~p)^(~q)
~ (p ^ q) and (~p) (~q)
48
Proof :
~ (p q) and (~p)^(~q)
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
Therefore ~ (p q) ⇔ (~p)^(~q)
49
2. Distributive Law
• p ᴧ (q r) ⇔ (p ᴧ q) (p ᴧ r)
• p (q ᴧ r) ⇔ (p q) ᴧ (p r)
50
Laws of Logic
• Let P , Q and R be the propositional variables. T and F represent the True
and False respectively.
❖ (P v Q) ⇔ (Q v P) Commutative Laws
❖ (P ^ Q) ⇔ (Q ^ P)
❖ P ^ (Q ^ R) ⇔ (P ^ Q) ^ R Associative Laws
❖ P v (Q v R) ⇔ (P v Q) v R
51
Laws of Logic….
❖ P ^ (Q v R) ⇔ (P ^ Q) v (P ^ R) Distributive Laws
❖ P v (Q ^ R) ⇔(P v Q) ^ (P v R)
❖ (P ^ P) ⇔ P Idempotent Laws
(P v P) ⇔ P
❖ (P v F ) ⇔ P Identity Laws
❖ (P ^ T ) ⇔ P
❖ (P v ¬P ) ⇔ T Inverse Laws
❖ (P ^ ¬P) ⇔ F
52
Laws of Logic…
❖ (P v T ) ⇔ T Domination Laws
❖ (P ^ F) ⇔ F
❖ P v (P ^ Q) ⇔ P Absorption Laws
❖ P ^(P v Q) ⇔ P
53
Exercise Problems
Simplify the following compound proposition using the laws of
logic:
1. (p v q) ᴧ ¬ {(¬p) v q}
54
Exercise Problems
2. Prove that ( p v q )ᴧ ¬(¬p ᴧ q ) ⇔ p
55
Exercise Problems
56
Exercise Problems
57
Exercise Problems
58
Exercise Problem :
59
Application to Switching Networks
• A switching network is made up of wires and
switches connecting two terminals say T1 and
T2.
• In such a network , each switch is open (so no
current flows through it) or closed(so that
current flows through it).
• If a switch is open, we assign the symbol 0 to it
and if it closed we assign 1.
60
Switching Networks…
• There is a close analog between switches and their
states and proposition and their truth values.
61
Switching Networks…
62
Switching Networks…
63
Switching Networks..
64
Examples:
Simplify the switching network shown below:
65
Solution
T1 __________ r __________T2
66
Example 2…
• Simplify the network shown below
• [p v (p ᴧ q) v (p ᴧq ᴧ¬r)] ᴧ [(p ᴧ r ᴧ t) v t]
67
Solution :
68
Example 3 & 4
69
Solution 3
70
Solution 4:
71
Try It Yourself
72
Duality
• Let s be a statement. If s contains no logical connectives
other than ᴧ and ᴠ, then the dual of s, denoted sd, is the
statement obtained from s by replacing each occurrence
of ᴠ by ᴧ and ᴧ by ᴠ respectively, and each
occurrence of T0 and F0 by F0 and T0, respectively.)
73
Write down the duals for the following propositions :
1. p→q
= [ ¬p ᴠ q ]d
= ¬p ᴧ q
2. (p→q) →r
= ¬(p→q) ᴠ r
= ¬(¬p ᴠ q) ᴠ r
= [ p ᴧ ¬q ᴠ r ]d
= p ᴠ ¬q ᴧ r
3. p ↔ q ?
74
Principle of Duality
Let s and t be the statements that contain no
logical connectives other than ᴠ and ᴧ .
If s ⇔ t
then sd ⇔ td
75
Example
Verify the principle of duality for the following logical
equivalence.
76
77
Other Connectives : ↑ ↓
For any two propositions p and q, the DeMorgan’s law
states that
¬(p ˄ q) ⇔ ¬p ᴠ ¬q and
¬(p ᴠ q) ⇔ ¬p ᴧ ¬q
78
• The symbol ↑ is called the NAND connective and is
the combination or not and and .
• The symbol ↓ is call the NOR connective and is the
combination of not and or
p q ¬p ¬q ¬pᴠ¬q ¬(p ˄ q)
↑
0 0 1 1 1 1
0 1 1 0 1 1
1 0 0 1 1 1
1 1 0 0 0 0
79
Exercise problems:
For any proposition p and q, prove the following
1. ¬(p ↓q) ⇔ ¬p ↑ ¬q
80
2. ¬(p ↑ q) ⇔ ¬p ↓ ¬q
81
Are ↑ and ↓ Associative ?
Is
p ↑(q ↑ r) ⇔ (p ↑ q) ↑ r ?
82
No!!
83
Exercise problems:
Express the following propositions in terms of only
NAND and NOR connectives
1. ¬p
2. p ᴧ q
3. p ᴠ q
4. p → q
84
85
Converse, Inverse and Contrapositive: Logical
Implication
Consider a conditional p → q then,
86
State conditional , converse, inverse and contrapositive for
the following primitive propositions
p: It rains
q: the game will be cancelled
1. p→q : If it rains, then the game will be cancelled.
2. q→p : If the game is cancelled, then it has rained.
3. ¬p→¬q : If it doesnot rain, then the game will not be
cancelled.
4. ¬q→¬p : If the game is not cancelled, then it has not
rained.
87
Truth Table :
p q ¬p ¬q p→q q →p ¬p→¬q ¬q→¬p
0 0 1 1 1 1 1 1
0 1 1 0 1 0 0 1
1 0 0 1 0 1 1 0
1 1 0 0 1 1 1 1
From the above Truth Table we have the following important results:
1. The conditional and Contrapositive are logically equivalent for any proposition p and q
( p → q ) ⇔ ( ¬q→¬p )
2. The converse and Inverse of a conditional are logically equivalent for any proposition
p and q. ( q →p ) ⇔ ( ¬p→¬q )
And also ( p → q ) ⇔ ( q →p )
(¬p→¬q) ⇔ (¬q→¬p)
88
Logical Implication :
Consider the implication p→q, for any two propositions p
and q.
p : 6 is a multiple of 2
q : 3 is a prime number
89
• Hence we are interested in conditional p→q where p
and q are related in some way, so that the truth value of
q depends upon truth value of p or vice verse. Such
conditional are called Hypothetical statements or
Implicative statements.
• When a hypothetical statement p→q is such that q is
true whenever p is true , then we say that p logically
implies q and symbolically written as p ➔ q.
• When a hypothetical statement p→q is such that q is is
not necessarily true whenever p is true , then we say
that p does not logically implies q and symbolically
written as p ➔ q.
90
Necessary and Sufficient Conditions :
Suppose that p ➔ q , then in order that q may be
true if is sufficient that p is true, also if p is true ,
then it necessary that q is true.
i.e For p ➔ q p is sufficient for q
q is necessary for p
91
Problems:
Using the truth table prove the following logical implication.
1. [ p ᴧ ( p→q ) ] ➔ q
p q p→q p ᴧ (p→q )
0 0 1 0
0 1 1 0
1 0 0 0
1 1 1 1
2. [ ( p→q ) ᴧ ¬q ] ➔ ¬q
p q p→q ¬q p→q ) ᴧ ¬q
0 0 1 1 1
0 1 1 0 0
1 0 0 1 0
1 1 1 0 0
3. The following are 3 valid arguments. Establish the validity of each
by the means of Truth Table. In each case, determine which rows of
the table are crucial for accessing the validity of the argument and
which rows can be ignored.
a. [ p ᴧ ( p → q) ᴧ r ] ➔ [ ( p ᴠ q ) → r ]
(a) (b)
p q r p→q (a) pᴠq (b)
0 0 0 1 0 0 1
0 0 1 1 0 0 1
0 1 0 1 0 1 0
0 1 1 1 0 1 1
1 0 0 0 0 1 0
1 0 1 0 0 1 1
1 1 0 1 0 1 0
1 1 1 1 1 1 1
93
b. [ [ ( p ᴧ q ) → r ] ᴧ ¬q ᴧ (p → r) ] ➔ (¬p ᴠ ¬q)
c. [ [ p ᴠ (q ᴠ r) ] ᴧ ¬q ] ➔ (p ᴠ r)
94
Rules of Inferences
Establishing the validity of an argument by constructing the Truth
Table is tedious method for the following reasons.
95
Rules of Inferences
Logical Implication: Rules of Inference
an argument: ( p1 p 2 p n ) → q
premises conclusion
is a valid argument
( p1 p 2 p n ) → q is a tautology
•
97
Rule 1, can be verified using the truth table
0 0 1 0 1
0 1 1 0 1
1 0 0 0 1
1 1 1 1 1
98
•
99
100
•
101
102
103
•
104
•
105
106
•
107
Problems 1:
P1 : if I study, I will not fail in the examination.
P2: If I don’t watch tv in the evening, I will study.
P3: I failed in the examination.
C : I must have watched tv in the evening
108
Then the given arguments can be read as
p → ¬q
¬r → p
q
Therefore r
109
Problem 2:
I will get grade A in this course or I will not graduate.
If I don’t not graduate, then I will join army
I got grade A
Therefore I will not join the army
Let the primitives be
p: I get grade A in tis course
q: I graduated
r: I join the army
110
Solution
111
Problem 3:
Consider the following arguments
1) Rita is baking a cake
2) If Rita is baking a cake, then she is not practicing her flute
3) If Rite is not practicing her flute, then her father will not buy
her a car
4) Therefore Rita’s father will not buy her a car.
112
113
Problem 4:
Show that the following argument is valid (for primitive
statements p, r, s, t and u) and the conclusion ¬p
p→r , r→s , t ˅ ¬s , ¬t ˅ u , ¬u
114
Solution :
115
Rule 4 : Rule of Conjunction
• This rule arises from the fact that if p and q are true statements
then p ˄ q is also a true statement.
• The statements p and q may occur in the development of an
argument as a given premises or may be the result that are
derived from the premises in the earlier arguments.
• Under these circumstances the two statements p and q can be
combined into their conjunction p ˄ q , and this new statement
can be used in later steps .
• Rule of Conjunction can be written as
p
q
Therefore p ˄ q
116
Problem on application of Rule of Conjunction
Test the validity of the following argument.
p˄q
p→(q→r)
r
117
Rule 5 : Rule of Disjunctive Syllogism
[ ( p V q) Л ¬p] → q
pVq
¬p
q
118
Rule 6 : Rule of Contradiction
Let ‘p’ denote an arbitrary statement, and F0 a
contradiction, then
(¬p → F0 ) → p i.e ¬p → F0
p
119
Rule 8 : Rule of Disjunctive Amplification
p → (p V q) i.e p
pVq
Problems :
1. Demonstrate the validity of the following argument
p→ r
¬p → q
q→s
¬r → s
120
121
2. Establish the validity of the argument
p→q
q→(r ᴧ s)
¬r ᴠ (¬t ᴠ u)
pᴧt
u
122
123
Show that the following argument is valid
If the band could not play rock music or the
refreshments were not delivered on time, then the New
year’s party would have been cancelled and Alicia
would have been angry.
If the party were cancelled , then refunds would be
made
No refunds were made
Therefore the band could play rock music.
124
125
Quanitifier
• A sentence that involves a variable , such as x, cannot be called
as a statement.
• These cannot be called as proposition unless the valve of x is
specified.
• Eg., x+2 is an even integer.
x divides 16 etc.,
• Sentences of this kinds are called as Open Statements.
• If the open statement contains a variable ‘x’ and when we
restrict certain allowable choice for this ‘x’. These allowable
choices are called the Universe or Universe of Discourse for
open statement.
126
Quantifier…
•
127
Quantifier…
• In the examples of p(x) and q(x,y) some substitutions
results in true statements and others results in false
statement.
• Therefore we can say
For some x, p(x) is True
For some x,y , q(x,y) is True
Similarly,
For some x, ¬p(x) is False
For some x,y , ¬q(x,y) is False
• The phrases “For some x” and “For some x,y” are said
to quantify the open statements p(x) and q(x,y)
respectively
128
Quantifier…
•
129
Quantifier…
•
130
Quantifier…
131
Quantifier and Logical Connectives
•
132
Quantifier and Logical Connectives…
Write the Truth value for the following.
i) p(2)
ii) ¬q(4)
iii) p(-1) ᴧ q(1)
iv) ¬p(3) ᴠ r(0)
v) p(0) → q(0)
vi) p(1) ↔ ¬q(2)
vii) p(4) ᴠ [ q(1) ᴧ r(2)]
viii) p(2) ᴧ [q(0) ᴠ ¬r(2)]
133
Solution :
i. True
ii. False
iii. False
iv. False
v. True
vi. False
vii. False
viii.True
134
Converse, Inverse and Contrapositive for open
statements
•
135
Exercise Problems:
136
Solution:
137
138
Truth values of Quantified Statements
•
139
Rules of Inference for Open Statement:
140
Logical Equivalence
141
Rules of Negation of Quantified Statements
142
Problems:
143
Solution:
144
Problem :
145
Solution
•
146
Validity of a Open Statement :
Eg., For the universe of all the people, consider the open
statements
m(x) : x is a mathematics professor
c(x) : x has studied Calculus
147
•
148
149
Problems
• Consider the universe of all triangles in the plane in conjunction
with the open statement
• p(t) : t has two sides of equal length
q(t) : t is an isosceles triangle
r(t) : t has two angles of equal measures
The arguments are
In triangle xyz there is no pair of angles of equal measure
If a triangle has 2 sides of equal length, then it is isosceles
If a triangle is isosceles, then it has two angles of equal measure.
Therefore triangle xyz has no two sides of equal length.
150
•
p(x) : x is square
q(x) : x has four sides
Arguments are
All square have four sides
The quadrilateral ABCD has four sides
Therefore ABCD is a square
152
153
Find whether the following argument is valid or not.( consider the
all the engineering students as universe)
154
•
155
156
The Rule of Universal Generalization
•
157
Solution:
158
159
1
Unit 2 - Relations
Definition : 2
Let A and B be two sets. Then a subset of A X B is called a Binary Relation or
just a Relation from A to B.
1
r
2
3
s
Example: 4
Let A = {1,2,3,4,5}
Define a relation R on set A by aRb if a<b
R = { (1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5) }
Eg., A = {1,2,3,4}
R = {(1,2),(2,3),(3,1),(4,3)} Asymmetric
R1 = {(1,2),(2,1),(1,1)} Not Asymmetric but
symmetric
Antisymmetric Relation 11
A relation R on a set A is said to be antisymmetric if (a,b) ∈ R
and (b,a) ∈ R ,then a=b
Eg., A = {1,2,3,4}
R = {(1,2),(3,4),(4,3),(1,1)} Not antisymmetric
R1 = {(1,1),(2,2),(2,3),(4,2)} antisymmetric.
A relation can be both symmetric and Antisymmetric 12
Let A = {1,2,3}
R1 = {(1,1),(2,2)} is both symmetric and Antisymmetric
Computer Recognition
REPRESENTATION OF RELATION FOR COMPUTER RECOGNITION
Tools for representation of a relation 17
1. Relation Matrix (Zero-One Matrix)
2. Directed Graphs (Digraphs)
1
3
4
Directed Graphs (Digraphs) :….. 22
A vertex which is neither a source or terminus vertex is called
Isolated Vertex
The vertex in which the source and terminating vertex are same
is called as the Self-loop
The number of edges terminating at a vertex is called the
In-degree of the vertex
The number of edges leaving the vertex is called the Out-
degree of that vertex
Problems : 23
1. Let A= {1,2,3,4} and let R be the relation on A defined by xRy if and only
“x divides y” written as x|y
a) Write down R as a set of ordered pairs.
b) Draw the digraph of R.
c) Determine the In-degree & Out-degree of the vertices in the
digraph.
1 2
a. R = {(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4)}
1 2 3 4
In-Degree 1 2 3 3 4 3
Out-Degree 4 2 1 1
Problems :…. 24
2. Let A = {1,2,3,4,6} and R be a relation on A defined by aRb if and only
if ‘a is multiple of b’. Represent the relation R as a matrix and draw its
diagraph. R = {(1,1),(2,1),(3,1),(4,1),(6,1),(2,2),(4,2),(6,2),(3,3),(6,3),(4,4),(6,6)}
1 0 0 0 0
1 1 0 0 0
M(R) = 1 0 1 0 0
1 1 0 1 0
1 1 1 0 1
Problems…. 25
3. Find the relation R on set A determined by the digraph given below, also
write the relation matrix.
Representation of properties of relation using Zero-One matrix 26
and digraph
1 1 1
0 1 0
0 1 1
0 1 0
0 0 1
1 0 0
0 1 1
1 0 0
1 0 0
1 1 1
0 1 0
0 1 1
1 1 1
0 0 1
1 1 0
1 0 1 0 1 1 1 1
M(R) = 0 0 0 1 M(S) = 0 0 0 1
1 1 1 0 0 1 0 1
Problems… 37
The digraph of two relations R and S on a set A = {a,b,c} are given below
Draw the digraph of R, R∩ S, R ∪ S and Sc
Solution 38
Problems.. 39
R s
a b c
R∘ s
A B C
Problems: 42
Let A = {1,2,3,4} B={w, x, y, z} and C={5,6,7}
Also, Let R1 be a relation from A to B
R1 = {(1,x)(2,x)(3,y)(3,z)}
And R2 and R3 be relation from B to C defined by
R2 = {(w,5)(x,6)} R3 = {(w,5)(w,6)}
Find R1∘R2 and R1∘R3
R1 R2
1 W
5
2 X
6
3 Y
7
4 z
R1∘R2 = {(1,6)(2,6)}
R1 R3 43
1 W
5
2 X
6
3 Y
7
4 z
R1∘R3 = {∅}
Composition ….. 44
If R is a relation A , then we can define the composition of R with itself namely R∘R, this is
denoted by R2 , similarly R∘( R∘R) = R3
In general Rn is a relation on A defined recursively by R1 = R, Rn = R∘Rn-1
R R2
1 1
1
R3 = {(1,4)(2,4)(4,4)} 2
2 2
3 3
3
4 4
4
Problems: 45
1. Let A = {1,2,3} B={w,x,y,z} C = {4,5,6}
Define the relations R1⊆ AxB , R2 ⊆BxC and R3 ⊆BxC where,
R1={(1,w) (3,w) (2,x)(1,y)}
R2= {(w,5)(x,6)(y,4)(y,6)}
R3={(w,4)(w,5)(y,5)}
a) Determine R1 ∘ (R2∪R3) and (R1 ∘R2) ∪(R1 ∘R3)
b) Determine R1 ∘(R2∩R3) and (R1 ∘R2) ∩(R1 ∘R3)
Solution: 46
a) R1 ∘ (R2∪R3) = {(1,5)(1,4)(3,5)(3,4)(2,6)(1,6)}
(R1 ∘R2) ∪(R1 ∘R3) = {(1,5)(3,5)(2,6)(1,4)(1,6)(3,4)}
b) R1 ∘(R2∩R3) = {(1,5)(3,5)}
(R1 ∘R2) ∩(R1 ∘R3) = {(1,5)(3,5)(1,4)}
Problems:… 47
0 1 0 0 1 0 0
M(R1) = 0 1 0 0 M(R2) = 0 1 0
0 0 1 1 0 0 0
0 0 0 0 0 0 0
0 1 0 0 1 0
0 1 0 0 1 0
M(R1 ∘R2) = M(R1) . M(R2) = 0 0 0
0 0 0
0 0 0 0 0 0
Problems:… 49
1 0 1 1 0 0
M(R) = 1 1 1 M(S) = 0 1 1
0 1 0 1 0 1
Eg., A = {1,2,3,4,5,6,7,8}
and following are its subsets
A1 = {1,3,5,7}
A2 = {2,4}
A3 = {6,8}
12
6
3
Problems:… 67
4. Draw the Hasse diagram for the divisibility relation on the set A
A = {2,3,6,12,24,36}
Solution 4: 68
Problems:… 69
D36 = {1,2,3,4,6,9,12,18,36}
Problems : .. 70
1 1 1 1 1
0 1 0 1 0
M(R) = 0 0 1 0 1
0 0 0 1 0
0 0 0 0 1
8. Draw the Hasse diagram of the relation R on a set 74
A = {1,2,3,4,5} whose matrix is as given below
1 0 1 1 1
0 1 1 1 1
M(R) = 0 0 1 1 1
0 0 0 1 0
0 0 0 0 1
Solution 8: 75
76
Draw the Hasse Diagram for the relation on set A
[1,2,3,5,6,10,15,30, /]
77
Solution
Total Order 78
Let R be a partial order on a set A , then R is called a Total Order
or linear order or totally ordered set or chain on A if ∀x,y ∈A is
such that either xRy or yRx. In this case the poset(A,R) is called
Totally Ordered Set
R = {(1,1)(1,2)(1,4)(1,8)(2,2)(2,4)(2,8)(4,4)(4,8)(8,8)} is a Total
Order on A
79
But, the same divisibility relation on the set A = {1,2,4,6,8}
R = {(1,1)(1,2)(1,4)(1,6)(1,8)(2,2)(2,4)(2,6)(2,8)(4,4)(4,8)(6,6)(8,8)}
But, neither 4 divides 6 nor 6 divides 8, Therefore its not Total
Order
Vn
83
Example :
Consider a set A = {1,2,3,4,5} and the partial order R on a set A whose
Hasse diagram its as given below. Find the Topological Sorting
Solution : 84
Step 1: Find a vertex V1 in the Hasse diagram that has no outgoing edge.
delete it and remove all the edges connected to it.
V1 = 1
V2 = 2
Step 3: Next vertex is 3 Thus v1 = 1,v2=2,v3=3,v4=5 85
v5=4, Therefore the total
V3 =3 order T on A is given by
4<5<3<2<1
1
Step 4: Next vertex is 5 2
3
5
V4 = 5 and V5=4
4
Compare the Hasse diagram and Topological sorted total order 86
diagram.
We observe that all the ordered pairs belonging to R are in T as
well , furthermore T contains ordered pairs that are not in R.
R = {(1,1)(2,2)(3,3)(4,4)(2,1)(3,2)(3,1)(4,2)(4,1)(4,5)(5,5)}
T = {(4,4)(4,5)(5,3)(4,3)(3,2)(5,2)(5,5)(3,3)(2,2)(1,1)(2,1)(3,1)(4,1)(5,1)(4,2)}
Note that : (4,3)(5,3)(5,2)(5,1) belong to T but not R. Thus we
have obtained the total order T on A such that R⊂T
Problem: 87
The digraph for a relation on set A = {1,2,3,4} is shown in figure
a) Verify that (A,R) is a poset and draw its Hasse diagram.
b) Topological sort (A,R)
c) How many more directed edges are needed in the digraph
of R to extend R to a total order?
Extremal Elements : 88
Maximal and Minimal Elements
1. In a poset , if an elements is not related to any other element
is called the Maximal Element.
2. In a poset, if no element is related to an element, that
element is called the Minimal Element.
89
Greatest Element : (Maximum Element)
An element a∈A is called a Greatest element of A if xRa
∀x∈A
(a,c)(b,c)(c,c)(c,d)(a,d)(c,e)(b,e)
LOWER BOUND (B) = {a, b, c}
Problems : 93
Find the Upper Bound and Lower Bound the Hasse diagrams show below.
1. 2. 3.
B1 = {d,e} B2 = {b.c}
B = {b,f}
UB(B) = { }
LUB(B) = { }
LB(B) = { }
GLB(B)= { }
Lattice: 99
The poset (A,R) is called a Lattice, if for all x,y∈A, the element
LUB{x, y} and GLB{x, y} exists in A .
A lattice is denoted as (L,R).
100
Check whether the poset [D12,/] is Lattice
Solution: 101
After removing all the reflexive, transitive pairs
R = {(1,2)(1,3)(2,4)(2,6)(3,6)(4,12)(6,12)}
1
Coding Theory
2
Introduction:
A
B
6
Symmetric Channel
Suppose ‘r’ differs from ‘c’ in exactly one place (say jth place), then, r1=
c1, r2= c2,r3=c3, rj-1 = cj-1 , rj ≠ cj , rj+1 = cj+1 ……rn = cn
Since the probability that ri = ci is (1-p) for each i, the probability
that r1 = c1 , r2=c2 …… rj-1 = cj-1 is (By the product rule)
▪ (1-p)(1-p)(1-p)(1-p) = (1 - p) j-1 // (j-1) factors
▪ Probability that rj ≠ cj is p
9
Continued….
c=1010110
r=1111011
Comparing c and r, r differs from c in 4 places,
Therefore probability with which r is received is = p4 (1-p)7-4
= (0.05)4 (1-0.05)3
= 0.000053
13
Problems…
3. The word c=1010011 sent through a binary symmetric channel is received as the word
r=T(c) = 1100110. Find the error pattern.
Solution : c=1010011 , r= 1100110
r = c+ e
1=1+e1, Therefore e1=0
1=0+e2, e2=1
0=1+e3, e3=1
0=0+e4, e4=0
1=0+e5, e5=1
1=1+e6, e6=0
0=1+e7, e7=1 Therefore error pattern e = 0110101
14
Problems..
5. The word c=1010110 is sent through a binary symmetric channel. If p=0.02 is the
probability of incorrect receipt of a signal. Find the probability that c is received as
r=1011111, determine error pattern.
The probability that exactly ‘k’ errors are made in the transmission is
nCk pk (1-p)n-k
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner