Representing Relations Closures of Relations - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Representing Relations Closures of Relations

Description:

Understand how to represent relations using matrices. ... Representing Relations ... the connection matrix for two relations, how does one find the connection ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 35
Provided by: isabellebi
Category:

less

Transcript and Presenter's Notes

Title: Representing Relations Closures of Relations


1
Representing RelationsClosures of Relations
2
Learning Objectives
  • Understand how to represent relations using
    matrices.
  • Understand how to represent relations using
    digraphs.
  • Understand what are closures.
  • Understand transitive closure and how to
    calculate it.

3
Representing Relations
  • Connection Matrices
  • Let R be a relation from
  • A a1 , a2 , . . . , am
  • to
  • B b1 , b2 , . . . , bn .
  • Definition An m x n connection matrix M for R is
  • defined by
  • Mij 1 if ltai , bj gt is in R,
  • 0 otherwise.

4
Representing Relations
  • Example
  • We assume the rows are labeled with the elements
    of A and the columns are labeled with the
    elements of B.
  • Let
  • A a, b, c
  • B e, f, g, h
  • R lta,egt, ltc, ggt
  • Matrix representation
  • Connection matrix M for R
  • Note the order of A and B matters

5
Representing Relations
  • Theorem Let R be a binary relation on a set A
    and let M be its connection matrix. Then
  • R is reflexive iff Mii 1 for all i.
  • R is symmetric iff M is a symmetric matrix M
    M T
  • R is antisymetric if Mij 0 or Mji 0 for all
    i ¹ j.

6
Representing Relations
  • Combining Connection Matrices
  • Definition the join of two matrices M 1 , M 2 ,
    denoted M 1 Ú M 2 , is the component wise boolean
    or of the two matrices.
  • Fact If M 1 is the connection matrix for R 1 and
    M 2 is the connection matrix for R 2 then the
    join of M 1 and M 2 , M 1 Ú M 2 is the connection
    matrix for R 1 È R 2.

7
Representing Relations
  • Definition the meet of two matrices M 1 , M 2 ,
    denoted M 1 Ù M 2 is the component wise boolean
    and of the two matrices.
  • Fact If M 1 is the connection matrix for R 1 and
    M 2 is the connection matrix for R 2 then the
    meet of M 1 and M 2 , M 1 Ù M 2 is the connection
    matrix for R 1 Ç R 2 .

8
Representing Relations
  • Obvious questions
  • Given the connection matrix for two relations,
    how does one find the connection matrix for
  • The complement?
  • The relative complement?
  • The symmetric difference?

9
Representing Relations
  • The Composition
  • Definition Let
  • M 1 be the connection matrix for R 1 and
  • M 2 be the connection matrix for R 2 .
  • The boolean product of two connection matrices M
    1 andM 2 , denoted M 1 Ä M 2 , is the connection
    matrix for the composition of R 2 with R 1 , R 2
    o R 1

10
Representing Relations
  • Why?
  • In order for there to be an arc ltx, zgt in the
    composition then there must be and arc ltx, ygt in
    R 1 and an arc lty, in R 2 for some y !
  • The Boolean product checks all possible ys. If
    at least
  • one such path exists, that is sufficient.
  • ____________________
  • Note the matrices M 1 and M 2 must be
    conformable the number of columns of M 1 must
    equal the number of rows of M 2 .
  • If M 1 is m x n and M 2 is n x p then M 1 Ä M 2
    is m x p.

11
Representing Relations
  • Example

12
Representing Relations
  • Note
  • there is an arc in R 1 from node 1 in A to node
    2 in B
  • there is an arc in R 2 from node 2 in B to node
    2 in
  • C.
  • Hence there is an arc in R 2 o R 1 from node 1
    in A to
  • node 2 in C.
  • ___________________
  • A useful result

13
Representing Relations
  • Digraphs
  • (see section 6.1)
  • Given the digraphs for R1 and R2 , find the
    digraphs for
  • R 2 È R 1
  • R 2 Ç R 1
  • R 2 - R 1

14
Representing Relations
  • Digraphs
  • (see section 6.1)
  • Given the digraphs for R1 and R2 , find the
    digraphs for
  • R 2 È R 1
  • R 2 Ç R 1
  • R 2 - R 1
  • R 2 Å R 1
  • R1c

15
Representing Relations
  • Digraphs
  • (see section 6.1)
  • Given the digraphs for R1 and R2 , find the
    digraphs for
  • R 2 È R 1
  • R 2 Ç R 1
  • R 2 - R 1

16
Closures of Relations
  • Definition The closure of a relation R with
    respect to
  • property P is the relation obtained by adding the
    minimum
  • number of ordered pairs to R to obtain property
    P.
  • In terms of the digraph representation of R
  • To find the reflexive closure - add loops.
  • To find the symmetric closure - add arcs in the
  • opposite direction.
  • To find the transitive closure - if there is a
    path from
  • a to b, add an arc from a to b.

17
Closures of Relations
  • Note Reflexive and symmetric closures are easy.
  • Transitive closures can be very complicated.
  • _________________
  • Definition Let A be a set and let D ltx, xgt
    x in A.
  • D is called the diagonal relation on A
    (sometimes called the equality relation E).
  • Note that D is the smallest (has the fewest
    number of ordered pairs) relation which is
    reflexive on A.

18
Closures of Relations
  • Reflexive Closure
  • Theorem Let R be a relation on A. The reflexive
    closure of R, denoted r(R), is R È D .
  • Add loops to all vertices on the digraph
    representation of R.
  • Put 1s on the diagonal of the connection
    matrix of R.

19
Closures of Relations
  • Symmetric Closure
  • Definition Let R be a relation on A. Then R -1
    or the
  • inverse of R is the relation
  • R 1 lt y, x gtlt x, y gtÎ R
  • __________________
  • Note to get R -1
  • reverse all the arcs in the digraph
    representation of R
  • take the transpose M T of the connection matrix
    M of R.

20
Closures of Relations
  • Note This relation is sometimes denoted as R T
    or R c
  • and called the converse of R
  • The composition of the relation with its inverse
    does not
  • necessarily produce the diagonal relation (recall
    that the
  • composition of a bijective function with its
    inverse is the
  • identity).
  • ___________________
  • Theorem Let R be a relation on A. The symmetric
  • closure of R, denoted s(R ), is the relation R È
    R -1 .

21
Closures of Relations
  • Examples

22
Closures of Relations
  • Examples
  • If A Z, then r( ¹ ) Z x Z
  • If A Z , then s( lt ) ¹.
  • What is the (infinite) connection matrix of s(lt)?
  • If A Z, then s(?) ?
  • Theorem R is symmetric iff R R -1

23
Closures of Relations
  • Theorem Let R 1 and R 2 be relations from A to
    B. Then

24
Closures of Relations
  • Paths
  • Definition A path of length n in a digraph G is
    a
  • sequence of edges ltx 0 , x 1 gtltx 1 , x 2 gt . . .
    ltx n-1 , x n gt.
  • The terminal vertex of the previous arc matches
    with the initial vertex of the following arc.
  • If x 0 x n the path is called a cycle or
    circuit. Similarly for relations.
  • _________________

25
Closures of Relations
  • Theorem Let R be a relation on A. There is a
    path of
  • length n from a to b iff lta, bgt Î R n .
  • Proof (by induction)
  • Basis An arc from a to b is a path of length 1
  • which is in R 1 R. Hence the assertion is true
    for n 1.
  • Induction Hypothesis Assume the assertion is
    true
  • for n.
  • Show it must be true for n1.
  • There is a path of length n1 from a to b iff
    there is an x in
  • A such that there is a path of length 1 from a to
    x and a
  • path of length n from x to b.

26
Closures of Relations
  • From the Induction Hypothesis,
  • lta, xgt Î R
  • and since ltx , bgt is a path of length n,
  • ltx, bgt Î R n .
  • If lta, xgt Î R and ltx, bgt Î Rn ,
  • then
  • lta, bgt Î Rn o R R n1
  • by the inductive definition of the powers of R.
  • Q. E. D.
  • ______________________

27
Closures of Relations
  • Useful Results for Transitive Closure
  • Theorem
  • If A Ì B and C Ì B, then A È C Ì B.
  • Theorem
  • If R Ì S and T Ì U then R o T Ì S o U.
  • Corollary
  • If R Ì S then R n Ì S n
  • Theorem
  • If R is transitive then so is R n

28
Closures of Relations
  • Transitive Closure
  • Recall that the transitive closure of a relation
    R, t(R), is
  • the smallest transitive relation containing R.
  • Also recall
  • R is transitive iff R n is contained in R for all
    n
  • Hence, if there is a path from x to y then there
    must be an
  • arc from x to y, or ltx, ygt is in R.
  • Example
  • If A Z and R lt i, i1gt then t(R) lt

29
Closures of Relations
30
Closures of Relations
  • _________________
  • Definition The connectivity relation or the star
    closure of the relation R, denoted R, is the set
    of ordered pairs lta, bgt such that there is a path
    (in R) from a to b. Since Rn consists of the
    pairs (a,b) such that there is a path of length n
    from a to b, it follows that

31
Closures of Relations
  • Examples
  • Let A Z and R lti, i1gt. R lt.
  • Let A the set of people, R ltx, ygt person
    x is a parent of person y. R ?
  • __________________

32
Closures of Relations
  • Theorem t(R) R.
  • Example
  • R2
  • R3
  • R4
  • R5
  • t(R) R
  • ______________________

33
Closures of Relations
  • Definition The closure of a relation R with
    respect to
  • property P is the relation obtained by adding the
    minimum
  • number of ordered pairs to R to obtain property
    P.
  • In terms of the digraph representation of R
  • To find the reflexive closure - add loops.
  • To find the symmetric closure - add arcs in the
  • opposite direction.
  • To find the transitive closure - if there is a
    path from
  • a to b, add an arc from a to b.

34
Closures of Relations
  • Definition The closure of a relation R with
    respect to
  • property P is the relation obtained by adding the
    minimum
  • number of ordered pairs to R to obtain property
    P.
  • In terms of the digraph representation of R
  • To find the reflexive closure - add loops.
  • To find the symmetric closure - add arcs in the
  • opposite direction.
  • To find the transitive closure - if there is a
    path from
  • a to b, add an arc from a to b.
Write a Comment
User Comments (0)
About PowerShow.com