title: Methods for efficiently verifying program logic when correct output is unknown
body: <p>While doing the "<a href="https://code.google.com/codejam/contest/6224486/dashboard#s=p2" rel="nofollow">Djikstra</a>" problem in the qualification round of Google's Code Jam this year, I had the problem of trying to verify my program. The standard method I use to do this kind of task is to write TWO programs which do the same thing in completely different ways. You then run both on the input. If the output differs between the two programs, you know have a bug in one or both of the programs. The disadvantage of this method is that the programmer has to create two programs, effectively doubling the time spent.</p>
  
  <p>Are there better/more efficient methods for verifying that a program is correct, compared to writing multiple versions of the program and running them against each other?</p>
  
  <p>Note that you only have this problem when the <strong>correct output is unknown</strong> and you have no way of generating validating input-output sets. If you know <em>a priori</em> what the output should be for any given set of input, then it is easy to verify a program. So, the question only applies to situations where you do not know what the correct output should be, you only know the specification for the process which the program is supposed to do.</p>
  
  <p>In the case of the Dijkstra problem, I could have written a "test data generator" which went <em>backwards</em> from output to generate a known input state. By doing this, I could have created test data sets by a writing a second program, but one that would have been much simpler than the solver, therefore much less work than writing two solvers, however, for the sake of argument, let's suppose this option wasn't available.</p>