Answer
No inverse
Work Step by Step
Given the function
\[
\ell: S \;\to\; \mathbb{Z}_{\mathrm{nonneg}}
\quad\text{by}\quad
\ell(s) = \text{the length of the string } s,
\]
where \(S\) is the set of **all** finite strings of 0's and 1's, and \(\mathbb{Z}_{\mathrm{nonneg}}\) is the set of all nonnegative integers \(\{0,1,2,\dots\}\).
We are to determine whether \(\ell\) is **one-to-one** (injective) and whether it is **onto** (surjective).
---
## (a) Is \(\ell\) one-to-one?
Recall that a function is injective if \(\ell(s_1) = \ell(s_2)\) always implies \(s_1 = s_2\).
- **Counterexample**: Consider the strings \(s_1 = "0"\) and \(s_2 = "1"\). Both have length 1, so
\[
\ell("0") \;=\; 1
\quad\text{and}\quad
\ell("1") \;=\; 1,
\]
yet \("0" \neq "1"\).
Because two distinct strings can have the same length, \(\ell\) is **not** one-to-one.
---
## (b) Is \(\ell\) onto?
A function is surjective if for **every** nonnegative integer \(n\), there is **some** string \(s \in S\) such that \(\ell(s) = n\).
- Given any \(n \in \mathbb{Z}_{\mathrm{nonneg}}\), we can construct a string of length \(n\). For example:
- If \(n=0\), the **empty string** has length 0.
- If \(n > 0\), then a string of \(n\) zeros (e.g. \("000\cdots0"\)) or \(n\) ones, or **any** combination of 0's and 1's, has length \(n\).
Hence, for every \(n\), there **exists** a string \(s\) with \(\ell(s) = n\). Therefore, \(\ell\) **is** onto \(\mathbb{Z}_{\mathrm{nonneg}}\).
---
### Conclusion
- \(\ell\) is **not** one-to-one (injective).
- \(\ell\) **is** onto (surjective).