Sets and Matrices: Understanding Sets, Their Operations, and Matrix Multiplication, Exercises of Logic

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

2021/2022

Uploaded on 09/12/2022

xyzxyz
xyzxyz 🇮🇳

4.8

(24)

309 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 5002: Discrete Structures Fall 2018
Lecture 4: September 27, 2018 1
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.
Sets and Matrices
Readings for this week:
Rosen, Chapter 2.1, 2.2, 2.5, 2.6
Sets, Set Operations, Cardinality of Sets, Matrices
4.1 Overview
1. Sets
2. Set Operations
3. Cardinality of Sets
4. DeMorgan’s Law for Sets
5. Matrices
4.2 Introduction
4.3 Situating Problem Introduction
4.4 Sets
Aset is a group of objects, usually with some relationship or similar property. The ob jects 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:
xA:xis in set A
x6∈ A:xis 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-1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Sets and Matrices: Understanding Sets, Their Operations, and Matrix Multiplication and more Exercises Logic in PDF only on Docsity!

CS 5002: Discrete Structures Fall 2018

Lecture 4: September 27, 2018 1

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.

Sets and Matrices

Readings for this week: Rosen, Chapter 2.1, 2.2, 2.5, 2. Sets, Set Operations, Cardinality of Sets, Matrices

4.1 Overview

  1. Sets
  2. Set Operations
  3. Cardinality of Sets
  4. DeMorgan’s Law for Sets
  5. Matrices

4.2 Introduction

4.3 Situating Problem Introduction

4.4 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 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

  • Example: The set V of vowels in English is V = {a, e, i, o, u}
  • Example: The set O of all odd positive integers less than 10 is: O = {x|x is an odd positive integer less than 10}
  • We use uppercase letters to denote a set.

Special Sets

N, Z, R are reserved to represent special sets:

  • N: the natural numbers { 1 , 2 , ...}
  • Z: the set of integers {..., − 2 , − 1 , 0 , 1 , 2 , ...}
  • Z+: the set of non-negative integers
  • R: the set of real numbers.
  • ∅: the empty set (no elements)

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.

U

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

A

B

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

A ∪ B

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

A ∩ 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

A \ B

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.

AA BB

A ⊕ B

A ⊕ B = (A ∪ B) \ (A ∩ B) (4.7)

Example:

Union of many sets

We use the following notation to denote the union of sets A 1 , A 2 , ..., An:

A 1 A 2

A 3

⋃^3

i=

A

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

A 1 A 2

A 3

⋂^3

i=

A

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:

  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).

4-10 Lecture 4: September 27, 2018

  1. 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
  2. Show that if A and B are sets, then A − (A − B) = A ∩ B.
  3. Show that if A is a subset of B, then the powerset of A is a subset of the power set of B.
  4. Show that symmetric difference follows the associative property using the following Venn diagrams. That is, (A ⊕ B) ⊕ C = A ⊕ (B ⊕ C)

A B

C

A B

C

A B

C

A B

C

Lecture 4: September 27, 2018 4-

4.6 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

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:

  • Add matrices (of the same shape) (Matrix Addition)
  • (Scalar Multiplication)
  • Multiply matrices
  • Transpose
  • Determinant

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

P

P ′

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:

P =

[

x 1 y 1

]

, P ′^ =

[

x′ 1 y′ y

]

, T =

[

tx ty

]

Per our earlier statement that p′^ = p + t:

P ′^ = P + T (4.26)

[

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

P = (1, 2)

P ′^ =?

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.

  • Now, I can make T as arbitrarily long as I need it by just duplicating rows of T.

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:

P ′^ = S · P (4.41)

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:

A · B · C = (A · B) · C = A · (B · C)

A · B 6 = B · A

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:

 

4.7 Summary

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