Book to prove that an algorithm is correct?

  • Context: Undergrad 
  • Thread starter Thread starter xeon123
  • Start date Start date
  • Tags Tags
    Algorithm Book
Click For Summary

Discussion Overview

The discussion revolves around finding resources to learn techniques for proving the correctness of algorithms, specifically focusing on the termination and convergence of recursive algorithms. Participants explore various aspects of algorithm correctness, including theoretical foundations and specific examples like the factorial function.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants inquire about the specific aspects of correctness being addressed, noting that proving termination and convergence for recursive algorithms differs from non-recursive ones.
  • One participant suggests that proving convergence could involve demonstrating that the geometric distance between expected and observed answers decreases with each recursive call.
  • Another participant emphasizes the importance of the data structure used in recursive algorithms when discussing termination conditions.
  • One participant mentions the halting problem as a foundational concept for understanding algorithm termination, suggesting that it is probabilistic in nature.
  • Discussion includes the idea that some recursive algorithms may not terminate for certain inputs, highlighting the need to analyze specific classes of algorithms.
  • Participants discuss the factorial function as a simple example, noting that it terminates when the input reaches zero and that recursive calls reduce the input value.
  • One participant proposes that understanding computational complexity, recursion theory, and automata theory is essential for grasping these concepts deeply.
  • There is mention of using probabilistic arguments to show whether a recursive algorithm is likely to terminate, with suggestions to explore mathematical analysis concepts like convergence and divergence.

Areas of Agreement / Disagreement

Participants express varying perspectives on the complexity of proving algorithm correctness, particularly regarding recursive algorithms. There is no consensus on a single approach or resource, and multiple viewpoints on the topic remain present.

Contextual Notes

The discussion highlights the complexity of proving termination and convergence, with references to various theoretical concepts that may influence understanding. Specific assumptions about input types and algorithm classes are acknowledged but not resolved.

Who May Find This Useful

This discussion may be useful for individuals interested in algorithm design, computer science theory, and those seeking to deepen their understanding of recursion and algorithm correctness.

xeon123
Messages
90
Reaction score
0
Does anyone knows a good book that teaches techniques to prove that an algorithm is correct?
 
Mathematics news on Phys.org
xeon123 said:
Does anyone knows a good book that teaches techniques to prove that an algorithm is correct?

Hey xeon123.

What part of correctness are you talking about?

If the algorithm is recursive and you want to prove termination and convergence then this is different from dealing with something non-recursive.

If you want to prove convergence in a recursive or similar sense, depending on the algorithm you could show that the geometric distance between expected answer and observed answer gets smaller with every recursive call.

In terms of terminating conditions, this will probably depend on the data structure being used as well especially if you have a recursive algorithm.

If you are dealing with a statistical algorithm like RNG simulation for custom distributions, then this needs even more analysis.

What kind of algorithm do you have in mind?
 
I was talking about proving the termination and convergence of a recursive algorithm. Since I'm learning this topic from scratch, any recursive problem, like factorial, is a good problem to understand.
 
xeon123 said:
I was talking about proving the termination and convergence of a recursive algorithm. Since I'm learning this topic from scratch, any recursive problem, like factorial, is a good problem to understand.

Like any mathematics, you usually want to look at a particular class of algorithms rather than 'the general case'.

The thing is that some recursive algorithms will not terminate either for any inputs for the algorithm, or for some subset of inputs.

One thing I think you should first take a look at concerns the halting problem. This will give you a general idea of whether an algorithm can terminate or not, and you'll find that this is probabilistic measure. For more information on this look at work by Gregory Chaitin (he has done some fascinating work).

The other thing would be to study computational complexity and recursion theory and theories of computation and probably automata theory as well. This particular subject is very much at the heart of computer science in the theoretical perspective.

For the factorial, you could analyze this under the bounded idea mentioned above.

The thing is that you know it will terminate when x = 0 (0! = 1) at the top of the call stack and assuming that the inputs are always integers >= 0, then you can show that the program always terminates since the next call will reduce the argument from x to x-1 if you take the factorial to give back f * factorial(f-1) in this recursive way.

Now again when you have complicated data structures like say trees or graphs and want to do stuff on these, then it gets a little more complex.

So intuitively, it will help if you form a class of functions that you know terminate by enforcing that every call that is done increases the probability of termination and that for all conditional possibilities corresponding to recursive function calls, you get an exhaustion of probabilities to be 1 for a finite number of recursive calls that are bounded in depth (like the factorial in this case for n! will have n+1 recursive calls and therefore a depth of n+1).

The general theory will deal with probabilistic arguments and if you can show that there is a non-zero chance that the recursive algorithm won't terminate, then you're done. From that you could then narrow down 'which inputs' will cause this and you can even use some of the ideas from mathematical analysis like convergence and divergence in this context.

It's a little hard to give specific advice for your query because it is actually a very complex thing and this question is at the very heart of what computation actually is and what a valid computation is just like mathematicians want to figure out what kind of functions converge: it's the same kind of analogy and understanding it in any depth is really important for understanding computation, just like understanding convergence is essential in mathematics.
 
Thank you for your reply, it's very useful.
 

Similar threads

Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
86
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
7K
  • · Replies 10 ·
Replies
10
Views
4K