Jaysen Tsao
Discrete Mathematics for Computer Science

Functions and Relations

Definition 53: Relation

A relation 𝑅 from a set 𝐴 to a set 𝐵 is a subset of the Cartesian product 𝐴×𝐵:

𝑅 is a relation from 𝐴 to 𝐵 iff 𝑅𝐴×𝐵.

If (𝑎,𝑏)𝑅, we say that 𝑎 is related to 𝑏 by 𝑅, and we write 𝑎𝑅𝑏.

Definition 54: Function

A relation 𝑅𝐴×𝐵 is a function iff the following two conditions hold:

  1. Totality. 𝑎𝐴,𝑏𝐵 such that (𝑎,𝑏)𝑅.
  2. Uniqueness. 𝑎𝐴,𝑏1,𝑏2𝐵,[(𝑎,𝑏1)𝑅 and (𝑎,𝑏2)𝑅]𝑏1=𝑏2.

Terminology: Domain, Codomain, Range

For a function 𝑓:𝐴𝐵, the set 𝐴 is called the domain of 𝑓, the set 𝐵 is called the codomain of 𝑓, and the set 𝑓(𝐴)={𝑓(𝑎)|𝑎𝐴} is called the range of 𝑓.

Notation

Denoting 𝑎𝑏 under 𝑓 asserts that 𝑓 maps 𝑎 to 𝑏, i.e. that 𝑓(𝑎)=𝑏.

Definition 55: Graph of a Function

The graph Gr(𝑓) of a function 𝑓:𝐴𝐵 is the set of ordered pairs (𝑎,𝑓(𝑎)) for all 𝑎𝐴:

Gr(𝑓)={(𝑎,𝑓(𝑎))|𝑎𝐴}.

Terminology: Partial Function

A partial function from 𝐴 to 𝐵 is a relation 𝑅𝐴×𝐵 that satisfies the uniqueness condition of functions but not necessarily the totality condition. In other words, a partial function may not be defined for every element of 𝐴.

Terminology: Endofunction

An endofunction or square function over a set 𝐴 is a function from 𝐴 to itself, i.e. a function 𝑓:𝐴𝐴.

Definition 56: Identity Function

For any set 𝐴, the identity function on 𝐴, denoted id𝐴, is the endofunction from 𝐴 to 𝐴 defined by 𝑥𝑥 for all 𝑥𝐴.

Functions with Multiple Arguments

Definition 57: 𝑛-ary Function

An 𝒏-ary function is a function that takes 𝑛 arguments. Formally, an 𝑛-ary function from sets 𝐴1,𝐴2,,𝐴𝑛 to a set 𝐵 is a function 𝑓:𝐴1×𝐴2××𝐴𝑛𝐵.

Terminology: Unary, Binary, Ternary Functions

In Definition 57, when 𝑛=1, we call 𝑓 a unary function; when 𝑛=2, we call 𝑓 a binary function; and when 𝑛=3, we call 𝑓 a ternary function. Also, when 𝑛=0, we call 𝑓 a nullary function, which is just a constant element of 𝐵.

Function Composition and Iteration

Definition 58: Composition of Functions

Let 𝑓:𝐴𝐵 and 𝑔:𝐵𝐶 be functions. The composition of 𝑔 and 𝑓, denoted 𝑔𝑓, is the function from 𝐴 to 𝐶 defined by (𝑔𝑓)(𝑥)=𝑔(𝑓(𝑥)) for all 𝑥𝐴.

Theorem 13: Compositions Involving the Identity Function

Let 𝑓:𝐴𝐵 be a function. Then id𝐵𝑓=𝑓id𝐴=𝑓.

Definition 59: Idempotent Function

A endofunction 𝑓:𝐴𝐴 is idempotent if 𝑓𝑓=𝑓.

Iteration, Transients, and Periods

Definition 60: Iterated Function

Let 𝑓:𝐴𝐴 be an endofunction. The 𝒏th iterate of 𝑓, denoted 𝑓𝑛, is defined recursively as follows:

𝑓0=id𝐴,𝑓𝑛+1=𝑓𝑓𝑛 for 𝑛0.

Definition 61: Trajectory of an Element under a Function

Let 𝑓:𝐴𝐴 be an endofunction and let 𝑥𝐴. The trajectory of 𝑥 under 𝑓, denoted traj 𝑓(𝑥), is the sequence of elements obtained by iteratively applying 𝑓 to 𝑥:

traj 𝑓(𝑥)=(𝑥,𝑓(𝑥),𝑓2(𝑥),𝑓3(𝑥),)
Example.

Let 𝑓: be defined by 𝑥𝑥2. Then the trajectory of 2 under 𝑓 is:

traj 𝑓(2)=(2,4,16,256,,22𝑛,)

Remark

While we are currently using 𝑓𝑛 to denote the 𝑛th iterate of a function, the notation 𝑓𝑛 may also be used to denote the 𝑛th power of a function in the context of function algebras, which is a different concept.

Definition 62: Periodic Element under a Function

Let 𝑓:𝐴𝐴 be an endofunction and let 𝑥𝐴. We say that 𝑥 is periodic under 𝑓 if there exists a positive integer 𝑛 such that 𝑓𝑛(𝑥)=𝑥. The smallest such positive integer 𝑛 is called the period of 𝑥 under 𝑓.

Theorem 14: Periodicity of Endofunctions with Finite Domains

Classification of Functions

Definition 63: Injective Function

A function 𝑓:𝐴𝐵 is injective or one-to-one if no two distinct elements in 𝐴 map to the same element in 𝐵. Formally:

𝑓 is injective iff 𝑥1,𝑥2𝐴,𝑓(𝑥1)=𝑓(𝑥2)𝑥1=𝑥2.

Definition 64: Surjective Function

A function 𝑓:𝐴𝐵 is surjective or onto if every element in 𝐵 is the image of at least one element in 𝐴. Formally:

𝑓 is surjective iff 𝑦𝐵,𝑥𝐴 such that 𝑓(𝑥)=𝑦.

Theorem 15: Alternative Characterization of Surjectivity

A function 𝑓:𝐴𝐵 is surjective iff the range of 𝑓 equal to its codomain 𝐵.

Definition 65: Bijection

A function 𝑓:𝐴𝐵 is bijective if it is both injective and surjective. In other words, a bijection is a function that establishes a one-to-one correspondence between the elements of 𝐴 and the elements of 𝐵.

Theorem 16: Inverse of a Bijection

Let 𝑓:𝐴𝐵 be a bijection. Then there exists a unique function 𝑓1:𝐵𝐴 such that 𝑓1𝑓=id𝐴 and 𝑓𝑓1=id𝐵. The function 𝑓1 is called the inverse of 𝑓.

For this reason, bijective functions are also called invertible functions.

Exercises

Exercise 9.