1

We say an algorithm runs in polynomial time if it is of the form $O(n^k)$ where $n$ is the size of the input, right?

So how do we judge how many inputs there are in: $(x_1 \vee x_2 \vee \overline{x_3}) \wedge (\overline{x_1} \vee \overline{x_2} \vee x_4) \wedge (x_2\vee x_3\vee x_5)$

...actually, in looking for an actual definition of an algorithm running in polynomial time, wolframAlpha says: "An algorithm is said to be solvable in polynomial time if the number of steps required to complete the algorithm for a given input is $O(n^k)$ for some non-negative integer $k$, where $n$ is the complexity of the input. "

So, then my question is, for my example, what is the complexity of the input? Is the complexity based on how many variables, or how many clauses?

Tom van der Zanden
  • 13,238
  • 1
  • 35
  • 54
Bill
  • 11
  • 1
  • 3
    I'm not sure what you're asking. The SAT problem has inputs (formulae we want to test for satisfiability) and the Boolean formula has variables. I've never heard the word "input" used to mean some parameter of the formula used as an input to the SAT problem: in what context did you come across this? – David Richerby Oct 03 '15 at 06:45
  • There is one input. – Yuval Filmus Oct 03 '15 at 08:07
  • 2
    "where n is the complexity of the input" -- that's a horrible way of putting things. $n$ is just the length of a (reasonable) encoding of the input, i.e. the string you put on the TM tape. Yes, the specific encoding can matter so you have to fix it. – Raphael Oct 04 '15 at 10:25

1 Answers1

-2

The complexity of SAT relates to the number of arguments to the Boolean function (i.e. the "distinct literals" in the expression), not the number of terms in a particular normal form.

The complexity of an algorithm which solves SAT is related to the size of the input that you give it. So if the input is the Unicode string (x1∨x2∨¬x3)∧(x1¬∨x2¬∨x4)∧(x2∨x3∨x5), then the size of that is the number of Unicode codepoints (or bytes or bits used to encode those codepoints).

The subject of SAT is the function, not the representation of the function. The complexity class (i.e. the complexity of any solver which is optimal for its computer) is the same whether functions are written as product-of-sums or a sum-of-products. This complexity varies with the number of arguments to the function.

The input to a SAT solver is the representation of the function. Your example is in the product-of-sums normal form, which is a common way to express SAT problems. This is not a coincidence — SAT is solved mindlessly if you instead give it a sum-of-products expression! The brute-force method of solving SAT is to enumerate the sum-of-products, where each term either contradicts itself (b ¬b) or represents a satisfied piece of the function's domain. This simple approach doesn't trivialize SAT because going from one normal form to the other causes a combinatorial explosion. The size of the domain of a function of $n$ Boolean arguments is $2^n$.

Thus, feeding a gigantic problem description into a simple algorithm may have the same computational (and space) complexity as feeding a simple but equivalent description into a sophisticated algorithm. For brevity, we tend to prefer to imagine the description to be simple and the algorithm to be complicated.

  • Unfortunately, this is wrong in a number of ways. You're confusing variables and literals (a literal is a variable or its negation; the "arguments to the Boolean function" are the variables). The input to SAT is, and can only be, a representation of the function: computational problems take strings as their input and an abstract function isn't a string. And, as you say in your third paragraph, which representation you use can make a huge difference, and that wouldn't make sense if SAT didn't deal with representations. – David Richerby Oct 03 '15 at 10:23
  • 1
    Your last paragraph is very unclear. Computational complexity is measured as a function of the input length so I don't understand what you mean by saying that one problem with a small input might have the same complexity as another problem with a large input. It doesn't make sense to talk about the complexity of a problem for a particular input length: complexity is how the resource requirements change as the input length changes. – David Richerby Oct 03 '15 at 10:24
  • @DavidRicherby 1. The question mentions distinct literals and my answer clarifies that terminology by relating them to the function. 2. If we are free to specify that the input is a $2^n$ bit representation of the function over its domain, then SAT is O(N) in the length of that bit-string. It makes sense to talk about the complexity all solutions to a category of problems, not one particular implementation, in the size of the problem, e.g. the number of variables. Because the worst-case complexity is invariant with the choice of string format, we say that SAT as a problem is NP-complete. – Potatoswatter Oct 03 '15 at 13:50
  • In other words: SAT is a class of algorithms, each mapping a string representing a function to a Boolean answer. SAT as a category says nothing about the format or length of the input strings (or whether they're strings at all). It says something about their content, namely how many variables are represented. Because it cares about content and not formatting, SAT has consistent properties such as a complexity class. – Potatoswatter Oct 03 '15 at 14:06
  • 2
    "SAT is a class of algorithms" No, SAT is a computational problem. – David Richerby Oct 03 '15 at 14:12
  • @DavidRicherby You have confused properties of one algorithm with properties of the problem. Algorithms (for certain sorts of computers) have input strings. Computational problems are more vague and work with pure mathematical objects. If you want to be pedantic, SAT defines a class of algorithms. – Potatoswatter Oct 03 '15 at 15:11
  • 1
    No, you're confusing algorithms with problems. Go check the definitions. – David Richerby Oct 03 '15 at 16:50
  • 1
    Potatoswatter, http://cs.stackexchange.com/q/13669/755 seems like it might be helpful here. – D.W. Oct 04 '15 at 03:23
  • @D.W. Not really; I don't see where I've strayed. David's assertion is that the complexity of a problem varies over the length of its encoded input, $w$ in the terminology after that link. My assertion is that the complexity of a problem is intrinsic to $X$ and varies with properties of $y$. The problem exists before you even invent an encoding. – Potatoswatter Oct 04 '15 at 06:44
  • @D.W. I've added a little more on the difference between problems and solvers. Better? Still wrong? – Potatoswatter Oct 04 '15 at 07:01
  • "The complexity of SAT is related to the number of arguments to the Boolean function" - that makes no sense. It sounds like you're trying to say that the complexity of SAT is related to some property of the SAT instance (the input; i.e., the Boolean formula we're testing satisfiability of). But that's a category error. The complexity of SAT is whatever it is. The complexity of a problem can't depend on some property of the input to the problem, because each problem has a single complexity, not one complexity per input. – D.W. Oct 04 '15 at 07:08
  • "The input to SAT is the function, not the representation of the function." - That's not right, either. SAT is a problem. Problems don't have inputs; algorithms have inputs. If you meant "The input to an algorithm for SAT is the function, not the representation of the function.", that's just wrong: the input to a SAT algorithm is a bit-string that represents a particular Boolean formula. Perhaps this is the heart of the issue.... (Plus, several of David Richerby's prior comments still seem relevant.) – D.W. Oct 04 '15 at 07:09
  • @D.W. It sounds like this could be fixed pretty easily by substituting some terminology. Right now I'm trying to review CS and I'd be interested in getting this terminology corrected, but this seems to be going in circles. Would you mind doing a chat? – Potatoswatter Oct 04 '15 at 07:15
  • I realize that "SAT" is the abstract notion of asking whether a function is satisfiable. What is a good name for that function? I think the word "input" is an unnecessary hangup here, but it is the key to the original question. – Potatoswatter Oct 04 '15 at 07:22
  • 2
    You are confusing "complexity" as measure of intuitive hardness of something with "(computational) complexity" as a well-defined, mathematical measure of computational (!) problems. – Raphael Oct 04 '15 at 10:28
  • 2
    Please consolidate this discussion in the form of improving edits, or continue it in chat. I'll expect some "obsolete" flags! Thank you. (cc @DavidRicherby) – Raphael Oct 04 '15 at 10:29
  • @Raphael You're just making it worse. No part of this answer is intended as "intuitive" and the whole point is to address the difference between the complexity class of problems and complexity of algorithms. There's a chat link above; follow it! — but ATM I'm off to dinner. – Potatoswatter Oct 04 '15 at 10:52
  • 3
    A problem is defined with respect to a particular representation of the input. The exact representation is often left out because “reasonable” representations are equivalent with respect to the complexity classes we usually study, but it does matter. For example, SAT is defined over arbitrary formulas, not only formulas in some normal form, and this matters. It isn't about the size of the input: the explosion in size if we pick a normal form is just a hint that the problem may not be in P. – Gilles 'SO- stop being evil' Oct 04 '15 at 13:03
  • Consider the problem of integer factoring: if the input representation is the prime factor decomposition — no size explosion here — then it's trivial; but if the input representation is the decimal expansion (or the binary expansion, that doesn't matter), it's not known to be polynomial. (And with a unary input, it's polynomial but you do get input size explosion.) For SAT, you could define the input space as a pair of a formula plus a boolean indicating whether a formula is satisfiable; then the problem would be trivially solvable in linear time, but uninteresting. – Gilles 'SO- stop being evil' Oct 04 '15 at 13:03
  • @Gilles I see, now, thanks. Still, it sounds like the "reasonable" representations of mathematical objects are the ones that can be recognized efficiently by the machine in question, and manipulated efficiently with respect to the operations defined on that object. Prime decomposition is sufficient to identify an integer, but "is not a" natural number because you can't perform O(N) addition and get a result in the same format. Providing a formula plus a Boolean flag only helps if you don't validate the input, which is itself cheating. Any machine is supposed to recognize its input grammar. – Potatoswatter Oct 05 '15 at 13:40
  • If each sort of mathematical entity has a well-defined class of reasonable representations for each abstract machine, then it still seems safe to say that the underlying problem such as SAT is defined for a mathematical entity, and a problem × a machine constrains the input formats — removing the choice of format from the analysis. – Potatoswatter Oct 05 '15 at 13:52