Domain, Codomain, and Image

A domain names allowed inputs, a codomain names the result set, and an image consists of results actually reached.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Read a finite example
  2. Use the distinction in a program
  3. Compute the image from actual mapped values
  4. Check how changing an interface affects the claim

Read a finite example

Map \(0,1,2\) to their squares with codomain all nonnegative integers. The image is \(\{0,1,4\}\). The value nine is permitted by the codomain but not reached by these inputs. Discrete mappings describe the assignment rule.

Use the distinction in a program

A report API can expose several statuses, while today's records use only two. Test every promised status using known inputs where possible. Exhaustive case handling describes the responsibility when reading those results.[1]

Compute the image from actual mapped values

Let \(f\) map \(\{1,2,3\}\) to \(\{0,1,2\}\) by taking the remainder modulo two. Its image is \(\{0,1\}\). The possible output type permits two, and the formula on the declared input never returns it. See surjectivity and codomain.

Input:   1  2  3
f(input) 1  0  1
Domain size: 3
Image size: 2
Codomain size: 3

Check how changing an interface affects the claim

Restricting the codomain to \(\{0,1\}\) makes the function surjective without changing its graph. Restricting the domain to odd inputs shrinks its image. State these sets before claiming invertibility or supported output values.

References

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