Sets, Relations and Functions in Discrete Mathematics Explained

Sets, relations and functions in discrete mathematics

Introduction

Three of the most important building blocks in discrete mathematics and computer science are set, relation, and function. They can be used to represent sets of objects, relationships between objects, and rules that relate inputs and outputs. Though these ideas seem abstract at first, they found many applications like programming languages, data structures, databases, algorithms, software development, and artificial intelligence. A set can be a collection of users or of numbers, a relation can be used to determine connections between records or objects, and a function can be used to determine the output of a particular input. These ideas provide students with a better understanding of the mathematics needed to address computational issues and to think about the behaviour of programs and systems.

Sets are a collection of distinct elements.In Discrete Mathematics, sets are defined as a group of unique elements.

A set is a collection of objects that is clearly defined, with each object in the set (or not in the set) being called an element or member of the set. Numbers, characters, words, computer objects, database records or almost anything else that is clearly identifiable can be put into sets. Sets are usually denoted by upper case letters A, B or C, with elements enclosed in curly braces { }. For instance, A = {1, 2, 3, 4} is a set with four elements in it. Elements are usually ordered and repeating elements are not new elements. Computer science makes use of sets especially in the grouping of information by common characteristics. For example, sets of all the possible file extensions can be declared by a programmer, and sets of records that meet specific criteria can be represented by a database system.

Set notation and elements in discrete mathematics

Set notation is a compact way of writing sets and their attributes. Roster notation is one method that has been used, for example, B = {2, 4, 6, 8}. Another way to write them is using set-builder notation which describes the property they must satisfy. For instance, the set B = {x | x is an even positive integer that is less than 10} represents the same set. The symbol ∈, which reads “is an element of” is used to mean membership. 4 ∈ B means 4 is an element of B. Knowing what these symbols mean is essential for many purposes in computer science, such as defining algorithms, data structures, formal specifications and logical conditions.

Set Operations

Set operations enable collection of different sets to be manipulated, compared or analyzed. The union operation ∪ is one of the most important operations. For two sets A and B, the union of the two sets is A ∪ B = {x | x ∈ A or x ∈ B}, meaning that it includes all elements shared by the two sets, but does not repeat them. For example, if A = {1, 2, 3} and B = {3, 4, 5}, then A ∪ B = {1, 2, 3, 4, 5}. The intersection of two sets, represented by ∩, is the set of elements common to both sets, for example, A ∩ B = {3}. The difference operation picks those elements that are in A but not in B, so A − B = {1, 2}. The complement of a set is everything that is not in the set but is in the universal set. These operations are commonly used in database queries, search systems, filtering algorithms, and programming tasks that require handling a collection of data.

Set operations showing union intersection and difference

The relationships can also be used to describe how collections can be compared to each other. If each element in A is also in B, then A is a subset of B, denoted as A ⊆ B. For example, if A = {1, 2} and B = {1, 2, 3, 4}, then A is a subset of B. A and B are equal sets when they have exactly the same elements. Cardinality of a set is the number of elements in the set. So, the cardinality of {a, b, c} is 3. These concepts are used in programming in the context of arrays, lists, hash sets and the results of database queries. For instance, it may be necessary for a programmer to find out if every element of one collection is also an element of another collection or to find the different values in two data sources.

Discrete structures offer a convenient structure for the study of sets, logic, relations and functions, and graphs, which underlie the reasoning of computer science.

Cartesian Products

The Cartesian product provides a way to create ordered pairs from two sets. Let A and B be sets; then the Cartesian product A × B consists of all ordered pairs (a, b) such that a ∈ A and b ∈ B. For example, if A = {1, 2} and B = {x, y}, then A × B = {(1, x), (1, y), (2, x), (2, y)}. An ordered pair is different from an ordered pair, e.g. (1, x) is distinct from (x, 1). If there are m elements in A and n elements in B, then A × B is the set of m × n ordered pairs. When learning about relations, it is important to note that a relation between two sets A and B can be considered as a subset of the Cartesian product of the sets A and B.

Cartesian product showing ordered pairs between two sets

There are a number of real-world applications of Cartesian products in computer science. Suppose there is a database with a collection of students and a collection of courses. The Cartesian product can be used as a conceptual model of all possible student-course combinations. A particular set of combinations can then be selected from a database based on specific criteria, for example registered students in certain courses. Combinations of possible inputs, Cartesian coordinates, state spaces and computational geometry also have relevance to Cartesian products. Though a Cartesian product of two or more sets may be quite large, once the concept is understood, it can be seen how various combinations of possible values can be formed and how relations can then be used to identify desirable relationships from among the combinations of values.

What Are Relations?

A relation is a relationship or association between elements. If A and B are any two sets, a relation from A to B is any subset of A × B. According to this definition a relation is a set of selected ordered pairs of the Cartesian product. For example, suppose A = {1, 2, 3} and B = {2, 4, 6}. The relation does not have to include all the elements of A and any element of A may be associated with several elements of B. This flexibility means that relations are useful for describing real world and computational relationships: friendships, database associations, prerequisites, relationships between web pages, and dependency relationships between software components, to name a few.

There are multiple ways to represent the relationships based on the problem being studied. In an ordered-pair representation, the elements that are related are described explicitly. A relation may be also expressed in the form of a table, matrix, directed graph or diagram. For instance, a studentID/courseID relation may be present in a database table with studentID as the relation’s row key and courseID as the relation’s local column key. A graph-based representation can depict elements as nodes and the relationships as edges. These are the various ways of representation which helps computer scientists to choose any suitable method for analysing any specific problem. Therefore, it is important to understand relations not only in theoretical mathematics but also in databases, graph algorithms, networking, data modeling, and in software engineering.

Relation and function mapping between domain and codomain

Types of Relations

Relationships can be of varying characteristics depending on the type of connections between the elements. A relation on a set is reflexive if for every element in the set, the element is related to itself. For the relation to be this way for a particular set A means that (a, a) is a member of the set for all a in A. A relation is symmetric when a is in the relation if and only if b is in the relation. For instance, if one person is a friendship of another then generally the inverse of the relationship is also modelled as a friendship. A relation is antisymmetric if for every a, b, whenever R(a, b) and R(b, a both hold, then a and b have to be the same element. A relation is transitive if a is related to b and b is related to c then a is related to c. These properties enable computer scientists to systematically categorize and examine relationships.

A partial order relation is one of the important relations. A relation is called a partial order if it is reflexive, antisymmetric, and transitive. Partial orders can be used to describe situations where some elements are comparable, others are not. For instance, the subset relation on sets is a partial order: it satisfies reflexivity, antisymmetry and transitivity. Partial orders are well-suited for scheduling, dependency management, version control, and algorithms which require ordering objects based on precedence constraints. Knowing the characteristics of a relation can guide programmers in the types of operations that can be safely performed and in organizing information.

Equivalence Relations

A relation that is reflexive, symmetric, and transitive is called an equivalence relation. The three properties enable the relation to group elements that, under a specific rule, are equivalent. For instance, let’s take integers and establish a relation in which two integers are in relation if they leave the same remainder when divided by a given positive integer. This relation is an equivalence relation. The elements can then be partitioned into equivalence classes, each of which consists of elements that are equivalent by the rule. A system can reason about groups of equivalent elements, rather than about each individual element separately.

In computing, many problems involve grouping objects by common properties and this is where equivalence relations come in handy. It is possible that a compiler has to identify expressions or states that act in the same way when under certain circumstances. A database can be structured around a similar attribute, and an information system can be structured around a similar attribute to classify objects into categories. Equivalence classes can help to reduce a complicated problem into a related group of elements that can be considered as a single conceptual group. The knowledge of equivalence relationships thus facilitates the students to relate mathematical reasoning to classification, data organization, optimization, algorithm design, etc.

Functions and Mappings 

A function is a relation where each element in the domain corresponds to exactly one element in the range. A function is typically represented as f: A → B, which means that elements of A are being mapped to elements of B by function f. If f(2) = 5, then f sends the number 2 to 5. The set of possible values for x is called the domain and the set of possible values for y is called the codomain. The range is the set of the outputs of the function. A characteristic of a function is that no x terminates in the function with more than one y value. But for different types of function, there may be multiple different inputs that match the output.

Programming is often viewed as a set of transformations from inputs to outputs, which is why functions are key elements of computer programs. A function could have a person’s age as a parameter, and return a classification; it could have a number as a parameter and return the square of that number; or it could have a data record as a parameter and return a formatted version of the data record. In programming languages, functions help keep things organized by enabling the definition of an operation that can be used over and over again. Mathematical functions are used as the theoretical grounds for talking about if they are consistent or not. Programmers can reason about data transformations and the behaviour of software better when they know what is the domain, the codomain, the input and the output of the software.

Types of Functions

Functions may be given by describing the relationship between the input and output. A function that maps different inputs to different outputs is called injective. That is, the values of the output must be the same if the two inputs are the same. This property helps to identify the property when a unique identification is required. A function in which each element in the codomain is “mapped” by a member of the domain is a surjective function, also known as an onto function. A function which is both injective and surjective is called bijective. A bijection is a one-to-one correspondence between two sets; that is, each element of one set has exactly one element in the other set. These differences are relevant in the context of algorithms, data structures, mappings, and mathematical proofs.

Functions can be compounded as well. If there are two functions f1 from A to B and f2 from B to C, then the two functions can be composed in such a way that an element x in A is first sent to B by f1 and then from B to C by f2. This is called composition of functions. In the world of programming, composition is the situation in which the result of one operation is used as an argument to another operation. For instance a program can get a number, transform it into another form, and then do some computation with the transformed number. So, if these operations are considered as functions, it is easier to analyze complex processes as a series of smaller transformations. It is particularly useful in functional programming, algorithms, data processing and software design.

Sets, Relations, and Functions 

All three concepts are connected in various aspects of computer science. Sets are sets of objects, relations are links between objects, and functions are controlled mappings between sets of inputs and outputs. For instance, in a database, sets can be organized as collections of records, relations can be used to define associations between tables, and functions can be used to describe transformations that can be applied to the values stored in a database. In graph theory, the vertices may be considered to be a set, and the edge is a relation among pairs of vertices. These structures can then be used to search for paths, find connected components, or find dependencies, which algorithms can process. This is an example of why sets, relations and functions are not abstract mathematical objects but a useful tool for modeling information in a computational context.

Applications of sets relations and functions in computer science

These ideas are also used in other ways in programming languages. A function may take a value from a specified domain and give a value as output, and data structures may have collections of values that can be thought of as sets. Relationships are established when programs require to model dependencies, permissions, associations, or connections between objects. Data can be seen as sets of observations and associations between objects, and functions as transformations and predictive maps in the field of AI and machine learning. Even if the programmer doesn’t use mathematical notation, there are concepts that still apply. These are the foundations that help students grasp the concepts of why things work in some algorithms and gives them language to talk about computational structures clearly.

Conclusion

Sets, relations, and functions provide an important foundation for discrete mathematics and computer science. Sets are a precise representation of collections of dissimilar objects and can be used to carry out set operations like union, intersection and difference. The idea of taking the Cartesian product of sets can be used to extend the notion of combination and this forms the basis of defining relations. Finally, relations are about relationships among elements, and they can be classified in terms of reflexivity, symmetry, antisymmetry and transitivity properties. 

Equivalence relations partition elements into groups, partial orders are ways of capturing precedence and comparison. Unlike relations, functions require each input to have exactly one output and are useful in describing transformations and computational processes. The ability to learn these concepts together will help students to build more robust mathematical thought and to gain a better understanding of algorithms, databases, programming languages, data structures and other aspects of computer science.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
0
Would love your thoughts, please comment.x
()
x