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.
% Part: sets-functions-relations% Chapter: functions% Section: composition\documentclass[../../../include/open-logic-section]{subfiles}\begin{document}\olfileid{sfr}{fun}{cmp}\olsection{Composition of Functions}\begin{explain}\oliflabeldef{sfr:fun:inv:sec}{We saw in \olref[inv]{sec} that theinverse~$f^{-1}$ of !!a{bijection}~$f$ is itself a function. Anotheroperation on functions is composition: w}{W}e can define a newfunction by composing two functions, $f$ and~$g$, i.e., by firstapplying $f$ and then~$g$. Of course, this is only possible if theranges and domains match, i.e., the range of~$f$ must be a subset ofthe domain of~$g$. \oliflabeldef{sfr:rel:ops:sec}{This operation onfunctions is the analogue of the operation of relative product onrelations from \olref[rel][ops]{sec}.}{}A diagram might help to explain the idea of composition. In\olref{fig:composition}, we depict two functions $f \colon A \to B$and $g \colon B \to C$ and their composition~$(\comp{f}{g})$. Thefunction $(\comp{f}{g}) \colon A \to C$ pairs each !!{element} of~$A$with !!a{element} of~$C$. We specify which !!{element} of~$C$!!a{element} of $A$ is paired with as follows: given an input $x \inA$, first apply the function $f$ to~$x$, which will output some $f(x)= y \in B$, then apply the function $g$ to~$y$, which will output some$g(f(x)) = g(y) = z \in C$.\begin{figure}\olasset[2\olphotowidth]{assets/diagrams/composition.tikz}\caption{The composition $g \circ f$ of two functions $f$ and~$g$.}\ollabel{fig:composition}\end{figure}\end{explain}\begin{defn}[Composition]Let $f\colon A \to B$ and $g\colon B \to C$ be functions. The\emph{composition} of $f$ with~$g$ is $\comp{f}{g} \colon A \to C$,where $(\comp{f}{g})(x) = g(f(x))$.\end{defn}\begin{ex}Consider the functions $f(x) = x + 1$, and $g(x) = 2x$. Since$(\comp{f}{g})(x) = g(f(x))$, for each input~$x$ you must first takeits successor, then multiply the result by two. So their compositionis given by $(\comp{f}{g})(x) = 2(x+1)$.\end{ex}\begin{prob}Show that if $f \colon A \to B$ and $g \colon B \to C$ are both!!{injective}, then $\comp{f}{g}\colon A \to C$ is !!{injective}.\end{prob}\begin{prob}Show that if $f \colon A \to B$ and $g \colon B \to C$ are both!!{surjective}, then $\comp{f}{g}\colon A \to C$ is !!{surjective}.\end{prob}\begin{prob}Suppose $f \colon A \to B$ and $g \colon B \to C$. Show that the graphof $\comp{f}{g}$ is $R_f \mid R_g$.\end{prob}\end{document}
content/sets-functions-relations/functions/function-basics.tex
140 lines; SHA-256 f01a58d84a175f42d8c233ef0e7d41c23d406b54e8f11475c14514b64eca3dc7. Open the preserved source file.
% Part: sets-functions-relations% Chapter: functions% Section: basics\documentclass[../../../include/open-logic-section]{subfiles}\begin{document}\olfileid{sfr}{fun}{bas}\olsection{Basics}\begin{explain}A \emph{function} is a map which sends each !!{element} of a given setto a specific !!{element} in some (other) given set. For instance, theoperation of adding~$1$ defines a function: each number~$n$ is mappedto a unique number~$n+1$.More generally, functions may take pairs, triples, etc., as inputs andreturn some kind of output. Many functions are familiar to us frombasic arithmetic. For instance, addition and multiplication arefunctions. They take in two numbers and return a third.In this mathematical, abstract sense, a function is a \emph{blackbox}: what matters is only what output is paired with what input, notthe method for calculating the output.\end{explain}\begin{defn}[Function]A \emph{function} $f \colon A \to B$ is a mapping of each !!{element}of~$A$ to an !!{element} of~$B$.We call $A$ the \emph{domain} of~$f$ and $B$ the \emph{codomain}of~$f$. The !!{element}s of~$A$ are called inputs or \emph{arguments}of~$f$, and the !!{element} of~$B$ that is paired with an argument~$x$by~$f$ is called the \emph{value of~$f$} for argument~$x$,written~$f(x)$.The \emph{range} $\ran{f}$ of~$f$ is the subset of the codomainconsisting of the values of~$f$ for some argument; $\ran{f} =\Setabs{f(x)}{x \in A}$.\end{defn}The diagram in \olref{fig:function} may help to think about functions. The ellipseon the left represents the function's \emph{domain}; the ellipse onthe right represents the function's \emph{codomain}; and an arrowpoints from an \emph{argument} in the domain to the corresponding\emph{value} in the codomain.\begin{figure}\olasset{assets/diagrams/function.tikz}\caption{A function is a mapping of each !!{element} of one set to!!a{element} of another. An arrow points from an argument in thedomain to the corresponding value in the codomain.}\ollabel{fig:function}\end{figure}\begin{ex}Multiplication takes pairs of natural numbers as inputs and maps themto natural numbers as outputs, so goes from $\Nat \times \Nat$ (thedomain) to $\Nat$ (the codomain). As it turns out, the range is also$\Nat$, since every $n \in \Nat$ is $n \times 1$.\end{ex}\begin{ex}Multiplication is a function because it pairs each input---each pairof natural numbers---with a single output: $\times \colon \Nat^2 \to\Nat$. By contrast, mapping a natural number~$n$ to a real~$x$ suchthat $x^2 = n$ is not functional, since each positive integer~$n$ has twosquare roots: $\sqrt{n}$ and~$-\sqrt{n}$. We can make it functional byonly returning the positive square root: $\sqrt{\phantom{X}} \colon\Nat \to \Real$.\end{ex}\begin{ex}The relation that pairs each student in a class with their final gradeis a function---no student can get two different final grades in thesame class. The relation that pairs each student in a class with theirparents is not a function: students can have zero, or two, or moreparents.\end{ex}\begin{explain}We can define functions by specifying in some precise way what thevalue of the function is for every possible argument. Different ways ofdoing this are by giving a formula, describing a method for computingthe value, or listing the values for each argument. However functionsare defined, we must make sure that for each argument we specify one,and only one, value.\end{explain}\begin{ex}Let $f \colon \Nat \to \Nat$ be defined such that $f(x) = x+1$. Thisis a definition that specifies $f$ as a function which takes innatural numbers and outputs natural numbers. It tells us that, given anatural number~$x$, $f$ will output its successor~$x+1$.In this case, the codomain $\Nat$ is not the range of~$f$, since thenatural number~$0$ is not the successor of any natural number. Therange of~$f$ is the set of all positive integers, $\Int^{+}$.\end{ex}\begin{ex}\ollabel{examplefunext}Let $g \colon \Nat \to \Nat$ be defined such that $g(x) = x+2-1$. Thistells us that $g$ is a function which takes in natural numbers andoutputs natural numbers. Given a natural number~$n$, $g$ will outputthe predecessor of the successor of the successor of~$x$, i.e.,$x+1$.\end{ex}\begin{explain}We just considered two functions, $f$ and $g$, with different\emph{definitions}. However, these are the \emph{same function}. Afterall, for any natural number~$n$, we have that $f(n) = n+1 = n+2-1 =g(n)$. Otherwise put: our definitions for $f$ and~$g$ specify thesame mapping by means of different equations. Implicitly, then, we arerelying upon a principle of extensionality for functions,\[\text{if }\forall x\, f(x) = g(x)\text{, then }f = g\]provided that $f$ and~$g$ share the same domain and codomain.\end{explain}\begin{ex}We can also define functions by cases. For instance, we could define$h \colon \Nat \to \Nat$ by\[h(x) =\begin{cases}\frac{x}{2} & \text{if $x$ is even} \\\frac{x+1}{2} & \text{if $x$ is odd.}\end{cases}\]Since every natural number is either even or odd, the output of thisfunction will always be a natural number. Just remember that if youdefine a function by cases, every possible input must fall intoexactly one case. In some cases, this will require a proof that thecases are exhaustive and exclusive.\end{ex}\end{document}
content/sets-functions-relations/functions/function-kinds.tex
118 lines; SHA-256 6dfe2a70579f8e3521d8e2286e2360dd58a19fbeda9718b62342105388ab4f93. Open the preserved source file.
% Part: sets-functions-relations% Chapter: functions% Section: kinds\documentclass[../../../include/open-logic-section]{subfiles}\begin{document}\olfileid{sfr}{fun}{kin}\olsection{Kinds of Functions}\begin{explain}It will be useful to introduce a kind of taxonomy for some of thekinds of functions which we encounter most frequently.To start, we might want to consider functions which have the propertythat every member of the codomain is a value of the function. Suchfunctions are called !!{surjective}, and can be pictured as in\olref{fig:surjective}.\begin{figure}\olasset{assets/diagrams/surjective.tikz}\caption{!!^a{surjective} function has every !!{element} of thecodomain as a value.}\ollabel{fig:surjective}\end{figure}\end{explain}\begin{defn}[!!^{surjective} function]A function $f \colon A \rightarrow B$ is \emph{!!{surjective}} iff $B$is also the range of~$f$, i.e., for every $y \in B$ there is at leastone $x \in A$ such that~$f(x) = y$, or in symbols:\[(\forall y \in B)(\exists x \in A)f(x) = y.\]We call such a function !!a{surjection} from $A$ to $B$.\end{defn}\begin{explain}If you want to show that $f$ is !!a{surjection}, then you need to showthat every object in $f$'s codomain is the value of $f(x)$ for someinput $x$.Note that any function \emph{induces} !!a{surjection}. After all,given a function $f \colon A \to B$, let $f' \colon A \to \ran{f}$ bedefined by $f'(x) = f(x)$. Since $\ran{f}$ is \emph{defined} as$\Setabs{f(x) \in B}{x \in A}$, this function $f'$ is guaranteed to be!!a{surjection}\end{explain}\begin{explain}Now, any function maps each possible input to a unique output. Butthere are also functions which never map different inputs to the sameoutputs. Such functions are called !!{injective}, and can be picturedas in \olref{fig:injective}.\begin{figure}\olasset{assets/diagrams/injective.tikz}\caption{!!^a{injective} function never maps two differentarguments to the same value.}\ollabel{fig:injective}\end{figure}\end{explain}\begin{defn}[!!^{injective} function]A function $f \colon A \rightarrow B$ is \emph{!!{injective}} iff foreach $y \in B$ there is at most one $x \in A$ such that~$f(x) = y$. Wecall such a function !!a{injection} from $A$ to~$B$.\end{defn}\begin{explain}If you want to show that $f$ is !!a{injection}, you need to show thatfor any !!{element}s $x$ and $y$ of $f$'s domain, if $f(x)=f(y)$, then$x=y$.\end{explain}\begin{ex}The constant function $f\colon \Nat \to \Nat$ given by $f(x) = 1$ isneither !!{injective}, nor !!{surjective}.The identity function $f\colon \Nat \to \Nat$ given by $f(x) = x$ isboth !!{injective} and !!{surjective}.The successor function $f \colon \Nat \to \Nat$ given by $f(x) = x+1$is !!{injective} but not !!{surjective}.The function $f \colon \Nat \to \Nat$ defined by:\[f(x) =\begin{cases}\frac{x}{2} & \text{if $x$ is even} \\\frac{x+1}{2} & \text{if $x$ is odd.}\end{cases}\]is !!{surjective}, but not !!{injective}.\end{ex}\begin{explain}Often enough, we want to consider functions which are both!!{injective} and !!{surjective}. We call such functions!!{bijective}. They look like the function pictured in\olref{fig:bijective}. !!^{bijection}s are also sometimes called\emph{one-to-one correspondences}, since they uniquely pair elementsof the codomain with elements of the domain.\begin{figure}\olasset{assets/diagrams/bijective.tikz}\caption{!!^a{bijective} function uniquely pairs the elements of thecodomain with those of the domain.}\ollabel{fig:bijective}\end{figure}\end{explain}\begin{defn}[!!^{bijection}]A function $f \colon A \to B$ is \emph{!!{bijective}} iff it is both!!{surjective} and !!{injective}. We call such a function!!a{bijection} from $A$ to~$B$ (or between $A$ and~$B$).\end{defn}\end{document}
content/sets-functions-relations/functions/functions-relations.tex
103 lines; SHA-256 0205f7168e0679f513e7c95ea7124ce364bce36f9e04f06d519e90f6a5480a5c. Open the preserved source file.
% Part: sets-functions-relations% Chapter: functions% Section: functions-relations\documentclass[../../../include/open-logic-section]{subfiles}\begin{document}\olfileid{sfr}{fun}{rel}\olsection{Functions as Relations}\begin{explain}A function which maps !!{element}s of~$A$ to !!{element}s of~$B$obviously defines a relation between $A$ and~$B$, namely the relationwhich holds between $x$ and $y$ iff $f(x) = y$. In fact, we mighteven---if we are interested in reducing the building blocks ofmathematics for instance---\emph{identify} the function~$f$ with thisrelation, i.e., with a set of pairs. This then raises the question:which relations define functions in this way?\end{explain}\begin{defn}[Graph of a function] Let $f\colon A \to B$ be a function.The \emph{graph} of~$f$ is the relation $R_f \subseteq A \times B$defined by\[R_f = \Setabs{\tuple{x,y}}{f(x) = y}.\]\end{defn}\begin{explain}The graph of a function is uniquely determined, by extensionality.Moreover, extensionality (on sets) will immediately vindicate theimplicit principle of extensionality for functions,whereby if $f$ and~$g$ share a domain and codomain then they areidentical if they agree on all values.Similarly, if a relation is ``functional'', then it is the graph of a function.\end{explain}\begin{prop}\ollabel{prop:graph-function}Let $R \subseteq A \times B$ be such that:\begin{enumerate}\item If $Rxy$ and $Rxz$ then $y = z$; and\item for every $x \in A$ there is some $y \in B$ such that $\tuple{x,y} \in R$.\end{enumerate}Then $R$ is the graph of the function $f\colon A \to B$ defined by$f(x) = y$ iff $Rxy$.\end{prop}\begin{proof}Suppose there is a $y$ such that $Rxy$. If there were another $z \neqy$ such that $Rxz$, the condition on~$R$ would be violated. Hence, ifthere is a $y$ such that $Rxy$, this $y$ is unique, and so $f$ iswell-defined. Obviously, $R_f = R$.\end{proof}\begin{explain}Every function $f\colon A \to B$ has a graph, i.e., a relation on $A\times B$ defined by $f(x) = y$. On the other hand, every relation~$R\subseteq A \times B$ with the properties given in\olref{prop:graph-function} is the graph of a function~$f \colon A \toB$. Because of this close connection between functions and theirgraphs, we can think of a function simply as its graph. In otherwords, functions can be identified with certain relations, i.e., withcertain sets of tuples. \oliflabeldef{sfr:rel:ref:sec}{Note, though,that the spirit of this ``identification'' is as in\olref[sfr][rel][ref]{sec}: it is not a claim about the metaphysics offunctions, but an observation that it is convenient to \emph{treat}functions as certain sets. One reason that this is so convenient, isthat w}{W}e can now consider performing similar operations onfunctions as we performed on relations (see\olref[sfr][rel][ops]{sec}). In particular:\end{explain}\begin{defn}\ollabel{defn:funimage}Let $f \colon A \to B$ be a function with $C\subseteq A$.The \emph{restriction} of~$f$ to~$C$ is thefunction~$\funrestrictionto{f}{C}\colon C \to B$ defined by$(\funrestrictionto{f}{C})(x) = f(x)$ for all $x \in C$. In otherwords, $\funrestrictionto{f}{C} = \Setabs{\tuple{x, y} \in R_f}{x \inC}$.The \emph{application} of~$f$ to~$C$ is $\funimage{f}{C} =\Setabs{f(x)}{x \in C}$. We also call this the \emph{image} of~$C$under~$f$.\end{defn}\begin{explain}It follows from these definitions that $\ran{f} =\funimage{f}{\dom{f}}$, for any function~$f$.\oliflabeldef{sfr:rel:ops:sec}{These notions are exactly as one wouldexpect, given the definitions in \olref[sfr][rel][ops]{sec} and ouridentification of functions with relations. But two otheroperations---inverses and relative products---require a little moredetail. We will provide that in \olref[inv]{sec} and\olref[cmp]{sec}.}{}\end{explain}\end{document}
content/sets-functions-relations/functions/functions.tex
26 lines; SHA-256 ce481e97a8f301c749d1461326b4ee3d0792b4adc15a1fceb7c6ed3b58ceca54. Open the preserved source file.
% Part: sets-functions-relations% Chapter: functions\documentclass[../../../include/open-logic-chapter]{subfiles}\begin{document}\olchapter{sfr}{fun}{Functions}\olimport{function-basics}\olimport{function-kinds}\olimport{functions-relations}\olimport{inverses}\olimport{composition}%\olimport{isomorphic-functions}\olimport{partial-functions}\OLEndChapterHook\end{document}
content/sets-functions-relations/functions/inverses.tex
177 lines; SHA-256 93a84a2705e1ed3c92a7f5206c4308420bebbbbcb43824c1eb50e05f83777c4b. Open the preserved source file.
% Part: sets-functions-relations% Chapter: functions% Section: inverses\documentclass[../../../include/open-logic-section]{subfiles}\begin{document}\olfileid{sfr}{fun}{inv}\olsection{Inverses of Functions}\begin{explain}We think of functions as maps. An obvious question to ask aboutfunctions, then, is whether the mapping can be ``reversed.'' Forinstance, the successor function $f(x) = x + 1$ can be reversed, inthe sense that the function $g(y) = y - 1$ ``undoes'' what $f$ does.But we must be careful. Although the definition of~$g$ defines afunction $\Int \to \Int$, it does not define a \emph{function} $\Nat\to \Nat$, since $g(0) \notin \Nat$. So even in simple cases, it isnot quite obvious whether a function can be reversed; it may depend onthe domain and codomain.This is made more precise by the notion of an inverse of a function.\end{explain}\begin{defn}A function $g \colon B \to A$ is an \emph{inverse} of a function $f\colon A \to B$ if $f(g(y)) = y$ and $g(f(x)) = x$ for all $x \in A$and $y \in B$.\end{defn}If $f$ has an inverse~$g$, we often write $f^{-1}$ instead of~$g$.\begin{explain}Now we will determine when functions have inverses. A good candidatefor an inverse of $f\colon A \to B$ is $g\colon B \to A$ ``definedby''\[g(y) = \text{``the'' $x$ such that $f(x) = y$.}\]But the scare quotes around ``defined by'' (and ``the'') suggest thatthis is not a definition. At least, it will not always work, withcomplete generality. For, in order for this definition to specify afunction, there has to be one and only one~$x$ such that $f(x) =y$---the output of~$g$ has to be uniquely specified. Moreover, it hasto be specified for every $y \in B$. If there are $x_1$ and $x_2 \inA$ with $x_1 \neq x_2$ but $f(x_1) = f(x_2)$, then $g(y)$ would not beuniquely specified for $y = f(x_1) = f(x_2)$. And if there is no~$x$at all such that $f(x) = y$, then $g(y)$ is not specified at all. Inother words, for $g$ to be defined, $f$~must be both !!{injective} and!!{surjective}.Let's go slowly. We'll divide the question into two: Given afunction~$f\colon A \to B$, when is there a function $g\colon B \to A$so that $g(f(x)) = x$? Such a $g$ ``undoes'' what $f$ does, and iscalled a \emph{left inverse} of~$f$. Secondly, when is there afunction $h\colon B \to A$ so that $f(h(y)) = y$? Such an $h$ iscalled a \emph{right inverse} of~$f$---$f$ ``undoes'' what $h$~does.\end{explain}\begin{prop}If $f\colon A \to B$ is !!{injective}, then there is a \emph{leftinverse}~$g\colon B \to A$ of~$f$ so that $g(f(x)) = x$ for all $x\in A$.\end{prop}\begin{proof}Suppose that $f\colon A \to B$ is !!{injective}. Consider a $y \in B$.If $y \in \ran{f}$, there is an $x \in A$ so that $f(x) = y$. Because$f$ is !!{injective}, there is only one such~$x \in A$. Then we candefine: $g(y) = x$, i.e., $g(y)$ is ``the'' $x \in A$ such that $f(x)= y$. If $y \notin \ran{f}$, we can map it to any~$a \in A$. So, wecan pick an $a \in A$ and define $g\colon B \to A$ by:\[g(y) = \begin{cases}x & \text{if $f(x) = y$}\\a & \text{if $y \notin \ran{f}$.}\end{cases}\]It is defined for all $y \in B$, since for each such $y \in \ran{f}$there is exactly one $x \in A$ such that $f(x) = y$. By definition, if$y = f(x)$, then $g(y) = x$, i.e., $g(f(x)) = x$.\end{proof}\begin{prob}Show that if $f\colon A \to B$ has a left inverse~$g$, then $f$~is!!{injective}.\end{prob}\begin{prop}If $f\colon A \to B$ is !!{surjective}, then there is a\emph{right inverse}~$h\colon B \to A$ of~$f$ so that $f(h(y)) =y$ for all~$y \in B$.\end{prop}\begin{proof}Suppose that $f\colon A \to B$ is !!{surjective}. Consider a $y \inB$. Since $f$~is !!{surjective}, there is an $x_y \in A$ with $f(x_y)= y$. Then we can define: $h(y) = x_y$, i.e., for each $y \in B$ wechoose some $x \in A$ so that $f(x) = y$; since $f$~is !!{surjective}there is always at least one to choose from.\footnote{Since $f$ is!!{surjective}, for every~$y \in B$ the set $\Setabs{x}{f(x) = y}$ isnonempty. Our definition of~$h$ requires that we choose a single $x$from each of these sets. That this is always possible is actually notobvious---the possibility of making these choices is simply assumed as an axiom.In other words, this proposition assumes the so-called Axiom ofChoice, an issue we will \oliflabeldef{sth:choice::chap}{revisit in \olref[sth][choice][]{chap}}{gloss over}.However, in many specific cases, e.g., when $A = \Nat$ or is finite, or when $f$ is !!{bijective},the Axiom of Choice is not required. (In the particular case when $f$ is !!{bijective}, for each $y \in B$ the set$\Setabs{x}{f(x) = y}$ has exactly one !!{element}, so that there is no choice to make.)}By definition, if $x = h(y)$,then $f(x) = y$, i.e., for any $y \in B$, $f(h(y)) = y$.\end{proof}\begin{prob}Show that if $f\colon A \to B$ has a right inverse~$h$, then $f$~is!!{surjective}.\end{prob}\begin{explain}By combining the ideas in the previous proof, we now get that every!!{bijection} has an inverse, i.e., there is a single functionwhich is both a left and right inverse of~$f$.\end{explain}\begin{prop}\ollabel{prop:bijection-inverse}If $f\colon A \to B$ is !!{bijective}, there is afunction~$f^{-1}\colon B \to A$ so that for all $x \in A$,$f^{-1}(f(x)) = x$ and for all $y \in B$, $f(f^{-1}(y)) = y$.\end{prop}\begin{proof}Exercise.\end{proof}\begin{prob}Prove \olref[sfr][fun][inv]{prop:bijection-inverse}. You have todefine~$f^{-1}$, show that it is a function, and show that it is aninverse of~$f$, i.e., $f^{-1}(f(x)) = x$ and $f(f^{-1}(y)) = y$ forall $x \in A$ and $y \in B$.\end{prob}\begin{explain}There is a slightly more general way to extract inverses. We saw in\olref[kin]{sec} that every function $f$ induces !!a{surjection} $f'\colon A \to \ran{f}$ by letting $f'(x) = f(x)$ for all $x \in A$.Clearly, if $f$~is !!{injective}, then $f'$~is !!{bijective}, so thatit has a unique inverse by \olref{prop:bijection-inverse}. By a veryminor abuse of notation, we sometimes call the inverse of $f'$ simply``the inverse of~$f$.''\end{explain}\begin{prop}\ollabel{prop:left-right}%Show that if $f\colon A \to B$ has a left inverse~$g$ and a rightinverse~$h$, then $h = g$.\end{prop}\begin{proof}Exercise.\end{proof}\begin{prob}Prove \olref[sfr][fun][inv]{prop:left-right}.\end{prob}\begin{prop}\ollabel{prop:inverse-unique}Every function~$f$ has at most one inverse.\end{prop}\begin{proof}Suppose $g$ and $h$ are both inverses of~$f$. Then in particular$g$~is a left inverse of~$f$ and $h$~is a right inverse. By\olref{prop:left-right}, $g = h$.\end{proof}\end{document}
content/sets-functions-relations/functions/partial-functions.tex
75 lines; SHA-256 2a1e79725a70fde443cc3c19c325a2c422c49e7ccd095c965f8c50fd5cc6b10b. Open the preserved source file.
% Part: sets-functions-relations% Chapter: functions% Section: partial-functions\documentclass[../../../include/open-logic-section]{subfiles}\begin{document}\olfileid{sfr}{fun}{par}\olsection{Partial Functions}\begin{explain}It is sometimes useful to relax the definition of function so that itis not required that the output of the function is defined for allpossible inputs. Such mappings are called \emph{partial functions}.\end{explain}\begin{defn}A \emph{partial function} $f \colon A \pto B$ is a mapping whichassigns to every !!{element} of~$A$ at most one !!{element} of~$B$.If $f$ assigns an element of~$B$ to $x \in A$, we say $f(x)$ is\emph{defined}, and otherwise \emph{undefined}. If $f(x)$ is defined,we write $f(x) \fdefined$, otherwise $f(x) \fundefined$. The\emph{domain} of a partial function~$f$ is the subset of~$A$ where itis defined, i.e., $\dom{f} = \Setabs{x \in A}{f(x) \fdefined}$.\end{defn}\begin{ex}Every function $f\colon A \to B$ is also a partial function. Partialfunctions that are defined everywhere on~$A$---i.e., what we so farhave simply called a function---are also called \emph{total}functions.\end{ex}\begin{ex}The partial function $f \colon \Real \pto \Real$ given by $f(x) = 1/x$is undefined for $x = 0$, and defined everywhere else.\end{ex}\begin{prob}Given $f\colon A \pto B$, define the partial function $g\colon B \ptoA$ by: for any $y \in B$, if there is a unique $x \in A$ such that$f(x) = y$, then $g(y) = x$; otherwise $g(y) \fundefined$. Show thatif $f$ is injective, then $g(f(x)) = x$ for all $x \in \dom{f}$, and$f(g(y)) = y$ for all $y \in \ran{f}$.\end{prob}\begin{defn}[Graph of a partial function]Let $f\colon A \pto B$ be a partial function. The \emph{graph} of~$f$is the relation $R_f \subseteq A \times B$ defined by\[R_f = \Setabs{\tuple{x,y}}{f(x) = y}.\]\end{defn}\begin{prop}Suppose $R \subseteq A \times B$ has the property that whenever $Rxy$and $Rxy'$ then $y = y'$. Then $R$ is the graph of the partialfunction $f\colon A \pto B$ defined by: if there is a $y$ such that$Rxy$, then $f(x) = y$, otherwise $f(x) \fundefined$. If $R$ is also\emph{serial}, i.e., for each $x \in A$ there is a $y \in B$ such that$Rxy$, then $f$ is total.\end{prop}\begin{proof}Suppose there is a $y$ such that $Rxy$. If there were another $y'\neq y$ such that $Rxy'$, the condition on $R$ would beviolated. Hence, if there is a $y$ such that $Rxy$, that $y$ isunique, and so $f$ is well-defined. Obviously, $R_f = R$ and $f$ istotal if~$R$ is serial.\end{proof}\end{document}