Inverting a Bijection

A bijection maps each output to exactly one input. Its inverse sends that output back to the unique originating input.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Reverse a small encoding
  2. Test both directions
  3. Reverse each pair only after checking uniqueness and coverage
  4. Verify both round trips against the declared sets

Reverse a small encoding

If statuses draft, sent, and read map to 0, 1, and 2, then the inverse at 1 yields sent. Check both distinct outputs and complete coverage for the declared sets. This combines injectivity with surjectivity.

Test both directions

Encoding and then decoding must recover each allowed status. Decoding and then encoding must recover every supported code too. Round-trip tests put those two equations into independently checkable examples.[1]

Reverse each pair only after checking uniqueness and coverage

A mapping from IDs A, B and C to distinct seats three, one and two uses every target seat. Its inverse sends one to B, two to C and three to A. Forward followed by backward returns the starting ID, and backward followed by forward returns the starting seat. See function composition order.

Forward: A→3, B→1, C→2
Backward: 1→B, 2→C, 3→A
Round trip from B: B→1→B
Round trip from 2: 2→C→2

Verify both round trips against the declared sets

If two IDs share one seat, one reverse entry cannot recover both. If a seat is unused, a reverse function on all seats has no corresponding preimage there. Enumerate small tables to inspect both requirements directly.

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩