Your nit is incorrect and the proof (at least the one that is there now) is completely correct. If a lossless compression algorithm compresses any string, then there must be some other string that is made longer by that algorithm. If a lossless transform does not make any strings longer, then it also cannot make any shorter and so isn't a compression algorithm.
A more formal version of the proof is as follows. Suppose that a lossless compression algorithm manages to compress some string of length longer than n to length n or less. There are exactly 2**n + 2**(n-1) + ... + 2**0 = 2**(n+1) - 1 strings of length n or less. If the algorithm does not make any string of length n or less longer than n, then at least 2**(n+1) strings must map into this set, and by the pidgeonhole principle at least 2 strings are sent to the same result. However if we get that resulting then we can't figure out the original string (because we could have started with 2 different strings) contradicting our assumption that the algorithm was lossless.
Therefore a lossless compression algorithm that manages to compress any string must make some other string longer.
(Of course in practice one hopes that the strings which are made longer are likely to be rare and not made much longer, while the strings that are made shorter are likely to be common and made much shorter...) | [reply] [Watch: Dir/Any] |
First, the proof (or my parsing of the proof :) changed since I first responded. If it did not change, then I offer my apologies to abell and blame it on my not consuming enough caffine.
As I read it now, the proof appears to be correct, even if you use an identity function (or something that looks like an identity function for a given x) for f(x) (example, replace all /a+/ with "a" . length($1) . "a" - a win for all /a+/ longer than 3, identity for /^[^a]*$/).
Like I said, a minor nit, which was plugged by abell or originally misread by /me.
| [reply] [Watch: Dir/Any] [d/l] [select] |