Discrete Mathematics in Computer Science Operations on Relations Malte Helmert, Gabriele R¨ oger University of Basel
Relations: Recap A relation over sets S 1 , . . . , S n is a set R ⊆ S 1 × · · · × S n . A binary relation is a relation over two sets. A homogeneous relation R over set S is a binary relation R ⊆ S × S .
Relations: Recap A relation over sets S 1 , . . . , S n is a set R ⊆ S 1 × · · · × S n . A binary relation is a relation over two sets. A homogeneous relation R over set S is a binary relation R ⊆ S × S .
Relations: Recap A relation over sets S 1 , . . . , S n is a set R ⊆ S 1 × · · · × S n . A binary relation is a relation over two sets. A homogeneous relation R over set S is a binary relation R ⊆ S × S .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . With the standard relations <, = and ≤ for N 0 , relation ≤ corresponds to the union of relations < and =. Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . With the standard relations <, = and ≤ for N 0 , relation ≤ corresponds to the union of relations < and =. Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . With the standard relations <, = and ≤ for N 0 , relation ≤ corresponds to the union of relations < and =. Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? With the standard relations ≤ , = and ≥ for N 0 , relation = corresponds to the intersection of ≤ and ≥ . If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . With the standard relations <, = and ≤ for N 0 , relation ≤ corresponds to the union of relations < and =. Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? With the standard relations ≤ , = and ≥ for N 0 , relation = corresponds to the intersection of ≤ and ≥ . If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R .
Set Operations Relations are sets of tuples, so we can build their union, intersection, complement, . . . . Let R be a relation over S 1 , . . . , S n and R ′ a relation over n . Then R ∪ R ′ is a relation over S 1 ∪ S ′ S ′ 1 , . . . , S ′ 1 , . . . , S n ∪ S ′ n . With the standard relations <, = and ≤ for N 0 , relation ≤ corresponds to the union of relations < and =. Let R and R ′ be relations over n sets. Then R ∩ R ′ is a relation. Over which sets? With the standard relations ≤ , = and ≥ for N 0 , relation = corresponds to the intersection of ≤ and ≥ . If R is a relation over S 1 , . . . , S n then so is the complementary relation ¯ R = ( S 1 × · · · × S n ) \ R . With the standard relations for N 0 , relation = is the complementary relation of � = and > the one of ≤ .
Inverse of a Relation Definition Let R ⊆ A × B be a binary relation over A and B . The inverse relation of R is the relation R − 1 ⊆ B × A given by R − 1 = { ( b , a ) | ( a , b ) ∈ R } . The inverse of the < relation over N 0 is the > relation. Relation R with xRy iff person x has a key for y . Inverse: Q with aQb iff lock a can be openened by person b .
Inverse of a Relation Definition Let R ⊆ A × B be a binary relation over A and B . The inverse relation of R is the relation R − 1 ⊆ B × A given by R − 1 = { ( b , a ) | ( a , b ) ∈ R } . The inverse of the < relation over N 0 is the > relation. Relation R with xRy iff person x has a key for y . Inverse: Q with aQb iff lock a can be openened by person b .
Composition of Relations Definition (Composition of relations) Let R 1 be a relation over A and B and R 2 be a relation over B and C . The composition of R 1 and R 2 is the relation R 2 ◦ R 1 with: R 2 ◦ R 1 = { ( a , c ) | there is a b ∈ B with ( a , b ) ∈ R 1 and ( b , c ) ∈ R 2 } How can we illustrate this graphically?
Composition of Relations Definition (Composition of relations) Let R 1 be a relation over A and B and R 2 be a relation over B and C . The composition of R 1 and R 2 is the relation R 2 ◦ R 1 with: R 2 ◦ R 1 = { ( a , c ) | there is a b ∈ B with ( a , b ) ∈ R 1 and ( b , c ) ∈ R 2 } How can we illustrate this graphically?
Composition is Associative Theorem (Associativity of composition) Let S 1 , . . . , S 4 be sets and R 1 , R 2 , R 3 relations with R i ⊆ S i × S i +1 . Then R 3 ◦ ( R 2 ◦ R 1 ) = ( R 3 ◦ R 2 ) ◦ R 1 .
Composition is Associative Theorem (Associativity of composition) Let S 1 , . . . , S 4 be sets and R 1 , R 2 , R 3 relations with R i ⊆ S i × S i +1 . Then R 3 ◦ ( R 2 ◦ R 1 ) = ( R 3 ◦ R 2 ) ◦ R 1 . Proof. It holds that ( x 1 , x 4 ) ∈ R 3 ◦ ( R 2 ◦ R 1 ) iff there is an x 3 with ( x 1 , x 3 ) ∈ R 2 ◦ R 1 and ( x 3 , x 4 ) ∈ R 3 .
Composition is Associative Theorem (Associativity of composition) Let S 1 , . . . , S 4 be sets and R 1 , R 2 , R 3 relations with R i ⊆ S i × S i +1 . Then R 3 ◦ ( R 2 ◦ R 1 ) = ( R 3 ◦ R 2 ) ◦ R 1 . Proof. It holds that ( x 1 , x 4 ) ∈ R 3 ◦ ( R 2 ◦ R 1 ) iff there is an x 3 with ( x 1 , x 3 ) ∈ R 2 ◦ R 1 and ( x 3 , x 4 ) ∈ R 3 . As ( x 1 , x 3 ) ∈ R 2 ◦ R 1 iff there is an x 2 with ( x 1 , x 2 ) ∈ R 1 and ( x 2 , x 3 ) ∈ R 2 , we have overall that ( x 1 , x 4 ) ∈ R 3 ◦ ( R 2 ◦ R 1 ) iff there are x 2 , x 3 with ( x 1 , x 2 ) ∈ R 1 , ( x 2 , x 3 ) ∈ R 2 and ( x 3 , x 4 ) ∈ R 3 .
Composition is Associative Theorem (Associativity of composition) Let S 1 , . . . , S 4 be sets and R 1 , R 2 , R 3 relations with R i ⊆ S i × S i +1 . Then R 3 ◦ ( R 2 ◦ R 1 ) = ( R 3 ◦ R 2 ) ◦ R 1 . Proof. It holds that ( x 1 , x 4 ) ∈ R 3 ◦ ( R 2 ◦ R 1 ) iff there is an x 3 with ( x 1 , x 3 ) ∈ R 2 ◦ R 1 and ( x 3 , x 4 ) ∈ R 3 . As ( x 1 , x 3 ) ∈ R 2 ◦ R 1 iff there is an x 2 with ( x 1 , x 2 ) ∈ R 1 and ( x 2 , x 3 ) ∈ R 2 , we have overall that ( x 1 , x 4 ) ∈ R 3 ◦ ( R 2 ◦ R 1 ) iff there are x 2 , x 3 with ( x 1 , x 2 ) ∈ R 1 , ( x 2 , x 3 ) ∈ R 2 and ( x 3 , x 4 ) ∈ R 3 . This is the case iff there is an x 2 with ( x 1 , x 2 ) ∈ R 1 and ( x 2 , x 4 ) ∈ R 3 ◦ R 2 , which holds iff ( x 1 , x 4 ) ∈ ( R 3 ◦ R 2 ) ◦ R 1 .
Transitive Closure Definition (Transitive closure) The transitive closure R ∗ of a relation R over set S is the smallest relation over S that is transitive and has R as a subset. The transitive closure always exists. Why? Example: If aRb specifies that block a lies on block b , what does R ∗ express?
Transitive Closure Definition (Transitive closure) The transitive closure R ∗ of a relation R over set S is the smallest relation over S that is transitive and has R as a subset. The transitive closure always exists. Why? Example: If aRb specifies that block a lies on block b , what does R ∗ express?
Transitive Closure Definition (Transitive closure) The transitive closure R ∗ of a relation R over set S is the smallest relation over S that is transitive and has R as a subset. The transitive closure always exists. Why? Example: If aRb specifies that block a lies on block b , what does R ∗ express?
Recommend
More recommend