One-to-one (injective) functions [00A0]
- March 10, 2026
Definition One-to-one / injective [00A1]
- March 10, 2026
A function f : A \to B is one-to-one (injective, an injection) iff no two different elements of the domain map to the same element of the codomain. That is, \forall a_1, a_2 \in A .\; a_1 \neq a_2 \rightarrow f(a_1) \neq f(a_2), or equivalently, taking the contrapositive, \forall a_1, a_2 \in A .\; f(a_1) = f(a_2) \rightarrow a_1 = a_2.
Remark Proving that a function is injective [00A2]
- March 10, 2026
If we want to prove that a function is one-to-one / injective, we typically use the first formulation: for arbitrary a_1, a_2 \in A, we must prove f(a_1) = f(a_2) \rightarrow a_1 = a_2, which we can do by supposing f(a_1) = f(a_2) and proving that a_1 = a_2.
Remark Proving that a function is not injective [00A3]
- March 10, 2026
To prove that a function is not one-to-one / injective, we need to prove the negation:
That is, we pick a_1 and a_2 which are not equal, and show that f(a_1) = f(a_2).
Which of our example functions g, h, and \ell are injective? For those that are not, could we make another function with the same domain and codomain which is injective?
Example [00A4]
- March 10, 2026
g is not not injective, since \diamond \neq \square but g(\diamond ) = g(\square ) = 6. We could easily make a different function with the same domain and codomain which is injective. For example, the function which is the same as g on \triangle and \square but sends \diamond to 349.
Example [00A5]
- March 10, 2026
h is injective, which we can prove as follows.
Proof.
- March 10, 2026
Example [00A6]
- March 10, 2026
\ell is very much not injective (for example, every single multiple of 3 maps to \diamond ). Moreover, there is no way to make an injective function with the same domain and codomain.
Checking injectivity with Disco [00A7]
- March 10, 2026
Let's use Disco to check the injectivity of our example functions from before.
Disco can tell us for sure that g is injective:
Disco> :test forall x:Bool, y:Bool. g(x) == g(y) -> x == y
- Certainly true: ∀x, y. g(x) == g(y) -> x == y
No counterexamples exist; all possible values were checked.With h, on the other hand, Disco cannot tell for sure, but reports that it tried a bunch of examples without finding a counterexample. This makes sense: since the domain of h is the natural numbers, there are infinitely many inputs to try, so Disco cannot try them all. (Of course, we can prove that h is injective, but Disco is not doing anything that sophisticated.)
Disco> :test forall x:N, y:N. h(x) == h(y) -> x == y
- Possibly true: ∀x, y. h(x) == h(y) -> x == y
Checked 100 possibilities without finding a counterexample.The function l is not injective, and Disco finds a counterexample immediately:
Disco> :test forall x:N, y:N. l(x) == l(y) -> x == y
- Certainly false: ∀x, y. l(x) == l(y) -> x == y
Found counterexample:
x = 0
y = 3
- Certainly true: l(x) == l(y)
- Left side: F
- Right side: F
- Certainly false: x == y
- Left side: 0
- Right side: 3Disco also easily finds a counterexample showing that j is not injective (try it yourself!).
As one last example, we can try making a function which is "almost" injective, which fools Disco:
k : N -> N
k(193) = 0
k(n) = 2n
Disco> :test forall x:N, y:N. k(x) == k(y) -> x == y
- Possibly true: ∀x, y. k(x) == k(y) -> x == y
Checked 100 possibilities without finding a counterexample.We can easily see that k is not injective, since k(0) = k(193) = 0, but Disco happened not to try those particular inputs. When Disco says that something is "possibly" true or false, we must take it with a grain of salt!