HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Can I use the following method to prove an algorithm is correct?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
canthemethodfollowingprovealgorithmcorrectuse

Problem

I'm trying to show that a solution I have obtained via an algorithm is correct. The way I plan on doing this is first by showing that an optimal solution does indeed exist. Then, I plan on showing that every other solution that is not the solution provided by my algorithm cannot be optimal. Finally, I show that the solution I have cannot be improved in the same way as any other solution.

Is this enough to show that my algorithm is optimal? In this case I am avoiding doing an "exchange argument" a la greedy algorithms. In fact, I don't really prove anything about how my solution is an improvement of the other ones, but simply that all of the other ones can be improved, and given that an optimal solution exists, the one I have must be it because it cannot be improved in the same way that the other ones can.

Solution

I am rather surprised that you raised this question since the meticulous and enlightening answers you have written to some math questions demonstrate sufficiently that you are capable of rigorous logical deduction. It seems that you became somewhat uncomfortable when you stumbled upon a new and unorthodox way to prove an algorithm is correct.

Believe in yourself. Believe in logic.

Yes, I believe you have shown your algorithm is correct. To be absolutely clear, suppose you have shown all of the following.

  • An optimal solution exists.



  • Your algorithm provides a solution and only one solution.



  • Every solution that is not the solution provided by your algorithm cannot be optimal.



Then your algorithm must provide an optimal solution. The implication is just simple logic.

You do not even need to show that solution provided cannot be improved in the same way as any other solution.

Context

StackExchange Computer Science Q#119997, answer score: 16

Revisions (0)

No revisions yet.