+ All Categories
Home > Documents > Closures of relations

Closures of relations

Date post: 14-Feb-2016
Category:
Upload: nancy
View: 40 times
Download: 0 times
Share this document with a friend
Description:
Closures of relations . A closure “extends” a relation to satisfy some property. But extends it as little as possible. . Definition . The closure of relation R with respect to property P is the relation S that i) contains R ii) satisfies property P - PowerPoint PPT Presentation
33
1 Closures of relations osure “extends” a relation to satisfy some property extends it as little as possible. n . The closure of relation R with respect to propert lation S that ontains R satisfies property P is contained in any relation satisfying i) and ii) smallest” relation satisfying i) and ii).
Transcript
Page 1: Closures of relations

1

Closures of relations

A closure “extends” a relation to satisfy some property.But extends it as little as possible.

Definition. The closure of relation R with respect to property P is the relation S that

i) contains Rii) satisfies property Piii) is contained in any relation satisfying i) and ii). That is

S is the “smallest” relation satisfying i) and ii).

Page 2: Closures of relations

2

Lemma 1. The reflexive closure of R is S = R {(a, a) | aA } =r(R).

S contains R and is reflexive by design. Furthermore, any relation satisfying i) must contain R, any satisfying ii) mustcontain the pairs (a, a), so any relation satisfying both i) and ii)must contain S

Proof. In accordance to the definition of a closure, we need to prove three things to show that S is reflexive closure:

i) S contains R ii) S is reflexive iii) S is the smallest relation satisfying i) and ii).

Page 3: Closures of relations

3

Lemma 2. The symmetric closure of R is S = R R-1 =s(R)

Proof. S is symmetric and contains R. It is also the smallest such .For suppose we have some symmetric relation T with R T.To show that T contains S we need to show that R-1 T. Take any (a, b) R-1 , it implies (b, a) R , and (b, a) T, since R T. But then (a, b) T as well, because T is symmetric by assumption. So, S = R R-1 T .

Page 4: Closures of relations

4

Theorem. The transitive closure of a relation R is the setS = {(a, b) | there is a path from a to b in R}= t (R)

Proof. Let’s show that S is transitive. Suppose (a, b) S and (b, c) S. This means there is a path from a to b and a path from b to c in R. If we “concatenate” them (attach the end of the (a, b)-path to the start of the (b, c)-path) we get a path from a to c. Thus, (a, c) S and S is transitive. We need to show, that any transitive relation T containing R contains S .Let’s prove by contradiction. Assume that there exists a transitive relation T containing R, that is smaller then S.

Page 5: Closures of relations

5

More formally: assume by the way of contradiction that thereexists a transitive relation T, such that RT, but S T.We want to show that it results to contradiction, that willprove the claim, that S is the smallest transitive relation,that includes R.

/

(x, y)S but (x, y)T

‘a path’ from x to y in R

xy

R

xy

T

since RT and T is transitive(x, y) T (contradiction)

/S T

Page 6: Closures of relations

6

An alternative way to represent transitive closure isas the union of paths with different length

t (R) = S1 S2 S3 … where Sn = {(a, b) | there is a path of length n from a to b in R }

Lemma 3. The transitive closure of the relation R is t(R) = R R2 R3…

(left for you to prove)

Theorem. (a, b) Rn iff there is a path of length n in R.(will be proved later by induction)

Thus, we can prove the following equivalent definition of transitive closure

Page 7: Closures of relations

7

Theorem. Suppose R is a relation on a set A, R AA, |A|=n, and there is a path of length m > n from a to b in R. Then there is a path from a to b of length less or equal n.

How many powers of R we need to find t (R)? It turns out that if |A|=n, we don’t need powers greater then n.

Example: n =4

• •

a b

b• c

There is a path of length 5 from a to a there is a shorter path.

Page 8: Closures of relations

8

Proof . Assume that there exists a path x0, x1,…, xm , a = x0 andb = xm, of length m, m>n. Then you have m “pigeons” and n “holes”, m >n. By Pigeonhole principle, at least two of vertices should coincide: xi=xj for some i < j (some vertex visited twice on the path). It means that we can cut off a loop and make a shorter path from a to b.

The length of a path from a to b, is at most n(n 1, if a b).

Page 9: Closures of relations

9

a=1, b =6

1, 2, 3, 4, 5, 3, 4, 6 - a path oflength 7 (1, 6)R7

1, 2, 4, 6 – the shortest path (1, 6)R3

It means that t(R) = R R2 R3 … Rn

Powers greater then n are not needed to compute t (R).

1, 2, 3, 4, 6– a shorter pathof length 4 (1, 6)R4

••

•12

3

4

5

6

Example

Page 10: Closures of relations

10

How to build transitive closure?

1

2 3

4 R = {(1, 1), (1, 2), (2, 3), (3, 1), (4, 1)}

t(R) = {(1, 1), (1, 2), (2, 3), (3, 1), (4, 1), (1, 3), (2, 1), (3, 2), (4, 2), (2, 2), (3, 3), (4, 3) }

R2={(1, 1), (1, 2), (1, 3), (2, 1), (3, 1), (3, 2),(4, 1), (4, 2) }

R3={(1, 1), (1, 2), (1, 3), (2, 1), (2,2), (3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (4, 3) }

R4={(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3),(3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (4, 3) }

Page 11: Closures of relations

11

We can also define a composition of closures, e. g. tr(R) = t(r(R)), rs(R)=r(s(R)), etc.

It turns out, that the order of composition does matter.

Theorem. For any binary relation R AA st(R) ts(R).By the theorem about symmetric and transitive closures

st(R) = s(t(R)) = t(R)(t(R))-1

= (R R2 R3 …)(R R2 R3 …)-1

ts(R) = t(s(R)) = t(R R-1) = (R R-1)(R R-1)2 (R R-1)3…

By the distributive property of composition over union(R R-1)2= (R R-1)(R R-1) = R(RR-1)R-1(R R-1)

= RR RR-1R-1R R-1R-1

= R2 RR-1R-1R R-2, where R-1R-1= R-2

Page 12: Closures of relations

12

In general, ts(R) is the union of terms of the form(R R-1)n = (R R-1)(R R-1)… (R R-1)

=R… R RR… R-1 … R-1R-1… R-1

Are RR-1 and R-1R the same?

Not at all!R-1={(b, a)}

a b

a

RR-1={(a, a)}b

R={(a, b)}

ba

a

R-1R={(b, b)}b

Page 13: Closures of relations

13

We can observe, that ts(R) includes compositions of all possible sequences of R and R-1, while st(R) is a union of positive and negative powers of R (but not mixtures). So, it can be proved that st(R)ts(R), but ts(R) st(R).

Proof. Take arbitrary (x, y) st(R) to show that (x, y)ts(R). By the Lemma 2 (x, y) st(R) implies that (x, y)t(R)(t(R))-1. We have two cases. Case 1: (x, y)t(R), i. e. there exists a path from x to y in R. It implies that there exist a path from x to y in s(R), since R s(R) = R R-1. By the definition of transitive closureit means that (x, y) t(s(R)). Case 2: (x, y)(t(R))-1 , i. e. (y, x)t(R), and similar to the case 1,there exists a path from y to x in R, that implies the path in s (R). It implies there exists a path from x to y, or (x, y) ts(R).

Try to find a counterexample to disproves that ts(R) st(R).

Page 14: Closures of relations

14

Equivalence relations and partitions.

Definition. A relation RAA is called an equivalence relationon A if it is symmetric, reflexive and transitive.

Consider the following relation on a set of all people:B = {(x, y)| x has the same birthday as y }

B is reflexive, symmetric and transitive. We can think about this relation as splitting all people into 366 categories, one for each possible day.

An equivalence relation on a set A represents some partition of this set.

Page 15: Closures of relations

15

Definition. For any set A subsets Ai A partition set A if • A = A1 A2 … An

• AiAj= , for any ij. • Ai for any i

Example. A={1, 2, 3, 4}, ={{2}, {1, 3}, {4}} is a partition of A.

A1

A2

A3A4

A

Page 16: Closures of relations

16

Definition. Suppose R is equivalence relation on a set A, and xA. Then the equivalence class of x with respect to Ris the set

[x]R={yA| yRx}

In the case of the same birthday relation B, if p is any person,then the equivalence class of p

[p]B={qP | pBq} ={qP | q has the same birthday as p}

For example, if John was born on Aug. 10, [John]B= {q P | q was born on Aug.10}

The set of all equivalence classes of elements of A is called A modulo R and is denoted A/R:

A/R={[x]R | x A}

Page 17: Closures of relations

17

Theorem 1. Suppose R is an equivalence relation on a set A.Then A/R ={[x]R | x A} is a partition of A.

We are going to prove that any equivalence relation R on Ainduces a partition of A and any partition of A gives rise to an equivalence relation.

Proof. To prove that A/R defines a partition, we must prove three properties of a partition. 1) The union of all equivalence classes [x]R equals A, i. e.

Since any equivalence class is a subset of A, their union is also a subset of A. So, all we need to show is

To prove this, suppose xA. Then x[x]R because [x]R ={y A | yRx }and xRx due to reflexive property of R.

Ax RAx

][

RAx

xA ][

Page 18: Closures of relations

18

2) To prove that A/R is pairwise disjoint we need to show,that for any x, y A if [x][y] then [x][y]=. It is easier to prove the contrapositive: if [x][y] , then [x]=[y]. So, assume [x][y] , then we can find an element z [x][y].It implies that xRz and zRy by definition of equivalence classes.Then xRz and zRy implies xRy due to transitive property of R. We now claim that [x][y]. Take any a [x], it implies aRx, whichimplies aRy because of xRy and transitive property of R.aRy implies a [y], i. e. [x][y]. Similarly [y][x], or [x]=[y].

3) None of equivalence classes is empty, because for any xA, x[x].

x[x]R implies RAx

xx ][

Page 19: Closures of relations

19

Theorem 2. Suppose A is a set and is a partition of A, i. e. is a set of disjoint nonempty subsets, such that any elementof A belongs to exactly one subset. Then the relation R on A defined as R = {(x, y) | x, y A and x and y belong to the same subset in }is an equivalence relation on A.

Proof. We need to prove that R is reflexive, symmetric and transitive.• R is reflexive because for any x A, x and itself belong to the samesubset in .• R is obviously symmetric• Suppose xRy and yRz, that is x and y belong to the same subset andy and z belong to the same subset. This implies that x and z belongto the same subset in , thus xRz.

Page 20: Closures of relations

20

Definition. A partition P2 is called a refinement of P1 if every set in P2 is a subset of one of sets in P1.

Example. Consider the partition P1.={{1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}},

induced by the relation R1 = {(x, y) | x = y mod(2)} on a set A = {1, 2, …10}.Then the relation R2 = {(x, y) | x = y mod(4)} induces a partitionP2.={{1, 5, 9}, {3, 7}, {2, 6, 10}, {4, 8}}, which is a refinement of P1.

Theorem. Suppose R1 and R2 are equivalence relations on a set A.Let P1 and P2 are partitions that correspond to R1 and R2 respectively.Then R1 R2 iff P1 is a refinement of P2

Page 21: Closures of relations

21

Definition. A binary relation R AA is a partial order, if it is reflexive, transitive and anti-symmetric.

Partial Orders.A particular type of binary relation on a set.

Examples: ‘less or equal’ ‘greater or equal’ ‘subset’ relation ‘divides’

The set A together with the partial order relation is called a poset.

Page 22: Closures of relations

22

Functions. Function is a special type of relation.

Definition. A function f : A B is a binary relation from A to Bsuch that, for every aA there exists a unique (i. e. exactly one) element b B such that (a, b) f .

If aA, write f(a) for corresponding element of B, b= f(a)

b is the image of a;

A = domain

a is the pre-image of b

B = co-domain. a f

b= f(a)

Recall that in a relation R A B an element a A may be related to more then one element of B, or it may be not related to any.

Page 23: Closures of relations

23

A

B f

relation f is not a function

A B f

relation f is not a function

Page 24: Closures of relations

24

The set of all images f (A) ={f (a)| aA}

is the range of f .

A

B f

a2

a1

a3a4

b1b2

b3

f (A) = {b1, b3}

In general f (A) is a proper subset of B.

Page 25: Closures of relations

25

Assume |A|=n, |B|=m. How many different functions f : A B exist?

Recall that there are 2nm different relations R A B, but not all of them are functions.

For relations we counted all subsets of A B. A function must include exactly n pairs, one for each element in A.Each of elements from the domain can be related to any elementfrom co-domain. So, we have m choices for each pair, the total number of functions is mn.

)}(,...),(),{(21 21 ninii b,ab,ab,af

where miii n ,...,,1 21

Page 26: Closures of relations

26

Properties of functions (surjective, injective, bijective )

Definition. Surjective (“onto”): range = co-domain.

A function f : AB is called surjective, if for any bB there exists aA, such that f (a) = b.

bB, aA (f (a)=b)

A

B f

a2

a1

a3a4

b1b2

b3

This function is not surjective because b2 does not have any pre-image.

Page 27: Closures of relations

27

If we have two finite sets |A| < |B|

A B f

a2

a1 b1b2

b3

a surjective function f : AB is impossible.

The necessary condition for a surjective function f : AB is |A| |B|.

Page 28: Closures of relations

28

Definition. Injective (“one-to-one”): a1, a2A, a1 a2 f (a1) f (a2)

A function f : AB is called injective, if for all a1, a2A, a1 a2 f (a1) f (a2). Equivalently, it means f (a1) = f (a2) a1 = a2

A B f

a2

a1 b1

b2a3

This function is not injective.

Page 29: Closures of relations

29

An injective function f : AB is possible if only |A| |B|.

A B f

a2

a1 b1

b2a3

f

A B

a2

a1 b1

b2a3

b3

A function that is both injective and surjective is called bijective. For this we need |A| |B| and |A| |B|, i. e. |A| = |B|.

Page 30: Closures of relations

30

Examples: • f (x)=x2 : R R

is not injective, since both +x and -x have the same image. is not surjective (but is surjective if regarded R R+)

A B f

Surjective, but not injective

A B f

Injective, but not surjective

Page 31: Closures of relations

31

Composition of functions

a A f

B

f (a)=b

g C

g (b)=c

gf (Note, that in the context of function composition, the order in which the functions appear is backward, i. e. the rightmost function is applied first)Theorem. Let f : AB and g: BC be two functions. The composition of f and g as relations defines a function gf : A C, such that gf (a)= g(f(a)).

Page 32: Closures of relations

32

Proof. We need to prove that composite relation gf is a function. For this we need to prove two things: 1) the composition gf relates each element aA to some c C. 2) an element c C assigned to a by gf is unique, so we can denote it c= g(f (a)).

1) existence: Let b=f (a) B. Let c=g(b) C. So, by the definition of composition of relations, (a, c)gf . Thus, cC [(a, c)gf ]

a A

g C

g (b)=c

f B

f (a)=b

gf

Page 33: Closures of relations

33

2) uniqueness: Suppose (a, c1)gf and (a, c2)gf . Then by the definition of composition, b1B, such that (a, b1)f and (b1, c1)g,and b2B, such that (a, b2)f and (b2, c2)g. Since f is a function, there may be only one b B, such that (a, b)f, so b1= b2. Since g is a function, (b, c1)g and (b, c2)g imply that c1= c2.

Thus, (gf )(a)= c= g (b) = g (f (a)).

a

c1

c2

b1

f g

b2


Recommended