Logic, Sets & the Language of Proof

surjection

A function f : A → B is a surjection, or onto, when its image fills the entire codomain: every element of B is hit by at least one element of A. In machine language, every value the codomain offers as a possible output actually gets produced by some input. Nothing in B is left unreached.

The precise statement is a “for all – there exists”: for every y ∈ B there exists x ∈ A with f(x) = y. To prove surjectivity you take an arbitrary target y in the codomain and exhibit (or prove the existence of) some x that maps to it — often by solving f(x) = y for x. Surjectivity is a property of the chosen codomain, not just of the rule: any function becomes surjective if you shrink its codomain down to its image.

This is exactly why specifying the codomain matters. f : R → R given by f(x) = e^x is not surjective, since negative numbers and 0 are never outputs; but f : R → (0, ∞) with the same rule is surjective. Surjectivity is the existence half of solvability: “f is onto” means “the equation f(x) = y has a solution for every y”, a viewpoint that recurs throughout analysis and the theory of equations.

f : R → R, f(x) = x^3 is surjective: given any y, x = y^(1/3) satisfies f(x) = y. But f : R → R, f(x) = x^2 is not — no real x gives f(x) = −1, since squares are never negative.

Onto means every target is solvable; squaring misses the negatives.

Also called
onto function映上函数映成函數