# Total function and termination

If we have a total function, is it by default terminating function? How can we prove the termination for this total function?

-

Not by default, but by definition. – MJD Aug 22 '12 at 2:08
What is the definition of a terminating function? – William Aug 22 '12 at 2:17
Can you provide the definitions of "total function" and "terminating function" you are using here? – Rahul Narain Aug 22 '12 at 22:45
There are total functions that are not computable, but in this case one only has (at best) a non-effective description of the function, and saying it is terminating does not really make sense. – Marc van Leeuwen Aug 28 '12 at 14:31

## 2 Answers

Since the definitions of "total function" say that is defined for all possible inputs, it seems that, yes, it must terminate (otherwise it would not be defined for any input that is does not terminate for).

-

Could you please give an example of this ? – Abufouda Aug 22 '12 at 2:06
Consider the function $f$ which adds 1 to its argument, unless the argument is 0, in which case it goes into an infinite loop and never yields a result. This is not a terminating function, since it will fail to terminate when given the argument 0. It is also not a total function, since it fails to yield a result when given the argument 0. – MJD Aug 22 '12 at 2:10

To echo @William: what does talk of 'termination' mean here?

It suggests (at least to this reader) the idea of a terminating computation. But even if we restrict ourselves to total functions that map numbers to numbers, not all such functions are computable. So on one very natural reading, not ever total function $f \colon \mathbb{N} \to \mathbb{N}$ can be said to be terminating (if that means that there is a way of computing $f$ which terminates for every input).

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 3, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9044329524040222, "perplexity_flag": "middle"}