0% found this document useful (0 votes)
33 views33 pages

LLM Data Types

This document discusses mathematical data types, focusing on sets, sequences, and functions. It provides definitions, properties, and operations related to sets, including union, intersection, and set builder notation. Additionally, it introduces functions, their domains, and how they can be defined and represented.

Uploaded by

abinemo51
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views33 pages

LLM Data Types

This document discusses mathematical data types, focusing on sets, sequences, and functions. It provides definitions, properties, and operations related to sets, including union, intersection, and set builder notation. Additionally, it introduces functions, their domains, and how they can be defined and represented.

Uploaded by

abinemo51
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

“mcs” — 2017/6/5 — 19:42 — page 97 — #105

4 Mathematical Data Types


We have assumed that you’ve already been introduced to the concepts of sets, se-
quences, and functions, and we’ve used them informally several times in previous
sections. In this chapter, we’ll now take a more careful look at these mathemati-
cal data types. We’ll quickly review the basic definitions, add a few more such as
“images” and “inverse images” that may not be familiar, and end the chapter with
some methods for comparing the sizes of sets.

4.1 Sets
Informally, a set is a bunch of objects, which are called the elements of the set.
The elements of a set can be just about anything: numbers, points in space, or even
other sets. The conventional way to write down a set is to list the elements inside
curly-braces. For example, here are some sets:

A D fAlex; Tippy; Shells; Shadowg dead pets


B D fred; blue; yellowg primary colors
C D ffa; bg; fa; cg; fb; cgg a set of sets

This works fine for small finite sets. Other sets might be defined by indicating how
to generate a list of them:

D WWD f1; 2; 4; 8; 16; : : :g the powers of 2

The order of elements is not significant, so fx; yg and fy; xg are the same set
written two different ways. Also, any object is, or is not, an element of a given set—
there is no notion of an element appearing more than once in a set.1 So, writing
fx; xg is just indicating the same thing twice: that x is in the set. In particular,
fx; xg D fxg.
The expression “e 2 S” asserts that e is an element of set S. For example,
32 2 D and blue 2 B, but Tailspin 62 A—yet.
Sets are simple, flexible, and everywhere. You’ll find some set mentioned in
nearly every section of this text.
1 It’s
not hard to develop a notion of multisets in which elements can occur more than once, but
multisets are not ordinary sets and are not covered in this text.
“mcs” — 2017/6/5 — 19:42 — page 98 — #106

98 Chapter 4 Mathematical Data Types

4.1.1 Some Popular Sets


Mathematicians have devised special symbols to represent some common sets.

symbol set elements


; the empty set none
N nonnegative integers f0; 1; 2; 3; : : :g
Z integers f: : : ; 3; 2; 1; 0; 1; 2; 3; : : :g
1 5
Q rational numbers 2; 3 ; 16;petc.
R real numbers ; e; p9; 2; etc.
C complex numbers i; 192 ; 2 2i; etc.

A superscript “C ” restricts a set to its positive elements; for example, RC denotes


the set of positive real numbers. Similarly, Z denotes the set of negative integers.

4.1.2 Comparing and Combining Sets


The expression S  T indicates that set S is a subset of set T , which means that
every element of S is also an element of T . For example, N  Z because every
nonnegative integer is an integer; Q  R because every rational number is a real
number, but C 6 R because not every complex number is a real number.
As a memory trick, think of the “” symbol as like the “” sign with the smaller
set or number on the left-hand side. Notice that just as n  n for any number n,
also S  S for any set S .
There is also a relation  on sets like the “less than” relation < on numbers.
S  T means that S is a subset of T , but the two are not equal. So just as n 6< n
for every number n, also A 6 A, for every set A. “S  T ” is read as “S is a strict
subset of T .”
There are several basic ways to combine sets. For example, suppose

X WWD f1; 2; 3g;


Y WWD f2; 3; 4g:

Definition 4.1.1.

 The union of sets A and B, denoted A [ B, includes exactly the elements


appearing in A or B or both. That is,

x 2A[B IFF x 2 A OR x 2 B:

So X [ Y D f1; 2; 3; 4g.
“mcs” — 2017/6/5 — 19:42 — page 99 — #107

4.1. Sets 99

 The intersection of A and B, denoted A \ B, consists of all elements that


appear in both A and B. That is,

x 2A\B IFF x 2 A AND x 2 B:

So, X \ Y D f2; 3g.

 The set difference of A and B, denoted A B, consists of all elements that


are in A, but not in B. That is,

x2A B IFF x 2 A AND x … B:

So, X Y D f1g and Y X D f4g.

Often all the sets being considered are subsets of a known domain of discourse
D. Then for any subset A of D, we define A to be the set of all elements of D not
in A. That is,
A WWD D A:
The set A is called the complement of A. So

A D ; IFF A D D:

For example, if the domain we’re working with is the integers, the complement
of the nonnegative integers is the set of negative integers:

NDZ :

We can use complement to rephrase subset in terms of equality

A  B is equivalent to A \ B D ;:

4.1.3 Power Set


The set of all the subsets of a set A is called the power set pow.A/ of A. So

B 2 pow.A/ IFF B  A:

For example, the elements of pow.f1; 2g/ are ;; f1g; f2g and f1; 2g.
More generally, if A has n elements, then there are 2n sets in pow.A/—see The-
orem 4.5.5. For this reason, some authors use the notation 2A instead of pow.A/.
“mcs” — 2017/6/5 — 19:42 — page 100 — #108

100 Chapter 4 Mathematical Data Types

4.1.4 Set Builder Notation


An important use of predicates is in set builder notation. We’ll often want to talk
about sets that cannot be described very well by listing the elements explicitly or
by taking unions, intersections, etc., of easily described sets. Set builder notation
often comes to the rescue. The idea is to define a set using a predicate; in particular,
the set consists of all values that make the predicate true. Here are some examples
of set builder notation:

A WWD fn 2 N j n is a prime and n D 4k C 1 for some integer kg;


B WWD fx 2 R j x 3 3x C 1 > 0g;
C WWD fa C bi 2 C j a2 C 2b 2  1g;
D WWD fL 2 books j L is cited in this textg:
The set A consists of all nonnegative integers n for which the predicate
“n is a prime and n D 4k C 1 for some integer k”
is true. Thus, the smallest elements of A are:
5; 13; 17; 29; 37; 41; 53; 61; 73; : : : :
Trying to indicate the set A by listing these first few elements wouldn’t work very
well; even after ten terms, the pattern is not obvious. Similarly, the set B consists
of all real numbers x for which the predicate
x3 3x C 1 > 0
is true. In this case, an explicit description of the set B in terms of intervals would
require solving a cubic equation. Set C consists of all complex numbers a C bi
such that:
a2 C 2b 2  1
This is an oval-shaped region around the origin in the complex plane. Finally, the
members of set D can be determined by filtering out journal articles in from the list
of references in the Bibliography 22.5.

4.1.5 Proving Set Equalities


Two sets are defined to be equal if they have exactly the same elements. That is,
X D Y means that z 2 X if and only if z 2 Y , for all elements z.2 So, set
equalities can be formulated and proved as “iff” theorems. For example:
2 Thisis actually the first of the ZFC axioms for set theory mentioned at the end of Section 1.3
and discussed further in Section 8.3.2.
“mcs” — 2017/6/5 — 19:42 — page 101 — #109

4.1. Sets 101

Theorem 4.1.2. [Distributive Law for Sets] Let A, B and C be sets. Then:

A \ .B [ C / D .A \ B/ [ .A \ C / (4.1)

Proof. The equality (4.1) is equivalent to the assertion that

z 2 A \ .B [ C / iff z 2 .A \ B/ [ .A \ C / (4.2)

for all z. Now we’ll prove (4.2) by a chain of iff’s.


Now we have

z 2 A \ .B [ C /
iff .z 2 A/ AND .z 2 B [ C / (def of \)
iff .z 2 A/ AND .z 2 B OR z 2 C / (def of [)
iff .z 2 A AND z 2 B/ OR .z 2 A AND z 2 C / (AND distributivity (3.9))
iff .z 2 A \ B/ OR .z 2 A \ C / (def of \)
iff z 2 .A \ B/ [ .A \ C / (def of [)

The proof of Theorem 4.1.2 illustrates a general method for proving a set equality
involving the basic set operations by checking that a corresponding propositional
formula is valid. As a further example, from De Morgan’s Law (3.14) for proposi-
tions
NOT .P AND Q/ is equivalent to P OR Q

we can derive (Problem 4.5) a corresponding De Morgan’s Law for set equality:

A \ B D A [ B: (4.3)

Despite this correspondence between two kinds of operations, it’s important not
to confuse propositional operations with set operations. For example, if X and Y
are sets, then it is wrong to write “X AND Y ” instead of “X \ Y .” Applying AND
to sets will cause your compiler—or your grader—to throw a type error, because
an operation that is only supposed to be applied to truth values has been applied to
sets. Likewise, if P and Q are propositions, then it is a type error to write “P [ Q”
instead of “P OR Q.”
“mcs” — 2017/6/5 — 19:42 — page 102 — #110

102 Chapter 4 Mathematical Data Types

4.2 Sequences
Sets provide one way to group a collection of objects. Another way is in a sequence,
which is a list of objects called its components, members, or elements. Short se-
quences are commonly described by listing the elements between parentheses; for
example, the sequence .a; b; c/ has three components. It would also be referred to
as a three element sequence or a sequence of length three. These phrases are all
synonyms—sequences are so basic that they appear everywhere and there are a lot
of ways to talk about them.
While both sets and sequences perform a gathering role, there are several differ-
ences.

 The elements of a set are required to be distinct, but elements in a sequence


can be the same. Thus, .a; b; a/ is a valid sequence of length three, but
fa; b; ag is a set with two elements, not three.

 The elements in a sequence have a specified order, but the elements of a


set do not. For example, .a; b; c/ and .a; c; b/ are different sequences, but
fa; b; cg and fa; c; bg are the same set.

 Texts differ on notation for the empty sequence; we use  for the empty
sequence.

The product operation is one link between sets and sequences. A Cartesian
product of sets, S1  S2      Sn , is a new set consisting of all sequences where
the first component is drawn from S1 , the second from S2 , and so forth. Length two
sequences are called pairs.3 For example, N  fa; bg is the set of all pairs whose
first element is a nonnegative integer and whose second element is an a or a b:

N  fa; bg D f.0; a/; .0; b/; .1; a/; .1; b/; .2; a/; .2; b/; : : :g

A product of n copies of a set S is denoted S n . For example, f0; 1g3 is the set of
all 3-bit sequences:

f0; 1g3 D f.0; 0; 0/; .0; 0; 1/; .0; 1; 0/; .0; 1; 1/; .1; 0; 0/; .1; 0; 1/; .1; 1; 0/; .1; 1; 1/g
3 Some texts call them ordered pairs.
“mcs” — 2017/6/5 — 19:42 — page 103 — #111

4.3. Functions 103

4.3 Functions
4.3.1 Domains and Images
A function assigns an element of one set, called the domain, to an element of an-
other set, called the codomain. The notation

f WA!B

indicates that f is a function with domain A and codomain B. The familiar notation
“f .a/ D b” indicates that f assigns the element b 2 B to a. Here b would be
called the value of f at argument a.
Functions are often defined by formulas, as in:
1
f1 .x/ WWD
x2
where x is a real-valued variable, or

f2 .y; z/ WWD y10yz

where y and z range over binary strings, or

f3 .x; n/ WWD the length n sequence .x; : : : ; x/


„ ƒ‚ …
n x’s

where n ranges over the nonnegative integers.


A function with a finite domain could be specified by a table that shows the value
of the function at each element of the domain. For example, a function f4 .P; Q/
where P and Q are propositional variables is specified by:

P Q f4 .P; Q/
T T T
T F F
F T T
F F T

Notice that f4 could also have been described by a formula:

f4 .P; Q/ WWD ŒP IMPLIES Q:

A function might also be defined by a procedure for computing its value at any
element of its domain, or by some other kind of specification. For example, define
“mcs” — 2017/6/5 — 19:42 — page 104 — #112

104 Chapter 4 Mathematical Data Types

f5 .y/ to be the length of a left to right search of the bits in the binary string y until
a 1 appears, so

f5 .0010/ D 3;
f5 .100/ D 1;
f5 .0000/ is undefined:

Notice that f5 does not assign a value to any string of just 0’s. This illustrates
an important fact about functions: they need not assign a value to every element
in the domain. In fact this came up in our first example f1 .x/ D 1=x 2 , which
does not assign a value to 0. So in general, functions may be partial functions,
meaning that there may be domain elements for which the function is not defined.
The set of domain elements for which a function is defined is called the support of
the function. If a function assigns a value to every element of its domain, that is, its
support equals its domain, it is called a total function.
It’s often useful to find the set of values a function takes when applied to the
elements in a set of arguments. So if f W A ! B, and S is a subset of A, we define
f .S / to be the set of all the values that f takes when it is applied to elements of S .
That is,
f .S / WWD fb 2 B j f .s/ D b for some s 2 Sg:
For example, if we let Œr; s denote set of numbers in the interval from r to s on the
real line, then f1 .Œ1; 2/ D Œ1=4; 1.
For another example, let’s take the “search for a 1” function f5 . If we let X be
the set of binary words which start with an even number of 0’s followed by a 1,
then f5 .X / would be the odd nonnegative integers.
Applying f to a set S of arguments is referred to as “applying f pointwise to
S ”, and the set f .S / is referred to as the image of S under f .4 The set of values
that arise from applying f to all possible arguments is called the range of f . That
is,
range.f / WWD f .domain.f //:
Some authors refer to the codomain as the range of a function, but they shouldn’t.
The distinction between the range and codomain will be important later in Sec-
tions 4.5 when we relate sizes of sets to properties of functions between them.
4 There is a picky distinction between the function f which applies to elements of A and the
function which applies f pointwise to subsets of A, because the domain of f is A, while the domain
of pointwise-f is pow.A/. It is usually clear from context whether f or pointwise-f is meant, so
there is no harm in overloading the symbol f in this way.
“mcs” — 2017/6/5 — 19:42 — page 105 — #113

4.4. Binary Relations 105

4.3.2 Function Composition


Doing things step by step is a universal idea. Taking a walk is a literal example, but
so is cooking from a recipe, executing a computer program, evaluating a formula,
and recovering from substance abuse.
Abstractly, taking a step amounts to applying a function, and going step by step
corresponds to applying functions one after the other. This is captured by the op-
eration of composing functions. Composing the functions f and g means that first
f is applied to some argument, x, to produce f .x/, and then g is applied to that
result to produce g.f .x//.
Definition 4.3.1. For functions f W A ! B and g W B ! C , the composition,
g ı f , of g with f is defined to be the function from A to C defined by the rule:
.g ı f /.x/ WWD g.f .x//;
for all x 2 A.
Function composition is familiar as a basic concept from elementary calculus,
and it plays an equally basic role in discrete mathematics.

4.4 Binary Relations


Binary relations define relations between two objects. For example, “less-than” on
the real numbers relates every real number a to a real number b, precisely when
a < b. Similarly, the subset relation relates a set A to another set B precisely when
A  B. A function f W A ! B is a special case of binary relation in which an
element a 2 A is related to an element b 2 B precisely when b D f .a/.
In this section we’ll define some basic vocabulary and properties of binary rela-
tions.
Definition 4.4.1. A binary relation R consists of a set A, called the domain of R,
a set B called the codomain of R, and a subset of A  B called the graph of R.
A relation whose domain is A and codomain is B is said to be “between A and
B”, or “from A to B.” As with functions, we write R W A ! B to indicate that R
is a relation from A to B. When the domain and codomain are the same set A we
simply say the relation is “on A.” It’s common to use “a R b” to mean that the pair
.a; b/ is in the graph of R.5
5 Writing the relation or operator symbol between its arguments is called infix notation. Infix

expressions like “m < n” or “m C n” are the usual notation used for things like the less-then relation
or the addition operation rather than prefix notation like “< .m; n/” or “C.m; n/.”
“mcs” — 2017/6/5 — 19:42 — page 106 — #114

106 Chapter 4 Mathematical Data Types

Notice that Definition 4.4.1 is exactly the same as the definition in Section 4.3
of a function, except that it doesn’t require the functional condition that, for each
domain element a, there is at most one pair in the graph whose first coordinate is
a. As we said, a function is a special case of a binary relation.
The “in-charge of” relation Chrg for MIT in Spring ’10 subjects and instructors
is a handy example of a binary relation. Its domain Fac is the names of all the
MIT faculty and instructional staff, and its codomain is the set SubNums of subject
numbers in the Fall ’09–Spring ’10 MIT subject listing. The graph of Chrg contains
precisely the pairs of the form

.hinstructor-namei ; hsubject-numi/

such that the faculty member named hinstructor-namei is in charge of the subject
with number hsubject-numi that was offered in Spring ’10. So graph.Chrg/ con-
tains pairs like
.T. Eng; 6.UAT/
.G. Freeman; 6.011/
.G. Freeman; 6.UAT/
.G. Freeman; 6.881/
.G. Freeman; 6.882/
.J. Guttag; 6.00/
.A. R. Meyer; 6.042/ (4.4)
.A. R. Meyer; 18.062/
.A. R. Meyer; 6.844/
.T. Leighton; 6.042/
.T. Leighton; 18.062/
::
:
Some subjects in the codomain SubNums do not appear among this list of pairs—
that is, they are not in range.Chrg/. These are the Fall term-only subjects. Simi-
larly, there are instructors in the domain Fac who do not appear in the list because
they are not in charge of any Spring term subjects.

4.4.1 Relation Diagrams


Some standard properties of a relation can be visualized in terms of a diagram. The
diagram for a binary relation R has points corresponding to the elements of the
domain appearing in one column (a very long column if domain.R/ is infinite). All
the elements of the codomain appear in another column which we’ll usually picture
as being to the right of the domain column. There is an arrow going from a point a
in the left-hand, domain column to a point b in the right-hand, codomain column,
“mcs” — 2017/6/5 — 19:42 — page 107 — #115

4.4. Binary Relations 107

precisely when the corresponding elements are related by R. For example, here are
diagrams for two functions:

A B A B
a - 1 a - 1
b PP 2 b PP 2
PP
3 PP
3
c PP P
Pq
c Q  P
Pq
3 3
PP 3
 Q

Pq
d   P 4 d  QQ 4
 QQ
e  s
5

Being a function is certainly an important property of a binary relation. What it


means is that every point in the domain column has at most one arrow coming out
of it. So we can describe being a function as the “ 1 arrow out” property. There
are four more standard properties of relations that come up all the time. Here are
all five properties defined in terms of arrows:
Definition 4.4.2. A binary relation R is:
 a function when it has the Œ 1 arrow out property.

 surjective when it has the Œ 1 arrows in property. That is, every point in
the right-hand, codomain column has at least one arrow pointing to it.

 total when it has the Œ 1 arrows out property.

 injective when it has the Œ 1 arrow in property.

 bijective when it has both the ŒD 1 arrow out and the ŒD 1 arrow in prop-
erty.
From here on, we’ll stop mentioning the arrows in these properties and for ex-
ample, just write Œ 1 in instead of Œ 1 arrows in.
So in the diagrams above, the relation on the left has the ŒD 1 out and Œ 1 in
properties, which means it is a total, surjective function. But it does not have the
Œ 1 in property because element 3 has two arrows going into it; it is not injective.
The relation on the right has the ŒD 1 out and Œ 1 in properties, which means
it is a total, injective function. But it does not have the Œ 1 in property because
element 4 has no arrow going into it; it is not surjective.
The arrows in a diagram for R correspond, of course, exactly to the pairs in the
graph of R. Notice that the arrows alone are not enough to determine, for example,
“mcs” — 2017/6/5 — 19:42 — page 108 — #116

108 Chapter 4 Mathematical Data Types

if R has the Œ 1 out, total, property. If all we knew were the arrows, we wouldn’t
know about any points in the domain column that had no arrows out. In other
words, graph.R/ alone does not determine whether R is total: we also need to
know what domain.R/ is.
Example 4.4.3. The function defined by the formula 1=x 2 has the Œ 1 out prop-
erty if its domain is RC , but not if its domain is some set of real numbers including
0. It has the ŒD 1 in and ŒD 1 out property if its domain and codomain are both
RC , but it has neither the Œ 1 in nor the Œ 1 out property if its domain and
codomain are both R.

4.4.2 Relational Images


The idea of the image of a set under a function extends directly to relations.

Definition 4.4.4. The image of a set Y under a relation R written R.Y /, is the set
of elements of the codomain B of R that are related to some element in Y . In terms
of the relation diagram, R.Y / is the set of points with an arrow coming in that starts
from some point in Y . The range range.R/ of R is the image R.A/ of the domain
A of R. That is, range.R/ is the set of all points in the codomain with an arrow
coming in.

For example, the set of subject numbers that Meyer is in charge of in Spring ’10
is exactly Chrg.A. Meyer/. To figure out what this is, we look for all the arrows
in the Chrg diagram that start at “A. Meyer,” and see which subject-numbers are
at the other end of these arrows. Looking at the list (4.4) of pairs in graph.Chrg/,
we see that these subject-numbers are f6.042, 18.062, 6.844g. Similarly, to find the
subject numbers that either Freeman or Eng are in charge of, we can collect all the
arrows that start at either “G. Freeman,” or “T. Eng” and, again, see which subject-
numbers are at the other end of these arrows. This is Chrg.fG. Freeman; T. Engg/.
Looking again at the list (4.4), we see that

Chrg.fG. Freeman; T. Engg/ D f6.011, 6.881, 6.882, 6.UATg

Finally, Fac is the set of all in-charge instructors, so Chrg.Fac/ is the set of all the
subjects listed for Spring ’10.

Inverse Relations and Images


Definition 4.4.5. The inverse, R 1 of a relation R W A ! B is the relation from B
to A defined by the rule
b R 1 a IFF a R b:
“mcs” — 2017/6/5 — 19:42 — page 109 — #117

4.5. Finite Cardinality 109

In other words, R 1 is the relation you get by reversing the direction of the
arrows in the diagram of R.

Definition 4.4.6. The inverse image of a set X  B under the relation R is defined
to be R 1 .X /, namely, the set of elements in A connected by an arrow to some
element in B. The support support.R/ is defined to R 1 .B/, namely, the set of
domain elements with at least one arrow out. The support of R is also called the
domain of definition of R.

Continuing with the in-charge example above, the set of instructors in charge
of 6.UAT in Spring ’10 is exactly the inverse image of f6.UATg under the Chrg
relation. From the list (4.4), we see that Eng and Freeman are both in charge of
6.UAT, that is,
1
fT. Eng; D. Freemang  Chrg .f6.UATg/:

We can’t assert equality here because there may be additional pairs further down
the list showing that additional instructors are co-incharge of 6.UAT.
Now let Intro be the set of introductory course 6 subject numbers. These are the
subject numbers that start with “6.0.” So the set of names of the instructors who
were in-charge of introductory course 6 subjects in Spring ’10, is Chrg 1 .Intro/.
From the part of the Chrg list shown in (4.4), we see that Meyer, Leighton, Free-
man, and Guttag were among the instructors in charge of introductory subjects in
Spring ’10. That is,
1
fMeyer, Leighton, Freeman, Guttagg  Chrg .Intro/:

Finally, Chrg 1 .SubNums/ is the set of all instructors who were in charge of a
subject listed for Spring ’10.

4.5 Finite Cardinality


A finite set is one that has only a finite number of elements. This number of ele-
ments is the “size” or cardinality of the set:

Definition 4.5.1. If A is a finite set, the cardinality jAj of A is the number of


elements in A.

A finite set may have no elements (the empty set), or one element, or two ele-
ments,. . . , so the cardinality of finite sets is always a nonnegative integer.
“mcs” — 2017/6/5 — 19:42 — page 110 — #118

110 Chapter 4 Mathematical Data Types

Now suppose R W A ! B is a function. This means that every element of A


contributes at most one arrow to the diagram for R, so the number of arrows is at
most the number of elements in A. That is, if R is a function, then

jAj  #arrows:

If R is also surjective, then every element of B has an arrow into it, so there must
be at least as many arrows in the diagram as the size of B. That is,

#arrows  jBj:

Combining these inequalities implies that if R is a surjective function, then jAj 


jBj.
In short, if we write A surj B to mean that there is a surjective function from
A to B, then we’ve just proved a lemma: if A surj B for finite sets A; B, then
jAj  jBj. The following definition and lemma lists this statement and three similar
rules relating domain and codomain size to relational properties.

Definition 4.5.2. Let A; B be (not necessarily finite) sets. Then

1. A surj B iff there is a surjective function from A to B.

2. A inj B iff there is an injective total relation from A to B.

3. A bij B iff there is a bijection from A to B.

Lemma 4.5.3. For finite sets A; B:

1. If A surj B, then jAj  jBj.

2. If A inj B, then jAj  jBj.

3. If A bij B, then jAj D jBj.

Proof. We’ve already given an “arrow” proof of implication 1. Implication 2. fol-


lows immediately from the fact that if R has the Œ 1 out, function property, and
the Œ 1 in, surjective property, then R 1 is total and injective, so A surj B iff
B inj A. Finally, since a bijection is both a surjective function and a total injective
relation, implication 3. is an immediate consequence of the first two. 

Lemma 4.5.3.1. has a converse: if the size of a finite set A is greater than or equal
to the size of another finite set B then it’s always possible to define a surjective
“mcs” — 2017/6/5 — 19:42 — page 111 — #119

4.5. Finite Cardinality 111

function from A to B. In fact, the surjection can be a total function. To see how
this works, suppose for example that

A D fa0 ; a1 ; a2 ; a3 ; a4 ; a5 g
B D fb0 ; b1 ; b2 ; b3 g:

Then define a total function f W A ! B by the rules

f .a0 / WWD b0 ; f .a1 / WWD b1 ; f .a2 / WWD b2 ; f .a3 / D f .a4 / D f .a5 / WWD b3 :

More concisely,
f .ai / WWD bmin.i;3/ ;
for 0  i  5. Since 5  3, this f is a surjection.
So we have figured out that if A and B are finite sets, then jAj  jBj if and only if
A surj B. All told, this argument wraps up the proof of a theorem that summarizes
the whole finite cardinality story:

Theorem 4.5.4. [Mapping Rules] For finite sets A; B,

jAj  jBj iff A surj B; (4.5)


jAj  jBj iff A inj B; (4.6)
jAj D jBj iff A bij B; (4.7)

4.5.1 How Many Subsets of a Finite Set?


As an application of the bijection mapping rule (4.7), we can give an easy proof of:

Theorem 4.5.5. There are 2n subsets of an n-element set. That is,

jAj D n implies j pow.A/j D 2n :

For example, the three-element set fa1 ; a2 ; a3 g has eight different subsets:

; fa1 g fa2 g fa1 ; a2 g


fa3 g fa1 ; a3 g fa2 ; a3 g fa1 ; a2 ; a3 g

Theorem 4.5.5 follows from the fact that there is a simple bijection from subsets
of A to f0; 1gn , the n-bit sequences. Namely, let a1 ; a2 ; : : : ; an be the elements
of A. The bijection maps each subset of S  A to the bit sequence .b1 ; : : : ; bn /
defined by the rule that
bi D 1 iff ai 2 S:
“mcs” — 2017/6/5 — 19:42 — page 112 — #120

112 Chapter 4 Mathematical Data Types

For example, if n D 10, then the subset fa2 ; a3 ; a5 ; a7 ; a10 g maps to a 10-bit
sequence as follows:

subset: f a2 ; a 3 ; a5 ; a7 ; a10 g
sequence: . 0; 1; 1; 0; 1; 0; 1; 0; 0; 1 /

Now by bijection case of the Mapping Rules 4.5.4.(4.7),

j pow.A/j D jf0; 1gn j:

But every computer scientist knows6 that there are 2n n-bit sequences! So we’ve
proved Theorem 4.5.5!

Problems for Section 4.1


Practice Problems
Problem 4.1.
For any set A, let pow.A/ be its power set, the set of all its subsets; note that A is
itself a member of pow.A/. Let ; denote the empty set.
(a) The elements of pow.f1; 2g/ are:

(b) The elements of pow.f;; f;gg/ are:

(c) How many elements are there in pow.f1; 2; : : : ; 8g/?

Problem 4.2.
Express each of the following assertions about sets by a formula of set theory.7
Expressions may use abbreviations introduced earlier (so it is now legal to use “D”
because we just defined it).
(a) x D ;.

(b) x D fy; zg.

(c) x  y. (x is a subset of y that might equal y.)


6 Incase you’re someone who doesn’t know how many n-bit sequences there are, you’ll find the
2n explained in Section 15.2.2.
7 See Section 8.3.2.
“mcs” — 2017/6/5 — 19:42 — page 113 — #121

4.5. Finite Cardinality 113

Now we can explain how to express “x is a proper subset of y” as a set theory


formula using things we already know how to express. Namely, letting “x ¤ y”
abbreviate NOT.x D y/, the expression

.x  y AND x ¤ y/;

describes a formula of set theory that means x  y.


From here on, feel free to use any previously expressed property in describing
formulas for the following:
(d) x D y [ z.

(e) x D y z.

(f) x D pow.y/.
S
(g) x D z2y z.
This means that y is supposed to be S S x is the union of all of
a collection of sets, and
them. A more concise notation for “ z2y z’ is simply “ y.”

Class Problems
Problem 4.3.
Set Formulas and Propositional Formulas.
(a) Verify that the propositional formula .P AND Q/ OR .P AND Q/ is equivalent
to P .

(b) Prove that


A D .A B/ [ .A \ B/
for all sets, A; B, by showing

x 2 A IFF x 2 .A B/ [ .A \ B/

for all elements x using the equivalence of part (a) in a chain of IFF’s.

Problem 4.4.
Prove

Theorem (Distributivity of union over intersection).

A [ .B \ C / D .A [ B/ \ .A [ C / (4.8)
“mcs” — 2017/6/5 — 19:42 — page 114 — #122

114 Chapter 4 Mathematical Data Types

for all sets, A; B; C , by using a chain of iff’s to show that

x 2 A [ .B \ C / IFF x 2 .A [ B/ \ .A [ C /

for all elements x. You may assume the corresponding propositional equivalence 3.10.

Problem 4.5.
Prove De Morgan’s Law for set equality

A \ B D A [ B: (4.9)

by showing with a chain of IFF’s that x 2 the left-hand side of (4.9) iff x 2 the
right-hand side. You may assume the propositional version (3.14) of De Morgan’s
Law.

Problem 4.6.
Powerset Properties.
Let A and B be sets.
(a) Prove that
pow.A \ B/ D pow.A/ \ pow.B/:

(b) Prove that


.pow.A/ [ pow.B//  pow.A [ B/;
with equality holding iff one of A or B is a subset of the other.

Problem 4.7.
Subset take-away8 is a two player game played with a finite set A of numbers.
Players alternately choose nonempty subsets of A with the conditions that a player
may not choose

 the whole set A, or

 any set containing a set that was named earlier.


8 From Christenson & Tilford, David Gale’s Subset Takeaway Game, American Mathematical

Monthly, Oct. 1997


“mcs” — 2017/6/5 — 19:42 — page 115 — #123

4.5. Finite Cardinality 115

The first player who is unable to move loses the game.


For example, if the size of A is one, then there are no legal moves and the second
player wins. If A has exactly two elements, then the only legal moves are the two
one-element subsets of A. Each is a good reply to the other, and so once again the
second player wins.
The first interesting case is when A has three elements. This time, if the first
player picks a subset with one element, the second player picks the subset with the
other two elements. If the first player picks a subset with two elements, the second
player picks the subset whose sole member is the third element. In both cases, these
moves lead to a situation that is the same as the start of a game on a set with two
elements, and thus leads to a win for the second player.
Verify that when A has four elements, the second player still has a winning strat-
egy.9

Homework Problems
Problem 4.8.
Let A, B and C be sets. Prove that

A [ B [ C D .A B/ [ .B C / [ .C A/ [ .A \ B \ C / (4.10)

using a chain of IFF’s as Section 4.1.5.

Problem 4.9.
Union distributes over the intersection of two sets:

A [ .B \ C / D .A [ B/ \ .A [ C / (4.11)

(see Problem 4.4).


Use (4.11) and the Well Ordering Principle to prove the Distributive Law of
union over the intersection of n sets:

A [ .B1 \    \ Bn 1 \ Bn /
D .A [ B1 / \    \ .A [ Bn 1/ \ .A [ Bn / (4.12)

Extending formulas to an arbitrary number of terms is a common (if mundane)


application of the WOP.
9 David Gale worked out some of the properties of this game and conjectured that the second
player wins the game for any set A. This remains an open problem.
“mcs” — 2017/6/5 — 19:42 — page 116 — #124

116 Chapter 4 Mathematical Data Types

Exam Problems
Problem 4.10.
You’ve seen how certain set identities follow from corresponding propositional
equivalences. For example, you proved by a chain of iff’s that

.A B/ [ .A \ B/ D A

using the fact that the propositional formula .P AND Q/ OR .P AND Q/ is equivalent
to P .
State a similar propositional equivalence that would justify the key step in a proof
for the following set equality organized as a chain of iff’s:
  
A B D A C [ .B \ C / [ A [ B \ C (4.13)

(You are not being asked to write out an iff-proof of the equality or to write out
a proof of the propositional equivalence. Just state the equivalence.)

Problem 4.11.
You’ve seen how certain set identities follow from corresponding propositional
equivalences. For example, you proved by a chain of iff’s that

.A B/ [ .A \ B/ D A

using the fact that the propositional formula .P AND Q/ OR .P AND Q/ is equivalent
to P .
State a similar propositional equivalence that would justify the key step in a proof
for the following set equality organized as a chain of iff’s:

A \ B \ C D A [ .B A/ [ C :

(You are not being asked to write out an iff-proof of the equality or to write out
a proof of the propositional equivalence. Just state the equivalence.)

Problem 4.12.
The set equation
A\B DA[B
follows from a certain equivalence between propositional formulas.
(a) What is the equivalence?

(b) Show how to derive the equation from this equivalence.


“mcs” — 2017/6/5 — 19:42 — page 117 — #125

4.5. Finite Cardinality 117

Problems for Section 4.2


Homework Problems
Problem 4.13.
Prove that for any sets A, B, C and D, if the Cartesian products A  B and C  D
are disjoint, then either A and C are disjoint or B and D are disjoint.

Problem 4.14. (a) Give a simple example where the following result fails, and
briefly explain why:
False Theorem. For sets A, B, C and D, let

L WWD .A [ B/  .C [ D/;
R WWD .A  C / [ .B  D/:

Then L D R.

(b) Identify the mistake in the following proof of the False Theorem.

Bogus proof. Since L and R are both sets of pairs, it’s sufficient to prove that
.x; y/ 2 L ! .x; y/ 2 R for all x; y.
The proof will be a chain of iff implications:

.x; y/ 2 R
iff .x; y/ 2 .A  C / [ .B  D/
iff .x; y/ 2 A  C , or .x; y/ 2 B  D
iff (x 2 A and y 2 C ) or else (x 2 B and y 2 D)
iff either x 2 A or x 2 B, and either y 2 C or y 2 D
iff x 2 A [ B and y 2 C [ D
iff .x; y/ 2 L.

(c) Fix the proof to show that R  L.


“mcs” — 2017/6/5 — 19:42 — page 118 — #126

118 Chapter 4 Mathematical Data Types

Problems for Section 4.4


Practice Problems
Problem 4.15.
The inverse R 1 of a binary relation R from A to B is the relation from B to A
defined by:
1
bR a iff a R b:
In other words, you get the diagram for R 1 from R by “reversing the arrows” in
the diagram describing R. Now many of the relational properties of R correspond
to different properties of R 1 . For example, R is total iff R 1 is a surjection.
Fill in the remaining entries is this table:
R is iff R 1 is
total a surjection
a function
a surjection
an injection
a bijection
Hint: Explain what’s going on in terms of “arrows” from A to B in the diagram
for R.

Problem 4.16.
Describe a total injective function ŒD 1 out, Œ 1 in;  from R ! R that is not a
bijection.

Problem 4.17.
For a binary relation R W A ! B, some properties of R can be determined from
just the arrows of R, that is, from graph.R/, and others require knowing if there
are elements in the domain A or the codomain B that don’t show up in graph.R/.
For each of the following possible properties of R, indicate whether it is always
determined by
1. graph.R/ alone,
2. graph.R/ and A alone,
3. graph.R/ and B alone,
“mcs” — 2017/6/5 — 19:42 — page 119 — #127

4.5. Finite Cardinality 119

4. all three parts of R.

Properties:
(a) surjective

(b) injective

(c) total

(d) function

(e) bijection

Problem 4.18.
For each of the following real-valued functions on the real numbers, indicate whether
it is a bijection, a surjection but not a bijection, an injection but not a bijection, or
neither an injection nor a surjection.
(a) x ! x C 2

(b) x ! 2x

(c) x ! x 2

(d) x ! x 3

(e) x ! sin x

(f) x ! x sin x

(g) x ! e x

Problem 4.19.
Let f W A ! B and g W B ! C be functions and h W A ! C be their composition,
namely, h.a/ WWD g.f .a// for all a 2 A.
(a) Prove that if f and g are surjections, then so is h.

(b) Prove that if f and g are bijections, then so is h.

(c) If f is a bijection, then so is f 1.


“mcs” — 2017/6/5 — 19:42 — page 120 — #128

120 Chapter 4 Mathematical Data Types

Problem 4.20.
Give an example of a relation R that is a total injective function from a set A to
itself but is not a bijection.

Class Problems
Problem 4.21. (a) Prove that if A surj B and B surj C , then A surj C .

(b) Explain why A surj B iff B inj A.

(c) Conclude from (a) and (b) that if A inj B and B inj C , then A inj C .

(d) According to Definition 4.5.2, A inj B requires a total injective relation. Ex-
plain why A inj B iff there is a total injective function from A to B.

Problem 4.22.
Five basic properties of binary relations R W A ! B are:

1. R is a surjection Œ 1 in

2. R is an injection Œ 1 in

3. R is a function Œ 1 out

4. R is total Œ 1 out

5. R is empty ŒD 0 out

Below are some assertions about R. For each assertion, indicate all the properties
above that the relation R must have. For example, the first assertion impllies that R
is a total surjection. Variables a; a1 ; : : : range over A and b; b1 ; : : : range over B.
(a) 8a 8b: a R b.

(b) NOT.8a 8b: a R b/.

(c) 8a 8b: NOT.a R b/.

(d) 8a 9b: a R b.

(e) 8b 9a: a R b.

(f) R is a bijection.
V
(g) 8a 9b1 a R b1 8b: a R b IMPLIES b D b1 .
“mcs” — 2017/6/5 — 19:42 — page 121 — #129

4.5. Finite Cardinality 121

(h) 8a; b: a R b OR a ¤ b.

(i) 8b1 ; b2 ; a: .a R b1 AND a R b2 / IMPLIES b1 D b2 .

(j) 8a1 ; a2 ; b: .a1 R b AND a2 R b/ IMPLIES a1 D a2 .

(k) 8a1 ; a2 ; b1 ; b2 : .a1 R b1 AND a2 R b2 AND a1 ¤ a2 / IMPLIES b1 ¤ b2 .

(l) 8a1 ; a2 ; b1 ; b2 : .a1 R b1 AND a2 R b2 AND b1 ¤ b2 / IMPLIES a1 ¤ a2 .

Problem 4.23.
Let R W A ! B be a binary relation. Each of the following formulas expresses
the fact that R has a familiar relational “arrow” property such as being surjective
or being a function.
Identify the relational property expressed by each of the following relational
expressions. Explain your reasoning.
(a) R ı R 1  IdB

(b) R 1 ı R  IdA

(c) R 1 ı R  IdA

(d) R ı R 1  IdB

Homework Problems
Problem 4.24.
Let f W A ! B and g W B ! C be functions.
(a) Prove that if the composition g ı f is a bijection, then f is a total injection
and g is a surjection.

(b) Show there is a total injection f and a bijection, g, such that g ı f is not a
bijection.

Problem 4.25.
Let A, B and C be nonempty sets, and let f W B ! C and g W A ! B be
functions. Let h WWD f ı g be the composition function of f and g, namely, the
function with domain A and codomain C such that h.x/ D f .g.x//.
(a) Prove that if h is surjective and f is total and injective, then g must be surjec-
tive.
“mcs” — 2017/6/5 — 19:42 — page 122 — #130

122 Chapter 4 Mathematical Data Types

Hint: contradiction.

(b) Suppose that h is injective and f is total. Prove that g must be injective and
provide a counterexample showing how this claim could fail if f was not total.

Problem 4.26.
Let A, B and C be sets, and let f W B ! C and g W A ! B be functions. Let
h W A ! C be the composition f ı g; that is, h.x/ WWD f .g.x// for x 2 A. Prove
or disprove the following claims:
(a) If h is surjective, then f must be surjective.

(b) If h is surjective, then g must be surjective.

(c) If h is injective, then f must be injective.

(d) If h is injective and f is total, then g must be injective.

Problem 4.27. (a)


Let R W D ! D be a binary relation on a set D. Let x; y be variables ranging over
D. Indicate the expressions below whose meaning is that R is an injective relation
Œ 1 in. Remember that R.x/ WWD fy j x R yg, and R is not necessarily a function
or a total relation.

(i) R.x/ \ R.y/ D ;


(ii) R.x/ D R.y/ IMPLIES x D y
(iii) R.x/ \ R.y/ D ; IMPLIES x ¤ y
(iv) x ¤ y IMPLIES R.x/ ¤ R.y/
(v) R.x/ \ R.y/ ¤ ; IMPLIES x ¤ y
(vi) R.x/ \ R.y/ ¤ ; IMPLIES x D y
(vii) R 1 .R.x// D fxg
(viii) R 1 .R.x//  fxg
(ix) R 1 .R.x//  fxg
(x) R.R 1 .x//  fxg
(xi) R.R 1 .x//  fxg
(xii) x ¤ y IMPLIES R.x/ \ R.y/ D ;
“mcs” — 2017/6/5 — 19:42 — page 123 — #131

4.5. Finite Cardinality 123

(b) Give an example of a set S such that there is no total injective relation from S
to the real interval Œ0; 1.

Problem 4.28.
The language of sets and relations may seem remote from the practical world of
programming, but in fact there is a close connection to relational databases, a
very popular software application building block implemented by such software
packages as MySQL. This problem explores the connection by considering how to
manipulate and analyze a large data set using operators over sets and relations. Sys-
tems like MySQL are able to execute very similar high-level instructions efficiently
on standard computer hardware, which helps programmers focus on high-level de-
sign.
Consider a basic Web search engine, which stores information on Web pages and
processes queries to find pages satisfying conditions provided by users. At a high
level, we can formalize the key information as:

 A set P of pages that the search engine knows about

 A binary relation L (for link) over pages, defined such that p1 L p2 iff page
p1 links to p2

 A set E of endorsers, people who have recorded their opinions about which
pages are high-quality

 A binary relation R (for recommends) between endorsers and pages, such


that e R p iff person e has recommended page p

 A set W of words that may appear on pages

 A binary relation M (for mentions) between pages and words, where p M w


iff word w appears on page p

Each part of this problem describes an intuitive, informal query over the data,
and your job is to produce a single expression using the standard set and relation
operators, such that the expression can be interpreted as answering the query cor-
rectly, for any data set. Your answers should use only the set and relation symbols
given above, in addition to terms standing for constant elements of E or W , plus
the following operators introduced in the text:

 set union [.
“mcs” — 2017/6/5 — 19:42 — page 124 — #132

124 Chapter 4 Mathematical Data Types

 set intersection \.
 set difference .
 relational image—for example, R.A/ for some set A, or R.a/ for some spe-
cific element a.
 relational inverse 1.

 . . . and one extra: relational composition which generalizes composition of


functions
a .R ı S / c WWD 9b 2 B: .a S b/ AND .b R c/:
In other words, a is related to c in R ı S if starting at a you can follow an S
arrow to the start of an R arrow and then follow the R arrow to get to c.10
Here is one worked example to get you started:
 Search description: The set of pages containing the word “logic”
 Solution expression: M 1 .“logic”/

Find similar solutions for each of the following searches:


(a) The set of pages containing the word “logic” but not the word “predicate”

(b) The set of pages containing the word “set” that have been recommended by
“Meyer”

(c) The set of endorsers who have recommended pages containing the word “al-
gebra”

(d) The relation that relates endorser e and word w iff e has recommended a page
containing w

(e) The set of pages that have at least one incoming or outgoing link

(f) The relation that relates word w and page p iff w appears on a page that links
to p

(g) The relation that relates word w and endorser e iff w appears on a page that
links to a page that e recommends

(h) The relation that relates pages p1 and p2 iff p2 can be reached from p1 by
following a sequence of exactly 3 links
10 Note the reversal of R and S in the definition; this is to make relational composition work like

function composition. For functions, f ı g means you apply g first. That is, if we let h be f ı g,
then h.x/ D f .g.x//.
“mcs” — 2017/6/5 — 19:42 — page 125 — #133

4.5. Finite Cardinality 125

Exam Problems
Problem 4.29.
Let A be the set containing the five sets: fag; fb; cg; fb; d g; fa; eg; fe; f g, and let
B be the set containing the three sets: fa; bg; fb; c; d g; fe; f g. Let R be the “is
subset of” binary relation from A to B defined by the rule:

XRY IFF X  Y:

(a) Fill in the arrows so the following figure describes the graph of the relation,
R:

A arrows B

fag

fa; bg

fb; cg

fb; c; d g

fb; d g

fe; f g

fa; eg

fe; f g

(b) Circle the properties below possessed by the relation R:

function total injective surjective bijective

(c) Circle the properties below possessed by the relation R 1:

function total injective surjective bijective


“mcs” — 2017/6/5 — 19:42 — page 126 — #134

126 Chapter 4 Mathematical Data Types

Problem 4.30. (a) Five assertions about a binary relation R W A ! B are bulleted
below. There are nine predicate formulas that express some of these assertions.
Write the numbers of the formulas next to the assertions they express. For example,
you should write “4” next to the last assertion, since formula (4) expresses the
assertion that R is the identity relation.
Variables a; a1 ; : : : range over the domain A and b; b1 ; : : : range over the codomain
B. More than one formula may express one assertion.

 R is a surjection
 R is an injection
 R is a function
 R is total
 R is the identity relation.

1. 8b: 9a: a R b.
2. 8a: 9b: a R b.
3. 8a: a R a.
4. 8a; b: a R b IFF a D b.
5. 8a; b: a R b OR a ¤ b.
6. 8b1 ; b2 ; a: .a R b1 AND a R b2 / IMPLIES b1 D b2 .
7. 8a1 ; a2 ; b: .a1 R b AND a2 R b/ IMPLIES a1 D a2 .
8. 8a1 ; a2 ; b1 ; b2 : .a1 R b1 AND a2 R b2 AND a1 ¤ a2 / IMPLIES b1 ¤ b2 .
9. 8a1 ; a2 ; b1 ; b2 : .a1 R b1 AND a2 R b2 AND b1 ¤ b2 / IMPLIES a1 ¤ a2 .

(b) Give an example of a relation R that satisfies three of the properties surjection,
injection, total, and function (you indicate which) but is not a bijection.

Problem 4.31.
Let f W D ! D be a total function from some nonempty set D to itself. In the
following propositions, x and y are variables ranging over D, and g is a variable
ranging over total functions from D to D. Indicate all of the propositions that are
equivalent to the proposition that f is an injection:

1. x D y OR f .x/ ¤ f .y/

2. x D y IMPLIES f .x/ D f .y/


“mcs” — 2017/6/5 — 19:42 — page 127 — #135

4.5. Finite Cardinality 127

3. x ¤ y IMPLIES f .x/ ¤ f .y/

4. f .x/ D f .y/ IMPLIES x D y

5. NOTŒ9x9y.x ¤ y AND f .x/ D f .y//

6. NOTŒ9z8x.f .x/ ¤ z/

7. 9g8x.g.f .x// D x/

8. 9g8x.f .g.x// D x/

Problem 4.32.
Prove that if relation R W A ! B is a total injection, Œ 1 out; Œ 1 in, then
1
R ı R D IdA ;

where IdA is the identity function on A.


(A simple argument in terms of ”arrows” will do the job.)

Problem 4.33.
Let R W A ! B be a binary relation.
(a) Prove that R is a function iff R ı R 1  IdB .
Write similar containment formulas involving R 1 ıR, RıR 1 , Ida , IdB equivalent
to the assertion that R has each of the following properties. No proof is required.
(b) total.

(c) a surjection.

(d) a injection.

Problem 4.34.
Let R W A ! B and S W B ! C be binary relations such that S ı R is a bijection
and jAj D 2.
Give an example of such R; S where neither R nor S is a function. Indicate ex-
actly which properties—total, surjection, function, and injection—your examples
of R and S have.
Hint: Let jBj D 4.
“mcs” — 2017/6/5 — 19:42 — page 128 — #136

128 Chapter 4 Mathematical Data Types

Problem 4.35.
The set f1; 2; 3g! consists of the infinite sequences of the digits 1,2, and 3, and
likewise f4; 5g! is the set of infinite sequences of the digits 4,5. For example

123123123 : : : 2 f1; 2; 3g! ;


222222222222 : : : 2 f1; 2; 3g! ;
4554445554444 : : : 2 f4; 5g! :

(a) Give an example of a total injective function

f W f1; 2; 3g! ! f4; 5g! :

(b) Give an example of a bijection g W .f1; 2; 3g!  f1; 2; 3g! / ! f1; 2; 3g! .

(c) Explain why there is a bijection between f1; 2; 3g!  f1; 2; 3g! and f4; 5g! .
(You need not explicitly define the bijection.)

Problems for Section 4.5


Practice Problems
Problem 4.36.
Assume f W A ! B is total function, and A is finite. Replace the ? with one of
; D;  to produce the strongest correct version of the following statements:
(a) jf .A/j ? jBj.

(b) If f is a surjection, then jAj ? jBj.

(c) If f is a surjection, then jf .A/j ? jBj.

(d) If f is an injection, then jf .A/j ? jAj.

(e) If f is a bijection, then jAj ? jBj.

Class Problems
Problem 4.37.
Let A D fa0 ; a1 ; : : : ; an 1 g be a set of size n, and B D fb0 ; b1 ; : : : ; bm 1 g a set
of size m. Prove that jA  Bj D mn by defining a simple bijection from A  B to
the nonnegative integers from 0 to mn 1.
“mcs” — 2017/6/5 — 19:42 — page 129 — #137

4.5. Finite Cardinality 129

Problem 4.38.
Let R W A ! B be a binary relation. Use an arrow counting argument to prove the
following generalization of the Mapping Rule 1.

Lemma. If R is a function, and X  A, then

jXj  jR.X /j:

You might also like