Partial and total functions [00KJ]
- January 23, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Definition Partial function [00K7]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
A relation R\colon A\mathbin {\nrightarrow } B is said to be functional when it relates an element of A to at most one element of B:
\forall a:A\mathpunct {.} \forall b_1,b_2:B\mathpunct {.} a\mathrel {R}b_1\land a\mathrel {R}b_2 \implies b_1 = b_2We refer to a functional relation as a partial function; we often use letters like f,g to refer to partial functions rather than R,S. When we write “f\colon A\mathbin {\rightharpoonup } B”, we mean that f is a partial function from A to B.
Theorem Closure of partial functions under identity and composition [00K8]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Partial functions are closed under identity and composition in the following sense:
- For any set A, the identity relation \mathsf {id}_{A} \colon A\mathbin {\nrightarrow } A is functional.
- For any sets A,B,C and functional relations f\colon A\mathbin {\rightharpoonup } B and g \colon B\mathbin {\rightharpoonup } C, the relational composite g\circ f \colon A\mathbin {\nrightarrow } C is functional.
Proof.
- January 22, 2024
- Jon Sterling
First, we prove that each identity relation \mathsf {id}_{A}\colon A\mathbin {\nrightarrow } A is functional. Fixing a,a_1,a_2:A such that a=a_1 and a=a_2, we must show that a_1=a_2; this follows from transitivity and symmetry of equality.
Next, we fix partial functions f\colon A\mathbin {\rightharpoonup } B and g \colon B\mathbin {\rightharpoonup } C to check that g\circ f \colon A\mathbin {\nrightarrow } C is functional. Fixing a:A and c_1,c_2:C such that a\mathrel {{\mathopen {}\left (g\circ f\right )\mathclose {}}}c_1 and a\mathrel {{\mathopen {}\left (g\circ f\right )\mathclose {}}}c_2, we must check that c_1=c_2. By definition of the relational composite, we have b_1,b_2:B such that a\mathrel {f}b_1\mathrel {g}c_1 and a\mathrel {f}b_2\mathrel {g}c_2. Because f\colon A\mathbin {\rightharpoonup } B is functional, we note that b_1 = b_2. Writing b=b_1=b_2, we therefore have b\mathrel {g}c_1 and b\mathrel {g}c_2. Because g\colon B\mathbin {\rightharpoonup } C is functional, we conclude that c_1=c_2.
Notation Values of partial functions [00KA]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Let f\colon A\mathbin {\rightharpoonup } B be a partial function. Given a:A, we will write f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } to mean that f is defined at a, i.e. there exists some (necessarily unique) b:B such that a\mathrel {f}b. When f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } holds, we may write f{\mathopen {}\left (a\right )\mathclose {}} to mean the unique b such that a\mathrel {f}b, which we shall refer to as the value of b.
Definition Domain of definition of a partial function [00KB]
- January 22, 2024
- Jon Sterling
The domain of definition of a partial function f\colon A\mathbin {\rightharpoonup } B is the subset {\mathopen {}\left \{a: A\,\middle \vert \,f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow }\right \}\mathclose {}}\subseteq A spanned by elements of the domain on which the partial function is defined.
Lemma Partial functional extensionality [00K9]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Let f,g\colon A\mathbin {\rightharpoonup } B be two partial functions. We have f=g if and only if for all a:A, f is defined at a if and only if g is defined at a and, moreover, the value of f at a is the same as the value of g at a:
f=g \Longleftrightarrow \forall a:A\mathpunct {.} {\mathopen {}\left ( f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } \Leftrightarrow g{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } \right )\mathclose {}} \land (f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow }\Rightarrow f{\mathopen {}\left (a\right )\mathclose {}} = g{\mathopen {}\left (a\right )\mathclose {}})Proof.
- January 22, 2024
- Jon Sterling
One direction is trivial. In the other direction, we assume \forall a:A\mathpunct {.} {\mathopen {}\left ( f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } \Leftrightarrow g{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } \right )\mathclose {}} \land {\mathopen {}\left ( f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow }\Rightarrow f{\mathopen {}\left (a\right )\mathclose {}} = g{\mathopen {}\left (a\right )\mathclose {}} \right )\mathclose {}} to deduce f=g. By relational extensionality, it suffices to show \forall a:A\mathpunct {.} \forall b:B\mathpunct {.} a\mathrel {f}b \Longleftrightarrow a\mathrel {g}b.
Fixing a:A and b:B, we assume a\mathrel {f} b to prove a\mathrel {g}b. By assumption, we deduce g{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } from f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow }, so there exists b'=g{\mathopen {}\left (a\right )\mathclose {}} such that a\mathrel {g}b'. By our other assumption, we know that f{\mathopen {}\left (a\right )\mathclose {}}=g{\mathopen {}\left (a\right )\mathclose {}}, so we conclude a\mathrel {g}b. The other direction works the same way.
Example Examples of partial functions [00KD]
- January 22, 2024
- Jon Sterling
The following are examples of partial functions:
- rational division {\div }\colon \mathbb {Q}\times \mathbb {Q}\mathbin {\rightharpoonup }\mathbb {Q} defined by {\mathopen {}\left \{{\mathopen {}\left ({\mathopen {}\left (r,s\right )\mathclose {}},t\right )\mathclose {}}:{\mathopen {}\left (\mathbb {Q}\times \mathbb {Q}\right )\mathclose {}}\times \mathbb {Q}\,\middle \vert \,r=s\cdot t\right \}\mathclose {}} with domain of definition {\mathopen {}\left \{{\mathopen {}\left (r,s\right )\mathclose {}}:\mathbb {Q}\times \mathbb {Q}\,\middle \vert \,s\not =0\right \}\mathclose {}};
- integer square root \sqrt {-}\colon \mathbb {Z}\mathbin {\rightharpoonup }\mathbb {Z} defined by {\mathopen {}\left \{{\mathopen {}\left (m,n\right )\mathclose {}}:\mathbb {Z}\times \mathbb {Z}\,\middle \vert \,m=n^2\right \}\mathclose {}} with domain of definition {\mathopen {}\left \{m:\mathbb {Z}\,\middle \vert \,\exists n:\mathbb {Z}\mathpunct {.} m=n^2\right \}\mathclose {}};
- real square root \sqrt {-}\colon \mathbb {R}\mathbin {\rightharpoonup }\mathbb {R} defined by {\mathopen {}\left \{{\mathopen {}\left (x,y\right )\mathclose {}}:\mathbb {R}\times \mathbb {R}\,\middle \vert \,x=y^2\right \}\mathclose {}} with domain of definition {\mathopen {}\left \{x:\mathbb {R}\,\middle \vert \,x\geq 0\right \}\mathclose {}}.
Lemma Cardinality of the set of partial functions [00KE]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
For all finite sets A and B, we have \mathord {\#}{\mathopen {}\left (A\mathbin {\rightharpoonup } B\right )\mathclose {}}={\mathopen {}\left (\mathord {\#}{B}+1\right )\mathclose {}}^{\mathord {\#}{A}}, recalling that \mathord {\#}{S} is the cardinality of a set S.
Proof.
- January 22, 2024
- Jon Sterling
A partial function f\colon A\mathbin {\rightharpoonup } B associates to each element a:A either a unique element f{\mathopen {}\left (a\right )\mathclose {}}:B when f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow }, or it associates nothing. Therefore, we have \mathord {\#}{A} many possibilities, each followed by \mathord {\#}{B}+1 many possibilities.
Definition Function [00KF]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
A partial function f\colon A\mathbin {\rightharpoonup } B is called total whenever its domain of definition coincides with its domain (source), i.e. we have f{\mathopen {}\left (a\right )\mathclose {}}{\downarrow } for all a:A. In this case, we will write f\colon A\to B and refer to it as a function or a map. Sometimes, we redundantly refer to it as a total function.
Just as we write \mathrm {Rel}{\mathopen {}\left (A,B\right )\mathclose {}} and {\mathopen {}\left (A\mathbin {\rightharpoonup } B\right )\mathclose {}}for the sets of relations and partial functions from A to B respectively, we shall write {\mathopen {}\left (A\to B\right )\mathclose {}} for the set of functions from A to B.
Lemma Functions are uniquely-valued relations [00KG]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Any relation R\colon A\mathbin {\nrightarrow } B is a function if and only if for all a:A, there exists some unique b:B such that a\mathrel {R}b.
Proof.
- January 22, 2024
- Jon Sterling
Symbolically, our second criterion is \forall a:A\mathpunct {.} \exists ! b:B\mathpunct {.} a\mathrel {R}b. Unfolding the definition of unique existence, this is equivalent to \forall a:A\mathpunct {.} {\mathopen {}\left (\forall b,b':B\mathpunct {.} a\mathrel {R}b\land a\mathrel {R}b'\implies b=b'\right )\mathclose {}}\land {\mathopen {}\left (\exists b:B\mathpunct {.} a\mathrel {R}b\right )\mathclose {}} which is, by the distributivity of universal quantification over conjunction, equivalent to the claim that R is both functional and total.
Lemma Cardinality of the set of functions [00KH]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
For all finite sets A and B, we have \#{\mathopen {}\left (A\to B\right )\mathclose {}} = \#B^{\#A}.
Proof.
- January 22, 2024
- Jon Sterling
A function f\colon A \to B associates to each element a:A a single element f{\mathopen {}\left (a\right )\mathclose {}}:B. Therefore, we have \#A possibilities, each followed by \#B possibilities.
Theorem Closure of functions under identity and composition [00KI]
- January 22, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Functions are closed under identity and composition.
Proof.
- January 22, 2024
- Jon Sterling
We have already seen in Theorem [00K8] that partial functions are closed under identity and composition. Therefore, it suffices to argue that the identity partial function is total, and that the composition of two total partial functions is total.
- We must show that for all a:A, there exists a' :A such that a\mathrel {\mathsf {id}_{A}} a'; unfolding the definition of the identity relation we may choose a' = a.
- Given f\colon A\to B and g\colon A \to C, we must check that for all a:A, there exists some c:C such that a\mathrel {{\mathopen {}\left (g\circ f\right )\mathclose {}}}c. By the definition of relational composition, we must show that there exists b:B and c:C and such that a\mathrel {f}b and b\mathrel {c}. We choose b = f{\mathopen {}\left (a\right )\mathclose {}} and c = g{\mathopen {}\left (b\right )\mathclose {}}=g{\mathopen {}\left (f{\mathopen {}\left (a\right )\mathclose {}}\right )\mathclose {}}.