today’s topics: associative and distributive properties of composition powers of a relation

31
1 ay’s topics: ssociative and distributive properties of compositi owers of a relation nverse relation Homework #3 is posted (due on June 26)

Upload: fagan

Post on 07-Jan-2016

30 views

Category:

Documents


0 download

DESCRIPTION

Homework #3 is posted (due on June 26). Today’s topics: Associative and distributive properties of composition Powers of a relation Inverse relation. S  T. C. R. S. T. A. D. B. R  S. Properties of composition. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

1

Today’s topics:• Associative and distributive properties of composition• Powers of a relation• Inverse relation

Homework #3 is posted (due on June 26)

Page 2: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

2

Theorem. Let R AB, S BC and T CD denote three binaryrelations. Then relation compositions satisfy the following associative law:

(RS)T = R(ST)

Properties of composition

RS

A C B

DT R S

ST

Page 3: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

3

Theorem. Let R AB, S BC and T CD denote three binaryrelations. Then relation compositions satisfy the following associative law:

(RS)T = R(ST)

Proof. First note that both sides define a relation from A to D. We also note the following:(RS)T = {(a, d) | aA and dD and cC [(a, c)RS cTd ]}

(by the definition of composition T )

= {(a, d) |… (cC, bB) [(aRb bSc ) cTd ]}(by definition of RS )

= {(a, d) |… (cC, bB) [aRb (bSc cTd )]}(by associative property of )

= {(a, d) |… (bB) [aRb (b, d ) ST ]}(by definition of ST )

= R(ST) (by the definition of composition R )

Page 4: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

4

Associative property of composition means, thatno ambiguity arises if we simply write RST .

We can also define powers of a relation RAA recursivelyas R1=R and Rn+1=RnR (n 1)

Definition. A path in a relation R is a sequence a0, … , ak with k 0 such that (ai, ai+1) R for every i<k . We call k the length of the path.

5•

1•

7•

6•

4 •

3•

2•

A

a0

a1

a2

a3

1, 5, 7, 6 – a path of length 3

Page 5: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

5

a1

a0 a2

a3

R (parent-of)

a1

RR= R2 (grandparent-of)

a0 a2

a3

RRR= R3

a1

a0 a2

a3

R4=

a1

a0 a2

a3

Powers of a relation

Page 6: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

6

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

Ra

c

d

b

R2

b

a d

c

R3

a

bc

d

Page 7: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

7

Proof 1) If RAA is reflexive, then for any aA, (a, a) R. To prove that R2 is reflexive, we need to show that for any aA, (a, a) R2, i. e. you can ‘return back to a in two steps’.This is obviously true, because you can simply repeat two loops.

Theorem. 1) If a relation R AA is reflexive, then R2 is also reflexive 2) If a relation R AA is symmetric, then R2 is also symmetric3) If a relation R AA is transitive, then R2 is also transitive.

Note, that we can prove in general, that if (a, a) R,then (a, a) Rn for any n > 0 (repeat loop n times)

Page 8: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

8

Proof. 2) R AA is symmetric R2 is symmetric

a b

R2

?

assume (a, b) R2 cA, (a, c) R and (c, b) R

c

a b

R

(b, c) R and (c, a) R

a b

Rc

(b, a) R2

a

b

Page 9: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

9

Proof 3) Assume R is transitive. To prove that R2 is transitive, assume that there exist (a, b) R2 and (b, c) R2 (otherwise R2

is ‘vacuously’ transitive) to show that (a, c) R2 .

Sketch of the proof

a bR2

c

a b

x A

c y A

a b

(a, b) R x

(b, c) R

yc

a b

x

yc(a, c) R2

Page 10: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

10

It is interesting also to see how the composition distributes over union and intersection.

Theorem. Let R AB, S BC and T BC denote three binary relations. Then

1) R(ST) = (RS)(RT)2) R(ST) (RS)(RT)

Page 11: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

11

1) R(ST) = (RS)(RT)

R = {(a1, b1), (a1, b2), (a2, b4)}

S = {(b1, c2), (b4, c1)} T ={(b4, c4)}

ST = {(b1, c2), (b4, c1), (b4, c4)}

AB C

R S

T

a1

a2

a3

c1

c2

c3

c4

b1

b2b3

b4

R(ST) = {(a1, c2), (a2, c1), (a2, c4)}

RS = {(a1, c2), (a2, c1)}, RT = {(a2, c4)},

(RS)(RT) ={(a1, c2), (a2, c1), (a2, c4)}

Page 12: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

12

Proof (1) R(ST)={(a, c)|aA and cC and

bB [aRb (b, c) ST]}… …..dfn of R

= {(a, c)|… bB [aRb ( bSc bT c)]}……………dfn of

= {(a, c)|… bB [(aRb bSc) (aRb bT c)]}……distributive law

= {(a, c)|… [bB (aRb bSc)] [bB (aRb bT c)]}

by x[p(x) q(x)] [x p(x)] [x q(x)]

= {(a, c)|… [(a, c)RS ] [(a, c)RT ]}

by dfn of composition

= {(a, c)|… (a, c)RS RT }

by dfn of

= RS RT

Page 13: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

13

Proof (2) R(ST) (RS)(RT)

Take an element (pair) (a, c) R(ST)

aA, cC and bB[aRb (b, c)(ST)]

dfn of composition

… bB[aRb (bSc bTc)]

dfn of ST

… bB[(aRb bSc)(aRbbTc)]

associative and idempotent laws

… [bB(aRb bSc)][bB(aRbbTc)]

by x[p(x) q(x)] [x p(x)] [x q(x)]

… [(a, c) RS] [(a, c) RT]

by dfn of composition

(a, c) (RS)(RT)

by dfn of

Page 14: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

14

The converse subset relation (RS)(RT) R(ST) can be disproved by the following counterexample:

R

R

S

T

a

b

c

d

R = {(a, b), (a, c)}

S = {(b, d )}

T = {(c, d )}

RS = {(a, d )} RT = {(a, d )} (RS)(RT)= {(a, d )}

ST = R(ST)= (RS)(RT) R(ST)/

Page 15: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

15

Definition. Inverse of relation R is defined as:R-1 = {(a, b) | (b, a)R} .

•Inverse of “parent-of” is “child of”.

•If R AB , then R-1 BA

• It is just relation “turned backward”.

Page 16: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

16

Prove or disprove that RR-1 is reflexive.

A B

R AB a1 b1

R-1 BA

a2 b2

A

a1

a2

RR-1 AA

Page 17: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

17

Theorem. Let R be a binary relation from A to B and S be a binary relation from B to C, so that RS is a composite relation from A to C. Then the inverse of this relation

(RS)-1 = S-1 R-1

Proof. (RS)-1 is a binary relation from C to A. (RS)-1 = {(c, a) | (a, c) RS }…….. by the definition of inverse

= {(c, a) | b B, aRb and bSc}…. by dfn of composition= {(c, a) | b B, (b, a) R-1 and (c, b) S-1 }

by dfn of inverse = {(c, a) | b B, (c, b) S-1 and (b, a)R-1}

by commutative property of and = {(c, a) | b B, (c, a) S-1R-1}

by dfn of composition= S-1 R-1

Page 18: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

18

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 19: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

19

Just a reminder:

• reflexive: aRa for any a A• symmetric: aRb bRa• transitive: aRbbRc aRc• anti-symmetric: aRbbRa a = b,

i. e. a b, aRb bRa

Page 20: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

20

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 21: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

21

Example: R={(a, b), (a, c), (b, d), (d, e)}

a b c d ea 0 1 1 0 0 b 0 0 0 1 0c 0 0 0 0 0d 0 0 0 0 1e 0 0 0 0 0

R

a b c d ea 1 1 1 0 0 b 0 1 0 1 0c 0 0 1 0 0d 0 0 0 1 1e 0 0 0 0 1

S = r (R)

a •

b • c

••e d

R

a •

•c •

••e d

b

r (R)

Page 22: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

22

Sometimes the relation on A that consists of all loops is called identity relation on A, i. e.

IA={(a, a)|aA}Then reflexive closure of a relation RAA is

r(R)=RIA

Example of a reflexive closure. Let A be any set and consider the relation on Power(A)

R = {(x, y)Power(A) Power(A) | xy}

The reflexive closure of R would be the relation: RIPower(A)={(x, y)Power(A)Power(A)|(x, y)R or (x, y) IPower(A)}

={(x, y)Power(A)Power(A)| xy or x=y} ={(x, y)Power(A)Power(A)| x y}

Thus, the reflexive closure of the ‘proper subset’ relation is the ‘subset’ relation.

Page 23: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

23

Consider the relation ‘less then’ on A={1, 2, 3, 4, 5}

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

What is the reflexive closure of R?

1 2

3

4

5

R

r(R)

1 2

3

4

5

Page 24: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

24

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 25: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

25

Example: R={(a, b), (a, c), (b, d), (d, e)}

a b c d ea 0 1 1 0 0 b 0 0 0 1 0c 0 0 0 0 0d 0 0 0 0 1e 0 0 0 0 0

R a b c d ea 0 1 1 0 0 b 1 0 0 1 0c 1 0 0 0 0d 0 1 0 0 1e 0 0 0 1 0

s (R)

a b

c

d

e

R

a

b

c

d

e

s(R)

Page 26: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

26

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 27: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

27

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 28: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

28

How to build transitive closure?

An alternative way to represent transitive closure isas the union of paths with different length (if |A| = n, the longest path has length n).

1

2 3

4R = {(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), (4, 2), (2, 2), (4, 3)}

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

(left for you to prove)

Page 29: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

29

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 30: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

30

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 31: Today’s topics:  Associative and distributive properties of composition  Powers of a relation

31

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).