1 / 13

Closure and Algorithms

Closure and Algorithms. Section 1.6 Mon, Sep 12, 2005. Transitive Closure. A relation R on a set A is transitively closed if the transitive property holds. ( a , b )  R and ( b , c )  R , then ( a , c )  R .

read
Download Presentation

Closure and Algorithms

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. Closure and Algorithms Section 1.6 Mon, Sep 12, 2005

  2. Transitive Closure • A relation R on a set A is transitively closed if the transitive property holds. • (a, b) R and (b, c) R, then (a, c) R. • Given a relation R on a set A, the transitive closure is the smallest set R* such that • RR*, • R* is transitively closed. • We may similarly define the reflexive closure and the symmetric closure of a set.

  3. A Transitive Closure Algorithm • Given a finite set RAA, • Let R* = R. • For each (a, b) R* and each (b, c) R*, • If (a, c) R*, then add (a, c) to R*. • Repeat until there is no change in R*. • R* is the transitive closure of R. • If A is a finite set, then this algorithm must terminate.

  4. Example • Let A be the set of all living people. • Let R be the “is a friend of” relation on A. • Let R* be the transitive closure of R. • What is R*? • What is the transitive closure of the “is the parent of” relation? • What is the symmetric closure of the “is the parent of” relation?

  5. Operators vs. Relations • A binary operator from a set A to a set B is a function from AA to B. • For example, + is a binary operator from NN to N: + : (a, b) a + b • A binary operator is also a ternary relation: • (a, b, c) is in the relation if the operator maps (a, b) to c. • For example, under the + operator, (3, 5, 8) is in the relation and (3, 5, 9) is not in the relation.

  6. Closed Operators • An operator on a set A is closed if it always produces a result that is back in the set A. • In this case, it is a ternary relation on A. • Or, if the operator is unary, then the relation is binary. • Addition is closed on the set N. • Division is not closed on the set N. • Squaring is closed on the set N. • Negation is not closed on the set N.

  7. Closed Operators • Consider the collection A of sets {A1, A2, A3, …}, where An = {1, 2, 3, …, n}, for all n N. • The set A is closed under both  and . • It is not closed under the set-difference operator. • Is it closed under symmetric difference?

  8. Closed Relations • An n-ary relation R is closed if the (n – 1)-ary operator underlying it is closed. • For example, consider the ternary operator on NNN to N. * : (a, b, c) > gcd(gcd(a, b), c). • Is this closed on the set of even natural numbers?

  9. The Closure of a Set under a Relation • Let R be a relation on a set A and let BA. • The closure of B under R is the smallest subset of A that contains B and that is closed under R. • Let A = N and let B = {6, 10, 15}. • What is the closure of B under the relation induced by the gcd function?

  10. The Closure of a Set under a Relation • Let A be the set of real numbers and let B be the set of positive integers. • What is the closure of B under division? • Let A = 2N and let B the collection of all sets {n}, for all nN. • What is the closure of B under union?

  11. A Closure Algorithm • Let R be an n-ary relation on a finite set A and let Bbe a subset ofA. • An algorithm to compute the closure of B: • Let B* = B. (This guarantees that B B*.) • Repeat the following steps until there is no change in B*. • For each b  A – B*, (b is not yet in B*.) For every possible choice b1, …, bn – 1  B*, If (b1, …, bn – 1, b)  R, Then add b to B*. (Now b is in B*.) • The set B* is the closure of B under R.

  12. Example • Let A be the set of real numbers. • Let R be the ternary relation |a – b| = c on A. • What is the closure of the set{1/2, 1/3, 1/4}?

  13. Algorithms • Two important properties of algorithms. • Every step is completely determined. • The process will terminate after a finite number of steps for all inputs. • Does the previous example have these properties?

More Related