Descent function

from Wikipedia, the free encyclopedia

A descent function is in the mathematics and in the computer science a function can be demonstrated with that a recursion terminates.

principle

A descending function is defined for a recursive function , the value of which decreases with each call of . This is chosen for the sake of simplicity . Such a descent function can be chosen, for example, so that it indicates the number of recursion steps remaining until the recursion terminates. Instead of the relation <(is smaller than) in , however, any other well-founded relation in can be used, i.e. every relation in that establishes an order in every subset of that begins with a certain element of this subset.

It is now demonstrated that the value of decreases with each call of , that is, if the value of is necessary for the calculation of , must apply.

The condition that the relation <must be well founded means that there must be a minimum. So at some point there cannot be a value of for which a smaller value can be found. From the fact that, according to the definition of , the value of must decrease with each recursion step, it can now be deduced that from any value onwards no further recursion step takes place and thus that the recursion terminates.

Examples

mathematics

Be

We define the descent function as follows:

With according to recursive function definition

is

and thus

true. This shows that the value of decreases with each recursion step; but since it cannot sink indefinitely, the recursion terminates.

Computer science

An algorithm is given by the following Java code :

 void triangle(String s) {
     System.out.println(s);
     if(s.length() <= 1) return;
     triangle(s.substring(1));
 }

So here the function triangle is called with a character string as argument. The transferred text is output, then the method is exited if the length of the string is only one character or less. However, if it is larger, the triangle method is called recursively with the rest of the character string after the first character has been truncated. A call with the string "Hello!" so results in the following output:

Hallo!
allo!
llo!
lo!
o!
!

To prove that triangle doesn't just say "Hello!" terminated, but also for all others, we use the length of the character string as the descent function . The result of the truncation of the first character in the recursion is

And so also about

and the definition of the soundness that the recursion terminates.

See also