












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to sets, their operations, and matrix multiplication. It covers topics such as sets and their elements, set equality, cardinality, set operations, and the power set of a set. Additionally, it introduces matrices, their multiplication, and applications to transformations. Useful for students studying discrete mathematics, logic, or linear algebra.
Typology: Exercises
1 / 20
This page cannot be seen from the preview
Don't miss anything!













CS 5002: Discrete Structures Fall 2018
Instructors: Adrienne Slaughter, Tamara Bonaci
Disclaimer: These notes have not been subjected to the usual scrutiny reserved for formal pub- lications. They may be distributed outside this class only with the permission of the Instructor.
Readings for this week: Rosen, Chapter 2.1, 2.2, 2.5, 2. Sets, Set Operations, Cardinality of Sets, Matrices
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 6 ∈ 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.
4-
4-2 Lecture 4: September 27, 2018
Special Sets
N, Z, R are reserved to represent special sets:
Set Equality
Two sets are equal if and only if they contain the same elements.
Venn Diagrams
A Venn diagram is a graphical representation of a set.
e a V
i o
u
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
4-4 Lecture 4: September 27, 2018
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 (a 1 , a 2 ,... , an) is the ordered collection that has a 1 as its first element, a 2 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:
(a 1 , a 2 ,... an) = (b 1 , b 2 ,... 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}
Lecture 4: September 27, 2018 4-
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 A 1 , A 2 ,... An denoted A 1 ×A 2.. .×An is the set of n-tuples (a 1 , a 2 ,... an) where ai ∈ Ai for i = 1, 2 ,... n.
A 1 × A 2... × An = {(a 1 , a 2 ,... an)|ai ∈ Ai for i = 1, 2 ,... n} (4.1)
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} (4.2)
Example: { 1 , 2 , 3 , 4 } ∪ { 7 , 8 , 9 } =? Answer:
Intersection
Let A and B be sets. The intersection of the sets A and B, denoted A ∩ B is the set that contains the elements in both A and B.
A ∩ B = {x|x ∈ A ∧ x ∈ B} (4.3)
Example: { 1 , 2 , 3 , 4 } ∩ {x : x ∈ N } =? Answer:
Lecture 4: September 27, 2018 4-
A \ B = {x : x ∈ A, x 6 ∈ B} (4.6)
Example: { 5 , 6 , 7 , 8 , 9 , 10 } \ { 7 , 8 , 9 } = ? 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.
Example:
Union of many sets
We use the following notation to denote the union of sets A 1 , A 2 , ..., An:
i=
A 1 ∪ A 2 ∪... ∪ An =
⋃^ n
i=
Ai (4.8)
Example: A 1 = { 1 , 2 , 3 , 4 }; A 2 = { 7 , 8 , 9 }, A 3 = { 4 , 5 , 6 , 7 } =? Answer:
Intersections of many sets
We use the following notation to denote the intersection of sets A 1 , A 2 , ..., An:
4-8 Lecture 4: September 27, 2018
i=
A 1 ∩ A 2 ∩... ∩ An =
⋂^ n
i=
Ai (4.9)
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.
Membership for Distributive Property A B C B ∪ C A ∩ (B ∪ C) A ∩ B A ∩ C (A ∩ B) ∪ (A ∩ C) 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0
DeMorgan’s Law
¬(p ∧ q) ≡ ¬p ∨ ¬q (4.10) ¬(p ∨ q) ≡ ¬p ∧ ¬q (4.11)
Set Problems
Example: 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:
Answer:
4-10 Lecture 4: September 27, 2018
Lecture 4: September 27, 2018 4-
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
A matrix is a rectangular array of numbers. A matrix with m rows and n columns is called an m × n matrix. The plural of matrix is matrices. A matrix with the same number of rows as columns is called square. Two 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.
m = 3 (4.13) n = 2 (4.14)
x 0 , 0 x 0 , 1 x 0 , 2 x 1 , 0 x 1 , 1 x 1 , 2 x 2 , 0 x 2 , 1 x 2 , 2
What can we do with a matrix? Regardless of what is represented by the matrix, for different reasons (and different applications) we need to manipulate matrices in different ways. We can:
Lecture 4: September 27, 2018 4-
(We know the final matrix will be 2 x 2, because A has 2 rows, B has 2 columns, and the final matrix of a matrix multiplication has the same number of rows as A, and the same number of cols as B)
4.6.0.3 Zero-One Matrices
Example: Sending email
Boolean operations on zero-one matrices: And,OR, XOR, ...
4.6.1 Situating Example: Graphics
Problem: I have this picture, about as simple as it can be:
2 4 6 8 10
2
4
6
8
10
x
y
I have a point on a screen, and I want to move it to another place. Right now, I’m just working with a point, but you could imagine that it’s a shape of some kind (a sprite!).
How do computers deal with this?
The point is represented by a matrix! To represent a change in the location of the point, we apply what’s called a transformation, or specifically in this case, a translation.
If the point is originally located at (x, y), the new position is (x′, y′), where:
x′^ = x + tx (4.23) y′^ = y + ty (4.24)
4-14 Lecture 4: September 27, 2018
That is: the new x is the original x plus the change in the x-direction, and the new y is the original y plus the change in the y-direction.
Here’s where matrices come in: we model the point as a column vector. The change is what we call the translation vector, also modeled as a column vector. Therefore we get something like this:
x 1 y 1
x′ 1 y′ y
tx ty
Per our earlier statement that p′^ = p + t:
x′ 1 y y′
x 1 y 1
tx ty
x 1 + tx y 1 + ty
=⇒ x′ 1 = x 1 + tx (4.29) y′ 1 = y 1 + ty (4.30)
Putting numbers to this:
I have a point at (1, 2). I need to move it 3cm horizontally, and 4cm vertically. What’s the final position?
2 4 6 8 10
2
4
6
8
10
x
y
4-16 Lecture 4: September 27, 2018
points we have. Or, I could just represent each point as a 1 × 2 matrix, and apply the same transform to each point.
tx ty tx ty tx ty tx ty
Translation is pretty straightforward. Let’s do something a little more complicated.
Scaling
2 4 6 8 10
2
4
6
8
10
x′^ = x · sx, y′^ = y · sy (4.39)
This means that to scale a polygon, we’ll multiple each vertex by the scaling factors sx and sy. sx is the amount to scale in the horizontal direction, and sy is the amount to scale in the vertical direction.
x′ y′
sx 0 0 sy
x y
which, similar to our translation transfromation, can be summarized as:
Where does those 0s in the scaling matrix above come from? Let’s do the math:
Lecture 4: September 27, 2018 4-
sx 0 0 sy
x y
(sx · x + 0 · y) (0 · x + xy · y)
In the above image, we have a polygon with the following coordinates:
We want to scale it by 4 in the x direction, and 6 in the y direction: sx = 4, sy = 6.
If we reconcile these final coordinates with the original figure, you see they correspond.
Composite Transforms: Scale & Translation
2 4 6 8 10
2
4
6
8
10
If we want to scale and translate, you can take the points, and first apply one transform, and then the other. But, that’s not terribly efficient. We can do multiple transforms at once, combining a scale and a translate:
Lecture 4: September 27, 2018 4-
Prove it by transforming the other points in the diagram above.
Matrix multiplication is associative, but not necessarily communtative:
Reflection
2 4 6 8 10
− 10
− 5
5
10
To reflect an object, we transform to produce a mirror image. The picture above shows a reflection around the x-axis, which is the axis of reflection.
The transform for reflecting around the x-axis is below:
x′ y′ 1
x y 1
To flip around the y axis:
Today, we talked about sets and matrices. When it comes to sets, the biggest thing is figuring out the size of a set. We use sets of known sizes to help us determine the sizes of other sets:
4-20 Lecture 4: September 27, 2018
Is that other set bigger than, smaller than, or the same size as this set? Now that we’ve talked about sets, you can likely see their direct application to logic and functions. In fact, set theory arose out of trying to reason about reasoning, that is what logic was.
We also talked about matrices. I used computer graphics to motivate our matrix manipula- tion exercises. In addition to learning about matrices, you learned a little bit about graphics as well!
Readings for NEXT week:
Rosen, Chapter 4.1, 4.2, 4.3, 4. Divisibility and Modular Arithmetic, Integer Representations and Algorithms, Primes and Greatest Common Divisors, Solving Congruences Solving Congruences