Injectivity and Losing Information
A mapping is injective when different inputs always produce different outputs. A collision provides a direct counterexample.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Find a useful collision
The square map on integers sends minus three and plus three to nine, so the sign is unrecoverable from its result. Restricting to nonnegative integers makes squaring injective. See domains and images.
Check encoding boundaries
Joining two arbitrary fields without separators can map distinct pairs to the same string. An encoding with recoverable field boundaries avoids that collision. Composite dictionary keys use structured boundaries for the same reason.[1]
Identify exactly which input distinction disappears
A key encoding that concatenates two fields without separators maps ("ab", "c") and ("a", "bc") to the same text. Distinct inputs now collide. A reversible length-prefixed encoding can give the decoder the exact component boundary. See composite dictionary keys.
Original pair Naive output Length-marked encoding
("ab","c") abc 2:ab1:c
("a","bc") abc 1:a2:bc
Check a left inverse on the stated domain
If a decoder recovers every allowed original pair, equal encodings imply equal originals. This proves injectivity over those inputs. State the length unit explicitly when encoding text and test empty components and characters represented by multiple bytes.