Module 1_basic Structures
Module 1_basic Structures
BASIC STRUCTURES
1. Sets
2. Set Operations
3. Cardinality of Sets
4. DeMorgan’s Law for Sets
5. Matrices
Introduction to Sets
A set is a group of objects, usually with some relationship or similar property. The objects in the
set are called elements or members of the set. A set contains its elements.
We use the symbol ∈ to indicate that an element is or is not in a set:
x ∈ A: x is in set A
x /∈ A: x is not in set A
A set is described by either listing out the elements of the set in braces, or using set builder
notation.
The rectangle represents U , the . The universal set is the set that contains all objects under
consideration. In this example, U is the set of all letters, and the set V is the set of vowels. Specific
elements are represented by a point (labeled or not).
Subset
The set A is a subset of B if and only if every element of A is also an element of the set B. We use
the notation: A ⊆ B
If A ⊆ B, then ∀x(x ∈ A → x ∈ B)
The null set ∅ is a subset of every set: To see that ∅ ⊆ S, see that every element in
is in
Further, every set is a subset of itself.
Proper Subset
When A is a subset of B and AB, we say that A is a proper subset of B, and write it:
A ⊂B
A = {1, 2, 3}
B = {x : 0 < x ≤ 4}
⇒A ⊂B
A : {a, b, c, d}
B : {a, b, c, d}
A ⊆ B (all elements in A are in B) B ⊆ A (all elements in B are in A)
⇒A = B
Cardinality
Let S be a set. If there are n distinct elements in S (and n is an integer greater than or equal to
0), S is a finite set, and n is the cardinality or S.
The cardinality of S is written |S|
Cardinality: Examples
Example: Let A be the set of odd positive integers less than 10. What’s |A|?
Answer:
Example: Let S be the set of letters in the alphabet. What’s |S|?
Answer:
Example: What’s |∅|?
Answer:
Power Set
Let S be a set. The power set of S is the set of all subsets of the set S. The power set of S is
written P(S).
Let S be the set {0, 1, 2}.
P(S) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}
Note: The empty set and S (the set itself) are members of the power set.
Power Set: Note
Example: What is the power set of the empty set?
Answer:
Example: What is the power set of the set {∅}?
Answer:
n-tuples
Sets are unordered, but we usually care about the ordering of elements.
For example, we may have a bunch of words, but it would be easier to search them if they’re sorted, or
put in a particular order.
Ordered n-tuple
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.
Ordered n-tuples are equal if and only if each corresponding pair of their elements are equal:
(a1, a2, . . . an) = (b1, b2, . . . bn ) if and only if:
ai = bi for i = 1, 2, . . . n.
Ordered Pairs
A 2-tuple is called a ordered pair.
The ordered pair (a, b) equals the ordered pair (c, d) if and only if a = c and b = d. (a, b) only
equals (b, a) if a = b.
Cartesian Products
The Cartesian product of sets A and B (denoted A × B) is the set of all ordered pairs (a, b)
where a ∈ A and b ∈ B.
A × B = {(a, b)|a ∈ A ∧ b ∈ B}
Example: What is the Cartesian product of A = {1, 2} and B = {a, b, c}? Answer: A × B =
Cartesian Products of multiple sets
The Cartesian product of sets A1, A2, . . . An denoted A1 ×A2 . . .×An is the set of n-tuples (a1, a2, .
. . an) where ai ∈ Ai for i = 1, 2, . . . n.
A : {a, b, c}
B : {1, 2, 3}
C : {blue, red, green}
⇒ A × B × C = {(a, 1, blue), (a, 1, red), (a, 1, green), (a, 2, blue) . . .}
The Cartesian product A × B × C consists of all ordered triples (a, b, c), where a ∈ A, b ∈
B, c ∈ C.
Union
Let A and B be sets. The union of the sets A and B, denoted A ∪ B is the set that contains
the elements in either A or in B, or in both.
∪
A ∪ B = {x|x ∈ A ∨ x ∈ B}
Intersection
∩ that contains
Let A and B be sets. The intersection of the sets A and B, denoted AB is the set
the elements in both A and B.
∩
A ∩ B = {x|x ∈ A ∧ x ∈ B}
Example: {1, 2, 3, 4} ∩ {x : x ∈ N } = ?
Answer:
Disjoint
Let A and B be sets. The two sets are disjoint if their intersection is the empty set.
Cardinality of sets
Inclusion-Exclusion Principle
We frequently want too know how many items are in groups.
Note that A| +
| B| counts
| all the elements in only A once, and all the elements in only B once.
BUT, it counts the elements in A and B TWICE.
Therefore, we need to subtract the number of elements that are in A and B
|A ∪ B| = |A| + |B| − |A ∩ B|
Complement of sets
The complement of a set A, denoted Ac is the set of elements that belong to U but which do not
belong to A: t
Ac
Ac = {x : x ∈ U, x /∈ A}
U : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
A : {2, 5, 8}
Differencsets
A\ B = {x : x ∈ A, x /∈ B}
Answer:
Symmetric Difference
The symmetric difference of sets A and B, denoted A ⊕ B is the set of elements that
belong to A or B but not both.
A ⊕ B = (A ∪ B) \ (A ∩ B)
Example:
Answer:
A1 ∩ A2
Membership table
Just like we use truth tables for determining equality of logic statements, we can use mem- bership
tables to prove equality of sets.
1 is used to indicate that an element belongs to a set; 0 is used to indicate that an element is not in
that set.
DeMorgan’s Law
Set Problems
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬qExample: Let A be the set of students who live within one mile of school, and B the set of
students who walks to campus from home. Describe each of these sets of students:
1. A ∩B
2. A ∪B
3. A −B
4. B −A
Answer:
1. The students who live within a mile of school and walk to campus (but not take the bus).
2. The students who live within a mile of school (and walk or drive), and the students who walk to
school (no matter how far it is).
3. The students who live within a mile of school but DON’T walk to school.
4. The students who walk to school but live further than a mile away.
Set Identities
Set Identities
Identity Name
A ∪∅= A Identity
A ∩U = A laws
A ∪U = U Dominatio
A∩∅= ∅ n laws
A ∪A = A Idempotent
A ∩A = A laws
(A) = A Compleme
ntation law
A ∪B = B ∪A Commutati
A ∩B = B ∩A ve laws
A ∪ (B ∪ C) = (A ∪ Associativ
B) ∪ C e laws
A ∩ (B ∩ C) = (A ∩
B) ∩ C
A ∩ (B ∪ C) = (A ∩ Distributiv
B) ∪ (A ∩ C) e laws
A ∪ (B ∩ C) = (A ∪
B) ∩ (A ∪ C)
A ∪B = A ∩B De
A ∩B = A ∪B Morgan’s
laws
2. Let E denote the set of even integers and O the set of odd integers. Z is the set of all integers.
Determine these sets:
(a) E ∪ O
(b) E ∩ O
(c) Z − E
(d) Z − O
3. Show that if A and B are sets, then A − (A − B) = A ∩ B.
4. Show that if A is a subset of B, then the powerset of A is a subset of the power set of B.Show that
symmetric difference follows the associative property using the following Venndiagrams. That is, (A
⊕ B) ⊕ C = A ⊕ (B ⊕ C)
Matrices
Matrices are used throughout discrete mathematics to express relationships between elements in sets. In
subsequent chapters we will use matrices in a wide variety of models. For instance, matrices will be used
in models of communications networks and transportation systems. Many algorithms will be developed
that use these matrix models. This section reviews matrix arithmetic that will be used in these
algorithms.
Example: Social network
Here’s something you might be familiar with: We start with a shape on the screen, and it transforms over
time. First it moves from one place to another, then it gets
Definition 1: Matrix
matrices are equal if they have the same number of rows and the same
number of columns and the corresponding entries in every position are
equal.