0

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!

  • It's generally considered poor form to alter the substance of your question to invalidate valid answers to the Question as asked. If you are accepting an answer (which is what seems to be reflected in your edit), there is a different mechanism to do so. – Eric Towers Nov 05 '21 at 20:05
  • Strict subset can be indicated with $\subsetneq$, \subsetneq. – Eric Towers Nov 05 '21 at 20:07
  • Eric, sorry about that, you're right. I wish I could find a better way to post the intermediary answers, but I don't know yet how. – Pol Dellaiera Nov 05 '21 at 20:09
  • I would extend your Question with a horizontal rule (it's on the edit bar above the textbox when you edit the Question) then describe your improved understanding about the problem or its problem domain in a new section below the rule. – Eric Towers Nov 05 '21 at 20:10
  • Why do you want $S \neq \Bbb{N}^k$. Is there something wrong with a partial function that happens to evaluate at all inputs (so is, in fact, a total function)? These are not antonyms. – Eric Towers Nov 05 '21 at 20:12
  • I updated the OP based on your tips. I included the original answer back (for reference) and the two edits that I made based on your feedback. I think the "edit 2" is closer to something good, what do you think? – Pol Dellaiera Nov 05 '21 at 20:41

1 Answers1

1

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.)

Eric Towers
  • 67,037
  • Thanks Eric. I will update my original definition in a few minutes based on your feedback.

    Also, I opened that question here because of this page: https://proofwiki.org/wiki/Definition:Partial_Function

    I don't understand why it is explained as such. Is that a better definition ?

    – Pol Dellaiera Nov 05 '21 at 19:28
  • @PolDellaiera : That definition is equivalent to the one I write and is not equivalent to the one in your Question. – Eric Towers Nov 05 '21 at 19:30
  • mmh. I don't get that.

    If your definition is the same as the one on proofwiki:

    • Why $S$ is $\subset$ and not $\subseteq$ in $\mathbb{N}^k$ ? Is it because if it is, then it's a total function?
    • I also don't know how to understand the phrase: $\forall x \in \mathbb{N} \setminus S$

    Do you have a book reference that I can read to understand correctly all of this?

    – Pol Dellaiera Nov 05 '21 at 19:41
  • "$\subset$" and "$\subseteq$" have identical definitions. "$\setminus$" is set difference, so "$\forall x \in \Bbb{N} \setminus S$" means "for each choice of $x$ from the natural numbers but not chosen from $S$, ...". – Eric Towers Nov 05 '21 at 19:43
  • Oh. I always considered "$\subset$" to be "is included" (strict), while "$\subseteq$" means "is included or equal to".

    Let me re-read all of that with that new piece of information :) Thanks!

    – Pol Dellaiera Nov 05 '21 at 19:49
  • I always thought that every total function is also a partial function (like every square is a rectangle, every Baire 2 function is a Baire 1 function, etc.), but I haven't looked into this as it hasn't come up in anything I've worked on (in a while, at least). The OP seems to be using a more restrictive meaning of "partial function". Also, whether $\subset$ and $\subseteq$ have identical definitions varies with author, this much I'm certain. – Dave L. Renfro Nov 05 '21 at 20:01
  • @DaveL.Renfro : Certainly, a partial function can have an empty subset on the domain for which it fails to evaluate, producing a total function. This is permitted in the various definitions in play. I would be very interested to see a reference that draws a semantic difference between "$\subset$" and "$\subseteq$". – Eric Towers Nov 05 '21 at 20:04
  • I updated the OP with what I think is a better definition based on your feedback and the difference between "$\subset$" and "$\subseteq$". What do you think ? – Pol Dellaiera Nov 05 '21 at 20:05
  • The symbol $\subset$ is what varies with author (some allow for equality, some use this to mean proper subset), and I thought this was well known. I don't feel up to looking through books now for examples of the variation in meaning in $\subset$ (which I've seen many, many times over the years), but perhaps these questions will suffice -- Confusion in symbol of subset. AND $A \subset B$ and $A \subseteq B$, what is the difference? – Dave L. Renfro Nov 05 '21 at 20:18