← Back to context

Comment by AnotherGoodName

21 hours ago

The site is taking forever to load but complexity theory doesn't really have the hard walls at things like O(nlogn) that people seem to think.

You can always always tradeoff time vs space. It's actually a fundamental part of complexity theory called Blums speedup theorem by the guy who invented complexity theory no less.

As an example you give me an nlogn solution and i take a portion of the inner loop, put it in a lookup table (who cares if the lookup table is 2^n in size, that's not what we're measuring here since we're specifically measuring time not space) and suddenly i have something better than nlogn since that lookup table is O(1).

That's not to say there's some merit to all of this. It's just that people shouldn't be as astonished by these results as they are. It's complexity theory. There's literally no such thing as a hard wall where something is nlogn in time and can't get lower. It can always get lower. But you need both the time and space complexities together to reason about this.

It’s been a while since I studied complexity theory, but is that what Blums speed up theorem says? A quick google search suggests it states that there exist computable functions where there is no optimal program that computes it.

Like, there exist problems that have a lower bound of n time where algorithms can get arbitrarily close to O(n) complexity but there is no program that actually reaches it (there is one that runs in time O(n^{1.1}), one that runs in O(n^{1.01}), etc).

But that doesn’t mean that there aren’t hard walls, it just means there are hard walls where every program’s runtime is > that wall, rather than >= that wall. But maybe I’m misunderstanding, or there are some corollaries I’m missing?

As an aside, as someone who studied more on the pure math side, Blums speed up theorem is rather intuitive. It looks like there might be a relatively elegant proof using topology. Blums speed up theorem is basically just a statement that the set of programs that implement a particular computable function doesn’t satisfy the greatest lower bound property. This is also the case for, for example, the set of rational numbers: there exist subsets of the rational numbers with a lower bound but not a greatest lower bound (like the set of all positive rational numbers q where q^2 >= 2). I’m hand waving, but I think in that same vein you can show that the set of programs under the topology of ordering by runtime is completely disconnected.

> You can always always tradeoff time vs space

Not always, isn't it? The theorem says that there exists a function that can be sped up, but not that every function can be. A trivial counter example would be the identity function on a TM. It's simply a HALT/ACCEPT. There's no way to reduce that.

The space/time trade-off is also not infinitely flexible, since it takes time to fill space. And lookup tables have to be constructed at run-time, or they'll be of finite size, and hence only a constant speed-up. Perhaps you were thinking of that theorem, the linear as wikipedia calls it? https://en.wikipedia.org/wiki/Linear_speedup_theorem

> There's literally no such thing as a hard wall where something is nlogn in time and can't get lower.

Isn't this an ironic example to use, since one of the only lower bounds we have actually found is nlogn for comparison-based sorting?

And anyways, this point seems too strong: the fact that TCS people believe NP != P is another example that we believe a lower bound exists, no? (And relatedly, the large portion of TCS that is dedicated to trying to figure out how to lower-bound anything, while admittedly not so successful yet, shows that researchers believe lower bounds exist. I mean, any complexity class non-equality hypothesis is an example of this, no?)

No, lookup tables aren’t magic. The lookup table is part of the program and the execution time includes reading the program itself. A table of size 2^n takes O(2^n) to read into memory.

  • You can read the table on demand. If you are only processing n elements with an algorithm that is very roughly nlogn, you would not be reading all 2^n entries of the lookup table.

You can’t put everything in a lookup table with the lookup cost being O(1).

If the things you have to memoize are super-linear, suppose you need to store some value related to all subsets of an input set of size n.

There’s no way you can do this in O(1), even assuming infinitely large memory.

Wouldn't it take an infinite lookup table to do this satisfying any two integers and still get an order-complexity speedup? The integers can be any size. You can't specify an arbitrarily variable sized lookup table in the normal formulation of these problems without computing the lookup table as part of the computation.

  • You seem to under the impression that we don’t currently use lookup tables for multiplication.

    But your right in that we don’t have a huge LUT as it’s not worth it.

    Small one in the ALU though, for partial products to add can be worth the additional wire length.

    • I don't believe that changes asymptotic worst case order complexity for multiplication of arbitrary sized integers on its own, naively applied. That's not the same as saying it doesn't provide any speedup to them.

  • Never infinite if you have bounds on integer size. For n bits of input it's always possible to have a 2^n space complexity lookup table that's O(1) speed since 2^n covers all possibilities of n bits.

    You don't need to go to these extremes regardless though. For small speedups take an nlogn algorithm and just move a very small part of the inner portion out in a similar tradeoff. Eg. "Every nth input is now part of a lookup." If you look at the openAIs <nlogn results there was a series of small improvements of this type (we take this part out, precomputing it, and likewise with this part and that small portion, aha! <nlogn!). I finally loaded the link above and it's 262million lines of such tricks in fact.

    • I think the thing non-mathematicians and non-CS people who only know complexity theory vaguely need to remember is that complexity theory has nothing to do with reality.

      A 2^64bits lookup table only has O(1) lookup if you ignore the impossibility of creating a machine that has 2 exabytes of storage where all those bytes have the same access time. Or you'd have to redefine O(1) to be “at most the worst case”. But strictly speaking from the mathematical definition it’s O(1). Which is why no one in practical engineering takes most complexity results seriously as the entire field maps to practice poorly precisely for these reasons (all our machines use fixed integer math and have limited tape storage)

    • The whole point of this problem is that there are no bounds on integer size.

      The whole point of complexity theory is that there are no bounds on input size.

      6 replies →

That particular lookup table would be O(n), and it wouldn't support unbounded inputs.

Than you modelled it incorrectly or n is small. A large lookup table is not O(1) in the real world as anyone who compares the access time of a register file, an L1 cache, and HBM3 (or DDR5) memory would realise. Even in a world of spherical cows in a vacuum lookup latency increases at least linearly with the radius of spherical volume the signal has to pass through.

  • However non-uniform your data access latencies are, algorithmic analysis treats all of them as O(1) as an axiom.

    If you don't like that convention, you are free to use your own, but it is going to confuse people who use the standard convention. And the convention makes a lot of sense when you stop and think about the problem that people are trying to solve.

> There's literally no such thing as a hard wall where something is nlogn in time and can't get lower

I guess you're saying that this holds in "realistic" computational models? Sorting in the decision tree model is famously \Omega(n log n)-time.