Download presentation
Presentation is loading. Please wait.
Published byLeo Madewell Modified over 10 years ago
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 R 2 … R n. 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={a 1,…,a n }. For 1≤k≤n, define a Boolean matrix W k as follows: W k has a 1 in position i, j if and only if there is a path from a i to a j in R whose interior vertices, if any, come from the set {a 1,…,a k }. Since any vertex must come from the set {a 1,…,a n }, it follows that the matrix W n has a 1 in position i, j if and only if some path in R connects a i with a j, i.e. W n =M Define W 0 to be M R, then the sequence W 0, W 1 …, W n has the first term as M R and last term as M Suppose W k =[t ij ] and W k-1 =[s ij ], then t ij =1 if and only if either (1) s ij =1 or (2) s ik =1 and s kj =1
3
Warshall’s Algorithm To compute W k from W k-1 Step1: First transfer to W k all 1’s in W k-1 Step2: List the locations p 1,p 2 …, in column k of W k-1, where the entry is 1, and the locations q 1,q 2 …, in row k of W k-1, where the entry is 1 Step3: Put 1’s in all the positions p i,p j of W k (if they are not already there) Compared with the formula (1) M =M (M ) …(M ), which requires about n 4 steps without the final joins, while the Warshall’s algorithm requires n 3 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 identity function on A, denoted by 1 A, is defined by 1 A (a)=a, if A 1 A, then 1 A (A 1 )= A 1 1 A 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) 1 B f=f (b) f 1 A =f if f is a one-to-one correspondence between A and B, then (c) f -1 f = 1 A (d) f f -1 =1 B Theorem3. (a) Let f: A B and g: B A be functions such that g f= 1 A and f g= 1 B. 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. (a)if f is one to one, then f is onto (b)if f is onto, then f is one to one
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.