Docstoc

relations

Document Sample
relations Powered By Docstoc
					Relations and Functions
Set theory provides a formal foundation for studying objects that are interesting and useful
in computer applications. When objects of several sets are related, we use more complex
sets called relations and functions to model their relationships. For example, the student
body and the academic departments in a college are related through the “Majors”
relationship, relating each student to the student’s current major(s). In another example, the
set of students and the set of classes offered in a given semester, are related based on the
classes taken by each student.
In this chapter, we will first study the formal definitions and properties of relations. We will
then study a restricted type of relations known as functions.
Relations
Notations and Definitions
Definition. A relation R defined over sets A and B is a (i.e. any) subset of A × B, that is, R ⊆
A × B. Such a relation is a binary relation; the degree of R is 2.
For each element (a, b) ∈ R of a binary relation R, we also write it as aRb.
Example. Let A = {Adam, John, Smith} be a set of students and B = {Art, History,
mathematics} be a set of departments. A relation, Student-major, showing the students and
their major(s) could be
 Student-major = {(Adam, History), (Adam, Mathematics), (John, Art), (Smith, History)}.
A binary relation R can be conveniently depicted by a directed graph, in which each pair
(a, b) ∈ R corresponds to a directed edge from vertex a to vertex b.
Example. The following digraph represents the Student-major relation defined in the
preceding example (p. 2-1).

                                        Art
          Adam



           John                         History



           Smith                        Mathematics

More generally, A relation can be defined over n sets, n ≥ 2.
Definition. An n-ary relation R over sets A1, A2, …, An , n ≥ 2, is a subset of the cartesian
                   n                  n
product      , that is,i R ⊆
                  ∏A             . The degree of R is n.
                                     ∏ Ai
                   i =1                i =1


Example. Consider the purchase of a new car, which frequently involves a buyer, a
salesperson, a new car, and a trade-in. Thus, a car purchase is a relation of degree 4,
because it can be considered as a subset of B × S × N × T, where B, S, N, and T stand for,
respectively, the sets of buyers, salespersons, new cars, and trade-ins.
We note here that a (finite) relation of any degree n can be conveniently represented by a
(two-dimensional) table of n columns, in which the rows of the table represent the tuples of
the relation. For example, a car sales table as described by the preceding example could be
depicted as follows:
             Buyer      Salesperson            New Car                Trade-in


             J. Smith   Mr. No-nonsense        Toyota Tacoma          Jeep Cherokee




In fact, the now popular relational database systems have their origin rooted in the theories
and properties of relations as studied in set theory, supplemented with implementation
techniques.
Properties and Manipulations of Binary Relations
Binary relations receive the most thorough studies because their simplicity, and because
that they form the basis for studying relations of higher degrees. We will consider the
following definitions and notations for binary relations.
Definition. Let R ⊆ A × B and S ⊆ B × C denote two relations. The composition of R and
S, denoted R S, is a binary relation over A and C defined as follows:
            R S = {(a, c)| a ∈ A and c ∈ C, and there exists b ∈ B such that aRb and bSc}.
Example. Let A = {a, b, c}, B = {1, 2}, and C = {p, q, r}. Define the relations
            R = {(a, 1), (a, 2), (b, 1), (c, 2)}, and S = {(1, p), (1, q), (2, r)}.
Then R S = {(a, p), (a, q), (a, r), (b, p), (b, q), (c, r)}.
The composition of two binary relations R ⊂ A × B and S ⊂ B × C can also be conveniently
depicted by “composing” the digraphs corresponding to R and S. That is, there is a
directed edge between x ∈ A and y ∈ C in R S iff there is a directed path of length 2
connecting vertex x, via a vertex z ∈ B, to vertex y, in the composed digraph.
Example. Two digraphs depicting R and S, and one digraph for R S of the preceding
example:
                 a                              p              a                      p
                                  1
                 b                              q
                                                               b                      q
                                  2
                 c                              r
                                                               c                      r
                         R            S                                 R S


Note that the digraph for the composition relation R S is the “composition” of the two
digraphs corresponding to, respectively, the relations R and S.
The following theorems summarize simple properties satisfied by relation compositions.
Theorem. Let R ⊆ A × B, S ⊆ B × C, and T ⊆ C × D denote three binary relations. Then
relation compositions satisfy the following associative law:
           (R S ) T = R (S T ).
Proof: We first note that both sides of the equation define a relation over A × D. We
also note the following:
(R S ) T = {(a, d)| a ∈ A and d ∈ D, and for some c ∈ C, (a, c) ∈ R S and cTd},
                    by the definition of T .
Since (a, c) ∈ R S means aRb and bSc for some b ∈ B, by definition of R S, the
relation (R S ) T consists of pairs (a, d) ∈ A × D such that for some b ∈ B and some c
∈ C, aRb, bSc and cTd. Similarly, by the definition of R ,
R (S T ) = {(a, d)| a ∈ A and d ∈ D, and for some b ∈ B, aRb and (b, d) ∈ S T}.
Since (b, d) ∈ S T means bSc and cTd for some c ∈ C; thus, the relation R (S T)
also consists of pairs (a, d) ∈ A × D such that for some b ∈ B and some c ∈ C, aRb, bSc
and cTd. Thus, (R S ) T = R (S T ), and the theorem is proved.
Example. Define 3 relations over A = {1, 2, 3}: R = {(1,2), (1,3)}, S = {(2,1), (3,2)},
and T = {(1,1), (2,3)}. Then, R S = {(1,1), (1,2)}, S T = {(2,1), (3,3)}, (R S ) T =
{(1,1), (1,3)} = R (S T).
Theorem. Let R ⊆ A × B, S ⊆ B × C, and T ⊆ B × C denote 3 binary relations. Then
(1) R (S ∪ T) = (R S) ∪ (R T);
(2) R (S ∩ T) ⊆ (R S) ∩ (R T). (In general, the two sides of (2) are not equal.)
Proof: (1) R (S ∪ T) = {(a, c)| a ∈ A and c ∈ C, and for some b ∈ B, aRb and (b, c)
                               ∈ S ∪ T}, definition of
                      = {(a, c)| a ∈ A and c ∈ C, and for some b ∈ B, aRb and ((b, c)
                                 ∈ S or (b, c) ∈ T)}, definition of ∪
                      = {(a, c)| a ∈ A and c ∈ C, and for some b ∈ B, (aRb and (b, c)
                                 ∈ S) or (aRb and (b, c) ∈ T)}, distributive law of and
                                 over or
                      = {(a, c)| a ∈ A and c ∈ C, and for some b ∈ B, aRb and (b, c)
                         ∈ S} ∪ {(a, c)| a ∈ A and c ∈ C, and for some b ∈ B, aRb
                         and (b, c) ∈ T}, definition of ∪
                      = (R S) ∪ (R T), definition of (R S) and (R T).
(2) If (a, c) ∈ R (S ∩ T), then there exists b ∈ B, such that aRb and (b, c) ∈ (S ∩ T),
by the definition of . Thus, (b, c) ∈ S and (b, c) ∈ T, by the definition of S ∩ T.
Therefore, since aRb, so (a, c) ∈ (R S) and (a, c) ∈ (R T), by the definition of .
Thus, (a, c) ∈ (R S) ∩ (R T), and (2) is proved.
When binary relation R is defined over a single set A, i.e., R ⊆ A × A, which is most
common in applications, we have the following definitions.
Definition. Let R ⊆ A × A be a binary relation.
(1) R is reflexive if for all a ∈ A, aRa, i,e., (a, a) ∈R. (In words, each element a of A is
related to itself via R.)
(2) R is irreflexive if for all a ∈ A, (a, a) ∉ R. (In words, each element a of A is not
related to itself via R.)
(3) R is symmetric if aRb implies bRa, i.e., for all (a, b) ∈ R, (b, a) ∈ R. (In words,
whenever a is related to b, b is related to a.)
(4) R is anti-symmetric if aRb and bRa imply a = b. Equivalently, this means if a ≠ b,
then (a, b) ∈ R implies (b, a) ∉ R. (In words, whenever a is related to b, and if a ≠ b,
then b is not related to a.)
(5) R is transitive if aRb and bRc imply aRc, i.e., if (a, b) ∈ R and (b, c) ∈ R, then (a, c)
∈ R. (In words, whenever a is related to b, and b is related to c, then a is related to c.)
Example. The relation R defined over {a, b, c} by the following                 a

digraph is not reflexive (e.g. (a, a) ∉ R); not irreflexive
(e.g., (c, c) ∈ R); not symmetric (e.g., (a, c) ∈ R but (c, a) ∉ R);                 c

not anti-symmetric (e.g. (a, b) ∈ R and (b, a) ∈ R, but a ≠ b);          b
and not transitive (e.g., (a, b) ∈ R and (b, a) ∈ R, but (a, a) ∉ R).
Example. Let A denote a non-empty set, and let Power(A) denote the power set of A,
i.e., the set of all subsets of A. The subset inclusion relationship, temporarily called SI
in this example, can be defined as a binary relation over Power(A) as follows:
            SI = {(a, b)| a ∈ Power(A) and b ∈ Power(A), and a ⊆ b}.
That is, (a, b) ∈ SI iff a ⊆ A, b ⊆ A, and a ⊆ b. Note that this set inclusion relation is
reflexive, anti-symmetric, and transitive.
Example. Consider a set S of the points (x, y) in the 2-dimensional plane, both x and y
are real numbers, such that (x – y)(x2 + y2 – 1) = 0. Thus, the set S is a relation over the
set of real numbers. Since the solutions to the equation (x – y)(x2 + y2 – 1) = 0 must
satisfy either x – y = 0 or x2 + y2 – 1 = 0, with the former (x – y = 0) being a line while
the latter (x2 + y2 – 1 = 0) the unit circle, the following graph depicts this relation S:
                                   y
          x2 + y2 – 1 = 0                 x–y=0

                               O
                                               x



Note that the relation S is reflexive and symmetric; S is not anti-symmetric (e.g., points
(1,0) and (0,1) both ∈ S), S is not irreflexive (because it is reflexive), and S is not
transitive (e.g., points (1,0) and (0,–1) both ∈ S, but the point (1,–1) ∉ S).
Example. Let Z denote the set of all integers (positive, zero, or negative). Define a binary
relation GE (for greater-than-or-equal-to) over Z as follows:
           GE = {(a, b)| a, b ∈ Z and a ≥ b}.
Thus, an element (a, b) ∈ GE, or a GE b, iff a ≥ b.
The relation GE is (1) reflexive because a ≥ a for all a ∈ Z; (2) anti-symmetric because if a
≥ b and b ≥ a, then a = b; (3) transitive because if a ≥ b and b ≥ c, then a ≥ c.
One important type of binary relations is an equivalence relation, defined as follows.
Definition. A binary relation R ⊆ A × A is an equivalence relation if R is reflexive,
symmetric, and transitive.
The reason that motives this definition is that equivalence relations provide a useful yet
simple notion for describing a set where related elements (via a relation R) are grouped
together. Let us consider some examples of equivalence relations.
Example. In a school class where the final grades are determined based on the straight-
percentage scale. That is, a person that earns 90% or above of the total points receives an
‘A’ grade; 80 to 89.99% receives a ‘B’ (using a two-decimal-place precision); 70 to 79.99%
receives a ‘C’ grade; 60 to 69.99% receives a ‘D’ grade; below 60% an ‘F’ grade. One
formal method that distinguishes the class of students is to define a relation R over the set of
students A, such that for students a and b, aRb iff a and b belong to the same percentage
point category. Then, it’s easy to see that relation R defines an equivalence relation, which
partitions set A into a disjoint union of groups of students based on their grades.
Definition. Let m ≥ 2 be an integer. Define a binary relation called modulus m and
denoted ≡m , over the set of integers Z, as follows:
           for integers a and b, a ≡m b iff m | (a – b), that is, a – b = mq for some integer q.
For example, when m = 5, we have 0 ≡5 5 ≡5 10, 1 ≡5 6 ≡5 11, etc. Two numbers a and b
such that a ≡m b, are called congruent mod m, often denoted a ≡ b (mod m).
Theorem. For m ≥ 2, the Modulus m relation is an equivalence relation.
Proof: We need to prove the relation ≡m is reflexive, symmetric, and transitive.
To prove the reflexive property, we need to prove a ≡m a for all a ∈ Z, that is, m | (a – a).
This is true, because a – a = 0 = m · 0, for all a ∈ Z.
To prove the symmetric property, we need to prove if a ≡m b then b ≡m a. Since a ≡m b
implies a – b = mq for some integer q, by definition of the modulus m relation. Thus,
multiplying this equation by (– 1) yields b – a = m (– q); thus, b ≡m a by definition.
To prove the transitive property, we need to prove if a ≡m b and b ≡m c, then a ≡m c. Note
that by the definition of ≡m , we have a – b = mp and b – c = mq , for some integers p and q.
Adding these two equations yields
           (a – b) + (b – c) = a – c , associative law and additive inverses, i.e. (– b) + b = 0
                            = mp + mq = m(p + q), distributive law.
Since (p + q) is an integer by the closure property of integer addition, the above equation
implies m | (a – c), i.e., a ≡m c, by definition of ≡m .
Similar to the example of student grades, the modulus m relation defined over the set of
integers Z divides Z into a disjoint union of m subsets, called a partition of Z. A list of
“representatives” for these m subsets could be 0, 1, 2, …, (m–1), in that these m
representatives are mutually non-congruent mod m, and any integer must be congruent to
exactly one of these representatives. More formally and generally, we have the
following definition and theorem for any equivalence relation.
Definition. Let R be an equivalence relation defined over a set A. For x ∈A, the
equivalence class containing x, denoted [x], is defined as follows:
           [x] = {a| a ∈ A, and aRx}, i.e., [x] contains all elements of A related to x.
Theorem. If R ⊆ A × A be an equivalence relation. Then the set of equivalence classes
defines a partition of A; that is,
           (1) for x ∈ A and y ∈ A, either [x] = [y] or [x] ∩ [y] = ∅;
           (2) for each x ∈ A, x ∈ [x].
Proof: (1) It suffices to prove that if [x] ∩ [y] ≠ ∅, then [x] = [y], by the contrapositive
law. Let z ∈ [x] ∩ [y]. Thus, zRx and zRy, by the definition of [x] and [y]. Note that zRx
implies xRz because R is symmetric. Thus, xRz and zRy imply xRy by the transitive
property of R. We now claim [x] ⊆ [y]. Note that a ∈ [x] implies aRx, which implies
aRy because xRy and by transitivity; thus, a ∈ [y] by definition of [y], so [x] ⊆ [y].
Similarly, [y] ⊆ [x]. Therefore, [x] = [y] by the definition of set equality.
(2) x ∈ [x] is true because xRx by the reflexive property of R.
As a consequence of the preceding theorem (p. 4-11), if R is an equivalence relation
defined over a set A, we use the notation A/R to denote the set of these equivalence
classes; that is,
            A/R = {[x] | x ∈ A}.
                                                                            A Partition



The converse of the preceding theorem (p. 2-11) is also true, proved as follows.
Theorem. Let A denote a (non-empty) set and Π be a partition of A, i.e., Π is a set of
disjoint subsets of A such that each element of A belongs to exactly one of such subsets.
The relation R over A induced by Π is defined as follows:
           for x and y ∈ A, xRy iff x and y belong to the same subset in the partition Π.
Then R is an equivalence relation over A.
Proof: We need to prove R is reflexive , symmetric, and transitive.
For each x ∈ A, we have xRx because x and itself belong to the same subset in Π. This
proves the reflexive property. The symmetric property requires that xRy implies yRx,
but this is true because in both cases, the relationship means x and y belong to the same
subset. Finally, to prove the transitive property, suppose xRy and yRz. That is, x and y
belong to the same subset, and y and z belong to the same subset. This implies that x
and z belong to the same subset in Π. Thus, xRz is proved.
Functions
Notations and definitions
We consider a special type of relations known as functions in this section. Recall that a
binary relation R ⊆ A × B is used to model a relationship between elements of A and
elements of B; thus, an ordered pairs (a, b) ∈ R means that the elements a and b are
“related”. In general, an element of A may be related to zero, one, or more elements of
B. Consider the following example of a Student-Classes relation which shows how a set
of students are related to a set of classes taken by the students.
Example:                                                  Animation
                         Adam
                                                          Calculus
                            John
                                                          Composition
                            Rice

                                                          Speech
                         Smith

                                                          Writing



Note that in the example, both Adam and John are taking multiple classes, Rice is taking
one class, and Smith is taking zero classes. We also note that the classes taken by Adam
and John overlap; the class Composition is not taken by any students.
Definition. A binary relation R ⊆ A × B is called a function if for each element a ∈ A
there exists a unique (i.e., one and only one) element b ∈ B such that (a, b) ∈ R.
Thus, the preceding Student-classes relation is not a function because of 3 violations: (1)
Adam is related to two classes; (2) John is related to two classes; and (3) Smith is related
to zero classes.
Definition. If a relation R ⊆ A × B is a function, the set A is called the domain, the set B
is the co-domain. Typically, a function is denoted by lower-case letter f (or g, h), and we
use the notation f: A → B to mean that f is a function defined from A to B. For each
element a ∈ A, the unique element that is related to a is denoted f(a) and called the
image of a, and a the pre-image of f(a). Thus, b = f(a) iff (a, b) ∈ f, where f is considered
as a relation. The set of all images, denoted f(A) = {f(a)| a ∈ A}, is the range of f.
The following picture is often used to depict a function f from A to B, or we say f maps A
to B.
                                                         B
                                      f
                            A                    f(A)




Note that in general, the image of the function, f(A), is a proper subset of B; that is f(A)
⊆ B but f(A) ≠ B.
It is quite common in sciences that a function is given by a formula, or an expression,
when the domain and the range are numbers. In this case, a function can be
represented by its graph in the coordinate system, usually in 2 dimensions.
Example. Consider the following functions f and g defined by formulas:
           f: R → R , f(x) = 2x + 1, where R denotes the set of real numbers; and
           g: [0, 1] → [0, 1], g(x) =     1 − x 2, where [0, 1] = {x| x ∈ R, 0 ≤ x ≤ 1}.
The graph of f is a line, and the graph of g is a quarter-circle, depicted as follows:


                                       f(x) = 2x + 1
                               (0,1)
                                         g(x) = 1 − x 2

                      (–1,0)            (1,0)




The domain of a function may be a Cartesian product of two sets; for example, f: A×B
→ C. In this case, for an element (a, b) ∈ A × B, its image under f is denoted f(a, b);
we say f is a two-variable function. Functions of n variables f: A1 × A2 × … × An → C,
n ≥ 2, are also possible.
Example. Define a 2-variable function f: Z × (Z − {0}) → Q as follows, where Z and
Q stand for the sets of, respectively, integers and rational numbers:
                       n
           f(n, m) =       , if m ≠ 0.
                       m
The images (i.e. function values) contain all fractional numbers (known as rational
numbers). Note that different elements of the domain can be mapped to the same
image. For example, f(1, 2) = f(2, 4) = 1 .
                                           2
Properties of Functions
Similar to the composition of relations, functions can be composed to form other
functions. We first consider one example.
Example. The following figures show two functions f and g considered as relations,
and the composed relation g f. (Note that in the context of function composition,
the order in which the functions appear is backward, i.e. the first function is at the
end.)
                  f           g                                            p
                                     p                      1
             1                                                             q
                        a            q                      2
             2          b            r                                     r
                                                            3
             3          c                                                  t
                                     t
                                                                 g f
Theorem. Let f: A → B and g: B → C be two functions. The composition of f and
g as relations defines a function g f : A → C, such that g f (a) = g(f(a)).
Proof: We need to show that for each element a ∈ A, the expression (or formula)
g(f(a)) assigns the unique element of C related to a based on the composition of f
and g considered as relations. By the definition of relation composition,
            g f = {(a, c) | a ∈ A and c ∈ C, there exists b ∈ B such that (a, b) ∈ f
                            and (b, c) ∈ g }.
However, (a, b) ∈ f means b = f (a) using the function notation, and (b, c) ∈ g
means c = g(b) by the function notation. Thus, the relation g f contains pairs
(a, c) with a ∈ A and c ∈ C, such that c = g(b) = g(f (a)), by substitutions. Further,
this element c that is related to element a via the composed relation g f is unique;
thus, the relation g f defines a function g f : A → C.
Example. Define function f: R → R and function g: R → R by the formulas f(x) =
x2 and g(x) = x + 1, where the set R denotes the set of real numbers. Thus,
            g f (x) = g(f(x)) = g(x2 ) = x2 + 1; and
            f g (x) = f(g(x)) = f(x + 1) = (x + 1)2.
Note that if two function f and g both map a set A to A, then the functions can be
composed in two different ways: g f and f g. In general, g f ≠ f g, as can be
seen from the preceding example.
Some functions satisfy additional properties, such as mapping distinct elements to
distinct images. The following definition formalizes these properties.
Definition. Let f: A → B be a function.
(1) f is injective, or is one-to-one, if for all a, b ∈ A, a ≠ b ⇒ f(a) ≠ f(b). Equivalently,
this means if f(a) = f(b) then a = b. We also say f is an injection in this case.
(2) f is surjective, or is onto, if f(A) = B. That is, if for every b ∈ B there exists a ∈ A
such that f(a) = b. We also say f is a surjection in this case.
(3) f is bijective if it is both injective and surjective. We also say f is a bijection in this
case.
Example. Consider the following functions and their properties:
            f : {1, 2, 3} → {a, b, c}, f(1) = f(2) = a, f(3) = b. Then, f is not injective
because it maps distinct elements 1 and 2 to the same image a. Also, f is not
surjective because no elements of A are mapped to element c.
            g(x) = 2x + 1, g: R → R , is a bijection, because if g(x) = g(y), i.e., if 2x +
1 = 2y + 1, then x = y , which proves that g is one-to-one. Also, for each y ∈ R,
solving 2x + 1 = y yields x = (y – 1) / 2, which is a real number if y ∈ R. Thus, we
found x ∈ R such that g(x) = 2x + 1 = y, proving that g is onto.
           h(x) = x2, h: R → R, is not one-to-one because h(1) = h(–1) = 1. Also, h is
not onto because h(x) ≥ 0 for all x ∈ R; thus, for example, there is no x ∈ R, x2 = –1.
Theorem. Consider functions f: A → B and g: B → C, and the composition g f : A → C.
(a) If both f and g are injective, then g f is injective.
(b) If both f and g are surjective, then g f is surjective.
(c) If both f and g are bijective, then g f is bijective.
Proof: (1) To prove g f is injective, we need to prove that for a, b ∈ A,
            if g f (a) = g f (b) --------- (1)
            then a = b ----------- (2), by the definition of injection.
Since g f (a) = g(f(a)) and g f (b) = g(f(b)), by the definition of g f , substituting into
(1) yields g(f(a)) = g(f(b)) ---------- (3).
Note that (3) implies f(a) = f(b) -------- (4), because g is injective. Also note that (4)
implies a = b because f is injective; thus, (2) is proved.
(b) To prove g f is surjective, we need to prove that for all c ∈ C, there exists a ∈ A such
that g f (a) = c --------- (1).
Note that since g: B → C is surjective, there exists b ∈ B such that g(b) = c ---------- (2).
Also, since f: A → B is surjective, there exists a ∈ A such that f (a) = b --------- (3). Thus,
g f (a) = g(f(a)) = g(b) = c, by substitutions of (2) and (3). Thus, (1) is proved.
(c) If both f and g are bijective, then both f and g are injective and surjective. By Parts (a)
and (b), g f is injective and surjective, so g f is bijective.
A bijection f: A → B maps each element of A to a unique element of B, and conversely,
each element of B has a unique element of A as its pre-image. The following theorem
makes a precise statement of this relationship.
Theorem. Let f: A → B be a bijection. Then the inverse relation of f, defined from B to
A as {(b, a) | b ∈ B and a ∈ A, and f (a) = b}, is a function from B to A such that g f(a)
= a for all a ∈ A, and f g(b) = b for all b ∈ B. The function g is called the inverse
function of f, denoted f–1.
Proof: Note that since f: A → B is a bijection, for each b ∈ B there exists one and only
one element a ∈ A, such that f (a) = b. Thus, the relation from B to A, relating b ∈ B to
its pre-image a ∈ A under f, is a function by the definition of function. That is, we have
defined a function
           g: B → A such that for b ∈ B, g(b) = a iff f (a) = b --------- (1)
Thus, g f (a) = g(f(a)), by definition of g f
               = a, by (1) . (i.e., call f(a) = b, then g(b) = a, and g(f(a)) = g(b) = a)
Similarly, f g(b) = f(g(b)), by definition of f g
                  = b, by (1). (i.e., call g(b) = a, then f (a) = b; thus, f(g(b)) = f (a) = b)
Example. A bijection f: R → R such that f(x) = 2x + 1. Its inverse function f–1 (y) = (y–
1) / 2. Note that f–1 f(x) = f–1 (2x + 1) = ((2x + 1) –1) / 2 = x. Similarly, f f–1 (y) =
f((y–1) / 2) = 2 ((y–1) / 2) + 1 = y.
The converse of the preceding theorem is also true.
Theorem. Let f: A → B and g: B → A be two functions. If g f(a) = a for all a ∈ A, and f
g(b) = b for all b ∈ B, then both f and g are bijections, and they are inverse functions of each
other, that is, g = f–1 and f = g–1.
Proof: We first prove that if
             g f(a) = a, for all a ∈ A -------- (1), and f g(b) = b, for all b ∈ B -------- (2),
then f is a bijection and g = f–1 ------------- (3).
We first prove that f is an injection. That is, suppose f(a) = f(a’), for a, a’ ∈ A ------- (4), we
want to prove that a = a’ ---------- (5). Applying function g to (4) yields
             g(f(a)) = g(f(a’)), because g is a function.
Thus, a = a’ because g(f(a)) = a and g(f(a’)) = a’, according to (1). So (5) is proved.
We then prove that f is a surjection; that is, we prove that for each b ∈ B, there exists a ∈ A
such that f(a) = b ------ (6). Let a = g(b). Then, f(a) = f(g(b)) = b, by (2). So (6) is proved.
We now prove that g = f–1. Consider an arbitrary a ∈ A. If f(a) = b ∈ B, then according to
(1), g(b) = g(f(a)) = a ----- (7). Conversely, for an arbitrary b ∈ B, if g(b) = a, then f(a) =
f(g(b)) = b ----- (8), according to (2). Thus, (7) and (8) imply that g(b) = a iff f(a) = b; thus,
g = f–1. So (3) is proved. By the symmetry between f and g, we can similarly prove that g is
a bijection and f = g–1. Thus, the theorem is proved.
When two functions f: A → B and g: B → A are inverses of each other, we have the
relationship g f(a) = a for all a ∈ A, or, equivalently, g f = IA, where IA denotes the
identity function defined on A (i.e., IA (a) = a for all a ∈ A). Similarly, we have f g =
IB, the identity function defined on B.
The following theorem shows how to compute the inverse of a composition.
Theorem. If f: A → B and g: B → C are two bijections. Then (g f )–1 = f –1 g–1.
Proof: Since both f and g are bijections, g f is also a bijection (Theorem on p. 2-19)
and its inverse exists (Theorem on p. 2-20). To prove (g f ) –1 = f–1 g–1, it suffices to
prove that
            (g f ) (f–1 g–1) = IC ----- (1), and (f–1 g–1) (g f ) = IA ----- (2),
according to the theorem on p. 2-21.
To prove (1), note that
           (g f ) (f–1 g–1) = ((g f ) f–1) g–1, by the associative property of
                                relation composition (Theorem on p. 2-5).
                              = (g (f     f–1)) g–1 , by the associative property
                              = (g IB) g–1 = g g–1 = IC , by the comment preceding
                                            the theorem, and by the fact g IB = g.
So (1) is proved. Similarly, (2) can be proved.
Example. Consider the following bijections (from p. 2-15):
             f: [–0.5, 0] → [0, 1], f(x) = 2x + 1, and
            g: [0, 1] → [0, 1], g(x) = 1 − x 2 ,
where [–0.5, 0] = {x| x ∈ R, –0.5 ≤ x ≤ 0}, and [0, 1] = {x| x ∈ R, 0 ≤ x ≤ 1}.
Thus, g f : [–0.5, 0] → [0, 1] is a bijection, and g f (x) = g(f(x)) = g(2x + 1) =       1 − (2 x + 1) 2

and (g f )–1(x) = f –1 g–1 (x) = f –1( 1 − x 2 ) = (( 1 − x 2 ) – 1) / 2.
This is true because by letting y = g(x), and solving for x in terms of y, we find x =      1− y2   .
Thus, g–1 (y) = 1 − y 2. Similarly, f –1(y) = (y – 1) / 2.
Some applications of functions
One of the most important applications of bijective functions is in the area of counting.
Theorem (The Counting Principle). If A and B are two finite sets.
(1) If there is a injection f: A → B, then |A| ≤ |B| ;
(2) If there is a surjection g: A → B, then |A| ≥ |B| ;
(3) If there is a bijection h: A → B, then |A| = |B|.
The idea of these results is very simple. If f: A → B is an injection, and if we enumerate the
elements of A as A = {a1, a2, …, an}, where n = |A|, then the images f (a1), f (a2), …, f (an), are
mutually distinct because f is one-to-one. Thus, |B| ≥ n because B contains these n elements.
Similarly, if g: A → B is a surjection, and if we enumerate the elements of B as B = {b1, b2,
…, bm}, then A must contain the pre-images of the elements of B. Suppose we use the
notations a1, a2, …, am to denote, respectively, the pre-images of b1, b2, …, bm; thus, g(ai)
= bi for 1 ≤ i ≤ m. Since g is a function, the elements a1, a2, …, am must be mutually
distinct (i.e., if ai = aj for some i ≠ j, then bi = g(ai) = g(aj) = bj , a contradiction). Therefore,
|A| ≥ m = |B|.
Property (3) is a consequence of (1) and (2), because |A| ≤ |B| and |A| ≥ |B| imply |A| = |B|.
Let us consider some applications of the Counting Principle.
Theorem. Let A = {a1, a2, …, an} be a set of n elements. Then |Power(A)| = 2n = 2|A|.
Proof: If n = 0, then A = ∅, and Power(A) = {∅}, so |Power(A)| = 1 = 20.
Suppose n ≥ 1. Let B = {0, 1} denote the set of 2 binary digits 0 and 1. Define the
                                                         n
Cartesian product of B with itself for n times, Bn = ∏ B = B × B × … × B (for n times).
                                                       i =1
Thus, each element of Bn is an n-tuple (b1, b2, …, bn), where bi = 0 or 1, for 1 ≤ i ≤ n.
Also, since |B| = 2, we have |Bn | = 2n by the Product Principle (p. 1-19). We now want to
find a bijection between the set Bn and Power(A), the set of all subsets of A. Define a
function f: Bn → Power(A), f(b1, b2, …, bn) = {ai | 1 ≤ i ≤ n and bi = 1}, that is, we include
element ai in the image (subset) iff the corresponding bi = 1. Similarly, we define a
function g: Power(A) → Bn such that if g(C) = (b1, b2, …, bn) where C ⊂ A, then bi = 1 iff
the corresponding ai ∈ C. These two functions f and g are inverses of each other, which
implies that f is a bijection; thus, |Power(A)| = 2n, by the Counting Principle.
Theorem. Let A denote a finite set and |A| = n, n ≥ 1. Then for 0 ≤ k ≤ n, the number
of subsets of A of size k = the number of subsets of A of size n – k.
(For example, let A = {1, 2, 3}. Then, there are 3 subsets of A of size 1: {1}, {2}, and
{3}; also, there are 3 subsets of A of size 2: {2, 3}, {1, 3}, and {1, 2}.)
Proof: Define the following (temporary) notation:
            Ak = {B| B ⊆ A and |B| = k}, for 0 ≤ k ≤ n; that is, Ak is the set of all subsets
            of A of size k.
Thus, we need to prove | Ak | = | An–k | ------- (1).
We define a function f: Ak → An–k , f(B) = A – B. That is, the function f maps a subset B
of A to the complement of B within A. In order to prove (1), it suffices to prove that f
is a bijection, by the Counting Principle Theorem on p. 2-23.
We first note that the function f is well-defined, in that it is indeed a function from Ak
to An–k. This is true because if |B| = k, then |A – B| = n – k. To prove that f is a
bijection, it suffices to find an inverse function as follows:
            Define g: An–k → Ak , g(B) = A – B.
Similar to the previous argument, the function g is well-defined. Also, it is simple to
verify that g f (B) = g(f(B)) = g(A – B) = A – (A – B) = B, and similarly, f g (B) = B.
Thus, g and f are inverse functions of each other (theorem on p. 2-21), and they are
bijections. Thus, (1) is proved.
Here is one more application of the counting principle (a counting argument):
Theorem. The sum of the first n odd numbers, 1 + 3 + … + (2n – 1) = n2, for n ≥ 1.
Proof: We will give a bijection between the sum of these odd numbers and the individual
dots that are arranged in an n by n square grid (see figure below for a 4 by 4 grid). We
enumerate the dots by a sequence of n steps. First, the lower left corner is listed. The
second step enumerates the dot above the lower-left corner, the dot to its right, and the dot
below the second, completing a T-shape with only the left-half of the head of T.
Similarly, the third step starts with the third dot counting up from the lower-left corner,
moving across right for two dots, then turning downward for 2 dots. This process
continues for a total of n steps, which will cover all the dots in the square grid.
We notice that in step k, 1 ≤ k ≤ n, there are exactly 2k – 1 dots visited;
this is because there are k dots across to its rightmost dot, and there are
then k – 1 dots moving downward to the end. Thus, we have defined a
one-to-one correspondence between the first n odd numbers, and the
individual dots in an n by n square grid, mapping the kth odd number to
those dots visited in the kth step of the enumeration. The Counting
Principle theorem (on p. 2-23) implies the “sizes” of the two
corresponding sets must be identical. Thus, we proved
                  n
                  ∑ (2k − 1) = n .
                                2
                 k =1

				
DOCUMENT INFO