Source and provenance

These are all 7 files in the frozen Functions source boundary, shown line by line and copied byte-for-byte for download. The reading views bind all 414 formula occurrences to their exact source locations.

content/sets-functions-relations/functions/composition.tex

67 lines; SHA-256 091c7ab9e4d0517b2a62f4ecf10e4eb75f0f83e31e1bbd9c365c4b751b981fee. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. % Section: composition
  4. \documentclass[../../../include/open-logic-section]{subfiles}
  5. \begin{document}
  6. \olfileid{sfr}{fun}{cmp}
  7. \olsection{Composition of Functions}
  8. \begin{explain}
  9. \oliflabeldef{sfr:fun:inv:sec}{We saw in \olref[inv]{sec} that the
  10. inverse~$f^{-1}$ of !!a{bijection}~$f$ is itself a function. Another
  11. operation on functions is composition: w}{W}e can define a new
  12. function by composing two functions, $f$ and~$g$, i.e., by first
  13. applying $f$ and then~$g$. Of course, this is only possible if the
  14. ranges and domains match, i.e., the range of~$f$ must be a subset of
  15. the domain of~$g$. \oliflabeldef{sfr:rel:ops:sec}{This operation on
  16. functions is the analogue of the operation of relative product on
  17. relations from \olref[rel][ops]{sec}.}{}
  18. A diagram might help to explain the idea of composition. In
  19. \olref{fig:composition}, we depict two functions $f \colon A \to B$
  20. and $g \colon B \to C$ and their composition~$(\comp{f}{g})$. The
  21. function $(\comp{f}{g}) \colon A \to C$ pairs each !!{element} of~$A$
  22. with !!a{element} of~$C$. We specify which !!{element} of~$C$
  23. !!a{element} of $A$ is paired with as follows: given an input $x \in
  24. A$, first apply the function $f$ to~$x$, which will output some $f(x)
  25. = y \in B$, then apply the function $g$ to~$y$, which will output some
  26. $g(f(x)) = g(y) = z \in C$.
  27. \begin{figure}
  28. \olasset[2\olphotowidth]{assets/diagrams/composition.tikz}
  29. \caption{The composition $g \circ f$ of two functions $f$ and~$g$.}
  30. \ollabel{fig:composition}
  31. \end{figure}
  32. \end{explain}
  33. \begin{defn}[Composition]
  34. Let $f\colon A \to B$ and $g\colon B \to C$ be functions. The
  35. \emph{composition} of $f$ with~$g$ is $\comp{f}{g} \colon A \to C$,
  36. where $(\comp{f}{g})(x) = g(f(x))$.
  37. \end{defn}
  38. \begin{ex}
  39. Consider the functions $f(x) = x + 1$, and $g(x) = 2x$. Since
  40. $(\comp{f}{g})(x) = g(f(x))$, for each input~$x$ you must first take
  41. its successor, then multiply the result by two. So their composition
  42. is given by $(\comp{f}{g})(x) = 2(x+1)$.
  43. \end{ex}
  44. \begin{prob}
  45. Show that if $f \colon A \to B$ and $g \colon B \to C$ are both
  46. !!{injective}, then $\comp{f}{g}\colon A \to C$ is !!{injective}.
  47. \end{prob}
  48. \begin{prob}
  49. Show that if $f \colon A \to B$ and $g \colon B \to C$ are both
  50. !!{surjective}, then $\comp{f}{g}\colon A \to C$ is !!{surjective}.
  51. \end{prob}
  52. \begin{prob}
  53. Suppose $f \colon A \to B$ and $g \colon B \to C$. Show that the graph
  54. of $\comp{f}{g}$ is $R_f \mid R_g$.
  55. \end{prob}
  56. \end{document}

content/sets-functions-relations/functions/function-basics.tex

140 lines; SHA-256 f01a58d84a175f42d8c233ef0e7d41c23d406b54e8f11475c14514b64eca3dc7. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. % Section: basics
  4. \documentclass[../../../include/open-logic-section]{subfiles}
  5. \begin{document}
  6. \olfileid{sfr}{fun}{bas}
  7. \olsection{Basics}
  8. \begin{explain}
  9. A \emph{function} is a map which sends each !!{element} of a given set
  10. to a specific !!{element} in some (other) given set. For instance, the
  11. operation of adding~$1$ defines a function: each number~$n$ is mapped
  12. to a unique number~$n+1$.
  13. More generally, functions may take pairs, triples, etc., as inputs and
  14. return some kind of output. Many functions are familiar to us from
  15. basic arithmetic. For instance, addition and multiplication are
  16. functions. They take in two numbers and return a third.
  17. In this mathematical, abstract sense, a function is a \emph{black
  18. box}: what matters is only what output is paired with what input, not
  19. the method for calculating the output.
  20. \end{explain}
  21. \begin{defn}[Function]
  22. A \emph{function} $f \colon A \to B$ is a mapping of each !!{element}
  23. of~$A$ to an !!{element} of~$B$.
  24. We call $A$ the \emph{domain} of~$f$ and $B$ the \emph{codomain}
  25. of~$f$. The !!{element}s of~$A$ are called inputs or \emph{arguments}
  26. of~$f$, and the !!{element} of~$B$ that is paired with an argument~$x$
  27. by~$f$ is called the \emph{value of~$f$} for argument~$x$,
  28. written~$f(x)$.
  29. The \emph{range} $\ran{f}$ of~$f$ is the subset of the codomain
  30. consisting of the values of~$f$ for some argument; $\ran{f} =
  31. \Setabs{f(x)}{x \in A}$.
  32. \end{defn}
  33. The diagram in \olref{fig:function} may help to think about functions. The ellipse
  34. on the left represents the function's \emph{domain}; the ellipse on
  35. the right represents the function's \emph{codomain}; and an arrow
  36. points from an \emph{argument} in the domain to the corresponding
  37. \emph{value} in the codomain.
  38. \begin{figure}
  39. \olasset{assets/diagrams/function.tikz}
  40. \caption{A function is a mapping of each !!{element} of one set to
  41. !!a{element} of another. An arrow points from an argument in the
  42. domain to the corresponding value in the codomain.}
  43. \ollabel{fig:function}
  44. \end{figure}
  45. \begin{ex}
  46. Multiplication takes pairs of natural numbers as inputs and maps them
  47. to natural numbers as outputs, so goes from $\Nat \times \Nat$ (the
  48. domain) to $\Nat$ (the codomain). As it turns out, the range is also
  49. $\Nat$, since every $n \in \Nat$ is $n \times 1$.
  50. \end{ex}
  51. \begin{ex}
  52. Multiplication is a function because it pairs each input---each pair
  53. of natural numbers---with a single output: $\times \colon \Nat^2 \to
  54. \Nat$. By contrast, mapping a natural number~$n$ to a real~$x$ such
  55. that $x^2 = n$ is not functional, since each positive integer~$n$ has two
  56. square roots: $\sqrt{n}$ and~$-\sqrt{n}$. We can make it functional by
  57. only returning the positive square root: $\sqrt{\phantom{X}} \colon
  58. \Nat \to \Real$.
  59. \end{ex}
  60. \begin{ex}
  61. The relation that pairs each student in a class with their final grade
  62. is a function---no student can get two different final grades in the
  63. same class. The relation that pairs each student in a class with their
  64. parents is not a function: students can have zero, or two, or more
  65. parents.
  66. \end{ex}
  67. \begin{explain}
  68. We can define functions by specifying in some precise way what the
  69. value of the function is for every possible argument. Different ways of
  70. doing this are by giving a formula, describing a method for computing
  71. the value, or listing the values for each argument. However functions
  72. are defined, we must make sure that for each argument we specify one,
  73. and only one, value.
  74. \end{explain}
  75. \begin{ex}
  76. Let $f \colon \Nat \to \Nat$ be defined such that $f(x) = x+1$. This
  77. is a definition that specifies $f$ as a function which takes in
  78. natural numbers and outputs natural numbers. It tells us that, given a
  79. natural number~$x$, $f$ will output its successor~$x+1$.
  80. In this case, the codomain $\Nat$ is not the range of~$f$, since the
  81. natural number~$0$ is not the successor of any natural number. The
  82. range of~$f$ is the set of all positive integers, $\Int^{+}$.
  83. \end{ex}
  84. \begin{ex}\ollabel{examplefunext}
  85. Let $g \colon \Nat \to \Nat$ be defined such that $g(x) = x+2-1$. This
  86. tells us that $g$ is a function which takes in natural numbers and
  87. outputs natural numbers. Given a natural number~$n$, $g$ will output
  88. the predecessor of the successor of the successor of~$x$, i.e.,
  89. $x+1$.
  90. \end{ex}
  91. \begin{explain}
  92. We just considered two functions, $f$ and $g$, with different
  93. \emph{definitions}. However, these are the \emph{same function}. After
  94. all, for any natural number~$n$, we have that $f(n) = n+1 = n+2-1 =
  95. g(n)$. Otherwise put: our definitions for $f$ and~$g$ specify the
  96. same mapping by means of different equations. Implicitly, then, we are
  97. relying upon a principle of extensionality for functions,
  98. \[
  99. \text{if }\forall x\, f(x) = g(x)\text{, then }f = g
  100. \]
  101. provided that $f$ and~$g$ share the same domain and codomain.
  102. \end{explain}
  103. \begin{ex}
  104. We can also define functions by cases. For instance, we could define
  105. $h \colon \Nat \to \Nat$ by
  106. \[
  107. h(x) =
  108. \begin{cases}
  109. \frac{x}{2} & \text{if $x$ is even} \\
  110. \frac{x+1}{2} & \text{if $x$ is odd.}
  111. \end{cases}
  112. \]
  113. Since every natural number is either even or odd, the output of this
  114. function will always be a natural number. Just remember that if you
  115. define a function by cases, every possible input must fall into
  116. exactly one case. In some cases, this will require a proof that the
  117. cases are exhaustive and exclusive.
  118. \end{ex}
  119. \end{document}

content/sets-functions-relations/functions/function-kinds.tex

118 lines; SHA-256 6dfe2a70579f8e3521d8e2286e2360dd58a19fbeda9718b62342105388ab4f93. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. % Section: kinds
  4. \documentclass[../../../include/open-logic-section]{subfiles}
  5. \begin{document}
  6. \olfileid{sfr}{fun}{kin}
  7. \olsection{Kinds of Functions}
  8. \begin{explain}
  9. It will be useful to introduce a kind of taxonomy for some of the
  10. kinds of functions which we encounter most frequently.
  11. To start, we might want to consider functions which have the property
  12. that every member of the codomain is a value of the function. Such
  13. functions are called !!{surjective}, and can be pictured as in
  14. \olref{fig:surjective}.
  15. \begin{figure}
  16. \olasset{assets/diagrams/surjective.tikz}
  17. \caption{!!^a{surjective} function has every !!{element} of the
  18. codomain as a value.}
  19. \ollabel{fig:surjective}
  20. \end{figure}
  21. \end{explain}
  22. \begin{defn}[!!^{surjective} function]
  23. A function $f \colon A \rightarrow B$ is \emph{!!{surjective}} iff $B$
  24. is also the range of~$f$, i.e., for every $y \in B$ there is at least
  25. one $x \in A$ such that~$f(x) = y$, or in symbols:
  26. \[
  27. (\forall y \in B)(\exists x \in A)f(x) = y.
  28. \]
  29. We call such a function !!a{surjection} from $A$ to $B$.
  30. \end{defn}
  31. \begin{explain}
  32. If you want to show that $f$ is !!a{surjection}, then you need to show
  33. that every object in $f$'s codomain is the value of $f(x)$ for some
  34. input $x$.
  35. Note that any function \emph{induces} !!a{surjection}. After all,
  36. given a function $f \colon A \to B$, let $f' \colon A \to \ran{f}$ be
  37. defined by $f'(x) = f(x)$. Since $\ran{f}$ is \emph{defined} as
  38. $\Setabs{f(x) \in B}{x \in A}$, this function $f'$ is guaranteed to be
  39. !!a{surjection}
  40. \end{explain}
  41. \begin{explain}
  42. Now, any function maps each possible input to a unique output. But
  43. there are also functions which never map different inputs to the same
  44. outputs. Such functions are called !!{injective}, and can be pictured
  45. as in \olref{fig:injective}.
  46. \begin{figure}
  47. \olasset{assets/diagrams/injective.tikz}
  48. \caption{!!^a{injective} function never maps two different
  49. arguments to the same value.}
  50. \ollabel{fig:injective}
  51. \end{figure}
  52. \end{explain}
  53. \begin{defn}[!!^{injective} function]
  54. A function $f \colon A \rightarrow B$ is \emph{!!{injective}} iff for
  55. each $y \in B$ there is at most one $x \in A$ such that~$f(x) = y$. We
  56. call such a function !!a{injection} from $A$ to~$B$.
  57. \end{defn}
  58. \begin{explain}
  59. If you want to show that $f$ is !!a{injection}, you need to show that
  60. for any !!{element}s $x$ and $y$ of $f$'s domain, if $f(x)=f(y)$, then
  61. $x=y$.
  62. \end{explain}
  63. \begin{ex}
  64. The constant function $f\colon \Nat \to \Nat$ given by $f(x) = 1$ is
  65. neither !!{injective}, nor !!{surjective}.
  66. The identity function $f\colon \Nat \to \Nat$ given by $f(x) = x$ is
  67. both !!{injective} and !!{surjective}.
  68. The successor function $f \colon \Nat \to \Nat$ given by $f(x) = x+1$
  69. is !!{injective} but not !!{surjective}.
  70. The function $f \colon \Nat \to \Nat$ defined by:
  71. \[
  72. f(x) =
  73. \begin{cases}
  74. \frac{x}{2} & \text{if $x$ is even} \\
  75. \frac{x+1}{2} & \text{if $x$ is odd.}
  76. \end{cases}
  77. \]
  78. is !!{surjective}, but not !!{injective}.
  79. \end{ex}
  80. \begin{explain}
  81. Often enough, we want to consider functions which are both
  82. !!{injective} and !!{surjective}. We call such functions
  83. !!{bijective}. They look like the function pictured in
  84. \olref{fig:bijective}. !!^{bijection}s are also sometimes called
  85. \emph{one-to-one correspondences}, since they uniquely pair elements
  86. of the codomain with elements of the domain.
  87. \begin{figure}
  88. \olasset{assets/diagrams/bijective.tikz}
  89. \caption{!!^a{bijective} function uniquely pairs the elements of the
  90. codomain with those of the domain.}
  91. \ollabel{fig:bijective}
  92. \end{figure}
  93. \end{explain}
  94. \begin{defn}[!!^{bijection}]
  95. A function $f \colon A \to B$ is \emph{!!{bijective}} iff it is both
  96. !!{surjective} and !!{injective}. We call such a function
  97. !!a{bijection} from $A$ to~$B$ (or between $A$ and~$B$).
  98. \end{defn}
  99. \end{document}

content/sets-functions-relations/functions/functions-relations.tex

103 lines; SHA-256 0205f7168e0679f513e7c95ea7124ce364bce36f9e04f06d519e90f6a5480a5c. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. % Section: functions-relations
  4. \documentclass[../../../include/open-logic-section]{subfiles}
  5. \begin{document}
  6. \olfileid{sfr}{fun}{rel}
  7. \olsection{Functions as Relations}
  8. \begin{explain}
  9. A function which maps !!{element}s of~$A$ to !!{element}s of~$B$
  10. obviously defines a relation between $A$ and~$B$, namely the relation
  11. which holds between $x$ and $y$ iff $f(x) = y$. In fact, we might
  12. even---if we are interested in reducing the building blocks of
  13. mathematics for instance---\emph{identify} the function~$f$ with this
  14. relation, i.e., with a set of pairs. This then raises the question:
  15. which relations define functions in this way?
  16. \end{explain}
  17. \begin{defn}[Graph of a function] Let $f\colon A \to B$ be a function.
  18. The \emph{graph} of~$f$ is the relation $R_f \subseteq A \times B$
  19. defined by
  20. \[
  21. R_f = \Setabs{\tuple{x,y}}{f(x) = y}.
  22. \]
  23. \end{defn}
  24. \begin{explain}
  25. The graph of a function is uniquely determined, by extensionality.
  26. Moreover, extensionality (on sets) will immediately vindicate the
  27. implicit principle of extensionality for functions,
  28. whereby if $f$ and~$g$ share a domain and codomain then they are
  29. identical if they agree on all values.
  30. Similarly, if a relation is ``functional'', then it is the graph of a function.
  31. \end{explain}
  32. \begin{prop}\ollabel{prop:graph-function}
  33. Let $R \subseteq A \times B$ be such that:
  34. \begin{enumerate}
  35. \item If $Rxy$ and $Rxz$ then $y = z$; and
  36. \item for every $x \in A$ there is some $y \in B$ such that $\tuple{x,
  37. y} \in R$.
  38. \end{enumerate}
  39. Then $R$ is the graph of the function $f\colon A \to B$ defined by
  40. $f(x) = y$ iff $Rxy$.
  41. \end{prop}
  42. \begin{proof}
  43. Suppose there is a $y$ such that $Rxy$. If there were another $z \neq
  44. y$ such that $Rxz$, the condition on~$R$ would be violated. Hence, if
  45. there is a $y$ such that $Rxy$, this $y$ is unique, and so $f$ is
  46. well-defined. Obviously, $R_f = R$.
  47. \end{proof}
  48. \begin{explain}
  49. Every function $f\colon A \to B$ has a graph, i.e., a relation on $A
  50. \times B$ defined by $f(x) = y$. On the other hand, every relation~$R
  51. \subseteq A \times B$ with the properties given in
  52. \olref{prop:graph-function} is the graph of a function~$f \colon A \to
  53. B$. Because of this close connection between functions and their
  54. graphs, we can think of a function simply as its graph. In other
  55. words, functions can be identified with certain relations, i.e., with
  56. certain sets of tuples. \oliflabeldef{sfr:rel:ref:sec}{Note, though,
  57. that the spirit of this ``identification'' is as in
  58. \olref[sfr][rel][ref]{sec}: it is not a claim about the metaphysics of
  59. functions, but an observation that it is convenient to \emph{treat}
  60. functions as certain sets. One reason that this is so convenient, is
  61. that w}{W}e can now consider performing similar operations on
  62. functions as we performed on relations (see
  63. \olref[sfr][rel][ops]{sec}). In particular:
  64. \end{explain}
  65. \begin{defn}\ollabel{defn:funimage}
  66. Let $f \colon A \to B$ be a function with $C\subseteq A$.
  67. The \emph{restriction} of~$f$ to~$C$ is the
  68. function~$\funrestrictionto{f}{C}\colon C \to B$ defined by
  69. $(\funrestrictionto{f}{C})(x) = f(x)$ for all $x \in C$. In other
  70. words, $\funrestrictionto{f}{C} = \Setabs{\tuple{x, y} \in R_f}{x \in
  71. C}$.
  72. The \emph{application} of~$f$ to~$C$ is $\funimage{f}{C} =
  73. \Setabs{f(x)}{x \in C}$. We also call this the \emph{image} of~$C$
  74. under~$f$.
  75. \end{defn}
  76. \begin{explain}
  77. It follows from these definitions that $\ran{f} =
  78. \funimage{f}{\dom{f}}$, for any function~$f$.
  79. \oliflabeldef{sfr:rel:ops:sec}{These notions are exactly as one would
  80. expect, given the definitions in \olref[sfr][rel][ops]{sec} and our
  81. identification of functions with relations. But two other
  82. operations---inverses and relative products---require a little more
  83. detail. We will provide that in \olref[inv]{sec} and
  84. \olref[cmp]{sec}.}{}
  85. \end{explain}
  86. \end{document}

content/sets-functions-relations/functions/functions.tex

26 lines; SHA-256 ce481e97a8f301c749d1461326b4ee3d0792b4adc15a1fceb7c6ed3b58ceca54. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. \documentclass[../../../include/open-logic-chapter]{subfiles}
  4. \begin{document}
  5. \olchapter{sfr}{fun}{Functions}
  6. \olimport{function-basics}
  7. \olimport{function-kinds}
  8. \olimport{functions-relations}
  9. \olimport{inverses}
  10. \olimport{composition}
  11. %\olimport{isomorphic-functions}
  12. \olimport{partial-functions}
  13. \OLEndChapterHook
  14. \end{document}

content/sets-functions-relations/functions/inverses.tex

177 lines; SHA-256 93a84a2705e1ed3c92a7f5206c4308420bebbbbcb43824c1eb50e05f83777c4b. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. % Section: inverses
  4. \documentclass[../../../include/open-logic-section]{subfiles}
  5. \begin{document}
  6. \olfileid{sfr}{fun}{inv}
  7. \olsection{Inverses of Functions}
  8. \begin{explain}
  9. We think of functions as maps. An obvious question to ask about
  10. functions, then, is whether the mapping can be ``reversed.'' For
  11. instance, the successor function $f(x) = x + 1$ can be reversed, in
  12. the sense that the function $g(y) = y - 1$ ``undoes'' what $f$ does.
  13. But we must be careful. Although the definition of~$g$ defines a
  14. function $\Int \to \Int$, it does not define a \emph{function} $\Nat
  15. \to \Nat$, since $g(0) \notin \Nat$. So even in simple cases, it is
  16. not quite obvious whether a function can be reversed; it may depend on
  17. the domain and codomain.
  18. This is made more precise by the notion of an inverse of a function.
  19. \end{explain}
  20. \begin{defn}
  21. A function $g \colon B \to A$ is an \emph{inverse} of a function $f
  22. \colon A \to B$ if $f(g(y)) = y$ and $g(f(x)) = x$ for all $x \in A$
  23. and $y \in B$.
  24. \end{defn}
  25. If $f$ has an inverse~$g$, we often write $f^{-1}$ instead of~$g$.
  26. \begin{explain}
  27. Now we will determine when functions have inverses. A good candidate
  28. for an inverse of $f\colon A \to B$ is $g\colon B \to A$ ``defined
  29. by''
  30. \[
  31. g(y) = \text{``the'' $x$ such that $f(x) = y$.}
  32. \]
  33. But the scare quotes around ``defined by'' (and ``the'') suggest that
  34. this is not a definition. At least, it will not always work, with
  35. complete generality. For, in order for this definition to specify a
  36. function, there has to be one and only one~$x$ such that $f(x) =
  37. y$---the output of~$g$ has to be uniquely specified. Moreover, it has
  38. to be specified for every $y \in B$. If there are $x_1$ and $x_2 \in
  39. A$ with $x_1 \neq x_2$ but $f(x_1) = f(x_2)$, then $g(y)$ would not be
  40. uniquely specified for $y = f(x_1) = f(x_2)$. And if there is no~$x$
  41. at all such that $f(x) = y$, then $g(y)$ is not specified at all. In
  42. other words, for $g$ to be defined, $f$~must be both !!{injective} and
  43. !!{surjective}.
  44. Let's go slowly. We'll divide the question into two: Given a
  45. function~$f\colon A \to B$, when is there a function $g\colon B \to A$
  46. so that $g(f(x)) = x$? Such a $g$ ``undoes'' what $f$ does, and is
  47. called a \emph{left inverse} of~$f$. Secondly, when is there a
  48. function $h\colon B \to A$ so that $f(h(y)) = y$? Such an $h$ is
  49. called a \emph{right inverse} of~$f$---$f$ ``undoes'' what $h$~does.
  50. \end{explain}
  51. \begin{prop}
  52. If $f\colon A \to B$ is !!{injective}, then there is a \emph{left
  53. inverse}~$g\colon B \to A$ of~$f$ so that $g(f(x)) = x$ for all $x
  54. \in A$.
  55. \end{prop}
  56. \begin{proof}
  57. Suppose that $f\colon A \to B$ is !!{injective}. Consider a $y \in B$.
  58. If $y \in \ran{f}$, there is an $x \in A$ so that $f(x) = y$. Because
  59. $f$ is !!{injective}, there is only one such~$x \in A$. Then we can
  60. define: $g(y) = x$, i.e., $g(y)$ is ``the'' $x \in A$ such that $f(x)
  61. = y$. If $y \notin \ran{f}$, we can map it to any~$a \in A$. So, we
  62. can pick an $a \in A$ and define $g\colon B \to A$ by:
  63. \[
  64. g(y) = \begin{cases}
  65. x & \text{if $f(x) = y$}\\
  66. a & \text{if $y \notin \ran{f}$.}
  67. \end{cases}
  68. \]
  69. It is defined for all $y \in B$, since for each such $y \in \ran{f}$
  70. there is exactly one $x \in A$ such that $f(x) = y$. By definition, if
  71. $y = f(x)$, then $g(y) = x$, i.e., $g(f(x)) = x$.
  72. \end{proof}
  73. \begin{prob}
  74. Show that if $f\colon A \to B$ has a left inverse~$g$, then $f$~is
  75. !!{injective}.
  76. \end{prob}
  77. \begin{prop}
  78. If $f\colon A \to B$ is !!{surjective}, then there is a
  79. \emph{right inverse}~$h\colon B \to A$ of~$f$ so that $f(h(y)) =
  80. y$ for all~$y \in B$.
  81. \end{prop}
  82. \begin{proof}
  83. Suppose that $f\colon A \to B$ is !!{surjective}. Consider a $y \in
  84. B$. Since $f$~is !!{surjective}, there is an $x_y \in A$ with $f(x_y)
  85. = y$. Then we can define: $h(y) = x_y$, i.e., for each $y \in B$ we
  86. choose some $x \in A$ so that $f(x) = y$; since $f$~is !!{surjective}
  87. there is always at least one to choose from.\footnote{Since $f$ is
  88. !!{surjective}, for every~$y \in B$ the set $\Setabs{x}{f(x) = y}$ is
  89. nonempty. Our definition of~$h$ requires that we choose a single $x$
  90. from each of these sets. That this is always possible is actually not
  91. obvious---the possibility of making these choices is simply assumed as an axiom.
  92. In other words, this proposition assumes the so-called Axiom of
  93. Choice, an issue we will \oliflabeldef{sth:choice::chap}{revisit in \olref[sth][choice][]{chap}}{gloss over}.
  94. However, in many specific cases, e.g., when $A = \Nat$ or is finite, or when $f$ is !!{bijective},
  95. the Axiom of Choice is not required. (In the particular case when $f$ is !!{bijective}, for each $y \in B$ the set
  96. $\Setabs{x}{f(x) = y}$ has exactly one !!{element}, so that there is no choice to make.)}
  97. By definition, if $x = h(y)$,
  98. then $f(x) = y$, i.e., for any $y \in B$, $f(h(y)) = y$.
  99. \end{proof}
  100. \begin{prob}
  101. Show that if $f\colon A \to B$ has a right inverse~$h$, then $f$~is
  102. !!{surjective}.
  103. \end{prob}
  104. \begin{explain}
  105. By combining the ideas in the previous proof, we now get that every
  106. !!{bijection} has an inverse, i.e., there is a single function
  107. which is both a left and right inverse of~$f$.
  108. \end{explain}
  109. \begin{prop}\ollabel{prop:bijection-inverse}
  110. If $f\colon A \to B$ is !!{bijective}, there is a
  111. function~$f^{-1}\colon B \to A$ so that for all $x \in A$,
  112. $f^{-1}(f(x)) = x$ and for all $y \in B$, $f(f^{-1}(y)) = y$.
  113. \end{prop}
  114. \begin{proof}
  115. Exercise.
  116. \end{proof}
  117. \begin{prob}
  118. Prove \olref[sfr][fun][inv]{prop:bijection-inverse}. You have to
  119. define~$f^{-1}$, show that it is a function, and show that it is an
  120. inverse of~$f$, i.e., $f^{-1}(f(x)) = x$ and $f(f^{-1}(y)) = y$ for
  121. all $x \in A$ and $y \in B$.
  122. \end{prob}
  123. \begin{explain}
  124. There is a slightly more general way to extract inverses. We saw in
  125. \olref[kin]{sec} that every function $f$ induces !!a{surjection} $f'
  126. \colon A \to \ran{f}$ by letting $f'(x) = f(x)$ for all $x \in A$.
  127. Clearly, if $f$~is !!{injective}, then $f'$~is !!{bijective}, so that
  128. it has a unique inverse by \olref{prop:bijection-inverse}. By a very
  129. minor abuse of notation, we sometimes call the inverse of $f'$ simply
  130. ``the inverse of~$f$.''
  131. \end{explain}
  132. \begin{prop}\ollabel{prop:left-right}%
  133. Show that if $f\colon A \to B$ has a left inverse~$g$ and a right
  134. inverse~$h$, then $h = g$.
  135. \end{prop}
  136. \begin{proof}
  137. Exercise.
  138. \end{proof}
  139. \begin{prob}
  140. Prove \olref[sfr][fun][inv]{prop:left-right}.
  141. \end{prob}
  142. \begin{prop}\ollabel{prop:inverse-unique}
  143. Every function~$f$ has at most one inverse.
  144. \end{prop}
  145. \begin{proof}
  146. Suppose $g$ and $h$ are both inverses of~$f$. Then in particular
  147. $g$~is a left inverse of~$f$ and $h$~is a right inverse. By
  148. \olref{prop:left-right}, $g = h$.
  149. \end{proof}
  150. \end{document}

content/sets-functions-relations/functions/partial-functions.tex

75 lines; SHA-256 2a1e79725a70fde443cc3c19c325a2c422c49e7ccd095c965f8c50fd5cc6b10b. Open the preserved source file.

  1. % Part: sets-functions-relations
  2. % Chapter: functions
  3. % Section: partial-functions
  4. \documentclass[../../../include/open-logic-section]{subfiles}
  5. \begin{document}
  6. \olfileid{sfr}{fun}{par}
  7. \olsection{Partial Functions}
  8. \begin{explain}
  9. It is sometimes useful to relax the definition of function so that it
  10. is not required that the output of the function is defined for all
  11. possible inputs. Such mappings are called \emph{partial functions}.
  12. \end{explain}
  13. \begin{defn}
  14. A \emph{partial function} $f \colon A \pto B$ is a mapping which
  15. assigns to every !!{element} of~$A$ at most one !!{element} of~$B$.
  16. If $f$ assigns an element of~$B$ to $x \in A$, we say $f(x)$ is
  17. \emph{defined}, and otherwise \emph{undefined}. If $f(x)$ is defined,
  18. we write $f(x) \fdefined$, otherwise $f(x) \fundefined$. The
  19. \emph{domain} of a partial function~$f$ is the subset of~$A$ where it
  20. is defined, i.e., $\dom{f} = \Setabs{x \in A}{f(x) \fdefined}$.
  21. \end{defn}
  22. \begin{ex}
  23. Every function $f\colon A \to B$ is also a partial function. Partial
  24. functions that are defined everywhere on~$A$---i.e., what we so far
  25. have simply called a function---are also called \emph{total}
  26. functions.
  27. \end{ex}
  28. \begin{ex}
  29. The partial function $f \colon \Real \pto \Real$ given by $f(x) = 1/x$
  30. is undefined for $x = 0$, and defined everywhere else.
  31. \end{ex}
  32. \begin{prob}
  33. Given $f\colon A \pto B$, define the partial function $g\colon B \pto
  34. A$ by: for any $y \in B$, if there is a unique $x \in A$ such that
  35. $f(x) = y$, then $g(y) = x$; otherwise $g(y) \fundefined$. Show that
  36. if $f$ is injective, then $g(f(x)) = x$ for all $x \in \dom{f}$, and
  37. $f(g(y)) = y$ for all $y \in \ran{f}$.
  38. \end{prob}
  39. \begin{defn}[Graph of a partial function]
  40. Let $f\colon A \pto B$ be a partial function. The \emph{graph} of~$f$
  41. is the relation $R_f \subseteq A \times B$ defined by
  42. \[
  43. R_f = \Setabs{\tuple{x,y}}{f(x) = y}.
  44. \]
  45. \end{defn}
  46. \begin{prop}
  47. Suppose $R \subseteq A \times B$ has the property that whenever $Rxy$
  48. and $Rxy'$ then $y = y'$. Then $R$ is the graph of the partial
  49. function $f\colon A \pto B$ defined by: if there is a $y$ such that
  50. $Rxy$, then $f(x) = y$, otherwise $f(x) \fundefined$. If $R$ is also
  51. \emph{serial}, i.e., for each $x \in A$ there is a $y \in B$ such that
  52. $Rxy$, then $f$ is total.
  53. \end{prop}
  54. \begin{proof}
  55. Suppose there is a $y$ such that $Rxy$. If there were another $y'
  56. \neq y$ such that $Rxy'$, the condition on $R$ would be
  57. violated. Hence, if there is a $y$ such that $Rxy$, that $y$ is
  58. unique, and so $f$ is well-defined. Obviously, $R_f = R$ and $f$ is
  59. total if~$R$ is serial.
  60. \end{proof}
  61. \end{document}