Composition of Relations
In math class, given two functions f(x) and g(x), you probably
had to figure out the composition of the functions, which is
denoted either by f(g(x)) OR f
°
g(x).
Basically, the way this worked is that you “plugged in” your
original x into one function, THEN you used the “answer” that
you got from that function to “plug in” to the second function.
And the order in which you did it mattered.
The same will be true of the composition of two relations. Here
is the formal definition of the composition of two relations R
and S, where R
⊆
A x B, S
⊆
B x C:
R
°
S = { (a,c) | a
∈
A
∧
c
∈
C
∧
(
5
b | (a,b)
∈
R
∧
(b,c)
∈
S) }
(Notice the difference in order here. When we compose a
relation, we write the relations in the order we apply them, not
the opposite order, as is done with functions.) Basically, when
you compose the relations R and S, you get a third relation
which relates elements from the set A to the set C, as long as
the “answer” from relation R can be the input for relation S.
We can use a directed graph again. Consider this example:
A = { ABC, NBC, CBS, FOX, HBO}
B = { NYPD Blue, Simpsons, Letterman, ER, X-Files,
Dennis Miller Show, Monday Night Football}
C = { Dennis Miller, Marge, Rick Schroeder, Gillian Anderson,
Noah Wyle}
R = {(ABC, NYPD Blue), (NBC, ER), (CBS,Letterman),
(HBO, Dennis Miller Show), (FOX, X-Files) }
S = { (MNF, Dennis Miller), (Simpsons, Marge),
(ER, Noah Wyle), (Party of 5, Neve Campbell)