# Lecture 12 Relations

Document Sample

```					Lecture 12 Relations

June 30th , 2003
Introduction
In the future computer science study, you
will use relations in database such as E-R
model, operations in relational database.
In graphics, you will use some matrix
theory.
In numerical computation, you are going to
see a whole lot of matrix operation.
Relations
Binary Relations

• Relationship between pairs of elements within a
set.
• Distinguish certain ordered pairs of objects from
other ordered pairs because the components of
the distinguished pairs satisfy some relationship
that the components of the other pairs do not.
The notation x  y indicates that the ordered pair (x,y)
satisfies a relation . The relation  may be defined in
words or simply by listing the ordered of pairs that
satisfy .

Example

Let S= {1,2,4}.
Consider the Cartesian product of S.
A relation  can be defined by x  y iif x=y/2,
abbreviated x  y  x = y/2.
(1,2) and (2,4) satisfy .
Alternative,  could be defined by saying that
{(1,2),(2,4)} is the set of ordered pairs satisfying .
• One way to define the binary relation 
is to specify a subset of S  S.

Definition:

Given a set S, a binary relation on a set S
is a subset of S  S (a set of ordered pairs
of elements of S).

x  y  (x,y)  
more general …
Definition:

Given two sets S and T, a binary relation from S to
T is a subset of S  T.
Given n sets S1, S2, …, Sn, n>2, an n-ary relation
on S1  S2  …  Sn is a subset
of S1  S2  …  Sn.
Examples
• Let S = {1, 2, 3} and T = {2, 4, 7}. Then the set
{ (1,2), (2,4), (2,7)} consists of elements from S  T. It is
a binary relation from S to T.
• Let S = {1,2,3} and consider S  S = S2.
S2={(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)}
Now let’s define a binary relation  given by:
x  y  x is odd
then  consists of the following pairs:
{(1,1),(1,2),(1,3),(3,1),(3,2),(3,3)}
Types of binary relations

• one-to-one
Each first component and each second component
appears only once in the relation.

S
T
• one-to-many
Some first component S1 appears more than once;
that is, one S1, is paired with more than one second
component.

S                                       T
• many-to-one
Some second component S2 appears more than
once; that is, one S2, is paired with more than one
first component.

S
T
• many-to-many
At least one first component S1 is paired with more
than one second component, and at least one
second component S2 is paired with more than one
first component.

S                                       T
If we have two binary relations, we can perform set
operations (union, intersection, and complement) that
results in new binary relations.

• x (  s) y  x  y or x s y
• x (  s) y  x  y and x s y
• x (’) y  not x  y

The basic set identities are also true in this context:
(Page 250)
• Associative properties
• Commutative properties
• Distributive properties
• Identity
• Complement properties
Properties of Relations
Let  be a binary relation on a set S. Then:

 is reflexive means (x)(x  S (x,x)  )
•  is symmetric means
(x)(y)(x  S  y  S  (x,y)    (y,x)  )
•  is transitive means
(x)(y)(z)(xS  yS  zS  (x,y)    (y,z)    (x,z)  )
•  is antisymmetric means
(x)(y)(xS  yS  (x,y)  (y,x)  x=y)
Example:
Consider the relation  on the set N.
• This relation is reflexive because for any
nonnegative integer x, x  x.
• It is also transitive because for any
nonnegative integers x,y, and z, if x  y and y 
z, then x  z.
• The relation is not symmetric; 3  4 does not
imply 4  3.
• The relation is antisymmetric since for any
nonnegative integers x, and y, if both x  y and
y  x, then y = x.
The equality relation on a set S is both
symmetric and antisymmetric.
The equality relation on S (or a subset of this
relation) is the only relation having both these
properties.
Suppose  is a symmetric and antisymmetric
relation on S, and let (x,y)  .
By symmetry, it follows that (y,x)  . But by
antisymmetry, x=y. Thus, only equal elements
can be related.
Closures of Relations

A binary relation * on a set S is the closure of
a relation  on S with respect to property P if:

1. * has property P
2.   *
3. * is a subset of any other relation on S that
includes  and has property P.

If a relation already has a property, it is its own
closure with respect to that property.
We can not extend the relation in order to find
its antisymmetric closure.

Example:
Find the reflexive, symmetric, and transitive
closure of the relation:
{(a,a),(b,b),(c,c),(a,c),(a,d),(b,d),(c,a),(d,a)}

Reflexive: (d,d)
Symmetric: (d,b)
Transitive: (b,a),(d,d),(d,c),(b,c),(c,d)
Partial Orderings
A binary relation on a set S that is reflexive,
antisymmetric, and transitive is called a partial
ordering on S.

If  is a partial ordering on S, then the ordered pair
(S,) is called a partially ordered set (aka poset).
• Let (S,) be a partially ordered set, and let AS. Then
 is a set of ordered pairs of elements of S, some of
which may be ordered pairs of elements of A.
If we select from  the ordered pairs of elements of A,
this new set is called the restriction of  to A and is a
partial ordering on A.

• Let (S,) be a partially ordered set. If x y, then either
x=y or xy. If x y but xy, we write x y and say that x
is a predecessor of y or y is a successor of x.

• A given y may have many predecessors, but if x y
and there is no x with x z y, then x is an immediate
predecessor of y.
Example:
Consider the relation “x divides y” on
{1,2,3,6,12,18}.

1.Write the ordered pairs (x,y) of this relation.
(1,1),(1,2),(1,3),(1,6),(1,12),(1,18),(2,2),(2,6),
(2,12),(2,18),(3,3),(3,6),(3,12),(3,18),(6,6),(6,12),(6,18),(
12,12),(18,18)
2.Write all the predecessors of 6.
1,2,3
3.Write all the immediate predecessors of 6.
2,3
Hasse Diagram
Visual depiction of a partially ordered set.

Each of the elements of S is represented by a
dot, called a node, or vertex, of the diagram.
If x is an immediate predecessor of y, then the
node for y is placed above the node for x and
the two nodes are connected by a straight-line
segment.
Two nodes in a Hasse diagram should never be
joined by a horizontal line.
Example:
Draw the Hasse diagram for the relation “x
divides y” on {1,2,3,6,12,18}.
1. Write the ordered pairs (x,y) of this relation.
2. Find the predecessors
3. Find the immediate predecessors
4. Draw the diagram
12       18

6
2              3
1
We can reconstruct the set of ordered pairs just by
looking the Hasse diagram.
The lines in the diagram tells us immediate
(predecessor, successor) pairs.
We can fill in the rest by using reflexive and transitive
properties.
Example: Partial order on the set {a,b,c,d,e,f}

e             Reflexive:
(a,a),(b,b),(c,c),(d,d),
b       c       d         (e,e),(f,f)
Transitive:
(a,b),(a,c),(a,d),(a,e),(d,e)
a           f
A partial ordering in which every element of the
set is related to every other element is called a
total ordering, or chain.

Total ordering diagram
Let (S,  ) be a partially ordered set.

1. If there is a yS with y x for all xS, then y is a least element
of the partially ordered set.
A least element if exists, is unique.
2. An element yS is minimal if there is no xS with x y.
3. In a Hasse diagram, a least element is below all others, while a
minimal element has no element below it.
4. If there is a yS with x y for all xS, then y is a greatest
element of the partially ordered set.
5. An element yS is maximal if there is no xS with y x.
6. A least element is always minimal and a greatest element is
always maximal, but the converses are not true.
7. In a totally ordered set, a minimal element is the least element
and a maximal element is the greatest element.
Example:
Draw the Hasse diagram for a partially ordered set with
four elements in which there are two minimal elements
but no least element, two maximal elements but no
greatest element, and each element is related to exactly
two other elements.
Final Notes
• Having some ordered pairs of the form
(x,x) does not make the relation reflexive.
• The definition of transitivity does not imply
that x,y, and z must be distinct elements.
• A relation that is not symmetric, is not
necessarily antisymmetric.
Exercise
• Exercise 4.1
– 8,10,14,20,23, 24, 25, 33, 34

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 4 posted: 12/10/2011 language: pages: 28
How are you planning on using Docstoc?