# How to prove the optimization version problem (whose decision version is NP-complete) can be solved in poly-time iff P=NP?

I have proved the decision version of my problem be $$\mathcal{NP}$$-complete. And I know that if I can solve the optimization version in poly-time, then I can just to compare the obtained minimum (or maximum) with target value in decision version. Thus, the decision version can be solved in poly-time as well. Since the decision version is $$\mathcal{NP}$$-hard, so is the optimization version, i.e., the optimization version is $$\mathcal{NP}$$-hard.

My question is how to prove the converse direction: if the decision version can be solved in poly-time, can the optimization version be solved in poly-time as well?

I in advance thank you for any suggestions!

• Consider the decision version of TSP: given a graph and a value k, decide whether the shortest TSP tour has length at most k. One could try a binary search on k. – Rafael Castro Jul 1 '19 at 1:22
• But what if the shortest length is not k, how many operations should we call to find the shortest length? Will it be poly-time operations? – Wei Jul 1 '19 at 1:30
• You could start k with a big upper bound: the sum of the weight of all edges, as example. I guess any binary search on that space search should be polynomial. But this is just a guess. – Rafael Castro Jul 1 '19 at 1:40
• I think it should be found in poly-time, since we have assumed P=NP, which implies a new upper bound can always be found in poly-time. But, I don't know how to convince myself for such conjecture. I want to show this guess theoretically. Anyway, thanks so much for replying. – Wei Jul 1 '19 at 1:44
• The two words “binary search” are surely convincing enough? Rafael: You get a much smaller bound by just taking a random tour. – gnasher729 Nov 28 '19 at 10:31

The most correct answer is "No". Consider an optimisation problem $$OP$$ for which the encoded length of the output is superpolynomial in the encoded length of the input. Clearly no algorithm can produce the output in time polynomial in the encoded length of the input, so $$OP \not\in \mathcal{P}$$. However, the decision version $$DP$$ takes as input both the input of $$OP$$ and the guessed answer, so it is allowed time polynomial in the sum of the two, and in particular does not need to execute in time polynomial in the length of the problem per se.
However, if you're guaranteed that the output of $$OP$$ has (asymtoptically) an encoded length which is polynomial in the encoded length of the input (say $$O(n^a)$$ for input length $$n$$ and unknown $$a$$), then you can do a binary search, starting at any reasonable guess, doubling unless you get high enough, and then searching back down. The number of calls of the decision problem is $$O(n^a)$$, each call of the decision problem takes time polynomial in $$n$$, and the product of two polynomials is a polynomial.