Anda di halaman 1dari 12

Lecture 7: Relational calculus

Bakhadyr Khoussainov
Computer Science Department, The University of Auckland, New Zealand bmk@cs.auckland.ac.nz

Relations and databases

In this section we establish a simple connection between relational databases and relations. We discuss a toy example of a database that contains information about the employees of a small software company. The company contains ten people. The database provides some information about these people and this information is presented using several tables (See the next two pages). We now describe these tables in detail. The table N ames associates employee IDs with the names of the people working for the company. The next two tables Gender1 and Gender2 specify the genders of the employees. The table DirectlyReports contains information about how reporting is done in the company. According to the DirectlyReports table if a row is (X, Y ) then this means that Y reports to X. For example, the people with IDs 01, 02 and 03 directly report to the person with ID 00. Finally, there are two other tables. One table is named BankAccounts and the other is named BirthDates. The BankAccounts table contains information about the banks, employee IDs and their corresponding account numbers. The BirthDates table contains the birth dates of the employees. Each of these tables consists of columns and rows. Each column has its name. For example, BirthDates table has four columns named and listed as follows: ID, Year, M onth, Day. These names of columns are called the attributes of the table. For example, Gender1 table has one attribute, BankAccounts table has three attributes, and DirectlyReports table has two attributes. Thus, our example of a database has six tables. The underlying set, called the domain of the database, is the collection of all entries of the tables. Thus, the domain D of our database consists of the names of people, their IDs, account numbers, the names of banks, birth dates, and months names. Each table T of the database describes a relationship between elements of the domain. Each row in table T describes a fact. For example the row (00, 1960, January, 30) in BirthDates table tells us that Elaine Aziz is born on January 30 in 1960. Consider the domain D of the database. Take a table T of the database. The most important part of T is its rows because they contain information. Each row is a tuple. No two rows in T are the same. Moreover, if we change the order of rows and have a new table T , then the tables T and T convey the same information. The order of the rows in the table therefore is not important. All the rows of T have the same length. This length is called the arity of T . The arity of the table T is thus the number of its attributes. For example, the arity of the table Gender1 is 1. The length of rows in the table DirectlyReports is 2. This table is of arity 2. The arity of the table Birthdates is 4, and of the table BankAccounts is 3.

ID 00 01 02 03 04 05 06 07 08 09

First Name Elaine Robert Andrei Michael Steven Nevil Ann Bruce Cynthia Marina

Last Name Aziz Simmons Goncharov Love Hosking Hosking Fong McDonald Roberts Mendes

Table 1. N ames table Female 00 06 08 09 Table 2. Gender1 table Male 01 02 03 04 05 07 Table 3. Gender2 table ID-1 00 00 00 01 02 02 03 03 08 ID-2 01 02 03 04 05 06 07 08 09

Table 4. DirectlyReports table

ID 00 01 02 03 04 05 06 07 08 09

Bank Name National Union National West-Union West-Uniion Westlake Bank Westlake Bank National National Westlake Bank

Account Number 712456001 713456501 712456001 512566001 712406006 212456708 415456051 912454087 032456548 945456100

Table 5. BankAccounts table

ID 00 01 02 03 04 05 06 07 08 09

Y ear 1960 1971 1974 1980 1964 1964 1968 1970 1981 1982

M onth January January March December August September September June June November

Day 30 10 11 22 23 30 1 15 3 16

Table 6. BirthDates table

Each table T is a set of tuples of the same length such that the components of the tuples are elements of the domain D. A table T of arity k can thus be identied with a subset of the set Dk , where Dk is the set of all k-tuples from D. Hence each table of arity k is a kplace relation on D. Gender1 and Gender2 are unary relations, DirectlyReports table is a binary relation, Birthdates table is a relation of arity 4, and BankAccounts table is a ternary relation on the set D. For example, Gender1 table is the following unary relation {00, 06, 08, 09}, and DirectlyReports table is the binary relation {(00, 01), (00, 02), (00, 03), (01, 04), (02, 05), (02, 06), (03, 07), (03, 08), (08, 09)}. Each relation on D can also be identied with a table. Indeed, if we are given a k-ary relation R on D, then R can be identied with a table in which each row has length k. A k-tuple (d1 , . . . , dk ) is a row of the table if and only if R is true on (d1 , . . . , dk ). We now give a precise mathematical denition to the concept of a database. Denition 1. A relational database is a tuple (A; R1 , . . . , Rn ), where 1. A is a nonempty set called the domain of the database, 2. All R1 , R2 , . . ., Rn are relations on the domain A called basic relations. In mathematics relational databases are usually called relational structures. We already have one example of a relational database explained above. It is worth noting now that any graph G = (V, E) can also be regarded as a relational database. Indeed, for a graph G = (V, E) we can treat the set V of vertices as the domain and the set E of edges as the binary relation represented as a table in which each row has length 2. We also note that our denition is such that the domain A of the database can be innite. We give another simple example that we will use in the next section of this lecture. Example 1. The relational database D = (D; R1 , R2 , U ) is dened as follows. The domain D is {0, 1, 2, 3, 4}. The binary relations R1 and R2 are {(0, 4), (4, 0), (0, 1), (0, 2), (0, 3), (4, 1), (4, 2), (4, 3)} and {(0, 1), (0, 2), (0, 3), (0, 4), (2, 3)}, respectively. The unary relation U is {0, 2, 4}. The reader can represent this relational database by writing down the tables for relations R1 , R2 , and U . Another nice representation is representing the relations R1 and R2 as directed graphs that we explained in the previous lecture.

The calculus of relations

The main purpose of this section is to explain general methods for building new relations from given ones. In particular, the methods applied to basic relations of a relational database produce other relations on the domain of the database. We use the relations dened in Example 1 to explain the methods. Assume that we are given a non-empty set A. The set A can be innite. We introduce the following operations on relations of the set A. These operations are called the rst order logic operations. One of the main applications of these operations is that they form the foundation of many (if not all) modern query languages such as SQL, Datalog, and XQuery.

The union operation. This operation takes as input two relations of the same arity and outputs their union. Formally, given two relations R1 and R2 both of arity k, their union is the relation R1 R2 . Thus, a tuple (a1 , . . . , ak ) belongs to R1 R2 if and only if either (a1 , . . . , ak ) R1 or (a1 , . . . , ak ) R2 . The union operation applied to relations R1 and R2 from Example 1 produces the following binary relation: R1 R2 = {(0, 4), (4, 0), (0, 1), (0, 2), (0, 3), (4, 1), (4, 2), (4, 3), (2, 3)}. The binary relation R1 R2 is thus true on all pairs (x, y) such that either R1 is true on (x, y) or R2 is true on (x, y). The intersection operation. This operation takes as input two relations of the same arity and outputs their intersection. Formally, given two relations R1 and R2 both of arity k, their intersection is the relation R1 R2 . Thus, a tuple (a1 , . . . , ak ) belongs to R1 R2 if and only if (a1 , . . . , ak ) R1 and (a1 , . . . , ak ) R2 . For instance, the intersection R1 R2 of R1 and R2 from Example 1 is the binary relation {(0, 1), (0, 2), (0, 3), (0, 4)}. The relation R1 R2 is thus true on all pairs (x, y) such that both R1 and R2 are true on (x, y). The complementation operation. This operation takes as input a relation and outputs its complement. Formally, given a relation R of arity k, its complement R is the relation Ak \ R. Thus, a tuple (a1 , . . . , ak ) belongs to R if and only if (a1 , . . . , ak ) R. In Example 1, the complement of U is the unary relation {1, 3}. Thus, U is true on x if and only U is false on x. The complement of R1 would be the binary relation R1 that is true on (x, y) if and only if R1 is false on (x, y). For example, R1 is true on pairs (1, 2) and (2, 2). The cylindrication operation. This operation takes as input a relation of arity k and outputs a relation of arity k + 1 as follows. Given a relation R of arity k, its cylindrication denoted by c(R), is the set {(a1 , . . . , ak , a) | (a1 , . . . , ak ) R and a A}. Note that the cylindrication operation increases the arity of an input relation by 1. For example the cylindrication c(U ) of U in Example 1 produces the binary relation: {(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)}. The cylindrications of R1 and R2 are ternary relations. The cylindrication of U is c(U ) = {(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4)}. The existentiation operation. This operation takes as input a relation R of arity k. Fix an i such that 1 i k. If k = 1 then this operation outputs the value T rue or the value F alse as follows. If R = then the output is T rue, and otherwise the output is F alse. Now assume that k > 1. Dene the following (k 1)-place relation, denoted by xi R, called an existentiation of R: {(a1 , . . . , ai1 , ai+1 , . . . , ak ) | there is an a A such that (a1 , . . . , ai1 , a, ai+1 , . . . , ak ) R}. Thus, for the relation xi R to be true on (b1 , . . . , bk1 ) it must be the case that the relation R is true on (b1 , . . . , bi1 , a, bi , . . . , bk1 ) for some a A.

Consider Example 1. Then both x1 U and x1 U have values T rue. For relation R1 we have the following: x1 R1 = {0, 1, 2, 3, 4} and x2 R1 = {0, 4}. For relation R2 we have the following: x1 R2 = {0, 1, 2, 3, 4} and x2 R2 = {0, 2}. These are now unary relations. The existentiation operation is essentially a search operation. Indeed, let us assume that we are given a binary relation R on the set N of all natural numbers. Consider the unary relation x1 R. Say we want to see if a natural number n is in x1 R. Algorithmically this can be explained as follows. Consider the following instructions: 1. 2. 3. 4. On input n N do the following: Initialize an integer variable i to 0. If (i, n) R then output n. Increment i, and repeat line 3).

Thus, if n is in x1 R then by the denition there exists an m such that (m, n) R. Hence, the instructions above output n for some i m. The converse is also true: if the above instructions output n then this means that a value of i is found such that (i, n) R. The value of i for which (i, n) R is usually referred to as a witness for n to be in x1 R. Thus, the instructions above search for a witness i to be found such that (i, n) R. If n is not in x1 R then the instructions above run forever searching for a witness. Another way to think about the existential operation is this. Assume that the k-place relation R is represented as table T (in which each row has length k and k > 1). Consider the following new table obtained by the rules below: Contracting: Remove the ith column from the table T . Let T1 be the new table. Cleaning: For every row j of T1 remove the row if the raw is identical to some row above it. Output the resulting table T2 . The table T2 represents the relation xi R. The introduced operations can be used to build new relations from given once. For instance, for relations R1 and R2 from Example 1, we can build the following new relations (and hence new tables for our database): R1 R2 , R1 R2 , x1 R1 , x2 R1 , c(R1 R2 ), etc. The -operation. This operation takes as input a relation R of arity k. Fix an i such that 1 i k. If k = 1 then this operation outputs the value T rue or the value F alse as follows. If R = A then the output is T rue, and otherwise the output is F alse. Now assume that k > 1. Dene the relation xi R of arity k 1 as follows {(a1 , . . . , ai1 , ai+1 , . . . , ak ) | for all a A we have (a1 , . . . , ai1 , a, ai+1 , . . . , ak ) R}. Thus, for the relation xi R to be true on (b1 , . . . , bk1 ) it must be the case that the relation R is true on (b1 , . . . , bi1 , a, bi , . . . , bk1 ) for all a A. Consider Example 1. Then both x1 U and x1 U have values F alse. Also, note that x1 (U ) has value T rue. For relation R1 we have the following: x1 R1 = and x2 R1 = . Also, U x2 ({(x1 , x2 ) | x1 = x2 } R1 ) = {0, 4}. For relation R2 we have the following: x1 R2 = and x2 ({(x1 , x2 ) | x1 = x2 } R2 ) = {0}. These are now unary relations.

The instantiation operation. This operation takes as input a relation R of arity k. Fix an i such that 1 i k, and choose an element a A. If k = 1 then this operation outputs the value T rue or the value F alse as follows. If R is true on a then the output is T rue, and otherwise the output is F alse. Now assume that k > 1. Dene the relation Inst(R, a, i) of arity k 1 as follows {(a1 , . . . , ai1 , ai+1 , . . . , ak ) | (a1 , . . . , ai1 , a, ai+1 , . . . , ak ) R}. For instance, for relations R1 and R2 in Example 1 we have Inst(R1 , 0, 1) = {1, 2, 3, 4} and Inst(R2 , 2, 1) = {3}. The rearrangement operation. We need a simple concept of a permutation. A permutation of the set {1, . . . , k} is any sequence i1 , i2 , . . . , ik of length k such that every number from the set {1, . . . , k} occurs in the sequence. For example, there are 6 permutations of the set {1, 2, 3} which are 1, 2, 3; 1, 3, 2; 2, 1, 3; 2, 3, 1; 3, 1, 2; and 3, 2, 1. It can be proved that the number of permutations of the set {1, . . . , k} is k!. This will be explained in the lectures on induction. The rearrangement operation takes as input a relation of arity k, rearranges its coordinates, and outputs the resulting relation. A formal denition is this. Let R be a relation of arity k. Let us x a permutation i1 , i2 , . . . , ik of set {1, 2, . . . , k}. Denote this permutation by . Then (R) is the relation dened as follows: (R) = {(a1 , . . . , ak ) | (ai1 , ai2 , . . . , aik ) R}. The relation (R) is called a rearrangement of R according to . For example, consider R2 in Example 1. For the permutation = 2, 1 we have (R2 ) = {(1, 0), (2, 0), (3, 0), (4, 0), (3, 2)}. The linkage operation. Suppose we are given two relations R1 and R2 of arity s and t, respectively. Let us take a number p 0 such that p s and p t. Dene the following new relation Linkp (R1 , R2 ) of arity s + t p. Put a tuple (a1 , . . . , asp , asp+1 , . . . , as , as+1 , . . . , as+tp ) into Linkp (R1 , R2 ) if and only if (a1 , . . . , as ) R1 and (asp+1 , . . . , ap , ap+1 , . . . , as+tp ) R2 . Note that in the tuple (a1 , . . . , asp , asp+1 , . . . , as , as+1 , . . . , as+tp ) above, the length of the tuples (a1 , . . . , asp ), (asp+1 , . . . , as ), and (as+1 , . . . , as+tp ) are sp, p, and tp, respectively. So, the total length of the tuple is s + t p. To explain this operations, represent R1 and R2 as tables. Roughly speaking Linp (R1 , R2 ) is a table obtained by merging the tables for R1 and R2 on the last p columns of R1 and the rst p columns of R2 . More formally, we create new table that links the tables for R1 and R2 as follows. Take a row (a1 , . . . , asp , asp+1 , . . . , as ) in the rst table. If there is a row (b1 , . . . , bp , . . . , bt ) in the second table such that (b1 , . . . , bp ) = (asp+1 , . . . , as ) then the tuple (a1 , . . . , as , bp+1 , . . . , bt ) is a row of the new table. Note that when p = 0, then Linp (R1 , R2 ) becomes the Cartesian product of sets R1 and R2 . For example, consider the relations R1 and R2 in Example 1. Let p = 1. Then Link1 (R1 , R2 ) is the following ternary relation {(4, 0, 1), (4, 0, 2), (4, 0, 3), (4, 0, 4), (0, 2, 3), (4, 2, 3)}. We can also link R1 with U when p = 1. In this case, Link1 (R1 , U ) = {(0, 4), (4, 0), (0, 2), (4, 2)}.

Equivalence relations

Equivalence relations are special types of binary relations on a given set. These relations often appear in many computer science and mathematics applications, especially when one tries to nd similarities between objects of study. In this part of the lecture we use the concepts introduced in the last two sections (Sections 6 and 7) of the previous lecture. Here is our denition. Denition 2. A binary relation E on a set A is an equivalence relation if E is reexive, symmetric, and transitive. For an equivalence relation E, if we have (x, y) E then we say that x and y are equivalent (or E-equivalent). Thus, in order to determine whether a given relation E is an equivalence relation one needs to prove the following. For all x A, the pair (x, x) is in E; for all x, y A if (x, y) E then it is the case that (y, x) E; and nally, for all x, y, z A, if both (x, y) and (y, z) are in E then (x, z) E. From the previous lectures we already know that the mod(p) relation on integers and the connectedness relation on graphs are examples of equivalence relations (see the second paragraph after Denition 3 in Lecture 2 and Theorems 1 and 2 in Lecture 3). Let A be a set and E be an equivalence relation on A. For each element a A, dene the following set denoted by [a]: [a] = {x | x A and (x, a) E}. The set [a] is called the equivalence class of a. As an example, consider the relation mod(p) on integers. Fix an integer n. The equivalence class of n is the set [n] = {m | m Z and (n, m) mod(p)}. We know from Lecture 2 that [n] consists of all integers m such that when divided by p the integers n and m have the same remainder. Therefore the equivalence classes of the mod(p) relation are the congruence classes . . ., p 1. 0, 1, As another example, consider the connectedness relation Connect(G) on a (undirected) graph G = (V, E). Fix a vertex v. The equivalence class of v is the set [n] = {u | u V and (v, u) Connects(G)}. We know from Lecture 3 that [v] consists of all vertexes u such that there is a path from v to u. Hence, the equivalence classes of the Connect(G) relation are the components of the graph G. There are two important properties of equivalence relations. We discuss them below. Property 1. If E is an equivalence relation on A then every element of the set A belongs to some equivalence class. To prove the property, indeed, take an element a A. Clearly, (a, a) E by reexivity of E. By the denition of the equivalence class [a], the element a belongs to [a]. Hence a belongs to its own equivalence class [a].

Property 2. Let E be an equivalence relation on A. If [a] and [b] are two equivalence classes, then either [a] [b] = or [a] = [b]. To prove the property we assume that the equivalence classes [a] and [b] have an element c in common (if these two classes have no elements in common then the property is true). This means that (a, c) E and (b, c) E. Hence, since E is transitive and symmetric, all elements x of the class [a] are equivalent to b, and thus belong to [b]. Similarly, all elements of the class [b] are equivalent to a, and hence belong to [a]. Therefore [a] = [b]. Example 2. On the set Z of integers consider the following relation E = {(x, y) | x y > 0 or x = y = 0}. This is an equivalence relation. Its equivalence classes are [1] = {x Z | x > 0}, [1] = {m Z | m < 0}, and [0] = {0}. Example 3. On the set Z of integers consider the following relation E = {(x, y) | |x| = |y|}, where |n| denotes the absolute value of n. This is an equivalence relation. Its equivalence classes are of the form {n, n}, where n Z. Note that the equivalence class of 0 is the set {0}. The above two properties show that every equivalence relation E on set A determines a collection of subsets that partition the set A. These subsets are the equivalence classes and satisfy the following two properties. The rst one is that every element of the underlying set A belongs to one of the subsets. The second one is that any two of the subsets are either equal or have no elements in common. We can single out these properties into the following denition. Denition 3. Let A be a set. A collection of non-empty subsets {A1 , A2 , A3 , . . .} of A is called a partition of A if the following two properties hold true: 1. A = A1 A2 A3 . . .. 2. For all distinct i and j we have Ai Aj = . We claim that we can build an equivalence relation naturally associated with a given partition of the set A. Indeed, let A1 , A2 , A3 , . . . be a collection of subsets of A that form a partition of A. Our goal is to build an equivalence relation such that the equivalence classes of the relation coincide with the partition {A1 , A2 , A3 , . . .}. Dene the following equivalence relation E based on this partition: {(x, y) | there is a j such that x, y Aj }. The relation E is an equivalence relation. It is reexive because for every x there is an i such that x Ai . Hence (x, x) Ai . The relation E is symmetric because if x, y Aj for some j then y, x Aj . Transitivity of E is obvious as well. For a nal note, let us now take an equivalence class [a] determined by the equivalence relation dened. It is easy to see that [a] coincides with the set Ai (in the partition given) which contains the element a. Similarly, every Ai coincides with the equivalence class [a] such that a Ai . Hence, we have established a natural correspondence between partitions of the set A and equivalence relations on A. Example 4. Consider the following partition of Z: {0}, {1, 1}, {2, 2}, {3, 3}, . . .. The equivalence relation E associated with this partitions is {(x, y) | x, y Z and |x| = |y|}.

Partial orders

Another class of binary relations that often occur in computer science, mathematics, and their applications is the class of partial orders. As for an equivalence relations, the denition of a partial order is quite simple: Denition 4. A binary relation E on set A is called a partial order on A if E is reexive, antisymmetric, and transitive. There are many natural examples of partial orders. Immediate ones are the natural order on the set Z of integers Z = {(x, y) | x y and x, y Z}, and the natural order on the set Q of rational numbers Q = {(x, y) | x y and x, y Q}. Here is another example. Consider the set A of all binary strings over the alphabet {0, 1} (see the denition of string in Lecture 1). We say that a string x is a prex of a string y if y = xv for some string v. For example, strings 0, 01, 011, 0110 are prexes of the string 011011. Consider the relation {(x, y) | x, y are binary strings and x is a prex of y}. This relation is a partial order on the set A. Indeed, it is reexive because every string x is a prex of itself. It is antisymmetric because if x is a prex of y and y is a prex of x then x = y. Finally, it is transitive because if x is a prex of y and y is a prex of z then x is clearly a prex of z. On the set N , consider the following binary relation R. A pair (x, y) is in R if and only if either x is odd and y is even or x and y have the same parity and x y. Clearly, (x, x) R by the denition of R. Let us prove that R is a transitive relation. Assume that (x, y) R and (y, z) R. There are three cases to consider. The rst case is when x is even. In this case y must be even, and hence z is even. Therefore, from the denition of R we have x y and y z, and hence (x, z) R. The second case is when z is odd. In this case y is odd, and hence x is odd. Therefore, from the denition of R we have x y and y z, and hence (x, z) R. The last case is when x is odd and z is even. Then (no matter what y is) the denition of R tells us that (x, z) R. This proves that R is transitive. It is not hard to check that R is antisymmetric. Thus, R is a partial order on N . Intuitively R orders N as follows. All even numbers are greater than odd numbers, and the natural order on even numbers and odd numbers is preserved. A set A together with a given partial order on it is called a partially ordered set. Thus, we can write a partially ordered set as a pair (A, ), where is a partial order on A. This is similar with our notation (V, E) for graphs, where by changing E one changes the graph. In the same manner, in the partially ordered set (A, ), we change the partially ordered set by changing the partial order . The partial order here is denoted by to be consistent with our notation of the order of integers and rational numbers. We could easily denote the partial order by some other symbol like R or S or . There are a couple of fundamental notions for partially ordered sets which we explain here. Say we are given a partially ordered set (A, ). An element a is called the greatest element if x a for all x A. For example, on the set of all negative integers 1 is the greatest element. An element a is called a maximal element if there is no x A such that a x and a = x. The following is easy to prove.

Proposition 1. If (A, ) has the greatest element then the greatest element is maximal. Moreover, in this case the maximal element is unique. Proof. Indeed, let a be the greatest element. Assume an element x is such that a x. Since a is the greatest, it must be the case that x a. Hence, by antisymmetry, we have a = x. Now, let b1 and b2 be two maximal elements in the partial order. Then, by the denition no element x exists such that x = b1 and b1 x. However, a is the greatest element. Therefore b1 a. Hence b1 = a. Similarly, b2 = a. Thus, b1 = b2 . This nishes the proof. Trees, introduced in Lecture 5, can also be considered as partially ordered sets. Indeed, let T be a tree. On the set of nodes introduce the following relation {(x, y) | y is an ancestor of x}. This relation is a partial order on the set of nodes. Note that the leafs of the tree are the maximal elements of the partial order.

Exercises

1. Consider the database described in the rst section. Write down the relations and their arities that are represented by the tables N ames, Gender2, and BankAccounts. 2. Consider the graph G representing a binary relation R. How do we change G to represent the relation R? 3. Let R be a k-pace relation with k > 1. Let i be such that 1 i k. Prove that that xi R = xi R. 4. Let R be a k-pace relation. Prove that that xk+1 c(R) = R. 5. Consider the following relational database (D; S, Add, M ult, Div, ), where The domain D is {0, 1, 2, 3, 4}. The successor relation: S = {(x, y) | y = x + 1 and x D}. The addition relation: Add = {(x, y, z) | x + y = z and x, y, z D}. The multiplication relation: M ult = {(x, y, z) | x y = z and x, y, z D}. The divisibility relation: Div = {(x, y, z) | x/y = z and x, y, z, D}. The order relation: = {(x, y) | x y and x, y D}. Do the following: (a) Write down the tables for S, Add, M ult, and Div. (b) Write down the following relations Add M ult, S, x1 S, x2 S, x1 M ult, Inst( , 2, 1), Inst(M ult, 1, 1). (c) Write down the following relations Link1 (S, S), Link1 (Add, S), Link2 (Add, M ult). (d) Write down the following relations x3 Add, x3 M ult, x2 x3 Add, x2 x3 M ult. 6. Consider the set A consisting of all soccer players of a city. Assume no player belong to two distinct teams. Consider the relation E = {(x, y) | x and y are in the same team }. Prove that E is an equivalence relation. What are the equivalence classes of E? 7. List all the equivalence relations on set A = {x, y, z}. With each equivalence relation list all of its equivalence classes. 8. Consider the set N . On the set P (N ) of all subsets of N dene the following relation E: {(X, Y ) | (X \ Y ) (Y \ X) is a nite set}. Show that E is an equivalence relation on P (N ). Describe equivalence classes of E.

9. Prove that if E1 and E2 are equivalence relations on A then so is E1 E2 . Is E1 E2 always an equivalence relation? 10. List all partial orders on the set {a, b, c}. 11. Consider the relation R = {(x, y) | x, y are positive natural numbers and x is a factor of y} on the set of all positive integers. Is it a partial order? 12. Consider the power set P (A). Prove that the relation on P (A) is a partial order. 13. Dene the least and minimal elements in a partially ordered set (This should be similar to the denitions of the greatest and the minimal elements). 14. Consider the following set A = {2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15}. On this set consider the relation R = {(x, y) | x divides y}. Prove that (A, R) is a partially ordered set. List all maximal and minimal elements of this partially ordered set. 15. On the set N consider the following binary relation R = {(x, y) | there is a natural number n such that y = 2n x}. Prove that this is a partial order of N . What are the minimal elements of the partially ordered set (N, R)?

Anda mungkin juga menyukai