Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
file_5.pptx
1. 1
CSE 173: Discrete Mathematics
Dr. Saifuddin Md.Tareeq
Professor, Dept of CSE, DU
smtareeq@cse.du.ac.bd
2. 2
Course Contents
Topic Chapters and
sections
Lecture Sequence
Logic 1.1,1.3-1.6 6
Set, Function 2.1-2.3 1
Algorithm 3.1-3.3 4
Number Theory 4.1-4.3 8
Induction Recursion 5.1-5.2 3
Counting 6.1-6.5 5
Probability 7.1-7.3 9
Relation 9.1,9.3,9.5 2
Graph 10.1-10.6 7
Book Kenneth H. Rosen. Discrete Mathematics and Its
Applications, 7th Edition, McGraw Hill.
3. 3
Course Lecture Sequence
Topic Chapters and
sections
Lecture Sequence
Set, Function 2.1-2.3 1
Relation 9.1,9.3,9.5 2
Induction Recursion 5.1-5.2 3
Algorithm 3.1-3.3 4
Counting 6.1-6.5 5
Logic 1.1,1.3-1.6 6
Graph 10.1-10.6 7
Number Theory 4.1-4.3 8
Probability 7.1-7.3 9
Book Kenneth H. Rosen. Discrete Mathematics and Its
Applications, 7th Edition, McGraw Hill.
4. 4
Course evaluation
Topic Marks Comment
Homework (3/3) 10 Subject to
NSU
evaluation
policy
Quizzes (2/3) 20
Mid term (2) 30
Final 40
5. 5
Discrete mathematics
Discrete mathematics
– study of mathematical structures and objects that are
fundamentally discrete rather than continuous.
• Examples of objects with discrete values are
– integers, graphs, or statements in logic.
• Discrete mathematics and computer science.
– Concepts from discrete mathematics are useful for
describing objects and problems in computer
algorithms and programming languages. These
have applications in cryptography, automated
theorem proving, and software development.
6. Set : Basic Discrete Structure
6
Discrete math =
– study of the discrete structures used to represent discrete objects
Many discrete structures are built usingsets
– Sets = collection of objects
Examples of discrete structures built with the help ofsets:
• Relations
• Graphs
• Combinations
7. Set
7
Definition:
A set is a (unordered) collection ofobjects.
These objects are sometimes called elements or
members of the set.
• Examples:
– Vowels in the English alphabet
V = { a, e, i, o, u }
– First seven prime numbers.
X = { 2, 3, 5, 7, 11, 13, 17 }
8. Representing Set
• A= {1,2,3 …,100}
8
Representing a set by:
1) Listing (enumerating) the members of the set.
2) Definition by property, using the set builder notation
{x| x has property P}.
Example:
•Even integers between 50 and 63.
1) E = {50, 52, 54, 56, 58, 60, 62}
2) E = {x| 50 <= x < 63, x is an even integer}
If enumeration of the members is hard we often use ellipses.
Example: a set of integers between 1 and 100
9. 9
Important set in discrete math
• Natural numbers:
– N = {0,1,2,3, …}
• Integers
– Z = {…, -2,-1,0,1,2, …}
• Positive integers
– Z+ = {1,2, 3.…}
• Rational numbers p is in Z | p is a member ofZ
– Q {p / q | p Z,q Z,q 0}
• Real numbers
– R
10. 10
Equality of Set
Definition: Two sets are equal if and only if they have the
same elements.
Example:
• {1,2,3} = {3,1,2} = {1,2,1,3,2}
Note: Duplicates don't contribute anything new to a set, so
remove them. The order of the elements in a set doesn't
contribute anything new.
Example: Are {1,2,3,4} and {1,2,2,4}equal?
11. 11
Equality of Set
Definition: Two sets are equal if and only if they have the
same elements.
Example:
• {1,2,3} = {3,1,2} = {1,2,1,3,2}
Note: Duplicates don't contribute anything new to a set, so
remove them. The order of the elements in a set doesn't
contribute anything new.
Example: Are {1,2,3,4} and {1,2,2,4}equal?
No!
12. Universal set
12
Special sets:
–The universal set is denoted by U: the set of all objects
under consideration.
– The empty set is denoted as Ø or { }.
U={1,2,3,4,5}
A={1,2,3,4,5}
B={1,2,3,4,5,6}
C={}
13. Venn Diagram
A set can be visualized using VennDiagrams:
– V={ A, B, C }
13
14. Subset
14
P Q PVQ P^Q P→Q
T→F
Q→P
T→F
~PV
Q
~QV
P
F F F F T T T T
F T T F T F T F
T F T F F T F T
T T T T T T T T
Statement: Arifis smart (T/F) How are you?
Proposition: T
Symbolic representation: p = Arif is smart(T/F)
OR
P= 4 is prime
Q= Today is Thursday
If p then q
P only if q
q whenever p
15. A subset
et of B:
Definition: A set A is said to be a subset of B if and only
if every element of A is also an element of B. We use A B
to indicate A is a subset of B.
Alternate way to define A is asubs
U={1,2,3,4,5,6,7,8}
A={}
B={1,2,3}
A B
x(x A) (x B)
15
16. Problem
Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6},
and D = {4, 6, 8}. Determine which of these sets
are subsets of which other of these sets.
16
17. Problem
Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6},
and D = {4, 6, 8}. Determine which of these sets
are subsets of which other of these sets.
B A
17
18. Problem
Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6},
and D = {4, 6, 8}. Determine which of these sets
are subsets of which other of these sets.
C A
18
19. Problem
Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6},
and D = {4, 6, 8}. Determine which of these sets
are subsets of which other of these sets.
C D
19
20. 20
Empty set/subset property
End of proof
• Recall the definition of a subset: all elements of a setA
must be also elements of B: x(x A x B)
• We must show the following implication holds forany
• F -> (T/F) T
x(x x S)
• Since the empty set does not contain any element, is x
always False
• Then the implication is always True. (F → T/F =T)
Theorem : S
•Empty set is a subset of anyset.
Proof:
T → F F
21. Venn diagram of Empty set
Theorem : S
• Empty set is a subset of any set. A={1,2,3}
U
Ø
A
21
22. Subset property
Theorem:
• Any set S is a subset of itself
Proof:
• the definition of a subset says: all elements of a set A must
be also elements of B:
• End of proof
A={1,2,3} B={1,2,3}
Note on equivalence:
• Two sets are equal if each is a subset of the other set.
x(x A x B)
• Applying this to S we get:
• x(x S x S) which is trivially True
S S
T → T T
F → F T
22
23. 23
A proper Subset
Definition:
A set A is said to be a proper subset of B if and only if
. We denote that Ais a proper
A B and A B
subset of B with the notation Α Β .
Example: A={1,2,3} B ={1,2}
Is: Α Β ?
24. 24
A proper Subset
Definition:
A set A is said to be a proper subset of B if and only if
. We denote that Ais a proper
A B and A B
subset of B with the notation Α Β .
Example: A={1,2,3} B ={1,2,3,4,5,6}
Is: Α Β ? Yes.
25. Cardinality
25
Definition: Let S be a set. If there are exactly n distinct
elements in S, where n is a nonnegative integer, we say S is
a finite set and that n is the cardinality of S. The cardinalityof
S is denoted by | S |.
Examples:
• V={1, 2, {3, 4}, 5}
| V | = 4
• A={a,b,c,d,e,f,g}
|A| =7
• | Ø | = 0
26. What is the cardinality of each of these sets?
a){a}
b){{a}}
c) {a, {a}}
d) {a, {a}, {a, {a}}}
26
Problem
27. What is the cardinality of each of these sets?
a){a}
b){{a}}
c) {a, {a}}
d) {a, {a}, {a, {a}}}
a) 1
27
Problem
28. What is the cardinality of each of these sets?
a){a}
b){{a}}
c) {a, {a}}
d) {a, {a}, {a, {a}}}
a) 1
b) 1
28
Problem
29. What is the cardinality of each of these sets?
a){a}
b){{a}}
c) {a, {a}}
d) {a, {a}, {a, {a}}}
a) 1
b) 1
c) 2
29
Problem
30. What is the cardinality of each of these sets?
a){a}
b){{a}}
c) {a, {a}}
d) {a, {a}, {a, {a}}}
a) 1
b) 1
c) 2
d) 3
30
Problem
31. Infinite set
31
Definition: Aset is infinite if it is not finite.
Examples:
• The set of natural numbers is an infinite set.
• N = {1, 2, 3, ... }
• The set of real numbers is an infinite set.
32. 32
Power set
Definition: Given a set S, the power set of S is the set of all
subsets of S. The power set is denoted by P(S).
Example
• What is the power set of Ø ? P(Ø ) = {Ø}
• What is the cardinality of P(Ø) ? | P(Ø) | =1.
Assume B={1,2}
• P(B) = {Ø, {1}, {2}, {1,2}}
•|P(B) | = 4
AssumeA={1,2,3}
• P(A) = {Ø, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3} }
• |P(A) | = 8
If S is a set with |S| = n then | P(S) | = ?
33. 33
Power set
Definition: Given a set S, the power set of S is the set of all
subsets of S. The power set is denoted by P(S).
Example
• What is the power set of Ø ? P(Ø ) ={Ø}
• What is the cardinality of P(Ø) ? | P(Ø) | =1.
Assume {1,2,3}
• P({1,2,3}) = {Ø, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3} }
• |P({1,2,3} | = 8
If S is a set with |S| = n then | P(S) | = ? 2n
34. 34
N-tuple
Example: Coordinates of a point in the 2-D plane (12, 16)
Sets are used to represent unordered collections.
•Ordered-n tuples are used to represent an ordered
collection.
Definition: An ordered n-tuple (x1, x2, ..., xN) is the ordered
collection that has x1 as its first element, x2 as its second
element, ..., and xN as its N-th element, N ˃=2.
(5,10)
(10,5)
35. 35
Cartesian Product
Definition: Let S and T be sets. The Cartesian product of S
and T, denoted by S x T, is the set of all ordered pairs (s,t),
where s ϵS and t ϵT. Hence,
• S x T = { (s,t) | s ϵS ˄tϵT}.T x
S = { (t,s) | t ϵT ˄sϵS}.
Examples:
• S = {1,2} and T = {a,b,c}
• S x T = { (1,a), (1,b), (1,c), (2,a), (2,b), (2,c)}
• T x S = { (a,1), (a, 2), (b,1), (b,2), (c,1), (c,2) }
• Is S x T and T x S equal?
36. Cartesian Product
36
Definition: Let S and T be sets. The Cartesian product of S
and T, denoted by S x T, is the set of all ordered pairs (s,t),
where s ϵS and t ϵT. Hence,
• S x T = { (s,t) | s ϵS ˄tϵT}.
Examples:
• S = {1,2} and T = {a,b,c}
• S x T = { (1,a), (1,b), (1,c), (2,a), (2,b), (2,c)}
• T x S = { (a,1), (a, 2), (b,1), (b,2), (c,1), (c,2) }
• Is S x T ≠ T x S!!!!
37. Cardinality of a Cartesian Product
37
• |S x T| = |S| * |T|.
|A|=2 |P(A)|=4
Example:
• A= {roll, name}
• B ={m1, m2}
• A x B= {(roll, m1),(roll, m2) (name, m1),(name, m2)}
• |A x B| = 4
• |A|=2, |B|=2 → |A| |B|= 4
38. Relation as a subset of a Cartesian
Product
38
A= {roll, name}
• B ={m1, m2}
• A x B= {(roll, m1),(roll, m2) (name, m1),(name, m2)}
R1={(roll,m1)}
Definition:A subset of the Cartesian productA x B is called a relation from
the set A to the set B.
roll m1
123 34
124 56
125 67
39. 39
Set Operation
Definition: Let A and B be sets. The union of A and B, denoted
by A U B, is the set that contains those elements that are in
both AandB.
• Alternate: A U B = { x |x ϵ A V x ϵ B }.
Example:
• A = {1,2,3,6} and B = { 2,4,6,9}
• A U B = ?
40. 40
Set Operation: Union
Definition: Let A and B be sets. The union of A and B, denoted
by A U B, is the set that contains those elements that are in
both AandB.
• Alternate: A U B = { x |x ϵ A V x ϵ B }.
Example:
• A = {1,2,3,6} and B = { 2,4,6,9}
• A U B = { 1,2,3,4,6,9 }
41. Set Operation: Intersection
Definition: Let A and B be sets. The intersection of A and B,
denoted by A ∩ B, is the set that contains those elements that
are in both AandB.
• Alternate: A ∩ B = { x |x ϵ A ˄ x ϵ B }.
Example:
• A = {1,2,3} and B = { 2,4,6,9}
• A∩ B = ? 41
42. Set Operation : Intersection
Definition: Let A and B be sets. The intersection of A and B,
denoted by A ∩ B, is the set that contains those elements that
are in both AandB.
• Alternate: A ∩ B = { x |x ϵ A ˄ x ϵ B }.
Example:
• A = {1,3,7} and B = { 2,4,6,9}
• A∩ B = ? 42
43. 43
Disjoin Set
Definition: Two sets are called disjoint if their intersection is
empty.
• Alternate:A and B are disjoint if and only if A ∩ B = Ø.
Example:
• A={1,2,3,6} B={4,7,8} Are these disjoint?
44. 44
Disjoin Set
Definition: Two sets are called disjoint if their intersection is
empty.
• Alternate:A and B are disjoint if and only if A ∩ B = Ø.
Example:
• A={1,2,3,6} B={4,7,8} Are these disjoint?
• Yes.
• A ∩ B = Ø
45. 45
Cardinality of set union
Cardinality of the set union.
• |AU B| = |A| + |B| - |A ∩ B|
Why this formula? A={1,2,3,4} B={5,6}
A={1,2,3,4} B={3,4, 5,6}
|AU B| =
= |A| + |B| - |A ∩ B|
= 4 + 4 - 2
|AU B| = |A|+|B| - |A ∩ B|
= 4+2-0
46. 46
Cardinality of set union
Cardinality of the set union.
• |AU B| = |A| + |B| - |A ∩ B|
Why this formula? Correct for an over-count.
A = {1,2,3,6} and B = { 2,4,6,9}
• A U B = { 1,2,3,4,6,9 }
|AU B| = |A| + |B| - |A∩ B| = 4+4-2 =6
47. 47
Set Difference
Example: A= {1,2,3,5,7} B ={1,5,6,8}
• A - B = ?
Definition: Let A and B be sets. The difference of A and B,
denoted by A - B, is the set containing those elements that
are in but not in B. The difference of A and B is also called
the complement of B with respect toA.
•Alternate: A B {x | x A x B}
48. 48
Set Difference
Example: A= {1,2,3,5,7} B ={1,5,6,8}
• A - B ={2,3,7}
Definition: Let A and B be sets. The difference of A and B,
denoted by A - B, is the set containing those elements that
are in but not in B. The difference of A and B is also called
the complement of B with respect toA.
•Alternate: A B {x | x A x B}
49. Let A = {a, b, c, d, e} and B = {a, b, c, d, e, f, g, h}.
Find
a) A ∪B.
b) B − A.
49
Problem
50. Let A = {a, b, c, d, e} and B = {a, b, c, d, e, f, g, h}.
Find
a) A ∪B.
b) B − A.
a) A ∪ B = {a, b, c, d, e, f, g, h}
50
Problem
51. Let A = {a, b, c, d, e} and B = {a, b, c, d, e, f, g, h}.
Find
a) A ∪B.
b) B − A.
a) A ∪ B = {a, b, c, d, e, f, g, h} = B
b) B – A = {f, g,h}
A – B = {}
51
Problem
52. 52
Complement of a Set
Definition: Let U be the universal set: the set of all objects
under the consideration.
Definition: The complement of the set A, denoted by Ã, is the
complement of A with respect toU.
• Alternate:Alternate:
Example: U={1,2,3,4,5,6,7,8} A={1,3,5}
• Ã=?
A {x | x A}
53. 53
Complement of a Set
Definition: Let U be the universal set: the set of all objects
under the consideration.
Definition: The complement of the set A, denoted by Ã, is the
complement of A with respect toU.
• Alternate:Alternate:
Example: U={1,2,3,4,5} A={1,3,5}
• Ã={2,4}
A {x | x A}
54. 54
Generalized union
Example:
i
• Let A= {1,2,...,i} i =1,2,...,n
Definition: The union of a collection of sets is the set that
contains those elements that are members of at least oneset
in the collection.
n
Ai {A1 A2 . . . An }
i 1
n
i 1
A i { 1 , 2 , . . . , n }
A1 = {1}
A2= {1,2}
A3= {1,2,3}
…………..
…………..
An ={1,2,3,4,...,n}
55. 55
Generalized intersection
• Let Ai= {1,2,...,i} i =1,2,...,n
Definition: The intersection of a collection of sets is the set
that contains those elements that are members of all setsin
the collection.
n
Ai {A1 A2 . . . An }
i 1
Example:
n
i 1
A i { 1 }
A1 = {1}
A2= {1,2}
A3= {1,2,3}
…………..
…………..
An ={1,2,3,4,...,n}
56. 56
Computer representation of set
How to represent sets in the computer?
• One solution: Data structures like a list
•A better solution: Assign a bit in a bit string to each element
in the universal set and set the bit to 1 if the element is
present otherwise use 0
Example:
All possible elements: U={1 2 3 4 5} = {00000}
• AssumeA={2,5}
– Computer representation: A =01001
• Assume B={1,5}
– Computer representation: B = 10001
57. 57
Computer representation of set
Example:
• A = 01001
• B = 10001
• The union is modeled with a bitwise or
•A U B = 11001
A-B ={01000}
B-A = {10000}
• The intersection is modeled with a bitwise and
• A ∩ B = 00001
• The complement is modeled with a bitwisenegation
• Ã =10110