6 ms·
There's already a known algorithm M you can implement right now that can find satisfying assignments to satisfiable SAT instances in polynomial time conditioned
by CaptainNegative 3y ago
There's already a known algorithm M you can implement right now that can find satisfying assignments to satisfiable SAT instances in polynomial time conditioned only on P=NP.
Note: I'll be glossing over a few technicalities in this explanation, feel free to ask about them.
Roughly, the algorithm M is as follows. Suppose you have input x of length n. For each integer c between 1 and n, encode c in binary and try to decode it in UTF-8. If it decodes, try to interpret it as a Python program, and run it on input x for 100n^c steps. If it executes successfully and outputs a valid assignment, return the assignment. Otherwise, continue onto the next c. If c=n and you haven't found an assignment yet, do a brute force search over assignments and return what you find.
Now suppose P=NP, so some Python program finds SAT solutions in polynomial time. In fact, there are infinitely many such programs, since each valid program can be prefixed with as many "pass" expressions as we want. Interpreting the UTF-8 encoding of any such program p in binary gives us some integer c.
There are only finitely many inputs of length ≤ c, so the slowest of them still runs in finite (and thus polynomial) time. For any input of length > c, the above algorithm M will spend at most 100(c-1)n^c time trying to execute the (c-1) different strings in Python for at most 100n^c steps each. If M happens on a solution before then, great! If it doesn't, then now we run p -- which by assumption does find solutions in polynomial time -- for 100n^c steps.
If 100n^c is an upper bound on the true running time of p, then this necessarily returns a valid assignment, meaning that we can find assignments in time O(c n^c) time for some integer c, i.e. polynomial time. Otherwise, if 100n^c is too small, we just wait for the next copy p' of p (with a pass prefixed to it) that will have an even looser time bound of 100n^c' . This also may not be enough, but eventually we will find some p''''' for which the time bound does suffice (depending on the true running time of p). And so we find valid solutions in O(c'''''n^c''''') time.
None of this required us to know what p is; effectively M makes the non-constructive constructive by trying every program out in a systematic way that the running time never exceeds some (also unknown) polynomial bound.
Is it practical? Suppose that the shortest Python program finding SAT assignments is at least 100 bytes long. Then c > 256^100, and thus the running time is something like O(n^(256^100)). So be sure to get a good CPU.
- skinner_ 3y agoVery nice explanation! I think it's worth mentioning that this is called universal search (you mention this in passing) or Levin Search or Levin's universal search algorithm. It was invented by Leonid Levin in 1972. https://steemit.com/steemstem/@markgritter/leonid-levin-s-universal-algorithm https://steemit.com/steemstem/@markgritter/leonid-levin-s-un...
- brabel 3y agoThis seems to be like you're trolling. You're basically doing a brute force search for polynomial time programs... so you do need to know the polynomial time program before you actually solve anything?! You're just bounding the search space by only allowing programs to run for a certain number of steps under the assumption that any problem you care to solve would be solvable within a finite amount of steps... and then claiming that both the search for the program and its execution turns out to run in polynomial time - which seems obviously wrong as you yourself point, the logarithmic you're talking about itself is growing exponentially on the size of the input?!?!
- sebzim4500 3y agoHe's not trolling, it's a well known result. >so you do need to know the polynomial time program before you actually solve anything?! No, you try all the programs one by one. Assuming P = NP one of them will work eventually. The number of programs you need to search before finding the correct one is a constant, even if we don't know what it is. Then by scaling the number of steps you do at each iteration you guarantee that the total runtime will be polynomial in the size of the input. It's exponential in the size of the P-time algorithm for SAT but that's a constant and therefore irrelevant to the complexity class.
- brabel 3y ago> No, you try all the programs one by one. Assuming P = NP one of them will work eventually. You're repeating what I said: you do need to find the program first, and you do that by brute force. What exactly is the disagreement here, do you not know that trying one-by-one is exactly what "brute force" means? Perhaps this theorem is mathematically sound and I am missing something, but as a programmer I can guarantee this solution is completely useless.