0% found this document useful (0 votes)
28 views24 pages

Sets in Discrete Structures

The document provides a comprehensive overview of set theory, including definitions, properties, and operations such as union, intersection, and difference. It also discusses important sets, set builder notation, power sets, and applications of set theory in mathematics and computer science. Additionally, it highlights the significance of Venn diagrams and the relevance of set theory in areas like database management, programming, algorithms, artificial intelligence, and networking.

Uploaded by

onibarnash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views24 pages

Sets in Discrete Structures

The document provides a comprehensive overview of set theory, including definitions, properties, and operations such as union, intersection, and difference. It also discusses important sets, set builder notation, power sets, and applications of set theory in mathematics and computer science. Additionally, it highlights the significance of Venn diagrams and the relevance of set theory in areas like database management, programming, algorithms, artificial intelligence, and networking.

Uploaded by

onibarnash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

PREPARED BY: MRSALCEDO

Roster Form
Set of positive even numbers less than 10, A = {2, 4, 6, 8}
Set of vowels in English alphabet, B = {a, e, i, o, u}

C = {{1, 2}, {{3}, 2}, {2}, {1}} C is a set that contains sets

Elements of C are:
{1, 2}
{{3}, 2}
{2}
{1}
SET BUILDER NOTATION
The set is defined by specifying a property that elements of
the set have in common
the set is described as S = { x | p(x) }
Examples
A = {x | 1≤x<10 and (x%2)=0} A = {2, 4, 6, 8}
B = {x | x is a vowel in the English alphabet} B = {a, e, i, o, u}
C = {x | x is a prime number} C = {2, 3, 5, 7, 11, 13,…}
D = {5x | x is an integer} D = {…, -10, -5, 0, 5, 10,…}
VENN DIAGRAM
Visual representation of relations between sets
A schematic diagram that shows possible logical relations between different
mathematical sets

a u U – Universe of discourse
i
A – name of the set
A e
c Lower case letters – elements in the set
o
x
U m
Important Sets

N − the set of all natural numbers = {1, 2, 3, 4, ...}


Z − the set of all integers = {…, −3, −2, −1, 0, 1, 2, 3, …}
Z+ − the set of all positive integers
Z- − the set of all negative integers
Q − the set of all rational numbers
R − the set of all real numbers
W − the set of all whole numbers
Properties of Sets
Cardinality
The number of unique elements of the set Equal Set
Denoted by | S | If two sets contain the same elements they are said to be equal
Cardinal Number Two sets are equal if and only if they have the same elements
A = {2, 4, 6, 8} ꓯx [x ∈ A ↔ x ∈ B]
|A| = 4 A = {1, 2, 3} B = {3, 2, 1}
B = {x | x is a vowel in the English alphabet} D = {2, 4, 6} E = {2, 2, 4, 6}
|B| = 5 Equivalent Set
Z = {…, −3, −2, −1, 0, 1, 2, 3, …} If the cardinalities of two sets are same, they are called
|Z| = ∞ equivalent sets
A = {1, 2, 3} B = {3, 2, 1}
Finite Set D = {2, 4, 6} E = {2, 2, 4, 6}
F = {2, 3, 4, 6}
A set which contains a definite number of elements A=B
A = {x | x ∈ Z+ and 10 < x < 100} D=E
|A| = |B| = |D| = |E|
Infinite Set |D| ≠ |F

A set which contains an infinite number of elements


B = {x | x ∈ Z+ and x > 10}
Subset
A set A is a subset of a set B if and only if everything in A is also in B
“A is a subset of B” is denoted by A ⊆ B
ꓯx [x ∈ A → x ∈ B]
A = {1, 2} B = {1, 2, 3}
D = {a, b, c} E = {a, b, c}
Proper Subset
A set A is a proper subset of a set B if A is a subset of B but not an equal set
A ⊆ B and |A| < |B|
“A is a proper subset of B” is denoted by A ⊂ B Universal Set
A = {1, 2} B = {1, 2, 3} A set which has all the elements in the universe of discourse
D = {a, b, c} E = {a, b, c} Denoted by U, where ꓯx [x ∈ U]
A⊆BB⊄A Let’s define U as the set of all animals on earth.
D⊆EE⊆D All mammals are a subset of U
A⊂B All fishes are a subset of U
D ⊄ E but D ⊆ E Empty Set / Null Set
A set with no elements
Denoted by { } or ∅, where ꓯx [x ∉ ∅]
An empty set is a finite set | ∅ | = 0
S = {x | x ∈ Z and 1 < x < 2}
|S| = 0
=∅
M⊆UM⊂U
F⊆UF⊂U
“Empty Sets” vs “A Set of Empty Set”

∅ and {∅} are different sets


∅ is an empty set Cardinality is 0
{∅} is a set with an element ∅ Cardinality is 1

Theorems on Universal and Empty Sets

Let A be an arbitrary set. It can be any set, even an empty or universal set
Theorem 1: A ⊆ U All sets belongs to a universal set
Theorem 2: ∅ ⊆ A An empty set is a subset of all sets
Theorem 3: A ⊆ A All sets are a subset of itself
Power Sets
Power set creates a new set whose elements are all subsets of a set
“Power set of set S” is denoted by P(S)
Cardinality of a power set of set S is 2n, where n = |S|
A = {1, 2}
Subsets of A are: ∅ {1} {2} {1, 2}
P(A) = {∅, {1}, {2}, {1, 2}}
|P(A)| = 22 = 4 Power set of an empty set Power set of a set of empty set
P(∅) = {∅} P({∅}) = {∅, {∅}}
A set will not be a subset of its own power set |P(∅)| = 20 = 1 |P({∅})| = 21 = 2
A ⊄ P(A)

A = {1, 2} B = {a}
P(A) = {∅, {1}, {2}, {1, 2}} P(B) = {∅, {a}}
1 ∉ P(A) and 2 ∉ P(A) |P(B)| = 21 = 2
B = {{1}, {1, 2}, ∅}
P(B) = {∅, {{1}}, {{1, 2}}, {∅}, {{1}, {1, 2}}, {{1}, ∅}, {{1, 2}, ∅}, {{1}, {1, 2}, ∅}}
|P(B)| = 23 = 8
EXERCISE: Use set builder notation to give the
description of each set
1. [0,3,6,9,12]
2. [m,n,o,p]
3.
Given: a=(2,4,6) b=(2,6) c=(4,6) d=(4,6,8)
Which of these sets are subsets of which other of these sets
4. What is the power set of (0,1,2)?
5. What is the power set of empty set?
Set Operations
1. Union A B
2. Intersection
3. Difference
4. Complement
5. Cartesian Product
4
1 2

Union 3
The union of set A and B is the set of elements which are in A, B and both A and B
Union is denoted by ∪
A ∪ B = { x | x ∈ A or x ∈ B}
A = {1, 2, 3} C
B = {2, 4} D
A ∪ B = {1, 2, 3, 4}
C = {1, {2}, 3}
D = {{3}, 4}
C ∪ D = {1, {2}, 3, {3}, 4}
Set Operations
1. Union A B
2. Intersection
3. Difference
4. Complement
5. Cartesian Product
4
1 2

Intersection
The intersection of set A and B is the set of elements which are in both A and B 6
Intersection is denoted by ∩ A ∩ B={ x | x ∈ A and x ∈ B} 5
C
A = {1, 2, 3} D
B = {2, 4}
A ∩ B = {2}

C = {1, 2, 3} Disjoint: Two sets are disjoint if their intersection is empty


D = {4, 5, 6}
C∩D=∅
Set Operations
1. Union A B
2. Intersection
3. Difference
4. Complement
5. Cartesian Product
1 4
2

Difference 3
The set difference of A and B is the set of
elements which are only in A but not in B
Denoted by A – B
A − B = { x | x ∈ A and x ∉ B}
A = {1, 2, 3}
B = {2, 4}
A – B = {1, 3}
B – A = {4}
A–B≠B–A
Set Operations U
2
1. Union A
2. Intersection
3. Difference 5 √81
4. Complement B
5. Cartesian Product
1
7
-12
6
3
Complement
The complement of a set A is the set of elements which are not in set A 4
Denoted by Ā or A’
Ā = ꓯx { x | x ∉ A }
Ā = (U − A) U={-12,1,2,3,4,5,6,7,√81}
U=Z A={1,3,5,7}
A = Z- B={-12,√81,}
Ā=W Ā={-12,2,4,6, √81}
For complement of a set, it's important to know which U the set belongs to Ḃ={1,2,3,4,5,6,7}
B = { x | x is an odd number}
B‘ = {x | x is not an odd number}
ORDERED PAIRS AND ORDERED N-TUPLES

Ordered pair is a pair of objects/elements with a particular order


given 2 objects, x and y, we can form an ordered pair (x, y) or (y, x)
We expand this concept into ordered n-tuples
ordered n-tuple is a set of n objects/elements with a particular order
Given n objects, x1, x2, …, xn, we can form an ordered n-tuple (x1, x2, …, xn)
Given 3 objects, 1, 2, and 3, we can form ordered 3-tuples
(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)
We can also relate the number of tuples n to n!; 3-tuples mean 3! = 3.2.1 = 6
2-tuples mean 2! = 2.1 = 2
4-tuples mean 4! = 4.3.2.1 = 24
“Tuples” is the number of characters/objects/variable in any function

Set theory has a wide range of applications in other disciplines of mathematics, owing to its
extremely generic and abstract character. Analysis is an area of mathematics in which differential and
integral calculus are essential components. Set theory is used to get a grasp of limit points and what is
meant by the continuity of a function in this branch of mathematics. Using an algebraic approach to set
operations leads to boolean algebra, where the operations of intersection, union, and difference are
viewed as logical operations that are equivalent to the logical operators and, or, not.
SET THEORY APPLICATION IN COMPUTERS
1. Database Management
Set theory is foundational for understanding databases. Data in a database can be thought of as a
collection of sets. For instance, a table in a relational database is essentially a set of tuples. The operations we
perform on these sets are similar to standard set operations, such as union, intersection, and difference.
2. Programming Languages
Many programming languages include built-in support for sets. For instance, Python has a set data structure that
allows you to perform set operations easily.
# Define two sets
set_a = {1, 2, 3, 4}
set_b = {3, 4, 5, 6}
# Union of sets
union_set = set_a | set_b
# Intersection of sets
intersection_set = set_a & set_b
# Difference of sets
difference_set = set_a - set_b
print("Union:", union_set) print("Intersection:",
intersection_set) print("Difference:",
difference_set)
SET THEORY APPLICATION IN COMPUTERS
3. Algorithms
Set theory is also essential in algorithm design and # Finding common elements in two lists
analysis. Many algorithms can be described in terms of set list_a = [1, 2, 3, 4]
operations. For example, searching and sorting algorithms can list_b = [3, 4, 5, 6]
common_elements = set(list_a) & set(list_b)
be conceptualized as operations on sets of data. print("Common Elements:", common_elements)

SET A SET B
4. Venn Diagrams in Set Theory
Venn diagrams visually represent set operations. They are
useful for illustrating relationships between different sets.
Below is a simple Venn diagram that shows the union and
intersection of two sets.

UNION INTERSECTION
In this diagram, Set A and Set B represent two different
datasets, and the arrows indicate the operations performed
between them.
SET THEORY APPLICATION IN COMPUTERS
5. Applications in Artificial Intelligence
# Facts as sets
Set theory also finds applications in artificial intelligence, animals = {'cat', 'dog', 'fish’}
particularly in knowledge representation and reasoning. The pets = {'dog', 'cat’}
relationships between different concepts can be modeled using # Check if pets are part of animals is_pet =
pets.issubset(animals)
sets and set operations. In AI, we often represent knowledge as print("Are all pets animals?", is_pet)
sets of facts.

6. Set Theory in Networking


Set theory concepts are frequently applied in networking,
particularly in the analysis of data packets and network traffic.
# Define allowed and blocked IP addresses
Understanding how data is grouped and classified can help allowed_ips = {'192.168.1.1', '192.168.1.2', '172.16.0.1'}
optimize network performance. blocked_ips = {'192.168.1.3', '172.16.0.2’}
# All IPs in the network
all_ips = allowed_ips | blocked_ips
Example: Packet Filtering # Check for allowed and blocked
print("Allowed IPs:", allowed_ips)
Network administrators often use set operations to filter packets print("Blocked IPs:", blocked_ips)
based on predefined criteria. Below is an example using Python
to demonstrate how sets can help identify allowed and blocked
packets:
SET THEORY APPLICATION IN COMPUTERS
# Example transactions
transactions = [
7. Set Theory in Data Mining {'milk', 'bread’},
{'bread', 'diapers’},
In data mining, set theory provides a foundation for understanding {'milk', 'diapers’},
relationships among data points. Techniques such as clustering and association {'bread', 'milk', 'diapers’},
{'milk', 'diapers'} ]
rules rely heavily on sets. # Create a set of all items
items = set()
for transaction
in transactions: items |= transaction
8. Advanced Topics: Fuzzy Sets
Fuzzy set theory extends traditional set theory to handle uncertainty and print("All unique items:", items)
partial truth. In fuzzy sets, an element's membership is expressed in degrees
ranging from 0 to 1.
TALL
Example: Fuzzy Membership
For instance, consider the fuzzy set of "tall people." Unlike standard sets, MEMBERSHIP MEMBERSHIP
MEMBERSHIP
where someone is either in or out, fuzzy sets allow for varying degrees of
membership.

JAKE:06 JOHN: 08 MARK:02


SET THEORY APPLICATION IN COMPUTERS

9. Set Theory in Machine Learning


Set theory also plays a significant role in machine learning,
where data is often grouped into sets for analysis.
Understanding the relationships between these sets can improve
model accuracy.

# Example of splitting data


data = {'feature1', 'feature2', 'feature3',
'feature4’}
training_set = {'feature1', 'feature2’}
testing_set = data - training_set

print("Testing set features:", testing_set)


Cartesian Product
The set of all ordered pairs (a, b), where a is an element of A and b is an element of B
The cartesian product of A and B is denoted by A x B
A = {1, 2, 3}
B = {a, b}
A x B = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}
B x A = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}
AxB≠BxA
Ax∅=∅
B2 = B x B
= {(a, a), (a, b), (b, a), (b, b)}

EXERCISE:

Find A2
A2 = ________________
Cartesian Product

Let A1, A2, …, An be n sets


The set of all ordered n-tuples (x1, x2, …, xn), where xi ϵ Aifor all i, 1 ≤ i ≤ n
The cartesian product of A1, A2, …, Anis denoted by A1x A2x … x An
A = {1, 2}
B = {a, b}
C = {green, blue}
A x B x C = {(1, a, green), (1, a, blue), (1, b, green), (1, b, blue),
(2, a, green), (2, a, blue), (2, b, green), (2, b, blue),}

B x A x C = {(a, 1, green), (a, 1, blue), (a, 2, green), (a, 2, blue),


(b, 1, green), (b, 1, blue), (b, 2, green), (b, 2, blue)}

EXERCISE:
C x A x B = ___________ C x B x A = _________ A x B x C = _____________
A x C x B = ___________ B x C x A = _________ (A x B) x C = ____________
CARTESIAN PRODUCT APPLICATION

Cartesian products are used to represent pixels in digital


images. Each pixel's position can be defined by an ordered
pair of coordinates, allowing for precise manipulation and
rendering of images on screens. Similarly, in 3D modeling,
coordinates are used to define the position and orientation
of objects in three-dimensional space, enabling the creation
of accurate and detailed models for engineering and
animation.
Cartesian Product
The cardinality of a cartesian product
Given |A| = m and |B| = n, |AxB| = mn
A = {1, 2, 3} |A| = 3
B = {a, b} |B| = 2
A x B = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)} |AxB| = 6
B x A = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)} |BxA| = 6
|AxB| and |BxA| are equivalent but not equal

Given sets, A1, A2,… , An


|A1x A2 x … x An| = n1x n2x … x nn
|A1| = n1
|A2| = n2

|An| = nn

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy