Specify the entire function
A function f from A to B includes a domain A and a specified codomain B. Its image is the subset of B actually reached. The image need not equal the codomain. State these sets before classifying a formula. The rule f(x)=x squared behaves differently from all reals to all reals than from nonnegative reals to nonnegative reals. Although the arithmetic expression is unchanged, both distinction between inputs and coverage of outputs can change. Asking whether a function is injective or surjective without specifying its domain and codomain can therefore leave the question underdetermined.
Injectivity preserves distinct inputs
Injectivity means that equal outputs imply equal inputs. Equivalently, distinct inputs never collide. A function taking one, two, and three to a, b, and c in the codomain {a,b,c,d} is injective even though d is unused. Injectivity concerns distinction, not coverage. Assigning identifiers to objects illustrates the property, but the modeled objects and time interval matter. Reusing an identifier after deletion may change the relevant domain of identities. Absence of duplicates in one database snapshot is not automatically a guarantee of uniqueness across all historical assignments or future operations.
Surjectivity covers the codomain
Surjectivity requires every member of the codomain to have at least one preimage. Mapping one and two to a and three to b is surjective onto {a,b}, despite the collision at a. Enlarging the codomain to {a,b,c} without changing the mapping makes it non-surjective because c is unreachable. Do not silently replace a required codomain with the observed image and then claim that coverage was proved. State the required outputs first, and explain why each has an input. This is an existence claim and does not by itself provide an efficient algorithm for finding that input.
A bijection has a well-defined inverse
A bijection is both injective and surjective. Every output then has exactly one preimage: surjectivity supplies existence and injectivity supplies uniqueness. This permits an inverse function on the whole codomain. Either property alone is weaker. A surjection may offer several possible predecessors, while an injection may leave some codomain elements unreachable. For finite sets of equal size, injectivity and surjectivity imply each other, but both finiteness and equal cardinality are essential assumptions of that counting argument. Keep the inverse’s specified domain explicit instead of treating a partial lookup as a total inverse function.
Infinite sets require a different counting intuition
On integers, f(n)=2n is injective but not surjective because no odd integer is reached. The domain and codomain are the same infinite set, showing why the finite equal-size argument cannot be transferred unchanged. On nonnegative integers, floor(n/2) is surjective but not injective: both 2k and 2k+1 map to k. These examples make the missing assumptions concrete. In software, a fixed-width integer type is finite and may overflow or wrap, depending on the language and operation. A theorem about mathematical integers does not establish the corresponding implementation’s behavior without checking those representation rules.
Check a composition
The composition of two injective functions is injective: equal composite outputs imply equal intermediate values, which imply equal inputs. The composition of two surjections is surjective by tracing a required output back through the two existence guarantees. These arguments assume that the functions compose with compatible domains and codomains. Check that type relationship explicitly; a formal property of each individual function cannot repair an undefined composition.