0% found this document useful (0 votes)
21 views50 pages

Group 7 Presentation 2

The document presents a comprehensive overview of set theory, including its introduction, types, properties, operations, and applications in computer science and engineering. It discusses the relationship between set theory, Boolean algebra, and propositional logic, as well as the use of Venn diagrams to illustrate set operations. Additionally, it covers structural induction as a proof technique for properties of sets and recursive data structures.

Uploaded by

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

Group 7 Presentation 2

The document presents a comprehensive overview of set theory, including its introduction, types, properties, operations, and applications in computer science and engineering. It discusses the relationship between set theory, Boolean algebra, and propositional logic, as well as the use of Venn diagrams to illustrate set operations. Additionally, it covers structural induction as a proof technique for properties of sets and recursive data structures.

Uploaded by

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

UNIVERSITY OF DAR ES SALAAM

Department of Computer Science & Engineering

Discrete Structure
(IS 143)

Presentation on set theory


1
Group Members
Student Name: Rose Baltazar Student Name: Jackson
Programme: Computer Science Matongo
Registration no.: 2024/04/00622 Programme: Computer Science
Gender: Female Registration no.: 2024/04/05932
Gender: Male

Student Name: Henry Chulla Student Name: Gloria Issawkisa


Programme: Computer Science Programme: Computer Science
Registration no.: 2024/04/01224 Registration no.: 2024/04/08085
Gender: Male Gender: Female

Student Name: Helman Jacob


Programme: Computer Science
Registration no.: 2024/04/02541
Gender: Male
Contents
● Introduction
● Types of sets
● Properties of sets
● Operation of sets
● Venn diagrams
● Relationship between Set theory, Boolean Algebra and propositional logic
● Applications of sets in Computer science and Engineering
● Examples of data types suitable for programming
● Advantages and disadvantages of set theory application in Computer Science
● Limitations of Set Theory in Computer Science and Engineering
Introduction
SET THEORY
Set was original introduced in Mathematics in (1870) by a German mathematician Georg
Cantor. Cantor introduced different concept such as Cardinality of a set , Infinite set and
the distinction between countable and uncountable set.
In early of 20th century between (1940s - 1950s), the set theory was first introduced in
computer science, in a field of formalization of algorithms and data structure, and later on
in programing language.
set
The word set is used in mathematics to mean any well defined collection of items or
objects. Sets are used to group objects together, but it’s not the case that, the objects in a
set have similar properties.
Introduction
Example of a set,
The set A of positive odd numbers less than 10, A={x| x is odd number<10}
The set V of all vowels in the English alphabet can be written as V = {a, e, i, o, u}.
NOTE: 1. we use capital letters to denote sets. For example, we can write:
A = {1, 2, 3, 4, 5}
Where A is a set of 1,2,3,4 and 5, in which 1,2,3,4 and 5 are known as the

membership or element. For example, 1∈ A , 2∈ A, 3∈ A, 4∈ A and 5∈ A


membership or element of set A; We can also use a symbol to represent a single

2. Lowercase letters are usually used to denote elements of sets. For example,
a∈ A
Ways or method of representing sets
There are two main way or method of representing set.
First method; Roster method it’s also known as (listing method), is the
way of representing a set by listing the element or member of a set. For example
let P be a set, then P= {1,2,3,4,5}
If there is a clear pattern to the elements, an ellipsis (three dots) can be used. For
example, the set of even number between 0 and 10 can be written as { 0, 2,… ,8}
This method of listing the elements of the set is also known as ‘Tabulation’
Second method; Set builder method, the set is defined by specifying a
property that elements of the set have in common. For example, let set B be the
set of even numbers between 0 and 30 can be written:
B= {x: x is even and 0 < x < 30}
Types of sets
SINGLETON SET
a singleton, Is a set having only one element /member.
For example: A= {2}
FINITE SET
A set which contain defined number of element.
For example: (i) A= {1,2,3,4,5}
INFINITE SET
A set which contain undefined or uncountable number of element.
For example: (i) A= {x| x is even number greater than zero x >0 }
Types of sets
SUBSET
A set A is a subset of the set B if and only if every element of A is also an element of
B. It’s denoted as A ⊆ B
For example: A= {a, c, f } and B= { a, b, c, d, e, f }
There two types of subset , which are Proper subset and Improper subset .
Proper subset, A set A is called proper subset of the set B, if set A does not contain all
element of set B. For example; A= {1,2,3} while B= {1,2,3,4,5,6}.
Improper subset, A set A is called improper subset of the set B, if set A contain all
element of set B. For example; A= {a, b, c} and B= {a, b, c}.
SUPER SET
If set A is a subset of B then, B is a super set.
Types of sets
POWER OF SET
A set of all subset of a set. Power of set Q is denoted as P(Q)
For example: Set A is given as A= {1,2,3} then the powerset of set A is P= { {}, {1}, {2},
{3}, {1,2}, {1,3}, {2,3}, {1,2,3} }
EMPTY SET /NULL SET
A set with no element. For example: A= {} or A= Φ .
UNIVERSAL SET
A set which contain all possible element of all given sets.
Example: If A = {0, 2, 7}, B = {3, 5, 6}, C = {1, 8, 9, 10} then the universal set can be
taken as the set. U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
1.Properties of sets

A∪A=A
● Idempotent Properties:

A∩A=A

(A ∪ B)' = A' ∩ B'


● De Morgan's Laws:

(A ∩ B)' = A' ∪ B’

A ∪ A' = U
● Complement Properties:

A ∩ A' = ∅
Properties of sets
• Identity Properties:
A∪∅=A
A∩U=A
• Commutative Properties:
A∪B=B∪A
A∩B=B∩A
• Associative Properties:
(A ∪ B) ∪ C = A ∪ (B ∪ C)
(A ∩ B) ∩ C = A ∩ (B ∩ C)
• Distributive Properties:
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
Operation of sets
UNION OF SETS:
Is the combination of two sets. The union of two sets A and B is the set whose
elements are all of the elements in A or in B or in both. And it’s denoted as A∪ B.
For example: Set A= {1, 2, 3} and set B= {4, 5, 8} then union of set A and B ( A∪ B) =
{1, 2, 3, 4, 5, 8}
INTERSECTION OF SETS
Two or more sets are said to be intersected if they have one or more common
elements. And it’s denoted as A∩B.
For example: Set A= {1, 2, 3, 4} and set B= {3, 4, 5} since set A and B have element 3
and4 which are common to both A and B then A and B intersect (A∩B).
symbolically: A∩B={x| x∈ A and x∈ B }
Operation of sets
DIFFERENCE OF TWO SETS (Relative complement )
If A and B are subsets of the universal set U, then the difference of set A to set B ( A - B ) means is
the element that is in set A but not in set B.
Symbolically: (A\B) or (A -B) = { x| x ∈ A and x ∉ B}
For example: Set A= {1, 2, 3, 4} and set B= {3, 4, 5, 6} , then A – B = {1, 2}
SYMMETRIC DIFFERENCE
If A and B are subsets of the universal set U, then the symmetric difference of set A and B
means the element can be either in set A or in set B but not in both. It’s denoted as (AΔB)
or( A⨁B).
Symbolically: A Δ B = {x| x ∈ A ∪ B and x ∉ A ∩ B} or A Δ B= (A – B) ∪ (B – A)
For example: Set A= { 1, 2, 3, 4} and set B= {3, 4, 5, 6, 7, 8}, then A Δ B = {1, 2, 5, 6, 7, 8}
COMPLEMENT OF A SET
Venn diagrams
● These are diagrams that are used to give a visual
presentation of sets and to highlight the way they relate to
one another .
● They usually uses circles to represent a single set ,
meanwhile a rectangle outside represent a universal set.
● Example of venn diagram.
Venn diagrams cont...
● Venn diagrams helps to illustrate various set operations as
follows
i) Union (A∪B).
•it’s shown by shading both circles in the venn
diagram.

ii) Intersection (A ∩ B).


• It’s shown by shading the area where two or
more sets overlaps
each other.
Venn diagrams cont...
iii)Difference (A – B).
• It’s shown by shading the area of set A that
doesn’t overlaps
set B.

iv)Complement (A’).
• It’s shown by shading the area outside the
particular set
within a universal set.
Venn diagrams cont..
● Venn diagrams are used in set theory to give a
graphical and much detailed representation
on the relationship that exists between
particular sets.

● Henceforth making it easier to understand


and solve set problems in Mathematics field.
Relationship between set theory, Boolean
Algebra and propositional logic
● Set theory.
Refers to the branch of Mathematics
that deals with the study of collection of things
or objects with similar characteristics.
• Boolean Algebra.
Is the branch of Mathematics which
deals with logical operations on binary
variables.(0 and 1)
It is an ideal figure in digital electronics and
Cont...
● Propositional Logic.
Refers to the branch of Mathematics
which deals with statements that can be either
true or false but not both.
Example. “If I study then I will pass”.
• The statement above can be judged whether
it’s true or not.
Cont...
● The relationship between set theory ,
Boolean Algebra and propositional logic
lies on how they handles truth values,
structure and most of all the way of reasoning.
● Relationship.
They use similar operations.
Set union (∪) ≈ Boolean and logic OR (+)
Set intersection (∩) ≈ Boolean and logic
AND (·)
Set complement (Aᶜ) ≈ Boolean and logic
Cont...
● Examples.
● In set theory:
If A = {1, 2}, B = {2, 3}, then A ∩ B = {2}

• In Boolean algebra:
If A = 1 (true), B = 1 (true), then A AND B = 1
So, Boolean algebra is like set theory with just two elements:
true and false.
Application of Set theory, Boolean algebra, and
Propositional Logic

● Databases.
SQL operations like JOIN, UNION, INTERSECT
are based on set theory as the foundation.
• Data structures.
Collections like arrays, lists, sets, and maps are often
treated as mathematical sets in most data structure
•Search Engines.
Search engines use the concept of intersection from the
set theory to match the search results and the queries.
Application cont...
● Digital circuitry and hardware.
Boolean algebra is used to design the electronic digital
circuits that uses logic, flip flops, adders and CPU.

• Programming Logic.
Conditional statements in programming languages are
based on Boolean functions.
Example Conditional statements like if, Else, loops and
every true/ false decision in code.
Application cont...
● Artificial intelligence.
Propositional Logic helps AI to reason and to make
decisions using rule-based systems, and logical inference
engines.
• Formal verification.
Propositional logic helps to Prove Mathematically if a
program or software works correctly according to it’s
specifications.
It finds all errors in the software even the ones that the test
might miss.
Demonstration on how structural induction is used to prove properties of sets and
recursive data structures

● Structural induction is a mathematical proof technique


used to demonstrate that a property holds for all elements
of a recursively defined set. It's particularly useful when
dealing with sets defined by rules that specify how to
construct complex elements from simpler ones.
● For easy understanding lets break into steps-by-step
procedures
Structural induction proof
Step 1: Define the Recursive Structure
Before applying structural induction, it's crucial to understand how the
structure (e.g., a set or a data structure) is built recursively. For a full
binary tree, the definition involves:
1. Base Level: A tree of height 0 consists of a single node, which is both
the root and the only leaf.
2. Recursive Construction: A tree of height n+1 is formed by taking two
full binary trees of height n and connecting them to a new root node.
● This recursive definition tells us that each "larger" tree is built from
simpler components, making it suitable for structural induction.
Structural induction proof

Step 2: State the Property to Prove


Next, clearly define the property you wish to prove. For
example:
• Property: The number of leaves in a full binary tree of
height n is 2n.
• This property relates the tree's height (n) to the number of
its leaves, and our goal is to show that the relationship
holds true for all possible values of n.
Structural induction proof
Step 3: Base Case
The base case verifies that the property holds for the simplest
possible instance of the structure.
• For n = 0: A full binary tree of height 0 has just one node,
which is also a leaf. So, the number of leaves is 1.
• The formula 2n gives 20 = 1 for n=0, which matches the
actual number of leaves.
● Since the property holds for n=0, the base case is proven.
Structural induction proof

Step 4: Inductive Hypothesis


The inductive hypothesis assumes the property is true for
some arbitrary value of n.
• Assume that for a full binary tree of height n, the number
of leaves is 2n. This assumption forms the foundation for
proving the property for the next step, n+1.
Structural induction proof

Step 5: Inductive Step


Using the inductive hypothesis, prove that the property holds for
n+1.
A full binary tree of height n+1 is constructed by attaching two
full binary trees of height n to a new root node. By the inductive
hypothesis, each subtree of height n has 2n leaves.
Adding the leaves from both subtrees gives:
2n+2n=2⋅2n=2n+1.
This shows that the property is true for n+1 if it is true for n.
Structural induction proof

NOTE:
● By completing both the base case and the inductive step,
the property is proven for all n≥0.
Application of Sets in Computer Science and
Engineering
● Databases: At the core of a relational database lies the concept of sets. Each table
represents a set of unique records (tuples) where operations such as union,
intersection, and difference are not only defined but essential. For example, when
combining results from multiple tables, the union operation ensures we don’t have
duplicates, thereby maintaining data integrity.
● Data Structures: Sets are implemented through various data structures such as
hash sets or balanced trees, which allow for efficient management of unique items.
This is particularly crucial in applications like spell checkers—where a dictionary
might be a set of valid words—and in performing efficient membership checks,
insertions, and deletions.
Cont..
● Formal Proofs and Logic: In the realm of formal methods, sets serve as a
foundation to define system properties. Through set theory, we can formulate
logical propositions that help verify the correctness of algorithms and
systems, thus ensuring that software behaves as expected.

● Graph Theory: When dealing with graphs, sets become fundamental in


representing the nodes (vertices) and the connections (edges). Set operations
allow us to explore various graph characteristics—like determining if paths
exist between nodes or discovering connected components. These operations
are integral to algorithms in networking, social networks, and more.
Cont.…

● Algorithms: From searching algorithms to optimization techniques, sets


underpin a multitude of algorithmic strategies. For instance, finding
intersections of sets helps us identify common elements in datasets—
essential for recommendation systems and clustering algorithms.
● Machine Learning: In machine learning, sets represent collections of
features, samples, or training data. Operations over sets enable tasks such
as clustering, classification, and data cleaning, where understanding
relationships between different elements is critical for achieving model
accuracy.
Cont..

● Networking: In network topology, sets represent nodes in a


communication network, while edges symbolize connections. Set theory
helps in analysing and optimizing routing protocols, ensuring efficient
communication between devices within various network architectures.

● Programming Language Semantics: Sets are often used to define the


semantics of programming languages, such as formalizing the types and
behaviours of variables. Understanding how data elements behave in
sets is critical for compiler design and language interpretation.
Examples of Data Types Suitable for Sets in
Programming
1. HashSet (Hash Table)
In languages like Java, a HashSet is frequently used to implement a
set. Behind the scenes, it employs a hash table to maintain elements.
If you are building an application that tracks user sessions, a HashSet
can be employed to store unique session IDs. You can quickly check
if a session is active (membership testing), and add or remove
sessions efficiently.
Cont.…

2. Set (Python's Built-in Type)


Python includes a built-in set type that allows you to create
sets effortlessly.
Consider a scenario where you want to find unique tags in a
blog application. By storing tags in a Python set, you can
quickly get the unique tags used across all posts.
Additionally, you can perform operations like intersection
and union to see overlapping tags between different posts.
Cont.…
3. TreeSet (Balanced Binary Search Tree)
In Java, a TreeSet implements a set using a balanced binary
search tree, maintaining order among elements.
If you're implementing a leaderboard in a gaming application
where you want to keep track of unique player scores and
retrieve them in sorted order, a TreeSet would be ideal. It
ensures that scores are unique and allows for efficient sorting.
Cont.…

4. Bit Set
A bit set is a data structure that uses bits to represent a set of
non-negative integers, with each bit indicating the presence
(1) or absence (0) of an element.
This might be used in network applications to track active
connections efficiently. For example, if you need to track which
IP addresses in a subnet are currently engaged, a bit set minimizes
memory usage while allowing quick membership testing.
Advantages and disadvantages of set
applications in Computer Science.
● Advantages.
 Allows efficient membership testing ; sets mainly helps to
check whether an element really exists .its an ideal for searching
and filtering mainly in algorithms where fast look ups is
important.
 Simplifies code and logic; sets reduces the manual loops and
conditions leads to more readable and concise codes.
Advantages cont...
 Efficient performance; as sets are generally faster than
lists of larger data thus is used in large data processing
like in databases.
 Supports mathematical operations; sets performs
mathematical operation for combining or comparing
datasets (union , intersection, difference)
 Automatic duplicate removal; sets ensures only the unique
data are stored as its useful in data cleaning.
Disadvantages
 No duplicate values; sets limits the elements as it
automatically removes the duplicates as sometimes its
important .example in counting votes or items .

 Unordered elements; sets doesn’t keep items in specific


order . This is bad for the tasks that order is important .
Cont...
 Higher memory use; sets can use more memory than
lists due to hashing, if a memory is limited a list is
more efficient.
 Not ideal for certain algorithms; some algorithms
require ordered or indexed structures which sets cannot
provide. e.g. binary search, and dynamic programming
which requires lists or arrays.
Limitations of Sets Theory in Computer Science and Engineering

1. Handling of Infinite Sets


● Problem: Set theory can handle infinite sets, but in real-world
computing, we deal with finite resources (like memory and
processing power). Infinite sets are theoretical constructs and are
not directly applicable to practical computational problems.
● Example: While set theory can describe an infinite set of integers, a
computer can only work with a finite subset of integers, making the
concept of infinite sets abstract and not directly implementable in
programs or hardware.
Limitations of Sets Theory in Computer Science and Engineering

2. Computational Complexity
● Problem: Set operations like union, intersection, and complement are
often conceptually simple but can be computationally expensive when
dealing with large data sets. While set theory can describe these
operations abstractly, efficient computation in practice often requires
optimization techniques.
● Example: Set membership tests (checking whether an element is in a set)
can be slow in large sets. Optimizing such operations in a real system
often requires using data structures like hash tables or trees, which go
beyond basic set theory.
Limitations of Sets Theory in Computer Science and Engineering

3. Representation of Data
● Problem: Set theory abstracts away many details of how data is stored and
represented in a computer. Real-world data structures and algorithms often
need to consider performance trade-offs, memory management, and access
patterns that set theory does not inherently address.
● Example: In computer science, sets may be represented using hash sets, trees,
or arrays, each with different time complexities for various operations. Set
theory does not specify the best representation for these data structures.
Limitations of Sets Theory in Computer Science and
Engineering

4. Fuzzy and Probabilistic Sets


● Problem: Classical set theory assumes crisp membership — an element either
belongs to a set or doesn't. However, in many areas of computer science, we
deal with uncertain or imprecise data. Concepts like fuzzy sets and
probabilistic sets (where membership can have degrees) extend set theory, but
they introduce complexity that classical set theory does not address directly.
● Example: In machine learning, we often deal with uncertain or imprecise data,
such as in classification problems where an object can partially belong to
multiple classes. This goes beyond the binary membership defined in
traditional set theory.
Limitations of Sets Theory in Computer Science and Engineering

5. Scalability Issues
 Problem: As the size of data sets grows, certain operations on sets, such as determining
intersections or computing power sets, can become inefficient. The scalability of
algorithms based on set theory often requires advanced techniques like approximation,
heuristics, or distributed computing.
 Example: Calculating the power set of a large set has exponential complexity (2^n
subsets), which becomes impractical for large n. Computer systems must find alternative
ways to deal with large data sets without explicitly computing the power set.
Limitations of Sets Theory in Computer Science and Engineering

6.Non-Disjoint Operations
 Problem: In classical set theory, operations like union, intersection, and difference are
well-defined for disjoint sets, but in many real-world scenarios, data may overlap or not
be cleanly separable. Set theory does not always provide an elegant way to handle non-
disjoint or partially overlapping data sets.
 Example: In database queries, when dealing with records that might have duplicate or
partially overlapping entries, handling such sets requires more sophisticated methods like
normalization, indexing, or multi-way joins.
References

• Winskel G. Set theory for computer science [Internet]. Cambridge: University of


Cambridge; 2010 [cited 2025 Apr 15]. Available from: mailto:[email protected]
• Rosen KH. Discrete mathematics and its applications. 7th ed. New York: McGraw-Hill
Education; 2012.
• Sipser M. Introduction to the theory of computation. Boston: Cengage Learning; 2012
Jun 27.
• Sedgewick R, Wayne K. Algorithms, Part I. Princeton: Princeton University; 2014 Feb.

You might also like