Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formally verifying the correctness of an algorithm

First of all, is this only possible on algorithms which have no side effects?

Secondly, where could I learn about this process, any good books, articles, etc?

like image 352
joemoe Avatar asked Jan 27 '10 19:01

joemoe


People also ask

How do you check the correctness of an algorithm?

The only way to prove the correctness of an algorithm over all possible inputs is by reasoning formally or mathematically about it. One form of reasoning is a "proof by induction", a technique that's also used by mathematicians to prove properties of numerical sequences.

What is algorithm verification?

A verification algorithm is a two-argument algorithm A, where one argument is an ordinary input string x, and the other argument is a binary string y called a certificate. Algorithm A verifies x if there exists a y such that A(x,y) = 1.

What is a proof of correctness?

A proof of correctness is a mathematical proof that a computer program or a part thereof will, when executed, yield correct results, i.e. results fulfilling specific requirements. Before proving a program correct, the theorem to be proved must, of course, be formulated.

What is the correctness and efficiency of an algorithm?

correctness and efficiency, where correctness means that a right result is obtained for all possible problem instances (size of the data structure, state of the input — sorted, unsorted, random, nearly-sorted etc), while efficiency means how the time and computer resources needed to successfully carry out the algorithm ...


2 Answers

COQ is a proof assistant that produces correct ocaml output. It's pretty complicated though. I never got around to looking at it, but my coworker started and then stopped using it after two months. It was mostly because he wanted to get things done quicker, but if you need to verify an algorithm this might be a good idea.

Here is a course that uses COQ and talks about proving algorithms.
And here is a tutorial about writing academic papers in COQ.

like image 145
nlucaroni Avatar answered Sep 28 '22 18:09

nlucaroni


  1. It's generally a lot easier to verify/prove correctness when no side effects are involved, but it's not an absolute requirement.
  2. You might want to look at some of the documentation for a formal specification language like Z. A formal specification isn't a proof itself, but is often the basis for one.
like image 39
Jerry Coffin Avatar answered Sep 28 '22 19:09

Jerry Coffin