A function is more than a formula: its input set, output set, and assignment rule determine what claims about it mean. This chapter keeps definitions, injectivity, surjectivity, composition, and inverses together because each answers a question about the same mapping. It builds on Naive Set Theory and prepares the view of a sequence as an indexed function [1][1] T. Button, Set Theory. Open Logic Project, 2026. Fall 2021 course text, revised July 2026. https://builds.openlogicproject.org/courses/set-theory/settheory-screen.pdf.

Specify the domain, codomain, and rule

DefinitionFunction

A function f:A→Bf:A\to B assigns to every a∈Aa\in A exactly one element f(a)∈Bf(a)\in B. Its domain is AA and its codomain is BB. Its image, or range, is f[A]={f(a):a∈A}f[A]=\{f(a):a\in A\}, a subset of BB.

For f:Z→Zf:\mathbb Z\to\mathbb Z with f(n)=n2f(n)=n^2, the codomain is all integers but the image is {0,1,4,9,…}\{0,1,4,9,\ldots\}. We regard functions as typed mappings: equality requires the same domain, codomain, and outputs. Thus the same formula with a different declared codomain can have different mapping properties.

There is one function from ∅\varnothing to any set BB, the empty function. There is no function from a nonempty AA to ∅\varnothing. These cases follow from the definition; it is unnecessary to ban empty sets from the definition of function.

The graph of ff is the set of ordered pairs (a,f(a))(a,f(a)). As a subset of A×BA\times B, it must associate exactly one output with every input. A relation may associate several outputs or none, so not every relation is a function. Detailed relation theory belongs to Relations and Order.

A formula must actually define a function

The rule x↦1/xx\mapsto1/x does not define a total function R→R\mathbb R\to\mathbb R, but does define one on R∖{0}\mathbb R\setminus\{0\}. On the same declared domain and codomain, 1/x1/x and x−1x^{-1} give exactly the same rule. The notation f−1f^{-1} for an inverse function, discussed below, is a separate use of the superscript.

A rule must also be independent of how an input is represented. For example, “send the rational number a/ba/b to its numerator aa” is not well-defined, since 1/2=2/41/2=2/4 would produce different outputs for the same rational number. To define a function on equivalence classes or other represented objects, check all allowed representations.

Images and preimages of sets

For S⊆AS\subseteq A and T⊆BT\subseteq B, define

f[S]={f(x):x∈S},f[S]=\{f(x):x\in S\}, f−1[T]={x∈A:f(x)∈T}.f^{-1}[T]=\{x\in A:f(x)\in T\}.

The first moves a subset forward; the second collects inputs whose outputs lie in a specified subset. The preimage notation is defined for every function and does not require an inverse function.

For f:R→Rf:\mathbb R\to\mathbb R, f(x)=x2f(x)=x^2, the image of {−1,0,2}\{-1,0,2\} is {0,1,4}\{0,1,4\}, while the preimage of {1,4}\{1,4\} is {−2,−1,1,2}\{-2,-1,1,2\}. Multiple inputs may contribute the same image element, which is listed only once.

PropositionImages preserve unions

For C,D⊆AC,D\subseteq A,

f[C∪D]=f[C]∪f[D].f[C\cup D]=f[C]\cup f[D].
Proof

If y∈f[C∪D]y\in f[C\cup D], choose x∈C∪Dx\in C\cup D with f(x)=yf(x)=y. The input lies in at least one of C,DC,D, so y∈f[C]∪f[D]y\in f[C]\cup f[D]. Conversely, if yy belongs to either image, a witnessing input belongs to C∪DC\cup D, giving membership in its image. This proves both inclusions.

There is therefore no counterexample to equality here. Intersections behave differently:

f[C∩D]⊆f[C]∩f[D].f[C\cap D]\subseteq f[C]\cap f[D].

For the square function with C={−1}C=\{-1\} and D={1}D=\{1\}, the left side is empty but the right side is {1}\{1\}. The two separate image memberships may be witnessed by different inputs.

Preimages preserve both unions and intersections, as well as complements relative to the declared sets:

f−1[B∖T]=A∖f−1[T].f^{-1}[B\setminus T]=A\setminus f^{-1}[T].

For example, membership in the left side means that x∈Ax\in A and f(x)∉Tf(x)\notin T, exactly the condition on the right. A preimage test always concerns the same input xx, explaining why no injectivity assumption is needed.

Injective, surjective, and bijective

PropertyMeaningHow to prove it
InjectiveEqual outputs force equal inputsAssume f(x)=f(y)f(x)=f(y) and derive x=yx=y
Surjective onto BBEvery element of the codomain is reachedTake arbitrary b∈Bb\in B and construct a∈Aa\in A with f(a)=bf(a)=b
BijectiveBoth of the aboveEstablish both obligations

To disprove injectivity, find distinct inputs with the same output. To disprove surjectivity, find a codomain element with no preimage. Having an output for every input is already required of a function; it is not the definition of surjectivity.

Three ways a map can cover its codomain. The arrows distinguish collisions between inputs from gaps in the stated codomain.

Three ways a map can cover its codomain. The arrows distinguish collisions between inputs from gaps in the stated codomain.

ExampleThe codomain changes surjectivity

The function x↦x2x\mapsto x^2 from R\mathbb R to R\mathbb R is neither injective nor surjective: −1,1-1,1 collide and −1-1 is not reached. From R\mathbb R to [0,∞)[0,\infty), it is surjective but still not injective. Restricting both the domain and codomain to [0,∞)[0,\infty) makes it bijective.

ProofA bijection with explicit witnesses

Let f:R→Rf:\mathbb R\to\mathbb R be f(x)=3x−2f(x)=3x-2. If f(x)=f(y)f(x)=f(y), then 3x−2=3y−23x-2=3y-2, so x=yx=y and ff is injective. Given arbitrary b∈Rb\in\mathbb R, choose a=(b+2)/3a=(b+2)/3. It is real and satisfies f(a)=bf(a)=b, proving surjectivity. Therefore ff is bijective.

For finite domain and codomain of the same size, injectivity and surjectivity are equivalent: selecting distinct outputs uses all available outputs. That statement does not extend unchanged to infinite sets. The map n↦n+1n\mapsto n+1 from N\mathbb N to itself is injective but misses 00.

Use mappings to compare cardinalities

The one-to-one pairing in Naive Set Theory is now precisely a bijection f:A→Bf:A\to B. It certifies ∣A∣=∣B∣|A|=|B|. An injection A→BA\to B places distinct elements of AA at distinct locations in BB; this is the meaning of ∣A∣≤∣B∣|A|\le|B| for general sets.

If BB is countable and there is an injection A→BA\to B, then AA is countable. For a finite BB, there are only finitely many available locations. For a countably infinite BB, scan an enumeration of BB and retain the locations used by the injection. Each element of AA is recovered at most once, and none is missed.

A related statement is useful for sequences: a nonempty set AA is countable exactly when some surjection N→A\mathbb N\to A exists. A finite nonempty list can be prolonged by repeating one element. Conversely, from a surjective list, keep each value only at its first occurrence; the resulting list is finite or countably infinite and includes every element. The empty set is countable too, but no function N→∅\mathbb N\to\varnothing exists.

These are statements about the existence of mappings. The instruction to retain first occurrences explains a mathematical listing; without computable data and equality tests, it does not promise an executable enumeration algorithm.

Composition and what can be inferred from it

If f:A→Bf:A\to B and g:B→Cg:B\to C, then g∘f:A→Cg\circ f:A\to C is defined by (g∘f)(a)=g(f(a))(g\circ f)(a)=g(f(a)). The function on the right acts first. Composition is associative but generally not commutative. Identity functions satisfy id⁡B∘f=f=f∘id⁡A\operatorname{id}_B\circ f=f=f\circ\operatorname{id}_A.

For f(x)=x+1f(x)=x+1 and g(x)=2xg(x)=2x on R\mathbb R, we get (g∘f)(x)=2x+2(g\circ f)(x)=2x+2 and (f∘g)(x)=2x+1(f\circ g)(x)=2x+1. Pointwise multiplication instead gives (fg)(x)=2x(x+1)(fg)(x)=2x(x+1). The operations answer different questions even when both functions share a numerical domain.

ProofComposing injective or surjective functions

If f,gf,g are injective and g(f(x))=g(f(y))g(f(x))=g(f(y)), injectivity of gg gives f(x)=f(y)f(x)=f(y), then that of ff gives x=yx=y.

If f,gf,g are surjective, take arbitrary c∈Cc\in C. Choose b∈Bb\in B with g(b)=cg(b)=c, then a∈Aa\in A with f(a)=bf(a)=b. Thus (g∘f)(a)=c(g\circ f)(a)=c. Therefore a composition of bijections is a bijection.

Some converse conclusions are weaker: if g∘fg\circ f is injective, ff must be injective; if g∘fg\circ f is surjective, gg must be surjective. One cannot conclude that both component functions are bijective merely because the composition is. An exercise below provides a counterexample.

Inverse functions and inverse images

A two-sided inverse of f:A→Bf:A\to B is a function h:B→Ah:B\to A satisfying

h∘f=id⁡A,f∘h=id⁡B.h\circ f=\operatorname{id}_A, \qquad f\circ h=\operatorname{id}_B.

Such an inverse exists exactly when ff is bijective. If ff is bijective, every b∈Bb\in B has exactly one preimage; assigning that preimage defines hh. Conversely, the first identity makes ff injective, and the second makes it surjective. The inverse is unique and is denoted f−1f^{-1}.

For f(x)=3x−2f(x)=3x-2, the inverse is f−1(b)=(b+2)/3f^{-1}(b)=(b+2)/3, not 1/(3b−2)1/(3b-2). An injective f:A→Bf:A\to B always has an inverse after regarding it as a bijection A→f[A]A\to f[A]; that does not make it invertible on all of BB when some outputs are missed.

The expression f−1[T]f^{-1}[T] still denotes a preimage set even when no inverse function exists. When ff is bijective, it agrees with the image of TT under the inverse function. Keeping the brackets and domains explicit prevents the two meanings from being confused.

Restrictions and partial functions

For D⊆AD\subseteq A, the restriction f∣D:D→Bf|_D:D\to B keeps the same outputs on a smaller domain. It is a total function on its own declared domain DD. A partial function p:A⇀Bp:A\rightharpoonup B instead has an actual domain D⊆AD\subseteq A while retaining AA as the ambient input set; some ambient inputs may have no output.

The reciprocal rule is partial on ambient input set R\mathbb R, but total as a map R∖{0}→R\mathbb R\setminus\{0\}\to\mathbb R. To encode missing outputs, introduce a fresh symbol ⊥∉B\bot\notin B and define a total map p∗:A→B∪{⊥}p^*:A\to B\cup\{\bot\} which agrees with pp on DD and returns ⊥\bot elsewhere. This changes the codomain explicitly; it does not prove that the original rule had an output at every input.

Exercises

ExerciseCheck the type of an input

For a mapping with domain {0,1}×P(Z)\{0,1\}\times\mathcal P(\mathbb Z) and codomain N\mathbb N, explain why (1,{−3,6})(1,\{-3,6\}) is a valid input and 99 a valid output value, while (8,−7)(8,-7) is not a valid input.

Show solution
Solution

The first component must lie in {0,1}\{0,1\}, and the second must be a subset of Z\mathbb Z. The first pair meets both requirements. The second has an invalid first component and an integer rather than an integer subset as its second component. Knowing that 99 is in the codomain does not determine which input, if any, maps to it.

ExerciseRepair the domain or the rule

Do x↦xx\mapsto\sqrt x and the relation y2=xy^2=x define functions R→R\mathbb R\to\mathbb R? Give a precise function obtained by making appropriate restrictions.

Show solution
Solution

The real square-root rule is undefined for negative inputs. The relation y2=xy^2=x also allows two outputs for positive xx. Requiring x≥0x\ge0 and choosing the nonnegative root gives the function [0,∞)→[0,∞)[0,\infty)\to[0,\infty), x↦xx\mapsto\sqrt x. Its existence and uniqueness are properties of the real numbers, not consequences of merely writing the relation.

ExerciseA surjection from integer pairs

For f:Z2→Zf:\mathbb Z^2\to\mathbb Z, f(m,n)=2m−nf(m,n)=2m-n, determine whether ff is injective and whether it is surjective.

Show solution
Solution

It is surjective: for arbitrary z∈Zz\in\mathbb Z, take (m,n)=(0,−z)(m,n)=(0,-z). It is not injective, since (0,0)(0,0) and (1,2)(1,2) both map to 00. Every claimed witness belongs to the declared product domain.

ExerciseA bijective composition need not have bijective factors

Take A=C={0}A=C=\{0\} and B={0,1}B=\{0,1\}. Let f:A→Bf:A\to B send 00 to 00, and let g:B→Cg:B\to C send both inputs to 00. Check g∘fg\circ f, ff, and gg.

Show solution
Solution

The composition is the identity on the singleton and hence bijective. But ff misses 11 and is not surjective; gg identifies two distinct inputs and is not injective. This refutes the claim that a bijective composition forces both factors to be bijections.

ExerciseWhen do images preserve intersections?

Prove that an injective ff satisfies f[C∩D]=f[C]∩f[D]f[C\cap D]=f[C]\cap f[D]. Identify where injectivity is used.

Show solution
Solution

The forward inclusion holds for every function. For the reverse, take y=f(c)=f(d)y=f(c)=f(d) with c∈Cc\in C and d∈Dd\in D. Injectivity gives c=dc=d, so this common input lies in C∩DC\cap D and witnesses membership on the left. The square-function counterexample in the text shows why the equality can fail without injectivity.

ExerciseCompute an inverse and a preimage

For f:[0,∞)→[0,∞)f:[0,\infty)\to[0,\infty), f(x)=x2f(x)=x^2, find its inverse and compute f−1[T]f^{-1}[T] for T=[1,4]T=[1,4]. Repeat the preimage computation when the domain is all of R\mathbb R.

Show solution
Solution

On the nonnegative domain, the inverse is y↦yy\mapsto\sqrt y and the preimage of [1,4][1,4] is [1,2][1,2]. On all reals, the preimage becomes [−2,−1]∪[1,2][-2,-1]\cup[1,2], even though the function is no longer injective and has no two-sided inverse. This distinguishes a preimage operation from an inverse function.

Continue with Sequences and Series. For detailed properties of elementary real functions, see the calculus collection; their long catalogue is not needed to establish the mapping concepts here.

References

  1. [1] T. Button, Set Theory. Open Logic Project, 2026. Fall 2021 course text, revised July 2026. https://builds.openlogicproject.org/courses/set-theory/settheory-screen.pdf ↩