1 / 11

Transitive Closure

Transitive Closure. Theorem 1. Let R be a relation on a set A. Then R  is the transitive closure of R.

ciro
Download Presentation

Transitive Closure

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. Transitive Closure Theorem 1. Let R be a relation on a set A. Then Ris the transitive closure of R. • the reachability relation R* of a relation R on a set A is defined as xR*y, which means that x=y or xRy, i.e. y is reachable from x if either y is x or there is some path from x to y • R*=R • M =M (M )(M )… Theorem 2. Let A be a set with |A|=n, and let R be a relation on A. Then R=RR2…Rn. In other words, powers of R greater than n are not needed to computer R.

  2. Warshall’s Algorithm • Let R be a relation on a set A={a1,…,an}. For 1≤k≤n, define a Boolean matrix Wk as follows: Wk has a 1 in position i, j if and only if there is a path from ai to aj in R whose interior vertices, if any, come from the set {a1,…,ak}. • Since any vertex must come from the set {a1,…,an}, it follows that the matrix Wn has a 1 in position i, j if and only if some path in R connects ai with aj, i.e. Wn=M • Define W0 to be MR, then the sequence W0, W1 …, Wn has the first term as MR and last term as M • Suppose Wk =[tij] and Wk-1 =[sij], then tij =1 if and only if either (1) sij =1 or (2) sik =1 and skj =1

  3. Warshall’s Algorithm To compute Wk from Wk-1 Step1: First transfer to Wk all 1’s in Wk-1 Step2: List the locations p1,p2 …, in column k of Wk-1, where the entry is 1, and the locations q1,q2 …, in row k of Wk-1, where the entry is 1 Step3: Put 1’s in all the positions pi,pj of Wk (if they are not already there) • Compared with the formula (1) M =M (M )…(M ), which requires about n4 steps without the final joins, while the Warshall’s algorithm requires n3 steps in all • Thus Warshall’s algorithm is a significant improvement over direct computation M of using the formula (1)

  4. Transitive Closure • if R and S are equivalence relations on a set A, then the relation RS is the largest equivalence relation contained in both R and S Theorem 3. If R and S are equivalence relations on a set A, then the smallest equivalence relation containing both R and S is (RS).

  5. 5. Functions Functions in Computer Science Growth of Functions

  6. Functions Function, a special type of relation • let A and B be nonempty sets, a function f from A to B, denoted as f: AB, is a relation from A to B such that for all aDom(f), f(a), the f-relative set of a, contains only one element of B, i.e. f(a)={b}, or f(a)=b • the relation f can be described as the set of pairs {(a, f(a)) | aDom(f)} • functions are also called mappings or transformations; the element a is called an argument of the function f, and f(a) is called the value of the function for the argument a, and is also referred to as the image of a under f

  7. Functions • let A be an arbitrary nonempty set, the identityfunction on A, denoted by 1A, is defined by 1A(a)=a, if A1A, then 1A(A1)= A1 • 1A is the relation  • suppose that f: AB and g: BC are functions, then the composition of f and g, gf is a relation; let aDom(gf), then (gf)(a)=g(f(a)) • if f and g are functions specified by giving formulas, then gf is also a function, and the formula for gf is produced by substituting the formula for f into the formula for g

  8. Special Types of Functions • let f be a function from A to B, then f is everywhere defined if Dom(f)=A; f is onto if Ran(f)=B; f is one to one if there is no f(a)=f(a') for two distinct elements a and a' of A • one to one: if f(a)=f(a'), then a=a' • if f is one to one and onto, it’s also called a bijection between Dom(f) and Ran(f) • f is called a one-to-one correspondence between A and B if f is everywhere defined, onto and one to one • a function f: AB is said to be invertible if its inverse relation f-1 is also a function

  9. Invertible Functions Theorem1. Let f: AB be a function. (a) then f-1 is a function from B to A if and only if f is one to one if f-1 is a function, then (b) the function f-1 is also one to one (c) f-1 is everywhere defined if and only if f is onto (d) f-1 is onto if and only if f is everywhere defined • if f is a one-to-one correspondence between A and B, then f-1 is a one-to-one correspondence between B and A; for all a in A and b in B, f(f-1(b))=b and f-1(f(a))=a • if f: AB is a one-to-one function, then the equation b=f(a) is equivalent to a= f-1(b)

  10. Composition of Functions Theorem2. Let f: AB be any function. Then (a) 1Bf=f (b) f1A=f if f is a one-to-one correspondence between A and B, then (c) f-1f = 1A (d) ff-1=1B Theorem3. (a) Let f: AB and g: BA be functions such that gf= 1A and fg= 1B.Then f is a one-to-one correspondence between A and B, g is a one-to-one correspondence between B and A, and each is the inverse of the other (b) Let f: AB and g: BC be invertible. Then gf is invertible, and (gf)-1=f-1 g-1

  11. Functions • It’s often easier to show that a function is one to one and onto by constructing an inverse instead of proceeding directly Theorem4. Let A and B be two finite sets with the same number of elements, and let f: AB be an everywhere defined function. • if f is one to one, then f is onto • if f is onto, then f is one to one

More Related