# PAMANTASAN NG LUNGSOD NG MAYNILA University of the City of Manila Intramuros, Manila

COLLEGE OF ENGINEERING AND TECHNOLOGY Computer Engineering Department

Project in Discrete Mathematics RELATIONS

ALVAREZ, Timothy Paul B. GILIBERTE, Gilamae C. MASANGCAY, Kevin A. PINCA, Aubrey Rose P.

BSCOE 4th Year

Engr. Melannie Mendoza FACULTY October 8, 2011

e. 1. the congruent mod 2.. The same applies when we are interested in more than 24 hours. and starts all over again from there. Being representable by one number such as we see on clocks is a binary relation on the set of natural numbers and it is an example of equivalence relation we are going to study here.. {<a. . 49th etc. 25. 2.
symmetric. However. where m is a positive integer greater than 1. b>| a b (mod m)}. 6} is as shown below. all even numbers are equivalent and all odd numbers are equivalent. . 2 and 14. share one number 1. Thus each pair of hours such as 1 and 13.. For example the digraph of the equivalence relation congruent mod 3 on {0.etc. etc. Example 2: The congruent modulo m relation on the set of integers i.RELATIONS I. Note that the equivalence relation on hours on a clock is the congruent mod 12.. 3} is an equivalence relation.. What we are doing here essentially is that we consider the numbers in each group such as 1. i. 3. 4. so are 37th. Introduction On the face of most clocks. 2. Thus the set of integers are divided into two subsets: evens and odds. equivalent in the sense that they all are represented by one number (they are congruent modulo 12). 5 .
Example 1: The equality relation (=) on a set of numbers such as {1. since a day has 24 hours after 12 hours. 13. Equivalence relations can also be represented by a digraph since they are a binary relation on a set.e. hours are represented by integers between 1 and 12.. 2. Example 3: Taking this discrete structures course together this semester is another equivalence relation. 25th hour is 1. is an equivalence relation. The concept of equivalence relation is characterized by three properties as follows: Definition(equivalence an equivalence (1) R is (2) R is (3) R is relation): A relation if binary relation R on a and only set A is if reflexive and transitive. a clock goes back to hour 1.
. respectively. and that when m = 2. It consists of three connected components.

..
where N is the set of natural numbers. Aj = . say b .. An} is a partition of A.. A2. .. equivalence classes are
[1]
=
{1. and the set of integers equivalent to a number between 1 and 12 in the equivalence relation on hours in the clock example are called an equivalence class.
.. Thus the set A is partitioned into equivalence classes by an equivalence relation on A. There are altogether twelve of them... 14. that is either [a] = [b] or [a] [b] = for arbitrary elements a and b of A. For an equivalence relation R on a set A. Example 4: For the equivalence relation of hours on a clock. . An be subsets of A. Then {A1. Thus the set A is in a sense covered by the equivalence classes. then the set consisting of the element bitself is an equivalence class. . does not belong to the equivalence class of any other element in A...
[2] = .
13.The set of even numbers and that of odd numbers in the equivalence relation of congruent mod 2.. . the set of the elements of A that are related to an element. if and only if
(1) (2) Ai
Ai = A. of A is called the equivalence class of element a and it is denoted by [a].. say a... j
and n. This is formally stated as a theorem below after the definition of partition. Formally it is defined as follows: Definition(equivalence class): For an equivalence relation R on a set A.. if Ai Aj . 26. 1 i. }
} =
=
{1+ 12n: n {2+ 12n: n N}
N} . {2.
. For if an element.. every element of A is in an equivalence class.. Definition (partition): Let A be a set and let A1. A2. Another property of equivalence class is that equivalence classes of two elements of a set A are either disjoint or identical.
25..

5}. but R1 II. or as mathematicians also say identified with. R2 is an
Theorem 3: Let R1 and R2 be equivalence relations.
Theorem 1: The set of equivalence classes of an equivalence relation on a set A is a partition of A. a vital branch underpinning all branches of mathematics and those fields that use mathematics. a mathematical concept. 5}.. How can the mathematician express the idea that 12 is equivalent to. 24 or 48? In general. 2 is equivalent to 14. Then R is R if and only if a an Ai and b Ai for
equivalence
relation. 38 «. and B3 = though B1 {4} do B2. 4}. 3}. B2 = {2. 1 i n. 3. Moreover. the mathematician can consider the elements of the set of non-negative integers: {0.
Equivalence relation. . Divide this integer by 12 and keep the remainder. 2. b> some i. an equivalence relation is one of the most used and pervasive tools in mathematics. An} be a partition of a set A.. and A3 = {2. 4. A3} is a partition of A. the mathematician succeeds in gaining a new perspective on the set of nonnegative integers. B1 = {1. suppose the mathematician wants to consider time measured in hours. For example. A2 = {3}. a partition of a set A determines an equivalence relation on A. However. Then {A1. Equivalence relation is defined in a branch of mathematics called set theory. A2. 5}. The power of an equivalence relation lies in its ability to partition a set into the disjoint union of subsets called equivalence classes. Theorem 2: Let {A1. Any non-negative number that gives the same remainder in this way is equivalent to any other such number. in this example (call it "clockwork" arithmetic). take any non-negative integer. 2 «}. what can a mathematician do with it? The mathematician can consider the elements of it.Example 5: Let A = {1. is a type of relation on a given set that provides a way for elements of that set to be identified with (meaning considered equivalent to for some present purpose) other elements of that set. 1. Discussion
R2 is not necessarily an equivalence relation. Then R1 equivalence relation. Introduction Given a set. The definition of equivalence relation is based on this
. 2. By positing that any nonnegative number is equivalent to its remainder after division by 12. 26. not form a partition for A because B1 B2 . Because of its power to partition a set. A1 = {1. Hence. Conversely.. Define a binary relation R on A as follows: <a.

then y is equivalent to x. of X if and only if (x. The Definition of Equivalence Relation
Let X be a set and let x. A third common way to rewrite the three properties of equivalence relation is: Reflexive Symmetric Transitive Property: Property: Property: if x if x ~ ~ x y x ~ and for y. x. Note that X may be empty. the interpretation of R is key here. In this case. of X has the relation R with any element. then x is equivalent to z. ~ is empty too.
Symmetric Property: if x is equivalent to y. z. Transitive Property: if x is equivalent to y and y is equivalent to z. XxX.
where x ~ y means that (x. y. An equivalence relation. Note R is just a subset of the Cartesian product. x) x is in in X. one can rewrite the three properties of equivalence relation as follows: Reflexive Symmetric Property: Property: (x. and z be elements of X. Relation Before discussing equivalence relation. on X is a relation on X such that: Reflexive Property: x is equivalent to x for all x in X. ~. z) is in ~. y) is an element of R. it is necessary to review the general concept of relation on a given set. y. for then all (y. A relation. In the language of sets. then ~ is non-empty too. z) are in ~.
. Hence any particular element. Equivalence relation is a special case of relation. x y then x in ~ ~ X. if (x. Let X be the given set. R. x. If X is non-empty. then (x.simple idea of considering some elements to be equivalent to others under the equivalence relation. y) and (y. y) is an element of the equivalence relation ~. on X is a subset of the Cartesian product of X with itself.
Transitive Property: if (x. x) y) is is in in ~ ~. y ~ all then z. ~.

the Cartesian product XxX. for the relation of equality. Clearly ~ is reflexive since the reminder of a number divided by 12 is unique. ~. by n ~ m if and only if n º m (mod 12) where n º m (mod 12) means that n and m give the same remainder after each is divided by 12. the other two properties follow. Let x. the three properties of equivalence relation are. y. Finally. In symbols. The relation of equality is defined by x ~ y if and only if x = y in X. Hence. This relation is sometimes called the trivial equivalence relation. again. (x. For all x in X. (y. (x. where <=> denotes forward and backwards logical implication. n º m (mod 12) <=> m º n (mod 12). Define an equivalence relation. That it is also an equivalence relation requires the verification of the three properties. X. Thus. and z be in X. (y. that follow easily from the definition: the relation of equality and the Cartesian product. To prove that this relation is an equivalence relation. Hence the Cartesian product is reflexive. An Example of an Equivalence Relation in Number Theory
Clockwork arithmetic provides an example of a simple equivalence relation found in number theory. the transitive property is also obvious since if n and m have the same remainder and m and p have the same remainder. x) is an element of XxX.Elementary
Examples
of
Equivalence
Relation
There are two obvious equivalence relations on a set. Introduction to Equivalence Classes
In the clockwork arithmetic example. Let n and m be non-negative integers. z). this relation is also the smallest possible equivalence relation on X since every other equivalence relation must contain this one as a subset. Also. the elements of the subset of the set
. That XxX is the largest relation follows from the definition of relation on X. The easiest way to see this fact is to consider the reflexive property in the language of sets. is an equivalence relation. This equivalence relation has already been introduced above. then n and p have the same remainder. the symmetric property is obvious since it does not matter whether the remainder of n or m is found first or second. y). Fortunately. easily satisfied. In symbols. Another equivalence relation on X. x). one must show that it satisfies the three properties of equivalence relation. Because the reflexive property is simply a restatement of x ~ y if and only if x = y in X. In symbols. the largest relation on X. By the definition of Cartesian product. Moreover. and (x. is the largest relation on X. the reflexive property is denoted n º n (mod 12). from the reflexive property. n º m º p (mod 12). the Cartesian product XxX. z) are all elements of XxX. Consider the set of non-negative integers. the symmetric and transitive properties also hold. the relation of equality is an equivalence relation. Hence.

Hence. in General. 37. Hence. B is contained in A. This fact can easily be gleaned in this example by looking at the equivalence classes listed above. y ~ x. Hence. 12.. Let x be an element of X. This subset is an example of an equivalence class under the equivalence relation. by the transitive property. x or y? The answer is either one. As mentioned above. In the clockwork arithmetic example. . To prove this fact in general.. 12. a naming problem arises. Let a be any element in A and b be any element in B. one can see that x ~ a and y ~ b. In the following. Therefore.. To prove that the element that represents an equivalence class does not matter. 13..}. by the transitive property.}. An Example of Equivalence Class
Every equivalence relation produces equivalence classes. the equivalence class of x is the subset of X: {y : x ~ y and y is an element of X}. one needs a theorem. Can confusion arise if two equivalence classes share a common element? No. the name of an equivalence class can be any element of that equivalence class. 25. In this example. Let ~ be an equivalence relation on X. . From the definition of equivalence class.}. x ~ b. If both x and y are in equivalence class. then which element should represent the equivalence class. A definition is needed. 12.. The Definition of Equivalence Class
Let X be a set.. By the symmetric property. Not Unique For equivalence classes with more than one element. In symbols. Truly it can be called the equivalence class of any multiple of 12 including 0. one must show that the equivalence class of x and the equivalence class of y as defined above are the same subsets of X for x ~ y.of non-negative integers that are multiples of 12 (including 0) are all equivalent to one another under the defined equivalence relation since they each have reminder 0 after division by 12. Hence.. . Let A be the equivalence class of x and B be the equivalence class of y. there are twelve equivalence classes: {0.. The Equivalence Class Representative is. or 24. . The reason is that any two different equivalence classes are disjoint... there are eleven other such equivalence classes: eleven subsets such that the elements of each subset has 1 to 11 as the remainder after division by 12. another equivalence class is the subset of the non-negative integers that begins {1. this fact will be freely used. Equivalence class is crucial to using equivalence relations.}.. Thus. y ~ a. 13. A is contained in B.
. {1. A = B.. The equivalence class of x is the subset of X that contains all elements of X that are equivalent to x under ~. .. {0. {11. 23. can be called the equivalence class of 0. The first equivalence class listed. and it does not matter which element of an equivalence class is chosen to represent that equivalence class.}. Then x is in A and y is in B. .

X is contained in the union of the equivalence classes.) Since every element of X belongs to an equivalence class. Note that. then x and y lie in the same element of P (and no others). y. Because x lies in only one element of P since P is a partition. one must show that it satisfies the three properties of equivalence relations. A and B are the same subset. Thus any pair of different equivalence classes are disjoint. Theorem
Let X be a set and P be a partition of X. one must show that the equivalence classes are disjoint: for any two different equivalence classes A and B. ~ is an equivalence relation corresponding to P. The reflexive property of equivalence relation says that every element of X is equivalent to at least one element of X. on X where. If x ~ y. the equivalence classes of ~ are the elements of P. To finish the proof. P corresponds to an equivalence relation. Hence. Therefore. ~. a ~ x. Since a and x are in A. for x and y elements of X. By the
. Let x. If x ~ y and y ~ z. x ~ x. x ~ y if and only if x and y lie in the same element of P. a ~ b. the equivalence classes of X form a partition of X. A is disjoint from B. Also note that if X is empty. (Note that this fact is assumed in the above definition of equivalence class. The Correspondence of Equivalence Relation and Partition
Let X be a set. they are the same equivalence class. every collection of equivalence classes (induced by an equivalence relation) is a partition of X. Let x be in both A and B. x ~ b. Thus y ~ x. by construction. Since b and x are in B. The equivalence classes of ~ form a partition (a disjoint collection of non-empty subsets whose union is the whole set) of X. and z be elements of X. A A converse Converse of this of partition the theorem Partition also exists. Consequently. that element and. Thus x ~ z. Hence. Thus any element of A is equivalent to any element of B. every element. belong to some equivalence class. then x and y lie in the same element of P (and no others) and so do y and z. Hence by the transitive property. By the partition theorem. ~ and the partition are both empty. To show that ~ is an equivalence relation on X. namely itself. thus. The upshot of this equality is that if two equivalence classes have one common element.A
Partition
Theorem
Let X be a non-empty set and ~ an equivalence relation on X. Let a be any element in A and b be any element in B.

bm connects v to z. Thus w ~ v. then there are two corresponding sequences of vertices that connect v to w and w to z respectively: a1. One of the most common uses of an equivalence relation is to produce a partition. Consider the mathematical object known as the simplicial complex. bm. v ~ w if and only if there is a sequence. b1. Let n = 1. v ~ z. «. «. an. but a simplicial complex in general can be composed of ³pieces´ that have higher dimension than the zero-dimensional vertex or the one-dimensional edge and does not necessarily lie in the plane. then there is a sequence of vertices. a1. an. ai+1] is an edge. ~ is an equivalence relation. an and b1.converse partition theorem. Hence. an. the vertices that are connected to each other by a sequence of edges partition the set of vertices of this simplicial complex. Note that every edge has a vertex at each endpoint. define an equivalence relation on the set of vertices as follows. On the purposed simplicial complex lying in the plane. A Visual Example from Algebraic Topology
A visual example of an equivalence relation producing a partition is found in the subfield of algebraic topology called simplicial homology. The purposed simplicial complex is also known as a special type of graph. which the reader (for the purposes of the present exposition only) may think of as points (called vertices) lying in a plane connected by lines (called edges) that do not cross each other except possibly through a vertex and do not partially overlap. an. connects w to v. If a vertex or an edge overlaps another vertex or edge respectively. this equivalence relation is a precise way of saying that all vertices that are connected to all others by a sequence of edges lie in the same equivalence class. every partition is a collection of equivalence classes induced by the mentioned equivalence relation. before one can assert that ~ is an equivalence relation. one must check that the three properties are satisfied. The vertices in each equivalence class are connected by edges only to fellow elements in that equivalence class. The sequence a1. «. then v ~ v. If v ~ w. Producing an equivalence relation from a partition is less common. but a vertex may stand alone. a1.) Hence. every pair of consecutive vertices are endpoints of an edge.
. a1. Visually. Thus an implicit sequence of edges is also being defined. «. «. but also useful. Also there are rules for crossing and overlapping in a simplicial complex in general that are not germane to the following. If v ~ w and w ~ z. However. Consequently. hence. The purposed simplicial complex is very simple and easy to visualize. of vertices connecting v to w (a1 = v and an = w) where [ai. the equivalence relation is reflexive. these vertices or edges are the same vertex and edge respectively. that connect v to w. They are not connected to any other vertex. Here n is an arbitrary positive integer and i an integer greater than or equal to 1 and less than or equal to n ± 1. Hence the sequence. «. (Note that in this sequence of vertices. Therefore. «. Let v and w be two vertices.

This new perspective may be impressed into many other types of service such as forming quotient groups in algebra or homology groups in simplicial homology.
Scope. It is advised that the user must input values that are relevant to the program made. it has been recommended that the future developers of this program be aware of the problem and can sooner be able to handle the matter. Any malfunction that the input may cause the computer system is no longer the responsibility of the programmers. The use of the term connected in this example means that vertices are connected by a sequence of vertices and edges. the equivalence relation induces a partition of the set by equivalence classes in each of which all elements are identified with each other. the user gains a new perspective on the set that he is working on. Hence.one may imagine that the vertices in each equivalence class form ³islands´ that a point may travel on. One more note on the visual example. With the equivalence classes in hand. every vertex must be in some equivalence class thereby ensuring that the equivalence classes do contain all vertices. It
. This concept is more properly called path-connected or arcconnected. Another limitation of the program is that it can only receive up to thirty values and can only partition it up to a mod of fifteen. By identifying elements of that set with some other elements of that set. Also. Besides allowing the reader to see a partition. Certainly. Limitation & Delimitation
The program created will accept pure integer values only. The uses are almost endless. Upon entering a string on the program. Coda Equivalence relations are so ubiquitous in mathematics and other fields that use mathematics because they enable the user to partition a set in a particular way of the user¶s design. if v is connected to w and w is connected to z. Consider the islands of vertices that are the equivalence classes. any vertex is connected to itself.
III. Finally. but there is no way for that point to move to another equivalence class since there is no path of edges to follow. then surely v is connected to z. Although it is foolish to rely on pictures in mathematics. Furthermore. the visual aspect of this example is edifying in another way. if v is connected to w. it will malfunction. then of course w is connected to v. a good picture is helpful. The reader should easily be able to intuit why all three properties of equivalence relation are necessary to ensure that equivalence classes partition a set.

IV. Algorithm Flowchart Screenshots
. V.has been clearly stated in the program that the programmers have given the users a limit of input choice that the screen resolution of Turbo C can handle. It has been maximized however up to the point that the table can be seen clearly. VI.

Source Code
/*START*/ #include<stdio. printf("\n"). } }while(numele<1 || numele>30). watchenter[w]=0.q<numele. do{ printf("\n\n\nEnter the number of elements you want to sort in partitions[1-30]: ").\n\n").w++) { sort[q][w]=0. for(w=0. printf("\nPlease follow given ranges and avoid character").VII. mod=0. ch.q++) { watch[q]=0. for(q=0. } } clrscr()."). if(numele<1 || numele>30) { printf("\nERROR! INVALID INPUT!\nTRY AGAIN. printf("Instructions:\n").h> int q. group=0. w=0. watchenter[15]. Thank you. numele. for(q=0. numele=0. group. &numele). printf("\ninput so as to avoid program malfunction.q++) {
.q<15. watchenterA. q=0. sort[15][30]. mod. set[w]=0. w.w<30. watchenterA=0. watch[15]. int set[30]. main(){ do{ ch=0. scanf("%i".

scanf("%i". watchenterA=0.
. if(set[q]<1) printf("\nERROR! INVALID INPUT!\nTRY AGAIN. for(q=0. set[q]). if(watchenter[q]>16) { printf("\n | "). } } printf("\n_____________________________________________________________________________ __\n"). }while(mod<2 || mod>15).q++) { printf("%i ".q<(mod). } printf("%i ".q<numele.q++) { group=set[q]-((set[q]/mod)*mod). if(mod<2 || mod>15) printf("\nERROR! INVALID INPUT!\nTRY AGAIN. } printf("_______________________________________________________________________________ \n").\n\n"). sort[group][q]=set[q].w++) { if(sort[q][w]>0) { watch[q]=watch[q]+1. q+1). }while(set[q]<1). watchenterA=watchenterA+1. q).w<30. watchenter[q]=watchenter[q]+1. printf("\n"). &mod).q++) { if(q<10) printf(" %i | ". for(q=0. printf("-------------------------------------------------------------------------------\n").\n\n"). printf("Your modulus: %i\n". scanf("%i". printf(" remainder | elements\n"). } do{ printf("\nEnter your modulus[2-15]: "). if(watchenterA>15) {printf("\n "). } } if(watch[q]==0) printf(" *no elements sorted*"). if(q>9) printf(" %i | ". &ch).q<numele. q). do{ printf("RETRY PROGRAM?\n[PRESS 1 to try again] [PRESS 0 to end program]"). scanf("%i".do{ printf("Input element number %i: ". printf("\nChoice: "). } clrscr(). for(q=0. mod). for(w=0. watchenter[q]=0. printf("Your elements: "). &set[q]). sort[q][w]).

return(0). else if(ch==0) {printf("\n\n THANK YOU! :)").com/EquivalenceRelation.html
.edu/~toida/nerzic/levela/relation/eq_relation/eq_relation.org/encyclopedia/Equivalence_Relation http://mathworld.iscid. References
http://www.wolfram. }while(ch==1).odu.if(ch!=1 && ch!=0) printf("\nERROR! INVALID INPUT!\nTRY AGAIN. sleep(1).html http://www.cs. } /*END*/
VIII. } }while(ch!=1 && ch!=0).\n\n").