Partial and total functions definitions

81 Views Asked by At

I have an IT background and I'm trying to find proper and formal definitions of partial and total functions.

I'm unsure about my answers, this is why I'm posting here.

Do you think you could give me some feedback? Do you think the following definitions are good? If not, could you please let me know what is wrong and eventually and good book about that?

Let $S \subseteq \mathbb{N}^k$.

Let $f: S \to \mathbb{N}$ be a function.

Partial function

$\exists x \in \mathbb{N}^k, f(x) \notin \mathbb{N}$. Then $f$ is known as a ``partial function''.

Total function

$\forall x \in \mathbb{N}^k, f(x) \in \mathbb{N}$. Then $f$ is known as a ``total function''.


Edit 1 - After some feedback

Let $S \subseteq \mathbb{N}^k$ (strict or equal to).

Let $f: S \to \mathbb{N}$ be a function.

If $S \neq \mathbb{N}^k$ then $\forall x \in \mathbb{N}^k \setminus S, f(x)$ is undefined and then $f$ is known as a partial function.

If $S = \mathbb{N}^k$ then $\forall x \in S, f(x)$ is defined and then $f$ is known as a total function.


Edit 2 - After more feedback

Partial function

Let $S \subsetneq \mathbb{N}^k$.

Let $f: S \rightharpoonup \mathbb{N}$ be a function.

$\forall x \in \mathbb{N}^k \setminus S, f(x)$ is undefined and then $f$ is known as a partial function.

Total function

Let $S = \mathbb{N}^k$.

Let $f: S \to \mathbb{N}$ be a function.

$\forall x \in S, f(x)$ is defined and then $f$ is known as a total function.

Thanks!

1

There are 1 best solutions below

9
On

Almost. You definition of total function is fine: a function that is defined on all of its domain and gives a result in the codomain for each element of the domain.

A partial function need not ever return a value, so it is not just that $f(x) \not \in \Bbb{N}$, but $f(x)$ may just fail to exist. There are a range of practical algorithmic behaviours that are of this type: evaluation of a function may fail to ever emit a result (it runs forever), evaluation of a function may complete without emitting a result (for example, it throws an exception), at el.

Once you say that $f:S \rightarrow \Bbb{N}$ is a function, any value returned by $f$ is an element of $\Bbb{N}$. If $f$ is a total function, it always returns a value. If $f$ is a partial function it may fail to evaluate on some inputs. (Also, unless you say otherwise, a partial function $f$ is deterministic: if $f(x)$ evaluates, all other evaluations of $f(x)$ evaluate to the same value and if $f(x)$ does not evaluate, no attempt to evaluate $f(x)$ ever evaluates.)