You are on page 1of 29

Discrete Structure

Set Theory
Mathematics
• Already been introduced to the
concepts of sets, sequences,
and functions, and we’ve used
them informally several times
Set
• What is a set? Well, simply put, it's a collection
• First we specify a common property among "things" (we define
this word later) and then we gather up all the "things" that have
this common property.
Set of clothes
For example, the items you wear: hat, shirt, jacket, pants, and so on.
You could come up with at least a hundred. This is known as a set.

Georg Cantor (1845-1918), a German mathema-


tician, was the first to propose the concept of 'Set
Theory. ' While researching "Problems on
Trigonometric Series," he came across sets,
which have since become one of mathematics'
most fundamental ideas.
Set

• A set is an unordered collection of objects, called elements or


members of the set.
• Set, in mathematics and logic, any collection of objects (elements),
which may be mathematical (e.g., numbers and functions) or not.
• A set is a gathering together into a whole of definite, distinct objects
of our perception or our thought—which are called elements of the
set (George Cantor, 1895).
Set
Set equality
Two sets are equal if and only if they contain exactly the same ele-
ments. denoted by A = B. Mathematically: A = B iff ∀x (x ∈ A ↔ x ∈ B)
Example: Are the following sets equal? Why &why not?
1. {1, 2, 3, 4} and {1, 2, 3, 4} True
2. {1, 2, 3, 4} and {4, 1, 3, 2} True
3. {a, b, c, d, e} and {a, a, c, b, e, d} True Singleton Set
4. {a, e, i, o} and {a, e, i, o, u} False Singleton set: a set with one element
are Ø and {Ø} equal?
Subset Ф:an empty set. Think of this as an empty folder
Let A and B be sets. A is a subset of B if and only {ф}: a set with one element.
if every element of
A is also an element of B, denoted by A ⊆ B.
A ⊆B if and only if ∀x(x ∈ A → x ∈ B)
Subset equality: Empty set
A ⊆ B = ∀x(x ∈ A → x ∈ B) B→ x ∈ A) A set that has no elements called empty set,
then A = B, ∀x(x ∈ A ↔ x ∈ B) or null set.
U Denoted by {} , Ø. The set of all Positive inte-
B
gers that are less than and equal to 0.
A
S = {x | x ∈ Z+ and x ≤ 0 } = {} = Ø
Set
Proper subset
Let A and B be sets.
A is a subset of a set B but that A ≠ B, we write
A ⊂ B and say that A is a proper subset of B

For A ⊂ B to be true, it must be the case that A ⊆ B and there must exist an element x of B that
is not an element of A, i.e.
∀x(x ∈ A → x ∈ B) ∧ ∃x(x ∈ B ∧ x ∉ A)

Cardinality of Set
Let S be a set. If there are exactly n distinct elements in S where n is a nonnegative integer,
then S is a finite set.
n is the cardinality of S, denoted by |S|.
A set is said to be infinite if it is not finite. Example:
1. A be the set of odd positive integers less than 10, |A| =5
2. S be the set of letters in the English alphabet, |S| =?

Power set
Let S be a set.
The power set of S is the set of all subsets of S, denoted by P(S). If a set has n elements, then its power
set has 2n elements
P({a ,b }) = {Ø,{a},{b},{a ,b }}
Set

Ordered n-tuples
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.
• a1 as its first element
• a2 as its second element
• ...
• an as its nth element
•Example: (a ,b ) is an ordered 2-tuple (ordered pair).

Ordered n-tuple
Let A=(a1, a2, …, an) and B=(b1, b2, …, bn) be ordered
n-tuples.
A and B are equal if and only if each corresponding pair of their
elements are equal, denoted by A=B. A=B if and only ai = bi
and for i = {1,2,…,n}
Example: Assume c ≠ b.
Are ordered 3-tuples (a ,b ,c ) and (a ,c ,b ) equal?
Set
• Cartesian product
•Let A and B be sets.
• The Cartesian product of A and B, denoted by A × B,
• is the set of all ordered pairs (a, b), where a ∈ A and
• b ∈ B. Hence,
A × B = {(a, b) | a ∈ A ∧ b ∈ B}.
Example:
•Cartesian product of A = {1, 2} and B = {a, b, c}? A × B = {(1, a), (1, b), (1, c), (2, a), (2,
b), (2, c)}
•The Cartesian product of sets A1, A2, …, An, denoted by A1 × A2 × … × An is the set of ordered n-tuples (a1,
a2, …, an), where ai belongs to Ai for i = 1,2, …, n.

•In other words,


•A1 × A2 × … × An = {(a1, a2, . . . , an) | ai ∈ Ai for i = 1, 2, . . . , n}.
Relations

Let A and B be sets.


A subset R of the Cartesian product A x B is called a relation from the set A to the set B.
The elements of R are ordered pairs, where the first element belongs to A and the second to B
Representation
1. Elements: The objects or values that belong to a set are called its elements.
Elements are unique and appear only once in a set.
2. Notation: Sets are usually denoted using curly braces {}. For example, a set
containing the elements 1, 2, and 3 is written as {1, 2, 3}.
3. Set Membership: A symbol (∈) is used to indicate whether an element belongs to
a set. For example, if "x" is an element of the set A, we write x ∈ A.

• a is an element of the set A, denoted by a ∈ A.

• a is not an element of the set A, denoted by a ∉ A.


Representation

Representation

• Descriptive Form Set of Prime Number

• Set Builder Form {n € N | n is a prime and n = 4k+1 for integer k

• Roster Form { 5; 13; 17; 29; 37; 41; 53; 61; 73; : : : :}
• Venn Diagram
Representation
 Statement (or Descriptive) Form
 Set of apple, orange, pear, and banana  Roster (or List) Form
 N: Set of all natural numbers
 Z: Set of all integers
 Q: Set of all rational numbers
 R: Set of all real numbers
 Z+: Set of all positive integers

 Set-builder notation
Representation

 Statement Form  Roster Form


 Boolean Set of apple, orange, pear, and
banana  Potential
 N: Boolean set of all natural numbers
 Z: Boolean set of all integers
 Q: Boolean set of all rational numbers  Actual
 R: Boolean set of all real numbers
 Z+: Boolean set of all positive integers

 Set-builder notation

 (general form)
 (potential)
(Actual)
Representation
 Statement Form
 Triadic set of apple, orange, pear, and banana
 N: Triadic set of all natural numbers
 Roster Form
 Z: Triadic set of all integers

 Q: Triadic set of all rational numbers


 Potential
 R: Triadic set of all real numbers
 Z+: Triadic set of all positive integers
 Non-actualized potential
 Set-builder notation

or
 (general form)
 Actualized
 (potential)

(non-actualized
potential) or

(Actual)
Representation
• Venn Diagram
Sets can be represented graphically using Venn diagram.
There are 100 students in a year group.
38 of them do archery. This information
can be shown on a Venn diagram.

• Universal set U contains all objects under consideration say English alphabets
is represented by a rectangle
• Other geometric figures are used to represent sets. Say set of vowels
• Points are used to represent particular elements of sets. i.e. a, e, i, o, u
Show set A={a,b,c} using Venn diagram
Operation
• Two sets can be combined in many different ways.
• Set operations can be used to combine sets.

Union
Let A and B be sets.
The union of A and B, denoted by A ∪ B, is
the set containing those elements that are either in A or
in B, or in both. A ∪ B = {x | x ∈ A ∨ x ∈ B}.
Shaded area represents A U B.

Intersection
Let A and B be sets.
The intersection of A and B, denoted by
A ∩ B, is the set containing those elements in both A and B.
A ∩ B = {x | x ∈ A ∧ x ∈ B}

Shaded area represents A ∩ B.


Difference
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 A but not in
B. (also called complement of B with respect to A)
A − B = {x | x ∈ A ∧ x ∉ B}

• A – B is shaded.
Operation
Complement
Let U be the universal set and A be a set.
The complement A, denoted by Ā, is the com-
plement of A with respect to U (which is U-A).
Ā = {x ∈ U | x ∉ A}.

Disjoint • Ā is shaded.
Two sets are called disjoint if their intersection is the empty set.
Example;
Let A = {1, 3, 5, 7, 9} and B = {2, 4, 6, 8, 10}.
A ∩ B = ∅, thus
A and B are disjoint
Generalized Union Generalized Intersection
The union of a collection of sets is the set that The intersection of a collection of sets is the
contains those elements that are members of at set that contains those elements that are
least one set in the collection. members of all the sets in the collection.
We use the notation We use the notation
A1 ∪ A2 ∪ · · · ∪ An =
to denote the union of the sets A1, A2, . . . , An A1 ∩ A2 ∩ · · · ∩ An =
Set Identities
• Much like the logical equivalences there are set identities which arise
frequently and can be proved using the definitions.
Membership Tables

• Set identities can also be proved using membership tables


• Use a membership table to show that
• A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).

A B AUB A∩B A-B A


1 1 1 1 0 0
1 0 1 0 1 0
0 1 1 0 0 1
0 0 0 0 0 1
Membership Table
Application

Set data structures are commonly used in a variety of computer science applications, including
• algorithms,
• data analysis
• databases.
The main advantage of using a set data structure is that it allows you to perform operations on a
collection of elements in an efficient and organized way.

In data structures, sets are often used to store and organize information. For example, sets can
be used to implement data structures such as hash tables and bloom filters. These data structures
rely on set operations such as union, intersection, and difference to efficiently store and retrieve
data.
In graph theory, sets are used to represent the vertices and edges of a graph. The set notation is
used to represent the relationships between the vertices and edges, and set operations are used
to perform operations such as finding the shortest path between two nodes.

In algorithms, set notation is also used to represent and manipulate sets of data.

In Database Set-based operations are used to manipulate and query databases, making it easy to
retrieve and analyze large amounts of data.
Application

• Set theory also plays an important role in computer program-


ming. Sets and Boolean logic are used in many programming
languages. For example, there are different types of variables in
many programming languages. These types might include text,
numbers, or booleans.
Image comparing a typical single-variable search ver-
sus a boolean search
Programming
 Programming Format
 Primitive datatype (set)
 User-define datatype (sequence)

In Java,
Set<Obj> set = new HashSet<Obj>
();
hash_Set.add(“apple");
hash_Set.add(“orange");
hash_Set.add(“pear");
hash_Set.add(“banana");
In C++,  In Javascript,
Set is a data structure
 Const A = new Set([ “apple“,“orange“, “pear“,
“banana“]);
 In Python,
 thisset = {"apple", “orange", “pear", “banana"}
 In Golang,
 Set is a data structure implemented using maps
Paradox
A seemingly absurd or self-contradictory statement that is or may be true
• 2=4 This sentence is false

A dichotomy is a partition of a whole (or


a set) into two parts (subsets).

Zeno’s Paradox
“That which is in locomotion must arrive
at the half-way stage before it arrives at
the goal.”

Hilbert’s Infinite Hotel


The manager tells the guest to go to the first room and
ask the person there to move to the next room, and to ask
the occupant in the next room to do the same. Thus, they
say, the new guest will get accommodation, and since the
hotel is infinite, the chain will go on forever
Paradox

• Banach-Tarski Paradox

• Scenario: Imagine two friends hiking in the woods. They grow


hungry and decide to split an apple, but half an apple feels meager.
Then one of them remembers one of the strangest ideas she’s ever en-
countered. It’s a mathematical theorem involving infinity that makes it
possible, at least in principle, to turn one apple into two.

• Paradox: According to the fundamental rules of mathematics, it’s pos-


sible to split a solid three-dimensional ball into pieces that recombine
to form two identical copies of the original.

• Two apples out of one.


Relations
• How many relations are there between the set A and B?

A={1,2,3}={1,2,3} and B={a,b}


.
mn
Based on the text, the number of relations between sets can be calculated using 2
2where m and n represent the number of members in each set.
6
Given this, I calculated this number to be 2 =64

A relation from a set A to a set B is a subset of A×B. Hence, a relation R consists


of ordered pairs (a,b), where a∈A ∈ and b∈B ∈ . If (a,b)∈R, we say that is
related to , and we also write aRb.
2
Define R={(a,b) ∈ R ∣ a < b} hence (a, b)∈R if and only if a<b. Obviously, saying
“a<b” is much clearer than “a R b.” If a and b are not related, we could say (a, b)∉R(,
or a ≮ b.
Bits
Fuzzy

• Fuzzy sets can be considered as an


extension and gross oversimplification of
classical sets.
• A fuzzy set assigns a degree of member-
ship, typically a real number from the in-
terval ([0,1]), to elements of a universe.
Fuzzy
Fuzzy sets are used in artificial intelligence. Each element in the universal set
U has a degree of membership, which is a real number between 0 and 1
(including 0 and 1),
In a fuzzy set S. The fuzzy set S is denoted by listing the elements with their
degrees of membership (elements with 0 degree of membership are not
listed).
For instance,
we write {0.6 Alice, 0.9 Brian, 0.4 Fred, 0.1 Oscar, 0.5 Rita}
For the set F (of famous people) to indicate that
Alice has a 0.6 degree of membership in F,
Brian has a 0.9 degree of membership in F,
Fred has a 0.4 degree of membership in F,
Oscar has a 0.1 degree of membership in F,
Rita has a 0.5 degree of membership in F
(so that Brian is the most famous and Oscar is the least famous of these
people).
Also suppose that R is the set of rich people with R = {0.4 Alice, 0.8 Brian,
0.2 Fred, 0.9 Oscar, 0.7 Rita}.
Fuzzy

• The complement of a fuzzy set S is the set S, with the degree of the
membership of an element in S equal to 1 minus the degree of
membership of this element in S. Find F (the fuzzy set of people
who are not famous) and R (the fuzzy set of people who are not
rich).
• The union of two fuzzy sets S and T is the fuzzy set S ∪ T , where
the degree of membership of an element in S ∪ T is the maximum
of the degrees of membership of this element in S and in T . Find
the fuzzy set F ∪ R of rich or famous people.
• The intersection of two fuzzy sets S and T is the fuzzy
set S ∩ T , where the degree of membership of an element
in S ∩ T is the minimum of the degrees of membership
of this element in S and in T . Find the fuzzy set F ∩ R
of rich and famous people.

You might also like