1 / 17

Reminders: Test3 is scheduled for Friday, April 25

Reminders: Test3 is scheduled for Friday, April 25 Email was sent that included a proposed schedule HW 8 is due Wednesday, April 9 in class Pascal’s Office Hours are cancelled (semester) Me: M,T 3:30-5pm & W 3:30-4:30pm - Ols 228D Emmanuel: R 7-8pm & F 3-4pm – Ols 011 (  25 th )

howell
Download Presentation

Reminders: Test3 is scheduled for Friday, April 25

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reminders: • Test3 is scheduled for Friday, April 25 • Email was sent that included a proposed schedule • HW 8 is due Wednesday, April 9 in class • Pascal’s Office Hours are cancelled (semester) • Me: M,T 3:30-5pm & W 3:30-4:30pm - Ols 228D • Emmanuel: R 7-8pm & F 3-4pm – Ols 011 (25th) • Return Test 2: • Avg: 70, Median: 74 • http://www.cs.virginia.edu/~cmt5n/cs202/test2/test2key.doc • < 50 scores are headed in the direction of failing • Be sure to review material that gave you trouble • Lower right hand corner has current letter grade

  2. Section 7.1: Relations and Their Properties Def: Let A and B be sets. A binary relation from A to B is a subset of AB. Remark: Note that this definition is identical to the definition of a map from A to B. Hence a binary relation from A to B is the same as a map from A to B. Ex: Let A = {a, b, c} and B = {1, 2, 3}. Then AB = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3), (c, 1), (c, 2), (c, 3)}. So, in particular, {(a, 3), (c, 1), (c, 2), (c, 3)} is a binary relation from A to B. We say that “a is related to 3” or “a R 3” since (a, 3)  R.

  3. Ex: Let A be the set of all cities in the world and B be the set of the 50 states in the USA. Define the relation R by R = {(a, b) | city a is in state b}. Then (Charlottesville, Virginia), (Portland, Oregon), and (New York, New York) are all members of R. (Charlottesville, Utah) is not a member of R. Note that some cities such as Reykjavik, which is the capital of Iceland, won’t appear as the first member of any pair in R even though Reykjavik is in the set A. This is because Reykjavik is not a city in any of the 50 states of the USA. Further note that (Richmond, Virginia) and (Richmond, Ohio) are both members of R. Strictly speaking, even though the two cities are labeled with the same name, they are different cities. [Such inconsistencies are why I usually stay away from RWE.

  4. Relations on a Set Terminology: Let A be a set. Then we can form a binary relation from A to A. Instead of calling such a relation “a binary relation from A to A” we instead say that R is a “relation on A”. Ex: Let A = {1, 2, 3, 4} and define R = {(a, b) | a divides b}. Then R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}. Ex: If A is a finite set with |A| = n, how many different relations are there on A? Since a relation on A is simply a subset of AA, then we are really asking “how many subsets are there of AA” or |P(AA)|? Well |AA| = n*n = n2 so |P(AA)| = 2|AA| = 2n2.

  5. Properties of Relations on a Set Def: A relation R on a set A is called reflexive if (a, a)  R for every element a  A. Ex: Let A = {1, 2, 3, 4} and define R = {(a, b) | a divides b}. We saw that R was reflexive since every number divides itself. In fact we could let A = Z+ and define R the same way and R would be reflexive. However this is a different relation than the previous relation. Indeed, this relation has infinite cardinality! Ex: Let A = {x, y, z} and R = {(x, x), (x, y), (y, y), (z, y)}. This relation is not reflexive since (z, z)  R. Ex: Let A be a set. Then R =  is a relation on A called the empty relation. The empty relation is only reflexive when A = .

  6. Def: A relation R on a set A is called symmetric if (b, a)  R whenever (a, b)  R. Ex: Let A = {1, 2, 3, 4} and define R = {(a, b) | a divides b}. R is not symmetric. For example, (1, 2)  R but (2, 1)  R. Ex: Let A = {w, x, y, z} and R = {(w, x), (x, w), (y, y), (y, z), (z, y)} This relation is symmetric. It satisfies the above criterion. Note that symmetry is a different kind of requirement than reflexivity. Reflexivity requires that certain pairs must be in R, namely all pairs of the form (a, a) for every element in A. However symmetry only requires that if a pair (a, b) is in R, then the pair (b, a) must also be in R. But it is not required that pairs of the form (a, b) are in R unless the pair (b, a) is in R. Simply stated, you must have both pairs or neither. Ex: The empty relation is always symmetric regardless of A.

  7. Def: A relation R on a set A is called antisymmetric if whenever (b, a)  R and (a, b)  R then a = b. Ex: Let A = {1, 2, 3, 4} and define R = {(a, b) | a divides b}. R is antisymmetric because the only way that it is possible that both a divides b and b divides a is if they are the same number. Ex: Let A = Z and define R = {(a, b) | a divides b}. R is not antisymmetric because 1 divides -1 and -1 divides 1 but 1  -1. Note that antisymmetry and symmetry are not opposites. It is possible for a relation to possess both properties (such as the empty relation), neither property (such as {(1, 2), (2, 1), (1, 3)} over {1, 2, 3}), or to have either one of the properties but not the other.

  8. Def: A relation R on a set A is called irreflexive if for every a  A (a, a)  R. That is, no element is related to itself. Ex: Let A = {1, 2, 3, 4} and define R = {(a, b) | a divides b}. R not irreflexive because 1 divides 1 for example. Ex: Let A = Z and define R = {(a, b) | a > b}. R is irreflexive because no integer is greater than itself. Note that irreflexivity and reflexivity are not opposites. It is possible for a relation to possess neither property (if some elements of A are related to themselves but others are not). However, it is not possible for a relation to possess both properties (unless the relation is on the empty set). Def: A relation R on a set A is called asymmetric if it is both antisymmetric and irreflexive. That is, the relation can not have both (a, b) and (b, a) even if a = b.

  9. Def: A relation R on a set A is called transitive if whenever (a, b) is in R and (b, c) is in R, then (a, c) is in R. Ex: Let A = Z+ and define R = {(a, b) | a divides b}. R is transitive because if a | b and b | c then a | c. [Theorem] Ex: Let A = Z and define R = {(a, b) | a > b}. R is transitive because if a > b and b > c then a > c. Note that transitivity, like symmetry, is possessed by a relation unless the stated condition is violated. So unless you can find pairs (a, b) and (b, c) which are in R while (a, c) is not, then the relation is transitive. In particular, the empty relation is always transitive because it has no pairs to violate the condition. Ex: How many reflexive relations are there on a finite set A? We are forced to include all pairs of the form (a, a). This leaves n(n – 1) pairs which may or may not be in a reflexive relation. So there are 2n(n – 1) reflexive relations on a set of size n.

  10. Anthology of Relations on a Finite Set Ex: A = . Then AA = . So there is only one relation on the empty set, namely the empty relation R = . [Properties?] Reflexive Symmetric Asymmetric Irreflexive Antisymmetric Transitive Ex: A = {1}. Then AA = {(1, 1)}. First, R = . [Properties?] Not Reflexive Symmetric Asymmetric Irreflexive Antisymmetric Transitive Ex: A = {1}. Then AA = {(1, 1)}. Now, R = {(1, 1)}. [Props?] Reflexive Symmetric Not Asymmetric Not Irreflexive Antisymmetric Transitive

  11. Combining Relations If we have two relations R and S from A to B then they are both subsets of AB so they can be combined in the same way that sets can via union, intersection, difference, etc. Ex: Let A and B both be the set of real numbers and consider R = {(x, y) | x < y} and S = {(x, y) | x > y}. Then R  S = {(x, y) | x < y or x > y} = {(x, y) | x  y} R  S = {(x, y) | x < y and x > y} =  R – S = R (since R and S are disjoint). We also have another natural way to combine two relations which corresponds to our notion of composition when dealing with functions. It is called composition of relations.

  12. Def: Let R be a relation from A to B and S be a relation from B to C. The composite of R and S is the relation consisting of ordered pairs (a, c), where a  A, c  C, and for which there exists an element b  B such that (a, b)  R and (b, c)  S. The composite of R and S is denoted SR. [Note the order]. Remark: We gave the general definition above, but we will be most concerned with the situation where A = B = C. That is where we are composing two relations over the same set A. Ex: Let A = {0, 1, 2, 3, 4} and consider the relations R and S over A where R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} and S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)}. What is SR? SR = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)}. RS = {(3, 1), (3, 4), (3, 3), (4, 1), (4, 4)}. Note that clearly RS  SR. The composite is not commutative.

  13. Ex: If we have a relation R over a set A, we can compose R with itself using the general definition. So RR contains all pairs (a, c) where a  A, c  A, and there exists some b  A such that (a, b)  R and (b, c)  R. The composure of R with itself is denoted R2. Remark: Note that we can only compose a relation with itself if it is a relation over a set. We can’t compose a relation with itself if it is a general relation from A to B with A  B. Ex: Let A = {0, 1, 2, 3, 4} and consider the relations R where R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)}. What is RR? RR = {(1, 1), (1, 4), (2, 1), (2, 4), (3, 1), (3, 4)}. As you can see R is not necessarily a subset of R2. Note that we could continue this process indefinitely. That is we might ask what is RR2? This we denote as R3.

  14. Def: Let R be a relation on the set A. The powers Rn of R are defined recursively as: R1 = R Rn + 1 = RnR Ex: Let A = {1, 2, 3, 4} and R = {(1, 1), (2, 1), (3, 2), (4, 3)}. R2 = RR = {(1, 1), (2, 1), (3, 1), (4, 2)}. R3 = R2R = {(1, 1), (2, 1), (3, 1), (4, 1)}. R4 = R3R = {(1, 1), (2, 1), (3, 1), (4, 1)}. It turns out that Rn = R3 for all n > 2. The powers of R have a special relationship to the property of transitivity. This is stated as a theorem: Theorem: The relation R on a set A is transitive if and only if Rn  R for all n  Z+.

  15. Proof: As an “if and only if” theorem we need to prove the implication in both directions. We first prove: If Rn  R for all n  Z+ then R is transitive. So assume Rn  R for all n  Z+. Then in particular, R2  R. Now we want to show that R is transitive. So let a, b, c  A such that (a, b)  R and (b, c)  R. We need to show that (a, c)  R. But since (a, b)  R and (b, c)  R then (a, c)  R2 by the definition of composite. Since R2  R then (a, c)  R2 implies that (a, c)  R. So R is transitive. Now we show that if R is transitive then Rn  R for all n  Z+. So assume R is transitive. Let P(n) be Rn  R. We use M.I. Base: P(1) means R1  R. That is R  R which is true. Ind: Let k  Z+ and assume P(k). That is Rk  R. Now we must show Rk + 1  R. So let (a, b)  Rk + 1. Then there is some x  A such that (a, x)  R and (x, b)  Rk. So (x, b)  R since Rk  R. But since R is transitive then (a, b)  R. So Rk + 1  R.

  16. We will not cover section 7.2 because it is more appropriate to a class on Databases. One thing that is important in section 7.2 is simply the fact that the concept of a relation can be extended beyond binary relations to represent a relationship on n sets. Def: Let A1, A2, …, An be sets. An n-ary relation on these sets is a subset of A1A2…An. N-ary relations and their properties are used as the basis for what are called Relational Databases. Ex: The school keeps databases relating each student with his/her SSN, major, GPA, etc. Such a database kept in a relational database structure would include n-tuples like (Johnathan Jones, 111-11-1111, Anthropology, 2.54, … )

More Related